@blade-hq/agent-react 2612.0.0-beta.77 → 2612.0.0-beta.79
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/README.md +12 -2
- package/dist/SessionPluginConfigForm-7LJ5SUNY.js +9 -0
- package/dist/SessionPluginConfigForm-7LJ5SUNY.js.map +1 -0
- package/dist/chat/LiteMessageList.d.ts +4 -0
- package/dist/{chunk-IVGTMWRV.js → chunk-66JXSDLB.js} +284 -289
- package/dist/chunk-66JXSDLB.js.map +1 -0
- package/dist/{chunk-VBHHFIII.js → chunk-C3LBNHVM.js} +12 -10
- package/dist/{chunk-VBHHFIII.js.map → chunk-C3LBNHVM.js.map} +1 -1
- package/dist/chunk-F4MWGSKX.js +1308 -0
- package/dist/chunk-F4MWGSKX.js.map +1 -0
- package/dist/{chunk-ZIECHNZA.js → chunk-FBGCDXRK.js} +110 -115
- package/dist/chunk-FBGCDXRK.js.map +1 -0
- package/dist/{chunk-26NE55SJ.js → chunk-FDB3J5QF.js} +8 -6
- package/dist/{chunk-26NE55SJ.js.map → chunk-FDB3J5QF.js.map} +1 -1
- package/dist/{chunk-WO2VCQ5N.js → chunk-FH5HA3GW.js} +551 -455
- package/dist/chunk-FH5HA3GW.js.map +1 -0
- package/dist/chunk-KHJEIHMJ.js +973 -0
- package/dist/chunk-KHJEIHMJ.js.map +1 -0
- package/dist/{chunk-XBEN2ASY.js → chunk-MWILWSPG.js} +4262 -3186
- package/dist/chunk-MWILWSPG.js.map +1 -0
- package/dist/{chunk-EQOKPZI2.js → chunk-NRYLAO3X.js} +87 -154
- package/dist/chunk-NRYLAO3X.js.map +1 -0
- package/dist/{chunk-F2IJZX2Z.js → chunk-SK43YNRX.js} +151 -1442
- package/dist/chunk-SK43YNRX.js.map +1 -0
- package/dist/components/BrowserConnectionDialog.d.ts +3 -2
- package/dist/components/ConfigConnection.d.ts +16 -0
- package/dist/components/ConnectorDetail.d.ts +46 -0
- package/dist/components/ConnectorRulesPanel.d.ts +2 -1
- package/dist/components/ConnectorRuntimeDiagnostics.d.ts +2 -2
- package/dist/components/DeviceConnection.d.ts +3 -1
- package/dist/components/FeishuPermissionStatus.d.ts +3 -1
- package/dist/components/ManagedConnection.d.ts +5 -2
- package/dist/components/PackEventNotice.d.ts +3 -0
- package/dist/components/SessionPluginConfigForm.d.ts +2 -1
- package/dist/connectors.d.ts +3 -0
- package/dist/connectors.js +7 -2
- package/dist/embed/entry.d.ts +4 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +13 -7
- package/dist/internal.js +16 -9
- package/dist/internal.js.map +1 -1
- package/dist/questions.js +8 -6
- package/dist/questions.js.map +1 -1
- package/dist/rich-input.js +21 -15
- package/dist/rich-input.js.map +1 -1
- package/dist/style.full.css +1 -1
- package/dist/tool-details.js +5 -4
- package/dist/tool-details.js.map +1 -1
- package/package.json +2 -2
- package/public-api.md +41 -3
- package/dist/chunk-EQOKPZI2.js.map +0 -1
- package/dist/chunk-F2IJZX2Z.js.map +0 -1
- package/dist/chunk-IVGTMWRV.js.map +0 -1
- package/dist/chunk-WO2VCQ5N.js.map +0 -1
- package/dist/chunk-XBEN2ASY.js.map +0 -1
- package/dist/chunk-ZIECHNZA.js.map +0 -1
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
useBladeClient,
|
|
3
|
-
useSessionHandle,
|
|
4
|
-
useSessionState
|
|
5
|
-
} from "./chunk-EQOKPZI2.js";
|
|
6
|
-
import {
|
|
7
|
-
LoaderCircle,
|
|
8
2
|
Plus,
|
|
9
|
-
Puzzle,
|
|
10
3
|
Trash2
|
|
11
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-KHJEIHMJ.js";
|
|
12
5
|
import {
|
|
13
6
|
__commonJS,
|
|
14
7
|
__toESM
|
|
@@ -1560,7 +1553,7 @@ var require_react_is_development = __commonJS({
|
|
|
1560
1553
|
var ContextProvider = REACT_PROVIDER_TYPE;
|
|
1561
1554
|
var Element = REACT_ELEMENT_TYPE;
|
|
1562
1555
|
var ForwardRef = REACT_FORWARD_REF_TYPE;
|
|
1563
|
-
var
|
|
1556
|
+
var Fragment3 = REACT_FRAGMENT_TYPE;
|
|
1564
1557
|
var Lazy = REACT_LAZY_TYPE;
|
|
1565
1558
|
var Memo = REACT_MEMO_TYPE;
|
|
1566
1559
|
var Portal = REACT_PORTAL_TYPE;
|
|
@@ -1628,7 +1621,7 @@ var require_react_is_development = __commonJS({
|
|
|
1628
1621
|
exports.ContextProvider = ContextProvider;
|
|
1629
1622
|
exports.Element = Element;
|
|
1630
1623
|
exports.ForwardRef = ForwardRef;
|
|
1631
|
-
exports.Fragment =
|
|
1624
|
+
exports.Fragment = Fragment3;
|
|
1632
1625
|
exports.Lazy = Lazy;
|
|
1633
1626
|
exports.Memo = Memo;
|
|
1634
1627
|
exports.Portal = Portal;
|
|
@@ -1669,379 +1662,6 @@ var require_react_is = __commonJS({
|
|
|
1669
1662
|
}
|
|
1670
1663
|
});
|
|
1671
1664
|
|
|
1672
|
-
// src/chat/runtime/input-history-storage.ts
|
|
1673
|
-
var generation = 0;
|
|
1674
|
-
function getInputHistoryGeneration() {
|
|
1675
|
-
return generation;
|
|
1676
|
-
}
|
|
1677
|
-
|
|
1678
|
-
// src/chat/runtime/input-cache-reset.ts
|
|
1679
|
-
var resetters = /* @__PURE__ */ new WeakMap();
|
|
1680
|
-
function onInputCachesReset(client, reset) {
|
|
1681
|
-
let set = resetters.get(client);
|
|
1682
|
-
if (!set) {
|
|
1683
|
-
set = /* @__PURE__ */ new Set();
|
|
1684
|
-
resetters.set(client, set);
|
|
1685
|
-
}
|
|
1686
|
-
set.add(reset);
|
|
1687
|
-
return () => {
|
|
1688
|
-
set.delete(reset);
|
|
1689
|
-
};
|
|
1690
|
-
}
|
|
1691
|
-
|
|
1692
|
-
// src/rich-input/lib/plugin-suggestions.ts
|
|
1693
|
-
var accountPreparation = /* @__PURE__ */ new WeakMap();
|
|
1694
|
-
var registeredClients = /* @__PURE__ */ new WeakSet();
|
|
1695
|
-
function pluginRefsForSend(refs, turns = []) {
|
|
1696
|
-
const latest = [...turns].reverse().find((turn) => turn.role === "user");
|
|
1697
|
-
return refs.length || latest?.refs?.length ? refs : void 0;
|
|
1698
|
-
}
|
|
1699
|
-
function prepareAccount(client) {
|
|
1700
|
-
if (!registeredClients.has(client)) {
|
|
1701
|
-
registeredClients.add(client);
|
|
1702
|
-
onInputCachesReset(client, () => accountPreparation.delete(client));
|
|
1703
|
-
}
|
|
1704
|
-
const current = accountPreparation.get(client);
|
|
1705
|
-
if (current && current.token === client.token) return current.ready;
|
|
1706
|
-
const ready = client.plugins.catalog().catch((error) => {
|
|
1707
|
-
accountPreparation.delete(client);
|
|
1708
|
-
throw error;
|
|
1709
|
-
});
|
|
1710
|
-
accountPreparation.set(client, { token: client.token, ready });
|
|
1711
|
-
return ready;
|
|
1712
|
-
}
|
|
1713
|
-
async function getPluginSuggestionItems(client, session, query, pendingPlugins = []) {
|
|
1714
|
-
if (!session && pendingPlugins.length === 0) return [];
|
|
1715
|
-
const path = session ? `/api/sessions/${encodeURIComponent(session)}/plugin-tools/mentions` : "/api/plugin-mentions/mentions";
|
|
1716
|
-
try {
|
|
1717
|
-
if (!session) await prepareAccount(client);
|
|
1718
|
-
const data = await client.json("POST", path, { arguments: { query, cursor: "" }, ...!session ? { plugin_selection: pendingPlugins } : {} });
|
|
1719
|
-
return [...data.items.map((item) => ({ ...item, kind: "plugin", name: item.label })), ...data.errors.map((message) => ({ kind: "pluginError", message }))];
|
|
1720
|
-
} catch {
|
|
1721
|
-
return [{ kind: "pluginError", message: "\u63D2\u4EF6\u6761\u76EE\u6682\u65F6\u65E0\u6CD5\u52A0\u8F7D\uFF0C\u8BF7\u91CD\u65B0\u8F93\u5165 @ \u91CD\u8BD5" }];
|
|
1722
|
-
}
|
|
1723
|
-
}
|
|
1724
|
-
|
|
1725
|
-
// src/chat/runtime/input-services.tsx
|
|
1726
|
-
import { createContext, useContext } from "react";
|
|
1727
|
-
import { jsx } from "react/jsx-runtime";
|
|
1728
|
-
function parseModelReasoningLevels(value) {
|
|
1729
|
-
if (!value) return {};
|
|
1730
|
-
try {
|
|
1731
|
-
const parsed = JSON.parse(value);
|
|
1732
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {};
|
|
1733
|
-
return Object.fromEntries(
|
|
1734
|
-
Object.entries(parsed).filter(
|
|
1735
|
-
(entry) => Boolean(entry[0]) && typeof entry[1] === "string" && Boolean(entry[1])
|
|
1736
|
-
)
|
|
1737
|
-
);
|
|
1738
|
-
} catch {
|
|
1739
|
-
return {};
|
|
1740
|
-
}
|
|
1741
|
-
}
|
|
1742
|
-
var RichInputServicesContext = createContext({});
|
|
1743
|
-
function RichInputServicesProvider({ value, children }) {
|
|
1744
|
-
return /* @__PURE__ */ jsx(RichInputServicesContext.Provider, { value, children });
|
|
1745
|
-
}
|
|
1746
|
-
function useRichInputServices() {
|
|
1747
|
-
return useContext(RichInputServicesContext);
|
|
1748
|
-
}
|
|
1749
|
-
|
|
1750
|
-
// src/rich-input/lib/client-query.ts
|
|
1751
|
-
import { useCallback, useEffect, useSyncExternalStore } from "react";
|
|
1752
|
-
var EMPTY = { data: void 0, error: null, isLoading: false, isFetching: false };
|
|
1753
|
-
var caches = /* @__PURE__ */ new WeakMap();
|
|
1754
|
-
function entryFor(client, key) {
|
|
1755
|
-
let cache = caches.get(client);
|
|
1756
|
-
if (!cache) {
|
|
1757
|
-
const created = /* @__PURE__ */ new Map();
|
|
1758
|
-
cache = created;
|
|
1759
|
-
caches.set(client, created);
|
|
1760
|
-
onInputCachesReset(client, () => {
|
|
1761
|
-
for (const [key2, entry2] of created) {
|
|
1762
|
-
entry2.request = null;
|
|
1763
|
-
entry2.fetchedAt = 0;
|
|
1764
|
-
update(entry2, EMPTY);
|
|
1765
|
-
const load = loadersFor(client).get(key2);
|
|
1766
|
-
if (load && entry2.listeners.size > 0) void fetchClientQuery(client, key2, load, { force: true }).catch(() => {
|
|
1767
|
-
});
|
|
1768
|
-
}
|
|
1769
|
-
});
|
|
1770
|
-
}
|
|
1771
|
-
let entry = cache.get(key);
|
|
1772
|
-
if (!entry) {
|
|
1773
|
-
entry = { snapshot: EMPTY, fetchedAt: 0, request: null, listeners: /* @__PURE__ */ new Set() };
|
|
1774
|
-
cache.set(key, entry);
|
|
1775
|
-
}
|
|
1776
|
-
return entry;
|
|
1777
|
-
}
|
|
1778
|
-
function update(entry, patch) {
|
|
1779
|
-
entry.snapshot = { ...entry.snapshot, ...patch };
|
|
1780
|
-
for (const listener of [...entry.listeners]) listener();
|
|
1781
|
-
}
|
|
1782
|
-
function fetchClientQuery(client, key, load, { staleMs = 3e4, force = false } = {}) {
|
|
1783
|
-
const entry = entryFor(client, key);
|
|
1784
|
-
if (entry.request) return entry.request;
|
|
1785
|
-
if (!force && entry.snapshot.data !== void 0 && Date.now() - entry.fetchedAt < staleMs) {
|
|
1786
|
-
return Promise.resolve(entry.snapshot.data);
|
|
1787
|
-
}
|
|
1788
|
-
const request = Promise.resolve().then(() => load(client));
|
|
1789
|
-
entry.request = request;
|
|
1790
|
-
update(entry, { isFetching: true, isLoading: entry.snapshot.data === void 0 });
|
|
1791
|
-
request.then(
|
|
1792
|
-
(data) => {
|
|
1793
|
-
if (entry.request !== request) return;
|
|
1794
|
-
entry.request = null;
|
|
1795
|
-
entry.fetchedAt = Date.now();
|
|
1796
|
-
update(entry, { data, error: null, isFetching: false, isLoading: false });
|
|
1797
|
-
},
|
|
1798
|
-
(error) => {
|
|
1799
|
-
if (entry.request !== request) return;
|
|
1800
|
-
entry.request = null;
|
|
1801
|
-
update(entry, { error, isFetching: false, isLoading: false });
|
|
1802
|
-
}
|
|
1803
|
-
);
|
|
1804
|
-
return request;
|
|
1805
|
-
}
|
|
1806
|
-
function setClientQueryData(client, key, updater) {
|
|
1807
|
-
const entry = entryFor(client, key);
|
|
1808
|
-
if (entry.snapshot.data === void 0) return;
|
|
1809
|
-
update(entry, { data: updater(entry.snapshot.data) });
|
|
1810
|
-
}
|
|
1811
|
-
function useClientQuery(key, load, { staleMs = 3e4 } = {}) {
|
|
1812
|
-
const client = useBladeClient();
|
|
1813
|
-
const subscribe = useCallback(
|
|
1814
|
-
(listener) => {
|
|
1815
|
-
if (!key) return () => {
|
|
1816
|
-
};
|
|
1817
|
-
const entry = entryFor(client, key);
|
|
1818
|
-
entry.listeners.add(listener);
|
|
1819
|
-
return () => {
|
|
1820
|
-
entry.listeners.delete(listener);
|
|
1821
|
-
};
|
|
1822
|
-
},
|
|
1823
|
-
[client, key]
|
|
1824
|
-
);
|
|
1825
|
-
const snapshot = useSyncExternalStore(
|
|
1826
|
-
subscribe,
|
|
1827
|
-
() => key ? entryFor(client, key).snapshot : EMPTY,
|
|
1828
|
-
() => key ? entryFor(client, key).snapshot : EMPTY
|
|
1829
|
-
);
|
|
1830
|
-
if (key) loadersFor(client).set(key, load);
|
|
1831
|
-
useEffect(() => {
|
|
1832
|
-
if (!key) return;
|
|
1833
|
-
const registered = loadersFor(client).get(key);
|
|
1834
|
-
if (registered) void fetchClientQuery(client, key, registered, { staleMs }).catch(() => {
|
|
1835
|
-
});
|
|
1836
|
-
}, [client, key, staleMs]);
|
|
1837
|
-
const refetch = useCallback(async () => {
|
|
1838
|
-
if (!key) return void 0;
|
|
1839
|
-
const registered = loadersFor(client).get(key);
|
|
1840
|
-
if (!registered) return void 0;
|
|
1841
|
-
return fetchClientQuery(client, key, registered, { force: true }).catch(() => void 0);
|
|
1842
|
-
}, [client, key]);
|
|
1843
|
-
return { ...snapshot, refetch };
|
|
1844
|
-
}
|
|
1845
|
-
var loaderRegistry = /* @__PURE__ */ new WeakMap();
|
|
1846
|
-
function loadersFor(client) {
|
|
1847
|
-
let loaders = loaderRegistry.get(client);
|
|
1848
|
-
if (!loaders) {
|
|
1849
|
-
loaders = /* @__PURE__ */ new Map();
|
|
1850
|
-
loaderRegistry.set(client, loaders);
|
|
1851
|
-
}
|
|
1852
|
-
return loaders;
|
|
1853
|
-
}
|
|
1854
|
-
function refreshClientQuery(client, key) {
|
|
1855
|
-
const entry = caches.get(client)?.get(key);
|
|
1856
|
-
if (!entry) return;
|
|
1857
|
-
entry.fetchedAt = 0;
|
|
1858
|
-
const load = loadersFor(client).get(key);
|
|
1859
|
-
if (load && entry.listeners.size > 0) void fetchClientQuery(client, key, load, { force: true }).catch(() => {
|
|
1860
|
-
});
|
|
1861
|
-
}
|
|
1862
|
-
|
|
1863
|
-
// src/rich-input/lib/session-data.ts
|
|
1864
|
-
import { useEffect as useEffect2, useRef } from "react";
|
|
1865
|
-
var sessionPath = (sessionId, rest) => `/api/sessions/${encodeURIComponent(sessionId)}/${rest}`;
|
|
1866
|
-
function useRefreshWhenRunEnds(sessionId, keys2) {
|
|
1867
|
-
const client = useBladeClient();
|
|
1868
|
-
const streaming = useSessionState(sessionId, (state) => state.isStreaming);
|
|
1869
|
-
const wasStreaming = useRef(streaming);
|
|
1870
|
-
useEffect2(() => {
|
|
1871
|
-
if (wasStreaming.current && !streaming) {
|
|
1872
|
-
for (const key of keys2) refreshClientQuery(client, key);
|
|
1873
|
-
}
|
|
1874
|
-
wasStreaming.current = streaming;
|
|
1875
|
-
});
|
|
1876
|
-
}
|
|
1877
|
-
function useClientSessionSkills(sessionId) {
|
|
1878
|
-
const key = sessionId ? `session-skills:${sessionId}` : null;
|
|
1879
|
-
const query = useClientQuery(
|
|
1880
|
-
key,
|
|
1881
|
-
(client) => client.json("GET", sessionPath(sessionId ?? "", "skills"))
|
|
1882
|
-
);
|
|
1883
|
-
useRefreshWhenRunEnds(sessionId, key ? [key] : []);
|
|
1884
|
-
return { data: query.data, loading: query.isLoading, error: query.error };
|
|
1885
|
-
}
|
|
1886
|
-
function useClientSkillStats(sessionId) {
|
|
1887
|
-
const key = sessionId ? `skill-stats:${sessionId}` : null;
|
|
1888
|
-
const query = useClientQuery(key, (client) => client.json("GET", sessionPath(sessionId ?? "", "skill-stats")), {
|
|
1889
|
-
staleMs: 3e5
|
|
1890
|
-
});
|
|
1891
|
-
useRefreshWhenRunEnds(sessionId, key ? [key] : []);
|
|
1892
|
-
return { data: query.data, loading: query.isLoading, error: query.error };
|
|
1893
|
-
}
|
|
1894
|
-
function useClientContextStats(sessionId) {
|
|
1895
|
-
const key = sessionId ? `context-stats:${sessionId}` : null;
|
|
1896
|
-
const query = useClientQuery(
|
|
1897
|
-
key,
|
|
1898
|
-
(client) => client.json("GET", sessionPath(sessionId ?? "", "context-stats"))
|
|
1899
|
-
);
|
|
1900
|
-
useRefreshWhenRunEnds(sessionId, key ? [key] : []);
|
|
1901
|
-
return { data: query.data, loading: query.isLoading, error: query.error };
|
|
1902
|
-
}
|
|
1903
|
-
function useClientBackgroundTasks(sessionId) {
|
|
1904
|
-
const client = useBladeClient();
|
|
1905
|
-
const key = sessionId ? `background-tasks:${sessionId}` : null;
|
|
1906
|
-
const query = useClientQuery(key, (c) => c.sessions.listBackgroundTasks(sessionId ?? ""));
|
|
1907
|
-
const session = useSessionHandle(sessionId);
|
|
1908
|
-
useEffect2(() => {
|
|
1909
|
-
if (!session || !key) return;
|
|
1910
|
-
return session.on("backgroundTask", () => refreshClientQuery(client, key));
|
|
1911
|
-
}, [client, key, session]);
|
|
1912
|
-
return { data: query.data, loading: query.isLoading, error: query.error };
|
|
1913
|
-
}
|
|
1914
|
-
function refreshClientSessionSkills(client, sessionId) {
|
|
1915
|
-
refreshClientQuery(client, `session-skills:${sessionId}`);
|
|
1916
|
-
refreshClientQuery(client, `skill-stats:${sessionId}`);
|
|
1917
|
-
}
|
|
1918
|
-
function useClientSessionModel(sessionId) {
|
|
1919
|
-
const key = sessionId ? `session-detail:${sessionId}` : null;
|
|
1920
|
-
const query = useClientQuery(key, (client) => client.sessions.getSession(sessionId ?? ""));
|
|
1921
|
-
useRefreshWhenRunEnds(sessionId, key ? [key] : []);
|
|
1922
|
-
return query.data?.model ?? null;
|
|
1923
|
-
}
|
|
1924
|
-
|
|
1925
|
-
// src/rich-input/model/model-data.ts
|
|
1926
|
-
var EMPTY_MODELS = [];
|
|
1927
|
-
var EMPTY_IDS = [];
|
|
1928
|
-
var CATALOG_KEY = "model-catalog";
|
|
1929
|
-
function useClientModelCatalog() {
|
|
1930
|
-
const { data, isLoading, isFetching, refetch } = useClientQuery(
|
|
1931
|
-
CATALOG_KEY,
|
|
1932
|
-
(client) => client.json("GET", "/api/config/models"),
|
|
1933
|
-
{ staleMs: 0 }
|
|
1934
|
-
);
|
|
1935
|
-
return {
|
|
1936
|
-
models: data?.models ?? EMPTY_MODELS,
|
|
1937
|
-
defaultModel: data?.default ?? "",
|
|
1938
|
-
thinkingAvailable: data?.thinkingAvailable ?? false,
|
|
1939
|
-
unavailableProviderIds: data?.unavailableProviderIds ?? EMPTY_IDS,
|
|
1940
|
-
unavailableModelIds: data?.unavailableModelIds ?? EMPTY_IDS,
|
|
1941
|
-
isLoading,
|
|
1942
|
-
isFetching,
|
|
1943
|
-
refresh: async () => {
|
|
1944
|
-
await refetch();
|
|
1945
|
-
}
|
|
1946
|
-
};
|
|
1947
|
-
}
|
|
1948
|
-
var PREFERRED_MODEL_KEY = "preferred_model";
|
|
1949
|
-
var MODEL_REASONING_LEVELS_KEY = "llm.model_thinking_preferences";
|
|
1950
|
-
var PREFERENCES_KEY = "model-preferences";
|
|
1951
|
-
function loadPreferences(client) {
|
|
1952
|
-
const query = new URLSearchParams();
|
|
1953
|
-
query.append("key", PREFERRED_MODEL_KEY);
|
|
1954
|
-
query.append("key", MODEL_REASONING_LEVELS_KEY);
|
|
1955
|
-
return client.json("GET", `/api/user/preferences?${query.toString()}`).then((response) => response.values ?? {});
|
|
1956
|
-
}
|
|
1957
|
-
async function writePreference(client, key, value) {
|
|
1958
|
-
const previous = await fetchClientQuery(client, PREFERENCES_KEY, loadPreferences, { staleMs: 6e4 }).catch(
|
|
1959
|
-
() => ({})
|
|
1960
|
-
);
|
|
1961
|
-
setClientQueryData(client, PREFERENCES_KEY, (current) => ({ ...current, [key]: value }));
|
|
1962
|
-
try {
|
|
1963
|
-
await client.json("PUT", `/api/user/preferences/${encodeURIComponent(key)}`, { value });
|
|
1964
|
-
} catch {
|
|
1965
|
-
setClientQueryData(client, PREFERENCES_KEY, (current) => ({ ...current, [key]: previous[key] ?? null }));
|
|
1966
|
-
}
|
|
1967
|
-
}
|
|
1968
|
-
var EMPTY_LEVELS = {};
|
|
1969
|
-
function useClientModelPreferences() {
|
|
1970
|
-
const client = useBladeClient();
|
|
1971
|
-
const { data } = useClientQuery(PREFERENCES_KEY, loadPreferences, { staleMs: 6e4 });
|
|
1972
|
-
const rawLevels = data?.[MODEL_REASONING_LEVELS_KEY] ?? null;
|
|
1973
|
-
const reasoningLevels = rawLevels ? parseModelReasoningLevels(rawLevels) : EMPTY_LEVELS;
|
|
1974
|
-
return {
|
|
1975
|
-
preferredModel: data?.[PREFERRED_MODEL_KEY] ?? null,
|
|
1976
|
-
setPreferredModel: (modelId) => void writePreference(client, PREFERRED_MODEL_KEY, modelId),
|
|
1977
|
-
reasoningLevels,
|
|
1978
|
-
setReasoningLevel: (modelId, level) => {
|
|
1979
|
-
if (!modelId) return;
|
|
1980
|
-
void writePreference(
|
|
1981
|
-
client,
|
|
1982
|
-
MODEL_REASONING_LEVELS_KEY,
|
|
1983
|
-
JSON.stringify({ ...reasoningLevels, [modelId]: level })
|
|
1984
|
-
);
|
|
1985
|
-
}
|
|
1986
|
-
};
|
|
1987
|
-
}
|
|
1988
|
-
|
|
1989
|
-
// src/rich-input/services.tsx
|
|
1990
|
-
import { useMemo, useRef as useRef2 } from "react";
|
|
1991
|
-
function useModelCatalog() {
|
|
1992
|
-
const use = useRichInputServices().useModelCatalog ?? useClientModelCatalog;
|
|
1993
|
-
return use();
|
|
1994
|
-
}
|
|
1995
|
-
function useModelPreferences() {
|
|
1996
|
-
const use = useRichInputServices().useModelPreferences ?? useClientModelPreferences;
|
|
1997
|
-
return use();
|
|
1998
|
-
}
|
|
1999
|
-
function useSessionConnection(sessionId) {
|
|
2000
|
-
const connection = useSessionState(sessionId, (state) => state.connection);
|
|
2001
|
-
const status = sessionId ? connection : "connected";
|
|
2002
|
-
const everConnected = useRef2(false);
|
|
2003
|
-
if (status === "connected") everConnected.current = true;
|
|
2004
|
-
return { status, reconnectAttempt: 0, hasEverConnected: everConnected.current };
|
|
2005
|
-
}
|
|
2006
|
-
function useComposerConnectionInfo(sessionId) {
|
|
2007
|
-
const use = useRichInputServices().useConnection ?? useSessionConnection;
|
|
2008
|
-
return use(sessionId);
|
|
2009
|
-
}
|
|
2010
|
-
function useComposerConnection(sessionId) {
|
|
2011
|
-
return useComposerConnectionInfo(sessionId).status;
|
|
2012
|
-
}
|
|
2013
|
-
function useSessionSkills(sessionId) {
|
|
2014
|
-
const use = useRichInputServices().useSessionSkills ?? useClientSessionSkills;
|
|
2015
|
-
return use(sessionId);
|
|
2016
|
-
}
|
|
2017
|
-
function useSkillStats(sessionId) {
|
|
2018
|
-
const use = useRichInputServices().useSkillStats ?? useClientSkillStats;
|
|
2019
|
-
return use(sessionId);
|
|
2020
|
-
}
|
|
2021
|
-
function useContextStats(sessionId) {
|
|
2022
|
-
const use = useRichInputServices().useContextStats ?? useClientContextStats;
|
|
2023
|
-
return use(sessionId);
|
|
2024
|
-
}
|
|
2025
|
-
function useBackgroundTaskList(sessionId) {
|
|
2026
|
-
const use = useRichInputServices().useBackgroundTasks ?? useClientBackgroundTasks;
|
|
2027
|
-
return use(sessionId);
|
|
2028
|
-
}
|
|
2029
|
-
function useClientSessionDataInvalidation() {
|
|
2030
|
-
const client = useBladeClient();
|
|
2031
|
-
return useMemo(
|
|
2032
|
-
() => ({
|
|
2033
|
-
filesUploaded: (_sessionId) => {
|
|
2034
|
-
},
|
|
2035
|
-
pluginsChanged: (sessionId) => refreshClientSessionSkills(client, sessionId)
|
|
2036
|
-
}),
|
|
2037
|
-
[client]
|
|
2038
|
-
);
|
|
2039
|
-
}
|
|
2040
|
-
function useSessionDataInvalidation() {
|
|
2041
|
-
const use = useRichInputServices().useSessionDataInvalidation ?? useClientSessionDataInvalidation;
|
|
2042
|
-
return use();
|
|
2043
|
-
}
|
|
2044
|
-
|
|
2045
1665
|
// ../../node_modules/.pnpm/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/deep-compare-strict.js
|
|
2046
1666
|
function deepCompareStrict(a, b) {
|
|
2047
1667
|
const typeofa = typeof a;
|
|
@@ -7780,7 +7400,7 @@ function toFieldPathId(fieldPath, globalFormOptions, parentPath, isMultiValue) {
|
|
|
7780
7400
|
|
|
7781
7401
|
// ../../node_modules/.pnpm/@rjsf+utils@6.10.0_react@19.2.4/node_modules/@rjsf/utils/lib/useAltDateWidgetProps.js
|
|
7782
7402
|
import { jsx as _jsx3 } from "react/jsx-runtime";
|
|
7783
|
-
import { useCallback
|
|
7403
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
7784
7404
|
function readyForChange(state) {
|
|
7785
7405
|
return Object.values(state).every((value) => value !== -1);
|
|
7786
7406
|
}
|
|
@@ -7788,16 +7408,16 @@ function DateElement(props) {
|
|
|
7788
7408
|
const { className = "form-control", type, range, value, select, rootId, name, disabled, readonly, autofocus, registry, onBlur, onFocus } = props;
|
|
7789
7409
|
const id = `${rootId}_${type}`;
|
|
7790
7410
|
const { SelectWidget: SelectWidget2 } = registry.widgets;
|
|
7791
|
-
const onChange =
|
|
7411
|
+
const onChange = useCallback((newValue) => select(type, newValue), [select, type]);
|
|
7792
7412
|
return _jsx3(SelectWidget2, { schema: { type: "integer" }, id, name, className, options: { enumOptions: dateRangeOptions(range[0], range[1]) }, placeholder: type, value, disabled, readonly, autofocus, onChange, onBlur, onFocus, registry, label: "", "aria-describedby": ariaDescribedByIds(rootId) });
|
|
7793
7413
|
}
|
|
7794
7414
|
function useAltDateWidgetProps(props) {
|
|
7795
7415
|
const { time: time2 = false, disabled = false, readonly = false, options, onChange, value } = props;
|
|
7796
7416
|
const [state, setState] = useState(parseDateString(value, time2));
|
|
7797
|
-
|
|
7417
|
+
useEffect(() => {
|
|
7798
7418
|
setState(parseDateString(value, time2));
|
|
7799
7419
|
}, [time2, value]);
|
|
7800
|
-
const handleChange =
|
|
7420
|
+
const handleChange = useCallback((property, newValue) => {
|
|
7801
7421
|
const nextState = {
|
|
7802
7422
|
...state,
|
|
7803
7423
|
[property]: typeof newValue === "undefined" ? -1 : newValue
|
|
@@ -7808,14 +7428,14 @@ function useAltDateWidgetProps(props) {
|
|
|
7808
7428
|
setState(nextState);
|
|
7809
7429
|
}
|
|
7810
7430
|
}, [state, onChange, time2]);
|
|
7811
|
-
const handleClear =
|
|
7431
|
+
const handleClear = useCallback((event) => {
|
|
7812
7432
|
event.preventDefault();
|
|
7813
7433
|
if (disabled || readonly) {
|
|
7814
7434
|
return;
|
|
7815
7435
|
}
|
|
7816
7436
|
onChange(void 0);
|
|
7817
7437
|
}, [disabled, readonly, onChange]);
|
|
7818
|
-
const handleSetNow =
|
|
7438
|
+
const handleSetNow = useCallback((event) => {
|
|
7819
7439
|
event.preventDefault();
|
|
7820
7440
|
if (disabled || readonly) {
|
|
7821
7441
|
return;
|
|
@@ -7823,14 +7443,14 @@ function useAltDateWidgetProps(props) {
|
|
|
7823
7443
|
const nextState = parseDateString((/* @__PURE__ */ new Date()).toJSON(), time2);
|
|
7824
7444
|
onChange(toDateString(nextState, time2));
|
|
7825
7445
|
}, [disabled, readonly, time2, onChange]);
|
|
7826
|
-
const elements =
|
|
7446
|
+
const elements = useMemo(() => getDateElementProps(state, time2, options.yearsRange, options.format), [state, time2, options.yearsRange, options.format]);
|
|
7827
7447
|
return { elements, handleChange, handleClear, handleSetNow };
|
|
7828
7448
|
}
|
|
7829
7449
|
|
|
7830
7450
|
// ../../node_modules/.pnpm/@rjsf+utils@6.10.0_react@19.2.4/node_modules/@rjsf/utils/lib/useDeepCompareMemo.js
|
|
7831
|
-
import { useRef
|
|
7451
|
+
import { useRef } from "react";
|
|
7832
7452
|
function useDeepCompareMemo(newValue) {
|
|
7833
|
-
const valueRef =
|
|
7453
|
+
const valueRef = useRef(newValue);
|
|
7834
7454
|
if (!deepEquals_default(newValue, valueRef.current)) {
|
|
7835
7455
|
valueRef.current = newValue;
|
|
7836
7456
|
}
|
|
@@ -7838,7 +7458,7 @@ function useDeepCompareMemo(newValue) {
|
|
|
7838
7458
|
}
|
|
7839
7459
|
|
|
7840
7460
|
// ../../node_modules/.pnpm/@rjsf+utils@6.10.0_react@19.2.4/node_modules/@rjsf/utils/lib/useFileWidgetProps.js
|
|
7841
|
-
import { useCallback as
|
|
7461
|
+
import { useCallback as useCallback2, useMemo as useMemo2 } from "react";
|
|
7842
7462
|
function addNameToDataURL(dataURL, name) {
|
|
7843
7463
|
return dataURL.replace(";base64", `;name=${encodeURIComponent(name)};base64`);
|
|
7844
7464
|
}
|
|
@@ -7892,14 +7512,14 @@ function extractFileInfo(dataURLs) {
|
|
|
7892
7512
|
}, []);
|
|
7893
7513
|
}
|
|
7894
7514
|
function useFileWidgetProps(value, onChange, multiple = false) {
|
|
7895
|
-
const values =
|
|
7515
|
+
const values = useMemo2(() => {
|
|
7896
7516
|
if (multiple && value) {
|
|
7897
7517
|
return Array.isArray(value) ? value : [value];
|
|
7898
7518
|
}
|
|
7899
7519
|
return [];
|
|
7900
7520
|
}, [value, multiple]);
|
|
7901
|
-
const filesInfo =
|
|
7902
|
-
const handleChange =
|
|
7521
|
+
const filesInfo = useMemo2(() => Array.isArray(value) ? extractFileInfo(value) : extractFileInfo([value || ""]), [value]);
|
|
7522
|
+
const handleChange = useCallback2(async (files) => {
|
|
7903
7523
|
const filesInfoEvent = await processFiles(files);
|
|
7904
7524
|
const newValue = filesInfoEvent.map((fileInfo) => fileInfo.dataURL || null);
|
|
7905
7525
|
if (multiple) {
|
|
@@ -7908,7 +7528,7 @@ function useFileWidgetProps(value, onChange, multiple = false) {
|
|
|
7908
7528
|
onChange(newValue[0]);
|
|
7909
7529
|
}
|
|
7910
7530
|
}, [values, multiple, onChange]);
|
|
7911
|
-
const handleRemove =
|
|
7531
|
+
const handleRemove = useCallback2((index) => {
|
|
7912
7532
|
if (multiple) {
|
|
7913
7533
|
const newValue = values.filter((_, i) => i !== index);
|
|
7914
7534
|
onChange(newValue);
|
|
@@ -8024,7 +7644,7 @@ var TranslatableString;
|
|
|
8024
7644
|
|
|
8025
7645
|
// ../../node_modules/.pnpm/@rjsf+core@6.10.0_@rjsf+utils@6.10.0_react@19.2.4__react@19.2.4_vue@3.5.40_typescript@5.9.3_/node_modules/@rjsf/core/lib/components/fields/ArrayField.js
|
|
8026
7646
|
import { jsx as _jsx4 } from "react/jsx-runtime";
|
|
8027
|
-
import { memo, useCallback as
|
|
7647
|
+
import { memo, useCallback as useCallback3, useMemo as useMemo3, useRef as useRef2, useState as useState2 } from "react";
|
|
8028
7648
|
var rowIdCounter = 0;
|
|
8029
7649
|
function generateRowId() {
|
|
8030
7650
|
rowIdCounter += 1;
|
|
@@ -8118,8 +7738,8 @@ function ArrayAsFiles(props) {
|
|
|
8118
7738
|
function ArrayFieldItemInner(props) {
|
|
8119
7739
|
const { itemKey, index, name, disabled, hideError, readonly, registry, uiOptions, parentUiSchema, canAdd, canRemove = true, canMoveUp, canMoveDown, rawItemSchema, itemData, itemUiSchema, parentFieldPathId, itemErrorSchema, autofocus, onBlur, onFocus, onChange, rawErrors, totalItems, title, handleAddItem, handleCopyItem, handleRemoveItem, handleReorderItems } = props;
|
|
8120
7740
|
const { schemaUtils, fields: { ArraySchemaField, SchemaField: SchemaField2 }, globalUiOptions, globalFormOptions } = registry;
|
|
8121
|
-
const itemSchema =
|
|
8122
|
-
const fieldPathId =
|
|
7741
|
+
const itemSchema = useMemo3(() => schemaUtils.retrieveSchema(rawItemSchema, itemData), [schemaUtils, rawItemSchema, itemData]);
|
|
7742
|
+
const fieldPathId = useMemo3(() => toFieldPathId(index, globalFormOptions, parentFieldPathId), [index, globalFormOptions, parentFieldPathId]);
|
|
8123
7743
|
const ItemSchemaField = ArraySchemaField || SchemaField2;
|
|
8124
7744
|
const ArrayFieldItemTemplate2 = getTemplate("ArrayFieldItemTemplate", registry, uiOptions);
|
|
8125
7745
|
const displayLabel = schemaUtils.getDisplayLabel(itemSchema, itemUiSchema, globalUiOptions);
|
|
@@ -8134,19 +7754,19 @@ function ArrayFieldItemInner(props) {
|
|
|
8134
7754
|
toolbar: false
|
|
8135
7755
|
};
|
|
8136
7756
|
has.toolbar = Object.keys(has).some((key) => has[key]);
|
|
8137
|
-
const onAddItem =
|
|
7757
|
+
const onAddItem = useCallback3((event) => {
|
|
8138
7758
|
handleAddItem(event, index + 1);
|
|
8139
7759
|
}, [handleAddItem, index]);
|
|
8140
|
-
const onCopyItem =
|
|
7760
|
+
const onCopyItem = useCallback3((event) => {
|
|
8141
7761
|
handleCopyItem(event, index);
|
|
8142
7762
|
}, [handleCopyItem, index]);
|
|
8143
|
-
const onRemoveItem =
|
|
7763
|
+
const onRemoveItem = useCallback3((event) => {
|
|
8144
7764
|
handleRemoveItem(event, index);
|
|
8145
7765
|
}, [handleRemoveItem, index]);
|
|
8146
|
-
const onMoveUpItem =
|
|
7766
|
+
const onMoveUpItem = useCallback3((event) => {
|
|
8147
7767
|
handleReorderItems(event, index, index - 1);
|
|
8148
7768
|
}, [handleReorderItems, index]);
|
|
8149
|
-
const onMoveDownItem =
|
|
7769
|
+
const onMoveDownItem = useCallback3((event) => {
|
|
8150
7770
|
handleReorderItems(event, index, index + 1);
|
|
8151
7771
|
}, [handleReorderItems, index]);
|
|
8152
7772
|
const templateProps = {
|
|
@@ -8193,13 +7813,13 @@ function NormalArray(props) {
|
|
|
8193
7813
|
const fieldTitle = schema.title || title || name;
|
|
8194
7814
|
const { schemaUtils, fields: fields2, formContext, globalUiOptions } = registry;
|
|
8195
7815
|
const { OptionalDataControlsField: OptionalDataControlsField2 } = fields2;
|
|
8196
|
-
const uiOptions =
|
|
8197
|
-
const schemaItems =
|
|
8198
|
-
const itemsSchema =
|
|
8199
|
-
const formData =
|
|
7816
|
+
const uiOptions = useMemo3(() => getUiOptions(uiSchema, globalUiOptions), [uiSchema, globalUiOptions]);
|
|
7817
|
+
const schemaItems = useMemo3(() => isObject(schema.items) ? schema.items : {}, [schema.items]);
|
|
7818
|
+
const itemsSchema = useMemo3(() => schemaUtils.retrieveSchema(schemaItems), [schemaUtils, schemaItems]);
|
|
7819
|
+
const formData = useMemo3(() => keyedToPlainFormData(keyedFormData), [keyedFormData]);
|
|
8200
7820
|
const renderOptionalField = shouldRenderOptionalField(registry, schema, required, uiSchema);
|
|
8201
7821
|
const hasFormData = isFormDataAvailable(formDataFromProps);
|
|
8202
|
-
const canAdd =
|
|
7822
|
+
const canAdd = useMemo3(() => canAddItem(registry, schema, formData, uiSchema) && (!renderOptionalField || hasFormData), [registry, schema, formData, uiSchema, renderOptionalField, hasFormData]);
|
|
8203
7823
|
const actualFormData = hasFormData ? keyedFormData : [];
|
|
8204
7824
|
const extraClass = renderOptionalField ? " rjsf-optional-array-field" : "";
|
|
8205
7825
|
const childFieldPathId = props.childFieldPathId ?? fieldPathId;
|
|
@@ -8266,11 +7886,11 @@ function FixedArray(props) {
|
|
|
8266
7886
|
let { formData: items = [] } = props;
|
|
8267
7887
|
const fieldTitle = schema.title || title || name;
|
|
8268
7888
|
const { fields: fields2, formContext, globalUiOptions } = registry;
|
|
8269
|
-
const uiOptions =
|
|
7889
|
+
const uiOptions = useMemo3(() => getUiOptions(uiSchema, globalUiOptions), [uiSchema, globalUiOptions]);
|
|
8270
7890
|
const { OptionalDataControlsField: OptionalDataControlsField2 } = fields2;
|
|
8271
7891
|
const renderOptionalField = shouldRenderOptionalField(registry, schema, required, uiSchema);
|
|
8272
7892
|
const hasFormData = isFormDataAvailable(formData);
|
|
8273
|
-
const schemaItems =
|
|
7893
|
+
const schemaItems = useMemo3(() => Array.isArray(schema.items) ? schema.items : [], [schema.items]);
|
|
8274
7894
|
const hasAdditionalItems = isObject(schema.additionalItems);
|
|
8275
7895
|
const childFieldPathId = props.childFieldPathId ?? fieldPathId;
|
|
8276
7896
|
if (items.length < schemaItems.length) {
|
|
@@ -8349,7 +7969,7 @@ function FixedArray(props) {
|
|
|
8349
7969
|
return _jsx4(Template, { ...arrayProps });
|
|
8350
7970
|
}
|
|
8351
7971
|
function useKeyedFormData(formData = []) {
|
|
8352
|
-
const newHash =
|
|
7972
|
+
const newHash = useMemo3(() => hashObject(formData), [formData]);
|
|
8353
7973
|
const [state, setState] = useState2(() => ({
|
|
8354
7974
|
formDataHash: newHash,
|
|
8355
7975
|
keyedFormData: generateKeyedFormData(formData)
|
|
@@ -8365,7 +7985,7 @@ function useKeyedFormData(formData = []) {
|
|
|
8365
7985
|
formDataHash = newHash;
|
|
8366
7986
|
setState({ formDataHash, keyedFormData });
|
|
8367
7987
|
}
|
|
8368
|
-
const updateKeyedFormData =
|
|
7988
|
+
const updateKeyedFormData = useCallback3((newData) => {
|
|
8369
7989
|
const plainFormData = keyedToPlainFormData(newData);
|
|
8370
7990
|
const updatedHash = hashObject(plainFormData);
|
|
8371
7991
|
setState({ formDataHash: updatedHash, keyedFormData: newData });
|
|
@@ -8377,12 +7997,12 @@ function ArrayField(props) {
|
|
|
8377
7997
|
const { schema, uiSchema, errorSchema, fieldPathId, registry, formData, onChange } = props;
|
|
8378
7998
|
const { globalFormOptions, schemaUtils, translateString } = registry;
|
|
8379
7999
|
const { keyedFormData, updateKeyedFormData } = useKeyedFormData(formData);
|
|
8380
|
-
const keyedFormDataRef =
|
|
8000
|
+
const keyedFormDataRef = useRef2(keyedFormData);
|
|
8381
8001
|
keyedFormDataRef.current = keyedFormData;
|
|
8382
|
-
const errorSchemaRef =
|
|
8002
|
+
const errorSchemaRef = useRef2(errorSchema);
|
|
8383
8003
|
errorSchemaRef.current = errorSchema;
|
|
8384
8004
|
const childFieldPathId = props.childFieldPathId ?? fieldPathId;
|
|
8385
|
-
const handleAddItem =
|
|
8005
|
+
const handleAddItem = useCallback3((event, index) => {
|
|
8386
8006
|
if (event) {
|
|
8387
8007
|
event.preventDefault();
|
|
8388
8008
|
}
|
|
@@ -8410,7 +8030,7 @@ function ArrayField(props) {
|
|
|
8410
8030
|
}
|
|
8411
8031
|
onChange(updateKeyedFormData(newKeyedFormData), childFieldPathId.path, newErrorSchema);
|
|
8412
8032
|
}, [registry, schema, onChange, updateKeyedFormData, childFieldPathId]);
|
|
8413
|
-
const handleCopyItem =
|
|
8033
|
+
const handleCopyItem = useCallback3((event, index) => {
|
|
8414
8034
|
if (event) {
|
|
8415
8035
|
event.preventDefault();
|
|
8416
8036
|
}
|
|
@@ -8438,7 +8058,7 @@ function ArrayField(props) {
|
|
|
8438
8058
|
}
|
|
8439
8059
|
onChange(updateKeyedFormData(newKeyedFormData), childFieldPathId.path, newErrorSchema);
|
|
8440
8060
|
}, [onChange, updateKeyedFormData, childFieldPathId]);
|
|
8441
|
-
const handleRemoveItem =
|
|
8061
|
+
const handleRemoveItem = useCallback3((event, index) => {
|
|
8442
8062
|
if (event) {
|
|
8443
8063
|
event.preventDefault();
|
|
8444
8064
|
}
|
|
@@ -8457,7 +8077,7 @@ function ArrayField(props) {
|
|
|
8457
8077
|
const newKeyedFormData = keyedFormDataRef.current.filter((_, i) => i !== index);
|
|
8458
8078
|
onChange(updateKeyedFormData(newKeyedFormData), childFieldPathId.path, newErrorSchema);
|
|
8459
8079
|
}, [onChange, updateKeyedFormData, childFieldPathId]);
|
|
8460
|
-
const handleReorderItems =
|
|
8080
|
+
const handleReorderItems = useCallback3((event, index, newIndex) => {
|
|
8461
8081
|
if (event) {
|
|
8462
8082
|
event.preventDefault();
|
|
8463
8083
|
event.currentTarget.blur();
|
|
@@ -8485,7 +8105,7 @@ function ArrayField(props) {
|
|
|
8485
8105
|
const newKeyedFormData = reOrderArray();
|
|
8486
8106
|
onChange(updateKeyedFormData(newKeyedFormData), childFieldPathId.path, newErrorSchema);
|
|
8487
8107
|
}, [onChange, updateKeyedFormData, childFieldPathId]);
|
|
8488
|
-
const handleChange =
|
|
8108
|
+
const handleChange = useCallback3((value, path, newErrorSchema, id) => {
|
|
8489
8109
|
const lastPathIsItemIndex = typeof path.at(-1) === "number";
|
|
8490
8110
|
onChange(
|
|
8491
8111
|
// We need to treat undefined items as nulls to have validation.
|
|
@@ -8497,7 +8117,7 @@ function ArrayField(props) {
|
|
|
8497
8117
|
id
|
|
8498
8118
|
);
|
|
8499
8119
|
}, [onChange]);
|
|
8500
|
-
const onSelectChange =
|
|
8120
|
+
const onSelectChange = useCallback3((value) => {
|
|
8501
8121
|
onChange(value, childFieldPathId.path, void 0, childFieldPathId?.[ID_KEY]);
|
|
8502
8122
|
}, [onChange, childFieldPathId]);
|
|
8503
8123
|
const arrayAsMultiProps = {
|
|
@@ -8542,7 +8162,7 @@ function ArrayField(props) {
|
|
|
8542
8162
|
|
|
8543
8163
|
// ../../node_modules/.pnpm/@rjsf+core@6.10.0_@rjsf+utils@6.10.0_react@19.2.4__react@19.2.4_vue@3.5.40_typescript@5.9.3_/node_modules/@rjsf/core/lib/components/fields/BooleanField.js
|
|
8544
8164
|
import { jsx as _jsx5 } from "react/jsx-runtime";
|
|
8545
|
-
import { useCallback as
|
|
8165
|
+
import { useCallback as useCallback4 } from "react";
|
|
8546
8166
|
function BooleanField(props) {
|
|
8547
8167
|
const { schema, name, uiSchema, fieldPathId, formData, registry, required, disabled, readonly, hideError, autofocus, title, onChange, onFocus, onBlur, rawErrors } = props;
|
|
8548
8168
|
const { title: schemaTitle } = schema;
|
|
@@ -8590,7 +8210,7 @@ function BooleanField(props) {
|
|
|
8590
8210
|
enumOptions = optionsList({ enum: enums }, uiSchema);
|
|
8591
8211
|
}
|
|
8592
8212
|
}
|
|
8593
|
-
const onWidgetChange =
|
|
8213
|
+
const onWidgetChange = useCallback4((value, errorSchema, id) => onChange(value, fieldPathId.path, errorSchema, id), [onChange, fieldPathId]);
|
|
8594
8214
|
return _jsx5(Widget, { options: { ...options, enumOptions }, schema, uiSchema, id: fieldPathId.$id, name, onChange: onWidgetChange, onFocus, onBlur, label, hideLabel: !displayLabel, value: formData, required, disabled, readonly, hideError, registry, autofocus, rawErrors, htmlName: fieldPathId.name });
|
|
8595
8215
|
}
|
|
8596
8216
|
var BooleanField_default = BooleanField;
|
|
@@ -8614,7 +8234,7 @@ function CyclicSchemaField(props) {
|
|
|
8614
8234
|
|
|
8615
8235
|
// ../../node_modules/.pnpm/@rjsf+core@6.10.0_@rjsf+utils@6.10.0_react@19.2.4__react@19.2.4_vue@3.5.40_typescript@5.9.3_/node_modules/@rjsf/core/lib/components/fields/FallbackField.js
|
|
8616
8236
|
import { jsx as _jsx7 } from "react/jsx-runtime";
|
|
8617
|
-
import { useMemo as
|
|
8237
|
+
import { useMemo as useMemo4, useState as useState4 } from "react";
|
|
8618
8238
|
function getFallbackTypeSelectionSchema(title) {
|
|
8619
8239
|
return {
|
|
8620
8240
|
type: "string",
|
|
@@ -8654,7 +8274,7 @@ function FallbackField(props) {
|
|
|
8654
8274
|
const uiOptions = getUiOptions(uiSchema);
|
|
8655
8275
|
const typeSelectorInnerFieldPathId = useDeepCompareMemo(toFieldPathId("__internal_type_selector", globalFormOptions, fieldPathId));
|
|
8656
8276
|
const schemaTitle = translateString(TranslatableString.Type);
|
|
8657
|
-
const typesOptionSchema =
|
|
8277
|
+
const typesOptionSchema = useMemo4(() => getFallbackTypeSelectionSchema(schemaTitle), [schemaTitle]);
|
|
8658
8278
|
const onTypeChange = (newType) => {
|
|
8659
8279
|
if (newType != null) {
|
|
8660
8280
|
setType(newType);
|
|
@@ -8993,7 +8613,7 @@ function LayoutHeaderField(props) {
|
|
|
8993
8613
|
|
|
8994
8614
|
// ../../node_modules/.pnpm/@rjsf+core@6.10.0_@rjsf+utils@6.10.0_react@19.2.4__react@19.2.4_vue@3.5.40_typescript@5.9.3_/node_modules/@rjsf/core/lib/components/fields/LayoutMultiSchemaField.js
|
|
8995
8615
|
import { jsx as _jsx10 } from "react/jsx-runtime";
|
|
8996
|
-
import { useState as useState5, useEffect as
|
|
8616
|
+
import { useState as useState5, useEffect as useEffect2 } from "react";
|
|
8997
8617
|
function getSelectedOption(options, selectorField, value) {
|
|
8998
8618
|
const defaultValue = "!@#!@$@#$!@$#";
|
|
8999
8619
|
const schemaOptions = options.map(({ schema }) => schema);
|
|
@@ -9029,7 +8649,7 @@ function LayoutMultiSchemaField(props) {
|
|
|
9029
8649
|
const optionsHash = hashObject(options);
|
|
9030
8650
|
const uiSchemaHash = uiSchema ? hashObject(uiSchema) : "";
|
|
9031
8651
|
const formDataHash = formData ? hashObject(formData) : "";
|
|
9032
|
-
|
|
8652
|
+
useEffect2(() => {
|
|
9033
8653
|
setEnumOptions(computeEnumOptions(schema, options, schemaUtils, uiSchema, formData));
|
|
9034
8654
|
}, [schemaHash, optionsHash, schemaUtils, uiSchemaHash, formDataHash]);
|
|
9035
8655
|
const { widget = discriminator ? "radio" : "select", title = "", placeholder = "", optionsSchemaSelector: selectorField = discriminator, hideError: uiSchemaHideError, ...uiOptions } = getUiOptions(uiSchema);
|
|
@@ -9068,12 +8688,12 @@ function LayoutMultiSchemaField(props) {
|
|
|
9068
8688
|
|
|
9069
8689
|
// ../../node_modules/.pnpm/@rjsf+core@6.10.0_@rjsf+utils@6.10.0_react@19.2.4__react@19.2.4_vue@3.5.40_typescript@5.9.3_/node_modules/@rjsf/core/lib/components/fields/MultiSchemaField.js
|
|
9070
8690
|
import { jsx as _jsx11 } from "react/jsx-runtime";
|
|
9071
|
-
import { useCallback as
|
|
8691
|
+
import { useCallback as useCallback5, useEffect as useEffect3, useMemo as useMemo5, useRef as useRef3, useState as useState6 } from "react";
|
|
9072
8692
|
function AnyOfField(props) {
|
|
9073
8693
|
const { name, disabled = false, errorSchema, formData, fieldPathId, onBlur, onChange, onFocus, options, readonly, registry, required = false, schema, uiSchema } = props;
|
|
9074
8694
|
const { schemaUtils } = registry;
|
|
9075
8695
|
const formDataHash = hashObject(formData ?? null);
|
|
9076
|
-
const retrievedOptions =
|
|
8696
|
+
const retrievedOptions = useMemo5(
|
|
9077
8697
|
() => options.map((opt) => schemaUtils.retrieveSchema(opt, formData)),
|
|
9078
8698
|
// oxlint-disable-next-line react-hooks/exhaustive-deps -- formDataHash is the value-stable proxy for formData
|
|
9079
8699
|
[options, schemaUtils, formDataHash]
|
|
@@ -9082,10 +8702,10 @@ function AnyOfField(props) {
|
|
|
9082
8702
|
const discriminator = getDiscriminatorFieldFromSchema(schema);
|
|
9083
8703
|
return schemaUtils.getClosestMatchingOption(formData, retrievedOptions, 0, discriminator);
|
|
9084
8704
|
});
|
|
9085
|
-
const skipNextOptionRecalculation =
|
|
9086
|
-
const prevFormDataRef =
|
|
9087
|
-
const prevFieldIdRef =
|
|
9088
|
-
|
|
8705
|
+
const skipNextOptionRecalculation = useRef3(false);
|
|
8706
|
+
const prevFormDataRef = useRef3(formData);
|
|
8707
|
+
const prevFieldIdRef = useRef3(fieldPathId.$id);
|
|
8708
|
+
useEffect3(() => {
|
|
9089
8709
|
const prevFormData = prevFormDataRef.current;
|
|
9090
8710
|
const prevFieldId = prevFieldIdRef.current;
|
|
9091
8711
|
prevFormDataRef.current = formData;
|
|
@@ -9103,7 +8723,7 @@ function AnyOfField(props) {
|
|
|
9103
8723
|
}
|
|
9104
8724
|
});
|
|
9105
8725
|
const fieldId = `${fieldPathId.$id}${schema.oneOf ? "__oneof_select" : "__anyof_select"}`;
|
|
9106
|
-
const onOptionChange =
|
|
8726
|
+
const onOptionChange = useCallback5(
|
|
9107
8727
|
(option2) => {
|
|
9108
8728
|
if (disabled || readonly) {
|
|
9109
8729
|
return;
|
|
@@ -9183,10 +8803,10 @@ function AnyOfField(props) {
|
|
|
9183
8803
|
var MultiSchemaField_default = AnyOfField;
|
|
9184
8804
|
|
|
9185
8805
|
// ../../node_modules/.pnpm/@rjsf+core@6.10.0_@rjsf+utils@6.10.0_react@19.2.4__react@19.2.4_vue@3.5.40_typescript@5.9.3_/node_modules/@rjsf/core/lib/components/fields/NullField.js
|
|
9186
|
-
import { useEffect as
|
|
8806
|
+
import { useEffect as useEffect4 } from "react";
|
|
9187
8807
|
function NullField(props) {
|
|
9188
8808
|
const { formData, onChange, fieldPathId } = props;
|
|
9189
|
-
|
|
8809
|
+
useEffect4(() => {
|
|
9190
8810
|
if (formData === void 0) {
|
|
9191
8811
|
onChange(null, fieldPathId.path);
|
|
9192
8812
|
}
|
|
@@ -9197,7 +8817,7 @@ var NullField_default = NullField;
|
|
|
9197
8817
|
|
|
9198
8818
|
// ../../node_modules/.pnpm/@rjsf+core@6.10.0_@rjsf+utils@6.10.0_react@19.2.4__react@19.2.4_vue@3.5.40_typescript@5.9.3_/node_modules/@rjsf/core/lib/components/fields/NumberField.js
|
|
9199
8819
|
import { jsx as _jsx12 } from "react/jsx-runtime";
|
|
9200
|
-
import { useState as useState7, useCallback as
|
|
8820
|
+
import { useState as useState7, useCallback as useCallback6 } from "react";
|
|
9201
8821
|
var trailingCharMatcherWithPrefix = /\.([0-9]*0)*$/;
|
|
9202
8822
|
var trailingCharMatcher = /[0.]0*$/;
|
|
9203
8823
|
function NumberField(props) {
|
|
@@ -9207,7 +8827,7 @@ function NumberField(props) {
|
|
|
9207
8827
|
const separator = getDecimalSeparator();
|
|
9208
8828
|
const escapedSeparator = separator === "." ? "\\." : separator;
|
|
9209
8829
|
let value = formData;
|
|
9210
|
-
const handleChange =
|
|
8830
|
+
const handleChange = useCallback6((newValue, path, errorSchema, id) => {
|
|
9211
8831
|
setLastValue(newValue);
|
|
9212
8832
|
const standardValue = typeof newValue === "string" ? newValue.replace(separator, ".") : newValue;
|
|
9213
8833
|
const normalizedValue = `${standardValue}`.startsWith(".") ? `0${standardValue}` : standardValue;
|
|
@@ -9237,7 +8857,7 @@ var NumberField_default = NumberField;
|
|
|
9237
8857
|
|
|
9238
8858
|
// ../../node_modules/.pnpm/@rjsf+core@6.10.0_@rjsf+utils@6.10.0_react@19.2.4__react@19.2.4_vue@3.5.40_typescript@5.9.3_/node_modules/@rjsf/core/lib/components/fields/ObjectField.js
|
|
9239
8859
|
import { jsx as _jsx13, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9240
|
-
import { memo as memo2, useCallback as
|
|
8860
|
+
import { memo as memo2, useCallback as useCallback7, useMemo as useMemo7, useRef as useRef5, useState as useState8 } from "react";
|
|
9241
8861
|
|
|
9242
8862
|
// ../../node_modules/.pnpm/markdown-to-jsx@9.10.2_react@19.2.4_vue@3.5.40_typescript@5.9.3_/node_modules/markdown-to-jsx/dist/react.js
|
|
9243
8863
|
import * as i0 from "react";
|
|
@@ -12376,24 +11996,24 @@ function ObjectFieldPropertyFn(props) {
|
|
|
12376
11996
|
const { globalFormOptions, fields: fields2 } = registry;
|
|
12377
11997
|
const { SchemaField: SchemaField2 } = fields2;
|
|
12378
11998
|
const innerFieldIdPathId = useDeepCompareMemo(toFieldPathId(propertyName, globalFormOptions, fieldPathId.path));
|
|
12379
|
-
const onPropertyChange =
|
|
11999
|
+
const onPropertyChange = useCallback7((value, path, newErrorSchema, id) => {
|
|
12380
12000
|
let normalizedValue = value;
|
|
12381
12001
|
if (value === void 0 && addedByAdditionalProperties && deepEquals_default(path, innerFieldIdPathId.path)) {
|
|
12382
12002
|
normalizedValue = "";
|
|
12383
12003
|
}
|
|
12384
12004
|
onChange(normalizedValue, path, newErrorSchema, id);
|
|
12385
12005
|
}, [onChange, addedByAdditionalProperties, innerFieldIdPathId]);
|
|
12386
|
-
const onKeyRename =
|
|
12006
|
+
const onKeyRename = useCallback7((value) => {
|
|
12387
12007
|
if (propertyName !== value) {
|
|
12388
12008
|
setWasPropertyKeyModified(true);
|
|
12389
12009
|
}
|
|
12390
12010
|
handleKeyRename(propertyName, value);
|
|
12391
12011
|
}, [propertyName, handleKeyRename]);
|
|
12392
|
-
const onKeyRenameBlur =
|
|
12012
|
+
const onKeyRenameBlur = useCallback7((event) => {
|
|
12393
12013
|
const { target: { value } } = event;
|
|
12394
12014
|
onKeyRename(value);
|
|
12395
12015
|
}, [onKeyRename]);
|
|
12396
|
-
const onRemoveProperty =
|
|
12016
|
+
const onRemoveProperty = useCallback7(() => {
|
|
12397
12017
|
handleRemoveProperty(propertyName);
|
|
12398
12018
|
}, [propertyName, handleRemoveProperty]);
|
|
12399
12019
|
return _jsx13(SchemaField2, { name: propertyName, required, schema, uiSchema, errorSchema, fieldPathId: innerFieldIdPathId, formData, wasPropertyKeyModified, onKeyRename, onKeyRenameBlur, onRemoveProperty, onChange: onPropertyChange, onBlur, onFocus, registry, disabled, readonly, hideError });
|
|
@@ -12403,15 +12023,15 @@ function ObjectField(props) {
|
|
|
12403
12023
|
const { schema: rawSchema, uiSchema = {}, formData, errorSchema, fieldPathId, name, required = false, disabled, readonly, hideError, onBlur, onFocus, onChange, registry, title } = props;
|
|
12404
12024
|
const { fields: fields2, schemaUtils, translateString, globalUiOptions } = registry;
|
|
12405
12025
|
const { OptionalDataControlsField: OptionalDataControlsField2 } = fields2;
|
|
12406
|
-
const formDataRef =
|
|
12026
|
+
const formDataRef = useRef5(formData);
|
|
12407
12027
|
formDataRef.current = formData;
|
|
12408
|
-
const schema =
|
|
12409
|
-
const uiOptions =
|
|
12410
|
-
const schemaProperties =
|
|
12028
|
+
const schema = useMemo7(() => schemaUtils.retrieveSchema(rawSchema, formData, true), [schemaUtils, rawSchema, formData]);
|
|
12029
|
+
const uiOptions = useMemo7(() => getUiOptions(uiSchema, globalUiOptions), [uiSchema, globalUiOptions]);
|
|
12030
|
+
const schemaProperties = useMemo7(() => schema.properties ?? {}, [schema.properties]);
|
|
12411
12031
|
const childFieldPathId = props.childFieldPathId ?? fieldPathId;
|
|
12412
|
-
const lastRenamedProperty =
|
|
12032
|
+
const lastRenamedProperty = useRef5({ previousKey: "", currentKey: void 0 });
|
|
12413
12033
|
const [additionalPropertyOrder, setAdditionalPropertyOrder] = useState8(() => getAdditionalPropertyOrder(schemaProperties));
|
|
12414
|
-
const definedPropertyOrder =
|
|
12034
|
+
const definedPropertyOrder = useMemo7(() => {
|
|
12415
12035
|
const additionalPropertySet = new Set(getAdditionalPropertyOrder(schemaProperties));
|
|
12416
12036
|
return Object.keys(schemaProperties).filter((property) => !additionalPropertySet.has(property));
|
|
12417
12037
|
}, [schemaProperties]);
|
|
@@ -12420,7 +12040,7 @@ function ObjectField(props) {
|
|
|
12420
12040
|
const renderOptionalField = shouldRenderOptionalField(registry, schema, required, uiSchema);
|
|
12421
12041
|
const hasFormData = isFormDataAvailable(formData);
|
|
12422
12042
|
let orderedProperties = [];
|
|
12423
|
-
const getAvailableKey =
|
|
12043
|
+
const getAvailableKey = useCallback7((preferredKey, existingFormData) => {
|
|
12424
12044
|
const { duplicateKeySuffixSeparator = "-" } = getUiOptions(uiSchema, globalUiOptions);
|
|
12425
12045
|
let index = 0;
|
|
12426
12046
|
let newKey = preferredKey;
|
|
@@ -12430,7 +12050,7 @@ function ObjectField(props) {
|
|
|
12430
12050
|
}
|
|
12431
12051
|
return newKey;
|
|
12432
12052
|
}, [uiSchema, globalUiOptions]);
|
|
12433
|
-
const onAddProperty =
|
|
12053
|
+
const onAddProperty = useCallback7(() => {
|
|
12434
12054
|
if (!(schema.additionalProperties || schema.patternProperties)) {
|
|
12435
12055
|
return;
|
|
12436
12056
|
}
|
|
@@ -12467,7 +12087,7 @@ function ObjectField(props) {
|
|
|
12467
12087
|
setAdditionalPropertyOrder((order) => [...order, newKey]);
|
|
12468
12088
|
onChange(newFormData, childFieldPathId.path);
|
|
12469
12089
|
}, [formData, onChange, translateString, schemaUtils, childFieldPathId, getAvailableKey, schema]);
|
|
12470
|
-
const handleKeyRename =
|
|
12090
|
+
const handleKeyRename = useCallback7((oldKey, newKey) => {
|
|
12471
12091
|
if (oldKey !== newKey) {
|
|
12472
12092
|
const currentFormData = formDataRef.current;
|
|
12473
12093
|
const actualNewKey = getAvailableKey(newKey, currentFormData);
|
|
@@ -12489,11 +12109,11 @@ function ObjectField(props) {
|
|
|
12489
12109
|
onChange(renamedObj, childFieldPathId.path);
|
|
12490
12110
|
}
|
|
12491
12111
|
}, [onChange, childFieldPathId, getAvailableKey]);
|
|
12492
|
-
const handleRemoveProperty =
|
|
12112
|
+
const handleRemoveProperty = useCallback7((key) => {
|
|
12493
12113
|
setAdditionalPropertyOrder((order) => order.filter((property) => property !== key));
|
|
12494
12114
|
onChange(ADDITIONAL_PROPERTY_KEY_REMOVE, [...childFieldPathId.path, key]);
|
|
12495
12115
|
}, [onChange, childFieldPathId]);
|
|
12496
|
-
const getStableKey =
|
|
12116
|
+
const getStableKey = useCallback7((property) => {
|
|
12497
12117
|
if (lastRenamedProperty.current.currentKey === property) {
|
|
12498
12118
|
return lastRenamedProperty.current.previousKey;
|
|
12499
12119
|
}
|
|
@@ -12580,7 +12200,7 @@ function OptionalDataControlsField(props) {
|
|
|
12580
12200
|
|
|
12581
12201
|
// ../../node_modules/.pnpm/@rjsf+core@6.10.0_@rjsf+utils@6.10.0_react@19.2.4__react@19.2.4_vue@3.5.40_typescript@5.9.3_/node_modules/@rjsf/core/lib/components/fields/SchemaField.js
|
|
12582
12202
|
import { jsx as _jsx15, Fragment as _Fragment, jsxs as _jsxs2 } from "react/jsx-runtime";
|
|
12583
|
-
import { useCallback as
|
|
12203
|
+
import { useCallback as useCallback8, memo as memo3 } from "react";
|
|
12584
12204
|
var COMPONENT_TYPES = {
|
|
12585
12205
|
array: "ArrayField",
|
|
12586
12206
|
boolean: "BooleanField",
|
|
@@ -12616,7 +12236,7 @@ function SchemaFieldRender(props) {
|
|
|
12616
12236
|
const { schemaUtils, globalFormOptions, globalUiOptions, fields: fields2 } = registry;
|
|
12617
12237
|
const { AnyOfField: _AnyOfField, OneOfField: _OneOfField, CyclicSchemaField: CyclicSchemaField2 } = fields2;
|
|
12618
12238
|
const fieldId = fieldPathId[ID_KEY];
|
|
12619
|
-
const handleFieldComponentChange =
|
|
12239
|
+
const handleFieldComponentChange = useCallback8((newFormData, path, newErrorSchema, id2) => {
|
|
12620
12240
|
const theId = id2 || fieldId;
|
|
12621
12241
|
return onChange(newFormData, path, newErrorSchema, theId);
|
|
12622
12242
|
}, [fieldId, onChange]);
|
|
@@ -12736,7 +12356,7 @@ var SchemaField_default = SchemaField;
|
|
|
12736
12356
|
|
|
12737
12357
|
// ../../node_modules/.pnpm/@rjsf+core@6.10.0_@rjsf+utils@6.10.0_react@19.2.4__react@19.2.4_vue@3.5.40_typescript@5.9.3_/node_modules/@rjsf/core/lib/components/fields/StringField.js
|
|
12738
12358
|
import { jsx as _jsx16 } from "react/jsx-runtime";
|
|
12739
|
-
import { useCallback as
|
|
12359
|
+
import { useCallback as useCallback9 } from "react";
|
|
12740
12360
|
function StringField(props) {
|
|
12741
12361
|
const { schema, name, uiSchema, fieldPathId, formData, required, disabled = false, readonly = false, autofocus = false, onChange, onBlur, onFocus, registry, rawErrors, hideError, title } = props;
|
|
12742
12362
|
const { title: schemaTitle, format: format2 } = schema;
|
|
@@ -12750,7 +12370,7 @@ function StringField(props) {
|
|
|
12750
12370
|
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
12751
12371
|
const label = uiTitle ?? title ?? schemaTitle ?? name;
|
|
12752
12372
|
const Widget = getWidget(schema, widget, widgets2);
|
|
12753
|
-
const onWidgetChange =
|
|
12373
|
+
const onWidgetChange = useCallback9((value, errorSchema, id) => onChange(value, fieldPathId.path, errorSchema, id), [onChange, fieldPathId]);
|
|
12754
12374
|
return _jsx16(Widget, { options: { ...options, enumOptions }, schema, uiSchema, id: fieldPathId.$id, name, label, hideLabel: !displayLabel, hideError, value: formData, onChange: onWidgetChange, onBlur, onFocus, required, disabled, readonly, autofocus, registry, placeholder, rawErrors, htmlName: fieldPathId.name });
|
|
12755
12375
|
}
|
|
12756
12376
|
var StringField_default = StringField;
|
|
@@ -12844,7 +12464,7 @@ function ArrayFieldTitleTemplate(props) {
|
|
|
12844
12464
|
|
|
12845
12465
|
// ../../node_modules/.pnpm/@rjsf+core@6.10.0_@rjsf+utils@6.10.0_react@19.2.4__react@19.2.4_vue@3.5.40_typescript@5.9.3_/node_modules/@rjsf/core/lib/components/templates/BaseInputTemplate.js
|
|
12846
12466
|
import { jsx as _jsx23, Fragment as _Fragment3, jsxs as _jsxs6 } from "react/jsx-runtime";
|
|
12847
|
-
import { useCallback as
|
|
12467
|
+
import { useCallback as useCallback10 } from "react";
|
|
12848
12468
|
|
|
12849
12469
|
// ../../node_modules/.pnpm/@rjsf+core@6.10.0_@rjsf+utils@6.10.0_react@19.2.4__react@19.2.4_vue@3.5.40_typescript@5.9.3_/node_modules/@rjsf/core/lib/components/SchemaExamples.js
|
|
12850
12470
|
import { jsx as _jsx22 } from "react/jsx-runtime";
|
|
@@ -12899,10 +12519,10 @@ function BaseInputTemplate(props) {
|
|
|
12899
12519
|
} else {
|
|
12900
12520
|
inputValue = value == null ? "" : value;
|
|
12901
12521
|
}
|
|
12902
|
-
const handleChange =
|
|
12903
|
-
const handleBlur =
|
|
12904
|
-
const handleFocus =
|
|
12905
|
-
const handleClear =
|
|
12522
|
+
const handleChange = useCallback10(({ target: { value: newValue } }) => onChange(newValue === "" ? options.emptyValue : newValue), [onChange, options]);
|
|
12523
|
+
const handleBlur = useCallback10(({ target }) => onBlur(id, target?.value), [onBlur, id]);
|
|
12524
|
+
const handleFocus = useCallback10(({ target }) => onFocus(id, target?.value), [onFocus, id]);
|
|
12525
|
+
const handleClear = useCallback10((e2) => {
|
|
12906
12526
|
e2.preventDefault();
|
|
12907
12527
|
e2.stopPropagation();
|
|
12908
12528
|
onChange(options.emptyValue);
|
|
@@ -13231,13 +12851,13 @@ var AltDateWidget_default = AltDateWidget;
|
|
|
13231
12851
|
|
|
13232
12852
|
// ../../node_modules/.pnpm/@rjsf+core@6.10.0_@rjsf+utils@6.10.0_react@19.2.4__react@19.2.4_vue@3.5.40_typescript@5.9.3_/node_modules/@rjsf/core/lib/components/widgets/CheckboxesWidget.js
|
|
13233
12853
|
import { jsx as _jsx46, jsxs as _jsxs17 } from "react/jsx-runtime";
|
|
13234
|
-
import { useCallback as
|
|
12854
|
+
import { useCallback as useCallback11 } from "react";
|
|
13235
12855
|
function CheckboxesWidget({ id, disabled, options, value, autofocus = false, readonly, onChange, onBlur, onFocus, htmlName }) {
|
|
13236
12856
|
const { inline = false, enumOptions, enumDisabled, emptyValue } = options;
|
|
13237
12857
|
const optionValueFormat = getOptionValueFormat(options);
|
|
13238
12858
|
const checkboxesValues = Array.isArray(value) ? value : [value];
|
|
13239
|
-
const handleBlur =
|
|
13240
|
-
const handleFocus =
|
|
12859
|
+
const handleBlur = useCallback11(({ target }) => onBlur(id, enumOptionValueDecoder(target?.value, enumOptions, optionValueFormat, emptyValue)), [onBlur, id, enumOptions, emptyValue, optionValueFormat]);
|
|
12860
|
+
const handleFocus = useCallback11(({ target }) => onFocus(id, enumOptionValueDecoder(target?.value, enumOptions, optionValueFormat, emptyValue)), [onFocus, id, enumOptions, emptyValue, optionValueFormat]);
|
|
13241
12861
|
return _jsx46("div", { className: "checkboxes", id, children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
|
|
13242
12862
|
const checked = enumOptionsIsSelected(option.value, checkboxesValues);
|
|
13243
12863
|
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.includes(option.value);
|
|
@@ -13257,13 +12877,13 @@ var CheckboxesWidget_default = CheckboxesWidget;
|
|
|
13257
12877
|
|
|
13258
12878
|
// ../../node_modules/.pnpm/@rjsf+core@6.10.0_@rjsf+utils@6.10.0_react@19.2.4__react@19.2.4_vue@3.5.40_typescript@5.9.3_/node_modules/@rjsf/core/lib/components/widgets/CheckboxWidget.js
|
|
13259
12879
|
import { jsx as _jsx47, jsxs as _jsxs18 } from "react/jsx-runtime";
|
|
13260
|
-
import { useCallback as
|
|
12880
|
+
import { useCallback as useCallback12 } from "react";
|
|
13261
12881
|
function CheckboxWidget({ schema, uiSchema, options, id, value, disabled, readonly, label, hideLabel, autofocus = false, onBlur, onFocus, onChange, registry, htmlName, required }) {
|
|
13262
12882
|
const DescriptionFieldTemplate = getTemplate("DescriptionFieldTemplate", registry, options);
|
|
13263
12883
|
const trueValueRequired = schemaRequiresTrueValue(schema) && required;
|
|
13264
|
-
const handleChange =
|
|
13265
|
-
const handleBlur =
|
|
13266
|
-
const handleFocus =
|
|
12884
|
+
const handleChange = useCallback12((event) => onChange(event.target.checked), [onChange]);
|
|
12885
|
+
const handleBlur = useCallback12((event) => onBlur(id, event.target.checked), [onBlur, id]);
|
|
12886
|
+
const handleFocus = useCallback12((event) => onFocus(id, event.target.checked), [onFocus, id]);
|
|
13267
12887
|
const uiOptions = getUiOptions(uiSchema);
|
|
13268
12888
|
const isCheckboxWidget = uiOptions.widget === "checkbox";
|
|
13269
12889
|
const description = isCheckboxWidget ? void 0 : options.description ?? schema.description;
|
|
@@ -13289,11 +12909,11 @@ function DateTimeWidget(props) {
|
|
|
13289
12909
|
|
|
13290
12910
|
// ../../node_modules/.pnpm/@rjsf+core@6.10.0_@rjsf+utils@6.10.0_react@19.2.4__react@19.2.4_vue@3.5.40_typescript@5.9.3_/node_modules/@rjsf/core/lib/components/widgets/DateWidget.js
|
|
13291
12911
|
import { jsx as _jsx50 } from "react/jsx-runtime";
|
|
13292
|
-
import { useCallback as
|
|
12912
|
+
import { useCallback as useCallback13 } from "react";
|
|
13293
12913
|
function DateWidget(props) {
|
|
13294
12914
|
const { onChange, options, registry } = props;
|
|
13295
12915
|
const BaseInputTemplate2 = getTemplate("BaseInputTemplate", registry, options);
|
|
13296
|
-
const handleChange =
|
|
12916
|
+
const handleChange = useCallback13((value) => onChange(value || void 0), [onChange]);
|
|
13297
12917
|
return _jsx50(BaseInputTemplate2, { type: "date", ...props, onChange: handleChange });
|
|
13298
12918
|
}
|
|
13299
12919
|
|
|
@@ -13361,12 +12981,12 @@ function PasswordWidget(props) {
|
|
|
13361
12981
|
|
|
13362
12982
|
// ../../node_modules/.pnpm/@rjsf+core@6.10.0_@rjsf+utils@6.10.0_react@19.2.4__react@19.2.4_vue@3.5.40_typescript@5.9.3_/node_modules/@rjsf/core/lib/components/widgets/RadioWidget.js
|
|
13363
12983
|
import { jsx as _jsx55, jsxs as _jsxs20 } from "react/jsx-runtime";
|
|
13364
|
-
import { useCallback as
|
|
12984
|
+
import { useCallback as useCallback14 } from "react";
|
|
13365
12985
|
function RadioWidget({ options, value, required, disabled, readonly, autofocus = false, onBlur, onFocus, onChange, id, htmlName }) {
|
|
13366
12986
|
const { enumOptions, enumDisabled, inline, emptyValue } = options;
|
|
13367
12987
|
const optionValueFormat = getOptionValueFormat(options);
|
|
13368
|
-
const handleBlur =
|
|
13369
|
-
const handleFocus =
|
|
12988
|
+
const handleBlur = useCallback14(({ target }) => onBlur(id, enumOptionValueDecoder(target?.value, enumOptions, optionValueFormat, emptyValue)), [onBlur, enumOptions, emptyValue, id, optionValueFormat]);
|
|
12989
|
+
const handleFocus = useCallback14(({ target }) => onFocus(id, enumOptionValueDecoder(target?.value, enumOptions, optionValueFormat, emptyValue)), [onFocus, enumOptions, emptyValue, id, optionValueFormat]);
|
|
13370
12990
|
return _jsx55("div", { className: "field-radio-group", id, role: "radiogroup", children: Array.isArray(enumOptions) && enumOptions.map((option, i) => {
|
|
13371
12991
|
const checked = enumOptionsIsSelected(option.value, value);
|
|
13372
12992
|
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.includes(option.value);
|
|
@@ -13387,23 +13007,23 @@ function RangeWidget(props) {
|
|
|
13387
13007
|
|
|
13388
13008
|
// ../../node_modules/.pnpm/@rjsf+core@6.10.0_@rjsf+utils@6.10.0_react@19.2.4__react@19.2.4_vue@3.5.40_typescript@5.9.3_/node_modules/@rjsf/core/lib/components/widgets/RatingWidget.js
|
|
13389
13009
|
import { jsx as _jsx57, jsxs as _jsxs22 } from "react/jsx-runtime";
|
|
13390
|
-
import { useCallback as
|
|
13010
|
+
import { useCallback as useCallback15 } from "react";
|
|
13391
13011
|
function RatingWidget({ id, value, required, disabled, readonly, onChange, onFocus, onBlur, schema, options, htmlName }) {
|
|
13392
13012
|
const { stars = 5, shape = "star" } = options;
|
|
13393
13013
|
const numStars = schema.maximum ? Math.min(schema.maximum, 5) : Math.min(Math.max(stars, 1), 5);
|
|
13394
13014
|
const min = schema.minimum || 0;
|
|
13395
|
-
const handleStarClick =
|
|
13015
|
+
const handleStarClick = useCallback15((starValue) => {
|
|
13396
13016
|
if (!disabled && !readonly) {
|
|
13397
13017
|
onChange(starValue);
|
|
13398
13018
|
}
|
|
13399
13019
|
}, [onChange, disabled, readonly]);
|
|
13400
|
-
const handleFocus =
|
|
13020
|
+
const handleFocus = useCallback15((event) => {
|
|
13401
13021
|
if (onFocus) {
|
|
13402
13022
|
const starValue = Number(event.target.dataset.value);
|
|
13403
13023
|
onFocus(id, starValue);
|
|
13404
13024
|
}
|
|
13405
13025
|
}, [onFocus, id]);
|
|
13406
|
-
const handleBlur =
|
|
13026
|
+
const handleBlur = useCallback15((event) => {
|
|
13407
13027
|
if (onBlur) {
|
|
13408
13028
|
const starValue = Number(event.target.dataset.value);
|
|
13409
13029
|
onBlur(id, starValue);
|
|
@@ -13433,7 +13053,7 @@ function RatingWidget({ id, value, required, disabled, readonly, onChange, onFoc
|
|
|
13433
13053
|
|
|
13434
13054
|
// ../../node_modules/.pnpm/@rjsf+core@6.10.0_@rjsf+utils@6.10.0_react@19.2.4__react@19.2.4_vue@3.5.40_typescript@5.9.3_/node_modules/@rjsf/core/lib/components/widgets/SelectWidget.js
|
|
13435
13055
|
import { jsx as _jsx58, jsxs as _jsxs23, Fragment as _Fragment5 } from "react/jsx-runtime";
|
|
13436
|
-
import { useCallback as
|
|
13056
|
+
import { useCallback as useCallback16 } from "react";
|
|
13437
13057
|
function getValue(event, multiple) {
|
|
13438
13058
|
if (multiple) {
|
|
13439
13059
|
return Array.from(event.target.options).slice().filter((o2) => o2.selected).map((o2) => o2.value);
|
|
@@ -13444,15 +13064,15 @@ function SelectWidget({ schema, id, options, value, required, disabled, readonly
|
|
|
13444
13064
|
const { enumOptions, enumDisabled, emptyValue: optEmptyVal } = options;
|
|
13445
13065
|
const emptyValue = multiple ? [] : "";
|
|
13446
13066
|
const optionValueFormat = getOptionValueFormat(options);
|
|
13447
|
-
const handleFocus =
|
|
13067
|
+
const handleFocus = useCallback16((event) => {
|
|
13448
13068
|
const newValue = getValue(event, multiple);
|
|
13449
13069
|
return onFocus(id, enumOptionValueDecoder(newValue, enumOptions, optionValueFormat, optEmptyVal));
|
|
13450
13070
|
}, [onFocus, id, multiple, enumOptions, optEmptyVal, optionValueFormat]);
|
|
13451
|
-
const handleBlur =
|
|
13071
|
+
const handleBlur = useCallback16((event) => {
|
|
13452
13072
|
const newValue = getValue(event, multiple);
|
|
13453
13073
|
return onBlur(id, enumOptionValueDecoder(newValue, enumOptions, optionValueFormat, optEmptyVal));
|
|
13454
13074
|
}, [onBlur, id, multiple, enumOptions, optEmptyVal, optionValueFormat]);
|
|
13455
|
-
const handleChange =
|
|
13075
|
+
const handleChange = useCallback16((event) => {
|
|
13456
13076
|
const newValue = getValue(event, multiple);
|
|
13457
13077
|
return onChange(enumOptionValueDecoder(newValue, enumOptions, optionValueFormat, optEmptyVal));
|
|
13458
13078
|
}, [onChange, multiple, enumOptions, optEmptyVal, optionValueFormat]);
|
|
@@ -13468,11 +13088,11 @@ var SelectWidget_default = SelectWidget;
|
|
|
13468
13088
|
|
|
13469
13089
|
// ../../node_modules/.pnpm/@rjsf+core@6.10.0_@rjsf+utils@6.10.0_react@19.2.4__react@19.2.4_vue@3.5.40_typescript@5.9.3_/node_modules/@rjsf/core/lib/components/widgets/TextareaWidget.js
|
|
13470
13090
|
import { jsx as _jsx59 } from "react/jsx-runtime";
|
|
13471
|
-
import { useCallback as
|
|
13091
|
+
import { useCallback as useCallback17 } from "react";
|
|
13472
13092
|
function TextareaWidget({ id, options, placeholder, value, required, disabled, readonly, autofocus = false, onChange, onBlur, onFocus, htmlName }) {
|
|
13473
|
-
const handleChange =
|
|
13474
|
-
const handleBlur =
|
|
13475
|
-
const handleFocus =
|
|
13093
|
+
const handleChange = useCallback17(({ target: { value: newValue } }) => onChange(newValue === "" ? options.emptyValue : newValue), [onChange, options.emptyValue]);
|
|
13094
|
+
const handleBlur = useCallback17(({ target }) => onBlur(id, target?.value), [onBlur, id]);
|
|
13095
|
+
const handleFocus = useCallback17(({ target }) => onFocus(id, target?.value), [id, onFocus]);
|
|
13476
13096
|
return _jsx59("textarea", { id, name: htmlName || id, className: "form-control", value: value || "", placeholder, required, disabled, readOnly: readonly, autoFocus: autofocus, rows: options.rows, onBlur: handleBlur, onFocus: handleFocus, onChange: handleChange, "aria-describedby": ariaDescribedByIds(id) });
|
|
13477
13097
|
}
|
|
13478
13098
|
var TextareaWidget_default = TextareaWidget;
|
|
@@ -13487,12 +13107,12 @@ function TextWidget(props) {
|
|
|
13487
13107
|
|
|
13488
13108
|
// ../../node_modules/.pnpm/@rjsf+core@6.10.0_@rjsf+utils@6.10.0_react@19.2.4__react@19.2.4_vue@3.5.40_typescript@5.9.3_/node_modules/@rjsf/core/lib/components/widgets/TimeWidget.js
|
|
13489
13109
|
import { jsx as _jsx61 } from "react/jsx-runtime";
|
|
13490
|
-
import { useCallback as
|
|
13110
|
+
import { useCallback as useCallback18 } from "react";
|
|
13491
13111
|
function TimeWidget(props) {
|
|
13492
13112
|
const { onChange, options, registry, schema, value } = props;
|
|
13493
13113
|
const BaseInputTemplate2 = getTemplate("BaseInputTemplate", registry, options);
|
|
13494
13114
|
const hasSecondPrecision = typeof schema.multipleOf === "number" && Number.isFinite(schema.multipleOf) && schema.multipleOf < 60;
|
|
13495
|
-
const handleChange =
|
|
13115
|
+
const handleChange = useCallback18((newValue) => {
|
|
13496
13116
|
if (!newValue) {
|
|
13497
13117
|
onChange(void 0);
|
|
13498
13118
|
} else if (hasSecondPrecision) {
|
|
@@ -14365,7 +13985,7 @@ var Form = class _Form extends Component {
|
|
|
14365
13985
|
};
|
|
14366
13986
|
|
|
14367
13987
|
// src/components/SessionPluginConfigForm.tsx
|
|
14368
|
-
import { isValidElement, useMemo as
|
|
13988
|
+
import { isValidElement, useMemo as useMemo8, useState as useState9 } from "react";
|
|
14369
13989
|
|
|
14370
13990
|
// src/components/plugin-config-schema.ts
|
|
14371
13991
|
function asSchema(value) {
|
|
@@ -14560,7 +14180,7 @@ function configDraftOperations(initial, values, retained, removed) {
|
|
|
14560
14180
|
}
|
|
14561
14181
|
|
|
14562
14182
|
// src/components/SessionPluginConfigForm.tsx
|
|
14563
|
-
import { Fragment as Fragment2, jsx
|
|
14183
|
+
import { Fragment as Fragment2, jsx, jsxs } from "react/jsx-runtime";
|
|
14564
14184
|
var defaults = getDefaultRegistry();
|
|
14565
14185
|
var validator = {
|
|
14566
14186
|
isValid(schema, data, rootSchema) {
|
|
@@ -14617,7 +14237,7 @@ function presentationSchema(schema) {
|
|
|
14617
14237
|
}
|
|
14618
14238
|
function ConfigMultiSchemaField(props) {
|
|
14619
14239
|
return /* @__PURE__ */ jsxs("div", { className: "rjsf-field", children: [
|
|
14620
|
-
/* @__PURE__ */
|
|
14240
|
+
/* @__PURE__ */ jsx("label", { htmlFor: isValidElement(props.selector) ? props.selector.props.id : void 0, children: "\u914D\u7F6E\u65B9\u5F0F" }),
|
|
14621
14241
|
props.selector,
|
|
14622
14242
|
props.optionSchemaField
|
|
14623
14243
|
] });
|
|
@@ -14645,12 +14265,12 @@ function ConfigSchemaField(inputProps) {
|
|
|
14645
14265
|
const pointer = pointerOf(originalConfigPath(fieldPathId.path, context.removed));
|
|
14646
14266
|
const originalMarker = [...context.retained].find(([, path2]) => path2 === pointer)?.[0];
|
|
14647
14267
|
if (schema.const !== void 0 && schema.writeOnly !== true)
|
|
14648
|
-
return /* @__PURE__ */
|
|
14268
|
+
return /* @__PURE__ */ jsx(Fragment2, { children: context.errors.filter((error) => error.path === pointer).map((error) => /* @__PURE__ */ jsx("p", { role: "alert", children: error.message }, error.message)) });
|
|
14649
14269
|
if (schema.writeOnly === true) {
|
|
14650
14270
|
const kept = typeof formData === "string" && context.retained.has(formData);
|
|
14651
14271
|
return /* @__PURE__ */ jsxs("div", { className: "rjsf-field", children: [
|
|
14652
14272
|
Array.isArray(schema.type) && schema.type.includes("null") ? /* @__PURE__ */ jsxs("label", { children: [
|
|
14653
|
-
/* @__PURE__ */
|
|
14273
|
+
/* @__PURE__ */ jsx(
|
|
14654
14274
|
"input",
|
|
14655
14275
|
{
|
|
14656
14276
|
type: "checkbox",
|
|
@@ -14662,8 +14282,8 @@ function ConfigSchemaField(inputProps) {
|
|
|
14662
14282
|
schema.title ?? props.name,
|
|
14663
14283
|
"\uFF1A\u7F6E\u4E3A\u7A7A\u503C"
|
|
14664
14284
|
] }) : null,
|
|
14665
|
-
/* @__PURE__ */
|
|
14666
|
-
/* @__PURE__ */
|
|
14285
|
+
/* @__PURE__ */ jsx("label", { htmlFor: fieldPathId.$id, "data-required": props.required, children: schema.title ?? props.name }),
|
|
14286
|
+
/* @__PURE__ */ jsx(
|
|
14667
14287
|
"input",
|
|
14668
14288
|
{
|
|
14669
14289
|
id: fieldPathId.$id,
|
|
@@ -14676,8 +14296,8 @@ function ConfigSchemaField(inputProps) {
|
|
|
14676
14296
|
onChange: (event) => onChange(event.target.value || originalMarker, fieldPathId.path)
|
|
14677
14297
|
}
|
|
14678
14298
|
),
|
|
14679
|
-
kept ? /* @__PURE__ */
|
|
14680
|
-
formData !== void 0 ? /* @__PURE__ */
|
|
14299
|
+
kept ? /* @__PURE__ */ jsx("p", { children: "\u5DF2\u4FDD\u5B58\uFF0C\u7559\u7A7A\u4FDD\u6301\u4E0D\u53D8" }) : null,
|
|
14300
|
+
formData !== void 0 ? /* @__PURE__ */ jsx(
|
|
14681
14301
|
"button",
|
|
14682
14302
|
{
|
|
14683
14303
|
type: "button",
|
|
@@ -14686,8 +14306,11 @@ function ConfigSchemaField(inputProps) {
|
|
|
14686
14306
|
children: "\u6E05\u9664\u5DF2\u4FDD\u5B58\u7684\u503C"
|
|
14687
14307
|
}
|
|
14688
14308
|
) : null,
|
|
14689
|
-
schema.description ? /* @__PURE__ */
|
|
14690
|
-
|
|
14309
|
+
schema.description ? context.collapseHelp ? /* @__PURE__ */ jsxs("details", { children: [
|
|
14310
|
+
/* @__PURE__ */ jsx("summary", { children: "\u5982\u4F55\u83B7\u53D6" }),
|
|
14311
|
+
/* @__PURE__ */ jsx("p", { children: schema.description })
|
|
14312
|
+
] }) : /* @__PURE__ */ jsx("p", { children: schema.description }) : null,
|
|
14313
|
+
context.errors.filter((error) => error.path === pointer).map((error) => /* @__PURE__ */ jsx("p", { role: "alert", children: error.message }, error.message))
|
|
14691
14314
|
] });
|
|
14692
14315
|
}
|
|
14693
14316
|
const types = Array.isArray(schema.type) ? schema.type : [schema.type];
|
|
@@ -14696,7 +14319,7 @@ function ConfigSchemaField(inputProps) {
|
|
|
14696
14319
|
const inner = { ...schema, type: nonNull[0] };
|
|
14697
14320
|
return /* @__PURE__ */ jsxs("div", { className: "rjsf-field", children: [
|
|
14698
14321
|
/* @__PURE__ */ jsxs("label", { children: [
|
|
14699
|
-
/* @__PURE__ */
|
|
14322
|
+
/* @__PURE__ */ jsx(
|
|
14700
14323
|
"input",
|
|
14701
14324
|
{
|
|
14702
14325
|
type: "checkbox",
|
|
@@ -14711,28 +14334,31 @@ function ConfigSchemaField(inputProps) {
|
|
|
14711
14334
|
schema.title ?? props.name,
|
|
14712
14335
|
"\uFF1A\u7F6E\u4E3A\u7A7A\u503C"
|
|
14713
14336
|
] }),
|
|
14714
|
-
nonNull.length && formData !== null ? /* @__PURE__ */
|
|
14337
|
+
nonNull.length && formData !== null ? /* @__PURE__ */ jsx(defaults.fields.SchemaField, { ...props, schema: inner }) : null
|
|
14715
14338
|
] });
|
|
14716
14339
|
}
|
|
14717
|
-
return /* @__PURE__ */
|
|
14340
|
+
return /* @__PURE__ */ jsx(defaults.fields.SchemaField, { ...props });
|
|
14718
14341
|
}
|
|
14719
14342
|
function ConfigFieldTemplate(props) {
|
|
14720
14343
|
const pointer = pointerOf(
|
|
14721
14344
|
originalConfigPath(props.fieldPathId.path, props.registry.formContext.removed)
|
|
14722
14345
|
);
|
|
14723
14346
|
return /* @__PURE__ */ jsxs("div", { className: props.classNames, hidden: props.hidden, children: [
|
|
14724
|
-
props.displayLabel ? /* @__PURE__ */
|
|
14725
|
-
props.displayLabel
|
|
14347
|
+
props.displayLabel ? /* @__PURE__ */ jsx("label", { htmlFor: props.id, "data-required": props.required, children: props.label }) : null,
|
|
14348
|
+
props.displayLabel && props.description ? props.registry.formContext.collapseHelp ? /* @__PURE__ */ jsxs("details", { children: [
|
|
14349
|
+
/* @__PURE__ */ jsx("summary", { children: "\u5982\u4F55\u83B7\u53D6" }),
|
|
14350
|
+
props.description
|
|
14351
|
+
] }) : props.description : null,
|
|
14726
14352
|
props.children,
|
|
14727
14353
|
props.help,
|
|
14728
|
-
props.registry.formContext.errors.filter((error) => error.path === pointer).map((error) => /* @__PURE__ */
|
|
14354
|
+
props.registry.formContext.errors.filter((error) => error.path === pointer).map((error) => /* @__PURE__ */ jsx("p", { role: "alert", children: error.message }, error.message))
|
|
14729
14355
|
] });
|
|
14730
14356
|
}
|
|
14731
14357
|
function ConfigArrayItem(props) {
|
|
14732
14358
|
const { buttonsProps: buttons, registry } = props;
|
|
14733
14359
|
return /* @__PURE__ */ jsxs("div", { className: "rjsf-array-item", children: [
|
|
14734
14360
|
props.children,
|
|
14735
|
-
buttons.hasRemove ? /* @__PURE__ */
|
|
14361
|
+
buttons.hasRemove ? /* @__PURE__ */ jsx(
|
|
14736
14362
|
"button",
|
|
14737
14363
|
{
|
|
14738
14364
|
type: "button",
|
|
@@ -14747,7 +14373,7 @@ function ConfigArrayItem(props) {
|
|
|
14747
14373
|
if (previous !== void 0) registry.formContext.removed.add(pointerOf(path));
|
|
14748
14374
|
buttons.onRemoveItem(event);
|
|
14749
14375
|
},
|
|
14750
|
-
children: /* @__PURE__ */
|
|
14376
|
+
children: /* @__PURE__ */ jsx(Trash2, { size: 14 })
|
|
14751
14377
|
}
|
|
14752
14378
|
) : null
|
|
14753
14379
|
] });
|
|
@@ -14760,14 +14386,15 @@ function SessionPluginConfigForm({
|
|
|
14760
14386
|
onSubmit,
|
|
14761
14387
|
onCancel,
|
|
14762
14388
|
submitLabel = "\u4FDD\u5B58",
|
|
14763
|
-
submittingLabel = "\u4FDD\u5B58\u4E2D\u2026"
|
|
14389
|
+
submittingLabel = "\u4FDD\u5B58\u4E2D\u2026",
|
|
14390
|
+
collapseHelp = false
|
|
14764
14391
|
}) {
|
|
14765
14392
|
const [initial] = useState9(() => createConfigDraft(config));
|
|
14766
14393
|
const [values, setValues] = useState9(initial.values);
|
|
14767
14394
|
const [removed] = useState9(() => /* @__PURE__ */ new Set());
|
|
14768
14395
|
const [draftFailure, setDraftFailure] = useState9(null);
|
|
14769
|
-
const support =
|
|
14770
|
-
const schema =
|
|
14396
|
+
const support = useMemo8(() => formSupport(config.schema), [config.schema]);
|
|
14397
|
+
const schema = useMemo8(() => {
|
|
14771
14398
|
try {
|
|
14772
14399
|
return config.schema ? presentationSchema(config.schema) : null;
|
|
14773
14400
|
} catch {
|
|
@@ -14775,6 +14402,7 @@ function SessionPluginConfigForm({
|
|
|
14775
14402
|
}
|
|
14776
14403
|
}, [config.schema]);
|
|
14777
14404
|
const context = {
|
|
14405
|
+
collapseHelp,
|
|
14778
14406
|
retained: initial.retained,
|
|
14779
14407
|
removed,
|
|
14780
14408
|
errors,
|
|
@@ -14784,11 +14412,11 @@ function SessionPluginConfigForm({
|
|
|
14784
14412
|
};
|
|
14785
14413
|
if (!schema || support)
|
|
14786
14414
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-3 text-xs", children: [
|
|
14787
|
-
/* @__PURE__ */
|
|
14788
|
-
/* @__PURE__ */
|
|
14415
|
+
/* @__PURE__ */ jsx("p", { children: support ?? "\u914D\u7F6E\u58F0\u660E\u7684\u7EC4\u5408\u65E0\u6CD5\u5448\u73B0\uFF0C\u8BF7\u8054\u7CFB\u63D2\u4EF6\u63D0\u4F9B\u65B9" }),
|
|
14416
|
+
/* @__PURE__ */ jsx("button", { type: "button", onClick: onCancel, children: "\u5173\u95ED" })
|
|
14789
14417
|
] });
|
|
14790
14418
|
return /* @__PURE__ */ jsxs("div", { className: "blade-plugin-config text-xs", children: [
|
|
14791
|
-
/* @__PURE__ */
|
|
14419
|
+
/* @__PURE__ */ jsx("style", { children: `
|
|
14792
14420
|
.blade-plugin-config .rjsf-field, .blade-plugin-config fieldset { min-width:0; margin:0 0 10px; padding:0; border:0 }
|
|
14793
14421
|
.blade-plugin-config label, .blade-plugin-config legend { display:block; font-size:12px; font-weight:500; overflow-wrap:anywhere; margin-bottom:4px }
|
|
14794
14422
|
.blade-plugin-config label[data-required=true]::after { content:' *'; color:hsl(var(--destructive)) }
|
|
@@ -14801,8 +14429,8 @@ function SessionPluginConfigForm({
|
|
|
14801
14429
|
.blade-plugin-config button:disabled { opacity:.5 }
|
|
14802
14430
|
.blade-plugin-config .control-label { display:block }
|
|
14803
14431
|
` }),
|
|
14804
|
-
failure || draftFailure ? /* @__PURE__ */
|
|
14805
|
-
/* @__PURE__ */
|
|
14432
|
+
failure || draftFailure ? /* @__PURE__ */ jsx("p", { role: "alert", children: failure ?? draftFailure }) : null,
|
|
14433
|
+
/* @__PURE__ */ jsx(
|
|
14806
14434
|
Form,
|
|
14807
14435
|
{
|
|
14808
14436
|
schema,
|
|
@@ -14816,7 +14444,7 @@ function SessionPluginConfigForm({
|
|
|
14816
14444
|
MultiSchemaFieldTemplate: ConfigMultiSchemaField,
|
|
14817
14445
|
ButtonTemplates: {
|
|
14818
14446
|
...defaults.templates.ButtonTemplates,
|
|
14819
|
-
AddButton: (props) => /* @__PURE__ */
|
|
14447
|
+
AddButton: (props) => /* @__PURE__ */ jsx(
|
|
14820
14448
|
"button",
|
|
14821
14449
|
{
|
|
14822
14450
|
type: "button",
|
|
@@ -14824,7 +14452,7 @@ function SessionPluginConfigForm({
|
|
|
14824
14452
|
"aria-label": "\u6DFB\u52A0\u4E00\u9879",
|
|
14825
14453
|
disabled: props.disabled,
|
|
14826
14454
|
onClick: props.onClick,
|
|
14827
|
-
children: /* @__PURE__ */
|
|
14455
|
+
children: /* @__PURE__ */ jsx(Plus, { size: 14 })
|
|
14828
14456
|
}
|
|
14829
14457
|
)
|
|
14830
14458
|
}
|
|
@@ -14866,935 +14494,16 @@ function SessionPluginConfigForm({
|
|
|
14866
14494
|
}
|
|
14867
14495
|
},
|
|
14868
14496
|
children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
14869
|
-
/* @__PURE__ */
|
|
14870
|
-
/* @__PURE__ */
|
|
14497
|
+
/* @__PURE__ */ jsx("button", { type: "button", onClick: onCancel, children: "\u53D6\u6D88" }),
|
|
14498
|
+
/* @__PURE__ */ jsx("button", { type: "submit", disabled: submitting, children: submitting ? submittingLabel : submitLabel })
|
|
14871
14499
|
] })
|
|
14872
14500
|
}
|
|
14873
14501
|
)
|
|
14874
14502
|
] });
|
|
14875
14503
|
}
|
|
14876
14504
|
|
|
14877
|
-
// src/components/SessionPluginIcon.tsx
|
|
14878
|
-
import { useEffect as useEffect7, useState as useState10 } from "react";
|
|
14879
|
-
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
14880
|
-
function sessionPluginLabel(plugin) {
|
|
14881
|
-
const display = typeof plugin.display_name === "string" ? plugin.display_name.trim() : "";
|
|
14882
|
-
return display || plugin.name;
|
|
14883
|
-
}
|
|
14884
|
-
var clientCaches = /* @__PURE__ */ new WeakMap();
|
|
14885
|
-
var BLOB_CACHE_LIMIT = 64;
|
|
14886
|
-
function iconBlob(client, sessionId, name, token) {
|
|
14887
|
-
let blobCache = clientCaches.get(client);
|
|
14888
|
-
if (!blobCache) {
|
|
14889
|
-
blobCache = /* @__PURE__ */ new Map();
|
|
14890
|
-
clientCaches.set(client, blobCache);
|
|
14891
|
-
}
|
|
14892
|
-
const key = sessionId ? `${sessionId}:${name}:${token}` : `account:${name}:${token}`;
|
|
14893
|
-
const cached = blobCache.get(key);
|
|
14894
|
-
if (cached) return cached;
|
|
14895
|
-
const pending = (sessionId ? client.sessions.fetchSessionPluginIcon(sessionId, name) : client.plugins.fetchIcon(name)).catch(() => {
|
|
14896
|
-
blobCache?.delete(key);
|
|
14897
|
-
return null;
|
|
14898
|
-
});
|
|
14899
|
-
if (blobCache.size >= BLOB_CACHE_LIMIT) blobCache.clear();
|
|
14900
|
-
blobCache.set(key, pending);
|
|
14901
|
-
return pending;
|
|
14902
|
-
}
|
|
14903
|
-
function SessionPluginIcon({ client, sessionId, plugin, size = 20, shape = "rounded", className }) {
|
|
14904
|
-
const [url, setUrl] = useState10(null);
|
|
14905
|
-
const token = plugin.icon;
|
|
14906
|
-
const inlineIcon = token && /^data:image\/(?:png|jpeg|gif|webp);base64,/.test(token) ? token : null;
|
|
14907
|
-
useEffect7(() => {
|
|
14908
|
-
setUrl(null);
|
|
14909
|
-
if (!token || inlineIcon) return;
|
|
14910
|
-
let alive = true;
|
|
14911
|
-
let objectUrl = null;
|
|
14912
|
-
void iconBlob(client, sessionId, plugin.name, token).then((blob) => {
|
|
14913
|
-
if (!alive || !blob) return;
|
|
14914
|
-
objectUrl = URL.createObjectURL(blob);
|
|
14915
|
-
setUrl(objectUrl);
|
|
14916
|
-
});
|
|
14917
|
-
return () => {
|
|
14918
|
-
alive = false;
|
|
14919
|
-
if (objectUrl) URL.revokeObjectURL(objectUrl);
|
|
14920
|
-
};
|
|
14921
|
-
}, [client, sessionId, plugin.name, token, inlineIcon]);
|
|
14922
|
-
const frame = `flex shrink-0 items-center justify-center overflow-hidden ${shape === "circle" ? "rounded-full" : "rounded"} ${className ?? ""}`;
|
|
14923
|
-
const frameStyle = { width: size, height: size };
|
|
14924
|
-
const source = url === "" ? null : inlineIcon ?? url;
|
|
14925
|
-
if (!source) {
|
|
14926
|
-
return /* @__PURE__ */ jsx3("span", { className: `${frame} bg-[hsl(var(--muted))] text-[hsl(var(--muted-foreground))]`, style: frameStyle, "data-plugin-icon": "placeholder", children: /* @__PURE__ */ jsx3(Puzzle, { "aria-hidden": true, size: Math.round(size * 0.7) }) });
|
|
14927
|
-
}
|
|
14928
|
-
return /* @__PURE__ */ jsx3("span", { className: frame, style: frameStyle, "data-plugin-icon": "image", children: /* @__PURE__ */ jsx3("img", { src: source, alt: "", "aria-hidden": true, className: "h-full w-full object-cover", onError: () => setUrl("") }) });
|
|
14929
|
-
}
|
|
14930
|
-
|
|
14931
|
-
// src/components/SessionPluginConfigDialog.tsx
|
|
14932
|
-
import { useEffect as useEffect8, useRef as useRef8, useState as useState11 } from "react";
|
|
14933
|
-
import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
14934
|
-
async function readFailure(error) {
|
|
14935
|
-
const response = error?.response;
|
|
14936
|
-
if (!response || typeof response.json !== "function") {
|
|
14937
|
-
return { message: "\u914D\u7F6E\u672A\u4FDD\u5B58\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5" };
|
|
14938
|
-
}
|
|
14939
|
-
try {
|
|
14940
|
-
const body = await response.json();
|
|
14941
|
-
const detail = body?.detail;
|
|
14942
|
-
if (typeof detail === "string") return { message: detail };
|
|
14943
|
-
if (detail && typeof detail === "object") {
|
|
14944
|
-
return {
|
|
14945
|
-
message: detail.message ?? "\u914D\u7F6E\u672A\u4FDD\u5B58\uFF0C\u8BF7\u68C0\u67E5\u586B\u5199\u5185\u5BB9",
|
|
14946
|
-
errors: Array.isArray(detail.errors) ? detail.errors : void 0,
|
|
14947
|
-
code: detail.code
|
|
14948
|
-
};
|
|
14949
|
-
}
|
|
14950
|
-
} catch {
|
|
14951
|
-
}
|
|
14952
|
-
return { message: "\u914D\u7F6E\u672A\u4FDD\u5B58\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5" };
|
|
14953
|
-
}
|
|
14954
|
-
function SessionPluginConfigDialog({
|
|
14955
|
-
client,
|
|
14956
|
-
sessionId,
|
|
14957
|
-
plugin,
|
|
14958
|
-
...props
|
|
14959
|
-
}) {
|
|
14960
|
-
return /* @__PURE__ */ jsx4(
|
|
14961
|
-
ConfigDialogState,
|
|
14962
|
-
{
|
|
14963
|
-
client,
|
|
14964
|
-
sessionId,
|
|
14965
|
-
plugin,
|
|
14966
|
-
...props
|
|
14967
|
-
},
|
|
14968
|
-
`${sessionId}:${plugin.name}`
|
|
14969
|
-
);
|
|
14970
|
-
}
|
|
14971
|
-
function ConfigDialogState({
|
|
14972
|
-
client,
|
|
14973
|
-
sessionId,
|
|
14974
|
-
plugin,
|
|
14975
|
-
onSaved,
|
|
14976
|
-
onClose
|
|
14977
|
-
}) {
|
|
14978
|
-
const [host, setHost] = useState11(null);
|
|
14979
|
-
const [restarting, setRestarting] = useState11(false);
|
|
14980
|
-
const [scope, setScope] = useState11("personal");
|
|
14981
|
-
const [config, setConfig] = useState11(null);
|
|
14982
|
-
const pendingRevision = scope === "global" && host?.state === "ready" && config?.revision != null && host.revision !== config.revision;
|
|
14983
|
-
const waitingForHost = host?.state === "starting" || host?.state === "updating" || pendingRevision;
|
|
14984
|
-
useEffect8(() => {
|
|
14985
|
-
if (!waitingForHost) return;
|
|
14986
|
-
const abort = new AbortController();
|
|
14987
|
-
let timer;
|
|
14988
|
-
const refresh = async () => {
|
|
14989
|
-
try {
|
|
14990
|
-
const next = await client.sessions.getSessionPluginConfig(sessionId, plugin.name, { signal: abort.signal }, scope);
|
|
14991
|
-
if (!abort.signal.aborted) setHost(next.host ?? null);
|
|
14992
|
-
} catch {
|
|
14993
|
-
}
|
|
14994
|
-
if (!abort.signal.aborted) timer = setTimeout(refresh, 2e3);
|
|
14995
|
-
};
|
|
14996
|
-
timer = setTimeout(refresh, 2e3);
|
|
14997
|
-
return () => {
|
|
14998
|
-
abort.abort();
|
|
14999
|
-
clearTimeout(timer);
|
|
15000
|
-
};
|
|
15001
|
-
}, [client, sessionId, plugin.name, scope, waitingForHost]);
|
|
15002
|
-
const [canConfigureGlobal, setCanConfigureGlobal] = useState11(false);
|
|
15003
|
-
const [loading, setLoading] = useState11(true);
|
|
15004
|
-
const [loadFailure, setLoadFailure] = useState11(null);
|
|
15005
|
-
const [saving, setSaving] = useState11(false);
|
|
15006
|
-
const [failure, setFailure] = useState11(null);
|
|
15007
|
-
const [fieldErrors, setFieldErrors] = useState11([]);
|
|
15008
|
-
const [formVersion, setFormVersion] = useState11(0);
|
|
15009
|
-
const alive = useRef8(true);
|
|
15010
|
-
const generation2 = useRef8(0);
|
|
15011
|
-
const dialog = useRef8(null);
|
|
15012
|
-
useEffect8(() => {
|
|
15013
|
-
const element = dialog.current;
|
|
15014
|
-
if (!element || element.open) return;
|
|
15015
|
-
if (typeof element.showModal === "function") element.showModal();
|
|
15016
|
-
else element.setAttribute("open", "");
|
|
15017
|
-
}, []);
|
|
15018
|
-
const load = async () => {
|
|
15019
|
-
const current = ++generation2.current;
|
|
15020
|
-
setLoading(true);
|
|
15021
|
-
setLoadFailure(null);
|
|
15022
|
-
try {
|
|
15023
|
-
const { config: state, can_configure_global, host: hostState } = await client.sessions.getSessionPluginConfig(sessionId, plugin.name, void 0, scope);
|
|
15024
|
-
if (!alive.current || generation2.current !== current) return;
|
|
15025
|
-
setCanConfigureGlobal(can_configure_global ?? false);
|
|
15026
|
-
setHost(hostState ?? null);
|
|
15027
|
-
setConfig(state);
|
|
15028
|
-
setFormVersion((value) => value + 1);
|
|
15029
|
-
} catch (error) {
|
|
15030
|
-
if (!alive.current || generation2.current !== current) return;
|
|
15031
|
-
const detail = await readFailure(error);
|
|
15032
|
-
if (!alive.current || generation2.current !== current) return;
|
|
15033
|
-
setLoadFailure(detail.message ?? "\u914D\u7F6E\u6682\u4E0D\u53EF\u7528");
|
|
15034
|
-
} finally {
|
|
15035
|
-
if (alive.current && generation2.current === current) setLoading(false);
|
|
15036
|
-
}
|
|
15037
|
-
};
|
|
15038
|
-
useEffect8(() => {
|
|
15039
|
-
alive.current = true;
|
|
15040
|
-
setConfig(null);
|
|
15041
|
-
setFailure(null);
|
|
15042
|
-
setFieldErrors([]);
|
|
15043
|
-
void load();
|
|
15044
|
-
return () => {
|
|
15045
|
-
alive.current = false;
|
|
15046
|
-
generation2.current++;
|
|
15047
|
-
};
|
|
15048
|
-
}, [client, sessionId, plugin.name, scope]);
|
|
15049
|
-
const save = async (draft) => {
|
|
15050
|
-
if (!config) return;
|
|
15051
|
-
const current = generation2.current;
|
|
15052
|
-
setSaving(true);
|
|
15053
|
-
setFailure(null);
|
|
15054
|
-
setFieldErrors([]);
|
|
15055
|
-
try {
|
|
15056
|
-
const { config: state } = await client.sessions.updateSessionPluginConfig(
|
|
15057
|
-
sessionId,
|
|
15058
|
-
plugin.name,
|
|
15059
|
-
{
|
|
15060
|
-
expected_revision: config.revision,
|
|
15061
|
-
set: draft.set,
|
|
15062
|
-
remove: draft.remove
|
|
15063
|
-
},
|
|
15064
|
-
void 0,
|
|
15065
|
-
scope
|
|
15066
|
-
);
|
|
15067
|
-
if (!alive.current || generation2.current !== current) return;
|
|
15068
|
-
setConfig(state);
|
|
15069
|
-
setFormVersion((value) => value + 1);
|
|
15070
|
-
if (scope === "personal") onSaved?.(state);
|
|
15071
|
-
} catch (error) {
|
|
15072
|
-
if (!alive.current || generation2.current !== current) return;
|
|
15073
|
-
const detail = await readFailure(error);
|
|
15074
|
-
if (!alive.current || generation2.current !== current) return;
|
|
15075
|
-
setFailure(detail.message ?? "\u914D\u7F6E\u672A\u4FDD\u5B58\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5");
|
|
15076
|
-
setFieldErrors(detail.errors ?? []);
|
|
15077
|
-
if (detail.code === "plugin_config_conflict") await load();
|
|
15078
|
-
} finally {
|
|
15079
|
-
if (alive.current) setSaving(false);
|
|
15080
|
-
}
|
|
15081
|
-
};
|
|
15082
|
-
return /* @__PURE__ */ jsxs2(Fragment3, { children: [
|
|
15083
|
-
/* @__PURE__ */ jsx4("style", { children: ".blade-plugin-dialog::backdrop { background: rgb(0 0 0 / 40%); }" }),
|
|
15084
|
-
/* @__PURE__ */ jsxs2(
|
|
15085
|
-
"dialog",
|
|
15086
|
-
{
|
|
15087
|
-
ref: dialog,
|
|
15088
|
-
"aria-modal": "true",
|
|
15089
|
-
"aria-label": `${sessionPluginLabel(plugin)} \u914D\u7F6E`,
|
|
15090
|
-
onCancel: (event) => {
|
|
15091
|
-
event.preventDefault();
|
|
15092
|
-
onClose();
|
|
15093
|
-
},
|
|
15094
|
-
onKeyDown: (event) => {
|
|
15095
|
-
if (event.key !== "Escape") return;
|
|
15096
|
-
event.preventDefault();
|
|
15097
|
-
event.stopPropagation();
|
|
15098
|
-
onClose();
|
|
15099
|
-
},
|
|
15100
|
-
style: {
|
|
15101
|
-
position: "fixed",
|
|
15102
|
-
inset: 0,
|
|
15103
|
-
margin: "auto",
|
|
15104
|
-
boxSizing: "border-box",
|
|
15105
|
-
width: "min(448px, calc(100% - 32px))"
|
|
15106
|
-
},
|
|
15107
|
-
className: "blade-plugin-dialog max-h-[80vh] overflow-y-auto rounded-lg border border-[hsl(var(--border))] bg-[hsl(var(--popover))] p-4 text-[hsl(var(--popover-foreground))] shadow-lg",
|
|
15108
|
-
children: [
|
|
15109
|
-
/* @__PURE__ */ jsxs2("div", { className: "mb-3 flex items-center gap-2", children: [
|
|
15110
|
-
/* @__PURE__ */ jsx4(SessionPluginIcon, { client, sessionId, plugin }),
|
|
15111
|
-
/* @__PURE__ */ jsx4(
|
|
15112
|
-
"span",
|
|
15113
|
-
{
|
|
15114
|
-
className: "min-w-0 flex-1 truncate text-sm font-medium",
|
|
15115
|
-
title: sessionPluginLabel(plugin),
|
|
15116
|
-
children: sessionPluginLabel(plugin)
|
|
15117
|
-
}
|
|
15118
|
-
),
|
|
15119
|
-
/* @__PURE__ */ jsx4(
|
|
15120
|
-
"button",
|
|
15121
|
-
{
|
|
15122
|
-
type: "button",
|
|
15123
|
-
"aria-label": "\u5173\u95ED",
|
|
15124
|
-
className: "shrink-0 text-xs underline",
|
|
15125
|
-
onClick: onClose,
|
|
15126
|
-
children: "\u5173\u95ED"
|
|
15127
|
-
}
|
|
15128
|
-
)
|
|
15129
|
-
] }),
|
|
15130
|
-
canConfigureGlobal ? /* @__PURE__ */ jsxs2("div", { className: "mb-3 flex gap-2 text-xs", children: [
|
|
15131
|
-
/* @__PURE__ */ jsx4("button", { type: "button", disabled: saving, "aria-pressed": scope === "personal", onClick: () => setScope("personal"), children: "\u6211\u7684\u767B\u5F55" }),
|
|
15132
|
-
/* @__PURE__ */ jsx4("button", { type: "button", disabled: saving, "aria-pressed": scope === "global", onClick: () => setScope("global"), children: "\u7EC4\u7EC7\u5171\u4EAB\u914D\u7F6E" })
|
|
15133
|
-
] }) : null,
|
|
15134
|
-
host ? /* @__PURE__ */ jsxs2("div", { className: "mb-3 space-y-1 text-xs", children: [
|
|
15135
|
-
/* @__PURE__ */ jsxs2("p", { children: [
|
|
15136
|
-
"\u670D\u52A1\uFF1A",
|
|
15137
|
-
pendingRevision ? "\u6B63\u5728\u66F4\u65B0" : host.reason,
|
|
15138
|
-
" \xB7 \u5DF2\u6062\u590D ",
|
|
15139
|
-
host.restarts,
|
|
15140
|
-
" \u6B21"
|
|
15141
|
-
] }),
|
|
15142
|
-
canConfigureGlobal ? /* @__PURE__ */ jsxs2(Fragment3, { children: [
|
|
15143
|
-
/* @__PURE__ */ jsxs2("p", { className: "break-all text-[hsl(var(--muted-foreground))]", children: [
|
|
15144
|
-
"\u5305\u6458\u8981\uFF1A",
|
|
15145
|
-
host.digest,
|
|
15146
|
-
" \xB7 \u914D\u7F6E\uFF1A",
|
|
15147
|
-
host.revision
|
|
15148
|
-
] }),
|
|
15149
|
-
/* @__PURE__ */ jsx4("button", { type: "button", disabled: restarting || saving, onClick: () => {
|
|
15150
|
-
setRestarting(true);
|
|
15151
|
-
void client.sessions.restartSessionPluginHost(sessionId, plugin.name).then(() => load()).catch(() => setFailure("\u670D\u52A1\u6682\u65F6\u4E0D\u53EF\u7528\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5")).finally(() => {
|
|
15152
|
-
if (alive.current) setRestarting(false);
|
|
15153
|
-
});
|
|
15154
|
-
}, children: restarting ? "\u6B63\u5728\u91CD\u542F\u2026" : "\u91CD\u542F\u670D\u52A1" }),
|
|
15155
|
-
host.recent?.length ? /* @__PURE__ */ jsxs2("details", { children: [
|
|
15156
|
-
/* @__PURE__ */ jsx4("summary", { children: "\u6700\u8FD1\u6D3B\u52A8" }),
|
|
15157
|
-
host.recent.map((line, index) => /* @__PURE__ */ jsx4("p", { children: line }, `${index}-${line}`))
|
|
15158
|
-
] }) : null
|
|
15159
|
-
] }) : null
|
|
15160
|
-
] }) : null,
|
|
15161
|
-
scope === "personal" && config?.auth_status === "expired" ? /* @__PURE__ */ jsx4("p", { className: "mb-2 text-xs", children: "\u767B\u5F55\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u91CD\u65B0\u586B\u5199" }) : null,
|
|
15162
|
-
scope === "personal" && config?.global_ready === false ? /* @__PURE__ */ jsx4("p", { className: "mb-2 text-xs", children: "\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\u586B\u5199\u5171\u4EAB\u914D\u7F6E" }) : null,
|
|
15163
|
-
scope === "global" ? /* @__PURE__ */ jsx4("p", { className: "mb-2 text-xs", children: "\u5171\u4EAB\u5BC6\u94A5\u7528\u4E8E\u63D2\u4EF6\u670D\u52A1\u3002\u547D\u4EE4\u7C7B\u63D2\u4EF6\u7684\u6C99\u76D2\u4EE3\u7801\u53EF\u4EE5\u8BFB\u53D6\u5B83\uFF1B\u9700\u4FDD\u5BC6\u65F6\u8BF7\u4F7F\u7528\u6258\u7BA1\u670D\u52A1\u3002" }) : null,
|
|
15164
|
-
loading ? /* @__PURE__ */ jsx4("p", { className: "text-xs text-[hsl(var(--muted-foreground))]", children: "\u6B63\u5728\u8BFB\u53D6\u914D\u7F6E\u2026" }) : null,
|
|
15165
|
-
loadFailure ? /* @__PURE__ */ jsxs2("div", { className: "space-y-2 text-xs", children: [
|
|
15166
|
-
/* @__PURE__ */ jsx4("p", { children: loadFailure }),
|
|
15167
|
-
/* @__PURE__ */ jsx4(
|
|
15168
|
-
"button",
|
|
15169
|
-
{
|
|
15170
|
-
type: "button",
|
|
15171
|
-
className: "rounded-full border border-[hsl(var(--border))] px-2.5 py-1",
|
|
15172
|
-
onClick: () => void load(),
|
|
15173
|
-
children: "\u91CD\u8BD5"
|
|
15174
|
-
}
|
|
15175
|
-
)
|
|
15176
|
-
] }) : null,
|
|
15177
|
-
config && !loading ? /* @__PURE__ */ jsx4(
|
|
15178
|
-
SessionPluginConfigForm,
|
|
15179
|
-
{
|
|
15180
|
-
config,
|
|
15181
|
-
submitting: saving,
|
|
15182
|
-
errors: fieldErrors,
|
|
15183
|
-
failure,
|
|
15184
|
-
onSubmit: (draft) => void save(draft),
|
|
15185
|
-
onCancel: onClose
|
|
15186
|
-
},
|
|
15187
|
-
formVersion
|
|
15188
|
-
) : null
|
|
15189
|
-
]
|
|
15190
|
-
}
|
|
15191
|
-
)
|
|
15192
|
-
] });
|
|
15193
|
-
}
|
|
15194
|
-
|
|
15195
|
-
// src/components/PluginConnectorList.tsx
|
|
15196
|
-
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
15197
|
-
function PluginSwitch({
|
|
15198
|
-
label,
|
|
15199
|
-
checked,
|
|
15200
|
-
pending,
|
|
15201
|
-
disabled,
|
|
15202
|
-
draft = false,
|
|
15203
|
-
onToggle
|
|
15204
|
-
}) {
|
|
15205
|
-
return /* @__PURE__ */ jsx5(
|
|
15206
|
-
"button",
|
|
15207
|
-
{
|
|
15208
|
-
type: "button",
|
|
15209
|
-
role: "switch",
|
|
15210
|
-
"aria-checked": checked,
|
|
15211
|
-
"aria-label": draft ? `${label} \u5F85\u9009` : `${label} \u542F\u7528`,
|
|
15212
|
-
disabled,
|
|
15213
|
-
onClick: () => onToggle(!checked),
|
|
15214
|
-
className: `relative inline-flex h-[18px] w-8 shrink-0 cursor-pointer items-center rounded-full border transition-colors disabled:cursor-not-allowed disabled:opacity-50 ${checked ? "border-transparent bg-[hsl(213_94%_55%)]" : "border-[hsl(var(--border))] bg-[hsl(var(--muted))]"}`,
|
|
15215
|
-
children: /* @__PURE__ */ jsx5(
|
|
15216
|
-
"span",
|
|
15217
|
-
{
|
|
15218
|
-
"aria-hidden": "true",
|
|
15219
|
-
className: `pointer-events-none flex h-3.5 w-3.5 items-center justify-center rounded-full bg-white shadow transition-transform ${checked ? "translate-x-[16px]" : "translate-x-[2px]"}`,
|
|
15220
|
-
children: pending ? /* @__PURE__ */ jsx5(LoaderCircle, { size: 9, className: "animate-spin text-[hsl(var(--muted-foreground))]" }) : null
|
|
15221
|
-
}
|
|
15222
|
-
)
|
|
15223
|
-
}
|
|
15224
|
-
);
|
|
15225
|
-
}
|
|
15226
|
-
function PluginConnectorList({
|
|
15227
|
-
client,
|
|
15228
|
-
sessionId,
|
|
15229
|
-
items,
|
|
15230
|
-
inFlight,
|
|
15231
|
-
busy,
|
|
15232
|
-
mutationError,
|
|
15233
|
-
onToggle,
|
|
15234
|
-
onRetry,
|
|
15235
|
-
onEditConfig,
|
|
15236
|
-
configuring,
|
|
15237
|
-
onConfigSaved,
|
|
15238
|
-
onConfigClose,
|
|
15239
|
-
disabledReason,
|
|
15240
|
-
unavailableText,
|
|
15241
|
-
emptyText,
|
|
15242
|
-
draft = false
|
|
15243
|
-
}) {
|
|
15244
|
-
const configuringItem = configuring ? items.find((item) => item.name === configuring.name) ?? null : null;
|
|
15245
|
-
return /* @__PURE__ */ jsxs3("div", { className: "py-0.5", children: [
|
|
15246
|
-
disabledReason ? /* @__PURE__ */ jsx5("div", { className: "px-3 py-1.5 text-[11px] text-[hsl(var(--muted-foreground))]", children: disabledReason }) : null,
|
|
15247
|
-
items.length === 0 ? /* @__PURE__ */ jsx5("div", { className: "px-3 py-1.5 text-[11px] text-[hsl(var(--muted-foreground))]", children: unavailableText ?? emptyText }) : null,
|
|
15248
|
-
items.map((item) => {
|
|
15249
|
-
const label = sessionPluginLabel(item);
|
|
15250
|
-
const actionable = !disabledReason && item.installed !== false || item.active;
|
|
15251
|
-
const pending = Boolean(inFlight[item.name]);
|
|
15252
|
-
const checked = item.active;
|
|
15253
|
-
return /* @__PURE__ */ jsxs3("div", { className: "group px-3 py-1", children: [
|
|
15254
|
-
/* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-2", children: [
|
|
15255
|
-
/* @__PURE__ */ jsx5(
|
|
15256
|
-
SessionPluginIcon,
|
|
15257
|
-
{
|
|
15258
|
-
client,
|
|
15259
|
-
sessionId: item.iconSource === "account" ? null : sessionId,
|
|
15260
|
-
plugin: item
|
|
15261
|
-
}
|
|
15262
|
-
),
|
|
15263
|
-
/* @__PURE__ */ jsx5("span", { className: "min-w-0 flex-1 truncate text-[11px]", title: label, children: label }),
|
|
15264
|
-
item.auth_status === "expired" || item.auth_status === "login_required" || item.auth_status === "unavailable" ? /* @__PURE__ */ jsx5("button", { type: "button", disabled: !sessionId || busy, onClick: () => onEditConfig(item), className: "shrink-0 text-[10px] underline", children: item.auth_status === "expired" ? "\u767B\u5F55\u5DF2\u8FC7\u671F" : item.auth_status === "unavailable" ? "\u6682\u65F6\u4E0D\u53EF\u7528" : "\u672A\u767B\u5F55" }) : null,
|
|
15265
|
-
!draft && item.config === "configured" ? /* @__PURE__ */ jsx5(
|
|
15266
|
-
"button",
|
|
15267
|
-
{
|
|
15268
|
-
type: "button",
|
|
15269
|
-
title: "\u66F4\u65B0\u8BE5\u63D2\u4EF6\u7684\u914D\u7F6E",
|
|
15270
|
-
disabled: busy || !sessionId,
|
|
15271
|
-
onClick: () => onEditConfig(item),
|
|
15272
|
-
className: "shrink-0 text-[10px] text-[hsl(var(--muted-foreground))] underline opacity-0 [@media(hover:none)]:opacity-100 transition-opacity focus-visible:opacity-100 group-hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-50",
|
|
15273
|
-
children: "\u66F4\u65B0\u914D\u7F6E"
|
|
15274
|
-
}
|
|
15275
|
-
) : null,
|
|
15276
|
-
!draft && (item.config === "required" || item.config === "error") ? /* @__PURE__ */ jsx5(
|
|
15277
|
-
"button",
|
|
15278
|
-
{
|
|
15279
|
-
type: "button",
|
|
15280
|
-
title: "\u8BE5\u63D2\u4EF6\u9700\u8981\u586B\u5199\u914D\u7F6E",
|
|
15281
|
-
disabled: busy || !sessionId,
|
|
15282
|
-
onClick: () => onEditConfig(item),
|
|
15283
|
-
className: "shrink-0 text-[10px] text-[hsl(var(--muted-foreground))] underline disabled:cursor-not-allowed disabled:opacity-50",
|
|
15284
|
-
children: "\u586B\u5199\u914D\u7F6E"
|
|
15285
|
-
}
|
|
15286
|
-
) : null,
|
|
15287
|
-
/* @__PURE__ */ jsx5(
|
|
15288
|
-
PluginSwitch,
|
|
15289
|
-
{
|
|
15290
|
-
label,
|
|
15291
|
-
checked,
|
|
15292
|
-
pending,
|
|
15293
|
-
draft,
|
|
15294
|
-
disabled: !actionable,
|
|
15295
|
-
onToggle: (next) => onToggle(item, next)
|
|
15296
|
-
}
|
|
15297
|
-
)
|
|
15298
|
-
] }),
|
|
15299
|
-
!draft && item.active && item.status !== "valid" && item.status !== "required" ? /* @__PURE__ */ jsxs3("div", { className: "mt-0.5 flex items-center gap-2 pl-7 text-[10px] text-[hsl(var(--muted-foreground))]", children: [
|
|
15300
|
-
/* @__PURE__ */ jsx5("span", { children: item.reason || "\u63D2\u4EF6\u6682\u4E0D\u53EF\u7528" }),
|
|
15301
|
-
/* @__PURE__ */ jsx5(
|
|
15302
|
-
"button",
|
|
15303
|
-
{
|
|
15304
|
-
type: "button",
|
|
15305
|
-
disabled: busy,
|
|
15306
|
-
onClick: () => onRetry(item),
|
|
15307
|
-
className: "underline disabled:cursor-not-allowed disabled:opacity-50",
|
|
15308
|
-
children: "\u91CD\u8BD5"
|
|
15309
|
-
}
|
|
15310
|
-
)
|
|
15311
|
-
] }) : null
|
|
15312
|
-
] }, item.name);
|
|
15313
|
-
}),
|
|
15314
|
-
mutationError ? /* @__PURE__ */ jsx5("div", { className: "px-3 pt-1 text-[10px] text-[hsl(var(--destructive))]", children: "\u64CD\u4F5C\u672A\u5B8C\u6210\uFF0C\u8BF7\u91CD\u8BD5" }) : null,
|
|
15315
|
-
configuring && configuringItem && sessionId ? /* @__PURE__ */ jsx5(
|
|
15316
|
-
SessionPluginConfigDialog,
|
|
15317
|
-
{
|
|
15318
|
-
client,
|
|
15319
|
-
sessionId,
|
|
15320
|
-
plugin: configuringItem,
|
|
15321
|
-
onSaved: onConfigSaved,
|
|
15322
|
-
onClose: onConfigClose
|
|
15323
|
-
}
|
|
15324
|
-
) : null
|
|
15325
|
-
] });
|
|
15326
|
-
}
|
|
15327
|
-
|
|
15328
|
-
// src/components/plugin-connector.ts
|
|
15329
|
-
function catalogToConnectorItems(catalog) {
|
|
15330
|
-
return catalog.map((entry) => ({
|
|
15331
|
-
name: entry.name,
|
|
15332
|
-
display_name: entry.display_name,
|
|
15333
|
-
icon: entry.icon,
|
|
15334
|
-
iconSource: "account",
|
|
15335
|
-
installed: entry.installed,
|
|
15336
|
-
connector: entry.connector,
|
|
15337
|
-
auth_status: entry.auth_status,
|
|
15338
|
-
active: false,
|
|
15339
|
-
status: "not_prepared",
|
|
15340
|
-
projected: false
|
|
15341
|
-
}));
|
|
15342
|
-
}
|
|
15343
|
-
function mergeConnectorItems(sessionPlugins, catalog) {
|
|
15344
|
-
const byName = new Map((catalog ?? []).map((entry) => [entry.name, entry]));
|
|
15345
|
-
return sessionPlugins.map((plugin) => {
|
|
15346
|
-
const entry = byName.get(plugin.name);
|
|
15347
|
-
if (!entry) {
|
|
15348
|
-
return {
|
|
15349
|
-
name: plugin.name,
|
|
15350
|
-
display_name: plugin.display_name ?? null,
|
|
15351
|
-
icon: plugin.icon ?? null,
|
|
15352
|
-
iconSource: "session",
|
|
15353
|
-
installed: plugin.installed,
|
|
15354
|
-
active: plugin.active,
|
|
15355
|
-
status: plugin.status,
|
|
15356
|
-
reason: plugin.reason,
|
|
15357
|
-
config: plugin.config,
|
|
15358
|
-
projected: plugin.projected
|
|
15359
|
-
};
|
|
15360
|
-
}
|
|
15361
|
-
return {
|
|
15362
|
-
name: plugin.name,
|
|
15363
|
-
display_name: entry.display_name ?? plugin.display_name ?? null,
|
|
15364
|
-
icon: entry.icon,
|
|
15365
|
-
iconSource: "account",
|
|
15366
|
-
installed: entry.installed,
|
|
15367
|
-
connector: entry.connector,
|
|
15368
|
-
auth_status: entry.auth_status,
|
|
15369
|
-
active: plugin.active,
|
|
15370
|
-
status: plugin.status,
|
|
15371
|
-
reason: plugin.reason,
|
|
15372
|
-
config: plugin.config,
|
|
15373
|
-
projected: plugin.projected
|
|
15374
|
-
};
|
|
15375
|
-
});
|
|
15376
|
-
}
|
|
15377
|
-
function filterConnectorItems(items, query) {
|
|
15378
|
-
const needle = query.trim().toLowerCase();
|
|
15379
|
-
if (!needle) return items;
|
|
15380
|
-
return items.filter(
|
|
15381
|
-
(item) => `${item.display_name ?? ""} ${item.name}`.toLowerCase().includes(needle)
|
|
15382
|
-
);
|
|
15383
|
-
}
|
|
15384
|
-
|
|
15385
|
-
// src/components/use-session-plugin-activation.ts
|
|
15386
|
-
import { isLocalConnectorName } from "@blade-hq/agent-client/internal";
|
|
15387
|
-
import { useCallback as useCallback20, useEffect as useEffect9, useMemo as useMemo10, useRef as useRef9, useState as useState12 } from "react";
|
|
15388
|
-
function useSessionPluginActivation({
|
|
15389
|
-
client,
|
|
15390
|
-
sessionId,
|
|
15391
|
-
onChange
|
|
15392
|
-
}) {
|
|
15393
|
-
const [plugins, setPlugins] = useState12([]);
|
|
15394
|
-
const [catalog, setCatalog] = useState12(null);
|
|
15395
|
-
const [loading, setLoading] = useState12(false);
|
|
15396
|
-
const [listError, setListError] = useState12(false);
|
|
15397
|
-
const [mutationError, setMutationError] = useState12(false);
|
|
15398
|
-
const [inFlight, setInFlight] = useState12({});
|
|
15399
|
-
const [configuring, setConfiguring] = useState12(null);
|
|
15400
|
-
const alive = useRef9(true);
|
|
15401
|
-
const generation2 = useRef9(0);
|
|
15402
|
-
const mutationGenerations = useRef9(/* @__PURE__ */ new Map());
|
|
15403
|
-
const desiredActivations = useRef9(/* @__PURE__ */ new Map());
|
|
15404
|
-
const pendingMutations = useRef9(/* @__PURE__ */ new Map());
|
|
15405
|
-
const submittedActivations = useRef9(/* @__PURE__ */ new Set());
|
|
15406
|
-
const serverActive = useRef9(/* @__PURE__ */ new Set());
|
|
15407
|
-
const lifetime = useRef9(0);
|
|
15408
|
-
const request = useRef9(null);
|
|
15409
|
-
const [desiredVersion, setDesiredVersion] = useState12(0);
|
|
15410
|
-
const setDesired = useCallback20((name, value) => {
|
|
15411
|
-
if (value === null) {
|
|
15412
|
-
if (!desiredActivations.current.delete(name)) return;
|
|
15413
|
-
} else {
|
|
15414
|
-
if (desiredActivations.current.get(name) === value) return;
|
|
15415
|
-
desiredActivations.current.set(name, value);
|
|
15416
|
-
}
|
|
15417
|
-
setDesiredVersion((version) => version + 1);
|
|
15418
|
-
}, []);
|
|
15419
|
-
const items = useMemo10(() => {
|
|
15420
|
-
void desiredVersion;
|
|
15421
|
-
const merged = mergeConnectorItems(plugins, catalog);
|
|
15422
|
-
return merged.map((item) => {
|
|
15423
|
-
if (configuring?.name === item.name && configuring.pendingActivation) {
|
|
15424
|
-
return { ...item, active: false };
|
|
15425
|
-
}
|
|
15426
|
-
const desired = desiredActivations.current.get(item.name);
|
|
15427
|
-
return desired === void 0 ? item : { ...item, active: desired };
|
|
15428
|
-
});
|
|
15429
|
-
}, [catalog, configuring, desiredVersion, plugins]);
|
|
15430
|
-
const markInFlight = useCallback20((name, on) => {
|
|
15431
|
-
setInFlight((current) => {
|
|
15432
|
-
if (on) return current[name] ? current : { ...current, [name]: true };
|
|
15433
|
-
if (!current[name]) return current;
|
|
15434
|
-
const { [name]: removed, ...rest } = current;
|
|
15435
|
-
void removed;
|
|
15436
|
-
return rest;
|
|
15437
|
-
});
|
|
15438
|
-
}, []);
|
|
15439
|
-
useEffect9(() => {
|
|
15440
|
-
alive.current = true;
|
|
15441
|
-
setPlugins([]);
|
|
15442
|
-
setCatalog(null);
|
|
15443
|
-
setLoading(false);
|
|
15444
|
-
setListError(false);
|
|
15445
|
-
setMutationError(false);
|
|
15446
|
-
setInFlight({});
|
|
15447
|
-
setConfiguring(null);
|
|
15448
|
-
desiredActivations.current.clear();
|
|
15449
|
-
mutationGenerations.current.clear();
|
|
15450
|
-
pendingMutations.current.clear();
|
|
15451
|
-
submittedActivations.current.clear();
|
|
15452
|
-
return () => {
|
|
15453
|
-
alive.current = false;
|
|
15454
|
-
lifetime.current++;
|
|
15455
|
-
generation2.current++;
|
|
15456
|
-
request.current?.abort();
|
|
15457
|
-
};
|
|
15458
|
-
}, [client]);
|
|
15459
|
-
const load = useCallback20(async () => {
|
|
15460
|
-
if (!alive.current) return;
|
|
15461
|
-
request.current?.abort();
|
|
15462
|
-
const controller = new AbortController();
|
|
15463
|
-
request.current = controller;
|
|
15464
|
-
const current = ++generation2.current;
|
|
15465
|
-
setLoading(true);
|
|
15466
|
-
setListError(false);
|
|
15467
|
-
try {
|
|
15468
|
-
const result = await client.sessions.listSessionPlugins(sessionId, { signal: controller.signal });
|
|
15469
|
-
const withConfig = await Promise.all(
|
|
15470
|
-
result.plugins.map(async (item) => {
|
|
15471
|
-
if (isLocalConnectorName(item.name) || item.config !== void 0 && item.config !== "unchecked") return item;
|
|
15472
|
-
try {
|
|
15473
|
-
const { config } = await client.sessions.getSessionPluginConfig(sessionId, item.name, {
|
|
15474
|
-
signal: controller.signal
|
|
15475
|
-
});
|
|
15476
|
-
return { ...item, config: config.state };
|
|
15477
|
-
} catch {
|
|
15478
|
-
return item;
|
|
15479
|
-
}
|
|
15480
|
-
})
|
|
15481
|
-
);
|
|
15482
|
-
if (alive.current && current === generation2.current) {
|
|
15483
|
-
serverActive.current = new Set(withConfig.filter((item) => item.active).map((item) => item.name));
|
|
15484
|
-
setPlugins(withConfig.map((item) => {
|
|
15485
|
-
const desired = desiredActivations.current.get(item.name);
|
|
15486
|
-
return desired === void 0 ? item : { ...item, active: desired };
|
|
15487
|
-
}));
|
|
15488
|
-
}
|
|
15489
|
-
} catch {
|
|
15490
|
-
if (alive.current && current === generation2.current && !controller.signal.aborted) setListError(true);
|
|
15491
|
-
} finally {
|
|
15492
|
-
if (alive.current && current === generation2.current) setLoading(false);
|
|
15493
|
-
}
|
|
15494
|
-
}, [client, sessionId]);
|
|
15495
|
-
const loadCatalog = useCallback20(async () => {
|
|
15496
|
-
try {
|
|
15497
|
-
const { plugins: entries } = await client.plugins.catalog();
|
|
15498
|
-
if (alive.current) setCatalog(entries);
|
|
15499
|
-
} catch {
|
|
15500
|
-
}
|
|
15501
|
-
}, [client]);
|
|
15502
|
-
const reload = useCallback20(() => {
|
|
15503
|
-
void load();
|
|
15504
|
-
void loadCatalog();
|
|
15505
|
-
}, [load, loadCatalog]);
|
|
15506
|
-
const abandon = useCallback20((name) => {
|
|
15507
|
-
setDesired(name, null);
|
|
15508
|
-
pendingMutations.current.delete(name);
|
|
15509
|
-
mutationGenerations.current.set(name, (mutationGenerations.current.get(name) ?? 0) + 1);
|
|
15510
|
-
markInFlight(name, false);
|
|
15511
|
-
void load();
|
|
15512
|
-
}, [load, markInFlight, setDesired]);
|
|
15513
|
-
const finish = useCallback20((name, mutation) => {
|
|
15514
|
-
pendingMutations.current.delete(name);
|
|
15515
|
-
setDesired(name, null);
|
|
15516
|
-
if (mutation === mutationGenerations.current.get(name)) markInFlight(name, false);
|
|
15517
|
-
}, [markInFlight, setDesired]);
|
|
15518
|
-
const commitActivation = useCallback20(
|
|
15519
|
-
async (name, active, mutation, startedAt) => {
|
|
15520
|
-
submittedActivations.current.add(name);
|
|
15521
|
-
try {
|
|
15522
|
-
const { plugin } = await client.sessions.setSessionPluginActivation(sessionId, name, active);
|
|
15523
|
-
if (!alive.current || startedAt !== lifetime.current) return;
|
|
15524
|
-
if (mutation !== mutationGenerations.current.get(name)) {
|
|
15525
|
-
const desired = desiredActivations.current.get(name);
|
|
15526
|
-
if (desired !== void 0 && desired !== plugin.active) {
|
|
15527
|
-
const next = (mutationGenerations.current.get(name) ?? 0) + 1;
|
|
15528
|
-
mutationGenerations.current.set(name, next);
|
|
15529
|
-
pendingMutations.current.set(name, next);
|
|
15530
|
-
markInFlight(name, true);
|
|
15531
|
-
await commitActivation(name, desired, next, startedAt);
|
|
15532
|
-
}
|
|
15533
|
-
return;
|
|
15534
|
-
}
|
|
15535
|
-
if (active) serverActive.current.add(name);
|
|
15536
|
-
else serverActive.current.delete(name);
|
|
15537
|
-
finish(name, mutation);
|
|
15538
|
-
setPlugins((current) => current.map((item) => item.name === plugin.name ? { ...item, ...plugin } : item));
|
|
15539
|
-
onChange?.(plugin);
|
|
15540
|
-
if (plugin.active && plugin.status === "required") {
|
|
15541
|
-
setConfiguring({ name: plugin.name, pendingActivation: true });
|
|
15542
|
-
}
|
|
15543
|
-
await load();
|
|
15544
|
-
} catch {
|
|
15545
|
-
if (alive.current && startedAt === lifetime.current && mutation === mutationGenerations.current.get(name)) {
|
|
15546
|
-
pendingMutations.current.delete(name);
|
|
15547
|
-
submittedActivations.current.delete(name);
|
|
15548
|
-
setDesired(name, null);
|
|
15549
|
-
markInFlight(name, false);
|
|
15550
|
-
setMutationError(true);
|
|
15551
|
-
void load();
|
|
15552
|
-
}
|
|
15553
|
-
}
|
|
15554
|
-
},
|
|
15555
|
-
[client, finish, load, markInFlight, onChange, sessionId, setDesired]
|
|
15556
|
-
);
|
|
15557
|
-
const enable = useCallback20(async (name) => {
|
|
15558
|
-
if (!alive.current) return;
|
|
15559
|
-
const startedAt = lifetime.current;
|
|
15560
|
-
const mutation = (mutationGenerations.current.get(name) ?? 0) + 1;
|
|
15561
|
-
mutationGenerations.current.set(name, mutation);
|
|
15562
|
-
pendingMutations.current.set(name, mutation);
|
|
15563
|
-
setDesired(name, true);
|
|
15564
|
-
setMutationError(false);
|
|
15565
|
-
markInFlight(name, true);
|
|
15566
|
-
request.current?.abort();
|
|
15567
|
-
generation2.current++;
|
|
15568
|
-
setLoading(false);
|
|
15569
|
-
let state;
|
|
15570
|
-
try {
|
|
15571
|
-
const result = await client.sessions.prepareSessionPluginConfig(sessionId, name);
|
|
15572
|
-
if (!alive.current || startedAt !== lifetime.current || mutation !== mutationGenerations.current.get(name)) return;
|
|
15573
|
-
state = result.config;
|
|
15574
|
-
} catch {
|
|
15575
|
-
if (!alive.current || startedAt !== lifetime.current || mutation !== mutationGenerations.current.get(name)) return;
|
|
15576
|
-
abandon(name);
|
|
15577
|
-
setMutationError(true);
|
|
15578
|
-
return;
|
|
15579
|
-
}
|
|
15580
|
-
if (state.state === "required") {
|
|
15581
|
-
pendingMutations.current.delete(name);
|
|
15582
|
-
markInFlight(name, false);
|
|
15583
|
-
setConfiguring({ name, pendingActivation: true });
|
|
15584
|
-
return;
|
|
15585
|
-
}
|
|
15586
|
-
if (state.state !== "configured" && state.state !== "not_required") {
|
|
15587
|
-
abandon(name);
|
|
15588
|
-
setMutationError(true);
|
|
15589
|
-
return;
|
|
15590
|
-
}
|
|
15591
|
-
setPlugins((current) => current.map((item) => item.name === name ? { ...item, config: state.state } : item));
|
|
15592
|
-
await commitActivation(name, true, mutation, startedAt);
|
|
15593
|
-
}, [abandon, client, commitActivation, markInFlight, sessionId, setDesired]);
|
|
15594
|
-
const disable = useCallback20((name) => {
|
|
15595
|
-
const startedAt = lifetime.current;
|
|
15596
|
-
request.current?.abort();
|
|
15597
|
-
generation2.current++;
|
|
15598
|
-
setLoading(false);
|
|
15599
|
-
if (!submittedActivations.current.has(name) && !serverActive.current.has(name)) {
|
|
15600
|
-
abandon(name);
|
|
15601
|
-
return;
|
|
15602
|
-
}
|
|
15603
|
-
const mutation = (mutationGenerations.current.get(name) ?? 0) + 1;
|
|
15604
|
-
mutationGenerations.current.set(name, mutation);
|
|
15605
|
-
pendingMutations.current.set(name, mutation);
|
|
15606
|
-
setDesired(name, false);
|
|
15607
|
-
setMutationError(false);
|
|
15608
|
-
markInFlight(name, true);
|
|
15609
|
-
void commitActivation(name, false, mutation, startedAt);
|
|
15610
|
-
}, [abandon, commitActivation, markInFlight, setDesired]);
|
|
15611
|
-
const toggle = useCallback20((item, next) => {
|
|
15612
|
-
if (next) void enable(item.name);
|
|
15613
|
-
else disable(item.name);
|
|
15614
|
-
}, [disable, enable]);
|
|
15615
|
-
const retry = useCallback20((item) => {
|
|
15616
|
-
void enable(item.name);
|
|
15617
|
-
}, [enable]);
|
|
15618
|
-
const editConfig = useCallback20((item) => {
|
|
15619
|
-
setConfiguring({ name: item.name, pendingActivation: false });
|
|
15620
|
-
}, []);
|
|
15621
|
-
const onConfigSaved = useCallback20((state) => {
|
|
15622
|
-
const target = configuring;
|
|
15623
|
-
if (!target) return;
|
|
15624
|
-
setConfiguring(null);
|
|
15625
|
-
void loadCatalog();
|
|
15626
|
-
setPlugins((current) => current.map((item) => item.name === target.name ? { ...item, config: state.state } : item));
|
|
15627
|
-
if (!target.pendingActivation || state.state !== "configured") {
|
|
15628
|
-
void load();
|
|
15629
|
-
return;
|
|
15630
|
-
}
|
|
15631
|
-
const startedAt = lifetime.current;
|
|
15632
|
-
const mutation = (mutationGenerations.current.get(target.name) ?? 0) + 1;
|
|
15633
|
-
mutationGenerations.current.set(target.name, mutation);
|
|
15634
|
-
pendingMutations.current.set(target.name, mutation);
|
|
15635
|
-
setDesired(target.name, true);
|
|
15636
|
-
markInFlight(target.name, true);
|
|
15637
|
-
void commitActivation(target.name, true, mutation, startedAt);
|
|
15638
|
-
}, [commitActivation, configuring, load, loadCatalog, markInFlight, setDesired]);
|
|
15639
|
-
const onConfigClose = useCallback20(() => {
|
|
15640
|
-
const target = configuring;
|
|
15641
|
-
if (!target) return;
|
|
15642
|
-
setConfiguring(null);
|
|
15643
|
-
if (target.pendingActivation) abandon(target.name);
|
|
15644
|
-
else void load();
|
|
15645
|
-
}, [abandon, configuring, load]);
|
|
15646
|
-
return {
|
|
15647
|
-
items,
|
|
15648
|
-
loading,
|
|
15649
|
-
listError,
|
|
15650
|
-
mutationError,
|
|
15651
|
-
inFlight,
|
|
15652
|
-
busy: Object.keys(inFlight).length > 0,
|
|
15653
|
-
configuring,
|
|
15654
|
-
reload,
|
|
15655
|
-
toggle,
|
|
15656
|
-
retry,
|
|
15657
|
-
editConfig,
|
|
15658
|
-
onConfigSaved,
|
|
15659
|
-
onConfigClose
|
|
15660
|
-
};
|
|
15661
|
-
}
|
|
15662
|
-
|
|
15663
|
-
// src/lib/message-shortcuts.ts
|
|
15664
|
-
function usesCommandKey() {
|
|
15665
|
-
if (typeof navigator === "undefined") return false;
|
|
15666
|
-
return /Mac|iPhone|iPad|iPod/i.test(navigator.platform || navigator.userAgent);
|
|
15667
|
-
}
|
|
15668
|
-
function queueShortcutLabel() {
|
|
15669
|
-
return usesCommandKey() ? "\u2318 Enter" : "Ctrl Enter";
|
|
15670
|
-
}
|
|
15671
|
-
function isQueueShortcut(event) {
|
|
15672
|
-
return usesCommandKey() ? event.metaKey : event.ctrlKey;
|
|
15673
|
-
}
|
|
15674
|
-
|
|
15675
|
-
// src/chat/runtime/actions.ts
|
|
15676
|
-
function buildPendingAskUserAnswer(state, message) {
|
|
15677
|
-
if (state.status !== "waiting_for_input") return void 0;
|
|
15678
|
-
const text = extractMessageText(message);
|
|
15679
|
-
if (!text) return void 0;
|
|
15680
|
-
for (let turnIndex = state.turns.length - 1; turnIndex >= 0; turnIndex -= 1) {
|
|
15681
|
-
const turn = state.turns[turnIndex];
|
|
15682
|
-
if (turn.loop_id === "root" || turn.role !== "assistant") continue;
|
|
15683
|
-
for (let toolIndex = turn.tool_calls.length - 1; toolIndex >= 0; toolIndex -= 1) {
|
|
15684
|
-
const toolCall = turn.tool_calls[toolIndex];
|
|
15685
|
-
if (toolCall.status !== "awaiting_answer") continue;
|
|
15686
|
-
if (!toolCall.tool_name.includes("AskUserQuestion")) continue;
|
|
15687
|
-
return { tool_call_id: toolCall.id, selections: {}, custom: { "0": text } };
|
|
15688
|
-
}
|
|
15689
|
-
}
|
|
15690
|
-
return void 0;
|
|
15691
|
-
}
|
|
15692
|
-
function extractMessageText(message) {
|
|
15693
|
-
if (typeof message === "string") return message.trim();
|
|
15694
|
-
return message.filter((part) => part.type === "text").map((part) => part.text.trim()).filter(Boolean).join("\n").trim();
|
|
15695
|
-
}
|
|
15696
|
-
function sendToSession(session, message, mode, askUserAnswer, extras = {}) {
|
|
15697
|
-
return session.send(message, {
|
|
15698
|
-
mode,
|
|
15699
|
-
askUserAnswer: askUserAnswer ?? buildPendingAskUserAnswer(session.getState(), message),
|
|
15700
|
-
model: extras.model,
|
|
15701
|
-
thinkingOverride: extras.thinkingOverride,
|
|
15702
|
-
reasoningLevel: extras.reasoningLevel,
|
|
15703
|
-
refs: extras.refs,
|
|
15704
|
-
contextAttachments: extras.contextAttachments,
|
|
15705
|
-
topicAssetRefs: extras.topicAssetRefs,
|
|
15706
|
-
whatif: extras.whatif,
|
|
15707
|
-
replayDecision: extras.replayDecision,
|
|
15708
|
-
queueWhenRunning: extras.queueWhenRunning
|
|
15709
|
-
});
|
|
15710
|
-
}
|
|
15711
|
-
|
|
15712
|
-
// src/chat/chat-theme.tsx
|
|
15713
|
-
var NEUTRAL = {
|
|
15714
|
-
text: "text-[hsl(var(--muted-foreground))]",
|
|
15715
|
-
border: "border-l-[hsl(var(--swf-border-strong))]",
|
|
15716
|
-
surface: "bg-[hsl(var(--muted))]"
|
|
15717
|
-
};
|
|
15718
|
-
var TONE_CLASSES = {
|
|
15719
|
-
running: NEUTRAL,
|
|
15720
|
-
reasoning: NEUTRAL,
|
|
15721
|
-
success: {
|
|
15722
|
-
text: "text-[hsl(var(--swf-success))]",
|
|
15723
|
-
border: "border-l-[hsl(var(--swf-success))]",
|
|
15724
|
-
surface: "bg-[hsl(var(--swf-success-soft))]"
|
|
15725
|
-
},
|
|
15726
|
-
warning: {
|
|
15727
|
-
text: "text-[hsl(var(--swf-warning))]",
|
|
15728
|
-
border: "border-l-[hsl(var(--swf-warning))]",
|
|
15729
|
-
surface: "bg-[hsl(var(--swf-warning-soft))]"
|
|
15730
|
-
},
|
|
15731
|
-
danger: {
|
|
15732
|
-
text: "text-[hsl(var(--swf-danger))]",
|
|
15733
|
-
border: "border-l-[hsl(var(--swf-danger))]",
|
|
15734
|
-
surface: "bg-[hsl(var(--swf-danger-soft))]"
|
|
15735
|
-
}
|
|
15736
|
-
};
|
|
15737
|
-
function chatTone(tone) {
|
|
15738
|
-
return TONE_CLASSES[tone];
|
|
15739
|
-
}
|
|
15740
|
-
|
|
15741
|
-
// src/lib/use-effect-event.ts
|
|
15742
|
-
import * as React from "react";
|
|
15743
|
-
function useEffectEventShim(callback) {
|
|
15744
|
-
const ref = React.useRef(callback);
|
|
15745
|
-
React.useLayoutEffect(() => {
|
|
15746
|
-
ref.current = callback;
|
|
15747
|
-
});
|
|
15748
|
-
return React.useCallback(((...args) => ref.current(...args)), []);
|
|
15749
|
-
}
|
|
15750
|
-
var builtin = React.useEffectEvent;
|
|
15751
|
-
var useEffectEvent2 = builtin ?? useEffectEventShim;
|
|
15752
|
-
|
|
15753
14505
|
export {
|
|
15754
|
-
|
|
15755
|
-
onInputCachesReset,
|
|
15756
|
-
pluginRefsForSend,
|
|
15757
|
-
getPluginSuggestionItems,
|
|
15758
|
-
queueShortcutLabel,
|
|
15759
|
-
isQueueShortcut,
|
|
15760
|
-
sendToSession,
|
|
15761
|
-
chatTone,
|
|
15762
|
-
RichInputServicesProvider,
|
|
15763
|
-
useRichInputServices,
|
|
15764
|
-
fetchClientQuery,
|
|
15765
|
-
setClientQueryData,
|
|
15766
|
-
useClientQuery,
|
|
15767
|
-
refreshClientQuery,
|
|
15768
|
-
useRefreshWhenRunEnds,
|
|
15769
|
-
useClientSessionSkills,
|
|
15770
|
-
useClientSkillStats,
|
|
15771
|
-
useClientContextStats,
|
|
15772
|
-
useClientBackgroundTasks,
|
|
15773
|
-
refreshClientSessionSkills,
|
|
15774
|
-
useClientSessionModel,
|
|
15775
|
-
useClientModelCatalog,
|
|
15776
|
-
PREFERRED_MODEL_KEY,
|
|
15777
|
-
MODEL_REASONING_LEVELS_KEY,
|
|
15778
|
-
useClientModelPreferences,
|
|
15779
|
-
useModelCatalog,
|
|
15780
|
-
useModelPreferences,
|
|
15781
|
-
useComposerConnectionInfo,
|
|
15782
|
-
useComposerConnection,
|
|
15783
|
-
useSessionSkills,
|
|
15784
|
-
useSkillStats,
|
|
15785
|
-
useContextStats,
|
|
15786
|
-
useBackgroundTaskList,
|
|
15787
|
-
useSessionDataInvalidation,
|
|
15788
|
-
useEffectEvent2 as useEffectEvent,
|
|
15789
|
-
SessionPluginConfigForm,
|
|
15790
|
-
sessionPluginLabel,
|
|
15791
|
-
SessionPluginIcon,
|
|
15792
|
-
SessionPluginConfigDialog,
|
|
15793
|
-
PluginConnectorList,
|
|
15794
|
-
catalogToConnectorItems,
|
|
15795
|
-
mergeConnectorItems,
|
|
15796
|
-
filterConnectorItems,
|
|
15797
|
-
useSessionPluginActivation
|
|
14506
|
+
SessionPluginConfigForm
|
|
15798
14507
|
};
|
|
15799
14508
|
/*! Bundled license information:
|
|
15800
14509
|
|
|
@@ -15809,4 +14518,4 @@ react-is/cjs/react-is.development.js:
|
|
|
15809
14518
|
* LICENSE file in the root directory of this source tree.
|
|
15810
14519
|
*)
|
|
15811
14520
|
*/
|
|
15812
|
-
//# sourceMappingURL=chunk-
|
|
14521
|
+
//# sourceMappingURL=chunk-SK43YNRX.js.map
|