@ai-matrx/chat 0.5.18 → 0.6.0

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.
Files changed (89) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/agents/components/identity-refs/AiIdentityRef.d.ts +33 -0
  3. package/dist/agents/components/identity-refs/AiIdentityRef.js +138 -0
  4. package/dist/agents/components/inputs/smart-input/QuicksetPanel.js +5 -9
  5. package/dist/agents/components/inputs/smart-input/RunSkillPicker.js +1 -1
  6. package/dist/agents/components/inputs/smart-input/RunToolPicker.js +6 -11
  7. package/dist/agents/components/inputs/smart-input/ShapeChipsRow.js +1 -1
  8. package/dist/agents/components/inputs/smart-input/composer/ComposerEffortPill.js +1 -1
  9. package/dist/agents/components/inputs/smart-input/composer/ComposerOutput.js +1 -1
  10. package/dist/agents/components/inputs/smart-input/composer/ComposerPlusMenu.js +1 -1
  11. package/dist/agents/components/inputs/smart-input/composer/useComposerAgent.js +1 -1
  12. package/dist/agents/components/inputs/smart-input/composer/useRunControlCounts.d.ts +3 -0
  13. package/dist/agents/components/inputs/smart-input/composer/useRunControlCounts.js +54 -0
  14. package/dist/agents/components/model-tiers/ModelTierIdentityList.js +1 -1
  15. package/dist/agents/components/run-controls/RunConfigOverrides.js +1 -1
  16. package/dist/agents/components/run-controls/RunInputCapabilities.js +1 -1
  17. package/dist/agents/components/run-controls/panels/shared.d.ts +0 -2
  18. package/dist/agents/hooks/useDiffEnrichment.js +3 -6
  19. package/dist/agents/identity/agent-catalog-lists.js +2 -1
  20. package/dist/agents/identity/agent-identity.js +2 -1
  21. package/dist/agents/identity/model-catalog.d.ts +9 -0
  22. package/dist/agents/identity/model-catalog.js +25 -0
  23. package/dist/agents/identity/preferred-chat-model.d.ts +9 -0
  24. package/dist/agents/identity/preferred-chat-model.js +33 -0
  25. package/dist/agents/identity/settings-store.d.ts +10 -0
  26. package/dist/agents/identity/settings-store.js +49 -0
  27. package/dist/agents/identity/skill-catalog.d.ts +27 -0
  28. package/dist/agents/identity/skill-catalog.js +100 -0
  29. package/dist/agents/identity/tool-catalog.d.ts +15 -0
  30. package/dist/agents/identity/tool-catalog.js +67 -0
  31. package/dist/agents/redux/agent-definition/cache-bust-middleware.d.ts +0 -1
  32. package/dist/agents/redux/agent-definition/cache-bust-middleware.js +1 -13
  33. package/dist/agents/redux/agent-definition/selectors.d.ts +12 -546
  34. package/dist/agents/redux/agent-settings/internal-utils.d.ts +2 -123
  35. package/dist/agents/redux/agent-settings/internal-utils.js +1 -315
  36. package/dist/agents/redux/agent-settings/settings-catalogue.d.ts +2 -78
  37. package/dist/agents/redux/agent-settings/settings-catalogue.js +1 -176
  38. package/dist/agents/redux/agent-settings/types.d.ts +2 -148
  39. package/dist/agents/redux/agent-settings/types.js +1 -0
  40. package/dist/agents/redux/agent-settings/ui-gates.d.ts +2 -54
  41. package/dist/agents/redux/agent-settings/ui-gates.js +1 -38
  42. package/dist/agents/redux/agent-shortcut-categories/selectors.d.ts +0 -100
  43. package/dist/agents/redux/agent-shortcuts/selectors.d.ts +0 -294
  44. package/dist/agents/redux/conversation-history/selectors.d.ts +0 -32
  45. package/dist/agents/redux/conversation-list/conversation-list.selectors.d.ts +0 -4
  46. package/dist/agents/redux/execution-system/active-requests/active-requests.selectors.d.ts +0 -108
  47. package/dist/agents/redux/execution-system/context-state/context-state.selectors.d.ts +0 -28
  48. package/dist/agents/redux/execution-system/conversations/conversations.selectors.d.ts +0 -10
  49. package/dist/agents/redux/execution-system/instance-context/instance-context.selectors.d.ts +0 -6
  50. package/dist/agents/redux/execution-system/instance-model-overrides/launch-model-overrides.js +1 -1
  51. package/dist/agents/redux/execution-system/instance-resources/instance-resources.selectors.d.ts +0 -16
  52. package/dist/agents/redux/execution-system/instance-ui-state/instance-ui-state.selectors.d.ts +0 -10
  53. package/dist/agents/redux/execution-system/instance-variable-values/instance-variable-values.selectors.d.ts +0 -14
  54. package/dist/agents/redux/execution-system/messages/messages.selectors.d.ts +0 -2
  55. package/dist/agents/redux/execution-system/observability/observability.selectors.d.ts +0 -14
  56. package/dist/agents/redux/execution-system/observational-memory/observational-memory.selectors.d.ts +0 -2
  57. package/dist/agents/redux/execution-system/selectors/aggregate.selectors.d.ts +0 -28
  58. package/dist/agents/redux/execution-system/thunks/process-stream.js +2 -5
  59. package/dist/agents/redux/execution-system/utils/loaded-skill-sources.d.ts +1 -1
  60. package/dist/agents/redux/execution-system/utils/loaded-skill-sources.js +3 -3
  61. package/dist/agents/redux/proposed-directives/proposedDirectivesSlice.d.ts +0 -2
  62. package/dist/agents/ui-first-tools/redux/agent-lists.selectors.d.ts +0 -4
  63. package/dist/host/ui-slots.d.ts +0 -46
  64. package/dist/host/ui-slots.js +0 -33
  65. package/dist/store/create-chat-store.d.ts +0 -4
  66. package/dist/store/middlewares.d.ts +0 -10
  67. package/dist/store/slices.d.ts +0 -2
  68. package/dist/store/slices.js +0 -4
  69. package/dist/surfaces/redux/selectors.d.ts +0 -4
  70. package/dist/tool-call-visualization/redux/selectors.d.ts +0 -2
  71. package/dist/ui/chat-default-model-knob.d.ts +1 -1
  72. package/dist/ui/chat-default-model-knob.js +1 -1
  73. package/package.json +4 -4
  74. package/dist/agents/components/model/AgentModelPanel.d.ts +0 -4
  75. package/dist/agents/components/model/AgentModelPanel.js +0 -9
  76. package/dist/agents/redux/agent-settings/agentSettingsSlice.d.ts +0 -1015
  77. package/dist/agents/redux/agent-settings/agentSettingsSlice.js +0 -659
  78. package/dist/agents/redux/agent-settings/selectors.d.ts +0 -10057
  79. package/dist/agents/redux/agent-settings/selectors.js +0 -234
  80. package/dist/agents/redux/agent-settings/useNormalizedControls.d.ts +0 -8
  81. package/dist/agents/redux/agent-settings/useNormalizedControls.js +0 -24
  82. package/dist/agents/redux/tools/tools.selectors.d.ts +0 -529
  83. package/dist/agents/redux/tools/tools.selectors.js +0 -24
  84. package/dist/agents/redux/tools/tools.slice.d.ts +0 -12
  85. package/dist/agents/redux/tools/tools.slice.js +0 -37
  86. package/dist/agents/redux/tools/tools.thunks.d.ts +0 -125
  87. package/dist/agents/redux/tools/tools.thunks.js +0 -45
  88. package/dist/host/defaults/setting-control-input.d.ts +0 -11
  89. package/dist/host/defaults/setting-control-input.js +0 -91
