agent-loft 0.2.111 → 0.2.112

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.
@@ -541,3 +541,167 @@ textarea.sending {
541
541
  display: none;
542
542
  }
543
543
  }
544
+
545
+ /* ---- 语音对话:通话时输入框换成通话条(views/voice-call.js) ---- */
546
+
547
+ .call-btn[hidden] {
548
+ display: none;
549
+ }
550
+
551
+ .call-panel {
552
+ background: var(--bg-input);
553
+ border: 1px solid color-mix(in srgb, var(--border) 85%, transparent);
554
+ border-radius: 22px;
555
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03), 0 4px 16px rgba(0, 0, 0, 0.05);
556
+ padding: 10px 10px 10px 16px;
557
+ }
558
+
559
+ .call-main {
560
+ display: flex;
561
+ align-items: center;
562
+ gap: 14px;
563
+ min-width: 0;
564
+ }
565
+
566
+ .call-wave {
567
+ display: flex;
568
+ align-items: center;
569
+ gap: 3px;
570
+ height: 28px;
571
+ flex-shrink: 0;
572
+ }
573
+
574
+ .call-bar {
575
+ width: 4px;
576
+ height: 100%;
577
+ border-radius: 2px;
578
+ background: var(--fg);
579
+ transform: scaleY(0.2);
580
+ transition: transform 80ms linear;
581
+ }
582
+
583
+ .call-panel.speaking .call-bar {
584
+ background: var(--accent);
585
+ }
586
+
587
+ .call-panel.connecting .call-bar {
588
+ opacity: 0.45;
589
+ animation: call-wait 1.1s ease-in-out infinite;
590
+ }
591
+
592
+ .call-panel.connecting .call-bar:nth-child(2) { animation-delay: 0.1s; }
593
+ .call-panel.connecting .call-bar:nth-child(3) { animation-delay: 0.2s; }
594
+ .call-panel.connecting .call-bar:nth-child(4) { animation-delay: 0.3s; }
595
+ .call-panel.connecting .call-bar:nth-child(5) { animation-delay: 0.4s; }
596
+
597
+ @keyframes call-wait {
598
+ 0%, 100% { transform: scaleY(0.2); }
599
+ 50% { transform: scaleY(0.6); }
600
+ }
601
+
602
+ .call-info {
603
+ flex: 1;
604
+ min-width: 0;
605
+ display: flex;
606
+ flex-direction: column;
607
+ gap: 2px;
608
+ }
609
+
610
+ .call-line {
611
+ display: flex;
612
+ align-items: baseline;
613
+ gap: 8px;
614
+ font-size: 14px;
615
+ font-weight: 500;
616
+ }
617
+
618
+ .call-time {
619
+ color: var(--fg-faint);
620
+ font-size: 12px;
621
+ font-variant-numeric: tabular-nums;
622
+ }
623
+
624
+ .call-caption {
625
+ display: flex;
626
+ gap: 6px;
627
+ min-width: 0;
628
+ font-size: 13px;
629
+ color: var(--fg-faint);
630
+ }
631
+
632
+ .call-panel.has-caption .call-caption {
633
+ color: var(--fg);
634
+ }
635
+
636
+ .call-who {
637
+ flex-shrink: 0;
638
+ color: var(--fg-faint);
639
+ }
640
+
641
+ .call-who:empty {
642
+ display: none;
643
+ }
644
+
645
+ /* 字幕只留最近两行:长句子往上滚走 */
646
+ .call-text {
647
+ min-width: 0;
648
+ display: -webkit-box;
649
+ -webkit-box-orient: vertical;
650
+ -webkit-line-clamp: 2;
651
+ overflow: hidden;
652
+ line-height: 1.45;
653
+ }
654
+
655
+ .call-ctls {
656
+ display: flex;
657
+ align-items: center;
658
+ gap: 8px;
659
+ flex-shrink: 0;
660
+ }
661
+
662
+ .call-ctl {
663
+ height: 36px;
664
+ min-width: 36px;
665
+ border-radius: 18px;
666
+ display: inline-grid;
667
+ place-items: center;
668
+ background: var(--bg-soft);
669
+ color: var(--fg);
670
+ }
671
+
672
+ .call-ctl svg {
673
+ width: 18px;
674
+ height: 18px;
675
+ }
676
+
677
+ .call-ctl.on {
678
+ color: var(--danger);
679
+ background: color-mix(in srgb, var(--danger) 12%, transparent);
680
+ }
681
+
682
+ .call-ctl.call-end {
683
+ padding: 0 16px;
684
+ font-size: 14px;
685
+ font-weight: 500;
686
+ color: #fff;
687
+ background: var(--danger);
688
+ }
689
+
690
+ @media (max-width: 640px) {
691
+ .call-panel {
692
+ padding-left: 12px;
693
+ }
694
+
695
+ .call-main {
696
+ gap: 10px;
697
+ }
698
+
699
+ .call-ctl.call-end {
700
+ padding: 0 12px;
701
+ }
702
+ }
703
+
704
+ /* 通话中输入框收起来,通话条顶上 */
705
+ .composer.in-call {
706
+ display: none;
707
+ }
@@ -156,6 +156,72 @@
156
156
  }
