agent-loft 0.2.118 → 0.2.120

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/README.md CHANGED
@@ -19,7 +19,7 @@
19
19
  - **人在哪,台面就在哪**:电脑上用网页,手机上用 PWA 或飞书。同一个会话、同一个授权请求,在哪个渠道处理都行,其他地方自动同步。
20
20
  - **跑在你自己的机器上**:代码、凭据和会话都留在本机,agent-loft 只是一层安全的遥控。
21
21
 
22
- Logo 就是这个意思:一大两小几颗星(多个 agent)站在同一张台面上。
22
+ Logo 是白底的三向汇合:橘红、暖橙和珊瑚红三个单元,表达多个 agent 汇到同一处协作。图标源文件是 `web/icon.svg`,修改后运行 `npm run icons` 同步生成 iPhone、PWA、桌面端和两处 loading 的图形资源。
23
23
 
24
24
  ## 六大核心亮点
25
25
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-loft",
3
- "version": "0.2.118",
3
+ "version": "0.2.120",
4
4
  "type": "module",
5
5
  "description": "多个 agent 的工作台:把本机 Claude Code / Codex 放到一处统一管理,用飞书和 Web 页面随时驱动——会话、审批、模型切换都共用",
6
6
  "keywords": [
@@ -42,6 +42,7 @@
42
42
  "typecheck": "tsc --noEmit",
43
43
  "test": "node --import tsx --test test/*.test.ts",
44
44
  "build:editor": "node scripts/build-editor.mjs",
45
+ "icons": "node scripts/build-icons.mjs",
45
46
  "prepublishOnly": "npm run typecheck"
46
47
  },
