skillmkt 0.2.0 → 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.
@@ -58,6 +58,9 @@ export async function run(ctx) {
58
58
  { label: '手动输入端点', v: 'manual' },
59
59
  { label: '跳过(确定性功能照常用)', v: 'skip' },
60
60
  ];
61
+ for (const f of found.filter((x) => x.needs_key)) {
62
+ info(`发现 ${f.name}:${f.port}(需要密钥,模型列表读不出)——选"手动输入端点"后填 ${f.base_url}`);
63
+ }
61
64
  const sel = await choose('选择模型端点:', opts);
62
65
  if (sel.v === 'manual') {
63
66
  // 手动输入交给 config set 提示
package/client/lib/llm.js CHANGED
@@ -55,31 +55,46 @@ export async function chat(llm, { system = '', user, maxTokens = 64, temperature
55
55
  } finally { clearTimeout(t); }
56
56
  }
57
57
 
58
- export const LLM_PROBES = [
59
- { port: 8001, name: 'OMLX' },
60
- { port: 11434, name: 'Ollama', probe: '/api/version' },
61
- { port: 1234, name: 'LM Studio' },
62
- { port: 8000, name: 'vLLM' },
63
- { port: 8080, name: 'mlx-lm/llama.cpp' },
64
- { port: 1337, name: 'Jan' },
65
- { port: 5000, name: 'text-gen-webui' },
66
- ];
58
+ export const LLM_PROBES = [8001, 11434, 1234, 8000, 8080, 1337, 5000];
67
59
 
68
- // 仅 init/config 使用——并发扫端口,能回 /v1/models 即可用端点
69
- export async function probeEndpoints(timeoutMs = 300) {
70
- const results = await Promise.allSettled(LLM_PROBES.map(async ({ port, name, probe }) => {
71
- const base = `http://localhost:${port}/v1`;
60
+ // 识别服务实现——有特征端点才冠名,认不出如实标"OpenAI 兼容服务"(oMLX 跑在 1234 时不该叫 LM Studio)
61
+ async function identifyImpl(port, timeoutMs) {
62
+ const get = async (p) => {
72
63
  const ctrl = new AbortController();
73
64
  const t = setTimeout(() => ctrl.abort(), timeoutMs);
74
- try {
75
- const res = await fetch(`${base}/models`, { signal: ctrl.signal });
76
- if (!res.ok) return null;
77
- const data = await res.json();
78
- return { name, port, base_url: base, models: (data.data || []).map((m) => m.id) };
79
- } catch {
80
- if (probe) { /* ollama 等特征端点降级可日后补 */ }
81
- return null;
82
- } finally { clearTimeout(t); }
65
+ try { const r = await fetch(`http://localhost:${port}${p}`, { signal: ctrl.signal }); return r.ok ? await r.json() : null; }
66
+ catch { return null; } finally { clearTimeout(t); }
67
+ };
68
+ if ((await get('/api/version'))?.version) return 'Ollama'; // Ollama 原生 API
69
+ if (await get('/api/v0/models')) return 'LM Studio API'; // 说 LM Studio 协议——也可能是 oMLX 等兼容实现
70
+ return 'OpenAI 兼容服务';
71
+ }
72
+
73
+ // 仅 init/config 使用——并发扫端口。/v1/models 通了即收录;
74
+ // 401/403 时用已知环境 key 重试,仍不通则标 needs_key 保留(别静默漏掉 oMLX 这类要 key 的本地服务)
75
+ export async function probeEndpoints(timeoutMs = 400) {
76
+ const envKeys = ['SKILLMKT_LLM_API_KEY', 'OMLX_API_KEY'].map((v) => process.env[v]).filter(Boolean);
77
+ const results = await Promise.allSettled(LLM_PROBES.map(async (port) => {
78
+ const base = `http://localhost:${port}/v1`;
79
+ const tryModels = async (key) => {
80
+ const ctrl = new AbortController();
81
+ const t = setTimeout(() => ctrl.abort(), timeoutMs);
82
+ try {
83
+ return await fetch(`${base}/models`, {
84
+ signal: ctrl.signal,
85
+ headers: key ? { authorization: `Bearer ${key}` } : {},
86
+ });
87
+ } catch { return null; } finally { clearTimeout(t); }
88
+ };
89
+ let res = await tryModels(null);
90
+ if (!res) return null;
91
+ if (res.status === 401 || res.status === 403) {
92
+ for (const k of envKeys) { res = await tryModels(k); if (res?.ok) break; }
93
+ }
94
+ const name = await identifyImpl(port, timeoutMs);
95
+ if (!res.ok) return { name, port, base_url: base, models: [], needs_key: true };
96
+ const data = await res.json();
97
+ return { name, port, base_url: base, models: (data.data || []).map((m) => m.id) };
83
98
  }));
84
99
  return results.map((r) => r.value).filter(Boolean);
85
100
  }
@@ -160,7 +160,10 @@ async function render() {
160
160
  app.querySelector('#probe').onclick = async () => {
161
161
  app.querySelector('#probe-out').textContent = '扫描中…';
162
162
  const eps = await api('/probe');
163
- app.querySelector('#eps').innerHTML = eps.flatMap((e) => e.models.slice(0, 6).map((m) => `<div class="ep" data-b="${esc(e.base_url)}" data-m="${esc(m)}">${esc(e.name)}:${e.port} — <code>${esc(m)}</code></div>`)).join('') || '<p class="mut" style="margin-top:8px">没扫到——请确认模型服务已启动(会检查 8001 / 11434 / 1234 / 8000 / 8080 / 1337 / 5000 端口)</p>';
163
+ app.querySelector('#eps').innerHTML = eps.flatMap((e) => e.needs_key
164
+ ? [`<div class="ep" data-b="${esc(e.base_url)}" data-m="">${esc(e.name)}:${e.port} — <span class="mut">需要密钥(先点这行填地址,再填密钥、测试连接)</span></div>`]
165
+ : e.models.slice(0, 6).map((m) => `<div class="ep" data-b="${esc(e.base_url)}" data-m="${esc(m)}">${esc(e.name)}:${e.port} — <code>${esc(m)}</code></div>`)).join('')
166
+ || '<p class="mut" style="margin-top:8px">没扫到——请确认模型服务已启动(会检查 8001 / 11434 / 1234 / 8000 / 8080 / 1337 / 5000 端口)</p>';
164
167
  app.querySelector('#probe-out').textContent = `发现 ${eps.length} 个服务,点击条目自动填入`;
165
168
  app.querySelectorAll('#eps [data-b]').forEach((d) => d.onclick = () => {
166
169
  app.querySelectorAll('#eps .ep').forEach((x) => x.classList.remove('sel'));
@@ -23,7 +23,7 @@
23
23
  * { box-sizing: border-box; }
24
24
  body { margin: 0; font: var(--font-body); background: var(--color-paper); color: var(--color-ink); }
25
25
 
26
- header { display: flex; align-items: baseline; gap: 30px; padding: 22px 32px 0; border-bottom: 1px solid var(--color-line); flex-wrap: wrap; }
26
+ header { display: flex; align-items: baseline; gap: 30px; padding: 22px 32px 0; border-bottom: 1px solid var(--color-line); flex-wrap: wrap; max-width: 1060px; margin-inline: auto; }
27
27
  header .brand { display: flex; align-items: baseline; gap: 12px; }
28
28
  header h1 { font: 600 24px/1 var(--font-display); margin: 0; letter-spacing: -0.01em; text-wrap: balance; }
29
29
  header .tag { font-size: 14px; color: var(--color-ink-mut); }
@@ -36,7 +36,7 @@ nav button:hover { color: var(--color-ink); }
36
36
  #live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-ok); }
37
37
  #live.off .dot { background: var(--color-bad); }
38
38
 
39
- main { padding: 30px 32px 80px; max-width: 1060px; }
39
+ main { padding: 30px 32px 80px; max-width: 1060px; margin-inline: auto; }
40
40
  h2 { font: 600 21px/1.3 var(--font-display); margin: 38px 0 4px; text-wrap: balance; }
41
41
  h2:first-child { margin-top: 0; }
42
42
  .desc { margin: 0 0 18px; color: var(--color-ink-mut); font-size: 15.5px; max-width: 64ch; }
@@ -89,7 +89,7 @@ td, th { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--col
89
89
  th { font-size: 14px; color: var(--color-ink-mut); font-weight: 500; }
90
90
  .empty { padding: 26px 20px; color: var(--color-ink-mut); }
91
91
  .empty code { font-size: 14.5px; }
92
- footer { padding: 22px 32px; border-top: 1px solid var(--color-line); font-size: 14px; color: var(--color-ink-mut); }
92
+ footer { padding: 22px 32px; border-top: 1px solid var(--color-line); font-size: 14px; color: var(--color-ink-mut); max-width: 1060px; margin-inline: auto; }
93
93
  </style></head><body>
94
94
  <header>
95
95
  <div class="brand"><h1>awesome-skill-market</h1><span class="tag">skillmkt 本地管理面板</span></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skillmkt",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "type": "module",
5
5
  "description": "Local-first agent skill manager: install, audit, merge, distribute.",
6
6
  "license": "MIT",