157
157
  }
158
158
 
159
+ /* ---- 专家编辑框:按用途分组 ---- */
160
+
161
+ .expert-form {
162
+ gap: 18px;
163
+ }
164
+
165
+ .form-section {
166
+ display: flex;
167
+ flex-direction: column;
168
+ gap: 12px;
169
+ min-width: 0;
170
+ }
171
+
172
+ .form-section + .form-section {
173
+ padding-top: 16px;
174
+ border-top: 1px solid var(--border);
175
+ }
176
+
177
+ .form-section-title {
178
+ margin: 0;
179
+ font-size: 13px;
180
+ font-weight: 600;
181
+ color: var(--fg-faint);
182
+ }
183
+
184
+ /* 两列的勾选:说明另起一行,不截断(权限、Codex 扩展能力) */
185
+ .check-list.grid {
186
+ display: grid;
187
+ grid-template-columns: repeat(2, minmax(0, 1fr));
188
+ gap: 10px 16px;
189
+ max-height: none;
190
+ }
191
+
192
+ .check-list.grid > .check-item {
193
+ flex-wrap: wrap;
194
+ align-items: center;
195
+ }
196
+
197
+ .check-list.grid > .check-item > small {
198
+ flex: 1 0 100%;
199
+ padding-left: 24px;
200
+ white-space: normal;
201
+ line-height: 1.45;
202
+ }
203
+
204
+ .check-item.disabled {
205
+ cursor: not-allowed;
206
+ opacity: 0.55;
207
+ }
208
+
209
+ .check-tag {
210
+ margin-left: 6px;
211
+ padding: 0 6px;
212
+ border-radius: 999px;
213
+ font-size: 11px;
214
+ font-style: normal;
215
+ color: var(--fg-faint);
216
+ background: var(--bg-soft);
217
+ }
218
+
219
+ @media (max-width: 640px) {
220
+ .check-list.grid {
221
+ grid-template-columns: minmax(0, 1fr);
222
+ }
223
+ }
224
+
159
225
  /* 按类型切换的一组字段:和别的字段一样排(间距由 .task-form 给) */
