@moxt-ai/mobius 0.0.438 → 0.0.439

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.
@@ -3,7 +3,7 @@ import {
3
3
  __export,
4
4
  __using,
5
5
  package_default
6
- } from "./chunk-XKWYAXD7.js";
6
+ } from "./chunk-J2RRCJX6.js";
7
7
 
8
8
  // src/engine/runtime/relay/runtime-revocation.ts
9
9
  var runtimeRevocationCloseCode = 1008;
@@ -63952,6 +63952,21 @@ function toGoalSnapshot(message) {
63952
63952
  };
63953
63953
  }
63954
63954
 
63955
+ // src/engine/acp/harness/claude/upstream/dist/permissions/bypass-requests.js
63956
+ var QUESTION_MESSAGE = "This session does not ask the user questions (bypass permissions mode), so the question was not shown. Decide with your best judgment, state the assumption you made, and continue. If the work cannot continue without an answer, end your turn and ask the question in your final message.";
63957
+ var BYPASS_PLAN_MODE_MESSAGE = "Plan mode is not available in this session: leaving it takes the user's approval, and the session does not ask for approval (bypass permissions mode). Continue the work in the current mode. If the user asked for a plan first, present it in your reply instead.";
63958
+ function declineBypassRequest(toolName, toolUseID, decisionReason) {
63959
+ if (toolName === "AskUserQuestion") {
63960
+ return { behavior: "deny", message: QUESTION_MESSAGE, toolUseID };
63961
+ }
63962
+ const reason = decisionReason?.trim();
63963
+ return {
63964
+ behavior: "deny",
63965
+ message: `This ${toolName} call needs the user's approval${reason ? ` (${reason})` : ""}, and this session does not ask for approval (bypass permissions mode), so it was not run. Repeating the same call will be declined again. If the step is still needed, do it in a way that needs no approval, such as a simpler or more narrowly targeted call; otherwise leave it undone and report it in your final message.`,
63966
+ toolUseID
63967
+ };
63968
+ }
63969
+
63955
63970
  // src/engine/acp/harness/claude/upstream/dist/permissions/modes.js
63956
63971
  var IS_ROOT = (process.geteuid?.() ?? process.getuid?.()) === 0;
63957
63972
  var ALLOW_BYPASS = !IS_ROOT || !!process.env.IS_SANDBOX;
@@ -66081,6 +66096,8 @@ var SessionModeManager = class {
66081
66096
  this.options.logError(`permissions.defaultMode "${effectiveMode}" is not available in this session; falling back to "default".`);
66082
66097
  effectiveMode = "default";
66083
66098
  await this.trySyncMode(query, effectiveMode, "Failed to sync clamped permissionMode to SDK:");
66099
+ } else if (effectiveMode === "bypassPermissions" && !await this.acceptsBypass(query)) {
66100
+ effectiveMode = "default";
66084
66101
  }
