orkestrator 2.35.3-beta → 2.35.5-beta

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.
@@ -24021,6 +24021,7 @@ var AGENT_INTERACTION_LIMITS = Object.freeze({
24021
24021
  maxSerializedPayloadBytes: 256 * 1024,
24022
24022
  maxIdLength: 512,
24023
24023
  maxProviderValueLength: 4096,
24024
+ maxSourceNameLength: 256,
24024
24025
  maxJournalEntries: 512,
24025
24026
  maxWorkflowSummaries: 64
24026
24027
  });
@@ -24088,6 +24089,19 @@ var LIMITED_HOLD_REASONS = new Set([
24088
24089
  "provider-limit",
24089
24090
  "upstream-may-expire"
24090
24091
  ]);
24092
+ var AGENT_INTERACTION_SOURCE_KINDS = ["mcp-server"];
24093
+ var SOURCE_SCOPE_LABELS = Object.freeze({
24094
+ user: "user settings",
24095
+ project: "project settings",
24096
+ local: "local settings",
24097
+ dynamic: "session settings",
24098
+ plugin: "a plugin",
24099
+ managed: "managed settings",
24100
+ enterprise: "enterprise settings",
24101
+ claudeai: "a claude.ai connector",
24102
+ agent: "an agent definition",
24103
+ sdk: "the agent host"
24104
+ });
24091
24105
  var UNATTENDED_POLICY_INSTRUCTION = "This is a non-interactive build session: no user can answer a provider input request. " + "If input is unavailable or declined, choose the safest likely assumption yourself, " + "state that assumption, and continue. Never treat the absence of a person as authorization.";
