@songsid/agend 2.3.5-alpha.10 → 2.3.5-alpha.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 +17 -0
- package/dist/accounts-view.js +24 -8
- package/dist/accounts-view.js.map +1 -1
- package/dist/agent-cli-instructions.md +2 -2
- package/dist/auth-api.d.ts +48 -16
- package/dist/auth-api.js +83 -32
- package/dist/auth-api.js.map +1 -1
- package/dist/authority/settings-role.d.ts +56 -0
- package/dist/authority/settings-role.js +48 -0
- package/dist/authority/settings-role.js.map +1 -0
- package/dist/backend/claude-code.d.ts +2 -0
- package/dist/backend/claude-code.js +32 -6
- package/dist/backend/claude-code.js.map +1 -1
- package/dist/backend/cli-env-probe.js +6 -2
- package/dist/backend/cli-env-probe.js.map +1 -1
- package/dist/backend/codex.d.ts +5 -3
- package/dist/backend/codex.js +31 -13
- package/dist/backend/codex.js.map +1 -1
- package/dist/backend/credential-profile.d.ts +18 -0
- package/dist/backend/credential-profile.js +46 -0
- package/dist/backend/credential-profile.js.map +1 -1
- package/dist/backend/kiro.js +1 -1
- package/dist/backend/kiro.js.map +1 -1
- package/dist/backend/muse.d.ts +3 -1
- package/dist/backend/muse.js +31 -1
- package/dist/backend/muse.js.map +1 -1
- package/dist/backend/types.d.ts +17 -1
- package/dist/backend/types.js.map +1 -1
- package/dist/backend-availability.d.ts +15 -0
- package/dist/backend-availability.js +37 -1
- package/dist/backend-availability.js.map +1 -1
- package/dist/build-provenance.json +1 -1
- package/dist/bundled-tmux-guard.d.ts +4 -0
- package/dist/bundled-tmux-guard.js +7 -0
- package/dist/bundled-tmux-guard.js.map +1 -1
- package/dist/claude-auth-status.d.ts +20 -8
- package/dist/claude-auth-status.js +38 -22
- package/dist/claude-auth-status.js.map +1 -1
- package/dist/cli-audited.d.ts +60 -0
- package/dist/cli-audited.js +84 -0
- package/dist/cli-audited.js.map +1 -0
- package/dist/cli-capability.d.ts +36 -5
- package/dist/cli-capability.js +2 -2
- package/dist/cli-capability.js.map +1 -1
- package/dist/cli-caps-module.d.ts +5 -1
- package/dist/cli-caps-module.js +4 -2
- package/dist/cli-caps-module.js.map +1 -1
- package/dist/cli-registry-check.js +16 -2
- package/dist/cli-registry-check.js.map +1 -1
- package/dist/cli-registry.d.ts +56 -4
- package/dist/cli-registry.js +1 -1
- package/dist/cli-registry.js.map +1 -1
- package/dist/cli-spec-antigravity.d.ts +12 -1
- package/dist/cli-spec-antigravity.js +13 -1
- package/dist/cli-spec-antigravity.js.map +1 -1
- package/dist/cli-spec-claude-code.d.ts +9 -0
- package/dist/cli-spec-claude-code.js +4 -2
- package/dist/cli-spec-claude-code.js.map +1 -1
- package/dist/cli-spec-codex.d.ts +10 -1
- package/dist/cli-spec-codex.js +5 -3
- package/dist/cli-spec-codex.js.map +1 -1
- package/dist/cli-spec-grok.d.ts +5 -0
- package/dist/cli-spec-grok.js +6 -1
- package/dist/cli-spec-grok.js.map +1 -1
- package/dist/cli-spec-kiro-cli.d.ts +7 -1
- package/dist/cli-spec-kiro-cli.js +7 -3
- package/dist/cli-spec-kiro-cli.js.map +1 -1
- package/dist/cli-spec-muse.d.ts +2 -0
- package/dist/cli-spec-muse.js +3 -1
- package/dist/cli-spec-muse.js.map +1 -1
- package/dist/cli-spec-opencode.d.ts +11 -1
- package/dist/cli-spec-opencode.js +7 -2
- package/dist/cli-spec-opencode.js.map +1 -1
- package/dist/cli.js +28 -1
- package/dist/cli.js.map +1 -1
- package/dist/create-host-account.d.ts +17 -0
- package/dist/create-host-account.js +47 -0
- package/dist/create-host-account.js.map +1 -0
- package/dist/daemon.d.ts +26 -0
- package/dist/daemon.js +131 -10
- package/dist/daemon.js.map +1 -1
- package/dist/delivery-outbox.js +7 -0
- package/dist/delivery-outbox.js.map +1 -1
- package/dist/fleet-context.d.ts +5 -1
- package/dist/fleet-manager.d.ts +363 -71
- package/dist/fleet-manager.js +1374 -367
- package/dist/fleet-manager.js.map +1 -1
- package/dist/fleet-process-handlers.d.ts +1 -1
- package/dist/fleet-process-handlers.js +3 -2
- package/dist/fleet-process-handlers.js.map +1 -1
- package/dist/general-knowledge/skills/concepts/SKILL.md +21 -14
- package/dist/general-knowledge/skills/credential-profiles/SKILL.md +9 -8
- package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +9 -1
- package/dist/general-knowledge/skills/kiro-engine-migration/SKILL.md +1 -1
- package/dist/general-knowledge/skills/web-dashboard/SKILL.md +27 -20
- package/dist/instance-lifecycle.js +33 -3
- package/dist/instance-lifecycle.js.map +1 -1
- package/dist/instructions.js +29 -6
- package/dist/instructions.js.map +1 -1
- package/dist/locale.js +125 -81
- package/dist/locale.js.map +1 -1
- package/dist/login-manager.d.ts +2 -2
- package/dist/login-manager.js +3 -2
- package/dist/login-manager.js.map +1 -1
- package/dist/native-model-catalog.d.ts +20 -0
- package/dist/native-model-catalog.js +107 -2
- package/dist/native-model-catalog.js.map +1 -1
- package/dist/public-web-gateway.js +1 -1
- package/dist/public-web-gateway.js.map +1 -1
- package/dist/public-web-link.d.ts +5 -0
- package/dist/public-web-link.js +8 -0
- package/dist/public-web-link.js.map +1 -1
- package/dist/runtime-api.d.ts +1 -1
- package/dist/runtime-api.js +104 -12
- package/dist/runtime-api.js.map +1 -1
- package/dist/runtime-autostart.d.ts +61 -0
- package/dist/runtime-autostart.js +161 -0
- package/dist/runtime-autostart.js.map +1 -0
- package/dist/runtime-background.d.ts +200 -0
- package/dist/runtime-background.js +480 -0
- package/dist/runtime-background.js.map +1 -0
- package/dist/runtime-build-info.js +5 -5
- package/dist/runtime-build-info.js.map +1 -1
- package/dist/runtime-cli-background.d.ts +92 -0
- package/dist/runtime-cli-background.js +336 -0
- package/dist/runtime-cli-background.js.map +1 -0
- package/dist/runtime-cli-install.d.ts +148 -8
- package/dist/runtime-cli-install.js +253 -59
- package/dist/runtime-cli-install.js.map +1 -1
- package/dist/runtime-cli.d.ts +8 -1
- package/dist/runtime-cli.js +206 -44
- package/dist/runtime-cli.js.map +1 -1
- package/dist/runtime-client-store.d.ts +11 -0
- package/dist/runtime-client-store.js +20 -5
- package/dist/runtime-client-store.js.map +1 -1
- package/dist/runtime-client.d.ts +23 -1
- package/dist/runtime-client.js +92 -6
- package/dist/runtime-client.js.map +1 -1
- package/dist/runtime-connection.d.ts +1 -1
- package/dist/runtime-connection.js +1 -1
- package/dist/runtime-connection.js.map +1 -1
- package/dist/runtime-coordinator.d.ts +95 -1
- package/dist/runtime-coordinator.js +344 -10
- package/dist/runtime-coordinator.js.map +1 -1
- package/dist/runtime-enroll-notice.d.ts +4 -0
- package/dist/runtime-enroll-notice.js +21 -0
- package/dist/runtime-enroll-notice.js.map +1 -0
- package/dist/runtime-enrollment.d.ts +21 -0
- package/dist/runtime-enrollment.js +52 -0
- package/dist/runtime-enrollment.js.map +1 -0
- package/dist/runtime-pane-native.js +4 -4
- package/dist/runtime-pane-native.js.map +1 -1
- package/dist/runtime-protocol.d.ts +78 -1
- package/dist/runtime-protocol.js +95 -5
- package/dist/runtime-protocol.js.map +1 -1
- package/dist/runtime-remote-accounts.d.ts +12 -0
- package/dist/runtime-remote-accounts.js +56 -5
- package/dist/runtime-remote-accounts.js.map +1 -1
- package/dist/runtime-remote-setup.d.ts +4 -1
- package/dist/runtime-remote-setup.js +4 -1
- package/dist/runtime-remote-setup.js.map +1 -1
- package/dist/runtime-update-controller.d.ts +11 -0
- package/dist/runtime-update-controller.js +56 -4
- package/dist/runtime-update-controller.js.map +1 -1
- package/dist/settings-api.d.ts +13 -1
- package/dist/settings-api.js +44 -20
- package/dist/settings-api.js.map +1 -1
- package/dist/settings-change.d.ts +5 -13
- package/dist/settings-change.js.map +1 -1
- package/dist/settings-confirmation.d.ts +11 -13
- package/dist/settings-confirmation.js +2 -6
- package/dist/settings-confirmation.js.map +1 -1
- package/dist/settings-effect.d.ts +5 -0
- package/dist/settings-effect.js +76 -10
- package/dist/settings-effect.js.map +1 -1
- package/dist/settings-http-confirmation.d.ts +8 -1
- package/dist/settings-http-confirmation.js +39 -13
- package/dist/settings-http-confirmation.js.map +1 -1
- package/dist/settings-request-capability.d.ts +7 -0
- package/dist/settings-request-capability.js +3 -1
- package/dist/settings-request-capability.js.map +1 -1
- package/dist/setup-i18n.js +4 -4
- package/dist/setup-i18n.js.map +1 -1
- package/dist/signin-keepalive.d.ts +25 -1
- package/dist/signin-keepalive.js +44 -1
- package/dist/signin-keepalive.js.map +1 -1
- package/dist/subagent-records.d.ts +45 -0
- package/dist/subagent-records.js +214 -0
- package/dist/subagent-records.js.map +1 -0
- package/dist/subagent-service.d.ts +27 -0
- package/dist/subagent-service.js +199 -0
- package/dist/subagent-service.js.map +1 -0
- package/dist/tmux-manager.d.ts +2 -2
- package/dist/tmux-manager.js +5 -3
- package/dist/tmux-manager.js.map +1 -1
- package/dist/ui/account-identity.js +7 -5
- package/dist/ui/accounts-keepalive.js +17 -17
- package/dist/ui/accounts-manage.js +34 -34
- package/dist/ui/accounts-view.js +68 -24
- package/dist/ui/agent-runtime-settings.js +1 -1
- package/dist/ui/backend-signin.js +67 -67
- package/dist/ui/chat-msg-actions.js +50 -4
- package/dist/ui/chat-quote.js +256 -0
- package/dist/ui/chat-store.js +9 -4
- package/dist/ui/cli-caps.js +7 -7
- package/dist/ui/credential-profile-select.js +4 -4
- package/dist/ui/general-location.js +1 -1
- package/dist/ui/host-install.js +290 -0
- package/dist/ui/hub-company-join-strings.js +3 -0
- package/dist/ui/hub-company-join.js +20 -2
- package/dist/ui/hub-owner-strings.js +5 -4
- package/dist/ui/hub-pairing-progress-strings.js +1 -1
- package/dist/ui/hub-quick-strings.js +4 -4
- package/dist/ui/hub-strings.js +6 -6
- package/dist/ui/machine-signin.js +4 -4
- package/dist/ui/model-picker.js +68 -0
- package/dist/ui/panel-chat.js +74 -13
- package/dist/ui/panel-fleet.js +8 -2
- package/dist/ui/panel-hub.js +8 -4
- package/dist/ui/panel-needs.js +2 -2
- package/dist/ui/panel-runtimes.js +232 -33
- package/dist/ui/panel-settings.js +7 -1
- package/dist/ui/panel-windows-cli.js +1 -1
- package/dist/ui/runtime-cli-install.js +99 -20
- package/dist/ui/runtime-commands.d.ts +2 -0
- package/dist/ui/runtime-commands.js +34 -1
- package/dist/ui/runtime-update-status.js +2 -2
- package/dist/ui/search-dialog.js +1 -0
- package/dist/ui/settings-access-overview.js +167 -0
- package/dist/ui/settings-access-strings.js +1 -1
- package/dist/ui/settings-catalog.js +19 -3
- package/dist/ui/settings-confirm.js +2 -2
- package/dist/ui/settings-devices.js +59 -25
- package/dist/ui/settings-dialogs.js +12 -13
- package/dist/ui/settings-guests.js +1 -1
- package/dist/ui/settings-hub-company-join.js +10 -7
- package/dist/ui/settings-hub-connection.js +121 -0
- package/dist/ui/settings-hub-membership.js +1 -1
- package/dist/ui/settings-hub-run.js +5 -6
- package/dist/ui/settings-hub-section.js +3 -6
- package/dist/ui/settings-hub.js +12 -7
- package/dist/ui/settings-layout.js +9 -7
- package/dist/ui/settings-outside.js +87 -19
- package/dist/ui/settings-registry.js +2 -1
- package/dist/ui/settings-revoke-strings.js +28 -0
- package/dist/ui/settings-strings.js +25 -25
- package/dist/ui/settings-web-authority.js +11 -4
- package/dist/ui/shared/accounts.css +11 -1
- package/dist/ui/shared/agend-auth.js +8 -1
- package/dist/ui/shared/app-i18n.js +10 -12
- package/dist/ui/shared/app-session.js +13 -16
- package/dist/ui/shared/app-shell.js +37 -37
- package/dist/ui/shared/app-store.js +2 -0
- package/dist/ui/shared/app.css +85 -14
- package/dist/ui/shared/chat-render.js +17 -5
- package/dist/ui/shared/chat-strings.js +4 -4
- package/dist/ui/shared/device-roles.js +27 -0
- package/dist/ui/shared/host-install.css +10 -0
- package/dist/ui/shared/hub-owner.css +6 -0
- package/dist/ui/shared/model-picker.css +21 -0
- package/dist/ui/shared/runtime-install.css +26 -1
- package/dist/ui/shared/setup-host-text.js +4 -4
- package/dist/ui/shared/signin.js +171 -64
- package/dist/ui/shared/subagent-row.css +15 -0
- package/dist/ui/shared/usage-dialog.js +28 -16
- package/dist/ui/shared/view-strings.js +7 -7
- package/dist/ui/shared/web-authorize.js +54 -4
- package/dist/ui/signin.html +19 -8
- package/dist/ui/structured-signin.js +30 -30
- package/dist/ui/subagent-row.js +72 -0
- package/dist/ui/web-terminal/terminal.js +9 -9
- package/dist/update-launch.js +4 -1
- package/dist/update-launch.js.map +1 -1
- package/dist/update-npm-env.d.ts +70 -0
- package/dist/update-npm-env.js +128 -0
- package/dist/update-npm-env.js.map +1 -0
- package/dist/usage/format-rich.js +1 -1
- package/dist/usage/format-rich.js.map +1 -1
- package/dist/usage/providers.js +2 -2
- package/dist/usage/providers.js.map +1 -1
- package/dist/usage/usage-api.d.ts +8 -2
- package/dist/usage/usage-api.js +12 -5
- package/dist/usage/usage-api.js.map +1 -1
- package/dist/web-api.d.ts +38 -4
- package/dist/web-api.js +370 -18
- package/dist/web-api.js.map +1 -1
- package/dist/web-auth.js +1 -1
- package/dist/web-auth.js.map +1 -1
- package/dist/web-backend-login.d.ts +2 -0
- package/dist/web-backend-login.js.map +1 -1
- package/dist/web-channel-echo.js +3 -1
- package/dist/web-channel-echo.js.map +1 -1
- package/dist/web-commands.d.ts +9 -1
- package/dist/web-commands.js +7 -1
- package/dist/web-commands.js.map +1 -1
- package/dist/web-host-install.d.ts +127 -0
- package/dist/web-host-install.js +165 -0
- package/dist/web-host-install.js.map +1 -0
- package/dist/web-remote-access.d.ts +194 -11
- package/dist/web-remote-access.js +458 -34
- package/dist/web-remote-access.js.map +1 -1
- package/dist/web-session.d.ts +11 -3
- package/dist/web-session.js.map +1 -1
- package/dist/web-signin-device.d.ts +16 -0
- package/dist/web-signin-device.js +81 -0
- package/dist/web-signin-device.js.map +1 -0
- package/dist/web-update.js +3 -1
- package/dist/web-update.js.map +1 -1
- package/dist/windows-cli-api.js +2 -1
- package/dist/windows-cli-api.js.map +1 -1
- package/dist/windows-cli-worker.d.ts +14 -0
- package/dist/windows-cli-worker.js +145 -1
- package/dist/windows-cli-worker.js.map +1 -1
- package/dist/windows-cli.d.ts +4 -0
- package/dist/windows-cli.js +9 -1
- package/dist/windows-cli.js.map +1 -1
- package/launcher/agend-install.cjs +16 -3
- package/package.json +1 -1
- package/templates/runtime-install/install.ps1 +219 -12
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
// AGEND-133 (upstream #3521): the Install button of Settings → Agents → AI sign-ins and API keys — installing an AI CLI on the AgEnD host from the dashboard.
|
|
2
|
+
// A module of its own, its words registered here (a tab that kept an older accounts-view.js never meets a raw key).
|
|
3
|
+
//
|
|
4
|
+
// The page only names a CLI. POST /ui/host-install `{ backend }` — the server looks up the registry's command and runs it as `/login` does (web-host-install.ts);
|
|
5
|
+
// nothing here is ever a command. The current (or last, for ten minutes) install is read from GET /ui/host-install: while one runs, every two seconds and
|
|
6
|
+
// whenever the stream's `backend_login` event says something moved (accounts-view.js listens, once, and reads both); its last lines of output, its verdict and the version found come from there.
|
|
7
|
+
import { html, useEffect, useState } from "/assets/app-html.js";
|
|
8
|
+
import { register, t } from "/assets/app-i18n.js";
|
|
9
|
+
import { createStore, useStore } from "/assets/app-store.js";
|
|
10
|
+
import { toast } from "/assets/ui-toast.js";
|
|
11
|
+
import { confirmedWrite } from "./settings-confirm.js";
|
|
12
|
+
|
|
13
|
+
register("hostinstall", {
|
|
14
|
+
en: {
|
|
15
|
+
install: "Install", installing: "Installing…", cancel: "Cancel install", dismiss: "Dismiss",
|
|
16
|
+
notInstalled: "Not installed on this AgEnD host. Install runs the CLI's official installer here, for the user AgEnD runs as.",
|
|
17
|
+
running: "Installing {0} (started on {1}).", runningNoOutput: "Waiting for the installer to print something…",
|
|
18
|
+
ok: "{0} is installed.", okVersion: "{0} {1} is installed.",
|
|
19
|
+
okUnverified: "The installer finished, but {0} was not found afterwards. Read its last lines below.",
|
|
20
|
+
failed: "The {0} install did not finish.", failedCode: "The {0} installer exited with code {1}.",
|
|
21
|
+
cancelled: "The {0} install was cancelled.", timeout: "The {0} install took too long and was stopped.",
|
|
22
|
+
cleanup: "The install window could not be confirmed closed: check the AgEnD host.",
|
|
23
|
+
output: "Installer output (last lines)",
|
|
24
|
+
started: "Installing {0}…", confirm: "Install {0} on the AgEnD host",
|
|
25
|
+
err_unsupported: "This CLI cannot be installed from here.", err_already: "{0} is already installed on this host.",
|
|
26
|
+
err_busy: "Another install or sign-in is running. Wait for it to end, or cancel it.", err_shutting_down: "AgEnD is shutting down.",
|
|
27
|
+
err_not_allowed: "Only a fleet admin signed in on this machine or its network can install a CLI.",
|
|
28
|
+
err_install_needs_a_local_admin: "Only a fleet admin signed in on this machine or its network can install a CLI.",
|
|
29
|
+
err_install_not_over_public_link: "Installing is not available over the public link. Open the dashboard on the machine running AgEnD.",
|
|
30
|
+
err_failed: "The install could not start.", err_other: "That did not work.",
|
|
31
|
+
cardLabelUpdate: "Update {0} on this AgEnD computer", err_expired: "The install was not confirmed in time.", err_rejected: "The install was turned down.", err_stale: "Settings changed before the install could start. Try again.",
|
|
32
|
+
err_install_confirmation_required: "The install must be confirmed first.",
|
|
33
|
+
err_latest_ack_required: "This page is out of date for this update. Refresh the page and try again.", err_latest_ack_mismatch: "This page is out of date for this update. Refresh the page and try again.",
|
|
34
|
+
},
|
|
35
|
+
"zh-TW": {
|
|
36
|
+
install: "安裝", installing: "安裝中…", cancel: "取消安裝", dismiss: "關閉",
|
|
37
|
+
notInstalled: "這台 AgEnD 主機還沒安裝。按「安裝」會在這裡,以 AgEnD 執行時的使用者身分,執行這個 CLI 的官方安裝程式。",
|
|
38
|
+
running: "正在安裝 {0}(從 {1} 啟動)。", runningNoOutput: "等安裝程式印出內容…",
|
|
39
|
+
ok: "{0} 已安裝。", okVersion: "{0} {1} 已安裝。",
|
|
40
|
+
okUnverified: "安裝程式已結束,但之後找不到 {0}。請看下方它的最後幾行。",
|
|
41
|
+
failed: "{0} 沒有安裝完成。", failedCode: "{0} 的安裝程式以結束碼 {1} 結束。",
|
|
42
|
+
cancelled: "已取消 {0} 的安裝。", timeout: "{0} 的安裝花太久,已停止。",
|
|
43
|
+
cleanup: "無法確認安裝視窗已關閉:請檢查 AgEnD 主機。",
|
|
44
|
+
output: "安裝程式輸出(最後幾行)",
|
|
45
|
+
started: "正在安裝 {0}…", confirm: "在 AgEnD 主機上安裝 {0}",
|
|
46
|
+
err_unsupported: "這個 CLI 不能從這裡安裝。", err_already: "這台主機已經安裝 {0}。",
|
|
47
|
+
err_busy: "另一個安裝或登入正在進行。請等它結束,或先取消它。", err_shutting_down: "AgEnD 正在關閉。",
|
|
48
|
+
err_not_allowed: "只有在這台機器或它的網路上登入的 fleet 管理員,才能安裝 CLI。",
|
|
49
|
+
err_install_needs_a_local_admin: "只有在這台機器或它的網路上登入的 fleet 管理員,才能安裝 CLI。",
|
|
50
|
+
err_install_not_over_public_link: "公開連結上不能安裝。請在執行 AgEnD 的機器上開啟儀表板。",
|
|
51
|
+
err_failed: "安裝無法開始。", err_other: "沒有成功。",
|
|
52
|
+
cardLabelUpdate: "在這台 AgEnD 電腦上更新 {0}", err_expired: "安裝沒有在時限內確認。", err_rejected: "安裝已被拒絕。", err_stale: "安裝開始前設定已經改變。請再試一次。",
|
|
53
|
+
err_install_confirmation_required: "安裝必須先經過確認。",
|
|
54
|
+
err_latest_ack_required: "這個頁面的版本已過期,無法進行這次更新。請重新整理頁面再試一次。", err_latest_ack_mismatch: "這個頁面的版本已過期,無法進行這次更新。請重新整理頁面再試一次。",
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
// AGEND-136 (#3521): the Update button beside Install. The page names the CLI and nothing else (POST /ui/host-update { backend }); the server picks the command and the
|
|
58
|
+
// AUDITED release it goes to (cli-audited.ts), so the button always says which version it installs. A CLI that updates itself shows the versions and no button.
|
|
59
|
+
register("hostinstall", {
|
|
60
|
+
en: {
|
|
61
|
+
update: "Update to {0}", updating: "Updating…", cancelUpdate: "Cancel update",
|
|
62
|
+
verCurrent: "{0} is installed — up to date. The newest version AgEnD has audited: {1}.",
|
|
63
|
+
verBehind: "{0} is installed. The newest version AgEnD has audited is {1}: Update installs exactly that, not the newest release.",
|
|
64
|
+
verSelf: "{0} is installed. The newest version AgEnD has audited is {1}. This CLI updates itself in the background, so there is no Update button.",
|
|
65
|
+
verNewer: "{0} is installed. That is newer than {1}, the newest version AgEnD has audited: not verified by AgEnD yet.",
|
|
66
|
+
verUnknown: "The installed version could not be read. The newest version AgEnD has audited: {0}.",
|
|
67
|
+
runningUpdate: "Updating {0} to {1} (started on {2}).",
|
|
68
|
+
updated: "{0} was updated from {1} to {2}.", updatedNoFrom: "{0} was updated to {1}.", updatedWarn: "Warning: the {0} installer finished (exit code 0), but the installed version is {1} and the audited version is {2}. It did not reach the audited version: read the installer's last lines below.",
|
|
69
|
+
updatedNoVersion: "The {0} installer finished (exit code 0), but the installed version could not be read afterwards, so it is not known whether it reached the audited version, {1}.",
|
|
70
|
+
failedUpdate: "The {0} update did not finish.", failedUpdateCode: "The {0} update exited with code {1}.",
|
|
71
|
+
cancelledUpdate: "The {0} update was cancelled.", timeoutUpdate: "The {0} update took too long and was stopped.",
|
|
72
|
+
err_not_installed: "{0} is not installed on this host.", err_version_unreadable: "AgEnD could not read the installed version of {0} just now, so it did not update it. Try again in a moment.", err_up_to_date: "{0} is already at the version AgEnD has audited (or newer): there is nothing to update.",
|
|
73
|
+
},
|
|
74
|
+
"zh-TW": {
|
|
75
|
+
update: "更新到 {0}", updating: "更新中…", cancelUpdate: "取消更新",
|
|
76
|
+
verCurrent: "已安裝 {0},是最新的。AgEnD 稽核過的最新版本:{1}。",
|
|
77
|
+
verBehind: "已安裝 {0}。AgEnD 稽核過的最新版本是 {1}:按「更新」會裝這個版本,不是最新釋出版。",
|
|
78
|
+
verSelf: "已安裝 {0}。AgEnD 稽核過的最新版本是 {1}。這個 CLI 會在背景自己更新,所以這裡沒有「更新」按鈕。",
|
|
79
|
+
verNewer: "已安裝 {0},比 AgEnD 稽核過的最新版本 {1} 還新:尚未經 AgEnD 驗證。",
|
|
80
|
+
verUnknown: "讀不到已安裝的版本。AgEnD 稽核過的最新版本:{0}。",
|
|
81
|
+
runningUpdate: "正在把 {0} 更新到 {1}(從 {2} 啟動)。",
|
|
82
|
+
updated: "{0} 已從 {1} 更新到 {2}。", updatedNoFrom: "{0} 已更新到 {1}。", updatedWarn: "警告:{0} 的安裝程式已結束(結束碼 0),但已安裝的版本是 {1},AgEnD 稽核過的版本是 {2},沒有更新到稽核版本。請看下方安裝程式的最後幾行。",
|
|
83
|
+
updatedNoVersion: "{0} 的安裝程式已結束(結束碼 0),但之後讀不到已安裝的版本,不確定有沒有更新到稽核版本 {1}。",
|
|
84
|
+
failedUpdate: "{0} 沒有更新完成。", failedUpdateCode: "{0} 的更新以結束碼 {1} 結束。",
|
|
85
|
+
cancelledUpdate: "已取消 {0} 的更新。", timeoutUpdate: "{0} 的更新花太久,已停止。",
|
|
86
|
+
err_not_installed: "這台主機沒有安裝 {0}。", err_version_unreadable: "AgEnD 剛才讀不到 {0} 目前安裝的版本,所以沒有更新。請稍後再試。", err_up_to_date: "{0} 已經是 AgEnD 稽核過的版本(或更新):不需要更新。",
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
// AGEND-153 (the maintainer's decision on #3539): the one named exception — a CLI that updates itself and whose own updater cannot choose a release (Antigravity). Its button goes to the LATEST
|
|
90
|
+
// release, which AgEnD has not audited, and says so on the button and in the line above it. Every other rule of an update (the held change, the asker's code, no public link) is the same.
|
|
91
|
+
register("hostinstall", {
|
|
92
|
+
en: {
|
|
93
|
+
updateLatest: "Update to latest (not audited by AgEnD)", cardLabelUpdateLatest: "Update {0} on this AgEnD computer to the latest release (not audited by AgEnD)",
|
|
94
|
+
verLatestCurrent: "{0} is installed — the version AgEnD has audited ({1}). Update goes to the latest release the vendor serves, which AgEnD has NOT audited: this CLI updates itself and cannot be pinned.",
|
|
95
|
+
verLatestBehind: "{0} is installed. The newest version AgEnD has audited is {1}. Update goes to the latest release the vendor serves, which AgEnD has NOT audited: this CLI updates itself and cannot be pinned.",
|
|
96
|
+
verLatestNewer: "{0} is installed. That is newer than {1}, the newest version AgEnD has audited: not verified by AgEnD yet. Update goes to the latest release the vendor serves, also not audited.",
|
|
97
|
+
runningUpdateLatest: "Updating {0} to the latest release, not audited by AgEnD (started on {2}).",
|
|
98
|
+
updatedLatestSame: "{0} is already at {1}, the latest release the vendor serves (not audited by AgEnD).",
|
|
99
|
+
updatedLatest: "{0} was updated from {1} to {2}, the latest release the vendor serves (not audited by AgEnD).", updatedLatestNoFrom: "{0} was updated to {1}, the latest release the vendor serves (not audited by AgEnD).",
|
|
100
|
+
updatedLatestNoVersion: "The {0} updater finished (exit code 0), but the installed version could not be read afterwards, so it is not known which release it is now.",
|
|
101
|
+
},
|
|
102
|
+
"zh-TW": {
|
|
103
|
+
updateLatest: "更新到最新版(未經盤點)", cardLabelUpdateLatest: "在這台 AgEnD 電腦上把 {0} 更新到最新版(未經 AgEnD 盤點)",
|
|
104
|
+
verLatestCurrent: "已安裝 {0},是 AgEnD 稽核過的版本({1})。按「更新」會更新到廠商釋出的最新版,這個版本 AgEnD 尚未稽核:這個 CLI 會自己更新,無法指定版本。",
|
|
105
|
+
verLatestBehind: "已安裝 {0}。AgEnD 稽核過的最新版本是 {1}。按「更新」會更新到廠商釋出的最新版,這個版本 AgEnD 尚未稽核:這個 CLI 會自己更新,無法指定版本。",
|
|
106
|
+
verLatestNewer: "已安裝 {0},比 AgEnD 稽核過的最新版本 {1} 還新:尚未經 AgEnD 驗證。按「更新」會更新到廠商釋出的最新版,同樣未經稽核。",
|
|
107
|
+
runningUpdateLatest: "正在把 {0} 更新到最新版,未經 AgEnD 盤點(從 {2} 啟動)。",
|
|
108
|
+
updatedLatestSame: "{0} 已經是 {1},也就是廠商釋出的最新版(未經 AgEnD 盤點)。",
|
|
109
|
+
updatedLatest: "{0} 已從 {1} 更新到 {2},廠商釋出的最新版(未經 AgEnD 盤點)。", updatedLatestNoFrom: "{0} 已更新到 {1},廠商釋出的最新版(未經 AgEnD 盤點)。",
|
|
110
|
+
updatedLatestNoVersion: "{0} 的更新程式已結束(結束碼 0),但之後讀不到已安裝的版本,不確定現在是哪個版本。",
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
const th = (k, ...v) => t(`hostinstall.${k}`, ...v);
|
|
114
|
+
function installStyles() {
|
|
115
|
+
if (typeof document === "undefined" || !document.head || document.querySelector('link[href="/assets/host-install.css"]')) return;
|
|
116
|
+
const link = document.createElement("link");
|
|
117
|
+
link.setAttribute("rel", "stylesheet"); link.setAttribute("href", "/assets/host-install.css"); document.head.appendChild(link);
|
|
118
|
+
}
|
|
119
|
+
function revealPending(id) {
|
|
120
|
+
const show = () => Array.from(document.querySelectorAll("[data-pending]")).find(n => n.getAttribute("data-pending") === id)?.scrollIntoView?.({ block: "center" });
|
|
121
|
+
if (typeof requestAnimationFrame === "function") requestAnimationFrame(() => requestAnimationFrame(show));
|
|
122
|
+
else setTimeout(show, 0);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** What this page knows: the current (or last) install as the server shows it, and the ones the person has dismissed. */
|
|
126
|
+
export const hostInstallStore = createStore({ loaded: false, run: null, dismissed: [], starting: null });
|
|
127
|
+
|
|
128
|
+
let reading = null, again = false;
|
|
129
|
+
/** Read GET /ui/host-install (one read at a time; one asked for while another is on its way follows it, so the last change is never missed). */
|
|
130
|
+
export function refreshHostInstall() {
|
|
131
|
+
if (reading) { again = true; return reading; }
|
|
132
|
+
reading = fetch("/ui/host-install", { cache: "no-store", credentials: "same-origin" })
|
|
133
|
+
.then((r) => (r.ok ? r.json() : null))
|
|
134
|
+
.then((b) => { if (b) hostInstallStore.set({ loaded: true, run: b.install || null }); return b; })
|
|
135
|
+
.catch(() => null)
|
|
136
|
+
.finally(() => { reading = null; if (again) { again = false; void refreshHostInstall(); } });
|
|
137
|
+
return reading;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
async function post(path, body) {
|
|
141
|
+
try {
|
|
142
|
+
const res = await fetch(path, { method: "POST", headers: { "Content-Type": "application/json" }, credentials: "same-origin", body: JSON.stringify(body) });
|
|
143
|
+
let json = null; try { json = await res.json(); } catch { /* none */ }
|
|
144
|
+
return { ok: res.ok, status: res.status, body: json };
|
|
145
|
+
} catch { return { ok: false, status: 0, body: null }; }
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const errorText = (code, backend) => {
|
|
149
|
+
const key = `err_${code}`, text = th(key, backend);
|
|
150
|
+
return text === `hostinstall.${key}` ? th("err_other") : text;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
/** Why a confirmed install did not start, as the Settings gate reports it (`apply_rejected: busy`), else what the write itself answered. */
|
|
154
|
+
const refusalOf = (r) => {
|
|
155
|
+
const outcome = r.confirmed && r.confirmed.outcome;
|
|
156
|
+
const m = outcome && typeof outcome.detail === "string" ? /apply_rejected: ([a-z_]+)/.exec(outcome.detail) : null;
|
|
157
|
+
if (m) return m[1];
|
|
158
|
+
if (r.confirmed && ["expired", "rejected", "stale"].includes(r.confirmed.state)) return r.confirmed.state;
|
|
159
|
+
return r.body && r.body.error;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Install (or update) `backend` on the host. Resolves true when the server started it. The page sends the CLI's id and nothing else — and through the Settings gate (AGEND-144):
|
|
164
|
+
* both are held changes like any other that acts on the host. Where the lenient default applies the change is applied at once; for an administrator who asked for their own code the
|
|
165
|
+
* card asks for it, bound to the digest of this change. Whatever the gate answers, the run shown is the server's. (Which release an update goes to and which command runs are the server's.)
|
|
166
|
+
*/
|
|
167
|
+
async function startHostCli(path, backend, labelKey, extra = {}) {
|
|
168
|
+
installStyles();
|
|
169
|
+
if (hostInstallStore.get().starting) return false;
|
|
170
|
+
hostInstallStore.set({ starting: backend });
|
|
171
|
+
let r;
|
|
172
|
+
try { r = await confirmedWrite(path, { body: { backend, ...extra }, label: th(labelKey, backend), displaySummary: () => [th(labelKey, backend)], onPending: revealPending }); }
|
|
173
|
+
catch { r = { ok: false, body: null }; }
|
|
174
|
+
finally { hostInstallStore.set({ starting: null }); }
|
|
175
|
+
if (r.ok && r.body && r.body.install) { hostInstallStore.set({ loaded: true, run: r.body.install }); return true; }
|
|
176
|
+
toast(errorText(refusalOf(r), backend));
|
|
177
|
+
void refreshHostInstall();
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
export const startHostInstall = (backend) => startHostCli("/ui/host-install", backend, "confirm");
|
|
181
|
+
/** Update `backend` on the host to the audited release (AGEND-136). */
|
|
182
|
+
/** AGEND-154 (Prism P2-1 on #3552): the update to the vendor's latest (`latest`, the one named exception) says so in the request — `acceptLatestUnaudited: true` — which is what lets the server run it; a page without this line sends `{ backend }`, and the server refuses. */
|
|
183
|
+
export const startHostUpdate = (backend, latest = false) => startHostCli("/ui/host-update", backend, latest ? "cardLabelUpdateLatest" : "cardLabelUpdate", latest ? { acceptLatestUnaudited: true } : {});
|
|
184
|
+
|
|
185
|
+
export async function cancelHostInstall() {
|
|
186
|
+
const r = await post("/ui/host-install/cancel", {});
|
|
187
|
+
if (!r.ok) toast(errorText(r.body && r.body.error));
|
|
188
|
+
void refreshHostInstall();
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export function dismissHostInstall(id) {
|
|
192
|
+
const s = hostInstallStore.get();
|
|
193
|
+
hostInstallStore.set({ dismissed: [...s.dismissed.slice(-20), id] });
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** Installing is offered to a signed-in local admin; the public link's page never shows it. */
|
|
197
|
+
export const hostInstallOffered = () => !(typeof document !== "undefined" && document.body && document.body.dataset.publicLink === "1");
|
|
198
|
+
|
|
199
|
+
/** The run to show for `backend` in its row: not one the person dismissed. */
|
|
200
|
+
export function runFor(state, backend) {
|
|
201
|
+
const run = state.run;
|
|
202
|
+
return run && run.backend === backend && !state.dismissed.includes(run.id) ? run : null;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** Is any install running right now (the window is one fleet-wide: a second one is refused)? */
|
|
206
|
+
export const installRunning = (state) => !!state.starting || !!(state.run && state.run.phase === "running");
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* The Install button of a row whose CLI is not installed on the host. `backend`'s own run shows in the row (HostInstallRun below); while another install runs
|
|
210
|
+
* (or a sign-in does: `blocked`), the button waits.
|
|
211
|
+
*/
|
|
212
|
+
export function InstallButton({ backend, blocked = false }) {
|
|
213
|
+
installStyles();
|
|
214
|
+
const state = useStore(hostInstallStore);
|
|
215
|
+
if (!hostInstallOffered()) return null;
|
|
216
|
+
return html`<button type="button" class="btn btn-sm btn-primary s-account-install" disabled=${blocked || installRunning(state)} onClick=${() => { void startHostInstall(backend); }}>${th("install")}</button>`;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* The version line of an installed CLI and its Update button (AGEND-136). `row.cliUpdate` is the server's reading: the audited release, where the installed version stands
|
|
221
|
+
* against it (`current`, `behind`, `newer`, `unknown`), whether the dashboard offers an update (`button`) and who updates it (`via`: "dashboard" or "self").
|
|
222
|
+
*/
|
|
223
|
+
export function VersionLine({ row, label, blocked = false }) {
|
|
224
|
+
const state = useStore(hostInstallStore);
|
|
225
|
+
const u = row.cliUpdate;
|
|
226
|
+
if (!u || !hostInstallOffered()) return null;
|
|
227
|
+
const installed = u.installed || row.version || "?";
|
|
228
|
+
const text = u.latest ? th(u.state === "current" ? "verLatestCurrent" : u.state === "newer" ? "verLatestNewer" : "verLatestBehind", installed, u.audited)
|
|
229
|
+
: u.state === "current" ? th("verCurrent", installed, u.audited)
|
|
230
|
+
: u.state === "newer" ? th("verNewer", installed, u.audited)
|
|
231
|
+
: u.state === "unknown" ? th("verUnknown", u.audited)
|
|
232
|
+
: u.via === "self" ? th("verSelf", installed, u.audited)
|
|
233
|
+
: th("verBehind", installed, u.audited);
|
|
234
|
+
const run = runFor(state, row.backend);
|
|
235
|
+
const updating = !!run && run.phase === "running" && run.mode === "update";
|
|
236
|
+
const buttonLabel = u.latest ? th("updateLatest") : th("update", u.audited);
|
|
237
|
+
return html`<div class="s-account-version" data-cli-update=${u.state} data-via=${u.via} data-latest=${u.latest ? "1" : "0"}>
|
|
238
|
+
<p class="note s-account-why">${text}</p>
|
|
239
|
+
${u.button ? html`<span class="s-actions"><button type="button" class="btn btn-sm btn-primary s-account-update" aria-label=${`${label} — ${buttonLabel}`} disabled=${blocked || installRunning(state)} onClick=${() => { void startHostUpdate(row.backend, !!u.latest); }}>${updating ? th("updating") : buttonLabel}</button></span>` : null}
|
|
240
|
+
</div>`;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/** The progress and the verdict of this CLI's install, under its row; nothing when there is none (or it was dismissed). */
|
|
244
|
+
export function HostInstallRun({ backend, label }) {
|
|
245
|
+
const state = useStore(hostInstallStore);
|
|
246
|
+
const run = runFor(state, backend);
|
|
247
|
+
const [busy, setBusy] = useState(false);
|
|
248
|
+
const live = !!run && run.phase === "running";
|
|
249
|
+
// Running: read it every 2 s too (a page whose stream is down still sees it move).
|
|
250
|
+
useEffect(() => {
|
|
251
|
+
if (!live) return undefined;
|
|
252
|
+
const h = setInterval(() => { void refreshHostInstall(); }, 2000);
|
|
253
|
+
return () => clearInterval(h);
|
|
254
|
+
}, [live]);
|
|
255
|
+
if (!run) return null;
|
|
256
|
+
const lines = Array.isArray(run.lines) ? run.lines : [];
|
|
257
|
+
let text, cls = "";
|
|
258
|
+
const update = run.mode === "update";
|
|
259
|
+
if (run.phase === "running") text = update ? (run.latest ? th("runningUpdateLatest", label, "", run.startedOn) : th("runningUpdate", label, run.targetVersion || "?", run.startedOn)) : th("running", label, run.startedOn);
|
|
260
|
+
else if (run.phase === "ok" && update) {
|
|
261
|
+
// An update says the version before and after (the binary probe's own readings). Exit code 0 is not enough: when the version read afterwards is not the audited release (`reached`
|
|
262
|
+
// false), or could not be read (null), it is a warning that names the installed and the audited version, not a success.
|
|
263
|
+
const target = run.targetVersion || "?";
|
|
264
|
+
if (!run.verified) { cls = "signin-message"; text = th("okUnverified", label); }
|
|
265
|
+
// The named exception goes to the vendor's newest release, so there is no audited release to have reached: the page says what was read before and after, and that it is not audited.
|
|
266
|
+
else if (run.latest) {
|
|
267
|
+
if (!run.version) { cls = "signin-warn"; text = th("updatedLatestNoVersion", label); }
|
|
268
|
+
else { cls = "signin-ok"; text = run.fromVersion === run.version ? th("updatedLatestSame", label, run.version) : run.fromVersion ? th("updatedLatest", label, run.fromVersion, run.version) : th("updatedLatestNoFrom", label, run.version); }
|
|
269
|
+
}
|
|
270
|
+
else if (run.reached === false) { cls = "signin-warn"; text = th("updatedWarn", label, run.version || "?", target); }
|
|
271
|
+
else if (run.reached === null || !run.version) { cls = "signin-warn"; text = th("updatedNoVersion", label, target); }
|
|
272
|
+
else { cls = "signin-ok"; text = run.fromVersion ? th("updated", label, run.fromVersion, run.version) : th("updatedNoFrom", label, run.version); }
|
|
273
|
+
}
|
|
274
|
+
else if (run.phase === "ok") { cls = run.verified ? "signin-ok" : "signin-message"; text = !run.verified ? th("okUnverified", label) : run.version ? th("okVersion", label, run.version) : th("ok", label); }
|
|
275
|
+
else if (run.phase === "cancelled") text = th(update ? "cancelledUpdate" : "cancelled", label);
|
|
276
|
+
else if (run.phase === "timeout") text = th(update ? "timeoutUpdate" : "timeout", label);
|
|
277
|
+
else text = run.exitCode !== null && run.exitCode !== undefined ? th(update ? "failedUpdateCode" : "failedCode", label, run.exitCode) : th(update ? "failedUpdate" : "failed", label);
|
|
278
|
+
const cancel = async () => { setBusy(true); await cancelHostInstall(); setBusy(false); };
|
|
279
|
+
return html`<div class="s-account-install-run" data-phase=${run.phase} role="status">
|
|
280
|
+
<p class=${`s-account-why ${cls}`}>${text}</p>
|
|
281
|
+
${lines.length ? html`<pre class="s-account-install-output" aria-label=${th("output")}>${lines.join("\n")}</pre>`
|
|
282
|
+
: run.phase === "running" ? html`<small class="note">${th("runningNoOutput")}</small>` : null}
|
|
283
|
+
${run.cleanupFailed ? html`<p class="note">${th("cleanup")}</p>` : null}
|
|
284
|
+
<div class="s-actions">${run.phase === "running"
|
|
285
|
+
? html`<button type="button" class="btn btn-sm btn-ghost" disabled=${busy} onClick=${cancel}>${th(update ? "cancelUpdate" : "cancel")}</button>`
|
|
286
|
+
: html`<button type="button" class="btn btn-sm btn-ghost" onClick=${() => dismissHostInstall(run.id)}>${th("dismiss")}</button>`}</div>
|
|
287
|
+
</div>`;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export { th as hostInstallText };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { register, t } from "/assets/app-i18n.js";
|
|
2
|
+
export const companyAdminStringsV1 = true;
|
|
2
3
|
register("companyJoin", {
|
|
3
4
|
en: {
|
|
4
5
|
title: "Connect to a Hub", lead: "Use your company account. A successful connection enables membership; no Agents are shared.",
|
|
@@ -25,6 +26,7 @@ register("companyJoin", {
|
|
|
25
26
|
inviteTitle: "Invitation exceptions", inviteLead: "For an eligible person without group permission. Issuing this invitation is your approval; it is bound to that person and this Hub.", inviteLogin: "Company sign-in name", inviteCreate: "Create invitation", inviteCopy: "Copy invitation",
|
|
26
27
|
manualApproved: "Approved by your Hub administrator.", adminTitle: "Company sign-in joining", adminLead: "People allowed by Group permissions can connect their own Fleets. No approval is needed for each Fleet.",
|
|
27
28
|
enabled: "Allow company-account Fleet connections", companyLink: "Company link", copy: "Copy company link", copied: "Copied", copyFailed: "Copy failed. Select and copy the link.",
|
|
29
|
+
accessTitle: "Allowed groups and people", accessLead: "Choose allowed AD groups, or invite an eligible person as an individual Fleet-connection exception.", groupOpen: "Manage group permissions", colleagueCopy: "Copy colleague connection link", colleagueHint: "This link carries the Hub address and its pinned identity. Colleagues paste it into their Fleet’s Settings → Hub.", linkDetails: "Connection link contents", offHint: "Turn on company-account Fleet connections before copying a connection link or creating an invitation.", inviteScope: "This invitation approves one Fleet connection. It does not grant permission to chat with or share Agents.",
|
|
28
30
|
firstUse: "On first use, this Fleet saves the Hub's identity. Use a company link you received from your administrator.",
|
|
29
31
|
linkLead: "Open your Fleet's Settings → Hub and paste this company link. If you know its web address, open those Settings below. This page does not connect a Fleet or ask for your company password.",
|
|
30
32
|
fleetAddress: "Fleet web address", openFleet: "Open Fleet Settings", invalidLink: "This company link is incomplete. Ask your Hub administrator for a new link.",
|
|
@@ -55,6 +57,7 @@ register("companyJoin", {
|
|
|
55
57
|
inviteTitle: "例外邀請", inviteLead: "提供給尚無群組權限的合格人員。發出邀請即代表你的核准,邀請只限該人員與這個 Hub 使用。", inviteLogin: "公司登入名稱", inviteCreate: "建立邀請", inviteCopy: "複製邀請",
|
|
56
58
|
manualApproved: "由 Hub 管理員核准。", adminTitle: "公司帳號連接", adminLead: "群組權限允許的人員可連接自己的 Fleet,不需逐一核准。",
|
|
57
59
|
enabled: "允許以公司帳號連接 Fleet", companyLink: "公司連結", copy: "複製公司連結", copied: "已複製", copyFailed: "複製失敗,請選取並複製連結。",
|
|
60
|
+
accessTitle: "允許的群組與人員", accessLead: "設定允許的 AD 群組,或為合格人員發出個別 Fleet 連接例外邀請。", groupOpen: "管理群組權限", colleagueCopy: "複製同仁連線連結", colleagueHint: "連結包含 Hub 位址與固定的身分指紋;請同仁貼到自己 Fleet 的「設定 → Hub」。", linkDetails: "連接連結內容", offHint: "請先開啟公司帳號連接,才能複製連結或建立邀請。", inviteScope: "邀請只核准一次 Fleet 連接,不會授予 Agent 對話或分享權限。",
|
|
58
61
|
firstUse: "首次連接時,這個 Fleet 會記住 Hub 的身分。請使用管理員提供的公司連結。",
|
|
59
62
|
linkLead: "請開啟你的 Fleet「設定 → Hub」,貼上這個公司連結。若知道 Fleet 網頁位址,也可在下方開啟設定。這個頁面不會連接 Fleet,也不會要求公司密碼。",
|
|
60
63
|
fleetAddress: "Fleet 網頁位址", openFleet: "開啟 Fleet 設定", invalidLink: "這個公司連結不完整,請向 Hub 管理員取得新連結。",
|
|
@@ -3,6 +3,7 @@ import { html, useEffect, useRef, useState } from "/assets/app-html.js";
|
|
|
3
3
|
import { Skeleton, ErrorState } from "/assets/ui-states.js";
|
|
4
4
|
import { hubClient } from "./hub-client.js";
|
|
5
5
|
import { hj, joinError } from "./hub-company-join-strings.js";
|
|
6
|
+
import * as entryWords from "./hub-company-join-strings.js";
|
|
6
7
|
export function joinRequest() {
|
|
7
8
|
try { const id = new URLSearchParams(location.search).get("join"); return /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/.test(id || "") ? id : null; }
|
|
8
9
|
catch { return null; }
|
|
@@ -78,10 +79,12 @@ export function HubCompanyJoinPage({ session }) {
|
|
|
78
79
|
${error ? html`<${ErrorState} message=${error} onRetry=${() => { setError(null); retry(); }} />` : null}
|
|
79
80
|
</section></div></div>`;
|
|
80
81
|
}
|
|
81
|
-
export
|
|
82
|
+
export const companyJoinAdminEntryV1 = entryWords.companyAdminStringsV1 === true;
|
|
83
|
+
export function CompanyJoinAdminCard({ entry = false, groups = false } = {}) {
|
|
82
84
|
const [view, setView] = useState(null), [error, setError] = useState(null), [busy, setBusy] = useState(false), [copied, setCopied] = useState(false);
|
|
83
85
|
const live = useRef(true), csrf = useRef(null);
|
|
84
86
|
const [inviteLogin, setInviteLogin] = useState(""), [invitation, setInvitation] = useState(null);
|
|
87
|
+
const [invitationCopied, setInvitationCopied] = useState(false);
|
|
85
88
|
const read = async () => {
|
|
86
89
|
const session = await hubClient().session();
|
|
87
90
|
if (!live.current) return;
|
|
@@ -101,8 +104,23 @@ export function CompanyJoinAdminCard() {
|
|
|
101
104
|
e.preventDefault(); if (busy || !inviteLogin.trim()) return; setBusy(true); setError(null);
|
|
102
105
|
const r = await call("/hub/v1/admin/company-join/invitations", "POST", { login: inviteLogin.trim() }, csrf.current);
|
|
103
106
|
if (!live.current) return; setBusy(false);
|
|
104
|
-
if (r.ok) setInvitation(r.url); else setError(joinError(r.code === "not-found" ? "denied" : r.code));
|
|
107
|
+
if (r.ok) { setInvitation(r.url); setInvitationCopied(false); } else setError(joinError(r.code === "not-found" ? "denied" : r.code));
|
|
105
108
|
};
|
|
109
|
+
if (entry) return html`<section class="card hub-company-join hub-admin-access" data-entry="allowed-groups-people"><h3>${hj("accessTitle")}</h3>
|
|
110
|
+
<p class="note">${hj("accessLead")}</p>
|
|
111
|
+
<div class="field-row">${groups ? html`<a class="btn btn-primary" href="/ui/hub/admin?view=groups">${hj("groupOpen")}</a>` : null}
|
|
112
|
+
<button type="button" class="btn" disabled=${!view?.enabled || !view?.companyLink || busy || !!error} aria-describedby="hubColleagueLinkHint" onClick=${async () => { try { await navigator.clipboard.writeText(view.companyLink); if (live.current) setCopied(true); } catch { if (live.current) setError(hj("copyFailed")); } }}>${hj(copied ? "copied" : "colleagueCopy")}</button></div>
|
|
113
|
+
<p class="note" id="hubColleagueLinkHint">${hj(view ? view.enabled ? "colleagueHint" : "offHint" : "loading")}</p>
|
|
114
|
+
${!view && !error ? html`<${Skeleton} variant="form" lines=${3} />` : null}
|
|
115
|
+
${error ? html`<${ErrorState} message=${error} onRetry=${read} />` : null}
|
|
116
|
+
${view ? html`<label class="check"><input type="checkbox" role="switch" class="s-ui-toggle" checked=${view.enabled} disabled=${busy || !!error} onChange=${e => change(e.target.checked)} /><span>${hj("enabled")}</span></label>
|
|
117
|
+
${view.companyLink && view.enabled ? html`<details class="s-ui-disclosure"><summary>${hj("linkDetails")}</summary><div class="s-disclosure-body"><label class="field"><span>${hj("companyLink")}</span><textarea rows="4" readonly value=${view.companyLink} /></label></div></details>` : null}` : null}
|
|
118
|
+
${view?.enabled ? html`<div class="form hub-admin-individual"><h4>${hj("inviteTitle")}</h4><p class="note">${hj("inviteLead")} ${hj("inviteScope")}</p>
|
|
119
|
+
<form class="form" onSubmit=${makeInvitation}><label class="field"><span>${hj("inviteLogin")}</span><input autocomplete="off" value=${inviteLogin} onInput=${e => setInviteLogin(e.target.value)} /></label>
|
|
120
|
+
<div class="field-row"><button class="btn btn-sm" type="submit" disabled=${busy || !!error || !inviteLogin.trim()}>${hj("inviteCreate")}</button></div></form>
|
|
121
|
+
${invitation ? html`<label class="field"><span>${hj("inviteTitle")}</span><textarea rows="4" readonly value=${invitation} /></label>
|
|
122
|
+
<button type="button" class="btn btn-sm" onClick=${async () => { try { await navigator.clipboard.writeText(invitation); if (live.current) setInvitationCopied(true); } catch { if (live.current) setError(hj("copyFailed")); } }}>${hj(invitationCopied ? "copied" : "inviteCopy")}</button>` : null}</div>` : null}
|
|
123
|
+
</section>`;
|
|
106
124
|
return html`<section class="card hub-company-join"><h3>${hj("adminTitle")}</h3><p class="note">${hj("adminLead")}</p>
|
|
107
125
|
${!view && !error ? html`<${Skeleton} variant="form" lines=${3} />` : null}
|
|
108
126
|
${error ? html`<${ErrorState} message=${error} onRetry=${read} />` : null}
|
|
@@ -3,15 +3,16 @@
|
|
|
3
3
|
// and rules come only from here.
|
|
4
4
|
import { register, t } from "/assets/app-i18n.js";
|
|
5
5
|
|
|
6
|
+
export const ownerAdminEntryV1 = true;
|
|
6
7
|
register("hubOwner", {
|
|
7
8
|
en: {
|
|
8
9
|
memberAddress: "Hub address", memberAddressHint: "Paste this address into the Hub address field in your fleet's Settings → Hub → Connect to a Hub, together with the code. This is separate from the Hub's browser address.",
|
|
9
10
|
memberAddressMissing: "Ask the administrator for the address to enter in the Hub address field; it may use a different port from this page.", copyHandoff: "Copy address and code", handoffCopied: "Address and code copied", handoffCopyFailed: "Couldn't copy. Select the address and code above to copy them.",
|
|
10
|
-
active: "Active", adminLead: "
|
|
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",
|
|
11
12
|
allow: "Allow…", allowDays: "For", allowGo: "Allow", allowLogin: "Their sign-in name",
|
|
12
13
|
allowLoginHint: "The account they sign in to this Hub with.", allowTitle: "Allow someone to ask {0}", approveGo: "Approve…",
|
|
13
|
-
approvedTag: "Approved", backToMine: "My shared agents", codeFor: "
|
|
14
|
-
makeCode: "
|
|
14
|
+
approvedTag: "Approved", backToMine: "My shared agents", codeFor: "Pairing code for {0}", codeUnusedYet: "Not used yet", fleetOf: "{0}'s fleet",
|
|
15
|
+
makeCode: "Create pairing code", mayAsk: "{0} may ask", mayAskNone: "No one may ask yet", mayAskOne: "1 may ask",
|
|
15
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.",
|
|
16
17
|
noFleets: "No fleet is paired yet.", ownerChecked: "The owner confirmed", ownerLogin: "Owner's sign-in name", pairSteps: "Pair a fleet",
|
|
17
18
|
pairedFleets: "Paired fleets · {0}", pauseGo: "Pause…", pauseLead: "No one can ask it until it is shared again. What was asked stays readable.",
|
|
@@ -28,7 +29,7 @@ register("hubOwner", {
|
|
|
28
29
|
"zh-TW": {
|
|
29
30
|
memberAddress: "Hub 位址", memberAddressHint: "在你的 Fleet「設定 → Hub → 連線到 Hub」的「Hub 位址」欄位貼上這個位址,並輸入配對碼。這與 Hub 的瀏覽器位址不同。",
|
|
30
31
|
memberAddressMissing: "請向管理員索取要填入「Hub 位址」欄位的位址;它的連接埠可能與這個頁面不同。", copyHandoff: "複製位址與配對碼", handoffCopied: "已複製位址與配對碼", handoffCopyFailed: "無法複製。請選取上方的位址與配對碼來複製。",
|
|
31
|
-
active: "使用中", adminLead: "
|
|
32
|
+
active: "使用中", adminLead: "管理允許連接的人員與已連接的 Fleet。這裡看不到任何人的對話。", manualAdvanced: "進階:使用配對碼連接", allow: "允許提問…", allowDays: "期限", allowGo: "允許", allowLogin: "對方的登入名稱",
|
|
32
33
|
allowLoginHint: "對方登入這個 Hub 用的帳號。", allowTitle: "允許提問 {0}", approveGo: "核准…", approvedTag: "已核准", backToMine: "我分享的 Agent",
|
|
33
34
|
codeFor: "給 {0} 的配對碼", codeUnusedYet: "還沒使用", fleetOf: "{0} 的 Fleet", makeCode: "產生配對碼", mayAsk: "{0} 人可以提問", mayAskNone: "還沒有人可以提問",
|
|
34
35
|
mayAskOne: "1 人可以提問", mineLead: "在這個 Hub 上代表你回答的 Agent:誰可以提問、到什麼時候、最近誰問過。要開始或停止分享,請到你 Fleet 的「設定 → Hub」。", mineLeadShort: "在這個 Hub 上代表你回答的 Agent:誰可以提問、到什麼時候、最近誰問過。", noFleets: "還沒有配對的 Fleet。",
|
|
@@ -7,7 +7,7 @@ register("hubPairingProgress", {
|
|
|
7
7
|
unknown: "The result cannot be checked right now. Review the pairing status and the confirmation card before trying again.",
|
|
8
8
|
},
|
|
9
9
|
"zh-TW": {
|
|
10
|
-
connectFailed: "配對未完成。請在 Hub
|
|
10
|
+
connectFailed: "配對未完成。請在 Hub 重新開始配對,再將新的手動配對碼填在這裡。",
|
|
11
11
|
notApplied: "這次要求未套用。請先查看上方的配對狀態,再決定是否重試。",
|
|
12
12
|
unknown: "目前無法確認結果。請先查看配對狀態與確認卡片,再決定是否重試。",
|
|
13
13
|
},
|
|
@@ -23,17 +23,17 @@ register("hubQuick", {
|
|
|
23
23
|
"zh-TW": {
|
|
24
24
|
start: "連接我的 Fleet", label: "Fleet 名稱", labelHint: "取一個你和 Hub 管理員都認得的名字。", labelExample: "例如:我的筆電",
|
|
25
25
|
privacy: "只連接你能控制的 Fleet。你的其他 Hub 登入工作階段、已連接的 Fleet 和 Hub 管理員都會收到通知。",
|
|
26
|
-
localTitle: "在你的 Fleet 確認", local: "在你的 Fleet 網頁開啟「設定 → Hub」,開啟「允許這個 Fleet 連線至 Hub」,將以下位址貼到「Hub
|
|
26
|
+
localTitle: "在你的 Fleet 確認", local: "在你的 Fleet 網頁開啟「設定 → Hub」,開啟「允許這個 Fleet 連線至 Hub」,將以下位址貼到「Hub 位址」欄位,再輸入手動配對碼,並在當地確認提示。",
|
|
27
27
|
remoteSteps: "也要在 Hub 完成指紋比對。", ownerStep: "在 Hub 比對這個指紋,並確認你的配對。", policyStep: "Hub 會檢查群組規則,或等待管理員核准。",
|
|
28
|
-
address: "Hub 位址", code: "
|
|
28
|
+
address: "Hub 位址", code: "手動配對碼", copy: "複製", copied: "已複製", expires: "有效至 {0}",
|
|
29
29
|
compareTitle: "比對指紋", compare: "在你的 Fleet 開啟「設定 → Hub → 等待核准」,將當地指紋與下方逐一比對,也要在你的 Fleet 確認。",
|
|
30
30
|
match: "指紋相符", mismatch: "指紋不同", mismatchStop: "指紋不同,已停止配對,沒有核准連線。請先檢查位址,再重新開始。",
|
|
31
|
-
stop: "停止配對", stopped: "已停止配對", again: "重新開始", waiting: "等待你的 Fleet
|
|
31
|
+
stop: "停止配對", stopped: "已停止配對", again: "重新開始", waiting: "等待你的 Fleet 使用手動配對碼並在當地確認…", claim: "等待你的 Fleet 建立已固定憑證的連線…",
|
|
32
32
|
another: "連接另一個 Fleet",
|
|
33
33
|
connected: "已連接", publish: "在你的 Fleet 分享 Agent", publishHint: "在你的 Fleet 開啟「設定 → Hub → 已分享的 Agent」,選擇你要分享的 Agent 並在當地確認。不會自動分享任何 Agent。",
|
|
34
34
|
publishNo: "Fleet 已連接,但你目前的權限不包含分享新的 Agent。請聯絡 Hub 管理員。",
|
|
35
35
|
expired: "這次配對已過期或被取代,無法再連接 Fleet。請重新開始。", unavailable: "目前無法確認權限或連線。請重試;此頁無法確認配對是否已完成。",
|
|
36
|
-
denied: "你目前無法連接 Fleet。請聯絡 Hub 管理員。", conflict: "
|
|
36
|
+
denied: "你目前無法連接 Fleet。請聯絡 Hub 管理員。", conflict: "管理員已為你建立手動配對碼。請使用它,或請管理員協助。",
|
|
37
37
|
limit: "已達 Fleet 或配對數量上限。請停止未使用的配對,或撤銷不再使用的 Fleet,再重試。", retry: "重試", failed: "這次操作未能完成,請重試。",
|
|
38
38
|
notices: "Fleet 安全通知", notice: "已連接新的 Fleet:{0}", approved: "由 Hub 群組規則核准。", revoke: "撤銷此 Fleet", revokeAsk: "要撤銷「{0}」嗎?它會立即失去 Hub 存取。你的其他 Fleet 和本機 Agent 工作不受影響。", revoked: "已撤銷",
|
|
39
39
|
revokeHint: "停止這個 Fleet 的 Hub 存取。你的其他 Fleet 和本機 Agent 工作不受影響。", review: "在 Hub 查看並撤銷", previous: "較早的通知", more: "顯示更早的通知", fleetId: "Fleet ID",
|
package/dist/ui/hub-strings.js
CHANGED
|
@@ -107,7 +107,7 @@ register("hub", {
|
|
|
107
107
|
noGrants: "目前沒有人可以提問。", grantLogin: "允許這個帳號提問", grantDays: "期間", days: "{0} 天", allow: "允許",
|
|
108
108
|
freeze: "停止所有提問", freezeAsk: "要停止所有人向 {0} 提問嗎?之後要再公開,需要你的 Fleet 重新核准。",
|
|
109
109
|
revoke: "撤銷", revokeAsk: "要撤銷 {0} 的權限嗎?對方的對話會關閉。",
|
|
110
|
-
adminOnly: "只有 Hub
|
|
110
|
+
adminOnly: "只有 Hub 管理員可以查看", adminOnlyHint: "已配對的 Fleet 與配對碼在這裡管理。",
|
|
111
111
|
pairTitle: "配對 Fleet", pairLead: "為已登入過這個 Hub 的人建立一次性配對碼,只能使用一次,十分鐘內有效。",
|
|
112
112
|
pairOwner: "擁有者帳號", pairCreate: "建立配對碼", pairCode: "請把這組配對碼交給 {0},在對方 Fleet 的設定頁輸入:",
|
|
113
113
|
pendingPairings: "配對請求", codeUnused: "配對碼尚未使用", ownerConfirmed: "擁有者已確認", ownerWaiting: "等待擁有者確認",
|
|
@@ -116,20 +116,20 @@ register("hub", {
|
|
|
116
116
|
noFleets: "還沒有配對的 Fleet。",
|
|
117
117
|
title: "連線到 Hub",
|
|
118
118
|
lead: "Hub 讓組織裡的人可以向你選擇公開的 Agent 提問。你的 Fleet 仍然屬於你:要公開哪些 Agent、誰可以提問,都由你決定。",
|
|
119
|
-
address: "Hub 位址", addressPh: "https://", addressHint: "Hub
|
|
119
|
+
address: "Hub 位址", addressPh: "https://", addressHint: "Hub 管理員給你的 https:// 位址。", code: "一次性配對碼", connect: "連線",
|
|
120
120
|
errAddress: "請輸入 Hub 的 https:// 位址。", errCode: "請完整輸入配對碼。",
|
|
121
121
|
errBusy: "這個 Fleet 已經連線,或正在等待核准。", errUnreachable: "無法連到這個位址的 Hub。",
|
|
122
122
|
errRefused: "Hub 拒絕了這個配對碼。", errFailed: "沒有成功,請再試一次。",
|
|
123
123
|
pendingTitle: "等待核准", pairingFp: "配對指紋",
|
|
124
124
|
pendingCompare: "請和 Hub 畫面上的指紋比對,兩者相同後再到 Hub 確認。",
|
|
125
|
-
pendingSteps: "還需要:", ownerStep: "你用自己的 Hub 帳號確認", adminStep: "Hub
|
|
125
|
+
pendingSteps: "還需要:", ownerStep: "你用自己的 Hub 帳號確認", adminStep: "Hub 管理員核准",
|
|
126
126
|
done: "已完成", waiting: "等待中", expires: "{0} 到期", cancel: "取消請求", showFull: "顯示完整指紋", hideFull: "收合",
|
|
127
127
|
pairedTitle: "已連線到 {0}", online: "在線", offline: "離線,正在重新連線", hubKeyFp: "Hub 金鑰指紋",
|
|
128
128
|
openHub: "開啟 Hub", disconnect: "中斷連線",
|
|
129
129
|
disconnectAsk: "要中斷與 {0} 的連線嗎?你在那裡公開的 Agent 都會撤回。",
|
|
130
130
|
disconnectPending: "已在這裡中斷。Hub 尚未確認,連得上時會再通知它。",
|
|
131
131
|
keyTitle: "Hub 的金鑰已變更",
|
|
132
|
-
keyLead: "重新配對前不會連線。若你沒有預期這個變更,請先詢問 Hub
|
|
132
|
+
keyLead: "重新配對前不會連線。若你沒有預期這個變更,請先詢問 Hub 管理員,再重新配對。",
|
|
133
133
|
keyApproved: "已核准的金鑰", keyOffered: "Hub 目前提供的金鑰", repair: "重新配對",
|
|
134
134
|
heldTitle: "暫停中", holdClear: "重新開始",
|
|
135
135
|
hold_unknown_outcome: "最後一個配對步驟的結果不明,確認之前不會執行任何工作。",
|
|
@@ -143,9 +143,9 @@ register("hub", {
|
|
|
143
143
|
waitingConfirm: "等待你的確認", pendingSent: "已送出確認:請在 General 的聊天或設定中確認,才會公開。",
|
|
144
144
|
errLimit: "最多只能公開 64 個 Agent。", notAvailable: "這個 AgEnD 版本無法使用此功能。",
|
|
145
145
|
hubStillNeeded: "還需要在 Hub 完成:", ownerStepHub: "你的確認:登入 Hub,在「我的公開 Agent」確認這個指紋。",
|
|
146
|
-
adminStepHub: "Hub
|
|
146
|
+
adminStepHub: "Hub 管理員核准這個指紋。", hubProgressHidden: "這個頁面看不到 Hub 那邊的進度,兩項都完成後就會連線。",
|
|
147
147
|
localMatch: "和 Hub 畫面上的一致", localConfirmed: "你已在這裡確認這個指紋。",
|
|
148
|
-
hold_disconnected: "已在這裡中斷連線。Hub
|
|
148
|
+
hold_disconnected: "已在這裡中斷連線。Hub 管理員撤銷之前,Hub 上仍會列出這個 Fleet。", startOver: "重新開始",
|
|
149
149
|
errConflict: "這份清單在其他分頁有變更,已重新載入,請再試一次。", errUnsaved: "無法儲存這個變更。",
|
|
150
150
|
errNotPaired: "請先連線到 Hub。", withdrawPending: "已在這裡撤回,連得上 Hub 時會再通知它。",
|
|
151
151
|
},
|
|
@@ -13,14 +13,14 @@ import { cliLabel } from "./cli-picker.js";
|
|
|
13
13
|
|
|
14
14
|
register("machineSignin", {
|
|
15
15
|
en: {
|
|
16
|
-
title: "
|
|
17
|
-
lead: "AgEnD asks {0}'s Runtime to
|
|
16
|
+
title: "Connect {0} account “{1}” on {2}",
|
|
17
|
+
lead: "AgEnD asks {0}'s Runtime to connect this account. You get a link here, open it in your browser, finish on the provider's official website, and paste back the authorization code it shows. The connection is kept on that computer, and anyone who can sign in to that Windows user can use it.",
|
|
18
18
|
console: "Using an Anthropic Console account instead? Run this on that computer: {0}",
|
|
19
19
|
close: "Close",
|
|
20
20
|
},
|
|
21
21
|
"zh-TW": {
|
|
22
|
-
title: "在 {2}
|
|
23
|
-
lead: "AgEnD 會請 {0} 的 Runtime
|
|
22
|
+
title: "在 {2} 連接 {0} 帳號「{1}」",
|
|
23
|
+
lead: "AgEnD 會請 {0} 的 Runtime 連接這個帳號。這裡會給你一個連結,在瀏覽器開啟、前往官方網站完成授權後,把它顯示的授權碼貼回來。連接資料保存在那台電腦上,能登入該 Windows 使用者的人都能使用它。",
|
|
24
24
|
console: "要改用 Anthropic Console 帳號嗎?請在那台電腦上執行:{0}",
|
|
25
25
|
close: "關閉",
|
|
26
26
|
},
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// M-2731: feature-owned words/styles travel with lazy panels, including tabs with an older shell/catalog module.
|
|
2
|
+
import { html, useEffect, useRef, useState } from "/assets/app-html.js";
|
|
3
|
+
import { register, t } from "/assets/app-i18n.js";
|
|
4
|
+
import { Icon } from "/assets/ui-icons.js";
|
|
5
|
+
import { ErrorState } from "/assets/ui-states.js";
|
|
6
|
+
import * as catalogStore from "./settings-catalog.js";
|
|
7
|
+
register("modelPicker", {
|
|
8
|
+
en: { refresh: "Refresh models", refreshing: "Refreshing models…", refreshed: "Model list refreshed.", failed: "Could not refresh models. The previous list and selection are kept.", more: "More models…", backend: "Choose backend", model: "Choose model", next: "Choose a backend; next choose its model and reasoning effort.", current: "Selected", nativeFailed: "Could not refresh models on this computer. Update its Runtime if needed and check that its owner allows account access. The previous list and selection are kept.", keep: "Refreshing keeps the selected model.", selectionHint: "Refresh keeps your selection; choose a model to apply it.", accountSource: "Source: selected account’s model listing." },
|
|
9
|
+
"zh-TW": { refresh: "重新整理模型", refreshing: "正在重新整理模型…", refreshed: "模型清單已更新。", failed: "無法重新整理模型。已保留原清單與選擇。", more: "更多模型…", backend: "選擇後端", model: "選擇模型", next: "選擇後端;下一步選模型與推理強度", current: "已選擇", nativeFailed: "無法在這台電腦重新整理模型。請確認 Runtime 已更新,且電腦擁有者允許存取帳號;已保留原清單與選擇。", keep: "重新整理會保留已選模型。", selectionHint: "重新整理只更新清單;選擇模型才會套用。", accountSource: "來源:已選帳號的模型清單。" },
|
|
10
|
+
});
|
|
11
|
+
export const mw = key => t(`modelPicker.${key}`);
|
|
12
|
+
export function modelPickerStyles() {
|
|
13
|
+
if (typeof document === "undefined" || !document.head || document.querySelector('link[href="/assets/model-picker.css"]')) return;
|
|
14
|
+
const link = document.createElement("link"); link.setAttribute("rel", "stylesheet"); link.setAttribute("href", "/assets/model-picker.css"); document.head.appendChild(link);
|
|
15
|
+
}
|
|
16
|
+
const answers = new Map(); // share only in-flight passive reads; the server owns catalog freshness
|
|
17
|
+
export function forgetModelPickerCatalogs() { answers.clear(); catalogStore.forgetCatalogs?.(); }
|
|
18
|
+
/** Selection remains owned by the form; rediscovery never calls its onChange or stages a change. */
|
|
19
|
+
export function useRefreshableModels(backend, instance, context = {}) {
|
|
20
|
+
const { runtime, machineId, profile } = context;
|
|
21
|
+
const target = { backend, ...(instance ? {instance} : {}), ...(runtime === "windows" ? {runtime} : {}), ...(machineId ? {machineId} : {}), ...(profile !== undefined ? {profile} : {}) };
|
|
22
|
+
const key = JSON.stringify(target);
|
|
23
|
+
const [state, set] = useState({ key, models: [], phase: "loading" });
|
|
24
|
+
const generation = useRef(0);
|
|
25
|
+
const current = useRef(key), flight = useRef(null), mounted = useRef(true);
|
|
26
|
+
current.current = key;
|
|
27
|
+
useEffect(() => { mounted.current = true; return () => { mounted.current = false; }; }, []);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
let live = true; const gen = ++generation.current;
|
|
30
|
+
const url = `/ui/models?${new URLSearchParams(target)}`;
|
|
31
|
+
if (!backend) { set({ key, models: [], phase: "idle" }); return () => { live = false; }; }
|
|
32
|
+
const hit = answers.get(key), fresh = !!hit;
|
|
33
|
+
const promise = fresh ? hit.promise : typeof catalogStore.readModelCatalogSnapshot === "function" ? catalogStore.readModelCatalogSnapshot(target)
|
|
34
|
+
: typeof catalogStore.readModelCatalog === "function" ? catalogStore.readModelCatalog(target).then(models => ({ models }))
|
|
35
|
+
: fetch(url, { credentials: "same-origin" }).then(async r => { if (!r.ok) throw Error(); const data = await r.json(); if (!Array.isArray(data.models)) throw Error(); return data; });
|
|
36
|
+
if (!fresh) { answers.set(key, { promise }); if (answers.size > 64) answers.delete(answers.keys().next().value); }
|
|
37
|
+
set({ key, models: [], phase: "loading" }); flight.current = null;
|
|
38
|
+
promise.finally(() => { if (answers.get(key)?.promise === promise) answers.delete(key); }).catch(() => {});
|
|
39
|
+
promise.then(data => { if (live && gen === generation.current) set({ key, models: data.models, source: data.source, phase: "idle" }); }, () => { if (answers.get(key)?.promise === promise) answers.delete(key); if (live && gen === generation.current) set({ key, models: [], phase: "load_error" }); });
|
|
40
|
+
return () => { live = false; };
|
|
41
|
+
}, [key]);
|
|
42
|
+
const shown = state.key === key ? state : { key, models: [], phase: "loading" };
|
|
43
|
+
async function refresh() {
|
|
44
|
+
if (flight.current || !backend) return;
|
|
45
|
+
const token = {}; flight.current = token; generation.current++;
|
|
46
|
+
set({ ...shown, phase: "busy" });
|
|
47
|
+
try {
|
|
48
|
+
const r = await fetch("/ui/models/refresh", { method: "POST", credentials: "same-origin", headers: { "Content-Type": "application/json" }, body: JSON.stringify(target) });
|
|
49
|
+
const data = await r.json();
|
|
50
|
+
if (!r.ok || data.refreshed !== true || !Array.isArray(data.models)) throw Error();
|
|
51
|
+
if (!mounted.current || current.current !== key || flight.current !== token) return;
|
|
52
|
+
answers.delete(key); // Retire the earlier passive flight before a remount can borrow it.
|
|
53
|
+
catalogStore.rememberModelCatalog?.(target, data);
|
|
54
|
+
set({ key, models: data.models, source: data.source, phase: "done" });
|
|
55
|
+
} catch { if (mounted.current && current.current === key && flight.current === token) set({ ...shown, phase: "error" }); }
|
|
56
|
+
finally { if (flight.current === token) flight.current = null; }
|
|
57
|
+
}
|
|
58
|
+
return { ...shown, loading: shown.phase === "loading", refresh, native: runtime === "windows" };
|
|
59
|
+
}
|
|
60
|
+
export function ModelRefresh({ state, disabled, initialFailure }) {
|
|
61
|
+
modelPickerStyles();
|
|
62
|
+
return html`<div class="model-refresh model-catalog-status"><button type="button" class="btn" disabled=${disabled || state.phase === "busy"} onClick=${state.refresh}>
|
|
63
|
+
<${Icon} name="restart" size=${16} />${mw(state.phase === "busy" ? "refreshing" : "refresh")}</button>
|
|
64
|
+
<p class="note">${mw("keep")}</p>
|
|
65
|
+
${(state.phase === "error" || state.phase === "load_error") ? html`<${ErrorState} message=${state.phase === "load_error" && initialFailure || mw(state.native ? "nativeFailed" : "failed")} onRetry=${disabled ? undefined : state.refresh} />`
|
|
66
|
+
: state.phase === "done" ? html`<p class="note" role="status">${mw("refreshed")}</p>` : null}</div>`;
|
|
67
|
+
}
|
|
68
|
+
export const modelLabel = value => ({ sonnet: "Sonnet", opus: "Opus", haiku: "Haiku" }[value] || value);
|