skillmkt 0.3.10 → 0.3.12

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.
@@ -148,8 +148,8 @@ async function render() {
148
148
  <p class="mut">点「扫描」自动发现本机正在运行的模型服务(LM Studio、Ollama、oMLX 等)。${cfg.llm?.model ? `当前使用:<code>${esc(cfg.llm.model)}</code>` : ''}</p>
149
149
  <div class="row"><button id="probe">扫描本机模型服务</button><span id="probe-out" class="mut"></span></div>
150
150
  <div id="eps"></div>
151
- <div class="frow"><span class="lab">服务地址</span><input type="text" id="murl" placeholder="http://localhost:1234/v1" value="${esc(cfg.llm?.base_url || '')}"></div>
152
- <div class="frow" id="key-row" style="display:none"><span class="lab">访问密钥</span><input type="text" id="mkey" value="${esc(cfg.llm?.api_key || '')}"><span class="fhint" id="key-hint"></span>
151
+ <div class="frow"><span class="lab">服务地址</span><input type="text" id="murl" autocomplete="off" placeholder="http://localhost:1234/v1" value="${esc(cfg.llm?.base_url || '')}"></div>
152
+ <div class="frow" id="key-row" style="display:none"><span class="lab">访问密钥</span><input type="text" id="mkey" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" data-1p-ignore data-lpignore="true" data-form-type="other" value="${esc(cfg.llm?.api_key?.startsWith('enc:') ? '已加密保存' : (cfg.llm?.api_key || ''))}"><span class="fhint" id="key-hint"></span>
153
153
  <div class="fsub">填了密钥会用本机机器码加密后存入 config.yml——文件拷到别的机器解不开,换机需重填。</div></div>
154
154
  <div class="frow" id="model-box"><span class="lab">模型名称</span>
155
155
  <div class="combo"><input type="text" id="mmodel" autocomplete="off" placeholder="可输入关键字搜索,扫描后自动列出发现的模型" value="${esc(cfg.llm?.model || '')}">
@@ -206,7 +206,7 @@ async function render() {
206
206
  d.classList.add('sel');
207
207
  app.querySelector('#murl').value = d.dataset.b;
208
208
  const ep = epsList.find((e) => e.base_url === d.dataset.b);
209
- if (ep?.needs_key && app.querySelector('#mkey').value.trim()) verifyKey();
209
+ if (ep?.needs_key && realKey()) verifyKey();
210
210
  else markKeyNeed(ep?.needs_key);
211
211
  refreshOpts();
212
212
  });