24092
24106
  var INTERACTIVE_AGENT_INTERACTION_POLICY = Object.freeze({
24093
24107
  version: AGENT_INTERACTION_POLICY_VERSION,
@@ -24163,8 +24177,11 @@ var REQUEST_KEYS = new Set([
24163
24177
  "createdAt",
24164
24178
  "updatedAt",
24165
24179
  "expiresAt",
24166
- "hold"
24180
+ "hold",
24181
+ "source"
24167
24182
  ]);
24183
+ var SOURCE_KEYS = new Set(["kind", "name", "scope"]);
24184
+ var SOURCE_KINDS = new Set(AGENT_INTERACTION_SOURCE_KINDS);
24168
24185
  var HOLD_KEYS = new Set(["available", "heldAt", "reason"]);
24169
24186
  var HOLD_REASONS = new Set(AGENT_INTERACTION_HOLD_REASONS);
24170
24187
  var PRESENTATION_KEYS = new Set([
@@ -24838,8 +24855,12 @@ function jsonArrayBytes(count, total) {
24838
24855
  }
24839
24856
  function planOldestFirstTrim(messages, maximumBytes, options = {}) {
24840
24857
  const measure = options.measure ?? encodedJsonBytes;
24841
- const sizes = messages.map((message) => measure(message));
24842
- let measuredValues = sizes.length;
24858
+ const known = options.messageSizes;
24859
+ if (known && known.length !== messages.length) {
24860
+ throw new Error("planOldestFirstTrim: messageSizes must describe every message");
24861
+ }
24862
+ const sizes = known ? known.slice() : messages.map((message) => measure(message));
24863
+ let measuredValues = known ? 0 : sizes.length;
24843
24864
  let total = sizes.reduce((sum, size) => sum + size, 0);
24844
24865
  let count = messages.length;
24845
24866
  let bytes = jsonArrayBytes(count, total);
@@ -24888,7 +24909,7 @@ function planOldestFirstTrim(messages, maximumBytes, options = {}) {
24888
24909
  function jsonStringContentBytes(value) {
24889
24910
  return value ? Buffer2.byteLength(JSON.stringify(value)) - 2 : 0;
24890
24911
  }
24891
- function boundTranscriptInPlace(state, limits) {
24912
+ function boundTranscriptInPlace(state, limits, rowSizes) {
24892
24913
  let changed = false;
24893
24914
  if (state.messages.length > limits.maxMessages) {
24894
24915
  const removed = state.messages.length - limits.maxMessages;
@@ -24903,12 +24924,15 @@ function boundTranscriptInPlace(state, limits) {
24903
24924
  continue;
24904
24925
  const removed = message.parts.length - limits.maxPartsPerMessage;
24905
24926
  message.parts.splice(0, removed);
24927
+ rowSizes?.invalidateRow(message);
24906
24928
  state.droppedParts += removed;
24907
24929
  state.transcriptTruncated = true;
24908
24930
  changed = true;
24909
24931
  }
24910
24932
  state.uncheckedTranscriptBytes = 0;
24911
- const plan = planOldestFirstTrim(state.messages, limits.maxTranscriptBytes);
24933
+ const plan = planOldestFirstTrim(state.messages, limits.maxTranscriptBytes, {
24934
+ messageSizes: rowSizes?.measureRows(state.messages)
24935
+ });
24912
24936
  if (plan.droppedMessages > 0) {
24913
24937
  const dropped = state.messages.splice(0, plan.droppedMessages);
24914
24938
  state.droppedMessages += dropped.length;
@@ -24918,78 +24942,342 @@ function boundTranscriptInPlace(state, limits) {
24918
24942
  }
24919
24943
  if (plan.droppedParts > 0) {
24920
24944
  state.messages[0].parts.splice(0, plan.droppedParts);
24945
+ rowSizes?.invalidateRow(state.messages[0]);
24921
24946
  state.droppedParts += plan.droppedParts;
24922
24947
  state.transcriptTruncated = true;
24923
24948
  changed = true;
24924
24949
  }
24925
24950
  return changed;
24926
24951
  }
24952
+ var VERIFY_REMEMBERED_SIZES = false;
24953
+
24954
+ class StaleTranscriptSizeError extends Error {
24955
+ constructor(kind, remembered, measured) {
24956
+ super(`Remembered transcript ${kind} size is stale (${remembered} bytes remembered, ` + `${measured} measured): a write path changed it without noting the change`);
24957
+ this.name = "StaleTranscriptSizeError";
24958
+ }
24959
+ }
24960
+
24961
+ class TranscriptRowSizes {
24962
+ #rows = new Map;
24963
+ #verify;
24964
+ constructor(options = {}) {
24965
+ this.#verify = options.verify ?? VERIFY_REMEMBERED_SIZES;
24966
+ }
24967
+ invalidate(id) {
24968
+ this.#rows.delete(id);
24969
+ }
24970
+ invalidateRow(row) {
24971
+ const id = rowId(row);
24972
+ if (id !== undefined)
24973
+ this.#rows.delete(id);
24974
+ }
24975
+ clear() {
24976
+ this.#rows.clear();
24977
+ }
24978
+ get size() {
24979
+ return this.#rows.size;
24980
+ }
24981
+ measureRows(messages, measure = encodedJsonBytes) {
24982
+ const previous = this.#rows;
24983
+ const next = new Map;
24984
+ const newest = messages.length - 1;
24985
+ const sizes = messages.map((row, index) => {
24986
+ const id = rowId(row);
24987
+ const known = id === undefined ? undefined : previous.get(id);
24988
+ const follower = messages[index + 1];
24989
+ let bytes;
24990
+ if (index < newest && known?.row === row && known.follower === follower) {
24991
+ bytes = known.bytes;
24992
+ if (this.#verify) {
24993
+ const measured = measure(row);
24994
+ if (measured !== bytes)
24995
+ throw new StaleTranscriptSizeError("row", bytes, measured);
24996
+ }
24997
+ } else {
24998
+ bytes = measure(row);
24999
+ }
25000
+ if (follower && id !== undefined)
25001
+ next.set(id, { row, follower, bytes });
25002
+ return bytes;
25003
+ });
25004
+ this.#rows = next;
25005
+ return sizes;
25006
+ }
25007
+ }
25008
+ function rowId(row) {
25009
+ const id = row.id;
25010
+ return typeof id === "string" ? id : undefined;
25011
+ }
25012
+
25013
+ class EncodedObjectSizes {
25014
+ #fields = new WeakMap;
25015
+ #verify;
25016
+ constructor(options = {}) {
25017
+ this.#verify = options.verify ?? VERIFY_REMEMBERED_SIZES;
25018
+ }
25019
+ measure(object) {
25020
+ let fields = this.#fields.get(object);
25021
+ if (!fields) {
25022
+ fields = new Map;
25023
+ this.#fields.set(object, fields);
25024
+ }
25025
+ let bytes = 2;
25026
+ let members = 0;
25027
+ for (const key of Object.keys(object)) {
25028
+ const value = object[key];
25029
+ if (value === undefined || typeof value === "function" || typeof value === "symbol") {
25030
+ fields.delete(key);
25031
+ continue;
25032
+ }
25033
+ let valueBytes;
25034
+ if (typeof value === "string") {
25035
+ valueBytes = encodedStringBytes(value, fields.get(key));
25036
+ fields.set(key, { value, bytes: valueBytes });
25037
+ } else {
25038
+ fields.delete(key);
25039
+ valueBytes = encodedJsonBytes(value);
25040
+ }
25041
+ bytes += encodedJsonBytes(key) + 1 + valueBytes;
25042
+ members += 1;
25043
+ }
25044
+ if (fields.size > members) {
25045
+ for (const key of Array.from(fields.keys())) {
25046
+ if (!Object.hasOwn(object, key))
25047
+ fields.delete(key);
25048
+ }
25049
+ }
25050
+ bytes += Math.max(0, members - 1);
25051
+ if (this.#verify) {
25052
+ const measured = encodedJsonBytes(object);
25053
+ if (measured !== bytes)
25054
+ throw new StaleTranscriptSizeError("part", bytes, measured);
25055
+ }
25056
+ return bytes;
25057
+ }
25058
+ }
25059
+ function encodedStringBytes(value, previous) {
25060
+ if (previous) {
25061
+ if (previous.value === value)
25062
+ return previous.bytes;
25063
+ const before = previous.value;
25064
+ if (value.length > before.length && value.startsWith(before)) {
25065
+ const suffix = value.slice(before.length);
25066
+ const high = before.charCodeAt(before.length - 1);
25067
+ const low = suffix.charCodeAt(0);
25068
+ const splitPair = high >= 55296 && high <= 56319 && low >= 56320 && low <= 57343;
25069
+ return previous.bytes + jsonStringContentBytes(suffix) - (splitPair ? 8 : 0);
25070
+ }
25071
+ }
25072
+ return Buffer2.byteLength(JSON.stringify(value));
25073
+ }
25074
+
25075
+ // ../protocol/src/node/bridge-transcript-bounds.ts
25076
+ function createBridgeTranscriptBounds(options) {
25077
+ const limits = {
25078
+ maxMessages: options.maxMessages,
25079
+ maxPartsPerMessage: options.maxPartsPerMessage,
25080
+ maxTranscriptBytes: options.maxTranscriptBytes
25081
+ };
25082
+ const revisedRows = new WeakMap;
25083
+ const rowSizes = new WeakMap;
25084
+ const sizesFor = (state) => {
25085
+ let sizes = rowSizes.get(state);
25086
+ if (!sizes) {
25087
+ sizes = new TranscriptRowSizes;
25088
+ rowSizes.set(state, sizes);
25089
+ }
25090
+ return sizes;
25091
+ };
25092
+ const noteRowRevised = (state, id) => {
25093
+ rowSizes.get(state)?.invalidate(id);
25094
+ if (state.messages.at(-1)?.id === id)
25095
+ return;
25096
+ let rows = revisedRows.get(state);
25097
+ if (!rows) {
25098
+ rows = new RecentlyRevisedRows;
25099
+ revisedRows.set(state, rows);
25100
+ }
25101
+ rows.note(id);
25102
+ };
25103
+ const boundTranscript = (state) => {
25104
+ const rowsBefore = state.messages.slice();
25105
+ const partsBefore = rowsBefore.map((row) => row.parts.length);
25106
+ const trimmed = boundTranscriptInPlace(state, limits, sizesFor(state));
25107
+ if (!trimmed)
25108
+ return false;
25109
+ const offset = rowsBefore.length - state.messages.length;
25110
+ state.messages.forEach((row, index) => {
25111
+ if (row.parts.length < partsBefore[index + offset])
25112
+ noteRowRevised(state, row.id);
25113
+ });
25114
+ return true;
25115
+ };
25116
+ return {
25117
+ streamIntervalBytes: options.streamIntervalBytes,
25118
+ boundTranscript,
25119
+ boundTranscriptForRead(state) {
25120
+ if (state.uncheckedTranscriptBytes === 0)
25121
+ return;
25122
+ if (boundTranscript(state))
25123
+ state.revision += 1;
25124
+ },
25125
+ streamingBoundDue(state) {
25126
+ return state.messages.length > limits.maxMessages || (state.messages.at(-1)?.parts.length ?? 0) > limits.maxPartsPerMessage || state.uncheckedTranscriptBytes >= options.streamIntervalBytes;
25127
+ },
25128
+ chargeTranscript(state, bytes) {
25129
+ if (bytes > 0)
25130
+ state.uncheckedTranscriptBytes += bytes;
25131
+ },
25132
+ noteRowRevised,
25133
+ rowChanged(state, row) {
25134
+ noteRowRevised(state, row.id);
25135
+ state.revision += 1;
25136
+ },
25137
+ forgetRowSize(state, row) {
25138
+ rowSizes.get(state)?.invalidate(row.id);
25139
+ },
25140
+ revisedRowsOverflowVersion(state) {
25141
+ return revisedRows.get(state)?.overflowVersion ?? 0;
25142
+ },
25143
+ revisedRowIds(state) {
25144
+ const ids = revisedRows.get(state)?.ids();
25145
+ return ids && ids.length > 0 ? ids : undefined;
25146
+ },
25147
+ forgetRevisedRows(state) {
25148
+ revisedRows.get(state)?.clear();
25149
+ rowSizes.get(state)?.clear();
25150
+ }
25151
+ };
25152
+ }
25153
+
25154
+ // ../protocol/src/node/bridge-transcript-text.ts
25155
+ import { Buffer as Buffer3 } from "node:buffer";
25156
+ function sliceUtf8(value, maximumBytes) {
25157
+ if (maximumBytes <= 0)
25158
+ return "";
25159
+ const buffer = Buffer3.from(value);
25160
+ if (buffer.length <= maximumBytes)
25161
+ return value;
25162
+ let end = maximumBytes;
25163
+ while (end > 0 && (buffer[end] & 192) === 128)
25164
+ end -= 1;
25165
+ return buffer.subarray(0, end).toString("utf8");
25166
+ }
25167
+ function boundUtf8Text(value, maximumBytes, notice) {
25168
+ if (Buffer3.byteLength(value) <= maximumBytes)
25169
+ return value;
25170
+ const available = Math.max(0, maximumBytes - Buffer3.byteLength(notice));
25171
+ return sliceUtf8(value, available) + notice;
25172
+ }
25173
+
25174
+ class BoundedTextAppender {
25175
+ notice;
25176
+ policy;
25177
+ saturated;
25178
+ #noticeBytes;
25179
+ #lengths = new WeakMap;
25180
+ constructor(options) {
25181
+ this.notice = options.notice;
25182
+ this.policy = options.policy;
25183
+ this.saturated = options.saturated ?? new WeakSet;
25184
+ this.#noticeBytes = Buffer3.byteLength(options.notice);
25185
+ }
25186
+ append(current, addition, maximumBytes, owner, saturate = true) {
25187
+ if (owner && saturate && this.saturated.has(owner))
25188
+ return { value: current, truncated: true };
25189
+ if (!addition)
25190
+ return { value: current, truncated: false };
25191
+ const currentBytes = this.byteLength(current, owner);
25192
+ const additionBytes = Buffer3.byteLength(addition);
25193
+ if (currentBytes + additionBytes <= maximumBytes) {
25194
+ const value = current + addition;
25195
+ if (owner) {
25196
+ this.#lengths.set(owner, {
25197
+ value,
25198
+ bytes: concatenatedBytes(current, currentBytes, addition, additionBytes)
25199
+ });
25200
+ }
25201
+ return { value, truncated: false };
25202
+ }
25203
+ if (owner) {
25204
+ this.#lengths.delete(owner);
25205
+ if (saturate)
25206
+ this.saturated.add(owner);
25207
+ }
25208
+ if (this.policy === "append-notice") {
25209
+ const available = maximumBytes - currentBytes - this.#noticeBytes;
25210
+ if (available <= 0) {
25211
+ const value = current.endsWith(this.notice) ? current : current + this.notice;
25212
+ return { value, truncated: true };
25213
+ }
25214
+ return { value: current + sliceUtf8(addition, available) + this.notice, truncated: true };
25215
+ }
25216
+ const contentLimit = Math.max(0, maximumBytes - this.#noticeBytes);
25217
+ const prefix = currentBytes <= contentLimit ? current : sliceUtf8(current, contentLimit);
25218
+ const prefixBytes = prefix === current ? currentBytes : Buffer3.byteLength(prefix);
25219
+ const usable = Math.max(0, contentLimit - prefixBytes);
25220
+ return {
25221
+ value: prefix + sliceUtf8(addition, usable) + sliceUtf8(this.notice, maximumBytes),
25222
+ truncated: true
25223
+ };
25224
+ }
25225
+ byteLength(value, owner) {
25226
+ const known = owner ? this.#lengths.get(owner) : undefined;
25227
+ if (known && known.value === value)
25228
+ return known.bytes;
25229
+ return Buffer3.byteLength(value);
25230
+ }
25231
+ }
25232
+ function concatenatedBytes(left, leftBytes, right, rightBytes) {
25233
+ const high = left.charCodeAt(left.length - 1);
25234
+ const low = right.charCodeAt(0);
25235
+ const splitPair = high >= 55296 && high <= 56319 && low >= 56320 && low <= 57343;
25236
+ return leftBytes + rightBytes - (splitPair ? 2 : 0);
25237
+ }
24927
25238
 
24928
25239
  // ../../bridges/cursor-bridge/src/transcript.ts
24929
25240
  var TRUNCATION_NOTICE = `
24930
25241
 
24931
25242
  [output truncated]`;
24932
25243
  var STREAM_BOUND_INTERVAL_BYTES = Math.min(MAX_TRANSCRIPT_BYTES, 1024 * 1024);
24933
- var TRANSCRIPT_LIMITS = {
25244
+ var bounds = createBridgeTranscriptBounds({
24934
25245
  maxMessages: MAX_MESSAGES,
24935
25246
  maxPartsPerMessage: MAX_PARTS_PER_MESSAGE,
24936
- maxTranscriptBytes: MAX_TRANSCRIPT_BYTES
24937
- };
25247
+ maxTranscriptBytes: MAX_TRANSCRIPT_BYTES,
25248
+ streamIntervalBytes: STREAM_BOUND_INTERVAL_BYTES
25249
+ });
25250
+ var appender = new BoundedTextAppender({
25251
+ notice: TRUNCATION_NOTICE,
25252
+ policy: "append-notice",
25253
+ saturated: saturatedText
25254
+ });
25255
+ var turnOutputAppender = new BoundedTextAppender({
25256
+ notice: TRUNCATION_NOTICE,
25257
+ policy: "append-notice",
25258
+ saturated: saturatedText
25259
+ });
25260
+ function appendTurnOutput(carrier, current, addition) {
25261
+ return turnOutputAppender.append(current, addition, MAX_MESSAGE_TEXT_BYTES, carrier).value;
25262
+ }
24938
25263
  function appendBounded(carrier, current, addition, limit = MAX_MESSAGE_TEXT_BYTES) {
24939
- if (!addition)
24940
- return current;
24941
- if (saturatedText.has(carrier))
24942
- return current;
24943
- const currentBytes = Buffer.byteLength(current);
24944
- const additionBytes = Buffer.byteLength(addition);
24945
- if (currentBytes + additionBytes <= limit)
24946
- return current + addition;
24947
- const available = limit - currentBytes - Buffer.byteLength(TRUNCATION_NOTICE);
24948
- saturatedText.add(carrier);
24949
- if (available <= 0) {
24950
- return current.endsWith(TRUNCATION_NOTICE) ? current : current + TRUNCATION_NOTICE;
24951
- }
24952
- return current + sliceToBytes(addition, available) + TRUNCATION_NOTICE;
25264
+ return appender.append(current, addition, limit, carrier).value;
24953
25265
  }
24954
25266
  function boundText(value, limit) {
24955
- if (Buffer.byteLength(value) <= limit)
24956
- return value;
24957
- const available = Math.max(0, limit - Buffer.byteLength(TRUNCATION_NOTICE));
24958
- return sliceToBytes(value, available) + TRUNCATION_NOTICE;
24959
- }
24960
- function sliceToBytes(value, limit) {
24961
- if (limit <= 0)
24962
- return "";
24963
- const buffer = Buffer.from(value);
24964
- if (buffer.length <= limit)
24965
- return value;
24966
- let end = limit;
24967
- while (end > 0 && (buffer[end] & 192) === 128)
24968
- end -= 1;
24969
- return buffer.subarray(0, end).toString("utf8");
25267
+ return boundUtf8Text(value, limit, TRUNCATION_NOTICE);
24970
25268
  }
25269
+ var sliceToBytes = sliceUtf8;
24971
25270
  function boundTranscript(state) {
24972
25271
  let childTrimmed = false;
24973
25272
  for (const row of liveRows(state)) {
24974
25273
  if (boundNestedParts(state, row, undefined, true))
24975
25274
  childTrimmed = true;
24976
25275
  }
24977
- const rowsBefore = state.messages.slice();
24978
- const partsBefore = rowsBefore.map((row) => row.parts.length);
24979
- const trimmed = boundTranscriptInPlace(state, TRANSCRIPT_LIMITS);
24980
- if (trimmed)
24981
- noteFrontTrimmedRows(state, rowsBefore, partsBefore);
25276
+ const trimmed = bounds.boundTranscript(state);
24982
25277
  if (trimmed || childTrimmed)
24983
25278
  forgetEvictedOpenText(state);
24984
25279
  return trimmed || childTrimmed;
24985
25280
  }
24986
- function noteFrontTrimmedRows(state, rowsBefore, partsBefore) {
24987
- const offset = rowsBefore.length - state.messages.length;
24988
- state.messages.forEach((row, index) => {
24989
- if (row.parts.length < partsBefore[index + offset])
24990
- noteRowRevised(state, row.id);
24991
- });
24992
- }
24993
25281
  function boundTranscriptForRead(state) {
24994
25282
  if (state.uncheckedTranscriptBytes === 0)
24995
25283
  return;
@@ -24999,7 +25287,6 @@ function boundTranscriptForRead(state) {
24999
25287
  function boundTranscriptDuringStreaming(state, grownParents) {
25000
25288
  const stats = statsFor(state);
25001
25289
  stats.checks += 1;
25002
- const newest = state.messages.at(-1);
25003
25290
  let grownRowsFit = true;
25004
25291
  if (grownParents && grownParents.size > 0) {
25005
25292
  const started = performance.now();
@@ -25017,9 +25304,8 @@ function boundTranscriptDuringStreaming(state, grownParents) {
25017
25304
  }
25018
25305
  recordCheckDuration(stats, started);
25019
25306
  }
25020
- if (grownRowsFit && state.messages.length <= MAX_MESSAGES && (newest?.parts.length ?? 0) <= MAX_PARTS_PER_MESSAGE && state.uncheckedTranscriptBytes < STREAM_BOUND_INTERVAL_BYTES) {
25307
+ if (grownRowsFit && !bounds.streamingBoundDue(state))
25021
25308
  return;
25022
- }
25023
25309
  const started = performance.now();
25024
25310
  stats.exactChecks += 1;
25025
25311
  if (boundTranscript(state)) {
@@ -25161,30 +25447,12 @@ function indexedToolCallRow(state, callId) {
25161
25447
  return turn.callsComplete ? null : undefined;
25162
25448
  return turnRowAt(state, turn, ordinal) ?? null;
25163
25449
  }
25164
- var revisedRows = new WeakMap;
25165
- function noteRowRevised(state, id) {
25166
- if (state.messages.at(-1)?.id === id)
25167
- return;
25168
- let rows = revisedRows.get(state);
25169
- if (!rows) {
25170
- rows = new RecentlyRevisedRows;
25171
- revisedRows.set(state, rows);
25172
- }
25173
- rows.note(id);
25174
- }
25175
- function rowChanged(state, row) {
25176
- noteRowRevised(state, row.id);
25177
- state.revision += 1;
25178
- }
25179
- function revisedRowsOverflowVersion(state) {
25180
- return revisedRows.get(state)?.overflowVersion ?? 0;
25181
- }
25182
- function revisedRowIds(state) {
25183
- const ids = revisedRows.get(state)?.ids();
25184
- return ids && ids.length > 0 ? ids : undefined;
25185
- }
25450
+ var noteRowRevised = bounds.noteRowRevised;
25451
+ var rowChanged = bounds.rowChanged;
25452
+ var revisedRowsOverflowVersion = bounds.revisedRowsOverflowVersion;
25453
+ var revisedRowIds = bounds.revisedRowIds;
25186
25454
  function startTranscriptEpoch(state) {
25187
- revisedRows.get(state)?.clear();
25455
+ bounds.forgetRevisedRows(state);
25188
25456
  state.transcriptEpoch = (state.transcriptEpoch ?? 0) + 1;
25189
25457
  }
25190
25458
  function liveRows(state) {
@@ -25202,10 +25470,7 @@ function parentsByRow(grownParents) {
25202
25470
  }
25203
25471
  return rows;
25204
25472
  }
25205
- function chargeTranscript(state, bytes) {
25206
- if (bytes > 0)
25207
- state.uncheckedTranscriptBytes += bytes;
25208
- }
25473
+ var chargeTranscript = bounds.chargeTranscript;
25209
25474
  var CHILD_TRIM_NOTICE = "[Earlier steps of this sub-agent were dropped: it reached the transcript display limit.]";
25210
25475
  var CHILD_PARTS_AFTER_TRIM = Math.floor(MAX_CHILD_PARTS_PER_TASK * 3 / 4);
25211
25476
  var CHILD_BYTES_AFTER_TRIM = Math.floor(MAX_CHILD_BYTES_PER_TASK * 3 / 4);
@@ -26783,7 +27048,7 @@ function applyTextDelta(state, text, kind, context) {
26783
27048
  message.content = appendBounded(message, message.content, text);
26784
27049
  chargeAppended(state, before, message.content);
26785
27050
  if (state.currentTurnOutput !== null) {
26786
- state.currentTurnOutput = appendBounded(message, state.currentTurnOutput, text);
27051
+ state.currentTurnOutput = appendTurnOutput(message, state.currentTurnOutput, text);
26787
27052
  }
26788
27053
  }
26789
27054
  rowChanged(state, message);
@@ -27289,7 +27554,7 @@ function completeStreamedProse(state, row, text) {
27289
27554
  row.content = appendBounded(row, row.content, text);
27290
27555
  chargeAppended(state, before, row.content);
27291
27556
  if (state.currentTurnOutput !== null) {
27292
- state.currentTurnOutput = appendBounded(row, state.currentTurnOutput, text);
27557
+ state.currentTurnOutput = appendTurnOutput(row, state.currentTurnOutput, text);
27293
27558
  }
27294
27559
  rowChanged(state, row);
27295
27560
  }
@@ -27417,9 +27682,10 @@ function createToolPart(state, message, callId, parentTaskUseId) {
27417
27682
  noteNestedPart(parentTaskUseId, message);
27418
27683
  return part;
27419
27684
  }
27685
+ var toolPartSizes = new EncodedObjectSizes;
27420
27686
  function chargeToolPart(state, part) {
27421
27687
  const source = toolSourceStates.get(part) ?? {};
27422
- const size = Buffer.byteLength(JSON.stringify(part));
27688
+ const size = toolPartSizes.measure(part);
27423
27689
  chargeTranscript(state, Math.max(0, size - (source.chargedBytes ?? 0)));
27424
27690
  source.chargedBytes = size;
27425
27691
  toolSourceStates.set(part, source);
@@ -27931,97 +28197,2468 @@ class RuntimeHealthRecorder {
27931
28197
  this.kinds.delete(oldest);
27932
28198
  }
27933
28199
  }
27934
- recordNotice(input) {
27935
- const message = bounded(input.message, MAX_RUNTIME_NOTICE_MESSAGE_LENGTH);
27936
- if (!message)
27937
- return;
27938
- const method = bounded(input.method, MAX_NATIVE_AGENT_DRIFT_KIND_LENGTH);
27939
- const key = `${method ?? ""}\x00${message}`;
27940
- const existing = this.notices.get(key);
27941
- const detail = bounded(input.detail, MAX_RUNTIME_NOTICE_DETAIL_LENGTH);
27942
- const receivedAt = bounded(input.receivedAt, 64) ?? new Date().toISOString();
27943
- const occurrences = [
27944
- ...existing?.occurrences ?? [],
27945
- { ...detail ? { detail } : {}, receivedAt }
27946
- ].slice(-MAX_RUNTIME_NOTICE_OCCURRENCES);
27947
- if (existing)
27948
- this.notices.delete(key);
27949
- this.notices.set(key, {
27950
- message,
27951
- ...method ? { method } : {},
27952
- count: (existing?.count ?? 0) + 1,
27953
- severity: input.severity ?? "warning",
27954
- source: input.source ?? "bridge",
27955
- occurrences
28200
+ recordNotice(input) {
28201
+ const message = bounded(input.message, MAX_RUNTIME_NOTICE_MESSAGE_LENGTH);
28202
+ if (!message)
28203
+ return;
28204
+ const method = bounded(input.method, MAX_NATIVE_AGENT_DRIFT_KIND_LENGTH);
28205
+ const key = `${method ?? ""}\x00${message}`;
28206
+ const existing = this.notices.get(key);
28207
+ const detail = bounded(input.detail, MAX_RUNTIME_NOTICE_DETAIL_LENGTH);
28208
+ const receivedAt = bounded(input.receivedAt, 64) ?? new Date().toISOString();
28209
+ const occurrences = [
28210
+ ...existing?.occurrences ?? [],
28211
+ { ...detail ? { detail } : {}, receivedAt }
28212
+ ].slice(-MAX_RUNTIME_NOTICE_OCCURRENCES);
28213
+ if (existing)
28214
+ this.notices.delete(key);
28215
+ this.notices.set(key, {
28216
+ message,
28217
+ ...method ? { method } : {},
28218
+ count: (existing?.count ?? 0) + 1,
28219
+ severity: input.severity ?? "warning",
28220
+ source: input.source ?? "bridge",
28221
+ occurrences
28222
+ });
28223
+ while (this.notices.size > MAX_RUNTIME_NOTICES) {
28224
+ const oldest = this.notices.keys().next().value;
28225
+ if (oldest === undefined)
28226
+ break;
28227
+ this.notices.delete(oldest);
28228
+ }
28229
+ }
28230
+ drift() {
28231
+ if (this.unknownEvents === 0)
28232
+ return;
28233
+ return { unknownEvents: this.unknownEvents, unknownKinds: [...this.kinds] };
28234
+ }
28235
+ listNotices() {
28236
+ return [...this.notices.values()];
28237
+ }
28238
+ advisories(limit = 5) {
28239
+ return [...this.notices.values()].filter((notice) => notice.severity === "error").slice(-limit).map((notice) => ({
28240
+ message: notice.message,
28241
+ severity: "error"
28242
+ }));
28243
+ }
28244
+ snapshot() {
28245
+ const drift = this.drift();
28246
+ return { ...drift ? { drift } : {}, notices: this.listNotices() };
28247
+ }
28248
+ reset() {
28249
+ this.unknownEvents = 0;
28250
+ this.kinds.clear();
28251
+ this.notices.clear();
28252
+ }
28253
+ }
28254
+ function emptyRuntimeHealth() {
28255
+ return { summary: {}, notices: [] };
28256
+ }
28257
+
28258
+ // ../../bridges/cursor-bridge/src/session-factory.ts
28259
+ function newSessionState(clientSessionKey, policy) {
28260
+ return {
28261
+ id: randomBytes3(16).toString("hex"),
28262
+ ...policy ? { policy } : {},
28263
+ ...clientSessionKey ? { clientSessionKey } : {},
28264
+ status: "idle",
28265
+ messages: [],
28266
+ droppedMessages: 0,
28267
+ droppedParts: 0,
28268
+ transcriptTruncated: false,
28269
+ revision: 0,
28270
+ structured: new Map,
28271
+ promptJournal: new Map,
28272
+ steerJournal: new Map,
28273
+ steerJournalBytes: 0,
28274
+ activeSubagentDescriptors: new Map,
28275
+ subagentLimitExceeded: false,
28276
+ todos: [],
28277
+ composer: emptyComposer(),
28278
+ agent: null,
28279
+ dispatching: false,
28280
+ promptSequence: 0,
28281
+ openTextParts: new Map,
28282
+ uncheckedTranscriptBytes: 0,
28283
+ currentTurnOutput: null,
28284
+ lastAccessed: Date.now(),
28285
+ observedMcpTools: new Set,
28286
+ health: new RuntimeHealthRecorder
28287
+ };
28288
+ }
28289
+
28290
+ // ../protocol/src/secret-redaction.ts
28291
+ var TEXT_RULES = [
28292
+ {
28293
+ pattern: /([a-z][a-z0-9+.-]*:\/\/)[^/\s:@]+(?::[^/\s@]*)?@/gi,
28294
+ replacement: "$1[redacted]@"
28295
+ },
28296
+ {
28297
+ pattern: /([?&](?:access[_-]?token|refresh[_-]?token|id[_-]?token|api[_-]?key|apikey|auth|authorization|token|secret|password|passwd|signature|sig|key|state|code)=)[^&\s"'`]+/gi,
28298
+ replacement: "$1[redacted]"
28299
+ },
28300
+ { pattern: /\bBearer\s+[A-Za-z0-9._~+/=-]{8,}/gi, replacement: "Bearer [redacted]" },
28301
+ { pattern: /\bBasic\s+[A-Za-z0-9+/=]{8,}/gi, replacement: "Basic [redacted]" },
28302
+ {
28303
+ pattern: /\beyJ[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{6,}/g,
28304
+ replacement: "[redacted]"
28305
+ },
28306
+ { pattern: /\bgh[pousr]_[A-Za-z0-9]{16,}/g, replacement: "[redacted]" },
28307
+ { pattern: /\bgithub_pat_[A-Za-z0-9_]{20,}/g, replacement: "[redacted]" },
28308
+ { pattern: /\b(?:sk|rk|pk)-[A-Za-z0-9_-]{12,}/g, replacement: "[redacted]" },
28309
+ { pattern: /\bxox[baprse]-[A-Za-z0-9-]{8,}/g, replacement: "[redacted]" },
28310
+ { pattern: /\bAKIA[0-9A-Z]{12,}/g, replacement: "[redacted]" },
28311
+ { pattern: /\bAIza[0-9A-Za-z_-]{20,}/g, replacement: "[redacted]" },
28312
+ {
28313
+ pattern: /\b((?:[A-Za-z0-9]+[_-])*(?:api[_-]?key|apikey|access[_-]?token|refresh[_-]?token|auth[_-]?token|token|secret|client[_-]?secret|password|passwd|passphrase|authorization))("?\s*[:=]\s*)("?)(?!Bearer\b|Basic\b|\[redacted\])[^\s"',;)&]{6,}\3/gi,
28314
+ replacement: "$1$2[redacted]"
28315
+ }
28316
+ ];
28317
+ function redactSecrets(value) {
28318
+ let result = value;
28319
+ for (const rule of TEXT_RULES) {
28320
+ result = result.replace(new RegExp(rule.pattern.source, rule.pattern.flags), rule.replacement);
28321
+ }
28322
+ return result;
28323
+ }
28324
+
28325
+ // ../protocol/src/log-error.ts
28326
+ var MAX_MESSAGE_CHARS = 1024;
28327
+ var MAX_STACK_FRAMES = 8;
28328
+ var MAX_FRAME_CHARS = 240;
28329
+ var MAX_RAW_FRAME_CHARS = 1024;
28330
+ var MAX_CAUSE_DEPTH = 2;
28331
+ var TRUNCATED_MARKER = "...[truncated]";
28332
+ var NAME_PATTERN = /^[A-Za-z_$][\w$.-]{0,63}$/;
28333
+ var CODE_PATTERN = /^[\w.:-]{1,64}$/;
28334
+ var SYSCALL_PATTERN = /^[\w./ -]{1,128}$/;
28335
+ var COMMAND_OUTPUT_FIELDS = ["stdout", "stderr", "cmd", "spawnargs"];
28336
+ var safeErrors = new WeakSet;
28337
+ function isSafeLogError(value) {
28338
+ return typeof value === "object" && value !== null && safeErrors.has(value);
28339
+ }
28340
+ function brand(details) {
28341
+ const safe = Object.freeze(details);
28342
+ safeErrors.add(safe);
28343
+ return safe;
28344
+ }
28345
+ function boundedText2(value, maxChars) {
28346
+ const cut = value.length > maxChars ? `${value.slice(0, maxChars - TRUNCATED_MARKER.length)}${TRUNCATED_MARKER}` : value;
28347
+ return redactSecrets(cut).replace(/[\u0000-\u001f\u007f-\u009f\u2028\u2029]+/g, " ").trim();
28348
+ }
28349
+ var FRAME_LOCATION = /(^|[\s(])((?:[a-z][a-z0-9+.-]*:\/\/[^/\s)]*)?(?:\/|[a-z]:[\\/]|\\\\).*?)(?=:\d+(?::\d+)?\)?(?:,|$)|\)(?:,|$)|,\s|$)/gi;
28350
+ var LOCATION_SCHEME = /^([a-z][a-z0-9+.-]*):\/\/[^/\s)]*/i;
28351
+ var APP_PATH = /(?:^|\/)((?:apps\/(?:backend|desktop|web|web-public)|packages\/(?:protocol|cli|toolchain)|bridges\/[\w-]+|[\w-]+-bridge)\/.*)$/;
28352
+ var PACKAGED_PATH = /\/((?:app\.asar(?:\.unpacked)?|resources)\/.*)$/i;
28353
+ function appRelativeLocation(location) {
28354
+ const scheme = LOCATION_SCHEME.exec(location)?.[1]?.toLowerCase();
28355
+ const isWebUrl = scheme !== undefined && scheme !== "file";
28356
+ const withoutOrigin = location.replace(LOCATION_SCHEME, "");
28357
+ const path = (isWebUrl ? withoutOrigin.split(/[?#]/, 1)[0] : withoutOrigin).replace(/\\/g, "/");
28358
+ const modules = path.lastIndexOf("/node_modules/");
28359
+ if (modules >= 0)
28360
+ return path.slice(modules + 1);
28361
+ const app = APP_PATH.exec(path)?.[1] ?? PACKAGED_PATH.exec(path)?.[1];
28362
+ if (app)
28363
+ return app;
28364
+ if (isWebUrl)
28365
+ return path.replace(/^\/+/, "");
28366
+ return `.../${path.slice(path.lastIndexOf("/") + 1)}`;
28367
+ }
28368
+ function relativeFrame(frame) {
28369
+ return frame.slice(0, MAX_RAW_FRAME_CHARS).replace(FRAME_LOCATION, (_match, lead, location) => `${lead}${appRelativeLocation(location)}`);
28370
+ }
28371
+ function read(target, key) {
28372
+ try {
28373
+ return target[key];
28374
+ } catch {
28375
+ return;
28376
+ }
28377
+ }
28378
+ function matching(value, pattern) {
28379
+ return typeof value === "string" && pattern.test(value) ? value : undefined;
28380
+ }
28381
+ function finite(value) {
28382
+ return typeof value === "number" && Number.isFinite(value) ? value : undefined;
28383
+ }
28384
+ function isCommandFailure(target, name, message) {
28385
+ return name === "CommandFailedError" || Boolean(message?.startsWith("Command failed")) || COMMAND_OUTPUT_FIELDS.some((field) => read(target, field) !== undefined);
28386
+ }
28387
+ function stackFrames(target, message) {
28388
+ const stack = read(target, "stack");
28389
+ if (typeof stack !== "string")
28390
+ return;
28391
+ const index = message ? stack.indexOf(message) : -1;
28392
+ const body = index >= 0 ? stack.slice(index + message.length) : stack;
28393
+ const frames = body.split(`
28394
+ `).filter((line) => /^\s*at\s/.test(line)).slice(0, MAX_STACK_FRAMES).map((line) => boundedText2(relativeFrame(line), MAX_FRAME_CHARS));
28395
+ return frames.length > 0 ? frames : undefined;
28396
+ }
28397
+ function describe2(error, includeStack, includeMessage, depth) {
28398
+ if (typeof error !== "object" || error === null) {
28399
+ if (!includeMessage)
28400
+ return { name: "NonError" };
28401
+ return {
28402
+ name: "NonError",
28403
+ message: typeof error === "string" ? boundedText2(error, MAX_MESSAGE_CHARS) : `[${typeof error}]`
28404
+ };
28405
+ }
28406
+ const rawMessage = read(error, "message");
28407
+ if (!(error instanceof Error) && typeof rawMessage !== "string") {
28408
+ return { name: "NonError", message: "[object]" };
28409
+ }
28410
+ const name = matching(read(error, "name"), NAME_PATTERN) ?? "Error";
28411
+ const message = typeof rawMessage === "string" ? rawMessage : undefined;
28412
+ const commandFailure = isCommandFailure(error, name, message);
28413
+ const stackHoldsMessage = message !== undefined && String(read(error, "stack") ?? "").includes(message);
28414
+ const details = { name };
28415
+ if (commandFailure)
28416
+ details.outputOmitted = true;
28417
+ else if (message && includeMessage)
28418
+ details.message = boundedText2(message, MAX_MESSAGE_CHARS);
28419
+ const code = read(error, "code");
28420
+ const safeCode = finite(code) ?? matching(code, CODE_PATTERN);
28421
+ if (safeCode !== undefined)
28422
+ details.code = safeCode;
28423
+ const errno = finite(read(error, "errno"));
28424
+ if (errno !== undefined)
28425
+ details.errno = errno;
28426
+ const syscall = matching(read(error, "syscall"), SYSCALL_PATTERN);
28427
+ if (syscall)
28428
+ details.syscall = syscall;
28429
+ const exitCode = finite(read(error, "exitCode"));
28430
+ if (exitCode !== undefined)
28431
+ details.exitCode = exitCode;
28432
+ const signal = matching(read(error, "signal"), CODE_PATTERN);
28433
+ if (signal)
28434
+ details.signal = signal;
28435
+ if (includeStack && (!commandFailure || stackHoldsMessage || !message)) {
28436
+ const frames = stackFrames(error, message);
28437
+ if (frames)
28438
+ details.stack = frames;
28439
+ }
28440
+ const members = read(error, "errors");
28441
+ if (Array.isArray(members))
28442
+ details.errorCount = members.length;
28443
+ const cause = read(error, "cause") ?? (Array.isArray(members) ? members[0] : undefined);
28444
+ if (cause !== undefined && cause !== null && depth < MAX_CAUSE_DEPTH) {
28445
+ details.cause = describe2(cause, false, includeMessage, depth + 1);
28446
+ }
28447
+ return details;
28448
+ }
28449
+ function formatLogError(error, options = {}) {
28450
+ try {
28451
+ return brand(describe2(error, options.stack !== false, options.message !== false, 0));
28452
+ } catch {
28453
+ return brand({ name: "Error", message: "[unreadable]" });
28454
+ }
28455
+ }
28456
+ function logErrorKind(error) {
28457
+ if (typeof error !== "object" || error === null)
28458
+ return "NonError";
28459
+ if (!(error instanceof Error) && typeof read(error, "message") !== "string")
28460
+ return "NonError";
28461
+ const code = read(error, "code");
28462
+ const safeCode = finite(code) ?? matching(code, CODE_PATTERN);
28463
+ if (safeCode !== undefined)
28464
+ return String(safeCode);
28465
+ return matching(read(error, "name"), NAME_PATTERN) ?? "Error";
28466
+ }
28467
+
28468
+ // ../protocol/src/log-vocabulary/define.ts
28469
+ var THROTTLE_LOG_EVENTS = {
28470
+ "throttle.suppressed": "Repeats of the throttled `site` were counted over a window, not written.",
28471
+ "throttle.recovered": "The throttled `site` succeeded again, so its fault has cleared.",
28472
+ "throttle.evicted": "The tracked-key limit dropped the `site`, so no recovered line follows unless it fails again."
28473
+ };
28474
+ function defineLogAreas(areas) {
28475
+ return areas;
28476
+ }
28477
+
28478
+ // ../protocol/src/log-vocabulary/agent-mail.ts
28479
+ var AGENT_MAIL_LOG_AREAS = defineLogAreas({
28480
+ "agent-mail": {
28481
+ description: "Delivering agent mail into waiting agent sessions.",
28482
+ events: {
28483
+ "delivery.waiting": "The drain passed over a pending message, for a reason it had not yet logged.",
28484
+ "drain.new-mail-failed": "Draining newly received mail failed; the next sweep delivers it.",
28485
+ "presence.sync-failed": "Mailboxes could not be synchronized.",
28486
+ "inject.verified": "An injected message's delivery was checked. Ids and decisions only.",
28487
+ "inject.dispatched": "Messages were dispatched into a session. Ids and decisions only.",
28488
+ "stopped-worker.action-failed": "Nothing could act on mail for a stopped worker.",
28489
+ "coordinator.start-failed": "The main coordinator could not be started for a new message.",
28490
+ "message.placed": "A message was placed in a mailbox. Ids and decisions only, never subjects or bodies.",
28491
+ "budget.hold-notify-failed": "The coordinator could not be told about held worker mail.",
28492
+ "budget.reset-failed": "The mail budget could not be reset for a prompted tab."
28493
+ }
28494
+ }
28495
+ });
28496
+
28497
+ // ../protocol/src/log-vocabulary/backend.ts
28498
+ var BACKEND_LOG_AREAS = defineLogAreas({
28499
+ "build.pipeline": {
28500
+ description: "Build delivery, ticket reconciliation and persisted pipeline recovery.",
28501
+ events: {
28502
+ "delivery-policy.failed": "A ticket delivery edit could not be reconciled with the running build.",
28503
+ "criteria.failed": "Verify could not record criterion results on the ticket.",
28504
+ "transcript-maintenance.failed": "Pipeline transcript maintenance failed.",
28505
+ "hydrate.failed": "The renderer could not load the authoritative pipeline snapshot."
28506
+ }
28507
+ },
28508
+ "backend.activity": {
28509
+ description: "The backend's recurring activity and maintenance jobs.",
28510
+ events: {
28511
+ "job.failed": "One pass of the job named in `scope` failed; its next pass retries.",
28512
+ ...THROTTLE_LOG_EVENTS
28513
+ }
28514
+ },
28515
+ backend: {
28516
+ description: "The backend process: startup, background notices and shutdown.",
28517
+ events: {
28518
+ starting: "The backend process is starting.",
28519
+ "ssh-socket.resolved": "An SSH agent socket was found.",
28520
+ "ssh-socket.missing": "No usable SSH agent socket was found.",
28521
+ "standalone-updater.mismatch": "--standalone-updater does not match --data-dir, so self-update is off.",
28522
+ "instance.publish-failed": "The instance descriptor could not be published.",
28523
+ "instance.republish-failed": "The instance descriptor could not be republished; a later pass retries.",
28524
+ "parent.exited": "The parent process exited, so local servers are shutting down.",
28525
+ "startup.step-failed": "One part of startup failed and the backend carried on; `step` says which.",
28526
+ "startup.setup-fence-failed": "An environment's interrupted setup could not be fenced.",
28527
+ "startup.setup-adopt-failed": "An environment's pending setup could not be adopted.",
28528
+ "startup.deletion-pending": "An interrupted environment deletion stays pending. Its owning step logged the detail.",
28529
+ "startup.looped-review-pending": "Cleanup of the retired Looped Review stays pending.",
28530
+ "notice.failed": "A background notice after a turn or prompt failed; `step` says which.",
28531
+ "artifacts.live-unavailable": "Live interactive artifacts are unavailable.",
28532
+ "shutdown.step-failed": "One part of shutdown failed and the rest went on; `step` says which.",
28533
+ "shutdown.signal-received": "A signal started shutdown, which tells a clean quit from the backend being killed.",
28534
+ "shutdown.finished": "Shutdown finished, and the process exits with `code`.",
28535
+ "port-policy.second-backend": "Another backend serves the default data directory, so this one avoids its ports.",
28536
+ "port-policy.serve-on-free-port": "--tailscale-serve is on a free gateway port; pass --port with --strict-gateway-port to keep one."
28537
+ }
28538
+ }
28539
+ });
28540
+
28541
+ // ../protocol/src/log-vocabulary/bridge.ts
28542
+ var MAX_BRIDGE_DIAGNOSTIC_BYTES = 8192;
28543
+ var BRIDGE_LOG_AREAS = defineLogAreas({
28544
+ "bridge.diagnostics": {
28545
+ description: "Metadata snapshots of bridge turns and processes: lifecycle, stalls and a keepalive at info, every minute at debug, and each change at trace. docs/architecture/bridge-diagnostics.md reads them.",
28546
+ tag: "bridge-diagnostics",
28547
+ maxStringChars: MAX_BRIDGE_DIAGNOSTIC_BYTES,
28548
+ events: {
28549
+ heartbeat: "A periodic snapshot of an open turn or process: every minute at debug; at info only as stall evidence (a stall starting or clearing, a late timer, a change during a silent stall) or the ten-minute keepalive.",
28550
+ change: "At trace only: a snapshot written as soon as the phase, the pending tools or a counter past its threshold changes.",
28551
+ "send-started": "A turn or process diagnostic scope began.",
28552
+ "send-resolved": "The provider accepted a dispatch.",
28553
+ "cancel-requested": "Cancellation of a turn was requested.",
28554
+ "cancel-settled": "The provider's cancel call returned or failed.",
28555
+ closed: "A diagnostic scope ended, with its final counters.",
28556
+ "snapshot-overflow": "A snapshot exceeded the bound, so only its size was written.",
28557
+ "debug-events": "A batch of allowlisted debug labels with their counts.",
28558
+ "setup-failed": "A Cursor setup step failed and swallowed its error.",
28559
+ "sdk-snapshot": "Cursor's SDK transports and executions at a boundary.",
28560
+ "sdk-snapshot-overflow": "A Cursor SDK snapshot exceeded the bound, so it was omitted."
28561
+ }
28562
+ },
28563
+ "bridge.lifecycle": {
28564
+ description: "What every long-lived bridge does the same way: its sweep and its shutdown.",
28565
+ events: {
28566
+ "idle-sweep.failed": "An idle sweep threw; the next tick retries.",
28567
+ "shutdown.failed": "Releasing the bridge failed during shutdown; it still exits."
28568
+ }
28569
+ },
28570
+ "bridge.acp": {
28571
+ description: "The ACP bridge behind Grok: its routes, sessions, saved state and change evidence.",
28572
+ events: {
28573
+ "command-change.record-failed": "A measured command change could not be recorded.",
28574
+ "evidence.record-failed": "Change evidence could not be recorded; the read loop carries on.",
28575
+ "evidence.shell-record-failed": "A shell observation could not be recorded.",
28576
+ "evidence.turn-record-failed": "Turn change evidence could not be recorded.",
28577
+ "server.listening": "The HTTP server is listening.",
28578
+ "state.composer-reset": "A saved composer state was malformed and was reset.",
28579
+ "state.discarded": "Saved bridge state could not be used and was discarded.",
28580
+ "state.persist-failed": "Saving bridge state failed; a later write retries.",
28581
+ "state.session-config-reset": "A saved session configuration was malformed and was reset."
28582
+ }
28583
+ },
28584
+ "bridge.claude": {
28585
+ description: "The Claude bridge: its routes, sessions, parked interactions and the Agent SDK turn loop.",
28586
+ events: {
28587
+ "commands.read-failed": "The command catalogue read failed; the cached answer stands.",
28588
+ "context-usage.read-failed": "The detailed context usage read failed; the route falls back.",
28589
+ "dispatch.rollback-failed": "Rolling back a prompt dispatch claim failed.",
28590
+ "event-subscriber.failed": "An event subscriber threw; other subscribers still ran.",
28591
+ "http.request-failed": "An HTTP route threw; it answered 500.",
28592
+ "mcp.config-ignored": "An MCP server configuration of an unsupported shape was ignored.",
28593
+ "mcp.read-failed": "Listing MCP servers failed; the route answered 500.",
28594
+ "models.fetch-failed": "Reading the supported models failed; the fallback catalogue is served.",
28595
+ "models.requested": "The model catalogue route was called.",
28596
+ "models.responded": "The model catalogue route answered.",
28597
+ "parent.gone": "The backend that launched this bridge has gone; shutting down.",
28598
+ "plan-approval.responding": "Answering a parked plan approval.",
28599
+ "plan-approval.response-failed": "The plan approval route failed.",
28600
+ "plan-approval.response-received": "The route received a plan approval answer.",
28601
+ "plan-approval.result": "A parked plan approval was answered.",
28602
+ "plan-approval.wait-failed": "A parked plan approval ended without an answer: cancelled, timed out or closed.",
28603
+ "plan-exit.failure-overridden": "ExitPlanMode failed after the user approved; treated as success with a continuation re-prompt.",
28604
+ "plan-mode.record-failed": "Plan mode from a status frame could not be recorded.",
28605
+ "plan.reprompt-approved-failed": "Re-prompting after an approved plan failed.",
28606
+ "plan.reprompt-feedback-failed": "Re-prompting with plan rejection feedback failed.",
28607
+ "plugin.path-missing": "A configured plugin was skipped because its path does not exist.",
28608
+ "plugin.unsafe-path": "An installed plugin was skipped because its install path is unsafe.",
28609
+ "plugins.read-failed": "Listing plugins failed; the route answered 500.",
28610
+ "prompt.accepted": "The route accepted a prompt and answered 202.",
28611
+ "prompt.failed": "A prompt turn failed; the session reports the error.",
28612
+ "prompt.processing-failed": "A prompt accepted by the route failed while processing.",
28613
+ "prompt.received": "A prompt reached the bridge; only its length is logged.",
28614
+ "prompt.send-failed": "A prompt request failed; the route answered with an error.",
28615
+ "query.close-failed": "Stopping the Claude query failed while closing a tab; the close stays pending.",
28616
+ "query.failed": "A Claude query ended with an error result.",
28617
+ "question.answer-failed": "The answer-question route failed.",
28618
+ "question.answering": "Answering a parked question.",
28619
+ "question.answers-prepared": "The route prepared a question answer for the session.",
28620
+ "question.answers-received": "A parked question received its answers.",
28621
+ "question.stale": "An answer arrived for a question no longer pending; the route answered stale.",
28622
+ "question.wait-failed": "A parked question ended without an answer: cancelled, timed out or closed.",
28623
+ "runtime.ended-under-resumed-turn": "The Claude runtime ended while a resumed root turn was still open.",
28624
+ "server.listening": "The HTTP server is listening.",
28625
+ "server.starting": "The HTTP server is about to bind.",
28626
+ "session.compact-failed": "A requested compaction failed.",
28627
+ "session.create-failed": "Creating a session failed; the route answered with an error.",
28628
+ "session.created": "A session was created or recovered.",
28629
+ "session.delete-failed": "Deleting a session failed.",
28630
+ "session.fork-failed": "Forking a session failed.",
28631
+ "session.rename-failed": "Renaming a session failed.",
28632
+ "session.resolve-failed": "A session could not be found or loaded for a request; action names the request.",
28633
+ "session.rewind-failed": "Rewinding session files failed.",
28634
+ "session.task-state-hydrate-failed": "Hydrating session task state failed; the route answered with an error.",
28635
+ "sessions.reconcile-failed": "Reconciling persisted sessions failed; the sessions already known are listed.",
28636
+ "sse.aborted": "The client closed an event stream.",
28637
+ "sse.cleanup": "An event stream connection was released.",
28638
+ "sse.closed": "An event stream was closed by the bridge; the client reconnects and replays.",
28639
+ "sse.handshake-failed": "An event stream failed during its handshake; the client reconnects.",
28640
+ "sse.keepalive-failed": "An event stream keepalive failed, usually a client that has gone; the connection closes.",
28641
+ "sse.opened": "An event stream connection opened.",
28642
+ "sse.subscribe-requested": "A client asked to subscribe to the event stream.",
28643
+ "sse.write-failed": "Writing to an event stream failed; the connection closes and the client reconnects.",
28644
+ "task.candidate-bound-reached": "An unresolved Bash call was not tracked as a background task: the candidate bound is full.",
28645
+ "task.details-persist-failed": "Shell task details could not be saved; the task carries on.",
28646
+ "task.settling-bound-reached": "A settling task was not tracked: the settling bound is full.",
28647
+ "task.stop-failed": "Stopping a background task failed on a control channel that had closed.",
28648
+ "task.stop-route-failed": "The stop-task route failed.",
28649
+ "transcript.background-hydrate-failed": "Hydrating a transcript in the background failed; the next read retries.",
28650
+ "transcript.hydrate-failed": "Hydrating a transcript before a prompt failed; the prompt runs and a later read retries."
28651
+ }
28652
+ },
28653
+ "bridge.codex": {
28654
+ description: "The Codex bridge: its routes, sessions and the app-server child it supervises.",
28655
+ events: {
28656
+ "account.connector-recovery-failed": "Recovering account connectors failed; the account answer stands.",
28657
+ "account.login-reload-failed": "Reloading the stored account login failed.",
28658
+ "account.sign-in-check-failed": "An account sign-in check failed; admission is left unchanged.",
28659
+ "account.usage-read-failed": "Reading account usage failed; the route answers 503.",
28660
+ "app-server.drain-expired": "The drain deadline expired, so app-server restarted with turns still in flight.",
28661
+ "app-server.exited": "app-server exited unexpectedly; the code and signal say how.",
28662
+ "app-server.invariant-violation": "app-server asked for something its configuration forbids.",
28663
+ "app-server.protocol-violation": "app-server wrote a line that is not valid protocol; it was ignored.",
28664
+ "app-server.recording": "Notification recording is on; recordings hold content.",
28665
+ "app-server.stale-reaped": "A stale app-server left by an earlier bridge was stopped.",
28666
+ "app-server.stderr": "Metadata of an app-server stderr line, never its content.",
28667
+ "app-server.stderr-suppressed": "app-server stderr lines beyond the budget were counted, not described.",
28668
+ "approval.cancel-failed": "Cancelling a turn after an approval answer failed.",
28669
+ "approval.present-failed": "Presenting an approval threw; it is auto-declined.",
28670
+ "approval.resolved-callback-failed": "An approval resolved callback threw.",
28671
+ "command-changes.record-failed": "Recording line changes for a command failed; the turn carries on.",
28672
+ "dispatch.reconcile-failed": "A dispatch could not be reconciled against its thread; it stays recovering.",
28673
+ "dispatch.restore-failed": "A journaled dispatch could not be restored after a restart; recovery retries.",
28674
+ "engine.listener-failed": "An engine event listener threw; the others still ran.",
28675
+ "engine.ready": "The app-server engine started.",
28676
+ "engine.start-failed": "The app-server engine failed to start; reported through health.",
28677
+ "engine.stop-failed": "Stopping the Codex engine failed during shutdown; the bridge exits anyway.",
28678
+ "generation.recovery-failed": "Recovering sessions after an app-server generation change failed.",
28679
+ "http.request-failed": "An HTTP route threw; it answered 500.",
28680
+ "idle-sweep.failed": "An idle sweep failed; the next one retries.",
28681
+ "interaction.present-failed": "Presenting an interaction threw; it is cancelled.",
28682
+ "interaction.resolved-callback-failed": "An interaction resolved callback threw.",
28683
+ "journal.persist-failed": "Saving the dispatch journal failed.",
28684
+ "message.publish-failed": "Publishing a message update failed.",
28685
+ "models.cache-persist-failed": "Saving the model cache failed.",
28686
+ "models.debug-read-failed": "`codex debug models` failed; another source is used.",
28687
+ "models.list-failed": "model/list failed; the cached models are served.",
28688
+ "models.refresh-failed": "A background model refresh failed; the cache stands.",
28689
+ "notification.enqueue-failed": "Queueing a notification threw.",
28690
+ "ordered-events.flush-failed": "Flushing before ordered-event reconciliation failed.",
28691
+ "ordered-events.publish-failed": "Publishing an ordered event failed; clients are told to rehydrate.",
28692
+ "ordered-events.reconcile-failed": "Reconciling ordered events failed.",
28693
+ "parent.gone": "The backend that launched this bridge has gone; stopping turns and shutting down.",
28694
+ "queue.task-failed": "A task on a per-thread queue failed.",
28695
+ "raw-log.write-failed": "Appending to the raw Codex log failed.",
28696
+ "recorder.notice": "The notification recorder needs attention: it is on, or was asked for without its confirmation.",
28697
+ "recorder.threw": "The notification recorder threw.",
28698
+ "recorder.write-failed": "Writing a notification recording failed; its lines were dropped.",
28699
+ "registry.persist-failed": "Saving the session registry failed; a later write retries.",
28700
+ "rollout.hydrate-failed": "A rollout could not be read to hydrate a thread.",
28701
+ "runtime-env.refresh-failed": "Refreshing the runtime environment failed; the last values stay.",
28702
+ "runtime-env.refreshed": "Runtime environment variables changed; names only, never values.",
28703
+ "server-request.answer-failed": "Answering a server request failed.",
28704
+ "server-request.flush-timeout": "An answer to a server request did not flush in time.",
28705
+ "server-request.handoff-failed": "Handing a server request to the router threw.",
28706
+ "session.config-apply-failed": "Applying session configuration failed; the route answers unavailable.",
28707
+ "sse.closed": "An event stream was closed by the bridge; the client reconnects and replays.",
28708
+ "sse.keepalive-failed": "An event stream keepalive failed.",
28709
+ "sse.observer-failed": "An event stream observer failed; it reconnects.",
28710
+ "sse.payload-serialize-failed": "An event payload could not be serialized; a placeholder was sent.",
28711
+ "sse.payload-snapshot-failed": "An event payload could not be snapshotted; a placeholder was sent.",
28712
+ "sse.subscriber-failed": "An event stream subscriber failed; it reconnects and replays.",
28713
+ "subagent.activity-load-failed": "Sub-agent activity could not be loaded; the transcript renders without it.",
28714
+ "thread.archive-failed": "Archiving or unarchiving a thread failed.",
28715
+ "thread.fork-failed": "thread/fork failed; the route answers 503.",
28716
+ "thread.fork-hydrate-failed": "A forked thread could not be hydrated and was closed.",
28717
+ "thread.reattach-failed": "A thread could not be re-attached.",
28718
+ "thread.rename-failed": "thread/name/set failed; the bridge title index stays authoritative.",
28719
+ "thread.turns-read-after-revert-failed": "A thread's turns could not be read after a revert.",
28720
+ "thread.turns-read-failed": "A thread's turns could not be read.",
28721
+ "thread.unsubscribe-failed": "thread/unsubscribe failed; the binding is kept so a retry can unsubscribe.",
28722
+ "threads.list-failed": "thread/list failed; sessions come from the rollout parser.",
28723
+ "transcript.serving-last-known": "A thread read failed, so the last known transcript is served.",
28724
+ "turn.capacity-retry-failed": "Retrying a turn after a capacity failure failed.",
28725
+ "turn.capacity-retry-journal-failed": "A capacity retry could not be journaled.",
28726
+ "turn.finalize-failed": "Finalizing a turn failed.",
28727
+ "turns.stopped": "Running turns were stopped because the backend went away."
28728
+ }
28729
+ },
28730
+ "bridge.cursor": {
28731
+ description: "The Cursor bridge: its routes, sessions and saved state.",
28732
+ events: {
28733
+ "agent.archive-failed": "Archiving or unarchiving an agent failed.",
28734
+ "http.route-failed": "An HTTP route failed unexpectedly; its error is not logged because it can hold content.",
28735
+ "startup.closes-failed": "Finishing closes a previous process left behind failed at startup.",
28736
+ "startup.closes-incomplete": "Some closes a previous process left behind did not finish at startup; a retried close finishes them.",
28737
+ "state.publication-failing": "Saving bridge state is failing; new prompts and steers are refused until it recovers.",
28738
+ "state.publication-recovered": "Saving bridge state recovered.",
28739
+ "state.transcripts-shortened": "The state file reached its limit, so some sessions were saved with a shortened transcript copy."
28740
+ }
28741
+ },
28742
+ "bridge.pi": {
28743
+ description: "The Pi bridge: its routes, sessions and saved state.",
28744
+ events: {
28745
+ "http.route-failed": "An HTTP route failed unexpectedly; its error is not logged because it can hold content.",
28746
+ "state.over-budget": "The state file stayed over budget after shedding transcripts, so the write was skipped.",
28747
+ "state.transcripts-shed": "The state file was over budget, so some sessions were saved without their transcript."
28748
+ }
28749
+ }
28750
+ });
28751
+
28752
+ // ../protocol/src/log-vocabulary/desktop.ts
28753
+ var DESKTOP_LOG_AREAS = defineLogAreas({
28754
+ desktop: {
28755
+ description: "The Electron main process: startup, windows, quit and the Local backend's life.",
28756
+ events: {
28757
+ "backend.docker-context-seed-failed": "An agent-test profile fell back to the default Docker context.",
28758
+ "backend.exited": "The Local backend exited unexpectedly; Local work is unavailable.",
28759
+ "backend.exited-recovering": "The Local backend exited just after a remote update; relaunching unattended.",
28760
+ "backend.keychain-link-remove-failed": "An agent-test profile kept a legacy link to the host keychain.",
28761
+ "backend.start-failed": "The Local backend did not start; continuing with remote machines.",
28762
+ "clipboard.write-failed": "Writing text to the system clipboard failed.",
28763
+ "instance.already-running": "Another instance holds this data directory; this one will quit.",
28764
+ "main-thread.stalled": "A timer fired late, so windows, IPC and the stdout reader waited.",
28765
+ "quit.stopping-backend": "The app is quitting and has asked the Local backend to stop.",
28766
+ "relaunch.schedule-failed": "The AppImage relaunch waiter failed; using Electron's relauncher.",
28767
+ "relaunch.service-register-failed": "The AppImage relaunch service was refused; using a detached waiter.",
28768
+ "renderer.gone-giving-up": "A renderer kept dying, so the window is no longer reloaded.",
28769
+ "renderer.gone-reloading": "A renderer died and the window is being reloaded.",
28770
+ "renderer.reload-failed": "Reloading a window after its renderer died failed.",
28771
+ "restart-prompt.failed": "A native restart prompt could not be shown.",
28772
+ "saved-machines.attach-failed": "Saved machines were not imported into the command node yet.",
28773
+ "saved-machines.attached": "Saved machines were imported into the local command node.",
28774
+ "startup.failed": "The application failed to start.",
28775
+ "uncaught-exception": "The main process hit an uncaught exception.",
28776
+ "uncaught-exception.dialog-failed": "The uncaught exception sheet could not be shown.",
28777
+ "window.create-failed": "A menu-driven new window could not be created.",
28778
+ "window.recreate-failed": "The main window could not be recreated on activation.",
28779
+ "window.second-launch-failed": "A second launch could not open a window."
28780
+ }
28781
+ },
28782
+ "desktop.startup": {
28783
+ description: "Renderer startup markers and renderer process failures. These are the only events the renderer can place in the persistent log.",
28784
+ tag: "DesktopStartup",
28785
+ events: {
28786
+ "backend-unavailable": "The renderer could not complete a Local backend read in time.",
28787
+ "bridge-unavailable": "The preload API or connection-list IPC did not answer.",
28788
+ checking: "The renderer began waiting for the desktop connection.",
28789
+ "page-load-failed": "Chromium failed to load the main document.",
28790
+ "preload-failed": "Electron rejected the preload script.",
28791
+ ready: "The renderer reached the desktop connection and may mount the workspace.",
28792
+ "renderer-error": "An uncaught error occurred while the renderer was starting.",
28793
+ "renderer-gone": "A renderer process exited.",
28794
+ "renderer-load-failed": "Importing or mounting the application failed.",
28795
+ "unhandled-rejection": "An unhandled rejection occurred while the renderer was starting."
28796
+ }
28797
+ },
28798
+ "desktop.dialog": {
28799
+ description: "Native dialogs, whose modal loops hold the main thread while they are open.",
28800
+ events: {
28801
+ "attention-failed": "A dialog could not ask for the user's attention.",
28802
+ closed: "A native dialog closed.",
28803
+ "open-failed": "A dialog could not open; it was answered as cancelled.",
28804
+ opening: "A native dialog is opening.",
28805
+ "preview-beforeunload-ignored": "A browser preview's beforeunload handler was ignored.",
28806
+ "renderer-beforeunload-cancelled": "A renderer's beforeunload handler cancelled an unload."
28807
+ }
28808
+ },
28809
+ "backend.client": {
28810
+ description: "The desktop's HTTP and event stream client for a backend.",
28811
+ events: {
28812
+ "event-stream.disconnected": "The event stream dropped; the client reconnects with backoff.",
28813
+ "event-stream.malformed-frame": "An event stream frame could not be parsed and was dropped."
28814
+ }
28815
+ },
28816
+ connections: {
28817
+ description: "The desktop's saved machines and active connection.",
28818
+ events: {
28819
+ "catalogue.legacy-read-failed": "The previous connection list could not be read to migrate.",
28820
+ "catalogue.restored-from-backup": "The device catalogue was unreadable; the backup was used.",
28821
+ "restore.failed": "The previous remote connection could not be restored; using Local.",
28822
+ "secure-storage.waiting": "Startup is waiting on an operating system keychain prompt."
28823
+ }
28824
+ },
28825
+ workspaces: {
28826
+ description: "Workspace realms the desktop holds on other machines.",
28827
+ events: {
28828
+ "route.moved-direct": "A relayed workspace moved to its direct route."
28829
+ }
28830
+ },
28831
+ toolchain: {
28832
+ description: "Preparing the pinned agent toolchain at desktop startup.",
28833
+ events: {
28834
+ "bootstrap-progress.show-failed": "The toolchain progress window could not be shown.",
28835
+ "prepare.failed": "Preparing the pinned agent tools failed."
28836
+ }
28837
+ },
28838
+ "artifact-host": {
28839
+ description: "Live artifact hosts in the desktop app.",
28840
+ events: {
28841
+ "host.ended": "A host ended; fields count its blocked and rejected requests by reason."
28842
+ }
28843
+ }
28844
+ });
28845
+
28846
+ // ../protocol/src/log-vocabulary/environment.ts
28847
+ var ENVIRONMENT_LOG_AREAS = defineLogAreas({
28848
+ environment: {
28849
+ description: "Environment naming, setup, status, moves, deletion and cleanup afterwards.",
28850
+ events: {
28851
+ "cleanup.branch-kept": "A deleted environment's local branch was kept, as it may hold unmerged work.",
28852
+ "rename.failed": "Naming an environment from its pending prompt failed for the first time.",
28853
+ "rename.still-failing": "That rename is still failing; written at the 2nd, 4th, 8th... failure.",
28854
+ "rename.recovered": "A rename from a pending prompt succeeded after failing.",
28855
+ "setup.attention-not-recorded": "Held setup could not be recorded as needing the user's attention.",
28856
+ "setup.coordinator-not-notified": "The worker's coordinator could not be told that its setup is held for approval.",
28857
+ "setup.unknown-environment": "The renderer was asked to act on the setup of an environment it does not hold.",
28858
+ "cleanup.rearmed": "A deleted environment's stopped cleanup is retried once under a new backend version.",
28859
+ "cleanup.exhausted": "A deleted environment's cleanup keeps failing after its attempts; written once per environment.",
28860
+ "cleanup.retry-not-admitted": "A cleanup retry was not admitted; the entry stays for the next start.",
28861
+ "cleanup.step-failed": "One step of a deleted environment's cleanup failed; a later reconcile retries it.",
28862
+ "cleanup.record-failed": "A finished cleanup step could not be recorded, so it may run again.",
28863
+ "cleanup.sweep-failed": "A cleanup sweep failed; written once per sweep.",
28864
+ "cleanup.reconcile-failed": "A cleanup reconcile pass failed; the next one retries.",
28865
+ "orphan-state.remove-failed": "An orphaned environment state directory could not be removed.",
28866
+ "orphan-state.removed": "Orphaned environment state directories were removed.",
28867
+ "orphan-state.sweep-failed": "Sweeping orphaned environment state failed.",
28868
+ "orphan-canvas.removed": "Orphaned design canvases were removed.",
28869
+ "orphan-canvas.sweep-failed": "Sweeping orphaned design canvases failed.",
28870
+ "orphan-branches.swept": "Orphaned environment branches were deleted, or kept as they may hold unmerged work.",
28871
+ "stray-workspace.remove-failed": "A stray workspace directory could not be removed.",
28872
+ "stray-workspace.removed": "Stray workspace directories were removed.",
28873
+ "stray-workspace.kept": "Unowned workspace directories that hold files were kept; remove them by hand if unneeded.",
28874
+ "temp-files.removed": "Abandoned temp files were removed.",
28875
+ "status.ownership-probe-failed": "A strict container ownership probe failed, so the stored status is kept.",
28876
+ "status.docker-error": "A transient Docker error stopped a status read, so the stored status is kept.",
28877
+ "setup.clear-launch-failed": "A pending agent launch could not be cleared after setup failed.",
28878
+ "setup.record-failure-failed": "A setup failure before its first attempt could not be recorded.",
28879
+ "lifecycle.failed": "Starting, rebuilding or recreating an environment failed; `operation` says which.",
28880
+ "tab-teardown.pending": "A tab's teardown failed and stays pending; the reconcile sweep retries.",
28881
+ "tab-reconcile.skipped": "Orphaned tab reconciliation was skipped because pane layouts are unreadable.",
28882
+ "orphan-session.reaped": "A native session no tab references was torn down.",
28883
+ "handoff-sweep.failed": "Sweeping transferred transcripts no tab references failed.",
28884
+ "delete.terminals-survived": "Terminal process trees outlived termination, so the deletion stops.",
28885
+ "delete.artifacts-left": "Graph run artifact directories were not removed.",
28886
+ "delete.worktrees-kept": "Graph runs kept branch worktrees.",
28887
+ "delete.step-failed": "One best-effort part of deleting an environment failed; `step` says which, and the rest goes on.",
28888
+ "merge-cleanup.resume-failed": "A merge cleanup interrupted by a restart could not be resumed.",
28889
+ "move.sessions-not-moved": "A provider's sessions could not follow a moved environment.",
28890
+ "move.recovery-failed": "Recovering an interrupted environment move failed.",
28891
+ "stop.settle-activity-failed": "Agent activity could not be settled after a runtime stopped.",
28892
+ ...THROTTLE_LOG_EVENTS
28893
+ }
28894
+ }
28895
+ });
28896
+
28897
+ // ../protocol/src/log-vocabulary/gateway.ts
28898
+ var GATEWAY_LOG_AREAS = defineLogAreas({
28899
+ gateway: {
28900
+ description: "The gateway other devices, browsers and the desktop connect through.",
28901
+ events: {
28902
+ "remote.start-failed": "The desktop could not start the remote gateway.",
28903
+ "remote.stop-failed": "The desktop could not stop the remote gateway cleanly.",
28904
+ disabled: "The gateway is disabled by its environment variable.",
28905
+ "tailscale.no-address": "No Tailscale address was found, so the gateway did not start.",
28906
+ "tailscale.no-address-fallback": "No Tailscale address was found, so the gateway binds its fallback address.",
28907
+ "control.listening": "The backend control listener is up.",
28908
+ "browser.listening": "The browser listener is up.",
28909
+ "browser.unavailable": "The browser listener could not start; control remains if started, or loopback is attempted.",
28910
+ "browser.unavailable-degraded": "No browser listener was started (`reason=no-tailscale-address`); control remains if started, or loopback is attempted.",
28911
+ "loopback.listening": "The loopback client listener is up.",
28912
+ "loopback.unavailable": "The loopback client listener could not start.",
28913
+ "auth-token.stored": "The gateway token's file was written. The path only, never the token.",
28914
+ "auth-token.persist-failed": "The gateway token could not be saved.",
28915
+ "port.fallback": "The preferred port was taken, so a nearby one is used.",
28916
+ "port.fallback-distant": "The preferred port and those nearby were taken, so another is used.",
28917
+ "request.failed": "A gateway request failed. Throttled: repeats are counted, not written.",
28918
+ "websocket.upgrade-failed": "A WebSocket upgrade failed.",
28919
+ "events.client-dropped": "An event-stream client buffered too much and was dropped; it reconnects and refetches.",
28920
+ "proxy.client-disconnected": "A proxy client went away, so its upstream request was aborted.",
28921
+ "throttle.suppressed": "Repeats of the throttled `site` were counted over a window, not written.",
28922
+ "throttle.recovered": "The throttled `site` succeeded again, so its fault has cleared.",
28923
+ "throttle.evicted": "The tracked-key limit dropped the `site`, so no recovered line follows unless it fails again."
28924
+ }
28925
+ },
28926
+ "gateway.terminal": {
28927
+ description: "The gateway's terminal WebSocket.",
28928
+ events: {
28929
+ "upgrade-rejected": "A terminal WebSocket upgrade was refused.",
28930
+ "socket-error": "A terminal WebSocket reported an error.",
28931
+ "subscription-failed": "A terminal subscription failed.",
28932
+ "operation-failed": "A terminal operation failed. Fixed text: the operation can hold terminal input."
28933
+ }
28934
+ },
28935
+ "gateway.tailscale": {
28936
+ description: "Tailscale Serve for desktop web access and a standalone backend.",
28937
+ events: {
28938
+ "web-access.disable-failed": "Desktop web access could not be turned off.",
28939
+ "web-access.enable-failed": "Desktop web access could not be turned on.",
28940
+ "web-access.cleanup-failed": "Cleaning up after a failed enable also failed.",
28941
+ "web-access.reset-failed": "Desktop web access could not be reset.",
28942
+ "startup.init-failed": "Desktop web access could not be initialized at startup.",
28943
+ available: "Tailscale Serve is publishing the gateway."
28944
+ }
28945
+ }
28946
+ });
28947
+
28948
+ // ../protocol/src/log-vocabulary/local-server.ts
28949
+ var LOCAL_SERVER_LOG_AREAS = defineLogAreas({
28950
+ "local-server": {
28951
+ description: "Agent bridge processes the backend runs on the host.",
28952
+ events: {
28953
+ "bridge.not-answering": "A bridge with work in progress fails health checks, so it is not restarted yet.",
28954
+ "bridge-runtime.installing": "A bridge runtime is being installed.",
28955
+ "bridge-runtime.installed": "A bridge runtime finished installing.",
28956
+ "opencode.database-lost-retrying": "OpenCode lost its shared database at startup, so it is retried.",
28957
+ "server.stopping": "A local server is being stopped, for the fixed `reason` given.",
28958
+ "reaper.tmux-list-failed": "Orphaned claude-tmux sessions could not be listed.",
28959
+ "reaper.tmux-kill-failed": "An orphaned tmux session could not be killed.",
28960
+ "reaper.tmux-reaped": "Orphaned claude-tmux sessions of a deleted environment were killed.",
28961
+ "reaper.runtime-root-remove-failed": "A claude-tmux runtime root could not be removed; it stays for a retry.",
28962
+ "reaper.server-unidentified": "An orphan candidate could not be identified, so its record is kept.",
28963
+ "reaper.server-refused": "An orphan candidate leads no process group, so it was not reaped.",
28964
+ "reaper.server-reaping": "An orphaned server is being stopped.",
28965
+ "reaper.server-kill-failed": "An orphaned server did not exit.",
28966
+ ...THROTTLE_LOG_EVENTS
28967
+ }
28968
+ }
28969
+ });
28970
+
28971
+ // ../protocol/src/log-vocabulary/git.ts
28972
+ var GIT_LOG_AREAS = defineLogAreas({
28973
+ git: {
28974
+ description: "Git operations the backend runs in environment worktrees and containers.",
28975
+ events: {
28976
+ "branch.rename-failed": "Renaming an environment's branch failed; the stored name is kept.",
28977
+ "branch.push-config-failed": "A branch was renamed but its push settings could not be written; the rename is undone.",
28978
+ "branch.rollback-failed": "Undoing a branch rename failed; the stored name follows whichever branch now exists."
28979
+ }
28980
+ }
28981
+ });
28982
+
28983
+ // ../protocol/src/log-vocabulary/logging.ts
28984
+ var LOGGING_LOG_AREAS = defineLogAreas({
28985
+ logging: {
28986
+ description: "The logger and the on-disk application log themselves.",
28987
+ events: {
28988
+ "capture.started": "Saving logs to disk began for this process.",
28989
+ "capture.stopped": "Saving logs to disk stopped for this process.",
28990
+ "config.invalid": "A logging environment variable held a value that was ignored.",
28991
+ "entries.dropped": "The log queue was full, so entries were dropped and counted.",
28992
+ "policy.changed": "The logging settings changed: saving, retention and levels, with no content.",
28993
+ "policy.bridge-predates-route": "A running bridge has no logging settings route; it applies them at its next start.",
28994
+ "policy.push-failed": "A running bridge did not take the logging settings after retries; its next start resends them.",
28995
+ "prune.failed": "Removing expired log files failed; the next sweep retries.",
28996
+ "write.failed": "Appending to the log file failed.",
28997
+ "unknown-area": "Code outside the type checker asked for an area that is not listed."
28998
+ }
28999
+ }
29000
+ });
29001
+
29002
+ // ../protocol/src/log-vocabulary/models.ts
29003
+ var MODEL_LOG_AREAS = defineLogAreas({
29004
+ models: {
29005
+ description: "Agent model catalogues and their persistent caches.",
29006
+ events: {
29007
+ "cache.write-failed": "A successful catalogue refresh could not update the host cache.",
29008
+ "seed.pi-failed": "The host Pi model catalogue could not be seeded; the next launch retries.",
29009
+ "bridge.not-ready": "The first-use catalogue bridge did not become ready.",
29010
+ "bridge.start-failed": "The first-use catalogue bridge failed to start.",
29011
+ "probe.exit-unclean": "A catalogue probe or sign-in server did not exit cleanly.",
29012
+ "download.deferred": "A model catalogue could not be downloaded yet."
29013
+ }
29014
+ }
29015
+ });
29016
+
29017
+ // ../protocol/src/log-vocabulary/native-agent.ts
29018
+ var NATIVE_AGENT_LOG_AREAS = defineLogAreas({
29019
+ "native-agent": {
29020
+ description: "Native agent sessions and what the backend reads from their bridges.",
29021
+ events: {
29022
+ "catalogue.outdated-bridge": "A bridge predates the command catalogue, so its commands stay unavailable.",
29023
+ "handoff.summary-read-failed": "Change summaries could not be read for a handoff, so the carrier says they are unmeasured.",
29024
+ "handoff.consume-failed": "A delivered handoff could not be marked consumed.",
29025
+ "job.pr-refresh-rollback-failed": "Rolling back a pull request refresh for a job failed.",
29026
+ "job.resend-queue-failed": "A resend could not be queued for a job.",
29027
+ "interaction.requests-dropped": "Interaction requests that could not be mapped were dropped.",
29028
+ "interaction.observe-failed": "Observing a session's interactions failed. Error class only.",
29029
+ "human-prompt.listener-failed": "A human prompt listener threw; the others still run.",
29030
+ "question.attention-record-failed": "Attention for an async question could not be recorded; the transcript stays readable.",
29031
+ "activity.reconcile-failed": "Reconciling an environment's activity failed. Error class only.",
29032
+ "activity.persist-failed": "An environment's activity could not be saved.",
29033
+ "pr-refresh.schedule-failed": "A pull request refresh after completion could not be scheduled.",
29034
+ "launch.startup-failed": "A startup launch failed; it retries unless `permanent`.",
29035
+ "queue.failing": "A native prompt queue keeps failing. The key and reason only, never the prompt.",
29036
+ "provider.retire-failed": "Retiring an obsolete provider failed.",
29037
+ "workflow-result.store-unavailable": "The workflow result store is unavailable, so the provider's result is used.",
29038
+ "catalogue.refresh-failed": "A provider's command catalogue could not be refreshed.",
29039
+ "dispatch.attach-failed": "Attaching an agent before dispatch failed; the prompt request answers authoritatively.",
29040
+ "coordinator-context.ack-failed": "Coordinator repository context could not be acknowledged.",
29041
+ "naming.prepare-failed": "First-prompt naming could not be prepared; the prompt still goes ahead.",
29042
+ "interrupt.persist-failed": "A turn interrupt could not be saved, so automatic publication stays fenced.",
29043
+ "resume.close-replaced-failed": "The session a resume replaced could not be closed.",
29044
+ "sign-in.check-failed": "A turn could not be checked for a login refusal.",
29045
+ "sign-in.resend-failed": "Sending refused prompts after sign-in failed.",
29046
+ "sign-in.prompt-resend-failed": "One refused prompt could not be sent again after sign-in. Error class only.",
29047
+ "shutdown.checkpoints-skipped": "Shutdown skipped display-tail checkpoints; provider history stays authoritative. Count only.",
29048
+ "turn-recovery.failed": "Recovering an incomplete turn failed.",
29049
+ "turn-recovery.exhausted": "A turn failed again after automatic recovery and is left for the user.",
29050
+ "turn-recovery.retrying": "An incomplete or provider-failed turn is being retried automatically.",
29051
+ "usage-limit.resend-failed": "Resending after a usage limit failed. An unknown send stays in the journal.",
29052
+ "title.strategy-failed": "A session title strategy failed, so the next is tried. Content-free: the error can quote the prompt.",
29053
+ ...THROTTLE_LOG_EVENTS
29054
+ }
29055
+ },
29056
+ "native-agent.goal": {
29057
+ description: "The /goal loop: advancing goals and their verifiers.",
29058
+ events: {
29059
+ "advance.failed": "A goal could not advance; the next sweep retries.",
29060
+ "attention.record-failed": "Attention for a goal could not be recorded.",
29061
+ "turn-end.settle-failed": "Turn-end work for a goal could not be settled.",
29062
+ "verifier.finish-failed": "A verifier failed to finish; the goal stays verifying, so the next sweep runs it again.",
29063
+ "verifier.stop-failed": "An earlier verifier could not be stopped.",
29064
+ "recover.failed": "Goals could not be recovered at startup."
29065
+ }
29066
+ },
29067
+ "native-agent.opencode": {
29068
+ description: "The OpenCode provider: its request monitor, retries and agent tools.",
29069
+ events: {
29070
+ "retry.abort-failed": "Aborting an automatic retry failed. Error class only.",
29071
+ "retry.abort-not-scheduled": "An automatic retry abort could not be scheduled. Error class only.",
29072
+ "agent-tools.unavailable": "OpenCode agent tools remain unavailable for a session.",
29073
+ "coordinator-servers.unavailable": "OpenCode coordinator research servers are unavailable.",
29074
+ "monitor.reconnecting": "The request monitor lost its stream and is reconnecting. Error class only.",
29075
+ "worker-limit.reached": "The bounded request workers are full, so the stream restarts and a snapshot reconciles.",
29076
+ "request.failed": "Handling a request event failed, so the stream restarts. Error class only."
29077
+ }
29078
+ }
29079
+ });
29080
+
29081
+ // ../protocol/src/log-vocabulary/preview.ts
29082
+ var PREVIEW_LOG_AREAS = defineLogAreas({
29083
+ preview: {
29084
+ description: "Browser and service previews: transports, partitions and captures.",
29085
+ events: {
29086
+ "attachment.release-failed": "Releasing a preview attachment failed; its lease expires it.",
29087
+ "capture-spool.load-failed": "The pending browser capture spool could not be loaded.",
29088
+ "certificate.refresh-failed": "Re-reading the preview certificate failed; the next check retries.",
29089
+ "certificate.renewal-refused": "A renewed certificate does not cover the preview hosts, so it was ignored.",
29090
+ "connection-cleanup.record-failed": "A forgotten connection's cleanup could not be recorded.",
29091
+ "link.open-external-failed": "A preview link could not be opened in the system browser.",
29092
+ "node.record-failed": "A node that owns preview partitions could not be recorded.",
29093
+ "partition.clear-failed": "A preview partition could not be cleared.",
29094
+ "partitions.record-cleared-failed": "Cleared preview partitions could not be recorded.",
29095
+ "partitions.record-nodes-failed": "The nodes that own preview partitions could not be saved.",
29096
+ "partitions.remove-failed": "Cleared preview partition directories could not be removed.",
29097
+ "partitions.retry-forgotten-failed": "Retrying a forgotten preview cleanup failed.",
29098
+ "port-hints.persist-failed": "Preview port hints could not be saved.",
29099
+ "transport.close-failed": "A preview transport could not be closed.",
29100
+ "ca-bundle.read-failed": "The upstream CA bundle could not be read.",
29101
+ "publication.start-failed": "Private preview publication did not start.",
29102
+ "publication.reconfigure-failed": "Preview publication could not be reconfigured.",
29103
+ "publication.listening": "Private preview origins are listening.",
29104
+ "certificate.reloaded": "The preview certificate was reloaded.",
29105
+ "access.revoked-close-failed": "A revoked preview resource could not be closed. Error class only.",
29106
+ "registry.invalid-definition": "An invalid stored preview service definition was ignored.",
29107
+ "registry.environment-reconcile-failed": "An environment's preview services could not be reconciled.",
29108
+ "registry.resolver-failed": "A preview resolver failed. Error class only.",
29109
+ "registry.revocation-listener-failed": "A preview revocation listener threw. Error class only.",
29110
+ "registry.change-emit-failed": "A preview change event could not be emitted. Error class only.",
29111
+ ...THROTTLE_LOG_EVENTS
29112
+ }
29113
+ }
29114
+ });
29115
+
29116
+ // ../protocol/src/log-vocabulary/runtime.ts
29117
+ var RUNTIME_LOG_AREAS = defineLogAreas({
29118
+ "event-loop": {
29119
+ description: "This process's event loop. A stall of 10 seconds or more is written at error, so no level hides it.",
29120
+ events: {
29121
+ stalled: "A timer fired late, so every request in that window waited."
29122
+ }
29123
+ }
29124
+ });
29125
+
29126
+ // ../protocol/src/log-vocabulary/terminal.ts
29127
+ var TERMINAL_LOG_AREAS = defineLogAreas({
29128
+ terminal: {
29129
+ description: "Terminals. The renderer's lines stay in the browser console; the backend's reach the saved log.",
29130
+ events: {
29131
+ "input.undelivered": "A keystroke did not reach a shell: `no-session` or `not-delivered`.",
29132
+ "orphan.reaped": "A terminal no tab references was closed.",
29133
+ "agent-completion.notify-failed": "A terminal agent's completion could not be reported.",
29134
+ "activity.record-failed": "Terminal environment activity could not be recorded.",
29135
+ "pty.exit-listener-failed": "A terminal exit listener threw; the others still run.",
29136
+ "pty.exit-notify-failed": "Notifying a terminal's exit failed.",
29137
+ "pty.late-exit-listener-failed": "A listener added after a terminal exited threw.",
29138
+ "setup.pty-reused": "A setup terminal reused its existing PTY.",
29139
+ "setup.pty-spawning": "A setup terminal is spawning its PTY. The argument count only, never the arguments.",
29140
+ "setup.pty-spawned": "A setup terminal's PTY started.",
29141
+ "setup.pty-exited": "A setup terminal's PTY exited.",
29142
+ "setup.preparing": "Workspace preparation started in the setup terminal.",
29143
+ "setup.session-creating": "A setup session is being created.",
29144
+ "setup.intro-emitted": "The setup intro was written to the terminal.",
29145
+ "setup.completed": "Setup finished.",
29146
+ "setup.failed": "Setup failed.",
29147
+ "setup.already-complete": "Setup was requested but had already finished.",
29148
+ "setup.renderer-ensured": "The renderer asked for setup to be running.",
29149
+ "setup.renderer-requested": "The renderer asked for the setup session.",
29150
+ "setup.renderer-requested-none": "The renderer asked for a setup session that does not exist.",
29151
+ "setup.no-commands": "An environment has no setup commands to run.",
29152
+ "setup.already-running": "Setup was requested while it was already running.",
29153
+ "setup.held-for-approval": "Setup is held until its commands are approved.",
29154
+ "setup.renderer-checked-session": "The renderer asked whether a setup terminal session exists.",
29155
+ "setup.renderer-requested-buffer": "The renderer asked for a setup terminal's output buffer. A size only, never its contents.",
29156
+ "input.resume-failed": "Asking the backend to resume refused terminal input failed.",
29157
+ "input.write-failed": "Writing input to a terminal session threw.",
29158
+ "listener.remove-failed": "Removing a terminal output listener threw.",
29159
+ "listener.released": "A terminal hook unmounted and dropped its output listener.",
29160
+ "session.unmounted": "A terminal hook unmounted; the shell keeps running.",
29161
+ "connect.called": "A terminal hook began connecting to a session.",
29162
+ "output.reconcile-failed": "Output could not be reconciled against the backend snapshot.",
29163
+ "session.stopped-while-disconnected": "A session ended while its event stream was down.",
29164
+ "session.disconnect-failed": "Closing or detaching a terminal session failed.",
29165
+ "session.resize-failed": "Resizing a terminal session failed, other than for a gone session.",
29166
+ "session.id-stored": "A new backend session id was saved for a terminal tab.",
29167
+ "session-key.environment-missing": "A local session key was built with no environment id.",
29168
+ "clipboard.image-failed": "An image pasted into a terminal could not be saved.",
29169
+ "clipboard.copy-failed": "Copying a terminal selection to the clipboard failed.",
29170
+ "clipboard.paste-failed": "A paste into a terminal failed; `target` says which path.",
29171
+ "clipboard.process-failed": "Reading or storing clipboard data for a paste failed.",
29172
+ "clipboard.image-save-failed": "An image from a paste event could not be written to disk.",
29173
+ "environment.ready-detected": "A first tab's output showed that the workspace is ready.",
29174
+ "shell.ready-detected": "A later tab's output showed that its shell is ready.",
29175
+ "setup.scripts-completed": "A setup tab's scripts reported their end by an escape code.",
29176
+ "setup.marked-complete": "The user marked a setup tab complete by hand.",
29177
+ "setup.awaiting-detection": "A first tab connected and is watching output for readiness.",
29178
+ "reconnect.setup-marker-found": "A reconnected tab's buffer already held the setup marker.",
29179
+ "reconnect.setup-marker-absent": "A reconnected first tab's buffer lacked the setup marker.",
29180
+ "reconnect.completed": "A terminal tab finished reconnecting to its session.",
29181
+ "restore.setup-marker-found": "A restored tab's buffer already held the setup marker.",
29182
+ "persistent-sessions.load-failed": "Listing an environment's saved sessions failed.",
29183
+ "persistent-session.restoring": "A tab began restoring from its saved session.",
29184
+ "persistent-session.found": "A tab found its saved session already recorded.",
29185
+ "persistent-session.creating": "A tab began recording a saved session for the sidebar.",
29186
+ "persistent-session.created": "A saved session for the sidebar was recorded.",
29187
+ "persistent-session.create-failed": "Recording a saved session for the sidebar failed.",
29188
+ "persistent-session.status-update-failed": "Marking a saved session connected failed.",
29189
+ "persistent-session.activity-update-failed": "Updating a saved session's activity failed.",
29190
+ "persistent-buffer.loaded": "A saved session's buffer loaded; only its length is logged.",
29191
+ "persistent-buffer.load-failed": "A saved session's buffer could not be loaded.",
29192
+ "persistent-buffer.save-failed": "Saving a session's buffer during cleanup failed.",
29193
+ "buffer.restore-failed": "Writing a saved buffer back into a terminal threw.",
29194
+ "buffer.serialize-failed": "Serializing a terminal's buffer during cleanup threw.",
29195
+ "command.launching": "A tab began launching its command in a new session.",
29196
+ "bootstrap.failed": "A launch request for a new session failed; it may retry.",
29197
+ "setup-session.bind-failed": "Looking up or binding the backend setup session failed.",
29198
+ "setup-tab.stale-removed": "A setup placeholder tab with no session was removed.",
29199
+ "multi-reviews.restore-failed": "Multi-review tabs could not be restored for an environment.",
29200
+ "pane-layout.restore-failed": "An environment's saved pane layout could not be read.",
29201
+ "pane-layout.history-migrate-failed": "Stripping private browser history fields failed.",
29202
+ "pane-layout.snapshot-remove-failed": "Removing an unusable pane layout snapshot failed.",
29203
+ "pane-layout.selection-migrate-failed": "Saving a migrated legacy pane selection failed.",
29204
+ "panes.reset": "An environment's panes were reset: its container changed or stopped.",
29205
+ "tabs.limit-reached": "A new tab was refused because the tab limit was reached.",
29206
+ "tab.created": "A new tab was added to a pane; `tabType` says which kind.",
29207
+ "tab.activated": "Opening a file selected the tab that already held it.",
29208
+ "tab.duplicate-refused": "A new tab was refused because its requested id is in use.",
29209
+ "tab.multi-review-refused": "A multi-review tab was refused for lack of a workflow id.",
29210
+ "tab.split-at-edge": "A dragged tab split a pane at one of its edges.",
29211
+ "tab.reordered": "A dragged tab moved within its pane.",
29212
+ "tab.moved": "A dragged tab moved to another pane.",
29213
+ "drag.ended": "A tab drag ended, whether or not it landed on a target.",
29214
+ "display.state": "The terminal container's overlays and tab count, on each dev render.",
29215
+ "compose.draft-restore-failed": "A saved compose draft could not be read.",
29216
+ "compose.draft-persist-failed": "A compose draft could not be saved or discarded.",
29217
+ "compose.image-too-large": "A pasted image stayed over the attachment limit after resizing.",
29218
+ "compose.image-add-failed": "Adding a pasted image to the compose bar failed.",
29219
+ "compose.image-save-failed": "Saving one compose image for sending failed; the rest proceed.",
29220
+ "compose.send-failed": "Sending from the compose bar failed.",
29221
+ "init-logs.load-failed": "A container's initialization logs could not be loaded.",
29222
+ "init-logs.refresh-stopped": "A container's initialization logs stopped refreshing.",
29223
+ "portal.terminal-created": "The portal host created a terminal for a new tab.",
29224
+ "portal.terminal-disposed": "The portal host disposed a terminal for a removed tab.",
29225
+ "link.open-failed": "Opening a terminal link in the external browser failed.",
29226
+ "canvas.context-unavailable": "A resize canvas had no 2D context; the original is kept.",
29227
+ ...THROTTLE_LOG_EVENTS
29228
+ }
29229
+ },
29230
+ "terminal.setup": {
29231
+ description: "The renderer attaching a backend-managed environment setup terminal.",
29232
+ events: {
29233
+ "session.bind-from-environment": "The environment hook bound a setup session to a tab.",
29234
+ "setup.started-received": "An environment-setup-started event arrived.",
29235
+ "setup.complete-received": "An environment-setup-complete event arrived.",
29236
+ "attach.state-changed": "A setup tab's attach inputs changed; runs per effect pass.",
29237
+ "terminal.preserve-failed": "Keeping a setup terminal's buffer before conversion failed.",
29238
+ "tab.marker-retired": "A setup tab with no live PTY stopped being a setup tab.",
29239
+ "tab.added": "The backend-managed setup tab was added to a new layout.",
29240
+ "session.bind-skipped": "A setup session lookup was already running for this tab.",
29241
+ "session.requested": "A tab asked the backend for its setup session.",
29242
+ "session.unavailable": "The backend had no setup session to give a tab.",
29243
+ "session.bind-started": "A backend setup session was found and is being bound to a tab.",
29244
+ "session.awaited": "The layout is waiting for a setup session before adding the tab.",
29245
+ "reconcile.started": "The reconcile effect found setup tabs that still need a session.",
29246
+ "reconnect-listener.install-failed": "Listening for event stream reconnects failed.",
29247
+ "layout.initial-decided": "An empty layout was evaluated for its setup tab; runs per effect."
29248
+ }
29249
+ }
29250
+ });
29251
+
29252
+ // ../protocol/src/log-vocabulary/tmux.ts
29253
+ var TMUX_LOG_AREAS = defineLogAreas({
29254
+ tmux: {
29255
+ description: "Claude tmux tabs: launch, the poll loop, cleanup and the tmux prompt queue.",
29256
+ events: {
29257
+ "poll.discovery-failed": "Finding the session's transcript failed; a later tick retries.",
29258
+ "poll.snapshot-failed": "Reading the hook and transcript state failed; the next tick retries.",
29259
+ "poll.drain-pending-failed": "Delivering pending hook events failed; the next tick retries.",
29260
+ "poll.drain-timeouts-failed": "Delivering hook timeouts failed; the next tick retries.",
29261
+ "poll.tail-failed": "Reading new transcript lines failed; the next tick retries.",
29262
+ "cleanup.session-stop-failed": "A tmux session could not be stopped while cleaning up an environment.",
29263
+ "cleanup.skipped": "Environment tmux cleanup was skipped because tmux could not be reached and nothing required it.",
29264
+ "cleanup.environments-load-failed": "Environments could not be loaded during tmux cleanup, so it stays incomplete.",
29265
+ "cleanup.kill-failed": "An environment's tmux sessions could not be killed.",
29266
+ "hooks.uninstall-failed": "Workspace hooks could not be uninstalled.",
29267
+ "hooks.git-exclude-failed": "The git exclude for Claude's local settings could not be set.",
29268
+ "naming.prepare-failed": "First-prompt naming could not be prepared; the prompt still goes ahead.",
29269
+ "orphans.skipped": "Orphan reconciliation was skipped because pane layouts are unreadable.",
29270
+ "orphan.reaped": "A tmux session no tab references was killed.",
29271
+ "orphan.kill-skipped": "An orphan tmux kill was skipped because the tmux server could not be reached.",
29272
+ "cli.thinking-display-probe-failed": "Probing the CLI for --thinking-display failed, so it launches without it.",
29273
+ "cli.fast-mode-unsupported": "The claude CLI lacks --settings, so it launches without fast mode.",
29274
+ "cli.effort-unsupported": "The claude CLI lacks --effort, so it launches without it.",
29275
+ "interactive.snapshot-failed": "An interactive snapshot failed; expected while a pane is closing.",
29276
+ "signal.arm-failed": "The Claude state signal could not be armed.",
29277
+ "signal.degraded": "The Claude state signal missed a change or rang too often, so polling stays at one second until it is re-armed.",
29278
+ "pr-refresh.schedule-failed": "A pull request refresh after a turn could not be scheduled.",
29279
+ "pr-probe.failed": "Probing for a pull request an agent created failed.",
29280
+ "activity.persist-failed": "Tmux tab activity could not be saved.",
29281
+ "fast-mode.persist-failed": "The launch fast mode could not be saved.",
29282
+ "fast-mode.repair-failed": "Fast mode metadata could not be repaired on a reattached session.",
29283
+ "pane.observe-failed": "A pane observation failed. Error class only: pane contents are sensitive.",
29284
+ "turn.failure-record-failed": "A failed turn could not be recorded.",
29285
+ "slash-command.settle-timeout": "Timed out waiting for a Claude slash command to settle.",
29286
+ "queue.failing": "A tmux prompt queue keeps failing to dispatch.",
29287
+ "queue.rename-failed": "An environment could not be named from its first prompt; the prompt still goes ahead.",
29288
+ ...THROTTLE_LOG_EVENTS
29289
+ }
29290
+ }
29291
+ });
29292
+
29293
+ // ../protocol/src/log-vocabulary/updater.ts
29294
+ var UPDATER_LOG_AREAS = defineLogAreas({
29295
+ updater: {
29296
+ description: "Desktop self-update: electron-updater and updates a remote client requested.",
29297
+ events: {
29298
+ "channel.following": "Update checks now follow a different release channel.",
29299
+ "check-report.failed": "A check's result could not be reported.",
29300
+ "check.failed": "An update check failed; the next periodic check retries.",
29301
+ "download.failed": "Downloading or staging an update failed.",
29302
+ downloaded: "An update finished downloading.",
29303
+ "library.message": "One line from electron-updater at its own level. Its debug output, which includes the differential download plan, is off by default.",
29304
+ "remote.check-failed": "A check a remote client requested failed.",
29305
+ "remote.installing": "Installing an update for a remote client.",
29306
+ "remote.read-failed": "Update requests could not be read from the Local backend.",
29307
+ "remote.relaunch-prepare-failed": "Preparing the relaunch after a remote update failed.",
29308
+ "remote.relaunched": "The app relaunched to finish a remote client's update.",
29309
+ "remote.report-failed": "An update report could not reach the Local backend.",
29310
+ "remote.restart-not-recorded": "The backend did not record a restart, so it was not installed.",
29311
+ "remote.unavailable": "Updates requested by remote clients are unavailable in this session.",
29312
+ "restart-prompt.failed": "The restart prompt for a downloaded update failed.",
29313
+ unavailable: "Auto-update could not be set up in this session.",
29314
+ "update.failed": "electron-updater reported an update error.",
29315
+ "standalone.restarting": "A standalone backend is restarting into a new version."
29316
+ }
29317
+ }
29318
+ });
29319
+
29320
+ // ../protocol/src/log-vocabulary/web-annotations.ts
29321
+ var WEB_ANNOTATIONS_LOG_AREAS = defineLogAreas({
29322
+ "web-annotations": {
29323
+ description: "Web annotation requests and their background reconciler.",
29324
+ events: {
29325
+ "reconcile.failed": "A background reconcile pass failed; the next one retries.",
29326
+ "legacy.degraded": "Legacy annotation storage is damaged, so the previous committed copy is served read-only.",
29327
+ "legacy.draft-index-problem": "The legacy draft index could not be used; `status` says why.",
29328
+ "legacy.unreadable-records": "The legacy import found unreadable records; they stay unread.",
29329
+ "legacy.unavailable": "Legacy annotation storage could not be read.",
29330
+ "legacy.unreadable": "An environment's legacy annotation storage is unreadable.",
29331
+ "legacy.archive-failed": "Imported legacy annotation files could not be archived.",
29332
+ "legacy.files-archived": "Legacy files beside an imported environment were archived, not imported.",
29333
+ "migration.draft-failed": "Migrating one draft failed.",
29334
+ "draft-reconcile.deferred": "Draft reconciliation was deferred; a later pass retries.",
29335
+ "request.handoff-deferred": "A request's handoff was deferred; a later pass retries.",
29336
+ "evidence.materialize-failed": "Materializing a request's evidence failed; it backs off and retries.",
29337
+ "queue.publish-deferred": "Publishing a request to the queue was deferred; it retries under the same id.",
29338
+ "request.reconcile-failed": "Reconciling a request failed; the next pass retries.",
29339
+ "turn-end.reconcile-failed": "Reconciling a request at the end of a turn failed; the next pass retries.",
29340
+ "gc.failed": "Annotation garbage collection failed; the next pass retries.",
29341
+ "record.unavailable": "An annotation record is unavailable; written once per record.",
29342
+ "storage.unavailable": "An environment's annotation store is unreadable.",
29343
+ "change-hint.listener-failed": "A change hint listener threw.",
29344
+ "orphan.remove-failed": "An orphaned environment's annotation storage could not be removed.",
29345
+ "storage.load-failed": "An environment's annotation storage could not be loaded.",
29346
+ ...THROTTLE_LOG_EVENTS
29347
+ }
29348
+ }
29349
+ });
29350
+
29351
+ // ../protocol/src/log-vocabulary/storage.ts
29352
+ var STORAGE_LOG_AREAS = defineLogAreas({
29353
+ storage: {
29354
+ description: "The SQLite-backed stores, their snapshots and imports from older formats.",
29355
+ events: {
29356
+ "usage.environment-label-failed": "Usage labels could not be retained for a removed environment; deletion continues.",
29357
+ "snapshot.integrity-failed": "An hourly database snapshot failed its integrity check and was discarded.",
29358
+ "snapshot.skipped-low-disk": "The hourly database snapshot was skipped because the disk lacks room; `retryAt` says when it tries again.",
29359
+ "snapshot.failed": "The hourly database snapshot failed; `retryAt` says when it tries again, if known.",
29360
+ "listener.attention-failed": "An environment attention listener threw; the committed mutation stands.",
29361
+ "listener.change-failed": "A resource change listener threw; the committed mutation stands.",
29362
+ "kanban.image-cleanup-failed": "An orphaned Kanban image could not be removed after its retries; it is safe to remove later.",
29363
+ "nodes.entries-dropped": "Unreadable node registry entries were ignored.",
29364
+ "preview-identity.reminted": "The data directory moved or was copied, so previews get a new backend identity.",
29365
+ "machine-profile.invalid": "The stored machine profile was invalid and the default was restored.",
29366
+ "permission-rules.cleanup-failed": "A deleted project's permission rules could not be removed.",
29367
+ "retired.turn-cleanup-pending": "Cleanup of a retired Looped Review turn did not finish and stays pending.",
29368
+ "handoffs.prune-failed": "Pruning agent handoffs that nothing references failed; a later prune retries.",
29369
+ "desktop-connections.malformed": "Stored desktop connection settings were malformed, so the local connection is used.",
29370
+ "legacy-json.moved": "JSON store files written after the SQLite migration were archived, not imported.",
29371
+ "legacy-json.archive-failed": "Imported JSON store files could not be archived."
29372
+ }
29373
+ }
29374
+ });
29375
+
29376
+ // ../protocol/src/log-vocabulary/build-pipeline.ts
29377
+ var BUILD_PIPELINE_LOG_AREAS = defineLogAreas({
29378
+ "build-pipeline": {
29379
+ description: "Build pipelines: their supervision, stages, transcripts and sidebar state.",
29380
+ events: {
29381
+ "sidebar.reconcile-failed": "Sidebar activity for pipelines could not be reconciled.",
29382
+ "sidebar.update-failed": "The sidebar could not be updated for one pipeline.",
29383
+ "result.consume-deferred": "Consuming a stage's workflow result failed; it stays staged and is retried.",
29384
+ "consolidation.consume-deferred": "Consuming a review consolidation result failed; it stays pending and is retried.",
29385
+ "dispatch.prepare-failed": "Attaching the agent before dispatch failed; the prompt request does the same work and answers authoritatively.",
29386
+ "interaction.resolved": "A human interaction on a pipeline stage resolved. Metadata only.",
29387
+ "transcripts.migrated": "A transcript migration pass moved stage transcripts; counts only.",
29388
+ "transcripts.maintenance-failed": "Migrating or sweeping stage transcripts failed; the next start retries.",
29389
+ "restore.skipped": "A pipeline could not be restored at startup and was skipped.",
29390
+ "criteria.record-failed": "Acceptance criteria results could not be recorded on the ticket.",
29391
+ "workspace.waiting": "A pipeline is waiting for its workspace; written once per reason.",
29392
+ "rewind.pending": "A pipeline's code rewind has not finished; written once per reason.",
29393
+ "kanban.status-failed": "A restarted pipeline's Kanban status could not be set; it retries shortly.",
29394
+ "usage.read-failed": "Reading a stage session's token usage failed.",
29395
+ "checkpoint.deferred": "A stage transcript checkpoint could not be written yet; the provider's history stands.",
29396
+ "checkpoint.not-committed": "A stage transcript checkpoint was reverted in the commit that should have kept it.",
29397
+ "legacy-transcript.deferred": "Moving a legacy inline transcript failed; the inline body stays readable."
29398
+ }
29399
+ }
29400
+ });
29401
+
29402
+ // ../protocol/src/log-vocabulary/agent-branch.ts
29403
+ var AGENT_BRANCH_LOG_AREAS = defineLogAreas({
29404
+ "agent-branch": {
29405
+ description: "Agent branches shared by review fan-outs, graph agents and goal verifiers; `owner` names which.",
29406
+ events: {
29407
+ "observation.checkpoint-failed": "Checkpointing reviewer observations failed; the next pass retries.",
29408
+ "transcript.mirror-failed": "Mirroring a reviewer transcript failed.",
29409
+ "usage.read-failed": "Reading a reviewer's token usage failed.",
29410
+ "result.nudge-failed": "An agent with an uncommitted result could not be nudged.",
29411
+ "dispatch.prepare-failed": "Attaching the agent before dispatch failed; the prompt request answers authoritatively.",
29412
+ "result.consume-deferred": "Consuming a branch's workflow result failed; it stays staged and is retried."
29413
+ }
29414
+ }
29415
+ });
29416
+
29417
+ // ../protocol/src/log-vocabulary/change-tracking.ts
29418
+ var CHANGE_TRACKING_LOG_AREAS = defineLogAreas({
29419
+ "change-tracking": {
29420
+ description: "Change tracking: turn capture, evidence pulls and measurements.",
29421
+ events: {
29422
+ "journal-import.failed": "Importing surviving OpenCode command journals as legacy summaries failed.",
29423
+ "projection.failed": "Projecting a change event onto its environment failed.",
29424
+ "startup.reconcile-failed": "Reconciling change tracking at startup failed.",
29425
+ "turn-start.capture-failed": "Capturing a turn's start failed, so the turn is untracked.",
29426
+ "dispatch.record-failed": "Recording a turn's dispatch outcome failed.",
29427
+ "turn.finalize-failed": "Finalizing a turn failed.",
29428
+ "turn.settle-failed": "Settling a late interrupted turn failed.",
29429
+ "evidence.pull-failed": "Pulling change evidence from a bridge failed; a later pull retries.",
29430
+ "measurement.failed": "Recomputing a tool's measurement failed."
29431
+ }
29432
+ },
29433
+ "diff-stats": {
29434
+ description: "Environment diff stats and the worktree signals that drive them.",
29435
+ events: {
29436
+ "baseline.update-failed": "An environment's diff baseline could not be updated.",
29437
+ "scan.watcher-failed": "An environment's diff watcher failed; its scans fall back to polling.",
29438
+ "scan.failed": "A diff scan failed; the last results stay, marked stale, and the scan is retried.",
29439
+ "scan.freshness-read-failed": "Reading whether an environment's remote is fresh failed.",
29440
+ "scan.listener-failed": "A change-tracking scan listener threw; the scan itself stands.",
29441
+ "emit.diff-stats-failed": "A diff stats change could not be emitted to its sink.",
29442
+ "emit.worktree-snapshot-failed": "A worktree snapshot could not be emitted to its sink.",
29443
+ "signal.demoted": "A worktree signal stopped being trusted, so scans fall back to timers until it is re-armed."
29444
+ }
29445
+ }
29446
+ });
29447
+
29448
+ // ../protocol/src/log-vocabulary/coordinator.ts
29449
+ var COORDINATOR_LOG_AREAS = defineLogAreas({
29450
+ coordinator: {
29451
+ description: "Coordinators: delegations, status wakes and their store.",
29452
+ events: {
29453
+ "delegation.open-failed": "A delegation could not be opened; `source` says for what.",
29454
+ "deliver-now.drain-failed": "The mail delivery pass after deliverNow failed; the next sweep delivers.",
29455
+ "mail.move-failed": "Mail could not move to the new main coordinator.",
29456
+ "work.move-failed": "Work could not move to the main coordinator.",
29457
+ "wake.observe-remote-workflow-failed": "A remote workflow could not be observed for status wakes.",
29458
+ "wake.observe-pull-request-failed": "A pull request could not be observed for status wakes.",
29459
+ "wake.observe-workflow-failed": "A workflow could not be observed for status wakes.",
29460
+ "wake.deliver-failed": "A workflow status wake could not be delivered; the next pass retries.",
29461
+ "wake.waiting-check-failed": "A waiting worker could not be checked; the next pass retries.",
29462
+ "wake.resolve-report-failed": "A finished Resolve tab could not be reported.",
29463
+ "wake.waiting-report-failed": "A waiting worker could not be reported.",
29464
+ "wake.worker-outcomes-failed": "Coordinator-owned workers' merges and deletions could not be checked; the next sweep retries.",
29465
+ "store.malformed": "The coordinator store was malformed and is treated as empty.",
29466
+ "store.unsupported-version": "The coordinator store has an unsupported version and is treated as empty.",
29467
+ "store.invalid-workspace": "An invalid coordinator workspace record was ignored.",
29468
+ "store.workflows-cleared": "The workflow store was full, so a batch of its oldest finished records was removed.",
29469
+ "store.workflows-in-use": "The workflow store was full and every record was still in use, so new work was refused.",
29470
+ "remote-worker.settle-failed": "A remote worker could not be settled."
29471
+ }
29472
+ }
29473
+ });
29474
+
29475
+ // ../protocol/src/log-vocabulary/review.ts
29476
+ var REVIEW_LOG_AREAS = defineLogAreas({
29477
+ review: {
29478
+ description: "Multi Review workflows: scheduling, graph runs and interactive fix sessions.",
29479
+ events: {
29480
+ "fix-tab.publish-failed": "A fix request was delivered but its tab could not be opened; the user is told.",
29481
+ "graph-run.not-started": "A workflow's graph run did not start.",
29482
+ "reconcile.scan-failed": "A reconciliation scan failed; the next scan retries.",
29483
+ "graph-engine.unavailable": "The graph engine is selected but unavailable, so the bespoke engine runs.",
29484
+ "graph-run.cancel-failed": "Cancelling a graph run failed; the next pass projects how it ended.",
29485
+ "delete.cleanup-failed": "A cleanup step after deleting a workflow failed; stale tabs reconcile away on hydration.",
29486
+ "fix-session.read-failed": "Reading an interactive fix session's state failed.",
29487
+ "fix-outcome.read-failed": "Reading an interactive fix's outcome failed; it stays pending.",
29488
+ "fix-usage.read-failed": "Reading a fix session's token usage failed.",
29489
+ "result.consume-deferred": "Consuming a workflow result failed; it stays staged and is retried.",
29490
+ "failure-triage.failed": "Classifying a review package's failing tests failed; the package is sealed without the triage and says so."
29491
+ }
29492
+ },
29493
+ "pull-request": {
29494
+ description: "Pull request monitoring, auto-merge and the `gh` reads behind them.",
29495
+ events: {
29496
+ "merged-state.persist-failed": "A merged pull request's state could not be saved; GitHub stays authoritative and cleanup goes on.",
29497
+ "refresh.failed": "A pull request could not be refreshed; the armed flag stands.",
29498
+ "arm.track-failed": "An armed environment could not be tracked; the monitor's next sync retries.",
29499
+ "gh.pr-list-unparseable": "`gh pr list` returned nothing that parses. Sizes only, never the output.",
29500
+ "monitor.start-failed": "Monitoring could not start for a newly opened pull request.",
29501
+ "cleanup-scheduler.missing": "A merged pull request was seen, but this runtime has no merge cleanup scheduler.",
29502
+ "auto-merge.evaluation-failed": "Evaluating an environment for auto-merge failed.",
29503
+ "auto-merge.merge-failed": "Auto-merge could not merge a pull request; the attempt is held and retried.",
29504
+ "auto-merge.resolve-failed": "Auto-merge could not launch Resolve for a pull request; the attempt is held and retried.",
29505
+ "monitor.detection-failed": "Checking an environment for its pull request failed.",
29506
+ "monitor.detection-admission-failed": "A pull request check could not be admitted to the work pool.",
29507
+ "monitor.terminal-repair-failed": "Repairing a merged or closed pull request's side effects failed.",
29508
+ "monitor.terminal-resume-failed": "Resuming a merged or closed pull request's side effects failed.",
29509
+ "monitor.stale-reading-ignored": "A non-merged reading (`state`) for a pull request already merged was ignored as stale.",
29510
+ "monitor.state-persist-failed": "A pull request's observed state could not be saved.",
29511
+ "monitor.state-clear-failed": "A pull request's saved state could not be cleared.",
29512
+ "monitor.task-reconcile-failed": "Updating the Kanban task of a merged or closed (`state`) pull request failed.",
29513
+ "monitor.task-store-failed": "A pull request could not be recorded on its Kanban task.",
29514
+ "monitor.emit-failed": "A pull request monitor event could not be emitted to its sink."
29515
+ }
29516
+ }
29517
+ });
29518
+
29519
+ // ../protocol/src/log-vocabulary/public-api.ts
29520
+ var PUBLIC_API_LOG_AREAS = defineLogAreas({
29521
+ "public-api": {
29522
+ description: "The public CLI's operations: their outcomes, reconciliation and exec workers.",
29523
+ events: {
29524
+ "outcome.record-failed": "A background operation's outcome could not be recorded; reconciliation settles it.",
29525
+ "goal-checks.stop-failed": "Goal checks could not be stopped.",
29526
+ "exec.list-failed": "Exec workers could not be listed.",
29527
+ "exec.cancel-failed": "An exec could not be cancelled.",
29528
+ "goal-workers.list-failed": "Goal check workers could not be listed.",
29529
+ "operation.reconcile-failed": "Reconciling one operation failed; the next pass retries.",
29530
+ "reconcile.pass-failed": "A reconciliation pass failed; the next one retries."
29531
+ }
29532
+ }
29533
+ });
29534
+
29535
+ // ../protocol/src/log-vocabulary/agent-accounts.ts
29536
+ var AGENT_ACCOUNTS_LOG_AREAS = defineLogAreas({
29537
+ "agent-accounts": {
29538
+ description: "Agent accounts: automatic switching, staged logins and plan usage.",
29539
+ events: {
29540
+ "switch-notice.failed": "A notice about an automatic account switch failed; the switch stands. `audience` says whose.",
29541
+ "auto-switch.check-failed": "An automatic account check failed; the next nudge retries.",
29542
+ "container-sync.failed": "Handing a login or account to a container failed; `step` says which part.",
29543
+ "last-usage.save-failed": "The last plan usage reading could not be saved; the next save retries.",
29544
+ "login-cleanup.failed": "A temporary login could not be cleaned up.",
29545
+ "login-refresh.deferred": "Containers were not told to refresh their login now; they reconcile from its durable generation."
29546
+ }
29547
+ }
29548
+ });
29549
+
29550
+ // ../protocol/src/log-vocabulary/docker.ts
29551
+ var DOCKER_LOG_AREAS = defineLogAreas({
29552
+ docker: {
29553
+ description: "Docker containers: lifecycle, starts, staged inputs and the login files they hold.",
29554
+ events: {
29555
+ "portable-inputs.relay-missing": "Docker is rootless and the image predates the staged-input relay, so the container cannot read them until rebuilt.",
29556
+ "project-seed.refused": "A project .env, .env.local or opencode.json was not copied into a new container: a link, not a regular file, outside the project, too large or unreadable.",
29557
+ "opencode.warm-incomplete": "OpenCode did not finish loading /workspace in a container.",
29558
+ "login-keeper.pass-failed": "A Claude login keeper pass failed; the next interval retries.",
29559
+ "login-keeper.refresh-failed": "Refreshing the host Claude login failed. Fixed text: CLI output can hold credentials.",
29560
+ "login-keeper.refresh-not-extended": "Refreshing the host Claude login did not extend its expiry.",
29561
+ "login-keeper.refresh-check-failed": "Checking the host Claude login after a refresh failed.",
29562
+ "login-watcher.pass-failed": "A container login file watcher pass failed; the next one retries.",
29563
+ "lifecycle.record-failure-failed": "A failed container operation could not be recorded.",
29564
+ "lifecycle.reconcile-failed": "Reconciling one environment's container operation failed; the next pass retries.",
29565
+ "replacement.clear-terminals-failed": "Terminal sessions could not be cleared after a container replacement.",
29566
+ "recovery.clear-terminals-failed": "Terminal sessions could not be cleared after a recovery restore.",
29567
+ "github-ranges.seed-not-copied": "The GitHub ranges seed could not be copied into a container, so its firewall fetches them.",
29568
+ "availability.probe-failed": "Docker is not available; written when the diagnostic changes. Fixed-shape metadata only: messages can hold daemon endpoints.",
29569
+ "start.port-collision-retrying": "An automatic host port collided on start, so it is retried once with fresh ports."
29570
+ }
29571
+ },
29572
+ "docker.reachability": {
29573
+ description: "Whether agents in containers can reach the backend's agent tools server.",
29574
+ events: {
29575
+ "check.crashed": "A reachability check crashed.",
29576
+ "check.started": "A reachability check started.",
29577
+ "check.finished": "A reachability check finished.",
29578
+ "check.probe": "One probe of a finished check.",
29579
+ "check.summary": "Content-free status and reason for a check that did not find the host reachable.",
29580
+ "check.remediation": "One command the user can run to unblock containers.",
29581
+ "shutdown.awaiting-network": "Shutdown is waiting for probe network preparation.",
29582
+ "shutdown.cleanup-deferred": "Probe network cleanup waits until its preparation settles.",
29583
+ "shutdown.removing-resources": "Shutdown is removing probe resources.",
29584
+ "shutdown.container-remove-failed": "A probe container could not be removed at shutdown.",
29585
+ "shutdown.network-remove-failed": "The probe network could not be removed at shutdown.",
29586
+ "probe.skipped": "A container probe was skipped because the agent tools server is not listening.",
29587
+ "preflight.refused": "A stage was refused because its container cannot reach the host.",
29588
+ "probe.prepare-failed": "A container could not be prepared for a probe.",
29589
+ "probe.result": "The outcome of probing one container.",
29590
+ "probe.contradicts-host": "A container probe disagrees with the host status, so the host is rechecked.",
29591
+ "topology.detected": "The Docker topology was read.",
29592
+ "firewall.detected": "The host firewall was read.",
29593
+ "probe-network.remove-failed": "The probe network could not be removed.",
29594
+ "probe-network.create-failed": "The probe network could not be created, so only the default bridge is checked.",
29595
+ "event.emit-failed": "A reachability event could not be emitted.",
29596
+ "host-addresses.list-failed": "Host addresses could not be listed.",
29597
+ "probe-image.present": "The probe image is already present.",
29598
+ "probe-image.pulling": "The probe image is being pulled.",
29599
+ "probe-image.pulled": "The probe image was pulled.",
29600
+ "probe-image.pull-failed": "The probe image could not be pulled.",
29601
+ "probe-image.fallback": "The environment image is used as the probe image.",
29602
+ "probe-image.missing": "No probe image is available.",
29603
+ "network.list-failed": "Docker networks could not be listed.",
29604
+ "network.inspect-failed": "A Docker network could not be inspected.",
29605
+ "stale-containers.removing": "Stale probe containers are being removed.",
29606
+ "stale-networks.removing": "Stale probe networks are being removed."
29607
+ }
29608
+ }
29609
+ });
29610
+
29611
+ // ../protocol/src/log-vocabulary/mcp.ts
29612
+ var MCP_LOG_AREAS = defineLogAreas({
29613
+ "control-mcp": {
29614
+ description: "The Control MCP server other agents and devices reach Orkestrator through.",
29615
+ events: {
29616
+ "listener.port-free": "The Control MCP's fixed port is free again, so it is listening.",
29617
+ "state-listener.failed": "A Control MCP state listener threw; the others still run.",
29618
+ "delegation.remote-open-failed": "A delegation could not be opened on another node.",
29619
+ "delegation.open-failed": "A coordinator delegation could not be opened."
29620
+ }
29621
+ },
29622
+ "mcp-management": {
29623
+ description: "Managed MCP configuration: its commands, overlays and apply loop.",
29624
+ events: {
29625
+ "command.failed": "An MCP management command failed; `ref` is the correlation id shown to the user.",
29626
+ "overlay.materialise-failed": "An MCP overlay could not be written.",
29627
+ "apply.tick-failed": "An MCP apply tick failed; the next one retries."
29628
+ }
29629
+ }
29630
+ });
29631
+
29632
+ // ../protocol/src/log-vocabulary/design.ts
29633
+ var DESIGN_LOG_AREAS = defineLogAreas({
29634
+ design: {
29635
+ description: "The design canvas: its library, renderer and session links.",
29636
+ events: {
29637
+ "change-signal.failed": "A design change signal failed.",
29638
+ "library.index-write-failed": "The design library index could not be written.",
29639
+ "library.refresh-failed": "The design library could not be refreshed.",
29640
+ "renderer.problem": "The renderer hit a limit or lost a browser; `problem` is a fixed name.",
29641
+ "task.failed": "A design background task failed.",
29642
+ "canvas.needs-recovery": "A design canvas is unreadable and marked for recovery.",
29643
+ "startup.step-failed": "One part of design startup failed; `step` says which.",
29644
+ "legacy.retire-failed": "A migrated legacy design could not be retired.",
29645
+ "profiles.swept": "Design startup removed stale browser profiles.",
29646
+ "session-link.record-failed": "A closing conversation could not be recorded on a design link."
29647
+ }
29648
+ }
29649
+ });
29650
+
29651
+ // ../protocol/src/log-vocabulary/graph.ts
29652
+ var GRAPH_LOG_AREAS = defineLogAreas({
29653
+ graph: {
29654
+ description: "Graph runs: launches, passes, rewinds, system actions and templates.",
29655
+ events: {
29656
+ "describe.pass-failed": "A graph describe pass failed. Content-free: never the description or draft.",
29657
+ "system.stop-failed": "A system action's work could not be stopped.",
29658
+ "system.action-failed": "A system action failed; `cause` is its fixed failure cause.",
29659
+ "attention.update-failed": "The sidebar could not be updated for a run.",
29660
+ "launch.ticket-link-failed": "A launched run's ticket could not be linked.",
29661
+ "launch.started": "A graph run was launched.",
29662
+ "launch.swept": "Runs that ended without an environment were removed.",
29663
+ "rewind.pending": "A run's code rewind has not finished.",
29664
+ "rewind.applied": "A run was restarted or rewound.",
29665
+ "rewind.waiting": "A run waits for its code rewind to finish.",
29666
+ "history.pruned": "Finished runs beyond an environment's history were removed.",
29667
+ "history.prune-failed": "Pruning an environment's run history failed.",
29668
+ "worktree.cleanup-failed": "A run's branch worktree cleanup failed.",
29669
+ "run.unreadable": "A run is unreadable, so it is not scheduled.",
29670
+ "run.pass-failed": "A pass over a run failed.",
29671
+ "transcript.capture-failed": "A run's transcript capture failed.",
29672
+ "ticket.link-failed": "A run's ticket could not be linked to its environment.",
29673
+ "template.skipped": "A built-in template was skipped as invalid or a duplicate."
29674
+ }
29675
+ }
29676
+ });
29677
+
29678
+ // ../protocol/src/log-vocabulary/nodes.ts
29679
+ var NODES_LOG_AREAS = defineLogAreas({
29680
+ nodes: {
29681
+ description: "Command nodes: links, handovers, leaf mail and project copies.",
29682
+ events: {
29683
+ "actions.resume-failed": "Approved actions could not be resumed; a later pass retries.",
29684
+ "project-copy.notify-failed": "The coordinator could not be told a project copy finished.",
29685
+ "mail.delivery-deferred": "Leaf mail could not reach a coordinator yet.",
29686
+ "command.post-step-failed": "A step after a routed command failed.",
29687
+ "seed-files.incomplete": "Seed files for a leaf environment were not all copied.",
29688
+ "contact.record-failed": "The latest controller contact could not be recorded.",
29689
+ "settings.send-failed": "Settings could not be sent to a node.",
29690
+ "verification.record-failed": "A node verification could not be recorded.",
29691
+ "profile.record-failed": "A node profile could not be recorded.",
29692
+ "detach.unconfirmed": "A forgotten node has not confirmed the detach yet.",
29693
+ "handover.recovery-pending": "Command handover recovery is still pending."
29694
+ }
29695
+ }
29696
+ });
29697
+
29698
+ // ../protocol/src/log-vocabulary/linear.ts
29699
+ var LINEAR_LOG_AREAS = defineLogAreas({
29700
+ linear: {
29701
+ description: "Linear issues read for build actions.",
29702
+ events: {
29703
+ "comments.load-failed": "An issue's comments could not be loaded; the issue still renders without them."
29704
+ }
29705
+ }
29706
+ });
29707
+
29708
+ // ../protocol/src/log-vocabulary/usage-history.ts
29709
+ var USAGE_HISTORY_LOG_AREAS = defineLogAreas({
29710
+ "usage-history": {
29711
+ description: "Recorded agent token usage.",
29712
+ events: {
29713
+ "record.failed": "Agent usage could not be recorded; a later read counts it.",
29714
+ "prune.failed": "Pruning recorded usage failed; the next prune retries."
29715
+ }
29716
+ }
29717
+ });
29718
+
29719
+ // ../protocol/src/log-vocabulary/feature.ts
29720
+ var FEATURE_LOG_AREAS = defineLogAreas({
29721
+ feature: {
29722
+ description: "Pipeline environments started from a feature, and feature planning.",
29723
+ events: {
29724
+ "naming.fallback": "Automatic naming failed, so a local fallback name is used. Error kind only: the description stays out.",
29725
+ "planning.legacy-adopt-failed": "Legacy planning conversations could not be adopted.",
29726
+ "planning.tick-retrying": "A planning tick failed on a transient error; the next tick retries."
29727
+ }
29728
+ }
29729
+ });
29730
+
29731
+ // ../protocol/src/log-vocabulary/host.ts
29732
+ var HOST_LOG_AREAS = defineLogAreas({
29733
+ host: {
29734
+ description: "The host machine: its executables, load, suspends and maintenance.",
29735
+ events: {
29736
+ "path.discovered": "Executable discovery finished. Counts and booleans only: PATH entries can hold private directory names.",
29737
+ "tool.available": "A host tool's availability was read.",
29738
+ "tool.missing": "A host tool was not found.",
29739
+ "maintenance.listener-failed": "A host maintenance listener threw; the others still run.",
29740
+ "suspend.reconcile-failed": "Reconciling due work after a host suspension failed.",
29741
+ "load.sample-failed": "Sampling machine load failed; the next sample retries."
29742
+ }
29743
+ }
29744
+ });
29745
+
29746
+ // ../protocol/src/log-vocabulary/transcript-artifacts.ts
29747
+ var TRANSCRIPT_ARTIFACTS_LOG_AREAS = defineLogAreas({
29748
+ "transcript-artifacts": {
29749
+ description: "Transcript artifacts: previews, printing, grants and their ledger. Ids, kinds, sizes and reason codes only.",
29750
+ events: {
29751
+ "announce-failed": "An artifact change could not be announced.",
29752
+ "cleanup-failed": "An artifact cleanup failed.",
29753
+ "grant-revocation-failed": "A grant could not be revoked.",
29754
+ "ledger-listener-failed": "A ledger listener threw.",
29755
+ "ledger-read-failed": "The ledger could not be read.",
29756
+ "operation-executor-failed": "A preview operation's executor failed.",
29757
+ "operation-failed": "A preview operation failed.",
29758
+ "pdf-preview": "A PDF preview was served.",
29759
+ "pdf-preview-failed": "A PDF preview failed.",
29760
+ "pdf-print-failed": "Printing an artifact to PDF failed.",
29761
+ "pdf-printed": "An artifact was printed to PDF.",
29762
+ "runtime-unavailable": "The artifact runtime could not be created."
29763
+ }
29764
+ }
29765
+ });
29766
+
29767
+ // ../protocol/src/log-vocabulary/scheduler.ts
29768
+ var SCHEDULER_LOG_AREAS = defineLogAreas({
29769
+ scheduler: {
29770
+ description: "Scheduled jobs and the backend-owned timing that fires them.",
29771
+ events: {
29772
+ "tick.failed": "A scheduler tick failed; the next tick retries.",
29773
+ "job.claim-failed": "A due job could not be claimed.",
29774
+ "fire.heartbeat-failed": "A running fire's heartbeat could not be recorded.",
29775
+ "fire.outcome-record-failed": "A finished fire's outcome could not be recorded."
29776
+ }
29777
+ }
29778
+ });
29779
+
29780
+ // ../protocol/src/log-vocabulary/web-app.ts
29781
+ var WEB_APP_LOG_AREAS = defineLogAreas({
29782
+ "web.app": {
29783
+ description: "The application root: startup checks and restoring state.",
29784
+ events: {
29785
+ "config.load-failed": "The application config could not be loaded.",
29786
+ "docker.check-failed": "A Docker availability probe failed; the result stays unknown.",
29787
+ "docker.checked": "A Docker availability check finished.",
29788
+ "docker.orphans-cleared": "Reconciling with Docker cleared orphaned container references.",
29789
+ "docker.sync-failed": "Reconciling environments with Docker failed; non-fatal.",
29790
+ "prompt-queues.restore-failed": "An environment's prompt queues could not be restored.",
29791
+ "multi-reviews.restore-failed": "An environment's multi reviews could not be restored.",
29792
+ "build-pipelines.migrate-failed": "Migrating legacy build pipelines failed; the next launch retries.",
29793
+ "build-pipelines.restore-failed": "A project's build pipelines could not be restored.",
29794
+ "macos-permissions.check-failed": "Reading macOS file permission status failed.",
29795
+ "cli-check.failed": "One startup CLI check failed; its result stays unknown.",
29796
+ "cli-check.completed": "A startup CLI check finished; one line per tool.",
29797
+ "cli-check.retried": "A user-requested CLI recheck finished.",
29798
+ "cli-check.retry-failed": "A user-requested CLI recheck failed.",
29799
+ "exit.failed": "Exiting through the plugin failed; the window closes instead.",
29800
+ "zoom.native-failed": "Applying native zoom failed; the CSS fallback is used.",
29801
+ "github-cli.status-failed": "Reading the GitHub CLI setup status failed.",
29802
+ "attachments.restore-failed": "Saved prompt attachments could not be restored before startup.",
29803
+ "startup-launch.persist-failed": "Saving the startup agent launch failed; nothing started.",
29804
+ "environment.start-failed": "Starting an environment from the terminal overlay failed.",
29805
+ "project.delete-failed": "Deleting a project from its dialog failed."
29806
+ }
29807
+ },
29808
+ "web.session": {
29809
+ description: "The renderer's terminal and agent session store.",
29810
+ events: {
29811
+ "status.update-failed": "A session status change could not be saved.",
29812
+ "activity.update-failed": "A best-effort session activity update failed.",
29813
+ "environment-sessions.disconnect-failed": "Disconnecting an environment's sessions failed.",
29814
+ "container-sessions.sync-failed": "Syncing sessions with container state failed.",
29815
+ "reorder.failed": "Reordering sessions failed; the list reloads from the backend.",
29816
+ "refresh.manual-failed": "A manual refresh of an agent tab failed."
29817
+ }
29818
+ },
29819
+ "web.action-bar": {
29820
+ description: "The environment action bar.",
29821
+ events: {
29822
+ "editor.open-failed": "The external editor could not be opened.",
29823
+ "run-commands.read-failed": "Reading the project's run commands file failed.",
29824
+ "environment.delete-failed": "Deleting an environment from the action bar failed.",
29825
+ "merge.started": "A user-requested PR merge started.",
29826
+ "merge.completed": "A user-requested PR merge command returned.",
29827
+ "merge.failed": "A user-requested PR merge failed."
29828
+ }
29829
+ }
29830
+ });
29831
+
29832
+ // ../protocol/src/log-vocabulary/web-build-pipeline.ts
29833
+ var WEB_BUILD_PIPELINE_LOG_AREAS = defineLogAreas({
29834
+ "web.build-pipeline": {
29835
+ description: "Build pipelines as the renderer starts, hydrates and shows them.",
29836
+ events: {
29837
+ "build.start-failed": "A build could not be started.",
29838
+ "pipeline.hydrate-failed": "A pipeline read failed; source says who asked for it.",
29839
+ "pipeline.project-mismatch": "A pending tab activation was dropped: wrong project.",
29840
+ "environment.not-found": "A build's environment read returned nothing after creation.",
29841
+ "environment.project-mismatch": "A build's environment was not added: wrong project.",
29842
+ "environment.hydrate-failed": "A build's environment read failed; live sync can recover.",
29843
+ "transcript.load-failed": "A stage transcript read failed and will retry with backoff.",
29844
+ "legacy.state-too-large": "Legacy pipeline state was over the limit and skipped.",
29845
+ "opencode-catalog.load-failed": "The cached OpenCode model list could not be loaded.",
29846
+ "opencode-preferences.load-failed": "OpenCode model preferences could not be loaded."
29847
+ }
29848
+ }
29849
+ });
29850
+
29851
+ // ../protocol/src/log-vocabulary/web-chat.ts
29852
+ var WEB_CHAT_LOG_AREAS = defineLogAreas({
29853
+ "web.chat": {
29854
+ description: "Rendering the agent transcript: messages, rich blocks and question cards.",
29855
+ events: {
29856
+ "message.copy-failed": "A message could not be copied to the clipboard.",
29857
+ "message.long-press-failed": "A user message's long-press action failed.",
29858
+ "message.link-open-failed": "A link in a message could not be opened.",
29859
+ "message.render-failed": "One transcript row failed to render; fields are the bounded diagnostic.",
29860
+ "image-preview.load-failed": "An image in a message could not be loaded for preview.",
29861
+ "session-list.load-failed": "The resume dialog could not fetch the resumable sessions.",
29862
+ "question.submit-failed": "An answer to an agent's question could not be submitted.",
29863
+ "question.dismiss-failed": "An agent's question could not be dismissed.",
29864
+ "rich-block.render-failed": "A rich block's renderer failed and its source is shown instead.",
29865
+ "rich-block.copy-failed": "A rich block's copy action could not write to the clipboard.",
29866
+ "scroll-viewport.not-found": "The scroll viewport was still missing when polling for it ended."
29867
+ }
29868
+ },
29869
+ "web.native-agent": {
29870
+ description: "The native agent tab and its composer.",
29871
+ events: {
29872
+ "model-catalogue.load-failed": "The native model catalogue could not be loaded.",
29873
+ "provider-lock.persist-failed": "The locked agent choice could not be saved.",
29874
+ "compose-draft.persist-failed": "A compose draft could not be saved.",
29875
+ "compose-draft.restore-failed": "A saved compose draft could not be restored.",
29876
+ "compose-draft.discard-failed": "A saved compose draft could not be discarded.",
29877
+ "paste.failed": "Pasting an image into a composer failed unexpectedly.",
29878
+ "agent-state.listen-failed": "Subscribing to a tab's agent state events failed.",
29879
+ "model-favorites.persist-failed": "The favorite model list could not be saved."
29880
+ }
29881
+ }
29882
+ });
29883
+
29884
+ // ../protocol/src/log-vocabulary/web-claude-tmux.ts
29885
+ var WEB_CLAUDE_TMUX_LOG_AREAS = defineLogAreas({
29886
+ "web.claude-tmux": {
29887
+ description: "The renderer's Claude tmux chat tab and interactive terminal.",
29888
+ events: {
29889
+ "sessions.list-failed": "The resume dialog could not list tmux sessions.",
29890
+ "tab.hydrate-failed": "Reading a tab's tmux session from the backend failed.",
29891
+ "models.catalog-unavailable": "The model catalogue failed; the bundled fallback stays.",
29892
+ "queue.promote-failed": "After an interrupt, the next queued prompt did not become the draft.",
29893
+ "files.load-failed": "The file list for @mentions could not be loaded.",
29894
+ "clipboard.image-failed": "An image pasted into the interactive terminal could not be saved.",
29895
+ "terminal.resize-failed": "Resizing the interactive terminal's session failed.",
29896
+ "terminal.recover-failed": "The interactive terminal could not reattach to its session."
29897
+ }
29898
+ }
29899
+ });
29900
+
29901
+ // ../protocol/src/log-vocabulary/web-design.ts
29902
+ var WEB_DESIGN_LOG_AREAS = defineLogAreas({
29903
+ "web.design": {
29904
+ description: "Opening design canvas tabs.",
29905
+ events: {
29906
+ "tab.duplicate-refused": "A design tab was not opened because its id is already in use."
29907
+ }
29908
+ }
29909
+ });
29910
+
29911
+ // ../protocol/src/log-vocabulary/web-environment.ts
29912
+ var WEB_ENVIRONMENT_LOG_AREAS = defineLogAreas({
29913
+ "web.environment": {
29914
+ description: "Environment lifecycle and dialogs as the renderer drives them.",
29915
+ events: {
29916
+ "start.called": "The renderer was asked to start an environment.",
29917
+ "start.unknown-environment": "A start was requested for an id the store does not hold.",
29918
+ "start.snapshot-read": "An environment's state as its start began.",
29919
+ "start.status-set": "The environment was marked as creating before the backend call.",
29920
+ "start.background-requested": "A start is being handed to the backend to run in background.",
29921
+ "start.backend-requested": "A foreground start call to the backend is being made.",
29922
+ "start.backend-completed": "The backend finished a foreground start.",
29923
+ "start.environment-refreshed": "An environment was read back after a foreground start.",
29924
+ "start.worktree-missing": "A local environment started with no worktree path.",
29925
+ "start.failed": "Starting an environment from the renderer failed.",
29926
+ "stop.called": "The renderer was asked to stop an environment.",
29927
+ "stop.status-set": "The environment's status was set while stopping it.",
29928
+ "stop.backend-requested": "A stop call to the backend is being made.",
29929
+ "stop.backend-completed": "The backend finished a stop.",
29930
+ "stop.sessions-disconnecting": "A stopped environment's sessions are being disconnected.",
29931
+ "stop.sessions-disconnected": "A stopped environment's sessions were disconnected.",
29932
+ "stop.failed": "Stopping an environment from the renderer failed.",
29933
+ "restart.failed": "Restarting an environment from the renderer failed.",
29934
+ "status-sync.failed": "An environment's status could not be synced from the backend.",
29935
+ "list.refresh-failed": "A background refresh of a project's environments failed.",
29936
+ "setup-snapshot.reconcile-failed": "An environment's setup state could not be reconciled.",
29937
+ "rename.received": "An environment-renamed event arrived.",
29938
+ "rename.pr-state-cleared": "A rename changed the branch, so stale PR state was cleared.",
29939
+ "unread.clear-failed": "An environment's unread work could not be cleared on the backend.",
29940
+ "create.failed": "Creating an environment from the dialog failed.",
29941
+ "create.port-mappings-invalid": "Creation was refused: a port is not between 1 and 65535.",
29942
+ "create.attachment-read-failed": "A file dropped on the create dialog could not be read.",
29943
+ "auto-start.failed": "A background start after creating an environment was rejected.",
29944
+ "models.pi-seed-failed": "The create dialog could not seed the Pi model catalogue.",
29945
+ "models.opencode-cache-load-failed": "The create dialog could not read cached OpenCode models.",
29946
+ "github-credential.check-failed": "The GitHub credential check before creating failed.",
29947
+ "feature-build.start-failed": "Starting a pipeline environment from the dialog failed.",
29948
+ "settings.extensions-load-failed": "The settings dialog could not load extensions.",
29949
+ "settings.container-reset-failed": "The settings dialog could not reset the container.",
29950
+ "settings.save-failed": "The settings dialog could not save.",
29951
+ "domains.test-failed": "Testing whether network whitelist domains resolve failed.",
29952
+ "network-whitelist.save-failed": "The network whitelist dialog could not save."
29953
+ }
29954
+ },
29955
+ "web.sidebar": {
29956
+ description: "The project and environment sidebar.",
29957
+ events: {
29958
+ "reorder.persist-failed": "A sidebar reorder could not be saved.",
29959
+ "fork.failed": "Forking an environment from the sidebar failed.",
29960
+ "auto-start.started": "Selecting an unstarted local environment is starting it.",
29961
+ "auto-start.failed": "Starting a local environment on selection failed.",
29962
+ "environment.stop-failed": "Stopping a selected environment failed.",
29963
+ "environment.restart-failed": "Restarting a selected environment failed.",
29964
+ "environment.delete-failed": "Deleting an environment from the sidebar failed.",
29965
+ "environments.load-failed": "A project's environments could not be loaded for the sidebar.",
29966
+ "project.add-failed": "Adding a project from the sidebar failed.",
29967
+ "project.create-failed": "Creating a project from scratch failed.",
29968
+ "project.delete-failed": "Deleting a project from the sidebar failed.",
29969
+ "folder.project-remove-failed": "A project could not be removed from its folder.",
29970
+ "folder.rename-failed": "A project folder could not be renamed.",
29971
+ "folder.ungroup-failed": "A project folder could not be removed.",
29972
+ "folder.sort-failed": "A project folder could not be sorted."
29973
+ }
29974
+ },
29975
+ "web.docker": {
29976
+ description: "The Docker settings view.",
29977
+ events: {
29978
+ "data.load-failed": "Container or image data could not be loaded.",
29979
+ "container.stop-failed": "Stopping a container from Docker settings failed.",
29980
+ "container.delete-failed": "Deleting a container from Docker settings failed.",
29981
+ "container.reattach-failed": "Reattaching a container to a project failed."
29982
+ }
29983
+ },
29984
+ "web.project": {
29985
+ description: "Adding a project from the renderer.",
29986
+ events: {
29987
+ "directory-picker.failed": "The directory picker could not be opened.",
29988
+ "git-remote.read-failed": "A chosen directory's git remote could not be read."
29989
+ }
29990
+ }
29991
+ });
29992
+
29993
+ // ../protocol/src/log-vocabulary/web-files.ts
29994
+ var WEB_FILES_LOG_AREAS = defineLogAreas({
29995
+ "web.files": {
29996
+ description: "The files panel, file viewer and file search.",
29997
+ events: {
29998
+ "file.save-failed": "A file could not be saved.",
29999
+ "git-changes.load-failed": "The files panel could not load the git changes.",
30000
+ "file-tree.load-failed": "The file tree could not be loaded.",
30001
+ "changes.refresh-failed": "Refreshing the files panel's changes failed.",
30002
+ "folder.load-failed": "An expanded folder's contents could not be loaded.",
30003
+ "path.copy-failed": "A file's path could not be copied to the clipboard.",
30004
+ "draft.persist-failed": "A file viewer tab's draft could not be saved.",
30005
+ "draft.restore-failed": "A file viewer tab's saved draft could not be restored.",
30006
+ "draft.discard-failed": "A file's saved draft could not be discarded before a reload."
30007
+ }
30008
+ }
30009
+ });
30010
+
30011
+ // ../protocol/src/log-vocabulary/web-github.ts
30012
+ var WEB_GITHUB_LOG_AREAS = defineLogAreas({
30013
+ "web.github": {
30014
+ description: "Pull request and GitHub issue views.",
30015
+ events: {
30016
+ "pull-request.url-failed": "A pull request's URL could not be read.",
30017
+ "pull-request.mode-request-failed": "The pull request monitor refused a watch mode request.",
30018
+ "pull-request.copy-failed": "A pull request value could not be copied to the clipboard.",
30019
+ "comment-edit-draft.clear-failed": "An edited comment's saved draft could not be cleared.",
30020
+ "issue-draft.clear-failed": "An edited issue's saved drafts could not be cleared.",
30021
+ "comment-draft.clear-failed": "A posted comment's draft could not be cleared."
30022
+ }
30023
+ },
30024
+ "web.linear": {
30025
+ description: "The Linear tickets view.",
30026
+ events: {
30027
+ "comment-draft.clear-failed": "A posted comment's draft could not be cleared."
30028
+ }
30029
+ }
30030
+ });
30031
+
30032
+ // ../protocol/src/log-vocabulary/web-kanban.ts
30033
+ var WEB_KANBAN_LOG_AREAS = defineLogAreas({
30034
+ "web.kanban": {
30035
+ description: "The Kanban board, its task dialog and project notes.",
30036
+ events: {
30037
+ "tasks.load-failed": "A project's tasks could not be loaded.",
30038
+ "task.add-failed": "A new task could not be added.",
30039
+ "task.update-failed": "A task's fields could not be updated.",
30040
+ "task.content-update-failed": "A task's content edit could not be saved.",
30041
+ "task.build-status-clear-failed": "A task's build status could not be cleared.",
30042
+ "task.delete-failed": "A task could not be deleted.",
30043
+ "task.move-failed": "A task move failed and its status was rolled back.",
30044
+ "comment.add-failed": "A comment could not be added to a task.",
30045
+ "comment.delete-failed": "A comment could not be deleted from a task.",
30046
+ "image.add-failed": "An image could not be added to a task.",
30047
+ "image.delete-failed": "An image could not be deleted from a task.",
30048
+ "notes.load-failed": "Project notes could not be loaded; the editor stays disabled.",
30049
+ "notes.save-failed": "Project notes could not be saved.",
30050
+ "notes.draft-retained": "A notes save failed; the edit stays in its durable draft.",
30051
+ "draft.restore-failed": "A saved create-task draft could not be restored.",
30052
+ "draft.persist-failed": "A create-task draft could not be saved; phase says when.",
30053
+ "draft.discard-failed": "A create-task draft could not be removed; phase says when.",
30054
+ "build.start-failed": "The task dialog could not start a build for a task.",
30055
+ "build.create-and-start-failed": "The task dialog could not create a task and build it."
30056
+ }
30057
+ },
30058
+ "web.feature-plan": {
30059
+ description: "Feature planning in the renderer.",
30060
+ events: {
30061
+ "features.load-failed": "A project's features could not be loaded.",
30062
+ "feature.create-failed": "A new feature could not be created.",
30063
+ "feature.update-failed": "A feature could not be updated.",
30064
+ "build.claim-failed": "A feature's build could not be claimed for a task.",
30065
+ "build.start-failed": "Starting a build from a feature failed.",
30066
+ "message.append-failed": "A message could not be added to a feature's chat.",
30067
+ "story-message.append-failed": "A message could not be added to a story's chat.",
30068
+ "planning.start-failed": "Feature planning could not be started.",
30069
+ "planning.retry-failed": "Feature planning could not be retried.",
30070
+ "planning.cancel-failed": "Feature planning could not be cancelled.",
30071
+ "drafts.persist-failed": "A project's feature chat drafts could not be saved.",
30072
+ "drafts.restore-failed": "A project's feature chat drafts could not be restored."
30073
+ }
30074
+ }
30075
+ });
30076
+
30077
+ // ../protocol/src/log-vocabulary/web-pane-layout.ts
30078
+ var WEB_PANE_LAYOUT_LOG_AREAS = defineLogAreas({
30079
+ "web.pane-layout": {
30080
+ description: "Panes and tabs in the renderer: moves, splits, teardown and saved layouts.",
30081
+ events: {
30082
+ "persist.failed": "A pane layout could not be written to the backend.",
30083
+ "persist.install-skipped": "A saved layout was not installed: its dependencies did not load.",
30084
+ "persist.settled-handler-failed": "A write-settled handler threw; later handlers still ran.",
30085
+ "environment.activated": "The active environment changed.",
30086
+ "environment.initialized": "An environment's pane state was initialized.",
30087
+ "environment.initialize-skipped": "Initialize was called with no active environment.",
30088
+ "environment.terminals-cleared": "A reset cleared the environment's terminal instances.",
30089
+ "terminal-session.cleanup-started": "A closed tab's terminal session is being cleaned up.",
30090
+ "teardown.pending": "A tab teardown was rejected; the backend keeps it pending and retries.",
30091
+ "browser-preview.destroy-failed": "Destroying a closed browser tab's preview failed.",
30092
+ "handoffs.prune-failed": "Pruning unreferenced agent handoffs failed.",
30093
+ "tab.reactivated": "A tab added twice was activated in its existing pane instead.",
30094
+ "tab.move-started": "A tab move passed its checks and is being applied.",
30095
+ "tab.move-failed": "A tab move was refused; `reason` says which lookup failed.",
30096
+ "tab.initial-prompt-cleared": "A tab's initial prompt was cleared.",
30097
+ "tab.initial-agent-options-cleared": "A tab's initial agent options were cleared.",
30098
+ "pane.split-depth-reached": "A split was refused at the maximum split depth.",
30099
+ "pane.edge-split-started": "An edge split passed its checks and is being applied.",
30100
+ "pane.edge-split-failed": "An edge split was refused; `reason` says which lookup failed.",
30101
+ "pane.close-refused": "Closing the only pane in a layout was refused.",
30102
+ "draft.discard-failed": "A closing tab's draft could not be discarded; the tab stayed open.",
30103
+ "draft.file-conflict-resolve-failed": "Discarding a newer saved file draft failed.",
30104
+ "draft.compose-conflict-resolve-failed": "Discarding a newer saved compose draft failed."
30105
+ }
30106
+ }
30107
+ });
30108
+
30109
+ // ../protocol/src/log-vocabulary/web-settings.ts
30110
+ var WEB_SETTINGS_LOG_AREAS = defineLogAreas({
30111
+ "web.settings": {
30112
+ description: "The settings screens.",
30113
+ events: {
30114
+ "config.save-failed": "Global settings could not be saved.",
30115
+ "config.load-failed": "The settings page could not load the config.",
30116
+ "config.reload-failed": "Re-reading the workspace config after a save failed.",
30117
+ "domains.test-failed": "The domain resolution test could not run.",
30118
+ "github-credentials.propagate-failed": "Propagating GitHub credentials to environments failed.",
30119
+ "credential.save-failed": "A credential could not be saved.",
30120
+ "credential.clear-failed": "A credential could not be cleared.",
30121
+ "gateway-token.save-failed": "The gateway token could not be saved.",
30122
+ "gateway-token.copy-failed": "Copying the gateway token to the clipboard failed.",
30123
+ "web-client-url.copy-failed": "Copying the web client address to the clipboard failed.",
30124
+ "backend-version.read-failed": "The debug tab could not read the backend version.",
30125
+ "messaging.flush-failed": "Saving pending messaging settings on unmount failed.",
30126
+ "directory-picker.failed": "The repository directory picker could not open.",
30127
+ "file-picker.failed": "The repository file picker could not open.",
30128
+ "repository.save-failed": "Repository settings could not be saved.",
30129
+ "model-catalogues.read-failed": "Reading the model catalogues for settings failed."
30130
+ }
30131
+ }
30132
+ });
30133
+
30134
+ // ../protocol/src/log-vocabulary/web-shell.ts
30135
+ var WEB_SHELL_LOG_AREAS = defineLogAreas({
30136
+ "web.startup": {
30137
+ description: "Loading the renderer, after the desktop connection check.",
30138
+ events: {
30139
+ "renderer.load-failed": "Importing or mounting the application failed.",
30140
+ "model-catalogue.restore-failed": "The cached model catalogue could not be restored; bundled fallbacks stay in use."
30141
+ }
30142
+ },
30143
+ "web.window": {
30144
+ description: "Errors nothing in the renderer caught. Bug reports classify these two lines.",
30145
+ events: {
30146
+ "error.unhandled": "A window error event reached the bootstrap handler.",
30147
+ "rejection.unhandled": "A promise rejected with no handler."
30148
+ }
30149
+ },
30150
+ "web.react": {
30151
+ description: "React's root error callbacks and the lazy view boundary.",
30152
+ events: {
30153
+ "root.caught-error": "An error boundary caught a render error.",
30154
+ "root.uncaught-error": "A render error reached the root with no boundary.",
30155
+ "root.recoverable-error": "React recovered from a render error by retrying.",
30156
+ "lazy-view.failed": "A lazily loaded view failed; fields are the bounded diagnostic."
30157
+ }
30158
+ }
30159
+ });
30160
+
30161
+ // ../protocol/src/log-vocabulary/web-sync.ts
30162
+ var WEB_SYNC_LOG_AREAS = defineLogAreas({
30163
+ "web.resource-sync": {
30164
+ description: "Keeping renderer stores current with backend resources.",
30165
+ events: {
30166
+ "handler.threw": "A resource change handler threw; other handlers still ran.",
30167
+ "resync-handler.threw": "A resync handler threw; the resync counts as failed.",
30168
+ "view-safety-check.threw": "A view safety check handler threw; the others still ran.",
30169
+ "snapshots.batch-failed": "A scoped snapshot batch failed; individual reads take over.",
30170
+ "manifest.scoped-check-failed": "The scoped manifest read failed; a full resync runs.",
30171
+ "manifest.check-failed": "The manifest read failed; a full resync runs.",
30172
+ "subscribe.failed": "Subscribing to a resource transport event failed.",
30173
+ "change.malformed": "A resource-changed payload had the wrong shape and was dropped.",
30174
+ "config.refresh-failed": "Refreshing the config store after a change failed.",
30175
+ "pane-layout.refresh-failed": "Refreshing an environment's pane layout failed.",
30176
+ "setup-completion.observe-failed": "Subscribing to setup completion events failed.",
30177
+ "resync.project-failed": "The authoritative project read failed during a store resync.",
30178
+ "resync.environment-failed": "The authoritative environment read failed during a resync.",
30179
+ "resync.read-failed": "One of a store resync's per-environment reads failed.",
30180
+ "resync.pane-failed": "A pane layout read failed during a store resync.",
30181
+ "agent-mail.summary-refresh-failed": "Refreshing the agent mail summary failed.",
30182
+ "agent-mail.mailbox-refresh-failed": "Refreshing one agent mailbox failed.",
30183
+ "prompt-queues.refresh-failed": "Refreshing an environment's prompt queues failed.",
30184
+ "build-pipeline.refresh-failed": "Refreshing one build pipeline failed.",
30185
+ "multi-review.refresh-failed": "Refreshing one multi review workflow failed.",
30186
+ "authoritative.resync-failed": "Re-reading a snapshot after a stream reconnect failed.",
30187
+ "observation.listener-threw": "A native observation invalidation listener threw.",
30188
+ "observation.subscribe-failed": "Subscribing to native observation events failed.",
30189
+ "hydration.status-listener-failed": "A bounded hydration status listener threw.",
30190
+ "hydration.notification-failed": "A bounded hydration change notification threw."
30191
+ }
30192
+ },
30193
+ "web.read-coordinator": {
30194
+ description: "The renderer's coalesced, bounded backend reads.",
30195
+ events: {
30196
+ "listener.threw": "A read state listener threw.",
30197
+ "read.settle-failed": "Applying a finished read's result threw."
30198
+ }
30199
+ },
30200
+ "web.gateway": {
30201
+ description: "The renderer's connection to the gateway: requests and event streams.",
30202
+ events: {
30203
+ "events.disconnected": "The main event stream dropped; it reconnects and replays.",
30204
+ "terminal-stream.disconnected": "A terminal event stream dropped; it reconnects.",
30205
+ "connection-listener.failed": "A main stream connection state listener threw.",
30206
+ "event-listener.failed": "A listener for a gateway event threw.",
30207
+ "stream-listener.failed": "A listener for the stream-connected notice threw."
30208
+ }
30209
+ },
30210
+ "web.federation": {
30211
+ description: "Events from federated nodes as the renderer receives them.",
30212
+ events: {
30213
+ "resync-handler.failed": "A node resync handler failed.",
30214
+ "event-handler.failed": "A handler for an event relayed from a node failed.",
30215
+ "environment.start-failed": "Starting an environment opened in a workspace window failed."
30216
+ }
30217
+ }
30218
+ });
30219
+
30220
+ // ../protocol/src/log-vocabulary/index.ts
30221
+ var LOG_VOCABULARY = {
30222
+ ...AGENT_MAIL_LOG_AREAS,
30223
+ ...BACKEND_LOG_AREAS,
30224
+ ...BRIDGE_LOG_AREAS,
30225
+ ...DESKTOP_LOG_AREAS,
30226
+ ...ENVIRONMENT_LOG_AREAS,
30227
+ ...GATEWAY_LOG_AREAS,
30228
+ ...LOCAL_SERVER_LOG_AREAS,
30229
+ ...GIT_LOG_AREAS,
30230
+ ...LOGGING_LOG_AREAS,
30231
+ ...MODEL_LOG_AREAS,
30232
+ ...NATIVE_AGENT_LOG_AREAS,
30233
+ ...PREVIEW_LOG_AREAS,
30234
+ ...RUNTIME_LOG_AREAS,
30235
+ ...TERMINAL_LOG_AREAS,
30236
+ ...TMUX_LOG_AREAS,
30237
+ ...UPDATER_LOG_AREAS,
30238
+ ...WEB_ANNOTATIONS_LOG_AREAS,
30239
+ ...STORAGE_LOG_AREAS,
30240
+ ...BUILD_PIPELINE_LOG_AREAS,
30241
+ ...AGENT_BRANCH_LOG_AREAS,
30242
+ ...CHANGE_TRACKING_LOG_AREAS,
30243
+ ...COORDINATOR_LOG_AREAS,
30244
+ ...REVIEW_LOG_AREAS,
30245
+ ...PUBLIC_API_LOG_AREAS,
30246
+ ...AGENT_ACCOUNTS_LOG_AREAS,
30247
+ ...DOCKER_LOG_AREAS,
30248
+ ...MCP_LOG_AREAS,
30249
+ ...DESIGN_LOG_AREAS,
30250
+ ...GRAPH_LOG_AREAS,
30251
+ ...NODES_LOG_AREAS,
30252
+ ...LINEAR_LOG_AREAS,
30253
+ ...USAGE_HISTORY_LOG_AREAS,
30254
+ ...FEATURE_LOG_AREAS,
30255
+ ...HOST_LOG_AREAS,
30256
+ ...TRANSCRIPT_ARTIFACTS_LOG_AREAS,
30257
+ ...SCHEDULER_LOG_AREAS,
30258
+ ...WEB_APP_LOG_AREAS,
30259
+ ...WEB_BUILD_PIPELINE_LOG_AREAS,
30260
+ ...WEB_CHAT_LOG_AREAS,
30261
+ ...WEB_CLAUDE_TMUX_LOG_AREAS,
30262
+ ...WEB_DESIGN_LOG_AREAS,
30263
+ ...WEB_ENVIRONMENT_LOG_AREAS,
30264
+ ...WEB_FILES_LOG_AREAS,
30265
+ ...WEB_GITHUB_LOG_AREAS,
30266
+ ...WEB_KANBAN_LOG_AREAS,
30267
+ ...WEB_PANE_LAYOUT_LOG_AREAS,
30268
+ ...WEB_SETTINGS_LOG_AREAS,
30269
+ ...WEB_SHELL_LOG_AREAS,
30270
+ ...WEB_SYNC_LOG_AREAS
30271
+ };
30272
+
30273
+ // ../protocol/src/logger.ts
30274
+ var LOG_LEVELS = ["error", "warn", "info", "debug", "trace"];
30275
+ var MAX_FIELD_CHARS = 2048;
30276
+ var TRUNCATION_MARKER_RESERVE = 32;
30277
+ var MAX_FIELDS = 32;
30278
+ var FIELD_NAME_PATTERN = /^[A-Za-z][\w.-]{0,63}$/;
30279
+ var BARE_TEXT_VALUE = /^[\w./:@+,~-]+$/;
30280
+ var THROTTLE_KIND_PATTERN = /^[\w.:-]{1,64}$/;
30281
+ var MAX_THROTTLE_SCOPE_CHARS = 128;
30282
+ var FORBIDDEN_FIELD_NAMES = new Set([
30283
+ "stdout",
30284
+ "stderr",
30285
+ "cmd",
30286
+ "spawnargs",
30287
+ "prompt",
30288
+ "token",
30289
+ "password",
30290
+ "secret",
30291
+ "authorization",
30292
+ "apikey",
30293
+ "cookie",
30294
+ "credentials"
30295
+ ]);
30296
+ var LEVEL_RANK = {
30297
+ error: 0,
30298
+ warn: 1,
30299
+ info: 2,
30300
+ debug: 3,
30301
+ trace: 4
30302
+ };
30303
+ var OUTPUT_METHOD = {
30304
+ error: "error",
30305
+ warn: "warn",
30306
+ info: "info",
30307
+ debug: "debug",
30308
+ trace: "debug"
30309
+ };
30310
+ var consoleSink = ({ method, line }) => {
30311
+ console[method](line);
30312
+ };
30313
+ var DEFAULT_CONFIG = {
30314
+ level: "info",
30315
+ areaLevels: {},
30316
+ format: "text",
30317
+ sink: consoleSink
30318
+ };
30319
+ var config2 = DEFAULT_CONFIG;
30320
+ var generation = 0;
30321
+ function configureLogger(change) {
30322
+ config2 = { ...config2, ...change };
30323
+ generation += 1;
30324
+ }
30325
+ function isLogLevel(value) {
30326
+ return typeof value === "string" && LOG_LEVELS.includes(value);
30327
+ }
30328
+ function areaSpec(area) {
30329
+ return Object.hasOwn(LOG_VOCABULARY, area) ? LOG_VOCABULARY[area] : undefined;
30330
+ }
30331
+ function thresholdRank(area) {
30332
+ for (let scope = area;; scope = scope.slice(0, scope.lastIndexOf("."))) {
30333
+ const level = Object.hasOwn(config2.areaLevels, scope) ? config2.areaLevels[scope] : undefined;
30334
+ if (level)
30335
+ return LEVEL_RANK[level];
30336
+ if (!scope.includes("."))
30337
+ return LEVEL_RANK[config2.level];
30338
+ }
30339
+ }
30340
+ function boundedString(value, maxChars) {
30341
+ if (value.length <= maxChars)
30342
+ return value;
30343
+ const kept = maxChars - TRUNCATION_MARKER_RESERVE;
30344
+ return `${value.slice(0, kept)}...[truncated ${value.length - kept} chars]`;
30345
+ }
30346
+ function sanitizeValue(name, value, maxChars) {
30347
+ if (FORBIDDEN_FIELD_NAMES.has(name.toLowerCase().replace(/[-_.]/g, "")))
30348
+ return "[forbidden]";
30349
+ switch (typeof value) {
30350
+ case "string":
30351
+ return boundedString(value, maxChars);
30352
+ case "number":
30353
+ return Number.isFinite(value) ? value : String(value);
30354
+ case "boolean":
30355
+ return value;
30356
+ case "undefined":
30357
+ return;
30358
+ case "bigint":
30359
+ return value.toString();
30360
+ case "object":
30361
+ if (value === null)
30362
+ return null;
30363
+ if (isSafeLogError(value))
30364
+ return value;
30365
+ if (value instanceof Error)
30366
+ return formatLogError(value);
30367
+ return "[rejected:object]";
30368
+ default:
30369
+ return `[rejected:${typeof value}]`;
30370
+ }
30371
+ }
30372
+ function sanitizeFields(fields, maxChars) {
30373
+ const clean = {};
30374
+ let count = 0;
30375
+ let dropped = 0;
30376
+ for (const name of Object.keys(fields)) {
30377
+ const value = sanitizeValue(name, fields[name], maxChars);
30378
+ if (value === undefined)
30379
+ continue;
30380
+ if (count >= MAX_FIELDS || !FIELD_NAME_PATTERN.test(name)) {
30381
+ dropped += 1;
30382
+ continue;
30383
+ }
30384
+ clean[name] = value;
30385
+ count += 1;
30386
+ }
30387
+ if (dropped > 0)
30388
+ clean.droppedFields = dropped;
30389
+ return count > 0 || dropped > 0 ? clean : undefined;
30390
+ }
30391
+ function textValue(value) {
30392
+ if (typeof value !== "string")
30393
+ return String(value);
30394
+ return BARE_TEXT_VALUE.test(value) ? value : JSON.stringify(value);
30395
+ }
30396
+ function appendTextField(parts, name, value) {
30397
+ if (typeof value !== "object" || value === null) {
30398
+ parts.push(`${name}=${textValue(value)}`);
30399
+ return;
30400
+ }
30401
+ for (const key of Object.keys(value)) {
30402
+ const entry = value[key];
30403
+ if (entry === undefined)
30404
+ continue;
30405
+ if (key === "cause")
30406
+ appendTextField(parts, `${name}.cause`, entry);
30407
+ else if (key === "stack")
30408
+ parts.push(`${name}.stack=${textValue(entry.join(" | "))}`);
30409
+ else
30410
+ parts.push(`${name}.${key}=${textValue(entry)}`);
30411
+ }
30412
+ }
30413
+ function escapeLogLine(line) {
30414
+ return line.replace(/[\u007f-\u009f\u2028\u2029]/g, (character) => `\\u${character.charCodeAt(0).toString(16).padStart(4, "0")}`);
30415
+ }
30416
+ function renderText(record) {
30417
+ const tag = areaSpec(record.area)?.tag ?? record.area;
30418
+ const parts = [`[${tag}]`, record.event];
30419
+ if (record.fields) {
30420
+ for (const name of Object.keys(record.fields))
30421
+ appendTextField(parts, name, record.fields[name]);
30422
+ }
30423
+ return escapeLogLine(parts.join(" "));
30424
+ }
30425
+ function renderJson(record) {
30426
+ return escapeLogLine(JSON.stringify(record));
30427
+ }
30428
+ function deliver(record) {
30429
+ try {
30430
+ config2.sink({
30431
+ method: OUTPUT_METHOD[record.level],
30432
+ line: config2.format === "json" ? renderJson(record) : renderText(record),
30433
+ record
27956
30434
  });
27957
- while (this.notices.size > MAX_RUNTIME_NOTICES) {
27958
- const oldest = this.notices.keys().next().value;
27959
- if (oldest === undefined)
27960
- break;
27961
- this.notices.delete(oldest);
27962
- }
30435
+ return true;
30436
+ } catch {
30437
+ return false;
27963
30438
  }
27964
- drift() {
27965
- if (this.unknownEvents === 0)
27966
- return;
27967
- return { unknownEvents: this.unknownEvents, unknownKinds: [...this.kinds] };
30439
+ }
30440
+ function buildRecord(level, area, event, fields) {
30441
+ const clean = fields ? sanitizeFields(fields, areaSpec(area)?.maxStringChars ?? MAX_FIELD_CHARS) : undefined;
30442
+ return {
30443
+ orklog: 1,
30444
+ ts: new Date().toISOString(),
30445
+ level,
30446
+ area,
30447
+ event,
30448
+ ...clean ? { fields: clean } : {}
30449
+ };
30450
+ }
30451
+ var LOG_THROTTLE_WINDOW_MS = 60000;
30452
+ var LOG_THROTTLE_MAX_KEYS = 512;
30453
+ var LOG_THROTTLE_IDLE_MS = 5 * LOG_THROTTLE_WINDOW_MS;
30454
+ var throttledSites = new Map;
30455
+ var throttledKeyCount = 0;
30456
+ var throttleRecency = 0;
30457
+ var throttleGeneration = generation;
30458
+ var nextThrottleFlushAt = 0;
30459
+ function writeThrottleLine(site, event, fields) {
30460
+ const spec = areaSpec(site.area);
30461
+ if (!spec)
30462
+ return;
30463
+ const listed = Object.hasOwn(spec.events, event);
30464
+ const line = { site: site.event, ...site.scope === undefined ? {} : { scope: site.scope } };
30465
+ deliver(buildRecord(site.level, site.area, listed ? event : "invalid-event", listed ? { ...line, ...fields } : undefined));
30466
+ }
30467
+ function syncThrottleLevels() {
30468
+ if (throttleGeneration === generation)
30469
+ return;
30470
+ throttleGeneration = generation;
30471
+ for (const [siteKey, site] of Array.from(throttledSites)) {
30472
+ if (LEVEL_RANK[site.level] <= thresholdRank(site.area))
30473
+ continue;
30474
+ throttledSites.delete(siteKey);
30475
+ throttledKeyCount -= site.keys.size;
27968
30476
  }
27969
- listNotices() {
27970
- return [...this.notices.values()];
30477
+ }
30478
+ function rollThrottleWindow(site, kind, key, now) {
30479
+ const elapsed = now - key.windowStart;
30480
+ if (elapsed >= 0 && elapsed < LOG_THROTTLE_WINDOW_MS)
30481
+ return;
30482
+ if (key.pending > 0) {
30483
+ writeThrottleLine(site, "throttle.suppressed", {
30484
+ kind,
30485
+ suppressed: key.pending,
30486
+ windowSeconds: Math.max(0, Math.round(elapsed / 1000))
30487
+ });
27971
30488
  }
27972
- advisories(limit = 5) {
27973
- return [...this.notices.values()].filter((notice) => notice.severity === "error").slice(-limit).map((notice) => ({
27974
- message: notice.message,
27975
- severity: "error"
27976
- }));
30489
+ key.pending = 0;
30490
+ key.windowStart = now;
30491
+ }
30492
+ function flushDueThrottleWindows(now) {
30493
+ if (now < nextThrottleFlushAt && nextThrottleFlushAt - now <= LOG_THROTTLE_WINDOW_MS)
30494
+ return;
30495
+ nextThrottleFlushAt = now + LOG_THROTTLE_WINDOW_MS;
30496
+ for (const site of throttledSites.values()) {
30497
+ for (const [kind, key] of site.keys)
30498
+ rollThrottleWindow(site, kind, key, now);
27977
30499
  }
27978
- snapshot() {
27979
- const drift = this.drift();
27980
- return { ...drift ? { drift } : {}, notices: this.listNotices() };
30500
+ }
30501
+ function evictOldestThrottleKey() {
30502
+ let oldest;
30503
+ for (const [siteKey, site] of throttledSites) {
30504
+ for (const [kind, key] of site.keys) {
30505
+ if (!oldest || key.recency < oldest.key.recency)
30506
+ oldest = { siteKey, site, kind, key };
30507
+ }
27981
30508
  }
27982
- reset() {
27983
- this.unknownEvents = 0;
27984
- this.kinds.clear();
27985
- this.notices.clear();
30509
+ if (!oldest)
30510
+ return;
30511
+ const { siteKey, site, kind, key } = oldest;
30512
+ writeThrottleLine(site, "throttle.evicted", { kind, suppressed: key.pending });
30513
+ site.keys.delete(kind);
30514
+ throttledKeyCount -= 1;
30515
+ if (site.keys.size === 0)
30516
+ throttledSites.delete(siteKey);
30517
+ }
30518
+ function throttleSiteKey(area, event, scope) {
30519
+ return `${area}\x00${event}\x00${scope ?? ""}`;
30520
+ }
30521
+ function noteThrottledFailure(area, level, event, scope, kind) {
30522
+ const now = Date.now();
30523
+ flushDueThrottleWindows(now);
30524
+ const siteKey = throttleSiteKey(area, event, scope);
30525
+ let site = throttledSites.get(siteKey);
30526
+ let known = site?.keys.get(kind);
30527
+ if (known && now - known.lastFailureAt >= LOG_THROTTLE_IDLE_MS) {
30528
+ site.keys.delete(kind);
30529
+ throttledKeyCount -= 1;
30530
+ if (site.keys.size === 0) {
30531
+ throttledSites.delete(siteKey);
30532
+ site = undefined;
30533
+ }
30534
+ known = undefined;
30535
+ }
30536
+ if (!known && throttledKeyCount >= LOG_THROTTLE_MAX_KEYS) {
30537
+ evictOldestThrottleKey();
30538
+ site = throttledSites.get(siteKey);
30539
+ }
30540
+ site ??= { area, event, scope, level, since: now, failures: 0, keys: new Map };
30541
+ site.level = level;
30542
+ site.failures += 1;
30543
+ throttledSites.delete(siteKey);
30544
+ throttledSites.set(siteKey, site);
30545
+ if (known) {
30546
+ rollThrottleWindow(site, kind, known, now);
30547
+ known.pending += 1;
30548
+ known.lastFailureAt = now;
30549
+ known.recency = ++throttleRecency;
30550
+ site.keys.delete(kind);
30551
+ site.keys.set(kind, known);
30552
+ return false;
27986
30553
  }
30554
+ site.keys.set(kind, {
30555
+ pending: 0,
30556
+ windowStart: now,
30557
+ lastFailureAt: now,
30558
+ recency: ++throttleRecency
30559
+ });
30560
+ throttledKeyCount += 1;
30561
+ return true;
27987
30562
  }
27988
- function emptyRuntimeHealth() {
27989
- return { summary: {}, notices: [] };
30563
+ function noteThrottledSuccess(area, event, scope) {
30564
+ const now = Date.now();
30565
+ flushDueThrottleWindows(now);
30566
+ const siteKey = throttleSiteKey(area, event, scope);
30567
+ const site = throttledSites.get(siteKey);
30568
+ if (!site)
30569
+ return;
30570
+ throttledSites.delete(siteKey);
30571
+ throttledKeyCount -= site.keys.size;
30572
+ let suppressed = 0;
30573
+ for (const key of site.keys.values())
30574
+ suppressed += key.pending;
30575
+ writeThrottleLine(site, "throttle.recovered", {
30576
+ failures: site.failures,
30577
+ kinds: site.keys.size,
30578
+ suppressed,
30579
+ faultSeconds: Math.max(0, Math.round((now - site.since) / 1000))
30580
+ });
30581
+ }
30582
+ function throttleKind(options) {
30583
+ if (options.kind === undefined)
30584
+ return logErrorKind(options.error);
30585
+ return THROTTLE_KIND_PATTERN.test(options.kind) ? options.kind : "invalid-kind";
30586
+ }
30587
+ function resolveFields(fields) {
30588
+ try {
30589
+ return typeof fields === "function" ? fields() : fields;
30590
+ } catch {
30591
+ return { fieldsFailed: true };
30592
+ }
27990
30593
  }
27991
-
27992
- // ../../bridges/cursor-bridge/src/session-factory.ts
27993
- function newSessionState(clientSessionKey, policy) {
30594
+ function deliverEvent(level, area, event, fields) {
30595
+ const spec = areaSpec(area);
30596
+ if (!spec)
30597
+ return deliver(buildRecord(level, "logging", "unknown-area", undefined));
30598
+ if (!Object.hasOwn(spec.events, event))
30599
+ return deliver(buildRecord(level, area, "invalid-event", undefined));
30600
+ return deliver(buildRecord(level, area, event, fields));
30601
+ }
30602
+ function tryWriteLog(level, area, event, fields) {
30603
+ if (LEVEL_RANK[level] > thresholdRank(area))
30604
+ return false;
30605
+ return deliverEvent(level, area, event, resolveFields(fields));
30606
+ }
30607
+ function createLogger(area) {
30608
+ const spec = areaSpec(area);
30609
+ let seenGeneration = -1;
30610
+ let rank = 0;
30611
+ const enabled = (level) => {
30612
+ if (seenGeneration !== generation) {
30613
+ seenGeneration = generation;
30614
+ rank = thresholdRank(area);
30615
+ }
30616
+ return LEVEL_RANK[level] <= rank;
30617
+ };
30618
+ const writeResolved = (level, event, resolved) => {
30619
+ deliverEvent(level, area, event, resolved);
30620
+ };
30621
+ const write = (level, event, fields) => {
30622
+ if (!enabled(level))
30623
+ return;
30624
+ writeResolved(level, event, resolveFields(fields));
30625
+ };
27994
30626
  return {
27995
- id: randomBytes3(16).toString("hex"),
27996
- ...policy ? { policy } : {},
27997
- ...clientSessionKey ? { clientSessionKey } : {},
27998
- status: "idle",
27999
- messages: [],
28000
- droppedMessages: 0,
28001
- droppedParts: 0,
28002
- transcriptTruncated: false,
28003
- revision: 0,
28004
- structured: new Map,
28005
- promptJournal: new Map,
28006
- steerJournal: new Map,
28007
- steerJournalBytes: 0,
28008
- activeSubagentDescriptors: new Map,
28009
- subagentLimitExceeded: false,
28010
- todos: [],
28011
- composer: emptyComposer(),
28012
- agent: null,
28013
- dispatching: false,
28014
- promptSequence: 0,
28015
- openTextParts: new Map,
28016
- uncheckedTranscriptBytes: 0,
28017
- currentTurnOutput: null,
28018
- lastAccessed: Date.now(),
28019
- observedMcpTools: new Set,
28020
- health: new RuntimeHealthRecorder
30627
+ error: (event, fields) => write("error", event, fields),
30628
+ warn: (event, fields) => write("warn", event, fields),
30629
+ info: (event, fields) => write("info", event, fields),
30630
+ debug: (event, fields) => write("debug", event, fields),
30631
+ trace: (event, fields) => write("trace", event, fields),
30632
+ throttled: (level, event, options) => {
30633
+ syncThrottleLevels();
30634
+ if (!enabled(level))
30635
+ return;
30636
+ if (!spec || !Object.hasOwn(spec.events, event) || event.startsWith("throttle.") || !Object.hasOwn(spec.events, "throttle.recovered")) {
30637
+ deliver(buildRecord(level, spec ? area : "logging", spec ? "invalid-event" : "unknown-area", undefined));
30638
+ return;
30639
+ }
30640
+ const kind = throttleKind(options);
30641
+ const scope = options.scope?.slice(0, MAX_THROTTLE_SCOPE_CHARS);
30642
+ if (!noteThrottledFailure(area, level, event, scope, kind))
30643
+ return;
30644
+ writeResolved(level, event, {
30645
+ ...scope === undefined ? {} : { scope },
30646
+ kind,
30647
+ ...resolveFields(options.fields)
30648
+ });
30649
+ },
30650
+ recovered: (event, scope) => {
30651
+ syncThrottleLevels();
30652
+ if (throttledKeyCount === 0)
30653
+ return;
30654
+ noteThrottledSuccess(area, event, scope?.slice(0, MAX_THROTTLE_SCOPE_CHARS));
30655
+ },
30656
+ isEnabled: enabled
28021
30657
  };
28022
30658
  }
28023
30659
 
28024
30660
  // ../../bridges/cursor-bridge/src/persistence.ts
30661
+ var log = createLogger("bridge.cursor");
28025
30662
  var tail = Promise.resolve();
28026
30663
  var pending;
28027
30664
  var pendingFailureHooks;
@@ -28267,7 +30904,11 @@ function noteFailure(error) {
28267
30904
  failing = failing ? { key, failures: failing.failures + 1, noticed: failing.noticed } : { key, failures: 1, noticed: new WeakMap };
28268
30905
  const errno = error?.code;
28269
30906
  const offenders = new Set(typed.sessionIds);
28270
- console.warn(`[cursor-bridge] state publication failing (${typed.code}${typeof errno === "string" ? `, ${errno.slice(0, 32)}` : ""}${offenders.size > 0 ? `; ${offenders.size} largest session(s) marked` : ""}); new prompts and steers are refused until it recovers`);
30907
+ log.warn("state.publication-failing", {
30908
+ code: typed.code,
30909
+ errno: typeof errno === "string" ? errno.slice(0, 32) : undefined,
30910
+ largestSessionsMarked: offenders.size
30911
+ });
28271
30912
  for (const state of sessions.values()) {
28272
30913
  const offender = offenders.has(state.id);
28273
30914
  const message = offender ? LARGEST_SESSION_NOTICE : typed.message;
@@ -28287,14 +30928,14 @@ function noteFailure(error) {
28287
30928
  var LARGEST_SESSION_NOTICE = "This session's saved state (structured results and prompt records) is among the largest keeping the Cursor bridge from saving. Close this tab, or other unused Cursor tabs, to free space.";
28288
30929
  function noteSuccess(shed) {
28289
30930
  if (failing) {
28290
- console.warn(`[cursor-bridge] state publication recovered after ${failing.failures} failed write(s)`);
30931
+ log.info("state.publication-recovered", { failedWrites: failing.failures });
28291
30932
  failing = undefined;
28292
30933
  }
28293
30934
  const newlyShed = shed.filter((id) => !lastShed.has(id));
28294
30935
  lastShed = new Set(shed);
28295
30936
  if (newlyShed.length === 0)
28296
30937
  return;
28297
- console.warn(`[cursor-bridge] state file at its size limit; saved ${newlyShed.length} session(s) with a shortened transcript copy`);
30938
+ log.warn("state.transcripts-shortened", { sessions: newlyShed.length });
28298
30939
  for (const id of newlyShed) {
28299
30940
  sessions.get(id)?.health.recordNotice({
28300
30941
  message: "The saved copy of this transcript keeps only its newest messages, to keep bridge state within its size limit. The conversation itself is kept; a bridge restart shows the transcript as truncated.",
@@ -28588,6 +31229,7 @@ async function withTimeout2(work, timeoutMs) {
28588
31229
  }
28589
31230
 
28590
31231
  // ../../bridges/cursor-bridge/src/session-tombstones.ts
31232
+ var log2 = createLogger("bridge.cursor");
28591
31233
  async function closeRestoredTombstone(id, ackTimeoutMs = CLOSE_ACK_TIMEOUT_MS) {
28592
31234
  if (!closingTombstones.has(id) && !tombstoneCloses.has(id))
28593
31235
  return "closed";
@@ -28671,7 +31313,7 @@ async function finishRestoredTombstones() {
28671
31313
  };
28672
31314
  await Promise.all(Array.from({ length: STARTUP_TOMBSTONE_CONCURRENCY }, worker));
28673
31315
  if (result.pending > 0 || result.failed > 0) {
28674
- console.warn(`[cursor-bridge] ${result.pending + result.failed} restored close(s) could not finish at startup; a retried close finishes them`);
31316
+ log2.warn("startup.closes-incomplete", { closes: result.pending + result.failed });
28675
31317
  }
28676
31318
  return result;
28677
31319
  }
@@ -28692,7 +31334,7 @@ async function withBudget(work, timeoutMs) {
28692
31334
  }
28693
31335
 
28694
31336
  // ../protocol/src/node/cursor-plan-usage.ts
28695
- import { Buffer as Buffer3 } from "node:buffer";
31337
+ import { Buffer as Buffer4 } from "node:buffer";
28696
31338
  var MIN_PLAUSIBLE_EPOCH_MS = Date.UTC(2020, 0, 1);
28697
31339
  var MAX_PLAUSIBLE_EPOCH_MS = Date.UTC(2100, 0, 1);
28698
31340
  var CURSOR_API_BASE = "https://api2.cursor.sh";
@@ -28785,7 +31427,7 @@ function jwtExpiryMs(token) {
28785
31427
  if (!payload)
28786
31428
  return;
28787
31429
  try {
28788
- const parsed = record2(JSON.parse(Buffer3.from(payload, "base64url").toString("utf8")));
31430
+ const parsed = record2(JSON.parse(Buffer4.from(payload, "base64url").toString("utf8")));
28789
31431
  const expirySeconds = finiteNumber(parsed?.exp);
28790
31432
  return expirySeconds === undefined ? undefined : expirySeconds * 1000;
28791
31433
  } catch {
@@ -28914,7 +31556,19 @@ import {
28914
31556
 
28915
31557
  // ../protocol/src/node/bridge-diagnostics.ts
28916
31558
  import { createHash as createHash2 } from "node:crypto";
28917
- var INTERVAL_MS = 60000;
31559
+
31560
+ // ../protocol/src/event-loop-stall-monitor.ts
31561
+ var log3 = createLogger("event-loop");
31562
+ var EVENT_LOOP_STALL_ALWAYS_LOG_MS = 1e4;
31563
+
31564
+ // ../protocol/src/node/bridge-diagnostics.ts
31565
+ var log4 = createLogger("bridge.diagnostics");
31566
+ var BRIDGE_DIAGNOSTICS_INTERVAL_MS = 60000;
31567
+ var INTERVAL_MS = BRIDGE_DIAGNOSTICS_INTERVAL_MS;
31568
+ var STALL_NO_DELTA_MS = 2 * INTERVAL_MS;
31569
+ var STALL_TOOL_PENDING_MS = 10 * 60000;
31570
+ var STALL_TICK_DELAY_MS = EVENT_LOOP_STALL_ALWAYS_LOG_MS;
31571
+ var BRIDGE_DIAGNOSTICS_KEEPALIVE_MS = 10 * 60000;
28918
31572
  var MAX_PENDING_TOOLS = 128;
28919
31573
  var MAX_REPORTED_TOOLS = 8;
28920
31574
  var MAX_ID_LENGTH = 1024;
@@ -28975,6 +31629,28 @@ var UPDATE_KINDS = new Set([
28975
31629
  "step-started",
28976
31630
  "step-completed"
28977
31631
  ]);
31632
+ var COUNTER_CHANGE_THRESHOLDS = {
31633
+ stderrBytes: 4096,
31634
+ requestsSent: 1,
31635
+ responsesReceived: 1,
31636
+ timeouts: 1,
31637
+ notificationsReceived: Number.POSITIVE_INFINITY,
31638
+ protocolErrors: 1
31639
+ };
31640
+ var WAITING_PHASES = new Set([
31641
+ "sending",
31642
+ "following",
31643
+ "draining",
31644
+ "cancelling"
31645
+ ]);
31646
+ function sameSet(a, b) {
31647
+ if (a.size !== b.size)
31648
+ return false;
31649
+ for (const value of a)
31650
+ if (!b.has(value))
31651
+ return false;
31652
+ return true;
31653
+ }
28978
31654
  function identity(value) {
28979
31655
  if (typeof value !== "string" || !value || value.length > MAX_ID_LENGTH)
28980
31656
  return;
@@ -28983,7 +31659,16 @@ function identity(value) {
28983
31659
  function readBridgeDebugFlag(value) {
28984
31660
  return value?.trim() === "1";
28985
31661
  }
31662
+ var liveDiagnostics;
31663
+ var liveScopes = new Set;
31664
+ function setLiveBridgeDiagnostics(enabled) {
31665
+ liveDiagnostics = enabled;
31666
+ for (const scope of Array.from(liveScopes))
31667
+ scope.syncActive();
31668
+ }
28986
31669
  function bridgeDebugEnabled(bridge, env = process.env) {
31670
+ if (liveDiagnostics !== undefined && env === process.env)
31671
+ return liveDiagnostics;
28987
31672
  const value = env.ORKESTRATOR_BRIDGE_DEBUG ?? env[`${bridge.toUpperCase()}_BRIDGE_DEBUG`];
28988
31673
  return readBridgeDebugFlag(value);
28989
31674
  }
@@ -29041,18 +31726,35 @@ function safeDiagnosticMetrics(value) {
29041
31726
  result.state = value.state;
29042
31727
  return result;
29043
31728
  }
29044
- var MAX_ENTRY_BYTES = 8192;
29045
- function writeDiagnostic(bridge, payload, write) {
31729
+ function bridgeDiagnosticsChangesEnabled() {
31730
+ return log4.isEnabled("trace");
31731
+ }
31732
+ function writeBridgeDiagnostic({ bridge, event, payload }) {
31733
+ return tryWriteLog("info", "bridge.diagnostics", event, { bridge, payload });
31734
+ }
31735
+ function bridgeDiagnosticsActive() {
31736
+ return log4.isEnabled("info");
31737
+ }
31738
+ function bridgeDiagnosticsStreamEnabled(bridge) {
31739
+ return bridgeDebugEnabled(bridge) || log4.isEnabled("debug");
31740
+ }
31741
+ function writeDiagnostic(bridge, event, payload, write) {
29046
31742
  try {
29047
- let json = JSON.stringify({ bridge, ...payload });
29048
- if (Buffer.byteLength(json) > MAX_ENTRY_BYTES)
29049
- json = JSON.stringify({
29050
- bridge,
29051
- event: "snapshot-overflow",
29052
- omittedBytes: Buffer.byteLength(json)
29053
- });
29054
- write(`[bridge-diagnostics] ${json}`);
29055
- } catch {}
31743
+ const json = JSON.stringify({ bridge, event, ...payload });
31744
+ const bytes = Buffer.byteLength(json);
31745
+ if (bytes <= MAX_BRIDGE_DIAGNOSTIC_BYTES) {
31746
+ const accepted = write({ bridge, event, payload: json });
31747
+ return accepted !== false;
31748
+ }
31749
+ const accepted = write({
31750
+ bridge,
31751
+ event: "snapshot-overflow",
31752
+ payload: JSON.stringify({ bridge, event: "snapshot-overflow", omittedBytes: bytes })
31753
+ });
31754
+ return accepted !== false;
31755
+ } catch {
31756
+ return false;
31757
+ }
29056
31758
  }
29057
31759
 
29058
31760
  class BridgeRunDiagnostics {
@@ -29062,6 +31764,7 @@ class BridgeRunDiagnostics {
29062
31764
  write;
29063
31765
  intervalMs;
29064
31766
  metrics;
31767
+ active;
29065
31768
  counters = {
29066
31769
  stderrBytes: 0,
29067
31770
  requestsSent: 0,
@@ -29083,25 +31786,38 @@ class BridgeRunDiagnostics {
29083
31786
  completedTools = 0;
29084
31787
  pending = new Map;
29085
31788
  phase = "sending";
31789
+ processScope = false;
29086
31790
  terminal = "pending";
29087
31791
  stream = "pending";
29088
31792
  cancellation = "none";
29089
31793
  cancelReason;
29090
31794
  run;
29091
31795
  closed = false;
31796
+ wasActive;
31797
+ baseline;
31798
+ changeQueued = false;
29092
31799
  timer;
29093
- constructor(bridge, state, now = Date.now, write = (line) => console.info(line), intervalMs = INTERVAL_MS, metrics = () => ({})) {
31800
+ constructor(bridge, state, now = Date.now, write = writeBridgeDiagnostic, intervalMs = INTERVAL_MS, metrics = () => ({}), active = () => true) {
29094
31801
  this.bridge = bridge;
29095
31802
  this.state = state;
29096
31803
  this.now = now;
29097
31804
  this.write = write;
29098
31805
  this.intervalMs = intervalMs;
29099
31806
  this.metrics = metrics;
31807
+ this.active = active;
29100
31808
  this.startedAt = this.lastTick = now();
31809
+ this.wasActive = active();
29101
31810
  this.timer = setInterval(() => this.report("heartbeat"), intervalMs);
29102
31811
  this.timer.unref();
31812
+ liveScopes.add(this);
29103
31813
  this.report("send-started");
29104
31814
  }
31815
+ syncActive() {
31816
+ const active = this.active();
31817
+ if (active && !this.wasActive)
31818
+ this.report("heartbeat");
31819
+ this.wasActive = active;
31820
+ }
29105
31821
  sent(runId) {
29106
31822
  this.run = identity(runId);
29107
31823
  this.phase = "following";
@@ -29125,7 +31841,8 @@ class BridgeRunDiagnostics {
29125
31841
  return;
29126
31842
  }
29127
31843
  if (stage === "completed") {
29128
- this.pending.delete(key);
31844
+ if (this.pending.delete(key))
31845
+ this.changed();
29129
31846
  this.completedTools++;
29130
31847
  return;
29131
31848
  }
@@ -29140,13 +31857,23 @@ class BridgeRunDiagnostics {
29140
31857
  stage: stage === "started" || existing?.stage === "started" ? "started" : "partial",
29141
31858
  nested
29142
31859
  });
31860
+ if (!existing)
31861
+ this.changed();
29143
31862
  }
29144
31863
  checkpoint(phase) {
31864
+ if (phase === "attached")
31865
+ this.processScope = true;
31866
+ if (phase === this.phase)
31867
+ return;
29145
31868
  this.phase = phase;
31869
+ this.changed();
29146
31870
  }
29147
31871
  count(key, amount = 1) {
29148
- if (!this.closed && Number.isSafeInteger(amount) && amount >= 0)
29149
- this.counters[key] += amount;
31872
+ if (this.closed || !Number.isSafeInteger(amount) || amount < 0)
31873
+ return;
31874
+ this.counters[key] += amount;
31875
+ if (amount > 0 && Number.isFinite(COUNTER_CHANGE_THRESHOLDS[key]))
31876
+ this.changed();
29150
31877
  }
29151
31878
  translationFailed() {
29152
31879
  this.translationFailures++;
@@ -29162,8 +31889,10 @@ class BridgeRunDiagnostics {
29162
31889
  }
29163
31890
  terminalSettled(outcome) {
29164
31891
  this.terminal = outcome;
29165
- if (outcome === "resolved")
31892
+ if (outcome === "resolved" && this.phase !== "draining") {
29166
31893
  this.phase = "draining";
31894
+ this.changed();
31895
+ }
29167
31896
  }
29168
31897
  requestCancellation(reason = "user") {
29169
31898
  this.cancellation = "pending";
@@ -29185,10 +31914,38 @@ class BridgeRunDiagnostics {
29185
31914
  if (this.closed)
29186
31915
  return;
29187
31916
  const now = this.now();
29188
- const age = (time) => time === undefined ? null : Math.max(0, now - time);
29189
31917
  const tickDelayMs = event === "heartbeat" ? Math.max(0, now - this.lastTick - this.intervalMs) : 0;
29190
31918
  if (event === "heartbeat")
29191
31919
  this.lastTick = now;
31920
+ if (!bridgeDiagnosticsActive())
31921
+ return;
31922
+ const stall = this.stallState(now, tickDelayMs);
31923
+ if (event === "heartbeat" && !this.active() && !this.periodicDue(now, stall))
31924
+ return;
31925
+ this.writeSnapshot(event, now, tickDelayMs, stall);
31926
+ }
31927
+ changed() {
31928
+ if (this.closed || this.changeQueued || !bridgeDiagnosticsChangesEnabled())
31929
+ return;
31930
+ this.changeQueued = true;
31931
+ queueMicrotask(() => {
31932
+ this.changeQueued = false;
31933
+ this.reportChange();
31934
+ });
31935
+ }
31936
+ reportChange() {
31937
+ if (this.closed || !bridgeDiagnosticsChangesEnabled() || !bridgeDiagnosticsActive())
31938
+ return;
31939
+ const last = this.baseline;
31940
+ if (last && !this.changedSince(last))
31941
+ return;
31942
+ const now = this.now();
31943
+ try {
31944
+ this.writeSnapshot("change", now, 0, this.stallState(now, 0));
31945
+ } catch {}
31946
+ }
31947
+ writeSnapshot(event, now, tickDelayMs, stall) {
31948
+ const age = (time) => time === undefined ? null : Math.max(0, now - time);
29192
31949
  const pendingTools = Array.from(this.pending.entries()).slice(0, MAX_REPORTED_TOOLS).map(([id, tool]) => ({
29193
31950
  id,
29194
31951
  kind: tool.kind,
@@ -29197,8 +31954,7 @@ class BridgeRunDiagnostics {
29197
31954
  ageMs: age(tool.since)
29198
31955
  }));
29199
31956
  try {
29200
- writeDiagnostic(this.bridge, {
29201
- event,
31957
+ const written = writeDiagnostic(this.bridge, event, {
29202
31958
  session: identity(this.state.id),
29203
31959
  run: this.run,
29204
31960
  phase: this.phase,
@@ -29225,18 +31981,76 @@ class BridgeRunDiagnostics {
29225
31981
  completedTools: this.completedTools,
29226
31982
  tickDelayMs
29227
31983
  }, this.write);
31984
+ if (!written)
31985
+ return;
31986
+ this.baseline = {
31987
+ at: now,
31988
+ phase: this.phase,
31989
+ pending: new Set(this.pending.keys()),
31990
+ counters: { ...this.counters },
31991
+ stall
31992
+ };
29228
31993
  } catch {}
29229
31994
  }
31995
+ periodicDue(now, stall) {
31996
+ if (stall.signals.has("tick-delay"))
31997
+ return true;
31998
+ const last = this.baseline;
31999
+ if (!last)
32000
+ return true;
32001
+ if (!sameSet(stall.signals, last.stall.signals) || !sameSet(stall.tools, last.stall.tools))
32002
+ return true;
32003
+ if (stall.signals.has("no-delta") && this.changedSince(last))
32004
+ return true;
32005
+ return now - last.at >= BRIDGE_DIAGNOSTICS_KEEPALIVE_MS;
32006
+ }
32007
+ changedSince(last) {
32008
+ if (this.phase !== last.phase)
32009
+ return true;
32010
+ if (this.pending.size !== last.pending.size)
32011
+ return true;
32012
+ for (const key of this.pending.keys())
32013
+ if (!last.pending.has(key))
32014
+ return true;
32015
+ for (const key of Object.keys(this.counters))
32016
+ if (this.counters[key] - last.counters[key] >= COUNTER_CHANGE_THRESHOLDS[key])
32017
+ return true;
32018
+ return false;
32019
+ }
32020
+ stallState(now, tickDelayMs) {
32021
+ const signals = new Set;
32022
+ const tools = new Set;
32023
+ let oldestPending;
32024
+ for (const [key, tool] of this.pending) {
32025
+ if (oldestPending === undefined || tool.since < oldestPending)
32026
+ oldestPending = tool.since;
32027
+ if (now - tool.since >= STALL_TOOL_PENDING_MS)
32028
+ tools.add(key);
32029
+ }
32030
+ const waitingSince = this.processScope ? oldestPending : WAITING_PHASES.has(this.phase) ? this.startedAt : undefined;
32031
+ if (waitingSince !== undefined) {
32032
+ const quietSince = Math.max(this.lastDelta ?? waitingSince, waitingSince);
32033
+ if (now - quietSince >= STALL_NO_DELTA_MS)
32034
+ signals.add("no-delta");
32035
+ }
32036
+ if (tools.size > 0)
32037
+ signals.add("tool-pending");
32038
+ if (tickDelayMs >= STALL_TICK_DELAY_MS)
32039
+ signals.add("tick-delay");
32040
+ return { signals, tools };
32041
+ }
29230
32042
  close(phase = "finished") {
29231
32043
  if (this.closed)
29232
32044
  return;
29233
32045
  this.phase = phase;
29234
32046
  this.report("closed");
29235
32047
  this.closed = true;
32048
+ liveScopes.delete(this);
29236
32049
  clearInterval(this.timer);
29237
32050
  this.pending.clear();
29238
32051
  }
29239
32052
  }
32053
+ var bufferedFlushes = new Set;
29240
32054
 
29241
32055
  // ../../bridges/cursor-bridge/src/sdk-diagnostics.ts
29242
32056
  import { AsyncLocalStorage } from "node:async_hooks";
@@ -29377,7 +32191,16 @@ function instrumentSdk(seam) {
29377
32191
  return startTimer.apply(this, args);
29378
32192
  };
29379
32193
  detector.trackActivity = function(...args) {
29380
- safely(() => owners.get(this)?.transportActivity(this, args[0], args[1]));
32194
+ safely(() => {
32195
+ if (!owners.has(this)) {
32196
+ const scope = scopes.getStore();
32197
+ if (!scope)
32198
+ return;
32199
+ owners.set(this, scope);
32200
+ scope.transport(this);
32201
+ }
32202
+ owners.get(this)?.transportActivity(this, args[0], args[1]);
32203
+ });
29381
32204
  return trackActivity.apply(this, args);
29382
32205
  };
29383
32206
  controller.run = function(...args) {
@@ -29451,6 +32274,7 @@ function install() {
29451
32274
  class CursorSdkDiagnostics {
29452
32275
  now;
29453
32276
  write;
32277
+ isActive;
29454
32278
  transports = [];
29455
32279
  transportEntries = new WeakMap;
29456
32280
  seen = new WeakSet;
@@ -29465,11 +32289,16 @@ class CursorSdkDiagnostics {
29465
32289
  closed = false;
29466
32290
  run;
29467
32291
  session;
29468
- coverage;
29469
- constructor(sessionId, now = Date.now, write = (line) => console.info(line)) {
32292
+ coverage = "unavailable";
32293
+ constructor(sessionId, now = Date.now, write = writeBridgeDiagnostic, isActive = () => true) {
29470
32294
  this.now = now;
29471
32295
  this.write = write;
32296
+ this.isActive = isActive;
29472
32297
  this.session = hash(sessionId);
32298
+ if (isActive())
32299
+ this.installSeam();
32300
+ }
32301
+ installSeam() {
29473
32302
  this.coverage = install();
29474
32303
  }
29475
32304
  follow(work) {
@@ -29558,7 +32387,7 @@ class CursorSdkDiagnostics {
29558
32387
  };
29559
32388
  }
29560
32389
  report(event) {
29561
- if (this.closed)
32390
+ if (this.closed || !this.isActive() || !bridgeDiagnosticsActive())
29562
32391
  return;
29563
32392
  safely(() => {
29564
32393
  const now = this.now();
@@ -29624,12 +32453,20 @@ class CursorSdkDiagnostics {
29624
32453
  droppedExecutions: this.droppedExecutions
29625
32454
  };
29626
32455
  const json = JSON.stringify(payload);
29627
- this.write(`[bridge-diagnostics] ${Buffer.byteLength(json) <= 8192 ? json : JSON.stringify({
32456
+ if (Buffer.byteLength(json) <= MAX_BRIDGE_DIAGNOSTIC_BYTES) {
32457
+ this.write({ bridge: "cursor", event: "sdk-snapshot", payload: json });
32458
+ return;
32459
+ }
32460
+ this.write({
29628
32461
  bridge: "cursor",
29629
32462
  event: "sdk-snapshot-overflow",
29630
- session: this.session,
29631
- run: this.run
29632
- })}`);
32463
+ payload: JSON.stringify({
32464
+ bridge: "cursor",
32465
+ event: "sdk-snapshot-overflow",
32466
+ session: this.session,
32467
+ run: this.run
32468
+ })
32469
+ });
29633
32470
  });
29634
32471
  }
29635
32472
  close() {
@@ -29643,11 +32480,16 @@ class CursorSdkDiagnostics {
29643
32480
  // ../../bridges/cursor-bridge/src/run-diagnostics.ts
29644
32481
  class CursorRunDiagnostics extends BridgeRunDiagnostics {
29645
32482
  sdk;
29646
- constructor(state, now, write, intervalMs) {
29647
- super("cursor", state, now, write, intervalMs);
29648
- this.sdk = new CursorSdkDiagnostics(state.id, now, write);
32483
+ constructor(state, now, write, intervalMs, active) {
32484
+ super("cursor", state, now, write, intervalMs, undefined, active);
32485
+ this.sdk = new CursorSdkDiagnostics(state.id, now, write, active);
29649
32486
  this.sdk.report("send-started");
29650
32487
  }
32488
+ syncActive() {
32489
+ if (this.active())
32490
+ this.sdk.installSeam();
32491
+ super.syncActive();
32492
+ }
29651
32493
  follow(work) {
29652
32494
  return this.sdk.follow(work);
29653
32495
  }
@@ -29681,15 +32523,15 @@ class CursorRunDiagnostics extends BridgeRunDiagnostics {
29681
32523
  }
29682
32524
  }
29683
32525
  function createRunDiagnostics(state) {
29684
- return bridgeDebugEnabled("cursor") ? new CursorRunDiagnostics(state) : undefined;
32526
+ return new CursorRunDiagnostics(state, undefined, undefined, undefined, () => bridgeDiagnosticsStreamEnabled("cursor"));
29685
32527
  }
29686
32528
  var MAX_SETUP_DETAIL_BYTES = 300;
29687
32529
  function cursorSetupDebug(stage, error) {
29688
32530
  if (!bridgeDebugEnabled("cursor"))
29689
32531
  return;
29690
32532
  const detail = (error instanceof Error ? error.message : String(error)).slice(0, MAX_SETUP_DETAIL_BYTES);
29691
- const entry = JSON.stringify({ bridge: "cursor", event: "setup-failed", stage, detail });
29692
- console.info(`[bridge-diagnostics] ${entry}`);
32533
+ const payload = JSON.stringify({ bridge: "cursor", event: "setup-failed", stage, detail });
32534
+ writeBridgeDiagnostic({ bridge: "cursor", event: "setup-failed", payload });
29693
32535
  }
29694
32536
 
29695
32537
  // ../../bridges/cursor-bridge/src/sandbox-bootstrap.ts
@@ -31516,6 +34358,8 @@ function trackTurnEvidence(conversationId, options) {
31516
34358
  }
31517
34359
 
31518
34360
  // ../../bridges/cursor-bridge/src/agent-session.ts
34361
+ var log5 = createLogger("bridge.cursor");
34362
+
31519
34363
  class CredentialError extends Error {
31520
34364
  constructor(message) {
31521
34365
  super(message);
@@ -32059,7 +34903,7 @@ async function setResumableAgentArchived(agentId, archived) {
32059
34903
  const options = { cwd: workingDirectory };
32060
34904
  await (archived ? api.archive(agentId, options) : api.unarchive(agentId, options));
32061
34905
  } catch (error) {
32062
- console.warn(`[cursor-bridge] Agent.${archived ? "archive" : "unarchive"} failed:`, error instanceof Error ? error.message : error);
34906
+ log5.warn("agent.archive-failed", { archived, error: formatLogError(error, { stack: false }) });
32063
34907
  return "failed";
32064
34908
  } finally {
32065
34909
  agentArchiveOperations.delete(agentId);
@@ -34077,7 +36921,7 @@ async function readWorkspaceImage(filePath, workspaceRoot) {
34077
36921
  }
34078
36922
  }
34079
36923
  // ../protocol/src/node/transcript-window.ts
34080
- import { Buffer as Buffer4 } from "node:buffer";
36924
+ import { Buffer as Buffer5 } from "node:buffer";
34081
36925
  var DEFAULT_ENVELOPE_RESERVE_BYTES = 256;
34082
36926
  var DEFAULT_CONTENT_FALLBACK_BYTES = 1024 * 1024;
34083
36927
  var MAX_TRANSCRIPT_INDEX_DIGITS = 16;
@@ -34101,7 +36945,7 @@ function transcriptTailStart(retained, tailMessages) {
34101
36945
  function retainUtf8Tail(value, maximumBytes) {
34102
36946
  if (maximumBytes <= 0)
34103
36947
  return "";
34104
- const encoded = Buffer4.from(value);
36948
+ const encoded = Buffer5.from(value);
34105
36949
  if (encoded.length <= maximumBytes)
34106
36950
  return value;
34107
36951
  let start = encoded.length - maximumBytes;
@@ -34114,7 +36958,7 @@ function boundTranscriptResponse(messages, maximumBytes, options = {}) {
34114
36958
  const contentFallbackBytes = options.contentFallbackBytes === undefined ? DEFAULT_CONTENT_FALLBACK_BYTES : options.contentFallbackBytes;
34115
36959
  const tail = options.tailMessages;
34116
36960
  const selected = tail !== undefined && messages.length > tail ? messages.slice(-tail) : [...messages];
34117
- const measure = options.measure ?? ((message) => Buffer4.byteLength(JSON.stringify(message)));
36961
+ const measure = options.measure ?? ((message) => Buffer5.byteLength(JSON.stringify(message)));
34118
36962
  const sizes = selected.map((message) => measure(message));
34119
36963
  let bytes = envelope + 2 + sizes.reduce((total, size) => total + size, 0) + Math.max(0, sizes.length - 1);
34120
36964
  let start = 0;
@@ -34126,7 +36970,7 @@ function boundTranscriptResponse(messages, maximumBytes, options = {}) {
34126
36970
  let truncatedContent = false;
34127
36971
  const oldestRetained = selected[start];
34128
36972
  if (bytes > maximumBytes && oldestRetained) {
34129
- const partSizes = oldestRetained.parts.map((part) => Buffer4.byteLength(JSON.stringify(part)));
36973
+ const partSizes = oldestRetained.parts.map((part) => Buffer5.byteLength(JSON.stringify(part)));
34130
36974
  const partCount = partSizes.length;
34131
36975
  while (omittedParts < partCount && bytes > maximumBytes) {
34132
36976
  const shed = partSizes[omittedParts];
@@ -34147,7 +36991,7 @@ function boundTranscriptResponse(messages, maximumBytes, options = {}) {
34147
36991
  };
34148
36992
  omittedParts = oldestRetained.parts.length;
34149
36993
  truncatedContent = true;
34150
- bytes = envelope + 2 + Buffer4.byteLength(JSON.stringify(selected[start]));
36994
+ bytes = envelope + 2 + Buffer5.byteLength(JSON.stringify(selected[start]));
34151
36995
  }
34152
36996
  }
34153
36997
  const bounded = selected.slice(start);
@@ -34299,8 +37143,158 @@ function publicRuntime(state) {
34299
37143
  ...notices.length > 0 ? { notices } : {}
34300
37144
  };
34301
37145
  }
37146
+ // ../protocol/src/log-policy.ts
37147
+ var BRIDGE_DIAGNOSTICS_LOG_AREA = "bridge.diagnostics";
37148
+ var MAX_LOG_DETAIL_AREAS = 256;
37149
+ var MAX_LOG_AREA_NAME_CHARS = 64;
37150
+ var LOG_AREA_NAME = /^[a-z][a-z0-9-]*(?:\.[a-z][a-z0-9-]*)*$/;
37151
+ function parseLogDetail(value) {
37152
+ if (typeof value !== "object" || value === null || Array.isArray(value))
37153
+ return null;
37154
+ const { level, areaLevels } = value;
37155
+ if (!isLogLevel(level))
37156
+ return null;
37157
+ if (areaLevels === undefined)
37158
+ return { level, areaLevels: {} };
37159
+ if (typeof areaLevels !== "object" || areaLevels === null || Array.isArray(areaLevels)) {
37160
+ return null;
37161
+ }
37162
+ const names = Object.keys(areaLevels).sort();
37163
+ if (names.length > MAX_LOG_DETAIL_AREAS)
37164
+ return null;
37165
+ const clean = {};
37166
+ for (const name of names) {
37167
+ const areaLevel = areaLevels[name];
37168
+ if (name.length > MAX_LOG_AREA_NAME_CHARS || !LOG_AREA_NAME.test(name))
37169
+ return null;
37170
+ if (!isLogLevel(areaLevel))
37171
+ return null;
37172
+ clean[name] = areaLevel;
37173
+ }
37174
+ return { level, areaLevels: clean };
37175
+ }
37176
+ var LEVEL_DETAIL = {
37177
+ error: 0,
37178
+ warn: 1,
37179
+ info: 2,
37180
+ debug: 3,
37181
+ trace: 4
37182
+ };
37183
+ function effectiveLogLevel(detail, area) {
37184
+ for (let scope = area;; scope = scope.slice(0, scope.lastIndexOf("."))) {
37185
+ const level = Object.hasOwn(detail.areaLevels, scope) ? detail.areaLevels[scope] : undefined;
37186
+ if (level)
37187
+ return level;
37188
+ if (!scope.includes("."))
37189
+ return detail.level;
37190
+ }
37191
+ }
37192
+ function logDetailEnablesBridgeDiagnostics(detail) {
37193
+ return LEVEL_DETAIL[effectiveLogLevel(detail, BRIDGE_DIAGNOSTICS_LOG_AREA)] >= LEVEL_DETAIL.debug;
37194
+ }
37195
+ var BRIDGE_LOG_POLICY_ROUTE = "/debug/log-policy";
37196
+ function parseBridgeLogPolicy(value) {
37197
+ const detail = parseLogDetail(value);
37198
+ if (!detail)
37199
+ return null;
37200
+ const { seq } = value;
37201
+ return Number.isSafeInteger(seq) && seq >= 0 ? { ...detail, seq } : null;
37202
+ }
37203
+
37204
+ // ../protocol/src/node/logger-environment.ts
37205
+ var LOG_LEVEL_ENV = "ORKESTRATOR_LOG_LEVEL";
37206
+ var LOG_FORMAT_ENV = "ORKESTRATOR_LOG_FORMAT";
37207
+ var BRIDGE_LOG_RELAY_ENV = "ORKESTRATOR_BRIDGE_LOG_RELAY";
37208
+ var bridgeLogLevelOverrides = new WeakMap;
37209
+ function logLevelEnvironmentValue(env) {
37210
+ return env[LOG_LEVEL_ENV] ?? bridgeLogLevelOverrides.get(env);
37211
+ }
37212
+ function parseLogLevels(value) {
37213
+ const parsed = { areaLevels: {}, invalid: [] };
37214
+ for (const entry of (value ?? "").split(",")) {
37215
+ const trimmed = entry.trim();
37216
+ if (!trimmed)
37217
+ continue;
37218
+ const separator = trimmed.indexOf("=");
37219
+ if (separator < 0) {
37220
+ if (isLogLevel(trimmed))
37221
+ parsed.level = trimmed;
37222
+ else
37223
+ parsed.invalid.push(trimmed);
37224
+ continue;
37225
+ }
37226
+ const area = trimmed.slice(0, separator);
37227
+ const level = trimmed.slice(separator + 1);
37228
+ if (isLogLevel(level) && isKnownScope(area))
37229
+ parsed.areaLevels[area] = level;
37230
+ else
37231
+ parsed.invalid.push(trimmed);
37232
+ }
37233
+ return parsed;
37234
+ }
37235
+ function isKnownScope(scope) {
37236
+ return Object.keys(LOG_VOCABULARY).some((area) => area === scope || area.startsWith(`${scope}.`));
37237
+ }
37238
+ function configureLoggerFromEnvironment(env, options = {}) {
37239
+ const levels = parseLogLevels(env[LOG_LEVEL_ENV]);
37240
+ const requestedFormat = env[LOG_FORMAT_ENV];
37241
+ const format = options.relayToSupervisor || requestedFormat === "json" ? "json" : "text";
37242
+ configureLogger({
37243
+ ...levels.level ? { level: levels.level } : {},
37244
+ areaLevels: levels.areaLevels,
37245
+ format
37246
+ });
37247
+ const log = createLogger("logging");
37248
+ if (levels.invalid.length > 0) {
37249
+ log.warn("config.invalid", { variable: LOG_LEVEL_ENV, entries: levels.invalid.length });
37250
+ }
37251
+ if (requestedFormat && requestedFormat !== "json" && requestedFormat !== "text") {
37252
+ log.warn("config.invalid", { variable: LOG_FORMAT_ENV, entries: 1 });
37253
+ }
37254
+ }
37255
+ function configureBridgeLogger(env = process.env) {
37256
+ const relayToSupervisor = env[BRIDGE_LOG_RELAY_ENV] === "1";
37257
+ bridgeLogLevelOverrides.set(env, env[LOG_LEVEL_ENV]);
37258
+ delete env[BRIDGE_LOG_RELAY_ENV];
37259
+ configureLoggerFromEnvironment(env, { relayToSupervisor });
37260
+ delete env[LOG_FORMAT_ENV];
37261
+ delete env[LOG_LEVEL_ENV];
37262
+ }
37263
+
37264
+ // ../protocol/src/node/log-policy.ts
37265
+ function effectiveLogDetail(detail, env = process.env) {
37266
+ const overrides = parseLogLevels(logLevelEnvironmentValue(env));
37267
+ return {
37268
+ level: overrides.level ?? detail.level,
37269
+ areaLevels: { ...detail.areaLevels, ...overrides.areaLevels }
37270
+ };
37271
+ }
37272
+ function applyLogDetail(detail, env = process.env) {
37273
+ const effective = effectiveLogDetail(detail, env);
37274
+ configureLogger(effective);
37275
+ return effective;
37276
+ }
37277
+
37278
+ // ../protocol/src/node/bridge-log-policy.ts
37279
+ var MAX_BRIDGE_LOG_POLICY_BYTES = 64 * 1024;
37280
+ var appliedSeq = -1;
37281
+ function applyBridgeLogPolicy(value, env = process.env) {
37282
+ const policy = parseBridgeLogPolicy(value);
37283
+ if (!policy)
37284
+ return { status: 400, body: { error: "Invalid log policy" } };
37285
+ if (policy.seq < appliedSeq) {
37286
+ return { status: 200, body: { applied: false, stale: true, seq: appliedSeq } };
37287
+ }
37288
+ appliedSeq = policy.seq;
37289
+ const effective = applyLogDetail(policy, env);
37290
+ const diagnostics = logDetailEnablesBridgeDiagnostics(effective);
37291
+ setLiveBridgeDiagnostics(diagnostics);
37292
+ return { status: 200, body: { applied: true, seq: policy.seq, diagnostics } };
37293
+ }
37294
+
34302
37295
  // ../protocol/src/human-prompts.ts
34303
37296
  var HUMAN_PROMPT_SCAN_BYTES = 16 * 1024;
37297
+ var HUMAN_PROMPT_OBSERVATION_ROWS = 64;
34304
37298
  function humanPromptObservation(messages, tasks) {
34305
37299
  const object = (value) => !!value && typeof value === "object" && !Array.isArray(value);
34306
37300
  const parts = [];
@@ -34334,7 +37328,7 @@ function humanPromptObservation(messages, tasks) {
34334
37328
  }
34335
37329
  };
34336
37330
  if (Array.isArray(messages)) {
34337
- for (let i = messages.length - 1;i >= Math.max(0, messages.length - 64); i--) {
37331
+ for (let i = messages.length - 1;i >= Math.max(0, messages.length - HUMAN_PROMPT_OBSERVATION_ROWS); i--) {
34338
37332
  const message = messages[i];
34339
37333
  if (object(message))
34340
37334
  walk(message.parts);
@@ -34480,7 +37474,7 @@ var DEFAULT_MCP_MANAGEMENT_ROLLOUT = Object.freeze({
34480
37474
  });
34481
37475
 
34482
37476
  // ../protocol/src/node/bridge-transcript-summary.ts
34483
- import { Buffer as Buffer5 } from "node:buffer";
37477
+ import { Buffer as Buffer6 } from "node:buffer";
34484
37478
  import { createHash as createHash6 } from "node:crypto";
34485
37479
 
34486
37480
  // ../protocol/src/node/progressive-transcript.ts
@@ -34565,7 +37559,7 @@ var MAX_SUMMARY_DEPTH = 8;
34565
37559
  var NESTED_PART_FIELDS = ["parts", "childTools", "subagentActions"];
34566
37560
  var LOCATOR_PREFIX = "bd1.";
34567
37561
  function encodeLocator(body) {
34568
- const locator = LOCATOR_PREFIX + Buffer5.from(JSON.stringify(body)).toString("base64url");
37562
+ const locator = LOCATOR_PREFIX + Buffer6.from(JSON.stringify(body)).toString("base64url");
34569
37563
  return locator.length <= BRIDGE_DETAIL_LOCATOR_MAX_LENGTH ? locator : undefined;
34570
37564
  }
34571
37565
  function decodeLocator(locator) {
@@ -34573,7 +37567,7 @@ function decodeLocator(locator) {
34573
37567
  return;
34574
37568
  }
34575
37569
  try {
34576
- const body = JSON.parse(Buffer5.from(locator.slice(LOCATOR_PREFIX.length), "base64url").toString("utf8"));
37570
+ const body = JSON.parse(Buffer6.from(locator.slice(LOCATOR_PREFIX.length), "base64url").toString("utf8"));
34577
37571
  if (!isRecord(body))
34578
37572
  return;
34579
37573
  const { m, p, d } = body;
@@ -34646,7 +37640,7 @@ function measureDetail(part, payload) {
34646
37640
  function digestPayload(payload) {
34647
37641
  const serialized = JSON.stringify(payload);
34648
37642
  return {
34649
- bytes: Buffer5.byteLength(serialized),
37643
+ bytes: Buffer6.byteLength(serialized),
34650
37644
  digest: createHash6("sha256").update(serialized).digest("base64url").slice(0, 32)
34651
37645
  };
34652
37646
  }
@@ -34821,7 +37815,7 @@ function revisedBeforeWindow(messages, startIndex, ids) {
34821
37815
  continue;
34822
37816
  found.delete(id);
34823
37817
  const summary = summarizeBridgeMessage(message);
34824
- const size = Buffer5.byteLength(JSON.stringify(summary));
37818
+ const size = Buffer6.byteLength(JSON.stringify(summary));
34825
37819
  if (revised.length >= BRIDGE_REVISED_MESSAGES_MAX || bytes + size > BRIDGE_REVISED_MESSAGES_MAX_BYTES) {
34826
37820
  omitted.push(summary);
34827
37821
  continue;
@@ -34883,7 +37877,7 @@ function bridgeTranscriptSummaryUpdate(messages, options) {
34883
37877
  }
34884
37878
  var PAGE_CURSOR_PREFIX = "bp1.";
34885
37879
  function encodePageCursor(body) {
34886
- const cursor = PAGE_CURSOR_PREFIX + Buffer5.from(JSON.stringify(body)).toString("base64url");
37880
+ const cursor = PAGE_CURSOR_PREFIX + Buffer6.from(JSON.stringify(body)).toString("base64url");
34887
37881
  return cursor.length <= BRIDGE_PAGE_CURSOR_MAX_LENGTH ? cursor : undefined;
34888
37882
  }
34889
37883
  function decodePageCursor(cursor) {
@@ -34891,7 +37885,7 @@ function decodePageCursor(cursor) {
34891
37885
  return;
34892
37886
  }
34893
37887
  try {
34894
- const body = JSON.parse(Buffer5.from(cursor.slice(PAGE_CURSOR_PREFIX.length), "base64url").toString("utf8"));
37888
+ const body = JSON.parse(Buffer6.from(cursor.slice(PAGE_CURSOR_PREFIX.length), "base64url").toString("utf8"));
34895
37889
  if (!isRecord(body))
34896
37890
  return;
34897
37891
  const { g, e, b } = body;
@@ -35369,6 +38363,8 @@ async function answerSessionActivityBatch(body, read, options = {}) {
35369
38363
  }
35370
38364
 
35371
38365
  // ../../bridges/cursor-bridge/src/http.ts
38366
+ var log6 = createLogger("bridge.cursor");
38367
+
35372
38368
  class HttpError extends Error {
35373
38369
  status;
35374
38370
  constructor(status, message) {
@@ -35397,6 +38393,10 @@ async function route(request, response, clientSignal) {
35397
38393
  });
35398
38394
  return json(response, answer.status, answer.body);
35399
38395
  }
38396
+ if (url.pathname === BRIDGE_LOG_POLICY_ROUTE && request.method === "POST") {
38397
+ const answer = applyBridgeLogPolicy(await readJson(request));
38398
+ return json(response, answer.status, answer.body);
38399
+ }
35400
38400
  if (await routeChangeEvidence(request, response, url))
35401
38401
  return;
35402
38402
  const handled = await routeGlobal(request, response, url);
@@ -35428,7 +38428,7 @@ async function route(request, response, clientSignal) {
35428
38428
  if (error instanceof PromptAttachmentError) {
35429
38429
  return json(response, 400, { error: error.message });
35430
38430
  }
35431
- console.error("[cursor-bridge] Unexpected HTTP route failure");
38431
+ log6.error("http.route-failed");
35432
38432
  return json(response, 500, { error: "Internal bridge error" });
35433
38433
  }
35434
38434
  }
@@ -36416,6 +39416,7 @@ function startParentWatchdog(options) {
36416
39416
  }
36417
39417
 
36418
39418
  // ../protocol/src/bridge-lifecycle.ts
39419
+ var log7 = createLogger("bridge.lifecycle");
36419
39420
  var TERMINATION_SIGNALS = ["SIGTERM", "SIGINT"];
36420
39421
  function errorKind(error) {
36421
39422
  if (error instanceof Error)
@@ -36431,11 +39432,9 @@ class BridgeLifecycle {
36431
39432
  #exit = null;
36432
39433
  #options;
36433
39434
  #timers;
36434
- #report;
36435
39435
  constructor(options) {
36436
39436
  this.#options = options;
36437
39437
  this.#timers = options.timers ?? runtimeIntervalTimers;
36438
- this.#report = options.report ?? ((message) => console.error(message));
36439
39438
  }
36440
39439
  get phase() {
36441
39440
  return this.#phase;
@@ -36471,7 +39470,10 @@ class BridgeLifecycle {
36471
39470
  }
36472
39471
  requestExit() {
36473
39472
  this.#exit ??= this.shutdown().then(() => this.#options.exit(0), (error) => {
36474
- this.#report(`${this.#options.label} shutdown failed (${errorKind(error)})`);
39473
+ log7.error("shutdown.failed", {
39474
+ bridge: this.#options.label,
39475
+ errorClass: errorKind(error)
39476
+ });
36475
39477
  this.#options.exit(1);
36476
39478
  });
36477
39479
  return this.#exit;
@@ -36485,7 +39487,10 @@ class BridgeLifecycle {
36485
39487
  try {
36486
39488
  idleSweep.run();
36487
39489
  } catch (error) {
36488
- this.#report(`${this.#options.label} idle sweep failed (${errorKind(error)})`);
39490
+ log7.warn("idle-sweep.failed", {
39491
+ bridge: this.#options.label,
39492
+ errorClass: errorKind(error)
39493
+ });
36489
39494
  }
36490
39495
  }, idleSweep.intervalMs);
36491
39496
  this.#disarmers.push(() => this.#timers.clearInterval(handle));
@@ -36554,6 +39559,7 @@ async function settleIdleDetaches() {
36554
39559
  }
36555
39560
 
36556
39561
  // ../../bridges/cursor-bridge/src/server.ts
39562
+ var log8 = createLogger("bridge.cursor");
36557
39563
  var IDLE_SWEEP_MS = 60 * 1000;
36558
39564
  var lifecycle;
36559
39565
  var server = createServer((request, response) => {
@@ -36588,7 +39594,7 @@ function lifecycleFor(listenPort, options) {
36588
39594
  applyWorkingDirectory();
36589
39595
  await loadPersistedState();
36590
39596
  finishRestoredTombstones().catch(() => {
36591
- console.warn("[cursor-bridge] restored closes could not be finished at startup");
39597
+ log8.warn("startup.closes-failed");
36592
39598
  });
36593
39599
  await new Promise((resolve) => server.listen(listenPort, hostname, resolve));
36594
39600
  },
@@ -36779,6 +39785,7 @@ async function runLogin(emit) {
36779
39785
  }
36780
39786
 
36781
39787
  // ../../bridges/cursor-bridge/src/index.ts
39788
+ configureBridgeLogger();
36782
39789
  installFatalRejectionGuard({ label: "[cursor-bridge]" });
36783
39790
  if (process.argv.includes("--login")) {
36784
39791
  process.exit(await runLogin((line) => process.stdout.write(`${line}
@@ -36852,6 +39859,7 @@ export {
36852
39859
  __testing,
36853
39860
  acceptsGzip,
36854
39861
  appendBounded,
39862
+ appendTurnOutput,
36855
39863
  applyCommandChanges,
36856
39864
  applyComposerPatch,
36857
39865
  applyInteractionUpdate,