Skip to content

Commit cda637e

Browse files
committed
fix: isolate session destinations for device builds
1 parent f0a9b1e commit cda637e

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/mcp/tools/device/build_device.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ export const handler = createSessionAwareTool<BuildDeviceParams>({
228228
internalSchema: toInternalSchema<BuildDeviceParams>(buildDeviceSchema),
229229
logicFunction: buildDeviceLogic,
230230
getExecutor: getDefaultCommandExecutor,
231+
clearSessionDeviceIdUnlessPrepared: true,
231232
requirements: [
232233
{ allOf: ['scheme'], message: 'scheme is required' },
233234
{ oneOf: ['projectPath', 'workspacePath'], message: 'Provide a project or workspace' },

src/utils/typed-tool-factory.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,15 @@ export function createSessionAwareTool<TParams>(opts: {
170170
getExecutor: () => CommandExecutor;
171171
requirements?: SessionRequirement[];
172172
exclusivePairs?: readonly ExclusiveParameterGroup[];
173+
clearSessionDeviceIdUnlessPrepared?: boolean;
173174
}): ToolHandler {
174175
return createSessionAwareHandler({
175176
internalSchema: opts.internalSchema,
176177
logicFunction: opts.logicFunction,
177178
getContext: opts.getExecutor,
178179
requirements: opts.requirements,
179180
exclusivePairs: opts.exclusivePairs,
181+
clearSessionDeviceIdUnlessPrepared: opts.clearSessionDeviceIdUnlessPrepared,
180182
});
181183
}
182184

@@ -186,6 +188,7 @@ export function createSessionAwareToolWithContext<TParams, TContext>(opts: {
186188
getContext: () => TContext;
187189
requirements?: SessionRequirement[];
188190
exclusivePairs?: readonly ExclusiveParameterGroup[];
191+
clearSessionDeviceIdUnlessPrepared?: boolean;
189192
}): ToolHandler {
190193
return createSessionAwareHandler(opts);
191194
}
@@ -196,13 +199,15 @@ function createSessionAwareHandler<TParams, TContext>(opts: {
196199
getContext: () => TContext;
197200
requirements?: SessionRequirement[];
198201
exclusivePairs?: readonly ExclusiveParameterGroup[];
202+
clearSessionDeviceIdUnlessPrepared?: boolean;
199203
}): ToolHandler {
200204
const {
201205
internalSchema,
202206
logicFunction,
203207
getContext,
204208
requirements = [],
205209
exclusivePairs = [],
210+
clearSessionDeviceIdUnlessPrepared = false,
206211
} = opts;
207212

208213
const impl = async (
@@ -236,7 +241,10 @@ function createSessionAwareHandler<TParams, TContext>(opts: {
236241
}
237242

238243
const sessionDefaults = filterSessionDefaultsForSchema(sessionStore.getAll(), internalSchema);
239-
if (sanitizedArgs.buildForTesting === true && sanitizedArgs.deviceId === undefined) {
244+
if (
245+
sanitizedArgs.deviceId === undefined &&
246+
(sanitizedArgs.buildForTesting === true || clearSessionDeviceIdUnlessPrepared)
247+
) {
240248
delete sessionDefaults.deviceId;
241249
}
242250
const hasExplicitPreparedSource =

0 commit comments

Comments
 (0)