orkestrator 2.35.5-beta → 2.36.0

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.",
@@ -989,6 +995,7 @@ var COORDINATOR_LOG_AREAS = defineLogAreas({
989
995
  "work.move-failed": "Work could not move to the main coordinator.",
990
996
  "wake.observe-remote-workflow-failed": "A remote workflow could not be observed for status wakes.",
991
997
  "wake.observe-pull-request-failed": "A pull request could not be observed for status wakes.",
998
+ "wake.observe-feature-plan-failed": "A feature plan could not be observed for status wakes.",
992
999
  "wake.observe-workflow-failed": "A workflow could not be observed for status wakes.",
993
1000
  "wake.deliver-failed": "A workflow status wake could not be delivered; the next pass retries.",
994
1001
  "wake.waiting-check-failed": "A waiting worker could not be checked; the next pass retries.",
@@ -1000,7 +1007,11 @@ var COORDINATOR_LOG_AREAS = defineLogAreas({
1000
1007
  "store.invalid-workspace": "An invalid coordinator workspace record was ignored.",
1001
1008
  "store.workflows-cleared": "The workflow store was full, so a batch of its oldest finished records was removed.",
1002
1009
  "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."
1010
+ "remote-worker.settle-failed": "A remote worker could not be settled.",
1011
+ "checkout.merge-followed": "After an environment's PR merged, the project checkout was fast-forwarded, or `outcome` says why not.",
1012
+ "checkout.merge-follow-failed": "Fast-forwarding the project checkout failed, after an environment's PR merged or before mail woke the main coordinator.",
1013
+ "checkout.mail-follow": "Before mail woke the main coordinator, the project checkout was fast-forwarded, or `outcome` says why not (`timed-out`, `failed`).",
1014
+ "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
1015
  }
1005
1016
  }
1006
1017
  });
