@songsid/agend 2.4.0-beta.10 → 2.4.0-beta.12
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/accounts-view.d.ts +29 -0
- package/dist/accounts-view.js +2 -14
- package/dist/accounts-view.js.map +1 -1
- package/dist/agent-endpoint.d.ts +1 -0
- package/dist/agent-endpoint.js +4 -2
- package/dist/agent-endpoint.js.map +1 -1
- package/dist/auth-api.d.ts +2 -0
- package/dist/auth-api.js +29 -2
- package/dist/auth-api.js.map +1 -1
- package/dist/backend/claude-code.js +35 -9
- package/dist/backend/claude-code.js.map +1 -1
- package/dist/backend/codex-precaution.d.ts +7 -0
- package/dist/backend/codex-precaution.js +102 -0
- package/dist/backend/codex-precaution.js.map +1 -0
- package/dist/backend/codex.d.ts +1 -0
- package/dist/backend/codex.js +18 -0
- package/dist/backend/codex.js.map +1 -1
- package/dist/backend/grok.js +21 -6
- package/dist/backend/grok.js.map +1 -1
- package/dist/backend/types.d.ts +9 -1
- package/dist/backend/types.js.map +1 -1
- package/dist/build-provenance.json +1 -1
- package/dist/channel/mcp-server.js +1 -1
- package/dist/channel/mcp-server.js.map +1 -1
- package/dist/channel/mcp-tools.js +3 -1
- package/dist/channel/mcp-tools.js.map +1 -1
- package/dist/claude-install-kind.d.ts +19 -0
- package/dist/claude-install-kind.js +54 -0
- package/dist/claude-install-kind.js.map +1 -0
- package/dist/cli-audited.js +3 -3
- package/dist/cli-audited.js.map +1 -1
- package/dist/daemon.d.ts +5 -0
- package/dist/daemon.js +22 -4
- package/dist/daemon.js.map +1 -1
- package/dist/event-log.d.ts +12 -0
- package/dist/event-log.js +40 -0
- package/dist/event-log.js.map +1 -1
- package/dist/fleet-manager.d.ts +122 -2
- package/dist/fleet-manager.js +482 -27
- package/dist/fleet-manager.js.map +1 -1
- package/dist/general-knowledge/skills/hub/SKILL.md +38 -6
- package/dist/general-knowledge/skills/web-dashboard/SKILL.md +16 -1
- package/dist/hub/admin-dashboard.js +3 -3
- package/dist/hub/admin-dashboard.js.map +1 -1
- package/dist/hub/agent-catalog-model.d.ts +276 -0
- package/dist/hub/agent-catalog-model.js +49 -0
- package/dist/hub/agent-catalog-model.js.map +1 -0
- package/dist/hub/agent-catalog.d.ts +137 -0
- package/dist/hub/agent-catalog.js +118 -0
- package/dist/hub/agent-catalog.js.map +1 -0
- package/dist/hub/agent-intro-model.d.ts +38 -0
- package/dist/hub/agent-intro-model.js +14 -0
- package/dist/hub/agent-intro-model.js.map +1 -0
- package/dist/hub/agent-intro-tool.d.ts +35 -0
- package/dist/hub/agent-intro-tool.js +83 -0
- package/dist/hub/agent-intro-tool.js.map +1 -0
- package/dist/hub/agent-intro.d.ts +31 -0
- package/dist/hub/agent-intro.js +51 -0
- package/dist/hub/agent-intro.js.map +1 -0
- package/dist/hub/catalog.d.ts +4 -2
- package/dist/hub/catalog.js +19 -3
- package/dist/hub/catalog.js.map +1 -1
- package/dist/hub/client.d.ts +3 -0
- package/dist/hub/client.js +47 -1
- package/dist/hub/client.js.map +1 -1
- package/dist/hub/compose/member.d.ts +19 -5
- package/dist/hub/compose/member.js +94 -13
- package/dist/hub/compose/member.js.map +1 -1
- package/dist/hub/compose/server.d.ts +5 -0
- package/dist/hub/compose/server.js +6 -1
- package/dist/hub/compose/server.js.map +1 -1
- package/dist/hub/execution/service.d.ts +1 -1
- package/dist/hub/execution/service.js +1 -0
- package/dist/hub/execution/service.js.map +1 -1
- package/dist/hub/http/compose.d.ts +3 -0
- package/dist/hub/http/compose.js +122 -15
- package/dist/hub/http/compose.js.map +1 -1
- package/dist/hub/http/schema.js +15 -0
- package/dist/hub/http/schema.js.map +1 -1
- package/dist/hub/mcp/tools.js +2 -1
- package/dist/hub/mcp/tools.js.map +1 -1
- package/dist/hub/member/agent-catalog.d.ts +28 -0
- package/dist/hub/member/agent-catalog.js +80 -0
- package/dist/hub/member/agent-catalog.js.map +1 -0
- package/dist/hub/member/agent-intro.d.ts +28 -0
- package/dist/hub/member/agent-intro.js +66 -0
- package/dist/hub/member/agent-intro.js.map +1 -0
- package/dist/hub/member/exposure-api.d.ts +3 -3
- package/dist/hub/member/exposure-api.js +4 -4
- package/dist/hub/member/exposure-api.js.map +1 -1
- package/dist/hub/member/exposures.d.ts +12 -4
- package/dist/hub/member/exposures.js +27 -13
- package/dist/hub/member/exposures.js.map +1 -1
- package/dist/hub/member/room-ask.d.ts +14 -1
- package/dist/hub/member/room-ask.js +76 -10
- package/dist/hub/member/room-ask.js.map +1 -1
- package/dist/hub/member/room-context-budget.d.ts +5 -0
- package/dist/hub/member/room-context-budget.js +34 -0
- package/dist/hub/member/room-context-budget.js.map +1 -0
- package/dist/hub/member/room-notification.d.ts +1 -1
- package/dist/hub/member/room-post.d.ts +6 -3
- package/dist/hub/member/room-post.js +9 -3
- package/dist/hub/member/room-post.js.map +1 -1
- package/dist/hub/member/sharing-journal.d.ts +252 -0
- package/dist/hub/member/sharing-journal.js +212 -0
- package/dist/hub/member/sharing-journal.js.map +1 -0
- package/dist/hub/member/sharing-link.d.ts +25 -0
- package/dist/hub/member/sharing-link.js +68 -0
- package/dist/hub/member/sharing-link.js.map +1 -0
- package/dist/hub/member/sharing-result.d.ts +6 -0
- package/dist/hub/member/sharing-result.js +46 -0
- package/dist/hub/member/sharing-result.js.map +1 -0
- package/dist/hub/member/sharing.d.ts +37 -0
- package/dist/hub/member/sharing.js +181 -0
- package/dist/hub/member/sharing.js.map +1 -0
- package/dist/hub/personal/owner-host.d.ts +6 -0
- package/dist/hub/personal/owner-host.js +4 -2
- package/dist/hub/personal/owner-host.js.map +1 -1
- package/dist/hub/protocol.d.ts +398 -4
- package/dist/hub/protocol.js +13 -5
- package/dist/hub/protocol.js.map +1 -1
- package/dist/hub/room-answer-status-model.d.ts +3 -0
- package/dist/hub/room-answer-status-model.js +4 -0
- package/dist/hub/room-answer-status-model.js.map +1 -0
- package/dist/hub/room-brief-model.d.ts +30 -0
- package/dist/hub/room-brief-model.js +37 -0
- package/dist/hub/room-brief-model.js.map +1 -0
- package/dist/hub/room-context-model.d.ts +2 -0
- package/dist/hub/room-context-model.js +2 -2
- package/dist/hub/room-context-model.js.map +1 -1
- package/dist/hub/room-members-model.d.ts +63 -0
- package/dist/hub/room-members-model.js +7 -0
- package/dist/hub/room-members-model.js.map +1 -0
- package/dist/hub/rooms/agents.d.ts +1 -0
- package/dist/hub/rooms/agents.js +62 -11
- package/dist/hub/rooms/agents.js.map +1 -1
- package/dist/hub/rooms/brief.d.ts +18 -0
- package/dist/hub/rooms/brief.js +39 -0
- package/dist/hub/rooms/brief.js.map +1 -0
- package/dist/hub/rooms/direct-view.d.ts +5 -1
- package/dist/hub/rooms/direct-view.js +2 -2
- package/dist/hub/rooms/direct-view.js.map +1 -1
- package/dist/hub/rooms/members-page.d.ts +33 -0
- package/dist/hub/rooms/members-page.js +37 -0
- package/dist/hub/rooms/members-page.js.map +1 -0
- package/dist/hub/rooms/purpose.d.ts +7 -0
- package/dist/hub/rooms/purpose.js +14 -0
- package/dist/hub/rooms/purpose.js.map +1 -0
- package/dist/hub/rooms/service.d.ts +43 -0
- package/dist/hub/rooms/service.js +80 -22
- package/dist/hub/rooms/service.js.map +1 -1
- package/dist/hub/rooms/types.d.ts +6 -1
- package/dist/hub/rooms.d.ts +1 -0
- package/dist/hub/rooms.js +9 -4
- package/dist/hub/rooms.js.map +1 -1
- package/dist/hub/runtime.d.ts +1 -1
- package/dist/hub/server.js +49 -1
- package/dist/hub/server.js.map +1 -1
- package/dist/hub/sharing-previous-access.d.ts +22 -0
- package/dist/hub/sharing-previous-access.js +93 -0
- package/dist/hub/sharing-previous-access.js.map +1 -0
- package/dist/hub/sharing-requests.d.ts +171 -0
- package/dist/hub/sharing-requests.js +311 -0
- package/dist/hub/sharing-requests.js.map +1 -0
- package/dist/hub/sharing-retention.d.ts +47 -0
- package/dist/hub/sharing-retention.js +83 -0
- package/dist/hub/sharing-retention.js.map +1 -0
- package/dist/hub/sharing-withdrawal.d.ts +14 -0
- package/dist/hub/sharing-withdrawal.js +28 -0
- package/dist/hub/sharing-withdrawal.js.map +1 -0
- package/dist/hub/types.d.ts +13 -5
- package/dist/hub-page-sharing-settings.d.ts +6 -0
- package/dist/hub-page-sharing-settings.js +19 -0
- package/dist/hub-page-sharing-settings.js.map +1 -0
- package/dist/hub-room-reply-warning.d.ts +2 -0
- package/dist/hub-room-reply-warning.js +16 -0
- package/dist/hub-room-reply-warning.js.map +1 -0
- package/dist/hub-sharing-notice.d.ts +43 -0
- package/dist/hub-sharing-notice.js +34 -0
- package/dist/hub-sharing-notice.js.map +1 -0
- package/dist/instance-lifecycle.d.ts +15 -0
- package/dist/instance-lifecycle.js +36 -1
- package/dist/instance-lifecycle.js.map +1 -1
- package/dist/locale.js +78 -0
- package/dist/locale.js.map +1 -1
- package/dist/login-controller.d.ts +26 -0
- package/dist/login-controller.js +72 -2
- package/dist/login-controller.js.map +1 -1
- package/dist/login-flows.js +1 -1
- package/dist/login-flows.js.map +1 -1
- package/dist/native-mcp.js +1 -1
- package/dist/native-mcp.js.map +1 -1
- package/dist/needs-you-hub.js +1 -1
- package/dist/needs-you-hub.js.map +1 -1
- package/dist/needs-you.d.ts +8 -1
- package/dist/needs-you.js +6 -0
- package/dist/needs-you.js.map +1 -1
- package/dist/office-share-page.js +1 -1
- package/dist/office-share-page.js.map +1 -1
- package/dist/outbound-handlers.d.ts +2 -1
- package/dist/outbound-handlers.js +17 -4
- package/dist/outbound-handlers.js.map +1 -1
- package/dist/outbound-schemas.d.ts +10 -0
- package/dist/outbound-schemas.js +3 -1
- package/dist/outbound-schemas.js.map +1 -1
- package/dist/public-web-gateway.js +9 -3
- package/dist/public-web-gateway.js.map +1 -1
- package/dist/remote-card-answer.d.ts +1 -1
- package/dist/remote-card-answer.js +8 -1
- package/dist/remote-card-answer.js.map +1 -1
- package/dist/remote-card-prompt.js +1 -1
- package/dist/remote-card-prompt.js.map +1 -1
- package/dist/restart-progress.d.ts +6 -0
- package/dist/restart-progress.js +5 -0
- package/dist/restart-progress.js.map +1 -1
- package/dist/settings-api.d.ts +1 -0
- package/dist/settings-api.js +84 -10
- package/dist/settings-api.js.map +1 -1
- package/dist/settings-baseline.d.ts +3 -0
- package/dist/settings-baseline.js +2 -2
- package/dist/settings-baseline.js.map +1 -1
- package/dist/settings-change.js +1 -0
- package/dist/settings-change.js.map +1 -1
- package/dist/settings-effect.d.ts +3 -0
- package/dist/settings-effect.js +33 -2
- package/dist/settings-effect.js.map +1 -1
- package/dist/tool-permissions.js +3 -3
- package/dist/tool-permissions.js.map +1 -1
- package/dist/ui/chat-quote.js +3 -261
- package/dist/ui/fleet-office-card.js +8 -4
- package/dist/ui/fleet-office-pack.d.ts +1 -0
- package/dist/ui/fleet-office-pack.js +6 -2
- package/dist/ui/fleet-office-play.js +84 -0
- package/dist/ui/fleet-office-store.js +23 -0
- package/dist/ui/fleet-office-zones.js +5 -1
- package/dist/ui/fleet-office.js +78 -8
- package/dist/ui/host-install.js +77 -3
- package/dist/ui/hub-agent-intro.js +35 -0
- package/dist/ui/hub-attachments.js +81 -3
- package/dist/ui/hub-chat-strings.js +4 -4
- package/dist/ui/hub-client.js +16 -1
- package/dist/ui/hub-grant-picker.js +25 -11
- package/dist/ui/hub-group-strings.js +3 -3
- package/dist/ui/hub-intro-notice.js +16 -0
- package/dist/ui/hub-my-agents-model.js +42 -0
- package/dist/ui/hub-my-agents-strings.js +18 -0
- package/dist/ui/hub-my-agents.js +144 -0
- package/dist/ui/hub-owner-strings.js +5 -5
- package/dist/ui/hub-personal-agent.js +5 -4
- package/dist/ui/hub-room-composer.js +37 -6
- package/dist/ui/hub-room-list.js +4 -3
- package/dist/ui/hub-room-members.js +5 -2
- package/dist/ui/hub-room-new.js +8 -5
- package/dist/ui/hub-room-purpose.js +19 -0
- package/dist/ui/hub-room-search.js +1 -1
- package/dist/ui/hub-room-settings.js +9 -0
- package/dist/ui/hub-room-strings.js +6 -4
- package/dist/ui/hub-room-thread.js +70 -17
- package/dist/ui/hub-strings.js +5 -5
- package/dist/ui/hub-welcome.js +6 -6
- package/dist/ui/notice-hub-sharing.js +81 -0
- package/dist/ui/panel-chat.js +19 -5
- package/dist/ui/panel-hub.js +77 -29
- package/dist/ui/panel-notices.js +2 -1
- package/dist/ui/settings-hub-connection.js +2 -2
- package/dist/ui/settings-hub-page-sharing.js +52 -0
- package/dist/ui/settings-hub.js +4 -2
- package/dist/ui/settings-registry.js +1 -0
- package/dist/ui/shared/app-i18n.js +2 -2
- package/dist/ui/shared/app-shell.js +14 -2
- package/dist/ui/shared/app-store.js +6 -2
- package/dist/ui/shared/app.js +3 -1
- package/dist/ui/shared/chat-msg-actions.js +3 -1
- package/dist/ui/shared/chat-quote.js +261 -0
- package/dist/ui/shared/hub-chat.css +31 -0
- package/dist/ui/shared/hub-my-agents.css +35 -0
- package/dist/ui/shared/hub-rooms-u2.css +5 -0
- package/dist/ui/shared/module-warm.d.ts +3 -0
- package/dist/ui/shared/module-warm.js +39 -0
- package/dist/web-api.d.ts +21 -5
- package/dist/web-api.js +138 -7
- package/dist/web-api.js.map +1 -1
- package/dist/web-asset-version.d.ts +65 -0
- package/dist/web-asset-version.js +259 -0
- package/dist/web-asset-version.js.map +1 -0
- package/dist/web-host-guard.js +3 -1
- package/dist/web-host-guard.js.map +1 -1
- package/dist/web-host-install.d.ts +30 -3
- package/dist/web-host-install.js +50 -4
- package/dist/web-host-install.js.map +1 -1
- package/dist/web-notices.d.ts +17 -0
- package/dist/web-notices.js +47 -6
- package/dist/web-notices.js.map +1 -1
- package/dist/web-terminal.d.ts +5 -0
- package/dist/web-terminal.js +11 -0
- package/dist/web-terminal.js.map +1 -1
- package/launcher/agend-install.cjs +48 -7
- package/package.json +1 -1
|
@@ -11,7 +11,7 @@ register("hubGrantPicker", {
|
|
|
11
11
|
failed: "The directory could not be searched just now. Try again.", unsupported: "This directory does not support that search.", limited: "Too many searches. Try again shortly.", retry: "Search again",
|
|
12
12
|
days: "Access lasts", day: "{0} days", expiry: "Choose up to 90 days. Access expires automatically; removing the grant also ends access to its chats.",
|
|
13
13
|
groupHint: "Direct members are checked again for every action. Nested and primary groups are not included. Whoever manages this AD group can change who may ask. Each person has a private chat.",
|
|
14
|
-
save: "Allow", cancel: "Cancel", refused: "The selected person or group changed or is no longer available. Search and choose again.", saveFailed: "Access could not be saved. Check the current agent and try again.",
|
|
14
|
+
saved: "Saved", save: "Allow", cancel: "Cancel", refused: "The selected person or group changed or is no longer available. Search and choose again.", saveFailed: "Access could not be saved. Check the current agent and try again.",
|
|
15
15
|
},
|
|
16
16
|
"zh-TW": {
|
|
17
17
|
title: "允許向 {0} 提問", kind: "允許對象", person: "個人", group: "AD 安全性群組", team: "團隊", teamPick: "選擇團隊", teamHint: "依團隊目前的成員允許提問;成員離開團隊後就不再適用這份權限,授權的到期時間照常計算。", findPerson: "尋找同仁", query: "姓名或登入帳號", hint: "請輸入 2 到 64 個字。",
|
|
@@ -19,7 +19,7 @@ register("hubGrantPicker", {
|
|
|
19
19
|
failed: "目前無法搜尋目錄,請再試一次。", unsupported: "這個目錄不支援這項搜尋。", limited: "搜尋太多次了,請稍後再試。", retry: "重新搜尋",
|
|
20
20
|
days: "允許多久", day: "{0} 天", expiry: "最長 90 天,到期自動失效;移除授權也會結束其聊天存取權。",
|
|
21
21
|
groupHint: "每次操作都會重新檢查直接成員,不含巢狀或主要群組。能管理這個 AD 群組的人,也能改變誰可以提問。每個人都有自己的私人對話。",
|
|
22
|
-
save: "允許提問", cancel: "取消", refused: "選取的同仁或群組已變更或無法使用,請重新搜尋選擇。", saveFailed: "無法儲存授權,請確認目前的 Agent 後再試。",
|
|
22
|
+
saved: "已儲存", save: "允許提問", cancel: "取消", refused: "選取的同仁或群組已變更或無法使用,請重新搜尋選擇。", saveFailed: "無法儲存授權,請確認目前的 Agent 後再試。",
|
|
23
23
|
},
|
|
24
24
|
});
|
|
25
25
|
const g = (key, ...args) => t(`hubGrantPicker.${key}`, ...args);
|
|
@@ -32,8 +32,10 @@ export function linkHubGrantPickerCss(doc = typeof document !== "undefined" ? do
|
|
|
32
32
|
doc.head.appendChild(link);
|
|
33
33
|
} catch { /* The form's existing controls still work if the stylesheet cannot be linked. */ }
|
|
34
34
|
}
|
|
35
|
-
export function HubGrantPicker({ x, client, act, onClose }) {
|
|
35
|
+
export function HubGrantPicker({ x, client, act, onClose, targets, grant, onResults, extra, legacy = false }) {
|
|
36
|
+
const [login, setLogin] = useState("");
|
|
36
37
|
const [kind, setKind] = useState("person"), [selected, setSelected] = useState(null), [days, setDays] = useState(7), [busy, setBusy] = useState(false), [error, setError] = useState(null), [unsupported, setUnsupported] = useState(false);
|
|
38
|
+
const [targetResults, setTargetResults] = useState({});
|
|
37
39
|
const life = useRef(0), writing = useRef(false), controllers = useRef(new Set());
|
|
38
40
|
const search = useMemo(() => async (kind, q) => {
|
|
39
41
|
const controller = new AbortController(); for (const old of controllers.current) old.abort(); controllers.current.add(controller);
|
|
@@ -49,22 +51,34 @@ export function HubGrantPicker({ x, client, act, onClose }) {
|
|
|
49
51
|
}, [client, x.id, x.revision]);
|
|
50
52
|
const change = () => { setSelected(null); setError(null); setUnsupported(false); };
|
|
51
53
|
const submit = async event => {
|
|
52
|
-
event?.preventDefault?.(); if (writing.current || !selected || client !== hubClient()) return;
|
|
54
|
+
event?.preventDefault?.(); if (writing.current || (legacy ? !login.trim() : !selected) || client !== hubClient()) return;
|
|
53
55
|
writing.current = true; setBusy(true); setError(null); const mine = life.current;
|
|
54
|
-
const subject = kind === "team" ? { kind: "team", teamId: selected.id } : kind === "group" ? { kind: "group", group: { realm: selected.realm, objectId: selected.objectId }, dn: selected.dn }
|
|
56
|
+
const subject = legacy ? null : kind === "team" ? { kind: "team", teamId: selected.id } : kind === "group" ? { kind: "group", group: { realm: selected.realm, objectId: selected.objectId }, dn: selected.dn }
|
|
55
57
|
: { kind: "person", person: { ...selected.person } };
|
|
56
|
-
const input = { exposureId: x.id, exposureRevision: x.revision, days, subject, ...(kind === "person" ? { login: selected.login } : {}) };
|
|
58
|
+
const input = { exposureId: x.id, exposureRevision: x.revision, days, ...(legacy ? { login: login.trim() } : { subject, ...(kind === "person" ? { login: selected.login } : {}) }) };
|
|
57
59
|
try {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
if (targets && grant) {
|
|
61
|
+
const results = {}; let failed = false;
|
|
62
|
+
for (const target of targets) {
|
|
63
|
+
if (mine !== life.current || client !== hubClient()) return;
|
|
64
|
+
const out = await grant({ ...input, exposureId: target.id, exposureRevision: target.revision });
|
|
65
|
+
results[target.id] = out?.ok ? g("saved") : g("saveFailed"); failed ||= !out?.ok;
|
|
66
|
+
}
|
|
67
|
+
if (mine === life.current && client === hubClient()) { setTargetResults(results); onResults?.(results); if (!failed) onClose(); else setError(g("saveFailed")); }
|
|
68
|
+
} else {
|
|
69
|
+
const out = await act(() => client.grant(input), undefined, () => { if (mine === life.current) setError(g("refused")); });
|
|
70
|
+
if (mine === life.current && client === hubClient()) { if (out?.ok) onClose(); else setError(g("refused")); }
|
|
71
|
+
}
|
|
60
72
|
} catch { if (mine === life.current) setError(g("saveFailed")); }
|
|
61
73
|
finally { if (mine === life.current) { writing.current = false; setBusy(false); } }
|
|
62
74
|
};
|
|
63
|
-
return html`<${Dialog} title=${g("title", x.displayName)} onClose=${onClose} actions=${html`<button type="button" class="btn" onClick=${onClose}>${g("cancel")}</button><button type="button" class="btn btn-primary" disabled=${busy || !selected} onClick=${submit}>${g("save")}</button>`}>
|
|
75
|
+
return html`<${Dialog} title=${g("title", x.displayName)} onClose=${onClose} actions=${html`<button type="button" class="btn" onClick=${onClose}>${g("cancel")}</button><button type="button" class="btn btn-primary" disabled=${busy || (legacy ? !login.trim() : !selected)} onClick=${submit}>${g("save")}</button>`}>
|
|
64
76
|
<form class="form hub-grant" data-grant-picker onSubmit=${submit}>
|
|
77
|
+
${extra || null}
|
|
78
|
+
${targets?.length > 1 ? html`<ul>${targets.map(target => html`<li>${target.displayName}${targetResults[target.id] ? ` · ${targetResults[target.id]}` : ""}</li>`)}</ul>` : null}
|
|
65
79
|
${error ? html`<p class="err" role="alert">${error}</p>` : null}
|
|
66
|
-
|
|
67
|
-
disabled=${busy} id="hubGrant" label=${g("kind")} onUnsupported=${() => setUnsupported(true)} onPick=${(type, row) => setSelected(type === "group" ? { ...row, realm: x.owner?.realm || "" } : row)}
|
|
80
|
+
${legacy ? html`<label class="field"><span>${g("query")}</span><input data-grant-login autocomplete="off" spellcheck=${false} disabled=${busy} value=${login} onInput=${e => setLogin(e.target.value)} /></label>` : html`<${SubjectPicker} client=${client} search=${search} kind=${kind} onKind=${next => { change(); setKind(next); }} selected=${selected} onClear=${change}
|
|
81
|
+
disabled=${busy} id="hubGrant" label=${g("kind")} onUnsupported=${() => setUnsupported(true)} onPick=${(type, row) => setSelected(type === "group" ? { ...row, realm: x.owner?.realm || "" } : row)} />`}
|
|
68
82
|
${unsupported ? html`<p class="err" role="status">${g("unsupported")}</p>` : null}
|
|
69
83
|
${kind === "group" ? html`<p class="note">${g("groupHint")}</p>` : null}
|
|
70
84
|
${kind === "team" ? html`<p class="note">${g("teamHint")}</p>` : null}
|
|
@@ -51,9 +51,9 @@ register("hubGroups", {
|
|
|
51
51
|
unknown: "The directory didn't answer, so this can't be checked right now.", retry: "Retry", ineligible: "Your directory account can't use this right now.",
|
|
52
52
|
deniedPerson: "Your Hub administrator has excluded your account from this.", suspended: "Paused by your Hub administrator.",
|
|
53
53
|
publishNot: "Sharing agents is not included in your access.",
|
|
54
|
-
// M-3190: the chat launcher's frame and
|
|
54
|
+
// M-3190: the chat launcher's frame and 我的 Agent → My fleets
|
|
55
55
|
readyBanner: "Your Hub is ready: create a pairing code to invite colleagues, or set up the room assistant →", readyGo: "Open Administration", readyDismiss: "Dismiss",
|
|
56
|
-
footFleets: "{0} fleets connected ({1})", listSep: ", ", footManage: "Manage in My
|
|
56
|
+
footFleets: "{0} fleets connected ({1})", listSep: ", ", footManage: "Manage in My agents →", footNone: "Want to share agents from your own AgEnD?", footConnect: "Connect a fleet in My agents →",
|
|
57
57
|
fleetsTitle: "My fleets", connectCount: "{0} of {1}", fleetMenu: "Fleet {0}", connectAnother: "+ Connect another fleet",
|
|
58
58
|
copy: "Copy", copied: "Copied", copyFailed: "Copy failed. Select the address and copy it.",
|
|
59
59
|
},
|
|
@@ -101,7 +101,7 @@ register("hubGroups", {
|
|
|
101
101
|
deniedPerson: "Hub 管理員已將你的帳號排除在外。", suspended: "已被 Hub 管理員暫停。",
|
|
102
102
|
publishNot: "你的存取權不包含分享 Agent。",
|
|
103
103
|
readyBanner: "Hub 已就緒:產生配對碼邀請同事加入,或設定房間助理 →", readyGo: "前往「管理」", readyDismiss: "關閉",
|
|
104
|
-
footFleets: "已連接 {0} 個 Fleet({1})", listSep: "、", footManage: "
|
|
104
|
+
footFleets: "已連接 {0} 個 Fleet({1})", listSep: "、", footManage: "前往「我的 Agent」管理 →", footNone: "要用自己的 AgEnD 分享 Agent?", footConnect: "前往「我的 Agent」連接 Fleet →",
|
|
105
105
|
fleetsTitle: "我的 Fleet", connectCount: "{0} / {1}", fleetMenu: "Fleet {0}", connectAnother: "+ 連接另一個 Fleet",
|
|
106
106
|
copy: "複製", copied: "已複製", copyFailed: "複製失敗。請選取位址再複製。",
|
|
107
107
|
},
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {html,useEffect,useRef,useState} from "/assets/app-html.js";
|
|
2
|
+
import {register,t} from "/assets/app-i18n.js";
|
|
3
|
+
register("hubIntroNotice",{
|
|
4
|
+
en:{title:"Agent introductions",body:"Introductions now show for {0} of your agents. Review them.",more:"Introductions now show for {0} more of your agents, from {1}. Review them.",fleet:"a Fleet",review:"Review {0}",ack:"Done",failed:"Could not load the introduction notice. Try again.",saveFailed:"Could not dismiss the notice. Try again.",retry:"Try again"},
|
|
5
|
+
"zh-TW":{title:"Agent 自我介紹",body:"你的 {0} 個 Agent 現在會顯示自我介紹,請檢查內容。",more:"你在 {1} 的 {0} 個 Agent 現在也會顯示自我介紹,請檢查內容。",fleet:"一個 Fleet",review:"檢查 {0}",ack:"完成",failed:"無法載入自我介紹通知,請再試一次。",saveFailed:"無法關閉通知,請再試一次。",retry:"再試一次"}
|
|
6
|
+
});
|
|
7
|
+
const word=(key,...args)=>t(`hubIntroNotice.${key}`,...args);
|
|
8
|
+
export const introNoticeOffered=(session,client)=>session?.features?.includes("agent-intro-defaults-v1")&&client?.agentIntroDefaultsV1===true;
|
|
9
|
+
export function IntroNotice({client}){
|
|
10
|
+
const [notice,setNotice]=useState(null),[failed,setFailed]=useState(false),[busy,setBusy]=useState(false),epoch=useRef(0);
|
|
11
|
+
const load=async()=>{const mine=epoch.current;try{const out=await client.introNotice();if(mine!==epoch.current)return;if(!out.ok){setFailed(true);return;}setNotice(out.notice);setFailed(false);}catch{if(mine===epoch.current)setFailed(true);}};
|
|
12
|
+
useEffect(()=>{epoch.current++;void load();return()=>{epoch.current++;};},[client]);
|
|
13
|
+
const ack=async()=>{if(busy)return;const mine=epoch.current;setBusy(true);try{const out=await client.acknowledgeIntroNotice();if(mine!==epoch.current)return;if(out.ok)setNotice(null);else setFailed(true);}catch{if(mine===epoch.current)setFailed(true);}finally{if(mine===epoch.current)setBusy(false);}};
|
|
14
|
+
if(!notice&&!failed)return null;
|
|
15
|
+
return html`<section class="card hub-intro-notice"><h3>${word("title")}</h3>${failed?html`<p class="err" role="alert">${word(notice?"saveFailed":"failed")}</p><button class="btn btn-sm" onClick=${load}>${word("retry")}</button>`:null}${notice?html`${notice.batches.map(batch=>html`<article key=${batch.fleetId}><p>${word(batch.more?"more":"body",batch.agents.length,batch.fleet||word("fleet"))}</p><ul>${batch.agents.map(agent=>html`<li key=${agent.id}><a class="btn btn-sm btn-ghost" href=${`/ui/hub/exposures?agent=${encodeURIComponent(agent.id)}`}>${word("review",agent.name)}</a></li>`)}</ul></article>`)}<button class="btn btn-sm" disabled=${busy} onClick=${ack}>${word("ack")}</button>`:null}</section>`;
|
|
16
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** Presentation only. A private local pointer or an accepted request is never publication authority. */
|
|
2
|
+
export function shareRows(fleet, mine) {
|
|
3
|
+
const seen = new Set();
|
|
4
|
+
const rows = (fleet.catalog?.agents || []).map(row => {
|
|
5
|
+
const exposure = row.exposure ? mine.find(x => x.id === row.exposure.id && x.fleetId === fleet.id) : null;
|
|
6
|
+
if (exposure) seen.add(exposure.id);
|
|
7
|
+
return { ...row, current: exposure, shared: !!exposure && exposure.state !== "withdrawn" };
|
|
8
|
+
});
|
|
9
|
+
for (const x of mine) if (x.fleetId === fleet.id && !seen.has(x.id)) rows.push({ instance: null, displayName: x.displayName, description: "", current: x, shared: x.state !== "withdrawn", shareable: false, reason: "old", general: false, kind: "agent" });
|
|
10
|
+
return rows.sort((a, b) => Number(a.general) - Number(b.general) || a.displayName.localeCompare(b.displayName));
|
|
11
|
+
}
|
|
12
|
+
export function rowAvailability(fleet, row, publish, sharedCount) {
|
|
13
|
+
if (!fleet.connected) return "offline";
|
|
14
|
+
if (!fleet.catalogSupported || !fleet.catalog?.requests) return "old";
|
|
15
|
+
if (!fleet.catalog.enabled) return "off";
|
|
16
|
+
if (!row.instance) return "old";
|
|
17
|
+
if (fleet.policyState === "suspended" || fleet.policyState === "revoked") return fleet.policyState;
|
|
18
|
+
if (fleet.policyState === "unknown") return "unknown";
|
|
19
|
+
if (row.shared) return null;
|
|
20
|
+
if (publish?.state !== "allow") return publish?.state === "deny" ? "denied" : "unknown";
|
|
21
|
+
if (!row.shareable) return row.reason === "remote-windows" ? "remote" : "unavailable";
|
|
22
|
+
return sharedCount >= 64 ? "limit" : null;
|
|
23
|
+
}
|
|
24
|
+
export const rowKey = (fleet, row) => `${fleet.id}:${row.instance || row.current?.id}`;
|
|
25
|
+
export function reconcileSharing(operation, fleets, mine, now = Date.now()) {
|
|
26
|
+
const fleet = fleets.find(f => f.id === operation.input.fleetId), results = operation.response?.result?.results || [];
|
|
27
|
+
const rows = operation.rows.map(row => {
|
|
28
|
+
const share = !!row.instance, result = results.find(r => share ? r.instance === row.instance : r.exposureId === row.id);
|
|
29
|
+
const local = fleet?.catalog?.agents.find(a => share ? a.instance === row.instance : a.exposure?.id === row.id);
|
|
30
|
+
const pointer = result?.ok ? result.after : local?.exposure;
|
|
31
|
+
const current = mine.find(x => x.id === (share ? pointer?.id : row.id) && x.fleetId === operation.input.fleetId);
|
|
32
|
+
const changed = pointer && pointer.revision > (row.before?.revision || 0);
|
|
33
|
+
const done = share ? changed && current?.revision >= pointer.revision && ["published", "paused"].includes(current.state)
|
|
34
|
+
: !current && changed && pointer.state === "withdrawn";
|
|
35
|
+
if (done) return { ...row, state: "done", current: share ? current : null };
|
|
36
|
+
if (result?.ok === false) return { ...row, state: "refused", code: result.code };
|
|
37
|
+
const expired = ["expired", "revoked"].includes(operation.response?.state);
|
|
38
|
+
if (expired && fleet?.catalog?.at > operation.at && (share ? !current : current?.revision === row.before?.revision)) return { ...row, state: "closed" };
|
|
39
|
+
return { ...row, state: now - operation.at >= 30_000 ? "uncertain" : "pending" };
|
|
40
|
+
});
|
|
41
|
+
return { rows, settled: rows.every(r => ["done", "refused", "closed"].includes(r.state)) };
|
|
42
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { register, t } from "/assets/app-i18n.js";
|
|
2
|
+
register("hubMyAgents", {
|
|
3
|
+
en: {
|
|
4
|
+
offlineShort:"Offline · last seen {0}", knownShared:"{0} shared", oldCountOne:"1 Fleet needs an update to share agents from here.", oldCount:"{0} Fleets need an update to share agents from here.", namesMore:"{0} and {1} more", lead:"The agents you can share on this Hub, and who may ask each one.", refresh:"Refresh", refreshing:"Checking…", fleet:"Fleet", connected:"Connected", offline:"This Fleet is offline. Shown as last seen at {0}.", count:"{0} of {1} shared", select:"Select all", general:"Your Fleet's General. It can manage this Fleet.", classic:"ClassicBot room", classicHint:"Hub questions and answers are not posted in its Discord or Telegram room, and the room's chat is not copied to the Hub. It is one agent with one memory: it may use what it learned in the room when it answers here.",
|
|
5
|
+
old:"Update this Fleet to share agents from here.", update:"Update this Fleet", updateHint:"On that computer, open Settings → Hub and check its connection and version.", off:"Sharing from the Hub page is turned off in this Fleet's Settings → Hub.", denied:"Your Hub administrator hasn't allowed you to share agents.", unknown:"The Hub could not check whether sharing is allowed. Refresh to check.", remote:"This kind of agent can't answer Hub questions yet.", unavailable:"This agent cannot answer Hub questions right now.", limit:"This Fleet already shares 64 agents, the most allowed.", suspended:"This Fleet is paused on this Hub.", revoked:"This Fleet was removed from this Hub.",
|
|
6
|
+
shared:"Shared", nobody:"nobody may ask yet", peopleOne:"1 person may ask", people:"{0} people may ask", subjects:"{0} people, groups or teams may ask", paused:"Paused", sharing:"Sharing…", stopping:"Stopping…", uncertain:"Not confirmed yet: this Fleet hasn't answered. Refresh to check.", refused:"Not shared: {0}", changed:"This list changed. It has been refreshed; tick again.",
|
|
7
|
+
shareOne:"Share 1 agent", stopOne:"Stop sharing 1 agent", stopTitleOne:"Stop sharing 1 agent?", accessTitleOne:"1 agent is shared. Who may ask it?", share:"Share {0} agents", stop:"Stop sharing {0} agents", mixed:"Share {0} · Stop sharing {1}", apply:"Apply changes", cancel:"Cancel", stopTitle:"Stop sharing {0} agents?", stopBody:"People will no longer be able to ask: {0}. Their lists of who may ask are cleared.", stopHint:"To keep the lists and only stop answers for now, pause sharing instead.", stopGo:"Stop sharing", pause:"Pause instead", pauseOne:"Pause sharing", later:"Decide later", accessTitle:"{0} agents are shared. Who may ask them?", accessLead:"Nobody can ask them until you choose.", same:"The same people for all {0}", each:"Choose for each agent", choose:"Choose who may ask", previousMixed:"Use the list it had before", previous:"Use the list it had before ({0} people)", used:"The previous list is saved.", saved:"Saved", saveFailed:"Could not save access for {0}. Check the current agent and try again.", personal:"On my own computer", details:"Open {0}",
|
|
8
|
+
empty:"You don't have an agent on this Hub yet.", already:"You can already ask other people's agents: open Chats, or @mention an agent in a room.", emptyLead:"To have an agent of your own that colleagues can ask:", personalOff:"Personal agents are turned off on this Hub. Ask your Hub administrator.", fleetLead:"If you run AgEnD, share the agents in it.", connectDenied:"Ask your Hub administrator to let you connect a Fleet.", apps:"Your own Claude Code or Codex can also use this Hub for you. That is for asking and posting as you. Colleagues can't ask it.", appsLink:"My AI apps", failed:"The list could not be read. Refresh to try again.",
|
|
9
|
+
},
|
|
10
|
+
"zh-TW": {
|
|
11
|
+
offlineShort:"離線 · 最後上線 {0}", knownShared:"已分享 {0}", oldCountOne:"有 1 個 Fleet 需要更新,才能從這裡分享 Agent。", oldCount:"有 {0} 個 Fleet 需要更新,才能從這裡分享 Agent。", namesMore:"{0} 等 {1} 個", lead:"可以分享到這個 Hub 的 Agent,以及誰可以向它們提問。", refresh:"重新整理", refreshing:"確認中…", fleet:"Fleet", connected:"已連接", offline:"這個 Fleet 目前離線,顯示的是 {0} 的狀態。", count:"已分享 {0} / {1}", select:"全選", general:"你的 Fleet 的 General,可以管理這個 Fleet。", classic:"ClassicBot 房間", classicHint:"Hub 的提問與回答不會貼到它的 Discord 或 Telegram 房間,房間的聊天也不會複製到 Hub。但它是同一個 Agent、同一份記憶:在這裡回答時,可能用到它在房間裡得知的內容。",
|
|
12
|
+
old:"請更新這個 Fleet,才能從這裡分享 Agent。", update:"更新這個 Fleet", updateHint:"請到那台電腦的「設定 → Hub」,確認連接狀態與版本。", off:"這個 Fleet 的「設定 → Hub」關閉了從 Hub 頁面分享。", denied:"Hub 管理員還沒有允許你分享 Agent。", unknown:"Hub 目前無法確認是否允許分享,請重新整理確認。", remote:"這種 Agent 還不能回答 Hub 的提問。", unavailable:"這個 Agent 目前無法回答 Hub 的提問。", limit:"這個 Fleet 已經分享 64 個 Agent,達到上限。", suspended:"這個 Fleet 在這個 Hub 已暫停。", revoked:"這個 Fleet 已從這個 Hub 移除。",
|
|
13
|
+
shared:"分享中", nobody:"還沒有人可以問", peopleOne:"1 人可以提問", people:"{0} 人可以提問", subjects:"{0} 個人員、群組或團隊可以提問", paused:"已暫停", sharing:"分享中…", stopping:"停止中…", uncertain:"還沒有確認:這個 Fleet 尚未回應,請重新整理確認。", refused:"沒有分享:{0}", changed:"清單已有變動並重新整理,請重新勾選。",
|
|
14
|
+
shareOne:"分享 1 個 Agent", stopOne:"停止分享 1 個 Agent", stopTitleOne:"要停止分享 1 個 Agent 嗎?", accessTitleOne:"已分享 1 個 Agent。誰可以問它?", share:"分享 {0} 個 Agent", stop:"停止分享 {0} 個 Agent", mixed:"分享 {0} 個 · 停止分享 {1} 個", apply:"套用變更", cancel:"取消", stopTitle:"要停止分享 {0} 個 Agent 嗎?", stopBody:"同仁將無法再問:{0}。這些 Agent 的「可以提問的人」名單會被清除。", stopHint:"如果只是暫時不回答、想保留名單,請改用「暫停分享」。", stopGo:"停止分享", pause:"改為暫停", pauseOne:"暫停分享", later:"稍後再決定", accessTitle:"已分享 {0} 個 Agent。誰可以問它們?", accessLead:"在你選擇之前,沒有人可以問它們。", same:"{0} 個都用同一份名單", each:"每個 Agent 分開選", choose:"選擇誰可以提問", previousMixed:"沿用之前的名單", previous:"沿用之前的名單({0} 人)", used:"已儲存之前的名單。", saved:"已儲存", saveFailed:"無法儲存 {0} 的提問權限,請確認目前的 Agent 後再試。", personal:"在我的電腦上", details:"開啟 {0}",
|
|
15
|
+
empty:"你在這個 Hub 還沒有自己的 Agent。", already:"你現在就可以問別人的 Agent:到「對話」,或在房間裡 @ 一個 Agent。", emptyLead:"想要有自己的 Agent 讓同仁提問:", personalOff:"這個 Hub 還沒有開啟個人 Agent,請洽 Hub 管理員。", fleetLead:"如果你有在使用 AgEnD,可以分享裡面的 Agent。", connectDenied:"請 Hub 管理員允許你連接 Fleet。", apps:"你自己的 Claude Code 或 Codex 也可以替你使用這個 Hub,用來提問和發言;同仁不能問它。", appsLink:"我的 AI App", failed:"無法讀取清單,請重新整理再試。",
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
export const ms = (key, ...args) => t(`hubMyAgents.${key}`, ...args);
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { AgentIntroSharingPreview } from "./hub-agent-intro.js";
|
|
2
|
+
/** Owner-only inventory. Saved requests survive page refresh; Fleet snapshots decide the result. */
|
|
3
|
+
import { lang } from "/assets/app-i18n.js";
|
|
4
|
+
import { html, useEffect, useRef, useState } from "/assets/app-html.js";
|
|
5
|
+
import { Dialog } from "/assets/ui-dialog.js";
|
|
6
|
+
import { ms } from "./hub-my-agents-strings.js";
|
|
7
|
+
import { rowAvailability, rowKey, shareRows, reconcileSharing } from "./hub-my-agents-model.js";
|
|
8
|
+
import { HubGrantPicker } from "./hub-grant-picker.js";
|
|
9
|
+
const tone = name => { let h = 0; for (const c of name) h = (h * 31 + c.codePointAt(0)) >>> 0; return h % 6; };
|
|
10
|
+
const shortSeen = at => Number.isFinite(at) ? new Intl.DateTimeFormat(lang() === "zh-TW" ? "zh-TW" : "en-GB", { month: "short", day: "numeric", hour: "2-digit", minute: "2-digit", hourCycle: "h23" }).format(at) : "—";
|
|
11
|
+
const Avatar = ({ name }) => html`<span class=${`hub-av sm t${tone(name)}`} aria-hidden="true">${[...name][0] || "?"}</span>`;
|
|
12
|
+
const mc = (key, n) => ms(n === 1 ? `${key}One` : key, n);
|
|
13
|
+
const STORE = "agend.hub.owner-sharing";
|
|
14
|
+
const safeRead = scope => { try { const v = JSON.parse(sessionStorage.getItem(STORE)); return v?.scope === scope && Array.isArray(v.operations) ? v.operations.filter(op => op && typeof op.at === "number" && Array.isArray(op.rows) && op.input && typeof op.input.idempotencyKey === "string" && typeof op.input.fleetId === "string" && Array.isArray(op.input.share) && Array.isArray(op.input.stop)).slice(-32) : []; } catch { return []; } };
|
|
15
|
+
function css() {
|
|
16
|
+
if (document.querySelector('link[data-hub-my-agents-css]')) return;
|
|
17
|
+
const link = document.createElement("link"); link.rel = "stylesheet"; link.href = "/assets/hub-my-agents.css"; link.setAttribute("data-hub-my-agents-css", "1"); document.head.appendChild(link);
|
|
18
|
+
}
|
|
19
|
+
const summary = x => !x?.grants?.length ? ms("nobody") : x.grants.some(g => g.subject?.kind !== "person") ? ms("subjects", x.grants.length) : mc("people", x.grants.length);
|
|
20
|
+
export function HubMyAgents({ client, scope, shared = [], policy = false, personal = false, apps = false, pausable = false, subjects = false, onChanged, onAllow }) {
|
|
21
|
+
const [data, setData] = useState(null), [mine, setMine] = useState(shared), [publish, setPublish] = useState(policy ? { state: "unknown" } : { state: "allow" });
|
|
22
|
+
const [draft, setDraft] = useState({}), [operations, setOperations] = useState(() => safeRead(scope)), [busy, setBusy] = useState(false), [error, setError] = useState(null), [confirm, setConfirm] = useState(false), [access, setAccess] = useState([]), [help, setHelp] = useState(false);
|
|
23
|
+
const life = useRef(0), writing = useRef(false), currentOps = useRef(operations), changed = useRef(onChanged), welcomed = useRef(null);
|
|
24
|
+
currentOps.current = operations; changed.current = onChanged;
|
|
25
|
+
const live = generation => generation === life.current;
|
|
26
|
+
const load = async generation => {
|
|
27
|
+
const [catalog, accepted, welcome] = await Promise.all([client.ownAgents(scope), client.catalog(), policy ? client.welcome() : Promise.resolve(null)]);
|
|
28
|
+
if (!live(generation)) return;
|
|
29
|
+
if (catalog.ok) setData(catalog); else setError(ms("failed"));
|
|
30
|
+
if (accepted.ok) setMine(accepted.mine || []);
|
|
31
|
+
if (policy) { welcomed.current = welcome?.ok ? welcome : null; setPublish(welcome?.ok ? welcome.publish : { state: "unknown" }); }
|
|
32
|
+
if (catalog.ok) setError(null);
|
|
33
|
+
};
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
css(); const generation = life.current; void load(generation);
|
|
36
|
+
const off = client.onSignedOut?.(() => { life.current++; setOperations([]); setDraft({}); setAccess([]); try { sessionStorage.removeItem(STORE); } catch { /* unavailable storage */ } });
|
|
37
|
+
return () => { life.current++; off?.(); };
|
|
38
|
+
}, [client, scope]);
|
|
39
|
+
useEffect(() => { try { sessionStorage.setItem(STORE, JSON.stringify({ scope, operations })); } catch { /* The in-memory frozen intent remains recoverable until this page closes. */ } }, [scope, operations]);
|
|
40
|
+
const fleets = (data?.fleets || []).map(f => ({ ...f, policyState: welcomed.current?.connect?.fleets?.find(x => x.id === f.id)?.status }));
|
|
41
|
+
const plans = fleets.map(f => ({ fleet: f, rows: shareRows(f, mine) }));
|
|
42
|
+
const pending = operations.flatMap(op => reconcileSharing(op, fleets, mine).rows.map(row => ({ ...row, op })));
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (!data) return;
|
|
45
|
+
const done = [], keep = [];
|
|
46
|
+
for (const op of currentOps.current) {
|
|
47
|
+
const outcome = reconcileSharing(op, fleets, mine);
|
|
48
|
+
for (const row of outcome.rows) if (row.state === "done" && row.instance && row.current && !op.offered?.includes(row.current.id)) done.push(row.current);
|
|
49
|
+
const offered = [...new Set([...(op.offered || []), ...done.map(x => x.id)])];
|
|
50
|
+
keep.push({ ...op, offered });
|
|
51
|
+
}
|
|
52
|
+
if (done.length) { setAccess(old => [...new Map([...old, ...done].map(x => [x.id, x])).values()]); setOperations(keep); changed.current?.(); }
|
|
53
|
+
}, [data, mine, operations]);
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
const generation = life.current;
|
|
56
|
+
const unresolved = currentOps.current.filter(op => !reconcileSharing(op, fleets, mine).settled && Date.now() - op.at < 610_000);
|
|
57
|
+
if (!unresolved.length) return;
|
|
58
|
+
const timer = setTimeout(async () => {
|
|
59
|
+
const next = await Promise.all(currentOps.current.map(async op => {
|
|
60
|
+
if (reconcileSharing(op, fleets, mine).settled) return op;
|
|
61
|
+
const r = await client.agentSharingRequest(scope, op.input.idempotencyKey);
|
|
62
|
+
return r.ok ? { ...op, response: r } : op;
|
|
63
|
+
}));
|
|
64
|
+
if (!live(generation)) return; setOperations(next); await load(generation);
|
|
65
|
+
}, 3_000);
|
|
66
|
+
return () => clearTimeout(timer);
|
|
67
|
+
}, [operations, data, mine]);
|
|
68
|
+
const persist = next => { currentOps.current = next; try { sessionStorage.setItem(STORE, JSON.stringify({ scope, operations: next })); } catch { /* preserve in memory */ } setOperations(next); };
|
|
69
|
+
const send = async (op, generation) => {
|
|
70
|
+
const r = await client.requestAgentSharing(scope, op.input);
|
|
71
|
+
if (!live(generation)) return;
|
|
72
|
+
const definite = r.status >= 400 && r.status < 500 && r.status !== 408;
|
|
73
|
+
const response = r.ok ? r : definite ? { state: "complete", result: { results: op.rows.map(row => ({ ...(row.instance ? { instance: row.instance } : { exposureId: row.id }), ok: false, code: r.code === "conflict" ? "stale-list" : r.code === "denied" ? "not-allowed" : "unavailable" })) } } : op.response;
|
|
74
|
+
persist(currentOps.current.map(x => x.input.idempotencyKey === op.input.idempotencyKey ? { ...x, response } : x));
|
|
75
|
+
};
|
|
76
|
+
const refresh = async () => {
|
|
77
|
+
if (writing.current) return; writing.current = true; setBusy(true); const generation = life.current;
|
|
78
|
+
try {
|
|
79
|
+
for (const op of currentOps.current) if (!reconcileSharing(op, fleets, mine).settled) await send(op, generation);
|
|
80
|
+
await Promise.all(fleets.filter(f => f.connected && f.catalogSupported).map(f => client.refreshOwnAgents(scope, f.id)));
|
|
81
|
+
await load(generation);
|
|
82
|
+
// The request returning is not the report. A bounded follow-up read lets a fresh report land.
|
|
83
|
+
setTimeout(() => { if (live(generation)) void load(generation); }, 1_000);
|
|
84
|
+
} finally { if (live(generation)) { writing.current = false; setBusy(false); } }
|
|
85
|
+
};
|
|
86
|
+
const changes = plans.flatMap(({ fleet, rows }) => rows.filter(row => Object.hasOwn(draft, rowKey(fleet, row)) && draft[rowKey(fleet, row)] !== row.shared).map(row => ({ ...row, fleet })));
|
|
87
|
+
const shares = changes.filter(r => !r.shared), stops = changes.filter(r => r.shared);
|
|
88
|
+
const apply = async () => {
|
|
89
|
+
if (writing.current) return; writing.current = true; setBusy(true); setConfirm(false); const generation = life.current;
|
|
90
|
+
try {
|
|
91
|
+
const next = plans.flatMap(({ fleet }) => {
|
|
92
|
+
const rows = changes.filter(r => r.fleet.id === fleet.id); if (!rows.length) return [];
|
|
93
|
+
return [{ input: { idempotencyKey: crypto.randomUUID(), fleetId: fleet.id, catalogRevision: fleet.catalog.revision, share: rows.filter(r => !r.shared).map(r => r.instance), stop: rows.filter(r => r.shared).map(r => r.current.id) }, at: Date.now(), rows: rows.map(r => ({ ...(r.shared ? { id: r.current.id } : { instance: r.instance }), name: r.displayName, before: r.current ? { id: r.current.id, revision: r.current.revision } : r.exposure || null })), response: null }];
|
|
94
|
+
});
|
|
95
|
+
persist([...currentOps.current.slice(-24), ...next]); setDraft({});
|
|
96
|
+
for (const op of next) { if (!live(generation)) return; await send(op, generation); }
|
|
97
|
+
await load(generation);
|
|
98
|
+
} finally { if (live(generation)) { writing.current = false; setBusy(false); } }
|
|
99
|
+
};
|
|
100
|
+
const pause = async targets => {
|
|
101
|
+
if (writing.current) return; writing.current = true; setBusy(true); setConfirm(false); const generation = life.current;
|
|
102
|
+
try { for (const row of targets) { const x = row.current; if (!live(generation)) return; const r = await client.ownerSharing(scope, x.id, x.revision, x.sharingEpoch || 0, true); if (!r.ok && live(generation)) setError(ms("saveFailed", x.displayName)); }
|
|
103
|
+
if (live(generation)) { setDraft(old => { const next = { ...old }; for (const row of targets) delete next[rowKey(row.fleet, row)]; return next; }); await load(generation); changed.current?.(); }
|
|
104
|
+
} finally { if (live(generation)) { writing.current = false; setBusy(false); } }
|
|
105
|
+
};
|
|
106
|
+
return html`<div class="hub-my-agents" data-my-agents><div class="field-row"><button class="btn btn-sm" disabled=${busy} onClick=${refresh}>${ms(busy ? "refreshing" : "refresh")}</button></div>
|
|
107
|
+
${fleets.filter(f => f.connected && (!f.catalogSupported || f.catalog?.requests !== true)).length ? html`<p class="note hub-banner warn" role="status">${mc("oldCount", fleets.filter(f => f.connected && (!f.catalogSupported || f.catalog?.requests !== true)).length)}</p>` : null}
|
|
108
|
+
${error ? html`<p class="err" role="alert">${error}</p>` : null}
|
|
109
|
+
${publish.state === "deny" ? html`<p class="note" role="status">${ms("denied")}</p>` : null}
|
|
110
|
+
${plans.map(({ fleet, rows }) => { const count = rows.filter(r => r.shared).length, waiting = pending.filter(r => r.op.input.fleetId === fleet.id && ["pending", "uncertain"].includes(r.state));
|
|
111
|
+
return html`<details class="card hub-agent-fleet" open key=${fleet.id}><summary><strong>${fleet.label || ms("fleet")}</strong><span class="note">${fleet.connected ? ms("connected") : ms("offlineShort", shortSeen(fleet.catalog?.at))} · ${!fleet.catalog || !fleet.catalog.requests || fleet.connected && !fleet.catalogSupported ? ms("knownShared", count) : ms("count", count, rows.length)}</span></summary>
|
|
112
|
+
${fleet.connected && (!fleet.catalogSupported || !fleet.catalog?.requests) ? html`<p class="note">${ms("old")} <button type="button" class="btn btn-sm" onClick=${() => setHelp(true)}>${ms("update")}</button></p>` : null}
|
|
113
|
+
${fleet.catalog?.enabled === false ? html`<p class="note">${ms("off")}</p>` : null}
|
|
114
|
+
<div class="field-row"><button type="button" class="btn btn-sm" data-share-all disabled=${busy || !!waiting.length || !rows.some(r => !r.general && !r.shared && !rowAvailability(fleet, r, publish, count))} onClick=${() => setDraft(old => { const next = { ...old }; let n = count; for (const row of rows) if (!row.general && !row.shared && !rowAvailability(fleet, row, publish, n)) { next[rowKey(fleet, row)] = true; n++; } return next; })}>${ms("select")}</button></div>
|
|
115
|
+
<div class="hub-rows">${rows.map(row => { const key = rowKey(fleet, row), status = [...pending].reverse().find(r => r.op.input.fleetId === fleet.id && (row.instance ? r.instance === row.instance : r.id === row.current?.id) && ["pending", "uncertain", "refused"].includes(r.state));
|
|
116
|
+
const reason = rowAvailability(fleet, row, publish, count), tick = ["pending", "uncertain"].includes(status?.state) ? !!status.instance : Object.hasOwn(draft, key) ? draft[key] : row.shared;
|
|
117
|
+
return html`<div class="hub-agent-choice" data-unavailable=${reason ? true : undefined} key=${key}><div class="s-row hub-row"><label class="hub-agent-tick"><input type="checkbox" data-share-agent=${row.instance || row.current?.id} aria-label=${row.displayName} checked=${tick} disabled=${busy || !!reason || !!waiting.length} onChange=${e => { const checked = e.target.checked; setDraft(old => ({ ...old, [key]: checked })); }} /></label><${Avatar} name=${row.displayName} size="sm" />
|
|
118
|
+
<span class="hub-row-text">${row.current ? html`<a href=${`/ui/hub/exposures?agent=${encodeURIComponent(row.current.id)}`} aria-label=${ms("details", row.displayName)}><strong>${row.displayName}</strong></a>` : html`<strong>${row.displayName}</strong>`}
|
|
119
|
+
${row.kind === "classic-room" ? html`<small class="tag">${ms("classic")}</small>` : null}<small class="note">${reason && reason !== "offline" ? ms(reason) : row.general ? ms("general") : row.description}</small>
|
|
120
|
+
${row.current?.intro ? html`<small class="note">${row.current.intro}</small>` : null}
|
|
121
|
+
${row.shared ? html`<small class="note">${ms(row.current.state !== "published" ? "paused" : "shared")} · ${summary(row.current)}</small>` : null}
|
|
122
|
+
${status ? html`<small class=${status.state === "refused" ? "err" : "note"} role="status">${status.state === "uncertain" ? ms("uncertain") : status.state === "refused" ? status.code === "stale-list" ? ms("changed") : ms("refused", ms(({ "not-allowed": "denied", "switched-off": "off", "limit": "limit", "not-shareable": "unavailable" })[status.code] || "unavailable")) : ms(status.instance ? "sharing" : "stopping")}</small>` : null}</span>
|
|
123
|
+
${pausable && row.shared && row.current.state === "published" && typeof client.ownerSharing === "function" ? html`<button type="button" class="btn btn-sm hub-agent-pause" disabled=${busy} onClick=${() => pause([{ ...row, fleet }])}>${ms("pauseOne")}</button>` : null}</div>
|
|
124
|
+
${row.kind === "classic-room" && tick && !row.shared ? html`<p class="note hub-classic-disclosure">${ms("classicHint")}</p>` : null}</div>`; })}</div></details>`;
|
|
125
|
+
})}
|
|
126
|
+
${mine.some(x => x.kind === "personal") ? html`<section class="card"><h3>${ms("personal")}</h3>${mine.filter(x => x.kind === "personal").map(x => html`<a class="s-row hub-row" href=${`/ui/hub/exposures?agent=${encodeURIComponent(x.id)}`}><span class="hub-row-text"><strong>${x.displayName}</strong><small class="note">${summary(x)}</small></span></a>`)}</section>` : null}
|
|
127
|
+
${data && !plans.length && !mine.some(x => x.kind === "personal") ? html`<section class="card"><h3>${ms("empty")}</h3><p>${ms("already")}</p><p>${ms("emptyLead")}</p>${personal ? null : html`<p class="note">${ms("personalOff")}</p>`}<p class="note">${welcomed.current?.connect?.state === "allow" ? ms("fleetLead") : ms("connectDenied")}</p>${apps ? html`<p>${ms("apps")} <a href="/ui/hub/ai-apps">${ms("appsLink")}</a></p>` : null}</section>` : null}
|
|
128
|
+
${changes.length ? html`<div class="hub-share-bar" role="region" aria-label=${ms("apply")}><strong>${changes.length === 1 ? changes[0].displayName : ms("namesMore", changes[0].displayName, lang() === "zh-TW" ? changes.length : changes.length - 1)}</strong><button class=${`btn ${stops.length ? "btn-danger" : "btn-primary"}`} disabled=${busy || plans.some(p => changes.filter(r => r.fleet.id === p.fleet.id).length > 64)} onClick=${() => stops.length ? setConfirm(true) : apply()}>${shares.length && stops.length ? ms("apply") : mc(shares.length ? "share" : "stop", changes.length)}</button><button class="btn" disabled=${busy} onClick=${() => setDraft({})}>${ms("cancel")}</button></div>` : null}
|
|
129
|
+
${confirm ? html`<${Dialog} title=${mc("stopTitle", stops.length)} onClose=${() => setConfirm(false)} actions=${html`<button class="btn" onClick=${() => setConfirm(false)}>${ms("cancel")}</button><button class="btn" onClick=${() => pause(stops)}>${ms("pause")}</button><button class="btn btn-danger" onClick=${apply}>${ms("stopGo")}</button>`}><p>${ms("stopBody", stops.map(r => r.displayName).join(", "))}</p><p class="note">${ms("stopHint")}</p></${Dialog}>` : null}
|
|
130
|
+
${help ? html`<${Dialog} title=${ms("update")} onClose=${() => setHelp(false)}><p>${ms("updateHint")}</p></${Dialog}>` : null}
|
|
131
|
+
${access.length ? html`<${SharingAccess} targets=${access} client=${client} scope=${scope} subjects=${subjects} onAllow=${onAllow} onClose=${() => { setAccess([]); void load(life.current); changed.current?.(); }} />` : null}
|
|
132
|
+
</div>`;
|
|
133
|
+
}
|
|
134
|
+
function SharingAccess({ targets, client, scope, subjects, onAllow, onClose }) {
|
|
135
|
+
const [introUpdates,setIntroUpdates]=useState({});
|
|
136
|
+
const introPreview=x=>client.agentIntrosV1?html`<${AgentIntroSharingPreview} key=${x.id} exposure=${{...x,...introUpdates[x.id]}} client=${client} onSaved=${value=>setIntroUpdates(old=>({...old,[x.id]:value}))} />`:null;
|
|
137
|
+
const [mode, setMode] = useState(targets.length === 1 ? "each" : null), [pick, setPick] = useState(null), [previous, setPrevious] = useState({}), [outcomes, setOutcomes] = useState({}), [busy, setBusy] = useState(false);
|
|
138
|
+
const life = useRef(0);
|
|
139
|
+
useEffect(() => { const generation = life.current; void Promise.all(targets.map(async x => [x.id, await client.previousAgentAccess(scope, x.id)])).then(rows => { if (generation === life.current) setPrevious(Object.fromEntries(rows)); }); return () => { life.current++; }; }, [client, scope, targets]);
|
|
140
|
+
useEffect(() => { if (targets.length === 1 && !pick) setPick(targets); }, []);
|
|
141
|
+
const usePrevious = async x => { if (busy) return; const generation = life.current; setBusy(true); const r = await client.usePreviousAgentAccess(scope, x.id, { revision: x.revision, digest: previous[x.id]?.previous?.digest }); if (generation === life.current) { setOutcomes(old => ({ ...old, [x.id]: r.ok ? ms("used") : ms("saveFailed", x.displayName) })); setBusy(false); } };
|
|
142
|
+
if (pick) return html`<${HubGrantPicker} x=${pick[0]} legacy=${!subjects} targets=${pick} client=${client} act=${async fn => fn()} grant=${input => client.ownerGrant(scope, input)} onClose=${() => setPick(null)} onResults=${results => setOutcomes(old => ({ ...old, ...results }))} extra=${html`${pick.map(x=>html`<div key=${x.id}><strong>${x.displayName}</strong>${introPreview(x)}</div>`)}${pick.length === 1 && previous[pick[0].id]?.previous ? html`<button class="btn" disabled=${busy} onClick=${() => usePrevious(pick[0])}>${ms(previous[pick[0].id].previous.peopleCount === null ? "previousMixed" : "previous", previous[pick[0].id].previous.count)}</button>${outcomes[pick[0].id] ? html`<p role="status">${outcomes[pick[0].id]}</p>` : null}` : null}`} />`;
|
|
143
|
+
return html`<${Dialog} title=${mc("accessTitle", targets.length)} onClose=${onClose} actions=${html`<button class="btn" onClick=${onClose}>${ms("later")}</button>`}><p>${ms("accessLead")}</p><div class="field-row"><button class="btn btn-primary" onClick=${() => { setMode("same"); setPick(targets); }}>${ms("same", targets.length)}</button><button class="btn" onClick=${() => setMode("each")}>${ms("each")}</button></div><ul class="hub-share-access-list">${targets.map(x => html`<li class="hub-share-access-item"><div class="hub-row-text"><strong>${x.displayName}</strong>${introPreview(x)}${outcomes[x.id] ? html`<small role="status">${outcomes[x.id]}</small>` : null}</div>${mode === "each" ? html`<button class="btn btn-sm" onClick=${() => setPick([x])}>${ms("choose")}</button>` : null}${previous[x.id]?.previous ? html`<button class="btn btn-sm" disabled=${busy} onClick=${() => usePrevious(x)}>${ms(previous[x.id].previous.peopleCount === null ? "previousMixed" : "previous", previous[x.id].previous.count)}</button>` : null}</li>`)}</ul></${Dialog}>`;
|
|
144
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// #3226 C: the words of the Hub's My
|
|
1
|
+
// #3226 C: the words of the Hub's My agents and Administration pages, en and zh-TW, and their stylesheet. A module
|
|
2
2
|
// of its own (#3261 review): a tab that loaded B's hub-chat-strings.js / hub-chat.css before C keeps them, so C's words
|
|
3
3
|
// and rules come only from here.
|
|
4
4
|
import { register, t } from "/assets/app-i18n.js";
|
|
@@ -11,7 +11,7 @@ register("hubOwner", {
|
|
|
11
11
|
active: "Active", adminLead: "Manage who may connect and see connected Fleets. You cannot read anyone’s chats here.", manualAdvanced: "Advanced: connect with a pairing code",
|
|
12
12
|
allow: "Allow…", allowDays: "For", allowGo: "Allow", allowLogin: "Their sign-in name",
|
|
13
13
|
allowLoginHint: "The account they sign in to this Hub with.", allowTitle: "Allow someone to ask {0}", approveGo: "Approve…",
|
|
14
|
-
approvedTag: "Approved", backToMine: "My
|
|
14
|
+
mineLeadNew: "The agents you can share on this Hub, and who may ask each one.", approvedTag: "Approved", backToMine: "My agents", codeFor: "Pairing code for {0}", codeUnusedYet: "Not used yet", fleetOf: "{0}'s fleet",
|
|
15
15
|
makeCode: "Create pairing code", mayAsk: "{0} may ask", mayAskNone: "No one may ask yet", mayAskOne: "1 may ask",
|
|
16
16
|
mineLead: "The agents that answer for you on this Hub: who may ask them, until when, and who asked lately. To share or stop sharing one, use your fleet's Settings → Hub.", mineLeadShort: "The agents that answer for you on this Hub: who may ask them, until when, and who asked lately.",
|
|
17
17
|
noFleets: "No fleet is connected yet.", ownerChecked: "The owner confirmed", ownerLogin: "Owner's sign-in name", pairSteps: "Pair a fleet",
|
|
@@ -23,14 +23,14 @@ register("hubOwner", {
|
|
|
23
23
|
yourAgentsCount: "My agents · {0}", sharedCount: "Shared · {0}", stageAnswered: "Answered", stageNot: "Not answered", stageWaiting: "Waiting", statePaused: "Sharing stopped on the Hub",
|
|
24
24
|
stateShared: "Shared", stateWithdrawn: "Withdrawn", stepApprove: "You approve", stepApproveHint: "Check the same fingerprint, then approve.",
|
|
25
25
|
stepCode: "Make a pairing code", stepCodeHint: "For the fleet's owner: they type it in their fleet within 10 minutes; it works once.",
|
|
26
|
-
stepOwner: "The owner checks the fingerprint", stepOwnerHint: "In their fleet, then on this Hub under My
|
|
26
|
+
stepOwner: "The owner checks the fingerprint", stepOwnerHint: "In their fleet, then on this Hub under My agents.",
|
|
27
27
|
untilLeft: "until {0} ({1})", waitingOwner: "Waiting for the owner", whoMayAsk: "Who may ask",
|
|
28
28
|
},
|
|
29
29
|
"zh-TW": {
|
|
30
30
|
memberAddress: "Hub 位址", memberAddressHint: "在你的 Fleet「設定 → Hub → 其他方式」的「Hub 位址」欄位貼上這個位址,並輸入配對碼。這與 Hub 的瀏覽器位址不同。",
|
|
31
31
|
memberAddressMissing: "請向管理員索取要填入「Hub 位址」欄位的位址;它的連接埠可能與這個頁面不同。", copyHandoff: "複製位址與配對碼", handoffCopied: "已複製位址與配對碼", handoffCopyFailed: "無法複製。請選取上方的位址與配對碼來複製。",
|
|
32
32
|
active: "使用中", adminLead: "管理允許連接的人員與已連接的 Fleet。這裡看不到任何人的對話。", manualAdvanced: "進階:使用配對碼連接", allow: "允許提問…", allowDays: "期限", allowGo: "允許", allowLogin: "對方的登入名稱",
|
|
33
|
-
allowLoginHint: "對方登入這個 Hub 用的帳號。", allowTitle: "允許提問 {0}", approveGo: "核准…", approvedTag: "已核准", backToMine: "
|
|
33
|
+
mineLeadNew: "可以分享到這個 Hub 的 Agent,以及誰可以向它們提問。", allowLoginHint: "對方登入這個 Hub 用的帳號。", allowTitle: "允許提問 {0}", approveGo: "核准…", approvedTag: "已核准", backToMine: "我的 Agent",
|
|
34
34
|
codeFor: "給 {0} 的配對碼", codeUnusedYet: "還沒使用", fleetOf: "{0} 的 Fleet", makeCode: "產生配對碼", mayAsk: "{0} 人可以提問", mayAskNone: "還沒有人可以提問",
|
|
35
35
|
mayAskOne: "1 人可以提問", mineLead: "在這個 Hub 上代表你回答的 Agent:誰可以提問、到什麼時候、最近誰問過。要開始或停止分享,請到你 Fleet 的「設定 → Hub」。", mineLeadShort: "在這個 Hub 上代表你回答的 Agent:誰可以提問、到什麼時候、最近誰問過。", noFleets: "還沒有已連接的 Fleet。",
|
|
36
36
|
ownerChecked: "擁有者已確認", ownerLogin: "擁有者的登入名稱", pairSteps: "配對一個 Fleet", pairedFleets: "已連接的 Fleet · {0}", pauseGo: "停止分享…",
|
|
@@ -38,7 +38,7 @@ register("hubOwner", {
|
|
|
38
38
|
recent: "最近的提問", recentLead: "誰問的、什麼時候,有沒有回答。問了什麼留在你 Fleet 的聊天裡。", recentNone: "還沒有人問過。", refresh: "重新整理", revokeItem: "撤銷…", revokedTag: "已撤銷",
|
|
39
39
|
rowMenu: "{0} 的更多動作", scopeHub: "這個 Hub", scopeYou: "你的", yourAgentsCount: "我的 Agent · {0}", sharedCount: "分享中 · {0}", stageAnswered: "已回答", stageNot: "未回答", stageWaiting: "等待中",
|
|
40
40
|
statePaused: "已在 Hub 停止分享", stateShared: "分享中", stateWithdrawn: "已停止分享", stepApprove: "你核准", stepApproveHint: "核對同一個指紋後核准。", stepCode: "產生配對碼",
|
|
41
|
-
stepCodeHint: "給 Fleet 的擁有者:10 分鐘內在他的 Fleet 輸入,只能用一次。", stepOwner: "擁有者核對指紋", stepOwnerHint: "在他的 Fleet 上,然後在這個 Hub
|
|
41
|
+
stepCodeHint: "給 Fleet 的擁有者:10 分鐘內在他的 Fleet 輸入,只能用一次。", stepOwner: "擁有者核對指紋", stepOwnerHint: "在他的 Fleet 上,然後在這個 Hub 的「我的 Agent」確認。",
|
|
42
42
|
untilLeft: "到 {0}({1})", waitingOwner: "等待擁有者", whoMayAsk: "可以提問的人",
|
|
43
43
|
},
|
|
44
44
|
});
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { hi, introCount, introPreview } from "./hub-agent-intro.js";
|
|
1
2
|
import {html,useEffect,useLayoutEffect,useRef,useState} from "/assets/app-html.js";
|
|
2
3
|
import {ErrorState,Skeleton} from "/assets/ui-states.js";
|
|
3
4
|
import {confirmDialog} from "/assets/ui-confirm.js";
|
|
4
5
|
import {runtimeEnrollCommand} from "./runtime-commands.js";
|
|
5
6
|
import {hp} from "./hub-personal-agent-strings.js";
|
|
6
7
|
const refused=()=>({ok:false});
|
|
7
|
-
const fields=agent=>({name:agent?.name??"",description:agent?.description??"",cli:agent?.cli??"",model:agent?.model??"",ifRevision:agent?.revision??0,answerOnly:agent?.answerOnly===true});
|
|
8
|
+
const fields=agent=>({name:agent?.name??"",description:agent?.introBy?agent.intro:introPreview(agent?.description??""),cli:agent?.cli??"",model:agent?.model??"",ifRevision:agent?.revision??0,answerOnly:agent?.answerOnly===true});
|
|
8
9
|
const policy=value=>({enabled:value.enabled===true,people:[...(value.people??[])],teams:[...(value.teams??[])]});
|
|
9
10
|
export function personalCliReason(cli){
|
|
10
11
|
if(cli?.available)return "canUse";
|
|
@@ -29,7 +30,7 @@ export function HubPersonalAgent({client,scope,isAdmin=false,onSaved=()=>{}}){
|
|
|
29
30
|
const enroll=async()=>{if(busyRef.current)return;markBusy(true);setError("");const mine=generation.current;let result;try{result=await client.personalEnrollment(scope);}catch{result=refused();}
|
|
30
31
|
if(mine!==generation.current)return;markBusy(false);if(!result?.ok){setError(hp("saveFailed"));return;}setIssued(result);setClock(Date.now());setCopied(false);setWaiting(false);setEditing(true);
|
|
31
32
|
};
|
|
32
|
-
const save=async event=>{event.preventDefault();if(busyRef.current||!form?.name.trim())return;markBusy(true);setError("");const mine=generation.current;
|
|
33
|
+
const save=async event=>{event.preventDefault();if(busyRef.current||!form?.name.trim()||introCount(form.description)>50)return;markBusy(true);setError("");const mine=generation.current;
|
|
33
34
|
let result;try{const {model,answerOnly,...input}=form;result=await client.savePersonalAgent(scope,{...input,...(model?{model}:{}),...(answerOnly?{answerOnly:true}:{})});}catch{result=refused();}
|
|
34
35
|
if(mine!==generation.current)return;markBusy(false);if(!result?.ok){setError(hp("saveFailed"));return;}dirty.current=false;setIssued(null);setEditing(false);await load(false,true);if(mine===generation.current)onSaved();
|
|
35
36
|
};
|
|
@@ -57,8 +58,8 @@ export function HubPersonalAgent({client,scope,isAdmin=false,onSaved=()=>{}}){
|
|
|
57
58
|
const configure=choices.length?html`<form onSubmit=${save} class="form"><label class="field"><span>${hp("cli")}</span><select required disabled=${busy} value=${form?.cli||""} onChange=${e=>edit({cli:e.target.value,model:"",answerOnly:e.target.value==="codex"&&form.answerOnly})}><option value=""></option>${choices.map(c=>html`<option value=${c.id}>${c.id==="codex"?"Codex":"Claude"}</option>`)}</select></label>
|
|
58
59
|
${answerOnlyChoice}<label class="field"><span>${hp("name")}</span><input required maxlength="256" disabled=${busy} value=${form?.name||""} onInput=${e=>edit({name:e.target.value})} /></label>
|
|
59
60
|
${!answerOnlyChoice?html`<p class="note" data-personal-disclosure>${hp("folderDisclosure")}</p>`:null}
|
|
60
|
-
${disclosure(hp("moreSettings"),html`<label class="field"><span>${
|
|
61
|
-
<div class="field-row"><button class="btn btn-sm btn-primary" disabled=${busy||!canUse(selected)||!computer.connected||!form?.name.trim()||!!view.agent&&!dirty.current}>${hp("save")}</button>${dirty.current?html`<span class="note" role="status">${hp("unsaved")}</span>`:null}</div></form>`:html`${cliReasons}${refreshButton}`;
|
|
61
|
+
${disclosure(hp("moreSettings"),html`<label class="field"><span>${hi("title")}</span>${view.agent&&!view.agent.introBy?html`<small class="note">${hi("review")}</small>${introCount(view.agent.description)>50?html`<small class="note">${hi("cut")}</small>`:null}`:null}<input placeholder=${hi("placeholder")} disabled=${busy} value=${form?.description||""} onInput=${e=>edit({description:e.target.value})} /><small class="note">${`${hi("hint")} ${introCount(form?.description)}/50`}</small></label><label class="field"><span>${hp("model")}</span><select disabled=${busy} value=${form?.model||""} onChange=${e=>edit({model:e.target.value})}><option value="">${hp("defaultModel")}</option>${(selected?.models??[]).map(m=>html`<option value=${m.id}>${m.label||m.id}</option>`)}</select></label>${cliReasons}`)}
|
|
62
|
+
<div class="field-row"><button class="btn btn-sm btn-primary" disabled=${busy||!canUse(selected)||!computer.connected||!form?.name.trim()||!!view.agent&&!dirty.current&&!!view.agent.introBy||introCount(form?.description)>50}>${hp("save")}</button>${dirty.current?html`<span class="note" role="status">${hp("unsaved")}</span>`:null}</div></form>`:html`${cliReasons}${refreshButton}`;
|
|
62
63
|
const sharing=html`<p class="note">${hp("notShared")}</p>${!view?.agent?.answerOnly?html`<p class="note" data-personal-sharing-disclosure>${hp("sharingDisclosure")}</p>`:null}<div class="field-row"><a class="btn btn-sm btn-primary" href=${`/ui/hub/exposures?agent=${encodeURIComponent(view?.agent?.exposureId??"")}`}>${hp("sharing")}</a>${view?.agent?html`<button type="button" class="btn btn-sm btn-ghost" onClick=${()=>setEditing(true)}>${hp("editAgent")}</button>`:null}</div>`;
|
|
63
64
|
const current=issued?2:computer?view.agent?4:3:1;
|
|
64
65
|
const setup=html`<ol class="runtime-steps">
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { hi } from "./hub-agent-intro.js";
|
|
1
2
|
import {hp} from "./hub-personal-agent-strings.js";
|
|
2
3
|
// M-3092 PR 2 (Hub rooms, track U): a room's composer — the Fleet chat's own ComposerInput, its palette (`cmd-palette`)
|
|
3
4
|
// and its reply bar (`reply-bar`), with what a room adds (docs/design/hub-rooms-ux.md §4):
|
|
@@ -12,6 +13,7 @@ import { t } from "/assets/app-i18n.js";
|
|
|
12
13
|
import { Icon } from "/assets/ui-icons.js";
|
|
13
14
|
import { hroom } from "./hub-room-strings.js";
|
|
14
15
|
import { presenceDot } from "./hub-room-presence.js";
|
|
16
|
+
import { pasteToAttach } from "./hub-attachments.js";
|
|
15
17
|
|
|
16
18
|
const ONLINE = new Set(["online", "idle", "working"]);
|
|
17
19
|
const agentsOf = (detail) => (detail?.members || []).filter((m) => m.kind === "agent" || m.kind === "later");
|
|
@@ -40,21 +42,46 @@ export function mentionOptions(detail, query = "") {
|
|
|
40
42
|
if ((detail?.settings?.allMention !== false || manager) && agents.length && hit(hroom("mentionAll")))
|
|
41
43
|
out.push({ kind: "all", key: "all", label: hroom("mentionAll"), hint: hroom("mentionAllHint", String(agents.length)) });
|
|
42
44
|
if ((detail?.members || []).some((m) => m.kind === "assistant") && hit(hroom("mentionAssistant")))
|
|
43
|
-
out.push({ kind: "assistant", key: "assistant", label: hroom("mentionAssistant"), hint:
|
|
44
|
-
for (const a of agents) if (hit(a.name, a.owner?.name)) out.push({ kind: "agent", key: a.id, label: `@${a.name}`, ...(a.answerOnly?{answerOnly:true}:{}), hint: a.answerOnly
|
|
45
|
+
out.push({ kind: "assistant", key: "assistant", label: hroom("mentionAssistant"), hint: hi("assistant") });
|
|
46
|
+
for (const a of agents) if (hit(a.name, a.owner?.name)) out.push({ kind: "agent", key: a.id, label: `@${a.name}`, ...(a.answerOnly?{answerOnly:true}:{}), hint: [a.intro,a.answerOnly?hp("answerOnlyAsker"):a.owner?.name].filter(Boolean).join(" · "), dot: presenceDot(a.presence, a.presenceReason) });
|
|
45
47
|
for (const p of (detail?.members || []).filter((m) => m.kind === "person" && m.id !== detail?.me?.id)) if (hit(p.name)) out.push({ kind: "person", key: p.id, label: `@${p.name}`, hint: "" });
|
|
46
48
|
return out;
|
|
47
49
|
}
|
|
48
50
|
|
|
49
|
-
|
|
51
|
+
// `@Name` not followed by an ASCII word character or `-` (as agents have always been read: "@研發助理幫我看" names it, no
|
|
52
|
+
// space needed). `person`: also not after an ASCII letter, digit, `_`, `@` or `\` — an email address or an escaped @ names no one.
|
|
53
|
+
const atName = (name, flags = "", person = false) =>
|
|
54
|
+
new RegExp(`${person ? "(?<![A-Za-z0-9_@\\\\])" : ""}@${String(name).replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?![\\w-])`, flags);
|
|
55
|
+
/**
|
|
56
|
+
* The mentions a text names (spec seam 1: "all", "assistant" or an agent's exposure id), read from the text as sent.
|
|
57
|
+
* M-3298: and each person it @s (their member id) — the reminder the @ menu promises: their room list's @ and their page's
|
|
58
|
+
* ping (hub-room-unread.js) read it from the message's mentions. A longer name is read first, so "@Alex Chen" is not also
|
|
59
|
+
* "@Alex"; never me; a name two members share, no one. It is the page's preview: the Hub resolves who a person's @ reminds
|
|
60
|
+
* from the text itself (hub/rooms/service.ts post()), and keeps from what a page sends only what routes (@all, assistant, agents).
|
|
61
|
+
*/
|
|
50
62
|
export function mentionsIn(text, detail) {
|
|
51
63
|
const s = String(text || ""), out = [];
|
|
52
64
|
if (s.includes(hroom("mentionAll"))) out.push("all");
|
|
53
65
|
if (s.includes(hroom("mentionAssistant"))) out.push("assistant");
|
|
54
|
-
for (const a of agentsOf(detail)) if (
|
|
66
|
+
for (const a of agentsOf(detail)) if (atName(a.name).test(s)) out.push(a.id);
|
|
67
|
+
const me = detail?.me?.id, named = [...agentsOf(detail).map((a) => ({ name: a.name, person: null })),
|
|
68
|
+
...(detail?.members || []).filter((m) => m.kind === "person" && m.name).map((m) => ({ name: m.name, person: m.id }))]
|
|
69
|
+
.sort((x, y) => String(y.name).length - String(x.name).length);
|
|
70
|
+
// A name two members share names no one (as the Hub reads it, #4132 review F1): the Hub decides who is reminded.
|
|
71
|
+
const shared = new Map();
|
|
72
|
+
for (const n of named) { const k = String(n.name).toLocaleLowerCase("en-US"); shared.set(k, (shared.get(k) || 0) + 1); }
|
|
73
|
+
let rest = s;
|
|
74
|
+
for (const n of named) {
|
|
75
|
+
if (!atName(n.name, "", !!n.person).test(rest)) continue;
|
|
76
|
+
if (n.person && n.person !== me && shared.get(String(n.name).toLocaleLowerCase("en-US")) === 1) out.push(n.person);
|
|
77
|
+
rest = rest.replace(atName(n.name, "g", !!n.person), (hit) => " ".repeat(hit.length));
|
|
78
|
+
}
|
|
55
79
|
return [...new Set(out)];
|
|
56
80
|
}
|
|
57
81
|
|
|
82
|
+
// M-3308: the paste helpers live with the Hub's files (hub-attachments.js), shared with the 1:1 question's composer (M-3311).
|
|
83
|
+
export { LONG_PASTE_CHARS, pastedFile } from "./hub-attachments.js";
|
|
84
|
+
|
|
58
85
|
/** Above the box when @所有 Agent is in it: how many answer now, how many after they come back (spec §4). */
|
|
59
86
|
export function allBar(detail) {
|
|
60
87
|
const agents = agentsOf(detail), online = agents.filter((a) => ONLINE.has(a.presence)).length;
|
|
@@ -109,6 +136,9 @@ export function RoomComposer({ store, detail, reply = null, onReply = () => {},
|
|
|
109
136
|
if (globalThis.AgendChatRender?.composerKey(e, { touch: touchScreen() }) === "send") { e.preventDefault(); void send(); }
|
|
110
137
|
};
|
|
111
138
|
const track = (v) => { setValue(v); setMsg(null); setCaret(input.current ? input.current.selectionStart ?? v.length : v.length); };
|
|
139
|
+
// M-3308 (the user: a screenshot pasted with Ctrl+V did nothing in a room): the Fleet chat's paste, through the room's own
|
|
140
|
+
// Attach and its file rules (hub-attachments.js pasteToAttach). A room that takes no files keeps the text (as before).
|
|
141
|
+
const onPaste = (e) => { if (!closed) pasteToAttach(e, attach); };
|
|
112
142
|
const paletteId = `hubMention-${room.id || "room"}`, optId = (o) => `${paletteId}-${o.key}`;
|
|
113
143
|
// M-3117: as the Fleet chat's dock has it — the box, then a failed send, then the line under it (its .composer-row).
|
|
114
144
|
if (closed) return html`<p class="hub-banner warn" role="status">${hroom(detail?.room?.archived ? "errArchived" : "errNotMember")}</p>`;
|
|
@@ -122,11 +152,12 @@ export function RoomComposer({ store, detail, reply = null, onReply = () => {},
|
|
|
122
152
|
${group && value.includes(hroom("mentionAll")) ? html`<p class="note hub-room-allbar" role="status">${allBar(detail)}</p>` : null}
|
|
123
153
|
${reply ? html`<div class="reply-bar" data-trust="composer" role="status"><span class="reply-text">${reply.sender ? `${reply.sender} · ` : ""}${String(reply.text || "").slice(0, 80)}</span>
|
|
124
154
|
<button type="button" class="icon-btn reply-cancel" title=${hroom("cancel")} aria-label=${hroom("cancel")} onClick=${() => { onReply(null); input.current?.focus(); }}><${Icon} name="close" size=${14} /></button></div>` : null}
|
|
125
|
-
<${ComposerInput} inputRef=${input} value=${value} attach=${attach} placeholder=${room.assistant ? hroom("composerAssistant") : group ? (short ? hroom("composerShort") : hroom("composer", room.name || "")) : hroom("composerDirect", room.name || "")} onValue=${track} onKeyDown=${onKeyDown}
|
|
155
|
+
<${ComposerInput} inputRef=${input} value=${value} attach=${attach} onPaste=${onPaste} placeholder=${room.assistant ? hroom("composerAssistant") : group ? (short ? hroom("composerShort") : hroom("composer", room.name || "")) : hroom("composerDirect", room.name || "")} onValue=${track} onKeyDown=${onKeyDown}
|
|
126
156
|
controls=${palette ? paletteId : undefined} expanded=${!!palette} activeDescendant=${chosen ? optId(chosen) : undefined}
|
|
127
157
|
stop=${{ hidden: true, disabled: true, title: t("chat.stopReply"), label: t("chat.stopReply"), onClick: () => {} }}
|
|
128
158
|
send=${{ hidden: false, disabled: (!value.trim() && !canSendEmpty) || busy, label: t("chat.send"), onClick: () => { void send(); } }} />
|
|
129
159
|
</div>
|
|
130
160
|
${msg ? html`<p class="err" role="alert">${msg.text}${msg.retry ? html` <button type="button" class="btn btn-sm" onClick=${send}>${hroom("retrySend")}</button>` : null}</p>` : null}
|
|
131
|
-
${
|
|
161
|
+
${/* M-3311 (3): the Fleet chat's line under the box — Enter sends, Shift+Enter a new line — and a group room's @agent hint after it. */ ""}
|
|
162
|
+
<div class=${`composer-row${group ? " hub-hints" : ""}`}><span class="hint hub-enter-hint">${t(touchScreen() ? "chat.nativeComposerHintTouch" : "chat.nativeComposerHint")}</span>${group ? html`<span class="hint hub-room-hint">${hroom("composerHint")}</span>` : null}</div>`;
|
|
132
163
|
}
|
package/dist/ui/hub-room-list.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { hi } from "./hub-agent-intro.js";
|
|
1
2
|
import {hp} from "./hub-personal-agent-strings.js";
|
|
2
3
|
// M-3092 (Hub rooms, track U): the Hub's conversation list, drawn as the Fleet chat draws its roster — the same row
|
|
3
4
|
// (`li.v-li > a.inst.v-inst`: avatar with its status dot, the name line and the second line), the same section head
|
|
@@ -30,7 +31,7 @@ export function listRoomOf(item) {
|
|
|
30
31
|
if (!item || typeof item !== "object" || typeof item.id !== "string") return null;
|
|
31
32
|
return { id: item.id, kind: "direct", name: String(item.exposureName || ""), people: 1, agents: 1, online: null, unread: 0,
|
|
32
33
|
lastAt: Number.isFinite(item.lastAt) ? item.lastAt : 0, lastText: "", lastAuthor: "",
|
|
33
|
-
agent: { ...(item.answerOnly?{answerOnly:true}:{}), exposureId: String(item.exposureId || ""), owner: { name: String(item.ownerName || "") }, presence: null }, limited: true, legacy: item };
|
|
34
|
+
agent: { ...(typeof item.intro==="string"?{intro:item.intro}:{}), ...(item.answerOnly?{answerOnly:true}:{}), exposureId: String(item.exposureId || ""), owner: { name: String(item.ownerName || "") }, presence: null }, limited: true, legacy: item };
|
|
34
35
|
}
|
|
35
36
|
/** The rooms list from whichever client this page has: roomList() when it can, else rooms() mapped by listRoomOf(). */
|
|
36
37
|
export function readRoomList(client) {
|
|
@@ -71,9 +72,9 @@ export function rowView(r) {
|
|
|
71
72
|
const group = r.kind === "group", limited = r.limited === true;
|
|
72
73
|
// Today's chats keep what their row said: closed, or a question waiting (the Fleet's working dot), else its owner.
|
|
73
74
|
const closed = limited && r.legacy?.state === "closed", waiting = limited && !closed && r.legacy?.waiting === true;
|
|
74
|
-
const line2 = group ? countsLine(r.people, r.agents)
|
|
75
|
+
const line2 = group ? [countsLine(r.people, r.agents),r.purpose].filter(Boolean).join(" · ")
|
|
75
76
|
: closed ? t("hubChat.tagClosed") : waiting ? t("hubChat.waiting")
|
|
76
|
-
: r.assistant ?
|
|
77
|
+
: r.assistant ? hi("assistant") : [r.agent?.intro,r.agent?.answerOnly ? hp("answerOnlyAsker") : String(r.agent?.owner?.name || "")].filter(Boolean).join(" · ");
|
|
77
78
|
return {
|
|
78
79
|
title: r.assistant ? tr("hubAssistant") : String(r.name || ""), line2,
|
|
79
80
|
avatar: { square: group, text: firstCharacter(r.assistant ? tr("hubAssistant") : String(r.name || "?")) || "?" },
|