@ai-matrx/chat 0.3.33 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -0
- package/dist/agents/addressing/useAgentHref.js +4 -1
- package/dist/agents/api/submit-tool-results.js +11 -1
- package/dist/agents/components/ambient-assistant/intelligence-places.js +2 -2
- package/dist/agents/components/chat/intelligence-places.js +7 -7
- package/dist/agents/components/chat/useCanvasScopedToConversation.js +1 -1
- package/dist/agents/components/inputs/smart-input/RunToolPicker.js +7 -13
- package/dist/agents/components/inputs/smart-input/composer/ComposerAgentPill.js +3 -2
- package/dist/agents/components/inputs/smart-input/composer/useComposerAgent.js +5 -5
- package/dist/agents/components/inputs/smart-input/composer/useComposerAgentFilter.js +3 -2
- package/dist/agents/components/messages-display/AgentConversationDisplay.js +4 -1
- package/dist/agents/components/run-controls/RunConfigOverrides.js +10 -16
- package/dist/agents/components/run-controls/panels/shared.d.ts +1 -1
- package/dist/agents/components/shared/AgentConversationColumn.js +3 -2
- package/dist/agents/components/working-document/workingDocumentSurface.d.ts +1 -1
- package/dist/agents/hooks/useAgentModelLabel.js +4 -3
- package/dist/agents/hooks/useDiffEnrichment.js +3 -5
- package/dist/agents/hooks/useModelControls.d.ts +5 -161
- package/dist/agents/identity/model-catalog.d.ts +37 -0
- package/dist/agents/identity/model-catalog.js +105 -0
- package/dist/agents/redux/agent-definition/selectors.d.ts +237 -237
- package/dist/agents/redux/agent-definition/thunks.d.ts +1 -1
- package/dist/agents/redux/agent-settings/agentSettingsSlice.d.ts +1 -1
- package/dist/agents/redux/agent-settings/agentSettingsSlice.js +4 -6
- package/dist/agents/redux/agent-settings/selectors.d.ts +13 -152
- package/dist/agents/redux/agent-settings/selectors.js +0 -39
- package/dist/agents/redux/agent-settings/useNormalizedControls.d.ts +8 -0
- package/dist/agents/redux/agent-settings/useNormalizedControls.js +24 -0
- package/dist/agents/redux/agent-shortcut-categories/selectors.d.ts +50 -50
- package/dist/agents/redux/agent-shortcuts/selectors.d.ts +147 -147
- package/dist/agents/redux/conversation-history/selectors.d.ts +16 -16
- package/dist/agents/redux/conversation-list/conversation-list.selectors.d.ts +2 -2
- package/dist/agents/redux/execution-system/active-requests/active-requests.selectors.d.ts +54 -54
- package/dist/agents/redux/execution-system/context-state/context-state.selectors.d.ts +14 -14
- package/dist/agents/redux/execution-system/conversations/conversations.selectors.d.ts +5 -5
- package/dist/agents/redux/execution-system/host-conversations/conversation-abilities.d.ts +12 -0
- package/dist/agents/redux/execution-system/host-conversations/conversation-abilities.js +25 -0
- package/dist/agents/redux/execution-system/host-conversations/host-conversation.thunks.d.ts +50 -0
- package/dist/agents/redux/execution-system/host-conversations/host-conversation.thunks.js +367 -0
- package/dist/agents/redux/execution-system/host-conversations/host-conversations.selectors.d.ts +28 -0
- package/dist/agents/redux/execution-system/host-conversations/host-conversations.selectors.js +41 -0
- package/dist/agents/redux/execution-system/host-conversations/host-conversations.slice.d.ts +43 -0
- package/dist/agents/redux/execution-system/host-conversations/host-conversations.slice.js +38 -0
- package/dist/agents/redux/execution-system/host-conversations/source-registry.d.ts +9 -0
- package/dist/agents/redux/execution-system/host-conversations/source-registry.js +15 -0
- package/dist/agents/redux/execution-system/host-conversations/useHostConversation.d.ts +4 -0
- package/dist/agents/redux/execution-system/host-conversations/useHostConversation.js +24 -0
- package/dist/agents/redux/execution-system/instance-context/instance-context.selectors.d.ts +3 -3
- package/dist/agents/redux/execution-system/instance-resources/default-remark-durability.d.ts +22 -0
- package/dist/agents/redux/execution-system/instance-resources/default-remark-durability.js +164 -0
- package/dist/agents/redux/execution-system/instance-resources/instance-resources.selectors.d.ts +8 -8
- package/dist/agents/redux/execution-system/instance-ui-state/instance-ui-state.selectors.d.ts +5 -5
- package/dist/agents/redux/execution-system/instance-user-input/composer-draft-store.js +20 -0
- package/dist/agents/redux/execution-system/instance-user-input/useComposerDraftRestore.js +2 -1
- package/dist/agents/redux/execution-system/instance-variable-values/instance-variable-values.selectors.d.ts +7 -7
- package/dist/agents/redux/execution-system/messages/messages.selectors.d.ts +1 -1
- package/dist/agents/redux/execution-system/observability/observability.selectors.d.ts +7 -7
- package/dist/agents/redux/execution-system/observational-memory/observational-memory.selectors.d.ts +1 -1
- package/dist/agents/redux/execution-system/selectors/aggregate.selectors.d.ts +14 -14
- package/dist/agents/redux/execution-system/thunks/execute-instance.thunk.js +2 -1
- package/dist/agents/redux/execution-system/thunks/execute-manual-instance.thunk.js +4 -3
- package/dist/agents/redux/execution-system/thunks/load-conversation.thunk.js +6 -0
- package/dist/agents/redux/execution-system/thunks/load-older-messages.thunk.js +12 -0
- package/dist/agents/redux/execution-system/thunks/process-stream.js +5 -3
- package/dist/agents/redux/execution-system/thunks/resolve-base-url.js +1 -1
- package/dist/agents/redux/execution-system/thunks/smart-execute.thunk.js +43 -0
- package/dist/agents/redux/execution-system/utils/continuation-body.d.ts +1 -0
- package/dist/agents/redux/execution-system/utils/continuation-body.js +2 -1
- package/dist/agents/redux/model-registry.d.ts +6 -4
- package/dist/agents/redux/model-registry.js +23 -5
- package/dist/agents/redux/proposed-directives/proposedDirectivesSlice.d.ts +1 -1
- package/dist/agents/redux/tools/tools.selectors.d.ts +1 -1
- package/dist/agents/resources/default-picker-items.d.ts +17 -0
- package/dist/agents/resources/default-picker-items.js +48 -0
- package/dist/agents/runtime/generation-job.js +4 -7
- package/dist/agents/runtime/get-model-capabilities.js +3 -3
- package/dist/agents/types/instance.types.d.ts +2 -1
- package/dist/agents/ui-first-tools/redux/agent-lists.selectors.d.ts +2 -2
- package/dist/cx-chat/components/SsrSidebarChats.js +1 -1
- package/dist/cx-chat/components/sidebar/SidebarUserFooter.js +1 -1
- package/dist/host/app-identity.d.ts +20 -0
- package/dist/host/app-identity.js +21 -0
- package/dist/host/bare-host-chrome.d.ts +14 -0
- package/dist/host/bare-host-chrome.js +44 -0
- package/dist/host/configure.d.ts +9 -1
- package/dist/host/configure.js +44 -8
- package/dist/host/content-ir-slots.d.ts +5 -1
- package/dist/host/content-ir-slots.js +5 -1
- package/dist/host/contract.d.ts +39 -2
- package/dist/host/db-types.d.ts +375 -10
- package/dist/host/defaults/navigation-hooks.d.ts +2 -0
- package/dist/host/defaults/navigation-hooks.js +7 -1
- package/dist/host/defaults/navigation.d.ts +4 -3
- package/dist/host/defaults/navigation.js +38 -7
- package/dist/host/defaults/org.d.ts +12 -4
- package/dist/host/defaults/org.js +39 -1
- package/dist/host/defaults/workspace-gate.d.ts +16 -0
- package/dist/host/defaults/workspace-gate.js +88 -0
- package/dist/host/diagnostics.d.ts +7 -2
- package/dist/host/diagnostics.js +6 -0
- package/dist/host/identity.js +2 -1
- package/dist/host/index.d.ts +5 -2
- package/dist/host/index.js +21 -1
- package/dist/host/no-database.d.ts +38 -0
- package/dist/host/no-database.js +107 -0
- package/dist/host/react.d.ts +1 -0
- package/dist/host/react.js +25 -2
- package/dist/host/registered-source.js +2 -2
- package/dist/host/source.d.ts +109 -0
- package/dist/host/source.js +86 -0
- package/dist/host/ui-slots.d.ts +8 -8
- package/dist/host/ui-slots.js +5 -3
- package/dist/mandates/useMandate.js +13 -0
- package/dist/public-chat/components/PublicMessageOptionsMenu.js +1 -1
- package/dist/store/create-chat-store.d.ts +4 -4
- package/dist/store/middlewares.d.ts +5 -5
- package/dist/store/slices.d.ts +1 -1
- package/dist/store/slices.js +4 -3
- package/dist/surfaces/redux/selectors.d.ts +2 -2
- package/dist/testing/turn-harness.d.ts +35 -0
- package/dist/testing/turn-harness.js +85 -0
- package/dist/tool-call-visualization/intelligence-places.js +1 -1
- package/dist/tool-call-visualization/redux/selectors.d.ts +1 -1
- package/dist/voice-agent/intelligence-places.js +6 -6
- package/package.json +9 -6
- package/dist/agents/model-registry/modelRegistrySlice.d.ts +0 -691
- package/dist/agents/model-registry/modelRegistrySlice.js +0 -574
- package/dist/host/model-class.d.ts +0 -33
- package/dist/host/model-class.js +0 -21
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Hook to parse and normalize model controls from dynamic API data
|
|
3
3
|
* Keeps snake_case naming for compatibility with Python backend
|
|
4
4
|
*/
|
|
5
|
-
import type { ModelClassControls } from "
|
|
5
|
+
import type { ModelClassControls } from "../identity/model-catalog.js";
|
|
6
6
|
import type { AIModelRecord } from "../redux/model-registry.js";
|
|
7
7
|
export interface ControlDefinition {
|
|
8
8
|
type: "number" | "integer" | "boolean" | "string" | "enum" | "array" | "string_array" | "object_array";
|
|
@@ -160,89 +160,11 @@ export declare function useModelControls(models: AIModelRecord[], selectedModelI
|
|
|
160
160
|
error: string;
|
|
161
161
|
} | {
|
|
162
162
|
normalizedControls: NormalizedControls;
|
|
163
|
-
selectedModel:
|
|
164
|
-
capabilities: import("../../host/db-types.js").Json | null;
|
|
165
|
-
common_name: string | null;
|
|
166
|
-
context_window: number | null;
|
|
167
|
-
cost_rating: number | null;
|
|
168
|
-
created_at: string;
|
|
169
|
-
created_by: string | null;
|
|
170
|
-
deleted_at: string | null;
|
|
171
|
-
description: string | null;
|
|
172
|
-
guest_fallback_id: string | null;
|
|
173
|
-
id: string;
|
|
174
|
-
is_deprecated: boolean | null;
|
|
175
|
-
is_premium: boolean | null;
|
|
176
|
-
is_primary: boolean | null;
|
|
177
|
-
is_system: boolean;
|
|
178
|
-
max_tokens: number | null;
|
|
179
|
-
metadata: import("../../host/db-types.js").Json;
|
|
180
|
-
mid_fallback_id: string | null;
|
|
181
|
-
name: string;
|
|
182
|
-
organization_id: string;
|
|
183
|
-
provider_id: string | null;
|
|
184
|
-
published_to_web: boolean;
|
|
185
|
-
published_to_web_at: string | null;
|
|
186
|
-
published_to_web_by: string | null;
|
|
187
|
-
release_date: string | null;
|
|
188
|
-
retired_at: string | null;
|
|
189
|
-
retry_fallback_id: string | null;
|
|
190
|
-
retry_max_attempts: number;
|
|
191
|
-
shown_to: import("../../host/db-types.js").Database["platform"]["Enums"]["shown_to"] | null;
|
|
192
|
-
speed_rating: number | null;
|
|
193
|
-
successor_id: string | null;
|
|
194
|
-
updated_at: string;
|
|
195
|
-
updated_by: string | null;
|
|
196
|
-
version: number;
|
|
197
|
-
visibility: import("../../host/db-types.js").Database["platform"]["Enums"]["visibility"];
|
|
198
|
-
_fetchType: import("../model-registry/modelRegistrySlice.js").ModelRecordFetchType;
|
|
199
|
-
maker: string | null;
|
|
200
|
-
controls: unknown;
|
|
201
|
-
constraints: unknown;
|
|
202
|
-
};
|
|
163
|
+
selectedModel: AIModelRecord;
|
|
203
164
|
error: null;
|
|
204
165
|
} | {
|
|
205
166
|
normalizedControls: NormalizedControls;
|
|
206
|
-
selectedModel:
|
|
207
|
-
capabilities: import("../../host/db-types.js").Json | null;
|
|
208
|
-
common_name: string | null;
|
|
209
|
-
context_window: number | null;
|
|
210
|
-
cost_rating: number | null;
|
|
211
|
-
created_at: string;
|
|
212
|
-
created_by: string | null;
|
|
213
|
-
deleted_at: string | null;
|
|
214
|
-
description: string | null;
|
|
215
|
-
guest_fallback_id: string | null;
|
|
216
|
-
id: string;
|
|
217
|
-
is_deprecated: boolean | null;
|
|
218
|
-
is_premium: boolean | null;
|
|
219
|
-
is_primary: boolean | null;
|
|
220
|
-
is_system: boolean;
|
|
221
|
-
max_tokens: number | null;
|
|
222
|
-
metadata: import("../../host/db-types.js").Json;
|
|
223
|
-
mid_fallback_id: string | null;
|
|
224
|
-
name: string;
|
|
225
|
-
organization_id: string;
|
|
226
|
-
provider_id: string | null;
|
|
227
|
-
published_to_web: boolean;
|
|
228
|
-
published_to_web_at: string | null;
|
|
229
|
-
published_to_web_by: string | null;
|
|
230
|
-
release_date: string | null;
|
|
231
|
-
retired_at: string | null;
|
|
232
|
-
retry_fallback_id: string | null;
|
|
233
|
-
retry_max_attempts: number;
|
|
234
|
-
shown_to: import("../../host/db-types.js").Database["platform"]["Enums"]["shown_to"] | null;
|
|
235
|
-
speed_rating: number | null;
|
|
236
|
-
successor_id: string | null;
|
|
237
|
-
updated_at: string;
|
|
238
|
-
updated_by: string | null;
|
|
239
|
-
version: number;
|
|
240
|
-
visibility: import("../../host/db-types.js").Database["platform"]["Enums"]["visibility"];
|
|
241
|
-
_fetchType: import("../model-registry/modelRegistrySlice.js").ModelRecordFetchType;
|
|
242
|
-
maker: string | null;
|
|
243
|
-
controls: unknown;
|
|
244
|
-
constraints: unknown;
|
|
245
|
-
};
|
|
167
|
+
selectedModel: AIModelRecord;
|
|
246
168
|
error: string;
|
|
247
169
|
};
|
|
248
170
|
/**
|
|
@@ -265,89 +187,11 @@ export declare function resolveModelControls(models: AIModelRecord[], selectedMo
|
|
|
265
187
|
error: string;
|
|
266
188
|
} | {
|
|
267
189
|
normalizedControls: NormalizedControls;
|
|
268
|
-
selectedModel:
|
|
269
|
-
capabilities: import("../../host/db-types.js").Json | null;
|
|
270
|
-
common_name: string | null;
|
|
271
|
-
context_window: number | null;
|
|
272
|
-
cost_rating: number | null;
|
|
273
|
-
created_at: string;
|
|
274
|
-
created_by: string | null;
|
|
275
|
-
deleted_at: string | null;
|
|
276
|
-
description: string | null;
|
|
277
|
-
guest_fallback_id: string | null;
|
|
278
|
-
id: string;
|
|
279
|
-
is_deprecated: boolean | null;
|
|
280
|
-
is_premium: boolean | null;
|
|
281
|
-
is_primary: boolean | null;
|
|
282
|
-
is_system: boolean;
|
|
283
|
-
max_tokens: number | null;
|
|
284
|
-
metadata: import("../../host/db-types.js").Json;
|
|
285
|
-
mid_fallback_id: string | null;
|
|
286
|
-
name: string;
|
|
287
|
-
organization_id: string;
|
|
288
|
-
provider_id: string | null;
|
|
289
|
-
published_to_web: boolean;
|
|
290
|
-
published_to_web_at: string | null;
|
|
291
|
-
published_to_web_by: string | null;
|
|
292
|
-
release_date: string | null;
|
|
293
|
-
retired_at: string | null;
|
|
294
|
-
retry_fallback_id: string | null;
|
|
295
|
-
retry_max_attempts: number;
|
|
296
|
-
shown_to: import("../../host/db-types.js").Database["platform"]["Enums"]["shown_to"] | null;
|
|
297
|
-
speed_rating: number | null;
|
|
298
|
-
successor_id: string | null;
|
|
299
|
-
updated_at: string;
|
|
300
|
-
updated_by: string | null;
|
|
301
|
-
version: number;
|
|
302
|
-
visibility: import("../../host/db-types.js").Database["platform"]["Enums"]["visibility"];
|
|
303
|
-
_fetchType: import("../model-registry/modelRegistrySlice.js").ModelRecordFetchType;
|
|
304
|
-
maker: string | null;
|
|
305
|
-
controls: unknown;
|
|
306
|
-
constraints: unknown;
|
|
307
|
-
};
|
|
190
|
+
selectedModel: AIModelRecord;
|
|
308
191
|
error: null;
|
|
309
192
|
} | {
|
|
310
193
|
normalizedControls: NormalizedControls;
|
|
311
|
-
selectedModel:
|
|
312
|
-
capabilities: import("../../host/db-types.js").Json | null;
|
|
313
|
-
common_name: string | null;
|
|
314
|
-
context_window: number | null;
|
|
315
|
-
cost_rating: number | null;
|
|
316
|
-
created_at: string;
|
|
317
|
-
created_by: string | null;
|
|
318
|
-
deleted_at: string | null;
|
|
319
|
-
description: string | null;
|
|
320
|
-
guest_fallback_id: string | null;
|
|
321
|
-
id: string;
|
|
322
|
-
is_deprecated: boolean | null;
|
|
323
|
-
is_premium: boolean | null;
|
|
324
|
-
is_primary: boolean | null;
|
|
325
|
-
is_system: boolean;
|
|
326
|
-
max_tokens: number | null;
|
|
327
|
-
metadata: import("../../host/db-types.js").Json;
|
|
328
|
-
mid_fallback_id: string | null;
|
|
329
|
-
name: string;
|
|
330
|
-
organization_id: string;
|
|
331
|
-
provider_id: string | null;
|
|
332
|
-
published_to_web: boolean;
|
|
333
|
-
published_to_web_at: string | null;
|
|
334
|
-
published_to_web_by: string | null;
|
|
335
|
-
release_date: string | null;
|
|
336
|
-
retired_at: string | null;
|
|
337
|
-
retry_fallback_id: string | null;
|
|
338
|
-
retry_max_attempts: number;
|
|
339
|
-
shown_to: import("../../host/db-types.js").Database["platform"]["Enums"]["shown_to"] | null;
|
|
340
|
-
speed_rating: number | null;
|
|
341
|
-
successor_id: string | null;
|
|
342
|
-
updated_at: string;
|
|
343
|
-
updated_by: string | null;
|
|
344
|
-
version: number;
|
|
345
|
-
visibility: import("../../host/db-types.js").Database["platform"]["Enums"]["visibility"];
|
|
346
|
-
_fetchType: import("../model-registry/modelRegistrySlice.js").ModelRecordFetchType;
|
|
347
|
-
maker: string | null;
|
|
348
|
-
controls: unknown;
|
|
349
|
-
constraints: unknown;
|
|
350
|
-
};
|
|
194
|
+
selectedModel: AIModelRecord;
|
|
351
195
|
error: string;
|
|
352
196
|
};
|
|
353
197
|
/**
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type ModelCatalog, type ModelClassConfig, type ModelRecord, type ModelRecords, type ModelRecordsState } from "@ai-matrx/agents/models";
|
|
2
|
+
export declare function getModelCatalog(): ModelCatalog;
|
|
3
|
+
export declare const getModelRecords: () => ModelRecords;
|
|
4
|
+
/** The records state now. A host with no database bound yet (a unit test) reads empty. */
|
|
5
|
+
export declare function readModelRecords(): ModelRecordsState;
|
|
6
|
+
/** Subscribe to a slice of the records. `select` must return a stable value for unchanged state. */
|
|
7
|
+
export declare function useModelRecords<T>(select: (state: ModelRecordsState) => T): T;
|
|
8
|
+
/** One model's record (options or full); reads the full record when `full` and it is missing. */
|
|
9
|
+
export declare function useModelRecord(modelId: string | null | undefined, options?: {
|
|
10
|
+
full?: boolean;
|
|
11
|
+
}): ModelRecord | undefined;
|
|
12
|
+
/** A model's display label; loads the options list (then the identity) when it is unknown. */
|
|
13
|
+
export declare function useModelLabel(modelId: string | null | undefined): string | undefined;
|
|
14
|
+
/** "Qwen3.8 27B · Matrx Lightning" when the model has several classes; loads the class index once. */
|
|
15
|
+
export declare function useModelLabelWithClass(modelId: string | null | undefined, offeringId: string | null | undefined): string | undefined;
|
|
16
|
+
/** Loads every model's classes once (no-op after the first success). */
|
|
17
|
+
export declare function useModelClassLabels(): void;
|
|
18
|
+
/**
|
|
19
|
+
* The resolved controls for the CLASS a model runs on. With a pin it loads that class's controls;
|
|
20
|
+
* without one it answers `undefined` and callers keep the model's own (preferred-class) controls.
|
|
21
|
+
* `{ pending: true }` while it loads, `{ failed: true }` when the pin is refused — never another
|
|
22
|
+
* class's controls.
|
|
23
|
+
*/
|
|
24
|
+
export type ModelClassControls = undefined | {
|
|
25
|
+
pending: true;
|
|
26
|
+
failed?: false;
|
|
27
|
+
config?: undefined;
|
|
28
|
+
} | {
|
|
29
|
+
pending?: false;
|
|
30
|
+
failed: true;
|
|
31
|
+
config?: undefined;
|
|
32
|
+
} | {
|
|
33
|
+
pending?: false;
|
|
34
|
+
failed?: false;
|
|
35
|
+
config: ModelClassConfig;
|
|
36
|
+
};
|
|
37
|
+
export declare function useModelClassControls(modelId: string | null | undefined, offeringId: string | null | undefined): ModelClassControls;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
import {
|
|
4
|
+
classConfigKey,
|
|
5
|
+
createModelCatalog,
|
|
6
|
+
EMPTY_MODEL_RECORDS,
|
|
7
|
+
selectModelById,
|
|
8
|
+
selectModelLabelById,
|
|
9
|
+
selectModelLabelWithClass
|
|
10
|
+
} from "@ai-matrx/agents/models";
|
|
11
|
+
import { useModelRecordsSelector } from "@ai-matrx/agents/models/react";
|
|
12
|
+
import { supabase } from "../../host/db.js";
|
|
13
|
+
import { captureError } from "../../host/diagnostics.js";
|
|
14
|
+
import { isSignedOutVisitor } from "../../host/identity.js";
|
|
15
|
+
import { chatHostHasDatabase } from "../../host/configure.js";
|
|
16
|
+
const KEY = /* @__PURE__ */ Symbol.for("ai-matrx.chat.model-catalog");
|
|
17
|
+
function getModelCatalog() {
|
|
18
|
+
const g = globalThis;
|
|
19
|
+
if (g[KEY]) return g[KEY];
|
|
20
|
+
const catalog = createModelCatalog({
|
|
21
|
+
// supabase-js satisfies the catalog's structural client as-is.
|
|
22
|
+
client: supabase,
|
|
23
|
+
// A host with no database has no catalog to read (host/source): nobody is signed in.
|
|
24
|
+
isSignedIn: async () => chatHostHasDatabase() && !await isSignedOutVisitor(),
|
|
25
|
+
errorSink: (event) => {
|
|
26
|
+
captureError({
|
|
27
|
+
source: "supabase-postgrest",
|
|
28
|
+
schema: "ai",
|
|
29
|
+
code: event.code,
|
|
30
|
+
message: event.message,
|
|
31
|
+
...event.context ? { details: JSON.stringify(event.context) } : {}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
g[KEY] = catalog;
|
|
36
|
+
return catalog;
|
|
37
|
+
}
|
|
38
|
+
const getModelRecords = () => getModelCatalog().records;
|
|
39
|
+
function readModelRecords() {
|
|
40
|
+
try {
|
|
41
|
+
return getModelRecords().getState();
|
|
42
|
+
} catch {
|
|
43
|
+
return EMPTY_MODEL_RECORDS;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function useModelRecords(select) {
|
|
47
|
+
return useModelRecordsSelector(getModelRecords(), select);
|
|
48
|
+
}
|
|
49
|
+
function useModelRecord(modelId, options) {
|
|
50
|
+
const record = useModelRecords((s) => selectModelById(s, modelId));
|
|
51
|
+
const full = options?.full === true;
|
|
52
|
+
const fetchType = record?._fetchType;
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (!modelId) return;
|
|
55
|
+
if (full && fetchType !== "full") void getModelRecords().loadModel(modelId);
|
|
56
|
+
else if (!fetchType) void getModelRecords().loadOptions();
|
|
57
|
+
}, [modelId, full, fetchType]);
|
|
58
|
+
return record;
|
|
59
|
+
}
|
|
60
|
+
function useModelLabel(modelId) {
|
|
61
|
+
const label = useModelRecords((s) => selectModelLabelById(s, modelId));
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
if (!modelId || label) return;
|
|
64
|
+
const records = getModelRecords();
|
|
65
|
+
void records.loadOptions().then(() => {
|
|
66
|
+
if (!selectModelLabelById(records.getState(), modelId)) void records.loadIdentity(modelId);
|
|
67
|
+
});
|
|
68
|
+
}, [modelId, label]);
|
|
69
|
+
return label;
|
|
70
|
+
}
|
|
71
|
+
function useModelLabelWithClass(modelId, offeringId) {
|
|
72
|
+
useModelLabel(modelId);
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (chatHostHasDatabase()) void getModelRecords().loadClasses();
|
|
75
|
+
}, []);
|
|
76
|
+
return useModelRecords((s) => selectModelLabelWithClass(s, modelId, offeringId));
|
|
77
|
+
}
|
|
78
|
+
function useModelClassLabels() {
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
if (chatHostHasDatabase()) void getModelRecords().loadClasses();
|
|
81
|
+
}, []);
|
|
82
|
+
}
|
|
83
|
+
function useModelClassControls(modelId, offeringId) {
|
|
84
|
+
const key = modelId && offeringId ? classConfigKey(modelId, offeringId) : null;
|
|
85
|
+
const config = useModelRecords((s) => key ? s.classConfigByOffering[key] : void 0);
|
|
86
|
+
const status = useModelRecords((s) => key ? s.classConfigStatusByOffering[key] : void 0);
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
if (modelId && offeringId) void getModelRecords().loadClassConfig(modelId, offeringId);
|
|
89
|
+
}, [modelId, offeringId]);
|
|
90
|
+
if (!modelId || !offeringId) return void 0;
|
|
91
|
+
if (config) return { config };
|
|
92
|
+
if (status === "failed") return { failed: true };
|
|
93
|
+
return { pending: true };
|
|
94
|
+
}
|
|
95
|
+
export {
|
|
96
|
+
getModelCatalog,
|
|
97
|
+
getModelRecords,
|
|
98
|
+
readModelRecords,
|
|
99
|
+
useModelClassControls,
|
|
100
|
+
useModelClassLabels,
|
|
101
|
+
useModelLabel,
|
|
102
|
+
useModelLabelWithClass,
|
|
103
|
+
useModelRecord,
|
|
104
|
+
useModelRecords
|
|
105
|
+
};
|