160
226
  .field-group {
161
227
  display: contents;
package/web/lib/ws.js CHANGED
@@ -11,6 +11,7 @@ import { setBusy } from "../views/composer.js";
11
11
  import { SH, shownHere } from "./shell.js";
12
12
  import { currentPushSub } from "./push.js";
13
13
  import { renderScheduled } from "../views/schedule.js";
14
+ import { onRealtimeEvent } from "../views/voice-call.js";
14
15
  import { reloadExperts } from "../views/experts.js";
15
16
 
16
17
  // ---------- WebSocket ----------
@@ -245,6 +246,9 @@ function onWsMessage(msg) {
245
246
  case "ev":
246
247
  applyEvent(msg);
247
248
  return;
249
+ case "rt":
250
+ onRealtimeEvent(msg);
251
+ return;
248
252
  case "replay":
249
253
  if (msg.key !== S.current) return;
250
254
  if (msg.reset) {
@@ -22,6 +22,15 @@ const PERMS = [
22
22
  { id: "exec", label: "跑命令", hint: "执行命令,等于能改任何文件;需要授权时会弹卡" },
23
23
  ];
24
24
  const FILE_LEVELS = ["read", "edit", "exec"];
25
+ /** Codex 自带、专家默认关掉的能力(core/experts.ts 的 CODEX_TOOLS)。admin:用这台机器上的东西,只有管理员能开 */
26
+ const CODEX_TOOLS = [
27
+ { id: "image_generation", label: "生图", hint: "Codex 自带的生图工具,图片显示在回复里,占 ChatGPT 订阅额度" },
28
+ { id: "multi_agent", label: "子智能体", hint: "把子任务派给 Codex 子智能体并行做,更费额度" },
29
+ { id: "browser", label: "操作浏览器", hint: "打开网页、点击、填表,用这台机器上 Codex 的浏览器和登录状态", admin: true },
30
+ { id: "computer_use", label: "操作桌面", hint: "截屏、点鼠标、敲键盘,控制这台机器的桌面(要有图形桌面)", admin: true },
31
+ { id: "apps", label: "插件和应用", hint: "Codex 插件,和 Codex 登录的 ChatGPT 账号连接的应用(邮箱、网盘……)", admin: true },
32
+ ];
33
+ const CODEX_TOOL_LABEL = Object.fromEntries(CODEX_TOOLS.map((t) => [t.id, t.label]));
25
34
  let refreshExpertsPage = () => {};
26
35
  document.addEventListener("aim:experts", () => refreshExpertsPage());
27
36
 
@@ -162,6 +171,7 @@ function expertCard(data, e, reload) {
162
171
  e.skills.length ? `${e.skills.length} 个技能` : null,
163
172
  e.mcp.length ? `${e.mcp.length} 个 MCP` : null,
164
173
  e.subagents.length ? `${e.subagents.length} 个子智能体` : null,
174
+ ...(e.engine === "codex" ? (e.codexTools ?? []).map((t) => CODEX_TOOL_LABEL[t]).filter(Boolean) : []),
165
175
  e.memory ? null : "不带记忆",
166
176
  ].filter(Boolean);
167
177
  return h(
@@ -187,6 +197,9 @@ function viewSharedExpert(e) {
187
197
  h("p", { class: "muted" }, "这是共享专家,设定由创建者维护。你的记忆和工具独立,工具可在「我的工具」里配置。"),
188
198
  field("说明", h("p", {}, e.description || "暂无说明")),
189
199
  field("引擎", h("p", {}, ENGINE_LABEL[e.engine])),
200
+ e.engine === "codex" && e.codexTools?.length
201
+ ? field("Codex 扩展能力", h("p", {}, e.codexTools.map((t) => CODEX_TOOL_LABEL[t] ?? t).join("、")), CODEX_TOOLS.some((t) => t.admin && e.codexTools.includes(t.id)) ? "操作浏览器、操作桌面、插件和应用只在管理员使用时打开" : null)
202
+ : null,
190
203
  field("提示词", prompt),
191
204
  ) });
192
205
  }
@@ -236,6 +249,38 @@ function field(label, input, hint) {
236
249
  return h("div", { class: "field" }, h("span", {}, label), input, hint ? h("small", {}, hint) : null);
237
250
  }
238
251
 
252
+ /** 编辑框里的一组字段,带个小标题。所有字段都藏起来时整组跟着藏(见 syncSections) */
253
+ function section(title, ...fields) {
254
+ return h("section", { class: "form-section" }, h("h3", { class: "form-section-title" }, title), ...fields);
255
+ }
256
+
257
+ function syncSections(body) {
258
+ for (const sec of body.querySelectorAll(".form-section")) {
259
+ sec.hidden = [...sec.children].filter((c) => !c.classList.contains("form-section-title")).every((c) => c.hidden);
260
+ }
261
+ }
262
+
263
+ /** Codex 扩展能力的勾选:本机能力只有管理员能勾,成员看得到但勾不了 */
264
+ function codexToolChecks(picked) {
265
+ const admin = isAdmin();
266
+ const boxes = CODEX_TOOLS.map((t) => {
267
+ const locked = !!t.admin && !admin;
268
+ const box = h("input", { type: "checkbox", checked: picked.includes(t.id) && !locked, disabled: locked });
269
+ const el = h(
270
+ "label",
271
+ { class: `check-item${locked ? " disabled" : ""}`, title: locked ? "只有管理员能开" : t.hint },
272
+ box,
273
+ h("span", {}, t.label, t.admin ? h("em", { class: "check-tag" }, "管理员") : null),
274
+ h("small", {}, t.hint),
275
+ );
276
+ return { id: t.id, box, el };
277
+ });
278
+ return {
279
+ el: h("div", { class: "check-list grid perm-list" }, boxes.map((b) => b.el)),
280
+ value: () => boxes.filter((b) => b.box.checked).map((b) => b.id),
281
+ };
282
+ }
283
+
239
284
  /** 一组勾选框:items [{ id, label, hint }],返回 { el, value() } */
240
285
  function checkList(items, picked, empty) {
241
286
  const boxes = items.map((it) => {
@@ -274,6 +319,7 @@ function openEditor(data, e, reload, preset) {
274
319
  pi: "追加在 pi 原装提示词后面(带上 pi 的工具用法和规则,每轮多约 600 token)",
275
320
  };
276
321
  const perms = permChecks(src);
322
+ const codexTools = codexToolChecks(src.codexTools ?? []);
277
323
  let cwd = src.cwd ?? "";
278
324
  const cwdBtn = h("button", { type: "button", class: "btn task-cwd" });
279
325
  const showCwd = () => {
@@ -323,35 +369,57 @@ function openEditor(data, e, reload, preset) {
323
369
  );
324
370
  fill(subBox, subs.el);
325
371
  subField.hidden = eng !== "claude";
372
+ codexField.hidden = eng !== "codex";
326
373
  baseField.hidden = eng !== "claude" && eng !== "pi";
327
374
  if (BASE_LABEL[eng]) basePrompt.options[1].textContent = BASE_LABEL[eng];
328
375
  perms.setEngine(eng);
376
+ syncSections(body);
329
377
  void models.load(eng);
330
378
  };
331
- const sync = () => (cwdField.hidden = perms.access() === "web");
379
+ const sync = () => {
380
+ cwdField.hidden = perms.access() === "web";
381
+ syncSections(body);
382
+ };
332
383
  const cwdField = field("默认工作目录", cwdBtn, "新建对话、定时任务时默认在这个目录里(可以再改)。点击选择目录,默认使用工作区根目录");
333
384
  const baseField = field("基础提示词", basePrompt);
334
385
  const subField = field("子智能体", subBox, "主专家可以把子任务派给它们(Agent 工具)。子智能体的权限不能超过主专家,只支持 Claude 专家");
386
+ const codexField = field(
387
+ "Codex 扩展能力",
388
+ codexTools.el,
389
+ "Codex 自带、专家默认关掉的能力(关着省 token)。标「管理员」的用的是这台机器上的浏览器、桌面和账号,只有管理员能开;共享给别人后,别人用时也不开",
390
+ );
335
391
  engine.onchange = renderEngineParts;
336
392
  perms.onchange = sync;
337
393
 
338
394
  const body = h(
339
395
  "div",
340
396
  { class: "modal-body task-form expert-form" },
341
- h("div", { class: "row-fields avatar-row" }, field("头像", avatar.el), field("名字", name)),
342
- field("说明", desc),
343
- field("共享", h("label", { class: "check-item" }, shared, h("span", {}, "共享给所有账号")), "其他账号可在网页、飞书私聊和定时任务中使用;只有你能修改设定。取消共享后,其他人的旧对话保留但不能继续调用。子智能体也需要先共享。"),
344
- h("div", { class: "row-fields" }, field("引擎", engine, e ? "建好后不能换" : null), field("模型", models.model), field("思考程度", models.effort)),
345
- field("提示词", prompt, "agent-loft 会在后面自动补上:这个专家能做什么、不能做什么,今天的日期,记忆"),
346
- baseField,
347
- field("权限", perms.el, "改文件包含读文件,跑命令包含改文件。什么都不勾就是只能聊天"),
348
- cwdField,
349
- field("我的技能", skills.el, "只影响你的工具选择;共享后其他账号单独选择自己的技能"),
350
- field("我的 MCP", mcpBox, "只使用你的 MCP;共享后不会把你的 MCP 或凭据交给其他账号"),
351
- subField,
352
- field("记忆", h("label", { class: "check-item" }, memory, h("span", {}, "使用聊天者自己的个人记忆(需在设置 → 记忆开启)"))),
353
- field("欢迎语", welcome),
354
- field("快捷提问", quick),
397
+ section(
398
+ "基本信息",
399
+ h("div", { class: "row-fields avatar-row" }, field("头像", avatar.el), field("名字", name)),
400
+ field("说明", desc),
401
+ field("共享", h("label", { class: "check-item" }, shared, h("span", {}, "共享给所有账号")), "其他账号可在网页、飞书私聊和定时任务中使用;只有你能修改设定。取消共享后,其他人的旧对话保留但不能继续调用。子智能体也需要先共享。"),
402
+ ),
403
+ section(
404
+ "模型和提示词",
405
+ h("div", { class: "row-fields" }, field("引擎", engine, e ? "建好后不能换" : null), field("模型", models.model), field("思考程度", models.effort)),
406
+ field("提示词", prompt, "agent-loft 会在后面自动补上:这个专家能做什么、不能做什么,今天的日期,记忆"),
407
+ baseField,
408
+ ),
409
+ section(
410
+ "权限和能力",
411
+ field("权限", perms.el, "改文件包含读文件,跑命令包含改文件。什么都不勾就是只能聊天"),
412
+ cwdField,
413
+ codexField,
414
+ ),
415
+ section(
416
+ "工具",
417
+ field("我的技能", skills.el, "只影响你的工具选择;共享后其他账号单独选择自己的技能"),
418
+ field("我的 MCP", mcpBox, "只使用你的 MCP;共享后不会把你的 MCP 或凭据交给其他账号"),
419
+ subField,
420
+ field("记忆", h("label", { class: "check-item" }, memory, h("span", {}, "使用聊天者自己的个人记忆(需在设置 → 记忆开启)"))),
421
+ ),
422
+ section("新对话页", field("欢迎语", welcome), field("快捷提问", quick)),
355
423
  );
356
424
  renderEngineParts();
357
425
  sync();
@@ -384,6 +452,7 @@ function openEditor(data, e, reload, preset) {
384
452
  skills: skills.value(),
385
453
  mcp: mcp.value(),
386
454
  subagents: engine.value === "claude" ? subs.value() : [],
455
+ codexTools: engine.value === "codex" ? codexTools.value() : [],
387
456
  memory: memory.checked,
388
457
  welcome: welcome.value,
389
458
  quickPrompts,
@@ -429,7 +498,7 @@ function permChecks(src) {
429
498
  return { p, el };
430
499
  });
431
500
  return Object.assign(api, {
432
- el: h("div", { class: "check-list perm-list" }, items.map((x) => x.el)),
501
+ el: h("div", { class: "check-list grid perm-list" }, items.map((x) => x.el)),
433
502
  // 藏起来的(Codex 的读网页)照旧按勾选状态存,和以前一样
434
503
  checked: (id) => boxes.get(id).checked,
435
504
  access: () => [...FILE_LEVELS].reverse().find((id) => boxes.get(id).checked) ?? "web",
@@ -8,6 +8,7 @@ import { addItem, openConversation, openLightbox, renderEmpty, scrollToBottom }
8
8
  import { renderScheduled } from "./schedule.js";
9
9
  import { renderTodos } from "./todos.js";
10
10
  import { cancelVoice, SpeechRec, toggleVoice } from "./voice.js";
11
+ import { callButton } from "./voice-call.js";
11
12
  import { closeSlashMenu, commandUsage, oneLine, slashKeydown, updateSlashMenu } from "./slash.js";
12
13
  import { doAction, openModelPicker, openSessions } from "./conv-actions.js";
13
14
 
@@ -103,6 +104,7 @@ export function renderComposer() {
103
104
  ui.ctxRing,
104
105
  ui.modelSlot,
105
106
  ui.micBtn,
107
+ callButton(),
106
108
  ui.sendBtn,
107
109
  ),
108
110
  );
@@ -612,7 +612,7 @@ function setQueueState(item, state) {
612
612
  function renderItem(item) {
613
613
  switch (item.type) {
614
614
  case "user": {
615
- const origin = item.origin && item.origin.channel !== "web" ? `来自${item.origin.name ?? item.origin.channel}` : "";
615
+ const origin = item.origin && item.origin.channel !== "web" && item.origin.channel !== "voice" ? `来自${item.origin.name ?? item.origin.channel}` : "";
616
616
  return h(
617
617
  "div",
618
618
  { class: "msg-user-group" },
@@ -10,6 +10,7 @@ import { openSchedule } from "./schedule.js";
10
10
  import { changeCwd, deleteConv, doAction, forkConversation, handoffConversation, openModelPicker, openPermissionPicker, renameConv, switchAgent } from "./conv-actions.js";
11
11
  import { capOfAccess, defaultPermissionFor, minPermission, permissionsUpTo, PERMISSIONS } from "../lib/permission.js";
12
12
  import { canSeeChanges, syncWorkspace, toggleWorkspace, workspaceButtons, workspaceStats } from "./workspace-entry.js";
13
+ import { syncCall } from "./voice-call.js";
13
14
 
14
15
  // ---------- 顶栏 ----------
15
16
 
@@ -398,6 +399,7 @@ export function renderContext() {
398
399
  agentEl,
399
400
  );
400
401
  updateCtxVisibility();
402
+ syncCall();
401
403
 
402
404
  // 直接显示实际的模型名和思考程度(和选择列表里一样的写法),不显示「默认模型」
403
405
  let model;