47
48
  "dependencies": {
@@ -2,6 +2,7 @@
2
2
  //
3
3
  // 会话怎么跑见 session.ts;会话列表 / 历史自己读 data/pi/sessions 下的 JSONL(history.ts)。
4
4
  // 记录是树结构(id / parentId),分叉、回退都用 SDK 的 SessionManager 另存一条新会话,原会话不动。
5
+ import type { AgentSession as PiAgentSession } from "@earendil-works/pi-coding-agent";
5
6
  import type { AgentCommand } from "../../core/command-catalog.js";
6
7
  import { config } from "../../core/config.js";
7
8
  import type {
@@ -38,8 +39,16 @@ export class PiDriver implements AgentDriver {
38
39
  }
39
40
  async stop(): Promise<void> {}
40
41
 
42
+ private sessions = new Map<string, PiAgentSession>();
43
+ private titled = new Set<string>();
44
+ private titling = new Map<string, Promise<string | undefined>>();
45
+
41
46
  createSession(opts: SessionOptions, events: AgentEvents, host: InteractionHost): AgentSession {
42
- return new PiSession(opts, events, host);
47
+ return new PiSession(opts, events, host, (session, active) => {
48
+ const id = session.sessionId;
49
+ if (active) this.sessions.set(id, session);
50
+ else if (this.sessions.get(id) === session) this.sessions.delete(id);
51
+ });
43
52
  }
44
53
 
45
54
  async listSessions(cwd: string | undefined, limit = 10): Promise<SessionSummary[]> {
@@ -56,7 +65,54 @@ export class PiDriver implements AgentDriver {
56
65
  }
57
66
 
58
67
  async sessionTitle(id: string): Promise<string | undefined> {
59
- return sessionTitleOf(id);
68
+ const name = sessionTitleOf(id);
69
+ if (name) return name;
70
+ const c = config().agents.pi;
71
+ if (!c.autoTitle) return undefined;
72
+ const pending = this.titling.get(id);
73
+ if (pending) return pending;
74
+ if (this.titled.has(id) || !sessionFile(id)) return undefined;
75
+ const history = readHistoryFile(id);
76
+ const first = history.findIndex((m) => m.role === "user" && m.text.trim());
77
+ if (first < 0) return undefined; // 空会话不消耗生成机会
78
+ this.titled.add(id); // 失败也不在每轮 / 同步重试时重复花 token
79
+ const task = this.generateTitle(id, c.titleModel, history.slice(first))
80
+ .catch((err) => {
81
+ console.error("[pi] 生成会话名称失败:", err instanceof Error ? err.message : err);
82
+ return undefined;
83
+ })
84
+ .finally(() => this.titling.delete(id));
85
+ this.titling.set(id, task);
86
+ return task;
87
+ }
88
+
89
+ /** 只发第一轮的问答,不带系统提示、工具结果或思考;后台调用不建新会话。 */
90
+ private async generateTitle(id: string, model: string, history: HistoryMessage[]): Promise<string | undefined> {
91
+ const file = sessionFile(id);
92
+ if (!file) return undefined;
93
+ const { pi } = await loadSdk();
94
+ const live = this.sessions.get(id);
95
+ const sm = live?.sessionManager ?? pi.SessionManager.open(file, SESSIONS_DIR);
96
+ const selected = sm.buildSessionContext().model;
97
+ const titleModel = model || (live?.model ? modelKey(live.model) : selected ? `${selected.provider}/${selected.modelId}` : "");
98
+ const answer = history[1]?.role === "assistant" ? history[1].text : undefined;
99
+ const out = (await this.complete({
100
+ system: "你给对话起标题。根据用户的第一条消息(和助手的回复)概括这次对话在做什么,输出一个简短的标题:和用户用同一种语言,中文不超过 15 个字,不加引号、句号和表情。",
101
+ prompt: `用户:\n${history[0]!.text.slice(0, 2000)}${answer ? `\n\n助手:\n${answer.slice(0, 1500)}` : ""}`,
102
+ schema: { type: "object", properties: { title: { type: "string" } }, required: ["title"], additionalProperties: false },
103
+ ...(titleModel ? { model: titleModel } : {}),
104
+ timeoutMs: 60_000,
105
+ })) as { title?: unknown };
106
+ if (typeof out?.title !== "string") return undefined;
107
+ const title = out.title.replace(/\s+/g, " ").trim().replace(/^["'“”‘’「」《》]+|["'“”‘’「」《》。.]+$/g, "").trim().slice(0, 80);
108
+ if (!title || !config().agents.pi.autoTitle || sessionFile(id) !== file) return undefined;
109
+ // 生成期间可能已有名称、续聊或恢复:重新取活实例 / 重读文件,不能接在旧 leaf 上丢掉后续分支。
110
+ const existing = sessionTitleOf(id);
111
+ if (existing) return existing;
112
+ const current = this.sessions.get(id);
113
+ if (current) current.setSessionName(title);
114
+ else pi.SessionManager.open(file, SESSIONS_DIR).appendSessionInfo(title);
115
+ return title;
60
116
  }
61
117
 
62
118
  async readHistory(id: string): Promise<HistoryMessage[]> {
@@ -219,6 +219,8 @@ export class PiSession implements AgentSession {
219
219
  private readonly opts: SessionOptions,
220
220
  private readonly events: AgentEvents,
221
221
  private readonly host: InteractionHost,
222
+ /** 驱动写会话元数据时必须用活着的实例,不能另开一个持有旧 leaf 的 SessionManager */
223
+ private readonly onSession?: (session: PiAgentSession, active: boolean) => void,
222
224
  ) {
223
225
  this.allowAll = opts.permission === "full";
224
226
  if (opts.model) this.runtime.model = opts.model;
@@ -313,6 +315,7 @@ export class PiSession implements AgentSession {
313
315
  this.syncPlanTool(session);
314
316
  if (fork) this.forked = true;
315
317
  this.session = session;
318
+ this.onSession?.(session, true);
316
319
  this.runtime = { model: modelKey(model), ...(session.supportsThinking() ? { effort: session.thinkingLevel } : {}) };
317
320
  return session;
318
321
  }
@@ -560,6 +563,7 @@ export class PiSession implements AgentSession {
560
563
  private drop(session: PiAgentSession): void {
561
564
  if (this.session !== session) return;
562
565
  this.session = null;
566
+ this.onSession?.(session, false);
563
567
  try {
564
568
  session.dispose();
565
569
  } catch {
@@ -88,6 +88,10 @@ export type AppConfig = {
88
88
  /** 思考程度(off / minimal / low / medium / high / xhigh),空 = pi 默认 */
89
89
  defaultEffort: string;
90
90
  models: string[];
91
+ /** SDK 不自动起名,由 agent-loft 在第一轮后后台生成一次 */
92
+ autoTitle: boolean;
93
+ /** 空 = 跟随会话模型 */
94
+ titleModel: string;
91
95
  };
92
96
  /**
93
97
  * dsh(DeepSeek Harness,npm i -g @deepseek-ai/dsh):每个会话一个 `dsh --profile acp` 进程。
@@ -186,7 +190,7 @@ export function defaultConfig(): AppConfig {
186
190
  // 默认不开:要先在设置里登录
187
191
  workbuddy: { enabled: false, environment: "workbuddy", cliPath: "", defaultModel: "", defaultEffort: "", models: [] },
188
192
  // 默认不开:要先填一家服务商的 API Key
189
- pi: { enabled: false, defaultModel: "", defaultEffort: "", models: [] },
193
+ pi: { enabled: false, defaultModel: "", defaultEffort: "", models: [], autoTitle: true, titleModel: "" },
190
194
  // 默认不开:要先装 dsh、配 DeepSeek API Key
191
195
  dsh: { enabled: false, path: "dsh", home: "", patch: "", defaultModel: "", defaultEffort: "", models: [] },
192
196
  },
Binary file
@@ -1,6 +1,6 @@
1
- /* ---------- logo 加载动画:三颗星依次跳起,台面跟着呼吸 ---------- */
2
- .loft-loader {
3
- --size: 26px;
1
+ /* ---------- 汇合:开屏三臂向内聚拢,回复中轻转并依次呼吸 ---------- */
2
+ .loft-loader,
3
+ .loft-stars {
4
4
  display: inline-block;
5
5
  flex-shrink: 0;
6
6
  width: var(--size);
@@ -8,161 +8,63 @@
8
8
  line-height: 0;
9
9
  }
10
10
 
11
- .loft-loader.xl {
12
- --size: 72px;
13
- }
11
+ .loft-loader { --size: 26px; }
12
+ .loft-loader.xl { --size: 72px; }
13
+ .loft-stars { --size: 18px; }
14
+ .loft-stars.lg { --size: 32px; }
14
15
 
15
- .loft-loader svg {
16
+ .loft-loader svg,
17
+ .loft-stars svg {
16
18
  display: block;
17
19
  width: 100%;
18
20
  height: 100%;
19
21
  overflow: visible;
20
22
  }
21
23
 
22
- .loft-loader path {
23
- transform-box: fill-box;
24
- transform-origin: 50% 50%;
25
- animation-duration: 1.6s;
26
- animation-iteration-count: infinite;
27
- animation-timing-function: cubic-bezier(0.45, 0, 0.25, 1);
28
- animation-fill-mode: both;
29
- animation-delay: calc(var(--t, 0ms) + var(--d, 0ms));
24
+ /* 以 SVG 的原点为中心,外层各自的 120° 旋转不受动画影响。 */
25
+ .lc-rotor,
26
+ .lc-arm {
27
+ transform-box: view-box;
28
+ transform-origin: 0 0;
30
29
  }
30
+ .lc-arm-0 { --d: 0ms; }
31
+ .lc-arm-1 { --d: -600ms; }
32
+ .lc-arm-2 { --d: -1200ms; }
31
33
 
32
- .loft-loader .ll-star {
33
- animation-name: loft-star;
34
+ .loft-loader .lc-arm {
35
+ animation: loft-converge 1.8s cubic-bezier(0.45, 0, 0.25, 1) infinite both;
36
+ animation-delay: calc(var(--t, 0ms) + var(--d));
34
37
  }
35
38
 
36
- .loft-loader .ll-l {
37
- --d: 0ms;
39
+ @keyframes loft-converge {
40
+ 0%, 100% { transform: translateY(-20px); opacity: 0.45; }
41
+ 28%, 60% { transform: translateY(0); opacity: 1; }
38
42
  }
39
43
 
40
- .loft-loader .ll-c {
41
- --d: 180ms;
42
- }
43
-
44
- .loft-loader .ll-r {
45
- --d: 360ms;
44
+ .loft-stars .lc-rotor {
45
+ animation: loft-orbit 1.8s cubic-bezier(0.45, 0, 0.55, 1) infinite both;
46
+ animation-delay: var(--t, 0ms);
46
47
  }
47
-
48
- .loft-loader .ll-plate {
49
- animation-name: loft-plate;
50
- --d: 260ms;
48
+ .loft-stars .lc-arm {
49
+ animation: loft-signal 1.8s ease-in-out infinite both;
50
+ animation-delay: calc(var(--t, 0ms) + var(--d));
51
51
  }
52
52
 
53
- .loft-loader .ll-shadow {
54
- animation-name: loft-shadow;
55
- --d: 320ms;
53
+ @keyframes loft-orbit {
54
+ from { transform: rotate(0deg); }
55
+ to { transform: rotate(360deg); }
56
56
  }
57
-
58
- @keyframes loft-star {
59
- 0%,
60
- 70%,
61
- 100% {
62
- transform: translateY(0) scale(0.72);
63
- opacity: 0.4;
64
- }
65
- 28% {
66
- transform: translateY(-22px) scale(1.06);
67
- opacity: 1;
68
- }
69
- 48% {
70
- transform: translateY(0) scale(0.92);
71
- opacity: 0.85;
72
- }
73
- }
74
-
75
- @keyframes loft-plate {
76
- 0%,
77
- 100% {
78
- opacity: 0.75;
79
- }
80
- 45% {
81
- opacity: 1;
82
- }
83
- }
84
-
85
- @keyframes loft-shadow {
86
- 0%,
87
- 100% {
88
- transform: translateY(-6px);
89
- opacity: 0.32;
90
- }
91
- 50% {
92
- transform: translateY(6px);
93
- opacity: 0.12;
94
- }
57
+ @keyframes loft-signal {
58
+ 0%, 100% { opacity: 0.5; }
59
+ 35%, 55% { opacity: 1; }
95
60
  }
96
61
 
97
62
  @media (prefers-reduced-motion: reduce) {
98
- .loft-loader .ll-star {
99
- animation-name: loft-star-calm;
100
- animation-duration: 2.4s;
101
- }
102
- .loft-loader .ll-shadow {
63
+ .loft-loader .lc-arm,
64
+ .loft-stars .lc-arm,
65
+ .loft-stars .lc-rotor {
103
66
  animation: none;
104
- opacity: 0.3;
105
- }
106
- }
107
-
108
- /* 回复末尾的精简版:只有一颗星,旋转 + 放大缩小 */
109
- .loft-stars {
110
- display: inline-block;
111
- flex-shrink: 0;
112
- width: 18px;
113
- height: 18px;
114
- line-height: 0;
115
- }
116
-
117
- /* 打开会话、读历史时用的大一号 */
118
- .loft-stars.lg {
119
- width: 32px;
120
- height: 32px;
121
- }
122
-
123
- .loft-stars svg {
124
- display: block;
125
- width: 100%;
126
- height: 100%;
127
- overflow: visible;
128
- }
129
-
130
- .loft-stars path {
131
- transform-box: fill-box;
132
- transform-origin: 50% 50%;
133
- animation: loft-twirl 1.8s cubic-bezier(0.45, 0, 0.25, 1) infinite both;
134
- animation-delay: var(--t, 0ms);
135
- }
136
-
137
- /* 四角星转 90° 正好回到原样,所以每轮转 180° 能无缝接上 */
138
- @keyframes loft-twirl {
139
- 0% {
140
- transform: rotate(0deg) scale(0.6);
141
- opacity: 0.55;
142
- }
143
- 45% {
144
- transform: rotate(110deg) scale(1.12);
145
- opacity: 1;
146
- }
147
- 100% {
148
- transform: rotate(180deg) scale(0.6);
149
- opacity: 0.55;
150
- }
151
- }
152
-
153
- @media (prefers-reduced-motion: reduce) {
154
- .loft-stars path {
155
- animation-name: loft-star-calm;
156
- animation-duration: 2.4s;
157
- }
158
- }
159
-
160
- @keyframes loft-star-calm {
161
- 0%,
162
- 100% {
163
- opacity: 0.4;
164
- }
165
- 40% {
67
+ transform: none;
166
68
  opacity: 1;
167
69
  }
168
70
  }
@@ -1,12 +1,21 @@
1
1
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
2
- <!-- Agent Loft:agent 工作台 —— 一大两小几颗星(多个 agent)站在同一张台面上,统一管理 -->
3
- <defs><linearGradient id="g" gradientUnits="userSpaceOnUse" x1="104" y1="104" x2="408" y2="408"><stop offset="0" stop-color="#3b82f6"/><stop offset="1" stop-color="#06b6d4"/></linearGradient></defs>
4
- <rect width="512" height="512" fill="#fff"/>
5
- <g transform="translate(256 257) scale(0.8) translate(-256 -257)">
6
- <path d="M256 296L404 364L256 432L108 364Z" fill="url(#g)" fill-opacity=".3"/>
7
- <path d="M256 252L404 320L256 388L108 320Z" fill="url(#g)"/>
8
- <path d="M256 82C268.92 145.08 268.92 145.08 332 158C268.92 170.92 268.92 170.92 256 234C243.08 170.92 243.08 170.92 180 158C243.08 145.08 243.08 145.08 256 82Z" fill="url(#g)"/>
9
- <path d="M152 186C158.46 217.54 158.46 217.54 190 224C158.46 230.46 158.46 230.46 152 262C145.54 230.46 145.54 230.46 114 224C145.54 217.54 145.54 217.54 152 186Z" fill="url(#g)" fill-opacity=".85"/>
10
- <path d="M360 186C366.46 217.54 366.46 217.54 398 224C366.46 230.46 366.46 230.46 360 262C353.54 230.46 353.54 230.46 322 224C353.54 217.54 353.54 217.54 360 186Z" fill="url(#g)" fill-opacity=".85"/>
2
+ <title>Agent Loft — 汇合</title>
3
+ <rect width="512" height="512" fill="#FFFFFF"/>
4
+ <defs>
5
+ <mask id="loft-center" maskUnits="userSpaceOnUse" x="-180" y="-180" width="360" height="360">
6
+ <rect x="-180" y="-180" width="360" height="360" fill="#FFFFFF"/>
7
+ <circle r="21" fill="#000000"/>
8
+ </mask>
9
+ </defs>
10
+ <g fill="#FF7444" color="#FF7444">
11
+ <g transform="translate(256 256)">
12
+ <g mask="url(#loft-center)">
13
+ <g class="lc-rotor">
14
+ <g class="lc-arm lc-arm-0"><rect x="-33" y="-133" width="66" height="139" rx="33" fill="#FF7444"/></g>
15
+ <g transform="rotate(120)"><g class="lc-arm lc-arm-1"><rect x="-33" y="-133" width="66" height="139" rx="33" fill="#FFB15B"/></g></g>
16
+ <g transform="rotate(240)"><g class="lc-arm lc-arm-2"><rect x="-33" y="-133" width="66" height="139" rx="33" fill="#F65364"/></g></g>
17
+ </g>
18
+ </g>
19
+ </g>
11
20
  </g>
12
21
  </svg>
package/web/icon.svg CHANGED
@@ -1,12 +1,21 @@
1
1
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
2
- <!-- Agent Loft:agent 工作台 —— 一大两小几颗星(多个 agent)站在同一张台面上,统一管理 -->
3
- <defs><linearGradient id="g" gradientUnits="userSpaceOnUse" x1="104" y1="104" x2="408" y2="408"><stop offset="0" stop-color="#3b82f6"/><stop offset="1" stop-color="#06b6d4"/></linearGradient></defs>
4
- <rect width="512" height="512" rx="116" fill="#fff"/>
5
- <g transform="translate(256 257) scale(1.0) translate(-256 -257)">
6
- <path d="M256 296L404 364L256 432L108 364Z" fill="url(#g)" fill-opacity=".3"/>
7
- <path d="M256 252L404 320L256 388L108 320Z" fill="url(#g)"/>
8
- <path d="M256 82C268.92 145.08 268.92 145.08 332 158C268.92 170.92 268.92 170.92 256 234C243.08 170.92 243.08 170.92 180 158C243.08 145.08 243.08 145.08 256 82Z" fill="url(#g)"/>
9
- <path d="M152 186C158.46 217.54 158.46 217.54 190 224C158.46 230.46 158.46 230.46 152 262C145.54 230.46 145.54 230.46 114 224C145.54 217.54 145.54 217.54 152 186Z" fill="url(#g)" fill-opacity=".85"/>
10
- <path d="M360 186C366.46 217.54 366.46 217.54 398 224C366.46 230.46 366.46 230.46 360 262C353.54 230.46 353.54 230.46 322 224C353.54 217.54 353.54 217.54 360 186Z" fill="url(#g)" fill-opacity=".85"/>
2
+ <title>Agent Loft — 汇合</title>
3
+ <rect width="512" height="512" rx="114" fill="#FFFFFF"/>
4
+ <defs>
5
+ <mask id="loft-center" maskUnits="userSpaceOnUse" x="-180" y="-180" width="360" height="360">
6
+ <rect x="-180" y="-180" width="360" height="360" fill="#FFFFFF"/>
7
+ <circle r="21" fill="#000000"/>
8
+ </mask>
9
+ </defs>
10
+ <g fill="#FF7444" color="#FF7444">
11
+ <g transform="translate(256 256)">
12
+ <g mask="url(#loft-center)">
13
+ <g class="lc-rotor">
14
+ <g class="lc-arm lc-arm-0"><rect x="-33" y="-133" width="66" height="139" rx="33" fill="#FF7444"/></g>
15
+ <g transform="rotate(120)"><g class="lc-arm lc-arm-1"><rect x="-33" y="-133" width="66" height="139" rx="33" fill="#FFB15B"/></g></g>
16
+ <g transform="rotate(240)"><g class="lc-arm lc-arm-2"><rect x="-33" y="-133" width="66" height="139" rx="33" fill="#F65364"/></g></g>
17
+ </g>
18
+ </g>
19
+ </g>
11
20
  </g>
12
21
  </svg>
package/web/index.html CHANGED
@@ -39,7 +39,22 @@
39
39
  <link rel="stylesheet" href="/css/mobile.css" />
40
40
  </head>
41
41
  <body>
42
- <div id="app"><div class="boot"><span class="loft-loader xl" role="img" aria-label="加载中"><svg viewBox="96 56 320 388" aria-hidden="true"><defs><linearGradient id="boot-g" gradientUnits="userSpaceOnUse" x1="104" y1="104" x2="408" y2="408"><stop offset="0" stop-color="#3b82f6"/><stop offset="1" stop-color="#06b6d4"/></linearGradient></defs><path class="ll-shadow" d="M256 296L404 364L256 432L108 364Z" fill="url(#boot-g)"/><path class="ll-plate" d="M256 252L404 320L256 388L108 320Z" fill="url(#boot-g)"/><path class="ll-star ll-l" d="M152 186C158.46 217.54 158.46 217.54 190 224C158.46 230.46 158.46 230.46 152 262C145.54 230.46 145.54 230.46 114 224C145.54 217.54 145.54 217.54 152 186Z" fill="url(#boot-g)"/><path class="ll-star ll-c" d="M256 82C268.92 145.08 268.92 145.08 332 158C268.92 170.92 268.92 170.92 256 234C243.08 170.92 243.08 170.92 180 158C243.08 145.08 243.08 145.08 256 82Z" fill="url(#boot-g)"/><path class="ll-star ll-r" d="M360 186C366.46 217.54 366.46 217.54 398 224C366.46 230.46 366.46 230.46 360 262C353.54 230.46 353.54 230.46 322 224C353.54 217.54 353.54 217.54 360 186Z" fill="url(#boot-g)"/></svg></span></div></div>
42
+ <div id="app"><div class="boot"><span class="loft-loader xl" role="img" aria-label="加载中"><svg xmlns="http://www.w3.org/2000/svg" viewBox="76 76 360 360" aria-hidden="true"><defs>
43
+ <mask id="loft-boot-center" maskUnits="userSpaceOnUse" x="-180" y="-180" width="360" height="360">
44
+ <rect x="-180" y="-180" width="360" height="360" fill="#FFFFFF"/>
45
+ <circle r="21" fill="#000000"/>
46
+ </mask>
47
+ </defs><g fill="#FF7444" color="#FF7444">
48
+ <g transform="translate(256 256)">
49
+ <g mask="url(#loft-boot-center)">
50
+ <g class="lc-rotor">
51
+ <g class="lc-arm lc-arm-0"><rect x="-33" y="-133" width="66" height="139" rx="33" fill="#FF7444"/></g>
52
+ <g transform="rotate(120)"><g class="lc-arm lc-arm-1"><rect x="-33" y="-133" width="66" height="139" rx="33" fill="#FFB15B"/></g></g>
53
+ <g transform="rotate(240)"><g class="lc-arm lc-arm-2"><rect x="-33" y="-133" width="66" height="139" rx="33" fill="#F65364"/></g></g>
54
+ </g>
55
+ </g>
56
+ </g>
57
+ </g></svg></span></div></div>
43
58
  <script type="module" src="/app.js"></script>
44
59
  </body>
45
60
  </html>
package/web/lib/dom.js CHANGED
@@ -1,4 +1,5 @@
1
1
  // ---------- 小工具 ----------
2
+ import { LOFT_MOTION_MS, loftLoaderSvg } from "./loft-mark.js";
2
3
 
3
4
  export const $app = document.getElementById("app");
4
5
  export const isTouch = matchMedia("(pointer: coarse)").matches;
@@ -95,23 +96,21 @@ ICON.dsh = `<svg viewBox="0 0 320 320"><image href="${new URL("../dsh.png", impo
95
96
  ICON.pi = '<svg viewBox="0 0 64 64"><rect x="2" y="2" width="60" height="60" rx="14" fill="currentColor"/><path fill="none" stroke="var(--bg, #fff)" stroke-width="6" stroke-linecap="round" d="M15 21h34M25 21v24M40 21v18c0 4 2 6 6 6"/></svg>';
96
97
 
97
98
  /**
98
- * 星星加载动画(回复末尾、打开会话时用)。开屏那个带台面的完整 logo 动画直接写在 index.html 里。
99
- * 每个实例的渐变 id 唯一,避免页面里有隐藏的同 id 渐变时画不出来。
99
+ * 汇合加载动画(回复末尾、打开会话时用);保留函数名供现有调用方使用。
100
+ * 每个实例的遮罩 id 唯一,隐藏或移除另一个实例不会影响当前图形。
100
101
  * 动画按全局时钟设负的起始延迟:回复被授权卡片分成几段时,新一段的动画接着播、不会一抖一抖地重来。
101
102
  */
102
103
  let loaderSeq = 0;
103
104
 
104
- /** 只有 logo 中间那颗大星,一边旋转一边放大缩小 */
105
- const STARS_MS = 1800;
106
105
  export function starsLoader(cls = "") {
107
- const id = `loft-g${++loaderSeq}`;
106
+ const id = `loft-reply-center-${++loaderSeq}`;
108
107
  const el = h("span", {
109
108
  class: `loft-stars${cls ? ` ${cls}` : ""}`,
110
109
  role: "img",
111
110
  "aria-label": "回复中",
112
- html: `<svg viewBox="180 82 152 152" aria-hidden="true"><defs><linearGradient id="${id}" gradientUnits="userSpaceOnUse" x1="180" y1="82" x2="332" y2="234"><stop offset="0" stop-color="#3b82f6"/><stop offset="1" stop-color="#06b6d4"/></linearGradient></defs><path d="M256 82C268.92 145.08 268.92 145.08 332 158C268.92 170.92 268.92 170.92 256 234C243.08 170.92 243.08 170.92 180 158C243.08 145.08 243.08 145.08 256 82Z" fill="url(#${id})"/></svg>`,
111
+ html: loftLoaderSvg(id),
113
112
  });
114
- el.style.setProperty("--t", `${-(performance.now() % STARS_MS).toFixed(0)}ms`);
113
+ el.style.setProperty("--t", `${-(performance.now() % LOFT_MOTION_MS).toFixed(0)}ms`);
115
114
  return el;
116
115
  }
117
116
 
@@ -0,0 +1,4 @@
1
+ // Generated by npm run icons from web/icon.svg.
2
+ export const LOFT_MOTION_MS = 1800;
3
+ const MARK = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"76 76 360 360\" aria-hidden=\"true\"><defs>\n <mask id=\"loft-center\" maskUnits=\"userSpaceOnUse\" x=\"-180\" y=\"-180\" width=\"360\" height=\"360\">\n <rect x=\"-180\" y=\"-180\" width=\"360\" height=\"360\" fill=\"#FFFFFF\"/>\n <circle r=\"21\" fill=\"#000000\"/>\n </mask>\n </defs><g fill=\"#FF7444\" color=\"#FF7444\">\n <g transform=\"translate(256 256)\">\n <g mask=\"url(#loft-center)\">\n <g class=\"lc-rotor\">\n <g class=\"lc-arm lc-arm-0\"><rect x=\"-33\" y=\"-133\" width=\"66\" height=\"139\" rx=\"33\" fill=\"#FF7444\"/></g>\n <g transform=\"rotate(120)\"><g class=\"lc-arm lc-arm-1\"><rect x=\"-33\" y=\"-133\" width=\"66\" height=\"139\" rx=\"33\" fill=\"#FFB15B\"/></g></g>\n <g transform=\"rotate(240)\"><g class=\"lc-arm lc-arm-2\"><rect x=\"-33\" y=\"-133\" width=\"66\" height=\"139\" rx=\"33\" fill=\"#F65364\"/></g></g>\n </g>\n </g>\n </g>\n </g></svg>";
4
+ export function loftLoaderSvg(id) { return MARK.replaceAll("loft-center", id); }
@@ -237,15 +237,19 @@ export function agentsTab(cfg, page) {
237
237
  const path = h("input", { value: settings.path });
238
238
  const home = h("input", { value: settings.home, placeholder: "留空用 ~/.codex" });
239
239
  const sandbox = h("select", {}, ["read-only", "workspace-write", "danger-full-access"].map((mode) => h("option", { value: mode, selected: mode === settings.sandbox }, mode)));
240
- const titleOn = h("input", { type: "checkbox", checked: !!settings.autoTitle });
241
- const titlePick = modelPicker("codex", settings.titleModel ?? "", "", "跟随 config.toml");
242
- const titleModel = h("div", { class: "grow field" }, titlePick.modelEl);
243
- const syncTitle = () => { titleModel.hidden = !titleOn.checked; };
244
- titleOn.addEventListener("change", syncTitle);
245
- syncTitle();
246
- codex = { path, home, sandbox, titleOn, titlePick, titleModel };
240
+ codex = { path, home, sandbox };
247
241
  config.append(field("codex 可执行文件", path, "以系统服务运行时 PATH 很短,建议写绝对路径"), field("CODEX_HOME", home), field("沙箱", sandbox, "workspace-write:目录内可读写,越界才弹授权。danger-full-access 等于关掉沙箱"));
248
242
  }
243
+ let titles = null;
244
+ if (engine === "codex" || engine === "pi") {
245
+ const on = h("input", { type: "checkbox", checked: settings.autoTitle ?? engine === "pi" });
246
+ const pick = modelPicker(engine, settings.titleModel ?? "", "", engine === "pi" ? "跟随会话模型" : "跟随 config.toml");
247
+ const model = h("div", { class: "grow field" }, pick.modelEl);
248
+ const sync = () => { model.hidden = !on.checked; };
249
+ on.addEventListener("change", sync);
250
+ sync();
251
+ titles = { on, pick, model };
252
+ }
249
253
  let site = null;
250
254
  let cliPath = null;
251
255
  if (engine === "workbuddy") {
@@ -283,7 +287,10 @@ export function agentsTab(cfg, page) {
283
287
  }
284
288
  config.append(h("small", { class: "muted" }, "默认模型、思考程度、权限和默认加载的技能 / MCP,在「设置 → 专家」里这个 Agent 的「设置」中修改。"));
285
289
  config.append(h("div", { class: "field" }, h("span", {}, "输入框可选模型"), models.el));
286
- if (codex) config.append(h("div", { class: "row title-row" }, h("label", { class: "check" }, codex.titleOn, "自动生成会话名称"), codex.titleModel));
290
+ if (titles) {
291
+ config.append(h("div", { class: "row title-row" }, h("label", { class: "check" }, titles.on, "自动生成会话名称"), titles.model));
292
+ if (engine === "pi") config.append(h("small", { class: "muted" }, "第一轮回复后在后台生成一次,会额外调用模型;留空跟随会话模型,可另选低成本模型。手动改名不会被覆盖。"));
293
+ }
287
294
  config.append(h("div", { class: "row" }, saveButton(() => {
288
295
  const selected = models.value();
289
296
  if (!selected) {
@@ -294,7 +301,8 @@ export function agentsTab(cfg, page) {
294
301
  enabled: on.checked, models: selected,
295
302
  ...(site ? { environment: site.value, cliPath: cliPath.value.trim() } : {}),
296
303
  ...(dsh ? { path: dsh.path.value.trim() || "dsh", home: dsh.home.value.trim(), patch: dsh.patch.value.trim() } : {}),
297
- ...(codex ? { path: codex.path.value.trim() || "codex", home: codex.home.value.trim(), sandbox: codex.sandbox.value, autoTitle: codex.titleOn.checked, titleModel: codex.titlePick.model() } : {}),
304
+ ...(codex ? { path: codex.path.value.trim() || "codex", home: codex.home.value.trim(), sandbox: codex.sandbox.value } : {}),
305
+ ...(titles ? { autoTitle: titles.on.checked, titleModel: titles.pick.model() } : {}),
298
306
  } } });
299
307
  }, `保存 ${label} 设置`)));
300
308
  page.append(h("div", { class: "section", "data-agent": engine }, config));