anentrypoint-design 0.0.91 → 0.0.93
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "anentrypoint-design",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.93",
|
|
4
4
|
"description": "247420 design system SDK — webjsx + modified ripple-ui, single-file ESM bundle for reproducible use of the AnEntrypoint design.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/247420.js",
|
|
@@ -17,7 +17,10 @@ export async function chat(h0) {
|
|
|
17
17
|
const skills = [...h0.pi.skills.values()];
|
|
18
18
|
const providers = await fetch('/api/providers').then(r => r.json()).catch(() => []);
|
|
19
19
|
const configured = providers.filter(p => p.configured);
|
|
20
|
+
const v1Models = await fetch('/v1/models').then(r => r.json()).then(j => j.data || []).catch(() => []);
|
|
21
|
+
const cached = await fetch('/api/models/cached').then(r => r.json()).catch(() => ({}));
|
|
20
22
|
const cs = window.__fd_chatState = window.__fd_chatState || { cwd: '', skill: '', provider: '', model: '', messages: [], busy: false, sessionId: null };
|
|
23
|
+
try { const last = localStorage.getItem('fd-chat-model'); if (last && !cs.model) cs.model = last } catch {}
|
|
21
24
|
if (!cs.cwd) cs.cwd = (getRecentPaths()[0] || '');
|
|
22
25
|
const root = document.getElementById('app');
|
|
23
26
|
const getMsgs = () => root.querySelector('#fd-chat-msgs');
|
|
@@ -91,8 +94,11 @@ export async function chat(h0) {
|
|
|
91
94
|
)
|
|
92
95
|
),
|
|
93
96
|
h('div', { class: 'fd-col' },
|
|
94
|
-
h('label', { class: 'fd-label' }, 'model'),
|
|
95
|
-
h('
|
|
97
|
+
h('label', { class: 'fd-label' }, 'model · ' + v1Models.length + ' available'),
|
|
98
|
+
h('select', { name: 'model', onchange: ev => { cs.model = ev.target.value; try { localStorage.setItem('fd-chat-model', cs.model) } catch {} } },
|
|
99
|
+
h('option', { value: '' }, '— auto —'),
|
|
100
|
+
...v1Models.map(m => h('option', { value: m.id, selected: cs.model === m.id ? 'true' : null }, m.id))
|
|
101
|
+
)
|
|
96
102
|
)
|
|
97
103
|
),
|
|
98
104
|
h('div', { class: 'fd-chat-send-row' },
|
|
@@ -65,13 +65,64 @@ function editor(field, cur, defVal, h0, skins) {
|
|
|
65
65
|
h('div', { class: 'fd-cfg-control' }, control, meta));
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
function prefRow(h0, idx, pref, providers, cached, total) {
|
|
69
|
+
const provider = pref.provider || '';
|
|
70
|
+
const model = pref.model || '';
|
|
71
|
+
const models = (cached[provider] && cached[provider].models) || [];
|
|
72
|
+
const onProv = ev => { const list = getPrefList(); list[idx] = { ...list[idx], provider: ev.target.value, model: '' }; commit(h0, 'agent.model_preference', list); };
|
|
73
|
+
const onModel = ev => { const list = getPrefList(); list[idx] = { ...list[idx], model: ev.target.value }; commit(h0, 'agent.model_preference', list); };
|
|
74
|
+
const onMove = dir => { const list = getPrefList(); const j = idx + dir; if (j < 0 || j >= list.length) return; const t = list[idx]; list[idx] = list[j]; list[j] = t; commit(h0, 'agent.model_preference', list); };
|
|
75
|
+
const onDel = () => { const list = getPrefList(); list.splice(idx, 1); commit(h0, 'agent.model_preference', list); };
|
|
76
|
+
return h('div', { class: 'fd-cfg-row', key: 'pref-' + idx, 'data-idx': idx },
|
|
77
|
+
h('label', { class: 'fd-cfg-label' }, '#' + (idx+1) + ' / ' + total),
|
|
78
|
+
h('div', { class: 'fd-cfg-control' },
|
|
79
|
+
h('select', { onchange: onProv },
|
|
80
|
+
h('option', { value: '' }, '(select provider)'),
|
|
81
|
+
...providers.map(p => h('option', { value: p, selected: p === provider ? 'true' : null }, p))),
|
|
82
|
+
models.length > 0
|
|
83
|
+
? h('select', { onchange: onModel },
|
|
84
|
+
h('option', { value: '' }, '(any/default)'),
|
|
85
|
+
...models.map(m => h('option', { value: m, selected: m === model ? 'true' : null }, m)))
|
|
86
|
+
: h('input', { type: 'text', placeholder: 'model (run discover for dropdown)', value: model, onchange: onModel }),
|
|
87
|
+
h('button', { class: 'btn', onclick: ev => { ev.preventDefault(); onMove(-1); } }, '↑'),
|
|
88
|
+
h('button', { class: 'btn', onclick: ev => { ev.preventDefault(); onMove(1); } }, '↓'),
|
|
89
|
+
h('button', { class: 'btn', onclick: ev => { ev.preventDefault(); onDel(); } }, '✕')));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function getPrefList() {
|
|
93
|
+
return (window.__fd_cfg_pref || []).slice();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function modelPrefPanel(h0, cfg, providers, cached) {
|
|
97
|
+
const list = Array.isArray(cfg?.agent?.model_preference) ? cfg.agent.model_preference : [];
|
|
98
|
+
window.__fd_cfg_pref = list.slice();
|
|
99
|
+
const rows = list.map((p, i) => prefRow(h0, i, p, providers, cached, list.length));
|
|
100
|
+
const addBtn = h('button', { class: 'btn-primary', onclick: ev => { ev.preventDefault(); const next = getPrefList(); next.push({ provider: '', model: '' }); commit(h0, 'agent.model_preference', next); } }, '+ add row');
|
|
101
|
+
const discoverBtn = h('button', { class: 'btn', onclick: async ev => {
|
|
102
|
+
ev.preventDefault();
|
|
103
|
+
(window.__fd_cfg_status = window.__fd_cfg_status || {})['agent.discovered_models'] = 'discovering…'; rerender();
|
|
104
|
+
try { await fetch('/api/models/discover', { method: 'POST', headers: { 'content-type': 'application/json' }, body: '{}' }); window.__fd_cfg_status['agent.discovered_models'] = 'discovered ✓'; }
|
|
105
|
+
catch (e) { window.__fd_cfg_status['agent.discovered_models'] = 'err: ' + (e.message || e); }
|
|
106
|
+
rerender();
|
|
107
|
+
} }, 'discover models');
|
|
108
|
+
const status = (window.__fd_cfg_status || {})['agent.discovered_models'];
|
|
109
|
+
return Panel({ title: 'model preference (ordered fallback chain)', count: list.length,
|
|
110
|
+
right: h('span', {}, discoverBtn, ' ', addBtn, status ? Chip({ tone: status.startsWith('err') ? 'miss' : status === 'discovered ✓' ? 'ok' : 'warn', children: status }) : null),
|
|
111
|
+
children: list.length === 0
|
|
112
|
+
? h('div', { class: 'fd-muted' }, 'no preferences — first available provider key will be used. add a row to override.')
|
|
113
|
+
: h('div', { class: 'fd-cfg-prefs' }, ...rows) });
|
|
114
|
+
}
|
|
115
|
+
|
|
68
116
|
export async function config(h0) {
|
|
69
117
|
const cfg = typeof h0.pi.config?.load === 'function' ? await h0.pi.config.load() : {};
|
|
70
118
|
const defaults = await fetch('/api/config/defaults').then(r => r.json()).catch(() => ({}));
|
|
71
119
|
const skins = await fetch('/api/skins').then(r => r.json()).catch(() => ['default']);
|
|
120
|
+
const provInfo = await fetch('/api/models/providers').then(r => r.json()).catch(() => ({ providers: [] }));
|
|
121
|
+
const cached = await fetch('/api/models/cached').then(r => r.json()).catch(() => ({}));
|
|
72
122
|
const commands = typeof h0.pi.cli?.values === 'function' ? [...h0.pi.cli.values()] : [];
|
|
73
123
|
const settingsPanel = Panel({ title: 'settings', count: KNOWN_FIELDS.length,
|
|
74
|
-
children: KNOWN_FIELDS.map(f => editor(f, getDot(cfg, f.key), getDot(defaults, f.key), h0, skins)) });
|
|
124
|
+
children: KNOWN_FIELDS.filter(f => f.key !== 'agent.model_preference').map(f => editor(f, getDot(cfg, f.key), getDot(defaults, f.key), h0, skins)) });
|
|
125
|
+
const prefPanel = modelPrefPanel(h0, cfg, provInfo.providers || [], cached || {});
|
|
75
126
|
const rawForm = Panel({ title: 'set arbitrary key (power-user)', children: Form({ fields: [
|
|
76
127
|
{ name: 'key', placeholder: 'dotted.key', required: true },
|
|
77
128
|
{ name: 'value', placeholder: 'value (json or string)', required: true }
|
|
@@ -89,8 +140,9 @@ export async function config(h0) {
|
|
|
89
140
|
Table({ headers: ['name','description'], rows: commands.map(c => [c.name, c.description||'']) }));
|
|
90
141
|
return [
|
|
91
142
|
Hero({ title: 'config', body: 'inline editors for known keys. raw setter is the fallback.', accent: 'v'+(cfg._config_version||0) }),
|
|
92
|
-
Kpi({ items: [[KNOWN_FIELDS.length,'editable'],[commands.length,'commands'],[cfg._config_version||0,'version']
|
|
143
|
+
Kpi({ items: [[KNOWN_FIELDS.length,'editable'],[(cfg?.agent?.model_preference||[]).length,'pref-rows'],[commands.length,'commands'],[cfg._config_version||0,'version']] }),
|
|
93
144
|
settingsPanel,
|
|
145
|
+
prefPanel,
|
|
94
146
|
rawForm,
|
|
95
147
|
allRaw,
|
|
96
148
|
cmds,
|