orkestrator 2.35.3-beta → 2.35.4-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);
@@ -28021,7 +28287,1658 @@ function newSessionState(clientSessionKey, policy) {
28021
28287
  };
28022
28288
  }
28023
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, depth) {
28398
+ if (typeof error !== "object" || error === null) {
28399
+ return {
28400
+ name: "NonError",
28401
+ message: typeof error === "string" ? boundedText2(error, MAX_MESSAGE_CHARS) : `[${typeof error}]`
28402
+ };
28403
+ }
28404
+ const rawMessage = read(error, "message");
28405
+ if (!(error instanceof Error) && typeof rawMessage !== "string") {
28406
+ return { name: "NonError", message: "[object]" };
28407
+ }
28408
+ const name = matching(read(error, "name"), NAME_PATTERN) ?? "Error";
28409
+ const message = typeof rawMessage === "string" ? rawMessage : undefined;
28410
+ const commandFailure = isCommandFailure(error, name, message);
28411
+ const stackHoldsMessage = message !== undefined && String(read(error, "stack") ?? "").includes(message);
28412
+ const details = { name };
28413
+ if (commandFailure)
28414
+ details.outputOmitted = true;
28415
+ else if (message)
28416
+ details.message = boundedText2(message, MAX_MESSAGE_CHARS);
28417
+ const code = read(error, "code");
28418
+ const safeCode = finite(code) ?? matching(code, CODE_PATTERN);
28419
+ if (safeCode !== undefined)
28420
+ details.code = safeCode;
28421
+ const errno = finite(read(error, "errno"));
28422
+ if (errno !== undefined)
28423
+ details.errno = errno;
28424
+ const syscall = matching(read(error, "syscall"), SYSCALL_PATTERN);
28425
+ if (syscall)
28426
+ details.syscall = syscall;
28427
+ const exitCode = finite(read(error, "exitCode"));
28428
+ if (exitCode !== undefined)
28429
+ details.exitCode = exitCode;
28430
+ const signal = matching(read(error, "signal"), CODE_PATTERN);
28431
+ if (signal)
28432
+ details.signal = signal;
28433
+ if (includeStack && (!commandFailure || stackHoldsMessage || !message)) {
28434
+ const frames = stackFrames(error, message);
28435
+ if (frames)
28436
+ details.stack = frames;
28437
+ }
28438
+ const members = read(error, "errors");
28439
+ if (Array.isArray(members))
28440
+ details.errorCount = members.length;
28441
+ const cause = read(error, "cause") ?? (Array.isArray(members) ? members[0] : undefined);
28442
+ if (cause !== undefined && cause !== null && depth < MAX_CAUSE_DEPTH) {
28443
+ details.cause = describe2(cause, false, depth + 1);
28444
+ }
28445
+ return details;
28446
+ }
28447
+ function formatLogError(error, options = {}) {
28448
+ try {
28449
+ return brand(describe2(error, options.stack !== false, 0));
28450
+ } catch {
28451
+ return brand({ name: "Error", message: "[unreadable]" });
28452
+ }
28453
+ }
28454
+ function logErrorKind(error) {
28455
+ if (typeof error !== "object" || error === null)
28456
+ return "NonError";
28457
+ if (!(error instanceof Error) && typeof read(error, "message") !== "string")
28458
+ return "NonError";
28459
+ const code = read(error, "code");
28460
+ const safeCode = finite(code) ?? matching(code, CODE_PATTERN);
28461
+ if (safeCode !== undefined)
28462
+ return String(safeCode);
28463
+ return matching(read(error, "name"), NAME_PATTERN) ?? "Error";
28464
+ }
28465
+
28466
+ // ../protocol/src/log-vocabulary/define.ts
28467
+ var THROTTLE_LOG_EVENTS = {
28468
+ "throttle.suppressed": "Repeats of the throttled `site` were counted over a window, not written.",
28469
+ "throttle.recovered": "The throttled `site` succeeded again, so its fault has cleared.",
28470
+ "throttle.evicted": "The tracked-key limit dropped the `site`, so no recovered line follows unless it fails again."
28471
+ };
28472
+ function defineLogAreas(areas) {
28473
+ return areas;
28474
+ }
28475
+
28476
+ // ../protocol/src/log-vocabulary/agent-mail.ts
28477
+ var AGENT_MAIL_LOG_AREAS = defineLogAreas({
28478
+ "agent-mail": {
28479
+ description: "Delivering agent mail into waiting agent sessions.",
28480
+ events: {
28481
+ "delivery.waiting": "The drain passed over a pending message, for a reason it had not yet logged."
28482
+ }
28483
+ }
28484
+ });
28485
+
28486
+ // ../protocol/src/log-vocabulary/backend.ts
28487
+ var BACKEND_LOG_AREAS = defineLogAreas({
28488
+ "build.pipeline": {
28489
+ description: "Build delivery, ticket reconciliation and persisted pipeline recovery.",
28490
+ events: {
28491
+ "delivery-policy.failed": "A ticket delivery edit could not be reconciled with the running build.",
28492
+ "criteria.failed": "Verify could not record criterion results on the ticket.",
28493
+ "transcript-maintenance.failed": "Pipeline transcript maintenance failed.",
28494
+ "hydrate.failed": "The renderer could not load the authoritative pipeline snapshot."
28495
+ }
28496
+ },
28497
+ "backend.activity": {
28498
+ description: "The backend's recurring activity and maintenance jobs.",
28499
+ events: {
28500
+ "job.failed": "One pass of the job named in `scope` failed; its next pass retries.",
28501
+ ...THROTTLE_LOG_EVENTS
28502
+ }
28503
+ }
28504
+ });
28505
+
28506
+ // ../protocol/src/log-vocabulary/bridge.ts
28507
+ var MAX_BRIDGE_DIAGNOSTIC_BYTES = 8192;
28508
+ var BRIDGE_LOG_AREAS = defineLogAreas({
28509
+ "bridge.diagnostics": {
28510
+ description: "Metadata snapshots of bridge turns and processes, written while Save Logs for Debugging is on. docs/architecture/bridge-diagnostics.md reads them.",
28511
+ tag: "bridge-diagnostics",
28512
+ maxStringChars: MAX_BRIDGE_DIAGNOSTIC_BYTES,
28513
+ events: {
28514
+ heartbeat: "The once-a-minute snapshot of a turn or process that is still open.",
28515
+ "send-started": "A turn or process diagnostic scope began.",
28516
+ "send-resolved": "The provider accepted a dispatch.",
28517
+ "cancel-requested": "Cancellation of a turn was requested.",
28518
+ "cancel-settled": "The provider's cancel call returned or failed.",
28519
+ closed: "A diagnostic scope ended, with its final counters.",
28520
+ "snapshot-overflow": "A snapshot exceeded the bound, so only its size was written.",
28521
+ "debug-events": "A batch of allowlisted debug labels with their counts.",
28522
+ "setup-failed": "A Cursor setup step failed and swallowed its error.",
28523
+ "sdk-snapshot": "Cursor's SDK transports and executions at a boundary.",
28524
+ "sdk-snapshot-overflow": "A Cursor SDK snapshot exceeded the bound, so it was omitted."
28525
+ }
28526
+ },
28527
+ "bridge.lifecycle": {
28528
+ description: "What every long-lived bridge does the same way: its sweep and its shutdown.",
28529
+ events: {
28530
+ "idle-sweep.failed": "An idle sweep threw; the next tick retries.",
28531
+ "shutdown.failed": "Releasing the bridge failed during shutdown; it still exits."
28532
+ }
28533
+ },
28534
+ "bridge.acp": {
28535
+ description: "The ACP bridge behind Grok: its routes, sessions, saved state and change evidence.",
28536
+ events: {
28537
+ "command-change.record-failed": "A measured command change could not be recorded.",
28538
+ "evidence.record-failed": "Change evidence could not be recorded; the read loop carries on.",
28539
+ "evidence.shell-record-failed": "A shell observation could not be recorded.",
28540
+ "evidence.turn-record-failed": "Turn change evidence could not be recorded.",
28541
+ "server.listening": "The HTTP server is listening.",
28542
+ "state.composer-reset": "A saved composer state was malformed and was reset.",
28543
+ "state.discarded": "Saved bridge state could not be used and was discarded.",
28544
+ "state.persist-failed": "Saving bridge state failed; a later write retries.",
28545
+ "state.session-config-reset": "A saved session configuration was malformed and was reset."
28546
+ }
28547
+ },
28548
+ "bridge.claude": {
28549
+ description: "The Claude bridge: its routes, sessions, parked interactions and the Agent SDK turn loop.",
28550
+ events: {
28551
+ "commands.read-failed": "The command catalogue read failed; the cached answer stands.",
28552
+ "context-usage.read-failed": "The detailed context usage read failed; the route falls back.",
28553
+ "dispatch.rollback-failed": "Rolling back a prompt dispatch claim failed.",
28554
+ "event-subscriber.failed": "An event subscriber threw; other subscribers still ran.",
28555
+ "http.request-failed": "An HTTP route threw; it answered 500.",
28556
+ "mcp.config-ignored": "An MCP server configuration of an unsupported shape was ignored.",
28557
+ "mcp.read-failed": "Listing MCP servers failed; the route answered 500.",
28558
+ "models.fetch-failed": "Reading the supported models failed; the fallback catalogue is served.",
28559
+ "models.requested": "The model catalogue route was called.",
28560
+ "models.responded": "The model catalogue route answered.",
28561
+ "parent.gone": "The backend that launched this bridge has gone; shutting down.",
28562
+ "plan-approval.responding": "Answering a parked plan approval.",
28563
+ "plan-approval.response-failed": "The plan approval route failed.",
28564
+ "plan-approval.response-received": "The route received a plan approval answer.",
28565
+ "plan-approval.result": "A parked plan approval was answered.",
28566
+ "plan-approval.wait-failed": "A parked plan approval ended without an answer: cancelled, timed out or closed.",
28567
+ "plan-exit.failure-overridden": "ExitPlanMode failed after the user approved; treated as success with a continuation re-prompt.",
28568
+ "plan-mode.record-failed": "Plan mode from a status frame could not be recorded.",
28569
+ "plan.reprompt-approved-failed": "Re-prompting after an approved plan failed.",
28570
+ "plan.reprompt-feedback-failed": "Re-prompting with plan rejection feedback failed.",
28571
+ "plugin.path-missing": "A configured plugin was skipped because its path does not exist.",
28572
+ "plugin.unsafe-path": "An installed plugin was skipped because its install path is unsafe.",
28573
+ "plugins.read-failed": "Listing plugins failed; the route answered 500.",
28574
+ "prompt.accepted": "The route accepted a prompt and answered 202.",
28575
+ "prompt.failed": "A prompt turn failed; the session reports the error.",
28576
+ "prompt.processing-failed": "A prompt accepted by the route failed while processing.",
28577
+ "prompt.received": "A prompt reached the bridge; only its length is logged.",
28578
+ "prompt.send-failed": "A prompt request failed; the route answered with an error.",
28579
+ "query.close-failed": "Stopping the Claude query failed while closing a tab; the close stays pending.",
28580
+ "query.failed": "A Claude query ended with an error result.",
28581
+ "question.answer-failed": "The answer-question route failed.",
28582
+ "question.answering": "Answering a parked question.",
28583
+ "question.answers-prepared": "The route prepared a question answer for the session.",
28584
+ "question.answers-received": "A parked question received its answers.",
28585
+ "question.stale": "An answer arrived for a question no longer pending; the route answered stale.",
28586
+ "question.wait-failed": "A parked question ended without an answer: cancelled, timed out or closed.",
28587
+ "runtime.ended-under-resumed-turn": "The Claude runtime ended while a resumed root turn was still open.",
28588
+ "server.listening": "The HTTP server is listening.",
28589
+ "server.starting": "The HTTP server is about to bind.",
28590
+ "session.compact-failed": "A requested compaction failed.",
28591
+ "session.create-failed": "Creating a session failed; the route answered with an error.",
28592
+ "session.created": "A session was created or recovered.",
28593
+ "session.delete-failed": "Deleting a session failed.",
28594
+ "session.fork-failed": "Forking a session failed.",
28595
+ "session.rename-failed": "Renaming a session failed.",
28596
+ "session.resolve-failed": "A session could not be found or loaded for a request; action names the request.",
28597
+ "session.rewind-failed": "Rewinding session files failed.",
28598
+ "session.task-state-hydrate-failed": "Hydrating session task state failed; the route answered with an error.",
28599
+ "sessions.reconcile-failed": "Reconciling persisted sessions failed; the sessions already known are listed.",
28600
+ "sse.aborted": "The client closed an event stream.",
28601
+ "sse.cleanup": "An event stream connection was released.",
28602
+ "sse.closed": "An event stream was closed by the bridge; the client reconnects and replays.",
28603
+ "sse.handshake-failed": "An event stream failed during its handshake; the client reconnects.",
28604
+ "sse.keepalive-failed": "An event stream keepalive failed, usually a client that has gone; the connection closes.",
28605
+ "sse.opened": "An event stream connection opened.",
28606
+ "sse.subscribe-requested": "A client asked to subscribe to the event stream.",
28607
+ "sse.write-failed": "Writing to an event stream failed; the connection closes and the client reconnects.",
28608
+ "task.candidate-bound-reached": "An unresolved Bash call was not tracked as a background task: the candidate bound is full.",
28609
+ "task.details-persist-failed": "Shell task details could not be saved; the task carries on.",
28610
+ "task.settling-bound-reached": "A settling task was not tracked: the settling bound is full.",
28611
+ "task.stop-failed": "Stopping a background task failed on a control channel that had closed.",
28612
+ "task.stop-route-failed": "The stop-task route failed.",
28613
+ "transcript.background-hydrate-failed": "Hydrating a transcript in the background failed; the next read retries.",
28614
+ "transcript.hydrate-failed": "Hydrating a transcript before a prompt failed; the prompt runs and a later read retries."
28615
+ }
28616
+ },
28617
+ "bridge.codex": {
28618
+ description: "The Codex bridge: its routes, sessions and the app-server child it supervises.",
28619
+ events: {
28620
+ "account.connector-recovery-failed": "Recovering account connectors failed; the account answer stands.",
28621
+ "account.login-reload-failed": "Reloading the stored account login failed.",
28622
+ "account.sign-in-check-failed": "An account sign-in check failed; admission is left unchanged.",
28623
+ "account.usage-read-failed": "Reading account usage failed; the route answers 503.",
28624
+ "app-server.drain-expired": "The drain deadline expired, so app-server restarted with turns still in flight.",
28625
+ "app-server.exited": "app-server exited unexpectedly; the code and signal say how.",
28626
+ "app-server.invariant-violation": "app-server asked for something its configuration forbids.",
28627
+ "app-server.protocol-violation": "app-server wrote a line that is not valid protocol; it was ignored.",
28628
+ "app-server.recording": "Notification recording is on; recordings hold content.",
28629
+ "app-server.stale-reaped": "A stale app-server left by an earlier bridge was stopped.",
28630
+ "app-server.stderr": "Metadata of an app-server stderr line, never its content.",
28631
+ "app-server.stderr-suppressed": "app-server stderr lines beyond the budget were counted, not described.",
28632
+ "approval.cancel-failed": "Cancelling a turn after an approval answer failed.",
28633
+ "approval.present-failed": "Presenting an approval threw; it is auto-declined.",
28634
+ "approval.resolved-callback-failed": "An approval resolved callback threw.",
28635
+ "command-changes.record-failed": "Recording line changes for a command failed; the turn carries on.",
28636
+ "dispatch.reconcile-failed": "A dispatch could not be reconciled against its thread; it stays recovering.",
28637
+ "dispatch.restore-failed": "A journaled dispatch could not be restored after a restart; recovery retries.",
28638
+ "engine.listener-failed": "An engine event listener threw; the others still ran.",
28639
+ "engine.ready": "The app-server engine started.",
28640
+ "engine.start-failed": "The app-server engine failed to start; reported through health.",
28641
+ "engine.stop-failed": "Stopping the Codex engine failed during shutdown; the bridge exits anyway.",
28642
+ "generation.recovery-failed": "Recovering sessions after an app-server generation change failed.",
28643
+ "http.request-failed": "An HTTP route threw; it answered 500.",
28644
+ "idle-sweep.failed": "An idle sweep failed; the next one retries.",
28645
+ "interaction.present-failed": "Presenting an interaction threw; it is cancelled.",
28646
+ "interaction.resolved-callback-failed": "An interaction resolved callback threw.",
28647
+ "journal.persist-failed": "Saving the dispatch journal failed.",
28648
+ "message.publish-failed": "Publishing a message update failed.",
28649
+ "models.cache-persist-failed": "Saving the model cache failed.",
28650
+ "models.debug-read-failed": "`codex debug models` failed; another source is used.",
28651
+ "models.list-failed": "model/list failed; the cached models are served.",
28652
+ "models.refresh-failed": "A background model refresh failed; the cache stands.",
28653
+ "notification.enqueue-failed": "Queueing a notification threw.",
28654
+ "ordered-events.flush-failed": "Flushing before ordered-event reconciliation failed.",
28655
+ "ordered-events.publish-failed": "Publishing an ordered event failed; clients are told to rehydrate.",
28656
+ "ordered-events.reconcile-failed": "Reconciling ordered events failed.",
28657
+ "parent.gone": "The backend that launched this bridge has gone; stopping turns and shutting down.",
28658
+ "queue.task-failed": "A task on a per-thread queue failed.",
28659
+ "raw-log.write-failed": "Appending to the raw Codex log failed.",
28660
+ "recorder.notice": "The notification recorder needs attention: it is on, or was asked for without its confirmation.",
28661
+ "recorder.threw": "The notification recorder threw.",
28662
+ "recorder.write-failed": "Writing a notification recording failed; its lines were dropped.",
28663
+ "registry.persist-failed": "Saving the session registry failed; a later write retries.",
28664
+ "rollout.hydrate-failed": "A rollout could not be read to hydrate a thread.",
28665
+ "runtime-env.refresh-failed": "Refreshing the runtime environment failed; the last values stay.",
28666
+ "runtime-env.refreshed": "Runtime environment variables changed; names only, never values.",
28667
+ "server-request.answer-failed": "Answering a server request failed.",
28668
+ "server-request.flush-timeout": "An answer to a server request did not flush in time.",
28669
+ "server-request.handoff-failed": "Handing a server request to the router threw.",
28670
+ "session.config-apply-failed": "Applying session configuration failed; the route answers unavailable.",
28671
+ "sse.closed": "An event stream was closed by the bridge; the client reconnects and replays.",
28672
+ "sse.keepalive-failed": "An event stream keepalive failed.",
28673
+ "sse.observer-failed": "An event stream observer failed; it reconnects.",
28674
+ "sse.payload-serialize-failed": "An event payload could not be serialized; a placeholder was sent.",
28675
+ "sse.payload-snapshot-failed": "An event payload could not be snapshotted; a placeholder was sent.",
28676
+ "sse.subscriber-failed": "An event stream subscriber failed; it reconnects and replays.",
28677
+ "subagent.activity-load-failed": "Sub-agent activity could not be loaded; the transcript renders without it.",
28678
+ "thread.archive-failed": "Archiving or unarchiving a thread failed.",
28679
+ "thread.fork-failed": "thread/fork failed; the route answers 503.",
28680
+ "thread.fork-hydrate-failed": "A forked thread could not be hydrated and was closed.",
28681
+ "thread.reattach-failed": "A thread could not be re-attached.",
28682
+ "thread.rename-failed": "thread/name/set failed; the bridge title index stays authoritative.",
28683
+ "thread.turns-read-after-revert-failed": "A thread's turns could not be read after a revert.",
28684
+ "thread.turns-read-failed": "A thread's turns could not be read.",
28685
+ "thread.unsubscribe-failed": "thread/unsubscribe failed; the binding is kept so a retry can unsubscribe.",
28686
+ "threads.list-failed": "thread/list failed; sessions come from the rollout parser.",
28687
+ "transcript.serving-last-known": "A thread read failed, so the last known transcript is served.",
28688
+ "turn.capacity-retry-failed": "Retrying a turn after a capacity failure failed.",
28689
+ "turn.capacity-retry-journal-failed": "A capacity retry could not be journaled.",
28690
+ "turn.finalize-failed": "Finalizing a turn failed.",
28691
+ "turns.stopped": "Running turns were stopped because the backend went away."
28692
+ }
28693
+ },
28694
+ "bridge.cursor": {
28695
+ description: "The Cursor bridge: its routes, sessions and saved state.",
28696
+ events: {
28697
+ "agent.archive-failed": "Archiving or unarchiving an agent failed.",
28698
+ "http.route-failed": "An HTTP route failed unexpectedly; its error is not logged because it can hold content.",
28699
+ "startup.closes-failed": "Finishing closes a previous process left behind failed at startup.",
28700
+ "startup.closes-incomplete": "Some closes a previous process left behind did not finish at startup; a retried close finishes them.",
28701
+ "state.publication-failing": "Saving bridge state is failing; new prompts and steers are refused until it recovers.",
28702
+ "state.publication-recovered": "Saving bridge state recovered.",
28703
+ "state.transcripts-shortened": "The state file reached its limit, so some sessions were saved with a shortened transcript copy."
28704
+ }
28705
+ },
28706
+ "bridge.pi": {
28707
+ description: "The Pi bridge: its routes, sessions and saved state.",
28708
+ events: {
28709
+ "http.route-failed": "An HTTP route failed unexpectedly; its error is not logged because it can hold content.",
28710
+ "state.over-budget": "The state file stayed over budget after shedding transcripts, so the write was skipped.",
28711
+ "state.transcripts-shed": "The state file was over budget, so some sessions were saved without their transcript."
28712
+ }
28713
+ }
28714
+ });
28715
+
28716
+ // ../protocol/src/log-vocabulary/desktop.ts
28717
+ var DESKTOP_LOG_AREAS = defineLogAreas({
28718
+ desktop: {
28719
+ description: "The Electron main process: startup, windows, quit and the Local backend's life.",
28720
+ events: {
28721
+ "backend.docker-context-seed-failed": "An agent-test profile fell back to the default Docker context.",
28722
+ "backend.exited": "The Local backend exited unexpectedly; Local work is unavailable.",
28723
+ "backend.exited-recovering": "The Local backend exited just after a remote update; relaunching unattended.",
28724
+ "backend.keychain-link-remove-failed": "An agent-test profile kept a legacy link to the host keychain.",
28725
+ "backend.start-failed": "The Local backend did not start; continuing with remote machines.",
28726
+ "clipboard.write-failed": "Writing text to the system clipboard failed.",
28727
+ "instance.already-running": "Another instance holds this data directory; this one will quit.",
28728
+ "main-thread.stalled": "A timer fired late, so windows, IPC and the stdout reader waited.",
28729
+ "quit.stopping-backend": "The app is quitting and has asked the Local backend to stop.",
28730
+ "relaunch.schedule-failed": "The AppImage relaunch waiter failed; using Electron's relauncher.",
28731
+ "relaunch.service-register-failed": "The AppImage relaunch service was refused; using a detached waiter.",
28732
+ "renderer.gone-giving-up": "A renderer kept dying, so the window is no longer reloaded.",
28733
+ "renderer.gone-reloading": "A renderer died and the window is being reloaded.",
28734
+ "renderer.reload-failed": "Reloading a window after its renderer died failed.",
28735
+ "restart-prompt.failed": "A native restart prompt could not be shown.",
28736
+ "saved-machines.attach-failed": "Saved machines were not imported into the command node yet.",
28737
+ "saved-machines.attached": "Saved machines were imported into the local command node.",
28738
+ "startup.failed": "The application failed to start.",
28739
+ "uncaught-exception": "The main process hit an uncaught exception.",
28740
+ "uncaught-exception.dialog-failed": "The uncaught exception sheet could not be shown.",
28741
+ "window.create-failed": "A menu-driven new window could not be created.",
28742
+ "window.recreate-failed": "The main window could not be recreated on activation.",
28743
+ "window.second-launch-failed": "A second launch could not open a window."
28744
+ }
28745
+ },
28746
+ "desktop.startup": {
28747
+ description: "Renderer startup markers and renderer process failures. These are the only events the renderer can place in the persistent log.",
28748
+ tag: "DesktopStartup",
28749
+ events: {
28750
+ "backend-unavailable": "The renderer could not complete a Local backend read in time.",
28751
+ "bridge-unavailable": "The preload API or connection-list IPC did not answer.",
28752
+ checking: "The renderer began waiting for the desktop connection.",
28753
+ "page-load-failed": "Chromium failed to load the main document.",
28754
+ "preload-failed": "Electron rejected the preload script.",
28755
+ ready: "The renderer reached the desktop connection and may mount the workspace.",
28756
+ "renderer-error": "An uncaught error occurred while the renderer was starting.",
28757
+ "renderer-gone": "A renderer process exited.",
28758
+ "renderer-load-failed": "Importing or mounting the application failed.",
28759
+ "unhandled-rejection": "An unhandled rejection occurred while the renderer was starting."
28760
+ }
28761
+ },
28762
+ "desktop.dialog": {
28763
+ description: "Native dialogs, whose modal loops hold the main thread while they are open.",
28764
+ events: {
28765
+ "attention-failed": "A dialog could not ask for the user's attention.",
28766
+ closed: "A native dialog closed.",
28767
+ "open-failed": "A dialog could not open; it was answered as cancelled.",
28768
+ opening: "A native dialog is opening.",
28769
+ "preview-beforeunload-ignored": "A browser preview's beforeunload handler was ignored.",
28770
+ "renderer-beforeunload-cancelled": "A renderer's beforeunload handler cancelled an unload."
28771
+ }
28772
+ },
28773
+ "backend.client": {
28774
+ description: "The desktop's HTTP and event stream client for a backend.",
28775
+ events: {
28776
+ "event-stream.disconnected": "The event stream dropped; the client reconnects with backoff.",
28777
+ "event-stream.malformed-frame": "An event stream frame could not be parsed and was dropped."
28778
+ }
28779
+ },
28780
+ connections: {
28781
+ description: "The desktop's saved machines and active connection.",
28782
+ events: {
28783
+ "catalogue.legacy-read-failed": "The previous connection list could not be read to migrate.",
28784
+ "catalogue.restored-from-backup": "The device catalogue was unreadable; the backup was used.",
28785
+ "restore.failed": "The previous remote connection could not be restored; using Local.",
28786
+ "secure-storage.waiting": "Startup is waiting on an operating system keychain prompt."
28787
+ }
28788
+ },
28789
+ workspaces: {
28790
+ description: "Workspace realms the desktop holds on other machines.",
28791
+ events: {
28792
+ "route.moved-direct": "A relayed workspace moved to its direct route."
28793
+ }
28794
+ },
28795
+ toolchain: {
28796
+ description: "Preparing the pinned agent toolchain at desktop startup.",
28797
+ events: {
28798
+ "bootstrap-progress.show-failed": "The toolchain progress window could not be shown.",
28799
+ "prepare.failed": "Preparing the pinned agent tools failed."
28800
+ }
28801
+ },
28802
+ "artifact-host": {
28803
+ description: "Live artifact hosts in the desktop app.",
28804
+ events: {
28805
+ "host.ended": "A host ended; fields count its blocked and rejected requests by reason."
28806
+ }
28807
+ }
28808
+ });
28809
+
28810
+ // ../protocol/src/log-vocabulary/environment.ts
28811
+ var ENVIRONMENT_LOG_AREAS = defineLogAreas({
28812
+ environment: {
28813
+ description: "Environment naming, held setup and cleanup after deletion.",
28814
+ events: {
28815
+ "cleanup.branch-kept": "A deleted environment's local branch was kept, as it may hold unmerged work.",
28816
+ "rename.failed": "Naming an environment from its pending prompt failed for the first time.",
28817
+ "rename.still-failing": "That rename is still failing; written at the 2nd, 4th, 8th... failure.",
28818
+ "rename.recovered": "A rename from a pending prompt succeeded after failing.",
28819
+ "setup.attention-not-recorded": "Held setup could not be recorded as needing the user's attention.",
28820
+ "setup.coordinator-not-notified": "The worker's coordinator could not be told that its setup is held for approval.",
28821
+ "setup.unknown-environment": "The renderer was asked to act on the setup of an environment it does not hold.",
28822
+ ...THROTTLE_LOG_EVENTS
28823
+ }
28824
+ }
28825
+ });
28826
+
28827
+ // ../protocol/src/log-vocabulary/gateway.ts
28828
+ var GATEWAY_LOG_AREAS = defineLogAreas({
28829
+ gateway: {
28830
+ description: "The remote gateway other devices and browsers connect through.",
28831
+ events: {
28832
+ "remote.start-failed": "The desktop could not start the remote gateway.",
28833
+ "remote.stop-failed": "The desktop could not stop the remote gateway cleanly."
28834
+ }
28835
+ }
28836
+ });
28837
+
28838
+ // ../protocol/src/log-vocabulary/local-server.ts
28839
+ var LOCAL_SERVER_LOG_AREAS = defineLogAreas({
28840
+ "local-server": {
28841
+ description: "Agent bridge processes the backend runs on the host.",
28842
+ events: {
28843
+ "bridge.not-answering": "A bridge with work in progress fails health checks, so it is not restarted yet.",
28844
+ ...THROTTLE_LOG_EVENTS
28845
+ }
28846
+ }
28847
+ });
28848
+
28849
+ // ../protocol/src/log-vocabulary/git.ts
28850
+ var GIT_LOG_AREAS = defineLogAreas({
28851
+ git: {
28852
+ description: "Git operations the backend runs in environment worktrees and containers.",
28853
+ events: {
28854
+ "branch.rename-failed": "Renaming an environment's branch failed; the stored name is kept.",
28855
+ "branch.push-config-failed": "A branch was renamed but its push settings could not be written; the rename is undone.",
28856
+ "branch.rollback-failed": "Undoing a branch rename failed; the stored name follows whichever branch now exists."
28857
+ }
28858
+ }
28859
+ });
28860
+
28861
+ // ../protocol/src/log-vocabulary/logging.ts
28862
+ var LOGGING_LOG_AREAS = defineLogAreas({
28863
+ logging: {
28864
+ description: "The logger and the on-disk application log themselves.",
28865
+ events: {
28866
+ "capture.started": "Saving logs to disk began for this process.",
28867
+ "capture.stopped": "Saving logs to disk stopped for this process.",
28868
+ "config.invalid": "A logging environment variable held a value that was ignored.",
28869
+ "entries.dropped": "The log queue was full, so entries were dropped and counted.",
28870
+ "policy.changed": "The logging settings changed: saving, retention and levels, with no content.",
28871
+ "policy.bridge-predates-route": "A running bridge has no logging settings route; it applies them at its next start.",
28872
+ "policy.push-failed": "A running bridge did not take the logging settings after retries; its next start resends them.",
28873
+ "prune.failed": "Removing expired log files failed; the next sweep retries.",
28874
+ "write.failed": "Appending to the log file failed.",
28875
+ "unknown-area": "Code outside the type checker asked for an area that is not listed."
28876
+ }
28877
+ }
28878
+ });
28879
+
28880
+ // ../protocol/src/log-vocabulary/models.ts
28881
+ var MODEL_LOG_AREAS = defineLogAreas({
28882
+ models: {
28883
+ description: "Agent model catalogues and their persistent caches.",
28884
+ events: {
28885
+ "cache.write-failed": "A successful catalogue refresh could not update the host cache."
28886
+ }
28887
+ }
28888
+ });
28889
+
28890
+ // ../protocol/src/log-vocabulary/native-agent.ts
28891
+ var NATIVE_AGENT_LOG_AREAS = defineLogAreas({
28892
+ "native-agent": {
28893
+ description: "Native agent sessions and what the backend reads from their bridges.",
28894
+ events: {
28895
+ "catalogue.outdated-bridge": "A bridge predates the command catalogue, so its commands stay unavailable.",
28896
+ ...THROTTLE_LOG_EVENTS
28897
+ }
28898
+ }
28899
+ });
28900
+
28901
+ // ../protocol/src/log-vocabulary/preview.ts
28902
+ var PREVIEW_LOG_AREAS = defineLogAreas({
28903
+ preview: {
28904
+ description: "Browser and service previews: transports, partitions and captures.",
28905
+ events: {
28906
+ "attachment.release-failed": "Releasing a preview attachment failed; its lease expires it.",
28907
+ "capture-spool.load-failed": "The pending browser capture spool could not be loaded.",
28908
+ "certificate.refresh-failed": "Re-reading the preview certificate failed; the next check retries.",
28909
+ "certificate.renewal-refused": "A renewed certificate does not cover the preview hosts, so it was ignored.",
28910
+ "connection-cleanup.record-failed": "A forgotten connection's cleanup could not be recorded.",
28911
+ "link.open-external-failed": "A preview link could not be opened in the system browser.",
28912
+ "node.record-failed": "A node that owns preview partitions could not be recorded.",
28913
+ "partition.clear-failed": "A preview partition could not be cleared.",
28914
+ "partitions.record-cleared-failed": "Cleared preview partitions could not be recorded.",
28915
+ "partitions.record-nodes-failed": "The nodes that own preview partitions could not be saved.",
28916
+ "partitions.remove-failed": "Cleared preview partition directories could not be removed.",
28917
+ "partitions.retry-forgotten-failed": "Retrying a forgotten preview cleanup failed.",
28918
+ "port-hints.persist-failed": "Preview port hints could not be saved.",
28919
+ "transport.close-failed": "A preview transport could not be closed.",
28920
+ ...THROTTLE_LOG_EVENTS
28921
+ }
28922
+ }
28923
+ });
28924
+
28925
+ // ../protocol/src/log-vocabulary/runtime.ts
28926
+ var RUNTIME_LOG_AREAS = defineLogAreas({
28927
+ "event-loop": {
28928
+ description: "This process's event loop. A stall of 10 seconds or more is written at error, so no level hides it.",
28929
+ events: {
28930
+ stalled: "A timer fired late, so every request in that window waited."
28931
+ }
28932
+ }
28933
+ });
28934
+
28935
+ // ../protocol/src/log-vocabulary/terminal.ts
28936
+ var TERMINAL_LOG_AREAS = defineLogAreas({
28937
+ terminal: {
28938
+ description: "The renderer's terminal. Its lines stay in the browser console, never the saved log.",
28939
+ events: {
28940
+ "input.undelivered": "A keystroke did not reach a shell: `no-session` or `not-delivered`.",
28941
+ "input.resume-failed": "Asking the backend to resume refused terminal input failed.",
28942
+ "input.write-failed": "Writing input to a terminal session threw.",
28943
+ "listener.remove-failed": "Removing a terminal output listener threw.",
28944
+ "listener.released": "A terminal hook unmounted and dropped its output listener.",
28945
+ "session.unmounted": "A terminal hook unmounted; the shell keeps running.",
28946
+ "connect.called": "A terminal hook began connecting to a session.",
28947
+ "output.reconcile-failed": "Output could not be reconciled against the backend snapshot.",
28948
+ "session.stopped-while-disconnected": "A session ended while its event stream was down.",
28949
+ "session.disconnect-failed": "Closing or detaching a terminal session failed.",
28950
+ "session.resize-failed": "Resizing a terminal session failed, other than for a gone session.",
28951
+ "session.id-stored": "A new backend session id was saved for a terminal tab.",
28952
+ "session-key.environment-missing": "A local session key was built with no environment id.",
28953
+ "clipboard.image-failed": "An image pasted into a terminal could not be saved.",
28954
+ "clipboard.copy-failed": "Copying a terminal selection to the clipboard failed.",
28955
+ "clipboard.paste-failed": "A paste into a terminal failed; `target` says which path.",
28956
+ "clipboard.process-failed": "Reading or storing clipboard data for a paste failed.",
28957
+ "clipboard.image-save-failed": "An image from a paste event could not be written to disk.",
28958
+ "environment.ready-detected": "A first tab's output showed that the workspace is ready.",
28959
+ "shell.ready-detected": "A later tab's output showed that its shell is ready.",
28960
+ "setup.scripts-completed": "A setup tab's scripts reported their end by an escape code.",
28961
+ "setup.marked-complete": "The user marked a setup tab complete by hand.",
28962
+ "setup.awaiting-detection": "A first tab connected and is watching output for readiness.",
28963
+ "reconnect.setup-marker-found": "A reconnected tab's buffer already held the setup marker.",
28964
+ "reconnect.setup-marker-absent": "A reconnected first tab's buffer lacked the setup marker.",
28965
+ "reconnect.completed": "A terminal tab finished reconnecting to its session.",
28966
+ "restore.setup-marker-found": "A restored tab's buffer already held the setup marker.",
28967
+ "persistent-sessions.load-failed": "Listing an environment's saved sessions failed.",
28968
+ "persistent-session.restoring": "A tab began restoring from its saved session.",
28969
+ "persistent-session.found": "A tab found its saved session already recorded.",
28970
+ "persistent-session.creating": "A tab began recording a saved session for the sidebar.",
28971
+ "persistent-session.created": "A saved session for the sidebar was recorded.",
28972
+ "persistent-session.create-failed": "Recording a saved session for the sidebar failed.",
28973
+ "persistent-session.status-update-failed": "Marking a saved session connected failed.",
28974
+ "persistent-session.activity-update-failed": "Updating a saved session's activity failed.",
28975
+ "persistent-buffer.loaded": "A saved session's buffer loaded; only its length is logged.",
28976
+ "persistent-buffer.load-failed": "A saved session's buffer could not be loaded.",
28977
+ "persistent-buffer.save-failed": "Saving a session's buffer during cleanup failed.",
28978
+ "buffer.restore-failed": "Writing a saved buffer back into a terminal threw.",
28979
+ "buffer.serialize-failed": "Serializing a terminal's buffer during cleanup threw.",
28980
+ "command.launching": "A tab began launching its command in a new session.",
28981
+ "bootstrap.failed": "A launch request for a new session failed; it may retry.",
28982
+ "setup-session.bind-failed": "Looking up or binding the backend setup session failed.",
28983
+ "setup-tab.stale-removed": "A setup placeholder tab with no session was removed.",
28984
+ "multi-reviews.restore-failed": "Multi-review tabs could not be restored for an environment.",
28985
+ "pane-layout.restore-failed": "An environment's saved pane layout could not be read.",
28986
+ "pane-layout.history-migrate-failed": "Stripping private browser history fields failed.",
28987
+ "pane-layout.snapshot-remove-failed": "Removing an unusable pane layout snapshot failed.",
28988
+ "pane-layout.selection-migrate-failed": "Saving a migrated legacy pane selection failed.",
28989
+ "panes.reset": "An environment's panes were reset: its container changed or stopped.",
28990
+ "tabs.limit-reached": "A new tab was refused because the tab limit was reached.",
28991
+ "tab.created": "A new tab was added to a pane; `tabType` says which kind.",
28992
+ "tab.activated": "Opening a file selected the tab that already held it.",
28993
+ "tab.duplicate-refused": "A new tab was refused because its requested id is in use.",
28994
+ "tab.multi-review-refused": "A multi-review tab was refused for lack of a workflow id.",
28995
+ "tab.split-at-edge": "A dragged tab split a pane at one of its edges.",
28996
+ "tab.reordered": "A dragged tab moved within its pane.",
28997
+ "tab.moved": "A dragged tab moved to another pane.",
28998
+ "drag.ended": "A tab drag ended, whether or not it landed on a target.",
28999
+ "display.state": "The terminal container's overlays and tab count, on each dev render.",
29000
+ "compose.draft-restore-failed": "A saved compose draft could not be read.",
29001
+ "compose.draft-persist-failed": "A compose draft could not be saved or discarded.",
29002
+ "compose.image-too-large": "A pasted image stayed over the attachment limit after resizing.",
29003
+ "compose.image-add-failed": "Adding a pasted image to the compose bar failed.",
29004
+ "compose.image-save-failed": "Saving one compose image for sending failed; the rest proceed.",
29005
+ "compose.send-failed": "Sending from the compose bar failed.",
29006
+ "init-logs.load-failed": "A container's initialization logs could not be loaded.",
29007
+ "init-logs.refresh-stopped": "A container's initialization logs stopped refreshing.",
29008
+ "portal.terminal-created": "The portal host created a terminal for a new tab.",
29009
+ "portal.terminal-disposed": "The portal host disposed a terminal for a removed tab.",
29010
+ "link.open-failed": "Opening a terminal link in the external browser failed.",
29011
+ "canvas.context-unavailable": "A resize canvas had no 2D context; the original is kept.",
29012
+ ...THROTTLE_LOG_EVENTS
29013
+ }
29014
+ },
29015
+ "terminal.setup": {
29016
+ description: "The renderer attaching a backend-managed environment setup terminal.",
29017
+ events: {
29018
+ "session.bind-from-environment": "The environment hook bound a setup session to a tab.",
29019
+ "setup.started-received": "An environment-setup-started event arrived.",
29020
+ "setup.complete-received": "An environment-setup-complete event arrived.",
29021
+ "attach.state-changed": "A setup tab's attach inputs changed; runs per effect pass.",
29022
+ "terminal.preserve-failed": "Keeping a setup terminal's buffer before conversion failed.",
29023
+ "tab.marker-retired": "A setup tab with no live PTY stopped being a setup tab.",
29024
+ "tab.added": "The backend-managed setup tab was added to a new layout.",
29025
+ "session.bind-skipped": "A setup session lookup was already running for this tab.",
29026
+ "session.requested": "A tab asked the backend for its setup session.",
29027
+ "session.unavailable": "The backend had no setup session to give a tab.",
29028
+ "session.bind-started": "A backend setup session was found and is being bound to a tab.",
29029
+ "session.awaited": "The layout is waiting for a setup session before adding the tab.",
29030
+ "reconcile.started": "The reconcile effect found setup tabs that still need a session.",
29031
+ "reconnect-listener.install-failed": "Listening for event stream reconnects failed.",
29032
+ "layout.initial-decided": "An empty layout was evaluated for its setup tab; runs per effect."
29033
+ }
29034
+ }
29035
+ });
29036
+
29037
+ // ../protocol/src/log-vocabulary/tmux.ts
29038
+ var TMUX_LOG_AREAS = defineLogAreas({
29039
+ tmux: {
29040
+ description: "The poll loop behind a Claude tmux tab.",
29041
+ events: {
29042
+ "poll.discovery-failed": "Finding the session's transcript failed; a later tick retries.",
29043
+ "poll.snapshot-failed": "Reading the hook and transcript state failed; the next tick retries.",
29044
+ "poll.drain-pending-failed": "Delivering pending hook events failed; the next tick retries.",
29045
+ "poll.drain-timeouts-failed": "Delivering hook timeouts failed; the next tick retries.",
29046
+ "poll.tail-failed": "Reading new transcript lines failed; the next tick retries.",
29047
+ ...THROTTLE_LOG_EVENTS
29048
+ }
29049
+ }
29050
+ });
29051
+
29052
+ // ../protocol/src/log-vocabulary/updater.ts
29053
+ var UPDATER_LOG_AREAS = defineLogAreas({
29054
+ updater: {
29055
+ description: "Desktop self-update: electron-updater and updates a remote client requested.",
29056
+ events: {
29057
+ "channel.following": "Update checks now follow a different release channel.",
29058
+ "check-report.failed": "A check's result could not be reported.",
29059
+ "check.failed": "An update check failed; the next periodic check retries.",
29060
+ "download.failed": "Downloading or staging an update failed.",
29061
+ downloaded: "An update finished downloading.",
29062
+ "library.message": "One line from electron-updater at its own level. Its debug output, which includes the differential download plan, is off by default.",
29063
+ "remote.check-failed": "A check a remote client requested failed.",
29064
+ "remote.installing": "Installing an update for a remote client.",
29065
+ "remote.read-failed": "Update requests could not be read from the Local backend.",
29066
+ "remote.relaunch-prepare-failed": "Preparing the relaunch after a remote update failed.",
29067
+ "remote.relaunched": "The app relaunched to finish a remote client's update.",
29068
+ "remote.report-failed": "An update report could not reach the Local backend.",
29069
+ "remote.restart-not-recorded": "The backend did not record a restart, so it was not installed.",
29070
+ "remote.unavailable": "Updates requested by remote clients are unavailable in this session.",
29071
+ "restart-prompt.failed": "The restart prompt for a downloaded update failed.",
29072
+ unavailable: "Auto-update could not be set up in this session.",
29073
+ "update.failed": "electron-updater reported an update error."
29074
+ }
29075
+ }
29076
+ });
29077
+
29078
+ // ../protocol/src/log-vocabulary/web-annotations.ts
29079
+ var WEB_ANNOTATIONS_LOG_AREAS = defineLogAreas({
29080
+ "web-annotations": {
29081
+ description: "Web annotation requests and their background reconciler.",
29082
+ events: {
29083
+ "reconcile.failed": "A background reconcile pass failed; the next one retries.",
29084
+ ...THROTTLE_LOG_EVENTS
29085
+ }
29086
+ }
29087
+ });
29088
+
29089
+ // ../protocol/src/log-vocabulary/web-app.ts
29090
+ var WEB_APP_LOG_AREAS = defineLogAreas({
29091
+ "web.app": {
29092
+ description: "The application root: startup checks and restoring state.",
29093
+ events: {
29094
+ "config.load-failed": "The application config could not be loaded.",
29095
+ "docker.check-failed": "A Docker availability probe failed; the result stays unknown.",
29096
+ "docker.checked": "A Docker availability check finished.",
29097
+ "docker.orphans-cleared": "Reconciling with Docker cleared orphaned container references.",
29098
+ "docker.sync-failed": "Reconciling environments with Docker failed; non-fatal.",
29099
+ "prompt-queues.restore-failed": "An environment's prompt queues could not be restored.",
29100
+ "multi-reviews.restore-failed": "An environment's multi reviews could not be restored.",
29101
+ "build-pipelines.migrate-failed": "Migrating legacy build pipelines failed; the next launch retries.",
29102
+ "build-pipelines.restore-failed": "A project's build pipelines could not be restored.",
29103
+ "macos-permissions.check-failed": "Reading macOS file permission status failed.",
29104
+ "cli-check.failed": "One startup CLI check failed; its result stays unknown.",
29105
+ "cli-check.completed": "A startup CLI check finished; one line per tool.",
29106
+ "cli-check.retried": "A user-requested CLI recheck finished.",
29107
+ "cli-check.retry-failed": "A user-requested CLI recheck failed.",
29108
+ "exit.failed": "Exiting through the plugin failed; the window closes instead.",
29109
+ "zoom.native-failed": "Applying native zoom failed; the CSS fallback is used.",
29110
+ "github-cli.status-failed": "Reading the GitHub CLI setup status failed.",
29111
+ "attachments.restore-failed": "Saved prompt attachments could not be restored before startup.",
29112
+ "startup-launch.persist-failed": "Saving the startup agent launch failed; nothing started.",
29113
+ "environment.start-failed": "Starting an environment from the terminal overlay failed.",
29114
+ "project.delete-failed": "Deleting a project from its dialog failed."
29115
+ }
29116
+ },
29117
+ "web.session": {
29118
+ description: "The renderer's terminal and agent session store.",
29119
+ events: {
29120
+ "status.update-failed": "A session status change could not be saved.",
29121
+ "activity.update-failed": "A best-effort session activity update failed.",
29122
+ "environment-sessions.disconnect-failed": "Disconnecting an environment's sessions failed.",
29123
+ "container-sessions.sync-failed": "Syncing sessions with container state failed.",
29124
+ "reorder.failed": "Reordering sessions failed; the list reloads from the backend.",
29125
+ "refresh.manual-failed": "A manual refresh of an agent tab failed."
29126
+ }
29127
+ },
29128
+ "web.action-bar": {
29129
+ description: "The environment action bar.",
29130
+ events: {
29131
+ "editor.open-failed": "The external editor could not be opened.",
29132
+ "run-commands.read-failed": "Reading the project's run commands file failed.",
29133
+ "environment.delete-failed": "Deleting an environment from the action bar failed.",
29134
+ "merge.started": "A user-requested PR merge started.",
29135
+ "merge.completed": "A user-requested PR merge command returned.",
29136
+ "merge.failed": "A user-requested PR merge failed."
29137
+ }
29138
+ }
29139
+ });
29140
+
29141
+ // ../protocol/src/log-vocabulary/web-build-pipeline.ts
29142
+ var WEB_BUILD_PIPELINE_LOG_AREAS = defineLogAreas({
29143
+ "web.build-pipeline": {
29144
+ description: "Build pipelines as the renderer starts, hydrates and shows them.",
29145
+ events: {
29146
+ "build.start-failed": "A build could not be started.",
29147
+ "pipeline.hydrate-failed": "A pipeline read failed; source says who asked for it.",
29148
+ "pipeline.project-mismatch": "A pending tab activation was dropped: wrong project.",
29149
+ "environment.not-found": "A build's environment read returned nothing after creation.",
29150
+ "environment.project-mismatch": "A build's environment was not added: wrong project.",
29151
+ "environment.hydrate-failed": "A build's environment read failed; live sync can recover.",
29152
+ "transcript.load-failed": "A stage transcript read failed and will retry with backoff.",
29153
+ "legacy.state-too-large": "Legacy pipeline state was over the limit and skipped.",
29154
+ "opencode-catalog.load-failed": "The cached OpenCode model list could not be loaded.",
29155
+ "opencode-preferences.load-failed": "OpenCode model preferences could not be loaded."
29156
+ }
29157
+ }
29158
+ });
29159
+
29160
+ // ../protocol/src/log-vocabulary/web-chat.ts
29161
+ var WEB_CHAT_LOG_AREAS = defineLogAreas({
29162
+ "web.chat": {
29163
+ description: "Rendering the agent transcript: messages, rich blocks and question cards.",
29164
+ events: {
29165
+ "message.copy-failed": "A message could not be copied to the clipboard.",
29166
+ "message.long-press-failed": "A user message's long-press action failed.",
29167
+ "message.link-open-failed": "A link in a message could not be opened.",
29168
+ "message.render-failed": "One transcript row failed to render; fields are the bounded diagnostic.",
29169
+ "image-preview.load-failed": "An image in a message could not be loaded for preview.",
29170
+ "session-list.load-failed": "The resume dialog could not fetch the resumable sessions.",
29171
+ "question.submit-failed": "An answer to an agent's question could not be submitted.",
29172
+ "question.dismiss-failed": "An agent's question could not be dismissed.",
29173
+ "rich-block.render-failed": "A rich block's renderer failed and its source is shown instead.",
29174
+ "rich-block.copy-failed": "A rich block's copy action could not write to the clipboard.",
29175
+ "scroll-viewport.not-found": "The scroll viewport was still missing when polling for it ended."
29176
+ }
29177
+ },
29178
+ "web.native-agent": {
29179
+ description: "The native agent tab and its composer.",
29180
+ events: {
29181
+ "model-catalogue.load-failed": "The native model catalogue could not be loaded.",
29182
+ "provider-lock.persist-failed": "The locked agent choice could not be saved.",
29183
+ "compose-draft.persist-failed": "A compose draft could not be saved.",
29184
+ "compose-draft.restore-failed": "A saved compose draft could not be restored.",
29185
+ "compose-draft.discard-failed": "A saved compose draft could not be discarded.",
29186
+ "paste.failed": "Pasting an image into a composer failed unexpectedly.",
29187
+ "agent-state.listen-failed": "Subscribing to a tab's agent state events failed.",
29188
+ "model-favorites.persist-failed": "The favorite model list could not be saved."
29189
+ }
29190
+ }
29191
+ });
29192
+
29193
+ // ../protocol/src/log-vocabulary/web-claude-tmux.ts
29194
+ var WEB_CLAUDE_TMUX_LOG_AREAS = defineLogAreas({
29195
+ "web.claude-tmux": {
29196
+ description: "The renderer's Claude tmux chat tab and interactive terminal.",
29197
+ events: {
29198
+ "sessions.list-failed": "The resume dialog could not list tmux sessions.",
29199
+ "tab.hydrate-failed": "Reading a tab's tmux session from the backend failed.",
29200
+ "models.catalog-unavailable": "The model catalogue failed; the bundled fallback stays.",
29201
+ "queue.promote-failed": "After an interrupt, the next queued prompt did not become the draft.",
29202
+ "files.load-failed": "The file list for @mentions could not be loaded.",
29203
+ "clipboard.image-failed": "An image pasted into the interactive terminal could not be saved.",
29204
+ "terminal.resize-failed": "Resizing the interactive terminal's session failed.",
29205
+ "terminal.recover-failed": "The interactive terminal could not reattach to its session."
29206
+ }
29207
+ }
29208
+ });
29209
+
29210
+ // ../protocol/src/log-vocabulary/web-design.ts
29211
+ var WEB_DESIGN_LOG_AREAS = defineLogAreas({
29212
+ "web.design": {
29213
+ description: "Opening design canvas tabs.",
29214
+ events: {
29215
+ "tab.duplicate-refused": "A design tab was not opened because its id is already in use."
29216
+ }
29217
+ }
29218
+ });
29219
+
29220
+ // ../protocol/src/log-vocabulary/web-environment.ts
29221
+ var WEB_ENVIRONMENT_LOG_AREAS = defineLogAreas({
29222
+ "web.environment": {
29223
+ description: "Environment lifecycle and dialogs as the renderer drives them.",
29224
+ events: {
29225
+ "start.called": "The renderer was asked to start an environment.",
29226
+ "start.unknown-environment": "A start was requested for an id the store does not hold.",
29227
+ "start.snapshot-read": "An environment's state as its start began.",
29228
+ "start.status-set": "The environment was marked as creating before the backend call.",
29229
+ "start.background-requested": "A start is being handed to the backend to run in background.",
29230
+ "start.backend-requested": "A foreground start call to the backend is being made.",
29231
+ "start.backend-completed": "The backend finished a foreground start.",
29232
+ "start.environment-refreshed": "An environment was read back after a foreground start.",
29233
+ "start.worktree-missing": "A local environment started with no worktree path.",
29234
+ "start.failed": "Starting an environment from the renderer failed.",
29235
+ "stop.called": "The renderer was asked to stop an environment.",
29236
+ "stop.status-set": "The environment's status was set while stopping it.",
29237
+ "stop.backend-requested": "A stop call to the backend is being made.",
29238
+ "stop.backend-completed": "The backend finished a stop.",
29239
+ "stop.sessions-disconnecting": "A stopped environment's sessions are being disconnected.",
29240
+ "stop.sessions-disconnected": "A stopped environment's sessions were disconnected.",
29241
+ "stop.failed": "Stopping an environment from the renderer failed.",
29242
+ "restart.failed": "Restarting an environment from the renderer failed.",
29243
+ "status-sync.failed": "An environment's status could not be synced from the backend.",
29244
+ "list.refresh-failed": "A background refresh of a project's environments failed.",
29245
+ "setup-snapshot.reconcile-failed": "An environment's setup state could not be reconciled.",
29246
+ "rename.received": "An environment-renamed event arrived.",
29247
+ "rename.pr-state-cleared": "A rename changed the branch, so stale PR state was cleared.",
29248
+ "unread.clear-failed": "An environment's unread work could not be cleared on the backend.",
29249
+ "create.failed": "Creating an environment from the dialog failed.",
29250
+ "create.port-mappings-invalid": "Creation was refused: a port is not between 1 and 65535.",
29251
+ "create.attachment-read-failed": "A file dropped on the create dialog could not be read.",
29252
+ "auto-start.failed": "A background start after creating an environment was rejected.",
29253
+ "models.pi-seed-failed": "The create dialog could not seed the Pi model catalogue.",
29254
+ "models.opencode-cache-load-failed": "The create dialog could not read cached OpenCode models.",
29255
+ "github-credential.check-failed": "The GitHub credential check before creating failed.",
29256
+ "feature-build.start-failed": "Starting a feature build from the dialog failed.",
29257
+ "settings.extensions-load-failed": "The settings dialog could not load extensions.",
29258
+ "settings.container-reset-failed": "The settings dialog could not reset the container.",
29259
+ "settings.save-failed": "The settings dialog could not save.",
29260
+ "domains.test-failed": "Testing whether network whitelist domains resolve failed.",
29261
+ "network-whitelist.save-failed": "The network whitelist dialog could not save."
29262
+ }
29263
+ },
29264
+ "web.sidebar": {
29265
+ description: "The project and environment sidebar.",
29266
+ events: {
29267
+ "reorder.persist-failed": "A sidebar reorder could not be saved.",
29268
+ "fork.failed": "Forking an environment from the sidebar failed.",
29269
+ "auto-start.started": "Selecting an unstarted local environment is starting it.",
29270
+ "auto-start.failed": "Starting a local environment on selection failed.",
29271
+ "environment.stop-failed": "Stopping a selected environment failed.",
29272
+ "environment.restart-failed": "Restarting a selected environment failed.",
29273
+ "environment.delete-failed": "Deleting an environment from the sidebar failed.",
29274
+ "environments.load-failed": "A project's environments could not be loaded for the sidebar.",
29275
+ "project.add-failed": "Adding a project from the sidebar failed.",
29276
+ "project.create-failed": "Creating a project from scratch failed.",
29277
+ "project.delete-failed": "Deleting a project from the sidebar failed.",
29278
+ "folder.project-remove-failed": "A project could not be removed from its folder.",
29279
+ "folder.rename-failed": "A project folder could not be renamed.",
29280
+ "folder.ungroup-failed": "A project folder could not be removed.",
29281
+ "folder.sort-failed": "A project folder could not be sorted."
29282
+ }
29283
+ },
29284
+ "web.docker": {
29285
+ description: "The Docker settings view.",
29286
+ events: {
29287
+ "data.load-failed": "Container or image data could not be loaded.",
29288
+ "container.stop-failed": "Stopping a container from Docker settings failed.",
29289
+ "container.delete-failed": "Deleting a container from Docker settings failed.",
29290
+ "container.reattach-failed": "Reattaching a container to a project failed."
29291
+ }
29292
+ },
29293
+ "web.project": {
29294
+ description: "Adding a project from the renderer.",
29295
+ events: {
29296
+ "directory-picker.failed": "The directory picker could not be opened.",
29297
+ "git-remote.read-failed": "A chosen directory's git remote could not be read."
29298
+ }
29299
+ }
29300
+ });
29301
+
29302
+ // ../protocol/src/log-vocabulary/web-files.ts
29303
+ var WEB_FILES_LOG_AREAS = defineLogAreas({
29304
+ "web.files": {
29305
+ description: "The files panel, file viewer and file search.",
29306
+ events: {
29307
+ "file.save-failed": "A file could not be saved.",
29308
+ "git-changes.load-failed": "The files panel could not load the git changes.",
29309
+ "file-tree.load-failed": "The file tree could not be loaded.",
29310
+ "changes.refresh-failed": "Refreshing the files panel's changes failed.",
29311
+ "folder.load-failed": "An expanded folder's contents could not be loaded.",
29312
+ "path.copy-failed": "A file's path could not be copied to the clipboard.",
29313
+ "draft.persist-failed": "A file viewer tab's draft could not be saved.",
29314
+ "draft.restore-failed": "A file viewer tab's saved draft could not be restored.",
29315
+ "draft.discard-failed": "A file's saved draft could not be discarded before a reload."
29316
+ }
29317
+ }
29318
+ });
29319
+
29320
+ // ../protocol/src/log-vocabulary/web-github.ts
29321
+ var WEB_GITHUB_LOG_AREAS = defineLogAreas({
29322
+ "web.github": {
29323
+ description: "Pull request and GitHub issue views.",
29324
+ events: {
29325
+ "pull-request.url-failed": "A pull request's URL could not be read.",
29326
+ "pull-request.mode-request-failed": "The pull request monitor refused a watch mode request.",
29327
+ "pull-request.copy-failed": "A pull request value could not be copied to the clipboard.",
29328
+ "comment-edit-draft.clear-failed": "An edited comment's saved draft could not be cleared.",
29329
+ "issue-draft.clear-failed": "An edited issue's saved drafts could not be cleared.",
29330
+ "comment-draft.clear-failed": "A posted comment's draft could not be cleared."
29331
+ }
29332
+ },
29333
+ "web.linear": {
29334
+ description: "The Linear tickets view.",
29335
+ events: {
29336
+ "comment-draft.clear-failed": "A posted comment's draft could not be cleared."
29337
+ }
29338
+ }
29339
+ });
29340
+
29341
+ // ../protocol/src/log-vocabulary/web-kanban.ts
29342
+ var WEB_KANBAN_LOG_AREAS = defineLogAreas({
29343
+ "web.kanban": {
29344
+ description: "The Kanban board, its task dialog and project notes.",
29345
+ events: {
29346
+ "tasks.load-failed": "A project's tasks could not be loaded.",
29347
+ "task.add-failed": "A new task could not be added.",
29348
+ "task.update-failed": "A task's fields could not be updated.",
29349
+ "task.content-update-failed": "A task's content edit could not be saved.",
29350
+ "task.build-status-clear-failed": "A task's build status could not be cleared.",
29351
+ "task.delete-failed": "A task could not be deleted.",
29352
+ "task.move-failed": "A task move failed and its status was rolled back.",
29353
+ "comment.add-failed": "A comment could not be added to a task.",
29354
+ "comment.delete-failed": "A comment could not be deleted from a task.",
29355
+ "image.add-failed": "An image could not be added to a task.",
29356
+ "image.delete-failed": "An image could not be deleted from a task.",
29357
+ "notes.load-failed": "Project notes could not be loaded; the editor stays disabled.",
29358
+ "notes.save-failed": "Project notes could not be saved.",
29359
+ "notes.draft-retained": "A notes save failed; the edit stays in its durable draft.",
29360
+ "draft.restore-failed": "A saved create-task draft could not be restored.",
29361
+ "draft.persist-failed": "A create-task draft could not be saved; phase says when.",
29362
+ "draft.discard-failed": "A create-task draft could not be removed; phase says when.",
29363
+ "build.start-failed": "The task dialog could not start a build for a task.",
29364
+ "build.create-and-start-failed": "The task dialog could not create a task and build it."
29365
+ }
29366
+ },
29367
+ "web.feature-plan": {
29368
+ description: "Feature planning in the renderer.",
29369
+ events: {
29370
+ "features.load-failed": "A project's features could not be loaded.",
29371
+ "feature.create-failed": "A new feature could not be created.",
29372
+ "feature.update-failed": "A feature could not be updated.",
29373
+ "build.claim-failed": "A feature's build could not be claimed for a task.",
29374
+ "build.start-failed": "Starting a build from a feature failed.",
29375
+ "message.append-failed": "A message could not be added to a feature's chat.",
29376
+ "story-message.append-failed": "A message could not be added to a story's chat.",
29377
+ "planning.start-failed": "Feature planning could not be started.",
29378
+ "planning.retry-failed": "Feature planning could not be retried.",
29379
+ "planning.cancel-failed": "Feature planning could not be cancelled.",
29380
+ "drafts.persist-failed": "A project's feature chat drafts could not be saved.",
29381
+ "drafts.restore-failed": "A project's feature chat drafts could not be restored."
29382
+ }
29383
+ }
29384
+ });
29385
+
29386
+ // ../protocol/src/log-vocabulary/web-pane-layout.ts
29387
+ var WEB_PANE_LAYOUT_LOG_AREAS = defineLogAreas({
29388
+ "web.pane-layout": {
29389
+ description: "Panes and tabs in the renderer: moves, splits, teardown and saved layouts.",
29390
+ events: {
29391
+ "persist.failed": "A pane layout could not be written to the backend.",
29392
+ "persist.install-skipped": "A saved layout was not installed: its dependencies did not load.",
29393
+ "persist.settled-handler-failed": "A write-settled handler threw; later handlers still ran.",
29394
+ "environment.activated": "The active environment changed.",
29395
+ "environment.initialized": "An environment's pane state was initialized.",
29396
+ "environment.initialize-skipped": "Initialize was called with no active environment.",
29397
+ "environment.terminals-cleared": "A reset cleared the environment's terminal instances.",
29398
+ "terminal-session.cleanup-started": "A closed tab's terminal session is being cleaned up.",
29399
+ "teardown.pending": "A tab teardown was rejected; the backend keeps it pending and retries.",
29400
+ "browser-preview.destroy-failed": "Destroying a closed browser tab's preview failed.",
29401
+ "handoffs.prune-failed": "Pruning unreferenced agent handoffs failed.",
29402
+ "tab.reactivated": "A tab added twice was activated in its existing pane instead.",
29403
+ "tab.move-started": "A tab move passed its checks and is being applied.",
29404
+ "tab.move-failed": "A tab move was refused; `reason` says which lookup failed.",
29405
+ "tab.initial-prompt-cleared": "A tab's initial prompt was cleared.",
29406
+ "tab.initial-agent-options-cleared": "A tab's initial agent options were cleared.",
29407
+ "pane.split-depth-reached": "A split was refused at the maximum split depth.",
29408
+ "pane.edge-split-started": "An edge split passed its checks and is being applied.",
29409
+ "pane.edge-split-failed": "An edge split was refused; `reason` says which lookup failed.",
29410
+ "pane.close-refused": "Closing the only pane in a layout was refused.",
29411
+ "draft.discard-failed": "A closing tab's draft could not be discarded; the tab stayed open.",
29412
+ "draft.file-conflict-resolve-failed": "Discarding a newer saved file draft failed.",
29413
+ "draft.compose-conflict-resolve-failed": "Discarding a newer saved compose draft failed."
29414
+ }
29415
+ }
29416
+ });
29417
+
29418
+ // ../protocol/src/log-vocabulary/web-settings.ts
29419
+ var WEB_SETTINGS_LOG_AREAS = defineLogAreas({
29420
+ "web.settings": {
29421
+ description: "The settings screens.",
29422
+ events: {
29423
+ "config.save-failed": "Global settings could not be saved.",
29424
+ "config.load-failed": "The settings page could not load the config.",
29425
+ "config.reload-failed": "Re-reading the workspace config after a save failed.",
29426
+ "domains.test-failed": "The domain resolution test could not run.",
29427
+ "github-credentials.propagate-failed": "Propagating GitHub credentials to environments failed.",
29428
+ "credential.save-failed": "A credential could not be saved.",
29429
+ "credential.clear-failed": "A credential could not be cleared.",
29430
+ "gateway-token.save-failed": "The gateway token could not be saved.",
29431
+ "gateway-token.copy-failed": "Copying the gateway token to the clipboard failed.",
29432
+ "web-client-url.copy-failed": "Copying the web client address to the clipboard failed.",
29433
+ "backend-version.read-failed": "The debug tab could not read the backend version.",
29434
+ "messaging.flush-failed": "Saving pending messaging settings on unmount failed.",
29435
+ "directory-picker.failed": "The repository directory picker could not open.",
29436
+ "file-picker.failed": "The repository file picker could not open.",
29437
+ "repository.save-failed": "Repository settings could not be saved.",
29438
+ "model-catalogues.read-failed": "Reading the model catalogues for settings failed."
29439
+ }
29440
+ }
29441
+ });
29442
+
29443
+ // ../protocol/src/log-vocabulary/web-shell.ts
29444
+ var WEB_SHELL_LOG_AREAS = defineLogAreas({
29445
+ "web.startup": {
29446
+ description: "Loading the renderer, after the desktop connection check.",
29447
+ events: {
29448
+ "renderer.load-failed": "Importing or mounting the application failed.",
29449
+ "model-catalogue.restore-failed": "The cached model catalogue could not be restored; bundled fallbacks stay in use."
29450
+ }
29451
+ },
29452
+ "web.window": {
29453
+ description: "Errors nothing in the renderer caught. Bug reports classify these two lines.",
29454
+ events: {
29455
+ "error.unhandled": "A window error event reached the bootstrap handler.",
29456
+ "rejection.unhandled": "A promise rejected with no handler."
29457
+ }
29458
+ },
29459
+ "web.react": {
29460
+ description: "React's root error callbacks and the lazy view boundary.",
29461
+ events: {
29462
+ "root.caught-error": "An error boundary caught a render error.",
29463
+ "root.uncaught-error": "A render error reached the root with no boundary.",
29464
+ "root.recoverable-error": "React recovered from a render error by retrying.",
29465
+ "lazy-view.failed": "A lazily loaded view failed; fields are the bounded diagnostic."
29466
+ }
29467
+ }
29468
+ });
29469
+
29470
+ // ../protocol/src/log-vocabulary/web-sync.ts
29471
+ var WEB_SYNC_LOG_AREAS = defineLogAreas({
29472
+ "web.resource-sync": {
29473
+ description: "Keeping renderer stores current with backend resources.",
29474
+ events: {
29475
+ "handler.threw": "A resource change handler threw; other handlers still ran.",
29476
+ "resync-handler.threw": "A resync handler threw; the resync counts as failed.",
29477
+ "view-safety-check.threw": "A view safety check handler threw; the others still ran.",
29478
+ "snapshots.batch-failed": "A scoped snapshot batch failed; individual reads take over.",
29479
+ "manifest.scoped-check-failed": "The scoped manifest read failed; a full resync runs.",
29480
+ "manifest.check-failed": "The manifest read failed; a full resync runs.",
29481
+ "subscribe.failed": "Subscribing to a resource transport event failed.",
29482
+ "change.malformed": "A resource-changed payload had the wrong shape and was dropped.",
29483
+ "config.refresh-failed": "Refreshing the config store after a change failed.",
29484
+ "pane-layout.refresh-failed": "Refreshing an environment's pane layout failed.",
29485
+ "setup-completion.observe-failed": "Subscribing to setup completion events failed.",
29486
+ "resync.project-failed": "The authoritative project read failed during a store resync.",
29487
+ "resync.environment-failed": "The authoritative environment read failed during a resync.",
29488
+ "resync.read-failed": "One of a store resync's per-environment reads failed.",
29489
+ "resync.pane-failed": "A pane layout read failed during a store resync.",
29490
+ "agent-mail.summary-refresh-failed": "Refreshing the agent mail summary failed.",
29491
+ "agent-mail.mailbox-refresh-failed": "Refreshing one agent mailbox failed.",
29492
+ "prompt-queues.refresh-failed": "Refreshing an environment's prompt queues failed.",
29493
+ "build-pipeline.refresh-failed": "Refreshing one build pipeline failed.",
29494
+ "multi-review.refresh-failed": "Refreshing one multi review workflow failed.",
29495
+ "authoritative.resync-failed": "Re-reading a snapshot after a stream reconnect failed.",
29496
+ "observation.listener-threw": "A native observation invalidation listener threw.",
29497
+ "observation.subscribe-failed": "Subscribing to native observation events failed.",
29498
+ "hydration.status-listener-failed": "A bounded hydration status listener threw.",
29499
+ "hydration.notification-failed": "A bounded hydration change notification threw."
29500
+ }
29501
+ },
29502
+ "web.read-coordinator": {
29503
+ description: "The renderer's coalesced, bounded backend reads.",
29504
+ events: {
29505
+ "listener.threw": "A read state listener threw.",
29506
+ "read.settle-failed": "Applying a finished read's result threw."
29507
+ }
29508
+ },
29509
+ "web.gateway": {
29510
+ description: "The renderer's connection to the gateway: requests and event streams.",
29511
+ events: {
29512
+ "events.disconnected": "The main event stream dropped; it reconnects and replays.",
29513
+ "terminal-stream.disconnected": "A terminal event stream dropped; it reconnects.",
29514
+ "connection-listener.failed": "A main stream connection state listener threw.",
29515
+ "event-listener.failed": "A listener for a gateway event threw.",
29516
+ "stream-listener.failed": "A listener for the stream-connected notice threw."
29517
+ }
29518
+ },
29519
+ "web.federation": {
29520
+ description: "Events from federated nodes as the renderer receives them.",
29521
+ events: {
29522
+ "resync-handler.failed": "A node resync handler failed.",
29523
+ "event-handler.failed": "A handler for an event relayed from a node failed.",
29524
+ "environment.start-failed": "Starting an environment opened in a workspace window failed."
29525
+ }
29526
+ }
29527
+ });
29528
+
29529
+ // ../protocol/src/log-vocabulary/index.ts
29530
+ var LOG_VOCABULARY = {
29531
+ ...AGENT_MAIL_LOG_AREAS,
29532
+ ...BACKEND_LOG_AREAS,
29533
+ ...BRIDGE_LOG_AREAS,
29534
+ ...DESKTOP_LOG_AREAS,
29535
+ ...ENVIRONMENT_LOG_AREAS,
29536
+ ...GATEWAY_LOG_AREAS,
29537
+ ...LOCAL_SERVER_LOG_AREAS,
29538
+ ...GIT_LOG_AREAS,
29539
+ ...LOGGING_LOG_AREAS,
29540
+ ...MODEL_LOG_AREAS,
29541
+ ...NATIVE_AGENT_LOG_AREAS,
29542
+ ...PREVIEW_LOG_AREAS,
29543
+ ...RUNTIME_LOG_AREAS,
29544
+ ...TERMINAL_LOG_AREAS,
29545
+ ...TMUX_LOG_AREAS,
29546
+ ...UPDATER_LOG_AREAS,
29547
+ ...WEB_ANNOTATIONS_LOG_AREAS,
29548
+ ...WEB_APP_LOG_AREAS,
29549
+ ...WEB_BUILD_PIPELINE_LOG_AREAS,
29550
+ ...WEB_CHAT_LOG_AREAS,
29551
+ ...WEB_CLAUDE_TMUX_LOG_AREAS,
29552
+ ...WEB_DESIGN_LOG_AREAS,
29553
+ ...WEB_ENVIRONMENT_LOG_AREAS,
29554
+ ...WEB_FILES_LOG_AREAS,
29555
+ ...WEB_GITHUB_LOG_AREAS,
29556
+ ...WEB_KANBAN_LOG_AREAS,
29557
+ ...WEB_PANE_LAYOUT_LOG_AREAS,
29558
+ ...WEB_SETTINGS_LOG_AREAS,
29559
+ ...WEB_SHELL_LOG_AREAS,
29560
+ ...WEB_SYNC_LOG_AREAS
29561
+ };
29562
+
29563
+ // ../protocol/src/logger.ts
29564
+ var LOG_LEVELS = ["error", "warn", "info", "debug", "trace"];
29565
+ var MAX_FIELD_CHARS = 2048;
29566
+ var TRUNCATION_MARKER_RESERVE = 32;
29567
+ var MAX_FIELDS = 32;
29568
+ var FIELD_NAME_PATTERN = /^[A-Za-z][\w.-]{0,63}$/;
29569
+ var BARE_TEXT_VALUE = /^[\w./:@+,~-]+$/;
29570
+ var THROTTLE_KIND_PATTERN = /^[\w.:-]{1,64}$/;
29571
+ var MAX_THROTTLE_SCOPE_CHARS = 128;
29572
+ var FORBIDDEN_FIELD_NAMES = new Set([
29573
+ "stdout",
29574
+ "stderr",
29575
+ "cmd",
29576
+ "spawnargs",
29577
+ "prompt",
29578
+ "token",
29579
+ "password",
29580
+ "secret",
29581
+ "authorization",
29582
+ "apikey",
29583
+ "cookie",
29584
+ "credentials"
29585
+ ]);
29586
+ var LEVEL_RANK = {
29587
+ error: 0,
29588
+ warn: 1,
29589
+ info: 2,
29590
+ debug: 3,
29591
+ trace: 4
29592
+ };
29593
+ var OUTPUT_METHOD = {
29594
+ error: "error",
29595
+ warn: "warn",
29596
+ info: "info",
29597
+ debug: "debug",
29598
+ trace: "debug"
29599
+ };
29600
+ var consoleSink = ({ method, line }) => {
29601
+ console[method](line);
29602
+ };
29603
+ var DEFAULT_CONFIG = {
29604
+ level: "info",
29605
+ areaLevels: {},
29606
+ format: "text",
29607
+ sink: consoleSink
29608
+ };
29609
+ var config2 = DEFAULT_CONFIG;
29610
+ var generation = 0;
29611
+ function configureLogger(change) {
29612
+ config2 = { ...config2, ...change };
29613
+ generation += 1;
29614
+ }
29615
+ function isLogLevel(value) {
29616
+ return typeof value === "string" && LOG_LEVELS.includes(value);
29617
+ }
29618
+ function areaSpec(area) {
29619
+ return Object.hasOwn(LOG_VOCABULARY, area) ? LOG_VOCABULARY[area] : undefined;
29620
+ }
29621
+ function thresholdRank(area) {
29622
+ for (let scope = area;; scope = scope.slice(0, scope.lastIndexOf("."))) {
29623
+ const level = Object.hasOwn(config2.areaLevels, scope) ? config2.areaLevels[scope] : undefined;
29624
+ if (level)
29625
+ return LEVEL_RANK[level];
29626
+ if (!scope.includes("."))
29627
+ return LEVEL_RANK[config2.level];
29628
+ }
29629
+ }
29630
+ function boundedString(value, maxChars) {
29631
+ if (value.length <= maxChars)
29632
+ return value;
29633
+ const kept = maxChars - TRUNCATION_MARKER_RESERVE;
29634
+ return `${value.slice(0, kept)}...[truncated ${value.length - kept} chars]`;
29635
+ }
29636
+ function sanitizeValue(name, value, maxChars) {
29637
+ if (FORBIDDEN_FIELD_NAMES.has(name.toLowerCase().replace(/[-_.]/g, "")))
29638
+ return "[forbidden]";
29639
+ switch (typeof value) {
29640
+ case "string":
29641
+ return boundedString(value, maxChars);
29642
+ case "number":
29643
+ return Number.isFinite(value) ? value : String(value);
29644
+ case "boolean":
29645
+ return value;
29646
+ case "undefined":
29647
+ return;
29648
+ case "bigint":
29649
+ return value.toString();
29650
+ case "object":
29651
+ if (value === null)
29652
+ return null;
29653
+ if (isSafeLogError(value))
29654
+ return value;
29655
+ if (value instanceof Error)
29656
+ return formatLogError(value);
29657
+ return "[rejected:object]";
29658
+ default:
29659
+ return `[rejected:${typeof value}]`;
29660
+ }
29661
+ }
29662
+ function sanitizeFields(fields, maxChars) {
29663
+ const clean = {};
29664
+ let count = 0;
29665
+ let dropped = 0;
29666
+ for (const name of Object.keys(fields)) {
29667
+ const value = sanitizeValue(name, fields[name], maxChars);
29668
+ if (value === undefined)
29669
+ continue;
29670
+ if (count >= MAX_FIELDS || !FIELD_NAME_PATTERN.test(name)) {
29671
+ dropped += 1;
29672
+ continue;
29673
+ }
29674
+ clean[name] = value;
29675
+ count += 1;
29676
+ }
29677
+ if (dropped > 0)
29678
+ clean.droppedFields = dropped;
29679
+ return count > 0 || dropped > 0 ? clean : undefined;
29680
+ }
29681
+ function textValue(value) {
29682
+ if (typeof value !== "string")
29683
+ return String(value);
29684
+ return BARE_TEXT_VALUE.test(value) ? value : JSON.stringify(value);
29685
+ }
29686
+ function appendTextField(parts, name, value) {
29687
+ if (typeof value !== "object" || value === null) {
29688
+ parts.push(`${name}=${textValue(value)}`);
29689
+ return;
29690
+ }
29691
+ for (const key of Object.keys(value)) {
29692
+ const entry = value[key];
29693
+ if (entry === undefined)
29694
+ continue;
29695
+ if (key === "cause")
29696
+ appendTextField(parts, `${name}.cause`, entry);
29697
+ else if (key === "stack")
29698
+ parts.push(`${name}.stack=${textValue(entry.join(" | "))}`);
29699
+ else
29700
+ parts.push(`${name}.${key}=${textValue(entry)}`);
29701
+ }
29702
+ }
29703
+ function escapeLogLine(line) {
29704
+ return line.replace(/[\u007f-\u009f\u2028\u2029]/g, (character) => `\\u${character.charCodeAt(0).toString(16).padStart(4, "0")}`);
29705
+ }
29706
+ function renderText(record) {
29707
+ const tag = areaSpec(record.area)?.tag ?? record.area;
29708
+ const parts = [`[${tag}]`, record.event];
29709
+ if (record.fields) {
29710
+ for (const name of Object.keys(record.fields))
29711
+ appendTextField(parts, name, record.fields[name]);
29712
+ }
29713
+ return escapeLogLine(parts.join(" "));
29714
+ }
29715
+ function renderJson(record) {
29716
+ return escapeLogLine(JSON.stringify(record));
29717
+ }
29718
+ function deliver(record) {
29719
+ try {
29720
+ config2.sink({
29721
+ method: OUTPUT_METHOD[record.level],
29722
+ line: config2.format === "json" ? renderJson(record) : renderText(record),
29723
+ record
29724
+ });
29725
+ } catch {}
29726
+ }
29727
+ function buildRecord(level, area, event, fields) {
29728
+ const clean = fields ? sanitizeFields(fields, areaSpec(area)?.maxStringChars ?? MAX_FIELD_CHARS) : undefined;
29729
+ return {
29730
+ orklog: 1,
29731
+ ts: new Date().toISOString(),
29732
+ level,
29733
+ area,
29734
+ event,
29735
+ ...clean ? { fields: clean } : {}
29736
+ };
29737
+ }
29738
+ var LOG_THROTTLE_WINDOW_MS = 60000;
29739
+ var LOG_THROTTLE_MAX_KEYS = 512;
29740
+ var LOG_THROTTLE_IDLE_MS = 5 * LOG_THROTTLE_WINDOW_MS;
29741
+ var throttledSites = new Map;
29742
+ var throttledKeyCount = 0;
29743
+ var throttleRecency = 0;
29744
+ var throttleGeneration = generation;
29745
+ var nextThrottleFlushAt = 0;
29746
+ function writeThrottleLine(site, event, fields) {
29747
+ const spec = areaSpec(site.area);
29748
+ if (!spec)
29749
+ return;
29750
+ const listed = Object.hasOwn(spec.events, event);
29751
+ const line = { site: site.event, ...site.scope === undefined ? {} : { scope: site.scope } };
29752
+ deliver(buildRecord(site.level, site.area, listed ? event : "invalid-event", listed ? { ...line, ...fields } : undefined));
29753
+ }
29754
+ function syncThrottleLevels() {
29755
+ if (throttleGeneration === generation)
29756
+ return;
29757
+ throttleGeneration = generation;
29758
+ for (const [siteKey, site] of Array.from(throttledSites)) {
29759
+ if (LEVEL_RANK[site.level] <= thresholdRank(site.area))
29760
+ continue;
29761
+ throttledSites.delete(siteKey);
29762
+ throttledKeyCount -= site.keys.size;
29763
+ }
29764
+ }
29765
+ function rollThrottleWindow(site, kind, key, now) {
29766
+ const elapsed = now - key.windowStart;
29767
+ if (elapsed >= 0 && elapsed < LOG_THROTTLE_WINDOW_MS)
29768
+ return;
29769
+ if (key.pending > 0) {
29770
+ writeThrottleLine(site, "throttle.suppressed", {
29771
+ kind,
29772
+ suppressed: key.pending,
29773
+ windowSeconds: Math.max(0, Math.round(elapsed / 1000))
29774
+ });
29775
+ }
29776
+ key.pending = 0;
29777
+ key.windowStart = now;
29778
+ }
29779
+ function flushDueThrottleWindows(now) {
29780
+ if (now < nextThrottleFlushAt && nextThrottleFlushAt - now <= LOG_THROTTLE_WINDOW_MS)
29781
+ return;
29782
+ nextThrottleFlushAt = now + LOG_THROTTLE_WINDOW_MS;
29783
+ for (const site of throttledSites.values()) {
29784
+ for (const [kind, key] of site.keys)
29785
+ rollThrottleWindow(site, kind, key, now);
29786
+ }
29787
+ }
29788
+ function evictOldestThrottleKey() {
29789
+ let oldest;
29790
+ for (const [siteKey, site] of throttledSites) {
29791
+ for (const [kind, key] of site.keys) {
29792
+ if (!oldest || key.recency < oldest.key.recency)
29793
+ oldest = { siteKey, site, kind, key };
29794
+ }
29795
+ }
29796
+ if (!oldest)
29797
+ return;
29798
+ const { siteKey, site, kind, key } = oldest;
29799
+ writeThrottleLine(site, "throttle.evicted", { kind, suppressed: key.pending });
29800
+ site.keys.delete(kind);
29801
+ throttledKeyCount -= 1;
29802
+ if (site.keys.size === 0)
29803
+ throttledSites.delete(siteKey);
29804
+ }
29805
+ function throttleSiteKey(area, event, scope) {
29806
+ return `${area}\x00${event}\x00${scope ?? ""}`;
29807
+ }
29808
+ function noteThrottledFailure(area, level, event, scope, kind) {
29809
+ const now = Date.now();
29810
+ flushDueThrottleWindows(now);
29811
+ const siteKey = throttleSiteKey(area, event, scope);
29812
+ let site = throttledSites.get(siteKey);
29813
+ let known = site?.keys.get(kind);
29814
+ if (known && now - known.lastFailureAt >= LOG_THROTTLE_IDLE_MS) {
29815
+ site.keys.delete(kind);
29816
+ throttledKeyCount -= 1;
29817
+ if (site.keys.size === 0) {
29818
+ throttledSites.delete(siteKey);
29819
+ site = undefined;
29820
+ }
29821
+ known = undefined;
29822
+ }
29823
+ if (!known && throttledKeyCount >= LOG_THROTTLE_MAX_KEYS) {
29824
+ evictOldestThrottleKey();
29825
+ site = throttledSites.get(siteKey);
29826
+ }
29827
+ site ??= { area, event, scope, level, since: now, failures: 0, keys: new Map };
29828
+ site.level = level;
29829
+ site.failures += 1;
29830
+ throttledSites.delete(siteKey);
29831
+ throttledSites.set(siteKey, site);
29832
+ if (known) {
29833
+ rollThrottleWindow(site, kind, known, now);
29834
+ known.pending += 1;
29835
+ known.lastFailureAt = now;
29836
+ known.recency = ++throttleRecency;
29837
+ site.keys.delete(kind);
29838
+ site.keys.set(kind, known);
29839
+ return false;
29840
+ }
29841
+ site.keys.set(kind, {
29842
+ pending: 0,
29843
+ windowStart: now,
29844
+ lastFailureAt: now,
29845
+ recency: ++throttleRecency
29846
+ });
29847
+ throttledKeyCount += 1;
29848
+ return true;
29849
+ }
29850
+ function noteThrottledSuccess(area, event, scope) {
29851
+ const now = Date.now();
29852
+ flushDueThrottleWindows(now);
29853
+ const siteKey = throttleSiteKey(area, event, scope);
29854
+ const site = throttledSites.get(siteKey);
29855
+ if (!site)
29856
+ return;
29857
+ throttledSites.delete(siteKey);
29858
+ throttledKeyCount -= site.keys.size;
29859
+ let suppressed = 0;
29860
+ for (const key of site.keys.values())
29861
+ suppressed += key.pending;
29862
+ writeThrottleLine(site, "throttle.recovered", {
29863
+ failures: site.failures,
29864
+ kinds: site.keys.size,
29865
+ suppressed,
29866
+ faultSeconds: Math.max(0, Math.round((now - site.since) / 1000))
29867
+ });
29868
+ }
29869
+ function throttleKind(options) {
29870
+ if (options.kind === undefined)
29871
+ return logErrorKind(options.error);
29872
+ return THROTTLE_KIND_PATTERN.test(options.kind) ? options.kind : "invalid-kind";
29873
+ }
29874
+ function resolveFields(fields) {
29875
+ try {
29876
+ return typeof fields === "function" ? fields() : fields;
29877
+ } catch {
29878
+ return { fieldsFailed: true };
29879
+ }
29880
+ }
29881
+ function createLogger(area) {
29882
+ const spec = areaSpec(area);
29883
+ let seenGeneration = -1;
29884
+ let rank = 0;
29885
+ const enabled = (level) => {
29886
+ if (seenGeneration !== generation) {
29887
+ seenGeneration = generation;
29888
+ rank = thresholdRank(area);
29889
+ }
29890
+ return LEVEL_RANK[level] <= rank;
29891
+ };
29892
+ const writeResolved = (level, event, resolved) => {
29893
+ if (!spec) {
29894
+ deliver(buildRecord(level, "logging", "unknown-area", undefined));
29895
+ } else if (Object.hasOwn(spec.events, event)) {
29896
+ deliver(buildRecord(level, area, event, resolved));
29897
+ } else {
29898
+ deliver(buildRecord(level, area, "invalid-event", undefined));
29899
+ }
29900
+ };
29901
+ const write = (level, event, fields) => {
29902
+ if (!enabled(level))
29903
+ return;
29904
+ writeResolved(level, event, resolveFields(fields));
29905
+ };
29906
+ return {
29907
+ error: (event, fields) => write("error", event, fields),
29908
+ warn: (event, fields) => write("warn", event, fields),
29909
+ info: (event, fields) => write("info", event, fields),
29910
+ debug: (event, fields) => write("debug", event, fields),
29911
+ trace: (event, fields) => write("trace", event, fields),
29912
+ throttled: (level, event, options) => {
29913
+ syncThrottleLevels();
29914
+ if (!enabled(level))
29915
+ return;
29916
+ if (!spec || !Object.hasOwn(spec.events, event) || event.startsWith("throttle.") || !Object.hasOwn(spec.events, "throttle.recovered")) {
29917
+ deliver(buildRecord(level, spec ? area : "logging", spec ? "invalid-event" : "unknown-area", undefined));
29918
+ return;
29919
+ }
29920
+ const kind = throttleKind(options);
29921
+ const scope = options.scope?.slice(0, MAX_THROTTLE_SCOPE_CHARS);
29922
+ if (!noteThrottledFailure(area, level, event, scope, kind))
29923
+ return;
29924
+ writeResolved(level, event, {
29925
+ ...scope === undefined ? {} : { scope },
29926
+ kind,
29927
+ ...resolveFields(options.fields)
29928
+ });
29929
+ },
29930
+ recovered: (event, scope) => {
29931
+ syncThrottleLevels();
29932
+ if (throttledKeyCount === 0)
29933
+ return;
29934
+ noteThrottledSuccess(area, event, scope?.slice(0, MAX_THROTTLE_SCOPE_CHARS));
29935
+ },
29936
+ isEnabled: enabled
29937
+ };
29938
+ }
29939
+
28024
29940
  // ../../bridges/cursor-bridge/src/persistence.ts