@@ -1,659 +0,0 @@
1
- import { createSlice, createAsyncThunk } from "@reduxjs/toolkit";
2
- import { tryWriteOne } from "@ai-matrx/data/db";
3
- import { createClient } from "../../../host/db.js";
4
- import { chatHostHasDatabase } from "../../../host/configure.js";
5
- import { recordUnavailable } from "../../../host/diagnostics.js";
6
- import { readModelRecords, selectModelById } from "../model-registry.js";
7
- import {
8
- computeOverrideDiff,
9
- detectConflicts,
10
- extractModelDefaults,
11
- mergeEffectiveSettings,
12
- parseModelControls,
13
- resolveConflicts,
14
- sanitizeSettings
15
- } from "./internal-utils.js";
16
- import { isJsonArray, isJsonObject } from "@ai-matrx/kit/json-format";
17
- import { VARIABLE_COMPONENT_TYPES } from "../../types/agent-definition.types.js";
18
- function isCustomComponentShape(value) {
19
- return typeof value.type === "string" && VARIABLE_COMPONENT_TYPES.includes(value.type);
20
- }
21
- function parseCustomComponent(raw) {
22
- if (!isJsonObject(raw)) return void 0;
23
- const cc = raw;
24
- return isCustomComponentShape(cc) ? cc : void 0;
25
- }
26
- function parseAgentVariables(raw) {
27
- if (!isJsonArray(raw)) return [];
28
- const result = [];
29
- for (const item of raw) {
30
- if (!isJsonObject(item)) continue;
31
- if (typeof item.name !== "string") continue;
32
- result.push({
33
- name: item.name,
34
- defaultValue: typeof item.defaultValue === "string" ? item.defaultValue : "",
35
- required: typeof item.required === "boolean" ? item.required : void 0,
36
- helpText: typeof item.helpText === "string" ? item.helpText : void 0,
37
- // customComponent is a deep, mostly-optional shape (picklist/toggle/min/max/etc.) —
38
- // only `type` (the required discriminant) is validated here; deeper validation
39
- // belongs to whichever component actually reads each nested field.
40
- customComponent: parseCustomComponent(item.customComponent)
41
- });
42
- }
43
- return result;
44
- }
45
- function makeEmptyEntry(agentId, source, context) {
46
- return {
47
- agentId,
48
- source,
49
- context,
50
- defaults: {},
51
- overrides: {},
52
- variable_defaults: [],
53
- variable_overrides: {},
54
- pendingSwitch: null,
55
- isDirty: false,
56
- isLoading: false,
57
- isSaving: false,
58
- error: null,
59
- lastFetchedAt: null
60
- };
61
- }
62
- const initialState = {
63
- entries: {},
64
- activeAgentId: null,
65
- availableTools: [],
66
- isLoadingTools: false,
67
- toolsError: null
68
- };
69
- const NEEDS_DATABASE = { condition: () => chatHostHasDatabase() };
70
- const fetchAvailableTools = createAsyncThunk(
71
- "agentSettings/fetchAvailableTools",
72
- async (_, { rejectWithValue }) => {
73
- try {
74
- const supabase = createClient();
75
- const { data, error } = await supabase.schema("tool").from("definition").select("id, name, description, category, icon").is("deleted_at", null).eq("is_active", true).order("category", { ascending: true }).order("name", { ascending: true });
76
- if (error) throw error;
77
- return data ?? [];
78
- } catch (err) {
79
- return rejectWithValue(
80
- err instanceof Error ? err.message : "Failed to fetch tools"
81
- );
82
- }
83
- },
84
- NEEDS_DATABASE
85
- );
86
- const loadAgentSettings = createAsyncThunk(
87
- "agentSettings/loadAgentSettings",
88
- async ({
89
- agentId,
90
- source,
91
- context = "builder"
92
- }, { rejectWithValue }) => {
93
- try {
94
- const supabase = createClient();
95
- let data = null;
96
- let error = null;
97
- if (source === "builtin") {
98
- const result = await supabase.schema("agent").from("definition").select("id, settings, variable_definitions").is("deleted_at", null).eq("id", agentId).maybeSingle();
99
- error = result.error;
100
- data = result.data ? {
101
- id: result.data.id,
102
- settings: result.data.settings,
103
- variable_defaults: result.data.variable_definitions
104
- } : null;
105
- } else {
106
- const result = await supabase.schema("agent").from("definition").select("id, settings, variable_definitions").is("deleted_at", null).eq("id", agentId).eq("agent_type", "user").maybeSingle();
107
- error = result.error;
108
- data = result.data ? {
109
- id: result.data.id,
110
- settings: result.data.settings,
111
- variable_defaults: result.data.variable_definitions
112
- } : null;
113
- }
114
- if (error) throw error;
115
- if (!data)
116
- throw recordUnavailable({
117
- entity: "agent",
118
- reason: "unknown",
119
- recordId: agentId,
120
- token: "agent",
121
- relation: "agent.definition"
122
- });
123
- const rawSettings = data.settings;
124
- const rawVariableDefaults = parseAgentVariables(
125
- data.variable_defaults
126
- );
127
- return {
128
- agentId,
129
- source,
130
- context,
131
- rawSettings,
132
- rawVariableDefaults
133
- };
134
- } catch (err) {
135
- return rejectWithValue(
136
- err instanceof Error ? err.message : "Failed to load agent settings"
137
- );
138
- }
139
- },
140
- NEEDS_DATABASE
141
- );
142
- const loadAgentSettingsDirect = createAsyncThunk(
143
- "agentSettings/loadAgentSettingsDirect",
144
- async ({
145
- agentId,
146
- source,
147
- context = "builder",
148
- data
149
- }, _thunkApi) => {
150
- return {
151
- agentId,
152
- source,
153
- context,
154
- rawSettings: data.settings ?? null,
155
- rawVariableDefaults: data.variable_defaults ?? null
156
- };
157
- },
158
- NEEDS_DATABASE
159
- );
160
- const requestModelSwitch = createAsyncThunk(
161
- "agentSettings/requestModelSwitch",
162
- async ({
163
- agentId,
164
- newModelId,
165
- offeringId
166
- }, { getState, rejectWithValue }) => {
167
- const state = getState();
168
- const models = readModelRecords();
169
- const newModel = selectModelById(models, newModelId);
170
- if (!newModel) {
171
- return rejectWithValue(`Model ${newModelId} not found in registry`);
172
- }
173
- const entry = state.agentSettings?.entries[agentId];
174
- if (!entry) {
175
- return rejectWithValue(`Agent ${agentId} not found in agentSettings`);
176
- }
177
- const newControls = parseModelControls(
178
- newModel.controls
179
- );
180
- const newDefaults = extractModelDefaults(
181
- newModel.controls
182
- );
183
- const currentEffective = mergeEffectiveSettings(
184
- entry.defaults,
185
- entry.overrides
186
- );
187
- const { conflicts, supportedKeys } = detectConflicts(
188
- currentEffective,
189
- newControls,
190
- newDefaults
191
- );
192
- const prevModelId = currentEffective.model ?? entry.defaults.model ?? "";
193
- const prevModel = selectModelById(models, prevModelId);
194
- const prevModelName = prevModel?.common_name || prevModel?.name || prevModelId || "Unknown";
195
- const newModelName = newModel.common_name || newModel.name || newModelId;
196
- return {
197
- agentId,
198
- pendingSwitch: {
199
- prevModelId,
200
- prevModelName,
201
- newModelId,
202
- newModelName,
203
- conflicts,
204
- supportedKeys,
205
- newModelControls: newControls,
206
- // Keep every set value by default — the server translates what the
207
- // new model does not carry natively (settings-translation K7). Reset
208
- // or remove is the person's explicit choice in the dialog.
209
- mode: "keep_all",
210
- customActions: {},
211
- ...offeringId ? { offeringId } : {}
212
- },
213
- newDefaults
214
- };
215
- },
216
- NEEDS_DATABASE
217
- );
218
- const saveAgentSettings = createAsyncThunk(
219
- "agentSettings/saveAgentSettings",
220
- async ({ agentId }, { getState, rejectWithValue }) => {
221
- const state = getState();
222
- const entry = state.agentSettings?.entries[agentId];
223
- if (!entry) {
224
- return rejectWithValue(`Agent ${agentId} not found`);
225
- }
226
- if (entry.context !== "builder") {
227
- return { agentId, savedAt: null };
228
- }
229
- try {
230
- const supabase = createClient();
231
- const settingsToSave = entry.defaults;
232
- const now = (/* @__PURE__ */ new Date()).toISOString();
233
- let error = null;
234
- if (entry.source === "builtin") {
235
- const result = await tryWriteOne(
236
- supabase.schema("agent").from("definition").update({
237
- settings: settingsToSave,
238
- variable_definitions: entry.variable_defaults,
239
- updated_at: now
240
- }).eq("id", agentId).select("id"),
241
- { action: "save", noun: "agent" }
242
- );
243
- error = result.error;
244
- } else {
245
- const result = await tryWriteOne(
246
- supabase.schema("agent").from("definition").update({
247
- settings: settingsToSave,
248
- variable_definitions: entry.variable_defaults,
249
- updated_at: now
250
- }).eq("id", agentId).eq("agent_type", "user").select("id"),
251
- { action: "save", noun: "agent" }
252
- );
253
- error = result.error;
254
- }
255
- if (error) throw error;
256
- return { agentId, savedAt: now };
257
- } catch (err) {
258
- return rejectWithValue(
259
- err instanceof Error ? err.message : "Failed to save agent settings"
260
- );
261
- }
262
- },
263
- NEEDS_DATABASE
264
- );
265
- const agentSettingsSlice = createSlice({
266
- name: "agentSettings",
267
- initialState,
268
- reducers: {
269
- // ── Initialization ──────────────────────────────────────────────────────
270
- /**
271
- * Directly initialize an entry (synchronous — data already available).
272
- * Useful for test context or when the data comes from another slice.
273
- */
274
- initializeAgent(state, action) {
275
- const { agentId, source, context, settings, variable_defaults } = action.payload;
276
- state.entries[agentId] = {
277
- ...makeEmptyEntry(agentId, source, context),
278
- defaults: sanitizeSettings(settings),
279
- variable_defaults: variable_defaults ?? [],
280
- lastFetchedAt: (/* @__PURE__ */ new Date()).toISOString()
281
- };
282
- },
283
- // ── Active Agent ────────────────────────────────────────────────────────
284
- setActiveAgent(state, action) {
285
- state.activeAgentId = action.payload;
286
- },
287
- removeAgent(state, action) {
288
- delete state.entries[action.payload];
289
- if (state.activeAgentId === action.payload) {
290
- state.activeAgentId = null;
291
- }
292
- },
293
- // ── Overrides (chat/test contexts) ──────────────────────────────────────
294
- /**
295
- * Set a single field override. Marks isDirty.
296
- * For 'builder' context use updateDefaults instead.
297
- */
298
- setOverride(state, action) {
299
- const { agentId, field, value } = action.payload;
300
- const entry = state.entries[agentId];
301
- if (!entry) return;
302
- entry.overrides[field] = value;
303
- entry.isDirty = true;
304
- },
305
- /**
306
- * Apply a full settings object from the dialog. The diff against defaults
307
- * is computed internally — only true overrides are stored.
308
- */
309
- applySettingsFromDialog(state, action) {
310
- const { agentId, newSettings } = action.payload;
311
- const entry = state.entries[agentId];
312
- if (!entry) return;
313
- if (entry.context === "builder") {
314
- entry.defaults = {
315
- ...sanitizeSettings(newSettings)
316
- };
317
- entry.isDirty = true;
318
- } else {
319
- entry.overrides = computeOverrideDiff(entry.defaults, newSettings);
320
- entry.isDirty = Object.keys(entry.overrides).length > 0;
321
- }
322
- },
323
- resetOverride(state, action) {
324
- const { agentId, field } = action.payload;
325
- const entry = state.entries[agentId];
326
- if (!entry) return;
327
- delete entry.overrides[field];
328
- entry.isDirty = Object.keys(entry.overrides).length > 0;
329
- },
330
- resetAllOverrides(state, action) {
331
- const entry = state.entries[action.payload];
332
- if (!entry) return;
333
- entry.overrides = {};
334
- entry.isDirty = false;
335
- },
336
- // ── Defaults (builder context) ──────────────────────────────────────────
337
- /**
338
- * Directly update defaults (builder mode — no override tracking).
339
- * Marks isDirty so the save button activates.
340
- */
341
- updateDefaults(state, action) {
342
- const { agentId, settings } = action.payload;
343
- const entry = state.entries[agentId];
344
- if (!entry) return;
345
- entry.defaults = {
346
- ...entry.defaults,
347
- ...sanitizeSettings(settings)
348
- };
349
- entry.isDirty = true;
350
- },
351
- // ── Variables (builder context — mutates defaults) ───────────────────────
352
- addVariable(state, action) {
353
- const { agentId, variable } = action.payload;
354
- const entry = state.entries[agentId];
355
- if (!entry) return;
356
- entry.variable_defaults.push(variable);
357
- entry.isDirty = true;
358
- },
359
- updateVariable(state, action) {
360
- const { agentId, name, updates } = action.payload;
361
- const entry = state.entries[agentId];
362
- if (!entry) return;
363
- const idx = entry.variable_defaults.findIndex((v) => v.name === name);
364
- if (idx !== -1) {
365
- entry.variable_defaults[idx] = {
366
- ...entry.variable_defaults[idx],
367
- ...updates
368
- };
369
- entry.isDirty = true;
370
- }
371
- },
372
- removeVariable(state, action) {
373
- const { agentId, name } = action.payload;
374
- const entry = state.entries[agentId];
375
- if (!entry) return;
376
- entry.variable_defaults = entry.variable_defaults.filter(
377
- (v) => v.name !== name
378
- );
379
- entry.isDirty = true;
380
- },
381
- // ── Variable Overrides (chat/test contexts) ──────────────────────────────
382
- setVariableOverride(state, action) {
383
- const { agentId, name, value } = action.payload;
384
- const entry = state.entries[agentId];
385
- if (!entry) return;
386
- entry.variable_overrides[name] = value;
387
- entry.isDirty = true;
388
- },
389
- resetVariableOverride(state, action) {
390
- const { agentId, name } = action.payload;
391
- const entry = state.entries[agentId];
392
- if (!entry) return;
393
- delete entry.variable_overrides[name];
394
- },
395
- resetAllVariableOverrides(state, action) {
396
- const entry = state.entries[action.payload];
397
- if (!entry) return;
398
- entry.variable_overrides = {};
399
- },
400
- // ── Model Switch Resolution ──────────────────────────────────────────────
401
- /**
402
- * Change the resolution mode while the conflict dialog is open.
403
- * Triggers re-render of the previewed resolved settings via selector.
404
- */
405
- setResolutionMode(state, action) {
406
- const { agentId, mode } = action.payload;
407
- const entry = state.entries[agentId];
408
- if (!entry?.pendingSwitch) return;
409
- entry.pendingSwitch.mode = mode;
410
- if (mode !== "custom") {
411
- entry.pendingSwitch.customActions = {};
412
- }
413
- },
414
- /**
415
- * Toggle a single conflict's action when mode is 'custom'.
416
- * Automatically promotes mode to 'custom' if needed.
417
- */
418
- setCustomConflictAction(state, action) {
419
- const { agentId, key, conflictAction } = action.payload;
420
- const entry = state.entries[agentId];
421
- if (!entry?.pendingSwitch) return;
422
- entry.pendingSwitch.mode = "custom";
423
- entry.pendingSwitch.customActions[key] = conflictAction;
424
- },
425
- /**
426
- * Confirm the pending model switch.
427
- * Resolves conflicts using current mode/customActions and applies the result.
428
- *
429
- * - In 'builder': updates defaults directly (the canonical state)
430
- * - In 'chat'/'test': updates overrides with the model change + resolved settings
431
- */
432
- confirmModelSwitch(state, action) {
433
- const agentId = action.payload;
434
- const entry = state.entries[agentId];
435
- if (!entry?.pendingSwitch) return;
436
- const pending = entry.pendingSwitch;
437
- const currentEffective = mergeEffectiveSettings(
438
- entry.defaults,
439
- entry.overrides
440
- );
441
- const resolved = resolveConflicts(currentEffective, pending);
442
- const finalSettings = {
443
- ...resolved,
444
- model: pending.newModelId
445
- };
446
- if (pending.offeringId) {
447
- finalSettings.offering_id = pending.offeringId;
448
- } else {
449
- delete finalSettings.offering_id;
450
- }
451
- if (entry.context === "builder") {
452
- entry.defaults = finalSettings;
453
- } else {
454
- entry.overrides = computeOverrideDiff(entry.defaults, finalSettings);
455
- }
456
- entry.pendingSwitch = null;
457
- entry.isDirty = true;
458
- },
459
- /**
460
- * Cancel the pending model switch — revert to previous model, clear pendingSwitch.
461
- */
462
- cancelModelSwitch(state, action) {
463
- const entry = state.entries[action.payload];
464
- if (!entry) return;
465
- entry.pendingSwitch = null;
466
- },
467
- // ── Status ──────────────────────────────────────────────────────────────
468
- setLoading(state, action) {
469
- const entry = state.entries[action.payload.agentId];
470
- if (entry) entry.isLoading = action.payload.value;
471
- },
472
- setSaving(state, action) {
473
- const entry = state.entries[action.payload.agentId];
474
- if (entry) entry.isSaving = action.payload.value;
475
- },
476
- setError(state, action) {
477
- const entry = state.entries[action.payload.agentId];
478
- if (entry) {
479
- entry.error = action.payload.error;
480
- entry.isLoading = false;
481
- entry.isSaving = false;
482
- }
483
- },
484
- clearError(state, action) {
485
- const entry = state.entries[action.payload];
486
- if (entry) entry.error = null;
487
- }
488
- },
489
- extraReducers: (builder) => {
490
- builder.addCase(loadAgentSettings.pending, (state, action) => {
491
- const { agentId, source, context = "builder" } = action.meta.arg;
492
- if (!state.entries[agentId]) {
493
- state.entries[agentId] = makeEmptyEntry(agentId, source, context);
494
- }
495
- state.entries[agentId].isLoading = true;
496
- state.entries[agentId].error = null;
497
- });
498
- builder.addCase(loadAgentSettings.fulfilled, (state, action) => {
499
- const { agentId, source, context, rawSettings, rawVariableDefaults } = action.payload;
500
- state.entries[agentId] = {
501
- ...makeEmptyEntry(agentId, source, context),
502
- defaults: sanitizeSettings(
503
- rawSettings
504
- ),
505
- variable_defaults: rawVariableDefaults ?? [],
506
- lastFetchedAt: (/* @__PURE__ */ new Date()).toISOString(),
507
- isLoading: false
508
- };
509
- });
510
- builder.addCase(loadAgentSettings.rejected, (state, action) => {
511
- const { agentId } = action.meta.arg;
512
- if (state.entries[agentId]) {
513
- state.entries[agentId].isLoading = false;
514
- state.entries[agentId].error = action.payload;
515
- }
516
- });
517
- builder.addCase(loadAgentSettingsDirect.fulfilled, (state, action) => {
518
- const { agentId, source, context, rawSettings, rawVariableDefaults } = action.payload;
519
- state.entries[agentId] = {
520
- ...makeEmptyEntry(agentId, source, context),
521
- defaults: sanitizeSettings(
522
- rawSettings
523
- ),
524
- variable_defaults: rawVariableDefaults ?? [],
525
- lastFetchedAt: (/* @__PURE__ */ new Date()).toISOString()
526
- };
527
- });
528
- builder.addCase(requestModelSwitch.fulfilled, (state, action) => {
529
- const { agentId, pendingSwitch } = action.payload;
530
- const entry = state.entries[agentId];
531
- if (!entry) return;
532
- entry.pendingSwitch = pendingSwitch;
533
- });
534
- builder.addCase(requestModelSwitch.rejected, (state, action) => {
535
- const { agentId } = action.meta.arg;
536
- const entry = state.entries[agentId];
537
- if (entry) {
538
- entry.error = action.payload;
539
- }
540
- });
541
- builder.addCase(saveAgentSettings.pending, (state, action) => {
542
- const entry = state.entries[action.meta.arg.agentId];
543
- if (entry) {
544
- entry.isSaving = true;
545
- entry.error = null;
546
- }
547
- });
548
- builder.addCase(saveAgentSettings.fulfilled, (state, action) => {
549
- const { agentId, savedAt } = action.payload;
550
- const entry = state.entries[agentId];
551
- if (!entry) return;
552
- entry.isSaving = false;
553
- entry.isDirty = false;
554
- if (savedAt) {
555
- entry.lastFetchedAt = savedAt;
556
- }
557
- });
558
- builder.addCase(saveAgentSettings.rejected, (state, action) => {
559
- const entry = state.entries[action.meta.arg.agentId];
560
- if (entry) {
561
- entry.isSaving = false;
562
- entry.error = action.payload;
563
- }
564
- });
565
- builder.addCase(fetchAvailableTools.pending, (state) => {
566
- state.isLoadingTools = true;
567
- state.toolsError = null;
568
- });
569
- builder.addCase(fetchAvailableTools.fulfilled, (state, action) => {
570
- state.isLoadingTools = false;
571
- state.availableTools = action.payload;
572
- });
573
- builder.addCase(fetchAvailableTools.rejected, (state, action) => {
574
- state.isLoadingTools = false;
575
- state.toolsError = action.payload;
576
- });
577
- }
578
- });
579
- const agentSettingsActions = agentSettingsSlice.actions;
580
- const {
581
- initializeAgent,
582
- setActiveAgent,
583
- removeAgent,
584
- setOverride,
585
- applySettingsFromDialog,
586
- resetOverride,
587
- resetAllOverrides,
588
- updateDefaults,
589
- addVariable,
590
- updateVariable,
591
- removeVariable,
592
- setVariableOverride,
593
- resetVariableOverride,
594
- resetAllVariableOverrides,
595
- setResolutionMode,
596
- setCustomConflictAction,
597
- confirmModelSwitch,
598
- cancelModelSwitch,
599
- setLoading,
600
- setSaving,
601
- setError,
602
- clearError
603
- } = agentSettingsSlice.actions;
604
- var agentSettingsSlice_default = agentSettingsSlice.reducer;
605
- import {
606
- buildApiPayload as buildApiPayload2,
607
- detectConflicts as detectConflicts2,
608
- extractModelDefaults as extractModelDefaults2,
609
- getActionForMode,
610
- mergeEffectiveSettings as mergeEffectiveSettings2,
611
- mergeVariableValues,
612
- parseModelControls as parseModelControls2,
613
- resolveConflicts as resolveConflicts2,
614
- sanitizeSettings as sanitizeSettings2,
615
- computeOverrideDiff as computeOverrideDiff2,
616
- PARAM_ALIASES
617
- } from "./internal-utils.js";
618
- export {
619
- PARAM_ALIASES,
620
- addVariable,
621
- agentSettingsActions,
622
- applySettingsFromDialog,
623
- buildApiPayload2 as buildApiPayload,
624
- cancelModelSwitch,
625
- clearError,
626
- computeOverrideDiff2 as computeOverrideDiff,
627
- confirmModelSwitch,
628
- agentSettingsSlice_default as default,
629
- detectConflicts2 as detectConflicts,
630
- extractModelDefaults2 as extractModelDefaults,
631
- fetchAvailableTools,
632
- getActionForMode,
633
- initializeAgent,
634
- loadAgentSettings,
635
- loadAgentSettingsDirect,
636
- mergeEffectiveSettings2 as mergeEffectiveSettings,
637
- mergeVariableValues,
638
- parseModelControls2 as parseModelControls,
639
- removeAgent,
640
- removeVariable,
641
- requestModelSwitch,
642
- resetAllOverrides,
643
- resetAllVariableOverrides,
644
- resetOverride,
645
- resetVariableOverride,
646
- resolveConflicts2 as resolveConflicts,
647
- sanitizeSettings2 as sanitizeSettings,
648
- saveAgentSettings,
649
- setActiveAgent,
650
- setCustomConflictAction,
651
- setError,
652
- setLoading,
653
- setOverride,
654
- setResolutionMode,
655
- setSaving,
656
- setVariableOverride,
657
- updateDefaults,
658
- updateVariable
659
- };