lemma-agent 1.1.1 → 1.1.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/dist/admin.js +28 -0
- package/dist/config.js +44 -0
- package/dist/main.js +44 -2
- package/dist/onboarding.js +428 -0
- package/dist/proxy.js +148 -66
- package/dist/terminal.js +51 -30
- package/package.json +1 -1
- package/web/js/editors.js +96 -0
- package/web/js/views.js +11 -2
package/web/js/editors.js
CHANGED
|
@@ -297,6 +297,102 @@ export function openAutonomyEditor(autonomy) {
|
|
|
297
297
|
});
|
|
298
298
|
}
|
|
299
299
|
|
|
300
|
+
export function openOnboardingWizard(state) {
|
|
301
|
+
const presets = state?.onboardingPresets ?? [];
|
|
302
|
+
const discovered = state?.proxyStatus?.discoveredAccounts ?? [];
|
|
303
|
+
const curOrch = state?.orchestrator ?? {};
|
|
304
|
+
const curProxy = state?.proxyStatus ?? {};
|
|
305
|
+
const budgetUsd = state?.budget?.perRunUsd ?? 3;
|
|
306
|
+
const accountsLine = discovered.length
|
|
307
|
+
? discovered.map((a) => `${a.detected ? "●" : "○"} ${esc(a.provider)}:${a.detected ? esc(a.authMode) : "无"}`).join(" · ")
|
|
308
|
+
: "未扫描本机账号";
|
|
309
|
+
|
|
310
|
+
openModal({
|
|
311
|
+
title: "首次配置引导 · 接入模型与本地网关",
|
|
312
|
+
submitText: "保存并启用",
|
|
313
|
+
bodyHtml: `
|
|
314
|
+
<p class="edit-note">本机已检测:${accountsLine}</p>
|
|
315
|
+
<div class="field-grid">
|
|
316
|
+
<label class="field"><span>接入模式</span><select name="mode">
|
|
317
|
+
<option value="byok"${curProxy.mode !== "relay" ? " selected" : ""}>自带 API Key / 多 Key 池 (BYOK)</option>
|
|
318
|
+
<option value="relay"${curProxy.mode === "relay" ? " selected" : ""}>云端托管中转 (Hosted Relay)</option>
|
|
319
|
+
<option value="native">保留本机已有登录态 / 环境变量</option>
|
|
320
|
+
</select></label>
|
|
321
|
+
<label class="field" data-sec="byok"><span>服务商预设</span><select name="preset">
|
|
322
|
+
${presets.map((p) => `<option value="${esc(p.id)}">${esc(p.label)}</option>`).join("")}
|
|
323
|
+
</select></label>
|
|
324
|
+
</div>
|
|
325
|
+
<div class="field-grid" data-sec="endpoint">
|
|
326
|
+
<label class="field"><span>协议类型</span><select name="type">
|
|
327
|
+
<option value="openai-compatible"${curOrch.type === "openai-compatible" ? " selected" : ""}>openai-compatible</option>
|
|
328
|
+
<option value="anthropic-compatible"${curOrch.type !== "openai-compatible" ? " selected" : ""}>anthropic-compatible</option>
|
|
329
|
+
</select></label>
|
|
330
|
+
<label class="field"><span>默认模型 ID</span><input name="modelId" value="${esc(curOrch.modelId ?? "")}" placeholder="如 deepseek-chat / claude-sonnet-5-5" /></label>
|
|
331
|
+
</div>
|
|
332
|
+
<label class="field" data-sec="byok-url"><span>API Base URL</span><input name="baseUrl" type="url" value="${esc(curOrch.baseUrl ?? presets[0]?.baseUrl ?? "")}" placeholder="https://api.deepseek.com" /></label>
|
|
333
|
+
<label class="field" data-sec="relay-url" hidden><span>云端 Relay 地址</span><input name="relayUrl" type="url" placeholder="https://relay.example.com" /></label>
|
|
334
|
+
<label class="field" data-sec="secret"><span>API Key / 平台 Token(支持逗号或换行填多把 Key,隐藏保存至 credentials.json)</span><textarea name="secret" rows="2" placeholder="sk-...(多把 Key 自动组成防 429 粘性池;留空保留现存凭据)" autocomplete="new-password"></textarea></label>
|
|
335
|
+
<div class="field-grid" data-sec="gateway">
|
|
336
|
+
<label class="field"><span>多渠道/多 Key 路由策略</span><select name="strategy">
|
|
337
|
+
<option value="rotate" selected>rotate(缓存粘性轮转)</option>
|
|
338
|
+
<option value="order">order(主备顺序容灾)</option>
|
|
339
|
+
</select></label>
|
|
340
|
+
<label class="field"><span>出站脱敏策略</span><select name="redactAction">
|
|
341
|
+
<option value="mask" selected>mask(确定性占位符脱敏)</option>
|
|
342
|
+
<option value="warn">warn(仅记录审计告警)</option>
|
|
343
|
+
<option value="block">block(命中敏感密钥拦截)</option>
|
|
344
|
+
</select></label>
|
|
345
|
+
<label class="field"><span>单轮预算上限(美元,留空不限)</span><input name="perRunUsd" type="number" min="0" step="0.1" value="${budgetUsd == null ? "" : esc(budgetUsd)}" /></label>
|
|
346
|
+
</div>
|
|
347
|
+
<label class="check-chip" data-sec="bridge"><input type="checkbox" name="enableBridge" /> 启用 Anthropic↔OpenAI 轻量桥接(用该 API 同步驱动 Claude CLI)</label>
|
|
348
|
+
`,
|
|
349
|
+
onMount(body) {
|
|
350
|
+
const modeEl = body.querySelector('[name="mode"]');
|
|
351
|
+
const presetEl = body.querySelector('[name="preset"]');
|
|
352
|
+
const typeEl = body.querySelector('[name="type"]');
|
|
353
|
+
const modelEl = body.querySelector('[name="modelId"]');
|
|
354
|
+
const baseEl = body.querySelector('[name="baseUrl"]');
|
|
355
|
+
const syncPreset = () => {
|
|
356
|
+
const p = presets.find((x) => x.id === presetEl?.value);
|
|
357
|
+
if (!p || p.id === "custom") return;
|
|
358
|
+
if (typeEl) typeEl.value = p.type;
|
|
359
|
+
if (baseEl) baseEl.value = p.baseUrl;
|
|
360
|
+
if (modelEl) modelEl.value = p.defaultModel;
|
|
361
|
+
};
|
|
362
|
+
const syncMode = () => {
|
|
363
|
+
const m = modeEl?.value;
|
|
364
|
+
body.querySelectorAll('[data-sec="byok"],[data-sec="byok-url"]').forEach((n) => (n.hidden = m !== "byok"));
|
|
365
|
+
body.querySelectorAll('[data-sec="relay-url"]').forEach((n) => (n.hidden = m !== "relay"));
|
|
366
|
+
body.querySelectorAll('[data-sec="endpoint"],[data-sec="secret"]').forEach((n) => (n.hidden = m === "native"));
|
|
367
|
+
body.querySelectorAll('[data-sec="bridge"]').forEach((n) => (n.hidden = m !== "byok"));
|
|
368
|
+
};
|
|
369
|
+
presetEl?.addEventListener("change", syncPreset);
|
|
370
|
+
modeEl?.addEventListener("change", syncMode);
|
|
371
|
+
if (presets[0] && !curOrch.baseUrl) syncPreset();
|
|
372
|
+
syncMode();
|
|
373
|
+
},
|
|
374
|
+
async onSubmit(body) {
|
|
375
|
+
const val = (n) => body.querySelector(`[name="${n}"]`)?.value ?? "";
|
|
376
|
+
const mode = val("mode");
|
|
377
|
+
const res = await post("/api/onboarding", {
|
|
378
|
+
mode,
|
|
379
|
+
preset: val("preset"),
|
|
380
|
+
type: val("type"),
|
|
381
|
+
baseUrl: val("baseUrl").trim(),
|
|
382
|
+
modelId: val("modelId").trim(),
|
|
383
|
+
relayUrl: val("relayUrl").trim(),
|
|
384
|
+
secret: val("secret"),
|
|
385
|
+
strategy: val("strategy"),
|
|
386
|
+
redactAction: val("redactAction"),
|
|
387
|
+
enableBridge: Boolean(body.querySelector('[name="enableBridge"]')?.checked),
|
|
388
|
+
enableProxy: true,
|
|
389
|
+
perRunUsd: val("perRunUsd").trim() === "" ? null : Number(val("perRunUsd")),
|
|
390
|
+
});
|
|
391
|
+
return res?.summary || "初始化配置已保存";
|
|
392
|
+
},
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
|
|
300
396
|
export function openOrchestratorEditor(orch) {
|
|
301
397
|
openModal({
|
|
302
398
|
title: "配置总控模型与接口",
|
package/web/js/views.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// 后台各页面。每个页面:mount(root, params) 渲染,update(kind, payload) 响应数据变化,unmount() 清理。
|
|
2
2
|
import { openDispatch } from "./drawer.js";
|
|
3
3
|
import { bindDagPanelEvents, classifyTopology, renderReviewLoopPanel, renderScopeMatrix, renderTaskDag } from "./dag.js";
|
|
4
|
-
import { openAutonomyEditor, openCreateIntegrationDialog, openLimitsEditor, openMemberEditor, openOrchestratorEditor, openRecoverDialog, openRepairIntegrationDialog, openResolveOperationDialog, runControlAction } from "./editors.js";
|
|
4
|
+
import { openAutonomyEditor, openCreateIntegrationDialog, openLimitsEditor, openMemberEditor, openOnboardingWizard, openOrchestratorEditor, openRecoverDialog, openRepairIntegrationDialog, openResolveOperationDialog, runControlAction } from "./editors.js";
|
|
5
5
|
import { createChangesView } from "./gitlens.js";
|
|
6
6
|
import { METRICS, MODES, RANGES, Sankey } from "./sankey.js";
|
|
7
7
|
import { buildRuns, callInfo, dispatchRows, isDispatch, loadEarlier, pendingChanges, runningJobs, store } from "./store.js";
|
|
@@ -193,7 +193,13 @@ function overview() {
|
|
|
193
193
|
const strip = el("div", "ov-strip");
|
|
194
194
|
strip.dataset.n = "strip";
|
|
195
195
|
strip.hidden = true;
|
|
196
|
+
const onboardBanner = el("section", "card");
|
|
197
|
+
onboardBanner.dataset.n = "onboard";
|
|
198
|
+
onboardBanner.hidden = true;
|
|
199
|
+
onboardBanner.innerHTML = `<header class="card-head"><div class="card-heading"><h2 class="card-title">首次配置引导 · 接入模型与本地代理网关</h2><div class="card-sub">尚未配置总控模型密钥,可一键导入 DeepSeek/Anthropic/OpenAI 多 Key 轮转池、Cloud Relay 或本机已有方案。</div></div><button type="button" class="primary-btn" data-open-onboard="1">立即向导配置</button></header>`;
|
|
200
|
+
onboardBanner.querySelector("[data-open-onboard]").addEventListener("click", () => openOnboardingWizard(store.state));
|
|
196
201
|
root.prepend(strip);
|
|
202
|
+
root.prepend(onboardBanner);
|
|
197
203
|
root.append(routes);
|
|
198
204
|
const act = el("section", "card act-card");
|
|
199
205
|
act.innerHTML = `<header class="card-head"><div class="card-heading"><h2 class="card-title">派工活动</h2><div class="card-sub" data-n="actSum"></div></div><div class="act-legend" data-n="actLegend"></div></header><div class="card-body" data-n="act"></div>`;
|
|
@@ -219,6 +225,8 @@ function overview() {
|
|
|
219
225
|
},
|
|
220
226
|
update(kind) {
|
|
221
227
|
const q = (n) => root.querySelector(`[data-n="${n}"]`);
|
|
228
|
+
const onboard = q("onboard");
|
|
229
|
+
if (onboard) onboard.hidden = !(store.state?.needsOnboarding && store.state?.canEditSettings);
|
|
222
230
|
const strip = q("strip");
|
|
223
231
|
const wasHidden = strip?.hidden;
|
|
224
232
|
this.strip(strip);
|
|
@@ -1458,6 +1466,7 @@ function config() {
|
|
|
1458
1466
|
const target = e.target instanceof Element ? e.target : null;
|
|
1459
1467
|
if (!target || !store.state) return;
|
|
1460
1468
|
if (target.closest("[data-edit-orch]")) openOrchestratorEditor(store.state.orchestrator);
|
|
1469
|
+
else if (target.closest("[data-open-onboard]")) openOnboardingWizard(store.state);
|
|
1461
1470
|
else if (target.closest("[data-edit-limits]")) openLimitsEditor(store.state);
|
|
1462
1471
|
else if (target.closest("[data-edit-autonomy]")) openAutonomyEditor(store.state.autonomy);
|
|
1463
1472
|
});
|
|
@@ -1484,7 +1493,7 @@ function config() {
|
|
|
1484
1493
|
["历史条目", num(s.entries)],
|
|
1485
1494
|
["进程", `pid ${s.pid} · 已运行 ${duration(Date.now() - s.startedAt)}`],
|
|
1486
1495
|
])}</div></section>
|
|
1487
|
-
<section class="card"><header class="card-head"><h2 class="card-title">总调度</h2>${canEdit ? `<button type="button" class="ghost-btn tiny" data-edit-orch="1">编辑总控</button>` : ""}</header>
|
|
1496
|
+
<section class="card"><header class="card-head"><h2 class="card-title">总调度</h2>${canEdit ? `<div style="display:flex;gap:8px"><button type="button" class="ghost-btn tiny" data-open-onboard="1">向导 / 网关一键配置</button><button type="button" class="ghost-btn tiny" data-edit-orch="1">编辑总控</button></div>` : ""}</header>
|
|
1488
1497
|
<div class="card-body">${dl([
|
|
1489
1498
|
["协议", code(o.type)],
|
|
1490
1499
|
["模型", code(o.modelId)],
|