@songsid/agend 2.4.0-alpha.3 → 2.4.0-alpha.4
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-cli-instructions.md +8 -4
- package/dist/agent-whats-new.js +7 -7
- package/dist/agent-whats-new.js.map +1 -1
- package/dist/auth-api.js +7 -1
- package/dist/auth-api.js.map +1 -1
- package/dist/backend/claude-code.d.ts +8 -0
- package/dist/backend/claude-code.js +11 -4
- package/dist/backend/claude-code.js.map +1 -1
- package/dist/backend/codex.js +7 -3
- package/dist/backend/codex.js.map +1 -1
- package/dist/backend/grok.d.ts +19 -0
- package/dist/backend/grok.js +112 -1
- package/dist/backend/grok.js.map +1 -1
- package/dist/backend/types.d.ts +10 -0
- package/dist/backend/types.js.map +1 -1
- package/dist/build-provenance.json +1 -1
- package/dist/channel/mcp-tools.js +2 -2
- package/dist/channel/mcp-tools.js.map +1 -1
- package/dist/child-process.d.ts +1 -0
- package/dist/child-process.js.map +1 -1
- package/dist/claude-model-observation.d.ts +71 -0
- package/dist/claude-model-observation.js +169 -0
- package/dist/claude-model-observation.js.map +1 -0
- package/dist/cross-instance-envelope.d.ts +4 -1
- package/dist/cross-instance-envelope.js +12 -7
- package/dist/cross-instance-envelope.js.map +1 -1
- package/dist/daemon.d.ts +24 -2
- package/dist/daemon.js +263 -35
- package/dist/daemon.js.map +1 -1
- package/dist/delivery-consumed-watch.d.ts +24 -0
- package/dist/delivery-consumed-watch.js +21 -10
- package/dist/delivery-consumed-watch.js.map +1 -1
- package/dist/delivery-outbox.d.ts +5 -1
- package/dist/delivery-outbox.js +5 -0
- package/dist/delivery-outbox.js.map +1 -1
- package/dist/fleet-manager.d.ts +11 -1
- package/dist/fleet-manager.js +80 -2
- package/dist/fleet-manager.js.map +1 -1
- package/dist/general-knowledge/skills/concepts/SKILL.md +16 -3
- package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +5 -3
- package/dist/general-knowledge/skills/hub/SKILL.md +161 -4
- package/dist/general-knowledge/skills/multi-channel/SKILL.md +1 -1
- package/dist/general-knowledge/skills/web-dashboard/SKILL.md +18 -7
- package/dist/general-knowledge/skills/worker-collaboration/SKILL.md +1 -1
- package/dist/grok-delivery-proof.d.ts +24 -0
- package/dist/grok-delivery-proof.js +124 -0
- package/dist/grok-delivery-proof.js.map +1 -0
- package/dist/hub/assistant/admin-types.d.ts +43 -0
- package/dist/hub/assistant/admin-types.js +2 -0
- package/dist/hub/assistant/admin-types.js.map +1 -0
- package/dist/hub/assistant/claude-host.d.ts +17 -0
- package/dist/hub/assistant/claude-host.js +300 -0
- package/dist/hub/assistant/claude-host.js.map +1 -0
- package/dist/hub/assistant/context.d.ts +3 -0
- package/dist/hub/assistant/context.js +7 -0
- package/dist/hub/assistant/context.js.map +1 -0
- package/dist/hub/assistant/fleet-host.d.ts +19 -0
- package/dist/hub/assistant/fleet-host.js +28 -0
- package/dist/hub/assistant/fleet-host.js.map +1 -0
- package/dist/hub/assistant/runner.d.ts +64 -0
- package/dist/hub/assistant/runner.js +239 -0
- package/dist/hub/assistant/runner.js.map +1 -0
- package/dist/hub/assistant/service.d.ts +51 -0
- package/dist/hub/assistant/service.js +143 -0
- package/dist/hub/assistant/service.js.map +1 -0
- package/dist/hub/assistant/store.d.ts +3 -0
- package/dist/hub/assistant/store.js +65 -0
- package/dist/hub/assistant/store.js.map +1 -0
- package/dist/hub/assistant/types.d.ts +60 -0
- package/dist/hub/assistant/types.js +2 -0
- package/dist/hub/assistant/types.js.map +1 -0
- package/dist/hub/catalog.js +22 -3
- package/dist/hub/catalog.js.map +1 -1
- package/dist/hub/client.d.ts +10 -0
- package/dist/hub/client.js +48 -8
- package/dist/hub/client.js.map +1 -1
- package/dist/hub/compose/member.d.ts +8 -1
- package/dist/hub/compose/member.js +224 -58
- package/dist/hub/compose/member.js.map +1 -1
- package/dist/hub/compose/server.d.ts +11 -1
- package/dist/hub/compose/server.js +68 -11
- package/dist/hub/compose/server.js.map +1 -1
- package/dist/hub/directory/admission.d.ts +15 -0
- package/dist/hub/directory/admission.js +56 -0
- package/dist/hub/directory/admission.js.map +1 -0
- package/dist/hub/directory/directory.d.ts +1 -1
- package/dist/hub/directory/directory.js +63 -0
- package/dist/hub/directory/directory.js.map +1 -1
- package/dist/hub/directory/types.d.ts +13 -0
- package/dist/hub/directory/types.js.map +1 -1
- package/dist/hub/group-policy/admin-control.d.ts +1 -0
- package/dist/hub/group-policy/admin-control.js +4 -2
- package/dist/hub/group-policy/admin-control.js.map +1 -1
- package/dist/hub/group-policy/admin-facts.d.ts +1 -0
- package/dist/hub/group-policy/admin-facts.js +2 -1
- package/dist/hub/group-policy/admin-facts.js.map +1 -1
- package/dist/hub/group-policy/admin-read.d.ts +1 -0
- package/dist/hub/group-policy/admin-read.js +3 -2
- package/dist/hub/group-policy/admin-read.js.map +1 -1
- package/dist/hub/group-policy/errors.d.ts +9 -0
- package/dist/hub/group-policy/errors.js +13 -0
- package/dist/hub/group-policy/errors.js.map +1 -0
- package/dist/hub/group-policy/store.d.ts +3 -9
- package/dist/hub/group-policy/store.js +5 -29
- package/dist/hub/group-policy/store.js.map +1 -1
- package/dist/hub/http/compose.d.ts +1 -0
- package/dist/hub/http/compose.js +429 -14
- package/dist/hub/http/compose.js.map +1 -1
- package/dist/hub/http/core.d.ts +6 -5
- package/dist/hub/http/core.js +74 -48
- package/dist/hub/http/core.js.map +1 -1
- package/dist/hub/http/deps.d.ts +18 -0
- package/dist/hub/http/schema.js +8 -0
- package/dist/hub/http/schema.js.map +1 -1
- package/dist/hub/init/member-certificate.d.ts +1 -0
- package/dist/hub/init/member-certificate.js +39 -0
- package/dist/hub/init/member-certificate.js.map +1 -0
- package/dist/hub/init/plan-digest.js +1 -0
- package/dist/hub/init/plan-digest.js.map +1 -1
- package/dist/hub/invitations.d.ts +96 -0
- package/dist/hub/invitations.js +292 -0
- package/dist/hub/invitations.js.map +1 -0
- package/dist/hub/join/certificate-trust.d.ts +13 -0
- package/dist/hub/join/certificate-trust.js +41 -0
- package/dist/hub/join/certificate-trust.js.map +1 -0
- package/dist/hub/join/certificate.d.ts +11 -0
- package/dist/hub/join/certificate.js +67 -0
- package/dist/hub/join/certificate.js.map +1 -0
- package/dist/hub/join/client.d.ts +5 -0
- package/dist/hub/join/client.js +30 -3
- package/dist/hub/join/client.js.map +1 -1
- package/dist/hub/join/http.js +5 -3
- package/dist/hub/join/http.js.map +1 -1
- package/dist/hub/join/local.d.ts +32 -1
- package/dist/hub/join/local.js +116 -11
- package/dist/hub/join/local.js.map +1 -1
- package/dist/hub/join/service.d.ts +17 -0
- package/dist/hub/join/service.js +12 -0
- package/dist/hub/join/service.js.map +1 -1
- package/dist/hub/join/trust.d.ts +9 -0
- package/dist/hub/join/trust.js +35 -0
- package/dist/hub/join/trust.js.map +1 -1
- package/dist/hub/member/pairing-api.js +9 -1
- package/dist/hub/member/pairing-api.js.map +1 -1
- package/dist/hub/member/room-ask.d.ts +137 -0
- package/dist/hub/member/room-ask.js +358 -0
- package/dist/hub/member/room-ask.js.map +1 -0
- package/dist/hub/member-journal.d.ts +18 -1
- package/dist/hub/member-journal.js +76 -3
- package/dist/hub/member-journal.js.map +1 -1
- package/dist/hub/member-origin.d.ts +177 -0
- package/dist/hub/member-origin.js +314 -0
- package/dist/hub/member-origin.js.map +1 -0
- package/dist/hub/pairing-notices.d.ts +1 -0
- package/dist/hub/pairing-notices.js +2 -1
- package/dist/hub/pairing-notices.js.map +1 -1
- package/dist/hub/pairing.d.ts +8 -0
- package/dist/hub/pairing.js +32 -5
- package/dist/hub/pairing.js.map +1 -1
- package/dist/hub/protocol.d.ts +159 -0
- package/dist/hub/protocol.js +19 -1
- package/dist/hub/protocol.js.map +1 -1
- package/dist/hub/roles/clock.d.ts +18 -0
- package/dist/hub/roles/clock.js +58 -0
- package/dist/hub/roles/clock.js.map +1 -0
- package/dist/hub/roles/cutover-marker.d.ts +57 -0
- package/dist/hub/roles/cutover-marker.js +26 -0
- package/dist/hub/roles/cutover-marker.js.map +1 -0
- package/dist/hub/roles/cutover.js +3 -17
- package/dist/hub/roles/cutover.js.map +1 -1
- package/dist/hub/roles/read.d.ts +7 -3
- package/dist/hub/roles/read.js +9 -1
- package/dist/hub/roles/read.js.map +1 -1
- package/dist/hub/rooms/admin.d.ts +45 -0
- package/dist/hub/rooms/admin.js +105 -0
- package/dist/hub/rooms/admin.js.map +1 -0
- package/dist/hub/rooms/agents.d.ts +74 -0
- package/dist/hub/rooms/agents.js +333 -0
- package/dist/hub/rooms/agents.js.map +1 -0
- package/dist/hub/rooms/assistant.d.ts +44 -0
- package/dist/hub/rooms/assistant.js +179 -0
- package/dist/hub/rooms/assistant.js.map +1 -0
- package/dist/hub/rooms/context.d.ts +10 -0
- package/dist/hub/rooms/context.js +24 -0
- package/dist/hub/rooms/context.js.map +1 -0
- package/dist/hub/rooms/direct-view.d.ts +39 -0
- package/dist/hub/rooms/direct-view.js +38 -0
- package/dist/hub/rooms/direct-view.js.map +1 -0
- package/dist/hub/rooms/directory.d.ts +35 -0
- package/dist/hub/rooms/directory.js +98 -0
- package/dist/hub/rooms/directory.js.map +1 -0
- package/dist/hub/rooms/schema.d.ts +11 -0
- package/dist/hub/rooms/schema.js +73 -0
- package/dist/hub/rooms/schema.js.map +1 -0
- package/dist/hub/rooms/service.d.ts +449 -0
- package/dist/hub/rooms/service.js +581 -0
- package/dist/hub/rooms/service.js.map +1 -0
- package/dist/hub/rooms/types.d.ts +79 -0
- package/dist/hub/rooms/types.js +2 -0
- package/dist/hub/rooms/types.js.map +1 -0
- package/dist/hub/rooms.d.ts +7 -1
- package/dist/hub/rooms.js +30 -5
- package/dist/hub/rooms.js.map +1 -1
- package/dist/hub/runtime.d.ts +8 -0
- package/dist/hub/runtime.js +57 -3
- package/dist/hub/runtime.js.map +1 -1
- package/dist/hub/server.d.ts +25 -0
- package/dist/hub/server.js +63 -5
- package/dist/hub/server.js.map +1 -1
- package/dist/hub/sessions.js +1 -1
- package/dist/hub/sessions.js.map +1 -1
- package/dist/hub/settings-commit.d.ts +6 -1
- package/dist/hub/settings-commit.js +15 -0
- package/dist/hub/settings-commit.js.map +1 -1
- package/dist/hub/settings-directory-recovery.d.ts +5 -0
- package/dist/hub/settings-directory-recovery.js +11 -1
- package/dist/hub/settings-directory-recovery.js.map +1 -1
- package/dist/hub/settings-member-address-control.d.ts +84 -0
- package/dist/hub/settings-member-address-control.js +150 -0
- package/dist/hub/settings-member-address-control.js.map +1 -0
- package/dist/hub/settings-member-address-decision.d.ts +229 -0
- package/dist/hub/settings-member-address-decision.js +318 -0
- package/dist/hub/settings-member-address-decision.js.map +1 -0
- package/dist/hub/settings-member-address-http.d.ts +9 -0
- package/dist/hub/settings-member-address-http.js +78 -0
- package/dist/hub/settings-member-address-http.js.map +1 -0
- package/dist/hub/settings-member-address-network.d.ts +2 -0
- package/dist/hub/settings-member-address-network.js +22 -0
- package/dist/hub/settings-member-address-network.js.map +1 -0
- package/dist/hub/settings-member-address-notices.d.ts +22 -0
- package/dist/hub/settings-member-address-notices.js +21 -0
- package/dist/hub/settings-member-address-notices.js.map +1 -0
- package/dist/hub/settings-member-address-policy.d.ts +21 -0
- package/dist/hub/settings-member-address-policy.js +34 -0
- package/dist/hub/settings-member-address-policy.js.map +1 -0
- package/dist/hub/settings-member-address.d.ts +64 -0
- package/dist/hub/settings-member-address.js +239 -0
- package/dist/hub/settings-member-address.js.map +1 -0
- package/dist/hub/socket.d.ts +2 -0
- package/dist/hub/socket.js +2 -0
- package/dist/hub/socket.js.map +1 -1
- package/dist/hub/teams/types.d.ts +41 -0
- package/dist/hub/teams/types.js +2 -0
- package/dist/hub/teams/types.js.map +1 -0
- package/dist/hub/tls.d.ts +47 -0
- package/dist/hub/tls.js +23 -6
- package/dist/hub/tls.js.map +1 -1
- package/dist/hub/types.d.ts +51 -3
- package/dist/hub/validation.d.ts +1 -1
- package/dist/hub/validation.js +2 -2
- package/dist/hub/validation.js.map +1 -1
- package/dist/hub/web-origin.d.ts +20 -7
- package/dist/hub/web-origin.js +26 -15
- package/dist/hub/web-origin.js.map +1 -1
- package/dist/hub-pilot-trust-settings.d.ts +4 -0
- package/dist/hub-pilot-trust-settings.js +13 -0
- package/dist/hub-pilot-trust-settings.js.map +1 -0
- package/dist/human-delivery-receipts.d.ts +4 -2
- package/dist/human-delivery-receipts.js +20 -13
- package/dist/human-delivery-receipts.js.map +1 -1
- package/dist/inbound-presentation.d.ts +28 -0
- package/dist/inbound-presentation.js +48 -0
- package/dist/inbound-presentation.js.map +1 -0
- package/dist/instance-lifecycle.js +1 -0
- package/dist/instance-lifecycle.js.map +1 -1
- package/dist/instructions.d.ts +4 -2
- package/dist/instructions.js +7 -4
- package/dist/instructions.js.map +1 -1
- package/dist/locale.js +14 -0
- package/dist/locale.js.map +1 -1
- package/dist/log-service.d.ts +3 -0
- package/dist/log-service.js +39 -22
- package/dist/log-service.js.map +1 -1
- package/dist/log-steps.d.ts +56 -1
- package/dist/log-steps.js +318 -56
- package/dist/log-steps.js.map +1 -1
- package/dist/needs-you-hub.js +6 -2
- package/dist/needs-you-hub.js.map +1 -1
- package/dist/needs-you.d.ts +5 -1
- package/dist/needs-you.js +4 -8
- package/dist/needs-you.js.map +1 -1
- package/dist/office-share-page.js +1 -1
- package/dist/office-share-page.js.map +1 -1
- package/dist/outbound-handlers.d.ts +1 -0
- package/dist/outbound-handlers.js +6 -0
- package/dist/outbound-handlers.js.map +1 -1
- package/dist/outbound-schemas.d.ts +1 -0
- package/dist/outbound-schemas.js +1 -0
- package/dist/outbound-schemas.js.map +1 -1
- package/dist/queued-handoffs.d.ts +3 -1
- package/dist/queued-handoffs.js +1 -1
- package/dist/queued-handoffs.js.map +1 -1
- package/dist/runtime-transcript-source.d.ts +2 -0
- package/dist/runtime-transcript-source.js +23 -1
- package/dist/runtime-transcript-source.js.map +1 -1
- package/dist/settings-api.d.ts +1 -0
- package/dist/settings-api.js +15 -8
- package/dist/settings-api.js.map +1 -1
- package/dist/settings-baseline.d.ts +3 -0
- package/dist/settings-baseline.js +2 -2
- package/dist/settings-baseline.js.map +1 -1
- package/dist/settings-effect.d.ts +3 -0
- package/dist/settings-effect.js +12 -2
- package/dist/settings-effect.js.map +1 -1
- package/dist/topic-commands.js +2 -1
- package/dist/topic-commands.js.map +1 -1
- package/dist/transcript-jsonl.d.ts +24 -0
- package/dist/transcript-jsonl.js +72 -22
- package/dist/transcript-jsonl.js.map +1 -1
- package/dist/transcript-monitor.d.ts +5 -1
- package/dist/transcript-monitor.js +65 -3
- package/dist/transcript-monitor.js.map +1 -1
- package/dist/transcript-needles.d.ts +1 -1
- package/dist/transcript-needles.js +1 -1
- package/dist/transcript-records.d.ts +2 -1
- package/dist/transcript-records.js.map +1 -1
- package/dist/transcript-sources.d.ts +4 -0
- package/dist/transcript-sources.js +2 -0
- package/dist/transcript-sources.js.map +1 -1
- package/dist/ui/agent-details-settings.js +10 -1
- package/dist/ui/chat-activity.js +2 -2
- package/dist/ui/fleet-canvas.js +5 -2
- package/dist/ui/fleet-office-card.js +4 -2
- package/dist/ui/fleet-org.js +2 -0
- package/dist/ui/hub-admin-rooms-strings.js +28 -0
- package/dist/ui/hub-admin-rooms.js +77 -0
- package/dist/ui/hub-assistant-admin-strings.js +26 -0
- package/dist/ui/hub-assistant-admin.js +85 -0
- package/dist/ui/hub-client.js +170 -14
- package/dist/ui/hub-invitations-strings.js +30 -0
- package/dist/ui/hub-invitations.js +108 -0
- package/dist/ui/hub-join-one-strings.js +2 -0
- package/dist/ui/hub-pairing-form-strings.js +48 -0
- package/dist/ui/hub-pilot-trust-strings.js +27 -0
- package/dist/ui/hub-pilot-trust.js +41 -0
- package/dist/ui/hub-room-composer.js +113 -0
- package/dist/ui/hub-room-favorites.js +90 -0
- package/dist/ui/hub-room-list.js +152 -0
- package/dist/ui/hub-room-members-strings.js +12 -0
- package/dist/ui/hub-room-members.js +104 -0
- package/dist/ui/hub-room-new-strings.js +46 -0
- package/dist/ui/hub-room-new.js +135 -0
- package/dist/ui/hub-room-presence.js +123 -0
- package/dist/ui/hub-room-settings-strings.js +26 -0
- package/dist/ui/hub-room-settings.js +134 -0
- package/dist/ui/hub-room-strings.js +222 -0
- package/dist/ui/hub-room-thread.js +262 -0
- package/dist/ui/hub-room-unread.js +51 -0
- package/dist/ui/hub-room-working.js +29 -0
- package/dist/ui/log-row.js +14 -5
- package/dist/ui/panel-details.js +6 -1
- package/dist/ui/panel-hub.js +91 -49
- package/dist/ui/panel-needs.js +2 -0
- package/dist/ui/settings-hub-company-join.js +31 -11
- package/dist/ui/settings-hub-connection.js +9 -3
- package/dist/ui/settings-hub-member-address.js +205 -0
- package/dist/ui/settings-hub-section.js +2 -0
- package/dist/ui/settings-hub.js +10 -4
- package/dist/ui/shared/app-i18n.js +2 -2
- package/dist/ui/shared/app-needs.js +3 -0
- package/dist/ui/shared/app-shell.js +4 -1
- package/dist/ui/shared/app.css +5 -0
- package/dist/ui/shared/chat-render.js +10 -0
- package/dist/ui/shared/chat-thread.js +14 -5
- package/dist/ui/shared/hub-chat.css +17 -0
- package/dist/ui/shared/hub-rooms-u2.css +42 -0
- package/dist/ui/shared/model-observation.js +16 -0
- package/dist/ui/shared/stale-tab.css +6 -0
- package/dist/ui/shared/stale-tab.js +50 -0
- package/dist/web-api.d.ts +2 -0
- package/dist/web-api.js +6 -2
- package/dist/web-api.js.map +1 -1
- package/package.json +1 -1
package/dist/hub/http/compose.js
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* - `receive(frame, link)` is S1's HubServer callback for an authenticated member link.
|
|
14
14
|
* - `close()` forgets the links. S5 closes the DB.
|
|
15
15
|
*/
|
|
16
|
+
import { HubGroupPolicyError } from "../group-policy/errors.js";
|
|
16
17
|
import { GROUP_POLICY_FEATURE, handleGroupHttp } from "../group-policy/admin-api.js";
|
|
17
18
|
import { handleHubDirectorySettingsHttp, HUB_DIRECTORY_SETTINGS_FEATURE, HUB_DIRECTORY_CA_FEATURE, HUB_DIRECTORY_EDITOR_FEATURE } from "../settings-directory-http.js";
|
|
18
19
|
import { handleHubSettingsHttp } from "../settings-api.js";
|
|
@@ -27,6 +28,9 @@ import { HubCatalogService } from "../catalog.js";
|
|
|
27
28
|
import { HubGrantSearch } from "../grant-search.js";
|
|
28
29
|
import { HubPolicyService } from "../policy.js";
|
|
29
30
|
import { HubRoomsService } from "../rooms.js";
|
|
31
|
+
import { HubRoomAdmin } from "../rooms/admin.js";
|
|
32
|
+
import { HubGroupRooms, HubRoomRefusal } from "../rooms/service.js";
|
|
33
|
+
import { directMessages, directRoomView, directUnread, markDirectRead } from "../rooms/direct-view.js";
|
|
30
34
|
import { HubAttachmentRefused } from "../attachments/store.js";
|
|
31
35
|
import { HubQuotaService } from "../quota.js";
|
|
32
36
|
import { HubCore, pairingOwnerByLogin } from "./core.js";
|
|
@@ -36,6 +40,7 @@ import { serveHubWorkspaceShell } from "../../web-api.js";
|
|
|
36
40
|
import { servePublicAsset } from "../../auth-api.js";
|
|
37
41
|
import { handleCompanyJoin, companyFlowCookie } from "../join/http.js";
|
|
38
42
|
import { CompanyJoinCodeRefusal, CompanyJoinLimit, CompanyJoinOfferPending } from "../join/service.js";
|
|
43
|
+
import { HubMemberAddressError } from "../settings-member-address-policy.js";
|
|
39
44
|
export { HUB_HTTP_MIGRATIONS };
|
|
40
45
|
/** S5's lazy entry (HubHttpEntry): this module itself — `createHubHttp` and `migrations`. */
|
|
41
46
|
export const migrations = HUB_HTTP_MIGRATIONS;
|
|
@@ -46,7 +51,20 @@ export const HUB_UI_MODULES = Object.freeze(["panel-hub.js", "hub-client.js", "h
|
|
|
46
51
|
// Hub UX U2 (M-2932): the group-search picker (its own words inside), shared with B2's join-code scope.
|
|
47
52
|
"hub-group-search.js", "hub-join-steps.js", "hub-grant-picker.js",
|
|
48
53
|
// B2: code management and the same-request Hub approval queue.
|
|
49
|
-
"hub-enrolment-code.js", "hub-enrolment-code-strings.js", "hub-join-queue.js", "hub-join-approval.js", "hub-joincode-flow-strings.js"
|
|
54
|
+
"hub-enrolment-code.js", "hub-enrolment-code-strings.js", "hub-join-queue.js", "hub-join-approval.js", "hub-joincode-flow-strings.js",
|
|
55
|
+
// Hub rooms (hub-rooms-ux.md §§2,5): the rooms words (#3850) then the presence helper (pure, no DOM).
|
|
56
|
+
"hub-room-strings.js", "hub-room-presence.js",
|
|
57
|
+
// Hub rooms §12: unread counts and the Fleet desktop-notify rule (lazy; screens load it).
|
|
58
|
+
"hub-room-unread.js",
|
|
59
|
+
// Hub rooms, track U2 (dev-claude2; hub-rooms-split.md section 3): new room, room settings, members rail, invitations,
|
|
60
|
+
// 管理 → 房間.
|
|
61
|
+
"hub-room-new.js", "hub-room-new-strings.js", "hub-room-settings.js", "hub-room-settings-strings.js", "hub-room-members.js", "hub-room-members-strings.js", "hub-invitations.js", "hub-invitations-strings.js", "hub-admin-rooms.js", "hub-admin-rooms-strings.js",
|
|
62
|
+
// M-3092 (Hub rooms, track U): the conversation list, a room on the shared thread, its composer.
|
|
63
|
+
"hub-room-list.js", "hub-room-thread.js", "hub-room-composer.js", "hub-assistant-admin.js", "hub-assistant-admin-strings.js",
|
|
64
|
+
// M-3092 S-145: the list's favourites (the Fleet sidebar's #1664 rules; per browser until a Hub-side store).
|
|
65
|
+
"hub-room-favorites.js",
|
|
66
|
+
// S-148: the working bar's words (#3857), shared by the room thread.
|
|
67
|
+
"hub-room-working.js"]);
|
|
50
68
|
const BODY_LIMIT = 96 * 1024;
|
|
51
69
|
const UPLOADS_PER_SESSION = 2, UPLOADS_TOTAL = 8;
|
|
52
70
|
const UUID = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;
|
|
@@ -143,6 +161,9 @@ export function createHubHttp(deps, sql) {
|
|
|
143
161
|
const sessions = new HubSessions(core), catalog = new HubCatalogService(core), policy = new HubPolicyService(core);
|
|
144
162
|
const grantSearch = new HubGrantSearch(core);
|
|
145
163
|
const rooms = new HubRoomsService(core, policy);
|
|
164
|
+
const groupRooms = new HubGroupRooms(core);
|
|
165
|
+
const invitations = deps.roomInvitations?.(core, groupRooms.invitationHost());
|
|
166
|
+
const roomAdmin = new HubRoomAdmin(core, event => groupRooms.publish(event), id => { groupRooms.assistant.forget(id); groupRooms.agents.sweep(id); });
|
|
146
167
|
const quota = new HubQuotaService(core);
|
|
147
168
|
const uiDir = join(dirname(fileURLToPath(import.meta.url)), "..", "..", "ui");
|
|
148
169
|
const live = () => !closed && core.live();
|
|
@@ -181,8 +202,8 @@ export function createHubHttp(deps, sql) {
|
|
|
181
202
|
};
|
|
182
203
|
const m = (re) => re.exec(path);
|
|
183
204
|
// Composed routes, not enrollment authority or the administrator's on/off switch. Older Hubs omit unsupported cards.
|
|
184
|
-
const offered = [...(deps.refreshAuthorization ? ["sharing-pause-v1"] : []), ...(deps.groupHttp ? [GROUP_POLICY_FEATURE, ...(deps.pairingNotices ? ["quick-pairing-v1"] : [])] : []), ...(grantSubjectsOffered() ? ["grant-subjects-v1"] : []),
|
|
185
|
-
...(deps.companyJoin ? ["company-join-v1", "enrolment-code-v1"] : []), ...(deps.directoryNotices ? ["directory-security-notices-v1"] : []),
|
|
205
|
+
const offered = ["rooms-v1", ...(deps.roomAssistant && deps.assistantAdmin ? ["room-assistant-v1"] : []), ...(deps.refreshAuthorization ? ["sharing-pause-v1"] : []), ...(deps.groupHttp ? [GROUP_POLICY_FEATURE, ...(deps.pairingNotices ? ["quick-pairing-v1"] : [])] : []), ...(grantSubjectsOffered() ? ["grant-subjects-v1"] : []),
|
|
206
|
+
...(deps.companyJoin ? ["company-join-v1", "enrolment-code-v1"] : []), ...(deps.directoryNotices ? ["directory-security-notices-v1"] : []), ...(deps.memberAddressNotices ? ["member-address-notices-v1"] : []),
|
|
186
207
|
...(deps.directorySettings ? [HUB_DIRECTORY_SETTINGS_FEATURE, HUB_DIRECTORY_CA_FEATURE, HUB_DIRECTORY_EDITOR_FEATURE] : [])];
|
|
187
208
|
const features = offered.length ? { features: offered } : {};
|
|
188
209
|
let r;
|
|
@@ -260,6 +281,34 @@ export function createHubHttp(deps, sql) {
|
|
|
260
281
|
}
|
|
261
282
|
throw new HttpError(405, "method");
|
|
262
283
|
}
|
|
284
|
+
if (deps.memberAddressNotices) {
|
|
285
|
+
const notices = deps.memberAddressNotices;
|
|
286
|
+
if (path === "/hub/v1/security-notices/member-address") {
|
|
287
|
+
if (method !== "GET")
|
|
288
|
+
throw new HttpError(405, "method");
|
|
289
|
+
signedIn();
|
|
290
|
+
if ([...query.keys()].some(k => k !== "before") || query.getAll("before").length > 1
|
|
291
|
+
|| query.has("before") && !/^[1-9][0-9]{0,15}$/.test(query.get("before")))
|
|
292
|
+
throw new HubProtocolError("invalid");
|
|
293
|
+
const page = await guard(() => notices.forSession(ctx, query.has("before") ? Number(query.get("before")) : undefined));
|
|
294
|
+
if (!live())
|
|
295
|
+
throw new HubProtocolError("unavailable");
|
|
296
|
+
signedIn();
|
|
297
|
+
return send(res, 200, page);
|
|
298
|
+
}
|
|
299
|
+
if ((r = m(/^\/hub\/v1\/security-notices\/member-address\/([^/]+)\/ack$/))) {
|
|
300
|
+
if (method !== "POST")
|
|
301
|
+
throw new HttpError(405, "method");
|
|
302
|
+
if ([...query.keys()].length)
|
|
303
|
+
throw new HubProtocolError("invalid");
|
|
304
|
+
csrf();
|
|
305
|
+
await guard(() => notices.acknowledgeSession(ctx, uuid(r[1])));
|
|
306
|
+
if (!live())
|
|
307
|
+
throw new HubProtocolError("unavailable");
|
|
308
|
+
signedIn();
|
|
309
|
+
return send(res, 200, { ok: true });
|
|
310
|
+
}
|
|
311
|
+
}
|
|
263
312
|
if (deps.directoryNotices) {
|
|
264
313
|
const notices = deps.directoryNotices;
|
|
265
314
|
if (path === "/hub/v1/security-notices/directory") {
|
|
@@ -431,12 +480,19 @@ export function createHubHttp(deps, sql) {
|
|
|
431
480
|
signedIn();
|
|
432
481
|
return send(res, 200, { activity: await guard(() => rooms.activity(ctx, uuid(r[1]))) });
|
|
433
482
|
}
|
|
483
|
+
if ((r = m(/^\/hub\/v1\/exposures\/([^/]+)\/rooms$/))) {
|
|
484
|
+
if (method !== "GET")
|
|
485
|
+
throw new HttpError(405, "method");
|
|
486
|
+
signedIn();
|
|
487
|
+
return send(res, 200, { rooms: await guard(() => groupRooms.roomsForExposure(ctx, uuid(r[1]))) });
|
|
488
|
+
}
|
|
434
489
|
if ((r = m(/^\/hub\/v1\/exposures\/([^/]+)\/sharing$/))) {
|
|
435
490
|
if (method !== "POST")
|
|
436
491
|
throw new HttpError(405, "method");
|
|
437
492
|
csrf();
|
|
438
493
|
const b = await body();
|
|
439
494
|
await guard(() => sharing.change(ctx, uuid(r[1]), b));
|
|
495
|
+
groupRooms.agents.publicationChanged(undefined, uuid(r[1]));
|
|
440
496
|
return send(res, 200, { ok: true });
|
|
441
497
|
}
|
|
442
498
|
if ((r = m(/^\/hub\/v1\/exposures\/([^/]+)\/freeze$/))) {
|
|
@@ -458,20 +514,309 @@ export function createHubHttp(deps, sql) {
|
|
|
458
514
|
await guard(() => quota.setVisible(ctx, exposureId, int(b.revision), b.visible));
|
|
459
515
|
return send(res, 200, { quotaVisible: b.visible, ...quota.projection(exposureId) });
|
|
460
516
|
}
|
|
517
|
+
if (path === "/hub/v1/admin/assistant" || path === "/hub/v1/admin/assistant/usage" || /^\/hub\/v1\/admin\/assistant\/rooms\/[^/]+\/stop$/.test(path)) {
|
|
518
|
+
const port = deps.roomAssistant && deps.assistantAdmin;
|
|
519
|
+
if (!port)
|
|
520
|
+
throw new HttpError(404, "not-found");
|
|
521
|
+
if (mutation)
|
|
522
|
+
csrf();
|
|
523
|
+
else
|
|
524
|
+
signedIn();
|
|
525
|
+
const permit = await guard(() => core.management(ctx, "hub.admin"));
|
|
526
|
+
const call = async (work) => {
|
|
527
|
+
permit.assertCurrent();
|
|
528
|
+
let result;
|
|
529
|
+
try {
|
|
530
|
+
result = await work();
|
|
531
|
+
}
|
|
532
|
+
catch {
|
|
533
|
+
permit.assertCurrent();
|
|
534
|
+
throw new HttpError(503, "unavailable");
|
|
535
|
+
}
|
|
536
|
+
permit.assertCurrent();
|
|
537
|
+
return result;
|
|
538
|
+
};
|
|
539
|
+
if (path === "/hub/v1/admin/assistant") {
|
|
540
|
+
if (method === "GET")
|
|
541
|
+
return send(res, 200, await guard(() => call(() => port.settings())));
|
|
542
|
+
if (method === "PUT") {
|
|
543
|
+
const b = await body();
|
|
544
|
+
return send(res, 200, await guard(() => call(() => port.configure(b))));
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
else if (path.endsWith("/usage") && method === "GET")
|
|
548
|
+
return send(res, 200, await guard(() => call(() => port.usage())));
|
|
549
|
+
else if (method === "POST") {
|
|
550
|
+
const id = uuid(path.split("/")[6]);
|
|
551
|
+
await guard(() => call(() => { groupRooms.assistant.cancel(id); return port.stopRoom(id); }));
|
|
552
|
+
return send(res, 200, { ok: true });
|
|
553
|
+
}
|
|
554
|
+
throw new HttpError(405, "method");
|
|
555
|
+
}
|
|
556
|
+
if (path === "/hub/v1/admin/rooms/creators") {
|
|
557
|
+
if (method === "GET") {
|
|
558
|
+
signedIn();
|
|
559
|
+
return send(res, 200, await guard(() => roomAdmin.creators(ctx)));
|
|
560
|
+
}
|
|
561
|
+
if (method === "PUT") {
|
|
562
|
+
csrf();
|
|
563
|
+
const b = await body();
|
|
564
|
+
return send(res, 200, await guard(() => roomAdmin.creators(ctx, b)));
|
|
565
|
+
}
|
|
566
|
+
throw new HttpError(405, "method");
|
|
567
|
+
}
|
|
568
|
+
if (path === "/hub/v1/admin/rooms") {
|
|
569
|
+
if (method !== "GET")
|
|
570
|
+
throw new HttpError(405, "method");
|
|
571
|
+
signedIn();
|
|
572
|
+
return send(res, 200, await guard(() => roomAdmin.list(ctx)));
|
|
573
|
+
}
|
|
574
|
+
if ((r = m(/^\/hub\/v1\/admin\/rooms\/([^/]+)(?:\/(join))?$/))) {
|
|
575
|
+
const roomId = uuid(r[1]);
|
|
576
|
+
csrf();
|
|
577
|
+
if (r[2] === "join" && method === "POST")
|
|
578
|
+
return send(res, 200, await guard(() => roomAdmin.join(ctx, roomId)));
|
|
579
|
+
if (!r[2] && method === "PATCH") {
|
|
580
|
+
const b = await body();
|
|
581
|
+
return send(res, 200, await guard(() => roomAdmin.archive(ctx, roomId, b)));
|
|
582
|
+
}
|
|
583
|
+
throw new HttpError(405, "method");
|
|
584
|
+
}
|
|
585
|
+
if (path === "/hub/v1/rooms/candidates") {
|
|
586
|
+
if (method !== "GET")
|
|
587
|
+
throw new HttpError(405, "method");
|
|
588
|
+
signedIn();
|
|
589
|
+
return send(res, 200, { candidates: await guard(() => groupRooms.candidates(ctx, query.get("q") ?? "", query.get("kind") ?? "person")) });
|
|
590
|
+
}
|
|
591
|
+
if ((r = m(/^\/hub\/v1\/rooms\/candidates\/group\/([^/]+)$/))) {
|
|
592
|
+
if (method !== "GET")
|
|
593
|
+
throw new HttpError(405, "method");
|
|
594
|
+
signedIn();
|
|
595
|
+
return send(res, 200, await guard(() => groupRooms.groupCandidate(ctx, uuid(r[1]))));
|
|
596
|
+
}
|
|
597
|
+
if (path === "/hub/v1/invitations") {
|
|
598
|
+
if (!invitations)
|
|
599
|
+
throw new HttpError(404, "not-found");
|
|
600
|
+
if (method !== "GET")
|
|
601
|
+
throw new HttpError(405, "method");
|
|
602
|
+
signedIn();
|
|
603
|
+
return send(res, 200, await guard(() => invitations.pending(ctx)));
|
|
604
|
+
}
|
|
605
|
+
if ((r = m(/^\/hub\/v1\/invitations\/([^/]+)\/(accept|decline)$/))) {
|
|
606
|
+
if (!invitations)
|
|
607
|
+
throw new HttpError(404, "not-found");
|
|
608
|
+
if (method !== "POST")
|
|
609
|
+
throw new HttpError(405, "method");
|
|
610
|
+
csrf();
|
|
611
|
+
const id = uuid(r[1]);
|
|
612
|
+
return send(res, 200, await guard(() => r[2] === "accept" ? invitations.accept(ctx, id) : invitations.decline(ctx, id)));
|
|
613
|
+
}
|
|
614
|
+
if ((r = m(/^\/hub\/v1\/rooms\/([^/]+)\/invitations(?:\/([^/]+))?$/))) {
|
|
615
|
+
if (!invitations)
|
|
616
|
+
throw new HttpError(404, "not-found");
|
|
617
|
+
csrf();
|
|
618
|
+
const id = uuid(r[1]);
|
|
619
|
+
if (method === "DELETE" && r[2])
|
|
620
|
+
return send(res, 200, await guard(() => invitations.cancel(ctx, id, uuid(r[2]))));
|
|
621
|
+
if (method === "POST" && !r[2]) {
|
|
622
|
+
const b = await body();
|
|
623
|
+
if (Object.keys(b).length !== 1 || !(Array.isArray(b.agents) || typeof b.team === "string"))
|
|
624
|
+
throw new HubProtocolError("invalid");
|
|
625
|
+
const input = Array.isArray(b.agents) ? { agents: b.agents.map(value => uuid(value)) } : { team: uuid(b.team) };
|
|
626
|
+
if (input.agents && input.agents.length > 64)
|
|
627
|
+
throw new HubProtocolError("invalid");
|
|
628
|
+
return send(res, 200, await guard(() => invitations.invite(ctx, id, input)));
|
|
629
|
+
}
|
|
630
|
+
throw new HttpError(405, "method");
|
|
631
|
+
}
|
|
632
|
+
if (path === "/hub/v1/rooms/events") {
|
|
633
|
+
if (method !== "GET")
|
|
634
|
+
throw new HttpError(405, "method");
|
|
635
|
+
const streamSession = signedIn(), streamPerson = personKeyString(await guard(() => ctx.requirePerson()));
|
|
636
|
+
const requestedNotices = query.get("notices"), notices = deps.pairingNotices;
|
|
637
|
+
const noticeVersion = requestedNotices === "3" && deps.companyJoin ? 3 : requestedNotices === "2" || requestedNotices === "3" ? 2 : null;
|
|
638
|
+
const initialNotices = notices && noticeVersion ? await guard(() => notices.forSession(ctx, noticeVersion)) : null;
|
|
639
|
+
if (streams.size >= 64 || !ctx.isCurrent?.())
|
|
640
|
+
throw new HubProtocolError("backpressure");
|
|
641
|
+
res.writeHead(200, { ...API_HEADERS, "Content-Type": "text/event-stream; charset=utf-8", Connection: "keep-alive", "X-Accel-Buffering": "no" });
|
|
642
|
+
let ended = false, queued = 0, tail = Promise.resolve(), noticesRunning = false, noticesDirty = false;
|
|
643
|
+
let offNotices = () => { };
|
|
644
|
+
const close = () => { if (ended)
|
|
645
|
+
return; ended = true; off(); offNotices(); clearInterval(heartbeat); streams.delete(close); res.end(); };
|
|
646
|
+
const off = groupRooms.subscribe(event => {
|
|
647
|
+
if (ended)
|
|
648
|
+
return;
|
|
649
|
+
if (event.audiencePerson && event.audiencePerson !== streamPerson)
|
|
650
|
+
return;
|
|
651
|
+
if (!event.audiencePerson && !groupRooms.interested(streamPerson, event))
|
|
652
|
+
return;
|
|
653
|
+
if (++queued > 64) {
|
|
654
|
+
close();
|
|
655
|
+
return;
|
|
656
|
+
}
|
|
657
|
+
tail = tail.then(async () => {
|
|
658
|
+
if (ended)
|
|
659
|
+
return;
|
|
660
|
+
let data;
|
|
661
|
+
// Concurrent agent checks can briefly fill the person's physical read slots. Keep this event in the bounded
|
|
662
|
+
// queue and re-read it after a short delay; persistent overload and all other failures still close the stream.
|
|
663
|
+
for (let attempt = 0;; attempt++) {
|
|
664
|
+
try {
|
|
665
|
+
if (event.audiencePerson) {
|
|
666
|
+
if (event.type === "invitation.changed") {
|
|
667
|
+
data = personKeyString(await ctx.requirePerson()) === event.audiencePerson ? {} : null;
|
|
668
|
+
}
|
|
669
|
+
else {
|
|
670
|
+
const view = await rooms.view(ctx, event.roomId);
|
|
671
|
+
if (event.type === "unread.changed")
|
|
672
|
+
data = { roomId: event.roomId, unread: directUnread(core, view) };
|
|
673
|
+
else if (event.type === "room.changed")
|
|
674
|
+
data = { roomId: event.roomId, room: directRoomView(view, rooms.presence(view.exposureId), directUnread(core, view)) };
|
|
675
|
+
else {
|
|
676
|
+
const page = await rooms.readPage(ctx, event.roomId, 0, streamSession.sessionId, { before: null, limit: 100 });
|
|
677
|
+
const message = directMessages(page.room, page.entries, streamSession.displayName).find(m => m.id === event.data.messageId);
|
|
678
|
+
data = message ? { roomId: event.roomId, message } : null;
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
else
|
|
683
|
+
data = await groupRooms.event(ctx, event);
|
|
684
|
+
break;
|
|
685
|
+
}
|
|
686
|
+
catch (error) {
|
|
687
|
+
if (!(error instanceof HubProtocolError) || error.code !== "backpressure" || attempt >= 3)
|
|
688
|
+
throw error;
|
|
689
|
+
await new Promise(resolve => setTimeout(resolve, 25 * 2 ** attempt));
|
|
690
|
+
if (ended || !live() || !ctx.isCurrent?.())
|
|
691
|
+
return close();
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
if (ended || !live() || !ctx.isCurrent?.())
|
|
695
|
+
return close();
|
|
696
|
+
if (data && !res.write(`event: ${event.type}\ndata: ${JSON.stringify(data)}\n\n`))
|
|
697
|
+
close();
|
|
698
|
+
}).catch(close).finally(() => { queued--; });
|
|
699
|
+
});
|
|
700
|
+
const pushNotices = async () => {
|
|
701
|
+
if (ended || !notices || !noticeVersion)
|
|
702
|
+
return;
|
|
703
|
+
if (noticesRunning) {
|
|
704
|
+
noticesDirty = true;
|
|
705
|
+
return;
|
|
706
|
+
}
|
|
707
|
+
noticesRunning = true;
|
|
708
|
+
try {
|
|
709
|
+
do {
|
|
710
|
+
noticesDirty = false;
|
|
711
|
+
const rows = await notices.forSession(ctx, noticeVersion);
|
|
712
|
+
if (ended || !live() || !ctx.isCurrent?.())
|
|
713
|
+
return close();
|
|
714
|
+
if (!res.write(`event: notices\ndata: ${JSON.stringify({ notices: rows })}\n\n`))
|
|
715
|
+
return close();
|
|
716
|
+
} while (noticesDirty);
|
|
717
|
+
}
|
|
718
|
+
catch {
|
|
719
|
+
close();
|
|
720
|
+
}
|
|
721
|
+
finally {
|
|
722
|
+
noticesRunning = false;
|
|
723
|
+
}
|
|
724
|
+
};
|
|
725
|
+
const heartbeat = setInterval(() => { if (!live() || !ctx.isCurrent?.())
|
|
726
|
+
close();
|
|
727
|
+
else if (!res.write(": heartbeat\n\n"))
|
|
728
|
+
close(); }, 15_000);
|
|
729
|
+
heartbeat.unref();
|
|
730
|
+
try {
|
|
731
|
+
if (notices && noticeVersion)
|
|
732
|
+
offNotices = notices.subscribe(() => void pushNotices());
|
|
733
|
+
}
|
|
734
|
+
catch {
|
|
735
|
+
close();
|
|
736
|
+
return;
|
|
737
|
+
}
|
|
738
|
+
streams.add(close);
|
|
739
|
+
res.on("close", close);
|
|
740
|
+
if (initialNotices)
|
|
741
|
+
res.write(`event: notices\ndata: ${JSON.stringify({ notices: initialNotices })}\n\n`);
|
|
742
|
+
res.write(": connected\n\n");
|
|
743
|
+
return;
|
|
744
|
+
}
|
|
461
745
|
if (path === "/hub/v1/rooms") {
|
|
462
746
|
if (method === "GET") {
|
|
463
747
|
signedIn();
|
|
464
748
|
const view = await guard(() => rooms.listAuthorized(ctx));
|
|
465
|
-
|
|
749
|
+
// Cached clients draw every row as a direct agent conversation. New roomList() opts into group rows.
|
|
750
|
+
if (query.get("v") !== "2")
|
|
751
|
+
return send(res, 200, { rooms: view.rooms.map(room => ({ ...room, ...quota.roomProjection(room, view.grantProof) })) });
|
|
752
|
+
const groups = await guard(() => groupRooms.list(ctx));
|
|
753
|
+
const pending = invitations ? await guard(() => invitations.pending(ctx)) : null;
|
|
754
|
+
return send(res, 200, { ...groups, invitations: pending?.invitations.length ?? 0, rooms: [...groups.rooms, ...view.rooms.map(room => ({ ...directRoomView(room, rooms.presence(room.exposureId), directUnread(core, room)), ...quota.roomProjection(room, view.grantProof) }))] });
|
|
466
755
|
}
|
|
467
756
|
if (method === "POST") {
|
|
468
757
|
csrf();
|
|
469
758
|
const b = await body();
|
|
759
|
+
if (b.exposureId === undefined)
|
|
760
|
+
return send(res, 200, await guard(() => groupRooms.create(ctx, b)));
|
|
470
761
|
const room = await guard(() => rooms.open(ctx, uuid(b.exposureId), uuid(b.grantId)));
|
|
471
762
|
return send(res, 200, { room: { id: room.id, exposureId: room.exposureId, grantId: room.grantId, state: room.state, exposureName: room.exposure.displayName, features: rooms.features(room.exposure.fleetId), ...quota.roomProjection(room, room.grantProof) } });
|
|
472
763
|
}
|
|
473
764
|
throw new HttpError(405, "method");
|
|
474
765
|
}
|
|
766
|
+
if ((r = m(/^\/hub\/v1\/rooms\/([^/]+)$/))) {
|
|
767
|
+
signedIn();
|
|
768
|
+
const roomId = uuid(r[1]);
|
|
769
|
+
if (groupRooms.has(roomId)) {
|
|
770
|
+
if (method === "GET") {
|
|
771
|
+
const view = await guard(() => groupRooms.detail(ctx, roomId));
|
|
772
|
+
const invited = invitations && view.me.role === "manager" && !view.room.archived ? await guard(() => invitations.forRoom(ctx, roomId)) : [];
|
|
773
|
+
return send(res, 200, { ...view, invited });
|
|
774
|
+
}
|
|
775
|
+
if (method === "PATCH") {
|
|
776
|
+
csrf();
|
|
777
|
+
const b = await body();
|
|
778
|
+
return send(res, 200, await guard(() => groupRooms.patch(ctx, roomId, b)));
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
else if (method === "GET") {
|
|
782
|
+
const room = await guard(() => rooms.view(ctx, roomId));
|
|
783
|
+
const person = personKeyString(room.asker), name = signedIn().displayName;
|
|
784
|
+
return send(res, 200, { room: directRoomView(room, rooms.presence(room.exposureId), directUnread(core, room)), me: { id: person, role: "member" },
|
|
785
|
+
members: [{ id: person, kind: "person", name, role: "member", presence: "online" }, { id: room.exposureId, kind: "agent", name: room.exposureName,
|
|
786
|
+
owner: { name: room.ownerName }, role: "member", presence: rooms.presence(room.exposureId), canAsk: room.state === "active" }],
|
|
787
|
+
settings: { allMention: false, historyForNew: "all" }, invited: [] });
|
|
788
|
+
}
|
|
789
|
+
throw new HttpError(405, "method");
|
|
790
|
+
}
|
|
791
|
+
if ((r = m(/^\/hub\/v1\/rooms\/([^/]+)\/members(?:\/([^/]+))?$/))) {
|
|
792
|
+
csrf();
|
|
793
|
+
const roomId = uuid(r[1]), memberId = r[2] ? uuid(r[2]) : null;
|
|
794
|
+
if (method === "POST" && !memberId) {
|
|
795
|
+
const b = await body();
|
|
796
|
+
return send(res, 200, await guard(() => groupRooms.add(ctx, roomId, b)));
|
|
797
|
+
}
|
|
798
|
+
if (method === "DELETE" && memberId)
|
|
799
|
+
return send(res, 200, await guard(() => groupRooms.changeMember(ctx, roomId, memberId)));
|
|
800
|
+
if (method === "PATCH" && memberId) {
|
|
801
|
+
const b = await body();
|
|
802
|
+
if (Object.keys(b).length !== 1 || !["manager", "member"].includes(String(b.role)))
|
|
803
|
+
throw new HubProtocolError("invalid");
|
|
804
|
+
return send(res, 200, await guard(() => groupRooms.changeMember(ctx, roomId, memberId, b.role)));
|
|
805
|
+
}
|
|
806
|
+
throw new HttpError(405, "method");
|
|
807
|
+
}
|
|
808
|
+
if ((r = m(/^\/hub\/v1\/rooms\/([^/]+)\/read$/))) {
|
|
809
|
+
if (method !== "POST")
|
|
810
|
+
throw new HttpError(405, "method");
|
|
811
|
+
csrf();
|
|
812
|
+
const b = await body(), roomId = uuid(r[1]);
|
|
813
|
+
if (groupRooms.has(roomId))
|
|
814
|
+
return send(res, 200, await guard(() => groupRooms.markRead(ctx, roomId, b.upTo)));
|
|
815
|
+
const room = await guard(() => rooms.view(ctx, roomId));
|
|
816
|
+
markDirectRead(core, roomId, str(b.upTo));
|
|
817
|
+
groupRooms.publish({ type: "unread.changed", roomId, data: { roomId }, audiencePerson: personKeyString(room.asker) });
|
|
818
|
+
return send(res, 200, { ok: true });
|
|
819
|
+
}
|
|
475
820
|
if ((r = m(/^\/hub\/v1\/rooms\/([^/]+)\/buttons$/))) {
|
|
476
821
|
if (method !== "POST")
|
|
477
822
|
throw new HttpError(405, "method");
|
|
@@ -481,18 +826,43 @@ export function createHubHttp(deps, sql) {
|
|
|
481
826
|
}
|
|
482
827
|
if ((r = m(/^\/hub\/v1\/rooms\/([^/]+)\/messages$/))) {
|
|
483
828
|
const roomId = uuid(r[1]);
|
|
829
|
+
if (groupRooms.has(roomId)) {
|
|
830
|
+
if (method === "GET") {
|
|
831
|
+
signedIn();
|
|
832
|
+
return send(res, 200, await guard(() => groupRooms.messages(ctx, roomId, query.get("before"), int(query.get("limit") ?? "50"))));
|
|
833
|
+
}
|
|
834
|
+
if (method === "POST") {
|
|
835
|
+
csrf();
|
|
836
|
+
const b = await body();
|
|
837
|
+
return send(res, 200, await guard(() => groupRooms.post(ctx, roomId, b)));
|
|
838
|
+
}
|
|
839
|
+
throw new HttpError(405, "method");
|
|
840
|
+
}
|
|
484
841
|
if (method === "GET") {
|
|
485
842
|
const s = signedIn();
|
|
486
843
|
// #3226 B + G: the room comes with its entries, fresh each poll — its view (state, grant's end, what its link
|
|
487
844
|
// negotiated) and its quota projection (G; absent when hidden or not shared).
|
|
488
|
-
const { entries, room: view, grantProof } = await guard(() => rooms.readPage(ctx, roomId, int(query.get("after") ?? "0"), s.sessionId));
|
|
489
|
-
|
|
845
|
+
const { entries, room: view, grantProof, more } = await guard(() => rooms.readPage(ctx, roomId, int(query.get("after") ?? "0"), s.sessionId, query.has("after") ? undefined : { before: query.get("before"), limit: int(query.get("limit") ?? "50") }));
|
|
846
|
+
let messages = directMessages(view, entries, s.displayName);
|
|
847
|
+
const cursor = query.get("before"), index = cursor ? messages.findIndex(m => m.id === cursor) : -1;
|
|
848
|
+
if (index >= 0)
|
|
849
|
+
messages = messages.slice(0, index);
|
|
850
|
+
const limit = int(query.get("limit") ?? "50"), overflow = !query.has("after") && messages.length > limit;
|
|
851
|
+
if (overflow)
|
|
852
|
+
messages = messages.slice(-limit);
|
|
853
|
+
return send(res, 200, { entries, room: { ...view, ...quota.roomProjection(view, grantProof) }, messages, more: (more ?? false) || overflow });
|
|
490
854
|
}
|
|
491
855
|
if (method === "POST") {
|
|
492
856
|
csrf();
|
|
493
857
|
const b = await body();
|
|
494
858
|
const files = b.files === undefined ? [] : Array.isArray(b.files) && b.files.length <= 10 ? b.files.map(uuid) : (() => { throw new HubProtocolError("invalid"); })();
|
|
495
|
-
|
|
859
|
+
if (b.mentions !== undefined && (!Array.isArray(b.mentions) || b.mentions.length))
|
|
860
|
+
throw new HubProtocolError("invalid");
|
|
861
|
+
const receipt = await guard(() => rooms.ask(ctx, roomId, uuid(b.idempotencyKey), typeof b.text === "string" ? b.text : "", files));
|
|
862
|
+
const room = await guard(() => rooms.view(ctx, roomId));
|
|
863
|
+
groupRooms.publish({ type: "message.added", roomId, data: { roomId, messageId: receipt.messageId }, audiencePerson: personKeyString(room.asker) });
|
|
864
|
+
return send(res, 200, { id: receipt.messageId, roomId, at: receipt.at, author: { kind: "person", id: personKeyString(room.asker), name: signedIn().displayName },
|
|
865
|
+
text: typeof b.text === "string" ? b.text : "", mentions: [], idempotencyKey: b.idempotencyKey, receipt });
|
|
496
866
|
}
|
|
497
867
|
throw new HttpError(405, "method");
|
|
498
868
|
}
|
|
@@ -662,7 +1032,9 @@ export function createHubHttp(deps, sql) {
|
|
|
662
1032
|
void req;
|
|
663
1033
|
throw new HttpError(404, "not-found");
|
|
664
1034
|
}
|
|
665
|
-
function fail(res, e) {
|
|
1035
|
+
function fail(res, e, method, path) {
|
|
1036
|
+
if (e instanceof HubRoomRefusal)
|
|
1037
|
+
return send(res, e.status, { code: e.code, ...e.details });
|
|
666
1038
|
if (e instanceof HubEnrolmentCodeLimit)
|
|
667
1039
|
return send(res, 429, { code: "backpressure", reason: e.reason });
|
|
668
1040
|
if (e instanceof CompanyJoinCodeRefusal)
|
|
@@ -677,10 +1049,19 @@ export function createHubHttp(deps, sql) {
|
|
|
677
1049
|
return send(res, e.status, { code: e.code });
|
|
678
1050
|
if (e instanceof HubSharingPaused)
|
|
679
1051
|
return send(res, 409, { code: "sharing-paused" });
|
|
1052
|
+
if (e instanceof HubMemberAddressError)
|
|
1053
|
+
return send(res, STATUS[e.code] ?? 503, { code: e.code });
|
|
680
1054
|
if (e instanceof HubAttachmentRefused)
|
|
681
1055
|
return send(res, 415, { code: e.refusal });
|
|
682
1056
|
if (e instanceof HubProtocolError) {
|
|
683
1057
|
const status = STATUS[e.code] ?? 400;
|
|
1058
|
+
if (status === 503) {
|
|
1059
|
+
try {
|
|
1060
|
+
deps.log?.("warn", "Hub HTTP unavailable", { method, path, code: e.code,
|
|
1061
|
+
cause: e.cause instanceof HubGroupPolicyError ? e.cause.message : e.code });
|
|
1062
|
+
}
|
|
1063
|
+
catch { /* diagnostics cannot replace the response */ }
|
|
1064
|
+
}
|
|
684
1065
|
return send(res, status, { code: e.code }, status === 429 ? { "Retry-After": "10" } : {});
|
|
685
1066
|
}
|
|
686
1067
|
send(res, 500, { code: "unavailable" });
|
|
@@ -697,7 +1078,7 @@ export function createHubHttp(deps, sql) {
|
|
|
697
1078
|
if (deps.companyJoin && live() && handleCompanyJoin(req, res, deps.companyJoin))
|
|
698
1079
|
return true;
|
|
699
1080
|
if (path.startsWith("/hub/v1/")) {
|
|
700
|
-
void api(req, res, path, url.searchParams).catch((e) => fail(res, e));
|
|
1081
|
+
void api(req, res, path, url.searchParams).catch((e) => fail(res, e, method, path));
|
|
701
1082
|
return true;
|
|
702
1083
|
}
|
|
703
1084
|
if (method !== "GET" && method !== "HEAD")
|
|
@@ -738,12 +1119,27 @@ export function createHubHttp(deps, sql) {
|
|
|
738
1119
|
throw new HubProtocolError("stale");
|
|
739
1120
|
rooms.noteLink(link);
|
|
740
1121
|
quota.noteLink(link);
|
|
1122
|
+
groupRooms.agents.noteLink(link);
|
|
741
1123
|
deps.pairingNotices?.noteLink(link);
|
|
742
1124
|
const reply = { v: 1, requestId: frame.requestId, linkEpoch: link.linkEpoch };
|
|
743
1125
|
switch (frame.type) {
|
|
1126
|
+
case "room.answer":
|
|
1127
|
+
try {
|
|
1128
|
+
return { ...reply, type: "room.answer-ack", payload: await groupRooms.agents.answer(frame.payload, link) };
|
|
1129
|
+
}
|
|
1130
|
+
catch (error) {
|
|
1131
|
+
// No ACK means the Fleet retains its frozen answer. A pause or transient read must not break its member link.
|
|
1132
|
+
if (error instanceof HubProtocolError && ["unavailable", "backpressure", "revoked", "not-found", "stale"].includes(error.code))
|
|
1133
|
+
return;
|
|
1134
|
+
throw error;
|
|
1135
|
+
}
|
|
1136
|
+
case "agent.state":
|
|
1137
|
+
groupRooms.agents.state(frame.payload, link);
|
|
1138
|
+
return;
|
|
744
1139
|
case "exposure.snapshot":
|
|
745
1140
|
await catalog.receiveSnapshot(frame.payload, link, frame.requestId);
|
|
746
1141
|
quota.prune();
|
|
1142
|
+
groupRooms.agents.publicationChanged(link.fleetId);
|
|
747
1143
|
return;
|
|
748
1144
|
case "exposure.quota":
|
|
749
1145
|
quota.receive(frame.payload, link);
|
|
@@ -753,8 +1149,16 @@ export function createHubHttp(deps, sql) {
|
|
|
753
1149
|
throw new HubProtocolError("incompatible");
|
|
754
1150
|
deps.pairingNotices.acknowledgeFleet(link, frame.payload.id);
|
|
755
1151
|
return;
|
|
756
|
-
case "receipt":
|
|
757
|
-
|
|
1152
|
+
case "receipt": {
|
|
1153
|
+
const payload = rooms.receipt(frame.payload, link);
|
|
1154
|
+
directChanged(payload.messageId, false);
|
|
1155
|
+
return { ...reply, type: "receipt", payload };
|
|
1156
|
+
}
|
|
1157
|
+
case "answer": {
|
|
1158
|
+
const payload = await rooms.answer(frame.payload, link);
|
|
1159
|
+
directChanged(payload.messageId, true);
|
|
1160
|
+
return { ...reply, type: "receipt", payload };
|
|
1161
|
+
}
|
|
758
1162
|
case "authorize.request": return { ...reply, type: "authorize.result", payload: await policy.authorize(frame.payload, link) };
|
|
759
1163
|
case "reconcile": {
|
|
760
1164
|
const page = rooms.reconcile(frame.payload, link);
|
|
@@ -768,27 +1172,38 @@ export function createHubHttp(deps, sql) {
|
|
|
768
1172
|
case "error": return;
|
|
769
1173
|
}
|
|
770
1174
|
}
|
|
1175
|
+
function directChanged(messageId, answer) {
|
|
1176
|
+
const row = core.atomic(db => db.prepare("SELECT room_id,asker FROM hub_messages WHERE id=?").get(messageId));
|
|
1177
|
+
if (!row)
|
|
1178
|
+
return;
|
|
1179
|
+
groupRooms.publish({ type: answer ? "message.added" : "message.updated", roomId: row.room_id, data: { roomId: row.room_id, messageId: answer ? `${messageId}:answer` : messageId }, audiencePerson: row.asker });
|
|
1180
|
+
groupRooms.publish({ type: "unread.changed", roomId: row.room_id, data: { roomId: row.room_id }, audiencePerson: row.asker });
|
|
1181
|
+
}
|
|
771
1182
|
function flushSoon(link, attempt = 0) {
|
|
772
1183
|
const t = setTimeout(() => {
|
|
773
1184
|
if (!live() || !link.current())
|
|
774
1185
|
return;
|
|
775
1186
|
void rooms.flush(link.fleetId).then((sent) => { if (!sent && attempt < 5)
|
|
776
1187
|
flushSoon(link, attempt + 1); }, () => { });
|
|
1188
|
+
groupRooms.agents.wake();
|
|
777
1189
|
void deps.pairingNotices?.flushFleet(link).catch(() => { });
|
|
778
1190
|
}, attempt === 0 ? 0 : 100 * attempt);
|
|
779
1191
|
t.unref?.();
|
|
780
1192
|
}
|
|
781
1193
|
rooms.buttons.start();
|
|
1194
|
+
groupRooms.agents.wake();
|
|
1195
|
+
groupRooms.assistant.start();
|
|
782
1196
|
return {
|
|
783
1197
|
directorySessions: Object.freeze({
|
|
784
1198
|
recentAuthentication: actor => sessions.recentAuthentication(actor),
|
|
785
1199
|
prepareDirectoryRotation: (token, actor) => sessions.prepareDirectoryRotation(token, actor),
|
|
786
1200
|
completeDirectoryRotation: (rotation, operationId) => sessions.completeDirectoryRotation(rotation, operationId),
|
|
787
1201
|
}),
|
|
788
|
-
handle, receive,
|
|
789
|
-
...(deps.
|
|
1202
|
+
handle, receive, memberClosed: fleetId => { if (live())
|
|
1203
|
+
groupRooms.agents.disconnected(fleetId); }, features: Object.freeze(["rooms-v1", "room-ask-v1", ...(deps.roomAssistant && deps.assistantAdmin ? ["room-assistant-v1"] : []), ...(deps.refreshAuthorization ? ["sharing-pause-v1"] : []), ...(deps.groupHttp ? [GROUP_POLICY_FEATURE, ...(deps.pairingNotices ? ["quick-pairing-v1"] : [])] : []), ...(grantSubjectsOffered() ? ["grant-subjects-v1"] : []),
|
|
1204
|
+
...(deps.directoryNotices ? ["directory-security-notices-v1"] : []), ...(deps.memberAddressNotices ? ["member-address-notices-v1"] : []), ...(deps.directorySettings ? [HUB_DIRECTORY_SETTINGS_FEATURE, HUB_DIRECTORY_CA_FEATURE, HUB_DIRECTORY_EDITOR_FEATURE] : [])]),
|
|
790
1205
|
async close() { closed = true; grantSearch.close(); for (const end of streams)
|
|
791
|
-
end(); await rooms.buttons.close(); rooms.forget(); quota.close(); },
|
|
1206
|
+
end(); await groupRooms.close(); await rooms.buttons.close(); rooms.forget(); quota.close(); },
|
|
792
1207
|
};
|
|
793
1208
|
}
|
|
794
1209
|
//# sourceMappingURL=compose.js.map
|