@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.cjs CHANGED
@@ -28,6 +28,7 @@ __export(index_exports, {
28
28
  DolfinhosStudio: () => DolfinhosStudio,
29
29
  KnowledgeBase: () => KnowledgeBase,
30
30
  MemoryBrowser: () => MemoryBrowser,
31
+ ModelSettings: () => ModelSettings,
31
32
  MyMemory: () => MyMemory,
32
33
  ProviderKeys: () => ProviderKeys,
33
34
  StudioError: () => StudioError,
@@ -37,7 +38,7 @@ __export(index_exports, {
37
38
  useStudio: () => useStudio
38
39
  });
39
40
  module.exports = __toCommonJS(index_exports);
40
- var import_react12 = require("react");
41
+ var import_react13 = require("react");
41
42
 
42
43
  // src/api.ts
43
44
  var import_react = require("react");
@@ -102,7 +103,11 @@ function createStudioClient(options = {}) {
102
103
  forget: (id) => request("DELETE", `/facts/${encodeURIComponent(id)}`),
103
104
  credentials: () => request("GET", "/credentials"),
104
105
  saveCredential: (name, value) => request("PUT", `/credentials/${encodeURIComponent(name)}`, { value }),
105
- removeCredential: (name) => request("DELETE", `/credentials/${encodeURIComponent(name)}`)
106
+ removeCredential: (name) => request("DELETE", `/credentials/${encodeURIComponent(name)}`),
107
+ models: () => request("GET", "/models"),
108
+ availableModels: (provider) => request("GET", `/models/${encodeURIComponent(provider)}/available`),
109
+ chooseModels: (choice) => request("PUT", "/models", choice),
110
+ resetModels: () => request("DELETE", "/models")
106
111
  };
107
112
  }
108
113
  var StudioContext = (0, import_react.createContext)(null);
@@ -719,8 +724,14 @@ function BehaviorSettings({ currency }) {
719
724
 
720
725
  // src/Keys.tsx
721
726
  var import_react7 = require("react");
727
+ var import_react8 = require("react");
722
728
  var import_jsx_runtime6 = require("react/jsx-runtime");
723
- function ProviderKey({ provider, onChanged }) {
729
+ function ProviderKey({
730
+ provider,
731
+ onChanged,
732
+ children,
733
+ compact
734
+ }) {
724
735
  const { client, locale } = useStudio();
725
736
  const id = (0, import_react7.useId)();
726
737
  const [editing, setEditing] = (0, import_react7.useState)(!provider.configured);
@@ -734,10 +745,13 @@ function ProviderKey({ provider, onChanged }) {
734
745
  await client.saveCredential(provider.name, value.trim());
735
746
  setValue("");
736
747
  setEditing(false);
737
- setMessage({ tone: "success", text: "Chave testada e salva. A partir de agora o uso de IA desta empresa vai para esta conta." });
738
- await onChanged();
748
+ setMessage({ tone: "success", text: "Chave testada e salva." });
749
+ await onChanged("saved");
739
750
  } catch (e) {
740
- setMessage({ tone: "error", text: e instanceof Error ? e.message : String(e) });
751
+ setMessage({
752
+ tone: "error",
753
+ text: e instanceof Error ? e.message : String(e)
754
+ });
741
755
  } finally {
742
756
  setBusy(null);
743
757
  }
@@ -750,9 +764,12 @@ function ProviderKey({ provider, onChanged }) {
750
764
  await client.removeCredential(provider.name);
751
765
  setEditing(true);
752
766
  setMessage({ tone: "success", text: "Chave removida." });
753
- await onChanged();
767
+ await onChanged("removed");
754
768
  } catch (e) {
755
- setMessage({ tone: "error", text: e instanceof Error ? e.message : String(e) });
769
+ setMessage({
770
+ tone: "error",
771
+ text: e instanceof Error ? e.message : String(e)
772
+ });
756
773
  } finally {
757
774
  setBusy(null);
758
775
  }
@@ -762,17 +779,18 @@ function ProviderKey({ provider, onChanged }) {
762
779
  /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { minWidth: 0 }, children: [
763
780
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "dlf-item-title", children: provider.label }),
764
781
  provider.configured && provider.updatedAt ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("p", { className: "dlf-item-meta", children: [
765
- "Chave terminada em ",
782
+ "Chave terminada em",
783
+ " ",
766
784
  /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { translate: "no", style: { fontVariantNumeric: "tabular-nums" }, children: [
767
785
  "\u2026",
768
786
  provider.last4
769
787
  ] }),
770
- " \xB7 salva em",
771
788
  " ",
789
+ "\xB7 salva em ",
772
790
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("time", { dateTime: provider.updatedAt, children: formatDateTime(provider.updatedAt, locale) })
773
791
  ] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
774
792
  provider.description && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "dlf-item-meta", children: provider.description }),
775
- provider.whenMissing && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "dlf-item-meta", children: provider.whenMissing })
793
+ provider.whenMissing && !compact && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "dlf-item-meta", children: provider.whenMissing })
776
794
  ] })
