@songsid/agend 2.4.0-beta.13 → 2.4.0-beta.15
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/agent-endpoint.js +28 -6
- package/dist/agent-endpoint.js.map +1 -1
- package/dist/auth-api.js +1 -0
- package/dist/auth-api.js.map +1 -1
- package/dist/backend/claude-code.d.ts +9 -0
- package/dist/backend/claude-code.js +60 -4
- package/dist/backend/claude-code.js.map +1 -1
- package/dist/backend/grok.js +11 -0
- package/dist/backend/grok.js.map +1 -1
- package/dist/backend/types.d.ts +3 -0
- package/dist/backend/types.js.map +1 -1
- package/dist/backend-availability.d.ts +1 -16
- package/dist/backend-availability.js +2 -91
- package/dist/backend-availability.js.map +1 -1
- package/dist/backend-version-static.d.ts +15 -0
- package/dist/backend-version-static.js +95 -0
- package/dist/backend-version-static.js.map +1 -0
- package/dist/build-provenance.json +1 -1
- package/dist/channel/adapters/telegram.js +3 -1
- package/dist/channel/adapters/telegram.js.map +1 -1
- package/dist/channel/mcp-server.js +18 -1
- package/dist/channel/mcp-server.js.map +1 -1
- package/dist/channel/tool-router.d.ts +4 -0
- package/dist/channel/tool-router.js +43 -19
- package/dist/channel/tool-router.js.map +1 -1
- package/dist/classic-channel-manager.d.ts +3 -0
- package/dist/classic-channel-manager.js +18 -0
- package/dist/classic-channel-manager.js.map +1 -1
- package/dist/classic-cli-guard.d.ts +66 -0
- package/dist/classic-cli-guard.js +209 -0
- package/dist/classic-cli-guard.js.map +1 -0
- package/dist/cli-audited.js +7 -5
- package/dist/cli-audited.js.map +1 -1
- package/dist/config-validator.js +3 -0
- package/dist/config-validator.js.map +1 -1
- package/dist/contact-auth-api.d.ts +17 -0
- package/dist/contact-auth-api.js +88 -0
- package/dist/contact-auth-api.js.map +1 -0
- package/dist/contact-auth-files.d.ts +6 -0
- package/dist/contact-auth-files.js +29 -0
- package/dist/contact-auth-files.js.map +1 -0
- package/dist/contact-auth-policy.d.ts +80 -0
- package/dist/contact-auth-policy.js +25 -0
- package/dist/contact-auth-policy.js.map +1 -0
- package/dist/contact-auth-service.d.ts +32 -0
- package/dist/contact-auth-service.js +99 -0
- package/dist/contact-auth-service.js.map +1 -0
- package/dist/contact-auth-store.d.ts +86 -0
- package/dist/contact-auth-store.js +357 -0
- package/dist/contact-auth-store.js.map +1 -0
- package/dist/contact-auth-types.d.ts +196 -0
- package/dist/contact-auth-types.js +7 -0
- package/dist/contact-auth-types.js.map +1 -0
- package/dist/daemon.d.ts +8 -0
- package/dist/daemon.js +93 -4
- package/dist/daemon.js.map +1 -1
- package/dist/delivery-outbox.d.ts +6 -0
- package/dist/delivery-outbox.js +19 -0
- package/dist/delivery-outbox.js.map +1 -1
- package/dist/fleet-manager.d.ts +48 -0
- package/dist/fleet-manager.js +484 -22
- package/dist/fleet-manager.js.map +1 -1
- package/dist/general-knowledge/skills/concepts/SKILL.md +18 -0
- package/dist/general-knowledge/skills/credential-profiles/SKILL.md +5 -0
- package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +38 -0
- package/dist/general-knowledge/skills/hub/SKILL.md +6 -0
- package/dist/general-knowledge/skills/web-dashboard/SKILL.md +5 -0
- package/dist/hub/audit/index.d.ts +3 -1
- package/dist/hub/audit/index.js +35 -3
- package/dist/hub/audit/index.js.map +1 -1
- package/dist/hub/catalog.d.ts +8 -0
- package/dist/hub/catalog.js +39 -4
- package/dist/hub/catalog.js.map +1 -1
- package/dist/hub/compose/server.d.ts +2 -0
- package/dist/hub/compose/server.js +11 -1
- package/dist/hub/compose/server.js.map +1 -1
- package/dist/hub/directory/directory.js +5 -2
- package/dist/hub/directory/directory.js.map +1 -1
- package/dist/hub/directory/types.d.ts +5 -1
- package/dist/hub/directory/types.js.map +1 -1
- package/dist/hub/group-policy/resources.d.ts +1 -1
- package/dist/hub/http/compose.d.ts +2 -0
- package/dist/hub/http/compose.js +123 -6
- package/dist/hub/http/compose.js.map +1 -1
- package/dist/hub/http/deps.d.ts +2 -0
- package/dist/hub/http/schema.js +6 -1
- package/dist/hub/http/schema.js.map +1 -1
- package/dist/hub/invitations.js +15 -7
- package/dist/hub/invitations.js.map +1 -1
- package/dist/hub/roles/cutover-inventory.d.ts +3 -0
- package/dist/hub/roles/cutover-inventory.js +20 -4
- package/dist/hub/roles/cutover-inventory.js.map +1 -1
- package/dist/hub/roles/cutover-marker.d.ts +18 -2
- package/dist/hub/roles/cutover-marker.js +6 -2
- package/dist/hub/roles/cutover-marker.js.map +1 -1
- package/dist/hub/room-agent-discovery-model.d.ts +29 -0
- package/dist/hub/room-agent-discovery-model.js +33 -0
- package/dist/hub/room-agent-discovery-model.js.map +1 -0
- package/dist/hub/room-agent-discovery.d.ts +14 -0
- package/dist/hub/room-agent-discovery.js +65 -0
- package/dist/hub/room-agent-discovery.js.map +1 -0
- package/dist/hub/room-agent-requests.d.ts +71 -0
- package/dist/hub/room-agent-requests.js +377 -0
- package/dist/hub/room-agent-requests.js.map +1 -0
- package/dist/hub/rooms/directory.d.ts +13 -0
- package/dist/hub/rooms/directory.js +12 -3
- package/dist/hub/rooms/directory.js.map +1 -1
- package/dist/hub/rooms/schema.d.ts +5 -0
- package/dist/hub/rooms/schema.js +9 -0
- package/dist/hub/rooms/schema.js.map +1 -1
- package/dist/hub/rooms/service.d.ts +43 -19
- package/dist/hub/rooms/service.js +67 -11
- package/dist/hub/rooms/service.js.map +1 -1
- package/dist/hub/rooms/types.d.ts +1 -1
- package/dist/instance-lifecycle.d.ts +3 -1
- package/dist/instance-lifecycle.js +4 -1
- package/dist/instance-lifecycle.js.map +1 -1
- package/dist/locale.js +34 -4
- package/dist/locale.js.map +1 -1
- package/dist/needs-you-hub.d.ts +1 -0
- package/dist/needs-you-hub.js +9 -0
- package/dist/needs-you-hub.js.map +1 -1
- package/dist/needs-you.d.ts +12 -2
- package/dist/needs-you.js.map +1 -1
- package/dist/outbound-handlers.d.ts +9 -0
- package/dist/outbound-handlers.js +46 -10
- package/dist/outbound-handlers.js.map +1 -1
- package/dist/runtime-cli-install.js +7 -7
- package/dist/runtime-cli-install.js.map +1 -1
- package/dist/topic-commands.d.ts +1 -1
- package/dist/topic-commands.js +4 -6
- package/dist/topic-commands.js.map +1 -1
- package/dist/ui/agent-details-settings.js +7 -5
- package/dist/ui/contact-auth-client.js +50 -0
- package/dist/ui/contact-auth-strings.js +195 -0
- package/dist/ui/contact-authorizations.js +125 -0
- package/dist/ui/contact-needs.js +100 -0
- package/dist/ui/contact-permissions.js +238 -0
- package/dist/ui/contact-ticket-badge.js +54 -0
- package/dist/ui/contact-tool-groups.js +39 -0
- package/dist/ui/hub-client.js +30 -7
- package/dist/ui/hub-invitations.js +5 -1
- package/dist/ui/hub-room-new.js +10 -3
- package/dist/ui/hub-room-owner-requests-strings.js +114 -0
- package/dist/ui/hub-room-owner-requests.js +264 -0
- package/dist/ui/hub-room-pins.js +43 -0
- package/dist/ui/hub-room-settings.js +11 -2
- package/dist/ui/hub-room-strings.js +3 -0
- package/dist/ui/hub-room-thread.js +47 -5
- package/dist/ui/panel-chat.js +2 -0
- package/dist/ui/panel-details.js +2 -0
- package/dist/ui/panel-fleet.js +3 -2
- package/dist/ui/panel-hub.js +7 -1
- package/dist/ui/panel-needs.js +11 -4
- package/dist/ui/panel-settings.js +3 -0
- package/dist/ui/settings-appearance.js +6 -1
- package/dist/ui/settings-registry.js +1 -1
- package/dist/ui/shared/app-i18n.js +4 -0
- package/dist/ui/shared/app-route.js +1 -1
- package/dist/ui/shared/app-shell.js +18 -7
- package/dist/ui/shared/app-stream.js +3 -1
- package/dist/ui/shared/app.css +86 -0
- package/dist/ui/shared/chat-quote.js +26 -2
- package/dist/ui/shared/chat-thread.js +6 -2
- package/dist/ui/shared/hub-rooms-u2.css +22 -0
- package/dist/ui/shared/text-undo.js +17 -3
- package/dist/ui/shared/theme-picker.js +46 -0
- package/dist/ui/shared/theme.js +36 -3
- package/dist/ui/shared/tokens.css +273 -0
- package/dist/ui/shared/ui-confirm.js +5 -2
- package/dist/web-api.d.ts +10 -0
- package/dist/web-api.js +55 -3
- package/dist/web-api.js.map +1 -1
- package/dist/web-chat-history.d.ts +5 -0
- package/dist/web-chat-history.js +26 -0
- package/dist/web-chat-history.js.map +1 -1
- package/dist/web-reply-files.d.ts +1 -0
- package/dist/web-reply-files.js +2 -0
- package/dist/web-reply-files.js.map +1 -1
- package/dist/web-shell-routes.d.ts +1 -1
- package/dist/web-shell-routes.js +2 -1
- package/dist/web-shell-routes.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* M-3339 (A2): the words of contact authorizations — a ClassicBot room's requests to other agents held for approval, the
|
|
3
|
+
* agent page's Permissions, Fleet → Authorizations, the chat badges, Needs you and the restricted-mode suggestion. en and
|
|
4
|
+
* zh-TW (admin is 管理員). A module of its own (namespace contactAuth); imports only app-i18n.
|
|
5
|
+
*/
|
|
6
|
+
import { register, t } from "/assets/app-i18n.js";
|
|
7
|
+
|
|
8
|
+
register("contactAuth", {
|
|
9
|
+
en: {
|
|
10
|
+
tab: "Permissions", lead: "Who may ask this agent to forward requests to other agents, and what this room may use.",
|
|
11
|
+
loading: "Loading permissions…", loadFailed: "Couldn't load permissions.", retry: "Try again",
|
|
12
|
+
forbidden: "Only this agent's managers can see its permissions.", unavailable: "Permissions are unavailable right now. Try again in a moment.",
|
|
13
|
+
stale: "Someone changed these permissions just now. They have been reloaded — check them and try again.",
|
|
14
|
+
saved: "Saved.", saveFailed: "Couldn't save.", readOnly: "You can see these permissions but not change them.",
|
|
15
|
+
// Mode (a ClassicBot room)
|
|
16
|
+
modeTitle: "Room mode", modeRestricted: "Restricted", modeLegacy: "Not restricted (older setting)",
|
|
17
|
+
modeRestrictedNote: "Requests from people who aren't admins to other agents wait for approval before anything is sent.",
|
|
18
|
+
modeLegacyNote: "Requests from this room go to other agents without approval.",
|
|
19
|
+
switchRestricted: "Switch to restricted", switchLegacy: "Turn restricted mode off",
|
|
20
|
+
confirmRestricted: "Switch this room to restricted mode?", confirmLegacy: "Turn restricted mode off? Requests from this room will go to other agents without approval. Work already handed to another agent stays as it is.",
|
|
21
|
+
wouldDisableTitle: "These tools will stop in this room:", wouldDisableNone: "No tool this room uses now will stop.",
|
|
22
|
+
// M-3387: what stops, by kind and layer.
|
|
23
|
+
toolsLostTitle: "AgEnD tools this room loses ({0}):", toolGroupLine: "• {0} ({1})",
|
|
24
|
+
toolGroup_fleet: "Fleet status and settings", toolGroup_agents: "Creating, starting and stopping agents and teams", toolGroup_usage: "Usage and logs",
|
|
25
|
+
toolGroup_schedules: "Schedules", toolGroup_tasks: "Task board and decisions", toolGroup_look: "Appearance, office and emoji",
|
|
26
|
+
toolGroup_repos: "Repositories and deployments", toolGroup_hub: "Hub rooms",
|
|
27
|
+
cliToolsLine: "The AI tool's own tools ({0}): {1}",
|
|
28
|
+
toolLayers: "Two layers: switching takes AgEnD's own tools away from this room. The AI tool's own tools (its shell, files, web) are stopped by the command-line guard, and only where the guard covers this room.",
|
|
29
|
+
showAllTools: "Show all {0} tool names",
|
|
30
|
+
impactIncomplete: "The backend's own tool list couldn't be read, so other tools may stop too.",
|
|
31
|
+
suggestBanner: "We suggest switching this room to restricted mode.",
|
|
32
|
+
switchOriginNote: "After switching, existing history is treated as unknown. New contacts, including an admin's, need approval; allowed-contact grants cannot match. Approval endorses this delivery without adding its origin to the receiving agent or clearing the source agent's retained origin.",
|
|
33
|
+
// Approvers
|
|
34
|
+
approversTitle: "Approvers", approversInherited: "Inherited from the agent's channel admins.", approversNone: "No channel approvers are selected. A verified host operator is the only permitted approver.",
|
|
35
|
+
approverRemove: "Remove {0}", approversReset: "Use the channel admins again",
|
|
36
|
+
approverAdmins: "Approver must be a Fleet admin for now.", approverPick: "Add an approver", approverAdd: "Add", approverNone: "Choose…",
|
|
37
|
+
invalidApprover: "That person can't approve. Approver must be a Fleet admin for now.",
|
|
38
|
+
// Guard
|
|
39
|
+
guardTitle: "Command-line guard", guard_ready: "Active", "guard_restart-required": "Restart needed", "guard_not-covered": "Not covered", guard_failed: "Failed",
|
|
40
|
+
guardNote: "The guard limits what the backend's own tools can do in this room. It is a policy control, not a security boundary on this computer.",
|
|
41
|
+
notCoveredWarning: "This AI tool or version isn't covered by the guard: it runs with its normal permissions; only contact approval applies.",
|
|
42
|
+
newRoomsRestricted: "New ClassicBot rooms start in restricted mode: requests from people who aren't admins to other agents wait for approval. Where the guard doesn't cover a room's AI tool or version, that tool runs with its normal permissions; only contact approval applies.",
|
|
43
|
+
guardBackend: "Backend: {0}", guardReasonOther: "The guard reported a state this page doesn't know.",
|
|
44
|
+
"guardReason_legacy-mode": "This room isn't in restricted mode, so the guard isn't used.",
|
|
45
|
+
"guardReason_unsupported-backend": "This backend isn't covered by the guard.",
|
|
46
|
+
"guardReason_unsupported-platform": "The guard isn't available on this computer's system.",
|
|
47
|
+
"guardReason_unsupported-version": "This version of the backend isn't covered by the guard.",
|
|
48
|
+
"guardReason_cli-mode": "The guard covers the backend only when it runs through AgEnD's tools, not in this mode.",
|
|
49
|
+
"guardReason_load-not-verified": "The guard hasn't been confirmed as loaded yet. Restart the agent to load it.",
|
|
50
|
+
"guardReason_stale-policy": "The room's settings changed since the agent started. Restart it to apply them.",
|
|
51
|
+
"guardReason_stale-launch": "The agent was started before the guard was set up. Restart it to apply it.",
|
|
52
|
+
"guardReason_not-running": "The agent isn't running, so the guard can't be checked.",
|
|
53
|
+
"guardReason_invalid-policy": "The guard's settings couldn't be read.",
|
|
54
|
+
"guardReason_missing-bound-mcp": "A tool the guard expects isn't available, so it isn't covered.",
|
|
55
|
+
"guardReason_missing-selected-mcp": "A selected MCP tool isn't available to the guard, so it isn't covered. Public reading and AgEnD's own tools still work.",
|
|
56
|
+
"guardReason_guard-files-changed": "The guard's files changed. Restart the agent to load them again.",
|
|
57
|
+
"guardReason_invalid-load-receipt": "The guard's load couldn't be confirmed.",
|
|
58
|
+
"guardReason_guard-unavailable": "The guard isn't available.",
|
|
59
|
+
"guardReason_binary-changed": "The backend program changed since it started. Restart the agent.",
|
|
60
|
+
// Room tools
|
|
61
|
+
toolsTitle: "Tools in this room", publicRead: "Public web search and page reading",
|
|
62
|
+
publicReadNote: "Read-only: searching the web and reading public pages. It doesn't allow running commands or reaching private networks.",
|
|
63
|
+
mcpTitle: "Extra MCP tools (exact names)", mcpNone: "No extra MCP tools.", mcpAdd: "Add", mcpAddLabel: "Exact MCP tool name",
|
|
64
|
+
mcpRemove: "Remove {0}", mcpOwnerWarning: "Uses the owner's account: its cost and identity are the owner's.", mcpPublicRead: "public read",
|
|
65
|
+
offByDefault: "Shell, files outside the room's scratch folder and the owner's credentials stay off.",
|
|
66
|
+
// Allowed contacts (grants)
|
|
67
|
+
grantsTitle: "Allowed contacts", grantsNone: "No allowed contacts. Each request asks the approver.",
|
|
68
|
+
grantsNote: "For a known origin, every originating person needs a matching allowed contact. Unknown origins cannot match these grants and need separate approval.",
|
|
69
|
+
grantRow: "{0} → {1}", grantVerbs: "For: {0}", grantExpires: "Until {0}", grantUses: "{0} uses left", grantUnlimited: "Until it expires",
|
|
70
|
+
grantRemove: "Remove", grantRemoveConfirm: "Remove this allowed contact? Later requests will ask again.",
|
|
71
|
+
originTitle: "Retained origin", originClear: "Clear retained origin", originCleared: "Retained origin cleared.",
|
|
72
|
+
originKind_none: "No retained origin", originKind_human: "One known person", originKind_mixed: "Multiple known people", originKind_unknown: "Unknown origin",
|
|
73
|
+
originPeople: "Originating people", originPeopleNone: "No known person.", originChain: "Agent hops", originChainNone: "No retained hops",
|
|
74
|
+
originReceipts: "{0} retained receipts", originLastCleared: "Last cleared by {0} at {1}",
|
|
75
|
+
originRetainedNote: "Origins stay with this agent, including work inherited from other agents. Only a managing administrator can explicitly clear them; idle, compaction and later admin messages do not.",
|
|
76
|
+
originClearConfirm: "Clear this agent's retained origin? You accept its current conversation as your own work. Earlier text is not erased. New non-admin requests will require approval again. Other agents, existing tickets and grants are unchanged.",
|
|
77
|
+
// History
|
|
78
|
+
historyTitle: "History", historyNone: "Nothing yet.",
|
|
79
|
+
"action_origin-clear": "Retained origin cleared",
|
|
80
|
+
action_policy: "Settings changed", action_approve: "Approved", action_decline: "Declined", "action_grant-add": "Contact allowed", "action_grant-remove": "Contact removed",
|
|
81
|
+
// Tickets
|
|
82
|
+
ticket: "Contact request #{0}", forwarded: "Forwarded (approved)",
|
|
83
|
+
state_pending: "Waiting for approval", state_approved: "Approved", state_delivered: "Forwarded", state_declined: "Declined", state_expired: "Expired", state_unknown: "Unknown",
|
|
84
|
+
verb_send_to_instance: "message", verb_delegate_task: "task", verb_request_information: "question", verb_broadcast: "broadcast", verb_report_result: "report",
|
|
85
|
+
from: "From {0}", via: "Via {0}", to: "To {0}", origin_unknown: "Origin unknown", origin_mixed: "Earlier non-admin request",
|
|
86
|
+
"reason_earlier-non-admin": "This agent's retained history includes non-admin input, so this contact needs approval.",
|
|
87
|
+
"reason_unknown-origin": "This agent's retained history has an unknown origin, so this contact needs approval.",
|
|
88
|
+
resetNote: "Approval or a matching administrator-written grant forwards this request with the administrator's endorsement. The receiving agent's origin is unchanged; the source agent keeps its own origin. A managing administrator can explicitly clear an agent's origin in Permissions. Automatic reset is not supported.",
|
|
89
|
+
created: "Asked {0}", expires: "Expires {0}", decided: "{0} by {1}",
|
|
90
|
+
approveOnce: "Approve once", decline: "Decline", alsoAllow: "Also allow this contact", alsoAllowUntil: "Until", alsoAllowUses: "Uses (empty: no limit)",
|
|
91
|
+
decidedNote: "Approving endorses and forwards this request once without adding its origin to the receiving agent. It doesn't approve the other agent's later actions.",
|
|
92
|
+
deliveryNote: "Forwarded means the request was delivered, not that the work is done.",
|
|
93
|
+
// Fleet → Authorizations
|
|
94
|
+
pageTitle: "Authorizations", pageLead: "Requests from ClassicBot rooms to other agents that wait for an approver.",
|
|
95
|
+
filterStatus: "Show", filter_pending: "Waiting", filter_all: "All", filterAgent: "Agent", filterAny: "Any",
|
|
96
|
+
filterPerson: "Only {0}", filterPersonClear: "Show everyone",
|
|
97
|
+
empty: "No requests.", emptyPending: "Nothing is waiting for approval.", more: "Show more",
|
|
98
|
+
decideFailed: "Couldn't record the decision.", alreadyDecided: "This request was decided elsewhere. It has been reloaded.",
|
|
99
|
+
// Needs you / suggestion
|
|
100
|
+
needsTitle: "{0} wants to contact {1}", needsOpen: "Open",
|
|
101
|
+
suggestTitle: "We suggest switching this room to restricted mode",
|
|
102
|
+
suggestGroup: "{0} existing ClassicBot room(s) can switch to restricted mode",
|
|
103
|
+
suggestBody: "Requests from people who aren't admins to other agents would wait for approval first.",
|
|
104
|
+
suggestSwitch: "Switch this room", suggestView: "See the impact and allowed contacts", suggestLater: "Later",
|
|
105
|
+
},
|
|
106
|
+
"zh-TW": {
|
|
107
|
+
tab: "權限", lead: "誰可以請這個 Agent 把請求轉交給其他 Agent,以及這個房間可以使用什麼。",
|
|
108
|
+
loading: "正在載入權限…", loadFailed: "無法載入權限。", retry: "重試",
|
|
109
|
+
forbidden: "只有這個 Agent 的管理員可以查看權限。", unavailable: "目前無法取得權限,請稍後再試。",
|
|
110
|
+
stale: "剛才有人修改了這些權限,已重新載入,請確認後再試一次。",
|
|
111
|
+
saved: "已儲存。", saveFailed: "無法儲存。", readOnly: "你可以查看這些權限,但無法修改。",
|
|
112
|
+
modeTitle: "房間模式", modeRestricted: "受限模式", modeLegacy: "未受限(舊設定)",
|
|
113
|
+
modeRestrictedNote: "非管理員對其他 Agent 的請求,要先經過核准才會送出。",
|
|
114
|
+
modeLegacyNote: "這個房間的請求會直接送給其他 Agent,不需核准。",
|
|
115
|
+
switchRestricted: "切換為受限模式", switchLegacy: "關閉受限模式",
|
|
116
|
+
confirmRestricted: "要將這個房間切換為受限模式嗎?", confirmLegacy: "要關閉受限模式嗎?這個房間的請求將直接送給其他 Agent,不需核准。已交給其他 Agent 的工作不會因此改變。",
|
|
117
|
+
wouldDisableTitle: "這個房間將停用下列工具:", wouldDisableNone: "這個房間目前使用的工具都不會停用。",
|
|
118
|
+
toolsLostTitle: "這個房間會失去的 AgEnD 工具({0} 個):", toolGroupLine: "• {0}({1})",
|
|
119
|
+
toolGroup_fleet: "Fleet 狀態與設定", toolGroup_agents: "建立、啟動與停止 Agent 和團隊", toolGroup_usage: "用量與紀錄",
|
|
120
|
+
toolGroup_schedules: "排程", toolGroup_tasks: "任務板與決策", toolGroup_look: "外觀、辦公室與表情",
|
|
121
|
+
toolGroup_repos: "程式庫與部署", toolGroup_hub: "Hub 房間",
|
|
122
|
+
cliToolsLine: "AI 工具本身的工具({0} 個):{1}",
|
|
123
|
+
toolLayers: "分成兩層:切換後,這個房間會失去 AgEnD 自己的工具;AI 工具本身的工具(命令列、檔案、網路)則由命令列防護停用,而且只有在防護涵蓋這個房間時才會停用。",
|
|
124
|
+
showAllTools: "顯示全部 {0} 個工具名稱",
|
|
125
|
+
impactIncomplete: "無法讀取後端本身的工具清單,因此可能還有其他工具會停用。",
|
|
126
|
+
suggestBanner: "建議將這個房間切換為受限模式。",
|
|
127
|
+
switchOriginNote: "切換後,既有歷史會視為來源不明。包含管理員在內的新聯絡都須逐筆核准,允許的聯絡授權無法配對;核准是對這次轉交背書,不會將來源加到接收的 Agent,也不會清除發送 Agent 自己保留的來源。",
|
|
128
|
+
approversTitle: "核准人", approversInherited: "沿用這個 Agent 所在頻道的管理員。", approversNone: "尚未選定頻道核准人,僅允許已驗證的主機操作者核准。",
|
|
129
|
+
approverRemove: "移除 {0}", approversReset: "改回沿用頻道管理員",
|
|
130
|
+
approverAdmins: "目前核准人必須是 Fleet 管理員。", approverPick: "新增核准人", approverAdd: "新增", approverNone: "選擇…",
|
|
131
|
+
invalidApprover: "這個人無法擔任核准人。目前核准人必須是 Fleet 管理員。",
|
|
132
|
+
guardTitle: "命令列防護", guard_ready: "已啟用", "guard_restart-required": "需要重新啟動", "guard_not-covered": "未涵蓋", guard_failed: "失敗",
|
|
133
|
+
guardNote: "防護會限制後端內建工具在這個房間能做的事。這是政策控制,不是這台電腦上的安全邊界。",
|
|
134
|
+
notCoveredWarning: "這個 AI 工具或版本不在防護範圍內:它會以原本的權限執行,只有聯絡申請需要核准。",
|
|
135
|
+
newRoomsRestricted: "新的 ClassicBot 房間預設為受限模式:非管理員對其他 Agent 的請求要先經過核准。若防護不涵蓋房間的 AI 工具或版本,該工具會以原本的權限執行,只有聯絡申請需要核准。",
|
|
136
|
+
guardBackend: "後端:{0}", guardReasonOther: "防護回報了這個頁面不認得的狀態。",
|
|
137
|
+
"guardReason_legacy-mode": "這個房間不是受限模式,因此不使用防護。",
|
|
138
|
+
"guardReason_unsupported-backend": "防護不支援這個後端。",
|
|
139
|
+
"guardReason_unsupported-platform": "這台電腦的系統無法使用防護。",
|
|
140
|
+
"guardReason_unsupported-version": "防護不支援這個版本的後端。",
|
|
141
|
+
"guardReason_cli-mode": "防護只在後端透過 AgEnD 工具執行時有效,這個模式不在範圍內。",
|
|
142
|
+
"guardReason_load-not-verified": "尚未確認防護已載入,請重新啟動 Agent 以載入。",
|
|
143
|
+
"guardReason_stale-policy": "Agent 啟動後房間設定有變更,請重新啟動以套用。",
|
|
144
|
+
"guardReason_stale-launch": "Agent 在防護設定前就已啟動,請重新啟動以套用。",
|
|
145
|
+
"guardReason_not-running": "Agent 沒有在執行,無法檢查防護。",
|
|
146
|
+
"guardReason_invalid-policy": "無法讀取防護設定。",
|
|
147
|
+
"guardReason_missing-bound-mcp": "防護需要的工具不在,因此不在涵蓋範圍內。",
|
|
148
|
+
"guardReason_missing-selected-mcp": "選用的 MCP 工具防護無法取得,因此不在涵蓋範圍內;公開讀取與 AgEnD 本身的工具仍可使用。",
|
|
149
|
+
"guardReason_guard-files-changed": "防護的檔案有變更,請重新啟動 Agent 以重新載入。",
|
|
150
|
+
"guardReason_invalid-load-receipt": "無法確認防護的載入狀態。",
|
|
151
|
+
"guardReason_guard-unavailable": "防護目前無法使用。",
|
|
152
|
+
"guardReason_binary-changed": "後端程式在啟動後有變更,請重新啟動 Agent。",
|
|
153
|
+
toolsTitle: "這個房間的工具", publicRead: "公開網頁搜尋與讀取",
|
|
154
|
+
publicReadNote: "唯讀:搜尋網頁、讀取公開頁面。不包含執行指令,也無法連到私人網路。",
|
|
155
|
+
mcpTitle: "額外的 MCP 工具(完整名稱)", mcpNone: "沒有額外的 MCP 工具。", mcpAdd: "新增", mcpAddLabel: "MCP 工具的完整名稱",
|
|
156
|
+
mcpRemove: "移除 {0}", mcpOwnerWarning: "使用擁有者的帳號:費用與身分都算在擁有者名下。", mcpPublicRead: "公開讀取",
|
|
157
|
+
offByDefault: "Shell、房間暫存資料夾以外的檔案與擁有者的憑證都維持關閉。",
|
|
158
|
+
grantsTitle: "常用轉交", grantsNone: "沒有常用轉交,每個請求都會詢問核准人。",
|
|
159
|
+
grantsNote: "來源已知時,每位最初提問者都須有相符的允許聯絡授權。來源不明無法配對這些授權,須另外核准。",
|
|
160
|
+
grantRow: "{0} → {1}", grantVerbs: "用途:{0}", grantExpires: "到 {0} 為止", grantUses: "剩下 {0} 次", grantUnlimited: "到期前不限次數",
|
|
161
|
+
grantRemove: "移除", grantRemoveConfirm: "要移除這個常用轉交嗎?之後的請求會再次詢問。",
|
|
162
|
+
originTitle: "保留的來源", originClear: "清除保留的來源", originCleared: "已清除保留的來源。",
|
|
163
|
+
originKind_none: "沒有保留的來源", originKind_human: "一位已知提問者", originKind_mixed: "多位已知提問者", originKind_unknown: "來源不明",
|
|
164
|
+
originPeople: "最初提問者", originPeopleNone: "沒有已知提問者。", originChain: "Agent 轉交路徑", originChainNone: "沒有保留的轉交路徑",
|
|
165
|
+
originReceipts: "保留 {0} 筆來源紀錄", originLastCleared: "最後由 {0} 於 {1} 清除",
|
|
166
|
+
originRetainedNote: "來源會跟著這個 Agent 保留,包含從其他 Agent 接手的工作。只有具管理權限的管理員能明確清除;閒置、壓縮對話或後來的管理員訊息都不會清除。",
|
|
167
|
+
originClearConfirm: "清除此 Agent 保留的來源?這表示你接受目前對話作為自己的工作,先前文字不會刪除。新的非管理員請求仍會再次需要核准。其他 Agent、既有申請與授權都不變。",
|
|
168
|
+
"action_origin-clear": "已清除保留的來源",
|
|
169
|
+
historyTitle: "紀錄", historyNone: "目前沒有紀錄。",
|
|
170
|
+
action_policy: "設定已變更", action_approve: "已核准", action_decline: "已拒絕", "action_grant-add": "已加入常用轉交", "action_grant-remove": "已移除常用轉交",
|
|
171
|
+
ticket: "聯絡申請 #{0}", forwarded: "已准轉交",
|
|
172
|
+
state_pending: "等待核准", state_approved: "已核准", state_delivered: "已准轉交", state_declined: "已拒絕", state_expired: "已過期", state_unknown: "狀態不明",
|
|
173
|
+
verb_send_to_instance: "訊息", verb_delegate_task: "交辦工作", verb_request_information: "詢問", verb_broadcast: "廣播", verb_report_result: "回報結果",
|
|
174
|
+
from: "來自 {0}", via: "經由 {0}", to: "給 {0}", origin_unknown: "來源不明", origin_mixed: "先前有非管理員的請求",
|
|
175
|
+
"reason_earlier-non-admin": "這個 Agent 保留的歷史含有非管理員輸入,因此這次聯絡需要核准。",
|
|
176
|
+
"reason_unknown-origin": "這個 Agent 保留的歷史來源不明,因此這次聯絡需要核准。",
|
|
177
|
+
resetNote: "核准或符合管理員設定的常用轉交,表示管理員對這次轉交背書。接收 Agent 的來源維持原狀,發送 Agent 仍保留自己的來源。具管理權限的管理員可在「權限」明確清除 Agent 的來源,不支援自動重設。",
|
|
178
|
+
created: "{0} 提出", expires: "{0} 到期", decided: "{1} 於 {0} 處理",
|
|
179
|
+
approveOnce: "核准這一次", decline: "拒絕", alsoAllow: "同時加入常用轉交", alsoAllowUntil: "到期時間", alsoAllowUses: "次數(留空表示不限)",
|
|
180
|
+
decidedNote: "核准表示管理員同意轉交這筆請求一次,接收的 Agent 不會繼承其來源;這不代表核准對方之後的處理。",
|
|
181
|
+
deliveryNote: "「已准轉交」表示請求已送達,不代表工作已完成。",
|
|
182
|
+
pageTitle: "授權", pageLead: "ClassicBot 房間對其他 Agent 提出、正在等待核准人的請求。",
|
|
183
|
+
filterStatus: "顯示", filter_pending: "等待中", filter_all: "全部", filterAgent: "Agent", filterAny: "任何",
|
|
184
|
+
filterPerson: "只看 {0}", filterPersonClear: "顯示所有人",
|
|
185
|
+
empty: "沒有請求。", emptyPending: "沒有等待核准的請求。", more: "顯示更多",
|
|
186
|
+
decideFailed: "無法記錄這個決定。", alreadyDecided: "這個請求已在其他地方處理,已重新載入。",
|
|
187
|
+
needsTitle: "{0} 想聯絡 {1}", needsOpen: "開啟",
|
|
188
|
+
suggestTitle: "建議將這個房間切換為受限模式",
|
|
189
|
+
suggestGroup: "{0} 個既有 ClassicBot 房間可以切換為受限模式",
|
|
190
|
+
suggestBody: "非管理員對其他 Agent 的請求,將先經過核准才會送出。",
|
|
191
|
+
suggestSwitch: "切換這個房間", suggestView: "查看影響與常用轉交", suggestLater: "稍後",
|
|
192
|
+
},
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
export const ca = (k, ...a) => t(`contactAuth.${k}`, ...a);
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// M-3339 (A2): Fleet → Authorizations — requests from ClassicBot rooms to other agents, held for an approver (the contact
|
|
2
|
+
// authorization contract: src/contact-auth-types.ts; docs/design/classic-contact-authorizations.md). The server scopes
|
|
3
|
+
// the list (approvers and the source room's admins only; at most 50 a page, then a cursor) and decides who may decide.
|
|
4
|
+
// - Show: waiting (default) or all; one agent; one person (an exact identity, picked from a request — never a name search).
|
|
5
|
+
// - A request: who asked (the origin, through which agents), from which room to which agent, the verb and its message,
|
|
6
|
+
// when it expires; Approve once / Decline when the reader may decide, with "also allow this contact" as a separate,
|
|
7
|
+
// explicit choice. Approving forwards this one request once; "Forwarded" means delivered, not that the work is done.
|
|
8
|
+
// - ?ticket=<id> opens that request at the top (from a chat badge, Needs you or a Permissions history row).
|
|
9
|
+
// It reads again on the stream's contact-auth frame and when the page is shown again (no timer).
|
|
10
|
+
import { html, useEffect, useState } from "/assets/app-html.js";
|
|
11
|
+
import { register } from "/assets/app-i18n.js";
|
|
12
|
+
import { appStore, useStore } from "/assets/app-store.js";
|
|
13
|
+
import { toast } from "/assets/ui-toast.js";
|
|
14
|
+
import { Skeleton, ErrorState, Empty } from "/assets/ui-states.js";
|
|
15
|
+
import { ca } from "./contact-auth-strings.js";
|
|
16
|
+
import { decideTicket, getTicket, listTickets, personKey, shortTicketId } from "./contact-auth-client.js";
|
|
17
|
+
|
|
18
|
+
// The Fleet tab's own label (panel-fleet.js reads fleet.<tab>).
|
|
19
|
+
register("fleet", { en: { authorizations: "Authorizations" }, "zh-TW": { authorizations: "授權" } });
|
|
20
|
+
|
|
21
|
+
const when = (iso) => { const d = new Date(iso); return Number.isFinite(d.getTime()) ? d.toLocaleString([], { dateStyle: "medium", timeStyle: "short" }) : ""; };
|
|
22
|
+
/** The server's reason codes (ContactTicket.reason, ContactPermissions.originRestriction.reason). */
|
|
23
|
+
export const REASONS = new Set(["earlier-non-admin", "unknown-origin"]);
|
|
24
|
+
const TONE = { pending: "warn", approved: "ok", delivered: "ok", declined: "bad", expired: "muted", unknown: "bad" };
|
|
25
|
+
const stateOf = (s) => (Object.prototype.hasOwnProperty.call(TONE, s) ? s : "unknown");
|
|
26
|
+
const label = (p) => (p && (p.label || p.userId)) || "";
|
|
27
|
+
/** datetime-local's value for a time `days` from now (the browser's own zone). */
|
|
28
|
+
const localIn = (days) => { const d = new Date(Date.now() + days * 864e5); d.setSeconds(0, 0); return new Date(d.getTime() - d.getTimezoneOffset() * 6e4).toISOString().slice(0, 16); };
|
|
29
|
+
|
|
30
|
+
/** One request: what it is, who asked, and — for its approver, while it waits — the decision. */
|
|
31
|
+
export function TicketCard({ ticket, onChange, onPerson, focus = false }) {
|
|
32
|
+
const [busy, setBusy] = useState(false);
|
|
33
|
+
const [allow, setAllow] = useState(false);
|
|
34
|
+
const [until, setUntil] = useState(() => localIn(7));
|
|
35
|
+
const [uses, setUses] = useState("");
|
|
36
|
+
const tk = ticket, st = stateOf(tk.state);
|
|
37
|
+
const decide = async (decision) => {
|
|
38
|
+
if (busy) return;
|
|
39
|
+
const n = uses.trim() === "" ? null : Math.max(1, Math.floor(Number(uses)));
|
|
40
|
+
const grant = decision === "approve-once" && allow && until ? { expiresAt: new Date(until).toISOString(), remainingUses: Number.isFinite(n) ? n : null } : undefined;
|
|
41
|
+
setBusy(true);
|
|
42
|
+
const r = await decideTicket(tk.id, { revision: tk.revision, decision, ...(grant ? { grant } : {}) });
|
|
43
|
+
setBusy(false);
|
|
44
|
+
if (r.ok) { onChange?.(r.data); return; }
|
|
45
|
+
if (r.code === "already-decided" || r.code === "expired" || r.code === "conflict") {
|
|
46
|
+
toast(ca("alreadyDecided"), false);
|
|
47
|
+
const again = await getTicket(tk.id);
|
|
48
|
+
if (again.ok) onChange?.(again.data);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
toast(ca(r.code === "forbidden" ? "forbidden" : r.code === "unavailable" ? "unavailable" : "decideFailed"), false);
|
|
52
|
+
};
|
|
53
|
+
const people = tk.origin?.people || [];
|
|
54
|
+
const originText = tk.origin?.kind === "unknown" ? ca("origin_unknown") : tk.origin?.kind === "mixed" ? ca("origin_mixed") : "";
|
|
55
|
+
return html`<article class=${`card contact-ticket${focus ? " focus" : ""}`} data-ticket=${tk.id} data-state=${st}>
|
|
56
|
+
<div class="contact-ticket-head"><strong title=${tk.id}>${ca("ticket", shortTicketId(tk.id))}</strong><span class=${`contact-pill ${TONE[st]}`}>${ca(`state_${st}`)}</span>
|
|
57
|
+
<span class="muted">${ca(`verb_${tk.verb}`)}</span></div>
|
|
58
|
+
<p class="contact-ticket-route">${ca("from", tk.source)} → ${ca("to", tk.target)}</p>
|
|
59
|
+
<p class="contact-ticket-origin">${people.map((p, i) => html`${i ? ", " : ""}<button type="button" class="link-btn" title=${ca("filterPerson", label(p))}
|
|
60
|
+
onClick=${() => onPerson?.(p)}>${label(p)}</button>`)}${originText ? html` <span class="contact-pill warn">${originText}</span>` : null}
|
|
61
|
+
${tk.origin?.chain?.length ? html` <span class="muted">${ca("via", tk.origin.chain.join(" → "))}</span>` : null}</p>
|
|
62
|
+
${tk.message ? html`<pre class="contact-ticket-message">${tk.message}</pre>` : null}
|
|
63
|
+
<p class="muted contact-ticket-times">${ca("created", when(tk.createdAt))} · ${tk.decidedAt ? ca("decided", when(tk.decidedAt), label(tk.decidedBy)) : ca("expires", when(tk.expiresAt))}</p>
|
|
64
|
+
${st === "delivered" ? html`<p class="note">${ca("deliveryNote")}</p>` : null}
|
|
65
|
+
${/* The server's reason code, in words (Sentinel's A1 copy); a code the page doesn't know says nothing rather than a guess. */ ""}
|
|
66
|
+
${REASONS.has(tk.reason) ? html`<p class="note contact-reason" data-reason=${tk.reason}>${ca(`reason_${tk.reason}`)}${st === "pending" ? html` ${ca("resetNote")}` : null}</p>` : null}
|
|
67
|
+
${tk.canDecide && st === "pending" ? html`<div class="contact-decide">
|
|
68
|
+
<p class="note">${ca("decidedNote")}</p>
|
|
69
|
+
<label class="check contact-toggle"><input type="checkbox" checked=${allow} disabled=${busy} onChange=${(e) => setAllow(e.currentTarget.checked)} /><span>${ca("alsoAllow")}</span></label>
|
|
70
|
+
${allow ? html`<div class="field-row contact-allow">
|
|
71
|
+
<label class="field"><span>${ca("alsoAllowUntil")}</span><input class="input" type="datetime-local" value=${until} disabled=${busy} onInput=${(e) => setUntil(e.currentTarget.value)} /></label>
|
|
72
|
+
<label class="field"><span>${ca("alsoAllowUses")}</span><input class="input" type="number" min="1" inputmode="numeric" value=${uses} disabled=${busy} onInput=${(e) => setUses(e.currentTarget.value)} /></label></div>` : null}
|
|
73
|
+
<div class="field-row"><button type="button" class="btn btn-sm btn-primary" disabled=${busy} onClick=${() => void decide("approve-once")}>${ca("approveOnce")}</button>
|
|
74
|
+
<button type="button" class="btn btn-sm" disabled=${busy} onClick=${() => void decide("decline")}>${ca("decline")}</button></div>
|
|
75
|
+
</div>` : null}
|
|
76
|
+
</article>`;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const ticketFromSearch = () => { try { const v = new URLSearchParams(location.search).get("ticket"); return v && /^[A-Za-z0-9_-]{1,64}$/.test(v) ? v : null; } catch { return null; } };
|
|
80
|
+
|
|
81
|
+
export function ContactAuthorizations() {
|
|
82
|
+
const { instances } = useStore(appStore);
|
|
83
|
+
const [status, setStatus] = useState("pending");
|
|
84
|
+
const [agent, setAgent] = useState("");
|
|
85
|
+
const [person, setPerson] = useState(null);
|
|
86
|
+
const [page, setPage] = useState({ loading: true, items: [], next: null });
|
|
87
|
+
const [focus, setFocus] = useState(null);
|
|
88
|
+
const focusId = ticketFromSearch();
|
|
89
|
+
const filters = { ...(status === "pending" ? { status: "pending" } : {}), ...(agent ? { agent } : {}), ...(person ? { person: personKey(person) } : {}) };
|
|
90
|
+
const read = async (cursor) => {
|
|
91
|
+
const r = await listTickets({ ...filters, ...(cursor ? { cursor } : {}) });
|
|
92
|
+
if (!r.ok) { setPage((p) => ({ ...p, loading: false, error: r.code })); return; }
|
|
93
|
+
setPage((p) => ({ loading: false, items: cursor ? [...p.items, ...r.data.items] : r.data.items, next: r.data.nextCursor }));
|
|
94
|
+
};
|
|
95
|
+
const readFocus = async () => { if (!focusId) return; const r = await getTicket(focusId); setFocus(r.ok ? r.data : null); };
|
|
96
|
+
const key = JSON.stringify(filters);
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
setPage({ loading: true, items: [], next: null });
|
|
99
|
+
void read(); void readFocus();
|
|
100
|
+
const sub = appStore.get().streamOn;
|
|
101
|
+
const off = typeof sub === "function" ? sub("contact-auth", () => { void read(); void readFocus(); }) : null;
|
|
102
|
+
const onShow = () => { if (document.visibilityState === "visible") { void read(); void readFocus(); } };
|
|
103
|
+
document.addEventListener("visibilitychange", onShow);
|
|
104
|
+
return () => { if (typeof off === "function") off(); document.removeEventListener("visibilitychange", onShow); };
|
|
105
|
+
}, [key, focusId]);
|
|
106
|
+
const replace = (tk) => { setPage((p) => ({ ...p, items: p.items.map((x) => (x.id === tk.id ? tk : x)) })); if (focus && focus.id === tk.id) setFocus(tk); };
|
|
107
|
+
const names = (instances || []).map((i) => i.name).filter(Boolean).sort();
|
|
108
|
+
const list = page.items.filter((x) => !focus || x.id !== focus.id);
|
|
109
|
+
return html`<div class="contact-auth-page">
|
|
110
|
+
<p class="note">${ca("pageLead")}</p>
|
|
111
|
+
<div class="field-row contact-filters">
|
|
112
|
+
<div class="seg" role="group" aria-label=${ca("filterStatus")}>${["pending", "all"].map((s) => html`<button key=${s} type="button" class=${`seg-item${status === s ? " active" : ""}`}
|
|
113
|
+
aria-pressed=${status === s ? "true" : "false"} onClick=${() => setStatus(s)}>${ca(`filter_${s}`)}</button>`)}</div>
|
|
114
|
+
<label class="field contact-agent-filter"><span>${ca("filterAgent")}</span><select class="input" value=${agent} onChange=${(e) => setAgent(e.currentTarget.value)}>
|
|
115
|
+
<option value="">${ca("filterAny")}</option>${names.map((n) => html`<option key=${n} value=${n}>${n}</option>`)}</select></label>
|
|
116
|
+
${person ? html`<button type="button" class="btn btn-sm btn-ghost contact-person-filter" onClick=${() => setPerson(null)}>${ca("filterPerson", label(person))} · ${ca("filterPersonClear")}</button>` : null}
|
|
117
|
+
</div>
|
|
118
|
+
${focus ? html`<${TicketCard} ticket=${focus} focus=${true} onChange=${replace} onPerson=${setPerson} />` : null}
|
|
119
|
+
${page.loading ? html`<${Skeleton} lines=${4} label=${ca("loading")} />`
|
|
120
|
+
: page.error && !page.items.length ? (page.error === "forbidden" ? html`<p class="note">${ca("forbidden")}</p>` : html`<${ErrorState} message=${ca(page.error === "unavailable" ? "unavailable" : "loadFailed")} onRetry=${() => void read()} />`)
|
|
121
|
+
: !list.length && !focus ? html`<${Empty} icon="key" title=${ca(status === "pending" ? "emptyPending" : "empty")} />`
|
|
122
|
+
: html`<div class="contact-ticket-list">${list.map((tk) => html`<${TicketCard} key=${tk.id} ticket=${tk} onChange=${replace} onPerson=${setPerson} />`)}</div>`}
|
|
123
|
+
${page.next ? html`<div class="field-row"><button type="button" class="btn btn-sm" onClick=${() => void read(page.next)}>${ca("more")}</button></div>` : null}
|
|
124
|
+
</div>`;
|
|
125
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// M-3339 (A2): Needs you's contact items (panel-needs.js hands item.type "contact" here). The server's needs list carries
|
|
2
|
+
// only references, scoped to the signed-in viewer (Sentinel's seam):
|
|
3
|
+
// - reason "contact_request", contactTicket { id, source, target }: the title names source and target; the request itself
|
|
4
|
+
// (who asked, the message, whether this reader may decide) is read from the scoped ticket route — never shown from the
|
|
5
|
+
// list. Approve once / Decline there (TicketCard); Open goes to Fleet → Authorizations.
|
|
6
|
+
// - reason "contact_restricted_suggestion", contactSuggestion { instance }: 切換這個房間 reads the room's permissions (its
|
|
7
|
+
// revision, and what would stop), confirms, then PUTs mode restricted; 查看影響與常用轉交 opens its Permissions;
|
|
8
|
+
// 稍後 acknowledges the reminder (POST /ui/needs/ack — the server's durable dismissal; the mode never changes).
|
|
9
|
+
// The item leaves the list when the server's next `needs` drops it.
|
|
10
|
+
import { html, useEffect, useState } from "/assets/app-html.js";
|
|
11
|
+
import { detailsPath } from "/assets/app-route.js";
|
|
12
|
+
import { Icon } from "/assets/ui-icons.js";
|
|
13
|
+
import { toast } from "/assets/ui-toast.js";
|
|
14
|
+
import { confirmDialog } from "/assets/ui-confirm.js";
|
|
15
|
+
import { ca } from "./contact-auth-strings.js";
|
|
16
|
+
import { getPermissions, getTicket, putPermissions } from "./contact-auth-client.js";
|
|
17
|
+
import { TicketCard } from "./contact-authorizations.js";
|
|
18
|
+
import { notCovered, wouldDisableMore, wouldDisableText } from "./contact-permissions.js";
|
|
19
|
+
|
|
20
|
+
const ID = /^[A-Za-z0-9_-]{1,64}$/;
|
|
21
|
+
|
|
22
|
+
function RequestNeed({ item }) {
|
|
23
|
+
const ref = item.contactTicket || {};
|
|
24
|
+
const [tk, setTk] = useState(null);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
let live = true;
|
|
27
|
+
if (ID.test(String(ref.id || ""))) void getTicket(ref.id).then((r) => { if (live && r.ok) setTk(r.data); });
|
|
28
|
+
return () => { live = false; };
|
|
29
|
+
}, [ref.id]);
|
|
30
|
+
return html`<div class="n-title"><strong>${ca("needsTitle", ref.source || "", ref.target || "")}</strong></div>
|
|
31
|
+
${tk ? html`<${TicketCard} ticket=${tk} onChange=${setTk} />` : null}
|
|
32
|
+
<div class="n-actions">${ID.test(String(ref.id || "")) ? html`<a class="btn btn-sm btn-ghost" href=${`/ui/fleet/authorizations?ticket=${encodeURIComponent(ref.id)}`}>${ca("needsOpen")}</a>` : null}</div>`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function SuggestionNeed({ item }) {
|
|
36
|
+
const name = item.contactSuggestion?.instance || item.instance;
|
|
37
|
+
const [busy, setBusy] = useState(false);
|
|
38
|
+
// The room's guard coverage, read (scoped) before the switch: not covered → said here, before the mode is set.
|
|
39
|
+
const [guard, setGuard] = useState(null);
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
let live = true;
|
|
42
|
+
if (name) void getPermissions(name).then((r) => { if (live && r.ok) setGuard(r.data.nativeGuard || null); });
|
|
43
|
+
return () => { live = false; };
|
|
44
|
+
}, [name]);
|
|
45
|
+
const switchRoom = async () => {
|
|
46
|
+
if (busy || !name) return;
|
|
47
|
+
setBusy(true);
|
|
48
|
+
try {
|
|
49
|
+
const r = await getPermissions(name);
|
|
50
|
+
if (!r.ok) { toast(ca(r.code === "forbidden" ? "forbidden" : r.code === "unavailable" ? "unavailable" : "loadFailed"), false); return; }
|
|
51
|
+
const p = r.data;
|
|
52
|
+
if (p.canSetMode !== true) { toast(ca("forbidden"), false); return; }
|
|
53
|
+
const ok = await confirmDialog({ title: ca("confirmRestricted"), confirmLabel: ca("suggestSwitch"), message: [ca("modeRestrictedNote"), ca("switchOriginNote"), wouldDisableText(p.roomTools, p.nativeGuard)].join("\n\n"), more: wouldDisableMore(p.roomTools) });
|
|
54
|
+
if (!ok) return;
|
|
55
|
+
const w = await putPermissions(name, { revision: p.revision, mode: "restricted" });
|
|
56
|
+
toast(ca(w.ok ? "saved" : w.code === "conflict" ? "stale" : w.code === "forbidden" ? "forbidden" : "saveFailed"), w.ok);
|
|
57
|
+
} finally { setBusy(false); }
|
|
58
|
+
};
|
|
59
|
+
const later = async () => {
|
|
60
|
+
if (busy) return;
|
|
61
|
+
setBusy(true);
|
|
62
|
+
let ok = false;
|
|
63
|
+
try { const r = await fetch("/ui/needs/ack", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ id: item.id }) }); ok = r.ok; } catch { ok = false; }
|
|
64
|
+
setBusy(false);
|
|
65
|
+
if (!ok) toast(ca("saveFailed"), false);
|
|
66
|
+
};
|
|
67
|
+
return html`<div class="n-title"><strong>${ca("suggestTitle")}</strong></div>
|
|
68
|
+
<p class="n-detail">${name}: ${ca("suggestBody")}</p>
|
|
69
|
+
<p class="feedback warning contact-origin-switch">${ca("switchOriginNote")}</p>
|
|
70
|
+
${notCovered(guard) ? html`<p class="feedback warning contact-not-covered">${ca("notCoveredWarning")}</p>` : null}
|
|
71
|
+
<div class="n-actions">
|
|
72
|
+
<button type="button" class="btn btn-sm btn-primary" disabled=${busy} onClick=${() => void switchRoom()}>${ca("suggestSwitch")}</button>
|
|
73
|
+
<a class="btn btn-sm" href=${`${detailsPath(name)}?cat=permissions`}>${ca("suggestView")}</a>
|
|
74
|
+
<button type="button" class="btn btn-sm btn-ghost" disabled=${busy} onClick=${() => void later()}>${ca("suggestLater")}</button>
|
|
75
|
+
</div>`;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** M-3381: a Needs you item that is a room's restricted-mode suggestion. */
|
|
79
|
+
export const isRestrictedSuggestion = (item) => item?.type === "contact" && item.reason === "contact_restricted_suggestion";
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* M-3381 (the user, beta.14: one row per existing room flooded the list): every room's restricted-mode suggestion in ONE
|
|
83
|
+
* low-key group, closed until opened — "N existing ClassicBot rooms can switch to restricted mode" — each room's card
|
|
84
|
+
* (switch / preview / later) inside it.
|
|
85
|
+
*/
|
|
86
|
+
export function ContactSuggestionsGroup({ items }) {
|
|
87
|
+
if (!items?.length) return null;
|
|
88
|
+
return html`<details class="n-group n-suggestions" data-trust="permission">
|
|
89
|
+
<summary class="n-group-head">${ca("suggestGroup", items.length)}</summary>
|
|
90
|
+
${items.map((item) => html`<${ContactNeedsItem} key=${item.id} item=${item} />`)}
|
|
91
|
+
</details>`;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** One contact item of Needs you (item.type "contact"); null for a reason this page doesn't know. */
|
|
95
|
+
export function ContactNeedsItem({ item }) {
|
|
96
|
+
const body = item.reason === "contact_request" ? html`<${RequestNeed} item=${item} />` : item.reason === "contact_restricted_suggestion" ? html`<${SuggestionNeed} item=${item} />` : null;
|
|
97
|
+
if (!body) return null;
|
|
98
|
+
return html`<article data-trust="permission" class="n-item contact-need" data-reason=${item.reason}>
|
|
99
|
+
<span class="n-icon"><${Icon} name="key" size=${18} /></span><div class="n-body">${body}</div></article>`;
|
|
100
|
+
}
|