Skip to content

Commit ee701e2

Browse files
committed
fix(muse): Supervised threads ask before commands again
Muse threads started without a permission profile, so Muse applied its own default, which can be :auto-review. T3 now selects :ask-me for Supervised and :unrestricted for Full access on session/start and session/resume, so resumed threads and mode changes pick it up too.
1 parent bf8ffe8 commit ee701e2

4 files changed

Lines changed: 43 additions & 3 deletions

File tree

‎packages/provider-muse/src/server/adapter.test.ts‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,32 @@ describe("MuseAdapterV2", () => {
381381
}).pipe(Effect.scoped, Effect.provide(testLayer)),
382382
);
383383

384+
it.effect("selects the runtime mode's permission profile on native start and resume", () =>
385+
Effect.gen(function* () {
386+
for (const [runtimeMode, profile, approvalMode] of [
387+
["approval-required", ":ask-me", "promptUnmatched"],
388+
["full-access", ":unrestricted", "allowAll"],
389+
] as const) {
390+
const policy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
391+
...runtimePolicy,
392+
runtimeMode,
393+
});
394+
const fresh = yield* makeFakeMuse();
395+
yield* makeHarness(fresh, INSTANCE_ID, undefined, undefined, undefined, policy);
396+
const started = yield* fresh.takeCall("session/start");
397+
assert.strictEqual(started.params.permissionProfile, profile);
398+
assert.strictEqual(started.params.approvalMode, approvalMode);
399+
400+
const saved = yield* makeFakeMuse();
401+
yield* makeHarness(saved, INSTANCE_ID, "saved-session", undefined, undefined, policy);
402+
const resumed = yield* saved.takeCall("session/resume");
403+
assert.strictEqual(resumed.params.permissionProfile, profile);
404+
const mode = yield* saved.takeCall("session/setApprovalMode");
405+
assert.strictEqual(mode.params.mode, approvalMode);
406+
}
407+
}).pipe(Effect.scoped, Effect.provide(testLayer)),
408+
);
409+
384410
it.effect("rejects a host without session MCP support before opening a native session", () =>
385411
Effect.gen(function* () {
386412
yield* (yield* McpProviderSessions.McpProviderSessions).set({

‎packages/provider-muse/src/server/adapter.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ import {
6464
import {
6565
createMuseSdkHostEffect,
6666
museApprovalMode,
67+
musePermissionProfile,
6768
museWorkspaceRoot,
6869
type createMuseSdkHost,
6970
type MuseSdkHost,
@@ -1791,17 +1792,21 @@ export const makeMuseAdapterV2 = Effect.fn("makeMuseAdapterV2")(function* (
17911792
}
17921793
: undefined;
17931794
const startModel = yield* resolveModel(args.modelSelection);
1795+
// Resume selects it too, since the thread may predate it or its mode changed.
1796+
// `session/setPermissionProfile` would need Muse's experimental API.
1797+
const permissionProfile = musePermissionProfile(args.runtimePolicy.runtimeMode);
17941798
const result = yield* request(
17951799
requestedId ? "session/resume" : "session/start",
17961800
requestedId
17971801
? // T3 already has the transcript; skip Muse's history payload.
1798-
{ excludeItems: true, ...(config ? { config } : {}) }
1802+
{ excludeItems: true, ...(config ? { config } : {}), permissionProfile }
17991803
: {
18001804
workspaceRoot: cwd,
18011805
...(config ? { config } : {}),
18021806
...(startModel ? { modelId: startModel } : {}),
18031807
providerId: "meta",
18041808
approvalMode: museApprovalMode(args.runtimePolicy.runtimeMode),
1809+
permissionProfile,
18051810
},
18061811
).pipe(
18071812
Effect.catch((error) => {

‎packages/provider-muse/src/server/sdk.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,15 @@ export function museApprovalMode(runtimeMode: RuntimeMode) {
138138
return runtimeMode === "full-access" ? "allowAll" : "promptUnmatched";
139139
}
140140

141+
/**
142+
* The permission profile `session/start` and `session/resume` select. Without
143+
* one Muse applies its own default, which can be `:auto-review`, where an AI
144+
* reviewer decides eligible approvals instead of the user.
145+
*/
146+
export function musePermissionProfile(runtimeMode: RuntimeMode) {
147+
return runtimeMode === "full-access" ? ":unrestricted" : ":ask-me";
148+
}
149+
141150
/** The `muse serve` arguments for a host: read-only hosts get no shell, writes, or workspace trust. */
142151
export function museServeArgs(
143152
options: Pick<MuseSdkHostOptions, "readOnly" | "sessionLogging" | "runtimeMode">,

‎packages/provider-muse/src/server/status.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ const MUSE_PRESENTATION = {
2424
displayName: "Muse Code",
2525
showInteractionModeToggle: false,
2626
reportsContextWindow: true,
27-
// Muse has no native "accept edits" or reviewer-backed mode, so T3 offers only
28-
// the two it maps directly: promptUnmatched and allowAll.
27+
// Muse has no native "accept edits" mode, so T3 offers only the two it maps
28+
// directly: :ask-me with promptUnmatched, and :unrestricted with allowAll.
2929
supportedRuntimeModes: ["approval-required", "full-access"],
3030
} as const;
3131

0 commit comments

Comments
 (0)