29941
+ var log = createLogger("bridge.cursor");
28025
29942
  var tail = Promise.resolve();
28026
29943
  var pending;
28027
29944
  var pendingFailureHooks;
@@ -28267,7 +30184,11 @@ function noteFailure(error) {
28267
30184
  failing = failing ? { key, failures: failing.failures + 1, noticed: failing.noticed } : { key, failures: 1, noticed: new WeakMap };
28268
30185
  const errno = error?.code;
28269
30186
  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`);
30187
+ log.warn("state.publication-failing", {
30188
+ code: typed.code,
30189
+ errno: typeof errno === "string" ? errno.slice(0, 32) : undefined,
30190
+ largestSessionsMarked: offenders.size
30191
+ });
28271
30192
  for (const state of sessions.values()) {
28272
30193
  const offender = offenders.has(state.id);
28273
30194
  const message = offender ? LARGEST_SESSION_NOTICE : typed.message;
@@ -28287,14 +30208,14 @@ function noteFailure(error) {
28287
30208
  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
30209
  function noteSuccess(shed) {
28289
30210
  if (failing) {
28290
- console.warn(`[cursor-bridge] state publication recovered after ${failing.failures} failed write(s)`);
30211
+ log.info("state.publication-recovered", { failedWrites: failing.failures });
28291
30212
  failing = undefined;
28292
30213
  }
28293
30214
  const newlyShed = shed.filter((id) => !lastShed.has(id));
28294
30215
  lastShed = new Set(shed);
28295
30216
  if (newlyShed.length === 0)
28296
30217
  return;
28297
- console.warn(`[cursor-bridge] state file at its size limit; saved ${newlyShed.length} session(s) with a shortened transcript copy`);
30218
+ log.warn("state.transcripts-shortened", { sessions: newlyShed.length });
28298
30219
  for (const id of newlyShed) {
28299
30220
  sessions.get(id)?.health.recordNotice({
28300
30221
  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 +30509,7 @@ async function withTimeout2(work, timeoutMs) {
28588
30509
  }
28589
30510
 
28590
30511
  // ../../bridges/cursor-bridge/src/session-tombstones.ts
30512
+ var log2 = createLogger("bridge.cursor");
28591
30513
  async function closeRestoredTombstone(id, ackTimeoutMs = CLOSE_ACK_TIMEOUT_MS) {
28592
30514
  if (!closingTombstones.has(id) && !tombstoneCloses.has(id))
28593
30515
  return "closed";
@@ -28671,7 +30593,7 @@ async function finishRestoredTombstones() {
28671
30593
  };
28672
30594
  await Promise.all(Array.from({ length: STARTUP_TOMBSTONE_CONCURRENCY }, worker));
28673
30595
  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`);
