@goodandready/dsh-moa 0.2.17 → 0.2.19
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/lib/client.js +49 -9
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -18,6 +18,10 @@ window.__ModuleLoader__.load({
|
|
|
18
18
|
var exports = module.exports
|
|
19
19
|
const React = require('react')
|
|
20
20
|
const NS = 'dsh-moa'
|
|
21
|
+
// Plugins page row seat (DSH 0.1.6-alpha.2): key = '<package name>#<row id>'.
|
|
22
|
+
const PKG = '@goodandready/dsh-moa'
|
|
23
|
+
const ROW_ID = 'dsh-moa'
|
|
24
|
+
const ROW_CONFIG_KEY = PKG + '#' + ROW_ID
|
|
21
25
|
const TITLE = 'Mixture of Agents (MoA)'
|
|
22
26
|
const SUBTITLE = 'Ensemble parallel candidate generation with judge synthesis via /moa.'
|
|
23
27
|
|
|
@@ -1827,16 +1831,24 @@ window.__ModuleLoader__.load({
|
|
|
1827
1831
|
function MoACard(props) {
|
|
1828
1832
|
ensureStyles()
|
|
1829
1833
|
const state = useMoASettings(props)
|
|
1830
|
-
const
|
|
1834
|
+
const page = !!(props && props.view === 'page')
|
|
1835
|
+
const [open, setOpen] = React.useState(!!page)
|
|
1836
|
+
|
|
1837
|
+
// Row seat (plugins.row.config): the host page draws title/icon/crumb and the
|
|
1838
|
+
// padding, so the summary is a one-liner and the page drops our card chrome.
|
|
1839
|
+
if (props && props.view === 'summary') {
|
|
1840
|
+
return React.createElement('div', { className: 'moa-sub' }, state.t('description') || SUBTITLE)
|
|
1841
|
+
}
|
|
1831
1842
|
|
|
1832
1843
|
return React.createElement(
|
|
1833
|
-
'li',
|
|
1834
|
-
{ className: 'moa-card' },
|
|
1844
|
+
page ? 'div' : 'li',
|
|
1845
|
+
{ className: page ? 'moa-page' : 'moa-card' },
|
|
1835
1846
|
React.createElement(
|
|
1836
1847
|
'button',
|
|
1837
1848
|
{
|
|
1838
1849
|
type: 'button',
|
|
1839
1850
|
className: 'moa-head',
|
|
1851
|
+
style: page ? { display: 'none' } : undefined,
|
|
1840
1852
|
'aria-expanded': open,
|
|
1841
1853
|
onClick: () => setOpen(!open),
|
|
1842
1854
|
},
|
|
@@ -1908,27 +1920,55 @@ window.__ModuleLoader__.load({
|
|
|
1908
1920
|
}
|
|
1909
1921
|
|
|
1910
1922
|
if (ctx.slots) {
|
|
1911
|
-
const registerCard = () => {
|
|
1923
|
+
const registerCard = (slotName, key) => () => {
|
|
1924
|
+
try {
|
|
1925
|
+
ctx.slots.register(
|
|
1926
|
+
{
|
|
1927
|
+
name: slotName,
|
|
1928
|
+
key,
|
|
1929
|
+
order: 35,
|
|
1930
|
+
locale: NS,
|
|
1931
|
+
inject: () => ({ ctx }),
|
|
1932
|
+
},
|
|
1933
|
+
(props) => React.createElement(MoAErrorBoundary, null, React.createElement(MoACard, props))
|
|
1934
|
+
)
|
|
1935
|
+
} catch (err) {
|
|
1936
|
+
console.warn('[dsh-moa] Failed to register ' + slotName + ':', err)
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
|
|
1940
|
+
// Plugin-list seat (plugins.item): the seat the current core (0.1.6-alpha.2)
|
|
1941
|
+
// renders as the plugin's own page with its configuration. It needs an id and a
|
|
1942
|
+
// static label, so it is registered on its own rather than through the keyed
|
|
1943
|
+
// helper above. The label must not read the locale: it is resolved while the
|
|
1944
|
+
// page renders, and a lookup there would take the whole client batch down.
|
|
1945
|
+
const registerItemSeat = () => {
|
|
1912
1946
|
try {
|
|
1913
1947
|
ctx.slots.register(
|
|
1914
1948
|
{
|
|
1915
|
-
name: '
|
|
1916
|
-
|
|
1949
|
+
name: 'plugins.item',
|
|
1950
|
+
id: ROW_ID,
|
|
1917
1951
|
order: 35,
|
|
1952
|
+
label: () => 'Mixture of Agents (MoA)',
|
|
1918
1953
|
locale: NS,
|
|
1919
1954
|
inject: () => ({ ctx }),
|
|
1920
1955
|
},
|
|
1921
1956
|
(props) => React.createElement(MoAErrorBoundary, null, React.createElement(MoACard, props))
|
|
1922
1957
|
)
|
|
1923
1958
|
} catch (err) {
|
|
1924
|
-
console.warn('[dsh-moa] Failed to register
|
|
1959
|
+
console.warn('[dsh-moa] Failed to register plugins.item:', err)
|
|
1925
1960
|
}
|
|
1926
1961
|
}
|
|
1927
1962
|
|
|
1928
1963
|
if (typeof ctx.slots.inject === 'function') {
|
|
1929
|
-
|
|
1964
|
+
// Plugin-list seat first, then the row seat and the legacy seat as fallbacks.
|
|
1965
|
+
ctx.slots.inject('plugins.item', registerItemSeat)
|
|
1966
|
+
ctx.slots.inject('plugins.row.config', registerCard('plugins.row.config', ROW_CONFIG_KEY))
|
|
1967
|
+
ctx.slots.inject('settings.plugin.item', registerCard('settings.plugin.item', NS))
|
|
1930
1968
|
} else {
|
|
1931
|
-
|
|
1969
|
+
registerItemSeat()
|
|
1970
|
+
registerCard('plugins.row.config', ROW_CONFIG_KEY)()
|
|
1971
|
+
registerCard('settings.plugin.item', NS)()
|
|
1932
1972
|
}
|
|
1933
1973
|
}
|
|
1934
1974
|
|