claude-code-rust 0.8.0 → 0.8.2
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.
|
@@ -217,6 +217,11 @@ function initialSessionModel(launchSettings) {
|
|
|
217
217
|
const model = typeof settings?.model === "string" ? settings.model.trim() : "";
|
|
218
218
|
return model || DEFAULT_MODEL_NAME;
|
|
219
219
|
}
|
|
220
|
+
function startupModelOption(launchSettings) {
|
|
221
|
+
const settings = settingsObjectFromLaunchSettings(launchSettings);
|
|
222
|
+
const model = typeof settings?.model === "string" ? settings.model.trim() : "";
|
|
223
|
+
return model ? { model } : {};
|
|
224
|
+
}
|
|
220
225
|
function initialSessionMode(launchSettings) {
|
|
221
226
|
const settings = settingsObjectFromLaunchSettings(launchSettings);
|
|
222
227
|
const permissions = settings?.permissions && typeof settings.permissions === "object" && !Array.isArray(settings.permissions)
|
|
@@ -224,6 +229,22 @@ function initialSessionMode(launchSettings) {
|
|
|
224
229
|
: undefined;
|
|
225
230
|
return permissionModeFromSettingsValue(permissions?.defaultMode) ?? DEFAULT_PERMISSION_MODE;
|
|
226
231
|
}
|
|
232
|
+
function startupPermissionModeOptions(launchSettings) {
|
|
233
|
+
const settings = settingsObjectFromLaunchSettings(launchSettings);
|
|
234
|
+
const permissions = settings?.permissions && typeof settings.permissions === "object" && !Array.isArray(settings.permissions)
|
|
235
|
+
? settings.permissions
|
|
236
|
+
: undefined;
|
|
237
|
+
const permissionMode = permissionModeFromSettingsValue(permissions?.defaultMode);
|
|
238
|
+
if (!permissionMode) {
|
|
239
|
+
return {};
|
|
240
|
+
}
|
|
241
|
+
return permissionMode === "bypassPermissions"
|
|
242
|
+
? {
|
|
243
|
+
permissionMode,
|
|
244
|
+
allowDangerouslySkipPermissions: true,
|
|
245
|
+
}
|
|
246
|
+
: { permissionMode };
|
|
247
|
+
}
|
|
227
248
|
function systemPromptFromLaunchSettings(launchSettings) {
|
|
228
249
|
const language = launchSettings.language?.trim();
|
|
229
250
|
if (!language) {
|
|
@@ -238,12 +259,16 @@ function systemPromptFromLaunchSettings(launchSettings) {
|
|
|
238
259
|
}
|
|
239
260
|
export function buildQueryOptions(params) {
|
|
240
261
|
const systemPrompt = systemPromptFromLaunchSettings(params.launchSettings);
|
|
262
|
+
const modelOption = startupModelOption(params.launchSettings);
|
|
263
|
+
const permissionModeOptions = startupPermissionModeOptions(params.launchSettings);
|
|
241
264
|
return {
|
|
242
265
|
cwd: params.cwd,
|
|
243
266
|
includePartialMessages: true,
|
|
244
267
|
executable: "node",
|
|
245
268
|
...(params.resume ? {} : { sessionId: params.provisionalSessionId }),
|
|
246
269
|
...(params.launchSettings.settings ? { settings: params.launchSettings.settings } : {}),
|
|
270
|
+
...modelOption,
|
|
271
|
+
...permissionModeOptions,
|
|
247
272
|
toolConfig: { askUserQuestion: { previewFormat: "markdown" } },
|
|
248
273
|
...(systemPrompt ? { systemPrompt } : {}),
|
|
249
274
|
...(params.launchSettings.agent_progress_summaries !== undefined
|
|
@@ -324,8 +324,9 @@ test("buildQueryOptions maps launch settings into sdk query options", () => {
|
|
|
324
324
|
append: "Always respond to the user in German unless the user explicitly asks for a different language. " +
|
|
325
325
|
"Keep code, shell commands, file paths, API names, tool names, and raw error text unchanged unless the user explicitly asks for translation.",
|
|
326
326
|
});
|
|
327
|
-
assert.equal(
|
|
328
|
-
assert.equal(
|
|
327
|
+
assert.equal(options.model, "haiku");
|
|
328
|
+
assert.equal(options.permissionMode, "plan");
|
|
329
|
+
assert.equal("allowDangerouslySkipPermissions" in options, false);
|
|
329
330
|
assert.equal("thinking" in options, false);
|
|
330
331
|
assert.equal("effort" in options, false);
|
|
331
332
|
assert.equal(options.agentProgressSummaries, true);
|
|
@@ -335,7 +336,7 @@ test("buildQueryOptions maps launch settings into sdk query options", () => {
|
|
|
335
336
|
askUserQuestion: { previewFormat: "markdown" },
|
|
336
337
|
});
|
|
337
338
|
});
|
|
338
|
-
test("buildQueryOptions forwards settings
|
|
339
|
+
test("buildQueryOptions forwards settings and maps startup model and permission mode", () => {
|
|
339
340
|
const input = new AsyncQueue();
|
|
340
341
|
const options = buildQueryOptions({
|
|
341
342
|
cwd: "C:/work",
|
|
@@ -367,10 +368,50 @@ test("buildQueryOptions forwards settings without direct model and permission fl
|
|
|
367
368
|
terminalProgressBarEnabled: false,
|
|
368
369
|
});
|
|
369
370
|
assert.equal("model" in options, false);
|
|
370
|
-
assert.equal(
|
|
371
|
+
assert.equal(options.permissionMode, "default");
|
|
372
|
+
assert.equal("allowDangerouslySkipPermissions" in options, false);
|
|
371
373
|
assert.equal("thinking" in options, false);
|
|
372
374
|
assert.equal("effort" in options, false);
|
|
373
375
|
});
|
|
376
|
+
test("buildQueryOptions trims startup model before passing sdk option", () => {
|
|
377
|
+
const input = new AsyncQueue();
|
|
378
|
+
const options = buildQueryOptions({
|
|
379
|
+
cwd: "C:/work",
|
|
380
|
+
launchSettings: {
|
|
381
|
+
settings: {
|
|
382
|
+
model: " claude-opus-4-6 ",
|
|
383
|
+
permissions: { defaultMode: "plan" },
|
|
384
|
+
},
|
|
385
|
+
},
|
|
386
|
+
provisionalSessionId: "session-model",
|
|
387
|
+
input,
|
|
388
|
+
canUseTool: async () => ({ behavior: "deny", message: "not used" }),
|
|
389
|
+
enableSdkDebug: false,
|
|
390
|
+
enableSpawnDebug: false,
|
|
391
|
+
sessionIdForLogs: () => "session-model",
|
|
392
|
+
});
|
|
393
|
+
assert.equal(options.model, "claude-opus-4-6");
|
|
394
|
+
assert.equal(options.permissionMode, "plan");
|
|
395
|
+
});
|
|
396
|
+
test("buildQueryOptions enables dangerous skip flag for bypass permissions startup mode", () => {
|
|
397
|
+
const input = new AsyncQueue();
|
|
398
|
+
const options = buildQueryOptions({
|
|
399
|
+
cwd: "C:/work",
|
|
400
|
+
launchSettings: {
|
|
401
|
+
settings: {
|
|
402
|
+
permissions: { defaultMode: "bypassPermissions" },
|
|
403
|
+
},
|
|
404
|
+
},
|
|
405
|
+
provisionalSessionId: "session-4",
|
|
406
|
+
input,
|
|
407
|
+
canUseTool: async () => ({ behavior: "deny", message: "not used" }),
|
|
408
|
+
enableSdkDebug: false,
|
|
409
|
+
enableSpawnDebug: false,
|
|
410
|
+
sessionIdForLogs: () => "session-4",
|
|
411
|
+
});
|
|
412
|
+
assert.equal(options.permissionMode, "bypassPermissions");
|
|
413
|
+
assert.equal(options.allowDangerouslySkipPermissions, true);
|
|
414
|
+
});
|
|
374
415
|
test("buildQueryOptions omits startup overrides for default logout path", () => {
|
|
375
416
|
const input = new AsyncQueue();
|
|
376
417
|
const options = buildQueryOptions({
|
|
@@ -385,6 +426,7 @@ test("buildQueryOptions omits startup overrides for default logout path", () =>
|
|
|
385
426
|
});
|
|
386
427
|
assert.equal("model" in options, false);
|
|
387
428
|
assert.equal("permissionMode" in options, false);
|
|
429
|
+
assert.equal("allowDangerouslySkipPermissions" in options, false);
|
|
388
430
|
assert.equal("systemPrompt" in options, false);
|
|
389
431
|
assert.equal("agentProgressSummaries" in options, false);
|
|
390
432
|
});
|