snow-ai 0.6.9 → 0.6.10

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.
package/bundle/cli.mjs CHANGED
@@ -71093,7 +71093,7 @@ var init_version = __esm({
71093
71093
  // dist/api/chat.js
71094
71094
  function convertToOpenAIMessages(messages, includeBuiltinSystemPrompt = true, customSystemPromptOverride, planMode = false, vulnerabilityHuntingMode = false) {
71095
71095
  var _a21;
71096
- const customSystemPrompt = customSystemPromptOverride || getCustomSystemPrompt();
71096
+ const customSystemPrompt = customSystemPromptOverride;
71097
71097
  let result2 = messages.map((msg) => {
71098
71098
  if (msg.role === "user" && msg.images && msg.images.length > 0) {
71099
71099
  const contentParts = [];
@@ -71283,6 +71283,7 @@ async function* createStreamingChatCompletion(options3, abortSignal, onRetry) {
71283
71283
  customSystemPromptContent = customPrompt.content;
71284
71284
  }
71285
71285
  }
71286
+ customSystemPromptContent || (customSystemPromptContent = getCustomSystemPromptForConfig(config3));
71286
71287
  yield* withRetryGenerator(async function* () {
71287
71288
  var _a21, _b14, _c6, _d4, _e2, _f;
71288
71289
  const requestBody = {
@@ -71304,7 +71305,7 @@ async function* createStreamingChatCompletion(options3, abortSignal, onRetry) {
71304
71305
  tool_choice: options3.tool_choice
71305
71306
  };
71306
71307
  const url = `${config3.baseUrl}/chat/completions`;
71307
- const customHeaders = options3.customHeaders || getCustomHeaders();
71308
+ const customHeaders = options3.customHeaders || getCustomHeadersForConfig(config3);
71308
71309
  const fetchOptions = addProxyToFetchOptions(url, {
71309
71310
  method: "POST",
71310
71311
  headers: {
@@ -71511,7 +71512,7 @@ function getResponsesReasoningConfig() {
71511
71512
  function resetOpenAIClient2() {
71512
71513
  }
71513
71514
  function convertToResponseInput(messages, includeBuiltinSystemPrompt = true, customSystemPromptOverride, planMode = false, vulnerabilityHuntingMode = false) {
71514
- const customSystemPrompt = customSystemPromptOverride || getCustomSystemPrompt();
71515
+ const customSystemPrompt = customSystemPromptOverride;
71515
71516
  const result2 = [];
71516
71517
  for (const msg of messages) {
71517
71518
  if (!msg)
@@ -71695,6 +71696,7 @@ async function* createStreamingResponse(options3, abortSignal, onRetry) {
71695
71696
  customSystemPromptContent = customPrompt.content;
71696
71697
  }
71697
71698
  }
71699
+ customSystemPromptContent || (customSystemPromptContent = getCustomSystemPromptForConfig(config3));
71698
71700
  const { input: requestInput, systemInstructions } = convertToResponseInput(
71699
71701
  options3.messages,
71700
71702
  options3.includeBuiltinSystemPrompt !== false,
@@ -71722,7 +71724,7 @@ async function* createStreamingResponse(options3, abortSignal, onRetry) {
71722
71724
  prompt_cache_key: options3.prompt_cache_key
71723
71725
  };
71724
71726
  const url = `${config3.baseUrl}/responses`;
71725
- const customHeaders = options3.customHeaders || getCustomHeaders();
71727
+ const customHeaders = options3.customHeaders || getCustomHeadersForConfig(config3);
71726
71728
  const fetchOptions = addProxyToFetchOptions(url, {
71727
71729
  method: "POST",
71728
71730
  headers: {
@@ -71934,7 +71936,7 @@ function convertToolsToGemini(tools) {
71934
71936
  }
71935
71937
  function convertToGeminiMessages(messages, includeBuiltinSystemPrompt = true, customSystemPromptOverride, planMode = false, vulnerabilityHuntingMode = false) {
71936
71938
  var _a21;
71937
- const customSystemPrompt = customSystemPromptOverride || getCustomSystemPrompt();
71939
+ const customSystemPrompt = customSystemPromptOverride;
71938
71940
  let systemInstruction;
71939
71941
  const contents = [];
71940
71942
  const toolCallIdToFunctionName = /* @__PURE__ */ new Map();
@@ -72118,6 +72120,7 @@ async function* createStreamingGeminiCompletion(options3, abortSignal, onRetry)
72118
72120
  customSystemPromptContent = customPrompt.content;
72119
72121
  }
72120
72122
  }
72123
+ customSystemPromptContent || (customSystemPromptContent = getCustomSystemPromptForConfig(config3));
72121
72124
  yield* withRetryGenerator(async function* () {
72122
72125
  var _a21;
72123
72126
  const { systemInstruction, contents } = convertToGeminiMessages(
@@ -72147,7 +72150,7 @@ async function* createStreamingGeminiCompletion(options3, abortSignal, onRetry)
72147
72150
  const modelName = effectiveModel.startsWith("models/") ? effectiveModel : `models/${effectiveModel}`;
72148
72151
  const baseUrl = config3.baseUrl && config3.baseUrl !== "https://api.openai.com/v1" ? config3.baseUrl : "https://generativelanguage.googleapis.com/v1beta";
72149
72152
  const url = `${baseUrl}/${modelName}:streamGenerateContent?key=${config3.apiKey}&alt=sse`;
72150
- const customHeaders = options3.customHeaders || getCustomHeaders();
72153
+ const customHeaders = options3.customHeaders || getCustomHeadersForConfig(config3);
72151
72154
  const fetchOptions = addProxyToFetchOptions(url, {
72152
72155
  method: "POST",
72153
72156
  headers: {
@@ -74421,7 +74424,9 @@ __export(apiConfig_exports, {
74421
74424
  clearConfigCache: () => clearConfigCache,
74422
74425
  getCustomHeaders: () => getCustomHeaders,
74423
74426
  getCustomHeadersConfig: () => getCustomHeadersConfig,
74427
+ getCustomHeadersForConfig: () => getCustomHeadersForConfig,
74424
74428
  getCustomSystemPrompt: () => getCustomSystemPrompt,
74429
+ getCustomSystemPromptForConfig: () => getCustomSystemPromptForConfig,
74425
74430
  getMCPConfig: () => getMCPConfig,
74426
74431
  getOpenAiConfig: () => getOpenAiConfig,
74427
74432
  getSystemPromptConfig: () => getSystemPromptConfig,
@@ -74696,7 +74701,10 @@ function saveSystemPromptConfig(config3) {
74696
74701
  }
74697
74702
  }
74698
74703
  function getCustomSystemPrompt() {
74699
- const { systemPromptId } = getOpenAiConfig();
74704
+ return getCustomSystemPromptForConfig(getOpenAiConfig());
74705
+ }
74706
+ function getCustomSystemPromptForConfig(apiConfig) {
74707
+ const { systemPromptId } = apiConfig;
74700
74708
  const config3 = getSystemPromptConfig();
74701
74709
  if (!config3) {
74702
74710
  return void 0;
@@ -74715,8 +74723,11 @@ function getCustomSystemPrompt() {
74715
74723
  return activePrompt == null ? void 0 : activePrompt.content;
74716
74724
  }
74717
74725
  function getCustomHeaders() {
74726
+ return getCustomHeadersForConfig(getOpenAiConfig());
74727
+ }
74728
+ function getCustomHeadersForConfig(apiConfig) {
74718
74729
  ensureConfigDirectory2();
74719
- const { customHeadersSchemeId } = getOpenAiConfig();
74730
+ const { customHeadersSchemeId } = apiConfig;
74720
74731
  const config3 = getCustomHeadersConfig();
74721
74732
  if (!config3) {
74722
74733
  return {};
@@ -74909,7 +74920,7 @@ function convertToolsToAnthropic(tools) {
74909
74920
  }
74910
74921
  function convertToAnthropicMessages(messages, includeBuiltinSystemPrompt = true, customSystemPromptOverride, cacheTTL = "5m", disableThinking = false, planMode = false, vulnerabilityHuntingMode = false) {
74911
74922
  var _a21;
74912
- const customSystemPrompt = customSystemPromptOverride || getCustomSystemPrompt();
74923
+ const customSystemPrompt = customSystemPromptOverride;
74913
74924
  let systemContent;
74914
74925
  const anthropicMessages = [];
74915
74926
  for (const msg of messages) {
@@ -75159,6 +75170,7 @@ async function* createStreamingAnthropicCompletion(options3, abortSignal, onRetr
75159
75170
  customSystemPromptContent = customPrompt.content;
75160
75171
  }
75161
75172
  }
75173
+ customSystemPromptContent || (customSystemPromptContent = getCustomSystemPromptForConfig(config3));
75162
75174
  const { system, messages } = convertToAnthropicMessages(
75163
75175
  options3.messages,
75164
75176
  options3.includeBuiltinSystemPrompt !== false,
@@ -75196,7 +75208,7 @@ async function* createStreamingAnthropicCompletion(options3, abortSignal, onRetr
75196
75208
  requestBody.thinking = config3.thinking;
75197
75209
  requestBody.temperature = 1;
75198
75210
  }
75199
- const customHeaders = options3.customHeaders || getCustomHeaders();
75211
+ const customHeaders = options3.customHeaders || getCustomHeadersForConfig(config3);
75200
75212
  const headers = {
75201
75213
  "Content-Type": "application/json",
75202
75214
  "x-api-key": config3.apiKey,
@@ -350830,9 +350842,33 @@ var init_hashBasedSnapshot = __esm({
350830
350842
  writable: true,
350831
350843
  value: void 0
350832
350844
  });
350845
+ Object.defineProperty(this, "fileLocks", {
350846
+ enumerable: true,
350847
+ configurable: true,
350848
+ writable: true,
350849
+ value: /* @__PURE__ */ new Map()
350850
+ });
350833
350851
  const projectId = getProjectId();
350834
350852
  this.snapshotsDir = path18.join(os8.homedir(), ".snow", "snapshots", projectId);
350835
350853
  }
350854
+ /**
350855
+ * Acquire a lock for a specific file path
350856
+ * Ensures sequential access to prevent race conditions
350857
+ */
350858
+ async acquireLock(filePath) {
350859
+ while (this.fileLocks.has(filePath)) {
350860
+ await this.fileLocks.get(filePath);
350861
+ }
350862
+ let releaseLock;
350863
+ const lockPromise = new Promise((resolve12) => {
350864
+ releaseLock = resolve12;
350865
+ });
350866
+ this.fileLocks.set(filePath, lockPromise);
350867
+ return () => {
350868
+ this.fileLocks.delete(filePath);
350869
+ releaseLock();
350870
+ };
350871
+ }
350836
350872
  /**
350837
350873
  * Ensure snapshots directory exists
350838
350874
  */
@@ -350855,10 +350891,11 @@ var init_hashBasedSnapshot = __esm({
350855
350891
  * @param originalContent Original file content (undefined for new files)
350856
350892
  */
350857
350893
  async backupFile(sessionId, messageIndex, filePath, workspaceRoot, existed, originalContent) {
350894
+ const snapshotPath = this.getSnapshotPath(sessionId, messageIndex);
350895
+ const releaseLock = await this.acquireLock(snapshotPath);
350858
350896
  try {
350859
350897
  logger.info(`[Snapshot] backupFile called: sessionId=${sessionId}, messageIndex=${messageIndex}, filePath=${filePath}, existed=${existed}`);
350860
350898
  await this.ensureSnapshotsDir();
350861
- const snapshotPath = this.getSnapshotPath(sessionId, messageIndex);
350862
350899
  logger.info(`[Snapshot] snapshotPath=${snapshotPath}`);
350863
350900
  const relativePath = path18.isAbsolute(filePath) ? path18.relative(workspaceRoot, filePath) : filePath;
350864
350901
  const backup = {
@@ -350888,6 +350925,8 @@ var init_hashBasedSnapshot = __esm({
350888
350925
  }
350889
350926
  } catch (error) {
350890
350927
  logger.warn(`[Snapshot] Failed to backup file ${filePath}:`, error);
350928
+ } finally {
350929
+ releaseLock();
350891
350930
  }
350892
350931
  }
350893
350932
  /**
@@ -350897,8 +350936,9 @@ var init_hashBasedSnapshot = __esm({
350897
350936
  * @param filePath File path to remove from backup
350898
350937
  */
350899
350938
  async removeFileBackup(sessionId, messageIndex, filePath, workspaceRoot) {
350939
+ const snapshotPath = this.getSnapshotPath(sessionId, messageIndex);
350940
+ const releaseLock = await this.acquireLock(snapshotPath);
350900
350941
  try {
350901
- const snapshotPath = this.getSnapshotPath(sessionId, messageIndex);
350902
350942
  try {
350903
350943
  const content = await fs16.readFile(snapshotPath, "utf-8");
350904
350944
  const metadata = JSON.parse(content);
@@ -350918,6 +350958,8 @@ var init_hashBasedSnapshot = __esm({
350918
350958
  }
350919
350959
  } catch (error) {
350920
350960
  logger.warn(`[Snapshot] Failed to remove file backup ${filePath}:`, error);
350961
+ } finally {
350962
+ releaseLock();
350921
350963
  }
350922
350964
  }
350923
350965
  /**
@@ -351914,6 +351956,8 @@ ${diffMsg}
351914
351956
  Matched: lines ${startLine}-${endLine} (occurrence ${occurrence}/${matches.length})
351915
351957
  Result: ${replaceLines.length} new lines` + (smartBoundaries.extended ? `
351916
351958
  \u{1F4CD} Context auto-extended to show complete code block (lines ${contextStart}-${finalContextEnd})` : ""),
351959
+ filePath,
351960
+ // Include file path for DiffViewer display on Resume/re-render
351917
351961
  oldContent,
351918
351962
  newContent: newContextContent,
351919
351963
  replacedContent,
@@ -352125,6 +352169,8 @@ ${formattedDiagnostics}`;
352125
352169
  Replaced: lines ${adjustedStartLine}-${adjustedEndLine} (${linesToModify} lines)
352126
352170
  Result: ${newContentLines.length} new lines` + (smartBoundaries.extended ? `
352127
352171
  \u{1F4CD} Context auto-extended to show complete code block (lines ${contextStart}-${finalContextEnd})` : ""),
352172
+ filePath,
352173
+ // Include file path for DiffViewer display on Resume/re-render
352128
352174
  oldContent,
352129
352175
  newContent: finalContextContent,
352130
352176
  replacedLines: replacedContent,
@@ -433541,34 +433587,26 @@ ${agent.role}`;
433541
433587
  tools: allowedTools,
433542
433588
  sessionId: currentSession == null ? void 0 : currentSession.id,
433543
433589
  //disableThinking: true, // Sub-agents 不使用 Extended Thinking
433544
- configProfile: agent.configProfile,
433545
- customSystemPromptId: agent.customSystemPrompt,
433546
- customHeaders: agent.customHeaders
433590
+ configProfile: agent.configProfile
433547
433591
  }, abortSignal) : config3.requestMethod === "gemini" ? createStreamingGeminiCompletion({
433548
433592
  model,
433549
433593
  messages,
433550
433594
  temperature: 0,
433551
433595
  tools: allowedTools,
433552
- configProfile: agent.configProfile,
433553
- customSystemPromptId: agent.customSystemPrompt,
433554
- customHeaders: agent.customHeaders
433596
+ configProfile: agent.configProfile
433555
433597
  }, abortSignal) : config3.requestMethod === "responses" ? createStreamingResponse({
433556
433598
  model,
433557
433599
  messages,
433558
433600
  temperature: 0,
433559
433601
  tools: allowedTools,
433560
433602
  prompt_cache_key: currentSession == null ? void 0 : currentSession.id,
433561
- configProfile: agent.configProfile,
433562
- customSystemPromptId: agent.customSystemPrompt,
433563
- customHeaders: agent.customHeaders
433603
+ configProfile: agent.configProfile
433564
433604
  }, abortSignal) : createStreamingChatCompletion({
433565
433605
  model,
433566
433606
  messages,
433567
433607
  temperature: 0,
433568
433608
  tools: allowedTools,
433569
- configProfile: agent.configProfile,
433570
- customSystemPromptId: agent.customSystemPrompt,
433571
- customHeaders: agent.customHeaders
433609
+ configProfile: agent.configProfile
433572
433610
  }, abortSignal);
433573
433611
  let currentContent = "";
433574
433612
  let toolCalls = [];
@@ -443317,12 +443355,8 @@ function SubAgentConfigScreen({ onBack, onSave, inlineMode = false, agentId }) {
443317
443355
  const [loadError, setLoadError] = (0, import_react66.useState)(null);
443318
443356
  const isEditMode = !!agentId;
443319
443357
  const [isBuiltinAgent, setIsBuiltinAgent] = (0, import_react66.useState)(false);
443320
- const [selectedSystemPromptIndex, setSelectedSystemPromptIndex] = (0, import_react66.useState)(0);
443321
443358
  const [selectedConfigProfileIndex, setSelectedConfigProfileIndex] = (0, import_react66.useState)(0);
443322
- const [selectedCustomHeadersIndex, setSelectedCustomHeadersIndex] = (0, import_react66.useState)(0);
443323
- const [confirmedSystemPromptIndex, setConfirmedSystemPromptIndex] = (0, import_react66.useState)(-1);
443324
443359
  const [confirmedConfigProfileIndex, setConfirmedConfigProfileIndex] = (0, import_react66.useState)(-1);
443325
- const [confirmedCustomHeadersIndex, setConfirmedCustomHeadersIndex] = (0, import_react66.useState)(-1);
443326
443360
  const toolCategories = [
443327
443361
  {
443328
443362
  name: t.subAgentConfig.filesystemTools,
@@ -443372,27 +443406,13 @@ function SubAgentConfigScreen({ onBack, onSave, inlineMode = false, agentId }) {
443372
443406
  tools: ["skill-execute"]
443373
443407
  }
443374
443408
  ];
443375
- const availableSystemPrompts = (0, import_react66.useMemo)(() => {
443376
- const config3 = getSystemPromptConfig();
443377
- if (!config3 || !config3.prompts)
443378
- return [];
443379
- return config3.prompts.map((p) => ({ name: p.name, id: p.id }));
443380
- }, []);
443381
443409
  const availableProfiles = (0, import_react66.useMemo)(() => {
443382
443410
  const profiles = getAllProfiles();
443383
443411
  return profiles.map((p) => p.name);
443384
443412
  }, []);
443385
- const availableCustomHeaders = (0, import_react66.useMemo)(() => {
443386
- const config3 = getCustomHeadersConfig();
443387
- if (!config3 || !config3.schemes)
443388
- return [];
443389
- return config3.schemes.map((s) => s.name);
443390
- }, []);
443391
443413
  (0, import_react66.useEffect)(() => {
443392
443414
  if (!agentId) {
443393
443415
  const activeProfile = getActiveProfileName();
443394
- const systemPromptConfig = getSystemPromptConfig();
443395
- const customHeadersConfig = getCustomHeadersConfig();
443396
443416
  if (activeProfile && availableProfiles.length > 0) {
443397
443417
  const profileIndex = availableProfiles.findIndex((p) => p === activeProfile);
443398
443418
  if (profileIndex >= 0) {
@@ -443400,103 +443420,39 @@ function SubAgentConfigScreen({ onBack, onSave, inlineMode = false, agentId }) {
443400
443420
  setConfirmedConfigProfileIndex(profileIndex);
443401
443421
  }
443402
443422
  }
443403
- if ((systemPromptConfig == null ? void 0 : systemPromptConfig.active) && availableSystemPrompts.length > 0) {
443404
- const promptIndex = availableSystemPrompts.findIndex((p) => p.id === systemPromptConfig.active);
443405
- if (promptIndex >= 0) {
443406
- setSelectedSystemPromptIndex(promptIndex);
443407
- setConfirmedSystemPromptIndex(promptIndex);
443408
- }
443409
- }
443410
- if ((customHeadersConfig == null ? void 0 : customHeadersConfig.active) && availableCustomHeaders.length > 0) {
443411
- const activeScheme = customHeadersConfig.schemes.find((s) => s.id === customHeadersConfig.active);
443412
- if (activeScheme) {
443413
- const headerIndex = availableCustomHeaders.findIndex((h) => h === activeScheme.name);
443414
- if (headerIndex >= 0) {
443415
- setSelectedCustomHeadersIndex(headerIndex);
443416
- setConfirmedCustomHeadersIndex(headerIndex);
443417
- }
443418
- }
443419
- }
443420
443423
  }
443421
- }, [
443422
- availableSystemPrompts,
443423
- availableProfiles,
443424
- availableCustomHeaders,
443425
- agentId
443426
- ]);
443424
+ }, [availableProfiles, agentId]);
443427
443425
  (0, import_react66.useEffect)(() => {
443428
- var _a21;
443429
- if (agentId) {
443430
- const agent = getSubAgent(agentId);
443431
- if (agent) {
443432
- const isBuiltin = [
443433
- "agent_explore",
443434
- "agent_plan",
443435
- "agent_general"
443436
- ].includes(agentId);
443437
- setIsBuiltinAgent(isBuiltin);
443438
- setAgentName(agent.name);
443439
- setDescription(agent.description);
443440
- setRole(agent.role || "");
443441
- setSelectedTools(new Set(agent.tools || []));
443442
- if (agent.configProfile) {
443443
- const profileIndex = availableProfiles.findIndex((p) => p === agent.configProfile);
443444
- if (profileIndex >= 0) {
443445
- setSelectedConfigProfileIndex(profileIndex);
443446
- setConfirmedConfigProfileIndex(profileIndex);
443447
- }
443448
- } else if (agent.builtin) {
443449
- const activeProfile = getActiveProfileName();
443450
- if (activeProfile && availableProfiles.length > 0) {
443451
- const profileIndex = availableProfiles.findIndex((p) => p === activeProfile);
443452
- if (profileIndex >= 0) {
443453
- setSelectedConfigProfileIndex(profileIndex);
443454
- setConfirmedConfigProfileIndex(profileIndex);
443455
- }
443456
- }
443457
- }
443458
- if (agent.customSystemPrompt) {
443459
- const promptIndex = availableSystemPrompts.findIndex((p) => p.id === agent.customSystemPrompt);
443460
- if (promptIndex >= 0) {
443461
- setSelectedSystemPromptIndex(promptIndex);
443462
- setConfirmedSystemPromptIndex(promptIndex);
443463
- }
443464
- } else if (agent.builtin) {
443465
- const systemPromptConfig = getSystemPromptConfig();
443466
- if ((systemPromptConfig == null ? void 0 : systemPromptConfig.active) && availableSystemPrompts.length > 0) {
443467
- const promptIndex = availableSystemPrompts.findIndex((p) => p.id === systemPromptConfig.active);
443468
- if (promptIndex >= 0) {
443469
- setSelectedSystemPromptIndex(promptIndex);
443470
- setConfirmedSystemPromptIndex(promptIndex);
443471
- }
443472
- }
443473
- }
443474
- if (agent.customHeaders) {
443475
- const headersConfig = getCustomHeadersConfig();
443476
- const headerName = (_a21 = headersConfig == null ? void 0 : headersConfig.schemes.find((s) => JSON.stringify(s.headers) === JSON.stringify(agent.customHeaders))) == null ? void 0 : _a21.name;
443477
- if (headerName) {
443478
- const headerIndex = availableCustomHeaders.findIndex((h) => h === headerName);
443479
- if (headerIndex >= 0) {
443480
- setSelectedCustomHeadersIndex(headerIndex);
443481
- setConfirmedCustomHeadersIndex(headerIndex);
443482
- }
443483
- }
443484
- } else if (agent.builtin) {
443485
- const customHeadersConfig = getCustomHeadersConfig();
443486
- if ((customHeadersConfig == null ? void 0 : customHeadersConfig.active) && availableCustomHeaders.length > 0) {
443487
- const activeScheme = customHeadersConfig.schemes.find((s) => s.id === customHeadersConfig.active);
443488
- if (activeScheme) {
443489
- const headerIndex = availableCustomHeaders.findIndex((h) => h === activeScheme.name);
443490
- if (headerIndex >= 0) {
443491
- setSelectedCustomHeadersIndex(headerIndex);
443492
- setConfirmedCustomHeadersIndex(headerIndex);
443493
- }
443494
- }
443495
- }
443426
+ if (!agentId) {
443427
+ return;
443428
+ }
443429
+ const agent = getSubAgent(agentId);
443430
+ if (!agent) {
443431
+ return;
443432
+ }
443433
+ const isBuiltin = ["agent_explore", "agent_plan", "agent_general"].includes(agentId);
443434
+ setIsBuiltinAgent(isBuiltin);
443435
+ setAgentName(agent.name);
443436
+ setDescription(agent.description);
443437
+ setRole(agent.role || "");
443438
+ setSelectedTools(new Set(agent.tools || []));
443439
+ if (agent.configProfile) {
443440
+ const profileIndex = availableProfiles.findIndex((p) => p === agent.configProfile);
443441
+ if (profileIndex >= 0) {
443442
+ setSelectedConfigProfileIndex(profileIndex);
443443
+ setConfirmedConfigProfileIndex(profileIndex);
443444
+ }
443445
+ } else if (agent.builtin) {
443446
+ const activeProfile = getActiveProfileName();
443447
+ if (activeProfile && availableProfiles.length > 0) {
443448
+ const profileIndex = availableProfiles.findIndex((p) => p === activeProfile);
443449
+ if (profileIndex >= 0) {
443450
+ setSelectedConfigProfileIndex(profileIndex);
443451
+ setConfirmedConfigProfileIndex(profileIndex);
443496
443452
  }
443497
443453
  }
443498
443454
  }
443499
- }, [agentId]);
443455
+ }, [agentId, availableProfiles]);
443500
443456
  (0, import_react66.useEffect)(() => {
443501
443457
  const loadMCPServices = async () => {
443502
443458
  try {
@@ -443566,7 +443522,6 @@ function SubAgentConfigScreen({ onBack, onSave, inlineMode = false, agentId }) {
443566
443522
  allToolCategories
443567
443523
  ]);
443568
443524
  const handleSave = (0, import_react66.useCallback)(() => {
443569
- var _a21;
443570
443525
  setSaveError(null);
443571
443526
  const errors = validateSubAgent({
443572
443527
  name: agentName,
@@ -443579,28 +443534,16 @@ function SubAgentConfigScreen({ onBack, onSave, inlineMode = false, agentId }) {
443579
443534
  }
443580
443535
  try {
443581
443536
  const selectedProfile = confirmedConfigProfileIndex >= 0 ? availableProfiles[confirmedConfigProfileIndex] : void 0;
443582
- let customHeadersObj;
443583
- if (confirmedCustomHeadersIndex >= 0) {
443584
- const selectedHeader = availableCustomHeaders[confirmedCustomHeadersIndex];
443585
- if (selectedHeader) {
443586
- const headersConfig = getCustomHeadersConfig();
443587
- const scheme = headersConfig == null ? void 0 : headersConfig.schemes.find((s) => s.name === selectedHeader);
443588
- customHeadersObj = scheme == null ? void 0 : scheme.headers;
443589
- }
443590
- }
443591
- const systemPromptId = confirmedSystemPromptIndex >= 0 ? (_a21 = availableSystemPrompts[confirmedSystemPromptIndex]) == null ? void 0 : _a21.id : void 0;
443592
443537
  if (isEditMode && agentId) {
443593
443538
  updateSubAgent(agentId, {
443594
443539
  name: agentName,
443595
443540
  description,
443596
443541
  role: role || void 0,
443597
443542
  tools: Array.from(selectedTools),
443598
- configProfile: selectedProfile || void 0,
443599
- customSystemPrompt: systemPromptId,
443600
- customHeaders: customHeadersObj
443543
+ configProfile: selectedProfile || void 0
443601
443544
  });
443602
443545
  } else {
443603
- createSubAgent(agentName, description, Array.from(selectedTools), role || void 0, selectedProfile || void 0, systemPromptId, customHeadersObj);
443546
+ createSubAgent(agentName, description, Array.from(selectedTools), role || void 0, selectedProfile || void 0);
443604
443547
  }
443605
443548
  setShowSuccess(true);
443606
443549
  setTimeout(() => {
@@ -443615,13 +443558,8 @@ function SubAgentConfigScreen({ onBack, onSave, inlineMode = false, agentId }) {
443615
443558
  description,
443616
443559
  role,
443617
443560
  selectedTools,
443618
- confirmedSystemPromptIndex,
443619
443561
  confirmedConfigProfileIndex,
443620
- confirmedCustomHeadersIndex,
443621
- availableSystemPrompts,
443622
443562
  availableProfiles,
443623
- availableCustomHeaders,
443624
- onSave,
443625
443563
  isEditMode,
443626
443564
  agentId,
443627
443565
  t
@@ -443643,8 +443581,6 @@ function SubAgentConfigScreen({ onBack, onSave, inlineMode = false, agentId }) {
443643
443581
  "description",
443644
443582
  "role",
443645
443583
  "configProfile",
443646
- "customSystemPrompt",
443647
- "customHeaders",
443648
443584
  "tools"
443649
443585
  ];
443650
443586
  const currentFieldIndex = mainFields.indexOf(currentField);
@@ -443656,20 +443592,6 @@ function SubAgentConfigScreen({ onBack, onSave, inlineMode = false, agentId }) {
443656
443592
  setSelectedConfigProfileIndex((prev) => prev - 1);
443657
443593
  }
443658
443594
  return;
443659
- } else if (currentField === "customSystemPrompt") {
443660
- if (availableSystemPrompts.length === 0 || selectedSystemPromptIndex === 0) {
443661
- setCurrentField("configProfile");
443662
- } else {
443663
- setSelectedSystemPromptIndex((prev) => prev - 1);
443664
- }
443665
- return;
443666
- } else if (currentField === "customHeaders") {
443667
- if (availableCustomHeaders.length === 0 || selectedCustomHeadersIndex === 0) {
443668
- setCurrentField("customSystemPrompt");
443669
- } else {
443670
- setSelectedCustomHeadersIndex((prev) => prev - 1);
443671
- }
443672
- return;
443673
443595
  } else if (currentField === "tools") {
443674
443596
  if (selectedToolIndex > 0) {
443675
443597
  setSelectedToolIndex((prev) => prev - 1);
@@ -443678,7 +443600,7 @@ function SubAgentConfigScreen({ onBack, onSave, inlineMode = false, agentId }) {
443678
443600
  setSelectedCategoryIndex((prev) => prev - 1);
443679
443601
  setSelectedToolIndex(prevCategory ? prevCategory.tools.length - 1 : 0);
443680
443602
  } else {
443681
- setCurrentField("customHeaders");
443603
+ setCurrentField("configProfile");
443682
443604
  }
443683
443605
  return;
443684
443606
  } else {
@@ -443690,28 +443612,15 @@ function SubAgentConfigScreen({ onBack, onSave, inlineMode = false, agentId }) {
443690
443612
  if (key.downArrow) {
443691
443613
  if (currentField === "configProfile") {
443692
443614
  if (availableProfiles.length === 0 || selectedConfigProfileIndex >= availableProfiles.length - 1) {
443693
- setCurrentField("customSystemPrompt");
443694
- } else {
443695
- setSelectedConfigProfileIndex((prev) => prev + 1);
443696
- }
443697
- return;
443698
- } else if (currentField === "customSystemPrompt") {
443699
- if (availableSystemPrompts.length === 0 || selectedSystemPromptIndex >= availableSystemPrompts.length - 1) {
443700
- setCurrentField("customHeaders");
443701
- } else {
443702
- setSelectedSystemPromptIndex((prev) => prev + 1);
443703
- }
443704
- return;
443705
- } else if (currentField === "customHeaders") {
443706
- if (availableCustomHeaders.length === 0 || selectedCustomHeadersIndex >= availableCustomHeaders.length - 1) {
443707
443615
  setCurrentField("tools");
443708
443616
  setSelectedCategoryIndex(0);
443709
443617
  setSelectedToolIndex(0);
443710
443618
  } else {
443711
- setSelectedCustomHeadersIndex((prev) => prev + 1);
443619
+ setSelectedConfigProfileIndex((prev) => prev + 1);
443712
443620
  }
443713
443621
  return;
443714
- } else if (currentField === "tools") {
443622
+ }
443623
+ if (currentField === "tools") {
443715
443624
  const currentCategory = allToolCategories[selectedCategoryIndex];
443716
443625
  if (!currentCategory)
443717
443626
  return;
@@ -443724,25 +443633,18 @@ function SubAgentConfigScreen({ onBack, onSave, inlineMode = false, agentId }) {
443724
443633
  setCurrentField("name");
443725
443634
  }
443726
443635
  return;
443727
- } else {
443728
- const nextIndex = currentFieldIndex < mainFields.length - 1 ? currentFieldIndex + 1 : 0;
443729
- setCurrentField(mainFields[nextIndex]);
443730
- return;
443731
443636
  }
443637
+ const nextIndex = currentFieldIndex < mainFields.length - 1 ? currentFieldIndex + 1 : 0;
443638
+ setCurrentField(mainFields[nextIndex]);
443639
+ return;
443732
443640
  }
443733
443641
  if (currentField === "role" && input2 === " ") {
443734
443642
  setRoleExpanded((prev) => !prev);
443735
443643
  return;
443736
443644
  }
443737
- if (currentField === "configProfile" || currentField === "customSystemPrompt" || currentField === "customHeaders") {
443645
+ if (currentField === "configProfile") {
443738
443646
  if (input2 === " ") {
443739
- if (currentField === "configProfile") {
443740
- setConfirmedConfigProfileIndex((prev) => prev === selectedConfigProfileIndex ? -1 : selectedConfigProfileIndex);
443741
- } else if (currentField === "customSystemPrompt") {
443742
- setConfirmedSystemPromptIndex((prev) => prev === selectedSystemPromptIndex ? -1 : selectedSystemPromptIndex);
443743
- } else if (currentField === "customHeaders") {
443744
- setConfirmedCustomHeadersIndex((prev) => prev === selectedCustomHeadersIndex ? -1 : selectedCustomHeadersIndex);
443745
- }
443647
+ setConfirmedConfigProfileIndex((prev) => prev === selectedConfigProfileIndex ? -1 : selectedConfigProfileIndex);
443746
443648
  return;
443747
443649
  }
443748
443650
  }
@@ -444059,34 +443961,6 @@ function SubAgentConfigScreen({ onBack, onSave, inlineMode = false, agentId }) {
444059
443961
  "profile"
444060
443962
  ))
444061
443963
  ),
444062
- import_react66.default.createElement(
444063
- Box_default,
444064
- { flexDirection: "column" },
444065
- import_react66.default.createElement(Text, { bold: true, color: theme14.colors.menuInfo }, t.subAgentConfig.customSystemPrompt),
444066
- import_react66.default.createElement(Box_default, { marginLeft: 2 }, renderScrollableList(
444067
- availableSystemPrompts,
444068
- selectedSystemPromptIndex,
444069
- confirmedSystemPromptIndex,
444070
- // 确认选中的项
444071
- currentField === "customSystemPrompt",
444072
- 5,
444073
- "prompt"
444074
- ))
444075
- ),
444076
- import_react66.default.createElement(
444077
- Box_default,
444078
- { flexDirection: "column" },
444079
- import_react66.default.createElement(Text, { bold: true, color: theme14.colors.menuInfo }, t.subAgentConfig.customHeaders),
444080
- import_react66.default.createElement(Box_default, { marginLeft: 2 }, renderScrollableList(
444081
- availableCustomHeaders,
444082
- selectedCustomHeadersIndex,
444083
- confirmedCustomHeadersIndex,
444084
- // 确认选中的项
444085
- currentField === "customHeaders",
444086
- 5,
444087
- "header"
444088
- ))
444089
- ),
444090
443964
  renderToolSelection(),
444091
443965
  import_react66.default.createElement(
444092
443966
  Box_default,
@@ -444107,7 +443981,6 @@ var init_SubAgentConfigScreen = __esm({
444107
443981
  init_mcpToolsManager();
444108
443982
  init_subAgentConfig();
444109
443983
  init_configManager();
444110
- init_apiConfig();
444111
443984
  init_i18n();
444112
443985
  init_ThemeContext();
444113
443986
  focusEventTokenRegex2 = /(?:\x1b)?\[[0-9;]*[IO]/g;
@@ -446791,17 +446664,12 @@ function DiffViewer({ oldContent = "", newContent, filename, completeOldContent,
446791
446664
  return import_react73.default.createElement(
446792
446665
  Box_default,
446793
446666
  { flexDirection: "column" },
446794
- import_react73.default.createElement(
446795
- Box_default,
446796
- { marginBottom: 1 },
446797
- import_react73.default.createElement(Text, { bold: true, color: "green" }, "[New File]"),
446798
- filename && import_react73.default.createElement(
446799
- Text,
446800
- { color: "cyan" },
446801
- " ",
446802
- filename
446803
- )
446804
- ),
446667
+ import_react73.default.createElement(Box_default, { marginBottom: 1 }, filename ? import_react73.default.createElement(
446668
+ import_react73.default.Fragment,
446669
+ null,
446670
+ import_react73.default.createElement(Text, { bold: true, color: "cyan" }, filename),
446671
+ import_react73.default.createElement(Text, { color: "green" }, " (new)")
446672
+ ) : import_react73.default.createElement(Text, { bold: true, color: "green" }, "New File")),
446805
446673
  import_react73.default.createElement(Box_default, { flexDirection: "column" }, allLines.map((line, index) => import_react73.default.createElement(
446806
446674
  Text,
446807
446675
  { key: index, color: "white", backgroundColor: theme14.colors.diffAdded },
@@ -446898,20 +446766,13 @@ function DiffViewer({ oldContent = "", newContent, filename, completeOldContent,
446898
446766
  }
446899
446767
  return computedHunks;
446900
446768
  }, [diffOldContent, diffNewContent, startLineNumber]);
446901
- const truncateContent = (content, maxWidth) => {
446902
- const cleanContent = content.replace(/[\r\n]/g, "");
446903
- if (cleanContent.length <= maxWidth) {
446904
- return cleanContent.padEnd(maxWidth, " ");
446905
- }
446906
- return cleanContent.slice(0, maxWidth - 1) + "~";
446769
+ const cleanContent = (content) => {
446770
+ return content.replace(/[\r\n]/g, "");
446907
446771
  };
446908
446772
  const renderSideBySide = (hunk, hunkIndex) => {
446909
446773
  const separatorWidth = 3;
446910
446774
  const lineNumWidth = 4;
446911
- const signWidth = 1;
446912
- const paddingWidth = 2;
446913
446775
  const panelWidth = Math.floor((columns - separatorWidth) / 2);
446914
- const contentWidth = panelWidth - lineNumWidth - signWidth - paddingWidth;
446915
446776
  const pairedLines = [];
446916
446777
  let leftIdx = 0;
446917
446778
  let rightIdx = 0;
@@ -446982,8 +446843,8 @@ function DiffViewer({ oldContent = "", newContent, filename, completeOldContent,
446982
446843
  const rightLineNum = pair.right.lineNum ? String(pair.right.lineNum).padStart(lineNumWidth, " ") : "".padStart(lineNumWidth, " ");
446983
446844
  const leftSign = pair.left.type === "removed" ? "-" : pair.left.type === "unchanged" ? " " : " ";
446984
446845
  const rightSign = pair.right.type === "added" ? "+" : pair.right.type === "unchanged" ? " " : " ";
446985
- const leftContent = truncateContent(pair.left.content, contentWidth);
446986
- const rightContent = truncateContent(pair.right.content, contentWidth);
446846
+ const leftContent = cleanContent(pair.left.content);
446847
+ const rightContent = cleanContent(pair.right.content);
446987
446848
  return {
446988
446849
  idx: idx2,
446989
446850
  leftLineNum,
@@ -447127,13 +446988,12 @@ function DiffViewer({ oldContent = "", newContent, filename, completeOldContent,
447127
446988
  import_react73.default.createElement(
447128
446989
  Box_default,
447129
446990
  { marginBottom: 1 },
447130
- import_react73.default.createElement(Text, { bold: true, color: "yellow" }, "[File Modified]"),
447131
- filename && import_react73.default.createElement(
447132
- Text,
447133
- { color: "cyan" },
447134
- " ",
447135
- filename
447136
- ),
446991
+ filename ? import_react73.default.createElement(
446992
+ import_react73.default.Fragment,
446993
+ null,
446994
+ import_react73.default.createElement(Text, { bold: true, color: "cyan" }, filename),
446995
+ import_react73.default.createElement(Text, { color: "yellow" }, " (modified)")
446996
+ ) : import_react73.default.createElement(Text, { bold: true, color: "yellow" }, "File Modified"),
447137
446997
  useSideBySide && import_react73.default.createElement(Text, { dimColor: true }, " (side-by-side)")
447138
446998
  ),
447139
446999
  import_react73.default.createElement(
@@ -542318,7 +542178,12 @@ var init_FileList = __esm({
542318
542178
  filteredFiles.map((file, index) => import_react94.default.createElement(
542319
542179
  Box_default,
542320
542180
  { key: `${file.path}-${file.lineNumber || 0}`, flexDirection: "column" },
542321
- import_react94.default.createElement(Text, { backgroundColor: index === displaySelectedIndex ? theme14.colors.menuSelected : void 0, color: index === displaySelectedIndex ? theme14.colors.menuNormal : file.isDirectory ? theme14.colors.warning : "white" }, searchMode === "content" && file.lineNumber !== void 0 ? `${file.path}:${file.lineNumber}` : file.isDirectory ? "\u25C7 " + file.path : "\u25C6 " + file.path),
542181
+ import_react94.default.createElement(
542182
+ Text,
542183
+ { backgroundColor: index === displaySelectedIndex ? theme14.colors.menuSelected : void 0, color: index === displaySelectedIndex ? theme14.colors.menuNormal : file.isDirectory ? theme14.colors.warning : "white" },
542184
+ index === displaySelectedIndex ? "\u276F " : " ",
542185
+ searchMode === "content" && file.lineNumber !== void 0 ? `${file.path}:${file.lineNumber}` : file.isDirectory ? "\u25C7 " + file.path : "\u25C6 " + file.path
542186
+ ),
542322
542187
  searchMode === "content" && file.lineContent && import_react94.default.createElement(
542323
542188
  Text,
542324
542189
  { backgroundColor: index === displaySelectedIndex ? theme14.colors.menuSelected : void 0, color: index === displaySelectedIndex ? theme14.colors.menuSecondary : theme14.colors.menuSecondary, dimColor: true },
@@ -551380,7 +551245,7 @@ async function handleConversationWithTools(options3) {
551380
551245
  arguments: {
551381
551246
  oldContent: resultData.oldContent,
551382
551247
  newContent: resultData.newContent,
551383
- filename: resultData.path || resultData.filename,
551248
+ filename: resultData.filePath || resultData.path || resultData.filename,
551384
551249
  completeOldContent: resultData.completeOldContent,
551385
551250
  completeNewContent: resultData.completeNewContent,
551386
551251
  contextStartLine: resultData.contextStartLine
@@ -552067,7 +551932,7 @@ function convertSessionMessagesToUI(sessionMessages) {
552067
551932
  arguments: {
552068
551933
  oldContent: resultData.oldContent,
552069
551934
  newContent: resultData.newContent,
552070
- filename: resultData.path || resultData.filename,
551935
+ filename: resultData.filePath || resultData.path || resultData.filename,
552071
551936
  completeOldContent: resultData.completeOldContent,
552072
551937
  completeNewContent: resultData.completeNewContent,
552073
551938
  contextStartLine: resultData.contextStartLine
@@ -552197,13 +552062,14 @@ function convertSessionMessagesToUI(sessionMessages) {
552197
552062
  editDiffData = {
552198
552063
  oldContent: resultData.oldContent,
552199
552064
  newContent: resultData.newContent,
552200
- filename: toolArgs.filePath,
552065
+ filename: resultData.filePath || toolArgs.filePath,
552201
552066
  completeOldContent: resultData.completeOldContent,
552202
552067
  completeNewContent: resultData.completeNewContent,
552203
552068
  contextStartLine: resultData.contextStartLine
552204
552069
  };
552205
552070
  toolArgs.oldContent = resultData.oldContent;
552206
552071
  toolArgs.newContent = resultData.newContent;
552072
+ toolArgs.filename = resultData.filePath || toolArgs.filePath;
552207
552073
  toolArgs.completeOldContent = resultData.completeOldContent;
552208
552074
  toolArgs.completeNewContent = resultData.completeNewContent;
552209
552075
  toolArgs.contextStartLine = resultData.contextStartLine;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snow-ai",
3
- "version": "0.6.9",
3
+ "version": "0.6.10",
4
4
  "description": "Intelligent Command Line Assistant powered by AI",
5
5
  "license": "MIT",
6
6
  "bin": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snow-ai",
3
- "version": "0.6.9",
3
+ "version": "0.6.10",
4
4
  "description": "Intelligent Command Line Assistant powered by AI",
5
5
  "license": "MIT",
6
6
  "bin": {