dsh-plugin-marginalia 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client.js +311 -49
- package/index.js +12 -0
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -278,14 +278,14 @@ window.__ModuleLoader__.load({
|
|
|
278
278
|
}
|
|
279
279
|
.mg-user-bubble {
|
|
280
280
|
max-width: 88%;
|
|
281
|
-
padding:
|
|
281
|
+
padding: 10px 16px;
|
|
282
282
|
border-radius: 18px;
|
|
283
|
-
background: var(--dsw-alias-bg-layer-2);
|
|
283
|
+
background: var(--dsw-specific-user-bubble, var(--dsw-alias-bg-layer-2));
|
|
284
284
|
color: var(--dsw-alias-label-primary);
|
|
285
285
|
white-space: pre-wrap;
|
|
286
286
|
word-break: break-word;
|
|
287
|
-
font-size: 14px;
|
|
288
|
-
line-height: 1.
|
|
287
|
+
font-size: var(--dsh-content-font-size, 14px);
|
|
288
|
+
line-height: 1.6;
|
|
289
289
|
}
|
|
290
290
|
.mg-assistant-body {
|
|
291
291
|
width: 100%;
|
|
@@ -423,22 +423,116 @@ window.__ModuleLoader__.load({
|
|
|
423
423
|
border-color: var(--dsw-alias-state-error-primary);
|
|
424
424
|
}
|
|
425
425
|
.mg-composer {
|
|
426
|
-
padding:
|
|
426
|
+
padding: 4px 14px 12px;
|
|
427
427
|
background: var(--dsw-alias-bg-base);
|
|
428
428
|
}
|
|
429
429
|
.mg-input-box {
|
|
430
|
+
position: relative;
|
|
430
431
|
display: flex;
|
|
431
432
|
flex-direction: column;
|
|
432
|
-
gap:
|
|
433
|
-
padding: 10px
|
|
434
|
-
border-radius:
|
|
435
|
-
border: 1px solid var(--dsw-alias-border-
|
|
436
|
-
background: var(--dsw-alias-bg-layer-1);
|
|
437
|
-
box-shadow: 0 2px
|
|
433
|
+
gap: 10px;
|
|
434
|
+
padding: 12px 14px 10px;
|
|
435
|
+
border-radius: var(--dsw-radius-panel, 20px);
|
|
436
|
+
border: 1px solid var(--dsw-alias-border-l2);
|
|
437
|
+
background: var(--dsw-specific-input-major, var(--dsw-alias-bg-layer-1));
|
|
438
|
+
box-shadow: var(--dsw-elevation-soft, 0 2px 10px rgba(0, 0, 0, 0.06));
|
|
439
|
+
font-size: var(--dsh-content-font-size, 14px);
|
|
438
440
|
}
|
|
439
441
|
.mg-input-box:focus-within {
|
|
440
442
|
border-color: var(--dsw-alias-border-l2);
|
|
441
443
|
}
|
|
444
|
+
.mg-model-wrap {
|
|
445
|
+
position: relative;
|
|
446
|
+
display: inline-flex;
|
|
447
|
+
align-items: center;
|
|
448
|
+
}
|
|
449
|
+
.mg-model-btn {
|
|
450
|
+
display: inline-flex;
|
|
451
|
+
align-items: center;
|
|
452
|
+
gap: 5px;
|
|
453
|
+
border: none;
|
|
454
|
+
background: transparent;
|
|
455
|
+
color: var(--dsw-alias-label-secondary);
|
|
456
|
+
font-size: 12.5px;
|
|
457
|
+
font-weight: 500;
|
|
458
|
+
padding: 4px 8px;
|
|
459
|
+
border-radius: 8px;
|
|
460
|
+
cursor: pointer;
|
|
461
|
+
max-width: 190px;
|
|
462
|
+
transition: background-color 0.15s ease, color 0.15s ease;
|
|
463
|
+
}
|
|
464
|
+
.mg-model-btn:hover {
|
|
465
|
+
background: var(--dsw-alias-bg-layer-2);
|
|
466
|
+
color: var(--dsw-alias-label-primary);
|
|
467
|
+
}
|
|
468
|
+
.mg-model-name {
|
|
469
|
+
overflow: hidden;
|
|
470
|
+
text-overflow: ellipsis;
|
|
471
|
+
white-space: nowrap;
|
|
472
|
+
}
|
|
473
|
+
.mg-model-menu {
|
|
474
|
+
position: absolute;
|
|
475
|
+
right: 0;
|
|
476
|
+
bottom: calc(100% + 8px);
|
|
477
|
+
width: 260px;
|
|
478
|
+
max-height: 320px;
|
|
479
|
+
overflow-y: auto;
|
|
480
|
+
padding: 6px;
|
|
481
|
+
border-radius: 14px;
|
|
482
|
+
background: var(--dsw-alias-bg-overlay, var(--dsw-alias-bg-layer-1));
|
|
483
|
+
border: 1px solid var(--dsw-alias-border-l1);
|
|
484
|
+
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
|
|
485
|
+
z-index: 100;
|
|
486
|
+
}
|
|
487
|
+
.mg-model-group {
|
|
488
|
+
padding: 4px 8px 2px;
|
|
489
|
+
font-size: 11px;
|
|
490
|
+
font-weight: 600;
|
|
491
|
+
color: var(--dsw-alias-label-secondary);
|
|
492
|
+
text-transform: uppercase;
|
|
493
|
+
letter-spacing: 0.03em;
|
|
494
|
+
}
|
|
495
|
+
.mg-model-item {
|
|
496
|
+
width: 100%;
|
|
497
|
+
display: flex;
|
|
498
|
+
align-items: center;
|
|
499
|
+
justify-content: space-between;
|
|
500
|
+
gap: 8px;
|
|
501
|
+
border: none;
|
|
502
|
+
background: transparent;
|
|
503
|
+
color: var(--dsw-alias-label-primary);
|
|
504
|
+
font-size: 12.5px;
|
|
505
|
+
padding: 6px 8px;
|
|
506
|
+
border-radius: 8px;
|
|
507
|
+
cursor: pointer;
|
|
508
|
+
text-align: left;
|
|
509
|
+
}
|
|
510
|
+
.mg-model-item:hover {
|
|
511
|
+
background: var(--dsw-alias-bg-layer-2);
|
|
512
|
+
}
|
|
513
|
+
.mg-model-item.is-selected {
|
|
514
|
+
color: var(--dsw-alias-brand-primary);
|
|
515
|
+
font-weight: 600;
|
|
516
|
+
}
|
|
517
|
+
.mg-effort-row {
|
|
518
|
+
display: flex;
|
|
519
|
+
flex-wrap: wrap;
|
|
520
|
+
gap: 4px;
|
|
521
|
+
padding: 4px 8px 6px;
|
|
522
|
+
}
|
|
523
|
+
.mg-effort-pill {
|
|
524
|
+
border: 1px solid var(--dsw-alias-border-l1);
|
|
525
|
+
background: transparent;
|
|
526
|
+
color: var(--dsw-alias-label-secondary);
|
|
527
|
+
font-size: 11px;
|
|
528
|
+
padding: 2px 7px;
|
|
529
|
+
border-radius: 999px;
|
|
530
|
+
cursor: pointer;
|
|
531
|
+
}
|
|
532
|
+
.mg-effort-pill.is-selected {
|
|
533
|
+
border-color: var(--dsw-alias-brand-primary);
|
|
534
|
+
color: var(--dsw-alias-brand-primary);
|
|
535
|
+
}
|
|
442
536
|
.mg-quote-strip {
|
|
443
537
|
display: flex;
|
|
444
538
|
flex-direction: column;
|
|
@@ -983,10 +1077,62 @@ window.__ModuleLoader__.load({
|
|
|
983
1077
|
const [streaming, setStreaming] = React.useState(false);
|
|
984
1078
|
const [copiedId, setCopiedId] = React.useState(null);
|
|
985
1079
|
const [notice, setNotice] = React.useState(null);
|
|
1080
|
+
const [catalog, setCatalog] = React.useState(null);
|
|
1081
|
+
const [selectedModel, setSelectedModel] = React.useState(() => {
|
|
1082
|
+
try {
|
|
1083
|
+
const raw = window.localStorage.getItem('dsh.marginalia.model.v1');
|
|
1084
|
+
return raw ? JSON.parse(raw) : null;
|
|
1085
|
+
} catch {
|
|
1086
|
+
return null;
|
|
1087
|
+
}
|
|
1088
|
+
});
|
|
1089
|
+
const [modelMenuOpen, setModelMenuOpen] = React.useState(false);
|
|
986
1090
|
|
|
987
1091
|
const abortRef = React.useRef(null);
|
|
988
1092
|
const scrollRef = React.useRef(null);
|
|
989
1093
|
const textareaRef = React.useRef(null);
|
|
1094
|
+
const modelMenuRef = React.useRef(null);
|
|
1095
|
+
|
|
1096
|
+
React.useEffect(() => {
|
|
1097
|
+
let cancelled = false;
|
|
1098
|
+
const loadCatalog = async () => {
|
|
1099
|
+
const fn = ctx.remote?.session?.modelCatalog;
|
|
1100
|
+
if (typeof fn !== 'function') return;
|
|
1101
|
+
try {
|
|
1102
|
+
const res = await fn();
|
|
1103
|
+
if (!cancelled && res) {
|
|
1104
|
+
setCatalog(res);
|
|
1105
|
+
setSelectedModel((curr) => curr || res.default || null);
|
|
1106
|
+
}
|
|
1107
|
+
} catch {
|
|
1108
|
+
// Ignore catalog load failure; server falls back to session/default model.
|
|
1109
|
+
}
|
|
1110
|
+
};
|
|
1111
|
+
loadCatalog();
|
|
1112
|
+
return () => {
|
|
1113
|
+
cancelled = true;
|
|
1114
|
+
};
|
|
1115
|
+
}, []);
|
|
1116
|
+
|
|
1117
|
+
React.useEffect(() => {
|
|
1118
|
+
if (!modelMenuOpen) return;
|
|
1119
|
+
const onDocDown = (e) => {
|
|
1120
|
+
if (modelMenuRef.current && !modelMenuRef.current.contains(e.target)) {
|
|
1121
|
+
setModelMenuOpen(false);
|
|
1122
|
+
}
|
|
1123
|
+
};
|
|
1124
|
+
document.addEventListener('mousedown', onDocDown);
|
|
1125
|
+
return () => document.removeEventListener('mousedown', onDocDown);
|
|
1126
|
+
}, [modelMenuOpen]);
|
|
1127
|
+
|
|
1128
|
+
function chooseModel(next) {
|
|
1129
|
+
setSelectedModel(next);
|
|
1130
|
+
try {
|
|
1131
|
+
window.localStorage.setItem('dsh.marginalia.model.v1', JSON.stringify(next));
|
|
1132
|
+
} catch {
|
|
1133
|
+
// Ignore storage error.
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
990
1136
|
|
|
991
1137
|
React.useEffect(() => {
|
|
992
1138
|
const listener = (nextQuotes) => {
|
|
@@ -1128,6 +1274,7 @@ window.__ModuleLoader__.load({
|
|
|
1128
1274
|
quotes: activeQuotes,
|
|
1129
1275
|
includeContext,
|
|
1130
1276
|
history: priorHistory,
|
|
1277
|
+
model: selectedModel || undefined,
|
|
1131
1278
|
}),
|
|
1132
1279
|
signal: controller.signal,
|
|
1133
1280
|
});
|
|
@@ -1486,47 +1633,162 @@ window.__ModuleLoader__.load({
|
|
|
1486
1633
|
: t('context.off')
|
|
1487
1634
|
: t('mode.main'),
|
|
1488
1635
|
),
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1636
|
+
h(
|
|
1637
|
+
'div',
|
|
1638
|
+
{ style: { display: 'inline-flex', alignItems: 'center', gap: '6px' } },
|
|
1639
|
+
mode === 'side' && catalog && Array.isArray(catalog.groups) && catalog.groups.length > 0
|
|
1640
|
+
? h(
|
|
1641
|
+
'div',
|
|
1642
|
+
{ className: 'mg-model-wrap', ref: modelMenuRef },
|
|
1643
|
+
h(
|
|
1644
|
+
'button',
|
|
1645
|
+
{
|
|
1646
|
+
type: 'button',
|
|
1647
|
+
className: 'mg-model-btn',
|
|
1648
|
+
onClick: () => setModelMenuOpen((v) => !v),
|
|
1649
|
+
},
|
|
1650
|
+
h(
|
|
1651
|
+
'span',
|
|
1652
|
+
{ className: 'mg-model-name' },
|
|
1653
|
+
(() => {
|
|
1654
|
+
const grp = catalog.groups.find((g) => g.id === selectedModel?.provider);
|
|
1655
|
+
const mod = grp?.models?.find((m) => m.id === selectedModel?.model);
|
|
1656
|
+
const name = mod?.name || selectedModel?.model || 'Model';
|
|
1657
|
+
return selectedModel?.reasoningEffort
|
|
1658
|
+
? name + ' · ' + selectedModel.reasoningEffort
|
|
1659
|
+
: name;
|
|
1660
|
+
})(),
|
|
1661
|
+
),
|
|
1662
|
+
h(
|
|
1663
|
+
'svg',
|
|
1664
|
+
{
|
|
1665
|
+
width: 12,
|
|
1666
|
+
height: 12,
|
|
1667
|
+
viewBox: '0 0 24 24',
|
|
1668
|
+
fill: 'none',
|
|
1669
|
+
stroke: 'currentColor',
|
|
1670
|
+
strokeWidth: 2,
|
|
1671
|
+
strokeLinecap: 'round',
|
|
1672
|
+
strokeLinejoin: 'round',
|
|
1673
|
+
},
|
|
1674
|
+
h('path', { d: 'M6 9l6 6 6-6' }),
|
|
1675
|
+
),
|
|
1676
|
+
),
|
|
1677
|
+
modelMenuOpen
|
|
1678
|
+
? h(
|
|
1679
|
+
'div',
|
|
1680
|
+
{ className: 'mg-model-menu' },
|
|
1681
|
+
catalog.groups.map((grp) =>
|
|
1682
|
+
h(
|
|
1683
|
+
'div',
|
|
1684
|
+
{ key: grp.id },
|
|
1685
|
+
h('div', { className: 'mg-model-group' }, grp.name || grp.id),
|
|
1686
|
+
(grp.models || []).map((mod) => {
|
|
1687
|
+
const isSel =
|
|
1688
|
+
selectedModel?.provider === grp.id &&
|
|
1689
|
+
selectedModel?.model === mod.id;
|
|
1690
|
+
const efforts = mod.reasoning?.efforts || [];
|
|
1691
|
+
return h(
|
|
1692
|
+
'div',
|
|
1693
|
+
{ key: mod.id },
|
|
1694
|
+
h(
|
|
1695
|
+
'button',
|
|
1696
|
+
{
|
|
1697
|
+
type: 'button',
|
|
1698
|
+
className: 'mg-model-item' + (isSel ? ' is-selected' : ''),
|
|
1699
|
+
onClick: () => {
|
|
1700
|
+
chooseModel({
|
|
1701
|
+
provider: grp.id,
|
|
1702
|
+
model: mod.id,
|
|
1703
|
+
...(mod.reasoning?.defaultEffort
|
|
1704
|
+
? { reasoningEffort: mod.reasoning.defaultEffort }
|
|
1705
|
+
: {}),
|
|
1706
|
+
});
|
|
1707
|
+
if (efforts.length === 0) setModelMenuOpen(false);
|
|
1708
|
+
},
|
|
1709
|
+
},
|
|
1710
|
+
h('span', null, mod.name || mod.id),
|
|
1711
|
+
isSel ? h('span', null, '✓') : null,
|
|
1712
|
+
),
|
|
1713
|
+
isSel && efforts.length > 0
|
|
1714
|
+
? h(
|
|
1715
|
+
'div',
|
|
1716
|
+
{ className: 'mg-effort-row' },
|
|
1717
|
+
efforts.map((eff) =>
|
|
1718
|
+
h(
|
|
1719
|
+
'button',
|
|
1720
|
+
{
|
|
1721
|
+
key: eff.id,
|
|
1722
|
+
type: 'button',
|
|
1723
|
+
className:
|
|
1724
|
+
'mg-effort-pill' +
|
|
1725
|
+
(selectedModel?.reasoningEffort === eff.id
|
|
1726
|
+
? ' is-selected'
|
|
1727
|
+
: ''),
|
|
1728
|
+
onClick: () => {
|
|
1729
|
+
chooseModel({
|
|
1730
|
+
provider: grp.id,
|
|
1731
|
+
model: mod.id,
|
|
1732
|
+
reasoningEffort: eff.id,
|
|
1733
|
+
});
|
|
1734
|
+
setModelMenuOpen(false);
|
|
1735
|
+
},
|
|
1736
|
+
},
|
|
1737
|
+
eff.name || eff.id,
|
|
1738
|
+
),
|
|
1739
|
+
),
|
|
1740
|
+
)
|
|
1741
|
+
: null,
|
|
1742
|
+
);
|
|
1743
|
+
}),
|
|
1744
|
+
),
|
|
1745
|
+
),
|
|
1746
|
+
)
|
|
1747
|
+
: null,
|
|
1748
|
+
)
|
|
1749
|
+
: null,
|
|
1750
|
+
streaming
|
|
1751
|
+
? h(
|
|
1752
|
+
'button',
|
|
1517
1753
|
{
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
strokeWidth: 2.3,
|
|
1524
|
-
strokeLinecap: 'round',
|
|
1525
|
-
strokeLinejoin: 'round',
|
|
1754
|
+
type: 'button',
|
|
1755
|
+
className: 'mg-circle-btn is-stop',
|
|
1756
|
+
title: t('stop'),
|
|
1757
|
+
'aria-label': t('stop'),
|
|
1758
|
+
onClick: handleStop,
|
|
1526
1759
|
},
|
|
1527
|
-
h(
|
|
1760
|
+
h(
|
|
1761
|
+
'svg',
|
|
1762
|
+
{ width: 12, height: 12, viewBox: '0 0 12 12', fill: 'currentColor' },
|
|
1763
|
+
h('rect', { x: 2, y: 2, width: 8, height: 8, rx: 1.5 }),
|
|
1764
|
+
),
|
|
1765
|
+
)
|
|
1766
|
+
: h(
|
|
1767
|
+
'button',
|
|
1768
|
+
{
|
|
1769
|
+
type: 'button',
|
|
1770
|
+
className: 'mg-circle-btn',
|
|
1771
|
+
title: t('send'),
|
|
1772
|
+
'aria-label': t('send'),
|
|
1773
|
+
disabled: !draft.trim() && quotes.length === 0,
|
|
1774
|
+
onClick: () => handleSubmit(),
|
|
1775
|
+
},
|
|
1776
|
+
h(
|
|
1777
|
+
'svg',
|
|
1778
|
+
{
|
|
1779
|
+
width: 15,
|
|
1780
|
+
height: 15,
|
|
1781
|
+
viewBox: '0 0 24 24',
|
|
1782
|
+
fill: 'none',
|
|
1783
|
+
stroke: 'currentColor',
|
|
1784
|
+
strokeWidth: 2.3,
|
|
1785
|
+
strokeLinecap: 'round',
|
|
1786
|
+
strokeLinejoin: 'round',
|
|
1787
|
+
},
|
|
1788
|
+
h('path', { d: 'M12 19V5M5 12l7-7 7 7' }),
|
|
1789
|
+
),
|
|
1528
1790
|
),
|
|
1529
|
-
|
|
1791
|
+
),
|
|
1530
1792
|
),
|
|
1531
1793
|
),
|
|
1532
1794
|
),
|
package/index.js
CHANGED
|
@@ -99,6 +99,14 @@ export function apply(ctx) {
|
|
|
99
99
|
const rawQuotes = Array.isArray(body?.quotes)
|
|
100
100
|
? body.quotes.filter((q) => typeof q === 'string' && q.trim()).map((q) => q.trim().slice(0, 4000))
|
|
101
101
|
: [];
|
|
102
|
+
const requestedModel =
|
|
103
|
+
body?.model && typeof body.model === 'object' && body.model.provider && body.model.model
|
|
104
|
+
? {
|
|
105
|
+
provider: String(body.model.provider),
|
|
106
|
+
model: String(body.model.model),
|
|
107
|
+
...(body.model.reasoningEffort ? { reasoningEffort: String(body.model.reasoningEffort) } : {}),
|
|
108
|
+
}
|
|
109
|
+
: undefined;
|
|
102
110
|
|
|
103
111
|
if (!question && rawQuotes.length === 0) {
|
|
104
112
|
return Response.json({ error: 'Question is required' }, { status: 400 });
|
|
@@ -132,6 +140,10 @@ export function apply(ctx) {
|
|
|
132
140
|
}
|
|
133
141
|
}
|
|
134
142
|
|
|
143
|
+
if (requestedModel) {
|
|
144
|
+
modelConfig = requestedModel;
|
|
145
|
+
}
|
|
146
|
+
|
|
135
147
|
if (!modelConfig?.provider || !modelConfig?.model) {
|
|
136
148
|
modelConfig = ctx.agentDefaultModel.currentSelection();
|
|
137
149
|
}
|
package/package.json
CHANGED