@songsid/agend 2.3.5-alpha.7 → 2.3.5-alpha.9
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-profiles.d.ts +6 -0
- package/dist/accounts-profiles.js +16 -0
- package/dist/accounts-profiles.js.map +1 -1
- package/dist/accounts-view.d.ts +17 -0
- package/dist/accounts-view.js +33 -6
- package/dist/accounts-view.js.map +1 -1
- package/dist/agent-cli-instructions.md +1 -1
- package/dist/agent-cli.js +5 -2
- package/dist/agent-cli.js.map +1 -1
- package/dist/agent-whats-new.js +5 -0
- package/dist/agent-whats-new.js.map +1 -1
- package/dist/apply-job.d.ts +5 -0
- package/dist/apply-job.js +10 -3
- package/dist/apply-job.js.map +1 -1
- package/dist/auth-api.d.ts +1 -1
- package/dist/auth-api.js +4 -2
- package/dist/auth-api.js.map +1 -1
- package/dist/authority/company-join.d.ts +16 -0
- package/dist/authority/company-join.js +37 -0
- package/dist/authority/company-join.js.map +1 -0
- package/dist/authority/hub-initialization.d.ts +13 -0
- package/dist/authority/hub-initialization.js +30 -0
- package/dist/authority/hub-initialization.js.map +1 -0
- package/dist/backend/claude-code.d.ts +1 -0
- package/dist/backend/claude-code.js +13 -0
- package/dist/backend/claude-code.js.map +1 -1
- package/dist/backend/types.d.ts +4 -0
- package/dist/backend/types.js.map +1 -1
- package/dist/build-provenance.json +1 -1
- package/dist/channel/mcp-tools.js +2 -2
- package/dist/channel/mcp-tools.js.map +1 -1
- package/dist/claude-model-minimum.d.ts +7 -0
- package/dist/claude-model-minimum.js +16 -0
- package/dist/claude-model-minimum.js.map +1 -0
- package/dist/config-validator.js +2 -1
- package/dist/config-validator.js.map +1 -1
- package/dist/daemon.d.ts +43 -1
- package/dist/daemon.js +176 -27
- package/dist/daemon.js.map +1 -1
- package/dist/decision-list.d.ts +2 -0
- package/dist/decision-list.js +1 -1
- package/dist/decision-list.js.map +1 -1
- package/dist/fleet-manager.d.ts +75 -3
- package/dist/fleet-manager.js +462 -53
- package/dist/fleet-manager.js.map +1 -1
- package/dist/general-knowledge/skills/concepts/SKILL.md +14 -3
- package/dist/general-knowledge/skills/delegation-playbook/SKILL.md +4 -1
- package/dist/general-knowledge/steering/core-rules.md +1 -1
- package/dist/hub/catalog.d.ts +1 -1
- package/dist/hub/catalog.js +151 -33
- package/dist/hub/catalog.js.map +1 -1
- package/dist/hub/client.js +4 -0
- package/dist/hub/client.js.map +1 -1
- package/dist/hub/compose/member.d.ts +6 -0
- package/dist/hub/compose/member.js +9 -1
- package/dist/hub/compose/member.js.map +1 -1
- package/dist/hub/compose/server.d.ts +55 -1
- package/dist/hub/compose/server.js +76 -10
- package/dist/hub/compose/server.js.map +1 -1
- package/dist/hub/directory/directory.d.ts +2 -0
- package/dist/hub/directory/directory.js +49 -4
- package/dist/hub/directory/directory.js.map +1 -1
- package/dist/hub/directory/types.d.ts +2 -0
- package/dist/hub/directory/types.js.map +1 -1
- package/dist/hub/enrollment-budget.d.ts +6 -0
- package/dist/hub/enrollment-budget.js +24 -0
- package/dist/hub/enrollment-budget.js.map +1 -0
- package/dist/hub/group-policy/admin-api.d.ts +30 -0
- package/dist/hub/group-policy/admin-api.js +83 -0
- package/dist/hub/group-policy/admin-api.js.map +1 -0
- package/dist/hub/group-policy/admin-control.d.ts +34 -0
- package/dist/hub/group-policy/admin-control.js +258 -0
- package/dist/hub/group-policy/admin-control.js.map +1 -0
- package/dist/hub/group-policy/admin-dto.d.ts +9 -1
- package/dist/hub/group-policy/admin-dto.js.map +1 -1
- package/dist/hub/group-policy/admin-facts.d.ts +17 -0
- package/dist/hub/group-policy/admin-facts.js +33 -0
- package/dist/hub/group-policy/admin-facts.js.map +1 -0
- package/dist/hub/group-policy/admin-impact.d.ts +51 -0
- package/dist/hub/group-policy/admin-impact.js +88 -0
- package/dist/hub/group-policy/admin-impact.js.map +1 -0
- package/dist/hub/group-policy/authorization.d.ts +22 -0
- package/dist/hub/group-policy/authorization.js +147 -2
- package/dist/hub/group-policy/authorization.js.map +1 -1
- package/dist/hub/group-policy/impact-inventory.d.ts +21 -0
- package/dist/hub/group-policy/impact-inventory.js +75 -0
- package/dist/hub/group-policy/impact-inventory.js.map +1 -0
- package/dist/hub/group-policy/resources.d.ts +13 -1
- package/dist/hub/group-policy/resources.js +92 -23
- package/dist/hub/group-policy/resources.js.map +1 -1
- package/dist/hub/group-policy/store.d.ts +11 -0
- package/dist/hub/group-policy/store.js +57 -2
- package/dist/hub/group-policy/store.js.map +1 -1
- package/dist/hub/group-policy/welcome.d.ts +36 -0
- package/dist/hub/group-policy/welcome.js +55 -0
- package/dist/hub/group-policy/welcome.js.map +1 -0
- package/dist/hub/http/compose.d.ts +2 -0
- package/dist/hub/http/compose.js +184 -8
- package/dist/hub/http/compose.js.map +1 -1
- package/dist/hub/http/core.d.ts +2 -0
- package/dist/hub/http/core.js +10 -1
- package/dist/hub/http/core.js.map +1 -1
- package/dist/hub/http/deps.d.ts +10 -0
- package/dist/hub/http/schema.js +4 -0
- package/dist/hub/http/schema.js.map +1 -1
- package/dist/hub/init/browser-certificate.d.ts +6 -1
- package/dist/hub/init/browser-certificate.js +22 -1
- package/dist/hub/init/browser-certificate.js.map +1 -1
- package/dist/hub/init/initializer.d.ts +11 -1
- package/dist/hub/init/initializer.js +202 -83
- package/dist/hub/init/initializer.js.map +1 -1
- package/dist/hub/init/layout.js +1 -1
- package/dist/hub/init/layout.js.map +1 -1
- package/dist/hub/init/text.js +2 -2
- package/dist/hub/init/text.js.map +1 -1
- package/dist/hub/init/types.d.ts +32 -4
- package/dist/hub/init/types.js.map +1 -1
- package/dist/hub/init/web-audit-import.d.ts +12 -0
- package/dist/hub/init/web-audit-import.js +39 -0
- package/dist/hub/init/web-audit-import.js.map +1 -0
- package/dist/hub/init/web-audit.d.ts +30 -0
- package/dist/hub/init/web-audit.js +42 -0
- package/dist/hub/init/web-audit.js.map +1 -0
- package/dist/hub/init/web-error.d.ts +6 -0
- package/dist/hub/init/web-error.js +8 -0
- package/dist/hub/init/web-error.js.map +1 -0
- package/dist/hub/init/web-http.d.ts +9 -0
- package/dist/hub/init/web-http.js +103 -0
- package/dist/hub/init/web-http.js.map +1 -0
- package/dist/hub/init/web.d.ts +118 -0
- package/dist/hub/init/web.js +428 -0
- package/dist/hub/init/web.js.map +1 -0
- package/dist/hub/init/wizard.js +1 -3
- package/dist/hub/init/wizard.js.map +1 -1
- package/dist/hub/join/client.d.ts +35 -0
- package/dist/hub/join/client.js +112 -0
- package/dist/hub/join/client.js.map +1 -0
- package/dist/hub/join/descriptor.d.ts +45 -0
- package/dist/hub/join/descriptor.js +52 -0
- package/dist/hub/join/descriptor.js.map +1 -0
- package/dist/hub/join/fleet-authority.d.ts +2 -0
- package/dist/hub/join/fleet-authority.js +3 -0
- package/dist/hub/join/fleet-authority.js.map +1 -0
- package/dist/hub/join/http.d.ts +8 -0
- package/dist/hub/join/http.js +112 -0
- package/dist/hub/join/http.js.map +1 -0
- package/dist/hub/join/invitation.d.ts +28 -0
- package/dist/hub/join/invitation.js +28 -0
- package/dist/hub/join/invitation.js.map +1 -0
- package/dist/hub/join/local-journal.d.ts +84 -0
- package/dist/hub/join/local-journal.js +65 -0
- package/dist/hub/join/local-journal.js.map +1 -0
- package/dist/hub/join/local.d.ts +116 -0
- package/dist/hub/join/local.js +419 -0
- package/dist/hub/join/local.js.map +1 -0
- package/dist/hub/join/private.d.ts +3 -0
- package/dist/hub/join/private.js +46 -0
- package/dist/hub/join/private.js.map +1 -0
- package/dist/hub/join/protocol.d.ts +69 -0
- package/dist/hub/join/protocol.js +96 -0
- package/dist/hub/join/protocol.js.map +1 -0
- package/dist/hub/join/receipt.d.ts +42 -0
- package/dist/hub/join/receipt.js +75 -0
- package/dist/hub/join/receipt.js.map +1 -0
- package/dist/hub/join/service.d.ts +177 -0
- package/dist/hub/join/service.js +564 -0
- package/dist/hub/join/service.js.map +1 -0
- package/dist/hub/join/store.d.ts +97 -0
- package/dist/hub/join/store.js +87 -0
- package/dist/hub/join/store.js.map +1 -0
- package/dist/hub/join/trust.d.ts +13 -0
- package/dist/hub/join/trust.js +68 -0
- package/dist/hub/join/trust.js.map +1 -0
- package/dist/hub/member/pairing-api.d.ts +2 -0
- package/dist/hub/member/pairing-api.js +7 -1
- package/dist/hub/member/pairing-api.js.map +1 -1
- package/dist/hub/member/pairing-notices.d.ts +18 -0
- package/dist/hub/member/pairing-notices.js +60 -0
- package/dist/hub/member/pairing-notices.js.map +1 -0
- package/dist/hub/pairing-notices.d.ts +47 -0
- package/dist/hub/pairing-notices.js +246 -0
- package/dist/hub/pairing-notices.js.map +1 -0
- package/dist/hub/pairing.d.ts +39 -1
- package/dist/hub/pairing.js +316 -16
- package/dist/hub/pairing.js.map +1 -1
- package/dist/hub/protocol.d.ts +61 -0
- package/dist/hub/protocol.js +8 -1
- package/dist/hub/protocol.js.map +1 -1
- package/dist/hub/room-read-pacer.d.ts +14 -0
- package/dist/hub/room-read-pacer.js +51 -0
- package/dist/hub/room-read-pacer.js.map +1 -0
- package/dist/hub/rooms.d.ts +7 -1
- package/dist/hub/rooms.js +25 -13
- package/dist/hub/rooms.js.map +1 -1
- package/dist/hub/runtime.d.ts +8 -1
- package/dist/hub/runtime.js +13 -0
- package/dist/hub/runtime.js.map +1 -1
- package/dist/hub/server.d.ts +3 -0
- package/dist/hub/server.js +18 -0
- package/dist/hub/server.js.map +1 -1
- package/dist/hub/session-directory-transition.d.ts +48 -0
- package/dist/hub/session-directory-transition.js +118 -0
- package/dist/hub/session-directory-transition.js.map +1 -0
- package/dist/hub/session-epoch.d.ts +16 -0
- package/dist/hub/session-epoch.js +50 -0
- package/dist/hub/session-epoch.js.map +1 -0
- package/dist/hub/sessions.d.ts +13 -0
- package/dist/hub/sessions.js +36 -16
- package/dist/hub/sessions.js.map +1 -1
- package/dist/hub/settings-api.d.ts +50 -0
- package/dist/hub/settings-api.js +92 -0
- package/dist/hub/settings-api.js.map +1 -0
- package/dist/hub/settings-commit.d.ts +95 -0
- package/dist/hub/settings-commit.js +490 -0
- package/dist/hub/settings-commit.js.map +1 -0
- package/dist/hub/settings-directory-decision.d.ts +433 -0
- package/dist/hub/settings-directory-decision.js +236 -0
- package/dist/hub/settings-directory-decision.js.map +1 -0
- package/dist/hub/settings-directory-proof.d.ts +77 -0
- package/dist/hub/settings-directory-proof.js +303 -0
- package/dist/hub/settings-directory-proof.js.map +1 -0
- package/dist/hub/store.d.ts +12 -2
- package/dist/hub/store.js +9 -5
- package/dist/hub/store.js.map +1 -1
- package/dist/hub/types.d.ts +15 -2
- package/dist/hub-host-settings.d.ts +48 -0
- package/dist/hub-host-settings.js +85 -0
- package/dist/hub-host-settings.js.map +1 -0
- package/dist/instance-lifecycle.d.ts +3 -0
- package/dist/instance-lifecycle.js +4 -0
- package/dist/instance-lifecycle.js.map +1 -1
- package/dist/locale.js +54 -30
- package/dist/locale.js.map +1 -1
- package/dist/login-controller.d.ts +9 -1
- package/dist/login-controller.js +20 -1
- package/dist/login-controller.js.map +1 -1
- package/dist/login-flows.js +4 -2
- package/dist/login-flows.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.js +1 -1
- package/dist/outbound-handlers.js.map +1 -1
- package/dist/outbound-schemas.d.ts +2 -0
- package/dist/outbound-schemas.js +4 -2
- package/dist/outbound-schemas.js.map +1 -1
- package/dist/pane-port.d.ts +1 -1
- package/dist/profile-signins.d.ts +107 -0
- package/dist/profile-signins.js +249 -0
- package/dist/profile-signins.js.map +1 -0
- package/dist/quickstart-api.js +2 -2
- package/dist/quickstart-api.js.map +1 -1
- package/dist/reply-buttons-controller.d.ts +5 -1
- package/dist/reply-buttons-controller.js +8 -4
- package/dist/reply-buttons-controller.js.map +1 -1
- package/dist/reply-buttons.d.ts +6 -2
- package/dist/reply-buttons.js +7 -3
- package/dist/reply-buttons.js.map +1 -1
- package/dist/scheduler/db.d.ts +10 -0
- package/dist/scheduler/db.js +38 -11
- package/dist/scheduler/db.js.map +1 -1
- package/dist/scheduler/types.d.ts +6 -1
- package/dist/settings-api.d.ts +9 -1
- package/dist/settings-api.js +200 -4
- package/dist/settings-api.js.map +1 -1
- package/dist/settings-confirmation.d.ts +1 -1
- package/dist/settings-confirmation.js +1 -1
- package/dist/settings-confirmation.js.map +1 -1
- package/dist/settings-effect.js +58 -0
- package/dist/settings-effect.js.map +1 -1
- package/dist/settings-http-confirmation.d.ts +3 -0
- package/dist/settings-http-confirmation.js +8 -5
- package/dist/settings-http-confirmation.js.map +1 -1
- package/dist/settings-request-capability.d.ts +5 -0
- package/dist/settings-request-capability.js +6 -1
- package/dist/settings-request-capability.js.map +1 -1
- package/dist/signin-keepalive.d.ts +2 -0
- package/dist/signin-keepalive.js +30 -2
- package/dist/signin-keepalive.js.map +1 -1
- package/dist/structured-signin-transport.d.ts +20 -2
- package/dist/structured-signin-transport.js +57 -6
- package/dist/structured-signin-transport.js.map +1 -1
- package/dist/team-membership.d.ts +7 -0
- package/dist/team-membership.js +10 -0
- package/dist/team-membership.js.map +1 -0
- package/dist/tmux-manager.d.ts +1 -1
- package/dist/tmux-manager.js +4 -1
- package/dist/tmux-manager.js.map +1 -1
- package/dist/topic-commands.js +1 -1
- package/dist/topic-commands.js.map +1 -1
- package/dist/ui/accounts-keepalive.js +10 -5
- package/dist/ui/accounts-manage.js +29 -11
- package/dist/ui/accounts-view.js +75 -28
- package/dist/ui/backend-signin.js +61 -16
- package/dist/ui/hub-attachments.js +3 -3
- package/dist/ui/hub-chat-strings.js +2 -0
- package/dist/ui/hub-client.js +50 -4
- package/dist/ui/hub-company-join-strings.js +74 -0
- package/dist/ui/hub-company-join.js +119 -0
- package/dist/ui/hub-group-policy.js +175 -0
- package/dist/ui/hub-group-strings.js +97 -0
- package/dist/ui/hub-owner-strings.js +12 -12
- package/dist/ui/hub-pairing-progress-strings.js +15 -0
- package/dist/ui/hub-quick-pairing.js +209 -0
- package/dist/ui/hub-quick-strings.js +43 -0
- package/dist/ui/hub-read-strings.js +7 -0
- package/dist/ui/hub-this-hub.js +112 -0
- package/dist/ui/hub-welcome.js +102 -0
- package/dist/ui/panel-hub.js +217 -28
- package/dist/ui/panel-needs.js +1 -1
- package/dist/ui/panel-settings.js +7 -4
- package/dist/ui/settings-apply.js +12 -5
- package/dist/ui/settings-devices.js +2 -2
- package/dist/ui/settings-dialogs.js +3 -1
- package/dist/ui/settings-hub-company-join.js +90 -0
- package/dist/ui/settings-hub-membership.js +20 -5
- package/dist/ui/settings-hub-preview.js +74 -0
- package/dist/ui/settings-hub-run.js +60 -0
- package/dist/ui/settings-hub-section.js +30 -3
- package/dist/ui/settings-hub.js +52 -11
- package/dist/ui/settings-registry.js +2 -0
- package/dist/ui/settings-restart-strings.js +17 -0
- package/dist/ui/settings-strings.js +6 -4
- package/dist/ui/shared/accounts-keepalive.css +11 -6
- package/dist/ui/shared/accounts.css +68 -18
- package/dist/ui/shared/app-i18n.js +4 -1
- package/dist/ui/shared/app-shell.js +39 -25
- package/dist/ui/shared/app.css +9 -8
- package/dist/ui/shared/chat-strings.js +13 -13
- package/dist/ui/shared/hub-chat.css +12 -0
- package/dist/ui/shared/hub-groups.css +28 -0
- package/dist/ui/shared/hub-owner.css +19 -1
- package/dist/ui/shared/hub.css +8 -1
- package/dist/ui/shared/setup-host-text.js +4 -1
- package/dist/ui/shared/signin.js +3 -1
- package/dist/ui/shared/usage-dialog.js +3 -72
- package/dist/ui/shared/usage-meter.js +84 -0
- package/dist/ui/shared/web-authorize.js +4 -4
- package/dist/ui/structured-signin.js +24 -6
- package/dist/update-dispatch.d.ts +32 -4
- package/dist/update-dispatch.js +146 -16
- package/dist/update-dispatch.js.map +1 -1
- package/dist/update-launch.d.ts +1 -1
- package/dist/update-launch.js +2 -2
- package/dist/update-launch.js.map +1 -1
- package/dist/update-marker.d.ts +2 -0
- package/dist/update-marker.js.map +1 -1
- package/dist/view-api.d.ts +2 -8
- package/dist/view-api.js +3 -9
- package/dist/view-api.js.map +1 -1
- package/dist/web-api.d.ts +7 -1
- package/dist/web-api.js +91 -14
- package/dist/web-api.js.map +1 -1
- package/dist/web-backend-login.d.ts +16 -2
- package/dist/web-backend-login.js +14 -0
- package/dist/web-backend-login.js.map +1 -1
- package/dist/web-notices.d.ts +9 -0
- package/dist/web-notices.js +19 -0
- package/dist/web-notices.js.map +1 -1
- package/dist/web-terminal.d.ts +7 -0
- package/dist/web-terminal.js +14 -2
- package/dist/web-terminal.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { hj } from "./hub-company-join-strings.js";
|
|
2
|
+
import { html, useEffect, useRef, useState } from "/assets/app-html.js";
|
|
3
|
+
import { ErrorState, Skeleton } from "/assets/ui-states.js";
|
|
4
|
+
import { confirmDialog } from "/assets/ui-confirm.js";
|
|
5
|
+
import { lang } from "/assets/app-i18n.js";
|
|
6
|
+
import { compareGroups, hubClient, safeWebOrigin } from "./hub-client.js";
|
|
7
|
+
import { hq } from "./hub-quick-strings.js";
|
|
8
|
+
import { hr } from "./hub-read-strings.js";
|
|
9
|
+
import { linkHubOwnerCss } from "./hub-owner-strings.js";
|
|
10
|
+
|
|
11
|
+
const reason = (r) => hq(r.code === "expired" ? "expired" : r.code === "conflict" ? "conflict" : r.code === "backpressure" ? "limit"
|
|
12
|
+
: r.code === "denied" || r.code === "revoked" ? "denied" : r.code === "unavailable" || r.code === "unreachable" ? "unavailable" : "failed");
|
|
13
|
+
const time = (at) => { try { return new Date(at).toLocaleString(lang() === "zh-TW" ? "zh-TW" : "en", { dateStyle: "medium", timeStyle: "short" }); } catch { return new Date(at).toLocaleString(); } };
|
|
14
|
+
|
|
15
|
+
/** The page controls its own attempt only. The separate fleet-local proof is never performed by this component. */
|
|
16
|
+
export function QuickPairingGuide({ allowed = false, publishAllowed = false, onConnected = () => {} }) {
|
|
17
|
+
const c = hubClient(), live = useRef(true), generation = useRef(0), reported = useRef(null);
|
|
18
|
+
const [attempt, setAttempt] = useState(null), [loading, setLoading] = useState(true), [busy, setBusy] = useState(false);
|
|
19
|
+
const [label, setLabel] = useState(""), [error, setError] = useState(null), [mismatch, setMismatch] = useState(false), [stopped, setStopped] = useState(false);
|
|
20
|
+
const [copied, setCopied] = useState(null), [full, setFull] = useState(false);
|
|
21
|
+
const load = async (id = null) => {
|
|
22
|
+
const captured = generation.current, r = await c.quickPairing(id);
|
|
23
|
+
if (!live.current || captured !== generation.current) return;
|
|
24
|
+
setLoading(false);
|
|
25
|
+
if (!r.ok) { if (r.code === "expired") { generation.current++; setAttempt(null); } setError(reason(r)); return; }
|
|
26
|
+
setError(null); setAttempt(old => r.attempt ? { ...(old?.id === r.attempt.id ? old : {}), ...r.attempt, memberOrigin: r.memberOrigin } : null);
|
|
27
|
+
};
|
|
28
|
+
useEffect(() => { linkHubOwnerCss(); live.current = true; void load(); return () => { live.current = false; generation.current++; }; }, []);
|
|
29
|
+
useEffect(() => { if (attempt?.connected && reported.current !== attempt.id) { reported.current = attempt.id; onConnected(); } }, [attempt?.connected, attempt?.id]);
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (!attempt?.id || attempt.connected || mismatch || stopped) return;
|
|
32
|
+
let pending = false;
|
|
33
|
+
const timer = setInterval(() => { if (!document.hidden && !pending) { pending = true; void load(attempt.id).finally(() => { pending = false; }); } }, 2000);
|
|
34
|
+
return () => clearInterval(timer);
|
|
35
|
+
}, [attempt?.id, attempt?.connected, mismatch, stopped]);
|
|
36
|
+
const create = async (event) => {
|
|
37
|
+
event.preventDefault(); if (busy || !allowed || !label.trim()) return;
|
|
38
|
+
const captured = ++generation.current; setBusy(true); setError(null); setMismatch(false); setStopped(false);
|
|
39
|
+
const r = await c.createQuickPairing(label.trim());
|
|
40
|
+
if (!live.current || captured !== generation.current) return;
|
|
41
|
+
setBusy(false);
|
|
42
|
+
if (!r.ok) { setError(reason(r)); return; }
|
|
43
|
+
setAttempt({ id: r.pairingId, code: r.code, expiresAt: r.expiresAt, memberOrigin: r.memberOrigin, state: "offered", connected: false });
|
|
44
|
+
};
|
|
45
|
+
const stop = async (different = false) => {
|
|
46
|
+
if (busy || !attempt?.id) return;
|
|
47
|
+
if (different) setMismatch(true);
|
|
48
|
+
const id = attempt.id, captured = ++generation.current; setBusy(true); setError(null);
|
|
49
|
+
const r = await c.stopQuickPairing(id);
|
|
50
|
+
if (!live.current || captured !== generation.current) return;
|
|
51
|
+
setBusy(false);
|
|
52
|
+
if (!r.ok) { setError(reason(r)); return; }
|
|
53
|
+
setStopped(true); setAttempt(null);
|
|
54
|
+
};
|
|
55
|
+
const match = async () => {
|
|
56
|
+
if (busy || mismatch || !attempt?.fingerprint) return;
|
|
57
|
+
const id = attempt.id, fp = attempt.fingerprint, captured = generation.current; setBusy(true); setError(null);
|
|
58
|
+
const r = await c.confirmPairing(id, fp);
|
|
59
|
+
if (!live.current || captured !== generation.current) return;
|
|
60
|
+
setBusy(false); if (!r.ok) { setError(reason(r)); return; }
|
|
61
|
+
await load(id);
|
|
62
|
+
};
|
|
63
|
+
const copy = async (key, value) => { try { await navigator.clipboard.writeText(value); if (live.current) setCopied(key); } catch { /* text remains selectable */ } };
|
|
64
|
+
// The Hub cannot observe the fleet-local button. Only its later claim proves that step completed; accepting
|
|
65
|
+
// the code or confirming on the Hub alone does not. Connected still requires the pinned ready link below.
|
|
66
|
+
if (loading) return html`<${Skeleton} variant="rows" lines=${2} />`;
|
|
67
|
+
if (!allowed && !attempt && !error) return null;
|
|
68
|
+
return html`<div data-quick-pairing="guide">
|
|
69
|
+
${error ? html`<${ErrorState} message=${error} onRetry=${() => load(attempt?.id)} />` : null}
|
|
70
|
+
${mismatch ? html`<p class="err" role="alert">${stopped ? hq("mismatchStop") : hq("compare")}</p>` : null}
|
|
71
|
+
${stopped ? html`<p class="note" role="status">${hq("stopped")}</p>` : null}
|
|
72
|
+
${!attempt ? allowed ? html`<form class="form" onSubmit=${create}><label class="field" for="quickFleetLabel"><span>${hq("label")}</span>
|
|
73
|
+
<input id="quickFleetLabel" value=${label} maxLength="120" required placeholder=${hq("labelExample")} onInput=${e => setLabel(e.target.value)} />
|
|
74
|
+
<small class="note">${hq("labelHint")} ${hq("privacy")}</small></label><div class="field-row"><button type="submit" class="btn btn-primary" disabled=${busy || !label.trim()}>${hq(stopped ? "again" : "start")}</button></div></form>` : null
|
|
75
|
+
: attempt.connected ? html`<p class="note" role="status"><b>${hq("connected")}</b></p><h4>${hq("publish")}</h4><p class="note">${hq(publishAllowed ? "publishHint" : "publishNo")}</p>
|
|
76
|
+
${allowed ? html`<div class="field-row"><button type="button" class="btn" onClick=${() => { generation.current++; setAttempt(null); }}>${hq("another")}</button></div>` : null}`
|
|
77
|
+
: html`<ol class="hub-steps"><li class=${attempt.state === "claimed" ? "done" : "now"}><div class="hub-step-body"><h4>${hq("localTitle")}</h4><p class="note">${hq("local")}</p>
|
|
78
|
+
<span class="note">${hq("address")}</span><code class="hub-fp-full">${attempt.memberOrigin}</code>
|
|
79
|
+
${attempt.code ? html`<span class="note">${hq("code")}</span><code class="hub-fp-groups">${attempt.code}</code><button type="button" class="btn btn-sm" onClick=${() => copy("code", attempt.code)}>${hq(copied === "code" ? "copied" : "copy")}</button>` : html`<p class="note">${hq(attempt.state === "claimed" ? "claim" : "waiting")}</p>`}
|
|
80
|
+
<p class="note">${hq("expires", time(attempt.expiresAt))}</p></div></li>
|
|
81
|
+
<li class=${attempt.fingerprint ? "now" : ""}><div class="hub-step-body"><h4>${hq("compareTitle")}</h4><p class="note">${hq("compare")}</p>
|
|
82
|
+
${attempt.fingerprint ? html`<code class="hub-fp-groups">${compareGroups(attempt.fingerprint)}</code>
|
|
83
|
+
<button type="button" class="btn btn-sm btn-ghost" aria-expanded=${full} onClick=${() => setFull(!full)}>${full ? "SHA-256 −" : "SHA-256 +"}</button>
|
|
84
|
+
${full ? html`<code class="hub-fp-full">${attempt.fingerprint}</code>` : null}
|
|
85
|
+
${attempt.ownerConfirmed ? html`<p class="note" role="status">${hq("claim")}</p>` : html`<div class="field-row"><button type="button" class="btn btn-primary" disabled=${busy || mismatch} onClick=${match}>${hq("match")}</button>
|
|
86
|
+
<button type="button" class="btn" disabled=${busy} onClick=${() => stop(true)}>${hq("mismatch")}</button></div>`}` : null}
|
|
87
|
+
</div></li></ol>`}
|
|
88
|
+
${attempt && !attempt.connected ? html`<div class="field-row"><button type="button" class="btn" disabled=${busy} onClick=${() => stop(false)}>${hq("stop")}</button></div>` : null}
|
|
89
|
+
</div>`;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function Notice({ notice, admin = false, memberOrigin = null, after = () => {} }) {
|
|
93
|
+
const [busy, setBusy] = useState(false), [error, setError] = useState(false);
|
|
94
|
+
const live = useRef(true); useEffect(() => () => { live.current = false; }, []);
|
|
95
|
+
const revoke = async () => {
|
|
96
|
+
if (busy || notice.revoked) return;
|
|
97
|
+
if (!(await confirmDialog({ message: hq("revokeAsk", notice.label), confirmLabel: hq("revoke"), danger: true })) || !live.current) return;
|
|
98
|
+
setBusy(true); setError(false); const c = hubClient();
|
|
99
|
+
const r = await (admin ? c.revokeFleet(notice.fleetId) : c.revokeOwnFleet(notice.fleetId, notice.generation));
|
|
100
|
+
if (!live.current) return;
|
|
101
|
+
setBusy(false); if (!r.ok) setError(true); else after();
|
|
102
|
+
};
|
|
103
|
+
let href = null;
|
|
104
|
+
if (memberOrigin) { try { const origin = new URL(memberOrigin); if (origin.protocol === "https:") href = `${origin.origin}/ui/hub?securityNotice=${encodeURIComponent(notice.id)}`; } catch { /* no link */ } }
|
|
105
|
+
return html`<div data-pairing-notice=${notice.id}><p><b>${hq("notice", notice.label)}</b></p><p class="note">${notice.source === "manual" ? hj("manualApproved") : hq("approved")} ${time(notice.at)}</p>
|
|
106
|
+
<p class="note">${hq("fleetId")} <code class="hub-fp-full">${notice.fleetId}</code></p>
|
|
107
|
+
<p class="note">${hq("revokeHint")}</p>
|
|
108
|
+
${notice.revoked ? html`<span class="tag">${hq("revoked")}</span>` : href ? html`<a class="btn" target="_blank" rel="noopener noreferrer" href=${href}>${hq("review")}</a>`
|
|
109
|
+
: html`<div class="field-row"><button type="button" class="btn btn-danger" disabled=${busy} onClick=${revoke}>${hq("revoke")}</button></div>`}
|
|
110
|
+
${error ? html`<p class="err" role="alert">${hq("revokeFailed")}</p>` : null}</div>`;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Narrowing remains available when current connect permission is denied or unknown. */
|
|
114
|
+
export function OwnedFleetRevoke({ fleet, onRevoked }) {
|
|
115
|
+
const [busy, setBusy] = useState(false), [error, setError] = useState(false);
|
|
116
|
+
const live = useRef(true); useEffect(() => () => { live.current = false; }, []);
|
|
117
|
+
if (!Number.isSafeInteger(fleet.generation) || fleet.status === "revoked") return null;
|
|
118
|
+
const revoke = async () => {
|
|
119
|
+
if (busy) return;
|
|
120
|
+
if (!(await confirmDialog({ message: hq("revokeAsk", fleet.label || fleet.id), confirmLabel: hq("revoke"), danger: true })) || !live.current) return;
|
|
121
|
+
setBusy(true); setError(false);
|
|
122
|
+
const r = await hubClient().revokeOwnFleet(fleet.id, fleet.generation);
|
|
123
|
+
if (!live.current) return;
|
|
124
|
+
setBusy(false); if (r.ok) onRevoked(); else setError(true);
|
|
125
|
+
};
|
|
126
|
+
return html`<button type="button" class="btn btn-sm btn-danger" disabled=${busy} onClick=${revoke}>${hq("revoke")}</button>
|
|
127
|
+
${error ? html`<small class="err" role="alert">${hq("revokeFailed")}</small>` : null}`;
|
|
128
|
+
}
|
|
129
|
+
export function PairingNotices({ admin = false, memberNotices = null, memberOrigin = null, empty = null }) {
|
|
130
|
+
const c = hubClient(), live = useRef(true), epoch = useRef(0), acked = useRef(new Set());
|
|
131
|
+
const [noticeError, setNoticeError] = useState(null);
|
|
132
|
+
const [notices, setNotices] = useState(memberNotices || []);
|
|
133
|
+
const [historyOpen, setHistoryOpen] = useState(false), [historyCount, setHistoryCount] = useState(99);
|
|
134
|
+
const load = async () => {
|
|
135
|
+
const mine = epoch.current;
|
|
136
|
+
let r; try { r = await c.pairingNotices(); } catch { r = { ok: false, code: "unreachable" }; }
|
|
137
|
+
if (live.current && mine === epoch.current) {
|
|
138
|
+
if (r.ok) { setNotices(r.notices || []); setNoticeError(null); }
|
|
139
|
+
else { setNotices([]); setNoticeError(r.code === "backpressure" ? "busy" : "noticesUnavailable"); }
|
|
140
|
+
}
|
|
141
|
+
return r;
|
|
142
|
+
};
|
|
143
|
+
useEffect(() => {
|
|
144
|
+
live.current = true; const mine = ++epoch.current;
|
|
145
|
+
const current = () => live.current && mine === epoch.current;
|
|
146
|
+
if (memberNotices) { setNotices(memberNotices); setNoticeError(null); return () => { live.current = false; epoch.current++; }; }
|
|
147
|
+
let off = () => {}, timer = null, reading = false;
|
|
148
|
+
const later = (fn, r = {}) => {
|
|
149
|
+
const seconds = Number(r.retryAfter); clearTimeout(timer);
|
|
150
|
+
timer = setTimeout(() => { if (current()) void fn(); },
|
|
151
|
+
(Number.isFinite(seconds) && seconds > 0 ? Math.max(1, Math.min(300, seconds)) : 10) * 1000);
|
|
152
|
+
};
|
|
153
|
+
const recover = async () => {
|
|
154
|
+
if (!current() || reading) return;
|
|
155
|
+
off(); reading = true;
|
|
156
|
+
const r = await load(); reading = false;
|
|
157
|
+
if (!current()) return;
|
|
158
|
+
if (r.ok) { setNoticeError("noticesRetry"); later(subscribe); }
|
|
159
|
+
else later(recover, r);
|
|
160
|
+
};
|
|
161
|
+
const subscribe = () => {
|
|
162
|
+
if (!current()) return;
|
|
163
|
+
off(); off = c.subscribePairingNotices(rows => { if (current()) { setNotices(rows); setNoticeError(null); } },
|
|
164
|
+
() => { if (current()) { setNoticeError("noticesRetry"); void recover(); } });
|
|
165
|
+
};
|
|
166
|
+
if (c.pairingNoticeSnapshotV1 === true) subscribe();
|
|
167
|
+
else void load().then(r => { if (current()) { if (r.ok) subscribe(); else later(recover, r); } });
|
|
168
|
+
return () => { live.current = false; epoch.current++; clearTimeout(timer); off(); };
|
|
169
|
+
}, [memberNotices]);
|
|
170
|
+
const requested = new URLSearchParams(location.search).get("securityNotice"), target = notices.find(n => n.id === requested) || notices[0];
|
|
171
|
+
const older = notices.filter(n => n !== target);
|
|
172
|
+
useEffect(() => {
|
|
173
|
+
if (memberNotices || !target) return;
|
|
174
|
+
let cancelled = false;
|
|
175
|
+
// A collapsed history is not shown. Bound rendering and ACK fan-out even at the 1024-record retention cap.
|
|
176
|
+
void (async () => { for (const n of [target, ...(historyOpen ? older.slice(0, historyCount) : [])]) {
|
|
177
|
+
if (cancelled || !live.current) return;
|
|
178
|
+
if (acked.current.has(n.id)) continue;
|
|
179
|
+
acked.current.add(n.id);
|
|
180
|
+
try { if (!(await c.acknowledgePairingNotice(n.id)).ok) acked.current.delete(n.id); }
|
|
181
|
+
catch { acked.current.delete(n.id); }
|
|
182
|
+
} })();
|
|
183
|
+
return () => { cancelled = true; };
|
|
184
|
+
}, [notices, memberNotices, historyOpen, historyCount]);
|
|
185
|
+
// `empty`: what a page of its own shows with no notice (the Hub's Notices page, cid-hub-shell-parity); elsewhere nothing.
|
|
186
|
+
if (!target && !noticeError) return empty;
|
|
187
|
+
const status = noticeError ? html`<p class="note" role="status" data-notices="retrying">${hr(noticeError)}</p>` : null;
|
|
188
|
+
if (!target) return html`<aside class="card hub-security-notices" aria-label=${hq("notices")}><h3>${hq("notices")}</h3>${status}</aside>`;
|
|
189
|
+
return html`<aside class="card hub-security-notices" aria-label=${hq("notices")}><h3>${hq("notices")}</h3>${status}
|
|
190
|
+
<${Notice} key=${target.id} notice=${target} admin=${admin} memberOrigin=${memberOrigin} after=${load} />
|
|
191
|
+
${older.length ? html`<details onToggle=${e => setHistoryOpen(e.currentTarget.open)}><summary>${hq("previous")} (${older.length})</summary>
|
|
192
|
+
${older.slice(0, historyCount).map(n => html`<${Notice} key=${n.id} notice=${n} admin=${admin} memberOrigin=${memberOrigin} after=${load} />`)}
|
|
193
|
+
${historyCount < older.length ? html`<button type="button" class="btn btn-sm" onClick=${() => setHistoryCount(n => n + 100)}>${hq("more")}</button>` : null}</details>` : null}
|
|
194
|
+
</aside>`;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** Same private, visible-only member poll as the switcher; no notice payload enters the fleet-wide SSE/guest stream. */
|
|
198
|
+
export function MemberPairingNotices() {
|
|
199
|
+
const c = hubClient(), [pairing, setPairing] = useState(null), [rows, setRows] = useState([]);
|
|
200
|
+
useEffect(() => {
|
|
201
|
+
if (!c.member || typeof c.pairingNotices !== "function") return;
|
|
202
|
+
let live = true;
|
|
203
|
+
const update = p => { if (live) { setPairing(p); setRows(c.pairingNotices()); } };
|
|
204
|
+
void c.pairing().then(update, () => {});
|
|
205
|
+
const off = c.subscribe(update); return () => { live = false; off(); };
|
|
206
|
+
}, []);
|
|
207
|
+
const origin = safeWebOrigin(pairing);
|
|
208
|
+
return origin && rows.length ? html`<${PairingNotices} memberNotices=${rows} memberOrigin=${origin} />` : null;
|
|
209
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Separate words so a cached earlier hub-strings module cannot expose raw keys.
|
|
2
|
+
import { register, t } from "/assets/app-i18n.js";
|
|
3
|
+
register("hubQuick", {
|
|
4
|
+
en: {
|
|
5
|
+
start: "Connect my fleet", label: "Fleet name", labelHint: "A name you and your Hub admin will recognise.",
|
|
6
|
+
labelExample: "For example, my laptop", privacy: "Connect only a fleet you control. Your other Hub sessions, connected fleets and Hub admin will be notified.",
|
|
7
|
+
localTitle: "Confirm on your fleet", local: "On your fleet's web page, open Settings → Hub. Turn on Allow this fleet to connect to a Hub, then paste this address into the Hub address field and enter the one-time code. Confirm the local prompt there.",
|
|
8
|
+
remoteSteps: "Finish the fingerprint check on the Hub too.", ownerStep: "On the Hub, compare this fingerprint and confirm your pairing.", policyStep: "The Hub checks its group policy, or waits for its administrator's approval.",
|
|
9
|
+
address: "Hub address", code: "One-time code", copy: "Copy", copied: "Copied", expires: "Expires {0}",
|
|
10
|
+
compareTitle: "Compare the fingerprints", compare: "On your fleet, open Settings → Hub → Waiting for approval. Compare its fingerprint with this one. Confirm locally on your fleet too.",
|
|
11
|
+
match: "They match", mismatch: "They differ", mismatchStop: "The fingerprints differ. Pairing is stopped; no connection was approved. Start again only after checking the address.",
|
|
12
|
+
stop: "Stop pairing", stopped: "Pairing stopped", again: "Start again", waiting: "Waiting for your fleet's code and local confirmation…",
|
|
13
|
+
another: "Connect another fleet",
|
|
14
|
+
claim: "Waiting for your fleet's pinned connection…", connected: "Connected", publish: "Share agents on your fleet", publishHint: "On your fleet, open Settings → Hub → Shared agents. Choose only the agents you want to share and confirm there. Nothing is shared automatically.",
|
|
15
|
+
publishNo: "Your fleet is connected. Sharing new agents is not included in your current permissions; contact your Hub admin.",
|
|
16
|
+
expired: "This attempt expired or was replaced. It cannot connect a fleet. Start again.", unavailable: "Permissions or the connection can't be checked right now. Retry; this page can't confirm whether pairing finished.",
|
|
17
|
+
denied: "Connecting a fleet is not available to you. Contact your Hub admin.", conflict: "An administrator's pairing code is already waiting for you. Use that code, or ask the admin for help.",
|
|
18
|
+
limit: "Your fleet or pairing limit is reached. Stop an unused attempt or revoke a fleet you no longer use, then try again.", retry: "Retry", failed: "This action could not finish. Retry.",
|
|
19
|
+
notices: "Fleet security notices", notice: "A new fleet was connected: {0}", approved: "Approved by your Hub's group policy.",
|
|
20
|
+
revoke: "Revoke this fleet", revokeAsk: "Revoke {0}? It loses its Hub access at once. Your other fleets and local agent work stay in place.", revoked: "Revoked", revokeHint: "Stops this fleet's Hub access. Your other fleets and local agent work stay in place.",
|
|
21
|
+
review: "Review and revoke on the Hub", previous: "Earlier notices", more: "Show older notices", fleetId: "Fleet ID", revokeFailed: "The fleet could not be revoked. Sign in again if your session ended, then retry.",
|
|
22
|
+
},
|
|
23
|
+
"zh-TW": {
|
|
24
|
+
start: "連接我的 Fleet", label: "Fleet 名稱", labelHint: "取一個你和 Hub 管理員都認得的名字。", labelExample: "例如:我的筆電",
|
|
25
|
+
privacy: "只連接你能控制的 Fleet。你的其他 Hub 登入工作階段、已連接的 Fleet 和 Hub 管理員都會收到通知。",
|
|
26
|
+
localTitle: "在你的 Fleet 確認", local: "在你的 Fleet 網頁開啟「設定 → Hub」,開啟「允許這個 Fleet 連線至 Hub」,將以下位址貼到「Hub 位址」欄位,再輸入一次性代碼,並在當地確認提示。",
|
|
27
|
+
remoteSteps: "也要在 Hub 完成指紋比對。", ownerStep: "在 Hub 比對這個指紋,並確認你的配對。", policyStep: "Hub 會檢查群組規則,或等待管理員核准。",
|
|
28
|
+
address: "Hub 位址", code: "一次性代碼", copy: "複製", copied: "已複製", expires: "有效至 {0}",
|
|
29
|
+
compareTitle: "比對指紋", compare: "在你的 Fleet 開啟「設定 → Hub → 等待核准」,將當地指紋與下方逐一比對,也要在你的 Fleet 確認。",
|
|
30
|
+
match: "指紋相符", mismatch: "指紋不同", mismatchStop: "指紋不同,已停止配對,沒有核准連線。請先檢查位址,再重新開始。",
|
|
31
|
+
stop: "停止配對", stopped: "已停止配對", again: "重新開始", waiting: "等待你的 Fleet 使用代碼並在當地確認…", claim: "等待你的 Fleet 建立已固定憑證的連線…",
|
|
32
|
+
another: "連接另一個 Fleet",
|
|
33
|
+
connected: "已連接", publish: "在你的 Fleet 分享 Agent", publishHint: "在你的 Fleet 開啟「設定 → Hub → 已分享的 Agent」,選擇你要分享的 Agent 並在當地確認。不會自動分享任何 Agent。",
|
|
34
|
+
publishNo: "Fleet 已連接,但你目前的權限不包含分享新的 Agent。請聯絡 Hub 管理員。",
|
|
35
|
+
expired: "這次配對已過期或被取代,無法再連接 Fleet。請重新開始。", unavailable: "目前無法確認權限或連線。請重試;此頁無法確認配對是否已完成。",
|
|
36
|
+
denied: "你目前無法連接 Fleet。請聯絡 Hub 管理員。", conflict: "管理員已為你建立配對代碼。請使用該代碼,或請管理員協助。",
|
|
37
|
+
limit: "已達 Fleet 或配對數量上限。請停止未使用的配對,或撤銷不再使用的 Fleet,再重試。", retry: "重試", failed: "這次操作未能完成,請重試。",
|
|
38
|
+
notices: "Fleet 安全通知", notice: "已連接新的 Fleet:{0}", approved: "由 Hub 群組規則核准。", revoke: "撤銷此 Fleet", revokeAsk: "要撤銷「{0}」嗎?它會立即失去 Hub 存取。你的其他 Fleet 和本機 Agent 工作不受影響。", revoked: "已撤銷",
|
|
39
|
+
revokeHint: "停止這個 Fleet 的 Hub 存取。你的其他 Fleet 和本機 Agent 工作不受影響。", review: "在 Hub 查看並撤銷", previous: "較早的通知", more: "顯示更早的通知", fleetId: "Fleet ID",
|
|
40
|
+
revokeFailed: "無法撤銷此 Fleet。如果登入已結束,請重新登入後再重試。",
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
export const hq = (key, ...args) => t(`hubQuick.${key}`, ...args);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Read recovery copy is loaded with its consumers, including tabs retaining older group strings.
|
|
2
|
+
import { register, t } from "/assets/app-i18n.js";
|
|
3
|
+
register("hubRead", {
|
|
4
|
+
en: { noticesRetry: "Live security notices are reconnecting. Retrying shortly…", noticesUnavailable: "Security notices can't be checked right now. Retrying shortly…", busy: "The Hub is busy. Retrying shortly…", catalogUnavailable: "Shared agents can't be checked right now. Retry." },
|
|
5
|
+
"zh-TW": { noticesRetry: "安全通知連線中斷,稍後會自動重試…", noticesUnavailable: "目前無法讀取安全通知,稍後會自動重試…", busy: "Hub 忙碌中,稍後會自動重試…", catalogUnavailable: "目前無法確認已分享的 Agent,請重試。" },
|
|
6
|
+
});
|
|
7
|
+
export const hr = (key) => t(`hubRead.${key}`);
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// M-2682: Hub Administration → This Hub, for the Hub's configured administrator. What this Hub is (read-only: its name, Hub ID,
|
|
2
|
+
// the member key fingerprint members compare when they pair, the issuer key id and the AgEnD version) and its name, changed
|
|
3
|
+
// or removed here instead of in the host's configuration (721ca0c3). How it was installed (hub.coexistence) is shown, not edited. The server reseals the Hub's settings with its own key
|
|
4
|
+
// and reloads the Hub with the new name; this card then reloads the page so the brand shows it. One click, no extra dialog:
|
|
5
|
+
// a name is not a security decision. Its own lazy module with its own words, so an older tab or server simply leaves it out.
|
|
6
|
+
// Shared components: card, field, btn, note, err, Skeleton.
|
|
7
|
+
import { html, useEffect, useState } from "/assets/app-html.js";
|
|
8
|
+
import { register, t } from "/assets/app-i18n.js";
|
|
9
|
+
import { Skeleton } from "/assets/ui-states.js";
|
|
10
|
+
import { toast } from "/assets/ui-toast.js";
|
|
11
|
+
import { hubClient, compareGroups } from "./hub-client.js";
|
|
12
|
+
|
|
13
|
+
register("hubThisHub", {
|
|
14
|
+
en: {
|
|
15
|
+
title: "This Hub", lead: "Its name is shown on the sign-in page and when you point at AgEnD Hub in the sidebar. The rest identifies this Hub and can't be changed here.",
|
|
16
|
+
name: "Hub name", noName: "No name", namePlaceholder: "No name: shown as AgEnD Hub", nameHint: "Up to 64 characters.",
|
|
17
|
+
save: "Save name", removeName: "Remove name", saving: "Saving…",
|
|
18
|
+
saved: "Saved. The Hub is reloading with its new name.", removed: "Name removed. The Hub is reloading.",
|
|
19
|
+
hubId: "Hub ID", memberKey: "Member key fingerprint", memberKeyHint: "People compare this when they pair a fleet with this Hub.",
|
|
20
|
+
issuerKey: "Issuer key", version: "AgEnD version", unknown: "Unknown",
|
|
21
|
+
install: "Installed as", install_dedicated: "Dedicated: this computer runs only the Hub", "install_same-user-pilot": "Beside a fleet, under the same user",
|
|
22
|
+
installHint: "Chosen when the Hub was set up.",
|
|
23
|
+
err_invalid: "Use 1 to 64 characters, without line breaks or control characters.",
|
|
24
|
+
err_unchanged: "That is already this Hub's name.",
|
|
25
|
+
err_stale: "The Hub's settings changed meanwhile. Check the name and save again.",
|
|
26
|
+
err_expired: "That took too long. Save again.",
|
|
27
|
+
err_busy: "Another change to the Hub's settings is still finishing. Try again in a moment.",
|
|
28
|
+
err_denied: "Only this Hub's administrator can rename it. Sign in again and retry.",
|
|
29
|
+
err_unavailable: "The Hub's settings can't be changed right now. Reload this page and try again.",
|
|
30
|
+
err_recovery: "The rename didn't finish. Reload this page to see the Hub's current name, then try again if it's not the one you want.",
|
|
31
|
+
err_failed: "The name wasn't saved. Try again.",
|
|
32
|
+
},
|
|
33
|
+
"zh-TW": {
|
|
34
|
+
title: "這個 Hub", lead: "名稱會顯示在登入頁,滑鼠移到側邊欄的 AgEnD Hub 上也會看到。其餘資料用來識別這個 Hub,不能在這裡變更。",
|
|
35
|
+
name: "Hub 名稱", noName: "沒有名稱", namePlaceholder: "沒有名稱:顯示為 AgEnD Hub", nameHint: "最多 64 個字元。",
|
|
36
|
+
save: "儲存名稱", removeName: "移除名稱", saving: "儲存中…",
|
|
37
|
+
saved: "已儲存。Hub 正在以新名稱重新載入。", removed: "已移除名稱。Hub 正在重新載入。",
|
|
38
|
+
hubId: "Hub ID", memberKey: "成員金鑰指紋", memberKeyHint: "有人把 Fleet 配對到這個 Hub 時,會比對這組指紋。",
|
|
39
|
+
issuerKey: "簽發金鑰", version: "AgEnD 版本", unknown: "不明",
|
|
40
|
+
install: "安裝方式", install_dedicated: "專用:這台電腦只執行 Hub", "install_same-user-pilot": "與 Fleet 共用同一個使用者",
|
|
41
|
+
installHint: "在設定 Hub 時選定。",
|
|
42
|
+
err_invalid: "請輸入 1 到 64 個字元,不能有換行或控制字元。",
|
|
43
|
+
err_unchanged: "這已經是這個 Hub 的名稱。",
|
|
44
|
+
err_stale: "Hub 的設定剛剛有變更。請確認名稱後再儲存一次。",
|
|
45
|
+
err_expired: "等候太久了,請再儲存一次。",
|
|
46
|
+
err_busy: "Hub 設定的另一項變更還在完成中,請稍後再試。",
|
|
47
|
+
err_denied: "只有這個 Hub 的管理員可以改名。請重新登入後再試。",
|
|
48
|
+
err_unavailable: "目前無法變更 Hub 的設定。請重新載入這個頁面後再試。",
|
|
49
|
+
err_recovery: "改名沒有完成。請重新載入這個頁面查看 Hub 目前的名稱,如果不是你要的名稱再試一次。",
|
|
50
|
+
err_failed: "名稱沒有儲存,請再試一次。",
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
const ht = (k, ...a) => t(`hubThisHub.${k}`, ...a);
|
|
54
|
+
const INSTALL = new Set(["dedicated", "same-user-pilot"]);
|
|
55
|
+
const ERR = new Set(["invalid", "unchanged", "stale", "expired", "busy", "denied", "unavailable", "recovery"]);
|
|
56
|
+
const errText = (r) => ht(`err_${ERR.has(r.code) ? r.code : "failed"}`);
|
|
57
|
+
|
|
58
|
+
/** After a rename the Hub reloads itself; wait until it answers with the new name, then reload this page (its brand). */
|
|
59
|
+
async function reloadWhenRenamed(name, { tries = 30, every = 1000 } = {}) {
|
|
60
|
+
for (let i = 0; i < tries; i++) {
|
|
61
|
+
await new Promise((r) => setTimeout(r, every));
|
|
62
|
+
try {
|
|
63
|
+
const r = await fetch("/hub/v1/session", { credentials: "same-origin", cache: "no-store" });
|
|
64
|
+
if (r.ok) { const s = await r.json(); if ((s?.hub?.name || null) === name) break; }
|
|
65
|
+
} catch { /* the Hub is restarting */ }
|
|
66
|
+
}
|
|
67
|
+
location.reload();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function ThisHubCard() {
|
|
71
|
+
const client = hubClient();
|
|
72
|
+
const [info, setInfo] = useState(undefined); // undefined: reading; null: not offered here
|
|
73
|
+
const [draft, setDraft] = useState("");
|
|
74
|
+
const [busy, setBusy] = useState(false);
|
|
75
|
+
const [error, setError] = useState("");
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
let live = true;
|
|
78
|
+
if (!client || client.thisHubV1 !== true) { setInfo(null); return; }
|
|
79
|
+
client.thisHub().then((r) => { if (!live) return; if (r.ok) { setInfo(r); setDraft(r.name || ""); } else setInfo(null); });
|
|
80
|
+
return () => { live = false; };
|
|
81
|
+
}, []);
|
|
82
|
+
if (info === null) return null;
|
|
83
|
+
if (info === undefined) return html`<section class="card hub-this-hub"><h3>${ht("title")}</h3><${Skeleton} variant="rows" lines=${3} /></section>`;
|
|
84
|
+
const save = async (name) => {
|
|
85
|
+
setBusy(true); setError("");
|
|
86
|
+
const p = await client.prepareHubName(name);
|
|
87
|
+
const c = p.ok ? await client.commitHubName(p.ref) : p;
|
|
88
|
+
if (!c.ok) { setBusy(false); setError(errText(c)); return; }
|
|
89
|
+
toast(ht(name === null ? "removed" : "saved"));
|
|
90
|
+
reloadWhenRenamed(name);
|
|
91
|
+
};
|
|
92
|
+
const typed = draft.trim(), current = info.name || "";
|
|
93
|
+
// The Hub's name shows here in plain sight (the sidebar's brand carries it only as its tooltip — the leader on Argon #18).
|
|
94
|
+
return html`<section class="card hub-this-hub" data-section="this-hub"><div class="hub-card-head"><h3>${ht("title")}</h3><span class="s-scope" data-hub-name=${current ? "set" : "none"}>${current || ht("noName")}</span></div><p class="note">${ht("lead")}</p>
|
|
95
|
+
${info.rename ? html`<form class="hub-this-form" onSubmit=${(e) => { e.preventDefault(); if (typed && typed !== current) save(typed); }}>
|
|
96
|
+
<label class="field"><span>${ht("name")}</span><input id="hubThisName" maxlength="64" autocomplete="off" placeholder=${ht("namePlaceholder")} value=${draft} disabled=${busy}
|
|
97
|
+
onInput=${(e) => { setDraft(e.target.value); setError(""); }} /><small class="note">${ht("nameHint")}</small></label>
|
|
98
|
+
<div class="hub-this-actions">
|
|
99
|
+
<button type="submit" class="btn btn-primary" disabled=${busy || !typed || typed === current}>${busy ? ht("saving") : ht("save")}</button>
|
|
100
|
+
${current ? html`<button type="button" class="btn" disabled=${busy} onClick=${() => save(null)}>${ht("removeName")}</button>` : null}
|
|
101
|
+
</div>
|
|
102
|
+
</form>` : html`<div class="field"><span>${ht("name")}</span><span>${current || ht("namePlaceholder")}</span></div>`}
|
|
103
|
+
${error ? html`<p class="err" role="alert">${error}</p>` : null}
|
|
104
|
+
<dl class="hub-this-facts">
|
|
105
|
+
<dt>${ht("hubId")}</dt><dd><code>${info.hubId}</code></dd>
|
|
106
|
+
<dt>${ht("memberKey")}</dt><dd><code class="hub-fp-groups" title=${info.memberSpkiSha256}>${compareGroups(info.memberSpkiSha256)}</code><small class="note">${ht("memberKeyHint")}</small></dd>
|
|
107
|
+
<dt>${ht("issuerKey")}</dt><dd><code>${info.issuerKeyId}</code></dd>
|
|
108
|
+
<dt>${ht("version")}</dt><dd>${info.version || ht("unknown")}</dd>
|
|
109
|
+
${info.coexistence ? html`<dt>${ht("install")}</dt><dd>${INSTALL.has(info.coexistence) ? ht(`install_${info.coexistence}`) : html`<code>${info.coexistence}</code>`}<small class="note">${ht("installHint")}</small></dd>` : null}
|
|
110
|
+
</dl>
|
|
111
|
+
</section>`;
|
|
112
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// #3298 S-89: the signed-in welcome on a Hub with group permissions — two large entries, "Chat with an agent" and "Connect your
|
|
2
|
+
// fleet", shaped by what this person may do now (no actions / ask only / full). It is a DISPLAY of the server's welcome
|
|
3
|
+
// projection (GET /hub/v1/me/welcome): it grants nothing, and every chat, pairing or sharing action asks the server again.
|
|
4
|
+
// An answer the directory couldn't give is "can't be checked right now" with Retry, never a cached yes. Shared components:
|
|
5
|
+
// a lead line, card, btn, tag, note, Skeleton/ErrorState; the two cards sit in .hub-welcome (hub.css: a two-up grid, one column
|
|
6
|
+
// on a phone).
|
|
7
|
+
import { html, useEffect, useRef, useState } from "/assets/app-html.js";
|
|
8
|
+
import { ErrorState, Skeleton } from "/assets/ui-states.js";
|
|
9
|
+
import { navigate } from "/assets/app-nav.js";
|
|
10
|
+
import { hubClient, hubName } from "./hub-client.js";
|
|
11
|
+
import { hg } from "./hub-group-strings.js";
|
|
12
|
+
import { hr } from "./hub-read-strings.js";
|
|
13
|
+
import { OwnedFleetRevoke, QuickPairingGuide } from "./hub-quick-pairing.js";
|
|
14
|
+
|
|
15
|
+
const FLEET_STATUS = { active: "fleetActive", suspended: "fleetPaused", revoked: "fleetRevoked", unknown: "fleetUnknown" };
|
|
16
|
+
|
|
17
|
+
/** Why an entry is unavailable, in the person's words. */
|
|
18
|
+
export function reasonText(entry, fallback) {
|
|
19
|
+
if (!entry) return hg(fallback);
|
|
20
|
+
if (entry.state === "unknown") return hg("unknown");
|
|
21
|
+
const r = entry.reason;
|
|
22
|
+
return hg(r === "person-denied" ? "deniedPerson" : r === "ineligible" ? "ineligible" : r === "suspended" ? "suspended" : fallback);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* `onChats` opens the chat list (the caller's own navigation). `askable` is how many agents are shared with this person
|
|
27
|
+
* (the catalog's own count), so a new owner with nothing shared reads "No agents have been shared with you yet".
|
|
28
|
+
*/
|
|
29
|
+
export function HubWelcome({ name, quick = false, onChats = () => navigate("/ui/hub?chats=1") }) {
|
|
30
|
+
const c = hubClient();
|
|
31
|
+
const [w, setW] = useState(null), [askable, setAskable] = useState(null), [error, setError] = useState(null);
|
|
32
|
+
const live = useRef(true), generation = useRef(0), retry = useRef(null);
|
|
33
|
+
const load = async () => {
|
|
34
|
+
if (!live.current) return;
|
|
35
|
+
clearTimeout(retry.current); retry.current = null;
|
|
36
|
+
const mine = ++generation.current;
|
|
37
|
+
const current = () => live.current && mine === generation.current;
|
|
38
|
+
const failed = (r, reason = "unknown") => {
|
|
39
|
+
if (!current()) return;
|
|
40
|
+
setError(r.code === "backpressure" ? "busy" : reason);
|
|
41
|
+
if (r.code === "backpressure") {
|
|
42
|
+
const seconds = Number(r.retryAfter);
|
|
43
|
+
retry.current = setTimeout(() => { if (current()) void load(); },
|
|
44
|
+
(Number.isFinite(seconds) && seconds > 0 ? Math.max(1, Math.min(300, seconds)) : 10) * 1000);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
setError(null); setW(null); setAskable(null);
|
|
48
|
+
try {
|
|
49
|
+
const [r, cat] = await Promise.all([c.welcome(), typeof c.catalog === "function" ? c.catalog() : Promise.resolve(null)]);
|
|
50
|
+
if (!current()) return;
|
|
51
|
+
if (!r.ok) { failed(r); return; }
|
|
52
|
+
if (cat && !cat.ok && (r.mode === "legacy" || r.chat?.state === "allow")) { failed(cat, "catalogUnavailable"); return; }
|
|
53
|
+
setW(r); setAskable(cat && Array.isArray(cat.askable) ? cat.askable.length : null);
|
|
54
|
+
} catch { failed({ code: "unreachable" }); }
|
|
55
|
+
};
|
|
56
|
+
useEffect(() => { live.current = true; void load(); return () => {
|
|
57
|
+
live.current = false; generation.current++; clearTimeout(retry.current);
|
|
58
|
+
}; }, []);
|
|
59
|
+
const refresh = async () => { const r = await c.welcome(); if (live.current && r.ok) setW(r); };
|
|
60
|
+
// The chats' panel header already names the page ("Chats"): the welcome greets in its lead, not with a second title
|
|
61
|
+
// stacked under the first (Argon #7). The Hub's name stays beside the greeting.
|
|
62
|
+
const head = html`<p class="s-page-lead hub-page-lead hub-welcome-lead"><strong>${hg("welcomeTitle", name || "")}</strong>${hubName() ? html` <span class="s-scope">${hubName()}</span>` : null}<br />${hg("welcomeLead")}</p>`;
|
|
63
|
+
if (error) return html`<div class="col hub-welcome-page">${head}${error === "busy"
|
|
64
|
+
? html`<p class="note" role="status" data-welcome="busy">${hr("busy")}</p>`
|
|
65
|
+
: html`<${ErrorState} message=${error === "catalogUnavailable" ? hr(error) : hg(error)} onRetry=${load} />`}</div>`;
|
|
66
|
+
if (!w) return html`<div class="col hub-welcome-page">${head}<div class="hub-welcome"><section class="card"><${Skeleton} variant="rows" lines=${3} /></section><section class="card"><${Skeleton} variant="rows" lines=${3} /></section></div></div>`;
|
|
67
|
+
const legacy = w.mode === "legacy";
|
|
68
|
+
const chat = w.chat || {}, connect = w.connect || {};
|
|
69
|
+
const chatOk = legacy || chat.state === "allow", connectOk = !legacy && connect.state === "allow";
|
|
70
|
+
const fleets = Array.isArray(connect.fleets) ? connect.fleets : [], max = Number(connect.maxFleets) || 0;
|
|
71
|
+
const quickOn = quick && c.quickPairingV1;
|
|
72
|
+
const used = fleets.filter((f) => f.status !== "revoked").length;
|
|
73
|
+
const atLimit = connectOk && max > 0 && used >= max;
|
|
74
|
+
const noActions = !legacy && chat.state !== "allow" && connect.state !== "allow" && chat.state !== "unknown" && connect.state !== "unknown";
|
|
75
|
+
const unknown = !legacy && (chat.state === "unknown" || connect.state === "unknown");
|
|
76
|
+
return html`<div class="col hub-welcome-page">${head}
|
|
77
|
+
${noActions ? html`<p class="note" role="status" data-welcome="no-actions">${hg("noActions")} ${hg("contactAdmin")}</p>` : null}
|
|
78
|
+
${unknown ? html`<p class="note" role="status" data-welcome="unknown">${hg("unknown")} <button type="button" class="btn btn-sm" onClick=${load}>${hg("retry")}</button></p>` : null}
|
|
79
|
+
<div class="hub-welcome">
|
|
80
|
+
<section class=${`card hub-welcome-card${chatOk ? "" : " is-off"}`} data-entry="chat" aria-disabled=${chatOk ? "false" : "true"}>
|
|
81
|
+
<h3>${hg("chatTitle")}</h3><p class="note">${hg("chatHint")}</p>
|
|
82
|
+
${chatOk ? (askable === 0
|
|
83
|
+
// Nothing shared with this person yet: say so — no button that opens an empty list (Argon #6).
|
|
84
|
+
? html`<p class="note" data-welcome="nothing-shared">${hg("chatNone")}</p>`
|
|
85
|
+
: html`<div class="hub-welcome-actions"><button type="button" class="btn btn-primary" onClick=${onChats}>${hg("chatGo")}</button></div>`)
|
|
86
|
+
: html`<p class="note">${reasonText(chat, "contactAdmin")}</p>`}
|
|
87
|
+
</section>
|
|
88
|
+
<section class=${`card hub-welcome-card${connectOk ? "" : " is-off"}`} data-entry="connect" aria-disabled=${connectOk ? "false" : "true"}>
|
|
89
|
+
<h3>${hg("connectTitle")}</h3><p class="note">${hg("connectHint")}</p>
|
|
90
|
+
${connectOk && max > 0 ? html`<p class="note" data-welcome="fleets">${hg("connectFleets", used, max)}</p>` : null}
|
|
91
|
+
${fleets.length ? html`<ul class="hub-welcome-fleets">${fleets.map((f) => html`<li key=${f.id}><span class="hub-fp-full">${f.label || f.id}</span> <span class=${`tag${f.status === "active" ? " ok" : f.status === "suspended" || f.status === "unknown" ? " warn" : ""}`} data-fleet-status=${f.status}>${hg(FLEET_STATUS[f.status] || "fleetUnknown")}</span>
|
|
92
|
+
${quickOn ? html`<${OwnedFleetRevoke} fleet=${f} onRevoked=${load} />` : null}</li>`)}</ul>` : null}
|
|
93
|
+
${legacy ? html`<p class="note">${hg("connectManual")}</p>`
|
|
94
|
+
: !connectOk ? html`<p class="note">${chat.state === "allow" && connect.reason === "no-group" ? hg("connectNotIncluded") : reasonText(connect, "contactAdmin")}</p>`
|
|
95
|
+
: atLimit ? html`<p class="note" data-welcome="limit">${hg("connectLimit")}</p>`
|
|
96
|
+
: !quick || !c.quickPairingV1 ? html`<p class="note">${hg("connectManual")}</p>` : null}
|
|
97
|
+
${quickOn ? html`<${QuickPairingGuide} allowed=${connectOk && !atLimit} publishAllowed=${w.publish?.state === "allow"} onConnected=${refresh} />` : null}
|
|
98
|
+
</section>
|
|
99
|
+
</div>
|
|
100
|
+
${!legacy && w.publish && w.publish.state !== "allow" && connectOk ? html`<p class="note" data-welcome="publish">${hg("publishNot")}</p>` : null}
|
|
101
|
+
</div>`;
|
|
102
|
+
}
|