777
795
  ] }),
778
796
  /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "dlf-actions", children: [
@@ -794,54 +812,230 @@ function ProviderKey({ provider, onChanged }) {
794
812
  void save();
795
813
  },
796
814
  children: [
797
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(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__ */ (0, import_jsx_runtime6.jsx)(
798
- "input",
815
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
816
+ Field,
799
817
  {
800
- id: `${id}-chave`,
801
- className: "dlf-input",
802
- type: "password",
803
- autoComplete: "off",
804
- spellCheck: false,
805
- maxLength: 500,
806
- placeholder: "sk-\u2026",
807
- value,
808
- onChange: (e) => setValue(e.target.value)
818
+ label: provider.configured ? "Nova chave" : "Chave de API",
819
+ htmlFor: `${id}-chave`,
820
+ hint: "A chave \xE9 testada no provedor antes de salvar e fica criptografada. Ningu\xE9m consegue v\xEA-la depois, nem aqui.",
821
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
822
+ "input",
823
+ {
824
+ id: `${id}-chave`,
825
+ className: "dlf-input",
826
+ type: "password",
827
+ autoComplete: "off",
828
+ spellCheck: false,
829
+ maxLength: 500,
830
+ placeholder: "sk-\u2026",
831
+ value,
832
+ onChange: (e) => setValue(e.target.value)
833
+ }
834
+ )
809
835
  }
810
- ) }),
836
+ ),
811
837
  /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "dlf-actions", children: [
812
838
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Button, { type: "submit", variant: "primary", loading: busy === "save", disabled: value.trim().length < 8, children: "Testar e salvar" }),
813
839
  provider.configured && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Button, { variant: "ghost", onClick: () => setEditing(false), children: "Cancelar" })
814
840
  ] })
815
841
  ]
816
842
  }
817
- )
843
+ ),
844
+ children
818
845
  ] });
819
846
  }