@@ -1032,6 +1043,7 @@ var REVIEW_LOG_AREAS = defineLogAreas({
1032
1043
  "gh.pr-list-unparseable": "`gh pr list` returned nothing that parses. Sizes only, never the output.",
1033
1044
  "monitor.start-failed": "Monitoring could not start for a newly opened pull request.",
1034
1045
  "cleanup-scheduler.missing": "A merged pull request was seen, but this runtime has no merge cleanup scheduler.",
1046
+ "checkout.follow-merge-lookup-failed": "A merged pull request's project could not be read, so its checkout was not fast-forwarded.",
1035
1047
  "auto-merge.evaluation-failed": "Evaluating an environment for auto-merge failed.",
1036
1048
  "auto-merge.merge-failed": "Auto-merge could not merge a pull request; the attempt is held and retried.",
1037
1049
  "auto-merge.resolve-failed": "Auto-merge could not launch Resolve for a pull request; the attempt is held and retried.",
@@ -1075,6 +1087,8 @@ var AGENT_ACCOUNTS_LOG_AREAS = defineLogAreas({
1075
1087
  "container-sync.failed": "Handing a login or account to a container failed; `step` says which part.",
1076
1088
  "last-usage.save-failed": "The last plan usage reading could not be saved; the next save retries.",
1077
1089
  "login-cleanup.failed": "A temporary login could not be cleaned up.",
1090
+ "login-renewal.failed": "Renewing an idle account's sign-in to read its usage failed; it is retried after a backoff.",
1091
+ "login-renewal.not-extended": "Claude Code ran to renew an idle account's sign-in, but its token is still lapsed.",
1078
1092
  "login-refresh.deferred": "Containers were not told to refresh their login now; they reconcile from its durable generation."
1079
1093
  }
1080
1094
  }
@@ -1088,6 +1102,7 @@ var DOCKER_LOG_AREAS = defineLogAreas({
1088
1102
  "portable-inputs.relay-missing": "Docker is rootless and the image predates the staged-input relay, so the container cannot read them until rebuilt.",
1089
1103
  "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
1104
  "opencode.warm-incomplete": "OpenCode did not finish loading /workspace in a container.",
1105
+ "lifecycle-event.reconcile-failed": "Reconciling an environment after a container start or stop event failed; the next status read retries.",
1091
1106
  "login-keeper.pass-failed": "A Claude login keeper pass failed; the next interval retries.",
1092
1107
  "login-keeper.refresh-failed": "Refreshing the host Claude login failed. Fixed text: CLI output can hold credentials.",
1093
1108
  "login-keeper.refresh-not-extended": "Refreshing the host Claude login did not extend its expiry.",
@@ -1211,7 +1226,7 @@ var GRAPH_LOG_AREAS = defineLogAreas({
1211
1226
  // ../protocol/src/log-vocabulary/nodes.ts
1212
1227
  var NODES_LOG_AREAS = defineLogAreas({
1213
1228
  nodes: {
1214
- description: "Command nodes: links, handovers, leaf mail and project copies.",
1229
+ description: "Command nodes: links, handovers, leaf mail, ticket sync and project copies.",
1215
1230
  events: {
1216
1231
  "actions.resume-failed": "Approved actions could not be resumed; a later pass retries.",
1217
1232
  "project-copy.notify-failed": "The coordinator could not be told a project copy finished.",
@@ -1223,7 +1238,11 @@ var NODES_LOG_AREAS = defineLogAreas({
1223
1238
  "verification.record-failed": "A node verification could not be recorded.",
1224
1239
  "profile.record-failed": "A node profile could not be recorded.",
1225
1240
  "detach.unconfirmed": "A forgotten node has not confirmed the detach yet.",
1226
- "handover.recovery-pending": "Command handover recovery is still pending."
1241
+ "handover.recovery-pending": "Command handover recovery is still pending.",
1242
+ "ticket-sync.work-record-failed": "A remote build started but its ticket work location could not be saved.",
1243
+ "ticket-sync.failed": "A Kanban sync with a node failed; it is retried.",
1244
+ "ticket-sync.unknown-project": "A node sent ticket changes for a project that no longer exists here.",
1245
+ "ticket-sync.forget-failed": "A detached command node's ticket copies could not be released."
1227
1246
  }
1228
1247
  }
1229
1248
  });
@@ -1806,7 +1825,7 @@ var LOG_VOCABULARY = {
1806
1825
  // ../protocol/src/secret-redaction.ts
1807
1826
  var TEXT_RULES = [
1808
1827
  {
1809
- pattern: /([a-z][a-z0-9+.-]*:\/\/)[^/\s:@]+(?::[^/\s@]*)?@/gi,
1828
+ pattern: /(?<![a-z0-9+.-])([a-z][a-z0-9+.-]*:\/\/)[^/\s:@]+(?::[^/\s@]*)?@/gi,
1810
1829
  replacement: "$1[redacted]@"
1811
1830
  },
1812
1831
  {
@@ -1826,7 +1845,7 @@ var TEXT_RULES = [
1826
1845
  { pattern: /\bAKIA[0-9A-Z]{12,}/g, replacement: "[redacted]" },
1827
1846
  { pattern: /\bAIza[0-9A-Za-z_-]{20,}/g, replacement: "[redacted]" },
1828
1847
  {
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,
1848
+ 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
1849
  replacement: "$1$2[redacted]"
1831
1850
  }
1832
1851
  ];
@@ -7280,6 +7299,27 @@ var SUPPRESSED_COMPOSER_PARAMETERS = Object.freeze({
7280
7299
  claude: Object.freeze(["parameter:thinking", "parameter:context1m"]),
7281
7300
  cursor: Object.freeze(["parameter:variant"])
7282
7301
  });
7302
+ var COMPACT_INSTRUCTIONS_MAX_LENGTH = 16000;
7303
+ function parseCompactInstructionsBody(body) {
7304
+ if (body === undefined || body === null)
7305
+ return { ok: true };
7306
+ if (typeof body !== "object" || Array.isArray(body)) {
7307
+ return { ok: false, error: "Compact request body must be an object" };
7308
+ }
7309
+ const raw = body.instructions;
7310
+ if (raw === undefined)
7311
+ return { ok: true };
7312
+ if (typeof raw !== "string")
7313
+ return { ok: false, error: "instructions must be a string" };
7314
+ const instructions = raw.trim();
7315
+ if (instructions.length > COMPACT_INSTRUCTIONS_MAX_LENGTH) {
7316
+ return {
7317
+ ok: false,
7318
+ error: `instructions must be at most ${COMPACT_INSTRUCTIONS_MAX_LENGTH} characters`
7319
+ };
7320
+ }
7321
+ return instructions ? { ok: true, instructions } : { ok: true };
7322
+ }
7283
7323
  function isNativeAgentExecutionPolicy(value) {
7284
7324
  if (!value || typeof value !== "object" || Array.isArray(value))
7285
7325
  return false;
@@ -9974,6 +10014,14 @@ class ToolTracker {
9974
10014
  getTool(toolUseId) {
9975
10015
  return this.tools.get(toolUseId);
9976
10016
  }
10017
+ getToolWithCreatedAt(toolUseId, createdAt) {
10018
+ const existing = this.tools.get(toolUseId);
10019
+ if (!existing || !createdAt || existing.createdAt)
10020
+ return existing;
10021
+ const stamped = { ...existing, createdAt };
10022
+ this.tools.set(toolUseId, stamped);
10023
+ return stamped;
10024
+ }
9977
10025
  }
9978
10026
  function parseMcpToolName(toolName, knownServerNames) {
9979
10027
  if (!toolName.startsWith("mcp_")) {
@@ -10185,11 +10233,13 @@ function refreshSettledToolRows(session, sessionId, toolTracker, toolUseIds, pub
10185
10233
  return part;
10186
10234
  }
10187
10235
  pending.delete(part.toolUseId);
10188
- const tracked = toolTracker.getTool(part.toolUseId);
10189
- if (!tracked || published?.has(message))
10236
+ if (published?.has(message))
10237
+ return part;
10238
+ const tracked = toolTracker.getToolWithCreatedAt(part.toolUseId, part.createdAt);
10239
+ if (!tracked || tracked === part)
10190
10240
  return part;
10191
10241
  changed = true;
10192
- return part.createdAt && !tracked.createdAt ? { ...tracked, createdAt: part.createdAt } : tracked;
10242
+ return tracked;
10193
10243
  });
10194
10244
  if (changed) {
10195
10245
  message.parts = parts;
@@ -10436,10 +10486,9 @@ function buildMessageParts(orderedParts, toolTracker) {
10436
10486
  parentTaskUseId: entry.parentTaskUseId
10437
10487
  });
10438
10488
  } 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
- }
10489
+ const tool = toolTracker.getToolWithCreatedAt(entry.value, entry.timestamp);
10490
+ if (tool)
10491
+ result.push(tool);
10443
10492
  } else if (entry.type === "text") {
10444
10493
  result.push({
10445
10494
  type: "text",
@@ -15191,7 +15240,7 @@ class PromptStream {
15191
15240
  const { session, sessionId } = this;
15192
15241
  const message = row.message;
15193
15242
  if (!message)
15194
- return;
15243
+ return false;
15195
15244
  const parts = message.parts;
15196
15245
  if (!row.published || row.publishedModelId !== message.modelId) {
15197
15246
  row.published = true;
@@ -15200,7 +15249,7 @@ class PromptStream {
15200
15249
  message.revision = (message.revision ?? 0) + 1;
15201
15250
  markTranscriptChanged(session);
15202
15251
  eventEmitter.emit({ type: "message.updated", sessionId, data: { message } });
15203
- return;
15252
+ return true;
15204
15253
  }
15205
15254
  const changedParts = [];
15206
15255
  for (let index = 0;index < parts.length; index += 1) {
@@ -15210,7 +15259,7 @@ class PromptStream {
15210
15259
  }
15211
15260
  }
15212
15261
  if (changedParts.length === 0 && parts.length === row.publishedParts.length) {
15213
- return;
15262
+ return false;
15214
15263
  }
15215
15264
  row.publishedParts = parts.slice();
15216
15265
  message.revision = (message.revision ?? 0) + 1;
@@ -15226,6 +15275,7 @@ class PromptStream {
15226
15275
  revision: message.revision
15227
15276
  }
15228
15277
  });
15278
+ return true;
15229
15279
  }
15230
15280
  newestRowMessage() {
15231
15281
  for (let index = this.rows.length - 1;index >= 0; index -= 1) {
@@ -15257,6 +15307,7 @@ class PromptStream {
15257
15307
  this.rebuildOrderedParts(row);
15258
15308
  const parts = buildMessageParts(row.orderedParts, this.toolTracker);
15259
15309
  const content = getMessageTextFromParts(parts);
15310
+ let sdkUuidChanged = false;
15260
15311
  if (!row.message) {
15261
15312
  if (parts.length === 0 && !content)
15262
15313
  return;
@@ -15277,14 +15328,17 @@ class PromptStream {
15277
15328
  row.message.parts = parts;
15278
15329
  if (row.modelId)
15279
15330
  row.message.modelId = row.modelId;
15280
- if (row.sdkUuid)
15331
+ if (row.sdkUuid && row.message.sdkUuid !== row.sdkUuid) {
15281
15332
  row.message.sdkUuid = row.sdkUuid;
15333
+ sdkUuidChanged = true;
15334
+ }
15282
15335
  }
15336
+ if (!this.emitRow(row) && !sdkUuidChanged)
15337
+ return;
15283
15338
  if (row.message && session.messages.at(-1) !== row.message) {
15284
15339
  (session.revisedRows ??= new RecentlyRevisedRows).note(row.message.id);
15285
15340
  }
15286
15341
  markTranscriptChanged(session);
15287
- this.emitRow(row);
15288
15342
  }
15289
15343
  flushStreamedAssistantMessage() {
15290
15344
  this.clearFlushTimer();
@@ -22260,6 +22314,72 @@ function boundTranscriptResponse(messages, maximumBytes, options = {}) {
22260
22314
  };
22261
22315
  }
22262
22316
 
22317
+ // ../../bridges/claude-bridge/src/services/execution-policy-narrowing.ts
22318
+ var APPROVALS_STRICTNESS = {
22319
+ "auto-approve": 0,
22320
+ ask: 1,
22321
+ deny: 2
22322
+ };
22323
+ var SANDBOX_STRICTNESS = {
22324
+ none: 0,
22325
+ container: 1,
22326
+ provider: 2
22327
+ };
22328
+ function networkStrictness(value) {
22329
+ return value === "restricted" ? 1 : 0;
22330
+ }
22331
+ function isSubset(candidate, of) {
22332
+ const allowed = new Set(of);
22333
+ return candidate.every((item) => allowed.has(item));
22334
+ }
22335
+ function rawCapabilityDenials(policy) {
22336
+ return [
22337
+ ...policy.capabilityPolicy?.deny ?? [],
22338
+ ...policy.capabilityPolicy?.extendedDeny ?? []
22339
+ ];
22340
+ }
22341
+ function executionPolicyWidenings(current, next) {
22342
+ if (!current)
22343
+ return [];
22344
+ const widened = [];
22345
+ if (next.id !== current.id)
22346
+ widened.push("id");
22347
+ if (APPROVALS_STRICTNESS[next.approvals] < APPROVALS_STRICTNESS[current.approvals]) {
22348
+ widened.push("approvals");
22349
+ }
22350
+ if (SANDBOX_STRICTNESS[next.sandbox] < SANDBOX_STRICTNESS[current.sandbox]) {
22351
+ widened.push("sandbox");
22352
+ }
22353
+ if (next.projectResources && !current.projectResources)
22354
+ widened.push("projectResources");
22355
+ if (networkStrictness(next.networkAccess) < networkStrictness(current.networkAccess)) {
22356
+ widened.push("networkAccess");
22357
+ }
22358
+ if (networkStrictness(next.containerNetworkAccess) < networkStrictness(current.containerNetworkAccess)) {
22359
+ widened.push("containerNetworkAccess");
22360
+ }
22361
+ const currentAllow = current.toolPolicy?.allow;
22362
+ const nextAllow = next.toolPolicy?.allow;
22363
+ const allowNarrows = currentAllow === undefined ? nextAllow === undefined || nextAllow.length === 0 : nextAllow !== undefined && isSubset(nextAllow, currentAllow);
22364
+ if (!allowNarrows)
22365
+ widened.push("toolPolicy.allow");
22366
+ if (!isSubset(current.toolPolicy?.deny ?? [], next.toolPolicy?.deny ?? [])) {
22367
+ widened.push("toolPolicy.deny");
22368
+ }
22369
+ if (!isSubset(rawCapabilityDenials(current), rawCapabilityDenials(next))) {
22370
+ widened.push("capabilityPolicy.deny");
22371
+ }
22372
+ if (!isSubset(next.capabilityPolicy?.allow ?? [], current.capabilityPolicy?.allow ?? [])) {
22373
+ widened.push("capabilityPolicy.allow");
22374
+ }
22375
+ const currentServers = nativeAgentUserMcpGrant(current);
22376
+ const nextServers = nativeAgentUserMcpGrant(next);
22377
+ if (currentServers !== undefined && (nextServers === undefined || !isSubset(nextServers, currentServers))) {
22378
+ widened.push("capabilityPolicy.userMcpServers");
22379
+ }
22380
+ return widened;
22381
+ }
22382
+
22263
22383
  // ../../bridges/claude-bridge/src/routes/session-close.ts
22264
22384
  function registerSessionCloseRoute(app) {
22265
22385
  app.post("/:id/close", async (c) => {
@@ -23074,6 +23194,10 @@ var interactionBodyLimit = bodyLimit({
23074
23194
  maxSize: MAX_QUESTION_ANSWER_REQUEST_BYTES,
23075
23195
  onError: (c) => c.json({ error: "Interaction response is too large" }, 413)
23076
23196
  });
23197
+ var compactBodyLimit = bodyLimit({
23198
+ maxSize: COMPACT_INSTRUCTIONS_MAX_LENGTH * 6 + 1024,
23199
+ onError: (c) => c.json({ error: "Compact request is too large" }, 413)
23200
+ });
23077
23201
  var holdBodyLimit = bodyLimit({
23078
23202
  maxSize: 1024,
23079
23203
  onError: (c) => c.json({ error: "Hold request is too large" }, 413)
@@ -23281,6 +23405,24 @@ session.post("/:id/config", async (c) => {
23281
23405
  if (Object.hasOwn(body, "policy") && !isNativeAgentExecutionPolicy(body.policy)) {
23282
23406
  return c.json({ error: "Invalid execution policy" }, 400);
23283
23407
  }
23408
+ const nextPolicy = effectiveExecutionPolicy(isNativeAgentExecutionPolicy(body.policy) ? body.policy : undefined);
23409
+ const refusePolicyWidening = () => {
23410
+ const widened = nextPolicy ? executionPolicyWidenings(sessionData.executionPolicy, nextPolicy) : [];
23411
+ if (widened.length > 0) {
23412
+ log21.warn("session.policy-widening-refused", {
23413
+ sessionId: sessionData.id,
23414
+ widened: widened.join(",")
23415
+ });
23416
+ return c.json({
23417
+ error: "Execution policy can only be narrowed on a live session; a wider policy applies after the agent bridge restarts.",
23418
+ code: "policy-widening-refused",
23419
+ widened
23420
+ }, 403);
23421
+ }
23422
+ };
23423
+ const refusal = refusePolicyWidening();
23424
+ if (refusal)
23425
+ return refusal;
23284
23426
  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
23427
  const approvalMode = claudeApprovalMode(body.approvalMode);
23286
23428
  const permissionMode = body.mode === "plan" ? "plan" : body.mode === "build" ? approvalMode ?? "bypassPermissions" : approvalMode !== undefined && sessionData.planMode !== true ? approvalMode : undefined;
@@ -23295,7 +23437,9 @@ session.post("/:id/config", async (c) => {
23295
23437
  } catch (error) {
23296
23438
  return c.json({ error: error instanceof Error ? error.message : "Failed to configure session" }, sessionErrorStatus(error));
23297
23439
  }
23298
- const nextPolicy = effectiveExecutionPolicy(isNativeAgentExecutionPolicy(body.policy) ? body.policy : undefined);
23440
+ const stalePolicyRefusal = refusePolicyWidening();
23441
+ if (stalePolicyRefusal)
23442
+ return stalePolicyRefusal;
23299
23443
  if (nextPolicy) {
23300
23444
  sessionData.executionPolicy = structuredClone(nextPolicy);
23301
23445
  }
@@ -23711,8 +23855,20 @@ session.post("/:id/fork", async (c) => {
23711
23855
  return c.json({ error: errorMessage(error, "Failed to fork session") }, sessionErrorStatus(error));
23712
23856
  }
23713
23857
  });
23714
- session.post("/:id/compact", async (c) => {
23858
+ session.post("/:id/compact", compactBodyLimit, async (c) => {
23715
23859
  const id = c.req.param("id");
23860
+ const text = await c.req.text().catch(() => "");
23861
+ let body;
23862
+ if (text.trim()) {
23863
+ try {
23864
+ body = JSON.parse(text);
23865
+ } catch {
23866
+ return c.json({ error: "Compact request body is not JSON" }, 400);
23867
+ }
23868
+ }
23869
+ const parsed = parseCompactInstructionsBody(body);
23870
+ if (!parsed.ok)
23871
+ return c.json({ error: parsed.error }, 400);
23716
23872
  const resolved = await resolveSession(id, "Failed to compact session");
23717
23873
  if (!resolved.ok)
23718
23874
  return c.json(resolved.body, resolved.status);
@@ -23725,10 +23881,11 @@ session.post("/:id/compact", async (c) => {
23725
23881
  if (sessionData.rewindInProgress === true) {
23726
23882
  return c.json({ error: "Session is restoring files from a checkpoint" }, 409);
23727
23883
  }
23728
- sendPrompt(id, "/compact").catch((error) => {
23884
+ const { instructions } = parsed;
23885
+ sendPrompt(id, instructions ? `/compact ${instructions}` : "/compact").catch((error) => {
23729
23886
  log21.error("session.compact-failed", { error: formatLogError(error) });
23730
23887
  });
23731
- return c.json({ status: "processing" }, 202);
23888
+ return c.json(instructions ? { status: "processing", instructions: "applied" } : { status: "processing" }, 202);
23732
23889
  });
23733
23890
  session.post("/:id/rewind", async (c) => {
23734
23891
  const id = c.req.param("id");