@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,117 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Emptying deleted conversations after they have been kept long enough - design/ai/shared-dock.md §9-5.
|
|
3
|
-
*
|
|
4
|
-
* `deleteAISession` is a soft delete: from that moment nobody can open the conversation or its files
|
|
5
|
-
* (every door checks the session), and within the retention period it can still be brought back whole.
|
|
6
|
-
* Nothing ever emptied them afterwards, so a deleted conversation's messages - and now its files - stayed
|
|
7
|
-
* forever (2026-09-25). This job removes a conversation, its messages, its participants and its attached
|
|
8
|
-
* files together once the retention period has passed.
|
|
9
|
-
*
|
|
10
|
-
* Retention: config `ai-assistant.sessionRetentionDays`, default 30. `0` or `false` turns the job off.
|
|
11
|
-
*
|
|
12
|
-
* The same run removes empty conversations nobody opened for a day (`session-cleanup.ts`, shared-dock.md §2-7) -
|
|
13
|
-
* 「새 대화」 starts a row before its first question, and one never asked stays in the list otherwise.
|
|
14
|
-
*/
|
|
15
|
-
import { config } from '@things-factory/env'
|
|
16
|
-
import { getRepository } from '@things-factory/shell'
|
|
17
|
-
import { In, IsNull, LessThan, Not } from 'typeorm'
|
|
18
|
-
|
|
19
|
-
import { ChatMessage } from '../chat-message/chat-message.js'
|
|
20
|
-
import { ChatSessionParticipant } from '../chat-session-participant/chat-session-participant.js'
|
|
21
|
-
import { ChatSession } from './chat-session.js'
|
|
22
|
-
import { removeSessionFiles } from './session-attachments.js'
|
|
23
|
-
|
|
24
|
-
import { DAY_MS, purgeCutoff, retentionDaysOf } from './session-retention.js'
|
|
25
|
-
import { EMPTY_DAYS, emptyAndAbandoned } from './session-cleanup.js'
|
|
26
|
-
|
|
27
|
-
export { DEFAULT_RETENTION_DAYS, purgeCutoff, retentionDaysOf } from './session-retention.js'
|
|
28
|
-
/** How many conversations one run empties - a large backlog is worked off over several runs. */
|
|
29
|
-
export const PURGE_BATCH = 100
|
|
30
|
-
|
|
31
|
-
export interface PurgeResult {
|
|
32
|
-
purged: number
|
|
33
|
-
/** Empty conversations removed - never asked anything, and nobody opened them for a day. */
|
|
34
|
-
emptied: number
|
|
35
|
-
failed: { sessionId: string; message: string }[]
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/** A conversation, its messages, its participants and its files, gone together. */
|
|
39
|
-
async function removeConversation(session: ChatSession): Promise<void> {
|
|
40
|
-
await removeSessionFiles(session as any)
|
|
41
|
-
/* Messages point at each other (parentMessage) - drop the links before the rows. */
|
|
42
|
-
await getRepository(ChatMessage).update({ session: { id: session.id }, parentMessage: Not(IsNull()) } as any, { parentMessage: null } as any)
|
|
43
|
-
await getRepository(ChatMessage).delete({ session: { id: session.id } } as any)
|
|
44
|
-
await getRepository(ChatSessionParticipant).delete({ session: { id: session.id } } as any)
|
|
45
|
-
/* Board patches and anything else hanging on the session go with it (ON DELETE CASCADE). */
|
|
46
|
-
await getRepository(ChatSession).delete({ id: In([session.id]) } as any)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/** Removes the empty conversations nobody opened for EMPTY_DAYS. Each is checked against its messages and seats, not the denormalized activity alone. */
|
|
50
|
-
export async function removeEmptySessions(now = new Date(), result: PurgeResult = { purged: 0, emptied: 0, failed: [] }): Promise<PurgeResult> {
|
|
51
|
-
const sessions = await getRepository(ChatSession).find({
|
|
52
|
-
where: { lastMessageAt: IsNull(), createdAt: LessThan(new Date(now.getTime() - EMPTY_DAYS * DAY_MS)) } as any,
|
|
53
|
-
relations: ['domain'],
|
|
54
|
-
take: PURGE_BATCH
|
|
55
|
-
})
|
|
56
|
-
for (const session of sessions) {
|
|
57
|
-
try {
|
|
58
|
-
const messages = await getRepository(ChatMessage).count({ where: { session: { id: session.id } } as any })
|
|
59
|
-
const seats = await getRepository(ChatSessionParticipant).find({ where: { session: { id: session.id } } as any, withDeleted: true })
|
|
60
|
-
const touched = seats.flatMap(seat => [seat.updatedAt, seat.lastReadAt]).filter(Boolean) as Date[]
|
|
61
|
-
const lastTouchedAt = touched.length ? new Date(Math.max(...touched.map(at => new Date(at).getTime()))) : null
|
|
62
|
-
if (!emptyAndAbandoned({ ...(session as any), messages, lastTouchedAt }, now)) continue
|
|
63
|
-
await removeConversation(session)
|
|
64
|
-
result.emptied++
|
|
65
|
-
} catch (error) {
|
|
66
|
-
result.failed.push({ sessionId: session.id!, message: (error as Error).message })
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return result
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/** Empties the conversations whose deletion is older than the retention period. */
|
|
73
|
-
export async function purgeDeletedSessions(now = new Date(), retentionDays = retentionDaysOf(config.get('ai-assistant', {})?.sessionRetentionDays)): Promise<PurgeResult> {
|
|
74
|
-
const result: PurgeResult = { purged: 0, emptied: 0, failed: [] }
|
|
75
|
-
if (retentionDays === null) return result
|
|
76
|
-
|
|
77
|
-
const sessions = await getRepository(ChatSession).find({
|
|
78
|
-
where: { deletedAt: LessThan(purgeCutoff(now, retentionDays)) } as any,
|
|
79
|
-
withDeleted: true,
|
|
80
|
-
relations: ['domain'],
|
|
81
|
-
take: PURGE_BATCH
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
for (const session of sessions) {
|
|
85
|
-
try {
|
|
86
|
-
await removeConversation(session)
|
|
87
|
-
result.purged++
|
|
88
|
-
} catch (error) {
|
|
89
|
-
/* One conversation that cannot be emptied must not stop the rest; it is tried again next run. */
|
|
90
|
-
result.failed.push({ sessionId: session.id!, message: (error as Error).message })
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return result
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
let timer: ReturnType<typeof setInterval> | undefined
|
|
98
|
-
|
|
99
|
-
/** Runs the job once a little after boot, then daily. The timer never keeps the process alive. */
|
|
100
|
-
export function schedulePurge(): void {
|
|
101
|
-
if (timer) return
|
|
102
|
-
const run = () =>
|
|
103
|
-
purgeDeletedSessions()
|
|
104
|
-
.then(result => removeEmptySessions(new Date(), result))
|
|
105
|
-
.then(({ purged, emptied, failed }) => {
|
|
106
|
-
if (purged || emptied || failed.length)
|
|
107
|
-
console.info(`[ai-assistant] purged ${purged} deleted and ${emptied} empty conversation(s)`, failed.length ? { failed } : '')
|
|
108
|
-
})
|
|
109
|
-
.catch(error => console.warn('[ai-assistant] purging deleted conversations failed:', (error as Error).message))
|
|
110
|
-
|
|
111
|
-
const first = setTimeout(run, 60 * 1000)
|
|
112
|
-
first.unref?.()
|
|
113
|
-
timer = setInterval(run, DAY_MS)
|
|
114
|
-
timer.unref?.()
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
process.on('bootstrap-module-start' as any, () => schedulePurge())
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/* How long a deleted conversation is kept before it is emptied - pure, tested alone (shared-dock.md §9-5). */
|
|
2
|
-
|
|
3
|
-
export const DAY_MS = 24 * 60 * 60 * 1000
|
|
4
|
-
export const DEFAULT_RETENTION_DAYS = 30
|
|
5
|
-
|
|
6
|
-
/** The retention the config asks for: a positive number of days, `null` when the job is off, the default when unreadable. */
|
|
7
|
-
export function retentionDaysOf(value: unknown): number | null {
|
|
8
|
-
if (value === false || value === 0 || value === '0') return null
|
|
9
|
-
const days = Number(value)
|
|
10
|
-
return Number.isFinite(days) && days > 0 ? days : DEFAULT_RETENTION_DAYS
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/** Conversations deleted before this moment are due. */
|
|
14
|
-
export function purgeCutoff(now: Date, retentionDays: number): Date {
|
|
15
|
-
return new Date(now.getTime() - retentionDays * DAY_MS)
|
|
16
|
-
}
|
|
17
|
-
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* ADR-0073 판정 2 — 새 대화가 공개로 태어나는가, 비공개는 누가 읽는가.
|
|
3
|
-
*
|
|
4
|
-
* 옮겨 적어 만든 세션이 공개로 태어나면 사적으로 오간 원문이 소급해서 공개된다. 그 한 줄을 여기서 문다.
|
|
5
|
-
*/
|
|
6
|
-
import { initialVisibility, isOpenRoom, mayReadSession, maySeat, SESSION_VISIBILITIES } from './session-visibility'
|
|
7
|
-
|
|
8
|
-
describe('session visibility', () => {
|
|
9
|
-
it('★ 앵커가 있어도 비공개로 시작한다 — 앵커는 무엇에 대한 이야기인지이지 누구에게 보이는지가 아니다', () => {
|
|
10
|
-
for (const anchorType of ['space', 'board', 'station', 'application', 'domain', 'subject', 'figure', 'instance']) {
|
|
11
|
-
expect(initialVisibility({ anchorType })).toBe('private')
|
|
12
|
-
}
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
it('★ 옮겨 적어 만든 대화는 비공개로 시작한다 — 원문이 소급 공개되지 않는다', () => {
|
|
16
|
-
expect(initialVisibility({ anchorType: 'board', copyOf: 'session-1' })).toBe('private')
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
it('앵커 없는 대화는 비공개로 시작한다', () => {
|
|
20
|
-
expect(initialVisibility({})).toBe('private')
|
|
21
|
-
expect(initialVisibility({ anchorType: null })).toBe('private')
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
it('★ 비공개 대화는 참여자만 읽는다', () => {
|
|
25
|
-
expect(mayReadSession('private', false)).toBe(false)
|
|
26
|
-
expect(mayReadSession('private', true)).toBe(true)
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
it('공개 대화는 참여자가 아니어도 읽는다 — 초대 절차가 없다', () => {
|
|
30
|
-
expect(mayReadSession('open', false)).toBe(true)
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
it('값이 없는 옛 행은 공개로 읽는다 — 오늘까지 도메인만 보고 있었다', () => {
|
|
34
|
-
expect(mayReadSession(undefined, false)).toBe(true)
|
|
35
|
-
})
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
/*
|
|
39
|
-
* ADR-0073 decision 3 (2026-10-24) — a group is read by its seats, and only the owner hands a seat out.
|
|
40
|
-
*/
|
|
41
|
-
describe('a group room', () => {
|
|
42
|
-
it('three rooms, no more', () => {
|
|
43
|
-
expect([...SESSION_VISIBILITIES]).toEqual(['open', 'group', 'private'])
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
it('★ a group is read by the people seated in it only', () => {
|
|
47
|
-
expect(mayReadSession('group', false)).toBe(false)
|
|
48
|
-
expect(mayReadSession('group', true)).toBe(true)
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
it('★ only an open room skips the seat lookup - a group is not open', () => {
|
|
52
|
-
expect(isOpenRoom('open')).toBe(true)
|
|
53
|
-
expect(isOpenRoom(undefined)).toBe(true)
|
|
54
|
-
expect(isOpenRoom('group')).toBe(false)
|
|
55
|
-
expect(isOpenRoom('private')).toBe(false)
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
it('★ who seats: anyone in an open room, the owner in a group, nobody in a private one', () => {
|
|
59
|
-
expect(maySeat('open', undefined)).toBe(true)
|
|
60
|
-
expect(maySeat('open', 'member')).toBe(true)
|
|
61
|
-
expect(maySeat('group', 'owner')).toBe(true)
|
|
62
|
-
expect(maySeat('group', 'member')).toBe(false)
|
|
63
|
-
expect(maySeat('group', 'viewer')).toBe(false)
|
|
64
|
-
expect(maySeat('group', undefined)).toBe(false)
|
|
65
|
-
expect(maySeat('private', 'owner')).toBe(false)
|
|
66
|
-
})
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
/*
|
|
70
|
-
* ADR-0073 결정 2 — 대상 없는 개인 질문은 공개 방으로 태어나지 않는다.
|
|
71
|
-
*
|
|
72
|
-
* `'none'` 은 저장되는 앵커 종류 목록에 든 글자다(대상이 없다는 것도 행에 적어야 하므로). 「값이 있으면
|
|
73
|
-
* 앵커가 있다」로 읽으면 그 글자가 앵커 노릇을 하고, `twin.none` 대화가 도메인 안 누구에게나 열린다.
|
|
74
|
-
*/
|
|
75
|
-
describe("'none' is not an anchor", () => {
|
|
76
|
-
it('★ 대상 없는 대화는 비공개로 시작한다 — 앵커 종류 목록에 그 글자가 있어도', () => {
|
|
77
|
-
expect(initialVisibility({ anchorType: 'none' })).toBe('private')
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
it('대상이 있는 대화도 비공개다', () => {
|
|
81
|
-
expect(initialVisibility({ anchorType: 'space' })).toBe('private')
|
|
82
|
-
})
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
/*
|
|
86
|
-
* Calling a door is not reading a conversation (ruled 2026-09-24).
|
|
87
|
-
*
|
|
88
|
-
* Every ai-assistant door now admits the domain owner (`test/open-doors.test.ts`), so the owner may
|
|
89
|
-
* open the dock anywhere in the domain. That says who may *call* — not whose private conversation they
|
|
90
|
-
* may read. The room rule is asked with two things only, the visibility and whether the caller sits in
|
|
91
|
-
* the room, and neither place that reads a room asks anything about ownership. If one ever did, a domain
|
|
92
|
-
* owner would read every private conversation in the domain, and nothing on the screen would say so.
|
|
93
|
-
*/
|
|
94
|
-
describe('the domain owner still reads a private conversation only as a participant', () => {
|
|
95
|
-
const { readFileSync } = require('fs')
|
|
96
|
-
const { join } = require('path')
|
|
97
|
-
const source = (path: string) => readFileSync(join(__dirname, '..', path), 'utf8') as string
|
|
98
|
-
|
|
99
|
-
/** The body of `chatMessages` — the stored path. The stream's path is the room lookup and `mayHearRoom`. */
|
|
100
|
-
const storedPath = () => {
|
|
101
|
-
const resolver = source('chat-session-resolver.ts')
|
|
102
|
-
const start = resolver.indexOf('async chatMessages(')
|
|
103
|
-
expect(start).toBeGreaterThan(0)
|
|
104
|
-
const end = resolver.indexOf('\n @', start)
|
|
105
|
-
return resolver.slice(start, end > start ? end : undefined)
|
|
106
|
-
}
|
|
107
|
-
const streamPath = () => {
|
|
108
|
-
const broadcast = source('chat-message/chat-message-broadcast.ts')
|
|
109
|
-
return source('chat-message/chat-message-room.ts') + broadcast.slice(broadcast.indexOf('export interface ChatRoomLookup'))
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const OWNERSHIP = /owner|superUser|checkPermission|hasPrivilege|privilege/i
|
|
113
|
-
|
|
114
|
-
it('★ the rule has no input for ownership — visibility and participation, nothing else', () => {
|
|
115
|
-
expect(mayReadSession.length).toBe(2)
|
|
116
|
-
expect(mayReadSession('private', false)).toBe(false)
|
|
117
|
-
})
|
|
118
|
-
|
|
119
|
-
it('★ the stored path asks the rule, and asks nothing about ownership', () => {
|
|
120
|
-
const body = storedPath()
|
|
121
|
-
expect(body).toMatch(/mayReadSession\(/)
|
|
122
|
-
expect(body).not.toMatch(OWNERSHIP)
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
it('★ the stream asks the same rule, and asks nothing about ownership', () => {
|
|
126
|
-
const body = streamPath()
|
|
127
|
-
expect(body).toMatch(/mayReadSession\(/)
|
|
128
|
-
expect(body).not.toMatch(OWNERSHIP)
|
|
129
|
-
})
|
|
130
|
-
})
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* 새 대화가 공개로 태어나는가 — ADR-0073 판정 2.
|
|
3
|
-
*
|
|
4
|
-
* 판정을 세션을 만드는 자리마다 적으면 한 곳이 빠진 날 그 세션만 다른 규칙으로 산다. 한 줄로 모은다.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/*
|
|
8
|
-
* Three rooms (2026-10-24, the user - ADR-0073 decision 3):
|
|
9
|
-
* open anyone in the domain walks in and writes.
|
|
10
|
-
* group the people the owner brought in, and the owner.
|
|
11
|
-
* private the owner alone. Nobody is seated, and turning a group private sends its members out.
|
|
12
|
-
*/
|
|
13
|
-
export type SessionVisibility = 'open' | 'group' | 'private'
|
|
14
|
-
|
|
15
|
-
export const SESSION_VISIBILITIES: readonly SessionVisibility[] = ['open', 'group', 'private']
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* 이렇게 만들어진 세션은 무엇으로 시작하나 — **언제나 비공개.**
|
|
19
|
-
*
|
|
20
|
-
* ── 앵커가 있으면 공개로 태어나던 것을 거둔 이유 (2026-09-30, 제품 오너) ──
|
|
21
|
-
* operato-office 의 대화는 앱 행(`application`)에 매달린다. 그래서 원장 · 급여를 묻는 경영자의 질문이 도메인
|
|
22
|
-
* 안 모든 직원에게 열린 방으로 태어났다. 목록은 그것을 「사업장 공개」 한 줄로만 말해서 공개와 비공개가 한눈에
|
|
23
|
-
* 갈리지 않았다. 앵커는 「무엇에 대한 이야기인가」이지 「누구에게 보이나」가 아니다.
|
|
24
|
-
*
|
|
25
|
-
* 공개는 owner 가 고른다(`setSessionVisibility`) — 화면이 여는 순간 되묻고, 공개 대화는 도크가 다르게 그린다.
|
|
26
|
-
*/
|
|
27
|
-
export function initialVisibility(_session: { anchorType?: string | null; copyOf?: string | null } = {}): SessionVisibility {
|
|
28
|
-
return 'private'
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Is the room open to everyone in the domain - so no seat needs looking up?
|
|
33
|
-
*
|
|
34
|
-
* Doors skip the participant lookup for an open room. They asked `visibility === 'private'` for it, and a
|
|
35
|
-
* group room is neither: asked that way, a group conversation read like an open one. They ask here.
|
|
36
|
-
*/
|
|
37
|
-
export function isOpenRoom(visibility: string | null | undefined): boolean {
|
|
38
|
-
return (visibility ?? 'open') === 'open'
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/** 이 사람이 이 대화를 읽을 수 있나. open 이면 도메인 안 누구나, group · private 이면 앉은 사람만. */
|
|
42
|
-
export function mayReadSession(visibility: string | null | undefined, isParticipant: boolean): boolean {
|
|
43
|
-
return isOpenRoom(visibility) || isParticipant
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* May this person seat someone in this conversation - by a mention or by inviting them?
|
|
48
|
-
*
|
|
49
|
-
* In an open room a seat grants nothing (anyone walks in), so anyone may point a colleague at it. In a group
|
|
50
|
-
* the seat is the key, and only the owner hands it out - a member's mention tells, it does not seat. A private
|
|
51
|
-
* room seats nobody: it is the owner's alone. Both seating doors ask this one line.
|
|
52
|
-
*/
|
|
53
|
-
export function maySeat(visibility: string | null | undefined, seatRole: string | null | undefined): boolean {
|
|
54
|
-
if (isOpenRoom(visibility)) return true
|
|
55
|
-
if (visibility === 'group') return seatRole === 'owner'
|
|
56
|
-
return false
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* 이 사람이 이 대화에 **쓸** 수 있나 — 읽을 수 있는 사람만 쓴다.
|
|
61
|
-
*
|
|
62
|
-
* 읽는 문(`chatMessages`)과 목록만 막고 쓰는 문을 열어 두면, 비공개 대화의 id 를 가진 사람이 그 안에 말을
|
|
63
|
-
* 넣을 수 있었다. `assistantChat` 에서는 더 나쁘다 — 답이 그 대화의 이력 위에서 만들어지므로, 읽을 수 없는
|
|
64
|
-
* 내용이 답으로 새어 나간다(2026-09-24, operato-ecs 두 사람 시험 7번). 쓰는 문도 같은 관문을 지난다.
|
|
65
|
-
*/
|
|
66
|
-
export function mayWriteSession(visibility: string | null | undefined, isParticipant: boolean): boolean {
|
|
67
|
-
return mayReadSession(visibility, isParticipant)
|
|
68
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The write gate - a private conversation is written by its people only (ADR-0073 decision 1, for writing).
|
|
3
|
-
* Reproduces operato-ecs two-person test step 7 (2026-09-24): an outsider wrote into a private conversation
|
|
4
|
-
* by its id, and through assistantChat the answer would be built on that private history.
|
|
5
|
-
*/
|
|
6
|
-
import { assertMayWriteSession } from './session-write-gate'
|
|
7
|
-
import { mayWriteSession } from './session-visibility'
|
|
8
|
-
import { isRoomRole } from '../chat-session-participant/participant-lookup-roles'
|
|
9
|
-
|
|
10
|
-
const t = (_key: string, options?: any) => options?.defaultValue ?? _key
|
|
11
|
-
|
|
12
|
-
describe('who may write into a conversation', () => {
|
|
13
|
-
it('anyone in the domain writes into a public one - no lookup', async () => {
|
|
14
|
-
let asked = false
|
|
15
|
-
await expect(
|
|
16
|
-
assertMayWriteSession({ session: { visibility: 'open' }, userId: 'bob', isParticipant: async () => ((asked = true), false), t })
|
|
17
|
-
).resolves.toBeUndefined()
|
|
18
|
-
expect(asked).toBe(false)
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
it('a row from before the visibility column is public', async () => {
|
|
22
|
-
await expect(assertMayWriteSession({ session: {}, userId: 'bob', isParticipant: async () => false, t })).resolves.toBeUndefined()
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
it('★ an outsider is refused on a private one, by a sentence that says what to do', async () => {
|
|
26
|
-
await expect(
|
|
27
|
-
assertMayWriteSession({ session: { visibility: 'private' }, userId: 'bob', isParticipant: async () => false, t })
|
|
28
|
-
).rejects.toThrow(/only they can write here\. ask the person who started it to bring you in/)
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
it('★ an outsider is refused on a group one too - a group is not an open room', async () => {
|
|
32
|
-
await expect(
|
|
33
|
-
assertMayWriteSession({ session: { visibility: 'group' }, userId: 'bob', isParticipant: async () => false, t })
|
|
34
|
-
).rejects.toThrow(/private to the people in it/)
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
it('a participant writes into a private one', async () => {
|
|
38
|
-
await expect(
|
|
39
|
-
assertMayWriteSession({ session: { visibility: 'private' }, userId: 'alice', isParticipant: async () => true, t })
|
|
40
|
-
).resolves.toBeUndefined()
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
it('no user is no participant', async () => {
|
|
44
|
-
await expect(assertMayWriteSession({ session: { visibility: 'private' }, isParticipant: async () => true, t })).rejects.toThrow()
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
it('the write rule is the read rule', () => {
|
|
48
|
-
expect(mayWriteSession('open', false)).toBe(true)
|
|
49
|
-
expect(mayWriteSession('private', false)).toBe(false)
|
|
50
|
-
expect(mayWriteSession('private', true)).toBe(true)
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
it('★ a hide-only viewer row is not being in the room', () => {
|
|
54
|
-
expect(isRoomRole('owner')).toBe(true)
|
|
55
|
-
expect(isRoomRole('member')).toBe(true)
|
|
56
|
-
expect(isRoomRole('viewer')).toBe(false)
|
|
57
|
-
expect(isRoomRole(undefined)).toBe(false)
|
|
58
|
-
})
|
|
59
|
-
})
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The gate every door that writes into a conversation passes - ADR-0073 decision 1, applied to writing.
|
|
3
|
-
*
|
|
4
|
-
* `mayWriteSession` is the rule; this looks up only what the rule needs (whether the writer is in the
|
|
5
|
-
* room, and only for a private conversation) and refuses by a named message. Kept apart from the resolvers
|
|
6
|
-
* so the five write doors call one line and cannot drift.
|
|
7
|
-
*/
|
|
8
|
-
import { mayWriteSession } from './session-visibility.js'
|
|
9
|
-
|
|
10
|
-
export interface WriteGateInput {
|
|
11
|
-
session: { id?: string; visibility?: string | null }
|
|
12
|
-
userId?: string
|
|
13
|
-
/** Is this user a participant of the session (owner or member)? Asked only for a group or private one. */
|
|
14
|
-
isParticipant: () => Promise<boolean>
|
|
15
|
-
t: (key: string, options?: Record<string, unknown>) => string
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export async function assertMayWriteSession({ session, userId, isParticipant, t }: WriteGateInput): Promise<void> {
|
|
19
|
-
const visibility = session.visibility ?? 'open'
|
|
20
|
-
/* A public conversation is open to everyone in the domain - no lookup. */
|
|
21
|
-
if (visibility === 'open') return
|
|
22
|
-
|
|
23
|
-
const participant = !!userId && (await isParticipant())
|
|
24
|
-
if (!mayWriteSession(visibility, participant)) {
|
|
25
|
-
throw new Error(
|
|
26
|
-
t('ai-assistant.text.private-session-refused', {
|
|
27
|
-
defaultValue: 'this conversation is private to the people in it - only they can write here. ask the person who started it to bring you in.'
|
|
28
|
-
})
|
|
29
|
-
)
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/** Station authoring must never append its design snapshot to another subject's history.
|
|
2
|
-
* This is a consistency check, not authorization; tenant/privilege checks stay in the resolver.
|
|
3
|
-
* Older Board sessions have only boardId, so preserve that supported read shape.
|
|
4
|
-
*/
|
|
5
|
-
const STATION_MISMATCH = 'this conversation belongs to another station screen. open the conversation of the screen you are on.'
|
|
6
|
-
|
|
7
|
-
export function assertStationSession(
|
|
8
|
-
session: {anchorType?:string|null;anchorId?:string|null;boardId?:string|null}|undefined,
|
|
9
|
-
host: {surface?:string;boardId?:unknown}|undefined,
|
|
10
|
-
/* The reader's sentence comes from the request (ADR-0054); without a translator it falls back to English. */
|
|
11
|
-
t?: (key: string, params?: Record<string, any>) => string
|
|
12
|
-
) {
|
|
13
|
-
if(host?.surface!=='station-screen-modeller')return
|
|
14
|
-
const boardId=host.boardId
|
|
15
|
-
const legacy=Boolean(session&&!session.anchorType&&session.boardId)
|
|
16
|
-
const valid=typeof boardId==='string'&&boardId.length>0&&session&&
|
|
17
|
-
(session.anchorType==='board'||legacy)&&
|
|
18
|
-
(session.anchorId||session.boardId)===boardId&&
|
|
19
|
-
(!session.boardId||session.boardId===boardId)
|
|
20
|
-
if(!valid)throw new Error(
|
|
21
|
-
t
|
|
22
|
-
? t('ai-assistant.text.other-station-history', { defaultValue: STATION_MISMATCH })
|
|
23
|
-
: STATION_MISMATCH
|
|
24
|
-
)
|
|
25
|
-
}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The files of this turn, read once for the model and for the tools (ADR-0061, 2026-10-16 decision 2).
|
|
3
|
-
*
|
|
4
|
-
* Before this the door put the files on the model's last message only and handed the tools the client's
|
|
5
|
-
* `hostContext`. A tool that needed the picture - figure's inner step generator - never got it: the dock uploads by
|
|
6
|
-
* `attachmentIds` and leaves `hostContext.image` empty.
|
|
7
|
-
*/
|
|
8
|
-
import { clearToolRegistry, registerToolCategory, registryAssistantChat } from '@things-factory/ai-client-base'
|
|
9
|
-
|
|
10
|
-
import { readTurnAttachments } from './turn-attachments'
|
|
11
|
-
|
|
12
|
-
const PNG_BYTES = Buffer.from([0x89, 0x50, 0x4e, 0x47])
|
|
13
|
-
const JPG_BYTES = Buffer.from([0xff, 0xd8, 0xff])
|
|
14
|
-
|
|
15
|
-
const rows = [
|
|
16
|
-
{ id: 'att-1', name: 'front.png', mimetype: 'image/png', size: '4' },
|
|
17
|
-
{ id: 'att-2', name: 'notes.txt', mimetype: 'text/plain', size: 12 },
|
|
18
|
-
{ id: 'att-3', name: 'side.jpg', mimetype: 'image/jpeg', size: 3 }
|
|
19
|
-
]
|
|
20
|
-
|
|
21
|
-
/* Storage stand-in: what attachmentForModel answers for each row. */
|
|
22
|
-
const read = async (row: any, maxChars: number) => {
|
|
23
|
-
if (row.id === 'att-1') return { type: 'image' as const, data: PNG_BYTES, mediaType: 'image/png', name: row.name }
|
|
24
|
-
if (row.id === 'att-3') return { type: 'image' as const, data: JPG_BYTES, mediaType: 'image/jpeg', name: row.name }
|
|
25
|
-
return { type: 'text' as const, text: 'twelve chars'.slice(0, maxChars), name: row.name, truncated: maxChars < 12 }
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
describe('the files of this turn', () => {
|
|
29
|
-
it('★ the tools get every file as the contract shapes it, in the order the person attached them', async () => {
|
|
30
|
-
const { forTools } = await readTurnAttachments(rows, 20_000, read)
|
|
31
|
-
|
|
32
|
-
expect(forTools).toEqual([
|
|
33
|
-
{ id: 'att-1', name: 'front.png', kind: 'image', mediaType: 'image/png', size: 4, data: PNG_BYTES },
|
|
34
|
-
{ id: 'att-2', name: 'notes.txt', kind: 'text', mediaType: 'text/plain', size: 12, text: 'twelve chars', truncated: false },
|
|
35
|
-
{ id: 'att-3', name: 'side.jpg', kind: 'image', mediaType: 'image/jpeg', size: 3, data: JPG_BYTES }
|
|
36
|
-
])
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
it('the model reads the same files - an image as bytes, a text file as its text with the cut said', async () => {
|
|
40
|
-
const { parts } = await readTurnAttachments(rows, 6, read)
|
|
41
|
-
|
|
42
|
-
expect(parts).toEqual([
|
|
43
|
-
{ type: 'image', source: { kind: 'base64', data: PNG_BYTES, mediaType: 'image/png' } },
|
|
44
|
-
{ type: 'text', text: '[attachment att-2: notes.txt - cut, the file is longer]\ntwelve' },
|
|
45
|
-
{ type: 'image', source: { kind: 'base64', data: JPG_BYTES, mediaType: 'image/jpeg' } }
|
|
46
|
-
])
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
it('a text file cut for the model is cut for the tools too, and says so', async () => {
|
|
50
|
-
const { forTools } = await readTurnAttachments([rows[1]], 6, read)
|
|
51
|
-
|
|
52
|
-
expect(forTools).toEqual([expect.objectContaining({ kind: 'text', text: 'twelve', truncated: true })])
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
it('no files: nothing for either', async () => {
|
|
56
|
-
expect(await readTurnAttachments([], 20_000, read)).toEqual({ parts: [], forTools: [] })
|
|
57
|
-
})
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
describe('the files reach a registered tool through the door', () => {
|
|
61
|
-
afterEach(() => clearToolRegistry())
|
|
62
|
-
|
|
63
|
-
it('★ what the door read is what the tool is handed - in its own field, not in host', async () => {
|
|
64
|
-
const handed: any[] = []
|
|
65
|
-
registerToolCategory({
|
|
66
|
-
name: 'drawing',
|
|
67
|
-
guidance: '- Call proposeDrawing for a drawing.',
|
|
68
|
-
specs: [
|
|
69
|
-
{
|
|
70
|
-
kind: 'read',
|
|
71
|
-
name: 'proposeDrawing',
|
|
72
|
-
description: 'proposes a drawing',
|
|
73
|
-
schema: { type: 'object', properties: {} },
|
|
74
|
-
doors: [],
|
|
75
|
-
builder: (_args: any, context: any) => {
|
|
76
|
-
handed.push(context)
|
|
77
|
-
return { ok: true }
|
|
78
|
-
}
|
|
79
|
-
} as any
|
|
80
|
-
]
|
|
81
|
-
})
|
|
82
|
-
const { forTools } = await readTurnAttachments(rows, 20_000, read)
|
|
83
|
-
let turn = 0
|
|
84
|
-
const client: any = {
|
|
85
|
-
chatWithTools: async () =>
|
|
86
|
-
turn++ === 0
|
|
87
|
-
? { toolCalls: [{ id: 'c1', name: 'proposeDrawing', arguments: {}, type: 'tool_use' }], stopReason: 'tool_use' }
|
|
88
|
-
: { text: 'done', toolCalls: [], stopReason: 'end_turn' }
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
await registryAssistantChat({
|
|
92
|
-
client,
|
|
93
|
-
messages: [{ role: 'user', content: 'make it like the pictures' }],
|
|
94
|
-
systemPrompt: 'draw',
|
|
95
|
-
toolCategories: ['drawing'],
|
|
96
|
-
toolAccess: async () => true,
|
|
97
|
-
state: { domain: { id: 'dom-1' }, user: { id: 'u-1' } },
|
|
98
|
-
hostContext: { figureId: 'fig-1' },
|
|
99
|
-
attachments: forTools
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
expect(handed).toHaveLength(1)
|
|
103
|
-
expect(handed[0].attachments.filter((file: any) => file.kind === 'image').map((file: any) => file.data)).toEqual([PNG_BYTES, JPG_BYTES])
|
|
104
|
-
expect(handed[0].host).toEqual({ figureId: 'fig-1' })
|
|
105
|
-
})
|
|
106
|
-
})
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The files sent with this turn, read once: as the parts the model reads after the question, and as the tools'
|
|
3
|
-
* `context.attachments` (ADR-0061, 2026-10-16 decision 2).
|
|
4
|
-
*
|
|
5
|
-
* The door checked them before this - each is stored with this conversation, the caller may write to it, the mode's
|
|
6
|
-
* policy took it. Only the door builds the tools' list; what a client puts in `hostContext` never becomes one.
|
|
7
|
-
*
|
|
8
|
-
* Storage is the caller's: it passes `attachmentForModel`, so the rule is tested without a file store.
|
|
9
|
-
*/
|
|
10
|
-
import type { ToolAttachment } from '@things-factory/ai-client-base'
|
|
11
|
-
|
|
12
|
-
export type ReadAttachment = (
|
|
13
|
-
row: any,
|
|
14
|
-
maxChars: number
|
|
15
|
-
) => Promise<
|
|
16
|
-
| { type: 'image'; data: Buffer; mediaType: string; name: string }
|
|
17
|
-
| { type: 'text'; text: string; name: string; truncated: boolean }
|
|
18
|
-
>
|
|
19
|
-
|
|
20
|
-
export interface TurnAttachments {
|
|
21
|
-
/** What the model reads after the question's text, one part per file. */
|
|
22
|
-
parts: any[]
|
|
23
|
-
/** The same files for the tools, in the order the person attached them. */
|
|
24
|
-
forTools: ToolAttachment[]
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export async function readTurnAttachments(rows: any[], maxChars: number, read: ReadAttachment): Promise<TurnAttachments> {
|
|
28
|
-
const parts: any[] = []
|
|
29
|
-
const forTools: ToolAttachment[] = []
|
|
30
|
-
for (const row of rows) {
|
|
31
|
-
const file = await read(row, maxChars)
|
|
32
|
-
const stored = { id: row.id, name: row.name, mediaType: row.mimetype, size: Number(row.size) || 0 }
|
|
33
|
-
if (file.type === 'image') {
|
|
34
|
-
parts.push({ type: 'image', source: { kind: 'base64', data: file.data, mediaType: file.mediaType } })
|
|
35
|
-
forTools.push({ ...stored, kind: 'image', data: file.data })
|
|
36
|
-
} else {
|
|
37
|
-
parts.push({
|
|
38
|
-
type: 'text',
|
|
39
|
-
text: `[attachment ${row.id}: ${file.name}${file.truncated ? ' - cut, the file is longer' : ''}]\n${file.text}`
|
|
40
|
-
})
|
|
41
|
-
forTools.push({ ...stored, kind: 'text', text: file.text, truncated: file.truncated })
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return { parts, forTools }
|
|
45
|
-
}
|