@dolfinhos/studio 0.2.0 → 0.3.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.
package/dist/index.d.cts CHANGED
@@ -154,6 +154,30 @@ interface ProviderCredential {
154
154
  updatedAt?: string;
155
155
  updatedBy?: string;
156
156
  }
157
+ /** O que a empresa usa de IA: papéis, provedores, a escolha dela e o que está valendo. */
158
+ interface ModelsOverview {
159
+ roles: Array<{
160
+ name: string;
161
+ label: string;
162
+ description?: string;
163
+ }>;
164
+ providers: Array<{
165
+ name: string;
166
+ label: string;
167
+ description?: string;
168
+ configured: boolean;
169
+ defaults?: Record<string, string>;
170
+ }>;
171
+ chosen: {
172
+ provider: string;
173
+ models: Record<string, string>;
174
+ } | null;
175
+ active: {
176
+ provider: string;
177
+ models: Record<string, string>;
178
+ source: 'empresa' | 'plataforma';
179
+ } | null;
180
+ }
157
181
  declare class StudioError extends Error {
158
182
  readonly status: number;
159
183
  constructor(message: string, status: number);
@@ -206,6 +230,21 @@ declare function createStudioClient(options?: StudioClientOptions): {
206
230
  removeCredential: (name: string) => Promise<{
207
231
  ok: true;
208
232
  }>;
233
+ models: () => Promise<ModelsOverview>;
234
+ availableModels: (provider: string) => Promise<{
235
+ id: string;
236
+ label?: string;
237
+ }[]>;
238
+ chooseModels: (choice: {
239
+ provider: string;
240
+ models: Record<string, string>;
241
+ }) => Promise<{
242
+ provider: string;
243
+ models: Record<string, string>;
244
+ }>;
245
+ resetModels: () => Promise<{
246
+ ok: true;
247
+ }>;
209
248
  };
210
249
  type StudioClient = ReturnType<typeof createStudioClient>;
211
250
  interface StudioLabels {
@@ -271,6 +310,11 @@ declare function BehaviorSettings({ currency }: {
271
310
 
272
311
  /** As chaves de API que esta empresa usa nos provedores de IA. Cada empresa paga o próprio uso. */
273
312
  declare function ProviderKeys(): react.JSX.Element;
313
+ /**
314
+ * O modelo de IA da empresa: a chave de cada provedor (DeepSeek, Claude,
315
+ * ChatGPT…), qual deles está em uso e o modelo de cada papel.
316
+ */
317
+ declare function ModelSettings(): react.JSX.Element;
274
318
 
275
319
  /** Documentos que o assistente e o bot consultam: perguntas frequentes, políticas, explicações. */
276
320
  declare function KnowledgeBase(): react.JSX.Element;
@@ -317,5 +361,5 @@ interface StudioProviderProps extends StudioClientOptions {
317
361
  */
318
362
  declare function StudioProvider({ children, endpoint, headers, fetch, labels, locale, navigate }: StudioProviderProps): react.JSX.Element;
319
363
 
320
- export { ApprovalsInbox, AuditLog, AutomationsEditor, BehaviorSettings, DolfinhosStudio, KnowledgeBase, MemoryBrowser, MyMemory, ProviderKeys, StudioContextProvider, StudioError, StudioProvider, UsageReport, createStudioClient, useResource, useStudio };
321
- export type { Actor, ApprovalItem, ApprovalsInboxProps, Audience, AuditRecord, Automation, Capability, DolfinhosStudioProps, EventInfo, Fact, FactSubject, Kind, KnowledgeDoc, KnowledgeHit, Mode, PendingApproval, ProviderCredential, Risk, Rule, Settings, StudioClient, StudioClientOptions, StudioLabels, StudioProviderProps, StudioSection, UsageSummary, UsageTotals };
364
+ export { ApprovalsInbox, AuditLog, AutomationsEditor, BehaviorSettings, DolfinhosStudio, KnowledgeBase, MemoryBrowser, ModelSettings, MyMemory, ProviderKeys, StudioContextProvider, StudioError, StudioProvider, UsageReport, createStudioClient, useResource, useStudio };
365
+ export type { Actor, ApprovalItem, ApprovalsInboxProps, Audience, AuditRecord, Automation, Capability, DolfinhosStudioProps, EventInfo, Fact, FactSubject, Kind, KnowledgeDoc, KnowledgeHit, Mode, ModelsOverview, PendingApproval, ProviderCredential, Risk, Rule, Settings, StudioClient, StudioClientOptions, StudioLabels, StudioProviderProps, StudioSection, UsageSummary, UsageTotals };
package/dist/index.d.ts CHANGED
@@ -154,6 +154,30 @@ interface ProviderCredential {
154
154
  updatedAt?: string;
155
155
  updatedBy?: string;
156
156
  }
157
+ /** O que a empresa usa de IA: papéis, provedores, a escolha dela e o que está valendo. */
158
+ interface ModelsOverview {
159
+ roles: Array<{
160
+ name: string;
161
+ label: string;
162
+ description?: string;
163
+ }>;
164
+ providers: Array<{
165
+ name: string;
166
+ label: string;
167
+ description?: string;
168
+ configured: boolean;
169
+ defaults?: Record<string, string>;
170
+ }>;
171
+ chosen: {
172
+ provider: string;
173
+ models: Record<string, string>;
174
+ } | null;
175
+ active: {
176
+ provider: string;
177
+ models: Record<string, string>;
178
+ source: 'empresa' | 'plataforma';
179
+ } | null;
180
+ }
157
181
  declare class StudioError extends Error {
158
182
  readonly status: number;
159
183
  constructor(message: string, status: number);
@@ -206,6 +230,21 @@ declare function createStudioClient(options?: StudioClientOptions): {
206
230
  removeCredential: (name: string) => Promise<{
207
231
  ok: true;
208
232
  }>;
233
+ models: () => Promise<ModelsOverview>;
234
+ availableModels: (provider: string) => Promise<{
235
+ id: string;
236
+ label?: string;
237
+ }[]>;
238
+ chooseModels: (choice: {
239
+ provider: string;
240
+ models: Record<string, string>;
241
+ }) => Promise<{
242
+ provider: string;
243
+ models: Record<string, string>;
244
+ }>;
245
+ resetModels: () => Promise<{
246
+ ok: true;
247
+ }>;
209
248
  };
210
249
  type StudioClient = ReturnType<typeof createStudioClient>;
211
250
  interface StudioLabels {
@@ -271,6 +310,11 @@ declare function BehaviorSettings({ currency }: {
271
310
 
272
311
  /** As chaves de API que esta empresa usa nos provedores de IA. Cada empresa paga o próprio uso. */
273
312
  declare function ProviderKeys(): react.JSX.Element;
313
+ /**
314
+ * O modelo de IA da empresa: a chave de cada provedor (DeepSeek, Claude,
315
+ * ChatGPT…), qual deles está em uso e o modelo de cada papel.
316
+ */
317
+ declare function ModelSettings(): react.JSX.Element;
274
318
 
275
319
  /** Documentos que o assistente e o bot consultam: perguntas frequentes, políticas, explicações. */
276
320
  declare function KnowledgeBase(): react.JSX.Element;
@@ -317,5 +361,5 @@ interface StudioProviderProps extends StudioClientOptions {
317
361
  */
318
362
  declare function StudioProvider({ children, endpoint, headers, fetch, labels, locale, navigate }: StudioProviderProps): react.JSX.Element;
319
363
 
320
- export { ApprovalsInbox, AuditLog, AutomationsEditor, BehaviorSettings, DolfinhosStudio, KnowledgeBase, MemoryBrowser, MyMemory, ProviderKeys, StudioContextProvider, StudioError, StudioProvider, UsageReport, createStudioClient, useResource, useStudio };
321
- export type { Actor, ApprovalItem, ApprovalsInboxProps, Audience, AuditRecord, Automation, Capability, DolfinhosStudioProps, EventInfo, Fact, FactSubject, Kind, KnowledgeDoc, KnowledgeHit, Mode, PendingApproval, ProviderCredential, Risk, Rule, Settings, StudioClient, StudioClientOptions, StudioLabels, StudioProviderProps, StudioSection, UsageSummary, UsageTotals };
364
+ export { ApprovalsInbox, AuditLog, AutomationsEditor, BehaviorSettings, DolfinhosStudio, KnowledgeBase, MemoryBrowser, ModelSettings, MyMemory, ProviderKeys, StudioContextProvider, StudioError, StudioProvider, UsageReport, createStudioClient, useResource, useStudio };
365
+ export type { Actor, ApprovalItem, ApprovalsInboxProps, Audience, AuditRecord, Automation, Capability, DolfinhosStudioProps, EventInfo, Fact, FactSubject, Kind, KnowledgeDoc, KnowledgeHit, Mode, ModelsOverview, PendingApproval, ProviderCredential, Risk, Rule, Settings, StudioClient, StudioClientOptions, StudioLabels, StudioProviderProps, StudioSection, UsageSummary, UsageTotals };
package/dist/index.js CHANGED
@@ -66,7 +66,11 @@ function createStudioClient(options = {}) {
66
66
  forget: (id) => request("DELETE", `/facts/${encodeURIComponent(id)}`),
67
67
  credentials: () => request("GET", "/credentials"),
68
68
  saveCredential: (name, value) => request("PUT", `/credentials/${encodeURIComponent(name)}`, { value }),
69
- removeCredential: (name) => request("DELETE", `/credentials/${encodeURIComponent(name)}`)
69
+ removeCredential: (name) => request("DELETE", `/credentials/${encodeURIComponent(name)}`),
70
+ models: () => request("GET", "/models"),
71
+ availableModels: (provider) => request("GET", `/models/${encodeURIComponent(provider)}/available`),
72
+ chooseModels: (choice) => request("PUT", "/models", choice),
73
+ resetModels: () => request("DELETE", "/models")
70
74
  };
71
75
  }
72
76
  var StudioContext = createContext(null);
@@ -683,8 +687,14 @@ function BehaviorSettings({ currency }) {
683
687
 
684
688
  // src/Keys.tsx
685
689
  import { useId as useId4, useState as useState6 } from "react";
690
+ import { useEffect as useEffect6 } from "react";
686
691
  import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
687
- function ProviderKey({ provider, onChanged }) {
692
+ function ProviderKey({
693
+ provider,
694
+ onChanged,
695
+ children,
696
+ compact
697
+ }) {
688
698
  const { client, locale } = useStudio();
689
699
  const id = useId4();
690
700
  const [editing, setEditing] = useState6(!provider.configured);
@@ -698,10 +708,13 @@ function ProviderKey({ provider, onChanged }) {
698
708
  await client.saveCredential(provider.name, value.trim());
699
709
  setValue("");
700
710
  setEditing(false);
701
- setMessage({ tone: "success", text: "Chave testada e salva. A partir de agora o uso de IA desta empresa vai para esta conta." });
702
- await onChanged();
711
+ setMessage({ tone: "success", text: "Chave testada e salva." });
712
+ await onChanged("saved");
703
713
  } catch (e) {
704
- setMessage({ tone: "error", text: e instanceof Error ? e.message : String(e) });
714
+ setMessage({
715
+ tone: "error",
716
+ text: e instanceof Error ? e.message : String(e)
717
+ });
705
718
  } finally {
706
719
  setBusy(null);
707
720
  }
@@ -714,9 +727,12 @@ function ProviderKey({ provider, onChanged }) {
714
727
  await client.removeCredential(provider.name);
715
728
  setEditing(true);
716
729
  setMessage({ tone: "success", text: "Chave removida." });
717
- await onChanged();
730
+ await onChanged("removed");
718
731
  } catch (e) {
719
- setMessage({ tone: "error", text: e instanceof Error ? e.message : String(e) });
732
+ setMessage({
733
+ tone: "error",
734
+ text: e instanceof Error ? e.message : String(e)
735
+ });
720
736
  } finally {
721
737
  setBusy(null);
722
738
  }
@@ -726,17 +742,18 @@ function ProviderKey({ provider, onChanged }) {
726
742
  /* @__PURE__ */ jsxs6("div", { style: { minWidth: 0 }, children: [
727
743
  /* @__PURE__ */ jsx6("p", { className: "dlf-item-title", children: provider.label }),
728
744
  provider.configured && provider.updatedAt ? /* @__PURE__ */ jsxs6("p", { className: "dlf-item-meta", children: [
729
- "Chave terminada em ",
745
+ "Chave terminada em",
746
+ " ",
730
747
  /* @__PURE__ */ jsxs6("span", { translate: "no", style: { fontVariantNumeric: "tabular-nums" }, children: [
731
748
  "\u2026",
732
749
  provider.last4
733
750
  ] }),
734
- " \xB7 salva em",
735
751
  " ",
752
+ "\xB7 salva em ",
736
753
  /* @__PURE__ */ jsx6("time", { dateTime: provider.updatedAt, children: formatDateTime(provider.updatedAt, locale) })
737
754
  ] }) : /* @__PURE__ */ jsxs6(Fragment2, { children: [
738
755
  provider.description && /* @__PURE__ */ jsx6("p", { className: "dlf-item-meta", children: provider.description }),
739
- provider.whenMissing && /* @__PURE__ */ jsx6("p", { className: "dlf-item-meta", children: provider.whenMissing })
756
+ provider.whenMissing && !compact && /* @__PURE__ */ jsx6("p", { className: "dlf-item-meta", children: provider.whenMissing })
740
757
  ] })
741
758
  ] }),
742
759
  /* @__PURE__ */ jsxs6("div", { className: "dlf-actions", children: [
@@ -758,37 +775,213 @@ function ProviderKey({ provider, onChanged }) {
758
775
  void save();
759
776
  },
760
777
  children: [
761
- /* @__PURE__ */ jsx6(Field, { label: provider.configured ? "Nova chave" : "Chave de API", htmlFor: `${id}-chave`, hint: "A chave \xE9 testada no provedor antes de salvar e fica criptografada. Ningu\xE9m consegue v\xEA-la depois, nem aqui.", children: /* @__PURE__ */ jsx6(
762
- "input",
778
+ /* @__PURE__ */ jsx6(
779
+ Field,
763
780
  {
764
- id: `${id}-chave`,
765
- className: "dlf-input",
766
- type: "password",
767
- autoComplete: "off",
768
- spellCheck: false,
769
- maxLength: 500,
770
- placeholder: "sk-\u2026",
771
- value,
772
- onChange: (e) => setValue(e.target.value)
781
+ label: provider.configured ? "Nova chave" : "Chave de API",
782
+ htmlFor: `${id}-chave`,
783
+ hint: "A chave \xE9 testada no provedor antes de salvar e fica criptografada. Ningu\xE9m consegue v\xEA-la depois, nem aqui.",
784
+ children: /* @__PURE__ */ jsx6(
785
+ "input",
786
+ {
787
+ id: `${id}-chave`,
788
+ className: "dlf-input",
789
+ type: "password",
790
+ autoComplete: "off",
791
+ spellCheck: false,
792
+ maxLength: 500,
793
+ placeholder: "sk-\u2026",
794
+ value,
795
+ onChange: (e) => setValue(e.target.value)
796
+ }
797
+ )
773
798
  }
774
- ) }),
799
+ ),
775
800
  /* @__PURE__ */ jsxs6("div", { className: "dlf-actions", children: [
776
801
  /* @__PURE__ */ jsx6(Button, { type: "submit", variant: "primary", loading: busy === "save", disabled: value.trim().length < 8, children: "Testar e salvar" }),
777
802
  provider.configured && /* @__PURE__ */ jsx6(Button, { variant: "ghost", onClick: () => setEditing(false), children: "Cancelar" })
778
803
  ] })
779
804
  ]
780
805
  }
781
- )
806
+ ),
807
+ children
782
808
  ] });
783
809
  }
784
810
  function ProviderKeys() {
785
811
  const { client } = useStudio();
786
812
  const list = useResource(() => client.credentials(), [client]);
787
- return /* @__PURE__ */ jsxs6(Section, { title: "Chave de IA", description: "A conta do provedor de IA que esta empresa usa. O gasto do assistente, do bot e das automa\xE7\xF5es vai para ela, e a aba Custos mostra quanto.", children: [
788
- list.error && /* @__PURE__ */ jsx6(Notice, { tone: "error", children: list.error }),
789
- list.loading && !list.data && /* @__PURE__ */ jsx6(Loading, {}),
790
- list.data && !list.data.length && /* @__PURE__ */ jsx6(Empty, { title: "A aplica\xE7\xE3o n\xE3o usa chaves por empresa" }),
791
- !!list.data?.length && /* @__PURE__ */ jsx6("ul", { className: "dlf-list", children: list.data.map((p) => /* @__PURE__ */ jsx6(ProviderKey, { provider: p, onChanged: list.reload }, p.name)) })
813
+ return /* @__PURE__ */ jsxs6(
814
+ Section,
815
+ {
816
+ title: "Chave de IA",
817
+ description: "A conta do provedor de IA que esta empresa usa. O gasto do assistente, do bot e das automa\xE7\xF5es vai para ela, e a aba Custos mostra quanto.",
818
+ children: [
819
+ list.error && /* @__PURE__ */ jsx6(Notice, { tone: "error", children: list.error }),
820
+ list.loading && !list.data && /* @__PURE__ */ jsx6(Loading, {}),
821
+ list.data && !list.data.length && /* @__PURE__ */ jsx6(Empty, { title: "A aplica\xE7\xE3o n\xE3o usa chaves por empresa" }),
822
+ !!list.data?.length && /* @__PURE__ */ jsx6("ul", { className: "dlf-list", children: list.data.map((p) => /* @__PURE__ */ jsx6(ProviderKey, { provider: p, onChanged: () => list.reload() }, p.name)) })
823
+ ]
824
+ }
825
+ );
826
+ }
827
+ function ModelChooser({ overview, provider, onSaved, onCancel }) {
828
+ const { client } = useStudio();
829
+ const id = useId4();
830
+ const label = overview.providers.find((p) => p.name === provider)?.label ?? provider;
831
+ const list = useResource(() => client.availableModels(provider), [client, provider]);
832
+ const suggested = overview.providers.find((p) => p.name === provider)?.defaults ?? {};
833
+ const start = overview.chosen?.provider === provider ? overview.chosen.models : overview.active?.provider === provider ? overview.active.models : suggested;
834
+ const [models, setModels] = useState6(start);
835
+ const [saving, setSaving] = useState6(false);
836
+ const [error, setError] = useState6(null);
837
+ useEffect6(() => {
838
+ if (!list.data?.length) return;
839
+ const inList = (id2) => !!id2 && list.data.some((m) => m.id === id2);
840
+ setModels(
841
+ (current) => Object.fromEntries(overview.roles.map((r) => [r.name, inList(current[r.name]) ? current[r.name] : inList(suggested[r.name]) ? suggested[r.name] : list.data[0].id]))
842
+ );
843
+ }, [list.data, overview.roles]);
844
+ async function save() {
845
+ setSaving(true);
846
+ setError(null);
847
+ try {
848
+ await client.chooseModels({ provider, models });
849
+ await onSaved();
850
+ } catch (e) {
851
+ setError(e instanceof Error ? e.message : String(e));
852
+ } finally {
853
+ setSaving(false);
854
+ }
855
+ }
856
+ return /* @__PURE__ */ jsxs6(
857
+ "form",
858
+ {
859
+ className: "dlf-form",
860
+ "aria-label": `Modelos do ${label}`,
861
+ onSubmit: (e) => {
862
+ e.preventDefault();
863
+ void save();
864
+ },
865
+ children: [
866
+ /* @__PURE__ */ jsxs6("p", { className: "dlf-item-title", children: [
867
+ "Usar ",
868
+ label
869
+ ] }),
870
+ list.error && /* @__PURE__ */ jsx6(Notice, { tone: "error", children: list.error }),
871
+ list.loading && !list.data && /* @__PURE__ */ jsx6(Loading, { label: "Buscando os modelos desta chave\u2026" }),
872
+ list.data && !list.data.length && /* @__PURE__ */ jsx6(Notice, { tone: "error", children: "A chave n\xE3o enxerga nenhum modelo de texto neste provedor." }),
873
+ !!list.data?.length && /* @__PURE__ */ jsx6("div", { className: "dlf-row", children: overview.roles.map((role) => /* @__PURE__ */ jsx6(Field, { label: role.label, htmlFor: `${id}-${role.name}`, hint: role.description, children: /* @__PURE__ */ jsx6("select", { id: `${id}-${role.name}`, className: "dlf-select", value: models[role.name] ?? "", onChange: (e) => setModels({ ...models, [role.name]: e.target.value }), children: list.data.map((m) => /* @__PURE__ */ jsx6("option", { value: m.id, children: m.label ? `${m.label} (${m.id})` : m.id }, m.id)) }) }, role.name)) }),
874
+ error && /* @__PURE__ */ jsx6(Notice, { tone: "error", children: error }),
875
+ /* @__PURE__ */ jsxs6("div", { className: "dlf-actions", children: [
876
+ /* @__PURE__ */ jsx6(Button, { type: "submit", variant: "primary", loading: saving, disabled: !list.data?.length, children: "Usar estes modelos" }),
877
+ /* @__PURE__ */ jsx6(Button, { variant: "ghost", onClick: onCancel, children: "Cancelar" })
878
+ ] })
879
+ ]
880
+ }
881
+ );
882
+ }
883
+ function ModelSettings() {
884
+ const { client } = useStudio();
885
+ const overview = useResource(() => client.models(), [client]);
886
+ const keys = useResource(() => client.credentials(), [client]);
887
+ const [choosing, setChoosing] = useState6(null);
888
+ const [message, setMessage] = useState6(null);
889
+ const refresh = async () => {
890
+ await Promise.all([overview.reload(), keys.reload()]);
891
+ };
892
+ const o = overview.data;
893
+ const labelOf = (name) => o?.providers.find((p) => p.name === name)?.label ?? name;
894
+ const roleLabel = (name) => o?.roles.find((r) => r.name === name)?.label ?? name;
895
+ async function reset() {
896
+ if (!window.confirm("Voltar ao autom\xE1tico? A empresa passa a usar a primeira chave cadastrada com os modelos sugeridos, ou a conta da plataforma.")) return;
897
+ try {
898
+ await client.resetModels();
899
+ setMessage({ tone: "success", text: "Voltou ao autom\xE1tico." });
900
+ await refresh();
901
+ } catch (e) {
902
+ setMessage({
903
+ tone: "error",
904
+ text: e instanceof Error ? e.message : String(e)
905
+ });
906
+ }
907
+ }
908
+ if (!o || !keys.data) {
909
+ const failure = overview.error ?? keys.error;
910
+ return failure ? /* @__PURE__ */ jsx6(Notice, { tone: "error", children: failure }) : /* @__PURE__ */ jsx6(Loading, {});
911
+ }
912
+ const whenMissing = keys.data.find((k) => k.whenMissing)?.whenMissing;
913
+ const chosenKeySaved = !!o.chosen && !!keys.data.find((k) => k.name === o.chosen.provider)?.configured;
914
+ return /* @__PURE__ */ jsxs6("div", { className: "dlf-stack", children: [
915
+ /* @__PURE__ */ jsxs6(
916
+ Section,
917
+ {
918
+ title: "Modelo de IA",
919
+ description: "Qual provedor de IA esta empresa usa, com a chave dela, e o modelo de cada parte do assistente. O gasto vai para a conta do provedor, e a aba Custos mostra quanto.",
920
+ children: [
921
+ message && /* @__PURE__ */ jsx6(Notice, { tone: message.tone, children: message.text }),
922
+ o.active ? /* @__PURE__ */ jsxs6("div", { className: "dlf-notice", children: [
923
+ /* @__PURE__ */ jsxs6("p", { className: "dlf-item-title", children: [
924
+ "Em uso: ",
925
+ labelOf(o.active.provider),
926
+ " ",
927
+ o.active.source === "empresa" ? "(chave da empresa)" : "(conta de IA da plataforma)"
928
+ ] }),
929
+ /* @__PURE__ */ jsx6("dl", { className: "dlf-dl", children: Object.entries(o.active.models).map(([role, model]) => /* @__PURE__ */ jsxs6("div", { style: { display: "contents" }, children: [
930
+ /* @__PURE__ */ jsx6("dt", { children: roleLabel(role) }),
931
+ /* @__PURE__ */ jsx6("dd", { translate: "no", children: model })
932
+ ] }, role)) }),
933
+ o.chosen && /* @__PURE__ */ jsx6("div", { className: "dlf-actions", style: { marginTop: "0.75rem" }, children: /* @__PURE__ */ jsx6(Button, { variant: "ghost", onClick: reset, children: "Voltar ao autom\xE1tico" }) })
934
+ ] }) : /* @__PURE__ */ jsx6(Notice, { tone: "error", children: "Esta empresa est\xE1 sem IA: cadastre a chave de um provedor abaixo." }),
935
+ o.active?.source === "plataforma" && whenMissing && /* @__PURE__ */ jsx6("p", { className: "dlf-muted dlf-measure", children: whenMissing }),
936
+ o.chosen && !chosenKeySaved && /* @__PURE__ */ jsxs6(Notice, { tone: "error", children: [
937
+ "A chave do ",
938
+ labelOf(o.chosen.provider),
939
+ " foi removida: a empresa voltou para o que est\xE1 em uso acima."
940
+ ] })
941
+ ]
942
+ }
943
+ ),
944
+ /* @__PURE__ */ jsxs6(Section, { title: "Provedores", description: "Cadastre a chave de um ou mais provedores e escolha qual usar.", children: [
945
+ !keys.data.length && /* @__PURE__ */ jsx6(Empty, { title: "A aplica\xE7\xE3o n\xE3o usa chaves por empresa" }),
946
+ !!keys.data.length && /* @__PURE__ */ jsx6("ul", { className: "dlf-list", children: keys.data.map((p) => {
947
+ const inUse = o.active?.source === "empresa" && o.active.provider === p.name;
948
+ return /* @__PURE__ */ jsxs6(
949
+ ProviderKey,
950
+ {
951
+ provider: p,
952
+ compact: true,
953
+ onChanged: async (change) => {
954
+ await refresh();
955
+ if (change === "saved" && !inUse) setChoosing(p.name);
956
+ if (change === "removed" && choosing === p.name) setChoosing(null);
957
+ },
958
+ children: [
959
+ p.configured && choosing !== p.name && /* @__PURE__ */ jsxs6("div", { className: "dlf-actions", children: [
960
+ inUse && /* @__PURE__ */ jsx6(Badge, { tone: "accent", children: "Em uso" }),
961
+ /* @__PURE__ */ jsx6(Button, { variant: inUse ? "ghost" : "secondary", onClick: () => setChoosing(p.name), children: inUse ? "Trocar os modelos" : `Usar ${p.label}` })
962
+ ] }),
963
+ choosing === p.name && /* @__PURE__ */ jsx6(
964
+ ModelChooser,
965
+ {
966
+ overview: o,
967
+ provider: p.name,
968
+ onCancel: () => setChoosing(null),
969
+ onSaved: async () => {
970
+ setChoosing(null);
971
+ setMessage({
972
+ tone: "success",
973
+ text: `Pronto: esta empresa agora usa ${p.label}.`
974
+ });
975
+ await refresh();
976
+ }
977
+ }
978
+ )
979
+ ]
980
+ },
981
+ p.name
982
+ );
983
+ }) })
984
+ ] })
792
985
  ] });
793
986
  }
794
987
 
@@ -1155,7 +1348,7 @@ var LABELS = {
1155
1348
  knowledge: "Conhecimento",
1156
1349
  memory: "Mem\xF3ria",
1157
1350
  usage: "Custos",
1158
- keys: "Chave de IA",
1351
+ keys: "Modelo de IA",
1159
1352
  audit: "Auditoria"
1160
1353
  };
1161
1354
  function DolfinhosStudio({ sections, section, defaultSection, onSectionChange, currency, pendingApprovals, onPendingApprovalsChange }) {
@@ -1178,7 +1371,7 @@ function DolfinhosStudio({ sections, section, defaultSection, onSectionChange, c
1178
1371
  knowledge: () => /* @__PURE__ */ jsx10(KnowledgeBase, {}),
1179
1372
  memory: () => /* @__PURE__ */ jsx10(MemoryBrowser, {}),
1180
1373
  usage: () => /* @__PURE__ */ jsx10(UsageReport, {}),
1181
- keys: () => /* @__PURE__ */ jsx10(ProviderKeys, {}),
1374
+ keys: () => /* @__PURE__ */ jsx10(ModelSettings, {}),
1182
1375
  audit: () => /* @__PURE__ */ jsx10(AuditLog, {})
1183
1376
  };
1184
1377
  return /* @__PURE__ */ jsxs10("div", { className: "dlf dlf-studio", children: [
@@ -1214,6 +1407,7 @@ export {
1214
1407
  DolfinhosStudio,
1215
1408
  KnowledgeBase,
1216
1409
  MemoryBrowser,
1410
+ ModelSettings,
1217
1411
  MyMemory,
1218
1412
  ProviderKeys,
1219
1413
  StudioError,