lemma-agent 1.1.3 → 1.1.4

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/main.js CHANGED
@@ -782,7 +782,7 @@ export async function startMain(overrides) {
782
782
  if (line === "/help") {
783
783
  log(MEMBER_HELP);
784
784
  log(TASK_HELP);
785
- log("/fast [成员ID|readonly] <任务> 单跳快路直连 · /projects 项目管理 · /project use|init|remove · /sessions 管理会话 · /tasks 分工 · /jobs 后台任务 · /model 选择当前总控模型 · /web 网页 · /exit 退出");
785
+ log("/fast [成员ID|readonly] <任务> 单跳快路直连 · /projects 项目管理 · /project use|init|remove · /clear 新空会话(旧会话保留在 /resume)· /resume 恢复会话 · /sessions 管理会话 · /tasks 分工 · /jobs 后台任务 · /model 选择当前总控模型 · /web 网页 · /exit 退出");
786
786
  log("/ready 就绪队列 · /workflow status|pause|resume 协作控制 · Enter 发送 · Ctrl+J 换行 · 滚轮/PgUp/PgDn 翻阅 · Ctrl+Home/End 到顶/最新 · Alt+End 最新 · Ctrl+K 会话 · Alt+C 关系树 · Ctrl+L 模型 · Ctrl+T 任务面板 · Ctrl+E 工具详情 · Alt+T 思考");
787
787
  log("/history 补载更早记录 · /thinking 展开/收起思考 · Ctrl+Shift+F 搜索已加载记录;思考仅展示服务实际返回的内容。");
788
788
  return true;
@@ -850,6 +850,19 @@ export async function startMain(overrides) {
850
850
  await sessionCommand(line);
851
851
  return true;
852
852
  }
853
+ if (line === "/clear" || line.startsWith("/clear ")) {
854
+ const rest = line.slice(6).trim();
855
+ await sessionCommand(rest ? `/session new ${rest}` : "/session new");
856
+ return true;
857
+ }
858
+ if (line === "/resume" || line.startsWith("/resume ")) {
859
+ const target = line.slice(7).trim();
860
+ if (target)
861
+ await sessionCommand(`/session use ${target}`);
862
+ else
863
+ await showTerminalConversations();
864
+ return true;
865
+ }
853
866
  if (line === "/conversations") {
854
867
  await showTerminalConversations();
855
868
  return true;
@@ -1314,10 +1327,10 @@ export async function startMain(overrides) {
1314
1327
  if (switchingSession && text !== "/exit" && text !== "/quit")
1315
1328
  return log(c.dim("正在切换,命令未执行,请稍后重试。"));
1316
1329
  // Task-owned 子对话由原派工管理,只允许查看或返回,不改变它的执行。
1317
- const readCommand = /^(?:\/help|\/history|\/thinking|\/ready|\/main|\/conversations|\/tree|\/taskgraph|\/conversation|\/id|\/projects?|\/sessions?|\/members|\/tasks|\/goal|\/jobs|\/changes|\/diff|\/usage|\/agents|\/web|\/learn|\/repair|\/exit|\/quit)(?:\s|$)/.test(text) && !/^\/jobs\s+cancel/.test(text);
1330
+ const readCommand = /^(?:\/help|\/history|\/thinking|\/ready|\/main|\/clear|\/resume|\/conversations|\/tree|\/taskgraph|\/conversation|\/id|\/projects?|\/sessions?|\/members|\/tasks|\/goal|\/jobs|\/changes|\/diff|\/usage|\/agents|\/web|\/learn|\/repair|\/exit|\/quit)(?:\s|$)/.test(text) && !/^\/jobs\s+cancel/.test(text);
1318
1331
  if (readingChild && !readCommand)
1319
1332
  return log(c.yellow("子对话为只读查看;请先 /main 返回总控再执行控制命令。"));
1320
- const bindsView = /^\/(?:sessions?|conversations|tree|main)(?:\s|$)/.test(text);
1333
+ const bindsView = /^\/(?:sessions?|conversations|tree|main|clear|resume)(?:\s|$)/.test(text);
1321
1334
  if (!bindsView)
1322
1335
  activeTerminalCommands++;
1323
1336
  try {
@@ -61,7 +61,14 @@ export function applyOrchestratorDraft(draft, current, input) {
61
61
  const secret = input.secret?.trim();
62
62
  const local = secret ? saveCredential(secret) : current.orchestrator.credential;
63
63
  return draft.apply((raw) => {
64
- raw.orchestrator = { ...current.orchestrator, ...api, modelId, credential: local, ...(local ? { apiKeyFromClaudeSettings: false, apiKeyEnv: [] } : {}) };
64
+ raw.orchestrator = {
65
+ ...current.orchestrator,
66
+ ...api,
67
+ modelId,
68
+ credential: local,
69
+ ...(api.type !== "anthropic-compatible" ? { apiKeyFromClaudeSettings: false } : {}),
70
+ ...(local ? { apiKeyFromClaudeSettings: false, apiKeyEnv: [] } : {}),
71
+ };
65
72
  });
66
73
  }
67
74
  export function applyAutonomyDraft(draft, current, input) {
package/dist/models.js CHANGED
@@ -17,7 +17,7 @@ export function resolveOrchestratorKey(config) {
17
17
  const local = readCredential(config.credential);
18
18
  if (local)
19
19
  return local;
20
- if (config.apiKeyFromClaudeSettings)
20
+ if (config.apiKeyFromClaudeSettings && config.type === "anthropic-compatible")
21
21
  return claudeSettingsEnv().token;
22
22
  return undefined;
23
23
  }
@@ -30,7 +30,7 @@ function keySource(config) {
30
30
  return `环境变量 ${name}`;
31
31
  if (readCredential(config.credential))
32
32
  return "本机凭据文件";
33
- if (config.apiKeyFromClaudeSettings) {
33
+ if (config.apiKeyFromClaudeSettings && config.type === "anthropic-compatible") {
34
34
  const claude = claudeSettingsEnv();
35
35
  if (claude.token)
36
36
  return "~/.claude/settings.json(与 Claude CLI 共用)";
@@ -42,7 +42,7 @@ function keySource(config) {
42
42
  export function orchestratorKeyWarning(config) {
43
43
  if (config.type === "builtin" || resolveOrchestratorKey(config))
44
44
  return undefined;
45
- if (config.apiKeyFromClaudeSettings) {
45
+ if (config.apiKeyFromClaudeSettings && config.type === "anthropic-compatible") {
46
46
  const claude = claudeSettingsEnv();
47
47
  if (claude.error)
48
48
  return `总控无法从 ~/.claude/settings.json 读取密钥(JSON 语法错误:${claude.error});请修复该文件或运行 /setup 配置总控凭据。`;
@@ -12,6 +12,7 @@ export const ONBOARDING_PRESETS = [
12
12
  baseUrl: "https://api.deepseek.com",
13
13
  defaultModel: "deepseek-chat",
14
14
  compactModel: "deepseek-chat",
15
+ apiKeyEnv: ["DEEPSEEK_API_KEY", "PI_ORCHESTRATOR_API_KEY"],
15
16
  price: { input: 0.27, output: 1.1, cacheRead: 0.07 },
16
17
  },
17
18
  {
@@ -22,6 +23,7 @@ export const ONBOARDING_PRESETS = [
22
23
  baseUrl: "https://api.anthropic.com",
23
24
  defaultModel: "claude-sonnet-5-5",
24
25
  compactModel: "claude-haiku-5-5",
26
+ apiKeyEnv: ["ANTHROPIC_API_KEY", "PI_ORCHESTRATOR_API_KEY"],
25
27
  price: { input: 3, output: 15, cacheRead: 0.3 },
26
28
  },
27
29
  {
@@ -32,6 +34,7 @@ export const ONBOARDING_PRESETS = [
32
34
  baseUrl: "https://api.openai.com/v1",
33
35
  defaultModel: "gpt-4.1",
34
36
  compactModel: "gpt-4.1-mini",
37
+ apiKeyEnv: ["OPENAI_API_KEY", "PI_ORCHESTRATOR_API_KEY"],
35
38
  price: { input: 2, output: 8, cacheRead: 0.5 },
36
39
  },
37
40
  {
@@ -42,6 +45,7 @@ export const ONBOARDING_PRESETS = [
42
45
  baseUrl: "https://open.bigmodel.cn/api/paas/v4",
43
46
  defaultModel: "glm-5.3",
44
47
  compactModel: "glm-5.3-flash",
48
+ apiKeyEnv: ["ZHIPU_API_KEY", "GLM_API_KEY", "PI_ORCHESTRATOR_API_KEY"],
45
49
  },
46
50
  {
47
51
  id: "kimi",
@@ -51,6 +55,7 @@ export const ONBOARDING_PRESETS = [
51
55
  baseUrl: "https://api.moonshot.cn/v1",
52
56
  defaultModel: "kimi-k2.5",
53
57
  compactModel: "moonshot-v1-8k",
58
+ apiKeyEnv: ["MOONSHOT_API_KEY", "KIMI_API_KEY", "PI_ORCHESTRATOR_API_KEY"],
54
59
  },
55
60
  {
56
61
  id: "custom",
@@ -59,6 +64,7 @@ export const ONBOARDING_PRESETS = [
59
64
  protocol: "openai",
60
65
  baseUrl: "",
61
66
  defaultModel: "",
67
+ apiKeyEnv: ["PI_ORCHESTRATOR_API_KEY"],
62
68
  },
63
69
  ];
64
70
  function splitSecretList(raw) {
@@ -105,15 +111,25 @@ export function applyOnboardingPlan(draft, current, input) {
105
111
  if (!relayUrl)
106
112
  throw new Error("托管中转模式需要填写云端 Relay 地址(relayUrl)。");
107
113
  const type = input.type ?? current.orchestrator.type ?? "anthropic-compatible";
108
- const modelId = input.modelId?.trim() || (type === "anthropic-compatible" ? "claude-sonnet-5-5" : "gpt-4.1");
109
- const cred = credIds[0] ?? current.proxy?.relay.credential;
110
- raw.orchestrator = {
114
+ const effectiveType = type === "builtin" ? "anthropic-compatible" : type;
115
+ const targetBase = `${relayUrl}/${effectiveType === "openai-compatible" ? "openai" : "anthropic"}`;
116
+ const sameEndpoint = current.orchestrator.type === effectiveType &&
117
+ (current.orchestrator.baseUrl ?? "").replace(/\/+$/, "") === targetBase;
118
+ const modelId = input.modelId?.trim() || (effectiveType === "anthropic-compatible" ? "claude-sonnet-5-5" : "gpt-4.1");
119
+ const cred = credIds[0] ?? current.proxy?.relay.credential ?? (sameEndpoint ? current.orchestrator.credential : undefined);
120
+ const nextOrch = {
111
121
  ...rawOrch,
112
- type: type === "builtin" ? "anthropic-compatible" : type,
113
- baseUrl: `${relayUrl}/${type === "openai-compatible" ? "openai" : "anthropic"}`,
122
+ type: effectiveType,
123
+ baseUrl: targetBase,
114
124
  modelId,
115
- ...(cred ? { credential: cred } : {}),
125
+ apiKeyFromClaudeSettings: false,
126
+ apiKeyEnv: cred ? [] : ["LEMMA_RELAY_TOKEN", "PI_ORCHESTRATOR_API_KEY"],
116
127
  };
128
+ if (cred)
129
+ nextOrch.credential = cred;
130
+ else
131
+ delete nextOrch.credential;
132
+ raw.orchestrator = nextOrch;
117
133
  raw.proxy = {
118
134
  ...(current.proxy),
119
135
  ...rawProxy,
@@ -139,15 +155,23 @@ export function applyOnboardingPlan(draft, current, input) {
139
155
  if (!modelId)
140
156
  throw new Error("请填写默认模型 ID。");
141
157
  const protocol = type === "anthropic-compatible" ? "anthropic" : "openai";
142
- const primaryCred = credIds[0] ?? current.orchestrator.credential;
143
- raw.orchestrator = {
158
+ const sameEndpoint = current.orchestrator.type === type &&
159
+ (current.orchestrator.baseUrl ?? "").replace(/\/+$/, "") === baseUrl;
160
+ const primaryCred = credIds[0] ?? (sameEndpoint ? current.orchestrator.credential : undefined);
161
+ const nextOrch = {
144
162
  ...rawOrch,
145
163
  type,
146
164
  baseUrl,
147
165
  modelId,
148
- ...(primaryCred ? { credential: primaryCred } : {}),
166
+ apiKeyFromClaudeSettings: type === "anthropic-compatible" && credIds.length === 0 ? Boolean(rawOrch.apiKeyFromClaudeSettings) : false,
167
+ apiKeyEnv: credIds.length > 0 ? [] : (preset.apiKeyEnv ?? ["PI_ORCHESTRATOR_API_KEY"]),
149
168
  ...(preset.price ? { price: preset.price } : {}),
150
169
  };
170
+ if (primaryCred)
171
+ nextOrch.credential = primaryCred;
172
+ else
173
+ delete nextOrch.credential;
174
+ raw.orchestrator = nextOrch;
151
175
  const prevUpstreams = rawProxy.upstreams ?? current.proxy.upstreams;
152
176
  const nextUpstreams = {
153
177
  ...prevUpstreams,
package/dist/terminal.js CHANGED
@@ -38,7 +38,9 @@ export const TERMINAL_COMMANDS = [
38
38
  ["apply", "应用改动"],
39
39
  ["drop", "丢弃改动"],
40
40
  ["clean", "清理工作副本"],
41
- ["new", "新上下文"],
41
+ ["new", "同会话重置模型上下文(保留历史/分工表/改动)"],
42
+ ["clear", "开启空上下文新会话(旧会话保留在 /resume,后台任务继续)"],
43
+ ["resume", "搜索并恢复历史会话或子对话(同 Ctrl+K)"],
42
44
  ["exit", "退出"],
43
45
  ["quit", "退出"],
44
46
  ["sessions", "列出隔离会话"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lemma-agent",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "Lemma: durable local multi-agent coding orchestration with isolated worktrees, blind review, and verified integration",
5
5
  "bin": {
6
6
  "lemma": "bin/lemma.mjs"