@@ -232,7 +232,7 @@ async function render() {
232
232
  // 拿密钥真发 /models——通过才收录模型并放出模型框;失败保持隐藏
233
233
  const verifyKey = async () => {
234
234
  const cur = app.querySelector('#murl').value.trim().replace(/\/+$/, '');
235
- const key = app.querySelector('#mkey').value.trim();
235
+ const key = realKey();
236
236
  if (!key) return;
237
237
  const out = app.querySelector('#smoke-out');
238
238
  out.textContent = '验证密钥…';
@@ -258,6 +258,12 @@ async function render() {
258
258
  });
259
259
  app.querySelector('#mmodel').addEventListener('input', () => { renderDrop(); app.querySelector('#model-drop').style.display = 'block'; });
260
260
  app.querySelector('#mmodel').addEventListener('blur', () => setTimeout(() => { app.querySelector('#model-drop').style.display = 'none'; }, 120));
261
+ // 已存的 enc: 密钥显示为「已加密保存」占位态:点击清空可输新密钥,留空失焦还原(不误删)
262
+ const ENC_DISP = '已加密保存';
263
+ const mk = app.querySelector('#mkey');
264
+ const realKey = () => { const v = mk.value.trim(); return v === ENC_DISP ? (cfg.llm?.api_key || '') : v; }; // 占位态→回传原始 enc: 值(服务端可解)
265
+ mk.addEventListener('focus', () => { if (mk.value === ENC_DISP) mk.value = ''; });
266
+ mk.addEventListener('blur', () => { if (!mk.value.trim() && cfg.llm?.api_key?.startsWith('enc:')) mk.value = ENC_DISP; });
261
267
  app.querySelector('#mkey').addEventListener('input', () => {
262
268
  keyOk = false; keyFailed = false; // 密钥改动→回到未验证态,模型框收起
263
269
  const cur = app.querySelector('#murl').value.trim().replace(/\/+$/, '');
@@ -266,7 +272,7 @@ async function render() {
266
272
  app.querySelector('#murl').addEventListener('change', async () => {
267
273
  const cur = app.querySelector('#murl').value.trim().replace(/\/+$/, '');
268
274
  const ep = epsList.find((e) => e.base_url === cur);
269
- const key = app.querySelector('#mkey').value.trim();
275
+ const key = realKey();
270
276
  if (ep) {
271
277
  if (ep.needs_key && key) return verifyKey();
272
278
  return markKeyNeed(ep.needs_key);
@@ -281,7 +287,7 @@ async function render() {
281
287
  app.querySelector('#mkey').addEventListener('change', async () => {
282
288
  const cur = app.querySelector('#murl').value.trim().replace(/\/+$/, '');
283
289
  const ep = epsList.find((e) => e.base_url === cur);
284
- const key = app.querySelector('#mkey').value.trim();
290
+ const key = realKey();
285
291
  if (!key || !(ep?.needs_key || (!ep && /^https?:\/\//.test(cur)))) return;
286
292
  await verifyKey();
287
293
  });
@@ -293,7 +299,7 @@ async function render() {
293
299
  app.querySelector('#smoke').onclick = async () => {
294
300
  const out = app.querySelector('#smoke-out');
295
301
  out.textContent = '测试中…';
296
- const r = await api('/llm-smoke', { method: 'POST', body: JSON.stringify({ base_url: app.querySelector('#murl').value, model: app.querySelector('#mmodel').value, api_key: app.querySelector('#mkey').value }) });
302
+ const r = await api('/llm-smoke', { method: 'POST', body: JSON.stringify({ base_url: app.querySelector('#murl').value, model: app.querySelector('#mmodel').value, api_key: realKey() }) });
297
303
  out.innerHTML = r.ok
298
304
  ? `连接成功<br>发送:${esc(r.sent)}<br>回复:${esc(r.reply || '(空回复)')}`
299
305
  : `连接失败:${esc(r.error)}`;
@@ -302,7 +308,8 @@ async function render() {
302
308
  app.querySelector('#save').onclick = async () => {
303
309
  try {
304
310
  const targets = [...app.querySelectorAll('[data-h]:checked')].map((x) => x.dataset.h);
305
- const r = await api('/config', { method: 'POST', body: JSON.stringify({ llm: { base_url: app.querySelector('#murl').value || null, model: app.querySelector('#mmodel').value || null, api_key: app.querySelector('#mkey').value || undefined, concurrency: 2, timeout_ms: 60000 }, default_targets: targets }) });
311
+ const api_key = realKey() || undefined; // 占位态→回传原始 enc: 值,保持不变
312
+ const r = await api('/config', { method: 'POST', body: JSON.stringify({ llm: { base_url: app.querySelector('#murl').value || null, model: app.querySelector('#mmodel').value || null, api_key, concurrency: 2, timeout_ms: 60000 }, default_targets: targets }) });
306
313
  saveMsg = r.ok ? `已保存到 config.yml${r.key_enc ? ',密钥已加密' : ''}` : `保存失败:${r.error}`;
307
314
  } catch (e) { saveMsg = `保存失败:${e.message}`; }
308
315
  saveMsgAt = Date.now();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skillmkt",
3
- "version": "0.3.10",
3
+ "version": "0.3.12",
4
4
  "type": "module",
5
5
  "description": "Local-first agent skill manager: install, audit, merge, distribute.",
6
6
  "license": "MIT",