@things-factory/ai-assistant 10.1.277 → 10.1.279
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-client/bootstrap.d.ts +4 -4
- package/dist-client/bootstrap.js +4 -8
- package/dist-client/components/ai-model-price-table.d.ts +32 -0
- package/dist-client/components/ai-model-price-table.js +311 -0
- package/dist-client/components/ai-usage-table.d.ts +17 -0
- package/dist-client/components/ai-usage-table.js +151 -0
- package/dist-client/index.d.ts +1 -0
- package/dist-client/index.js +2 -0
- package/dist-client/pages/ai-model-price-page.d.ts +37 -0
- package/dist-client/pages/ai-model-price-page.js +312 -0
- package/dist-client/route.d.ts +1 -1
- package/dist-client/route.js +4 -0
- package/dist-client/settings/ai-agent-setting-let.js +11 -0
- package/dist-client/utils/model-price-model.d.ts +31 -0
- package/dist-client/utils/model-price-model.js +30 -0
- package/dist-client/utils/usage-charts.d.ts +21 -0
- package/dist-client/utils/usage-charts.js +45 -0
- package/dist-client/utils/usage-model.d.ts +44 -0
- package/dist-client/utils/usage-model.js +44 -0
- package/dist-server/service/ai-agent-resolver.d.ts +46 -0
- package/dist-server/service/ai-agent-resolver.js +252 -0
- package/dist-server/service/assistant-mode/mode-categories.js +2 -2
- package/dist-server/service/chat-message/message-doors.d.ts +6 -10
- package/dist-server/service/chat-message/message-doors.js +5 -12
- package/dist-server/service/data-read/read-target.d.ts +3 -4
- package/dist-server/service/people/person-subject.d.ts +9 -5
- package/dist-server/service/people/person-subject.js +14 -19
- package/package.json +25 -10
- package/things-factory.config.js +4 -1
- package/translations/en.json +46 -4
- package/translations/es.json +43 -1
- package/translations/ja.json +43 -1
- package/translations/ko.json +46 -4
- package/translations/ms.json +43 -1
- package/translations/zh.json +43 -1
- package/client/bootstrap.ts +0 -27
- package/client/components/assistant-chat.test.ts +0 -149
- package/client/components/assistant-chat.ts +0 -5599
- package/client/components/assistant-dock.ts +0 -1036
- package/client/components/assistant-invite.ts +0 -138
- package/client/components/assistant-mode.test.ts +0 -119
- package/client/components/assistant-mode.ts +0 -174
- package/client/components/assistant-selection-bar.test.ts +0 -167
- package/client/components/assistant-selection-bar.ts +0 -178
- package/client/components/assistant-session-manager.ts +0 -915
- package/client/components/assistant-session-toolbar.ts +0 -80
- package/client/components/chat-defaults.ts +0 -64
- package/client/components/chat-echo-dedup.test.ts +0 -253
- package/client/components/chat-echo-dedup.ts +0 -190
- package/client/components/chat-input-builder.test.ts +0 -86
- package/client/components/chat-input-builder.ts +0 -133
- package/client/components/chat-proposal-survival.test.ts +0 -73
- package/client/components/entry-review.ts +0 -346
- package/client/components/markdown.test.ts +0 -518
- package/client/components/markdown.ts +0 -508
- package/client/components/mention-popup-helpers.ts +0 -433
- package/client/components/mention-popup.test.ts +0 -588
- package/client/components/mention-popup.ts +0 -261
- package/client/components/panel-aria.test.ts +0 -59
- package/client/components/proposal-outcome-line.ts +0 -74
- package/client/components/proposal-request.test.ts +0 -73
- package/client/components/reply-message.test.ts +0 -15
- package/client/components/reply-message.ts +0 -11
- package/client/components/roster-identity.test.ts +0 -8
- package/client/components/roster-identity.ts +0 -4
- package/client/components/workspace-view.ts +0 -486
- package/client/index.ts +0 -36
- package/client/pages/assistant-workspace-page.ts +0 -317
- package/client/route.ts +0 -9
- package/client/settings/agent-settings-model.ts +0 -164
- package/client/settings/ai-agent-setting-let.ts +0 -667
- package/client/settings/ai-usage-setting-let.ts +0 -240
- package/client/settings/usage-model.ts +0 -46
- package/client/setup-assistant-dock.ts +0 -177
- package/client/tsconfig.json +0 -13
- package/client/utils/addressed-draft.test.ts +0 -31
- package/client/utils/agent-choice.ts +0 -56
- package/client/utils/applied-screens.ts +0 -36
- package/client/utils/assistant-activity.ts +0 -122
- package/client/utils/assistant-ask.test.ts +0 -38
- package/client/utils/assistant-ask.ts +0 -93
- package/client/utils/assistant-capability-read.ts +0 -24
- package/client/utils/assistant-capability.test.ts +0 -17
- package/client/utils/assistant-capability.ts +0 -19
- package/client/utils/assistant-navigation.test.ts +0 -66
- package/client/utils/assistant-navigation.ts +0 -11
- package/client/utils/assistant-proposals.ts +0 -85
- package/client/utils/assistant-request-context.ts +0 -63
- package/client/utils/assistant-selection.test.ts +0 -54
- package/client/utils/assistant-selection.ts +0 -75
- package/client/utils/assistant-session-actions.ts +0 -32
- package/client/utils/assistant-session-admin.ts +0 -239
- package/client/utils/assistant-session-controller.test.ts +0 -75
- package/client/utils/assistant-session-controller.ts +0 -208
- package/client/utils/assistant-session-transport.ts +0 -46
- package/client/utils/assistant-surface.ts +0 -178
- package/client/utils/assistant-typing.test.ts +0 -33
- package/client/utils/assistant-typing.ts +0 -53
- package/client/utils/attachment-policy.ts +0 -106
- package/client/utils/composer-frame.ts +0 -77
- package/client/utils/document-text.ts +0 -332
- package/client/utils/entry-hash.ts +0 -35
- package/client/utils/entry-proposal.ts +0 -215
- package/client/utils/entry-workspace.ts +0 -70
- package/client/utils/invite-proposal-register.ts +0 -31
- package/client/utils/invite-proposal.test.ts +0 -40
- package/client/utils/invite-proposal.ts +0 -54
- package/client/utils/menu-room.ts +0 -33
- package/client/utils/open-page.ts +0 -21
- package/client/utils/pasted-table.ts +0 -145
- package/client/utils/pdf-pages.ts +0 -25
- package/client/utils/spreadsheet-text.ts +0 -125
- package/client/utils/workspace.ts +0 -89
- package/dist-client/bootstrap.js.map +0 -1
- package/dist-client/components/assistant-chat.js.map +0 -1
- package/dist-client/components/assistant-chat.test.d.ts +0 -1
- package/dist-client/components/assistant-chat.test.js +0 -138
- package/dist-client/components/assistant-chat.test.js.map +0 -1
- package/dist-client/components/assistant-dock.js.map +0 -1
- package/dist-client/components/assistant-invite.js.map +0 -1
- package/dist-client/components/assistant-mode.js.map +0 -1
- package/dist-client/components/assistant-mode.test.d.ts +0 -1
- package/dist-client/components/assistant-mode.test.js +0 -100
- package/dist-client/components/assistant-mode.test.js.map +0 -1
- package/dist-client/components/assistant-selection-bar.js.map +0 -1
- package/dist-client/components/assistant-selection-bar.test.d.ts +0 -1
- package/dist-client/components/assistant-selection-bar.test.js +0 -148
- package/dist-client/components/assistant-selection-bar.test.js.map +0 -1
- package/dist-client/components/assistant-session-manager.js.map +0 -1
- package/dist-client/components/assistant-session-toolbar.js.map +0 -1
- package/dist-client/components/chat-defaults.js.map +0 -1
- package/dist-client/components/chat-echo-dedup.js.map +0 -1
- package/dist-client/components/chat-echo-dedup.test.d.ts +0 -1
- package/dist-client/components/chat-echo-dedup.test.js +0 -223
- package/dist-client/components/chat-echo-dedup.test.js.map +0 -1
- package/dist-client/components/chat-input-builder.js.map +0 -1
- package/dist-client/components/chat-input-builder.test.d.ts +0 -1
- package/dist-client/components/chat-input-builder.test.js +0 -70
- package/dist-client/components/chat-input-builder.test.js.map +0 -1
- package/dist-client/components/chat-proposal-survival.test.d.ts +0 -1
- package/dist-client/components/chat-proposal-survival.test.js +0 -61
- package/dist-client/components/chat-proposal-survival.test.js.map +0 -1
- package/dist-client/components/entry-review.js.map +0 -1
- package/dist-client/components/markdown.js.map +0 -1
- package/dist-client/components/markdown.test.d.ts +0 -1
- package/dist-client/components/markdown.test.js +0 -418
- package/dist-client/components/markdown.test.js.map +0 -1
- package/dist-client/components/mention-popup-helpers.js.map +0 -1
- package/dist-client/components/mention-popup.js.map +0 -1
- package/dist-client/components/mention-popup.test.d.ts +0 -1
- package/dist-client/components/mention-popup.test.js +0 -474
- package/dist-client/components/mention-popup.test.js.map +0 -1
- package/dist-client/components/panel-aria.test.d.ts +0 -1
- package/dist-client/components/panel-aria.test.js +0 -53
- package/dist-client/components/panel-aria.test.js.map +0 -1
- package/dist-client/components/proposal-outcome-line.js.map +0 -1
- package/dist-client/components/proposal-request.test.d.ts +0 -1
- package/dist-client/components/proposal-request.test.js +0 -63
- package/dist-client/components/proposal-request.test.js.map +0 -1
- package/dist-client/components/reply-message.js.map +0 -1
- package/dist-client/components/reply-message.test.d.ts +0 -1
- package/dist-client/components/reply-message.test.js +0 -16
- package/dist-client/components/reply-message.test.js.map +0 -1
- package/dist-client/components/roster-identity.js.map +0 -1
- package/dist-client/components/roster-identity.test.d.ts +0 -1
- package/dist-client/components/roster-identity.test.js +0 -9
- package/dist-client/components/roster-identity.test.js.map +0 -1
- package/dist-client/components/workspace-view.js.map +0 -1
- package/dist-client/index.js.map +0 -1
- package/dist-client/pages/assistant-workspace-page.js.map +0 -1
- package/dist-client/route.js.map +0 -1
- package/dist-client/settings/agent-settings-model.js.map +0 -1
- package/dist-client/settings/ai-agent-setting-let.js.map +0 -1
- package/dist-client/settings/ai-usage-setting-let.d.ts +0 -25
- package/dist-client/settings/ai-usage-setting-let.js +0 -258
- package/dist-client/settings/ai-usage-setting-let.js.map +0 -1
- package/dist-client/settings/usage-model.d.ts +0 -32
- package/dist-client/settings/usage-model.js +0 -25
- package/dist-client/settings/usage-model.js.map +0 -1
- package/dist-client/setup-assistant-dock.js.map +0 -1
- package/dist-client/tsconfig.tsbuildinfo +0 -1
- package/dist-client/utils/addressed-draft.test.d.ts +0 -1
- package/dist-client/utils/addressed-draft.test.js +0 -27
- package/dist-client/utils/addressed-draft.test.js.map +0 -1
- package/dist-client/utils/agent-choice.js.map +0 -1
- package/dist-client/utils/applied-screens.js.map +0 -1
- package/dist-client/utils/assistant-activity.js.map +0 -1
- package/dist-client/utils/assistant-ask.js.map +0 -1
- package/dist-client/utils/assistant-ask.test.d.ts +0 -1
- package/dist-client/utils/assistant-ask.test.js +0 -40
- package/dist-client/utils/assistant-ask.test.js.map +0 -1
- package/dist-client/utils/assistant-capability-read.js.map +0 -1
- package/dist-client/utils/assistant-capability.js.map +0 -1
- package/dist-client/utils/assistant-capability.test.d.ts +0 -1
- package/dist-client/utils/assistant-capability.test.js +0 -16
- package/dist-client/utils/assistant-capability.test.js.map +0 -1
- package/dist-client/utils/assistant-navigation.js.map +0 -1
- package/dist-client/utils/assistant-navigation.test.d.ts +0 -1
- package/dist-client/utils/assistant-navigation.test.js +0 -63
- package/dist-client/utils/assistant-navigation.test.js.map +0 -1
- package/dist-client/utils/assistant-proposals.js.map +0 -1
- package/dist-client/utils/assistant-request-context.js.map +0 -1
- package/dist-client/utils/assistant-selection.js.map +0 -1
- package/dist-client/utils/assistant-selection.test.d.ts +0 -1
- package/dist-client/utils/assistant-selection.test.js +0 -46
- package/dist-client/utils/assistant-selection.test.js.map +0 -1
- package/dist-client/utils/assistant-session-actions.js.map +0 -1
- package/dist-client/utils/assistant-session-admin.js.map +0 -1
- package/dist-client/utils/assistant-session-controller.js.map +0 -1
- package/dist-client/utils/assistant-session-controller.test.d.ts +0 -1
- package/dist-client/utils/assistant-session-controller.test.js +0 -56
- package/dist-client/utils/assistant-session-controller.test.js.map +0 -1
- package/dist-client/utils/assistant-session-transport.js.map +0 -1
- package/dist-client/utils/assistant-surface.js.map +0 -1
- package/dist-client/utils/assistant-typing.js.map +0 -1
- package/dist-client/utils/assistant-typing.test.d.ts +0 -1
- package/dist-client/utils/assistant-typing.test.js +0 -30
- package/dist-client/utils/assistant-typing.test.js.map +0 -1
- package/dist-client/utils/attachment-policy.js.map +0 -1
- package/dist-client/utils/composer-frame.js.map +0 -1
- package/dist-client/utils/document-text.js.map +0 -1
- package/dist-client/utils/entry-hash.js.map +0 -1
- package/dist-client/utils/entry-proposal.js.map +0 -1
- package/dist-client/utils/entry-workspace.js.map +0 -1
- package/dist-client/utils/invite-proposal-register.js.map +0 -1
- package/dist-client/utils/invite-proposal.js.map +0 -1
- package/dist-client/utils/invite-proposal.test.d.ts +0 -1
- package/dist-client/utils/invite-proposal.test.js +0 -35
- package/dist-client/utils/invite-proposal.test.js.map +0 -1
- package/dist-client/utils/menu-room.js.map +0 -1
- package/dist-client/utils/open-page.js.map +0 -1
- package/dist-client/utils/pasted-table.js.map +0 -1
- package/dist-client/utils/pdf-pages.js.map +0 -1
- package/dist-client/utils/spreadsheet-text.js.map +0 -1
- package/dist-client/utils/workspace.js.map +0 -1
- package/dist-server/door-declaration-report.js.map +0 -1
- package/dist-server/index.js.map +0 -1
- package/dist-server/role-tasks.js.map +0 -1
- package/dist-server/service/ai-agent-resolver.js.map +0 -1
- package/dist-server/service/assistant-capability-resolver.js.map +0 -1
- package/dist-server/service/assistant-chat-resolver.js.map +0 -1
- package/dist-server/service/assistant-mode/assistant-mode-resolver.js.map +0 -1
- package/dist-server/service/assistant-mode/fallback-subjects.js.map +0 -1
- package/dist-server/service/assistant-mode/index.js.map +0 -1
- package/dist-server/service/assistant-mode/mode-categories.js.map +0 -1
- package/dist-server/service/assistant-mode/record-subject.js.map +0 -1
- package/dist-server/service/assistant-mode/registry.js.map +0 -1
- package/dist-server/service/assistant-mode/resolve.js.map +0 -1
- package/dist-server/service/assistant-mode/screen-rules.js.map +0 -1
- package/dist-server/service/assistant-mode/turn-lines.js.map +0 -1
- package/dist-server/service/assistant-mode/types.js.map +0 -1
- package/dist-server/service/chat-message/carried-turns.js.map +0 -1
- package/dist-server/service/chat-message/chat-message-broadcast.js.map +0 -1
- package/dist-server/service/chat-message/chat-message-publish.js.map +0 -1
- package/dist-server/service/chat-message/chat-message-room.js.map +0 -1
- package/dist-server/service/chat-message/chat-message-subscription.js.map +0 -1
- package/dist-server/service/chat-message/chat-message.js.map +0 -1
- package/dist-server/service/chat-message/chat-typing-subscription.js.map +0 -1
- package/dist-server/service/chat-message/chat-typing.js.map +0 -1
- package/dist-server/service/chat-message/door-access.js.map +0 -1
- package/dist-server/service/chat-message/fold-history.js.map +0 -1
- package/dist-server/service/chat-message/fold-session-history.js.map +0 -1
- package/dist-server/service/chat-message/history-summary.js.map +0 -1
- package/dist-server/service/chat-message/index.js.map +0 -1
- package/dist-server/service/chat-message/llm-history.js.map +0 -1
- package/dist-server/service/chat-message/message-doors.js.map +0 -1
- package/dist-server/service/chat-message/proposal-outcome.js.map +0 -1
- package/dist-server/service/chat-message/reader-gate.js.map +0 -1
- package/dist-server/service/chat-message/room-message.js.map +0 -1
- package/dist-server/service/chat-message/room-turn.js.map +0 -1
- package/dist-server/service/chat-message/used-tools.js.map +0 -1
- package/dist-server/service/chat-session/attachment-policy.js.map +0 -1
- package/dist-server/service/chat-session/attachment-route.js.map +0 -1
- package/dist-server/service/chat-session/attachment-tool-result.js.map +0 -1
- package/dist-server/service/chat-session/attachment-tools.js.map +0 -1
- package/dist-server/service/chat-session/chat-session.js.map +0 -1
- package/dist-server/service/chat-session/index.js.map +0 -1
- package/dist-server/service/chat-session/session-activity-broadcast.js.map +0 -1
- package/dist-server/service/chat-session/session-activity-publish.js.map +0 -1
- package/dist-server/service/chat-session/session-activity-subscription.js.map +0 -1
- package/dist-server/service/chat-session/session-anchor.js.map +0 -1
- package/dist-server/service/chat-session/session-attachments.js.map +0 -1
- package/dist-server/service/chat-session/session-cleanup.js.map +0 -1
- package/dist-server/service/chat-session/session-inbox.js.map +0 -1
- package/dist-server/service/chat-session/session-kind.js.map +0 -1
- package/dist-server/service/chat-session/session-name.js.map +0 -1
- package/dist-server/service/chat-session/session-purge.js.map +0 -1
- package/dist-server/service/chat-session/session-retention.js.map +0 -1
- package/dist-server/service/chat-session/session-visibility.js.map +0 -1
- package/dist-server/service/chat-session/session-write-gate.js.map +0 -1
- package/dist-server/service/chat-session/station-session-guard.js.map +0 -1
- package/dist-server/service/chat-session/turn-attachments.js.map +0 -1
- package/dist-server/service/chat-session-participant/chat-session-participant.js.map +0 -1
- package/dist-server/service/chat-session-participant/index.js.map +0 -1
- package/dist-server/service/chat-session-participant/invite-notification.js.map +0 -1
- package/dist-server/service/chat-session-participant/mention-invite.js.map +0 -1
- package/dist-server/service/chat-session-participant/participant-lookup-roles.js.map +0 -1
- package/dist-server/service/chat-session-participant/participant-lookup.js.map +0 -1
- package/dist-server/service/chat-session-participant/presence.js.map +0 -1
- package/dist-server/service/chat-session-participant/read-roster.js.map +0 -1
- package/dist-server/service/chat-session-resolver.js.map +0 -1
- package/dist-server/service/data-entry/entry-apply.js.map +0 -1
- package/dist-server/service/data-entry/entry-hash.js.map +0 -1
- package/dist-server/service/data-entry/entry-refusal.js.map +0 -1
- package/dist-server/service/data-entry/entry-resolver.js.map +0 -1
- package/dist-server/service/data-entry/entry-screen.js.map +0 -1
- package/dist-server/service/data-entry/entry-sources.js.map +0 -1
- package/dist-server/service/data-entry/entry-target.js.map +0 -1
- package/dist-server/service/data-entry/entry-tools.js.map +0 -1
- package/dist-server/service/data-entry/entry-update.js.map +0 -1
- package/dist-server/service/data-read/list-read.js.map +0 -1
- package/dist-server/service/data-read/read-target.js.map +0 -1
- package/dist-server/service/data-read/read-tools.js.map +0 -1
- package/dist-server/service/grounding-sources.js.map +0 -1
- package/dist-server/service/help-documents/help-keys.js.map +0 -1
- package/dist-server/service/help-documents/help-tools.js.map +0 -1
- package/dist-server/service/index.js.map +0 -1
- package/dist-server/service/people/index.js.map +0 -1
- package/dist-server/service/people/invite-tools.js.map +0 -1
- package/dist-server/service/people/people-keys.js.map +0 -1
- package/dist-server/service/people/people-read.js.map +0 -1
- package/dist-server/service/people/person-subject.js.map +0 -1
- package/dist-server/service/request-translator.js.map +0 -1
- package/dist-server/service/testing/conversation-script.js.map +0 -1
- package/dist-server/service/testing/mode-conformance.js.map +0 -1
- package/dist-server/service/tool-access.js.map +0 -1
- package/dist-server/service/types.js.map +0 -1
- package/dist-server/service/unattended-run/assistant-run.js.map +0 -1
- package/dist-server/service/unattended-run/index.js.map +0 -1
- package/dist-server/service/unattended-run/limits.js.map +0 -1
- package/dist-server/service/unattended-run/run-as.js.map +0 -1
- package/dist-server/service/unattended-run/run-budget.js.map +0 -1
- package/dist-server/service/unattended-run/run-ledger.js.map +0 -1
- package/dist-server/service/unattended-run/run-outcome.js.map +0 -1
- package/dist-server/service/unattended-run/run-store.js.map +0 -1
- package/dist-server/service/unattended-run/run-unattended.js.map +0 -1
- package/dist-server/service/unattended-run/unattended-prompt.js.map +0 -1
- package/dist-server/service/workspace/workspace-blocks.js.map +0 -1
- package/dist-server/service/workspace/workspace-tools.js.map +0 -1
- package/dist-server/tool-registry-boot-report.js.map +0 -1
- package/dist-server/tsconfig.tsbuildinfo +0 -1
- package/docs/session-controller.md +0 -52
- package/server/door-declaration-report.test.ts +0 -53
- package/server/door-declaration-report.ts +0 -61
- package/server/explicit-graphql-types.test.ts +0 -56
- package/server/index.ts +0 -36
- package/server/role-tasks.ts +0 -14
- package/server/service/ai-agent-resolver.ts +0 -330
- package/server/service/assistant-capability-resolver.ts +0 -66
- package/server/service/assistant-chat-resolver.ts +0 -640
- package/server/service/assistant-mode/assistant-mode-resolver.ts +0 -101
- package/server/service/assistant-mode/conversation-category.test.ts +0 -48
- package/server/service/assistant-mode/fallback-subjects.ts +0 -36
- package/server/service/assistant-mode/index.ts +0 -22
- package/server/service/assistant-mode/mode-categories.ts +0 -178
- package/server/service/assistant-mode/mode-front.test.ts +0 -181
- package/server/service/assistant-mode/one-conversation-per-subject.test.ts +0 -37
- package/server/service/assistant-mode/open-subject-door.test.ts +0 -52
- package/server/service/assistant-mode/record-subject.test.ts +0 -41
- package/server/service/assistant-mode/record-subject.ts +0 -44
- package/server/service/assistant-mode/registry.test.ts +0 -171
- package/server/service/assistant-mode/registry.ts +0 -139
- package/server/service/assistant-mode/resolve.test.ts +0 -129
- package/server/service/assistant-mode/resolve.ts +0 -113
- package/server/service/assistant-mode/screen-rules.test.ts +0 -99
- package/server/service/assistant-mode/screen-rules.ts +0 -103
- package/server/service/assistant-mode/turn-lines.ts +0 -43
- package/server/service/assistant-mode/types.ts +0 -138
- package/server/service/chat-message/carried-turns.test.ts +0 -80
- package/server/service/chat-message/carried-turns.ts +0 -112
- package/server/service/chat-message/chat-message-broadcast.integration.test.ts +0 -73
- package/server/service/chat-message/chat-message-broadcast.test.ts +0 -40
- package/server/service/chat-message/chat-message-broadcast.ts +0 -70
- package/server/service/chat-message/chat-message-publish.ts +0 -22
- package/server/service/chat-message/chat-message-room.test.ts +0 -145
- package/server/service/chat-message/chat-message-room.ts +0 -50
- package/server/service/chat-message/chat-message-subscription.ts +0 -77
- package/server/service/chat-message/chat-message.ts +0 -289
- package/server/service/chat-message/chat-typing-subscription.ts +0 -52
- package/server/service/chat-message/chat-typing.test.ts +0 -45
- package/server/service/chat-message/chat-typing.ts +0 -48
- package/server/service/chat-message/door-access.test.ts +0 -72
- package/server/service/chat-message/door-access.ts +0 -65
- package/server/service/chat-message/fold-history-window.test.ts +0 -184
- package/server/service/chat-message/fold-history.test.ts +0 -98
- package/server/service/chat-message/fold-history.ts +0 -77
- package/server/service/chat-message/fold-session-history.test.ts +0 -116
- package/server/service/chat-message/fold-session-history.ts +0 -115
- package/server/service/chat-message/history-summary.test.ts +0 -127
- package/server/service/chat-message/history-summary.ts +0 -100
- package/server/service/chat-message/index.ts +0 -13
- package/server/service/chat-message/llm-history.test.ts +0 -245
- package/server/service/chat-message/llm-history.ts +0 -182
- package/server/service/chat-message/message-doors.test.ts +0 -124
- package/server/service/chat-message/message-doors.ts +0 -137
- package/server/service/chat-message/proposal-outcome.test.ts +0 -111
- package/server/service/chat-message/proposal-outcome.ts +0 -99
- package/server/service/chat-message/reader-gate.ts +0 -44
- package/server/service/chat-message/room-message.test.ts +0 -21
- package/server/service/chat-message/room-message.ts +0 -22
- package/server/service/chat-message/room-turn.ts +0 -42
- package/server/service/chat-message/used-tools.test.ts +0 -19
- package/server/service/chat-message/used-tools.ts +0 -25
- package/server/service/chat-session/attachment-policy.test.ts +0 -42
- package/server/service/chat-session/attachment-policy.ts +0 -91
- package/server/service/chat-session/attachment-route.ts +0 -45
- package/server/service/chat-session/attachment-tool-result.test.ts +0 -63
- package/server/service/chat-session/attachment-tool-result.ts +0 -37
- package/server/service/chat-session/attachment-tools.ts +0 -66
- package/server/service/chat-session/chat-session.ts +0 -244
- package/server/service/chat-session/group-room.test.ts +0 -233
- package/server/service/chat-session/index.ts +0 -5
- package/server/service/chat-session/session-activity-broadcast.ts +0 -77
- package/server/service/chat-session/session-activity-publish.ts +0 -49
- package/server/service/chat-session/session-activity-receivers.test.ts +0 -26
- package/server/service/chat-session/session-activity-subscription.ts +0 -66
- package/server/service/chat-session/session-anchor.ts +0 -142
- package/server/service/chat-session/session-attachments.ts +0 -90
- package/server/service/chat-session/session-cleanup.test.ts +0 -83
- package/server/service/chat-session/session-cleanup.ts +0 -69
- package/server/service/chat-session/session-inbox.test.ts +0 -273
- package/server/service/chat-session/session-inbox.ts +0 -240
- package/server/service/chat-session/session-kind.test.ts +0 -24
- package/server/service/chat-session/session-kind.ts +0 -32
- package/server/service/chat-session/session-name.ts +0 -32
- package/server/service/chat-session/session-purge.test.ts +0 -24
- package/server/service/chat-session/session-purge.ts +0 -117
- package/server/service/chat-session/session-retention.ts +0 -17
- package/server/service/chat-session/session-visibility.test.ts +0 -130
- package/server/service/chat-session/session-visibility.ts +0 -68
- package/server/service/chat-session/session-write-gate.test.ts +0 -59
- package/server/service/chat-session/session-write-gate.ts +0 -31
- package/server/service/chat-session/station-session-guard.ts +0 -25
- package/server/service/chat-session/turn-attachments.test.ts +0 -106
- package/server/service/chat-session/turn-attachments.ts +0 -45
- package/server/service/chat-session-participant/chat-session-participant.ts +0 -135
- package/server/service/chat-session-participant/index.ts +0 -8
- package/server/service/chat-session-participant/invite-notification.test.ts +0 -80
- package/server/service/chat-session-participant/invite-notification.ts +0 -118
- package/server/service/chat-session-participant/mention-invite.test.ts +0 -173
- package/server/service/chat-session-participant/mention-invite.ts +0 -180
- package/server/service/chat-session-participant/participant-lookup-roles.ts +0 -6
- package/server/service/chat-session-participant/participant-lookup.ts +0 -22
- package/server/service/chat-session-participant/presence.test.ts +0 -39
- package/server/service/chat-session-participant/presence.ts +0 -21
- package/server/service/chat-session-participant/read-roster.test.ts +0 -27
- package/server/service/chat-session-participant/read-roster.ts +0 -17
- package/server/service/chat-session-resolver.ts +0 -1455
- package/server/service/data-entry/data-entry-update.test.ts +0 -378
- package/server/service/data-entry/data-entry.test.ts +0 -494
- package/server/service/data-entry/entry-apply.ts +0 -247
- package/server/service/data-entry/entry-hash.ts +0 -35
- package/server/service/data-entry/entry-refusal.test.ts +0 -73
- package/server/service/data-entry/entry-refusal.ts +0 -20
- package/server/service/data-entry/entry-resolver.ts +0 -74
- package/server/service/data-entry/entry-screen.ts +0 -14
- package/server/service/data-entry/entry-sources.ts +0 -39
- package/server/service/data-entry/entry-target.ts +0 -774
- package/server/service/data-entry/entry-tools.ts +0 -282
- package/server/service/data-entry/entry-update.ts +0 -238
- package/server/service/data-read/data-read.test.ts +0 -395
- package/server/service/data-read/detail-lists.test.ts +0 -61
- package/server/service/data-read/list-missing.test.ts +0 -49
- package/server/service/data-read/list-read.ts +0 -146
- package/server/service/data-read/list-status.test.ts +0 -46
- package/server/service/data-read/read-target.ts +0 -510
- package/server/service/data-read/read-tools.ts +0 -334
- package/server/service/data-read/read-words.test.ts +0 -99
- package/server/service/data-read/record-keys.test.ts +0 -42
- package/server/service/grounding-sources.test.ts +0 -55
- package/server/service/grounding-sources.ts +0 -46
- package/server/service/help-documents/help-keys.ts +0 -2
- package/server/service/help-documents/help-tools.test.ts +0 -40
- package/server/service/help-documents/help-tools.ts +0 -88
- package/server/service/index.ts +0 -99
- package/server/service/people/index.ts +0 -15
- package/server/service/people/invite-tools.ts +0 -159
- package/server/service/people/invite.test.ts +0 -159
- package/server/service/people/people-keys.ts +0 -16
- package/server/service/people/people-read.test.ts +0 -82
- package/server/service/people/people-read.ts +0 -56
- package/server/service/people/person-subject.test.ts +0 -163
- package/server/service/people/person-subject.ts +0 -88
- package/server/service/request-translator.test.ts +0 -45
- package/server/service/request-translator.ts +0 -33
- package/server/service/session-anchor.test.ts +0 -198
- package/server/service/station-session-guard.test.ts +0 -31
- package/server/service/testing/conversation-scenario.test.ts +0 -164
- package/server/service/testing/conversation-script.test.ts +0 -133
- package/server/service/testing/conversation-script.ts +0 -296
- package/server/service/testing/mode-conformance.test.ts +0 -61
- package/server/service/testing/mode-conformance.ts +0 -165
- package/server/service/tool-access.test.ts +0 -96
- package/server/service/tool-access.ts +0 -36
- package/server/service/types.ts +0 -15
- package/server/service/unattended-run/assistant-run.ts +0 -199
- package/server/service/unattended-run/index.ts +0 -10
- package/server/service/unattended-run/limits.ts +0 -24
- package/server/service/unattended-run/run-as.ts +0 -38
- package/server/service/unattended-run/run-budget.ts +0 -58
- package/server/service/unattended-run/run-ledger.ts +0 -31
- package/server/service/unattended-run/run-outcome.ts +0 -43
- package/server/service/unattended-run/run-store-race.pg.test.ts +0 -83
- package/server/service/unattended-run/run-store.ts +0 -162
- package/server/service/unattended-run/run-unattended.test.ts +0 -478
- package/server/service/unattended-run/run-unattended.ts +0 -248
- package/server/service/unattended-run/unattended-prompt.ts +0 -24
- package/server/service/workspace/workspace-blocks.ts +0 -134
- package/server/service/workspace/workspace-tools.ts +0 -108
- package/server/service/workspace/workspace.test.ts +0 -74
- package/server/tool-registry-boot-report.test.ts +0 -41
- package/server/tool-registry-boot-report.ts +0 -63
- package/test/ai-agent-settings.test.ts +0 -123
- package/test/applied-screens.test.ts +0 -65
- package/test/assistant-chat-call-sites.test.ts +0 -92
- package/test/assistant-dock.test.ts +0 -294
- package/test/assistant-request-context.test.ts +0 -72
- package/test/assistant-session-controller.test.ts +0 -87
- package/test/assistant-session-manager.test.ts +0 -186
- package/test/assistant-session-toolbar.test.ts +0 -43
- package/test/attachment-one-rule.test.ts +0 -46
- package/test/attachment-policy-agree.test.ts +0 -38
- package/test/composer-frame.test.ts +0 -173
- package/test/document-text.test.ts +0 -175
- package/test/entry-card-styles.test.ts +0 -18
- package/test/entry-proposal.test.ts +0 -186
- package/test/entry-workspace.test.ts +0 -89
- package/test/menu-room.test.ts +0 -33
- package/test/open-doors.test.ts +0 -164
- package/test/open-page.test.ts +0 -31
- package/test/pasted-table.test.ts +0 -147
- package/test/refusals-in-korean.test.ts +0 -80
- package/test/session-discovery.test.ts +0 -43
- package/test/spreadsheet-text.test.ts +0 -92
- package/test/translations.test.ts +0 -80
- package/test/workspace.test.ts +0 -54
- package/tsconfig.json +0 -9
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The records a person picked on a screen and handed to the assistant - `askAssistant({ selection })`.
|
|
3
|
-
*
|
|
4
|
-
* The conversation keeps them as a note: one line the person reads (「선택 1건 · 계약 대장: H2022019 · 브라이스톤 IT3.0
|
|
5
|
-
* Website」) and one line the model reads - the list and the ids, after `[keys]`. The screen hides the key line; the
|
|
6
|
-
* model is handed the note as stored. Until 2026-10-24 the screen sent the selection as JSON and the conversation
|
|
7
|
-
* opened on `{"source":"explicit-page-selection",…}`.
|
|
8
|
-
*/
|
|
9
|
-
import { ENTRY_RECORDS_PREFIX } from './entry-proposal.js'
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* The grid's own row picker - a list that hands its rows to the assistant shows it beside `ox-assistant-selection-bar`
|
|
13
|
-
* (data-grist gutter `row-selector`, many at once).
|
|
14
|
-
*/
|
|
15
|
-
export const SELECTION_ROW_PICKER = { type: 'gutter', gutterName: 'row-selector', multiple: true }
|
|
16
|
-
|
|
17
|
-
/** A picked row as the person reads it, when the screen gives no words of its own - its code or number, then its name. */
|
|
18
|
-
export function selectionLabel(row: any): string {
|
|
19
|
-
return [row?.code || row?.number, row?.name || row?.title || row?.description]
|
|
20
|
-
.filter(Boolean)
|
|
21
|
-
.join(' · ')
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* The rows a person picked, as the assistant is handed them (`askAssistant({ selection })`): saved rows only (an id, no
|
|
26
|
-
* pending edit), each once, in screen order - never whole rows. Given the list's axis, each id is the record's key
|
|
27
|
-
* `<axis>:<uuid>`, the one that list's read tool takes (read-target.ts `recordIdOfKey`): a bare uuid names no tool, and
|
|
28
|
-
* a model read a contract's id with a dashboard's card tool (2026-10-25, Office 미수금).
|
|
29
|
-
*/
|
|
30
|
-
export function selectedRecords(rows: any[], options: { axis?: string; labelOf?: (row: any) => string } = {}): { id: string; label: string }[] {
|
|
31
|
-
const { axis, labelOf = selectionLabel } = options
|
|
32
|
-
const seen = new Set<string>()
|
|
33
|
-
return (rows ?? [])
|
|
34
|
-
.filter(row => row?.id && !row.__dirty__ && !seen.has(row.id) && !!seen.add(row.id))
|
|
35
|
-
.map(row => ({ id: axis ? `${axis}:${row.id}` : row.id, label: labelOf(row) || '' }))
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/** The line the model reads begins with this; the conversation does not draw it. */
|
|
39
|
-
export const SELECTION_KEYS_PREFIX = '[keys]'
|
|
40
|
-
|
|
41
|
-
/** Labels named on the person's line - the rest are counted. */
|
|
42
|
-
export const SELECTION_LABELS_SHOWN = 5
|
|
43
|
-
|
|
44
|
-
export interface AssistantSelection {
|
|
45
|
-
/** The list the records were picked from, as the person knows it (「계약 대장」). */
|
|
46
|
-
title: string
|
|
47
|
-
/** The list's query (`contracts`) - which list the ids belong to, for the model. */
|
|
48
|
-
list?: string
|
|
49
|
-
records: { id: string; label?: string }[]
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export type SelectionTranslate = (key: string, defaultValue: string, options?: Record<string, unknown>) => string
|
|
53
|
-
|
|
54
|
-
/** The note stored in the conversation - the person's line, then the key line. Empty when nothing was picked. */
|
|
55
|
-
export function selectionNote(selection: AssistantSelection, t: SelectionTranslate): string {
|
|
56
|
-
const seen = new Set<string>()
|
|
57
|
-
const records = (selection?.records ?? []).filter(one => one?.id && !seen.has(one.id) && !!seen.add(one.id))
|
|
58
|
-
if (!records.length) return ''
|
|
59
|
-
const labels = records.map(one => (one.label || '').replace(/\s+/g, ' ').trim()).filter(Boolean)
|
|
60
|
-
const shown = labels.slice(0, SELECTION_LABELS_SHOWN).join(', ')
|
|
61
|
-
const rest = labels.length - Math.min(labels.length, SELECTION_LABELS_SHOWN)
|
|
62
|
-
const line = t('selection-note', 'Selected {count} · {title}', { count: records.length, title: selection.title })
|
|
63
|
-
const named = shown ? `${line}: ${shown}${rest > 0 ? ` ${t('selection-more', 'and {count} more', { count: rest })}` : ''}` : line
|
|
64
|
-
const keys = `${SELECTION_KEYS_PREFIX} ${selection.list ? `${selection.list} ` : ''}${records.map(one => one.id).join(' ')}`
|
|
65
|
-
return `${named}\n${keys}`
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/** A note as the conversation draws it - without the lines only the model reads (a selection's keys, an entry's records). */
|
|
69
|
-
export function noteForDisplay(content: string): string {
|
|
70
|
-
return (content ?? '')
|
|
71
|
-
.split('\n')
|
|
72
|
-
.filter(line => !line.startsWith(SELECTION_KEYS_PREFIX) && !line.startsWith(ENTRY_RECORDS_PREFIX))
|
|
73
|
-
.join('\n')
|
|
74
|
-
.trim()
|
|
75
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Which actions a row of the conversation list offers this viewer - pure, so the rule is tested alone.
|
|
3
|
-
*
|
|
4
|
-
* The same hints the server gives on each inbox entry; the doors decide again:
|
|
5
|
-
* rename any participant (the name is the topic label; reversible)
|
|
6
|
-
* hide/unhide anyone, for their own list only (reversible)
|
|
7
|
-
* delete the creator (`mine`) (not reversible from a screen)
|
|
8
|
-
* visibility the owner (`owner`) (opening shows what is already written)
|
|
9
|
-
* leave a participant who is not the owner (the owner deletes or makes it private instead)
|
|
10
|
-
*/
|
|
11
|
-
export function sessionActions(entry: { participant?: boolean; hidden?: boolean; mine?: boolean; owner?: boolean }) {
|
|
12
|
-
return {
|
|
13
|
-
rename: entry.participant !== false,
|
|
14
|
-
hide: !entry.hidden,
|
|
15
|
-
unhide: !!entry.hidden,
|
|
16
|
-
remove: !!entry.mine,
|
|
17
|
-
setVisibility: !!entry.owner,
|
|
18
|
-
leave: !!entry.participant && !entry.owner
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* What a picked set of rows can have done to it at once - each row by the same hints as its own menu: delete the
|
|
24
|
-
* ones I started, leave the ones I am only in, hide any (2026-10-25, the user: 「멀티셀렉트로 한번에 지울 수 있게」).
|
|
25
|
-
*/
|
|
26
|
-
export function bulkActions(entries: { id: string; participant?: boolean; hidden?: boolean; mine?: boolean; owner?: boolean }[]) {
|
|
27
|
-
return {
|
|
28
|
-
remove: entries.filter(entry => sessionActions(entry).remove).map(entry => entry.id),
|
|
29
|
-
leave: entries.filter(entry => !sessionActions(entry).remove && sessionActions(entry).leave).map(entry => entry.id),
|
|
30
|
-
hide: entries.filter(entry => sessionActions(entry).hide).map(entry => entry.id)
|
|
31
|
-
}
|
|
32
|
-
}
|
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
import { client } from '@operato/graphql'
|
|
2
|
-
import { i18next } from '@operato/i18n'
|
|
3
|
-
import gql from 'graphql-tag'
|
|
4
|
-
|
|
5
|
-
export { bulkActions, sessionActions } from './assistant-session-actions.js'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Managing the conversations on one anchor - list, rename, hide, delete, and who may read them.
|
|
9
|
-
*
|
|
10
|
-
* These were written once, inside operato-twin's dock (things-factory `b3d1081f4c`, `b44c986c07`,
|
|
11
|
-
* 2026-07-30), and every other dock (plant, figure, warehouse, ecs) had only the tabs. They are the
|
|
12
|
-
* framework's doors (`chatSessionInbox` · `renameAISession` · `hideAISession` · `deleteAISession` ·
|
|
13
|
-
* `setSessionVisibility`), so the screen for them belongs here too - one list every dock opens.
|
|
14
|
-
*
|
|
15
|
-
* Who may do what is the server's to decide; the entry carries hints only:
|
|
16
|
-
* rename any participant (the name is the topic label; reversible)
|
|
17
|
-
* hide/unhide anyone, for their own list only (reversible)
|
|
18
|
-
* delete the creator (`mine`) (not reversible from a screen)
|
|
19
|
-
* visibility the owner (`owner`) (opening shows what is already written)
|
|
20
|
-
* leave a member, never the owner (in a group, leaving ends reading here)
|
|
21
|
-
* restore the creator, while it is kept (deleted ones are kept `deletedDays`, shared-dock.md §9-5)
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
/** Who reads it: everyone in the domain, the people the owner brought in, or the owner alone (ADR-0073 decision 3). */
|
|
25
|
-
export type SessionVisibility = 'open' | 'group' | 'private'
|
|
26
|
-
|
|
27
|
-
/** One row of `chatSessionInbox`, as the list draws it. */
|
|
28
|
-
export interface AssistantSessionEntry {
|
|
29
|
-
id: string
|
|
30
|
-
name?: string
|
|
31
|
-
kind?: string
|
|
32
|
-
lastMessageAt?: string
|
|
33
|
-
lastMessagePreview?: string
|
|
34
|
-
previewRedacted?: boolean
|
|
35
|
-
unread?: boolean
|
|
36
|
-
participant?: boolean
|
|
37
|
-
/** I created it - only then may I delete it. */
|
|
38
|
-
mine?: boolean
|
|
39
|
-
/** I own it - only then may I change who reads it. */
|
|
40
|
-
owner?: boolean
|
|
41
|
-
/** Hidden from my own list (returned only with the hidden filter on). */
|
|
42
|
-
hidden?: boolean
|
|
43
|
-
visibility?: SessionVisibility | string
|
|
44
|
-
/** No activity for the archive period - out of the list until asked for or searched. */
|
|
45
|
-
archived?: boolean
|
|
46
|
-
/** Why the list suggests clearing it (mine only): never asked anything, or idle for 30 days. */
|
|
47
|
-
cleanupReason?: 'empty' | 'inactive' | string
|
|
48
|
-
/** Whole days since the last activity. */
|
|
49
|
-
idleDays?: number
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/** A conversation I deleted that is still kept - it can be brought back until `purgesAt`. */
|
|
53
|
-
export interface DeletedSessionEntry {
|
|
54
|
-
id: string
|
|
55
|
-
name?: string
|
|
56
|
-
kind?: string
|
|
57
|
-
deletedAt: string
|
|
58
|
-
purgesAt?: string
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/** How long conversations are kept; `null` when that keeping is off. */
|
|
62
|
-
export interface SessionKeeping {
|
|
63
|
-
deletedDays: number | null
|
|
64
|
-
archiveDays: number | null
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/** Legacy single filter - kept for callers written before the filter set. */
|
|
68
|
-
export type AssistantSessionFilter = 'all' | 'mine' | 'hidden'
|
|
69
|
-
|
|
70
|
-
/** What the manager narrows by (design/ai/shared-dock.md §2-6). Defaults: this kind, everyone's, any visibility, hidden out. */
|
|
71
|
-
export interface AssistantSessionFilters {
|
|
72
|
-
/** A kind (mode) to list; empty lists every kind on the anchor. */
|
|
73
|
-
kind?: string
|
|
74
|
-
whose?: 'all' | 'mine' | 'participant'
|
|
75
|
-
visibility?: 'all' | SessionVisibility
|
|
76
|
-
includeHidden?: boolean
|
|
77
|
-
unreadOnly?: boolean
|
|
78
|
-
/** Also the archived ones. */
|
|
79
|
-
includeArchived?: boolean
|
|
80
|
-
/** Only my own the list suggests clearing - hidden and archived ones included. */
|
|
81
|
-
cleanupOnly?: boolean
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export interface AssistantSessionQuery {
|
|
85
|
-
anchorType: string
|
|
86
|
-
anchorId: string
|
|
87
|
-
search?: string
|
|
88
|
-
filter?: AssistantSessionFilter
|
|
89
|
-
filters?: AssistantSessionFilters
|
|
90
|
-
limit?: number
|
|
91
|
-
offset?: number
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export interface AssistantSessionPage {
|
|
95
|
-
entries: AssistantSessionEntry[]
|
|
96
|
-
/** How many pass the filter - so "load more" knows whether the end of the list is the end of the data. */
|
|
97
|
-
total: number
|
|
98
|
-
/** How many I hid - so a hidden conversation is never forgotten. */
|
|
99
|
-
hiddenCount: number
|
|
100
|
-
/** How many are archived - the same, for the ones left idle. */
|
|
101
|
-
archivedCount: number
|
|
102
|
-
/** How many of mine the list suggests clearing. */
|
|
103
|
-
cleanupCount: number
|
|
104
|
-
keeping: SessionKeeping
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export interface AssistantSessionAdmin {
|
|
108
|
-
inbox(query: AssistantSessionQuery): Promise<AssistantSessionPage>
|
|
109
|
-
rename(sessionId: string, name: string): Promise<boolean>
|
|
110
|
-
hide(sessionId: string, hidden: boolean): Promise<boolean>
|
|
111
|
-
remove(sessionId: string): Promise<boolean>
|
|
112
|
-
setVisibility(sessionId: string, visibility: SessionVisibility): Promise<boolean>
|
|
113
|
-
leave(sessionId: string): Promise<boolean>
|
|
114
|
-
deleted(anchorType: string, anchorId: string): Promise<DeletedSessionEntry[]>
|
|
115
|
-
restore(sessionId: string): Promise<boolean>
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/** The page size the server allows at most (`chatSessionInbox` clamps to 200). */
|
|
119
|
-
export const SESSION_PAGE_MAX = 200
|
|
120
|
-
|
|
121
|
-
async function mutate(mutation: any, variables: Record<string, unknown>, field: string): Promise<boolean> {
|
|
122
|
-
const result = await client.mutate({ mutation, variables })
|
|
123
|
-
if (result.errors?.length) throw new Error(result.errors[0].message)
|
|
124
|
-
return result.data?.[field] === true
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/** The framework's session doors, as they are. */
|
|
128
|
-
export const assistantSessionAdmin: AssistantSessionAdmin = {
|
|
129
|
-
async inbox({ anchorType, anchorId, search, filter = 'all', filters = {}, limit = 50, offset = 0 }) {
|
|
130
|
-
const hidden = filters.includeHidden ?? filter === 'hidden'
|
|
131
|
-
const mine = filters.whose ? filters.whose === 'mine' : filter === 'mine'
|
|
132
|
-
const result = await client.query({
|
|
133
|
-
query: gql`
|
|
134
|
-
query ($t: String!, $i: String!, $h: Boolean, $q: String, $m: Boolean, $l: Int, $o: Int, $k: String, $p: Boolean, $v: String, $u: Boolean, $a: Boolean, $c: Boolean) {
|
|
135
|
-
hiddenSessionCount(anchorType: $t, anchorId: $i)
|
|
136
|
-
archivedSessionCount(anchorType: $t, anchorId: $i)
|
|
137
|
-
cleanupSessionCount(anchorType: $t, anchorId: $i)
|
|
138
|
-
aiSessionKeeping { deletedDays archiveDays }
|
|
139
|
-
chatSessionInboxTotal(anchorType: $t, anchorId: $i, showHidden: $h, search: $q, mineOnly: $m, kind: $k, participantOnly: $p, visibility: $v, unreadOnly: $u, includeArchived: $a, cleanupOnly: $c)
|
|
140
|
-
chatSessionInbox(anchorType: $t, anchorId: $i, showHidden: $h, search: $q, mineOnly: $m, kind: $k, participantOnly: $p, visibility: $v, unreadOnly: $u, includeArchived: $a, cleanupOnly: $c, limit: $l, offset: $o) {
|
|
141
|
-
id
|
|
142
|
-
name
|
|
143
|
-
kind
|
|
144
|
-
lastMessageAt
|
|
145
|
-
lastMessagePreview
|
|
146
|
-
previewRedacted
|
|
147
|
-
unread
|
|
148
|
-
participant
|
|
149
|
-
mine
|
|
150
|
-
owner
|
|
151
|
-
hidden
|
|
152
|
-
visibility
|
|
153
|
-
archived
|
|
154
|
-
cleanupReason
|
|
155
|
-
idleDays
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
`,
|
|
159
|
-
variables: {
|
|
160
|
-
t: anchorType,
|
|
161
|
-
i: anchorId,
|
|
162
|
-
/* Hidden ones only when asked - elsewhere they stay out of the list. */
|
|
163
|
-
h: hidden,
|
|
164
|
-
q: search?.trim() || null,
|
|
165
|
-
m: mine,
|
|
166
|
-
k: filters.kind || null,
|
|
167
|
-
p: filters.whose === 'participant' || null,
|
|
168
|
-
v: filters.visibility && filters.visibility !== 'all' ? filters.visibility : null,
|
|
169
|
-
u: filters.unreadOnly || null,
|
|
170
|
-
a: filters.includeArchived || null,
|
|
171
|
-
c: filters.cleanupOnly || null,
|
|
172
|
-
l: Math.min(SESSION_PAGE_MAX, Math.max(1, limit)),
|
|
173
|
-
o: Math.max(0, offset)
|
|
174
|
-
},
|
|
175
|
-
fetchPolicy: 'no-cache'
|
|
176
|
-
})
|
|
177
|
-
|
|
178
|
-
if (result.errors?.length) throw new Error(result.errors[0].message)
|
|
179
|
-
const entries = result.data?.chatSessionInbox
|
|
180
|
-
if (!Array.isArray(entries)) {
|
|
181
|
-
throw new Error(i18next.t('ai-assistant.text.sessions-unreadable', { defaultValue: 'could not load the conversation list.' }))
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
return {
|
|
185
|
-
/* With the hidden filter the server returns hidden ones alongside the rest, marked - the total counts both. */
|
|
186
|
-
entries,
|
|
187
|
-
total: result.data?.chatSessionInboxTotal ?? entries.length,
|
|
188
|
-
hiddenCount: result.data?.hiddenSessionCount ?? 0,
|
|
189
|
-
archivedCount: result.data?.archivedSessionCount ?? 0,
|
|
190
|
-
cleanupCount: result.data?.cleanupSessionCount ?? 0,
|
|
191
|
-
keeping: {
|
|
192
|
-
deletedDays: result.data?.aiSessionKeeping?.deletedDays ?? null,
|
|
193
|
-
archiveDays: result.data?.aiSessionKeeping?.archiveDays ?? null
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
},
|
|
197
|
-
|
|
198
|
-
rename(sessionId, name) {
|
|
199
|
-
return mutate(gql`mutation ($id: String!, $n: String!) { renameAISession(sessionId: $id, name: $n) }`, { id: sessionId, n: name }, 'renameAISession')
|
|
200
|
-
},
|
|
201
|
-
|
|
202
|
-
hide(sessionId, hidden) {
|
|
203
|
-
return mutate(gql`mutation ($id: String!, $h: Boolean) { hideAISession(sessionId: $id, hidden: $h) }`, { id: sessionId, h: hidden }, 'hideAISession')
|
|
204
|
-
},
|
|
205
|
-
|
|
206
|
-
remove(sessionId) {
|
|
207
|
-
return mutate(gql`mutation ($id: String!) { deleteAISession(sessionId: $id) }`, { id: sessionId }, 'deleteAISession')
|
|
208
|
-
},
|
|
209
|
-
|
|
210
|
-
setVisibility(sessionId, visibility) {
|
|
211
|
-
return mutate(
|
|
212
|
-
gql`mutation ($id: String!, $v: String!) { setSessionVisibility(sessionId: $id, visibility: $v) }`,
|
|
213
|
-
{ id: sessionId, v: visibility },
|
|
214
|
-
'setSessionVisibility'
|
|
215
|
-
)
|
|
216
|
-
},
|
|
217
|
-
|
|
218
|
-
leave(sessionId) {
|
|
219
|
-
return mutate(gql`mutation ($id: String!) { leaveAISession(sessionId: $id) }`, { id: sessionId }, 'leaveAISession')
|
|
220
|
-
},
|
|
221
|
-
|
|
222
|
-
async deleted(anchorType, anchorId) {
|
|
223
|
-
const result = await client.query({
|
|
224
|
-
query: gql`
|
|
225
|
-
query ($t: String!, $i: String!) {
|
|
226
|
-
deletedAISessions(anchorType: $t, anchorId: $i) { id name kind deletedAt purgesAt }
|
|
227
|
-
}
|
|
228
|
-
`,
|
|
229
|
-
variables: { t: anchorType, i: anchorId },
|
|
230
|
-
fetchPolicy: 'no-cache'
|
|
231
|
-
})
|
|
232
|
-
if (result.errors?.length) throw new Error(result.errors[0].message)
|
|
233
|
-
return result.data?.deletedAISessions ?? []
|
|
234
|
-
},
|
|
235
|
-
|
|
236
|
-
restore(sessionId) {
|
|
237
|
-
return mutate(gql`mutation ($id: String!) { restoreAISession(sessionId: $id) }`, { id: sessionId }, 'restoreAISession')
|
|
238
|
-
}
|
|
239
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* What this guards: opening a conversation marks it read, wherever the panel is mounted.
|
|
3
|
-
*
|
|
4
|
-
* Read position is a fact other participants see — the unread dot, the bold row in the list. Only
|
|
5
|
-
* the twin dock called it, by hand, at one of the four places a conversation becomes the open one.
|
|
6
|
-
* Once a mention can bring someone into a figure or plant conversation, three screens telling
|
|
7
|
-
* different stories about "read" is the same defect in three places.
|
|
8
|
-
*/
|
|
9
|
-
import { AssistantSessionController } from './assistant-session-controller'
|
|
10
|
-
|
|
11
|
-
const target = { scope: 'scope-1', anchorType: 'figure', anchorId: 'fig-1' }
|
|
12
|
-
|
|
13
|
-
function controller(sessions: any[] = [{ id: 's1', name: 'first' }]) {
|
|
14
|
-
const read: string[] = []
|
|
15
|
-
const store = new Map<string, string>()
|
|
16
|
-
const transport = {
|
|
17
|
-
list: async () => sessions,
|
|
18
|
-
create: async () => ({ id: 's2', name: 'new' }),
|
|
19
|
-
isEmpty: async () => false,
|
|
20
|
-
markRead: async (sessionId: string) => {
|
|
21
|
-
read.push(sessionId)
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
const instance = new AssistantSessionController(
|
|
25
|
-
transport as any,
|
|
26
|
-
() => {},
|
|
27
|
-
{ getItem: key => store.get(key) ?? null, setItem: (key, value) => store.set(key, value) }
|
|
28
|
-
)
|
|
29
|
-
return { instance, read, transport }
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
it('★ opening a conversation marks it read', async () => {
|
|
33
|
-
const { instance, read } = controller()
|
|
34
|
-
|
|
35
|
-
await instance.open(target)
|
|
36
|
-
|
|
37
|
-
expect(read).toEqual(['s1'])
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
it('★ switching to another conversation marks that one', async () => {
|
|
41
|
-
const { instance, read } = controller([{ id: 's1' }, { id: 's9' }])
|
|
42
|
-
await instance.open(target)
|
|
43
|
-
|
|
44
|
-
instance.select('s9')
|
|
45
|
-
|
|
46
|
-
expect(read).toEqual(['s1', 's9'])
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
it('the same conversation staying open is not marked again', async () => {
|
|
50
|
-
const { instance, read } = controller()
|
|
51
|
-
await instance.open(target)
|
|
52
|
-
|
|
53
|
-
instance.select('s1')
|
|
54
|
-
|
|
55
|
-
expect(read).toEqual(['s1'])
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
it('★ a transport that cannot mark read does not break opening a conversation', async () => {
|
|
59
|
-
const { instance } = controller()
|
|
60
|
-
;(instance as any).transport.markRead = async () => {
|
|
61
|
-
throw new Error('offline')
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
await expect(instance.open(target)).resolves.toBeUndefined()
|
|
65
|
-
expect(instance.state.sessionId).toBe('s1')
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
it('a host with no markRead at all still works — it is optional', async () => {
|
|
69
|
-
const { instance } = controller()
|
|
70
|
-
;(instance as any).transport.markRead = undefined
|
|
71
|
-
|
|
72
|
-
await instance.open(target)
|
|
73
|
-
|
|
74
|
-
expect(instance.state.sessionId).toBe('s1')
|
|
75
|
-
})
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
export interface AssistantSession {
|
|
2
|
-
id: string
|
|
3
|
-
name?: string
|
|
4
|
-
/**
|
|
5
|
-
* 어느 대화인가 — 등록된 모드의 kind (ADR-0072 결정 3).
|
|
6
|
-
*
|
|
7
|
-
* 목록은 한 대상의 대화를 **모두** 보여 준다. 그 대상 위에 대화가 둘 설 수 있으므로(A17), 고른 것이
|
|
8
|
-
* 지금 열려 있는 대화와 다를 수 있다. 그때 화면은 그 대화로 따라가야 한다 — 안 그러면 문이 거절하고
|
|
9
|
-
* (`session-kind-mismatch`), 목록은 눌리는데 안 열리는 목록이 된다.
|
|
10
|
-
*
|
|
11
|
-
* 칸이 서기 전에 난 세션에는 값이 없다. 그때는 지금 대화로 두고, 서버가 다음 턴에 찍는다.
|
|
12
|
-
*/
|
|
13
|
-
kind?: string
|
|
14
|
-
/** Who reads it: 'open' (everyone in the domain), 'group' (the people the owner brought in) or 'private' (the owner alone). The dock draws an open one apart. */
|
|
15
|
-
visibility?: string
|
|
16
|
-
/** Whether this person sits in it - `false` for someone else's open conversation the dock showed; absent on one just made. */
|
|
17
|
-
participant?: boolean
|
|
18
|
-
}
|
|
19
|
-
export interface AssistantSessionTarget {
|
|
20
|
-
/** Account/domain boundary supplied by the authenticated host. */
|
|
21
|
-
scope: string
|
|
22
|
-
anchorType: string
|
|
23
|
-
anchorId: string
|
|
24
|
-
/** The conversation kind (mode) the tabs list - all readable conversations of it, not only mine (shared dock §2-6). */
|
|
25
|
-
kind?: string
|
|
26
|
-
}
|
|
27
|
-
export interface AssistantSessionTransport {
|
|
28
|
-
list(target: AssistantSessionTarget): Promise<AssistantSession[]>
|
|
29
|
-
create(target: AssistantSessionTarget): Promise<AssistantSession>
|
|
30
|
-
isEmpty?(sessionId: string): Promise<boolean>
|
|
31
|
-
/**
|
|
32
|
-
* 이 대화를 여기까지 읽었다 — 열린 대화가 바뀔 때 한 번.
|
|
33
|
-
*
|
|
34
|
-
* 읽은 지점은 **다른 참여자에게 보이는 사실**이다(안 읽음 배지 · 목록의 굵은 글씨). 도크마다 손으로
|
|
35
|
-
* 부르던 것을 여기로 올렸다 — twin 만 부르고 있었고, 멘션으로 사람이 들어올 수 있게 된 뒤에는
|
|
36
|
-
* 세 화면이 같은 사실을 달리 말하게 된다.
|
|
37
|
-
*/
|
|
38
|
-
markRead?(sessionId: string): Promise<void> | void
|
|
39
|
-
}
|
|
40
|
-
export interface AssistantSessionState {
|
|
41
|
-
target?: AssistantSessionTarget
|
|
42
|
-
sessions: AssistantSession[]
|
|
43
|
-
sessionId: string
|
|
44
|
-
loading: boolean
|
|
45
|
-
error: string
|
|
46
|
-
/** Changes on reset, including temporary conversations without a server ID. */
|
|
47
|
-
revision: number
|
|
48
|
-
}
|
|
49
|
-
const keyOf = (target?: AssistantSessionTarget) => target
|
|
50
|
-
? JSON.stringify([target.scope, target.anchorType, target.anchorId]) : ''
|
|
51
|
-
|
|
52
|
-
/** Domain-neutral session lifecycle. Never deletes history or edits host documents. */
|
|
53
|
-
export class AssistantSessionController {
|
|
54
|
-
state: AssistantSessionState = { sessions: [], sessionId: '', loading: false, error: '', revision: 0 }
|
|
55
|
-
private generation = 0
|
|
56
|
-
private preferred = new Map<string, string>()
|
|
57
|
-
private pending = new Map<string, Promise<AssistantSession[]>>()
|
|
58
|
-
|
|
59
|
-
private transport: AssistantSessionTransport
|
|
60
|
-
private changed: (state: AssistantSessionState) => void
|
|
61
|
-
private storage?: Pick<Storage, 'getItem' | 'setItem'>
|
|
62
|
-
private lazy: boolean
|
|
63
|
-
private preparing?: Promise<string | undefined>
|
|
64
|
-
constructor(transport: AssistantSessionTransport, changed: (state: AssistantSessionState) => void,
|
|
65
|
-
storage?: Pick<Storage, 'getItem' | 'setItem'>, options: { lazy?: boolean } = {}) {
|
|
66
|
-
this.transport = transport
|
|
67
|
-
this.changed = changed
|
|
68
|
-
this.storage = storage
|
|
69
|
-
this.lazy = !!options.lazy
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
private remember(key: string, id: string) {
|
|
73
|
-
this.preferred.set(key, id)
|
|
74
|
-
try { this.storage?.setItem('assistant-session:' + key, id) } catch { /* Storage is optional. */ }
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
private preference(key: string): string | undefined {
|
|
78
|
-
try { return this.preferred.get(key) || this.storage?.getItem('assistant-session:' + key) || undefined }
|
|
79
|
-
catch { return this.preferred.get(key) }
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
private publish(patch: Partial<AssistantSessionState>) {
|
|
83
|
-
const before = this.state.sessionId
|
|
84
|
-
this.state = { ...this.state, ...patch }
|
|
85
|
-
/*
|
|
86
|
-
* 열린 대화가 바뀌면 읽음 지점을 옮긴다. 한 자리에서 하는 이유는 여는 길이 넷이기 때문이다
|
|
87
|
-
* (열기 · 고르기 · 새로 시작 · 보내며 만들기) — 갈래마다 부르면 한 곳이 빠진다.
|
|
88
|
-
*/
|
|
89
|
-
if (this.state.sessionId && this.state.sessionId !== before) void this.markRead(this.state.sessionId)
|
|
90
|
-
this.changed(this.state)
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/** 실패는 삼킨다 — 읽음 표시가 못 가는 것이 대화를 막을 이유는 아니다. */
|
|
94
|
-
private async markRead(sessionId: string): Promise<void> {
|
|
95
|
-
try {
|
|
96
|
-
await this.transport.markRead?.(sessionId)
|
|
97
|
-
} catch {
|
|
98
|
-
/* noop */
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
async open(target?: AssistantSessionTarget, force = false): Promise<void> {
|
|
103
|
-
const key = keyOf(target)
|
|
104
|
-
if (!force && key === keyOf(this.state.target) && (this.state.loading || this.state.sessionId || (this.lazy && this.state.target && !this.state.error))) return
|
|
105
|
-
const generation = ++this.generation
|
|
106
|
-
const snapshot = target ? { ...target } : undefined
|
|
107
|
-
this.publish({ target: snapshot, sessions: [], sessionId: '', loading: !!target, error: '' })
|
|
108
|
-
if (!snapshot) return
|
|
109
|
-
try {
|
|
110
|
-
let pending = this.pending.get(key)
|
|
111
|
-
if (!pending) {
|
|
112
|
-
pending = (async () => {
|
|
113
|
-
const sessions = await this.transport.list(snapshot)
|
|
114
|
-
// Failed/malformed reads must not create replacement sessions.
|
|
115
|
-
if (!Array.isArray(sessions) || sessions.some(session => !session.id)) throw new Error('Invalid session list')
|
|
116
|
-
if (sessions.length || this.lazy) return [...sessions]
|
|
117
|
-
// Do not issue a mutation for a target abandoned while the inbox was loading.
|
|
118
|
-
if (keyOf(this.state.target) !== key || this.pending.get(key) !== pending) throw new Error('Session target changed')
|
|
119
|
-
const created = await this.transport.create(snapshot)
|
|
120
|
-
if (!created?.id) throw new Error('Invalid new session')
|
|
121
|
-
return [created]
|
|
122
|
-
})()
|
|
123
|
-
this.pending.set(key, pending)
|
|
124
|
-
void pending.finally(() => {
|
|
125
|
-
if (this.pending.get(key) === pending) this.pending.delete(key)
|
|
126
|
-
}).catch(() => {})
|
|
127
|
-
}
|
|
128
|
-
const sessions = await pending
|
|
129
|
-
if (generation !== this.generation) return
|
|
130
|
-
const preference = this.preference(key)
|
|
131
|
-
const sessionId = this.lazy && preference === '__draft__' ? '' : sessions.find(session => session.id === preference)?.id || sessions[0]?.id || ''
|
|
132
|
-
this.remember(key, sessionId || '__draft__')
|
|
133
|
-
this.publish({ sessions, sessionId, loading: false })
|
|
134
|
-
} catch (error) {
|
|
135
|
-
if (generation === this.generation) this.publish({ loading: false, error: error instanceof Error ? error.message : String(error) })
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
select(id: string): boolean {
|
|
140
|
-
if (this.state.loading || !this.state.sessions.some(session => session.id === id)) return false
|
|
141
|
-
this.remember(keyOf(this.state.target), id)
|
|
142
|
-
this.publish({ sessionId: id, error: '' })
|
|
143
|
-
return true
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
async reset(): Promise<void> {
|
|
147
|
-
if (this.state.loading || this.preparing) return
|
|
148
|
-
if (this.lazy) {
|
|
149
|
-
if (!this.state.sessionId) return
|
|
150
|
-
++this.generation
|
|
151
|
-
this.remember(keyOf(this.state.target), '__draft__')
|
|
152
|
-
this.publish({ sessionId: '', error: '', revision: this.state.revision + 1 })
|
|
153
|
-
return
|
|
154
|
-
}
|
|
155
|
-
const target = this.state.target
|
|
156
|
-
if (!target) {
|
|
157
|
-
this.publish({ sessions: [], sessionId: '', error: '', revision: this.state.revision + 1 })
|
|
158
|
-
return
|
|
159
|
-
}
|
|
160
|
-
const generation = ++this.generation
|
|
161
|
-
const key = keyOf(target)
|
|
162
|
-
this.publish({ loading: true, error: '' })
|
|
163
|
-
try {
|
|
164
|
-
if (this.state.sessionId && this.transport.isEmpty) {
|
|
165
|
-
const empty = await this.transport.isEmpty(this.state.sessionId)
|
|
166
|
-
if (generation !== this.generation) return
|
|
167
|
-
if (empty) { this.publish({ loading: false }); return }
|
|
168
|
-
}
|
|
169
|
-
const session = await this.transport.create({ ...target })
|
|
170
|
-
if (!session?.id) throw new Error('Invalid new session')
|
|
171
|
-
this.remember(key, session.id)
|
|
172
|
-
if (generation !== this.generation) return
|
|
173
|
-
this.publish({ sessions: [session, ...this.state.sessions.filter(existing => existing.id !== session.id)], sessionId: session.id,
|
|
174
|
-
loading: false, revision: this.state.revision + 1 })
|
|
175
|
-
} catch (error) {
|
|
176
|
-
if (generation === this.generation) this.publish({ loading: false, error: error instanceof Error ? error.message : String(error) })
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/** Called only for a real send. Adoption happens before hosts render the new ID. */
|
|
181
|
-
prepareSession(adopt: (id: string) => void = () => {}): Promise<string | undefined> {
|
|
182
|
-
if (this.state.sessionId) return Promise.resolve(this.state.sessionId)
|
|
183
|
-
if (!this.state.target) return Promise.resolve(undefined)
|
|
184
|
-
if (this.state.loading || this.state.error) return Promise.reject(new Error('Session history is not ready'))
|
|
185
|
-
if (this.preparing) return this.preparing
|
|
186
|
-
const target = { ...this.state.target }, generation = this.generation
|
|
187
|
-
const pending = (async () => {
|
|
188
|
-
const session = await this.transport.create(target)
|
|
189
|
-
if (generation !== this.generation) throw new Error('Session target changed')
|
|
190
|
-
if (!session?.id) throw new Error('Invalid new session')
|
|
191
|
-
adopt(session.id)
|
|
192
|
-
this.remember(keyOf(target), session.id)
|
|
193
|
-
this.publish({ sessionId: session.id, sessions: [session, ...this.state.sessions] })
|
|
194
|
-
return session.id
|
|
195
|
-
})()
|
|
196
|
-
this.preparing = pending
|
|
197
|
-
void pending.finally(() => { if (this.preparing === pending) this.preparing = undefined }).catch(() => {})
|
|
198
|
-
return pending
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/** Invalidate pending UI updates at logout/disposal. Server authorization remains authoritative. */
|
|
202
|
-
clear() {
|
|
203
|
-
++this.generation
|
|
204
|
-
this.preferred.clear()
|
|
205
|
-
this.pending.clear()
|
|
206
|
-
this.publish({ target: undefined, sessions: [], sessionId: '', loading: false, error: '', revision: this.state.revision + 1 })
|
|
207
|
-
}
|
|
208
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { client } from '@operato/graphql'
|
|
2
|
-
import { i18next } from '@operato/i18n'
|
|
3
|
-
import gql from 'graphql-tag'
|
|
4
|
-
import type { AssistantSessionTransport } from './assistant-session-controller'
|
|
5
|
-
|
|
6
|
-
/** Existing authorized session API; does not introduce a product-specific storage format. */
|
|
7
|
-
export const assistantSessionTransport: AssistantSessionTransport = {
|
|
8
|
-
async isEmpty(sessionId) {
|
|
9
|
-
const result = await client.query({
|
|
10
|
-
query: gql`query($id:String!){chatMessages(sessionId:$id,limit:1){id}}`,
|
|
11
|
-
variables: { id: sessionId }, fetchPolicy: 'no-cache'
|
|
12
|
-
})
|
|
13
|
-
if (result.errors?.length) throw new Error(result.errors[0].message)
|
|
14
|
-
if (!Array.isArray(result.data?.chatMessages)) throw new Error(i18next.t('ai-assistant.text.messages-unreadable', { defaultValue: 'could not read this conversation.' }))
|
|
15
|
-
return result.data.chatMessages.length === 0
|
|
16
|
-
},
|
|
17
|
-
async list(target) {
|
|
18
|
-
const result = await client.query({
|
|
19
|
-
/*
|
|
20
|
-
* Every readable conversation of this kind on the anchor, not only mine - the same scope the manager
|
|
21
|
-
* shows by default (design/ai/shared-dock.md §2-6). Without a kind: every kind, as before.
|
|
22
|
-
*/
|
|
23
|
-
query: gql`query($type:String!,$id:String!,$kind:String){chatSessionInbox(anchorType:$type,anchorId:$id,kind:$kind,limit:100){id name kind visibility participant}}`,
|
|
24
|
-
variables: { type: target.anchorType, id: target.anchorId, kind: target.kind || null }, fetchPolicy: 'no-cache'
|
|
25
|
-
})
|
|
26
|
-
if (result.errors?.length) throw new Error(result.errors[0].message)
|
|
27
|
-
if (!Array.isArray(result.data?.chatSessionInbox)) throw new Error(i18next.t('ai-assistant.text.sessions-unreadable', { defaultValue: 'could not load the conversation list.' }))
|
|
28
|
-
return result.data.chatSessionInbox
|
|
29
|
-
},
|
|
30
|
-
async markRead(sessionId) {
|
|
31
|
-
/* 참여자가 아닌 대화(내 읽음 지점이 없는 자리)면 서버가 false 를 돌려준다 — 그것도 답이다. */
|
|
32
|
-
await client.mutate({
|
|
33
|
-
mutation: gql`mutation($id:String!){markSessionRead(sessionId:$id)}`,
|
|
34
|
-
variables: { id: sessionId }
|
|
35
|
-
})
|
|
36
|
-
},
|
|
37
|
-
async create(target) {
|
|
38
|
-
const result = await client.mutate({
|
|
39
|
-
mutation: gql`mutation($type:String!,$id:String!){createAISession(anchorType:$type,anchorId:$id){id name kind visibility}}`,
|
|
40
|
-
variables: { type: target.anchorType, id: target.anchorId }
|
|
41
|
-
})
|
|
42
|
-
if (result.errors?.length) throw new Error(result.errors[0].message)
|
|
43
|
-
if (!result.data?.createAISession?.id) throw new Error(i18next.t('ai-assistant.text.session-not-created', { defaultValue: 'could not start a conversation.' }))
|
|
44
|
-
return result.data.createAISession
|
|
45
|
-
}
|
|
46
|
-
}
|