66085
66102
  return {
66086
66103
  modes: { currentModeId: effectiveMode, availableModes },
@@ -66110,6 +66127,12 @@ var SessionModeManager = class {
66110
66127
  availableModeIds(modes) {
66111
66128
  return modes.availableModes.map((mode) => mode.id);
66112
66129
  }
66130
+ /** Whether the session must not wait for the user. Claude Code still sends
66131
+ * some requests for a person under bypassPermissions; the adapter answers
66132
+ * them itself (see permissions/bypass-requests.ts). */
66133
+ neverAsksUser(session) {
66134
+ return session.modes.currentModeId === "bypassPermissions";
66135
+ }
66113
66136
  effectiveMode(session, requestedMode) {
66114
66137
  return requestedMode === "auto" && this.isAutoUnavailable(session) ? AUTO_MODE_FALLBACK : requestedMode;
66115
66138
  }
@@ -66261,12 +66284,25 @@ var SessionModeManager = class {
66261
66284
  modes.push({
66262
66285
  id: "bypassPermissions",
66263
66286
  name: "Bypass permissions",
66264
- description: "Accepts all permissions",
66287
+ description: "Never asks the user: runs tools without approval and declines anything that would need a person's approval or answer",
66265
66288
  _meta: { kind: "full_access" }
66266
66289
  });
66267
66290
  }
66268
66291
  return modes;
66269
66292
  }
66293
+ /** Claude Code starts in the default mode, without an error, when its
66294
+ * settings disable bypassPermissions; only selecting the mode reports that.
66295
+ * A session shown as bypassing permissions must really do so, because it
66296
+ * answers Claude Code's remaining requests itself (see neverAsksUser). */
66297
+ async acceptsBypass(query) {
66298
+ try {
66299
+ await query.setPermissionMode("bypassPermissions");
66300
+ return true;
66301
+ } catch (error62) {
66302
+ this.options.logError('permissions.defaultMode "bypassPermissions" was not accepted by Claude Code; falling back to "default".', error62);
66303
+ return false;
66304
+ }
66305
+ }
66270
66306
  async trySyncMode(query, mode, errorMessage) {
66271
66307
  try {
66272
66308
  await query.setPermissionMode(mode);
@@ -69055,6 +69091,10 @@ ${message.api_refusal_explanation}` : "";
69055
69091
  message: "Session not found"
69056
69092
  };
69057
69093
  }
69094
+ if (this.sessionModes.neverAsksUser(session)) {
69095
+ this.logger.log(`[claude-agent-acp] Declined ${toolName} without asking: the session bypasses permissions`);
69096
+ return declineBypassRequest(toolName, toolUseID, decisionReason);
69097
+ }
69058
69098
  const parentToolUseId = agentID ? session.liveBackgroundTasks.get(agentID)?.parentToolUseId ?? "" : void 0;
69059
69099
  if (agentID && parentToolUseId === "") {
69060
69100
  this.logger.log(`[claude-agent-acp] No parent tool_use recorded for subagent ${agentID}; sending the ${toolName} permission request unattributed`);
@@ -69138,6 +69178,10 @@ ${message.api_refusal_explanation}` : "";
69138
69178
  if (isUrl && !support.url || !isUrl && !support.form) {
69139
69179
  return { action: "decline" };
69140
69180
  }
69181
+ const session = this.sessions[sessionId];
69182
+ if (session && this.sessionModes.neverAsksUser(session)) {
69183
+ return { action: "decline" };
69184
+ }
69141
69185
  const createRequest = mcpElicitationToCreateRequest(request, sessionId);
69142
69186
  if (!createRequest) {
69143
69187
  return { action: "decline" };
@@ -69200,6 +69244,10 @@ ${message.api_refusal_explanation}` : "";
69200
69244
  if (request.dialogKind !== REFUSAL_FALLBACK_DIALOG_KIND) {
69201
69245
  return { behavior: "cancelled" };
69202
69246
  }
69247
+ const session = this.sessions[sessionId];
69248
+ if (session && this.sessionModes.neverAsksUser(session)) {
69249
+ return { behavior: "cancelled" };
69250
+ }
69203
69251
  const prompt = extractRefusalFallbackPrompt(request.payload);
69204
69252
  if (!prompt) {
69205
69253
  this.logger.error(`refusal_fallback_prompt payload had an unexpected shape; cancelling the dialog: ${JSON.stringify(request.payload)}`);
@@ -69585,6 +69633,31 @@ ${message.api_refusal_explanation}` : "";
69585
69633
  tools,
69586
69634
  hooks: {
69587
69635
  ...userProvidedOptions?.hooks,
69636
+ // Claude enters plan mode without asking under bypassPermissions, but
69637
+ // only the user's approval of the plan leaves it, and that mode never
69638
+ // asks. Keep the session out of plan mode, where Claude could neither
69639
+ // write nor leave.
69640
+ PreToolUse: [
69641
+ ...userProvidedOptions?.hooks?.PreToolUse || [],
69642
+ {
69643
+ matcher: "EnterPlanMode",
69644
+ hooks: [
69645
+ async (input3) => {
69646
+ const live = this.sessions[sessionId];
69647
+ if (input3.hook_event_name !== "PreToolUse" || !live || !this.sessionModes.neverAsksUser(live)) {
69648
+ return { continue: true };
69649
+ }
69650
+ return {
69651
+ hookSpecificOutput: {
69652
+ hookEventName: "PreToolUse",
69653
+ permissionDecision: "deny",
69654
+ permissionDecisionReason: BYPASS_PLAN_MODE_MESSAGE
69655
+ }
69656
+ };
69657
+ }
69658
+ ]
69659
+ }
69660
+ ],
69588
69661
  PostToolUse: [
69589
69662
  ...userProvidedOptions?.hooks?.PostToolUse || [],
69590
69663
  {
@@ -96626,4 +96699,4 @@ export {
96626
96699
  * MIT Licensed
96627
96700
  *)
96628
96701
  */
96629
- //# sourceMappingURL=chunk-INF4TYV5.js.map
96702
+ //# sourceMappingURL=chunk-FDHUTFPW.js.map