@narumitw/pi-firecrawl 0.50.5 → 0.51.1

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/src/settings.ts CHANGED
@@ -8,7 +8,16 @@ import { FIRECRAWL_TOOL_NAMES, type FirecrawlToolName } from "./tool-names.js";
8
8
  const NEW_SETTINGS_FILE = "pi-firecrawl.json";
9
9
  const LEGACY_SETTINGS_FILE = "pi-firecrawl-settings.json";
10
10
 
11
+ export const FIRECRAWL_TOOL_MODES = ["codemode", "lazy", "direct"] as const;
12
+ export type FirecrawlToolMode = (typeof FIRECRAWL_TOOL_MODES)[number];
13
+ export const DEFAULT_TOOL_MODE: FirecrawlToolMode = "codemode";
14
+
15
+ export function isFirecrawlToolMode(value: unknown): value is FirecrawlToolMode {
16
+ return FIRECRAWL_TOOL_MODES.includes(value as FirecrawlToolMode);
17
+ }
18
+
11
19
  export interface FirecrawlSettings {
20
+ toolMode?: FirecrawlToolMode;
12
21
  tools: FirecrawlToolName[];
13
22
  updatedAt: number;
14
23
  }
@@ -77,7 +86,7 @@ async function readSettingsDocument(filePath: string): Promise<SettingsDocumentR
77
86
  return {
78
87
  result: {
79
88
  kind: "invalid",
80
- reason: `${filePath}: expected tools to be an array of Firecrawl tool names`,
89
+ reason: `${filePath}: expected valid tools, a finite updatedAt, and toolMode (codemode, lazy, or direct) when present`,
81
90
  },
82
91
  };
