@things-factory/ai-assistant 10.1.278 → 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/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,88 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The application's help documents, for the assistant (ADR-0181) - the same index the screen's `?` asks
|
|
3
|
-
* (@things-factory/help). How to do a piece of work, which screen it is on, what a word means: the model finds the part
|
|
4
|
-
* and reads it, rather than the mode's prompt carrying the manual.
|
|
5
|
-
*
|
|
6
|
-
* The help is no one's secret - every screen's `?` opens it for whoever is there - so the tools reach no door. Whether
|
|
7
|
-
* the person may open the screen a part names is still that screen's own door. A source's parts - the company's rules
|
|
8
|
-
* (ADR-0187 decision 12) - are found only where the source lets the person read them; they open where the source says.
|
|
9
|
-
*/
|
|
10
|
-
import { registerToolCategory, type ToolCategory, type ToolSpec } from '@things-factory/ai-client-base'
|
|
11
|
-
import { readHelp, searchHelp } from '@things-factory/help'
|
|
12
|
-
|
|
13
|
-
import { HELP_CATEGORY } from './help-keys.js'
|
|
14
|
-
|
|
15
|
-
/** Where a part opens in the application - the help page at that part. */
|
|
16
|
-
export const helpLink = (topic: string, section = '') => `help?topic=${encodeURIComponent(topic)}${section ? `§ion=${encodeURIComponent(section)}` : ''}`
|
|
17
|
-
|
|
18
|
-
const languageOf = (context: any): string | undefined => context?.state?.lng || context?.state?.language || undefined
|
|
19
|
-
|
|
20
|
-
export async function searchHelpDocuments(args: { query?: string; limit?: number }, context?: any) {
|
|
21
|
-
const query = String(args?.query ?? '').trim()
|
|
22
|
-
if (!query) return { found: 0, parts: [], message: 'name what to look for.' }
|
|
23
|
-
const parts = (await searchHelp(query, { lang: languageOf(context), limit: Math.min(Math.max(Number(args?.limit) || 5, 1), 10), context })).map(hit => ({
|
|
24
|
-
topic: hit.topic,
|
|
25
|
-
section: hit.section,
|
|
26
|
-
title: hit.documentTitle === hit.title ? hit.title : `${hit.documentTitle} › ${hit.title}`,
|
|
27
|
-
summary: hit.summary,
|
|
28
|
-
link: hit.link ?? helpLink(hit.topic, hit.section)
|
|
29
|
-
}))
|
|
30
|
-
return parts.length ? { found: parts.length, parts } : { found: 0, parts: [], message: 'the help has nothing on this - say so; do not answer from general knowledge as if it were this application.' }
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export async function readHelpDocument(args: { topic?: string; section?: string }, context?: any) {
|
|
34
|
-
const topic = String(args?.topic ?? '').trim()
|
|
35
|
-
const section = String(args?.section ?? '').trim()
|
|
36
|
-
const part = topic ? await readHelp(topic, section, languageOf(context), context) : null
|
|
37
|
-
if (!part) return { found: false, message: `no help part ${topic}${section ? `#${section}` : ''} - search again with searchHelp.` }
|
|
38
|
-
return { found: true, ...part, link: part.link ?? helpLink(part.topic, part.section) }
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const searchSpec = {
|
|
42
|
-
kind: 'read',
|
|
43
|
-
name: 'searchHelp',
|
|
44
|
-
doors: [],
|
|
45
|
-
description:
|
|
46
|
-
"Search this application's help and manuals (how to do a piece of work, which screen and menu it is on, what a term means). " +
|
|
47
|
-
'Returns the matching parts with a one-line summary and a link; read one with readHelp.',
|
|
48
|
-
schema: {
|
|
49
|
-
type: 'object',
|
|
50
|
-
properties: {
|
|
51
|
-
query: { type: 'string', description: 'The words to look for, in the language of the help - a screen or menu name, a task, a term ("지출결의 지급", "휴가 신청").' },
|
|
52
|
-
limit: { type: 'number', description: 'How many parts, 1-10. Default 5.' }
|
|
53
|
-
},
|
|
54
|
-
required: ['query']
|
|
55
|
-
},
|
|
56
|
-
builder: (args: any, context: any) => searchHelpDocuments(args, context)
|
|
57
|
-
} as ToolSpec
|
|
58
|
-
|
|
59
|
-
const readSpec = {
|
|
60
|
-
kind: 'read',
|
|
61
|
-
name: 'readHelp',
|
|
62
|
-
doors: [],
|
|
63
|
-
description: 'Read one part of the help (topic and section from searchHelp), or the whole document when section is left out.',
|
|
64
|
-
schema: {
|
|
65
|
-
type: 'object',
|
|
66
|
-
properties: {
|
|
67
|
-
topic: { type: 'string', description: 'The topic from searchHelp ("office/guide-employee").' },
|
|
68
|
-
section: { type: 'string', description: 'The section from searchHelp ("leave"). Leave out for the whole document.' }
|
|
69
|
-
},
|
|
70
|
-
required: ['topic']
|
|
71
|
-
},
|
|
72
|
-
builder: (args: any, context: any) => readHelpDocument(args, context)
|
|
73
|
-
} as ToolSpec
|
|
74
|
-
|
|
75
|
-
export const helpCategory: ToolCategory = {
|
|
76
|
-
name: HELP_CATEGORY,
|
|
77
|
-
description: "the application's help and manuals",
|
|
78
|
-
guidance: [
|
|
79
|
-
'- When the person asks how to do something in this application, where a screen or menu is, what the steps are, or what a term on a screen means, call searchHelp, then readHelp on the part that answers it - before you answer.',
|
|
80
|
-
'- Answer from what readHelp returned, in your own short words, and end with the part as a link: [its title](its link). Never invent a menu, a button or a step the help does not name.',
|
|
81
|
-
'- When searchHelp finds nothing, say the help does not cover it; then answer only what your other tools show.',
|
|
82
|
-
'- The help says how the application works; figures and records still come from the other tools.',
|
|
83
|
-
"- A part of the company's own rules (a topic under regulation/) is the company's: answer with the article and its effective day as a link. Where the guidance on the law and the company's rule read differently, show both and do not judge between them."
|
|
84
|
-
].join('\n'),
|
|
85
|
-
specs: [searchSpec, readSpec]
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
registerToolCategory(helpCategory)
|
package/server/service/index.ts
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { ChatSessionResolver } from './chat-session-resolver.js'
|
|
2
|
-
import { AssistantChatResolver } from './assistant-chat-resolver.js'
|
|
3
|
-
import { AssistantModeResolver } from './assistant-mode/assistant-mode-resolver.js'
|
|
4
|
-
import { AssistantCapabilityResolver } from './assistant-capability-resolver.js'
|
|
5
|
-
import { AiAgentResolver } from './ai-agent-resolver.js'
|
|
6
|
-
import { MySessionActivitySubscription } from './chat-session/session-activity-subscription.js'
|
|
7
|
-
import { ChatMessageSubscription } from './chat-message/chat-message-subscription.js'
|
|
8
|
-
import { ChatTypingSubscription } from './chat-message/chat-typing-subscription.js'
|
|
9
|
-
import { entities as ChatSessionEntities } from './chat-session/index.js'
|
|
10
|
-
import { entities as ChatMessageEntities } from './chat-message/index.js'
|
|
11
|
-
import { entities as ChatSessionParticipantEntities } from './chat-session-participant/index.js'
|
|
12
|
-
import './chat-session/attachment-tools.js'
|
|
13
|
-
import './chat-session/session-purge.js'
|
|
14
|
-
import './chat-session/attachment-route.js'
|
|
15
|
-
import { EntryProposalResolver } from './data-entry/entry-resolver.js'
|
|
16
|
-
import './workspace/workspace-tools.js'
|
|
17
|
-
import './help-documents/help-tools.js'
|
|
18
|
-
/* Who works here, and the card that brings one of them into a conversation - every conversation carries both. */
|
|
19
|
-
import './people/index.js'
|
|
20
|
-
import { entities as UnattendedRunEntities } from './unattended-run/index.js'
|
|
21
|
-
|
|
22
|
-
export * from './types.js'
|
|
23
|
-
export * from './chat-session-resolver.js'
|
|
24
|
-
export * from './assistant-chat-resolver.js'
|
|
25
|
-
/* The mode registry — each app server declares what its conversations are (ADR-0061 decision 7). */
|
|
26
|
-
export * from './assistant-mode/index.js'
|
|
27
|
-
export { requestTranslator } from './request-translator.js'
|
|
28
|
-
export * from './assistant-capability-resolver.js'
|
|
29
|
-
/*
|
|
30
|
-
* 대화 각본 하네스는 **런타임 export 에서 뺀다**(ADR-0070 A15 결정 ④) — 시험 도구가 서버 번들에
|
|
31
|
-
* 실린다. 시험은 경로로 가져온다: `…/service/testing/conversation-script.js`.
|
|
32
|
-
*/
|
|
33
|
-
export * from './tool-access.js'
|
|
34
|
-
/* Data entry from material - an app registers what it can enter; a mode names it (design/ai/data-entry.md). */
|
|
35
|
-
export * from './data-entry/entry-target.js'
|
|
36
|
-
export { registerEntryTarget, entryCategoryOf, runAsCaller } from './data-entry/entry-tools.js'
|
|
37
|
-
/* An application's tool that prepares many changes at once makes the same change card the model's would (2026-10-24). */
|
|
38
|
-
export { proposeChanges, MAX_CHANGES } from './data-entry/entry-update.js'
|
|
39
|
-
/* Reading an application's lists - an app registers what it lets read; a mode names it (design/ai/read-targets.md). */
|
|
40
|
-
export * from './data-read/read-target.js'
|
|
41
|
-
export { registerReadTarget, readCategoryOf, registerDetailRead, detailCategoryOf, runDetail, type DetailRun } from './data-read/read-tools.js'
|
|
42
|
-
export * from './data-read/list-read.js'
|
|
43
|
-
export * from './people/index.js'
|
|
44
|
-
/* The AI 작업 패널 - large results on a page of their own (design/ai/workspace.md). */
|
|
45
|
-
export * from './workspace/workspace-blocks.js'
|
|
46
|
-
/* 무엇이 근거인가 — 도구 결과 밖의 셋(프롬프트 · 대화 · 화면 스냅숏). */
|
|
47
|
-
export * from './grounding-sources.js'
|
|
48
|
-
/* 앵커 순수 로직 — 호스트가 앵커 종류를 참조한다(리졸버는 데코레이터 때문에 무겁다). */
|
|
49
|
-
export * from './chat-session/session-anchor.js'
|
|
50
|
-
/* Who may read a conversation — one rule, also asked by doors outside this package (board-ai's revertPatch). */
|
|
51
|
-
export * from './chat-session/session-visibility.js'
|
|
52
|
-
export * from './chat-session/index.js'
|
|
53
|
-
/* 순수 로직들 — 호스트(board-ai 등)가 같은 규칙을 쓰라고 공개한다. 베끼면 한쪽만 고쳐진다. */
|
|
54
|
-
export * from './chat-session/session-inbox.js'
|
|
55
|
-
export * from './chat-session/attachment-policy.js'
|
|
56
|
-
export * from './chat-session/session-purge.js'
|
|
57
|
-
export * from './chat-session/session-activity-publish.js'
|
|
58
|
-
export * from './chat-session/session-activity-broadcast.js'
|
|
59
|
-
export * from './chat-message/llm-history.js'
|
|
60
|
-
export * from './chat-message/history-summary.js'
|
|
61
|
-
export * from './chat-message/fold-history.js'
|
|
62
|
-
/* 상한 밖으로 밀려난 앞부분을 요약으로 접는 orchestration — 중립 문이 부른다. */
|
|
63
|
-
export * from './chat-message/fold-session-history.js'
|
|
64
|
-
export * from './chat-message/chat-message-publish.js'
|
|
65
|
-
export * from './chat-message/chat-message-broadcast.js'
|
|
66
|
-
export * from './chat-session-participant/invite-notification.js'
|
|
67
|
-
/* 멘션이 사람을 불러들이는 자리 — 사람의 말을 저장하는 문만 부른다(ADR-0071 결정 1). */
|
|
68
|
-
export * from './chat-session-participant/mention-invite.js'
|
|
69
|
-
export * from './chat-session-participant/presence.js'
|
|
70
|
-
export * from './chat-message/index.js'
|
|
71
|
-
export * from './chat-session-participant/index.js'
|
|
72
|
-
/* Reading the stored proposals of a conversation and whether one is answered - a package that applies its own card reads them as entry does. */
|
|
73
|
-
export { PROPOSAL_OUTCOME_PREFIX } from './chat-message/proposal-outcome.js'
|
|
74
|
-
export { assertMayWriteSession } from './chat-session/session-write-gate.js'
|
|
75
|
-
/* A mode run with no person in it - a scheduled draft (operato-application/design/ai/unattended-run.md). */
|
|
76
|
-
export * from './unattended-run/index.js'
|
|
77
|
-
|
|
78
|
-
export const entities = [...ChatSessionEntities, ...ChatMessageEntities, ...ChatSessionParticipantEntities, ...UnattendedRunEntities]
|
|
79
|
-
|
|
80
|
-
export const schema = {
|
|
81
|
-
resolverClasses: [
|
|
82
|
-
ChatSessionResolver,
|
|
83
|
-
/* 문서를 갖지 않은 표면의 대화 — board 를 안 싣는 제품이 물어볼 수 있는 자리. */
|
|
84
|
-
AssistantChatResolver,
|
|
85
|
-
/* 화면이 자기 대화가 무엇을 주는지 묻는 자리 — 문구는 서버가 요청 로케일로 옮겨 낸다. */
|
|
86
|
-
AssistantModeResolver,
|
|
87
|
-
/* 「이 배포에 AI 가 있나 · 무엇이 선언 없이 등록됐나」 — 창구 하나(표준 A7-a). */
|
|
88
|
-
AssistantCapabilityResolver,
|
|
89
|
-
/* A domain's AI agents - the settings card and the dock's picker (design/ai/agent-settings.md). */
|
|
90
|
-
AiAgentResolver,
|
|
91
|
-
ChatMessageSubscription,
|
|
92
|
-
/* 「입력 중」 — 저장하지 않는 방의 한 줄. 듣는 사람은 메시지와 같은 방 판정을 지난다. */
|
|
93
|
-
ChatTypingSubscription,
|
|
94
|
-
/* 내가 참여한 모든 세션의 활동 — 창을 닫아 둔 표면이 배지·목록을 갱신할 수 있게. */
|
|
95
|
-
MySessionActivitySubscription,
|
|
96
|
-
/* 사람이 누른 입력 제안을 쓰는 자리 — 행마다 앱의 코드로, 그 사람의 권한으로. */
|
|
97
|
-
EntryProposalResolver
|
|
98
|
-
]
|
|
99
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The people tools every conversation carries - the people list (people-read.ts) and the invite card (invite-tools.ts).
|
|
3
|
-
* Registered once, at boot, as the AI 작업 패널 is.
|
|
4
|
-
*/
|
|
5
|
-
import { registerReadTarget } from '../data-read/read-tools.js'
|
|
6
|
-
import { peopleReadTarget } from './people-read.js'
|
|
7
|
-
import './invite-tools.js'
|
|
8
|
-
import './person-subject.js'
|
|
9
|
-
|
|
10
|
-
registerReadTarget(peopleReadTarget())
|
|
11
|
-
|
|
12
|
-
export * from './people-keys.js'
|
|
13
|
-
export { peopleReadTarget, PEOPLE_SELECTION } from './people-read.js'
|
|
14
|
-
export { PERSON_AXIS, PERSON_QUESTION_KEY, PERSON_GUIDANCE, personOfAnchor, personSeatOf, personRoomRefusal } from './person-subject.js'
|
|
15
|
-
export { proposeInvite, findPeopleNamed, inviteCategory, MAX_INVITE_CANDIDATES, type InviteCandidate } from './invite-tools.js'
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* proposeInvite - the model offers a card that brings someone into this conversation (ADR-0073 decision 3).
|
|
3
|
-
*
|
|
4
|
-
* The card is a proposal: the model seats nobody. What an assistant writes must not seat people (mention-invite.ts,
|
|
5
|
-
* rule ①), so the seat is given when a person presses the card - the dock calls `inviteToAISession` with that
|
|
6
|
-
* person's request, and the door asks `maySeat` with their seat. This tool only finds who is meant and says whether
|
|
7
|
-
* this person could press it here.
|
|
8
|
-
*
|
|
9
|
-
* Who is meant is the server's to settle, never the model's memory: the name is looked up in the organization's own
|
|
10
|
-
* list as the person (the read people-read.ts opens), so a user id the model made up is never on a card. One person
|
|
11
|
-
* by that name - the card invites them. Several - the card lists each and the person picks one; the model does not ask.
|
|
12
|
-
*/
|
|
13
|
-
import { registerToolCategory, type ToolCategory, type ToolSpec } from '@things-factory/ai-client-base'
|
|
14
|
-
import { getRepository } from '@things-factory/shell'
|
|
15
|
-
|
|
16
|
-
import { runAsCaller } from '../data-entry/entry-tools.js'
|
|
17
|
-
import type { GraphqlRunner } from '../data-entry/entry-update.js'
|
|
18
|
-
import { ChatSession } from '../chat-session/chat-session.js'
|
|
19
|
-
import { maySeat } from '../chat-session/session-visibility.js'
|
|
20
|
-
import { ChatSessionParticipant } from '../chat-session-participant/chat-session-participant.js'
|
|
21
|
-
import { isRoomRole } from '../chat-session-participant/participant-lookup-roles.js'
|
|
22
|
-
import { PEOPLE_SELECTION } from './people-read.js'
|
|
23
|
-
import { INVITE_CATEGORY } from './people-keys.js'
|
|
24
|
-
|
|
25
|
-
/** At most this many people on one card - a name that matches more is too broad to pick from. */
|
|
26
|
-
export const MAX_INVITE_CANDIDATES = 8
|
|
27
|
-
|
|
28
|
-
export interface InviteCandidate {
|
|
29
|
-
userId: string
|
|
30
|
-
name: string
|
|
31
|
-
department?: string
|
|
32
|
-
position?: string
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const PEOPLE_QUERY =
|
|
36
|
-
'query ($filters: [Filter!], $pagination: Pagination, $search: String) ' +
|
|
37
|
-
`{ employees(filters: $filters, pagination: $pagination, search: $search) { items { ${PEOPLE_SELECTION} } total } }`
|
|
38
|
-
|
|
39
|
-
const ACTIVE = { name: 'active', operator: 'eq', value: true }
|
|
40
|
-
|
|
41
|
-
const candidateOf = (row: any): InviteCandidate | undefined =>
|
|
42
|
-
row?.user?.id
|
|
43
|
-
? {
|
|
44
|
-
userId: String(row.user.id),
|
|
45
|
-
name: String(row.name ?? ''),
|
|
46
|
-
...(row.department?.name ? { department: String(row.department.name) } : {}),
|
|
47
|
-
...(row.jobPosition ? { position: String(row.jobPosition) } : {})
|
|
48
|
-
}
|
|
49
|
-
: undefined
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* The people a name means, as the person may see them: the exact name first, then the name as a search term. Only
|
|
53
|
-
* people with an account - an invite seats a user.
|
|
54
|
-
*/
|
|
55
|
-
export async function findPeopleNamed(run: GraphqlRunner, name: string): Promise<{ people: InviteCandidate[]; error?: string }> {
|
|
56
|
-
const ask = async (variables: Record<string, unknown>) => {
|
|
57
|
-
const answer = await run(PEOPLE_QUERY, { pagination: { page: 1, limit: MAX_INVITE_CANDIDATES + 1 }, ...variables })
|
|
58
|
-
if (answer.errors?.length) return { error: answer.errors.map(one => one.message).join('; ') }
|
|
59
|
-
return { rows: (answer.data?.employees?.items ?? []) as any[] }
|
|
60
|
-
}
|
|
61
|
-
const exact = await ask({ filters: [ACTIVE, { name: 'name', operator: 'eq', value: name }] })
|
|
62
|
-
if ('error' in exact) return { people: [], error: exact.error }
|
|
63
|
-
const rows = exact.rows!.length ? exact.rows! : ((await ask({ filters: [ACTIVE], search: name })) as any).rows ?? []
|
|
64
|
-
return { people: rows.map(candidateOf).filter(Boolean) as InviteCandidate[] }
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/** Why this person cannot bring anyone into this room, in their words - or nothing when they can. */
|
|
68
|
-
function seatRefusal(visibility: string | null | undefined, t: (key: string, options: any) => string): string | undefined {
|
|
69
|
-
if (visibility === 'private')
|
|
70
|
-
return t('ai-assistant.text.invite-private-refused', { defaultValue: 'a private conversation is yours alone. make it a group to bring people in.' })
|
|
71
|
-
return t('ai-assistant.text.invite-owner-only', { defaultValue: 'only the person who started this group conversation can bring people in.' })
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export async function proposeInvite(args: any, context: any, run: GraphqlRunner = runAsCaller(context)) {
|
|
75
|
-
const t = (key: string, options: any) => (typeof context?.t === 'function' ? context.t(key, options) : String(options?.defaultValue ?? key))
|
|
76
|
-
const { domain, user } = context?.state ?? {}
|
|
77
|
-
const name = typeof args?.name === 'string' ? args.name.trim() : ''
|
|
78
|
-
const wanted = typeof args?.userId === 'string' ? args.userId.trim() : ''
|
|
79
|
-
if (!name) return { rejected: true, error: 'no-name', message: 'say whom to invite - the name the person used.' }
|
|
80
|
-
|
|
81
|
-
const conversationId = context?.conversation?.id
|
|
82
|
-
const session: any = conversationId && domain?.id ? await getRepository(ChatSession).findOne({ where: { id: conversationId, domain: { id: domain.id } } as any }) : undefined
|
|
83
|
-
if (!session) return { rejected: true, error: 'no-conversation', message: 'this conversation is not stored yet, so nobody can be brought into it.' }
|
|
84
|
-
|
|
85
|
-
/* Asked before anyone is looked up: the card must be one this person can press here. */
|
|
86
|
-
const seats = await getRepository(ChatSessionParticipant).find({ where: { domain: { id: domain.id }, session: { id: session.id } } as any })
|
|
87
|
-
const mine = seats.find((seat: any) => seat.userId === user?.id)?.role
|
|
88
|
-
if (!maySeat(session.visibility, mine)) {
|
|
89
|
-
/* Who reads the conversation is the person's to change, in the conversation list - the model has no tool for it (2026-10-24: it offered 「그룹 대화로 바꿔줘」). */
|
|
90
|
-
return {
|
|
91
|
-
rejected: true,
|
|
92
|
-
error: 'may-not-invite',
|
|
93
|
-
message: `${seatRefusal(session.visibility, t)} Say so in one line - do not offer a card. Who reads this conversation is changed by the person who started it, from the conversation list (⋯); you cannot change it, so never offer to or suggest asking you.`
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const found = await findPeopleNamed(run, name)
|
|
98
|
-
if (found.error) return { rejected: true, error: 'people-unreadable', message: `the people list could not be read: ${found.error}` }
|
|
99
|
-
const here = new Set(seats.filter((seat: any) => isRoomRole(seat.role)).map((seat: any) => seat.userId))
|
|
100
|
-
const already = found.people.filter(one => here.has(one.userId))
|
|
101
|
-
let people = found.people.filter(one => !here.has(one.userId) && one.userId !== user?.id)
|
|
102
|
-
if (wanted) people = people.filter(one => one.userId === wanted)
|
|
103
|
-
|
|
104
|
-
if (!people.length) {
|
|
105
|
-
return already.length
|
|
106
|
-
? { rejected: true, error: 'already-here', message: `${already.map(one => one.name).join(', ')} is already in this conversation.` }
|
|
107
|
-
: { rejected: true, error: 'not-found', message: `no one named "${name}" with an account is in the people list this person may see.` }
|
|
108
|
-
}
|
|
109
|
-
if (people.length > MAX_INVITE_CANDIDATES) {
|
|
110
|
-
return { rejected: true, error: 'too-many', message: `more than ${MAX_INVITE_CANDIDATES} people match "${name}" - ask for the full name or the department.` }
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const one = people.length === 1 ? people[0] : undefined
|
|
114
|
-
return {
|
|
115
|
-
proposed: true,
|
|
116
|
-
kind: 'invite',
|
|
117
|
-
icon: 'person_add',
|
|
118
|
-
label: one
|
|
119
|
-
? t('ai-assistant.people.invite-one', { name: one.name, defaultValue: 'Invite {name} to this conversation' })
|
|
120
|
-
: t('ai-assistant.people.invite-pick', { name, count: people.length, defaultValue: '{count} people named {name} - pick whom to invite' }),
|
|
121
|
-
...(one && (one.department || one.position) ? { reason: [one.department, one.position].filter(Boolean).join(' · ') } : {}),
|
|
122
|
-
people,
|
|
123
|
-
message: one
|
|
124
|
-
? `the card invites ${one.name}${one.department ? ` (${one.department})` : ''}. The person presses it; they are told when they join. Say that in one line.`
|
|
125
|
-
: `${people.length} people match "${name}"; the card lists each with department and position and the person picks one. Do not ask which - the card does.`
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const spec = {
|
|
130
|
-
kind: 'read',
|
|
131
|
-
name: 'proposeInvite',
|
|
132
|
-
/* It reads people through the organization's list - the same door that list has, so it is offered where that list is. */
|
|
133
|
-
doors: ['Query.employees'],
|
|
134
|
-
description:
|
|
135
|
-
'Offer a card that brings someone into this conversation. Give the name the person used; the server finds them in ' +
|
|
136
|
-
"the organization's people list and puts them on the card (several people by that name: the card lists each, the " +
|
|
137
|
-
'person picks). The person presses the card - nobody joins until then. One call per person.',
|
|
138
|
-
schema: {
|
|
139
|
-
type: 'object',
|
|
140
|
-
properties: {
|
|
141
|
-
name: { type: 'string', description: 'The name of the person to invite, as the person said it.' },
|
|
142
|
-
userId: { type: 'string', description: 'The user id from the people list, when it was read already and the person meant that one.' }
|
|
143
|
-
},
|
|
144
|
-
required: ['name']
|
|
145
|
-
},
|
|
146
|
-
builder: (args: any, context: any) => proposeInvite(args, context)
|
|
147
|
-
} as ToolSpec
|
|
148
|
-
|
|
149
|
-
export const inviteCategory: ToolCategory = {
|
|
150
|
-
name: INVITE_CATEGORY,
|
|
151
|
-
description: 'bring someone into this conversation - a card the person presses',
|
|
152
|
-
guidance: [
|
|
153
|
-
'- When the person asks to invite, add or bring someone into this conversation, call proposeInvite with that name in the same turn. Never send them to a screen to do it.',
|
|
154
|
-
'- To answer who someone is or who works where, read the people list (queryOrganizationEmployee).'
|
|
155
|
-
].join('\n'),
|
|
156
|
-
specs: [spec]
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
registerToolCategory(inviteCategory)
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The invite card (people/invite-tools.ts) on sqlite - the room's rules are the stored ones, the people list is a
|
|
3
|
-
* stand-in for the organization's query as the person.
|
|
4
|
-
*
|
|
5
|
-
* Asked 「정연희 초대해 줘」 the model said it had no tool to look people up and sent the person to a screen
|
|
6
|
-
* (2026-10-24). Now the name is found in the people list and the card carries whom it means; the card itself seats
|
|
7
|
-
* nobody - a person pressing it does, through the invite door.
|
|
8
|
-
*/
|
|
9
|
-
import type { DataSource } from 'typeorm'
|
|
10
|
-
|
|
11
|
-
const { DataSource: TypeOrmDataSource } = require('typeorm')
|
|
12
|
-
const shell = require('@things-factory/shell')
|
|
13
|
-
const authBase = require('@things-factory/auth-base')
|
|
14
|
-
|
|
15
|
-
function loadCompiled(modulePath: string): any {
|
|
16
|
-
const { existsSync } = require('fs')
|
|
17
|
-
const { join } = require('path')
|
|
18
|
-
const resolved = join(__dirname, '..', '..', '..', 'dist-server', 'service', `${modulePath}.js`)
|
|
19
|
-
if (!existsSync(resolved)) throw new Error(`ai-assistant has no build output: ${resolved}\nBuild first:\n yarn workspace @things-factory/ai-assistant build:server`)
|
|
20
|
-
return require(resolved)
|
|
21
|
-
}
|
|
22
|
-
const { ChatSession } = loadCompiled('chat-session/chat-session')
|
|
23
|
-
const { ChatMessage } = loadCompiled('chat-message/chat-message')
|
|
24
|
-
const { ChatSessionParticipant } = loadCompiled('chat-session-participant/chat-session-participant')
|
|
25
|
-
const { proposeInvite, MAX_INVITE_CANDIDATES } = loadCompiled('people/invite-tools')
|
|
26
|
-
|
|
27
|
-
let db: DataSource
|
|
28
|
-
let domain: any
|
|
29
|
-
let owner: any
|
|
30
|
-
let member: any
|
|
31
|
-
let session: any
|
|
32
|
-
let asked: Array<{ document: string; variables: any }>
|
|
33
|
-
|
|
34
|
-
beforeAll(async () => {
|
|
35
|
-
db = new TypeOrmDataSource({
|
|
36
|
-
type: 'sqlite',
|
|
37
|
-
database: ':memory:',
|
|
38
|
-
synchronize: true,
|
|
39
|
-
dropSchema: true,
|
|
40
|
-
namingStrategy: new shell.NamingStrategy(),
|
|
41
|
-
entities: [...shell.entities, ...authBase.entities, ChatSession, ChatMessage, ChatSessionParticipant],
|
|
42
|
-
logging: false
|
|
43
|
-
})
|
|
44
|
-
await db.initialize()
|
|
45
|
-
shell.addDataSource('default', db)
|
|
46
|
-
domain = await db.getRepository(shell.Domain).save({ name: 'acme', subdomain: 'acme' })
|
|
47
|
-
owner = await db.getRepository(authBase.User).save({ name: 'owner', username: 'owner', email: 'owner@example.com', status: 'activated' })
|
|
48
|
-
member = await db.getRepository(authBase.User).save({ name: 'member', username: 'member', email: 'member@example.com', status: 'activated' })
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
afterAll(async () => {
|
|
52
|
-
shell.removeDataSource('default')
|
|
53
|
-
await db?.destroy()
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
beforeEach(async () => {
|
|
57
|
-
asked = []
|
|
58
|
-
session = await db.getRepository(ChatSession).save({ domain, anchorType: 'domain', anchorId: domain.id, name: 'pricing', visibility: 'group', creator: owner })
|
|
59
|
-
await db.getRepository(ChatSessionParticipant).save({ domain, session: { id: session.id }, user: { id: owner.id }, role: 'owner' })
|
|
60
|
-
await db.getRepository(ChatSessionParticipant).save({ domain, session: { id: session.id }, user: { id: member.id }, role: 'member' })
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
const person = (name: string, userId: string | null, department = 'Sales', position = 'Manager') => ({
|
|
64
|
-
id: `e-${name}-${userId}`,
|
|
65
|
-
name,
|
|
66
|
-
jobPosition: position,
|
|
67
|
-
department: { id: `d-${department}`, name: department },
|
|
68
|
-
user: userId ? { id: userId } : null
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
/** The people list as the organization's query answers it: by exact name, then by search. */
|
|
72
|
-
function peopleList(rows: any[]) {
|
|
73
|
-
return async (document: string, variables: any) => {
|
|
74
|
-
asked.push({ document, variables })
|
|
75
|
-
const exact = (variables.filters ?? []).find((one: any) => one.name === 'name')
|
|
76
|
-
const items = exact ? rows.filter(row => row.name === exact.value) : rows.filter(row => row.name.includes(variables.search ?? ''))
|
|
77
|
-
return { data: { employees: { items, total: items.length } } }
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const as = (user: any, conversation: any = session) => ({ state: { domain, user }, ...(conversation ? { conversation: { id: conversation.id } } : {}) })
|
|
82
|
-
const seats = async () => (await db.getRepository(ChatSessionParticipant).find({ where: { session: { id: session.id } } as any })).map((row: any) => [row.userId, row.role]).sort()
|
|
83
|
-
|
|
84
|
-
describe('the invite card', () => {
|
|
85
|
-
it('★ one person by that name - the card invites them, with where they work', async () => {
|
|
86
|
-
const card = await proposeInvite({ name: '정연희' }, as(owner), peopleList([person('정연희', 'u-jung'), person('김민수', 'u-kim')]))
|
|
87
|
-
expect(card).toMatchObject({ proposed: true, kind: 'invite', people: [{ userId: 'u-jung', name: '정연희', department: 'Sales', position: 'Manager' }], reason: 'Sales · Manager' })
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
it('★ the card seats nobody - only a person pressing it does (the invite door)', async () => {
|
|
91
|
-
const before = await seats()
|
|
92
|
-
await proposeInvite({ name: '정연희' }, as(owner), peopleList([person('정연희', 'u-jung')]))
|
|
93
|
-
expect(await seats()).toEqual(before)
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
it('★ two people of one name - the card lists both and the person picks', async () => {
|
|
97
|
-
const card = await proposeInvite({ name: '정연희' }, as(owner), peopleList([person('정연희', 'u-1', 'Sales'), person('정연희', 'u-2', 'Finance')]))
|
|
98
|
-
expect(card.people.map((one: any) => one.userId)).toEqual(['u-1', 'u-2'])
|
|
99
|
-
expect(card.reason).toBeUndefined()
|
|
100
|
-
expect(card.message).toMatch(/do not ask which/i)
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
it('a user id read before narrows the card to that one', async () => {
|
|
104
|
-
const card = await proposeInvite({ name: '정연희', userId: 'u-2' }, as(owner), peopleList([person('정연희', 'u-1'), person('정연희', 'u-2')]))
|
|
105
|
-
expect(card.people.map((one: any) => one.userId)).toEqual(['u-2'])
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
it('★ a user id the model made up is never on a card', async () => {
|
|
109
|
-
const card = await proposeInvite({ name: '정연희', userId: 'made-up' }, as(owner), peopleList([person('정연희', 'u-1')]))
|
|
110
|
-
expect(card).toMatchObject({ rejected: true, error: 'not-found' })
|
|
111
|
-
})
|
|
112
|
-
|
|
113
|
-
it('no exact name - the name is searched', async () => {
|
|
114
|
-
const card = await proposeInvite({ name: '연희' }, as(owner), peopleList([person('정연희', 'u-1')]))
|
|
115
|
-
expect(card.people.map((one: any) => one.userId)).toEqual(['u-1'])
|
|
116
|
-
expect(asked[1].variables.search).toBe('연희')
|
|
117
|
-
})
|
|
118
|
-
|
|
119
|
-
it('people who left are never asked for, and no contact or bank field is read', async () => {
|
|
120
|
-
await proposeInvite({ name: '정연희' }, as(owner), peopleList([person('정연희', 'u-1')]))
|
|
121
|
-
expect(asked[0].variables.filters).toContainEqual({ name: 'active', operator: 'eq', value: true })
|
|
122
|
-
expect(asked[0].document).not.toMatch(/phone|email|address|bank|emergency|contact|photo/i)
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
it('someone without an account cannot be invited; someone already here is said', async () => {
|
|
126
|
-
expect(await proposeInvite({ name: '정연희' }, as(owner), peopleList([person('정연희', null)]))).toMatchObject({ rejected: true, error: 'not-found' })
|
|
127
|
-
expect(await proposeInvite({ name: 'member' }, as(owner), peopleList([person('member', member.id)]))).toMatchObject({ rejected: true, error: 'already-here' })
|
|
128
|
-
})
|
|
129
|
-
|
|
130
|
-
it('a name that matches too many is narrowed first', async () => {
|
|
131
|
-
const many = Array.from({ length: MAX_INVITE_CANDIDATES + 1 }, (_, i) => person('정연희', `u-${i}`))
|
|
132
|
-
expect(await proposeInvite({ name: '정연희' }, as(owner), peopleList(many))).toMatchObject({ rejected: true, error: 'too-many' })
|
|
133
|
-
})
|
|
134
|
-
})
|
|
135
|
-
|
|
136
|
-
describe('the card is offered only where the person could press it', () => {
|
|
137
|
-
it('★ a member of a group cannot bring anyone in - no card, and nobody is looked up', async () => {
|
|
138
|
-
const card = await proposeInvite({ name: '정연희' }, as(member), peopleList([person('정연희', 'u-1')]))
|
|
139
|
-
expect(card).toMatchObject({ rejected: true, error: 'may-not-invite' })
|
|
140
|
-
expect(card.message).toMatch(/you cannot change it, so never offer/)
|
|
141
|
-
expect(asked).toEqual([])
|
|
142
|
-
})
|
|
143
|
-
|
|
144
|
-
it('★ a private conversation takes nobody', async () => {
|
|
145
|
-
await db.getRepository(ChatSession).update(session.id, { visibility: 'private' })
|
|
146
|
-
expect(await proposeInvite({ name: '정연희' }, as(owner), peopleList([person('정연희', 'u-1')]))).toMatchObject({ rejected: true, error: 'may-not-invite' })
|
|
147
|
-
})
|
|
148
|
-
|
|
149
|
-
it('in an open conversation anyone may point a colleague at it', async () => {
|
|
150
|
-
await db.getRepository(ChatSession).update(session.id, { visibility: 'open' })
|
|
151
|
-
expect(await proposeInvite({ name: '정연희' }, as(member), peopleList([person('정연희', 'u-1')]))).toMatchObject({ proposed: true })
|
|
152
|
-
})
|
|
153
|
-
|
|
154
|
-
it('a turn without a stored conversation, or one of another domain, has no room to invite into', async () => {
|
|
155
|
-
expect(await proposeInvite({ name: '정연희' }, as(owner, null), peopleList([]))).toMatchObject({ rejected: true, error: 'no-conversation' })
|
|
156
|
-
const other = await db.getRepository(shell.Domain).save({ name: 'other', subdomain: 'other' })
|
|
157
|
-
expect(await proposeInvite({ name: '정연희' }, { state: { domain: other, user: owner }, conversation: { id: session.id } }, peopleList([]))).toMatchObject({ rejected: true, error: 'no-conversation' })
|
|
158
|
-
})
|
|
159
|
-
})
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The names of the people tools - every conversation carries them (mode-categories.ts), so they live apart from the
|
|
3
|
-
* tools themselves and the categories can be named without loading them.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/** The organization's people as a read target - its `employees` list, read as the person (people-read.ts). */
|
|
7
|
-
export const PEOPLE_READ_KEY = 'organization.employee'
|
|
8
|
-
|
|
9
|
-
/** The category of that read - `data-read:<key>`, as every read target's. */
|
|
10
|
-
export const PEOPLE_READ_CATEGORY = `data-read:${PEOPLE_READ_KEY}`
|
|
11
|
-
|
|
12
|
-
/** The invite card - bring someone into this conversation (invite-tools.ts). */
|
|
13
|
-
export const INVITE_CATEGORY = 'chat-invite'
|
|
14
|
-
|
|
15
|
-
/** Both, in the order a turn puts them in front: find the person, then the card. */
|
|
16
|
-
export const PEOPLE_CATEGORIES = [PEOPLE_READ_CATEGORY, INVITE_CATEGORY]
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The people list every conversation reads (people-read.ts) - the organization's own query, behind its own door, and
|
|
3
|
-
* nothing private in what it reads.
|
|
4
|
-
*/
|
|
5
|
-
import { peopleReadTarget, PEOPLE_SELECTION } from './people-read'
|
|
6
|
-
import { PEOPLE_CATEGORIES, PEOPLE_READ_CATEGORY, INVITE_CATEGORY } from './people-keys'
|
|
7
|
-
import { modeFrontCategories, modeToolCategories, unattendedToolCategories } from '../assistant-mode/mode-categories'
|
|
8
|
-
import { rootFieldOf } from '../data-entry/entry-target'
|
|
9
|
-
|
|
10
|
-
describe('the people list', () => {
|
|
11
|
-
const target = peopleReadTarget()
|
|
12
|
-
|
|
13
|
-
it("★ reads the organization's own list - its door decides who may read people", () => {
|
|
14
|
-
expect(rootFieldOf(target.query, 'query')).toBe('Query.employees')
|
|
15
|
-
expect(target.key).toBe('organization.employee')
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
it('★ the invite card reads people through the same door - offered only where the list is', () => {
|
|
19
|
-
/* The tool module holds entities - read as built, as the database suites do. */
|
|
20
|
-
const { inviteCategory } = require(require('path').join(__dirname, '..', '..', '..', 'dist-server', 'service', 'people', 'invite-tools.js'))
|
|
21
|
-
expect(inviteCategory.specs.map((spec: any) => spec.doors)).toEqual([[rootFieldOf(target.query, 'query')]])
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
it('★ reads no contact, address, bank or emergency field', () => {
|
|
25
|
-
expect(target.query).not.toMatch(/phone|email|address|bank|emergency|contact|photo|profile|note/i)
|
|
26
|
-
expect(PEOPLE_SELECTION.split(/[\s{}]+/).filter(Boolean).sort()).toEqual(['alias', 'department', 'id', 'id', 'id', 'jobPosition', 'jobResponsibility', 'name', 'name', 'user'].sort())
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
it('people who left are out of reach - a fixed filter the model cannot lift', () => {
|
|
30
|
-
expect(target.fixedFilters).toEqual([{ name: 'active', operator: 'eq', value: true }])
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
it('★ a department, a position, a responsibility each has its own condition - never the name search', () => {
|
|
34
|
-
const by = (name: string) => target.criteria.find(one => one.name === name)!
|
|
35
|
-
expect(by('position').filter('프로')).toEqual({ name: 'jobPosition', operator: 'i_like', value: '프로' })
|
|
36
|
-
expect(by('responsibility').filter('회계')).toEqual({ name: 'jobResponsibility', operator: 'i_like', value: '회계' })
|
|
37
|
-
expect(by('department').filter('영업')).toEqual({ name: 'departmentName', operator: 'i_like', value: '영업' })
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
it("★ every part-of condition is on a field the organization's list lets LIKE reach - one outside is dropped without a word", () => {
|
|
41
|
-
const source = require('fs').readFileSync(require('path').join(__dirname, '..', '..', '..', '..', 'organization', 'server', 'service', 'employee', 'employee-query.ts'), 'utf8') as string
|
|
42
|
-
const searchables = JSON.parse(source.match(/searchables: (\[[^\]]*\])/)![1].replace(/'/g, '"')) as string[]
|
|
43
|
-
const liked = target.criteria.map(one => [one.filter('x')].flat()).flat().filter((f: any) => /like/.test(f.operator)).map((f: any) => f.name)
|
|
44
|
-
expect(liked.length).toBeGreaterThan(0)
|
|
45
|
-
expect(liked.filter(name => !searchables.includes(name))).toEqual([])
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
it("the organization's list takes a department by its name", () => {
|
|
49
|
-
const source = require('fs').readFileSync(require('path').join(__dirname, '..', '..', '..', '..', 'organization', 'server', 'service', 'employee', 'employee-query.ts'), 'utf8') as string
|
|
50
|
-
expect(source).toMatch(/filtersMap: \{ departmentName: \{ columnName: 'name', relationColumn: 'department' \} \}/)
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
it('carries the user id an invite takes, and finds by name', () => {
|
|
54
|
-
expect(target.columns.find(one => one.name === 'userId')?.path).toBe('user.id')
|
|
55
|
-
expect(target.search).toBeTruthy()
|
|
56
|
-
})
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
describe('every conversation carries the people tools', () => {
|
|
60
|
-
const mode = { toolCategories: ['office-reads'], readTargets: ['office.contract'] }
|
|
61
|
-
|
|
62
|
-
it('★ offered in every mode, and in front of every turn', () => {
|
|
63
|
-
for (const category of PEOPLE_CATEGORIES) {
|
|
64
|
-
expect(modeToolCategories(mode)).toContain(category)
|
|
65
|
-
expect(modeToolCategories({})).toContain(category)
|
|
66
|
-
expect(modeFrontCategories(mode)).toContain(category)
|
|
67
|
-
expect(modeFrontCategories({}, { page: 'anything' })).toContain(category)
|
|
68
|
-
}
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
it('not in an unattended run - nobody is there to press an invite', () => {
|
|
72
|
-
expect(unattendedToolCategories(mode)).not.toContain(INVITE_CATEGORY)
|
|
73
|
-
expect(unattendedToolCategories(mode)).not.toContain(PEOPLE_READ_CATEGORY)
|
|
74
|
-
})
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
describe('the invite card knows which conversation it is in', () => {
|
|
78
|
-
it("★ the conversation door hands the stored session to the tools - the server's value, never the client's", () => {
|
|
79
|
-
const source = require('fs').readFileSync(require('path').join(__dirname, '..', 'assistant-chat-resolver.ts'), 'utf8') as string
|
|
80
|
-
expect(source).toMatch(/\.\.\.\(session\?\.id \? \{ conversation: \{ id: session\.id \} \} : \{\}\)/)
|
|
81
|
-
})
|
|
82
|
-
})
|