@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,334 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The tools of an AI 조회 target (operato-application/design/ai/read-targets.md §4, §5).
|
|
3
|
-
*
|
|
4
|
-
* query<X> reads the rows through the application's list query as the person, and tells the model the count, the
|
|
5
|
-
* sums, the groups and a few rows. A longer result goes on the AI 작업 패널 as a proposal the server builds from the rows
|
|
6
|
-
* themselves - the table is never written by the model. open<X>Screen reads nothing: it hands the card the address
|
|
7
|
-
* of the application's list screen with the conditions it takes.
|
|
8
|
-
*/
|
|
9
|
-
import { registerToolCategory, type ToolCategory, type ToolSpec } from '@things-factory/ai-client-base'
|
|
10
|
-
|
|
11
|
-
import { readFieldValue, rootFieldOf } from '../data-entry/entry-target.js'
|
|
12
|
-
import type { GraphqlRunner } from '../data-entry/entry-update.js'
|
|
13
|
-
import { runAsCaller } from '../data-entry/entry-tools.js'
|
|
14
|
-
import { normalizeWorkspace, workspaceContents } from '../workspace/workspace-blocks.js'
|
|
15
|
-
import {
|
|
16
|
-
declareReadTarget,
|
|
17
|
-
filtersOf,
|
|
18
|
-
currenciesOf,
|
|
19
|
-
declareDetailRead,
|
|
20
|
-
detailToolName,
|
|
21
|
-
MAX_DETAIL_CHARS,
|
|
22
|
-
type DetailArg,
|
|
23
|
-
type DetailRead,
|
|
24
|
-
groupsOf,
|
|
25
|
-
legendOf,
|
|
26
|
-
queryToolName,
|
|
27
|
-
readCategoryName,
|
|
28
|
-
readCriteria,
|
|
29
|
-
readRows,
|
|
30
|
-
ROWS_FOR_MODEL,
|
|
31
|
-
screenAddress,
|
|
32
|
-
screenToolName,
|
|
33
|
-
sumsOf,
|
|
34
|
-
wordOf,
|
|
35
|
-
type ReadCriterion,
|
|
36
|
-
type ReadTarget
|
|
37
|
-
} from './read-target.js'
|
|
38
|
-
|
|
39
|
-
/** The reader's words for a key - the key's own default when the translator has none. */
|
|
40
|
-
const wordsOf = (context: any) => (key: string | undefined, fallback: string) => {
|
|
41
|
-
if (!key || typeof context?.t !== 'function') return fallback
|
|
42
|
-
try {
|
|
43
|
-
const said = context.t(key)
|
|
44
|
-
return said && said !== key ? String(said) : fallback
|
|
45
|
-
} catch {
|
|
46
|
-
return fallback
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function criterionSchema(criterion: ReadCriterion): any {
|
|
51
|
-
/* One type per field - Gemini's function schema refuses a list of types (2026-10-01). */
|
|
52
|
-
const type = criterion.type === 'number' ? 'number' : criterion.type === 'integer' ? 'integer' : criterion.type === 'boolean' ? 'boolean' : 'string'
|
|
53
|
-
const said = [criterion.description, criterion.type === 'date' ? 'YYYY-MM-DD' : criterion.format === 'month' ? 'YYYY-MM' : undefined, criterion.type === 'enum' ? `one of: ${criterion.values!.join(', ')}` : undefined]
|
|
54
|
-
.filter(Boolean)
|
|
55
|
-
.join('. ')
|
|
56
|
-
if (criterion.many) return { type: 'array', items: { type }, ...(said ? { description: `${said} - one or more` } : {}) }
|
|
57
|
-
return { type, ...(said ? { description: said } : {}) }
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export async function queryRecords(target: ReadTarget, args: any, context: any, run: GraphqlRunner) {
|
|
61
|
-
const { criteria, refused } = readCriteria(target, args)
|
|
62
|
-
if (refused.length) {
|
|
63
|
-
return { rejected: true, error: 'condition-unreadable', refused, message: `these conditions do not fit their type: ${refused.map(one => `${one.name} (${one.code})`).join(', ')}. Fix them and call again.` }
|
|
64
|
-
}
|
|
65
|
-
let read
|
|
66
|
-
try {
|
|
67
|
-
read = await readRows(target, filtersOf(target, criteria), run, typeof criteria.text === 'string' && target.search ? criteria.text : undefined, {
|
|
68
|
-
timeZone: context?.state?.domain?.timezone
|
|
69
|
-
})
|
|
70
|
-
} catch (error: any) {
|
|
71
|
-
return { rejected: true, error: 'query-failed', message: `the list could not be read: ${error?.message ?? error}` }
|
|
72
|
-
}
|
|
73
|
-
const { rows, total, complete } = read
|
|
74
|
-
const sums = sumsOf(target, rows)
|
|
75
|
-
const groupBy = typeof args?.groupBy === 'string' && args.groupBy ? args.groupBy : undefined
|
|
76
|
-
const groups = groupBy ? groupsOf(target, rows, groupBy) : undefined
|
|
77
|
-
const words = wordsOf(context)
|
|
78
|
-
const label = words(target.labelKey, target.key)
|
|
79
|
-
/* The rows keep their codes - a condition names them; the person is told the words (ADR-0163, 2026-10-26). */
|
|
80
|
-
const legend = legendOf(target.columns, rows, words)
|
|
81
|
-
|
|
82
|
-
const said = {
|
|
83
|
-
target: target.key,
|
|
84
|
-
criteria,
|
|
85
|
-
total,
|
|
86
|
-
read: rows.length,
|
|
87
|
-
complete,
|
|
88
|
-
sums,
|
|
89
|
-
...(groupBy ? (groups ? { groupBy, groups: groups.slice(0, 50), ...(groups.length > 50 ? { moreGroups: groups.length - 50 } : {}) } : { groupBy, groupRefused: 'no such column' }) : {}),
|
|
90
|
-
rows: rows.slice(0, ROWS_FOR_MODEL),
|
|
91
|
-
...(rows.length > ROWS_FOR_MODEL ? { rowsNotShown: rows.length - ROWS_FOR_MODEL } : {}),
|
|
92
|
-
...(Object.keys(legend).length ? { legend, legendNote: 'a coded value is said by its word in legend, never by its code' } : {})
|
|
93
|
-
}
|
|
94
|
-
const incomplete = complete
|
|
95
|
-
? ''
|
|
96
|
-
: ` Only ${rows.length} of ${total} rows were read; the sums and groups are of those rows, not of the list - say so, and ask the person to narrow the conditions.`
|
|
97
|
-
|
|
98
|
-
if (rows.length === 1 && args?.show !== 'workspace') {
|
|
99
|
-
return { ...said, record: rows[0], message: 'one record - answer from its fields; say a field it does not have as not recorded.' }
|
|
100
|
-
}
|
|
101
|
-
if (rows.length <= ROWS_FOR_MODEL && args?.show !== 'workspace') {
|
|
102
|
-
return { ...said, message: `${rows.length} rows of ${total}.${incomplete} Answer from these rows; every number you say comes from them.` }
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/* The workspace is built here from the rows as read - the model never copies the table. */
|
|
106
|
-
const columns = target.columns.map(column => ({ name: column.name, label: words(column.labelKey, column.name), type: column.type }))
|
|
107
|
-
const shownRows = rows.map(row => Object.fromEntries(Object.entries(row).map(([name, value]) => [name, wordOf(target.columns.find(one => one.name === name), value, words)])))
|
|
108
|
-
const groupColumn = target.columns.find(one => one.name === groupBy)
|
|
109
|
-
const totalColumns = target.columns.filter(one => one.total)
|
|
110
|
-
/* A sum per currency is one figure and one group column per currency it holds - 「계약금액 (USD)」. */
|
|
111
|
-
const sumColumns = totalColumns.flatMap(column => {
|
|
112
|
-
const label = words(column.labelKey, column.name)
|
|
113
|
-
const codes = currenciesOf([sums, ...(groups ?? []).map(group => group.sums)], column.name)
|
|
114
|
-
return column.currency
|
|
115
|
-
? codes.map(code => ({ name: `${column.name}:${code}`, label: `${label} (${code})`, of: (one: Record<string, any>) => one[column.name]?.[code] ?? 0 }))
|
|
116
|
-
: [{ name: column.name, label, of: (one: Record<string, any>) => one[column.name] }]
|
|
117
|
-
})
|
|
118
|
-
const title = typeof args?.title === 'string' && args.title.trim() ? args.title.trim() : `${label} · ${rows.length}`
|
|
119
|
-
const { workspace } = normalizeWorkspace({
|
|
120
|
-
name: typeof args?.name === 'string' && args.name ? args.name : target.key.replace(/\./g, '-'),
|
|
121
|
-
title,
|
|
122
|
-
...(complete ? {} : { summary: `${total} / ${rows.length}` }),
|
|
123
|
-
blocks: [
|
|
124
|
-
{
|
|
125
|
-
kind: 'metrics',
|
|
126
|
-
items: [{ label: words('ai-assistant.read.count', 'rows'), value: String(rows.length), ...(complete ? {} : { note: `/ ${total}` }) }, ...sumColumns.map(column => ({ label: column.label, value: String(column.of(sums)) }))]
|
|
127
|
-
},
|
|
128
|
-
...(groups
|
|
129
|
-
? [
|
|
130
|
-
{
|
|
131
|
-
kind: 'table',
|
|
132
|
-
caption: words(target.columns.find(one => one.name === groupBy)?.labelKey, groupBy!),
|
|
133
|
-
columns: [{ name: 'key', label: words(target.columns.find(one => one.name === groupBy)?.labelKey, groupBy!), type: 'string' }, { name: 'count', label: words('ai-assistant.read.count', 'rows'), type: 'number' }, ...sumColumns.map(column => ({ name: column.name, label: column.label, type: 'number' }))],
|
|
134
|
-
rows: groups.map(group => ({ key: wordOf(groupColumn, group.key, words), count: group.count, ...Object.fromEntries(sumColumns.map(column => [column.name, column.of(group.sums)])) }))
|
|
135
|
-
}
|
|
136
|
-
]
|
|
137
|
-
: []),
|
|
138
|
-
{ kind: 'table', caption: label, columns, rows: shownRows }
|
|
139
|
-
]
|
|
140
|
-
})
|
|
141
|
-
return {
|
|
142
|
-
proposed: true,
|
|
143
|
-
kind: 'workspace',
|
|
144
|
-
icon: 'table_view',
|
|
145
|
-
label: title,
|
|
146
|
-
...said,
|
|
147
|
-
forScreen: { workspace, contents: workspaceContents(workspace!) },
|
|
148
|
-
message: `${rows.length} rows of ${total} are on the AI 작업 패널 as read - the person opens it from the card.${incomplete} Say the point in one or two lines from the sums, groups and rows above; do not write the table out.`
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export function openScreen(target: ReadTarget, args: any, context: any) {
|
|
153
|
-
const { criteria, refused } = readCriteria(target, args)
|
|
154
|
-
if (refused.length) return { rejected: true, error: 'condition-unreadable', refused, message: 'fix the conditions and call again.' }
|
|
155
|
-
const address = screenAddress(target, criteria)
|
|
156
|
-
if (!address) return { rejected: true, error: 'no-screen', message: 'this list has no screen to open.' }
|
|
157
|
-
const words = wordsOf(context)
|
|
158
|
-
return {
|
|
159
|
-
proposed: true,
|
|
160
|
-
kind: 'open-page',
|
|
161
|
-
icon: 'open_in_new',
|
|
162
|
-
label: words(target.screen!.labelKey ?? target.labelKey, target.key),
|
|
163
|
-
target: target.key,
|
|
164
|
-
href: address.href,
|
|
165
|
-
applied: address.applied,
|
|
166
|
-
notApplied: address.notApplied,
|
|
167
|
-
/* The card says them in the reader's words. */
|
|
168
|
-
notAppliedLabels: address.notApplied.map(name => words(target.criteria.find(one => one.name === name)?.labelKey ?? (name === 'text' || name === 'id' ? `ai-assistant.read.${name}` : undefined), name)),
|
|
169
|
-
message:
|
|
170
|
-
'the card opens the screen when the person presses it.' +
|
|
171
|
-
(address.notApplied.length ? ` The screen does not take ${address.notApplied.join(', ')} - say so.` : '')
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
export function readCategoryOf(target: ReadTarget, run: (context: any) => GraphqlRunner = runAsCaller): ToolCategory {
|
|
176
|
-
const door = rootFieldOf(target.query, 'query')
|
|
177
|
-
const conditions = {
|
|
178
|
-
...Object.fromEntries(target.criteria.map(criterion => [criterion.name, criterionSchema(criterion)])),
|
|
179
|
-
...(target.search ? { text: { type: 'string', description: `words to find - ${target.search.description}` } } : {})
|
|
180
|
-
}
|
|
181
|
-
const specs: ToolSpec[] = [
|
|
182
|
-
{
|
|
183
|
-
kind: 'read',
|
|
184
|
-
name: queryToolName(target.key),
|
|
185
|
-
/* The person must be able to read the list on its screen - the tool is not a second way in. */
|
|
186
|
-
doors: [door],
|
|
187
|
-
description:
|
|
188
|
-
`Read ${target.description} Set the conditions the question names. Returns the count, the sums, ` +
|
|
189
|
-
`groups when groupBy is given (a date column groups by month) and the first ${ROWS_FOR_MODEL} rows; more rows go on the AI 작업 패널 as read.`,
|
|
190
|
-
schema: {
|
|
191
|
-
type: 'object',
|
|
192
|
-
properties: {
|
|
193
|
-
id: { type: 'string', description: 'One record by its id, from an earlier answer - its detail.' },
|
|
194
|
-
...conditions,
|
|
195
|
-
groupBy: { type: 'string', description: `One column to group by: ${target.columns.map(one => one.name).join(', ')}.` },
|
|
196
|
-
show: { type: 'string', enum: ['answer', 'workspace'], description: 'workspace to put even a short result on the AI 작업 패널.' },
|
|
197
|
-
title: { type: 'string', description: 'The workspace title, in the person\'s language.' },
|
|
198
|
-
name: { type: 'string', description: 'The workspace key; the same key again makes a new version.' }
|
|
199
|
-
}
|
|
200
|
-
},
|
|
201
|
-
builder: (args: any, context: any) => queryRecords(target, args, context, run(context))
|
|
202
|
-
} as ToolSpec,
|
|
203
|
-
...(target.screen
|
|
204
|
-
? [
|
|
205
|
-
{
|
|
206
|
-
kind: 'read',
|
|
207
|
-
name: screenToolName(target.key),
|
|
208
|
-
doors: [door],
|
|
209
|
-
description: `Offer the person the screen that lists ${target.description} with these conditions. Reads nothing. The screen takes: ${target.screen.takes.join(', ')}.`,
|
|
210
|
-
schema: { type: 'object', properties: conditions },
|
|
211
|
-
builder: (args: any, context: any) => openScreen(target, args, context)
|
|
212
|
-
} as ToolSpec
|
|
213
|
-
]
|
|
214
|
-
: [])
|
|
215
|
-
]
|
|
216
|
-
return {
|
|
217
|
-
name: readCategoryName(target.key),
|
|
218
|
-
description: `data read: ${target.key}`,
|
|
219
|
-
guidance: [
|
|
220
|
-
`- To answer from ${target.key} records - a list, or one record found by its name, code or id - call ${queryToolName(target.key)} with the conditions the question names. Every number you say comes from its result - never add up rows yourself; use its sums and groups.`,
|
|
221
|
-
`- A list, a summary by item or month, or a comparison: call it with groupBy, and let a long result go on the AI 작업 패널 - then answer in one or two lines.`,
|
|
222
|
-
`- When the result says complete: false, say how many of how many were read and ask to narrow - never call partial sums the total.`,
|
|
223
|
-
...(target.columns.some(one => one.currency)
|
|
224
|
-
? [`- Sums of ${target.columns.filter(one => one.currency).map(one => one.name).join(', ')} come per currency. Say each currency's sum; never add two currencies into one number. A comparison across currencies uses a rate you read, and says the rate and its date.`]
|
|
225
|
-
: []),
|
|
226
|
-
...(target.screen ? [`- When the person wants to work on the records themselves (edit, sort, export), call ${screenToolName(target.key)}; say which conditions the screen does not take.`] : [])
|
|
227
|
-
].join('\n'),
|
|
228
|
-
specs
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* What an application calls at boot to let the assistant read one of its lists. A mode opens it by naming the key
|
|
234
|
-
* in `readTargets`.
|
|
235
|
-
*/
|
|
236
|
-
export function registerReadTarget(target: ReadTarget): void {
|
|
237
|
-
declareReadTarget(target)
|
|
238
|
-
registerToolCategory(readCategoryOf(target))
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
/* ── One answer of a query (DetailRead) ───────────────────────────────────────────────────────────────────── */
|
|
242
|
-
|
|
243
|
-
function argSchema(arg: DetailArg): any {
|
|
244
|
-
const type = arg.type === 'number' ? 'number' : arg.type === 'integer' ? 'integer' : arg.type === 'boolean' ? 'boolean' : 'string'
|
|
245
|
-
const said = [arg.description, arg.type === 'date' ? 'YYYY-MM-DD' : undefined, arg.type === 'enum' ? `one of: ${arg.values!.join(', ')}` : undefined].filter(Boolean).join('. ')
|
|
246
|
-
return { type, ...(said ? { description: said } : {}) }
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* What running a detail read as the person gave - the root field's value, or why there is none. Shared by the tool,
|
|
251
|
-
* which hands the value to the model, and by every other reader of a detail read (a dashboard card, ADR-0160
|
|
252
|
-
* decision 2), which has its own limits: the arguments, the door and the query are one, the size rule is the tool's.
|
|
253
|
-
*/
|
|
254
|
-
export interface DetailRun {
|
|
255
|
-
/** The root field's value - absent when `error` says why. */
|
|
256
|
-
value?: unknown
|
|
257
|
-
error?: 'argument-unreadable' | 'query-failed' | 'not-found'
|
|
258
|
-
refused?: { name: string; code: string }[]
|
|
259
|
-
message?: string
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
/** Runs the query as the person with the arguments given - read by their declared types, a missing required one refused. */
|
|
263
|
-
export async function runDetail(target: DetailRead, args: any, run: GraphqlRunner): Promise<DetailRun> {
|
|
264
|
-
const variables: Record<string, unknown> = {}
|
|
265
|
-
const refused: { name: string; code: string }[] = []
|
|
266
|
-
for (const arg of target.args ?? []) {
|
|
267
|
-
const value = args?.[arg.name]
|
|
268
|
-
if (value === undefined || value === null || value === '') {
|
|
269
|
-
if (arg.required) refused.push({ name: arg.name, code: 'required' })
|
|
270
|
-
continue
|
|
271
|
-
}
|
|
272
|
-
const { read, code } = readFieldValue({ name: arg.name, type: arg.type === 'string' ? 'text' : arg.type, values: arg.values, axis: arg.axis } as any, value)
|
|
273
|
-
if (read === undefined) refused.push({ name: arg.name, code: code ?? 'unreadable' })
|
|
274
|
-
else variables[arg.name] = read
|
|
275
|
-
}
|
|
276
|
-
if (refused.length) return { error: 'argument-unreadable', refused }
|
|
277
|
-
let answer
|
|
278
|
-
try {
|
|
279
|
-
answer = await run(target.query, variables)
|
|
280
|
-
} catch (error: any) {
|
|
281
|
-
return { error: 'query-failed', message: String(error?.message ?? error) }
|
|
282
|
-
}
|
|
283
|
-
if (answer.errors?.length) return { error: 'query-failed', message: answer.errors.map(one => one.message).join('; ') }
|
|
284
|
-
const root = rootFieldOf(target.query, 'query').replace(/^Query\./, '')
|
|
285
|
-
const value = answer.data?.[root]
|
|
286
|
-
if (value === null || value === undefined) return { error: 'not-found' }
|
|
287
|
-
return { value }
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
/** Runs the query as the person with the arguments the model set; the answer as the query returned it. */
|
|
291
|
-
export async function queryDetail(target: DetailRead, args: any, run: GraphqlRunner) {
|
|
292
|
-
const ran = await runDetail(target, args, run)
|
|
293
|
-
if (ran.error) {
|
|
294
|
-
if (ran.error === 'argument-unreadable')
|
|
295
|
-
return { rejected: true, error: 'argument-unreadable', refused: ran.refused, message: `these arguments are missing or do not fit their type: ${ran.refused.map(one => `${one.name} (${one.code})`).join(', ')}. Fix them and call again.` }
|
|
296
|
-
if (ran.error === 'query-failed') return { rejected: true, error: 'query-failed', message: `it could not be read: ${ran.message}` }
|
|
297
|
-
return { target: target.key, found: false, message: 'nothing was found for these arguments - say so; do not fill it in.' }
|
|
298
|
-
}
|
|
299
|
-
const value = ran.value
|
|
300
|
-
const size = JSON.stringify(value).length
|
|
301
|
-
if (size > MAX_DETAIL_CHARS) return { rejected: true, error: 'answer-too-large', size, message: `the answer runs to ${size} characters, more than ${MAX_DETAIL_CHARS} - narrow the arguments, or read the list it is made of.` }
|
|
302
|
-
return { target: target.key, answer: value, message: 'answer from these fields; every number you say comes from them. Amounts are in the currency beside them - never add two currencies into one number.' }
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
export function detailCategoryOf(target: DetailRead, run: (context: any) => GraphqlRunner = runAsCaller): ToolCategory {
|
|
306
|
-
const door = rootFieldOf(target.query, 'query')
|
|
307
|
-
const name = detailToolName(target.key)
|
|
308
|
-
return {
|
|
309
|
-
name: readCategoryName(target.key),
|
|
310
|
-
description: `data read: ${target.key}`,
|
|
311
|
-
guidance: `- To answer about ${target.description.replace(/\.$/, '')}, call ${name}. Every number you say comes from its answer.`,
|
|
312
|
-
specs: [
|
|
313
|
-
{
|
|
314
|
-
kind: 'read',
|
|
315
|
-
name,
|
|
316
|
-
/* The person must be able to run the query on its screen - the tool is not a second way in. */
|
|
317
|
-
doors: [door],
|
|
318
|
-
description: `Read ${target.description}`,
|
|
319
|
-
schema: {
|
|
320
|
-
type: 'object',
|
|
321
|
-
...((target.args ?? []).some(one => one.required) ? { required: (target.args ?? []).filter(one => one.required).map(one => one.name) } : {}),
|
|
322
|
-
properties: Object.fromEntries((target.args ?? []).map(arg => [arg.name, argSchema(arg)]))
|
|
323
|
-
},
|
|
324
|
-
builder: (args: any, context: any) => queryDetail(target, args, run(context))
|
|
325
|
-
} as ToolSpec
|
|
326
|
-
]
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
/** What an application calls at boot to let the assistant read one answer of its API. A mode opens it by key in `readTargets`. */
|
|
331
|
-
export function registerDetailRead(target: DetailRead): void {
|
|
332
|
-
declareDetailRead(target)
|
|
333
|
-
registerToolCategory(detailCategoryOf(target))
|
|
334
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* What people read off a list (ADR-0163, 2026-10-26: answers and cards showed EVENT, unread and 2026-10-26T09:09:03Z):
|
|
3
|
-
* a moment in the domain's time zone, and a coded value by its word - the rows keep the code, so a condition means the
|
|
4
|
-
* same in every language.
|
|
5
|
-
*/
|
|
6
|
-
import { listReadTarget } from './list-read'
|
|
7
|
-
import { clearReadTargets, legendOf, localDateTime, rowOf, wordOf } from './read-target'
|
|
8
|
-
import { queryRecords } from './read-tools'
|
|
9
|
-
|
|
10
|
-
const WORDS: Record<string, string> = { 'notice.kind.HR': '인사', 'notice.kind.EVENT': '행사', 'notice.state.unread': '안 읽음' }
|
|
11
|
-
const say = (key: string | undefined, fallback: string) => (key && WORDS[key]) || fallback
|
|
12
|
-
|
|
13
|
-
describe('a moment', () => {
|
|
14
|
-
it('★ is said in the domain\'s time zone, to the minute', () => {
|
|
15
|
-
expect(localDateTime('2026-10-26T09:09:03.235Z', 'Asia/Seoul')).toBe('2026-10-26 18:09')
|
|
16
|
-
/* Past midnight there, it is the next day. */
|
|
17
|
-
expect(localDateTime('2026-10-26T20:00:00Z', 'Asia/Seoul')).toBe('2026-10-27 05:00')
|
|
18
|
-
expect(localDateTime('2026-10-26T20:00:00Z', 'UTC')).toBe('2026-10-26 20:00')
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
it('★ a day, a month or anything else stays as it is', () => {
|
|
22
|
-
expect(localDateTime('2026-10-26', 'Asia/Seoul')).toBe('2026-10-26')
|
|
23
|
-
expect(localDateTime('2026-10', 'Asia/Seoul')).toBe('2026-10')
|
|
24
|
-
expect(localDateTime('2026-10-26Tnot', 'Asia/Seoul')).toBe('2026-10-26Tnot')
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
it('★ a row reads its date columns so, and leaves the other columns alone', () => {
|
|
28
|
-
const columns = [
|
|
29
|
-
{ name: 'at', type: 'date' as const },
|
|
30
|
-
{ name: 'note', type: 'string' as const }
|
|
31
|
-
]
|
|
32
|
-
expect(rowOf({ columns }, { id: 'a', at: '2026-10-26T09:09:03.235Z', note: '2026-10-26T09:09:03.235Z' }, { timeZone: 'Asia/Seoul' })).toEqual({
|
|
33
|
-
id: 'a',
|
|
34
|
-
at: '2026-10-26 18:09',
|
|
35
|
-
note: '2026-10-26T09:09:03.235Z'
|
|
36
|
-
})
|
|
37
|
-
})
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
describe('a coded value', () => {
|
|
41
|
-
const kind = { name: 'kind', words: 'notice.kind.' }
|
|
42
|
-
it('★ is read by its word, the code itself when there is none', () => {
|
|
43
|
-
expect(wordOf(kind, 'HR', say)).toBe('인사')
|
|
44
|
-
expect(wordOf(kind, 'SYSTEM', say)).toBe('SYSTEM')
|
|
45
|
-
expect(wordOf({ name: 'title' }, 'HR', say)).toBe('HR')
|
|
46
|
-
expect(wordOf(kind, null, say)).toBeNull()
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
it('★ the legend names the codes the rows hold, column by column', () => {
|
|
50
|
-
expect(legendOf([kind, { name: 'title' }], [{ kind: 'HR', title: 'a' }, { kind: 'EVENT', title: 'b' }, { kind: null }], say)).toEqual({ kind: { HR: '인사', EVENT: '행사' } })
|
|
51
|
-
})
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
describe('the read tool', () => {
|
|
55
|
-
const target = listReadTarget({
|
|
56
|
-
key: 'test.notices',
|
|
57
|
-
title: 'title.notices',
|
|
58
|
-
name: 'notices',
|
|
59
|
-
listQuery: 'notices',
|
|
60
|
-
selection: 'id title kind state publishedAt',
|
|
61
|
-
columns: [
|
|
62
|
-
{ name: 'title', type: 'string' },
|
|
63
|
-
{ name: 'kind', type: 'string', words: 'notice.kind.' },
|
|
64
|
-
{ name: 'state', type: 'string', words: 'notice.state.' },
|
|
65
|
-
{ name: 'publishedAt', type: 'date' }
|
|
66
|
-
],
|
|
67
|
-
status: { field: 'state', values: ['unread', 'read'] }
|
|
68
|
-
})
|
|
69
|
-
const items = Array.from({ length: 3 }, (_, i) => ({ id: `n${i}`, title: `t${i}`, kind: i ? 'EVENT' : 'HR', state: 'unread', publishedAt: '2026-10-26T09:09:03.235Z' }))
|
|
70
|
-
const calls: any[] = []
|
|
71
|
-
const run = async (_document: string, variables: any) => (calls.push(variables), { data: { notices: { items, total: items.length } } })
|
|
72
|
-
/* Not this machine's zone - a read that forgot the domain's zone would read the machine's instead. */
|
|
73
|
-
const context = { t: (key: string) => WORDS[key] ?? key, state: { domain: { timezone: 'UTC' } } }
|
|
74
|
-
|
|
75
|
-
beforeEach(() => {
|
|
76
|
-
clearReadTargets()
|
|
77
|
-
calls.length = 0
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
it('★ gives the model the codes, their words and the moments in the domain\'s time - and its condition names the code', async () => {
|
|
81
|
-
const result: any = await queryRecords(target, { status: 'unread' }, context, run)
|
|
82
|
-
expect(calls[0].filters).toEqual([{ name: 'state', operator: 'eq', value: 'unread' }])
|
|
83
|
-
expect(result.rows[0]).toMatchObject({ kind: 'HR', state: 'unread', publishedAt: '2026-10-26 09:09' })
|
|
84
|
-
expect(result.legend).toEqual({ kind: { HR: '인사', EVENT: '행사' }, state: { unread: '안 읽음' } })
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
it('★ the 작업 패널 table shows the words', async () => {
|
|
88
|
-
const result: any = await queryRecords(target, { show: 'workspace' }, context, run)
|
|
89
|
-
const table = result.forScreen.workspace.blocks.find((one: any) => one.kind === 'table')
|
|
90
|
-
expect(table.rows[0]).toMatchObject({ kind: '인사', state: '안 읽음', publishedAt: '2026-10-26 09:09' })
|
|
91
|
-
})
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
describe('a column of many', () => {
|
|
95
|
-
it('★ a path through a list reads each one, comma-separated - an invention\'s inventors', () => {
|
|
96
|
-
const columns = [{ name: 'inventors', path: 'inventors.name', type: 'string' }, { name: 'none', path: 'none.name', type: 'string' }] as any
|
|
97
|
-
expect(rowOf({ columns }, { id: 'a', inventors: [{ name: '김가람' }, { name: '이나래' }], none: [] })).toEqual({ id: 'a', inventors: '김가람, 이나래', none: null })
|
|
98
|
-
})
|
|
99
|
-
})
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* A read takes a record by the key it was shown by (2026-10-23) - `<axis>:<uuid>`, as an open record's anchor and an
|
|
3
|
-
* application's evidence write it. A 360 read and a list read asked by id took the key as the id and found nothing.
|
|
4
|
-
*/
|
|
5
|
-
import { readCriteria, type DetailRead, type ReadTarget } from './read-target'
|
|
6
|
-
import { queryDetail } from './read-tools'
|
|
7
|
-
|
|
8
|
-
const ID = 'f92c04ec-40c4-4be8-8160-080cff20e750'
|
|
9
|
-
|
|
10
|
-
describe('a read names the record the model was shown', () => {
|
|
11
|
-
const lines = { key: 'office.cash-transaction', criteria: [] } as unknown as ReadTarget
|
|
12
|
-
|
|
13
|
-
it('★ a list read by id takes the key of its own axis - the target key\'s last part', () => {
|
|
14
|
-
expect(readCriteria(lines, { id: `cash-transaction:${ID}` }).criteria).toEqual({ id: ID })
|
|
15
|
-
expect(readCriteria(lines, { id: ID }).criteria).toEqual({ id: ID })
|
|
16
|
-
/* Another record's key is not this record - asked as written, it finds nothing. */
|
|
17
|
-
expect(readCriteria(lines, { id: `contract:${ID}` }).criteria).toEqual({ id: `contract:${ID}` })
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
it('★ a row whose own id is not a uuid is read by its key too - a training standing `<kind>:<year>:<employee>`', () => {
|
|
21
|
-
const standings = { key: 'compliance.trainings', criteria: [] } as unknown as ReadTarget
|
|
22
|
-
expect(readCriteria(standings, { id: `trainings:PRIVACY:2026:${ID}` }).criteria).toEqual({ id: `PRIVACY:2026:${ID}` })
|
|
23
|
-
expect(readCriteria(standings, { id: `PRIVACY:2026:${ID}` }).criteria).toEqual({ id: `PRIVACY:2026:${ID}` })
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
it('★ a whole answer takes the key of the axis its id argument declares', async () => {
|
|
27
|
-
const summary: DetailRead = {
|
|
28
|
-
key: 'office.contract-360',
|
|
29
|
-
description: "one contract's 360.",
|
|
30
|
-
query: 'query ($id: String!) { contract360(id: $id) { code } }',
|
|
31
|
-
args: [{ name: 'id', type: 'string', required: true, axis: 'contract' }]
|
|
32
|
-
}
|
|
33
|
-
const asked: any[] = []
|
|
34
|
-
const run = async (_document: string, variables: any) => {
|
|
35
|
-
asked.push(variables)
|
|
36
|
-
return { data: { contract360: { code: 'H2026012' } } }
|
|
37
|
-
}
|
|
38
|
-
await queryDetail(summary, { id: `contract:${ID}` }, run)
|
|
39
|
-
await queryDetail(summary, { id: `cash-transaction:${ID}` }, run)
|
|
40
|
-
expect(asked).toEqual([{ id: ID }, { id: `cash-transaction:${ID}` }])
|
|
41
|
-
})
|
|
42
|
-
})
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* What this guards: the grounding warning does not fire on the person's own words.
|
|
3
|
-
*
|
|
4
|
-
* The guard compares identifiers in the answer against the evidence. The neutral door handed it
|
|
5
|
-
* the tool results alone, so `EQ-CAM-DRIVER-01` — typed by the person, echoed by the assistant —
|
|
6
|
-
* came back as an identifier with no basis whenever the tool that would have confirmed it refused
|
|
7
|
-
* or was not called. A warning that fires on what the person just typed teaches people to ignore
|
|
8
|
-
* warnings.
|
|
9
|
-
*/
|
|
10
|
-
import { checkGrounding, buildGroundedCorpus } from '@things-factory/ai-client-base'
|
|
11
|
-
|
|
12
|
-
import { groundingSourcesFor } from './grounding-sources'
|
|
13
|
-
|
|
14
|
-
const corpus = (sources: any, toolResults: string[] = []) => buildGroundedCorpus({ ...sources, toolResults })
|
|
15
|
-
|
|
16
|
-
it('★ an identifier the person typed is evidence', () => {
|
|
17
|
-
const sources = groundingSourcesFor({
|
|
18
|
-
systemPrompt: 'you answer about one space',
|
|
19
|
-
messages: [{ content: 'EQ-CAM-DRIVER-01 을 가운데에 놓아줘' }]
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
expect(checkGrounding('EQ-CAM-DRIVER-01 배치를 제안했습니다', corpus(sources))).toEqual([])
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
it('★ an identifier the surface sent in its snapshot is evidence', () => {
|
|
26
|
-
const sources = groundingSourcesFor({ hostContext: { components: [{ tag: 'EQ-CAM-DRIVER-01' }] } })
|
|
27
|
-
|
|
28
|
-
expect(checkGrounding('EQ-CAM-DRIVER-01 은 이미 보드에 있습니다', corpus(sources))).toEqual([])
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
it('★ an identifier from nowhere is still flagged — this must not become an empty guard', () => {
|
|
32
|
-
const sources = groundingSourcesFor({
|
|
33
|
-
systemPrompt: 'you answer about one space',
|
|
34
|
-
messages: [{ content: '지금 상태 알려줘' }],
|
|
35
|
-
hostContext: { spaceId: 'S-12' }
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
expect(checkGrounding('EQ-NOT-REAL-99 가 멈춰 있습니다', corpus(sources))).toEqual(['EQ-NOT-REAL-99'])
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
it('the names in the system prompt are evidence — a mode may list what can be placed', () => {
|
|
42
|
-
const sources = groundingSourcesFor({ systemPrompt: 'placeable types: twin-base-card, twin-storage' })
|
|
43
|
-
|
|
44
|
-
expect(checkGrounding('twin-storage 로 놓겠습니다', corpus(sources))).toEqual([])
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
it('non-text turns and unserialisable context are left out rather than failing', () => {
|
|
48
|
-
const circular: any = {}
|
|
49
|
-
circular.self = circular
|
|
50
|
-
|
|
51
|
-
const sources = groundingSourcesFor({ messages: [{ content: [{ type: 'image' }] as any }], hostContext: circular })
|
|
52
|
-
|
|
53
|
-
expect(sources.messages).toBeUndefined()
|
|
54
|
-
expect(sources.hostContext).toBeUndefined()
|
|
55
|
-
})
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* What counts as evidence, besides the tool results (ADR-0042's cousin: the grounding guard).
|
|
3
|
-
*
|
|
4
|
-
* The guard flags identifiers in an answer that appear in none of the evidence — that is how an
|
|
5
|
-
* invented order number or tag is caught. `ai-client-base` documents three legitimate sources
|
|
6
|
-
* beside the tool results: the system prompt, the conversation itself, and the context the host
|
|
7
|
-
* put in front of it. The neutral door passed none of them, so the corpus was the tool results
|
|
8
|
-
* alone, and an identifier the **person themselves typed** came back flagged as unfounded.
|
|
9
|
-
*
|
|
10
|
-
* A warning that fires on the person's own words is worse than no warning: a few of those and the
|
|
11
|
-
* warning stops being read, including the time it is right.
|
|
12
|
-
*/
|
|
13
|
-
export interface GroundingSourceInput {
|
|
14
|
-
systemPrompt?: string
|
|
15
|
-
/** The turns handed to the model this call. Image parts and other non-text carry no identifiers. */
|
|
16
|
-
messages?: Array<{ content?: unknown }>
|
|
17
|
-
/** What the surface said it is looking at. Client-supplied, and evidence about that person's screen. */
|
|
18
|
-
hostContext?: unknown
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function groundingSourcesFor(input: GroundingSourceInput): {
|
|
22
|
-
systemPrompt?: string
|
|
23
|
-
messages?: string[]
|
|
24
|
-
hostContext?: string
|
|
25
|
-
} {
|
|
26
|
-
const messages = (input.messages ?? [])
|
|
27
|
-
.map(message => (typeof message?.content === 'string' ? message.content : ''))
|
|
28
|
-
.filter(Boolean)
|
|
29
|
-
|
|
30
|
-
return {
|
|
31
|
-
systemPrompt: input.systemPrompt,
|
|
32
|
-
messages: messages.length ? messages : undefined,
|
|
33
|
-
hostContext: stringifyHostContext(input.hostContext)
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/** The snapshot is evidence as text — only identifier tokens are read out of it. */
|
|
38
|
-
function stringifyHostContext(hostContext: unknown): string | undefined {
|
|
39
|
-
if (!hostContext || typeof hostContext !== 'object') return undefined
|
|
40
|
-
try {
|
|
41
|
-
return JSON.stringify(hostContext)
|
|
42
|
-
} catch {
|
|
43
|
-
/* A snapshot that cannot be serialised is no evidence — it is not a reason to fail the turn. */
|
|
44
|
-
return undefined
|
|
45
|
-
}
|
|
46
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The help tools (ADR-0181): the assistant finds a part of the application's help and reads it, in the person's language.
|
|
3
|
-
*/
|
|
4
|
-
jest.mock('@things-factory/help', () => {
|
|
5
|
-
const { HelpIndex, partsOfDocument } = jest.requireActual('../../../../help/server/help-index')
|
|
6
|
-
const index = new HelpIndex([
|
|
7
|
-
...partsOfDocument('office/guide-employee.ko.html', '<h1>모든 직원</h1><h2 id="spending">경비 · 지출 올리기</h2><p>내 정보 › 내 지출결의 에서 새 결의를 작성합니다.</p>'),
|
|
8
|
-
...partsOfDocument('office/guide-employee.html', '<h1>Everyone</h1><h2 id="spending">Spending</h2><p>Write a new claim in My expense claims.</p>')
|
|
9
|
-
])
|
|
10
|
-
return { searchHelp: async (q: string, o: any) => index.search(q, o), readHelp: async (t: string, s: string, l: string) => index.read(t, s, l) }
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
import { helpCategory, readHelpDocument, searchHelpDocuments } from './help-tools'
|
|
14
|
-
import { modeFrontCategories, modeToolCategories } from '../assistant-mode/mode-categories'
|
|
15
|
-
|
|
16
|
-
const korean = { state: { lng: 'ko' } }
|
|
17
|
-
|
|
18
|
-
describe('the help tools', () => {
|
|
19
|
-
it('finds a part with its title and its link', async () => {
|
|
20
|
-
expect(await searchHelpDocuments({ query: '지출결의 올리기' }, korean)).toEqual({
|
|
21
|
-
found: 1,
|
|
22
|
-
parts: [{ topic: 'office/guide-employee', section: 'spending', title: '모든 직원 › 경비 · 지출 올리기', summary: '내 정보 › 내 지출결의 에서 새 결의를 작성합니다.', link: 'help?topic=office%2Fguide-employee§ion=spending' }]
|
|
23
|
-
})
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
it('says when the help has nothing, so the model does not answer from elsewhere', async () => {
|
|
27
|
-
expect(await searchHelpDocuments({ query: '주식 매수 방법' }, korean)).toMatchObject({ found: 0, message: expect.stringContaining('say so') })
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
it('reads a part in the person\'s language', async () => {
|
|
31
|
-
expect(await readHelpDocument({ topic: 'office/guide-employee', section: 'spending' }, { state: { lng: 'en' } })).toMatchObject({ found: true, title: 'Spending' })
|
|
32
|
-
expect(await readHelpDocument({ topic: 'office/guide-employee', section: 'none' }, korean)).toMatchObject({ found: false })
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
it('reaches no door, and every conversation has it in front', () => {
|
|
36
|
-
expect(helpCategory.specs.map(spec => spec.doors)).toEqual([[], []])
|
|
37
|
-
expect(modeToolCategories({})).toContain('help-documents')
|
|
38
|
-
expect(modeFrontCategories({})).toContain('help-documents')
|
|
39
|
-
})
|
|
40
|
-
})
|