83
92
  } catch (error) {
@@ -117,14 +126,19 @@ async function pathEntryExists(filePath: string) {
117
126
  }
118
127
 
119
128
  export function normalizeFirecrawlSettings(value: unknown): FirecrawlSettings | undefined {
120
- if (!value || typeof value !== "object") return undefined;
121
- const settings = value as { tools?: unknown; updatedAt?: unknown };
129
+ if (!value || typeof value !== "object" || Array.isArray(value)) return undefined;
130
+ const settings = value as { tools?: unknown; updatedAt?: unknown; toolMode?: unknown };
131
+ if (settings.toolMode !== undefined && !isFirecrawlToolMode(settings.toolMode)) return undefined;
122
132
  if (typeof settings.updatedAt !== "number" || !Number.isFinite(settings.updatedAt)) {
123
133
  return undefined;
124
134
  }
125
135
  if (!Array.isArray(settings.tools)) return undefined;
126
136
  if (!settings.tools.every(isFirecrawlToolName)) return undefined;
127
- return { tools: orderedUniqueFirecrawlTools(settings.tools), updatedAt: settings.updatedAt };
137
+ return {
138
+ toolMode: settings.toolMode ?? DEFAULT_TOOL_MODE,
139
+ tools: orderedUniqueFirecrawlTools(settings.tools),
140
+ updatedAt: settings.updatedAt,
141
+ };
128
142
  }
129
143
 
130
144
  function isFirecrawlToolName(value: unknown): value is FirecrawlToolName {
@@ -146,26 +160,52 @@ export function saveSettings(
146
160
  if (!normalizedSettings) {
147
161
  return Promise.reject(new Error("Cannot save invalid Firecrawl settings"));
148
162
  }
149
- const operation = settingsSaveQueue.then(() => saveSettingsNow(normalizedSettings, operations));
163
+ return queueSettingsSave({ ...normalizedSettings, toolMode: settings.toolMode }, operations);
164
+ }
165
+
166
+ export function saveToolMode(
167
+ toolMode: FirecrawlToolMode,
168
+ fallbackTools: readonly FirecrawlToolName[],
169
+ operations: Partial<SettingsFileOperations> = {},
170
+ ): Promise<void> {
171
+ if (!isFirecrawlToolMode(toolMode) || !fallbackTools.every(isFirecrawlToolName)) {
172
+ return Promise.reject(new Error("Cannot save invalid Firecrawl settings"));
173
+ }
174
+ return queueSettingsSave({ toolMode, updatedAt: Date.now() }, operations, fallbackTools);
175
+ }
176
+
177
+ function queueSettingsSave(
178
+ patch: Partial<FirecrawlSettings> & { updatedAt: number },
179
+ operations: Partial<SettingsFileOperations>,
180
+ fallbackTools: readonly FirecrawlToolName[] = FIRECRAWL_TOOL_NAMES,
181
+ ): Promise<void> {
182
+ const filePath = settingsFilePath();
183
+ const legacyPath = legacySettingsFilePath();
184
+ const fallback = [...fallbackTools];
185
+ const operation = settingsSaveQueue.then(() => saveSettingsNow(filePath, legacyPath, patch, operations, fallback));
150
186
  settingsSaveQueue = operation.catch(() => undefined);
151
187
  return operation;
152
188
  }
153
189
 
154
190
  async function saveSettingsNow(
155
- settings: FirecrawlSettings,
191
+ filePath: string,
192
+ legacyPath: string,
193
+ patch: Partial<FirecrawlSettings> & { updatedAt: number },
156
194
  operations: Partial<SettingsFileOperations>,
195
+ fallbackTools: readonly FirecrawlToolName[],
157
196
  ): Promise<void> {
158
- const filePath = settingsFilePath();
159
197
  let current = await readSettingsDocument(filePath);
160
198
  const replaceCanonical = current.result.kind !== "missing";
161
- if (!replaceCanonical) current = await readSettingsDocument(legacySettingsFilePath());
199
+ if (!replaceCanonical) current = await readSettingsDocument(legacyPath);
162
200
  if (current.result.kind === "invalid") {
163
201
  throw new Error(`Cannot save Firecrawl settings until you repair ${current.result.reason}`);
164
202
  }
165
203
  const nextDocument = {
166
204
  ...(current.document ?? {}),
167
- tools: [...settings.tools],
168
- updatedAt: settings.updatedAt,
205
+ toolMode:
206
+ patch.toolMode ?? (current.result.kind === "loaded" ? current.result.settings.toolMode : DEFAULT_TOOL_MODE),
207
+ tools: [...(patch.tools ?? (current.result.kind === "loaded" ? current.result.settings.tools : fallbackTools))],
208
+ updatedAt: patch.updatedAt,
169
209
  };
170
210
  await mkdir(dirname(filePath), { recursive: true });
171
211
  const tempFile = `${filePath}.${process.pid}.${randomUUID()}.tmp`;
@@ -6,8 +6,18 @@ import {
6
6
  availableFirecrawlTools,
7
7
  FIRECRAWL_LOAD_TOOL_NAME,
8
8
  firecrawlToolExposureMode,
9
+ firecrawlToolMode,
10
+ restoreAvailableFirecrawlPolicy,
9
11
  } from "./lazy-tools.js";
10
- import { loadSettings, type SettingsLoadResult, saveSettings, settingsFilePath } from "./settings.js";
12
+ import {
13
+ DEFAULT_TOOL_MODE,
14
+ type FirecrawlToolMode,
15
+ loadSettings,
16
+ type SettingsLoadResult,
17
+ saveSettings,
18
+ saveToolMode,
19
+ settingsFilePath,
20
+ } from "./settings.js";
11
21
  import { FIRECRAWL_TOOL_NAMES, type FirecrawlToolName } from "./tool-names.js";
12
22
 
13
23
  type CommandContext = ExtensionCommandContext;
@@ -17,49 +27,63 @@ type ToolSelectorAction = "toggle" | "enableAll" | "disableAll";
17
27
  interface ToolStatusSummary {
18
28
  availabilityStatus: ToolAvailabilityStatus;
19
29
  availableFirecrawlToolCount: number;
30
+ callableFirecrawlToolCount: number;
20
31
  loadedFirecrawlToolCount: number;
21
32
  activeNonFirecrawlToolCount: number;
22
33
  }
23
34
 
24
35
  type ToolSelectionSaveResult = "saved" | "available-tools-changed" | "failed";
25
36
 
26
- let settingsNotice: string | undefined;
27
- let sessionGeneration = 0;
28
- let sessionController = new AbortController();
37
+ interface FirecrawlSessionState {
38
+ generation: number;
39
+ controller: AbortController;
40
+ notice?: string;
41
+ }
42
+ const sessionStates = new WeakMap<ExtensionAPI, FirecrawlSessionState>();
43
+
44
+ function sessionState(pi: ExtensionAPI): FirecrawlSessionState {
45
+ let state = sessionStates.get(pi);
46
+ if (!state) {
47
+ state = { generation: 0, controller: new AbortController() };
48
+ sessionStates.set(pi, state);
49
+ }
50
+ return state;
51
+ }
29
52
 
30
- export function advanceFirecrawlSessionGeneration(): number {
31
- sessionController.abort(new DOMException("Firecrawl session replaced", "AbortError"));
32
- sessionController = new AbortController();
33
- return ++sessionGeneration;
53
+ export function advanceFirecrawlSessionGeneration(pi: ExtensionAPI): number {
54
+ const state = sessionState(pi);
55
+ state.controller.abort(new DOMException("Firecrawl session replaced", "AbortError"));
56
+ state.controller = new AbortController();
57
+ return ++state.generation;
34
58
  }
35
59
 
36
- export function currentFirecrawlSessionGeneration(): number {
37
- return sessionGeneration;
60
+ export function currentFirecrawlSessionGeneration(pi: ExtensionAPI): number {
61
+ return sessionState(pi).generation;
38
62
  }
39
63
 
40
- export function isCurrentFirecrawlSession(generation: number): boolean {
41
- return generation === sessionGeneration;
64
+ export function isCurrentFirecrawlSession(pi: ExtensionAPI, generation: number): boolean {
65
+ return generation === sessionState(pi).generation;
42
66
  }
43
67
 
44
- export function currentFirecrawlSessionSignal(): AbortSignal {
45
- return sessionController.signal;
68
+ export function currentFirecrawlSessionSignal(pi: ExtensionAPI): AbortSignal {
69
+ return sessionState(pi).controller.signal;
46
70
  }
47
71
 
48
- export function clearSettingsNotice() {
49
- settingsNotice = undefined;
72
+ export function clearSettingsNotice(pi: ExtensionAPI) {
73
+ sessionState(pi).notice = undefined;
50
74
  }
51
75
 
52
- export function recordSettingsNotice(settings: SettingsLoadResult) {
53
- settingsNotice = settings.notice;
76
+ export function recordSettingsNotice(pi: ExtensionAPI, settings: SettingsLoadResult) {
77
+ sessionState(pi).notice = settings.notice;
54
78
  }
55
79
 
56
80
  export async function showToolSelector(pi: ExtensionAPI, ctx: CommandContext) {
57
- const generation = sessionGeneration;
81
+ const generation = currentFirecrawlSessionGeneration(pi);
58
82
  if (!ctx.hasUI || (ctx.mode !== "tui" && ctx.mode !== "rpc")) {
59
83
  throw new Error("/firecrawl tools requires TUI or RPC mode");
60
84
  }
61
- const menuSignal = sessionController.signal;
62
- const isCurrent = () => isCurrentFirecrawlSession(generation) && !menuSignal.aborted;
85
+ const menuSignal = currentFirecrawlSessionSignal(pi);
86
+ const isCurrent = () => isCurrentFirecrawlSession(pi, generation) && !menuSignal.aborted;
63
87
  const { defineMenu, runMenu } = await import("@narumitw/pi-tui-kit");
64
88
  if (!isCurrent()) return;
65
89
  const menu = defineMenu<undefined, ToolSelectorScreen, ToolSelectorAction>({
@@ -127,9 +151,9 @@ export async function showToolSelector(pi: ExtensionAPI, ctx: CommandContext) {
127
151
  signal: menuSignal,
128
152
  isCurrent,
129
153
  });
130
- if (result.kind !== "closed" || !isCurrentFirecrawlSession(generation)) return;
154
+ if (result.kind !== "closed" || !isCurrentFirecrawlSession(pi, generation)) return;
131
155
  const status = await buildStatusMessage(pi);
132
- if (!isCurrentFirecrawlSession(generation)) return;
156
+ if (!isCurrentFirecrawlSession(pi, generation)) return;
133
157
  ctx.ui.notify(status, hasApiKey() ? "info" : "warning");
134
158
  }
135
159
 
@@ -139,11 +163,11 @@ export async function updateFirecrawlTools(
139
163
  selectedTools: readonly FirecrawlToolName[],
140
164
  action: string,
141
165
  ) {
142
- const generation = sessionGeneration;
166
+ const generation = currentFirecrawlSessionGeneration(pi);
143
167
  const result = await transactSelectedTools(pi, ctx, selectedTools, generation);
144
- if (result !== "saved" || !isCurrentFirecrawlSession(generation)) return;
168
+ if (result !== "saved" || !isCurrentFirecrawlSession(pi, generation)) return;
145
169
  const status = await buildStatusMessage(pi);
146
- if (!isCurrentFirecrawlSession(generation)) return;
170
+ if (!isCurrentFirecrawlSession(pi, generation)) return;
147
171
  ctx.ui.notify(
148
172
  sanitizeFirecrawlDisplay(`Firecrawl tool catalog ${action}.\n\n${status}`),
149
173
  hasApiKey() ? "info" : "warning",
@@ -154,8 +178,57 @@ export async function setSelectedFirecrawlTools(
154
178
  pi: ExtensionAPI,
155
179
  ctx: CommandContext,
156
180
  selectedTools: readonly FirecrawlToolName[],
181
+ notificationSignal?: AbortSignal,
182
+ ): Promise<boolean> {
183
+ return (
184
+ (await transactSelectedTools(
185
+ pi,
186
+ ctx,
187
+ selectedTools,
188
+ currentFirecrawlSessionGeneration(pi),
189
+ undefined,
190
+ notificationSignal,
191
+ )) === "saved"
192
+ );
193
+ }
194
+
195
+ export function setFirecrawlCapabilityEnabled(
196
+ pi: ExtensionAPI,
197
+ ctx: CommandContext,
198
+ name: FirecrawlToolName,
199
+ enabled: boolean,
200
+ notificationSignal?: AbortSignal,
157
201
  ): Promise<boolean> {
158
- return (await transactSelectedTools(pi, ctx, selectedTools, sessionGeneration)) === "saved";
202
+ const generation = currentFirecrawlSessionGeneration(pi);
203
+ const fallbackTools = availableFirecrawlTools(pi);
204
+ const operation = toolTransactionQueue.then(async () => {
205
+ const current = isCurrentFirecrawlSession(pi, generation);
206
+ // A stale owner may read persisted state, but must not read or mutate runtime state.
207
+ const settings = current ? undefined : await loadSettings();
208
+ const base = current
209
+ ? availableFirecrawlTools(pi)
210
+ : settings?.kind === "loaded"
211
+ ? settings.settings.tools
212
+ : fallbackTools;
213
+ const selected = new Set(base);
214
+ if (enabled) selected.add(name);
215
+ else selected.delete(name);
216
+ return (
217
+ (await transactSelectedToolsNow(
218
+ pi,
219
+ ctx,
220
+ orderedFirecrawlTools(selected),
221
+ generation,
222
+ undefined,
223
+ notificationSignal,
224
+ )) === "saved"
225
+ );
226
+ });
227
+ toolTransactionQueue = operation.then(
228
+ () => undefined,
229
+ () => undefined,
230
+ );
231
+ return operation;
159
232
  }
160
233
 
161
234
  let toolTransactionQueue = Promise.resolve();
@@ -170,9 +243,11 @@ function transactSelectedTools(
170
243
  selectedTools: readonly FirecrawlToolName[],
171
244
  expectedGeneration: number,
172
245
  expectedAvailableTools?: readonly FirecrawlToolName[],
246
+ notificationSignal?: AbortSignal,
173
247
  ): Promise<ToolSelectionSaveResult> {
248
+ const acceptedTools = [...selectedTools];
174
249
  const operation = toolTransactionQueue.then(() =>
175
- transactSelectedToolsNow(pi, ctx, selectedTools, expectedGeneration, expectedAvailableTools),
250
+ transactSelectedToolsNow(pi, ctx, acceptedTools, expectedGeneration, expectedAvailableTools, notificationSignal),
176
251
  );
177
252
  toolTransactionQueue = operation.then(
178
253
  () => undefined,
@@ -187,8 +262,17 @@ async function transactSelectedToolsNow(
187
262
  selectedTools: readonly FirecrawlToolName[],
188
263
  expectedGeneration: number,
189
264
  expectedAvailableTools?: readonly FirecrawlToolName[],
265
+ notificationSignal?: AbortSignal,
190
266
  ): Promise<ToolSelectionSaveResult> {
191
- if (!isCurrentFirecrawlSession(expectedGeneration)) return "failed";
267
+ if (!isCurrentFirecrawlSession(pi, expectedGeneration)) {
268
+ // Lifecycle waits include accepted writes even when their runtime owner has gone away.
269
+ try {
270
+ await persistSettings(selectedTools);
271
+ return "saved";
272
+ } catch {
273
+ return "failed";
274
+ }
275
+ }
192
276
  if (expectedAvailableTools && !arraysEqual(availableFirecrawlTools(pi), expectedAvailableTools)) {
193
277
  ctx.ui.notify(
194
278
  "Firecrawl tool availability changed while the selector was open. Review the current state and try again.",
@@ -198,27 +282,55 @@ async function transactSelectedToolsNow(
198
282
  }
199
283
  const previousActiveTools = pi.getActiveTools();
200
284
  const previousAvailableTools = availableFirecrawlTools(pi);
285
+ const sessionOwner = ctx.sessionManager;
201
286
  try {
202
- applyFirecrawlTools(pi, selectedTools, ctx.sessionManager);
287
+ applyFirecrawlTools(pi, selectedTools, sessionOwner);
203
288
  await persistSettings(selectedTools);
204
- return isCurrentFirecrawlSession(expectedGeneration) ? "saved" : "failed";
289
+ return isCurrentFirecrawlSession(pi, expectedGeneration) ? "saved" : "failed";
205
290
  } catch (error) {
291
+ // Restore only the uncommitted policy. Replacement startup waits for this queue;
292
+ // old work must never re-register tools, change its active set, or publish old UI.
293
+ if (!isCurrentFirecrawlSession(pi, expectedGeneration)) {
294
+ restoreAvailableFirecrawlPolicy(pi, previousAvailableTools, sessionOwner);
295
+ return "failed";
296
+ }
206
297
  let rollbackError: unknown;
207
298
  try {
208
- applyAvailableFirecrawlTools(pi, previousAvailableTools, ctx.sessionManager);
209
- const currentNonCapabilityTools = pi
299
+ applyAvailableFirecrawlTools(pi, previousAvailableTools, sessionOwner);
300
+ const currentOtherTools = pi
210
301
  .getActiveTools()
211
- .filter((name) => !FIRECRAWL_TOOL_NAMES.includes(name as FirecrawlToolName));
302
+ .filter(
303
+ (name) => name !== FIRECRAWL_LOAD_TOOL_NAME && !FIRECRAWL_TOOL_NAMES.includes(name as FirecrawlToolName),
304
+ );
212
305
  const previousLoadedTools = previousActiveTools.filter((name) =>
213
306
  FIRECRAWL_TOOL_NAMES.includes(name as FirecrawlToolName),
214
307
  );
215
308
  const restoredFirecrawlTools =
216
- firecrawlToolExposureMode(pi) === "eager" ? previousAvailableTools : previousLoadedTools;
217
- pi.setActiveTools(unique([...currentNonCapabilityTools, ...restoredFirecrawlTools]));
309
+ firecrawlToolMode(pi) === "codemode"
310
+ ? previousLoadedTools
311
+ : firecrawlToolExposureMode(pi) === "eager"
312
+ ? previousAvailableTools
313
+ : previousLoadedTools;
314
+ const desired = new Set([
315
+ ...(firecrawlToolMode(pi) === "lazy" ? [FIRECRAWL_LOAD_TOOL_NAME] : []),
316
+ ...restoredFirecrawlTools,
317
+ ]);
318
+ const restoredOrder = [...currentOtherTools];
319
+ // Keep current unrelated order and restore owned tools at their previous anchors.
320
+ for (const [index, name] of previousActiveTools.entries()) {
321
+ if (!desired.has(name)) continue;
322
+ const nextOther = previousActiveTools
323
+ .slice(index + 1)
324
+ .find((candidate) => currentOtherTools.includes(candidate));
325
+ if (nextOther) restoredOrder.splice(restoredOrder.indexOf(nextOther), 0, name);
326
+ else restoredOrder.push(name);
327
+ }
328
+ pi.setActiveTools(unique([...restoredOrder, ...desired]));
218
329
  } catch (caught) {
219
330
  rollbackError = caught;
220
331
  }
221
- if (!isCurrentFirecrawlSession(expectedGeneration)) return "failed";
332
+ if (!isCurrentFirecrawlSession(pi, expectedGeneration)) return "failed";
333
+ if (notificationSignal?.aborted) return "failed";
222
334
  ctx.ui.notify(
223
335
  sanitizeFirecrawlDisplay(
224
336
  rollbackError
@@ -231,6 +343,33 @@ async function transactSelectedToolsNow(
231
343
  }
232
344
  }
233
345
 
346
+ export function setFirecrawlToolMode(
347
+ pi: ExtensionAPI,
348
+ ctx: CommandContext,
349
+ mode: FirecrawlToolMode,
350
+ notificationSignal?: AbortSignal,
351
+ ): Promise<boolean> {
352
+ const generation = currentFirecrawlSessionGeneration(pi);
353
+ const fallbackTools = availableFirecrawlTools(pi);
354
+ const operation = toolTransactionQueue.then(async () => {
355
+ // Accepted mode writes are global persistence, not work owned by the old session.
356
+ try {
357
+ await saveToolMode(mode, fallbackTools);
358
+ return true;
359
+ } catch (error) {
360
+ if (!notificationSignal?.aborted && isCurrentFirecrawlSession(pi, generation)) {
361
+ ctx.ui.notify(sanitizeFirecrawlDisplay(`Firecrawl settings save failed: ${formatError(error)}`), "warning");
362
+ }
363
+ return false;
364
+ }
365
+ });
366
+ toolTransactionQueue = operation.then(
367
+ () => undefined,
368
+ () => undefined,
369
+ );
370
+ return operation;
371
+ }
372
+
234
373
  function arraysEqual<T>(left: readonly T[], right: readonly T[]) {
235
374
  return left.length === right.length && left.every((value, index) => value === right[index]);
236
375
  }
@@ -248,6 +387,19 @@ function getToolStatusSummary(pi: ExtensionAPI): ToolStatusSummary {
248
387
  const activeToolNames = new Set(pi.getActiveTools());
249
388
  const loadedFirecrawlToolCount = FIRECRAWL_TOOL_NAMES.filter((name) => activeToolNames.has(name)).length;
250
389
  const availableFirecrawlToolCount = availableFirecrawlTools(pi).length;
390
+ // getAllTools reflects host allowlists/exclusions; callability is distinct from declaration.
391
+ const callableFirecrawlToolCount = new Set(
392
+ pi
393
+ .getAllTools()
394
+ .filter(
395
+ (tool) =>
396
+ firecrawlToolNames.has(tool.name) &&
397
+ (tool.exposure === "codemode" ||
398
+ tool.exposure === "deferred" ||
399
+ ((tool.exposure ?? "direct") === "direct" && activeToolNames.has(tool.name))),
400
+ )
401
+ .map((tool) => tool.name),
402
+ ).size;
251
403
  const activeNonFirecrawlToolCount = Array.from(activeToolNames).filter(
252
404
  (name) => !firecrawlToolNames.has(name) && name !== FIRECRAWL_LOAD_TOOL_NAME,
253
405
  ).length;
@@ -261,27 +413,33 @@ function getToolStatusSummary(pi: ExtensionAPI): ToolStatusSummary {
261
413
  return {
262
414
  availabilityStatus,
263
415
  availableFirecrawlToolCount,
416
+ callableFirecrawlToolCount,
264
417
  loadedFirecrawlToolCount,
265
418
  activeNonFirecrawlToolCount,
266
419
  };
267
420
  }
268
421
 
269
422
  export async function buildStatusMessage(pi: ExtensionAPI) {
270
- const generation = sessionGeneration;
423
+ const generation = currentFirecrawlSessionGeneration(pi);
271
424
  const settings = await loadSettings();
272
- if (!isCurrentFirecrawlSession(generation)) return "";
273
- recordSettingsNotice(settings);
425
+ if (!isCurrentFirecrawlSession(pi, generation)) return "";
426
+ recordSettingsNotice(pi, settings);
274
427
  const summary = getToolStatusSummary(pi);
275
428
  const persistedSetting = persistedSettingLabel(settings);
429
+ const savedMode = settings.kind === "loaded" ? (settings.settings.toolMode ?? DEFAULT_TOOL_MODE) : DEFAULT_TOOL_MODE;
276
430
  return sanitizeFirecrawlDisplay(
277
431
  [
278
432
  `Firecrawl tools available: ${formatRuntimeStatus(summary)}`,
433
+ `Running tool mode: ${firecrawlToolMode(pi)}`,
434
+ `Saved tool mode: ${savedMode}${settings.kind === "loaded" ? "" : " (default; no valid override)"}`,
435
+ ...(savedMode !== firecrawlToolMode(pi) ? ["Tool mode change pending: /reload required"] : []),
279
436
  `Tool exposure: ${firecrawlToolExposureMode(pi)}`,
437
+ `Callable capability tools: ${summary.callableFirecrawlToolCount}/${FIRECRAWL_TOOL_NAMES.length}`,
280
438
  `Loaded capability tools this session: ${summary.loadedFirecrawlToolCount}/${FIRECRAWL_TOOL_NAMES.length}`,
281
439
  `Loader: ${pi.getActiveTools().includes(FIRECRAWL_LOAD_TOOL_NAME) ? "active" : "inactive"}`,
282
440
  `Persisted tool catalog: ${persistedSetting}`,
283
441
  `Settings file: ${settingsFilePath()}`,
284
- ...(settingsNotice ? [`Settings note: ${settingsNotice}`] : []),
442
+ ...(sessionState(pi).notice ? [`Settings note: ${sessionState(pi).notice}`] : []),
285
443
  `Other active tools preserved: ${summary.activeNonFirecrawlToolCount}`,
286
444
  `API key: ${hasApiKey() ? "present" : "missing"} (FIRECRAWL_API_KEY)`,
287
445
  `API URL: ${configuredApiUrl()}`,
@@ -309,6 +467,7 @@ export function buildCommandGuide() {
309
467
  "/firecrawl config — show API key presence and API URL",
310
468
  "/firecrawl quickstart — alias for /firecrawl config",
311
469
  "/firecrawl status — show tool and settings status",
470
+ "/firecrawl settings — choose tool mode (applies after /reload) and available tools",
312
471
  "/firecrawl tools — choose available Firecrawl tools",
313
472
  "/firecrawl toggle — alias for /firecrawl tools",
314
473
  "/firecrawl enable — make all Firecrawl tools available",