orkestrator 2.35.5-beta → 2.36.1

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.
@@ -161,6 +161,7 @@ var BRIDGE_LOG_AREAS = defineLogAreas({
161
161
  "session.created": "A session was created or recovered.",
162
162
  "session.delete-failed": "Deleting a session failed.",
163
163
  "session.fork-failed": "Forking a session failed.",
164
+ "session.policy-widening-refused": "A config request tried to widen a live session's execution policy and was refused; widened names the axes.",
164
165
  "session.rename-failed": "Renaming a session failed.",
165
166
  "session.resolve-failed": "A session could not be found or loaded for a request; action names the request.",
166
167
  "session.rewind-failed": "Rewinding session files failed.",
@@ -293,6 +294,7 @@ var DESKTOP_LOG_AREAS = defineLogAreas({
293
294
  "backend.keychain-link-remove-failed": "An agent-test profile kept a legacy link to the host keychain.",
294
295
  "backend.start-failed": "The Local backend did not start; continuing with remote machines.",
295
296
  "clipboard.write-failed": "Writing text to the system clipboard failed.",
297
+ "dev-mode.ignored-packaged": "A packaged app was launched with ELECTRON_DEV=1 and ignored it; it loads its bundled renderer.",
296
298
  "instance.already-running": "Another instance holds this data directory; this one will quit.",
297
299
  "main-thread.stalled": "A timer fired late, so windows, IPC and the stdout reader waited.",
298
300
  "quit.stopping-backend": "The app is quitting and has asked the Local backend to stop.",
@@ -365,7 +367,8 @@ var DESKTOP_LOG_AREAS = defineLogAreas({
365
367
  description: "Preparing the pinned agent toolchain at desktop startup.",
366
368
  events: {
367
369
  "bootstrap-progress.show-failed": "The toolchain progress window could not be shown.",
368
- "prepare.failed": "Preparing the pinned agent tools failed."
370
+ "prepare.failed": "Preparing the pinned agent tools failed.",
371
+ "prepare.ready": "The pinned agent tools were verified and activated; durationMs is how long startup waited."
369
372
  }
370
373
  },
371
374
  "artifact-host": {
@@ -553,6 +556,7 @@ var NATIVE_AGENT_LOG_AREAS = defineLogAreas({
553
556
  description: "Native agent sessions and what the backend reads from their bridges.",
554
557
  events: {
555
558
  "catalogue.outdated-bridge": "A bridge predates the command catalogue, so its commands stay unavailable.",
559
+ "compact.instructions-ignored": "A bridge compacted without confirming the instructions sent with /compact: it predates them.",
556
560
  "handoff.summary-read-failed": "Change summaries could not be read for a handoff, so the carrier says they are unmeasured.",
557
561
  "handoff.consume-failed": "A delivered handoff could not be marked consumed.",
558
562
  "job.pr-refresh-rollback-failed": "Rolling back a pull request refresh for a job failed.",
@@ -808,6 +812,8 @@ var TMUX_LOG_AREAS = defineLogAreas({
808
812
  "interactive.snapshot-failed": "An interactive snapshot failed; expected while a pane is closing.",
809
813
  "signal.arm-failed": "The Claude state signal could not be armed.",
810
814
  "signal.degraded": "The Claude state signal missed a change or rang too often, so polling stays at one second until it is re-armed.",
815
+ "hook-signal.arm-failed": "The tmux hook doorbell could not be armed.",
816
+ "hook-signal.degraded": "The tmux hook doorbell missed a hook, so idle tabs poll every second until it is re-armed.",
811
817
  "pr-refresh.schedule-failed": "A pull request refresh after a turn could not be scheduled.",
812
818
  "pr-probe.failed": "Probing for a pull request an agent created failed.",
813
819
  "activity.persist-failed": "Tmux tab activity could not be saved.",
@@ -927,6 +933,7 @@ var BUILD_PIPELINE_LOG_AREAS = defineLogAreas({
927
933
  "usage.read-failed": "Reading a stage session's token usage failed.",
928
934
  "checkpoint.deferred": "A stage transcript checkpoint could not be written yet; the provider's history stands.",
929
935
  "checkpoint.not-committed": "A stage transcript checkpoint was reverted in the commit that should have kept it.",
936
+ "worker-mail.claim-failed": "Mail queued for a worker could not be claimed at its turn end; it stays queued.",
930
937
  "legacy-transcript.deferred": "Moving a legacy inline transcript failed; the inline body stays readable."
931
938
  }
932
939
  }
@@ -989,18 +996,27 @@ var COORDINATOR_LOG_AREAS = defineLogAreas({
989
996
  "work.move-failed": "Work could not move to the main coordinator.",
990
997
  "wake.observe-remote-workflow-failed": "A remote workflow could not be observed for status wakes.",
991
998
  "wake.observe-pull-request-failed": "A pull request could not be observed for status wakes.",
999
+ "wake.observe-feature-plan-failed": "A feature plan could not be observed for status wakes.",
992
1000
  "wake.observe-workflow-failed": "A workflow could not be observed for status wakes.",
993
1001
  "wake.deliver-failed": "A workflow status wake could not be delivered; the next pass retries.",
994
1002
  "wake.waiting-check-failed": "A waiting worker could not be checked; the next pass retries.",
995
1003
  "wake.resolve-report-failed": "A finished Resolve tab could not be reported.",
996
1004
  "wake.waiting-report-failed": "A waiting worker could not be reported.",
997
1005
  "wake.worker-outcomes-failed": "Coordinator-owned workers' merges and deletions could not be checked; the next sweep retries.",
1006
+ "pr-watch.added": "A pull request a coordinator conversation showed joined the project's watch; `source` says how.",
1007
+ "pr-watch.observe-failed": "A watched pull request could not be observed; the next sweep retries.",
1008
+ "pr-watch.read-failed": "GitHub could not be read for a watched pull request; `code` is the error category.",
1009
+ "pr-watch.removed": "A watched pull request stopped being watched without a reading; `reason` is `deleted` (GitHub confirmed it is gone) or `unreadable` (not found for the give-up period).",
998
1010
  "store.malformed": "The coordinator store was malformed and is treated as empty.",
999
1011
  "store.unsupported-version": "The coordinator store has an unsupported version and is treated as empty.",
1000
1012
  "store.invalid-workspace": "An invalid coordinator workspace record was ignored.",
1001
1013
  "store.workflows-cleared": "The workflow store was full, so a batch of its oldest finished records was removed.",
1002
1014
  "store.workflows-in-use": "The workflow store was full and every record was still in use, so new work was refused.",
1003
- "remote-worker.settle-failed": "A remote worker could not be settled."
1015
+ "remote-worker.settle-failed": "A remote worker could not be settled.",
1016
+ "checkout.merge-followed": "After an environment's PR merged, the project checkout was fast-forwarded, or `outcome` says why not.",
1017
+ "checkout.merge-follow-failed": "Fast-forwarding the project checkout failed, after an environment's PR merged or before mail woke the main coordinator.",
1018
+ "checkout.mail-follow": "Before mail woke the main coordinator, the project checkout was fast-forwarded, or `outcome` says why not (`timed-out`, `failed`).",
1019
+ "checkout.mail-follow-failed": "Before mail woke the main coordinator, checking whether to fast-forward the project checkout failed; the mail was delivered anyway."
1004
1020
  }
1005
1021
  }
1006
1022
  });
@@ -1032,6 +1048,7 @@ var REVIEW_LOG_AREAS = defineLogAreas({
1032
1048
  "gh.pr-list-unparseable": "`gh pr list` returned nothing that parses. Sizes only, never the output.",
1033
1049
  "monitor.start-failed": "Monitoring could not start for a newly opened pull request.",
1034
1050
  "cleanup-scheduler.missing": "A merged pull request was seen, but this runtime has no merge cleanup scheduler.",
1051
+ "checkout.follow-merge-lookup-failed": "A merged pull request's project could not be read, so its checkout was not fast-forwarded.",
1035
1052
  "auto-merge.evaluation-failed": "Evaluating an environment for auto-merge failed.",
1036
1053
  "auto-merge.merge-failed": "Auto-merge could not merge a pull request; the attempt is held and retried.",
1037
1054
  "auto-merge.resolve-failed": "Auto-merge could not launch Resolve for a pull request; the attempt is held and retried.",
@@ -1075,6 +1092,8 @@ var AGENT_ACCOUNTS_LOG_AREAS = defineLogAreas({
1075
1092
  "container-sync.failed": "Handing a login or account to a container failed; `step` says which part.",
1076
1093
  "last-usage.save-failed": "The last plan usage reading could not be saved; the next save retries.",
1077
1094
  "login-cleanup.failed": "A temporary login could not be cleaned up.",
1095
+ "login-renewal.failed": "Renewing an idle account's sign-in to read its usage failed; it is retried after a backoff.",
1096
+ "login-renewal.not-extended": "Claude Code ran to renew an idle account's sign-in, but its token is still lapsed.",
1078
1097
  "login-refresh.deferred": "Containers were not told to refresh their login now; they reconcile from its durable generation."
1079
1098
  }
1080
1099
  }
@@ -1088,6 +1107,7 @@ var DOCKER_LOG_AREAS = defineLogAreas({
1088
1107
  "portable-inputs.relay-missing": "Docker is rootless and the image predates the staged-input relay, so the container cannot read them until rebuilt.",
1089
1108
  "project-seed.refused": "A project .env, .env.local or opencode.json was not copied into a new container: a link, not a regular file, outside the project, too large or unreadable.",
1090
1109
  "opencode.warm-incomplete": "OpenCode did not finish loading /workspace in a container.",
1110
+ "lifecycle-event.reconcile-failed": "Reconciling an environment after a container start or stop event failed; the next status read retries.",
1091
1111
  "login-keeper.pass-failed": "A Claude login keeper pass failed; the next interval retries.",
1092
1112
  "login-keeper.refresh-failed": "Refreshing the host Claude login failed. Fixed text: CLI output can hold credentials.",
1093
1113
  "login-keeper.refresh-not-extended": "Refreshing the host Claude login did not extend its expiry.",
@@ -1211,7 +1231,7 @@ var GRAPH_LOG_AREAS = defineLogAreas({
1211
1231
  // ../protocol/src/log-vocabulary/nodes.ts
1212
1232
  var NODES_LOG_AREAS = defineLogAreas({
1213
1233
  nodes: {
1214
- description: "Command nodes: links, handovers, leaf mail and project copies.",
1234
+ description: "Command nodes: links, handovers, leaf mail, ticket sync and project copies.",
1215
1235
  events: {
1216
1236
  "actions.resume-failed": "Approved actions could not be resumed; a later pass retries.",
1217
1237
  "project-copy.notify-failed": "The coordinator could not be told a project copy finished.",
@@ -1223,7 +1243,11 @@ var NODES_LOG_AREAS = defineLogAreas({
1223
1243
  "verification.record-failed": "A node verification could not be recorded.",
1224
1244
  "profile.record-failed": "A node profile could not be recorded.",
1225
1245
  "detach.unconfirmed": "A forgotten node has not confirmed the detach yet.",
1226
- "handover.recovery-pending": "Command handover recovery is still pending."
1246
+ "handover.recovery-pending": "Command handover recovery is still pending.",
1247
+ "ticket-sync.work-record-failed": "A remote build started but its ticket work location could not be saved.",
1248
+ "ticket-sync.failed": "A Kanban sync with a node failed; it is retried.",
1249
+ "ticket-sync.unknown-project": "A node sent ticket changes for a project that no longer exists here.",
1250
+ "ticket-sync.forget-failed": "A detached command node's ticket copies could not be released."
1227
1251
  }
1228
1252
  }
1229
1253
  });
@@ -1806,7 +1830,7 @@ var LOG_VOCABULARY = {
1806
1830
  // ../protocol/src/secret-redaction.ts
1807
1831
  var TEXT_RULES = [
1808
1832
  {
1809
- pattern: /([a-z][a-z0-9+.-]*:\/\/)[^/\s:@]+(?::[^/\s@]*)?@/gi,
1833
+ pattern: /(?<![a-z0-9+.-])([a-z][a-z0-9+.-]*:\/\/)[^/\s:@]+(?::[^/\s@]*)?@/gi,
1810
1834
  replacement: "$1[redacted]@"
1811
1835
  },
1812
1836
  {
@@ -1826,7 +1850,7 @@ var TEXT_RULES = [
1826
1850
  { pattern: /\bAKIA[0-9A-Z]{12,}/g, replacement: "[redacted]" },
1827
1851
  { pattern: /\bAIza[0-9A-Za-z_-]{20,}/g, replacement: "[redacted]" },
1828
1852
  {
1829
- 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,
1853
+ pattern: /(?<![A-Za-z0-9_-])(-*\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,
1830
1854
  replacement: "$1$2[redacted]"
1831
1855
  }
1832
1856
  ];
@@ -7280,6 +7304,27 @@ var SUPPRESSED_COMPOSER_PARAMETERS = Object.freeze({
7280
7304
  claude: Object.freeze(["parameter:thinking", "parameter:context1m"]),
7281
7305
  cursor: Object.freeze(["parameter:variant"])
7282
7306
  });
7307
+ var COMPACT_INSTRUCTIONS_MAX_LENGTH = 16000;
7308
+ function parseCompactInstructionsBody(body) {
7309
+ if (body === undefined || body === null)
7310
+ return { ok: true };
7311
+ if (typeof body !== "object" || Array.isArray(body)) {
7312
+ return { ok: false, error: "Compact request body must be an object" };
7313
+ }
7314
+ const raw = body.instructions;
7315
+ if (raw === undefined)
7316
+ return { ok: true };
7317
+ if (typeof raw !== "string")
7318
+ return { ok: false, error: "instructions must be a string" };
7319
+ const instructions = raw.trim();
7320
+ if (instructions.length > COMPACT_INSTRUCTIONS_MAX_LENGTH) {
7321
+ return {
7322
+ ok: false,
7323
+ error: `instructions must be at most ${COMPACT_INSTRUCTIONS_MAX_LENGTH} characters`
7324
+ };
7325
+ }
7326
+ return instructions ? { ok: true, instructions } : { ok: true };
7327
+ }
7283
7328
  function isNativeAgentExecutionPolicy(value) {
7284
7329
  if (!value || typeof value !== "object" || Array.isArray(value))
7285
7330
  return false;
@@ -9974,6 +10019,14 @@ class ToolTracker {
9974
10019
  getTool(toolUseId) {
9975
10020
  return this.tools.get(toolUseId);
9976
10021
  }
10022
+ getToolWithCreatedAt(toolUseId, createdAt) {
10023
+ const existing = this.tools.get(toolUseId);
10024
+ if (!existing || !createdAt || existing.createdAt)
10025
+ return existing;
10026
+ const stamped = { ...existing, createdAt };
10027
+ this.tools.set(toolUseId, stamped);
10028
+ return stamped;
10029
+ }
9977
10030
  }
9978
10031
  function parseMcpToolName(toolName, knownServerNames) {
9979
10032
  if (!toolName.startsWith("mcp_")) {
@@ -10185,11 +10238,13 @@ function refreshSettledToolRows(session, sessionId, toolTracker, toolUseIds, pub
10185
10238
  return part;
10186
10239
  }
10187
10240
  pending.delete(part.toolUseId);
10188
- const tracked = toolTracker.getTool(part.toolUseId);
10189
- if (!tracked || published?.has(message))
10241
+ if (published?.has(message))
10242
+ return part;
10243
+ const tracked = toolTracker.getToolWithCreatedAt(part.toolUseId, part.createdAt);
10244
+ if (!tracked || tracked === part)
10190
10245
  return part;
10191
10246
  changed = true;
10192
- return part.createdAt && !tracked.createdAt ? { ...tracked, createdAt: part.createdAt } : tracked;
10247
+ return tracked;
10193
10248
  });
10194
10249
  if (changed) {
10195
10250
  message.parts = parts;
@@ -10436,10 +10491,9 @@ function buildMessageParts(orderedParts, toolTracker) {
10436
10491
  parentTaskUseId: entry.parentTaskUseId
10437
10492
  });
10438
10493
  } else if (entry.type === "tool-ref") {
10439
- const tool = toolTracker.getTool(entry.value);
10440
- if (tool) {
10441
- result.push(entry.timestamp && !tool.createdAt ? { ...tool, createdAt: entry.timestamp } : tool);
10442
- }
10494
+ const tool = toolTracker.getToolWithCreatedAt(entry.value, entry.timestamp);
10495
+ if (tool)
10496
+ result.push(tool);
10443
10497
  } else if (entry.type === "text") {
10444
10498
  result.push({
10445
10499
  type: "text",
@@ -15191,7 +15245,7 @@ class PromptStream {
15191
15245
  const { session, sessionId } = this;
15192
15246
  const message = row.message;
15193
15247
  if (!message)
15194
- return;
15248
+ return false;
15195
15249
  const parts = message.parts;
15196
15250
  if (!row.published || row.publishedModelId !== message.modelId) {
15197
15251
  row.published = true;
@@ -15200,7 +15254,7 @@ class PromptStream {
15200
15254
  message.revision = (message.revision ?? 0) + 1;
15201
15255
  markTranscriptChanged(session);
15202
15256
  eventEmitter.emit({ type: "message.updated", sessionId, data: { message } });
15203
- return;
15257
+ return true;
15204
15258
  }
15205
15259
  const changedParts = [];
15206
15260
  for (let index = 0;index < parts.length; index += 1) {
@@ -15210,7 +15264,7 @@ class PromptStream {
15210
15264
  }
15211
15265
  }
15212
15266
  if (changedParts.length === 0 && parts.length === row.publishedParts.length) {
15213
- return;
15267
+ return false;
15214
15268
  }
15215
15269
  row.publishedParts = parts.slice();
15216
15270
  message.revision = (message.revision ?? 0) + 1;
@@ -15226,6 +15280,7 @@ class PromptStream {
15226
15280
  revision: message.revision
15227
15281
  }
15228
15282
  });
15283
+ return true;
15229
15284
  }
15230
15285
  newestRowMessage() {
15231
15286
  for (let index = this.rows.length - 1;index >= 0; index -= 1) {
@@ -15257,6 +15312,7 @@ class PromptStream {
15257
15312
  this.rebuildOrderedParts(row);
15258
15313
  const parts = buildMessageParts(row.orderedParts, this.toolTracker);
15259
15314
  const content = getMessageTextFromParts(parts);
15315
+ let sdkUuidChanged = false;
15260
15316
  if (!row.message) {
15261
15317
  if (parts.length === 0 && !content)
15262
15318
  return;
@@ -15277,14 +15333,17 @@ class PromptStream {
15277
15333
  row.message.parts = parts;
15278
15334
  if (row.modelId)
15279
15335
  row.message.modelId = row.modelId;
15280
- if (row.sdkUuid)
15336
+ if (row.sdkUuid && row.message.sdkUuid !== row.sdkUuid) {
15281
15337
  row.message.sdkUuid = row.sdkUuid;
15338
+ sdkUuidChanged = true;
15339
+ }
15282
15340
  }
15341
+ if (!this.emitRow(row) && !sdkUuidChanged)
15342
+ return;
15283
15343
  if (row.message && session.messages.at(-1) !== row.message) {
15284
15344
  (session.revisedRows ??= new RecentlyRevisedRows).note(row.message.id);
15285
15345
  }
15286
15346
  markTranscriptChanged(session);
15287
- this.emitRow(row);
15288
15347
  }
15289
15348
  flushStreamedAssistantMessage() {
15290
15349
  this.clearFlushTimer();
@@ -16349,6 +16408,9 @@ function agentMailCapabilities(tabType, agent, locked = true) {
16349
16408
  }
16350
16409
  if (tabType === "claude-tmux")
16351
16410
  return { canPull: true, canSend: true, canInject: true };
16411
+ if (tabType === "pipeline-worker") {
16412
+ return agent ? { canPull: true, canSend: true, canInject: true } : { canPull: false, canSend: false, canInject: false };
16413
+ }
16352
16414
  if (["claude", "codex", "opencode"].includes(tabType)) {
16353
16415
  return { canPull: true, canSend: true, canInject: false };
16354
16416
  }
@@ -22260,6 +22322,72 @@ function boundTranscriptResponse(messages, maximumBytes, options = {}) {
22260
22322
  };
22261
22323
  }
22262
22324
 
22325
+ // ../../bridges/claude-bridge/src/services/execution-policy-narrowing.ts
22326
+ var APPROVALS_STRICTNESS = {
22327
+ "auto-approve": 0,
22328
+ ask: 1,
22329
+ deny: 2
22330
+ };
22331
+ var SANDBOX_STRICTNESS = {
22332
+ none: 0,
22333
+ container: 1,
22334
+ provider: 2
22335
+ };
22336
+ function networkStrictness(value) {
22337
+ return value === "restricted" ? 1 : 0;
22338
+ }
22339
+ function isSubset(candidate, of) {
22340
+ const allowed = new Set(of);
22341
+ return candidate.every((item) => allowed.has(item));
22342
+ }
22343
+ function rawCapabilityDenials(policy) {
22344
+ return [
22345
+ ...policy.capabilityPolicy?.deny ?? [],
22346
+ ...policy.capabilityPolicy?.extendedDeny ?? []
22347
+ ];
22348
+ }
22349
+ function executionPolicyWidenings(current, next) {
22350
+ if (!current)
22351
+ return [];
22352
+ const widened = [];
22353
+ if (next.id !== current.id)
22354
+ widened.push("id");
22355
+ if (APPROVALS_STRICTNESS[next.approvals] < APPROVALS_STRICTNESS[current.approvals]) {
22356
+ widened.push("approvals");
22357
+ }
22358
+ if (SANDBOX_STRICTNESS[next.sandbox] < SANDBOX_STRICTNESS[current.sandbox]) {
22359
+ widened.push("sandbox");
22360
+ }
22361
+ if (next.projectResources && !current.projectResources)
22362
+ widened.push("projectResources");
22363
+ if (networkStrictness(next.networkAccess) < networkStrictness(current.networkAccess)) {
22364
+ widened.push("networkAccess");
22365
+ }
22366
+ if (networkStrictness(next.containerNetworkAccess) < networkStrictness(current.containerNetworkAccess)) {
22367
+ widened.push("containerNetworkAccess");
22368
+ }
22369
+ const currentAllow = current.toolPolicy?.allow;
22370
+ const nextAllow = next.toolPolicy?.allow;
22371
+ const allowNarrows = currentAllow === undefined ? nextAllow === undefined || nextAllow.length === 0 : nextAllow !== undefined && isSubset(nextAllow, currentAllow);
22372
+ if (!allowNarrows)
22373
+ widened.push("toolPolicy.allow");
22374
+ if (!isSubset(current.toolPolicy?.deny ?? [], next.toolPolicy?.deny ?? [])) {
22375
+ widened.push("toolPolicy.deny");
22376
+ }
22377
+ if (!isSubset(rawCapabilityDenials(current), rawCapabilityDenials(next))) {
22378
+ widened.push("capabilityPolicy.deny");
22379
+ }
22380
+ if (!isSubset(next.capabilityPolicy?.allow ?? [], current.capabilityPolicy?.allow ?? [])) {
22381
+ widened.push("capabilityPolicy.allow");
22382
+ }
22383
+ const currentServers = nativeAgentUserMcpGrant(current);
22384
+ const nextServers = nativeAgentUserMcpGrant(next);
22385
+ if (currentServers !== undefined && (nextServers === undefined || !isSubset(nextServers, currentServers))) {
22386
+ widened.push("capabilityPolicy.userMcpServers");
22387
+ }
22388
+ return widened;
22389
+ }
22390
+
22263
22391
  // ../../bridges/claude-bridge/src/routes/session-close.ts
22264
22392
  function registerSessionCloseRoute(app) {
22265
22393
  app.post("/:id/close", async (c) => {
@@ -23074,6 +23202,10 @@ var interactionBodyLimit = bodyLimit({
23074
23202
  maxSize: MAX_QUESTION_ANSWER_REQUEST_BYTES,
23075
23203
  onError: (c) => c.json({ error: "Interaction response is too large" }, 413)
23076
23204
  });
23205
+ var compactBodyLimit = bodyLimit({
23206
+ maxSize: COMPACT_INSTRUCTIONS_MAX_LENGTH * 6 + 1024,
23207
+ onError: (c) => c.json({ error: "Compact request is too large" }, 413)
23208
+ });
23077
23209
  var holdBodyLimit = bodyLimit({
23078
23210
  maxSize: 1024,
23079
23211
  onError: (c) => c.json({ error: "Hold request is too large" }, 413)
@@ -23281,6 +23413,24 @@ session.post("/:id/config", async (c) => {
23281
23413
  if (Object.hasOwn(body, "policy") && !isNativeAgentExecutionPolicy(body.policy)) {
23282
23414
  return c.json({ error: "Invalid execution policy" }, 400);
23283
23415
  }
23416
+ const nextPolicy = effectiveExecutionPolicy(isNativeAgentExecutionPolicy(body.policy) ? body.policy : undefined);
23417
+ const refusePolicyWidening = () => {
23418
+ const widened = nextPolicy ? executionPolicyWidenings(sessionData.executionPolicy, nextPolicy) : [];
23419
+ if (widened.length > 0) {
23420
+ log21.warn("session.policy-widening-refused", {
23421
+ sessionId: sessionData.id,
23422
+ widened: widened.join(",")
23423
+ });
23424
+ return c.json({
23425
+ error: "Execution policy can only be narrowed on a live session; a wider policy applies after the agent bridge restarts.",
23426
+ code: "policy-widening-refused",
23427
+ widened
23428
+ }, 403);
23429
+ }
23430
+ };
23431
+ const refusal = refusePolicyWidening();
23432
+ if (refusal)
23433
+ return refusal;
23284
23434
  const { effort, parameterValues } = resolveUltracodeEffort(typeof body.reasoningId === "string" ? body.reasoningId : undefined, body.parameterValues && typeof body.parameterValues === "object" && !Array.isArray(body.parameterValues) ? body.parameterValues : undefined);
23285
23435
  const approvalMode = claudeApprovalMode(body.approvalMode);
23286
23436
  const permissionMode = body.mode === "plan" ? "plan" : body.mode === "build" ? approvalMode ?? "bypassPermissions" : approvalMode !== undefined && sessionData.planMode !== true ? approvalMode : undefined;
@@ -23295,7 +23445,9 @@ session.post("/:id/config", async (c) => {
23295
23445
  } catch (error) {
23296
23446
  return c.json({ error: error instanceof Error ? error.message : "Failed to configure session" }, sessionErrorStatus(error));
23297
23447
  }
23298
- const nextPolicy = effectiveExecutionPolicy(isNativeAgentExecutionPolicy(body.policy) ? body.policy : undefined);
23448
+ const stalePolicyRefusal = refusePolicyWidening();
23449
+ if (stalePolicyRefusal)
23450
+ return stalePolicyRefusal;
23299
23451
  if (nextPolicy) {
23300
23452
  sessionData.executionPolicy = structuredClone(nextPolicy);
23301
23453
  }
@@ -23711,8 +23863,20 @@ session.post("/:id/fork", async (c) => {
23711
23863
  return c.json({ error: errorMessage(error, "Failed to fork session") }, sessionErrorStatus(error));
23712
23864
  }
23713
23865
  });
23714
- session.post("/:id/compact", async (c) => {
23866
+ session.post("/:id/compact", compactBodyLimit, async (c) => {
23715
23867
  const id = c.req.param("id");
23868
+ const text = await c.req.text().catch(() => "");
23869
+ let body;
23870
+ if (text.trim()) {
23871
+ try {
23872
+ body = JSON.parse(text);
23873
+ } catch {
23874
+ return c.json({ error: "Compact request body is not JSON" }, 400);
23875
+ }
23876
+ }
23877
+ const parsed = parseCompactInstructionsBody(body);
23878
+ if (!parsed.ok)
23879
+ return c.json({ error: parsed.error }, 400);
23716
23880
  const resolved = await resolveSession(id, "Failed to compact session");
23717
23881
  if (!resolved.ok)
23718
23882
  return c.json(resolved.body, resolved.status);
@@ -23725,10 +23889,11 @@ session.post("/:id/compact", async (c) => {
23725
23889
  if (sessionData.rewindInProgress === true) {
23726
23890
  return c.json({ error: "Session is restoring files from a checkpoint" }, 409);
23727
23891
  }
23728
- sendPrompt(id, "/compact").catch((error) => {
23892
+ const { instructions } = parsed;
23893
+ sendPrompt(id, instructions ? `/compact ${instructions}` : "/compact").catch((error) => {
23729
23894
  log21.error("session.compact-failed", { error: formatLogError(error) });
23730
23895
  });
23731
- return c.json({ status: "processing" }, 202);
23896
+ return c.json(instructions ? { status: "processing", instructions: "applied" } : { status: "processing" }, 202);
23732
23897
  });
23733
23898
  session.post("/:id/rewind", async (c) => {
23734
23899
  const id = c.req.param("id");