820
847
  function ProviderKeys() {
821
848
  const { client } = useStudio();
822
849
  const list = useResource(() => client.credentials(), [client]);
823
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(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: [
824
- list.error && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Notice, { tone: "error", children: list.error }),
825
- list.loading && !list.data && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Loading, {}),
826
- list.data && !list.data.length && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Empty, { title: "A aplica\xE7\xE3o n\xE3o usa chaves por empresa" }),
827
- !!list.data?.length && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("ul", { className: "dlf-list", children: list.data.map((p) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ProviderKey, { provider: p, onChanged: list.reload }, p.name)) })
850
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
851
+ Section,
852
+ {
853
+ title: "Chave de IA",
854
+ 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.",
855
+ children: [
856
+ list.error && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Notice, { tone: "error", children: list.error }),
857
+ list.loading && !list.data && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Loading, {}),
858
+ list.data && !list.data.length && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Empty, { title: "A aplica\xE7\xE3o n\xE3o usa chaves por empresa" }),
859
+ !!list.data?.length && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("ul", { className: "dlf-list", children: list.data.map((p) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ProviderKey, { provider: p, onChanged: () => list.reload() }, p.name)) })
860
+ ]
861
+ }
862
+ );
863
+ }
864
+ function ModelChooser({ overview, provider, onSaved, onCancel }) {
865
+ const { client } = useStudio();
866
+ const id = (0, import_react7.useId)();
867
+ const label = overview.providers.find((p) => p.name === provider)?.label ?? provider;
868
+ const list = useResource(() => client.availableModels(provider), [client, provider]);
869
+ const suggested = overview.providers.find((p) => p.name === provider)?.defaults ?? {};
870
+ const start = overview.chosen?.provider === provider ? overview.chosen.models : overview.active?.provider === provider ? overview.active.models : suggested;
871
+ const [models, setModels] = (0, import_react7.useState)(start);
872
+ const [saving, setSaving] = (0, import_react7.useState)(false);
873
+ const [error, setError] = (0, import_react7.useState)(null);
874
+ (0, import_react8.useEffect)(() => {
875
+ if (!list.data?.length) return;
876
+ const inList = (id2) => !!id2 && list.data.some((m) => m.id === id2);
877
+ setModels(
878
+ (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]))
879
+ );
880
+ }, [list.data, overview.roles]);
881
+ async function save() {
882
+ setSaving(true);
883
+ setError(null);
884
+ try {
885
+ await client.chooseModels({ provider, models });
886
+ await onSaved();
887
+ } catch (e) {
888
+ setError(e instanceof Error ? e.message : String(e));
889
+ } finally {
890
+ setSaving(false);
891
+ }
892
+ }
893
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
894
+ "form",
895
+ {
896
+ className: "dlf-form",
897
+ "aria-label": `Modelos do ${label}`,
898
+ onSubmit: (e) => {
899
+ e.preventDefault();
900
+ void save();
901
+ },
902
+ children: [
903
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("p", { className: "dlf-item-title", children: [
904
+ "Usar ",
905
+ label
906
+ ] }),
907
+ list.error && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Notice, { tone: "error", children: list.error }),
908
+ list.loading && !list.data && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Loading, { label: "Buscando os modelos desta chave\u2026" }),
909
+ list.data && !list.data.length && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Notice, { tone: "error", children: "A chave n\xE3o enxerga nenhum modelo de texto neste provedor." }),
910
+ !!list.data?.length && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "dlf-row", children: overview.roles.map((role) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Field, { label: role.label, htmlFor: `${id}-${role.name}`, hint: role.description, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("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__ */ (0, import_jsx_runtime6.jsx)("option", { value: m.id, children: m.label ? `${m.label} (${m.id})` : m.id }, m.id)) }) }, role.name)) }),
911
+ error && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Notice, { tone: "error", children: error }),
912
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "dlf-actions", children: [
913
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Button, { type: "submit", variant: "primary", loading: saving, disabled: !list.data?.length, children: "Usar estes modelos" }),
914
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Button, { variant: "ghost", onClick: onCancel, children: "Cancelar" })
915
+ ] })
916
+ ]
917
+ }
918
+ );
919
+ }
920
+ function ModelSettings() {
921
+ const { client } = useStudio();
922
+ const overview = useResource(() => client.models(), [client]);
923
+ const keys = useResource(() => client.credentials(), [client]);
924
+ const [choosing, setChoosing] = (0, import_react7.useState)(null);
925
+ const [message, setMessage] = (0, import_react7.useState)(null);
926
+ const refresh = async () => {
927
+ await Promise.all([overview.reload(), keys.reload()]);
928
+ };
929
+ const o = overview.data;
930
+ const labelOf = (name) => o?.providers.find((p) => p.name === name)?.label ?? name;
931
+ const roleLabel = (name) => o?.roles.find((r) => r.name === name)?.label ?? name;
932
+ async function reset() {
933
+ 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;
934
+ try {
935
+ await client.resetModels();
936
+ setMessage({ tone: "success", text: "Voltou ao autom\xE1tico." });
937
+ await refresh();
938
+ } catch (e) {
939
+ setMessage({
940
+ tone: "error",
941
+ text: e instanceof Error ? e.message : String(e)
942
+ });
943
+ }
944
+ }
945
+ if (!o || !keys.data) {
946
+ const failure = overview.error ?? keys.error;
947
+ return failure ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Notice, { tone: "error", children: failure }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Loading, {});
948
+ }
949
+ const whenMissing = keys.data.find((k) => k.whenMissing)?.whenMissing;
950
+ const chosenKeySaved = !!o.chosen && !!keys.data.find((k) => k.name === o.chosen.provider)?.configured;
951
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "dlf-stack", children: [
952
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
953
+ Section,
954
+ {
955
+ title: "Modelo de IA",
956
+ 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.",
957
+ children: [
958
+ message && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Notice, { tone: message.tone, children: message.text }),
959
+ o.active ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "dlf-notice", children: [
960
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("p", { className: "dlf-item-title", children: [
961
+ "Em uso: ",
962
+ labelOf(o.active.provider),
963
+ " ",
964
+ o.active.source === "empresa" ? "(chave da empresa)" : "(conta de IA da plataforma)"
965
+ ] }),
966
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("dl", { className: "dlf-dl", children: Object.entries(o.active.models).map(([role, model]) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "contents" }, children: [
967
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("dt", { children: roleLabel(role) }),
968
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("dd", { translate: "no", children: model })
969
+ ] }, role)) }),
970
+ o.chosen && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "dlf-actions", style: { marginTop: "0.75rem" }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Button, { variant: "ghost", onClick: reset, children: "Voltar ao autom\xE1tico" }) })
971
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Notice, { tone: "error", children: "Esta empresa est\xE1 sem IA: cadastre a chave de um provedor abaixo." }),
972
+ o.active?.source === "plataforma" && whenMissing && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "dlf-muted dlf-measure", children: whenMissing }),
973
+ o.chosen && !chosenKeySaved && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Notice, { tone: "error", children: [
974
+ "A chave do ",
975
+ labelOf(o.chosen.provider),
976
+ " foi removida: a empresa voltou para o que est\xE1 em uso acima."
977
+ ] })
978
+ ]
979
+ }
980
+ ),
981
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Section, { title: "Provedores", description: "Cadastre a chave de um ou mais provedores e escolha qual usar.", children: [
982
+ !keys.data.length && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Empty, { title: "A aplica\xE7\xE3o n\xE3o usa chaves por empresa" }),
983
+ !!keys.data.length && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("ul", { className: "dlf-list", children: keys.data.map((p) => {
984
+ const inUse = o.active?.source === "empresa" && o.active.provider === p.name;
985
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
986
+ ProviderKey,
987
+ {
988
+ provider: p,
989
+ compact: true,
990
+ onChanged: async (change) => {
991
+ await refresh();
992
+ if (change === "saved" && !inUse) setChoosing(p.name);
993
+ if (change === "removed" && choosing === p.name) setChoosing(null);
994
+ },
995
+ children: [
996
+ p.configured && choosing !== p.name && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "dlf-actions", children: [
997
+ inUse && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Badge, { tone: "accent", children: "Em uso" }),
998
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Button, { variant: inUse ? "ghost" : "secondary", onClick: () => setChoosing(p.name), children: inUse ? "Trocar os modelos" : `Usar ${p.label}` })
999
+ ] }),
1000
+ choosing === p.name && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1001
+ ModelChooser,
1002
+ {
1003
+ overview: o,
1004
+ provider: p.name,
1005
+ onCancel: () => setChoosing(null),
1006
+ onSaved: async () => {
1007
+ setChoosing(null);
1008
+ setMessage({
1009
+ tone: "success",
1010
+ text: `Pronto: esta empresa agora usa ${p.label}.`
1011
+ });
1012
+ await refresh();
1013
+ }
1014
+ }
1015
+ )
1016
+ ]
1017
+ },
1018
+ p.name
1019
+ );
1020
+ }) })
1021
+ ] })
828
1022
  ] });