30596
+ log2.warn("startup.closes-incomplete", { closes: result.pending + result.failed });
28675
30597
  }
28676
30598
  return result;
28677
30599
  }
@@ -28692,7 +30614,7 @@ async function withBudget(work, timeoutMs) {
28692
30614
  }
28693
30615
 
28694
30616
  // ../protocol/src/node/cursor-plan-usage.ts
28695
- import { Buffer as Buffer3 } from "node:buffer";
30617
+ import { Buffer as Buffer4 } from "node:buffer";
28696
30618
  var MIN_PLAUSIBLE_EPOCH_MS = Date.UTC(2020, 0, 1);
28697
30619
  var MAX_PLAUSIBLE_EPOCH_MS = Date.UTC(2100, 0, 1);
28698
30620
  var CURSOR_API_BASE = "https://api2.cursor.sh";
@@ -28785,7 +30707,7 @@ function jwtExpiryMs(token) {
28785
30707
  if (!payload)
28786
30708
  return;
28787
30709
  try {
28788
- const parsed = record2(JSON.parse(Buffer3.from(payload, "base64url").toString("utf8")));
30710
+ const parsed = record2(JSON.parse(Buffer4.from(payload, "base64url").toString("utf8")));
28789
30711
  const expirySeconds = finiteNumber(parsed?.exp);
28790
30712
  return expirySeconds === undefined ? undefined : expirySeconds * 1000;
28791
30713
  } catch {
@@ -28914,6 +30836,7 @@ import {
28914
30836
 
28915
30837
  // ../protocol/src/node/bridge-diagnostics.ts
28916
30838
  import { createHash as createHash2 } from "node:crypto";
30839
+ var log3 = createLogger("bridge.diagnostics");
28917
30840
  var INTERVAL_MS = 60000;
28918
30841
  var MAX_PENDING_TOOLS = 128;
28919
30842
  var MAX_REPORTED_TOOLS = 8;
@@ -28983,7 +30906,16 @@ function identity(value) {
28983
30906
  function readBridgeDebugFlag(value) {
28984
30907
  return value?.trim() === "1";
28985
30908
  }
30909
+ var liveDiagnostics;
30910
+ var liveScopes = new Set;
30911
+ function setLiveBridgeDiagnostics(enabled) {
30912
+ liveDiagnostics = enabled;
30913
+ for (const scope of Array.from(liveScopes))
30914
+ scope.syncActive();
30915
+ }
28986
30916
  function bridgeDebugEnabled(bridge, env = process.env) {
30917
+ if (liveDiagnostics !== undefined && env === process.env)
30918
+ return liveDiagnostics;
28987
30919
  const value = env.ORKESTRATOR_BRIDGE_DEBUG ?? env[`${bridge.toUpperCase()}_BRIDGE_DEBUG`];
28988
30920
  return readBridgeDebugFlag(value);
28989
30921
  }
@@ -29041,17 +30973,25 @@ function safeDiagnosticMetrics(value) {
29041
30973
  result.state = value.state;
29042
30974
  return result;
29043
30975
  }
29044
- var MAX_ENTRY_BYTES = 8192;
29045
- function writeDiagnostic(bridge, payload, write) {
30976
+ function writeBridgeDiagnostic({ bridge, event, payload }) {
30977
+ log3.info(event, { bridge, payload });
30978
+ }
30979
+ function bridgeDiagnosticsActive() {
30980
+ return log3.isEnabled("info");
30981
+ }
30982
+ function writeDiagnostic(bridge, event, payload, write) {
29046
30983
  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}`);
30984
+ const json = JSON.stringify({ bridge, event, ...payload });
30985
+ const bytes = Buffer.byteLength(json);
30986
+ if (bytes <= MAX_BRIDGE_DIAGNOSTIC_BYTES) {
30987
+ write({ bridge, event, payload: json });
30988
+ return;
30989
+ }
30990
+ write({
30991
+ bridge,
30992
+ event: "snapshot-overflow",
30993
+ payload: JSON.stringify({ bridge, event: "snapshot-overflow", omittedBytes: bytes })
30994
+ });
29055
30995
  } catch {}
29056
30996
  }
29057
30997
 
@@ -29062,6 +31002,7 @@ class BridgeRunDiagnostics {
29062
31002
  write;
29063
31003
  intervalMs;
29064
31004
  metrics;
31005
+ active;
29065
31006
  counters = {
29066
31007
  stderrBytes: 0,
29067
31008
  requestsSent: 0,
@@ -29089,19 +31030,29 @@ class BridgeRunDiagnostics {
29089
31030
  cancelReason;
29090
31031
  run;
29091
31032
  closed = false;
31033
+ wasActive;
29092
31034
  timer;
29093
- constructor(bridge, state, now = Date.now, write = (line) => console.info(line), intervalMs = INTERVAL_MS, metrics = () => ({})) {
31035
+ constructor(bridge, state, now = Date.now, write = writeBridgeDiagnostic, intervalMs = INTERVAL_MS, metrics = () => ({}), active = () => true) {
29094
31036
  this.bridge = bridge;
29095
31037
  this.state = state;
29096
31038
  this.now = now;
29097
31039
  this.write = write;
29098
31040
  this.intervalMs = intervalMs;
29099
31041
  this.metrics = metrics;
31042
+ this.active = active;
29100
31043
  this.startedAt = this.lastTick = now();
31044
+ this.wasActive = active();
29101
31045
  this.timer = setInterval(() => this.report("heartbeat"), intervalMs);
29102
31046
  this.timer.unref();
31047
+ liveScopes.add(this);
29103
31048
  this.report("send-started");
29104
31049
  }
31050
+ syncActive() {
31051
+ const active = this.active();
31052
+ if (active && !this.wasActive)
31053
+ this.report("heartbeat");
31054
+ this.wasActive = active;
31055
+ }
29105
31056
  sent(runId) {
29106
31057
  this.run = identity(runId);
29107
31058
  this.phase = "following";
@@ -29189,6 +31140,8 @@ class BridgeRunDiagnostics {
29189
31140
  const tickDelayMs = event === "heartbeat" ? Math.max(0, now - this.lastTick - this.intervalMs) : 0;
29190
31141
  if (event === "heartbeat")
29191
31142
  this.lastTick = now;
31143
+ if (!this.active() || !bridgeDiagnosticsActive())
31144
+ return;
29192
31145
  const pendingTools = Array.from(this.pending.entries()).slice(0, MAX_REPORTED_TOOLS).map(([id, tool]) => ({
29193
31146
  id,
29194
31147
  kind: tool.kind,
@@ -29197,8 +31150,7 @@ class BridgeRunDiagnostics {
29197
31150
  ageMs: age(tool.since)
29198
31151
  }));
29199
31152
  try {
29200
- writeDiagnostic(this.bridge, {
29201
- event,
31153
+ writeDiagnostic(this.bridge, event, {
29202
31154
  session: identity(this.state.id),
29203
31155
  run: this.run,
29204
31156
  phase: this.phase,
@@ -29233,6 +31185,7 @@ class BridgeRunDiagnostics {
29233
31185
  this.phase = phase;
29234
31186
  this.report("closed");
29235
31187
  this.closed = true;
31188
+ liveScopes.delete(this);
29236
31189
  clearInterval(this.timer);
29237
31190
  this.pending.clear();
29238
31191
  }
@@ -29377,7 +31330,16 @@ function instrumentSdk(seam) {
29377
31330
  return startTimer.apply(this, args);
29378
31331
  };
29379
31332
  detector.trackActivity = function(...args) {
29380
- safely(() => owners.get(this)?.transportActivity(this, args[0], args[1]));
31333
+ safely(() => {
31334
+ if (!owners.has(this)) {
31335
+ const scope = scopes.getStore();
31336
+ if (!scope)
31337
+ return;
31338
+ owners.set(this, scope);
31339
+ scope.transport(this);
31340
+ }
31341
+ owners.get(this)?.transportActivity(this, args[0], args[1]);
31342
+ });
29381
31343
  return trackActivity.apply(this, args);
29382
31344
  };
29383
31345
  controller.run = function(...args) {
@@ -29451,6 +31413,7 @@ function install() {
29451
31413
  class CursorSdkDiagnostics {
29452
31414
  now;
29453
31415
  write;
31416
+ isActive;
29454
31417
  transports = [];
29455
31418
  transportEntries = new WeakMap;
29456
31419
  seen = new WeakSet;
@@ -29465,11 +31428,16 @@ class CursorSdkDiagnostics {
29465
31428
  closed = false;
29466
31429
  run;
29467
31430
  session;
29468
- coverage;
29469
- constructor(sessionId, now = Date.now, write = (line) => console.info(line)) {
31431
+ coverage = "unavailable";
31432
+ constructor(sessionId, now = Date.now, write = writeBridgeDiagnostic, isActive = () => true) {
29470
31433
  this.now = now;
29471
31434
  this.write = write;
31435
+ this.isActive = isActive;
29472
31436
  this.session = hash(sessionId);
31437
+ if (isActive())
31438
+ this.installSeam();
31439
+ }
31440
+ installSeam() {
29473
31441
  this.coverage = install();
29474
31442
  }
29475
31443
  follow(work) {
@@ -29558,7 +31526,7 @@ class CursorSdkDiagnostics {
29558
31526
  };
29559
31527
  }
29560
31528
  report(event) {
29561
- if (this.closed)
31529
+ if (this.closed || !this.isActive() || !bridgeDiagnosticsActive())
29562
31530
  return;
29563
31531
  safely(() => {
29564
31532
  const now = this.now();
@@ -29624,12 +31592,20 @@ class CursorSdkDiagnostics {
29624
31592
  droppedExecutions: this.droppedExecutions
29625
31593
  };
29626
31594
  const json = JSON.stringify(payload);
29627
- this.write(`[bridge-diagnostics] ${Buffer.byteLength(json) <= 8192 ? json : JSON.stringify({
31595
+ if (Buffer.byteLength(json) <= MAX_BRIDGE_DIAGNOSTIC_BYTES) {
31596
+ this.write({ bridge: "cursor", event: "sdk-snapshot", payload: json });
31597
+ return;
31598
+ }
31599
+ this.write({
29628
31600
  bridge: "cursor",
29629
31601
  event: "sdk-snapshot-overflow",
29630
- session: this.session,
29631
- run: this.run
29632
- })}`);
31602
+ payload: JSON.stringify({
31603
+ bridge: "cursor",
31604
+ event: "sdk-snapshot-overflow",
31605
+ session: this.session,
31606
+ run: this.run
31607
+ })
31608
+ });
29633
31609
  });
29634
31610
  }
29635
31611
  close() {
@@ -29643,11 +31619,16 @@ class CursorSdkDiagnostics {
29643
31619
  // ../../bridges/cursor-bridge/src/run-diagnostics.ts
29644
31620
  class CursorRunDiagnostics extends BridgeRunDiagnostics {
29645
31621
  sdk;
29646
- constructor(state, now, write, intervalMs) {
29647
- super("cursor", state, now, write, intervalMs);
29648
- this.sdk = new CursorSdkDiagnostics(state.id, now, write);
31622
+ constructor(state, now, write, intervalMs, active) {
31623
+ super("cursor", state, now, write, intervalMs, undefined, active);
31624
+ this.sdk = new CursorSdkDiagnostics(state.id, now, write, active);
29649
31625
  this.sdk.report("send-started");
29650
31626
  }
31627
+ syncActive() {
31628
+ if (this.active())
31629
+ this.sdk.installSeam();
31630
+ super.syncActive();
31631
+ }
29651
31632
  follow(work) {
29652
31633
  return this.sdk.follow(work);
29653
31634
  }
@@ -29681,15 +31662,15 @@ class CursorRunDiagnostics extends BridgeRunDiagnostics {
29681
31662
  }
29682
31663
  }
29683
31664
  function createRunDiagnostics(state) {
29684
- return bridgeDebugEnabled("cursor") ? new CursorRunDiagnostics(state) : undefined;
31665
+ return new CursorRunDiagnostics(state, undefined, undefined, undefined, () => bridgeDebugEnabled("cursor"));
29685
31666
  }
29686
31667
  var MAX_SETUP_DETAIL_BYTES = 300;
29687
31668
  function cursorSetupDebug(stage, error) {
29688
31669
  if (!bridgeDebugEnabled("cursor"))
29689
31670
  return;
29690
31671
  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}`);
31672
+ const payload = JSON.stringify({ bridge: "cursor", event: "setup-failed", stage, detail });
31673
+ writeBridgeDiagnostic({ bridge: "cursor", event: "setup-failed", payload });
29693
31674
  }
29694
31675
 
29695
31676
  // ../../bridges/cursor-bridge/src/sandbox-bootstrap.ts
@@ -31516,6 +33497,8 @@ function trackTurnEvidence(conversationId, options) {
31516
33497
  }
31517
33498
 
31518
33499
  // ../../bridges/cursor-bridge/src/agent-session.ts
33500
+ var log4 = createLogger("bridge.cursor");
33501
+
31519
33502
  class CredentialError extends Error {
31520
33503
  constructor(message) {
31521
33504
  super(message);
@@ -32059,7 +34042,7 @@ async function setResumableAgentArchived(agentId, archived) {
32059
34042
  const options = { cwd: workingDirectory };
32060
34043
  await (archived ? api.archive(agentId, options) : api.unarchive(agentId, options));
32061
34044
  } catch (error) {
32062
- console.warn(`[cursor-bridge] Agent.${archived ? "archive" : "unarchive"} failed:`, error instanceof Error ? error.message : error);
34045
+ log4.warn("agent.archive-failed", { archived, error: formatLogError(error, { stack: false }) });
32063
34046
  return "failed";
32064
34047
  } finally {
32065
34048
  agentArchiveOperations.delete(agentId);
@@ -34077,7 +36060,7 @@ async function readWorkspaceImage(filePath, workspaceRoot) {
34077
36060
  }
34078
36061
  }
34079
36062
  // ../protocol/src/node/transcript-window.ts
34080
- import { Buffer as Buffer4 } from "node:buffer";
36063
+ import { Buffer as Buffer5 } from "node:buffer";
34081
36064
  var DEFAULT_ENVELOPE_RESERVE_BYTES = 256;
34082
36065
  var DEFAULT_CONTENT_FALLBACK_BYTES = 1024 * 1024;
34083
36066
  var MAX_TRANSCRIPT_INDEX_DIGITS = 16;
@@ -34101,7 +36084,7 @@ function transcriptTailStart(retained, tailMessages) {
34101
36084
  function retainUtf8Tail(value, maximumBytes) {
34102
36085
  if (maximumBytes <= 0)
34103
36086
  return "";
34104
- const encoded = Buffer4.from(value);
36087
+ const encoded = Buffer5.from(value);
34105
36088
  if (encoded.length <= maximumBytes)
34106
36089
  return value;
34107
36090
  let start = encoded.length - maximumBytes;
@@ -34114,7 +36097,7 @@ function boundTranscriptResponse(messages, maximumBytes, options = {}) {
34114
36097
  const contentFallbackBytes = options.contentFallbackBytes === undefined ? DEFAULT_CONTENT_FALLBACK_BYTES : options.contentFallbackBytes;
34115
36098
  const tail = options.tailMessages;
34116
36099
  const selected = tail !== undefined && messages.length > tail ? messages.slice(-tail) : [...messages];
34117
- const measure = options.measure ?? ((message) => Buffer4.byteLength(JSON.stringify(message)));
36100
+ const measure = options.measure ?? ((message) => Buffer5.byteLength(JSON.stringify(message)));
34118
36101
  const sizes = selected.map((message) => measure(message));
34119
36102
  let bytes = envelope + 2 + sizes.reduce((total, size) => total + size, 0) + Math.max(0, sizes.length - 1);
34120
36103
  let start = 0;
@@ -34126,7 +36109,7 @@ function boundTranscriptResponse(messages, maximumBytes, options = {}) {
34126
36109
  let truncatedContent = false;
34127
36110
  const oldestRetained = selected[start];
34128
36111
  if (bytes > maximumBytes && oldestRetained) {
34129
- const partSizes = oldestRetained.parts.map((part) => Buffer4.byteLength(JSON.stringify(part)));
36112
+ const partSizes = oldestRetained.parts.map((part) => Buffer5.byteLength(JSON.stringify(part)));
34130
36113
  const partCount = partSizes.length;
34131
36114
  while (omittedParts < partCount && bytes > maximumBytes) {
34132
36115
  const shed = partSizes[omittedParts];
@@ -34147,7 +36130,7 @@ function boundTranscriptResponse(messages, maximumBytes, options = {}) {
34147
36130
  };
34148
36131
  omittedParts = oldestRetained.parts.length;
34149
36132
  truncatedContent = true;
34150
- bytes = envelope + 2 + Buffer4.byteLength(JSON.stringify(selected[start]));
36133
+ bytes = envelope + 2 + Buffer5.byteLength(JSON.stringify(selected[start]));
34151
36134
  }
34152
36135
  }
34153
36136
  const bounded = selected.slice(start);
@@ -34299,8 +36282,158 @@ function publicRuntime(state) {
34299
36282
  ...notices.length > 0 ? { notices } : {}
34300
36283
  };
34301
36284
  }
36285
+ // ../protocol/src/log-policy.ts
36286
+ var BRIDGE_DIAGNOSTICS_LOG_AREA = "bridge.diagnostics";
36287
+ var MAX_LOG_DETAIL_AREAS = 256;
36288
+ var MAX_LOG_AREA_NAME_CHARS = 64;
36289
+ var LOG_AREA_NAME = /^[a-z][a-z0-9-]*(?:\.[a-z][a-z0-9-]*)*$/;
36290
+ function parseLogDetail(value) {
36291
+ if (typeof value !== "object" || value === null || Array.isArray(value))
36292
+ return null;
36293
+ const { level, areaLevels } = value;
36294
+ if (!isLogLevel(level))
36295
+ return null;
36296
+ if (areaLevels === undefined)
36297
+ return { level, areaLevels: {} };
36298
+ if (typeof areaLevels !== "object" || areaLevels === null || Array.isArray(areaLevels)) {
36299
+ return null;
36300
+ }
36301
+ const names = Object.keys(areaLevels).sort();
36302
+ if (names.length > MAX_LOG_DETAIL_AREAS)
36303
+ return null;
36304
+ const clean = {};
36305
+ for (const name of names) {
36306
+ const areaLevel = areaLevels[name];
36307
+ if (name.length > MAX_LOG_AREA_NAME_CHARS || !LOG_AREA_NAME.test(name))
36308
+ return null;
36309
+ if (!isLogLevel(areaLevel))
36310
+ return null;
36311
+ clean[name] = areaLevel;
36312
+ }
36313
+ return { level, areaLevels: clean };
36314
+ }
36315
+ var LEVEL_DETAIL = {
36316
+ error: 0,
36317
+ warn: 1,
36318
+ info: 2,
36319
+ debug: 3,
36320
+ trace: 4
36321
+ };
36322
+ function effectiveLogLevel(detail, area) {
36323
+ for (let scope = area;; scope = scope.slice(0, scope.lastIndexOf("."))) {
36324
+ const level = Object.hasOwn(detail.areaLevels, scope) ? detail.areaLevels[scope] : undefined;
36325
+ if (level)
36326
+ return level;
36327
+ if (!scope.includes("."))
36328
+ return detail.level;
36329
+ }
36330
+ }
36331
+ function logDetailEnablesBridgeDiagnostics(detail) {
36332
+ return LEVEL_DETAIL[effectiveLogLevel(detail, BRIDGE_DIAGNOSTICS_LOG_AREA)] >= LEVEL_DETAIL.debug;
36333
+ }
36334
+ var BRIDGE_LOG_POLICY_ROUTE = "/debug/log-policy";
36335
+ function parseBridgeLogPolicy(value) {
36336
+ const detail = parseLogDetail(value);
36337
+ if (!detail)
36338
+ return null;
36339
+ const { seq } = value;
36340
+ return Number.isSafeInteger(seq) && seq >= 0 ? { ...detail, seq } : null;
36341
+ }
36342
+
36343
+ // ../protocol/src/node/logger-environment.ts
36344
+ var LOG_LEVEL_ENV = "ORKESTRATOR_LOG_LEVEL";
36345
+ var LOG_FORMAT_ENV = "ORKESTRATOR_LOG_FORMAT";
36346
+ var BRIDGE_LOG_RELAY_ENV = "ORKESTRATOR_BRIDGE_LOG_RELAY";
36347
+ var bridgeLogLevelOverrides = new WeakMap;
36348
+ function logLevelEnvironmentValue(env) {
36349
+ return env[LOG_LEVEL_ENV] ?? bridgeLogLevelOverrides.get(env);
36350
+ }
36351
+ function parseLogLevels(value) {
36352
+ const parsed = { areaLevels: {}, invalid: [] };
36353
+ for (const entry of (value ?? "").split(",")) {
36354
+ const trimmed = entry.trim();
36355
+ if (!trimmed)
36356
+ continue;
36357
+ const separator = trimmed.indexOf("=");
36358
+ if (separator < 0) {
36359
+ if (isLogLevel(trimmed))
36360
+ parsed.level = trimmed;
36361
+ else
36362
+ parsed.invalid.push(trimmed);
36363
+ continue;
36364
+ }
36365
+ const area = trimmed.slice(0, separator);
36366
+ const level = trimmed.slice(separator + 1);
36367
+ if (isLogLevel(level) && isKnownScope(area))
36368
+ parsed.areaLevels[area] = level;
36369
+ else
36370
+ parsed.invalid.push(trimmed);
36371
+ }
36372
+ return parsed;
36373
+ }
36374
+ function isKnownScope(scope) {
36375
+ return Object.keys(LOG_VOCABULARY).some((area) => area === scope || area.startsWith(`${scope}.`));
36376
+ }
36377
+ function configureLoggerFromEnvironment(env, options = {}) {
36378
+ const levels = parseLogLevels(env[LOG_LEVEL_ENV]);
36379
+ const requestedFormat = env[LOG_FORMAT_ENV];
36380
+ const format = options.relayToSupervisor || requestedFormat === "json" ? "json" : "text";
36381
+ configureLogger({
36382
+ ...levels.level ? { level: levels.level } : {},
36383
+ areaLevels: levels.areaLevels,
36384
+ format
36385
+ });
36386
+ const log = createLogger("logging");
36387
+ if (levels.invalid.length > 0) {
36388
+ log.warn("config.invalid", { variable: LOG_LEVEL_ENV, entries: levels.invalid.length });
36389
+ }
36390
+ if (requestedFormat && requestedFormat !== "json" && requestedFormat !== "text") {
36391
+ log.warn("config.invalid", { variable: LOG_FORMAT_ENV, entries: 1 });
36392
+ }
36393
+ }
36394
+ function configureBridgeLogger(env = process.env) {
36395
+ const relayToSupervisor = env[BRIDGE_LOG_RELAY_ENV] === "1";
36396
+ bridgeLogLevelOverrides.set(env, env[LOG_LEVEL_ENV]);
36397
+ delete env[BRIDGE_LOG_RELAY_ENV];
36398
+ configureLoggerFromEnvironment(env, { relayToSupervisor });
36399
+ delete env[LOG_FORMAT_ENV];
36400
+ delete env[LOG_LEVEL_ENV];
36401
+ }
36402
+
36403
+ // ../protocol/src/node/log-policy.ts
36404
+ function effectiveLogDetail(detail, env = process.env) {
36405
+ const overrides = parseLogLevels(logLevelEnvironmentValue(env));
36406
+ return {
36407
+ level: overrides.level ?? detail.level,
36408
+ areaLevels: { ...detail.areaLevels, ...overrides.areaLevels }
36409
+ };
36410
+ }
36411
+ function applyLogDetail(detail, env = process.env) {
36412
+ const effective = effectiveLogDetail(detail, env);
36413
+ configureLogger(effective);
36414
+ return effective;
36415
+ }
36416
+
36417
+ // ../protocol/src/node/bridge-log-policy.ts
36418
+ var MAX_BRIDGE_LOG_POLICY_BYTES = 64 * 1024;
36419
+ var appliedSeq = -1;
36420
+ function applyBridgeLogPolicy(value, env = process.env) {
36421
+ const policy = parseBridgeLogPolicy(value);
36422
+ if (!policy)
36423
+ return { status: 400, body: { error: "Invalid log policy" } };
36424
+ if (policy.seq < appliedSeq) {
36425
+ return { status: 200, body: { applied: false, stale: true, seq: appliedSeq } };
36426
+ }
36427
+ appliedSeq = policy.seq;
36428
+ const effective = applyLogDetail(policy, env);
36429
+ const diagnostics = logDetailEnablesBridgeDiagnostics(effective);
36430
+ setLiveBridgeDiagnostics(diagnostics);
36431
+ return { status: 200, body: { applied: true, seq: policy.seq, diagnostics } };
36432
+ }
36433
+
34302
36434
  // ../protocol/src/human-prompts.ts
34303
36435
  var HUMAN_PROMPT_SCAN_BYTES = 16 * 1024;
36436
+ var HUMAN_PROMPT_OBSERVATION_ROWS = 64;
34304
36437
  function humanPromptObservation(messages, tasks) {
34305
36438
  const object = (value) => !!value && typeof value === "object" && !Array.isArray(value);
34306
36439
  const parts = [];
@@ -34334,7 +36467,7 @@ function humanPromptObservation(messages, tasks) {
34334
36467
  }
34335
36468
  };
34336
36469
  if (Array.isArray(messages)) {
34337
- for (let i = messages.length - 1;i >= Math.max(0, messages.length - 64); i--) {
36470
+ for (let i = messages.length - 1;i >= Math.max(0, messages.length - HUMAN_PROMPT_OBSERVATION_ROWS); i--) {
34338
36471
  const message = messages[i];
34339
36472
  if (object(message))
34340
36473
  walk(message.parts);
@@ -34480,7 +36613,7 @@ var DEFAULT_MCP_MANAGEMENT_ROLLOUT = Object.freeze({
34480
36613
  });
34481
36614
 
34482
36615
  // ../protocol/src/node/bridge-transcript-summary.ts
34483
- import { Buffer as Buffer5 } from "node:buffer";
36616
+ import { Buffer as Buffer6 } from "node:buffer";
34484
36617
  import { createHash as createHash6 } from "node:crypto";
34485
36618
 
34486
36619
  // ../protocol/src/node/progressive-transcript.ts
@@ -34565,7 +36698,7 @@ var MAX_SUMMARY_DEPTH = 8;
34565
36698
  var NESTED_PART_FIELDS = ["parts", "childTools", "subagentActions"];
34566
36699
  var LOCATOR_PREFIX = "bd1.";
34567
36700
  function encodeLocator(body) {
34568
- const locator = LOCATOR_PREFIX + Buffer5.from(JSON.stringify(body)).toString("base64url");
36701
+ const locator = LOCATOR_PREFIX + Buffer6.from(JSON.stringify(body)).toString("base64url");
34569
36702
  return locator.length <= BRIDGE_DETAIL_LOCATOR_MAX_LENGTH ? locator : undefined;
34570
36703
  }
34571
36704
  function decodeLocator(locator) {
@@ -34573,7 +36706,7 @@ function decodeLocator(locator) {
34573
36706
  return;
34574
36707
  }
34575
36708
  try {
34576
- const body = JSON.parse(Buffer5.from(locator.slice(LOCATOR_PREFIX.length), "base64url").toString("utf8"));
36709
+ const body = JSON.parse(Buffer6.from(locator.slice(LOCATOR_PREFIX.length), "base64url").toString("utf8"));
34577
36710
  if (!isRecord(body))
34578
36711
  return;
34579
36712
  const { m, p, d } = body;
@@ -34646,7 +36779,7 @@ function measureDetail(part, payload) {
34646
36779
  function digestPayload(payload) {
34647
36780
  const serialized = JSON.stringify(payload);
34648
36781
  return {
34649
- bytes: Buffer5.byteLength(serialized),
36782
+ bytes: Buffer6.byteLength(serialized),
34650
36783
  digest: createHash6("sha256").update(serialized).digest("base64url").slice(0, 32)
34651
36784
  };
34652
36785
  }
@@ -34821,7 +36954,7 @@ function revisedBeforeWindow(messages, startIndex, ids) {
34821
36954
  continue;
34822
36955
  found.delete(id);
34823
36956
  const summary = summarizeBridgeMessage(message);
34824
- const size = Buffer5.byteLength(JSON.stringify(summary));
36957
+ const size = Buffer6.byteLength(JSON.stringify(summary));
34825
36958
  if (revised.length >= BRIDGE_REVISED_MESSAGES_MAX || bytes + size > BRIDGE_REVISED_MESSAGES_MAX_BYTES) {
34826
36959
  omitted.push(summary);
34827
36960
  continue;
@@ -34883,7 +37016,7 @@ function bridgeTranscriptSummaryUpdate(messages, options) {
34883
37016
  }
34884
37017
  var PAGE_CURSOR_PREFIX = "bp1.";
34885
37018
  function encodePageCursor(body) {
34886
- const cursor = PAGE_CURSOR_PREFIX + Buffer5.from(JSON.stringify(body)).toString("base64url");
37019
+ const cursor = PAGE_CURSOR_PREFIX + Buffer6.from(JSON.stringify(body)).toString("base64url");
34887
37020
  return cursor.length <= BRIDGE_PAGE_CURSOR_MAX_LENGTH ? cursor : undefined;
34888
37021
  }
34889
37022
  function decodePageCursor(cursor) {
@@ -34891,7 +37024,7 @@ function decodePageCursor(cursor) {
34891
37024
  return;
34892
37025
  }
34893
37026
  try {
34894
- const body = JSON.parse(Buffer5.from(cursor.slice(PAGE_CURSOR_PREFIX.length), "base64url").toString("utf8"));
37027
+ const body = JSON.parse(Buffer6.from(cursor.slice(PAGE_CURSOR_PREFIX.length), "base64url").toString("utf8"));
34895
37028
  if (!isRecord(body))
34896
37029
  return;
34897
37030
  const { g, e, b } = body;
@@ -35369,6 +37502,8 @@ async function answerSessionActivityBatch(body, read, options = {}) {
35369
37502
  }
35370
37503
 
35371
37504
  // ../../bridges/cursor-bridge/src/http.ts
37505
+ var log5 = createLogger("bridge.cursor");
37506
+
35372
37507
  class HttpError extends Error {
35373
37508
  status;
35374
37509
  constructor(status, message) {
@@ -35397,6 +37532,10 @@ async function route(request, response, clientSignal) {
35397
37532
  });
35398
37533
  return json(response, answer.status, answer.body);
35399
37534
  }
37535
+ if (url.pathname === BRIDGE_LOG_POLICY_ROUTE && request.method === "POST") {
37536
+ const answer = applyBridgeLogPolicy(await readJson(request));
37537
+ return json(response, answer.status, answer.body);
37538
+ }
35400
37539
  if (await routeChangeEvidence(request, response, url))
35401
37540
  return;
35402
37541
  const handled = await routeGlobal(request, response, url);
@@ -35428,7 +37567,7 @@ async function route(request, response, clientSignal) {
35428
37567
  if (error instanceof PromptAttachmentError) {
35429
37568
  return json(response, 400, { error: error.message });
35430
37569
  }
35431
- console.error("[cursor-bridge] Unexpected HTTP route failure");
37570
+ log5.error("http.route-failed");
35432
37571
  return json(response, 500, { error: "Internal bridge error" });
35433
37572
  }
35434
37573
  }
@@ -36416,6 +38555,7 @@ function startParentWatchdog(options) {
36416
38555
  }
36417
38556
 
36418
38557
  // ../protocol/src/bridge-lifecycle.ts
38558
+ var log6 = createLogger("bridge.lifecycle");
36419
38559
  var TERMINATION_SIGNALS = ["SIGTERM", "SIGINT"];
36420
38560
  function errorKind(error) {
36421
38561
  if (error instanceof Error)
@@ -36431,11 +38571,9 @@ class BridgeLifecycle {
36431
38571
  #exit = null;
36432
38572
  #options;
36433
38573
  #timers;
36434
- #report;
36435
38574
  constructor(options) {
36436
38575
  this.#options = options;
36437
38576
  this.#timers = options.timers ?? runtimeIntervalTimers;
36438
- this.#report = options.report ?? ((message) => console.error(message));
36439
38577
  }
36440
38578
  get phase() {
36441
38579
  return this.#phase;
@@ -36471,7 +38609,10 @@ class BridgeLifecycle {
36471
38609
  }
36472
38610
  requestExit() {
36473
38611
  this.#exit ??= this.shutdown().then(() => this.#options.exit(0), (error) => {
36474
- this.#report(`${this.#options.label} shutdown failed (${errorKind(error)})`);
38612
+ log6.error("shutdown.failed", {
38613
+ bridge: this.#options.label,
38614
+ errorClass: errorKind(error)
38615
+ });
36475
38616
  this.#options.exit(1);
36476
38617
  });
36477
38618
  return this.#exit;
@@ -36485,7 +38626,10 @@ class BridgeLifecycle {
36485
38626
  try {
36486
38627
  idleSweep.run();
36487
38628
  } catch (error) {
36488
- this.#report(`${this.#options.label} idle sweep failed (${errorKind(error)})`);
38629
+ log6.warn("idle-sweep.failed", {
38630
+ bridge: this.#options.label,
38631
+ errorClass: errorKind(error)
38632
+ });
36489
38633
  }
36490
38634
  }, idleSweep.intervalMs);
36491
38635
  this.#disarmers.push(() => this.#timers.clearInterval(handle));
@@ -36554,6 +38698,7 @@ async function settleIdleDetaches() {
36554
38698
  }
36555
38699
 
36556
38700
  // ../../bridges/cursor-bridge/src/server.ts
38701
+ var log7 = createLogger("bridge.cursor");
36557
38702
  var IDLE_SWEEP_MS = 60 * 1000;
36558
38703
  var lifecycle;
36559
38704
  var server = createServer((request, response) => {
@@ -36588,7 +38733,7 @@ function lifecycleFor(listenPort, options) {
36588
38733
  applyWorkingDirectory();
36589
38734
  await loadPersistedState();
36590
38735
  finishRestoredTombstones().catch(() => {
36591
- console.warn("[cursor-bridge] restored closes could not be finished at startup");
38736
+ log7.warn("startup.closes-failed");
36592
38737
  });
36593
38738
  await new Promise((resolve) => server.listen(listenPort, hostname, resolve));
36594
38739
  },
@@ -36779,6 +38924,7 @@ async function runLogin(emit) {
36779
38924
  }
36780
38925
 
36781
38926
  // ../../bridges/cursor-bridge/src/index.ts
38927
+ configureBridgeLogger();
36782
38928
  installFatalRejectionGuard({ label: "[cursor-bridge]" });
36783
38929
  if (process.argv.includes("--login")) {
36784
38930
  process.exit(await runLogin((line) => process.stdout.write(`${line}
@@ -36852,6 +38998,7 @@ export {
36852
38998
  __testing,
36853
38999
  acceptsGzip,
36854
39000
  appendBounded,
39001
+ appendTurnOutput,
36855
39002
  applyCommandChanges,
36856
39003
  applyComposerPatch,
36857
39004
  applyInteractionUpdate,