@things-factory/ai-assistant 10.1.278 → 10.1.280
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/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 -183
- 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 -132
- 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 -509
- 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 -161
- package/server/service/people/person-subject.ts +0 -83
- 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,66 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* MySessionActivitySubscription — **내가 참여한 모든 세션**의 활동 알림.
|
|
3
|
-
*
|
|
4
|
-
* 기존 chatMessageActivity 는 그 세션을 열어 둔 구독자에게 본문을 보낸다 → 창을 닫아 두면 새 메시지를
|
|
5
|
-
* 알 수 없었다. 이 구독은 배지·목록 갱신용으로 최소 정보만 보낸다(본문 없음).
|
|
6
|
-
*
|
|
7
|
-
* 도메인 격리는 필터가, "내 것만" 은 참여자 검사가 성립시킨다(session-activity-broadcast.ts).
|
|
8
|
-
*/
|
|
9
|
-
import { Resolver, Subscription, Root, ObjectType, Field } from 'type-graphql'
|
|
10
|
-
import { filter, pipe } from 'graphql-yoga'
|
|
11
|
-
import { assertDomainSubscribeAllowed, pubsub } from '@things-factory/shell'
|
|
12
|
-
|
|
13
|
-
import { SESSION_ACTIVITY_TOPIC, sessionActivityFilter, type SessionActivityPayload } from './session-activity-broadcast.js'
|
|
14
|
-
|
|
15
|
-
export { publishSessionActivity } from './session-activity-publish.js'
|
|
16
|
-
|
|
17
|
-
@ObjectType({ description: 'Activity notice for a session the current user participates in — badge/list refresh only, no message body.' })
|
|
18
|
-
export class SessionActivity {
|
|
19
|
-
@Field({ description: 'Session that had activity.' })
|
|
20
|
-
sessionId!: string
|
|
21
|
-
|
|
22
|
-
@Field({
|
|
23
|
-
description:
|
|
24
|
-
"Kind of activity: 'message' (new message — raise the unread badge) or 'meta' (session itself changed, e.g. renamed — refresh the list but do not badge)."
|
|
25
|
-
})
|
|
26
|
-
kind!: string
|
|
27
|
-
|
|
28
|
-
@Field({ nullable: true, description: "What the session is anchored to: 'board' | 'space' | 'instance' | 'none'." })
|
|
29
|
-
anchorType?: string
|
|
30
|
-
|
|
31
|
-
@Field({ nullable: true, description: 'Id of the anchored target.' })
|
|
32
|
-
anchorId?: string
|
|
33
|
-
|
|
34
|
-
@Field({ description: 'Activity timestamp (ISO).' })
|
|
35
|
-
at!: string
|
|
36
|
-
|
|
37
|
-
@Field({ nullable: true, description: 'One-line preview (not the full body).' })
|
|
38
|
-
preview?: string
|
|
39
|
-
|
|
40
|
-
@Field({ nullable: true, description: 'User who caused the activity — clients skip badging their own.' })
|
|
41
|
-
actorId?: string
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
@Resolver(SessionActivity)
|
|
45
|
-
export class MySessionActivitySubscription {
|
|
46
|
-
@Subscription(() => SessionActivity, {
|
|
47
|
-
description:
|
|
48
|
-
'Subscribes to activity in every session the current user participates in, so a closed chat surface can still show unread badges and refresh its list.',
|
|
49
|
-
subscribe: async ({ context }) => {
|
|
50
|
-
const { domain, user } = context.state
|
|
51
|
-
await assertDomainSubscribeAllowed(domain, user, (d, u) => process.superUserGranted(d, u))
|
|
52
|
-
return pipe(pubsub.subscribe(SESSION_ACTIVITY_TOPIC), filter(sessionActivityFilter(domain.id, user.id)))
|
|
53
|
-
}
|
|
54
|
-
})
|
|
55
|
-
mySessionActivity(@Root() payload: SessionActivityPayload): SessionActivity {
|
|
56
|
-
return {
|
|
57
|
-
sessionId: payload.sessionId,
|
|
58
|
-
kind: payload.kind ?? 'message',
|
|
59
|
-
anchorType: payload.anchorType,
|
|
60
|
-
anchorId: payload.anchorId,
|
|
61
|
-
at: payload.at,
|
|
62
|
-
preview: payload.preview,
|
|
63
|
-
actorId: payload.actorId
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* 세션 앵커 순수 로직 — 리졸버와 분리.
|
|
3
|
-
*
|
|
4
|
-
* chat-session-resolver 는 type-graphql 의 **매개변수 데코레이터**(@Arg)를 쓰므로 jest 의 babel
|
|
5
|
-
* 파서가 읽지 못한다. 순수 함수를 여기 두면 단위 테스트가 가능하다(chat-echo-dedup ·
|
|
6
|
-
* chat-input-builder 와 같은 관례).
|
|
7
|
-
*
|
|
8
|
-
* **앵커란**: 대화가 무엇에 매달려 있는지. 저작 대화는 보드에, 운영 대화는 공간(사이트와 그 공간에서
|
|
9
|
-
* 도는 트윈들)에 매달린다. 앵커가 대화의 성격과 **이력 경계**를 정한다 — 보드 편집 이력에 운영
|
|
10
|
-
* 문답이 끼지 않아야 하고, 그 반대도 마찬가지다.
|
|
11
|
-
*
|
|
12
|
-
* **하위호환**: 기존 행은 앵커 컬럼이 비어 있고 boardId 만 있다. 백필하지 않고 **읽을 때** board
|
|
13
|
-
* 앵커로 간주한다(컬럼 추가만으로 끝내기 위함). 보드 앵커 세션은 anchorId 와 boardId 를 함께
|
|
14
|
-
* 쓴다(dual-write) — 기존 조회·인덱스·소비자(operato-board 등)가 그대로 동작한다.
|
|
15
|
-
*
|
|
16
|
-
* ── Why this file validates instead of casting (2026-09-09) ──────────────────────
|
|
17
|
-
* `anchorColumns` used to do `(anchorType || 'none') as SessionAnchorType`. That is a cast, not a
|
|
18
|
-
* check: the type existed and nothing enforced it, so any string reached a nullable varchar and
|
|
19
|
-
* was stored. The plant lane was about to add a product and stopped to ask which value to write,
|
|
20
|
-
* which is the only reason this was noticed — the column would have accepted whatever it sent.
|
|
21
|
-
*
|
|
22
|
-
* A wrong value here is not a wrong value in one row. The anchor decides which conversations are
|
|
23
|
-
* listed together and which history a reply may see, so a typo silently creates a second,
|
|
24
|
-
* invisible bucket: the session is written, the inbox query for the real anchor does not match
|
|
25
|
-
* it, and the conversation is simply gone from the list with no error anywhere.
|
|
26
|
-
*
|
|
27
|
-
* Two rules follow, and both are refusals rather than defaults:
|
|
28
|
-
*
|
|
29
|
-
* · An unknown anchor type throws. A default of 'none' would be worse than a typo, because it
|
|
30
|
-
* turns "you named something that does not exist" into "this conversation is about nothing".
|
|
31
|
-
* · Every anchor except 'none' requires an id. An anchor is a pointer; `('space', '')` points
|
|
32
|
-
* nowhere, and `anchorWhere` would then look for an empty string while `anchorColumns` stored
|
|
33
|
-
* NULL — the lookup misses its own row and every call creates another session.
|
|
34
|
-
*
|
|
35
|
-
* 'none' therefore means exactly one thing: **not addressable by anchor.** It is the UI state for
|
|
36
|
-
* "nothing picked yet" (twin's dock refuses to create a session while it holds 'none'), not a
|
|
37
|
-
* value a product writes because it has nothing narrower to point at. A product whose subject is
|
|
38
|
-
* the whole tenant anchors to 'domain' and holds the domain id — that conversation is listable and
|
|
39
|
-
* has a history boundary, and "unanchored" has neither.
|
|
40
|
-
*
|
|
41
|
-
* Adding a value to this set is an architect's call, not a lane's. A new anchor type means a new
|
|
42
|
-
* kind of subject a conversation can be about, and it is stored — once rows carry it, renaming it
|
|
43
|
-
* orphans them.
|
|
44
|
-
*/
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* 대화가 매달릴 수 있는 것. **저장되는 값이므로 늘리는 것은 아키텍트 판단이다.**
|
|
48
|
-
*
|
|
49
|
-
* board 보드 저작 대화 — 그 보드의 편집 이력
|
|
50
|
-
* space 공간 운영 대화 — 사이트와 그 공간에서 도는 트윈들
|
|
51
|
-
* instance 트윈 하나에 대한 대화
|
|
52
|
-
* domain 테넌트 전체가 주제인 대화 — 공장 전체 문답처럼 더 좁게 가리킬 것이 없을 때
|
|
53
|
-
* subject one subject in a 360 — `<axis>:<itemId>`: the 360 frame's axis word (ADR-0067, the shared
|
|
54
|
-
* frame; no new words are made here) and that row's uuid. Anchoring to `domain` instead
|
|
55
|
-
* would put every subject's conversations in one bucket and lose the per-subject list and
|
|
56
|
-
* history boundary (ruled 2026-09-24).
|
|
57
|
-
* none 앵커로 찾을 수 없는 대화. 「아직 아무것도 고르지 않았다」는 화면 상태다
|
|
58
|
-
*/
|
|
59
|
-
// Figure-specific history requested explicitly: reuse the existing varchar
|
|
60
|
-
// anchor columns, without writing Figure ids into the legacy boardId column.
|
|
61
|
-
export const SESSION_ANCHOR_TYPES = ['board', 'figure', 'application', 'space', 'instance', 'domain', 'subject', 'none'] as const
|
|
62
|
-
|
|
63
|
-
export type SessionAnchorType = (typeof SESSION_ANCHOR_TYPES)[number]
|
|
64
|
-
|
|
65
|
-
export function isSessionAnchorType(value: unknown): value is SessionAnchorType {
|
|
66
|
-
return typeof value === 'string' && (SESSION_ANCHOR_TYPES as readonly string[]).includes(value)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function assertAnchorType(anchorType: string | undefined, where: string): SessionAnchorType {
|
|
70
|
-
const type = anchorType || 'none'
|
|
71
|
-
if (!isSessionAnchorType(type)) {
|
|
72
|
-
throw new Error(
|
|
73
|
-
`[board-ai/session-anchor] ${where}: '${type}' is not an anchor type. ` +
|
|
74
|
-
`Allowed: ${SESSION_ANCHOR_TYPES.join(' · ')}. ` +
|
|
75
|
-
'The anchor decides which conversations are listed together and which history a reply may see, ' +
|
|
76
|
-
'so an unrecognised value would write a session the inbox can never find. ' +
|
|
77
|
-
'If a new kind of subject is needed, raise it — this set is stored in rows.'
|
|
78
|
-
)
|
|
79
|
-
}
|
|
80
|
-
return type
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* A `subject` anchor id is `<axis>:<itemId>`, the item being that row's uuid (ruled 2026-09-24).
|
|
85
|
-
*
|
|
86
|
-
* Checked because the shape is the whole contract: a screen that passes what it shows — an EPC like
|
|
87
|
-
* `urn:epc:id:sgtin:…`, or an order's name — would store a pointer to nothing stable. A name changes
|
|
88
|
-
* and the conversation is orphaned; an EPC splits on its own colons. Refused here, on write and on
|
|
89
|
-
* read, rather than stored and never found.
|
|
90
|
-
*/
|
|
91
|
-
const SUBJECT_ANCHOR_ID = /^[a-z][a-z0-9-]*:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i
|
|
92
|
-
|
|
93
|
-
function assertSubjectAnchorId(type: SessionAnchorType, id: string | undefined, where: string): void {
|
|
94
|
-
if (type !== 'subject' || !id || SUBJECT_ANCHOR_ID.test(id)) return
|
|
95
|
-
throw new Error(
|
|
96
|
-
`[ai-assistant/session-anchor] ${where}: '${id}' is not a subject anchor. ` +
|
|
97
|
-
"A subject anchor is '<axis>:<itemId>' — the 360 frame's axis word and the row's uuid, " +
|
|
98
|
-
"for example 'items:6f1c…'. Resolve what the screen shows (an EPC, a name) to the row's uuid first."
|
|
99
|
-
)
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/** 앵커 → 저장할 컬럼 값. 보드 앵커는 boardId 에도 같은 값을 넣어 기존 조회가 그대로 동작하게 한다. */
|
|
103
|
-
export function anchorColumns(
|
|
104
|
-
anchorType: string | undefined,
|
|
105
|
-
anchorId: string | undefined
|
|
106
|
-
): { anchorType: SessionAnchorType; anchorId?: string; boardId?: string } {
|
|
107
|
-
const type = assertAnchorType(anchorType, 'anchorColumns')
|
|
108
|
-
const id = anchorId || undefined
|
|
109
|
-
if (type !== 'none' && !id) {
|
|
110
|
-
throw new Error(
|
|
111
|
-
`[board-ai/session-anchor] anchorColumns: anchor '${type}' was given no id. ` +
|
|
112
|
-
'An anchor is a pointer, so this would store NULL while the lookup searches for the id it was ' +
|
|
113
|
-
'given — the session would not be found by its own anchor and every call would create another. ' +
|
|
114
|
-
"Use 'none' for a conversation that is deliberately not addressable by anchor."
|
|
115
|
-
)
|
|
116
|
-
}
|
|
117
|
-
assertSubjectAnchorId(type, id, 'anchorColumns')
|
|
118
|
-
return { anchorType: type, anchorId: id, boardId: type === 'board' ? id : undefined }
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* 앵커 조회 조건. 보드 앵커는 **앵커 컬럼이 빈 옛 행도 잡아야** 하므로 boardId 로 찾는다
|
|
123
|
-
* (dual-write 덕분에 신규 행도 같은 조건에 걸린다). 그 밖 앵커는 앵커 컬럼으로 찾는다.
|
|
124
|
-
*
|
|
125
|
-
* 여기서도 앵커 이름을 검사한다 — 읽기 경로에서 틀린 이름은 오류가 아니라 **0 행**으로 나오고,
|
|
126
|
-
* 화면은 「대화가 없다」로 그린다. 그 증상으로는 원인을 못 찾는다.
|
|
127
|
-
*/
|
|
128
|
-
/**
|
|
129
|
-
* 이 앵커의 세션을 찾는 조건 — `kind` 를 주면 **그 대화의** 세션만 본다(ADR-0072 결정 3).
|
|
130
|
-
*
|
|
131
|
-
* 한 대상 위에 대화가 둘 설 수 있게 되면서(A17), 앵커만으로 찾으면 저작 대화를 찾는 자리에서 운영
|
|
132
|
-
* 대화가 잡힌다. figure 에서 그것이 화면으로 나왔다 — 모드를 바꿨는데 같은 세션이 그대로 남아 새 말이
|
|
133
|
-
* 앞 대화에 붙었다(2026-09-18, Figure 레인 :3300).
|
|
134
|
-
*
|
|
135
|
-
* `kind` 를 안 주면 앵커의 대화를 모두 본다 — 목록처럼 대화를 가리지 않고 훑는 자리다.
|
|
136
|
-
*/
|
|
137
|
-
export function anchorWhere(domainId: string, anchorType: string, anchorId: string, kind?: string): any {
|
|
138
|
-
const type = assertAnchorType(anchorType, 'anchorWhere')
|
|
139
|
-
assertSubjectAnchorId(type, anchorId, 'anchorWhere')
|
|
140
|
-
const where = type === 'board' ? { boardId: anchorId, domain: { id: domainId } } : { anchorType: type, anchorId, domain: { id: domainId } }
|
|
141
|
-
return kind ? { ...where, kind } : where
|
|
142
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* A conversation's files - stored in attachment-base, opened only through the conversation.
|
|
3
|
-
*
|
|
4
|
-
* Files are kept with `refType: 'chat-session'`, `refBy: <session id>` (design/ai/shared-dock.md §9-2).
|
|
5
|
-
* They are never handed out through attachment-base's own route: that route is public and unauthenticated
|
|
6
|
-
* (routes.ts, "TODO make this secure"), so a private conversation's file would leave the conversation.
|
|
7
|
-
* Every read here passes the conversation's gate first (§9-3); this module only does the storage part.
|
|
8
|
-
*/
|
|
9
|
-
import { Attachment, STORAGE, createAttachment } from '@things-factory/attachment-base'
|
|
10
|
-
import { getRepository } from '@things-factory/shell'
|
|
11
|
-
|
|
12
|
-
import { attachmentKindOf, TEXT_CHARS_FOR_MODEL } from './attachment-policy.js'
|
|
13
|
-
|
|
14
|
-
export const CHAT_ATTACHMENT_REF = 'chat-session'
|
|
15
|
-
|
|
16
|
-
export interface StoredChatAttachment {
|
|
17
|
-
id: string
|
|
18
|
-
name: string
|
|
19
|
-
mimetype: string
|
|
20
|
-
size: number
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function describeAttachment(row: any): StoredChatAttachment {
|
|
24
|
-
return { id: row.id, name: row.name, mimetype: row.mimetype, size: Number(row.size) || 0 }
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/** Stores uploaded files under the conversation. The caller has passed the write gate and the mode's policy. */
|
|
28
|
-
export async function saveChatAttachments(sessionId: string, files: any[], context: any): Promise<StoredChatAttachment[]> {
|
|
29
|
-
const saved: StoredChatAttachment[] = []
|
|
30
|
-
for (const file of files) {
|
|
31
|
-
const row = await createAttachment(null, { attachment: { file, category: 'chat', refType: CHAT_ATTACHMENT_REF, refBy: sessionId } }, context)
|
|
32
|
-
saved.push(describeAttachment(row))
|
|
33
|
-
}
|
|
34
|
-
return saved
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/** One file of the conversation - `undefined` when it is not this conversation's. */
|
|
38
|
-
export async function findChatAttachment(domainId: string, sessionId: string, attachmentId: string): Promise<any | undefined> {
|
|
39
|
-
return (
|
|
40
|
-
(await getRepository(Attachment).findOne({
|
|
41
|
-
where: { id: attachmentId, domain: { id: domainId }, refType: CHAT_ATTACHMENT_REF, refBy: sessionId } as any
|
|
42
|
-
})) ?? undefined
|
|
43
|
-
)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* What the model gets for a file: an image as bytes, a text file as its text (cut at the mode's maxChars -
|
|
48
|
-
* TEXT_CHARS_FOR_MODEL when it declares none -
|
|
49
|
-
* and the cut is said), anything else as a line that names it.
|
|
50
|
-
*/
|
|
51
|
-
export async function attachmentForModel(row: any, maxChars: number = TEXT_CHARS_FOR_MODEL): Promise<
|
|
52
|
-
| { type: 'image'; data: Buffer; mediaType: string; name: string }
|
|
53
|
-
| { type: 'text'; text: string; name: string; truncated: boolean }
|
|
54
|
-
> {
|
|
55
|
-
const kind = attachmentKindOf({ type: row.mimetype, name: row.name })
|
|
56
|
-
if (kind === 'image') {
|
|
57
|
-
const data = await STORAGE.readFile(row.path)
|
|
58
|
-
return { type: 'image', data: Buffer.isBuffer(data) ? data : Buffer.from(data), mediaType: row.mimetype, name: row.name }
|
|
59
|
-
}
|
|
60
|
-
const content = String(await STORAGE.readFile(row.path, 'utf8'))
|
|
61
|
-
const truncated = content.length > maxChars
|
|
62
|
-
return { type: 'text', text: truncated ? content.slice(0, maxChars) : content, name: row.name, truncated }
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/** Removes these files from storage and their rows. */
|
|
66
|
-
export async function removeAttachmentRows(ids: string[]): Promise<void> {
|
|
67
|
-
if (!ids.length) return
|
|
68
|
-
const rows = await getRepository(Attachment).find({ where: ids.map(id => ({ id, refType: CHAT_ATTACHMENT_REF })) as any })
|
|
69
|
-
for (const row of rows) {
|
|
70
|
-
try {
|
|
71
|
-
await STORAGE.deleteFile((row as any).path)
|
|
72
|
-
} catch {
|
|
73
|
-
/* already gone from storage */
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
if (rows.length) await getRepository(Attachment).delete(rows.map(row => (row as any).id))
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/** Removes a conversation's files from storage and their rows - the purge's part (§9-5). */
|
|
80
|
-
export async function removeSessionFiles(session: { id?: string; domain?: { id?: string } }): Promise<void> {
|
|
81
|
-
const rows = await getRepository(Attachment).find({ where: { refType: CHAT_ATTACHMENT_REF, refBy: session.id } as any })
|
|
82
|
-
for (const row of rows) {
|
|
83
|
-
try {
|
|
84
|
-
await STORAGE.deleteFile((row as any).path)
|
|
85
|
-
} catch {
|
|
86
|
-
/* A file already gone from storage must not keep its row alive. */
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
if (rows.length) await getRepository(Attachment).delete(rows.map(row => (row as any).id))
|
|
90
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/* Keeping the conversation list short - design/ai/shared-dock.md §2-7. */
|
|
2
|
-
|
|
3
|
-
import { listedEntries } from './session-inbox'
|
|
4
|
-
import { archiveDaysOf, cleanupReason, DEFAULT_ARCHIVE_DAYS, emptyAndAbandoned, idleDays, isArchived } from './session-cleanup'
|
|
5
|
-
|
|
6
|
-
const now = new Date('2026-10-25T12:00:00Z')
|
|
7
|
-
const daysAgo = (days: number) => new Date(now.getTime() - days * 24 * 60 * 60 * 1000)
|
|
8
|
-
|
|
9
|
-
describe('archive', () => {
|
|
10
|
-
it('defaults to 60 days and reads a positive number; 0 or false turns it off', () => {
|
|
11
|
-
expect(DEFAULT_ARCHIVE_DAYS).toBe(60)
|
|
12
|
-
expect(archiveDaysOf(undefined)).toBe(60)
|
|
13
|
-
expect(archiveDaysOf('90')).toBe(90)
|
|
14
|
-
expect(archiveDaysOf(0)).toBeNull()
|
|
15
|
-
expect(archiveDaysOf(false)).toBeNull()
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
it('counts idle days from the last message, or from the start when there is none', () => {
|
|
19
|
-
expect(idleDays({ lastMessageAt: daysAgo(3), createdAt: daysAgo(100) }, now)).toBe(3)
|
|
20
|
-
expect(idleDays({ lastMessageAt: null, createdAt: daysAgo(7) }, now)).toBe(7)
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
it('archives after the period without activity, and a new message brings it back', () => {
|
|
24
|
-
expect(isArchived({ lastMessageAt: daysAgo(60) }, now, 60)).toBe(true)
|
|
25
|
-
expect(isArchived({ lastMessageAt: daysAgo(59) }, now, 60)).toBe(false)
|
|
26
|
-
expect(isArchived({ lastMessageAt: daysAgo(400) }, now, null)).toBe(false)
|
|
27
|
-
})
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
describe('what the list suggests clearing', () => {
|
|
31
|
-
it('suggests only my own conversations', () => {
|
|
32
|
-
expect(cleanupReason({ mine: false, lastMessageAt: null, createdAt: daysAgo(5) }, now)).toBeNull()
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
it('an empty one, and one idle for 30 days', () => {
|
|
36
|
-
expect(cleanupReason({ mine: true, lastMessageAt: null, createdAt: daysAgo(0) }, now)).toBe('empty')
|
|
37
|
-
expect(cleanupReason({ mine: true, lastMessageAt: daysAgo(30) }, now)).toBe('inactive')
|
|
38
|
-
expect(cleanupReason({ mine: true, lastMessageAt: daysAgo(29) }, now)).toBeNull()
|
|
39
|
-
})
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
describe('the empty conversations the daily job removes', () => {
|
|
43
|
-
const empty = { lastMessageAt: null, messages: 0, createdAt: daysAgo(2), lastTouchedAt: daysAgo(2) }
|
|
44
|
-
|
|
45
|
-
it('removes one never asked anything and not opened for a day', () => {
|
|
46
|
-
expect(emptyAndAbandoned(empty, now)).toBe(true)
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
it('keeps one with any message, even when the activity column was never written', () => {
|
|
50
|
-
expect(emptyAndAbandoned({ ...empty, messages: 1 }, now)).toBe(false)
|
|
51
|
-
expect(emptyAndAbandoned({ ...empty, lastMessageAt: daysAgo(2) }, now)).toBe(false)
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
it('keeps one started today, or opened today', () => {
|
|
55
|
-
expect(emptyAndAbandoned({ ...empty, createdAt: daysAgo(0) }, now)).toBe(false)
|
|
56
|
-
expect(emptyAndAbandoned({ ...empty, lastTouchedAt: daysAgo(0) }, now)).toBe(false)
|
|
57
|
-
})
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
describe('what the list stands on', () => {
|
|
61
|
-
const rows = [
|
|
62
|
-
{ id: 'live' },
|
|
63
|
-
{ id: 'old', archived: true },
|
|
64
|
-
{ id: 'hid', hidden: true },
|
|
65
|
-
{ id: 'empty', cleanupReason: 'empty', hidden: true },
|
|
66
|
-
{ id: 'idle', cleanupReason: 'inactive', archived: true }
|
|
67
|
-
]
|
|
68
|
-
const ids = (opts = {}) => listedEntries(rows, opts).map(row => row.id)
|
|
69
|
-
|
|
70
|
-
it('leaves the archived and the hidden out by default', () => {
|
|
71
|
-
expect(ids()).toEqual(['live'])
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
it('shows the archived when asked, or when searching', () => {
|
|
75
|
-
expect(ids({ includeArchived: true })).toEqual(['live', 'old', 'idle'])
|
|
76
|
-
expect(ids({ search: 'x' })).toEqual(['live', 'old', 'idle'])
|
|
77
|
-
expect(ids({ search: ' ' })).toEqual(['live'])
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
it('the suggestions are every candidate, hidden or archived', () => {
|
|
81
|
-
expect(ids({ cleanupOnly: true })).toEqual(['empty', 'idle'])
|
|
82
|
-
})
|
|
83
|
-
})
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Keeping the conversation list short - pure, tested alone (design/ai/shared-dock.md §2-7).
|
|
3
|
-
*
|
|
4
|
-
* 2026-10-25, the user: 「AI 세션관리를 좀 더 편리하게」 - many at once, suggestions of what to clear, a period after the
|
|
5
|
-
* last update. Three rules come out of it:
|
|
6
|
-
*
|
|
7
|
-
* archived No activity for `sessionArchiveDays` (default 60): the list leaves it out until asked
|
|
8
|
-
* (「보관 포함」) or searched. Nothing is written - a new message brings it back by itself.
|
|
9
|
-
* Archiving deletes nothing: a conversation holds the cards it offered and what came of them.
|
|
10
|
-
* candidate What the list suggests clearing, only among the caller's own (only the creator deletes):
|
|
11
|
-
* `empty` - no message ever; `inactive` - no activity for INACTIVE_DAYS.
|
|
12
|
-
* empty A conversation that never got a message and that nobody opened for EMPTY_DAYS is removed by the
|
|
13
|
-
* daily job - there is nothing in it to keep.
|
|
14
|
-
*/
|
|
15
|
-
import { DAY_MS } from './session-retention.js'
|
|
16
|
-
|
|
17
|
-
export const DEFAULT_ARCHIVE_DAYS = 60
|
|
18
|
-
/** A conversation of mine is suggested for clearing after this many days without activity. */
|
|
19
|
-
export const INACTIVE_DAYS = 30
|
|
20
|
-
/** An empty conversation nobody touched for this long is removed. */
|
|
21
|
-
export const EMPTY_DAYS = 1
|
|
22
|
-
|
|
23
|
-
export type CleanupReason = 'empty' | 'inactive'
|
|
24
|
-
|
|
25
|
-
interface Activity {
|
|
26
|
-
lastMessageAt?: Date | string | null
|
|
27
|
-
createdAt?: Date | string | null
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function time(value: Date | string | null | undefined): number {
|
|
31
|
-
if (!value) return 0
|
|
32
|
-
const at = value instanceof Date ? value.getTime() : Date.parse(value)
|
|
33
|
-
return Number.isFinite(at) ? at : 0
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/** The archive period the config asks for: a positive number of days, `null` when archiving is off, the default otherwise. */
|
|
37
|
-
export function archiveDaysOf(value: unknown): number | null {
|
|
38
|
-
if (value === false || value === 0 || value === '0') return null
|
|
39
|
-
const days = Number(value)
|
|
40
|
-
return Number.isFinite(days) && days > 0 ? days : DEFAULT_ARCHIVE_DAYS
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/** Whole days since the conversation last moved - its last message, or its start when it has none. */
|
|
44
|
-
export function idleDays(session: Activity, now: Date): number {
|
|
45
|
-
const last = time(session.lastMessageAt) || time(session.createdAt)
|
|
46
|
-
return last ? Math.floor((now.getTime() - last) / DAY_MS) : 0
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function isArchived(session: Activity, now: Date, archiveDays: number | null): boolean {
|
|
50
|
-
return archiveDays !== null && idleDays(session, now) >= archiveDays
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/** Why the list suggests clearing this conversation, or `null`. Only one the caller started - only the creator deletes. */
|
|
54
|
-
export function cleanupReason(session: Activity & { mine?: boolean }, now: Date): CleanupReason | null {
|
|
55
|
-
if (!session.mine) return null
|
|
56
|
-
if (!time(session.lastMessageAt)) return 'empty'
|
|
57
|
-
return idleDays(session, now) >= INACTIVE_DAYS ? 'inactive' : null
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Whether the daily job removes an empty conversation: no message, started more than EMPTY_DAYS ago, and no seat in it
|
|
62
|
-
* touched since (opening a conversation marks its reader's seat). A dock holding it open the same day keeps it.
|
|
63
|
-
*/
|
|
64
|
-
export function emptyAndAbandoned(session: Activity & { messages: number; lastTouchedAt?: Date | string | null }, now: Date): boolean {
|
|
65
|
-
if (session.messages > 0 || time(session.lastMessageAt)) return false
|
|
66
|
-
const cutoff = now.getTime() - EMPTY_DAYS * DAY_MS
|
|
67
|
-
const started = time(session.createdAt)
|
|
68
|
-
return !!started && started < cutoff && time(session.lastTouchedAt) < cutoff
|
|
69
|
-
}
|