829
1023
  }
830
1024
 
831
1025
  // src/Knowledge.tsx
832
- var import_react8 = require("react");
1026
+ var import_react9 = require("react");
833
1027
  var import_jsx_runtime7 = require("react/jsx-runtime");
834
1028
  function KnowledgeBase() {
835
1029
  const { client, locale } = useStudio();
836
- const ids = (0, import_react8.useId)();
1030
+ const ids = (0, import_react9.useId)();
837
1031
  const docs = useResource(() => client.knowledge(), [client]);
838
- const [draft, setDraft] = (0, import_react8.useState)(null);
839
- const [saving, setSaving] = (0, import_react8.useState)(null);
840
- const [message, setMessage] = (0, import_react8.useState)(null);
841
- const [query, setQuery] = (0, import_react8.useState)("");
842
- const [queryAudience, setQueryAudience] = (0, import_react8.useState)("all");
843
- const [hits, setHits] = (0, import_react8.useState)(null);
844
- const [searching, setSearching] = (0, import_react8.useState)(false);
1032
+ const [draft, setDraft] = (0, import_react9.useState)(null);
1033
+ const [saving, setSaving] = (0, import_react9.useState)(null);
1034
+ const [message, setMessage] = (0, import_react9.useState)(null);
1035
+ const [query, setQuery] = (0, import_react9.useState)("");
1036
+ const [queryAudience, setQueryAudience] = (0, import_react9.useState)("all");
1037
+ const [hits, setHits] = (0, import_react9.useState)(null);
1038
+ const [searching, setSearching] = (0, import_react9.useState)(false);
845
1039
  async function save() {
846
1040
  if (!draft) return;
847
1041
  setSaving("form");
@@ -978,13 +1172,13 @@ function KnowledgeBase() {
978
1172
  }
979
1173
 
980
1174
  // src/Memory.tsx
981
- var import_react9 = require("react");
1175
+ var import_react10 = require("react");
982
1176
  var import_jsx_runtime8 = require("react/jsx-runtime");
983
1177
  function FactList({ subject, emptyText }) {
984
1178
  const { client, locale } = useStudio();
985
1179
  const facts = useResource(() => client.facts(subject), [client, subject.type, subject.id]);
986
- const [removing, setRemoving] = (0, import_react9.useState)(null);
987
- const [error, setError] = (0, import_react9.useState)(null);
1180
+ const [removing, setRemoving] = (0, import_react10.useState)(null);
1181
+ const [error, setError] = (0, import_react10.useState)(null);
988
1182
  async function forget(fact) {
989
1183
  if (!window.confirm(`Esquecer \u201C${fact.text}\u201D? O assistente deixa de usar isso nas pr\xF3ximas conversas.`)) return;
990
1184
  setRemoving(fact.id);
@@ -1018,7 +1212,7 @@ function FactList({ subject, emptyText }) {
1018
1212
  function MemoryBrowser() {
1019
1213
  const { client, labels, locale } = useStudio();
1020
1214
  const subjects = useResource(() => client.factSubjects(), [client]);
1021
- const [open, setOpen] = (0, import_react9.useState)(null);
1215
+ const [open, setOpen] = (0, import_react10.useState)(null);
1022
1216
  const typeLabel = (type) => labels.subjects?.[type] ?? type;
1023
1217
  if (open) {
1024
1218
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
@@ -1066,10 +1260,10 @@ function MyMemory({ subject }) {
1066
1260
  }
1067
1261
 
1068
1262
  // src/Studio.tsx
1069
- var import_react11 = require("react");
1263
+ var import_react12 = require("react");
1070
1264
 
1071
1265
  // src/Usage.tsx
1072
- var import_react10 = require("react");
1266
+ var import_react11 = require("react");
1073
1267
  var import_jsx_runtime9 = require("react/jsx-runtime");
1074
1268
  var periodRange = (period) => {
1075
1269
  const now = /* @__PURE__ */ new Date();
@@ -1080,8 +1274,8 @@ var periodRange = (period) => {
1080
1274
  };
1081
1275
  function UsageReport() {
1082
1276
  const { client, labels, locale } = useStudio();
1083
- const ids = (0, import_react10.useId)();
1084
- const [period, setPeriod] = (0, import_react10.useState)("month");
1277
+ const ids = (0, import_react11.useId)();
1278
+ const [period, setPeriod] = (0, import_react11.useState)("month");
1085
1279
  const usage = useResource(() => client.usage(periodRange(period)), [client, period]);
1086
1280
  const data = usage.data;
1087
1281
  const money = (n) => formatMoney(n, data?.currency ?? null, locale);
@@ -1191,13 +1385,13 @@ var LABELS = {
1191
1385
  knowledge: "Conhecimento",
1192
1386
  memory: "Mem\xF3ria",
1193
1387
  usage: "Custos",
1194
- keys: "Chave de IA",
1388
+ keys: "Modelo de IA",
1195
1389
  audit: "Auditoria"
1196
1390
  };
1197
1391
  function DolfinhosStudio({ sections, section, defaultSection, onSectionChange, currency, pendingApprovals, onPendingApprovalsChange }) {
1198
1392
  const visible = sections ?? Object.keys(LABELS);
1199
- const [own, setOwn] = (0, import_react11.useState)(defaultSection ?? visible[0]);
1200
- const [pending, setPending] = (0, import_react11.useState)(pendingApprovals);
1393
+ const [own, setOwn] = (0, import_react12.useState)(defaultSection ?? visible[0]);
1394
+ const [pending, setPending] = (0, import_react12.useState)(pendingApprovals);
1201
1395
  const current = section ?? own;
1202
1396
  const select = (s) => {
1203
1397
  setOwn(s);
@@ -1214,7 +1408,7 @@ function DolfinhosStudio({ sections, section, defaultSection, onSectionChange, c
1214
1408
  knowledge: () => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(KnowledgeBase, {}),
1215
1409
  memory: () => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(MemoryBrowser, {}),
1216
1410
  usage: () => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(UsageReport, {}),
1217
- keys: () => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ProviderKeys, {}),
1411
+ keys: () => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ModelSettings, {}),
1218
1412
  audit: () => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(AuditLog, {})
1219
1413
  };
1220
1414
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "dlf dlf-studio", children: [
@@ -1234,12 +1428,12 @@ function DolfinhosStudio({ sections, section, defaultSection, onSectionChange, c
1234
1428
  // src/index.tsx
1235
1429
  var import_jsx_runtime11 = require("react/jsx-runtime");
1236
1430
  function StudioProvider({ children, endpoint, headers, fetch: fetch2, labels, locale = "pt-BR", navigate }) {
1237
- const client = (0, import_react12.useMemo)(
1431
+ const client = (0, import_react13.useMemo)(
1238
1432
  () => createStudioClient({ ...endpoint ? { endpoint } : {}, ...headers ? { headers } : {}, ...fetch2 ? { fetch: fetch2 } : {} }),
1239
1433
  // eslint-disable-next-line react-hooks/exhaustive-deps
1240
1434
  [endpoint]
1241
1435
  );
1242
- const value = (0, import_react12.useMemo)(() => ({ client, labels: labels ?? {}, locale, ...navigate ? { navigate } : {} }), [client, labels, locale, navigate]);
1436
+ const value = (0, import_react13.useMemo)(() => ({ client, labels: labels ?? {}, locale, ...navigate ? { navigate } : {} }), [client, labels, locale, navigate]);
1243
1437
  return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(StudioContextProvider, { value, children });
1244
1438
  }
1245
1439
  // Annotate the CommonJS export names for ESM import in node:
@@ -1251,6 +1445,7 @@ function StudioProvider({ children, endpoint, headers, fetch: fetch2, labels, lo
1251
1445
  DolfinhosStudio,
1252
1446
  KnowledgeBase,
1253
1447
  MemoryBrowser,
1448
+ ModelSettings,
1254
1449
  MyMemory,
1255
1450
  ProviderKeys,
1256
1451
  StudioError,