@songsid/agend 2.4.0-beta.7 → 2.4.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth-api.js +4 -0
- package/dist/auth-api.js.map +1 -1
- package/dist/backend/antigravity.d.ts +9 -2
- package/dist/backend/antigravity.js +24 -6
- package/dist/backend/antigravity.js.map +1 -1
- package/dist/backend/cli-env-probe.js +1 -1
- package/dist/backend/cli-env-probe.js.map +1 -1
- package/dist/backend/cli-runtime-switch.js +1 -26
- package/dist/backend/cli-runtime-switch.js.map +1 -1
- package/dist/build-provenance.json +1 -1
- package/dist/connect/mcp.d.ts +9 -0
- package/dist/connect/mcp.js +10 -0
- package/dist/connect/mcp.js.map +1 -0
- package/dist/connect/stdio.d.ts +1 -1
- package/dist/connect/stdio.js +22 -28
- package/dist/connect/stdio.js.map +1 -1
- package/dist/daemon.d.ts +13 -0
- package/dist/daemon.js +64 -1
- package/dist/daemon.js.map +1 -1
- package/dist/dispatcher-liveness.d.ts +51 -1
- package/dist/dispatcher-liveness.js +92 -2
- package/dist/dispatcher-liveness.js.map +1 -1
- package/dist/fleet-manager.d.ts +56 -1
- package/dist/fleet-manager.js +243 -32
- package/dist/fleet-manager.js.map +1 -1
- package/dist/general-knowledge/skills/hub/SKILL.md +83 -3
- package/dist/general-knowledge/skills/web-dashboard/SKILL.md +10 -2
- package/dist/hub/admin-dashboard.js +17 -1
- package/dist/hub/admin-dashboard.js.map +1 -1
- package/dist/hub/audit/index.d.ts +2 -0
- package/dist/hub/audit/index.js +8 -0
- package/dist/hub/audit/index.js.map +1 -1
- package/dist/hub/buttons.js +3 -1
- package/dist/hub/buttons.js.map +1 -1
- package/dist/hub/catalog.d.ts +7 -4
- package/dist/hub/catalog.js +19 -10
- package/dist/hub/catalog.js.map +1 -1
- package/dist/hub/client.d.ts +3 -0
- package/dist/hub/client.js +14 -2
- package/dist/hub/client.js.map +1 -1
- package/dist/hub/compose/member.js +28 -11
- package/dist/hub/compose/member.js.map +1 -1
- package/dist/hub/compose/server.d.ts +5 -0
- package/dist/hub/compose/server.js +91 -10
- package/dist/hub/compose/server.js.map +1 -1
- package/dist/hub/group-policy/admin-api.d.ts +1 -0
- package/dist/hub/group-policy/admin-api.js +1 -1
- package/dist/hub/group-policy/admin-api.js.map +1 -1
- package/dist/hub/group-policy/admin-dto.d.ts +2 -1
- package/dist/hub/group-policy/admin-impact.d.ts +32 -3
- package/dist/hub/group-policy/admin-impact.js +14 -2
- package/dist/hub/group-policy/admin-impact.js.map +1 -1
- package/dist/hub/group-policy/admin-inventory.d.ts +2 -0
- package/dist/hub/group-policy/admin-inventory.js +13 -4
- package/dist/hub/group-policy/admin-inventory.js.map +1 -1
- package/dist/hub/group-policy/authorization.d.ts +2 -0
- package/dist/hub/group-policy/authorization.js +7 -2
- package/dist/hub/group-policy/authorization.js.map +1 -1
- package/dist/hub/group-policy/impact-inventory.d.ts +1 -1
- package/dist/hub/group-policy/impact-inventory.js.map +1 -1
- package/dist/hub/group-policy/resources.d.ts +2 -0
- package/dist/hub/group-policy/resources.js +12 -1
- package/dist/hub/group-policy/resources.js.map +1 -1
- package/dist/hub/http/compose.js +164 -23
- package/dist/hub/http/compose.js.map +1 -1
- package/dist/hub/http/core.js +27 -0
- package/dist/hub/http/core.js.map +1 -1
- package/dist/hub/http/deps.d.ts +12 -0
- package/dist/hub/http/schema.js +6 -0
- package/dist/hub/http/schema.js.map +1 -1
- package/dist/hub/join/service.d.ts +1 -1
- package/dist/hub/join/service.js.map +1 -1
- package/dist/hub/mcp/auth-schema.d.ts +7 -0
- package/dist/hub/mcp/auth-schema.js +31 -0
- package/dist/hub/mcp/auth-schema.js.map +1 -0
- package/dist/hub/mcp/auth.d.ts +89 -0
- package/dist/hub/mcp/auth.js +374 -0
- package/dist/hub/mcp/auth.js.map +1 -0
- package/dist/hub/mcp/catalog.d.ts +44 -0
- package/dist/hub/mcp/catalog.js +31 -0
- package/dist/hub/mcp/catalog.js.map +1 -0
- package/dist/hub/mcp/door-schema.d.ts +7 -0
- package/dist/hub/mcp/door-schema.js +20 -0
- package/dist/hub/mcp/door-schema.js.map +1 -0
- package/dist/hub/mcp/http.d.ts +25 -0
- package/dist/hub/mcp/http.js +259 -0
- package/dist/hub/mcp/http.js.map +1 -0
- package/dist/hub/mcp/policy.d.ts +65 -0
- package/dist/hub/mcp/policy.js +153 -0
- package/dist/hub/mcp/policy.js.map +1 -0
- package/dist/hub/mcp/server.d.ts +3 -0
- package/dist/hub/mcp/server.js +32 -0
- package/dist/hub/mcp/server.js.map +1 -0
- package/dist/hub/mcp/tools.d.ts +31 -0
- package/dist/hub/mcp/tools.js +176 -0
- package/dist/hub/mcp/tools.js.map +1 -0
- package/dist/hub/member/room-ask.d.ts +4 -4
- package/dist/hub/member/room-ask.js +12 -0
- package/dist/hub/member/room-ask.js.map +1 -1
- package/dist/hub/member/room-mention-feedback.d.ts +44 -0
- package/dist/hub/member/room-mention-feedback.js +121 -0
- package/dist/hub/member/room-mention-feedback.js.map +1 -0
- package/dist/hub/member/room-notification.d.ts +9 -0
- package/dist/hub/member/room-notification.js +2 -0
- package/dist/hub/member/room-notification.js.map +1 -0
- package/dist/hub/member/room-post-answers.d.ts +1 -7
- package/dist/hub/member/room-post-answers.js.map +1 -1
- package/dist/hub/member/room-post.d.ts +3 -0
- package/dist/hub/member/room-post.js +9 -1
- package/dist/hub/member/room-post.js.map +1 -1
- package/dist/hub/pairing.d.ts +15 -1
- package/dist/hub/pairing.js +33 -2
- package/dist/hub/pairing.js.map +1 -1
- package/dist/hub/personal/owner-host.d.ts +140 -0
- package/dist/hub/personal/owner-host.js +287 -0
- package/dist/hub/personal/owner-host.js.map +1 -0
- package/dist/hub/personal/refusals.d.ts +11 -0
- package/dist/hub/personal/refusals.js +33 -0
- package/dist/hub/personal/refusals.js.map +1 -0
- package/dist/hub/personal/runtime-host.d.ts +26 -0
- package/dist/hub/personal/runtime-host.js +51 -0
- package/dist/hub/personal/runtime-host.js.map +1 -0
- package/dist/hub/personal/schema.d.ts +4 -0
- package/dist/hub/personal/schema.js +54 -0
- package/dist/hub/personal/schema.js.map +1 -0
- package/dist/hub/personal/turns.d.ts +39 -0
- package/dist/hub/personal/turns.js +221 -0
- package/dist/hub/personal/turns.js.map +1 -0
- package/dist/hub/personal/types.d.ts +42 -0
- package/dist/hub/personal/types.js +2 -0
- package/dist/hub/personal/types.js.map +1 -0
- package/dist/hub/policy.d.ts +1 -1
- package/dist/hub/policy.js +2 -0
- package/dist/hub/policy.js.map +1 -1
- package/dist/hub/protocol.d.ts +43 -0
- package/dist/hub/protocol.js +16 -4
- package/dist/hub/protocol.js.map +1 -1
- package/dist/hub/quota.js +3 -1
- package/dist/hub/quota.js.map +1 -1
- package/dist/hub/roles/admin-control.d.ts +29 -0
- package/dist/hub/roles/admin-control.js +187 -0
- package/dist/hub/roles/admin-control.js.map +1 -0
- package/dist/hub/roles/admin-types.d.ts +72 -0
- package/dist/hub/roles/admin-types.js +2 -0
- package/dist/hub/roles/admin-types.js.map +1 -0
- package/dist/hub/roles/allowed-list-control.d.ts +34 -0
- package/dist/hub/roles/allowed-list-control.js +179 -0
- package/dist/hub/roles/allowed-list-control.js.map +1 -0
- package/dist/hub/roles/allowed-list.d.ts +8 -0
- package/dist/hub/roles/allowed-list.js +49 -0
- package/dist/hub/roles/allowed-list.js.map +1 -0
- package/dist/hub/roles/audit-details.d.ts +144 -0
- package/dist/hub/roles/audit-details.js +26 -0
- package/dist/hub/roles/audit-details.js.map +1 -0
- package/dist/hub/roles/authority.d.ts +12 -0
- package/dist/hub/roles/authority.js +39 -3
- package/dist/hub/roles/authority.js.map +1 -1
- package/dist/hub/roles/change.d.ts +3 -1
- package/dist/hub/roles/change.js +4 -3
- package/dist/hub/roles/change.js.map +1 -1
- package/dist/hub/roles/clock.d.ts +3 -0
- package/dist/hub/roles/clock.js +1 -1
- package/dist/hub/roles/clock.js.map +1 -1
- package/dist/hub/roles/cutover-inventory.d.ts +2 -0
- package/dist/hub/roles/cutover-inventory.js +8 -1
- package/dist/hub/roles/cutover-inventory.js.map +1 -1
- package/dist/hub/roles/cutover.d.ts +2 -2
- package/dist/hub/roles/cutover.js +3 -4
- package/dist/hub/roles/cutover.js.map +1 -1
- package/dist/hub/roles/delegation.d.ts +4 -1
- package/dist/hub/roles/delegation.js +3 -2
- package/dist/hub/roles/delegation.js.map +1 -1
- package/dist/hub/roles/expiry-effects.d.ts +8 -0
- package/dist/hub/roles/expiry-effects.js +50 -0
- package/dist/hub/roles/expiry-effects.js.map +1 -0
- package/dist/hub/roles/migrations.d.ts +7 -0
- package/dist/hub/roles/migrations.js +44 -0
- package/dist/hub/roles/migrations.js.map +1 -0
- package/dist/hub/roles/model.d.ts +2 -0
- package/dist/hub/roles/model.js +2 -1
- package/dist/hub/roles/model.js.map +1 -1
- package/dist/hub/roles/overview.d.ts +8 -0
- package/dist/hub/roles/overview.js +15 -0
- package/dist/hub/roles/overview.js.map +1 -0
- package/dist/hub/roles/resource-effects.d.ts +17 -0
- package/dist/hub/roles/resource-effects.js +62 -0
- package/dist/hub/roles/resource-effects.js.map +1 -0
- package/dist/hub/roles/review.d.ts +16 -0
- package/dist/hub/roles/review.js +42 -0
- package/dist/hub/roles/review.js.map +1 -0
- package/dist/hub/roles/writer.d.ts +14 -3
- package/dist/hub/roles/writer.js +64 -16
- package/dist/hub/roles/writer.js.map +1 -1
- package/dist/hub/room-mention-feedback-model.d.ts +12 -0
- package/dist/hub/room-mention-feedback-model.js +12 -0
- package/dist/hub/room-mention-feedback-model.js.map +1 -0
- package/dist/hub/rooms/agents.d.ts +3 -1
- package/dist/hub/rooms/agents.js +96 -11
- package/dist/hub/rooms/agents.js.map +1 -1
- package/dist/hub/rooms/direct-view.d.ts +6 -2
- package/dist/hub/rooms/direct-view.js +3 -3
- package/dist/hub/rooms/direct-view.js.map +1 -1
- package/dist/hub/rooms/service.d.ts +27 -3
- package/dist/hub/rooms/service.js +74 -13
- package/dist/hub/rooms/service.js.map +1 -1
- package/dist/hub/rooms/types.d.ts +3 -1
- package/dist/hub/rooms.d.ts +12 -2
- package/dist/hub/rooms.js +87 -17
- package/dist/hub/rooms.js.map +1 -1
- package/dist/hub/runtime.js +1 -1
- package/dist/hub/runtime.js.map +1 -1
- package/dist/hub/server.d.ts +2 -0
- package/dist/hub/server.js +19 -3
- package/dist/hub/server.js.map +1 -1
- package/dist/hub/session-directory-transition.d.ts +2 -1
- package/dist/hub/session-directory-transition.js +10 -3
- package/dist/hub/session-directory-transition.js.map +1 -1
- package/dist/hub/sessions.d.ts +1 -1
- package/dist/hub/sessions.js +26 -4
- package/dist/hub/sessions.js.map +1 -1
- package/dist/hub/settings-commit.d.ts +32 -1
- package/dist/hub/settings-commit.js +11 -4
- package/dist/hub/settings-commit.js.map +1 -1
- package/dist/hub/settings-directory-ca.js +1 -1
- package/dist/hub/settings-directory-ca.js.map +1 -1
- package/dist/hub/settings-directory-control.js +7 -7
- package/dist/hub/settings-directory-control.js.map +1 -1
- package/dist/hub/settings-directory-http.d.ts +2 -0
- package/dist/hub/settings-directory-http.js +21 -6
- package/dist/hub/settings-directory-http.js.map +1 -1
- package/dist/hub/settings-directory-proof.d.ts +5 -1
- package/dist/hub/settings-directory-proof.js +27 -9
- package/dist/hub/settings-directory-proof.js.map +1 -1
- package/dist/hub/settings-directory-recovery.js +2 -1
- package/dist/hub/settings-directory-recovery.js.map +1 -1
- package/dist/hub/settings-directory-save.d.ts +2 -0
- package/dist/hub/settings-directory-save.js +9 -6
- package/dist/hub/settings-directory-save.js.map +1 -1
- package/dist/hub/sharing.js +2 -2
- package/dist/hub/sharing.js.map +1 -1
- package/dist/hub/types.d.ts +26 -3
- package/dist/locale.js +13 -10
- package/dist/locale.js.map +1 -1
- package/dist/login-controller.d.ts +19 -2
- package/dist/login-controller.js +26 -8
- package/dist/login-controller.js.map +1 -1
- package/dist/native-model-catalog.d.ts +15 -0
- package/dist/native-model-catalog.js +43 -3
- package/dist/native-model-catalog.js.map +1 -1
- package/dist/runtime-build-info.js +1 -0
- package/dist/runtime-build-info.js.map +1 -1
- package/dist/runtime-cli.js +31 -5
- package/dist/runtime-cli.js.map +1 -1
- package/dist/runtime-client-store.d.ts +5 -0
- package/dist/runtime-client-store.js +28 -0
- package/dist/runtime-client-store.js.map +1 -1
- package/dist/runtime-client.d.ts +4 -0
- package/dist/runtime-client.js +33 -10
- package/dist/runtime-client.js.map +1 -1
- package/dist/runtime-coordinator.d.ts +4 -2
- package/dist/runtime-coordinator.js +33 -6
- package/dist/runtime-coordinator.js.map +1 -1
- package/dist/runtime-install.d.ts +6 -1
- package/dist/runtime-install.js +12 -4
- package/dist/runtime-install.js.map +1 -1
- package/dist/runtime-personal-answer-only-probe.d.ts +3 -0
- package/dist/runtime-personal-answer-only-probe.js +134 -0
- package/dist/runtime-personal-answer-only-probe.js.map +1 -0
- package/dist/runtime-personal-answer-only.d.ts +16 -0
- package/dist/runtime-personal-answer-only.js +54 -0
- package/dist/runtime-personal-answer-only.js.map +1 -0
- package/dist/runtime-personal-answer.d.ts +7 -2
- package/dist/runtime-personal-answer.js +12 -3
- package/dist/runtime-personal-answer.js.map +1 -1
- package/dist/runtime-personal-preflight.d.ts +8 -0
- package/dist/runtime-personal-preflight.js +103 -0
- package/dist/runtime-personal-preflight.js.map +1 -0
- package/dist/runtime-personal-profile.d.ts +7 -1
- package/dist/runtime-personal-profile.js +24 -4
- package/dist/runtime-personal-profile.js.map +1 -1
- package/dist/runtime-personal-protocol.d.ts +10 -0
- package/dist/runtime-personal-protocol.js +15 -0
- package/dist/runtime-personal-protocol.js.map +1 -0
- package/dist/runtime-personal-stage.d.ts +37 -0
- package/dist/runtime-personal-stage.js +167 -0
- package/dist/runtime-personal-stage.js.map +1 -0
- package/dist/runtime-protocol.d.ts +2 -0
- package/dist/setup-form.js +10 -0
- package/dist/setup-form.js.map +1 -1
- package/dist/tunnel/lease.d.ts +14 -0
- package/dist/tunnel/lease.js +23 -0
- package/dist/tunnel/lease.js.map +1 -1
- package/dist/ui/backend-signin.js +86 -20
- package/dist/ui/chat-activity-groups.js +41 -8
- package/dist/ui/chat-activity.js +3 -1
- package/dist/ui/chat-store.js +39 -2
- package/dist/ui/chat-tour.js +1 -1
- package/dist/ui/fleet-canvas.js +10 -5
- package/dist/ui/fleet-office.js +73 -7
- package/dist/ui/hub-ai-apps-strings.js +6 -0
- package/dist/ui/hub-ai-apps.js +83 -0
- package/dist/ui/hub-client.js +32 -1
- package/dist/ui/hub-directory-editor-strings.js +2 -2
- package/dist/ui/hub-directory-editor.js +1 -0
- package/dist/ui/hub-group-policy.js +4 -3
- package/dist/ui/hub-group-strings.js +2 -2
- package/dist/ui/hub-personal-agent-strings.js +160 -0
- package/dist/ui/hub-personal-agent.js +94 -0
- package/dist/ui/hub-role-audit.js +39 -0
- package/dist/ui/hub-role-forms.js +99 -0
- package/dist/ui/hub-role-notices.js +11 -0
- package/dist/ui/hub-role-view.js +86 -0
- package/dist/ui/hub-roles-strings.js +439 -0
- package/dist/ui/hub-roles.js +83 -0
- package/dist/ui/hub-room-composer.js +3 -2
- package/dist/ui/hub-room-list.js +4 -3
- package/dist/ui/hub-room-members.js +4 -2
- package/dist/ui/hub-room-settings.js +6 -0
- package/dist/ui/hub-room-source-strings.js +17 -0
- package/dist/ui/hub-room-source.js +34 -0
- package/dist/ui/hub-room-thread.js +10 -4
- package/dist/ui/hub-switcher.js +2 -2
- package/dist/ui/hub-this-hub.js +2 -2
- package/dist/ui/model-picker.js +4 -1
- package/dist/ui/panel-chat.js +4 -4
- package/dist/ui/panel-fleet.js +3 -3
- package/dist/ui/panel-hub.js +51 -31
- package/dist/ui/panel-settings.js +2 -3
- package/dist/ui/runtime-commands.d.ts +2 -2
- package/dist/ui/runtime-commands.js +7 -4
- package/dist/ui/settings-build-version.js +2 -2
- package/dist/ui/settings-catalog.js +22 -0
- package/dist/ui/settings-hub-setup.js +2 -1
- package/dist/ui/settings-strings.js +2 -0
- package/dist/ui/shared/access-overview.css +1 -1
- package/dist/ui/shared/accounts-keepalive.css +1 -1
- package/dist/ui/shared/accounts.css +1 -1
- package/dist/ui/shared/agent-sheet.js +2 -2
- package/dist/ui/shared/app-prefs.js +5 -2
- package/dist/ui/shared/app-shell.js +20 -8
- package/dist/ui/shared/app-stream.js +3 -1
- package/dist/ui/shared/app-swipe.js +3 -1
- package/dist/ui/shared/app.css +142 -48
- package/dist/ui/shared/app.js +1 -1
- package/dist/ui/shared/chat-thread.js +5 -1
- package/dist/ui/shared/chat-work-bar.css +5 -5
- package/dist/ui/shared/connector-prompt.d.ts +1 -0
- package/dist/ui/shared/connector-prompt.js +10 -0
- package/dist/ui/shared/hub-ai-apps.css +12 -0
- package/dist/ui/shared/hub-chat.css +9 -2
- package/dist/ui/shared/hub-groups.css +1 -1
- package/dist/ui/shared/hub-owner.css +5 -5
- package/dist/ui/shared/hub-roles.css +99 -0
- package/dist/ui/shared/hub-rooms-u2.css +14 -0
- package/dist/ui/shared/hub.css +13 -5
- package/dist/ui/shared/instance-nav.js +24 -9
- package/dist/ui/shared/loading.css +1 -1
- package/dist/ui/shared/model-picker.css +2 -2
- package/dist/ui/shared/preview-panel-actions.js +1 -1
- package/dist/ui/shared/preview-panel.js +2 -2
- package/dist/ui/shared/signin.js +27 -12
- package/dist/ui/shared/task-board.css +2 -2
- package/dist/ui/shared/tokens.css +1 -1
- package/dist/ui/shared/ui-toast.js +4 -4
- package/dist/ui/shared/usage-dialog.js +110 -16
- package/dist/ui/shared/view-strings.js +8 -0
- package/dist/ui/signin.html +4 -2
- package/dist/ui/structured-signin.js +64 -12
- package/dist/ui/web-terminal/terminal.css +1 -1
- package/dist/web-api.d.ts +4 -0
- package/dist/web-api.js +39 -23
- package/dist/web-api.js.map +1 -1
- package/dist/web-backend-login.d.ts +5 -1
- package/dist/web-backend-login.js +8 -2
- package/dist/web-backend-login.js.map +1 -1
- package/dist/web-prefs.js +2 -0
- package/dist/web-prefs.js.map +1 -1
- package/dist/windows-cli-worker.d.ts +10 -0
- package/dist/windows-cli-worker.js +109 -14
- package/dist/windows-cli-worker.js.map +1 -1
- package/dist/windows-cli.d.ts +10 -1
- package/dist/windows-cli.js +47 -13
- package/dist/windows-cli.js.map +1 -1
- package/package.json +1 -1
- package/templates/runtime-install/install.ps1 +24 -4
|
@@ -27,7 +27,11 @@
|
|
|
27
27
|
// step has no group at all. Text after the last reply with substance stays in that reply's group (the same block as the
|
|
28
28
|
// turn's other steps), and only until its reply row arrives is it ever the live group.
|
|
29
29
|
// A page labels `text`, `time`, `turn` and `none` as inferred. A reply call seen a moment before its row arrives is
|
|
30
|
-
// `live`
|
|
30
|
+
// `live` so the group does not jump when the row comes.
|
|
31
|
+
// Where the live group sits (#3756): before the first agent row newer than its start (`from`) that no group claims — the
|
|
32
|
+
// reply row of this very turn can arrive (SSE) before the steps read that names it, and the block must not be drawn
|
|
33
|
+
// under it for one read and then jump above it. At the end when there is none, when a person's message newer than the
|
|
34
|
+
// start comes first (it may start another turn: the work is never hung on a later reply), and for rows with no time.
|
|
31
35
|
//
|
|
32
36
|
// Keys: `act:<turn>:<n>` (n: the segment's number in its turn) — the same key while a segment is live and after its
|
|
33
37
|
// reply arrives, so the page keeps the node (no remount, no scroll jump). A turn the transcript gave no id for is named
|
|
@@ -73,8 +77,12 @@ function turnsOf(steps) {
|
|
|
73
77
|
* @returns { groups: Group[], live: Group|null }
|
|
74
78
|
* Group = { key, turn, n, level, rowKey: string|null, items: Step[], trailing: Step[], ts: number, from, to (ms: when the
|
|
75
79
|
* work for the reply began — the turn's start, or the previous reply's call — and when it ended; `to` 0 while live), partial?: true,
|
|
76
|
-
* ended: the segment is complete (false: live), turnEnded: the turn is over — only then are `trailing` steps "never sent"
|
|
77
|
-
*
|
|
80
|
+
* ended: the segment is complete (false: live), turnEnded: the turn is over — only then are `trailing` steps "never sent",
|
|
81
|
+
* promptKey?: the live group's own prompt row (the key of its turn's user row, when the ledger has it), waitsFor?: the
|
|
82
|
+
* live group's reply call's id, when its result named one (its row is the only one it may go before); atEnd?: true —
|
|
83
|
+
* a live group composeRows always puts last (chat-activity.js' status-only "Working…" line) }
|
|
84
|
+
* `groups` are in thread order; `rowKey` is the row a group sits above (null: between rows by `ts`; the live group by
|
|
85
|
+
* composeRows' rule).
|
|
78
86
|
*/
|
|
79
87
|
export function groupSteps(rows, steps, opts = {}) {
|
|
80
88
|
const now = opts.now ?? Date.now();
|
|
@@ -85,6 +93,7 @@ export function groupSteps(rows, steps, opts = {}) {
|
|
|
85
93
|
const turns = turnsOf(steps);
|
|
86
94
|
const groups = [];
|
|
87
95
|
let live = null;
|
|
96
|
+
let livePrompt = null; // the newest turn's own prompt row (only it has a live group): composeRows, #3756
|
|
88
97
|
// Prism #3709 R4: the rows some reply call names by its explicit id. A call that names none yet (its result not seen) may
|
|
89
98
|
// still be matched by its words or its time — but never onto a row another call has proved to be its own.
|
|
90
99
|
const named = new Set();
|
|
@@ -127,6 +136,7 @@ export function groupSteps(rows, steps, opts = {}) {
|
|
|
127
136
|
const userRow = first && first.anchor && first.anchor.messageId
|
|
128
137
|
? users.find((r) => r.x.anchor === first.anchor.messageId) || null : null;
|
|
129
138
|
const tkey = turn.turn || `~${(first || turn.steps[0]).id}`;
|
|
139
|
+
if (lastTurn && userRow) livePrompt = rowKeyOf(userRow.x);
|
|
130
140
|
// Which agent rows can belong to this turn's replies by time: between its user row and the next user row; with no
|
|
131
141
|
// user row to go by, between the turn's first step and the next turn's first (rows keep their own clock).
|
|
132
142
|
const next = userRow ? users.find((r) => r.i > userRow.i) : null;
|
|
@@ -164,7 +174,7 @@ export function groupSteps(rows, steps, opts = {}) {
|
|
|
164
174
|
const awaiting = lastTurn && (sg.reply.status === "running" || (sg.reply.ts && now - sg.reply.ts < AWAIT_ROW_MS));
|
|
165
175
|
if (!awaiting) { groups.push({ ...base, level: "none", rowKey: null }); return; }
|
|
166
176
|
if (live) groups.push({ ...live, level: "none", ended: true });
|
|
167
|
-
live = { ...base, level: "live", rowKey: null, ended: false };
|
|
177
|
+
live = { ...base, level: "live", rowKey: null, ended: false, ...(sg.reply.anchor && sg.reply.anchor.messageId ? { waitsFor: sg.reply.anchor.messageId } : {}) };
|
|
168
178
|
});
|
|
169
179
|
if (!tail.length) {
|
|
170
180
|
// nothing shown yet, but the agent is working on this turn (the page says so: `busy`). Some CLIs write a
|
|
@@ -196,13 +206,15 @@ export function groupSteps(rows, steps, opts = {}) {
|
|
|
196
206
|
if (lastPlaced) { lastPlaced.trailing = tail; lastPlaced.to = tail[tail.length - 1].ts || lastPlaced.to; return; }
|
|
197
207
|
groups.push({ key: `act:${tkey}:${n}`, turn: turn.turn, n, level: "none", rowKey: null, items: tail, trailing: [], ts: tail[0].ts || 0, from, to: tail[tail.length - 1].ts || 0, ended: true, turnEnded: ended, ...(partial && !segs.length ? { partial: true } : {}) });
|
|
198
208
|
});
|
|
209
|
+
if (live && livePrompt) live.promptKey = livePrompt;
|
|
199
210
|
if (live && opts.busy) { live.busy = true; if (opts.phase) live.phase = opts.phase; } // the page knows the agent is working: this live group is shown even when it holds nothing to show yet; grok's phase (reasoning, a tool…) is what the live line says
|
|
200
211
|
return { groups, live };
|
|
201
212
|
}
|
|
202
213
|
|
|
203
214
|
/**
|
|
204
215
|
* The ledger rows with each group as a synthetic `{ role: "activity" }` row before the reply it belongs to; a group
|
|
205
|
-
* with no row (`none`, by its time) between the rows; the live group
|
|
216
|
+
* with no row (`none`, by its time) between the rows; the live group before the reply row it is waiting for (see the
|
|
217
|
+
* top: `liveRowIndex`), else last. The rows themselves are never changed.
|
|
206
218
|
*/
|
|
207
219
|
export function composeRows(rows, { groups, live }) {
|
|
208
220
|
const before = new Map();
|
|
@@ -213,13 +225,34 @@ export function composeRows(rows, { groups, live }) {
|
|
|
213
225
|
const act = (g) => ({ role: "activity", boot: "act", id: g.key, group: g, ts: g.ts ? new Date(g.ts).toISOString() : "" });
|
|
214
226
|
const out = [];
|
|
215
227
|
const looseLeft = loose.slice().sort((a, b) => a.ts - b.ts);
|
|
216
|
-
|
|
228
|
+
const liveAt = live ? liveRowIndex(rows, live, before) : -1;
|
|
229
|
+
rows.forEach((x, i) => {
|
|
217
230
|
const t = rowTs(x);
|
|
218
231
|
while (looseLeft.length && t && looseLeft[0].ts && looseLeft[0].ts < t) out.push(act(looseLeft.shift()));
|
|
219
232
|
for (const g of before.get(rowKeyOf(x)) || []) out.push(act(g));
|
|
233
|
+
if (i === liveAt) out.push(act(live));
|
|
220
234
|
out.push(x);
|
|
221
|
-
}
|
|
235
|
+
});
|
|
222
236
|
for (const g of looseLeft) out.push(act(g));
|
|
223
|
-
if (live) out.push(act(live));
|
|
237
|
+
if (live && liveAt < 0) out.push(act(live));
|
|
224
238
|
return out;
|
|
225
239
|
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* #3756: the row the live group goes before — the first agent row newer than the group's start that no group claims
|
|
243
|
+
* (a reply of this turn whose row came before the steps read that names it). -1 (the end): a person's message newer
|
|
244
|
+
* than the start comes first (other than the turn's own prompt), there is no such row, or the group has no start.
|
|
245
|
+
* Rows with no time are passed over. A reply call whose result named its row's id waits for that row only (R4: never a
|
|
246
|
+
* guess); while it is missing, the end. A group marked `atEnd` (the status-only "Working…" line) is always last.
|
|
247
|
+
*/
|
|
248
|
+
function liveRowIndex(rows, live, claimed) {
|
|
249
|
+
const from = live.from || live.ts || 0;
|
|
250
|
+
if (!from || live.atEnd) return -1;
|
|
251
|
+
for (let i = 0; i < rows.length; i++) {
|
|
252
|
+
const x = rows[i], t = rowTs(x);
|
|
253
|
+
if (t <= from) continue; // older, or no time (0)
|
|
254
|
+
if (x.role === "user" && rowKeyOf(x) !== live.promptKey) return -1;
|
|
255
|
+
if (x.role === "agent" && !claimed.has(rowKeyOf(x)) && (!live.waitsFor || x.anchor === live.waitsFor)) return i;
|
|
256
|
+
}
|
|
257
|
+
return -1;
|
|
258
|
+
}
|
package/dist/ui/chat-activity.js
CHANGED
|
@@ -245,7 +245,9 @@ export function composeActivity(name, rows, now = Date.now(), opts = {}) {
|
|
|
245
245
|
function statusRows(rows, since, statusOnly, phase) {
|
|
246
246
|
let from = Number.isFinite(since) ? since : 0;
|
|
247
247
|
if (!from) { for (let i = rows.length - 1; i >= 0; i--) if (rows[i].role === "user") { const t = Date.parse(rows[i].ts); if (Number.isFinite(t)) from = t; break; } }
|
|
248
|
-
|
|
248
|
+
// atEnd: the "Working…" line stays under the newest row (#3756 moves a turn's live group above a reply that came
|
|
249
|
+
// before its steps; this line never becomes a reply's block, and the agent may still be working after a reply)
|
|
250
|
+
const live = { key: "act:status", turn: "status", n: 0, level: "live", rowKey: null, items: [], trailing: [], ts: from, from, to: 0, ended: false, turnEnded: false, busy: true, atEnd: true, ...(statusOnly ? { statusOnly: true } : {}), ...(phase ? { phase } : {}) };
|
|
249
251
|
return composeRows(rows, { groups: [], live });
|
|
250
252
|
}
|
|
251
253
|
|
package/dist/ui/chat-store.js
CHANGED
|
@@ -56,6 +56,9 @@ export function createChatStore(deps) {
|
|
|
56
56
|
commands: {},
|
|
57
57
|
};
|
|
58
58
|
const subs = new Set();
|
|
59
|
+
const commandLeases = new Map(); // instance → the `alive` the card on screen was run under (its pane / page lease)
|
|
60
|
+
const instanceBackends = new Map(); // instance → the backend its status frame named
|
|
61
|
+
const modelRereads = new Map(); // instance → whether another `models` event came while its open /model menu was being read again
|
|
59
62
|
const historyRequests = new Map();
|
|
60
63
|
const visible = new Map(); // mount token → agent; cleanup never clears a successor's focus
|
|
61
64
|
let focused = null;
|
|
@@ -111,6 +114,7 @@ export function createChatStore(deps) {
|
|
|
111
114
|
if (!d || !Array.isArray(d.instances)) return;
|
|
112
115
|
for (const i of d.instances) {
|
|
113
116
|
s.instanceStatus[i.name] = i.status;
|
|
117
|
+
if (typeof i.backend === "string") instanceBackends.set(i.name, i.backend);
|
|
114
118
|
noteExec(i.name, (i.execution_state !== undefined ? i.execution_state : i.state) ?? null);
|
|
115
119
|
const waits = i.state === "awaiting_input" ? (typeof i.interaction_summary === "string" ? i.interaction_summary : "") : null;
|
|
116
120
|
if (i.name === s.current && waits != null && s.awaiting[i.name] == null) deps.announce(tf("chat.awaiting", i.name));
|
|
@@ -600,6 +604,7 @@ export function createChatStore(deps) {
|
|
|
600
604
|
// What it was run with (#4003 review): a list asked for ("/model") is a menu while it loads; a pick ("/model <id>") is not.
|
|
601
605
|
const pending = { command, busy: true, ...(args ? { args } : {}), ...(opts.action && previous?.command === command ? { choices: previous.choices } : {}) };
|
|
602
606
|
s.commands[target] = pending;
|
|
607
|
+
commandLeases.set(target, alive);
|
|
603
608
|
changed(target);
|
|
604
609
|
const post = async (extra) => {
|
|
605
610
|
try { return await api("POST", "/ui/command", { instance: target, command, ...(args ? { args } : {}), ...(opts.action ? { action: opts.action } : {}), ...extra }); }
|
|
@@ -639,7 +644,38 @@ export function createChatStore(deps) {
|
|
|
639
644
|
showCommand(name, { ...c, compact: view.state });
|
|
640
645
|
changed(name);
|
|
641
646
|
}
|
|
642
|
-
function dismissCommand(target) { delete s.commands[target]; changed(target); }
|
|
647
|
+
function dismissCommand(target) { delete s.commands[target]; commandLeases.delete(target); changed(target); }
|
|
648
|
+
/**
|
|
649
|
+
* The `models` stream event (a sign-in ended, or a discovery that outlasted the menu's wait finished): a /model menu still
|
|
650
|
+
* open on this card reads its list again, in place. It is the same plain `/model` read the menu opened with — it applies
|
|
651
|
+
* no model — and it lands only while the card is still the one on screen and the lease it was run under is alive: a pick,
|
|
652
|
+
* Refresh, another command, a dismissal or a page that moved on in the meantime all retire it. The "more" view (its own
|
|
653
|
+
* action) and /backend's steps are not re-read.
|
|
654
|
+
*/
|
|
655
|
+
async function reloadModelMenu(event) {
|
|
656
|
+
const only = event && typeof event.backend === "string" ? event.backend : null;
|
|
657
|
+
for (const target of Object.keys(s.commands)) {
|
|
658
|
+
const card = s.commands[target], alive = commandLeases.get(target);
|
|
659
|
+
if (!card || card.command !== "model" || card.busy || card.error || !card.choices || card.choices.step === "backend") continue;
|
|
660
|
+
if ((card.choices.actions || []).includes("refreshAll") || !alive || !alive()) continue;
|
|
661
|
+
const backend = instanceBackends.get(target);
|
|
662
|
+
if (only && backend && backend !== only) continue;
|
|
663
|
+
if (modelRereads.has(target)) { modelRereads.set(target, true); continue; } // read once more when this one is back
|
|
664
|
+
modelRereads.set(target, false);
|
|
665
|
+
try {
|
|
666
|
+
let shownCard = card;
|
|
667
|
+
do {
|
|
668
|
+
modelRereads.set(target, false);
|
|
669
|
+
let r;
|
|
670
|
+
try { r = await api("POST", "/ui/command", { instance: target, command: "model" }); } catch { break; }
|
|
671
|
+
if (!alive() || s.commands[target] !== shownCard || !r || r.error || !r.choices || r.choices.step === "backend") break;
|
|
672
|
+
shownCard = { command: "model", busy: false, choices: r.choices };
|
|
673
|
+
showCommand(target, shownCard);
|
|
674
|
+
changed(target);
|
|
675
|
+
} while (modelRereads.get(target));
|
|
676
|
+
} finally { modelRereads.delete(target); }
|
|
677
|
+
}
|
|
678
|
+
}
|
|
643
679
|
/** Whether a command can start for `target` now (none is out): checked before a typed command line is consumed. */
|
|
644
680
|
const commandFree = (target) => !(s.commands[target] && s.commands[target].busy);
|
|
645
681
|
|
|
@@ -666,6 +702,7 @@ export function createChatStore(deps) {
|
|
|
666
702
|
stream.on("reply_buttons", applyReplyButtons);
|
|
667
703
|
stream.on("reactions", applyReactions); // #2305
|
|
668
704
|
stream.on("clock", noteServerClock); // #1823
|
|
705
|
+
stream.on("models", reloadModelMenu);
|
|
669
706
|
}
|
|
670
707
|
|
|
671
708
|
return {
|
|
@@ -679,7 +716,7 @@ export function createChatStore(deps) {
|
|
|
679
716
|
applyReplyButtons, clickReplyButton,
|
|
680
717
|
uploadFile, send, retryOutgoing, deleteOutgoing, putBackOutgoing, threadRows, addFiles, removeFile, attachPastedText, fileBackAsText, isPasted, setDraft,
|
|
681
718
|
startReply, clearReply, findQuoted, addToDraft, captureDraft, draftCurrent, clearCapturedDraft, acceptDraft,
|
|
682
|
-
cancelReply, isUser, runCommand, dismissCommand, commandFree,
|
|
719
|
+
cancelReply, isUser, runCommand, dismissCommand, commandFree, reloadModelMenu,
|
|
683
720
|
allHidden: (name) => s.allHidden.has(name),
|
|
684
721
|
};
|
|
685
722
|
}
|
package/dist/ui/chat-tour.js
CHANGED
|
@@ -15,7 +15,7 @@ const TOUR_KEY = "agend_tour_done";
|
|
|
15
15
|
const byId = (id) => document.getElementById(id) || document.querySelector(`.ws-focused [id$="-${id}"]`);
|
|
16
16
|
// On a phone the instance list is in the closed drawer: the tour outlines what opens it (☰), and for "needs you" the
|
|
17
17
|
// bottom tab's badge (#1408 step 5: retargeted to the app's shell).
|
|
18
|
-
const narrow = () => typeof matchMedia === "function" && matchMedia("(max-width: 899px)").matches;
|
|
18
|
+
const narrow = () => typeof matchMedia === "function" && matchMedia("(max-width: 899px), (pointer: coarse) and (max-height: 500px) and (max-width: 1023px)").matches;
|
|
19
19
|
const STEPS = [
|
|
20
20
|
{ text: "chat.tour1", spot: () => (narrow() ? byId("sbOpen") : byId("instanceList")) },
|
|
21
21
|
{ text: "chat.tour2", spot: () => byId("main") },
|
package/dist/ui/fleet-canvas.js
CHANGED
|
@@ -29,7 +29,7 @@ import { Icon } from "/assets/ui-icons.js";
|
|
|
29
29
|
import { avatarOf, firstCharacter, namesOf } from "/assets/instance-nav.js";
|
|
30
30
|
import { identityClasses, identityOf, paintIdentity, useIdentityColors } from "/assets/identity-color.js";
|
|
31
31
|
import { buildOrgView, nodeText, OrgChart, OrgSummary } from "./fleet-org.js";
|
|
32
|
-
import { Office } from "./fleet-office.js";
|
|
32
|
+
import { Office, useOfficePhone } from "./fleet-office.js";
|
|
33
33
|
import { OC, REST_KEY, SUM_LINE, canvasLayout, hits, needle, openingRegion, summaryRows } from "./fleet-canvas-layout.js";
|
|
34
34
|
import { createTrafficStore, FAR_K, HEAD, POLL_MS, sendingBy, trafficEdges } from "./fleet-traffic.js";
|
|
35
35
|
import { routeScene } from "./fleet-route-scene.js";
|
|
@@ -74,7 +74,7 @@ const MODE_KEY = "agend_org_mode", FOLD_KEY = "agend_org_folded", LIVE_KEY = "ag
|
|
|
74
74
|
const MODES = ["canvas", "list", "office"];
|
|
75
75
|
/** The org page's view: this device's choice, else the canvas — on a phone the list (M-3166, Argon 5: a phone opens on it). */
|
|
76
76
|
function readMode() {
|
|
77
|
-
const phone = typeof matchMedia === "function" && matchMedia("(max-width: 899px)").matches, fallback = phone ? "list" : "canvas";
|
|
77
|
+
const phone = typeof matchMedia === "function" && matchMedia("(max-width: 899px), (pointer: coarse) and (max-height: 500px) and (max-width: 1023px)").matches, fallback = phone ? "list" : "canvas";
|
|
78
78
|
try { const m = localStorage.getItem(MODE_KEY); return MODES.includes(m) ? m : fallback; } catch { return fallback; }
|
|
79
79
|
}
|
|
80
80
|
function readLive() { try { return localStorage.getItem(LIVE_KEY) !== "0"; } catch { return true; } }
|
|
@@ -458,6 +458,8 @@ export function OrgCanvas({ org, app, lease }) {
|
|
|
458
458
|
useIdentityColors();
|
|
459
459
|
const [mode, setMode] = useState(readMode);
|
|
460
460
|
const [live, setLive] = useState(readLive);
|
|
461
|
+
// M-3253: on a phone the Office's tools (and Live) are one ⋯ sheet at the end of this bar: one row, Find keeps its width.
|
|
462
|
+
const phone = useOfficePhone(), [officeMore, setOfficeMore] = useState(false), officeSheet = phone && mode === "office";
|
|
461
463
|
const traffic = useTraffic(lease, live);
|
|
462
464
|
const sending = useMemo(() => sendingBy(traffic), [traffic]);
|
|
463
465
|
const [folded, setFolded] = useState(readFolded);
|
|
@@ -499,14 +501,17 @@ export function OrgCanvas({ org, app, lease }) {
|
|
|
499
501
|
<input type="search" value=${query} placeholder=${tc("findShort")} autocomplete="off" onInput=${(e) => setQuery(e.target.value)} onKeyDown=${onFind} />
|
|
500
502
|
${q ? html`<span class="oc-found" role="status">${found ? (found === 1 ? tc("foundOne") : tc("found", found)) : tc("noMatch")}</span>` : null}</label>` : null}
|
|
501
503
|
${mode === "canvas" && live ? html`<${KeyToggle} open=${keyOpen} onToggle=${toggleKey} />` : null}
|
|
502
|
-
|
|
503
|
-
onClick=${() => setLive((v) => !v)}><span class="oc-live-dot" aria-hidden="true"></span>${tc("live")}</button
|
|
504
|
+
${officeSheet ? null : html`<button type="button" class=${`btn btn-sm oc-live${live ? " on" : ""}`} aria-pressed=${live ? "true" : "false"} title=${live ? tc("liveOn") : tc("liveOff")}
|
|
505
|
+
onClick=${() => setLive((v) => !v)}><span class="oc-live-dot" aria-hidden="true"></span>${tc("live")}</button>`}
|
|
504
506
|
<div class="seg-inline" role="group" aria-label=${tc("view")}>${modeBtn("canvas")}${modeBtn("list")}${modeBtn("office")}</div>
|
|
507
|
+
${officeSheet ? html`<button type="button" class="icon-btn oo-more-btn" aria-haspopup="dialog" aria-expanded=${officeMore ? "true" : "false"}
|
|
508
|
+
aria-label=${t("app.more")} title=${t("app.more")} onClick=${() => setOfficeMore(true)}><${Icon} name="more" /></button>` : null}
|
|
505
509
|
</div>
|
|
506
510
|
</div>
|
|
507
511
|
${mode === "canvas" && live && keyOpen ? html`<${Legend} />` : null}
|
|
508
512
|
${mode === "list" ? html`<${OrgChart} org=${org} app=${app} bare=${true} sending=${sending} />`
|
|
509
|
-
: mode === "office" ? html`<${Office} view=${view} traffic=${live ? traffic : null} q=${q} lease=${lease} onOpen=${openChat}
|
|
513
|
+
: mode === "office" ? html`<${Office} view=${view} traffic=${live ? traffic : null} q=${q} lease=${lease} onOpen=${openChat}
|
|
514
|
+
more=${officeSheet && officeMore} onMore=${officeSheet ? setOfficeMore : null} live=${live} onLive=${setLive} />`
|
|
510
515
|
: html`<${Canvas} view=${view} folded=${folded} onFold=${onFold} q=${q} jump=${jump} traffic=${live ? traffic : null} />`}
|
|
511
516
|
</div>`;
|
|
512
517
|
}
|
package/dist/ui/fleet-office.js
CHANGED
|
@@ -79,6 +79,7 @@ import { POLL_MS } from "./fleet-traffic.js";
|
|
|
79
79
|
import { OfficeEditor, officeForSave } from "./fleet-office-editor.js";
|
|
80
80
|
import { LayoutEditor, handlesOf } from "./fleet-office-layout.js";
|
|
81
81
|
import { ShareButton } from "./office-share-dialog.js";
|
|
82
|
+
import { Dialog } from "/assets/ui-dialog.js";
|
|
82
83
|
import { DLG, boxColours, boxLayout, createDialogue, createFaces, drawBox, fitBox, messageOf, onBox, pickFront, portraitSrc, stageOf, talkOf, wrap } from "./fleet-office-dialogue.js";
|
|
83
84
|
import { applyOverrides, fitNight, fitSeatFor, stripBox } from "./fleet-office-pack.js";
|
|
84
85
|
import { ALL_ID, LOBBY_TILE, OV, createCrossFlights, cropToRooms, fromTile, inTile, labelAt, lobbyNodes, overviewOk, tileAt, tileBox, tileLayout, visibleTiles } from "./fleet-office-overview.js";
|
|
@@ -115,6 +116,7 @@ register("orgo", {
|
|
|
115
116
|
dialogue: "Dialogue", dialogueTitle: "When a person messages someone here, show their words and the reply in a box at the bottom (this browser only)",
|
|
116
117
|
dlgWorking: "Working…", dlgSomeone: "Someone", dlgHeardShare: "Sent {0} a message.", dlgAnsweredShare: "Replied.", dlgFile: "(sent a file)", dlgSays: "{0}: {1}",
|
|
117
118
|
dlgBox: "Dialogue: {0}. Click for their card, double-click for their chat.",
|
|
119
|
+
zones: "Go to an area", zoneAll: "Whole office", zoneN: "{0} {1}",
|
|
118
120
|
},
|
|
119
121
|
"zh-TW": {
|
|
120
122
|
label: "辦公室:每個 team 是一間房間,每個 Agent 一張桌子;General 和未加入 team 的 Agent 在大廳。拖曳平移;滾輪、雙指、+ 和 − 縮放,0 顯示整個場景,F 切換全螢幕。",
|
|
@@ -143,6 +145,7 @@ register("orgo", {
|
|
|
143
145
|
dialogue: "對話框", dialogueTitle: "有人傳訊息給這裡的成員時,在下方的對話框顯示訊息與回覆(只限這個瀏覽器)",
|
|
144
146
|
dlgWorking: "處理中…", dlgSomeone: "有人", dlgHeardShare: "傳了一則訊息給 {0}。", dlgAnsweredShare: "已回覆。", dlgFile: "(傳了一個檔案)", dlgSays: "{0}:{1}",
|
|
145
147
|
dlgBox: "對話框:{0}。點一下看資料卡,點兩下開啟聊天。",
|
|
148
|
+
zones: "移到區域", zoneAll: "總覽", zoneN: "{0} {1}",
|
|
146
149
|
},
|
|
147
150
|
});
|
|
148
151
|
const to = (k, ...v) => t(`orgo.${k}`, ...v);
|
|
@@ -221,6 +224,33 @@ const UP_MS = 1800;
|
|
|
221
224
|
const FIND_K = 2;
|
|
222
225
|
/** #2661: below this stage width (CSS px) the card is a bottom sheet. */
|
|
223
226
|
const SHEET_W = 560;
|
|
227
|
+
/**
|
|
228
|
+
* M-3253 (Argon's phone review): the Office's phone layout — a phone's width (the shell's), or a phone turned sideways (a
|
|
229
|
+
* coarse pointer in a short window: an iPhone's 956 × 440 is wider than 899 px). There the Office's tools are one ⋯ sheet,
|
|
230
|
+
* zone pills jump to a readable zoom, a tap near a person picks them, and their card is a bottom sheet.
|
|
231
|
+
*/
|
|
232
|
+
export const OFFICE_PHONE_Q = "(max-width: 899px), (pointer: coarse) and (max-height: 500px) and (max-width: 1023px)";
|
|
233
|
+
export function useOfficePhone() {
|
|
234
|
+
const read = () => { try { return typeof matchMedia === "function" && matchMedia(OFFICE_PHONE_Q).matches; } catch { return false; } };
|
|
235
|
+
const [on, setOn] = useState(read);
|
|
236
|
+
useEffect(() => {
|
|
237
|
+
if (typeof matchMedia !== "function") return undefined;
|
|
238
|
+
const mq = matchMedia(OFFICE_PHONE_Q), changed = () => setOn(!!mq.matches);
|
|
239
|
+
changed(); mq.addEventListener?.("change", changed);
|
|
240
|
+
return () => mq.removeEventListener?.("change", changed);
|
|
241
|
+
}, []);
|
|
242
|
+
return on;
|
|
243
|
+
}
|
|
244
|
+
/** M-3253: a tap this many CSS px from a person (a fingertip's 44 px across) picks them when nobody is right under it. */
|
|
245
|
+
export const TAP_R = 22;
|
|
246
|
+
/** M-3253: a zone pill's zoom (CSS px a logical unit): the name tags at their own size. */
|
|
247
|
+
export const ZONE_K = 1;
|
|
248
|
+
/** M-3253: of `list` ({ x, y } in logical units), the one nearest (x, y) within `r` logical units, or null. */
|
|
249
|
+
export function nearestPerson(list, x, y, r) {
|
|
250
|
+
let best = null, bestD = r * r;
|
|
251
|
+
for (const it of list) { const d = (it.x - x) ** 2 + (it.y - y) ** 2; if (d <= bestD) { bestD = d; best = it; } }
|
|
252
|
+
return best;
|
|
253
|
+
}
|
|
224
254
|
/** How often the picture can change when nothing is in the air (the poses loop at 4 fps; a bubble types faster). */
|
|
225
255
|
const FPS = 12;
|
|
226
256
|
const STYLES = BUILT_IN_SKINS;
|
|
@@ -672,7 +702,10 @@ export function OfficeKey({ pal }) {
|
|
|
672
702
|
* `opening` the office it opens on (the share's), instead of the one this browser chose last; #2861: `talk` the share's
|
|
673
703
|
* conversations (its /state's: who heard or answered a person, when — never what was said), instead of the stream's.
|
|
674
704
|
*/
|
|
675
|
-
export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetImage, opening, talk }) {
|
|
705
|
+
export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetImage, opening, talk, more = false, onMore = null, live = null, onLive = null }) {
|
|
706
|
+
// M-3253: on a phone the page above (fleet-canvas.js) puts a ⋯ in its bar: `more` is that sheet open, `onMore(open)`;
|
|
707
|
+
// `live` / `onLive` its Live toggle, which moves into the sheet. Without one (a share link's page) the bar stays.
|
|
708
|
+
const phone = useOfficePhone(), compact = phone && typeof onMore === "function";
|
|
676
709
|
const store = useMemo(() => createOfficeStore(lease ? { fetch: (path, o) => lease.fetch(path, o) } : {}), [lease]);
|
|
677
710
|
const [stored, setStored] = useState([]);
|
|
678
711
|
const [storedRev, setStoredRev] = useState(null); // the rev the list was read at (a save sends it)
|
|
@@ -1599,10 +1632,21 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1599
1632
|
};
|
|
1600
1633
|
// #2661: a click (or a tap) on a person opens their card; on the same person again, or off everyone, closes it; on
|
|
1601
1634
|
// someone else, switches to theirs. A double-click skips the card and opens the chat.
|
|
1635
|
+
/** M-3253: a tap that hits nobody: the person within TAP_R CSS px of it (one office; All offices' tiles keep the exact hit). */
|
|
1636
|
+
const nearOf = (e) => {
|
|
1637
|
+
const w = pointOf(e);
|
|
1638
|
+
if (!w || overview) return null;
|
|
1639
|
+
const at = now();
|
|
1640
|
+
const list = people.filter((d) => d.node && d.node.i).map((d) => {
|
|
1641
|
+
const wk = zones ? walkers.at(d.node.name, at) : null;
|
|
1642
|
+
return { key: d.key, node: d.node, x: wk ? wk.x : d.box.x + d.box.w / 2, y: wk ? wk.y - 32 : d.box.y + d.box.h / 2 };
|
|
1643
|
+
});
|
|
1644
|
+
return nearestPerson(list, w.x, w.y, TAP_R / Math.max(OK_MIN, view0().k));
|
|
1645
|
+
};
|
|
1602
1646
|
const onClick = (e) => {
|
|
1603
1647
|
const box = dlgAt(e);
|
|
1604
1648
|
if (box) { focusPerson(box.key); return; }
|
|
1605
|
-
const d = deskOf(e);
|
|
1649
|
+
const d = deskOf(e) || (lastType.current === "touch" ? nearOf(e) : null);
|
|
1606
1650
|
if (!d || !d.node.i) { setTip(null); setCard(null); return; }
|
|
1607
1651
|
if (lastType.current === "touch") setTip(null);
|
|
1608
1652
|
cardFrom.current = null;
|
|
@@ -1749,8 +1793,16 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1749
1793
|
const carChrome = () => !carousel ? null : html`<button type="button" class="btn btn-sm oo-car-pause" onClick=${() => setCarPlaying((p) => !p)}>${to(carPlaying ? "pause" : "resume")}</button>
|
|
1750
1794
|
<button type="button" class="btn btn-sm oo-car-next" onClick=${() => stepCar(1)}>${to("next")}</button>
|
|
1751
1795
|
<span class="muted oo-car-now">${custom ? custom.name : ""} · ${to(carPlaying ? "playing" : "paused")}</span>`;
|
|
1752
|
-
|
|
1753
|
-
|
|
1796
|
+
// M-3253: the zone pills (a phone, one office on a zones style): the whole office, or an area at ZONE_K, centred.
|
|
1797
|
+
const zoneList = compact && zones && !overview && !layout ? Object.entries(L.areas || {}).map(([key, a]) => ({ key, rect: a.rect,
|
|
1798
|
+
n: people.filter((d) => d.area === areaName(key)).length })).filter((z) => z.rect && z.n > 0) : [];
|
|
1799
|
+
const toZone = (z) => { const v = view0(); raw.current = ZONE_K; setView(centreOn({ ...v, k: ZONE_K }, size, z.rect.x + z.rect.w / 2, z.rect.y + z.rect.h / 2)); };
|
|
1800
|
+
const closeMore = () => onMore && onMore(false);
|
|
1801
|
+
// In the sheet: Edit offices and Edit layout open their own editors (outside it): the sheet closes after their click.
|
|
1802
|
+
const sheetClick = (e) => { if (typeof e.target?.closest === "function" && e.target.closest(".oo-edit, .oo-layout")) closeMore(); };
|
|
1803
|
+
const tile = (icon, label, fn, cls, pressed) => html`<button type="button" class=${`oo-sheet-tile ${cls}`} aria-pressed=${pressed === undefined ? undefined : pressed ? "true" : "false"}
|
|
1804
|
+
onClick=${fn}><${Icon} name=${icon} size=${20} /><span>${label}</span></button>`;
|
|
1805
|
+
const barItems = html`
|
|
1754
1806
|
<label class="oo-pick"><span class="oo-pick-label">${to("office")}</span>${officeSelect("oo-office")}</label>
|
|
1755
1807
|
${auto ? html`<label class="oo-pick"><span class="oo-pick-label">${to("styleLabel")}</span>
|
|
1756
1808
|
<select class="tb-select" value=${STYLES.includes(style) || packs.some((pk) => pk.id === style) ? style : skin.id} title=${to(canEdit ? "styleForAll" : "styleHere")} onChange=${(e) => pickStyle(e.target.value)}>
|
|
@@ -1787,8 +1839,18 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1787
1839
|
title=${overview || carouselPick ? to(carouselPick ? "carouselNoEdit" : "overviewNoEdit") : undefined}>${t("orge.edit")}</button>` : null}
|
|
1788
1840
|
${canLayout ? html`<button type="button" class="btn btn-sm oo-layout" onClick=${openLayout}>${t("orgl.edit")}</button>` : null}
|
|
1789
1841
|
${canShare ? html`<${ShareButton} offices=${stored} current=${overview ? "all" : custom ? custom.id : null} disabled=${!!layout}
|
|
1790
|
-
get=${lease ? (path, o) => lease.fetch(path, o) : undefined} />` : null}
|
|
1791
|
-
|
|
1842
|
+
get=${lease ? (path, o) => lease.fetch(path, o) : undefined} />` : null}`;
|
|
1843
|
+
return html`<div class=${`oo${fs ? ` fs ${fs}` : ""}${compact ? " phone" : ""}`} ref=${ooRef}>
|
|
1844
|
+
${compact ? null : html`<div class="oo-bar">${barItems}</div>`}
|
|
1845
|
+
${compact && more ? html`<${Dialog} title=${to("office")} cls="oo-sheet" onClose=${closeMore}>
|
|
1846
|
+
<div class="oo-sheet-tiles">
|
|
1847
|
+
${tile("fitwidth", to("fit"), () => { closeMore(); fit(); }, "oo-sheet-fit")}
|
|
1848
|
+
${tile("fitwidth", to("fill"), toggleFill, "oo-sheet-fill", fitMode === "cover")}
|
|
1849
|
+
${tile("fullscreen", to("fullscreen"), () => { closeMore(); enterFs(); }, "oo-sheet-fs")}
|
|
1850
|
+
</div>
|
|
1851
|
+
${typeof onLive === "function" ? html`<label class="check oo-sheet-live"><input type="checkbox" checked=${!!live} onChange=${() => onLive(!live)} /><span>${t("orgc.live")}</span></label>` : null}
|
|
1852
|
+
<div class="oo-bar oo-sheet-bar" onClick=${sheetClick}>${barItems}</div>
|
|
1853
|
+
</${Dialog}>` : null}
|
|
1792
1854
|
${traffic && keyOpen ? html`<${OfficeKey} pal=${pal} />` : null}
|
|
1793
1855
|
${editing && !overview && !carouselPick ? html`<${OfficeEditor} offices=${stored} rev=${storedRev} view=${view} store=${store} packs=${packs}
|
|
1794
1856
|
ask=${ask} current=${() => shown.current} onSaved=${adopt} onClose=${() => setEditing(false)} />` : null}
|
|
@@ -1815,7 +1877,7 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1815
1877
|
model=${cardModel({ node: cardOf.node, lv, levels: wordsOf(cardOf.skin), share: !onOpen,
|
|
1816
1878
|
state: stateWords(cardOf.node), now: caption(officePose(cardOf.node.state), cardOf.node.state),
|
|
1817
1879
|
where: [cardOf.office || (custom ? custom.name : to("allOffice")), cardOf.area].filter(Boolean).join(" · ") })}
|
|
1818
|
-
avatar=${drawAvatar} sheet=${size.w < SHEET_W} place=${(el) => { cardEl.current = el; placeCard(); }}
|
|
1880
|
+
avatar=${drawAvatar} sheet=${phone || size.w < SHEET_W} place=${(el) => { cardEl.current = el; placeCard(); }}
|
|
1819
1881
|
onChat=${onOpen ? () => { const n = cardOf.node.name; setCard(null); open(n); } : null} onFind=${findCard} onClose=${closeCard} />` : null}
|
|
1820
1882
|
<ul class="oo-desks" aria-label=${to("desks")}>${people.map((d) => {
|
|
1821
1883
|
const nt = nodeText(d.node), cap = caption(officePose(d.node.state), d.node.state), where = d.office ? ` · ${d.office}` : "";
|
|
@@ -1833,6 +1895,10 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1833
1895
|
title=${to("fillTitle")} onClick=${toggleFill}>${to("fill")}</button>
|
|
1834
1896
|
<button type="button" class="icon-btn oo-fs" aria-label=${to(fs ? "exitFullscreen" : "fullscreen")} title=${to(fs ? "exitFullscreen" : "fullscreen")} onClick=${toggleFs}><${Icon} name=${fs ? "fullscreenexit" : "fullscreen"} size=${16} /></button>
|
|
1835
1897
|
</div>
|
|
1898
|
+
${zoneList.length ? html`<div class="oo-zone-pills" role="group" aria-label=${to("zones")}>
|
|
1899
|
+
<button type="button" class="btn btn-sm oo-zone-all" onClick=${() => fit()}>${to("zoneAll")}</button>
|
|
1900
|
+
${zoneList.map((z) => html`<button key=${z.key} type="button" class="btn btn-sm oo-zone" data-area=${z.key} onClick=${() => toZone(z)}>${to("zoneN", areaName(z.key), z.n)}</button>`)}
|
|
1901
|
+
</div>` : null}
|
|
1836
1902
|
${fs ? html`<div class="oo-fs-bar">${officeSelect("oo-fs-office")}${carChrome()}</div>` : null}
|
|
1837
1903
|
<svg ref=${miniRef} class="oc-mini oo-mini" viewBox=${`0 0 ${Math.max(1, L.width)} ${Math.max(1, L.height)}`} aria-hidden="true" onClick=${onMini}>
|
|
1838
1904
|
<title>${to("overview")}</title>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import {register,t} from "/assets/app-i18n.js";
|
|
2
|
+
register("hubApps",{
|
|
3
|
+
en:{returnLabel:"After you allow, you go back to",localReturn:"This app is running on this computer.",returnWarning:"Only allow if you started from that app or site.",manual:"Set it up by hand",promptHint:"Paste this into {0} and it adds the address for you.",genericHint:"Add the address above as a remote MCP server in your app.",may:"May: {0}",justNow:"just now",title:"My AI apps",consentHeading:"Connect an AI app",consentTitle:"Let {0} use this Hub as you?",consentLead:"{0} will be able to do the things ticked below. People will see “{1} via {0}” on what it posts.",read:"Read the rooms you are in",post:"Post in those rooms",ask:"Ask the agents you may ask",inbox:"Answer questions sent to it",later:"Later",privacy:"What it reads goes to your AI app and its provider.",noAdmin:"It cannot change rooms, teams or settings, and it cannot do anything an administrator does.",unverified:"The app gave this name itself. The Hub can't check who made it.",allow:"Allow",cancel:"Cancel",denied:"Your administrator has not enabled AI app access for your account on this Hub.",failed:"That did not finish. Try again, or start connecting again in your app.",expired:"This connection request has expired. Start connecting again in your app.",retry:"Try again",loading:"Loading…",empty:"No AI apps are connected.",disconnect:"Disconnect",disconnected:"App disconnected.",idle:"A connection ends after 30 days without use. Disconnect takes effect at once.",connectTitle:"Connect your app",connectLead:"Add this remote MCP address in your app. Sign in with the account you use for this Hub and choose what the app may do. Nothing else needs to be installed.",address:"Hub MCP address",copyAddress:"Copy address",copied:"Copied.",copyFailed:"Copy failed. Select and copy the text below.",appChoice:"Your app",claude:"Claude Code",codex:"Codex",generic:"Another MCP app",copyPrompt:"Copy setup prompt",prompt:"Configure {app} to connect to my Hub using the remote HTTP MCP server below. Use the browser sign-in and consent flow. Install no AgEnD package or proxy. Never bypass certificate verification. Do not copy credentials or other personal configuration into this setup.",config:"Remote MCP configuration",adminTitle:"AI apps",adminSwitch:"Let people connect their own AI apps",everyone:"Everyone who can use this Hub",selected:"Only these groups, teams or people",save:"Save",saved:"Saved.",narrowWarning:"Narrowing this ends every existing app connection. People who are still allowed connect again in their app.",remove:"Remove",removeLabel:"Remove {0}",roomSwitch:"Allow AI apps to read and post",rateLimited:"{0}'s AI app was slowed down.",chooseScope:"Choose at least one permission.",dates:"Connected {0} · last used {1}",unknown:"Not yet",invalidReturn:"The app's return address could not be opened. Start connecting again in your app.",signInAgain:"Sign in again to see your apps.",styleFailed:"The page style could not load. Try again."},
|
|
4
|
+
"zh-TW":{returnLabel:"允許之後會回到",localReturn:"這個 App 在這台電腦上執行。",returnWarning:"只有在你是從這個 App 或網站開始時才允許。",manual:"手動設定",promptHint:"貼到 {0},它會幫你加入這個位址。",genericHint:"在你的 App 裡,把上面的位址新增為遠端 MCP 伺服器。",may:"可以:{0}",justNow:"剛剛",title:"我的 AI App",consentHeading:"連接 AI App",consentTitle:"要讓 {0} 以你的身分使用這個 Hub 嗎?",consentLead:"{0} 可以做下面勾選的事。它發的訊息會顯示「{1} 透過 {0}」。",read:"讀你所在的房間",post:"在這些房間發言",ask:"問你可以問的 Agent",inbox:"回答別人問它的問題",later:"之後開放",privacy:"它讀到的內容會交給你的 AI App 與它的服務商。",noAdmin:"它不能更改房間、團隊或設定,也不能做管理員的動作。",unverified:"這個名稱是 App 自己提供的,Hub 無法確認它的來源。",allow:"允許",cancel:"取消",denied:"管理員沒有開放讓你的帳號在這個 Hub 連接 AI App。",failed:"剛才沒有完成。請再試一次,或回到 App 重新開始連接。",expired:"這次連接要求已過期,請回到 App 重新開始連接。",retry:"重試",loading:"載入中…",empty:"尚未連接任何 AI App。",disconnect:"中斷連接",disconnected:"已中斷 App 連接。",idle:"30 天沒有使用,連接就會自動結束。中斷連接會立即生效。",connectTitle:"連接你的 App",connectLead:"在 App 加入這個遠端 MCP 位址,用你登入這個 Hub 的帳號登入,再選擇 App 可以做的事。不用另外安裝程式。",address:"Hub MCP 位址",copyAddress:"複製位址",copied:"已複製。",copyFailed:"複製失敗,請選取下方文字自行複製。",appChoice:"你的 App",claude:"Claude Code",codex:"Codex",generic:"其他 MCP App",copyPrompt:"複製設定提示",prompt:"請把 {app} 設定為透過下方遠端 HTTP MCP 伺服器連接我的 Hub,使用瀏覽器登入與同意流程。不要安裝 AgEnD 套件或其他程式,也不能略過憑證驗證。不要把憑證或其他個人設定複製到這份設定。",config:"遠端 MCP 設定",adminTitle:"AI App",adminSwitch:"允許同仁連接自己的 AI App",everyone:"所有可以使用這個 Hub 的人",selected:"只有這些群組、團隊或人員",save:"儲存",saved:"已儲存。",narrowWarning:"縮小這個範圍會結束所有現有 App 連接。仍可使用的人需要回到 App 重新連接。",remove:"移除",removeLabel:"移除 {0}",roomSwitch:"允許 AI App 讀取及發言",rateLimited:"{0} 的 AI App 被放慢了。",chooseScope:"請至少選一項權限。",dates:"連接於 {0} · 上次使用 {1}",unknown:"尚無",invalidReturn:"無法開啟 App 的返回位址,請回到 App 重新開始連接。",signInAgain:"請重新登入後查看你的 App。",styleFailed:"頁面樣式載入失敗,請再試一次。"}
|
|
5
|
+
});
|
|
6
|
+
export const ha=(key,...args)=>t(`hubApps.${key}`,...args);
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/** Person-owned app connections. All authority remains in the Hub; names are display data. */
|
|
2
|
+
import {html,useEffect,useMemo,useRef,useState} from "/assets/app-html.js";
|
|
3
|
+
import {lang} from "/assets/app-i18n.js";
|
|
4
|
+
import {hubConnectorPrompt} from "/assets/connector-prompt.js";
|
|
5
|
+
import {SubjectPicker,subjectText} from "./hub-subject-picker.js";
|
|
6
|
+
import {ha} from "./hub-ai-apps-strings.js";
|
|
7
|
+
|
|
8
|
+
export const APP_SCOPES=Object.freeze(["rooms:read","rooms:post","agents:ask"]);
|
|
9
|
+
const keys={"rooms:read":"read","rooms:post":"post","agents:ask":"ask"};
|
|
10
|
+
const styles=new WeakMap();
|
|
11
|
+
export function linkHubAppsCss(doc=typeof document==="undefined"?null:document){
|
|
12
|
+
if(!doc?.head)return Promise.resolve(false);if(styles.has(doc))return styles.get(doc);
|
|
13
|
+
const loaded=new Promise(resolve=>{const link=doc.createElement("link");link.setAttribute("rel","stylesheet");link.setAttribute("href","/assets/hub-ai-apps.css");link.setAttribute("data-hub-apps-css","1");
|
|
14
|
+
link.addEventListener("load",()=>resolve(true),{once:true});link.addEventListener("error",()=>{link.remove();styles.delete(doc);resolve(false);},{once:true});doc.head.appendChild(link);});styles.set(doc,loaded);return loaded;
|
|
15
|
+
}
|
|
16
|
+
function useStyle(){const[ready,setReady]=useState(null),[retry,setRetry]=useState(0);useEffect(()=>{let live=true;linkHubAppsCss().then(r=>{if(live)setReady(r);});return()=>{live=false;};},[retry]);return[ready,()=>setRetry(n=>n+1)];}
|
|
17
|
+
function StyleWait({ready,retry}){return html`<p role="status">${ha(ready===false?"styleFailed":"loading")}</p>${ready===false?html`<button class="btn hub-app-button" type="button" onClick=${retry}>${ha("retry")}</button>`:null}`;}
|
|
18
|
+
function useLife(client,key){const epoch=useRef(0),identity=useRef({client,key});if(identity.current.client!==client||identity.current.key!==key){epoch.current++;identity.current={client,key};}
|
|
19
|
+
useEffect(()=>{const off=client.onSignedOut?.(()=>{epoch.current++;});return()=>{epoch.current++;off?.();};},[client,key]);return epoch;}
|
|
20
|
+
function useRead(client,method,arg,scope){
|
|
21
|
+
const[slot,setSlot]=useState(null),[revision,setRevision]=useState(0),epoch=useRef(0),identity=useMemo(()=>({}),[client,method,arg,scope]);
|
|
22
|
+
useEffect(()=>{let live=true;const mine=++epoch.current;setSlot({identity,value:null});Promise.resolve().then(()=>client[method](scope,arg)).then(out=>{if(live&&mine===epoch.current)setSlot({identity,value:out});},()=>{if(live&&mine===epoch.current)setSlot({identity,value:{ok:false}});});
|
|
23
|
+
const off=client.onSignedOut?.(()=>{epoch.current++;setSlot({identity,value:{ok:false,status:401}});});return()=>{live=false;epoch.current++;off?.();};},[identity,revision]);
|
|
24
|
+
return[slot?.identity===identity?slot.value:null,()=>setRevision(n=>n+1)];
|
|
25
|
+
}
|
|
26
|
+
const errorText=r=>ha(r?.status===401?"signInAgain":r?.status===403?"denied":r?.status===400?"expired":"failed");
|
|
27
|
+
function ReadError({value,retry}){return html`<p class="err" role="alert">${errorText(value)}</p><button class="btn hub-app-button" type="button" onClick=${retry}>${ha("retry")}</button>`;}
|
|
28
|
+
export function appReturnUrl(value){try{const u=new URL(value);return !u.username&&!u.password&&!u.hash&&(u.protocol==="https:"||u.protocol==="http:"&&["127.0.0.1","[::1]","localhost"].includes(u.hostname))?u.href:null;}catch{return null;}}
|
|
29
|
+
export function appDestination(origin){try{const u=new URL(origin);if(u.origin!==origin||!appReturnUrl(origin))return null;return u.origin;}catch{return null;}}
|
|
30
|
+
export function AppConsentPage({client,request,person,returnTo=url=>location.assign(url)}){
|
|
31
|
+
const scope=useMemo(()=>client.aiAppsScope?.(),[client]),[view,reload]=useRead(client,"appConsent",request,scope),[scopes,setScopes]=useState([]),[busy,setBusy]=useState(false),[error,setError]=useState(""),life=useLife(client,request),[ready,retry]=useStyle();
|
|
32
|
+
const destination=appDestination(view?.redirectOrigin);
|
|
33
|
+
const offered=JSON.stringify(view?.scopes||[]);useEffect(()=>{setScopes(APP_SCOPES.filter(scope=>view?.scopes?.includes(scope)));setError("");},[request,offered]);
|
|
34
|
+
useEffect(()=>{setBusy(false);setError("");},[request]);
|
|
35
|
+
const finish=async cancel=>{if(busy||!cancel&&(!scopes.length||!destination))return;const mine=life.current;setBusy(true);setError("");let out;try{out=await client.saveAppConsent(scope,request,cancel?{cancel:true}:{scopes});}catch{out={ok:false};}
|
|
36
|
+
if(mine!==life.current)return;setBusy(false);const target=out.ok&&appReturnUrl(out.location);if(target)returnTo(target);else setError(out.ok?ha("invalidReturn"):errorText(out));};
|
|
37
|
+
return html`<div class="s-section-layout hub-ai-apps"><section class="card"><h2>${view?.ok?ha("consentTitle",view.name):ha("consentHeading")}</h2>
|
|
38
|
+
${!ready?html`<${StyleWait} ready=${ready} retry=${retry}/>`:view===null?html`<p role="status">${ha("loading")}</p>`:!view.ok?html`<${ReadError} value=${view} retry=${reload}/>`:html`
|
|
39
|
+
<p>${ha("consentLead",view.name,person||"")}</p><p class="note">${ha("unverified")}</p>
|
|
40
|
+
<div class="hub-app-destination"><strong>${ha(destination?.startsWith("http:")?"localReturn":"returnLabel")}</strong><p>${destination||ha("invalidReturn")}</p><p class="note">${ha("returnWarning")}</p></div>
|
|
41
|
+
${APP_SCOPES.filter(scope=>view.scopes.includes(scope)).map(scope=>html`<label class="check" key=${scope}><input type="checkbox" data-app-scope=${scope} checked=${scopes.includes(scope)} disabled=${busy} onChange=${e=>setScopes(old=>e.target.checked?[...old,scope]:old.filter(x=>x!==scope))}/><span>${ha(keys[scope])}</span></label>`)}
|
|
42
|
+
<label class="check"><input type="checkbox" disabled=${true} checked=${false}/><span>${ha("inbox")} · ${ha("later")}</span></label>
|
|
43
|
+
<p class="note">${ha("noAdmin")}</p><p class="note">${ha("privacy")}</p>${!scopes.length?html`<p class="note">${ha("chooseScope")}</p>`:null}
|
|
44
|
+
<div class="hub-app-actions"><button type="button" class="btn btn-primary hub-app-button" disabled=${busy||!scopes.length||!destination} onClick=${()=>finish(false)}>${ha("allow")}</button><button type="button" class="btn hub-app-button" disabled=${busy} onClick=${()=>finish(true)}>${ha("cancel")}</button></div>`}
|
|
45
|
+
${error?html`<p class="err" role="alert">${error}</p>`:null}</section></div>`;
|
|
46
|
+
}
|
|
47
|
+
function SetupCard({address}){
|
|
48
|
+
const[app,setApp]=useState("claude"),[note,setNote]=useState("");const prompt=hubConnectorPrompt(address,app,ha);
|
|
49
|
+
const copy=async text=>{try{await navigator.clipboard.writeText(text);setNote(ha("copied"));}catch{setNote(ha("copyFailed"));}};
|
|
50
|
+
return html`<section class="card"><h3>${ha("connectTitle")}</h3><p class="note">${ha("connectLead")}</p>
|
|
51
|
+
<label class="field"><span>${ha("address")}</span><input type="url" readonly=${true} value=${address||""}/></label><div class="hub-app-actions"><button type="button" class="btn btn-primary hub-app-button" disabled=${!prompt} onClick=${()=>copy(address)}>${ha("copyAddress")}</button></div>
|
|
52
|
+
<label class="field"><span>${ha("appChoice")}</span><select value=${app} onChange=${e=>setApp(e.target.value)}>${["claude","codex","generic"].map(key=>html`<option value=${key}>${ha(key)}</option>`)}</select></label>
|
|
53
|
+
<p class="note">${app==="generic"?ha("genericHint"):ha("promptHint",ha(app))}</p>
|
|
54
|
+
${app!=="generic"?html`<div class="hub-app-actions"><button type="button" class="btn hub-app-button" disabled=${!prompt} onClick=${()=>copy(prompt)}>${ha("copyPrompt")}</button></div>`:null}<p class="note" role="status">${note}</p>
|
|
55
|
+
<details class="s-ui-disclosure" open=${note===ha("copyFailed")?true:undefined}><summary>${ha("manual")}</summary><div class="s-disclosure-body"><textarea readonly=${true} rows="7" aria-label=${ha("config")} value=${prompt}/></div></details></section>`;
|
|
56
|
+
}
|
|
57
|
+
export function appConnectionDates(connected,lastUsed,now=Date.now()){
|
|
58
|
+
const locale=lang()==="zh-TW"?"zh-TW":"en-GB",at=Number(connected),last=Number(lastUsed);
|
|
59
|
+
const date=Number.isFinite(at)?new Intl.DateTimeFormat(locale,{day:"numeric",month:"short"}).format(at):ha("unknown");
|
|
60
|
+
const seconds=Math.max(0,(now-last)/1000),rtf=new Intl.RelativeTimeFormat(lang()==="zh-TW"?"zh-TW":"en",{numeric:"always"});
|
|
61
|
+
const relative=!Number.isFinite(last)?ha("unknown"):seconds<60?ha("justNow"):seconds<3600?rtf.format(-Math.floor(seconds/60),"minute"):seconds<86400?rtf.format(-Math.floor(seconds/3600),"hour"):rtf.format(-Math.floor(seconds/86400),"day");
|
|
62
|
+
return ha("dates",date,relative);
|
|
63
|
+
}
|
|
64
|
+
export function MyAiAppsPage({client}){
|
|
65
|
+
const scope=useMemo(()=>client.aiAppsScope?.(),[client]),[view,reload]=useRead(client,"aiApps",undefined,scope),[busy,setBusy]=useState(null),[note,setNote]=useState(""),life=useLife(client),[ready,retry]=useStyle();
|
|
66
|
+
const disconnect=async id=>{if(busy)return;const mine=life.current;setBusy(id);let out;try{out=await client.disconnectAiApp(scope,id);}catch{out={ok:false};}if(mine!==life.current)return;setBusy(null);setNote(out.ok?ha("disconnected"):errorText(out));if(out.ok)reload();};
|
|
67
|
+
return html`<div class="s-section-layout hub-ai-apps">${!ready?html`<section class="card"><${StyleWait} ready=${ready} retry=${retry}/></section>`:view===null?html`<section class="card"><p role="status">${ha("loading")}</p></section>`:!view.ok?html`<section class="card"><${ReadError} value=${view} retry=${reload}/></section>`:html`
|
|
68
|
+
${view.available===false?html`<section class="card"><p role="status">${ha("denied")}</p></section>`:null}<${SetupCard} address=${view.address}/>
|
|
69
|
+
<section class="card"><h3>${ha("title")}</h3><p class="note">${ha("idle")}</p>${view.apps?.length?html`<ul class="hub-app-list">${view.apps.map(app=>html`<li class="s-row hub-app-entry" key=${app.id}><div class="hub-app-row"><strong>${app.name}</strong><small class="note">${appConnectionDates(app.connectedAt,app.lastUsedAt)}</small><small>${ha("may",APP_SCOPES.filter(scope=>app.scopes?.includes(scope)).map(scope=>ha(keys[scope])).join(" · "))}</small></div><button type="button" class="btn hub-app-button hub-app-disconnect" disabled=${busy!==null} onClick=${()=>disconnect(app.id)}>${ha("disconnect")}</button></li>`)}</ul>`:html`<p>${ha("empty")}</p>`}<p role="status" class="note">${note}</p></section>`}</div>`;
|
|
70
|
+
}
|
|
71
|
+
export function AiAppsAdminCard({client}){
|
|
72
|
+
const scope=useMemo(()=>client.aiAppsScope?.(),[client]),[view,reload]=useRead(client,"aiAppsSettings",undefined,scope),[draft,setDraft]=useState(null),[busy,setBusy]=useState(false),[note,setNote]=useState(""),life=useLife(client),[ready,retry]=useStyle();
|
|
73
|
+
useEffect(()=>{if(view?.ok)setDraft({revision:view.revision,enabled:view.enabled,everyone:view.everyone,subjects:view.subjects||[]});},[view]);
|
|
74
|
+
const search=useMemo(()=>(kind,q)=>client.searchAiAppSubjects(scope,kind,q),[client,scope]);
|
|
75
|
+
const pick=(kind,row)=>{const id=kind==="person"?`${row.person?.realm}/${row.person?.objectId}`:kind==="team"?row.id:row.objectId,name=row.name||row.displayName||row.cn||row.login;
|
|
76
|
+
setDraft(old=>old.subjects.some(s=>s.kind===kind&&s.id===id)?old:{...old,subjects:[...old.subjects,{kind,id,name}]});};
|
|
77
|
+
const save=async()=>{if(busy||!draft)return;const mine=life.current;setBusy(true);let out;try{out=await client.saveAiAppsSettings(scope,draft);}catch{out={ok:false};}if(mine!==life.current)return;setBusy(false);setNote(out.ok?ha("saved"):errorText(out));if(out.ok)reload();};
|
|
78
|
+
return html`<section class="card hub-ai-apps"><h3>${ha("adminTitle")}</h3>${!ready?html`<${StyleWait} ready=${ready} retry=${retry}/>`:view===null?html`<p role="status">${ha("loading")}</p>`:!view.ok?html`<${ReadError} value=${view} retry=${reload}/>`:draft?html`
|
|
79
|
+
<label class="check"><input class="s-ui-toggle" type="checkbox" role="switch" checked=${draft.enabled} disabled=${busy} onChange=${e=>{const value=e.target.checked;setDraft(old=>({...old,enabled:value}));}}/><span>${ha("adminSwitch")}</span></label>
|
|
80
|
+
${[true,false].map(everyone=>html`<label class="check"><input type="radio" name="hubAppAllowed" checked=${draft.everyone===everyone} disabled=${busy||!draft.enabled} onChange=${()=>setDraft(old=>({...old,everyone}))}/><span>${ha(everyone?"everyone":"selected")}</span></label>`)}
|
|
81
|
+
${!draft.everyone?html`<ul class="hub-app-list">${draft.subjects.map(row=>html`<li class="s-row" key=${`${row.kind}:${row.id}`}><span class="grow">${row.name} · ${subjectText(row.kind)}</span><button type="button" class="btn hub-app-button" disabled=${busy||!draft.enabled} aria-label=${ha("removeLabel",row.name)} onClick=${()=>setDraft({...draft,subjects:draft.subjects.filter(x=>x!==row)})}>${ha("remove")}</button></li>`)}</ul><${SubjectPicker} client=${client} search=${search} disabled=${busy||!draft.enabled} onPick=${pick}/>`:null}
|
|
82
|
+
<p class="note">${ha("narrowWarning")}</p><div class="hub-app-actions"><button type="button" class="btn btn-primary hub-app-button" disabled=${busy} onClick=${save}>${ha("save")}</button></div><p class="note" role="status">${note}</p>`:null}</section>`;
|
|
83
|
+
}
|