@things-factory/ai-assistant 10.1.277 → 10.1.279
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-client/bootstrap.d.ts +4 -4
- package/dist-client/bootstrap.js +4 -8
- package/dist-client/components/ai-model-price-table.d.ts +32 -0
- package/dist-client/components/ai-model-price-table.js +311 -0
- package/dist-client/components/ai-usage-table.d.ts +17 -0
- package/dist-client/components/ai-usage-table.js +151 -0
- package/dist-client/index.d.ts +1 -0
- package/dist-client/index.js +2 -0
- package/dist-client/pages/ai-model-price-page.d.ts +37 -0
- package/dist-client/pages/ai-model-price-page.js +312 -0
- package/dist-client/route.d.ts +1 -1
- package/dist-client/route.js +4 -0
- package/dist-client/settings/ai-agent-setting-let.js +11 -0
- package/dist-client/utils/model-price-model.d.ts +31 -0
- package/dist-client/utils/model-price-model.js +30 -0
- package/dist-client/utils/usage-charts.d.ts +21 -0
- package/dist-client/utils/usage-charts.js +45 -0
- package/dist-client/utils/usage-model.d.ts +44 -0
- package/dist-client/utils/usage-model.js +44 -0
- package/dist-server/service/ai-agent-resolver.d.ts +46 -0
- package/dist-server/service/ai-agent-resolver.js +252 -0
- package/dist-server/service/assistant-mode/mode-categories.js +2 -2
- package/dist-server/service/chat-message/message-doors.d.ts +6 -10
- package/dist-server/service/chat-message/message-doors.js +5 -12
- package/dist-server/service/data-read/read-target.d.ts +3 -4
- package/dist-server/service/people/person-subject.d.ts +9 -5
- package/dist-server/service/people/person-subject.js +14 -19
- package/package.json +25 -10
- package/things-factory.config.js +4 -1
- package/translations/en.json +46 -4
- package/translations/es.json +43 -1
- package/translations/ja.json +43 -1
- package/translations/ko.json +46 -4
- package/translations/ms.json +43 -1
- package/translations/zh.json +43 -1
- package/client/bootstrap.ts +0 -27
- package/client/components/assistant-chat.test.ts +0 -149
- package/client/components/assistant-chat.ts +0 -5599
- package/client/components/assistant-dock.ts +0 -1036
- package/client/components/assistant-invite.ts +0 -138
- package/client/components/assistant-mode.test.ts +0 -119
- package/client/components/assistant-mode.ts +0 -174
- package/client/components/assistant-selection-bar.test.ts +0 -167
- package/client/components/assistant-selection-bar.ts +0 -178
- package/client/components/assistant-session-manager.ts +0 -915
- package/client/components/assistant-session-toolbar.ts +0 -80
- package/client/components/chat-defaults.ts +0 -64
- package/client/components/chat-echo-dedup.test.ts +0 -253
- package/client/components/chat-echo-dedup.ts +0 -190
- package/client/components/chat-input-builder.test.ts +0 -86
- package/client/components/chat-input-builder.ts +0 -133
- package/client/components/chat-proposal-survival.test.ts +0 -73
- package/client/components/entry-review.ts +0 -346
- package/client/components/markdown.test.ts +0 -518
- package/client/components/markdown.ts +0 -508
- package/client/components/mention-popup-helpers.ts +0 -433
- package/client/components/mention-popup.test.ts +0 -588
- package/client/components/mention-popup.ts +0 -261
- package/client/components/panel-aria.test.ts +0 -59
- package/client/components/proposal-outcome-line.ts +0 -74
- package/client/components/proposal-request.test.ts +0 -73
- package/client/components/reply-message.test.ts +0 -15
- package/client/components/reply-message.ts +0 -11
- package/client/components/roster-identity.test.ts +0 -8
- package/client/components/roster-identity.ts +0 -4
- package/client/components/workspace-view.ts +0 -486
- package/client/index.ts +0 -36
- package/client/pages/assistant-workspace-page.ts +0 -317
- package/client/route.ts +0 -9
- package/client/settings/agent-settings-model.ts +0 -164
- package/client/settings/ai-agent-setting-let.ts +0 -667
- package/client/settings/ai-usage-setting-let.ts +0 -240
- package/client/settings/usage-model.ts +0 -46
- package/client/setup-assistant-dock.ts +0 -177
- package/client/tsconfig.json +0 -13
- package/client/utils/addressed-draft.test.ts +0 -31
- package/client/utils/agent-choice.ts +0 -56
- package/client/utils/applied-screens.ts +0 -36
- package/client/utils/assistant-activity.ts +0 -122
- package/client/utils/assistant-ask.test.ts +0 -38
- package/client/utils/assistant-ask.ts +0 -93
- package/client/utils/assistant-capability-read.ts +0 -24
- package/client/utils/assistant-capability.test.ts +0 -17
- package/client/utils/assistant-capability.ts +0 -19
- package/client/utils/assistant-navigation.test.ts +0 -66
- package/client/utils/assistant-navigation.ts +0 -11
- package/client/utils/assistant-proposals.ts +0 -85
- package/client/utils/assistant-request-context.ts +0 -63
- package/client/utils/assistant-selection.test.ts +0 -54
- package/client/utils/assistant-selection.ts +0 -75
- package/client/utils/assistant-session-actions.ts +0 -32
- package/client/utils/assistant-session-admin.ts +0 -239
- package/client/utils/assistant-session-controller.test.ts +0 -75
- package/client/utils/assistant-session-controller.ts +0 -208
- package/client/utils/assistant-session-transport.ts +0 -46
- package/client/utils/assistant-surface.ts +0 -178
- package/client/utils/assistant-typing.test.ts +0 -33
- package/client/utils/assistant-typing.ts +0 -53
- package/client/utils/attachment-policy.ts +0 -106
- package/client/utils/composer-frame.ts +0 -77
- package/client/utils/document-text.ts +0 -332
- package/client/utils/entry-hash.ts +0 -35
- package/client/utils/entry-proposal.ts +0 -215
- package/client/utils/entry-workspace.ts +0 -70
- package/client/utils/invite-proposal-register.ts +0 -31
- package/client/utils/invite-proposal.test.ts +0 -40
- package/client/utils/invite-proposal.ts +0 -54
- package/client/utils/menu-room.ts +0 -33
- package/client/utils/open-page.ts +0 -21
- package/client/utils/pasted-table.ts +0 -145
- package/client/utils/pdf-pages.ts +0 -25
- package/client/utils/spreadsheet-text.ts +0 -125
- package/client/utils/workspace.ts +0 -89
- package/dist-client/bootstrap.js.map +0 -1
- package/dist-client/components/assistant-chat.js.map +0 -1
- package/dist-client/components/assistant-chat.test.d.ts +0 -1
- package/dist-client/components/assistant-chat.test.js +0 -138
- package/dist-client/components/assistant-chat.test.js.map +0 -1
- package/dist-client/components/assistant-dock.js.map +0 -1
- package/dist-client/components/assistant-invite.js.map +0 -1
- package/dist-client/components/assistant-mode.js.map +0 -1
- package/dist-client/components/assistant-mode.test.d.ts +0 -1
- package/dist-client/components/assistant-mode.test.js +0 -100
- package/dist-client/components/assistant-mode.test.js.map +0 -1
- package/dist-client/components/assistant-selection-bar.js.map +0 -1
- package/dist-client/components/assistant-selection-bar.test.d.ts +0 -1
- package/dist-client/components/assistant-selection-bar.test.js +0 -148
- package/dist-client/components/assistant-selection-bar.test.js.map +0 -1
- package/dist-client/components/assistant-session-manager.js.map +0 -1
- package/dist-client/components/assistant-session-toolbar.js.map +0 -1
- package/dist-client/components/chat-defaults.js.map +0 -1
- package/dist-client/components/chat-echo-dedup.js.map +0 -1
- package/dist-client/components/chat-echo-dedup.test.d.ts +0 -1
- package/dist-client/components/chat-echo-dedup.test.js +0 -223
- package/dist-client/components/chat-echo-dedup.test.js.map +0 -1
- package/dist-client/components/chat-input-builder.js.map +0 -1
- package/dist-client/components/chat-input-builder.test.d.ts +0 -1
- package/dist-client/components/chat-input-builder.test.js +0 -70
- package/dist-client/components/chat-input-builder.test.js.map +0 -1
- package/dist-client/components/chat-proposal-survival.test.d.ts +0 -1
- package/dist-client/components/chat-proposal-survival.test.js +0 -61
- package/dist-client/components/chat-proposal-survival.test.js.map +0 -1
- package/dist-client/components/entry-review.js.map +0 -1
- package/dist-client/components/markdown.js.map +0 -1
- package/dist-client/components/markdown.test.d.ts +0 -1
- package/dist-client/components/markdown.test.js +0 -418
- package/dist-client/components/markdown.test.js.map +0 -1
- package/dist-client/components/mention-popup-helpers.js.map +0 -1
- package/dist-client/components/mention-popup.js.map +0 -1
- package/dist-client/components/mention-popup.test.d.ts +0 -1
- package/dist-client/components/mention-popup.test.js +0 -474
- package/dist-client/components/mention-popup.test.js.map +0 -1
- package/dist-client/components/panel-aria.test.d.ts +0 -1
- package/dist-client/components/panel-aria.test.js +0 -53
- package/dist-client/components/panel-aria.test.js.map +0 -1
- package/dist-client/components/proposal-outcome-line.js.map +0 -1
- package/dist-client/components/proposal-request.test.d.ts +0 -1
- package/dist-client/components/proposal-request.test.js +0 -63
- package/dist-client/components/proposal-request.test.js.map +0 -1
- package/dist-client/components/reply-message.js.map +0 -1
- package/dist-client/components/reply-message.test.d.ts +0 -1
- package/dist-client/components/reply-message.test.js +0 -16
- package/dist-client/components/reply-message.test.js.map +0 -1
- package/dist-client/components/roster-identity.js.map +0 -1
- package/dist-client/components/roster-identity.test.d.ts +0 -1
- package/dist-client/components/roster-identity.test.js +0 -9
- package/dist-client/components/roster-identity.test.js.map +0 -1
- package/dist-client/components/workspace-view.js.map +0 -1
- package/dist-client/index.js.map +0 -1
- package/dist-client/pages/assistant-workspace-page.js.map +0 -1
- package/dist-client/route.js.map +0 -1
- package/dist-client/settings/agent-settings-model.js.map +0 -1
- package/dist-client/settings/ai-agent-setting-let.js.map +0 -1
- package/dist-client/settings/ai-usage-setting-let.d.ts +0 -25
- package/dist-client/settings/ai-usage-setting-let.js +0 -258
- package/dist-client/settings/ai-usage-setting-let.js.map +0 -1
- package/dist-client/settings/usage-model.d.ts +0 -32
- package/dist-client/settings/usage-model.js +0 -25
- package/dist-client/settings/usage-model.js.map +0 -1
- package/dist-client/setup-assistant-dock.js.map +0 -1
- package/dist-client/tsconfig.tsbuildinfo +0 -1
- package/dist-client/utils/addressed-draft.test.d.ts +0 -1
- package/dist-client/utils/addressed-draft.test.js +0 -27
- package/dist-client/utils/addressed-draft.test.js.map +0 -1
- package/dist-client/utils/agent-choice.js.map +0 -1
- package/dist-client/utils/applied-screens.js.map +0 -1
- package/dist-client/utils/assistant-activity.js.map +0 -1
- package/dist-client/utils/assistant-ask.js.map +0 -1
- package/dist-client/utils/assistant-ask.test.d.ts +0 -1
- package/dist-client/utils/assistant-ask.test.js +0 -40
- package/dist-client/utils/assistant-ask.test.js.map +0 -1
- package/dist-client/utils/assistant-capability-read.js.map +0 -1
- package/dist-client/utils/assistant-capability.js.map +0 -1
- package/dist-client/utils/assistant-capability.test.d.ts +0 -1
- package/dist-client/utils/assistant-capability.test.js +0 -16
- package/dist-client/utils/assistant-capability.test.js.map +0 -1
- package/dist-client/utils/assistant-navigation.js.map +0 -1
- package/dist-client/utils/assistant-navigation.test.d.ts +0 -1
- package/dist-client/utils/assistant-navigation.test.js +0 -63
- package/dist-client/utils/assistant-navigation.test.js.map +0 -1
- package/dist-client/utils/assistant-proposals.js.map +0 -1
- package/dist-client/utils/assistant-request-context.js.map +0 -1
- package/dist-client/utils/assistant-selection.js.map +0 -1
- package/dist-client/utils/assistant-selection.test.d.ts +0 -1
- package/dist-client/utils/assistant-selection.test.js +0 -46
- package/dist-client/utils/assistant-selection.test.js.map +0 -1
- package/dist-client/utils/assistant-session-actions.js.map +0 -1
- package/dist-client/utils/assistant-session-admin.js.map +0 -1
- package/dist-client/utils/assistant-session-controller.js.map +0 -1
- package/dist-client/utils/assistant-session-controller.test.d.ts +0 -1
- package/dist-client/utils/assistant-session-controller.test.js +0 -56
- package/dist-client/utils/assistant-session-controller.test.js.map +0 -1
- package/dist-client/utils/assistant-session-transport.js.map +0 -1
- package/dist-client/utils/assistant-surface.js.map +0 -1
- package/dist-client/utils/assistant-typing.js.map +0 -1
- package/dist-client/utils/assistant-typing.test.d.ts +0 -1
- package/dist-client/utils/assistant-typing.test.js +0 -30
- package/dist-client/utils/assistant-typing.test.js.map +0 -1
- package/dist-client/utils/attachment-policy.js.map +0 -1
- package/dist-client/utils/composer-frame.js.map +0 -1
- package/dist-client/utils/document-text.js.map +0 -1
- package/dist-client/utils/entry-hash.js.map +0 -1
- package/dist-client/utils/entry-proposal.js.map +0 -1
- package/dist-client/utils/entry-workspace.js.map +0 -1
- package/dist-client/utils/invite-proposal-register.js.map +0 -1
- package/dist-client/utils/invite-proposal.js.map +0 -1
- package/dist-client/utils/invite-proposal.test.d.ts +0 -1
- package/dist-client/utils/invite-proposal.test.js +0 -35
- package/dist-client/utils/invite-proposal.test.js.map +0 -1
- package/dist-client/utils/menu-room.js.map +0 -1
- package/dist-client/utils/open-page.js.map +0 -1
- package/dist-client/utils/pasted-table.js.map +0 -1
- package/dist-client/utils/pdf-pages.js.map +0 -1
- package/dist-client/utils/spreadsheet-text.js.map +0 -1
- package/dist-client/utils/workspace.js.map +0 -1
- package/dist-server/door-declaration-report.js.map +0 -1
- package/dist-server/index.js.map +0 -1
- package/dist-server/role-tasks.js.map +0 -1
- package/dist-server/service/ai-agent-resolver.js.map +0 -1
- package/dist-server/service/assistant-capability-resolver.js.map +0 -1
- package/dist-server/service/assistant-chat-resolver.js.map +0 -1
- package/dist-server/service/assistant-mode/assistant-mode-resolver.js.map +0 -1
- package/dist-server/service/assistant-mode/fallback-subjects.js.map +0 -1
- package/dist-server/service/assistant-mode/index.js.map +0 -1
- package/dist-server/service/assistant-mode/mode-categories.js.map +0 -1
- package/dist-server/service/assistant-mode/record-subject.js.map +0 -1
- package/dist-server/service/assistant-mode/registry.js.map +0 -1
- package/dist-server/service/assistant-mode/resolve.js.map +0 -1
- package/dist-server/service/assistant-mode/screen-rules.js.map +0 -1
- package/dist-server/service/assistant-mode/turn-lines.js.map +0 -1
- package/dist-server/service/assistant-mode/types.js.map +0 -1
- package/dist-server/service/chat-message/carried-turns.js.map +0 -1
- package/dist-server/service/chat-message/chat-message-broadcast.js.map +0 -1
- package/dist-server/service/chat-message/chat-message-publish.js.map +0 -1
- package/dist-server/service/chat-message/chat-message-room.js.map +0 -1
- package/dist-server/service/chat-message/chat-message-subscription.js.map +0 -1
- package/dist-server/service/chat-message/chat-message.js.map +0 -1
- package/dist-server/service/chat-message/chat-typing-subscription.js.map +0 -1
- package/dist-server/service/chat-message/chat-typing.js.map +0 -1
- package/dist-server/service/chat-message/door-access.js.map +0 -1
- package/dist-server/service/chat-message/fold-history.js.map +0 -1
- package/dist-server/service/chat-message/fold-session-history.js.map +0 -1
- package/dist-server/service/chat-message/history-summary.js.map +0 -1
- package/dist-server/service/chat-message/index.js.map +0 -1
- package/dist-server/service/chat-message/llm-history.js.map +0 -1
- package/dist-server/service/chat-message/message-doors.js.map +0 -1
- package/dist-server/service/chat-message/proposal-outcome.js.map +0 -1
- package/dist-server/service/chat-message/reader-gate.js.map +0 -1
- package/dist-server/service/chat-message/room-message.js.map +0 -1
- package/dist-server/service/chat-message/room-turn.js.map +0 -1
- package/dist-server/service/chat-message/used-tools.js.map +0 -1
- package/dist-server/service/chat-session/attachment-policy.js.map +0 -1
- package/dist-server/service/chat-session/attachment-route.js.map +0 -1
- package/dist-server/service/chat-session/attachment-tool-result.js.map +0 -1
- package/dist-server/service/chat-session/attachment-tools.js.map +0 -1
- package/dist-server/service/chat-session/chat-session.js.map +0 -1
- package/dist-server/service/chat-session/index.js.map +0 -1
- package/dist-server/service/chat-session/session-activity-broadcast.js.map +0 -1
- package/dist-server/service/chat-session/session-activity-publish.js.map +0 -1
- package/dist-server/service/chat-session/session-activity-subscription.js.map +0 -1
- package/dist-server/service/chat-session/session-anchor.js.map +0 -1
- package/dist-server/service/chat-session/session-attachments.js.map +0 -1
- package/dist-server/service/chat-session/session-cleanup.js.map +0 -1
- package/dist-server/service/chat-session/session-inbox.js.map +0 -1
- package/dist-server/service/chat-session/session-kind.js.map +0 -1
- package/dist-server/service/chat-session/session-name.js.map +0 -1
- package/dist-server/service/chat-session/session-purge.js.map +0 -1
- package/dist-server/service/chat-session/session-retention.js.map +0 -1
- package/dist-server/service/chat-session/session-visibility.js.map +0 -1
- package/dist-server/service/chat-session/session-write-gate.js.map +0 -1
- package/dist-server/service/chat-session/station-session-guard.js.map +0 -1
- package/dist-server/service/chat-session/turn-attachments.js.map +0 -1
- package/dist-server/service/chat-session-participant/chat-session-participant.js.map +0 -1
- package/dist-server/service/chat-session-participant/index.js.map +0 -1
- package/dist-server/service/chat-session-participant/invite-notification.js.map +0 -1
- package/dist-server/service/chat-session-participant/mention-invite.js.map +0 -1
- package/dist-server/service/chat-session-participant/participant-lookup-roles.js.map +0 -1
- package/dist-server/service/chat-session-participant/participant-lookup.js.map +0 -1
- package/dist-server/service/chat-session-participant/presence.js.map +0 -1
- package/dist-server/service/chat-session-participant/read-roster.js.map +0 -1
- package/dist-server/service/chat-session-resolver.js.map +0 -1
- package/dist-server/service/data-entry/entry-apply.js.map +0 -1
- package/dist-server/service/data-entry/entry-hash.js.map +0 -1
- package/dist-server/service/data-entry/entry-refusal.js.map +0 -1
- package/dist-server/service/data-entry/entry-resolver.js.map +0 -1
- package/dist-server/service/data-entry/entry-screen.js.map +0 -1
- package/dist-server/service/data-entry/entry-sources.js.map +0 -1
- package/dist-server/service/data-entry/entry-target.js.map +0 -1
- package/dist-server/service/data-entry/entry-tools.js.map +0 -1
- package/dist-server/service/data-entry/entry-update.js.map +0 -1
- package/dist-server/service/data-read/list-read.js.map +0 -1
- package/dist-server/service/data-read/read-target.js.map +0 -1
- package/dist-server/service/data-read/read-tools.js.map +0 -1
- package/dist-server/service/grounding-sources.js.map +0 -1
- package/dist-server/service/help-documents/help-keys.js.map +0 -1
- package/dist-server/service/help-documents/help-tools.js.map +0 -1
- package/dist-server/service/index.js.map +0 -1
- package/dist-server/service/people/index.js.map +0 -1
- package/dist-server/service/people/invite-tools.js.map +0 -1
- package/dist-server/service/people/people-keys.js.map +0 -1
- package/dist-server/service/people/people-read.js.map +0 -1
- package/dist-server/service/people/person-subject.js.map +0 -1
- package/dist-server/service/request-translator.js.map +0 -1
- package/dist-server/service/testing/conversation-script.js.map +0 -1
- package/dist-server/service/testing/mode-conformance.js.map +0 -1
- package/dist-server/service/tool-access.js.map +0 -1
- package/dist-server/service/types.js.map +0 -1
- package/dist-server/service/unattended-run/assistant-run.js.map +0 -1
- package/dist-server/service/unattended-run/index.js.map +0 -1
- package/dist-server/service/unattended-run/limits.js.map +0 -1
- package/dist-server/service/unattended-run/run-as.js.map +0 -1
- package/dist-server/service/unattended-run/run-budget.js.map +0 -1
- package/dist-server/service/unattended-run/run-ledger.js.map +0 -1
- package/dist-server/service/unattended-run/run-outcome.js.map +0 -1
- package/dist-server/service/unattended-run/run-store.js.map +0 -1
- package/dist-server/service/unattended-run/run-unattended.js.map +0 -1
- package/dist-server/service/unattended-run/unattended-prompt.js.map +0 -1
- package/dist-server/service/workspace/workspace-blocks.js.map +0 -1
- package/dist-server/service/workspace/workspace-tools.js.map +0 -1
- package/dist-server/tool-registry-boot-report.js.map +0 -1
- package/dist-server/tsconfig.tsbuildinfo +0 -1
- package/docs/session-controller.md +0 -52
- package/server/door-declaration-report.test.ts +0 -53
- package/server/door-declaration-report.ts +0 -61
- package/server/explicit-graphql-types.test.ts +0 -56
- package/server/index.ts +0 -36
- package/server/role-tasks.ts +0 -14
- package/server/service/ai-agent-resolver.ts +0 -330
- package/server/service/assistant-capability-resolver.ts +0 -66
- package/server/service/assistant-chat-resolver.ts +0 -640
- package/server/service/assistant-mode/assistant-mode-resolver.ts +0 -101
- package/server/service/assistant-mode/conversation-category.test.ts +0 -48
- package/server/service/assistant-mode/fallback-subjects.ts +0 -36
- package/server/service/assistant-mode/index.ts +0 -22
- package/server/service/assistant-mode/mode-categories.ts +0 -178
- package/server/service/assistant-mode/mode-front.test.ts +0 -181
- package/server/service/assistant-mode/one-conversation-per-subject.test.ts +0 -37
- package/server/service/assistant-mode/open-subject-door.test.ts +0 -52
- package/server/service/assistant-mode/record-subject.test.ts +0 -41
- package/server/service/assistant-mode/record-subject.ts +0 -44
- package/server/service/assistant-mode/registry.test.ts +0 -171
- package/server/service/assistant-mode/registry.ts +0 -139
- package/server/service/assistant-mode/resolve.test.ts +0 -129
- package/server/service/assistant-mode/resolve.ts +0 -113
- package/server/service/assistant-mode/screen-rules.test.ts +0 -99
- package/server/service/assistant-mode/screen-rules.ts +0 -103
- package/server/service/assistant-mode/turn-lines.ts +0 -43
- package/server/service/assistant-mode/types.ts +0 -138
- package/server/service/chat-message/carried-turns.test.ts +0 -80
- package/server/service/chat-message/carried-turns.ts +0 -112
- package/server/service/chat-message/chat-message-broadcast.integration.test.ts +0 -73
- package/server/service/chat-message/chat-message-broadcast.test.ts +0 -40
- package/server/service/chat-message/chat-message-broadcast.ts +0 -70
- package/server/service/chat-message/chat-message-publish.ts +0 -22
- package/server/service/chat-message/chat-message-room.test.ts +0 -145
- package/server/service/chat-message/chat-message-room.ts +0 -50
- package/server/service/chat-message/chat-message-subscription.ts +0 -77
- package/server/service/chat-message/chat-message.ts +0 -289
- package/server/service/chat-message/chat-typing-subscription.ts +0 -52
- package/server/service/chat-message/chat-typing.test.ts +0 -45
- package/server/service/chat-message/chat-typing.ts +0 -48
- package/server/service/chat-message/door-access.test.ts +0 -72
- package/server/service/chat-message/door-access.ts +0 -65
- package/server/service/chat-message/fold-history-window.test.ts +0 -184
- package/server/service/chat-message/fold-history.test.ts +0 -98
- package/server/service/chat-message/fold-history.ts +0 -77
- package/server/service/chat-message/fold-session-history.test.ts +0 -116
- package/server/service/chat-message/fold-session-history.ts +0 -115
- package/server/service/chat-message/history-summary.test.ts +0 -127
- package/server/service/chat-message/history-summary.ts +0 -100
- package/server/service/chat-message/index.ts +0 -13
- package/server/service/chat-message/llm-history.test.ts +0 -245
- package/server/service/chat-message/llm-history.ts +0 -182
- package/server/service/chat-message/message-doors.test.ts +0 -124
- package/server/service/chat-message/message-doors.ts +0 -137
- package/server/service/chat-message/proposal-outcome.test.ts +0 -111
- package/server/service/chat-message/proposal-outcome.ts +0 -99
- package/server/service/chat-message/reader-gate.ts +0 -44
- package/server/service/chat-message/room-message.test.ts +0 -21
- package/server/service/chat-message/room-message.ts +0 -22
- package/server/service/chat-message/room-turn.ts +0 -42
- package/server/service/chat-message/used-tools.test.ts +0 -19
- package/server/service/chat-message/used-tools.ts +0 -25
- package/server/service/chat-session/attachment-policy.test.ts +0 -42
- package/server/service/chat-session/attachment-policy.ts +0 -91
- package/server/service/chat-session/attachment-route.ts +0 -45
- package/server/service/chat-session/attachment-tool-result.test.ts +0 -63
- package/server/service/chat-session/attachment-tool-result.ts +0 -37
- package/server/service/chat-session/attachment-tools.ts +0 -66
- package/server/service/chat-session/chat-session.ts +0 -244
- package/server/service/chat-session/group-room.test.ts +0 -233
- package/server/service/chat-session/index.ts +0 -5
- package/server/service/chat-session/session-activity-broadcast.ts +0 -77
- package/server/service/chat-session/session-activity-publish.ts +0 -49
- package/server/service/chat-session/session-activity-receivers.test.ts +0 -26
- package/server/service/chat-session/session-activity-subscription.ts +0 -66
- package/server/service/chat-session/session-anchor.ts +0 -142
- package/server/service/chat-session/session-attachments.ts +0 -90
- package/server/service/chat-session/session-cleanup.test.ts +0 -83
- package/server/service/chat-session/session-cleanup.ts +0 -69
- package/server/service/chat-session/session-inbox.test.ts +0 -273
- package/server/service/chat-session/session-inbox.ts +0 -240
- package/server/service/chat-session/session-kind.test.ts +0 -24
- package/server/service/chat-session/session-kind.ts +0 -32
- package/server/service/chat-session/session-name.ts +0 -32
- package/server/service/chat-session/session-purge.test.ts +0 -24
- package/server/service/chat-session/session-purge.ts +0 -117
- package/server/service/chat-session/session-retention.ts +0 -17
- package/server/service/chat-session/session-visibility.test.ts +0 -130
- package/server/service/chat-session/session-visibility.ts +0 -68
- package/server/service/chat-session/session-write-gate.test.ts +0 -59
- package/server/service/chat-session/session-write-gate.ts +0 -31
- package/server/service/chat-session/station-session-guard.ts +0 -25
- package/server/service/chat-session/turn-attachments.test.ts +0 -106
- package/server/service/chat-session/turn-attachments.ts +0 -45
- package/server/service/chat-session-participant/chat-session-participant.ts +0 -135
- package/server/service/chat-session-participant/index.ts +0 -8
- package/server/service/chat-session-participant/invite-notification.test.ts +0 -80
- package/server/service/chat-session-participant/invite-notification.ts +0 -118
- package/server/service/chat-session-participant/mention-invite.test.ts +0 -173
- package/server/service/chat-session-participant/mention-invite.ts +0 -180
- package/server/service/chat-session-participant/participant-lookup-roles.ts +0 -6
- package/server/service/chat-session-participant/participant-lookup.ts +0 -22
- package/server/service/chat-session-participant/presence.test.ts +0 -39
- package/server/service/chat-session-participant/presence.ts +0 -21
- package/server/service/chat-session-participant/read-roster.test.ts +0 -27
- package/server/service/chat-session-participant/read-roster.ts +0 -17
- package/server/service/chat-session-resolver.ts +0 -1455
- package/server/service/data-entry/data-entry-update.test.ts +0 -378
- package/server/service/data-entry/data-entry.test.ts +0 -494
- package/server/service/data-entry/entry-apply.ts +0 -247
- package/server/service/data-entry/entry-hash.ts +0 -35
- package/server/service/data-entry/entry-refusal.test.ts +0 -73
- package/server/service/data-entry/entry-refusal.ts +0 -20
- package/server/service/data-entry/entry-resolver.ts +0 -74
- package/server/service/data-entry/entry-screen.ts +0 -14
- package/server/service/data-entry/entry-sources.ts +0 -39
- package/server/service/data-entry/entry-target.ts +0 -774
- package/server/service/data-entry/entry-tools.ts +0 -282
- package/server/service/data-entry/entry-update.ts +0 -238
- package/server/service/data-read/data-read.test.ts +0 -395
- package/server/service/data-read/detail-lists.test.ts +0 -61
- package/server/service/data-read/list-missing.test.ts +0 -49
- package/server/service/data-read/list-read.ts +0 -146
- package/server/service/data-read/list-status.test.ts +0 -46
- package/server/service/data-read/read-target.ts +0 -510
- package/server/service/data-read/read-tools.ts +0 -334
- package/server/service/data-read/read-words.test.ts +0 -99
- package/server/service/data-read/record-keys.test.ts +0 -42
- package/server/service/grounding-sources.test.ts +0 -55
- package/server/service/grounding-sources.ts +0 -46
- package/server/service/help-documents/help-keys.ts +0 -2
- package/server/service/help-documents/help-tools.test.ts +0 -40
- package/server/service/help-documents/help-tools.ts +0 -88
- package/server/service/index.ts +0 -99
- package/server/service/people/index.ts +0 -15
- package/server/service/people/invite-tools.ts +0 -159
- package/server/service/people/invite.test.ts +0 -159
- package/server/service/people/people-keys.ts +0 -16
- package/server/service/people/people-read.test.ts +0 -82
- package/server/service/people/people-read.ts +0 -56
- package/server/service/people/person-subject.test.ts +0 -163
- package/server/service/people/person-subject.ts +0 -88
- package/server/service/request-translator.test.ts +0 -45
- package/server/service/request-translator.ts +0 -33
- package/server/service/session-anchor.test.ts +0 -198
- package/server/service/station-session-guard.test.ts +0 -31
- package/server/service/testing/conversation-scenario.test.ts +0 -164
- package/server/service/testing/conversation-script.test.ts +0 -133
- package/server/service/testing/conversation-script.ts +0 -296
- package/server/service/testing/mode-conformance.test.ts +0 -61
- package/server/service/testing/mode-conformance.ts +0 -165
- package/server/service/tool-access.test.ts +0 -96
- package/server/service/tool-access.ts +0 -36
- package/server/service/types.ts +0 -15
- package/server/service/unattended-run/assistant-run.ts +0 -199
- package/server/service/unattended-run/index.ts +0 -10
- package/server/service/unattended-run/limits.ts +0 -24
- package/server/service/unattended-run/run-as.ts +0 -38
- package/server/service/unattended-run/run-budget.ts +0 -58
- package/server/service/unattended-run/run-ledger.ts +0 -31
- package/server/service/unattended-run/run-outcome.ts +0 -43
- package/server/service/unattended-run/run-store-race.pg.test.ts +0 -83
- package/server/service/unattended-run/run-store.ts +0 -162
- package/server/service/unattended-run/run-unattended.test.ts +0 -478
- package/server/service/unattended-run/run-unattended.ts +0 -248
- package/server/service/unattended-run/unattended-prompt.ts +0 -24
- package/server/service/workspace/workspace-blocks.ts +0 -134
- package/server/service/workspace/workspace-tools.ts +0 -108
- package/server/service/workspace/workspace.test.ts +0 -74
- package/server/tool-registry-boot-report.test.ts +0 -41
- package/server/tool-registry-boot-report.ts +0 -63
- package/test/ai-agent-settings.test.ts +0 -123
- package/test/applied-screens.test.ts +0 -65
- package/test/assistant-chat-call-sites.test.ts +0 -92
- package/test/assistant-dock.test.ts +0 -294
- package/test/assistant-request-context.test.ts +0 -72
- package/test/assistant-session-controller.test.ts +0 -87
- package/test/assistant-session-manager.test.ts +0 -186
- package/test/assistant-session-toolbar.test.ts +0 -43
- package/test/attachment-one-rule.test.ts +0 -46
- package/test/attachment-policy-agree.test.ts +0 -38
- package/test/composer-frame.test.ts +0 -173
- package/test/document-text.test.ts +0 -175
- package/test/entry-card-styles.test.ts +0 -18
- package/test/entry-proposal.test.ts +0 -186
- package/test/entry-workspace.test.ts +0 -89
- package/test/menu-room.test.ts +0 -33
- package/test/open-doors.test.ts +0 -164
- package/test/open-page.test.ts +0 -31
- package/test/pasted-table.test.ts +0 -147
- package/test/refusals-in-korean.test.ts +0 -80
- package/test/session-discovery.test.ts +0 -43
- package/test/spreadsheet-text.test.ts +0 -92
- package/test/translations.test.ts +0 -80
- package/test/workspace.test.ts +0 -54
- package/tsconfig.json +0 -9
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"attachment-policy.js","sourceRoot":"","sources":["../../client/utils/attachment-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GA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AAK,EAAE;QAC5F,CAAC,CAAC,EAAE,IAAI,EAAE,sBAAsB,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,WAAY,EAAE,CAAA;AAClG,CAAC;AAED,uHAAuH;AACvH,MAAM,UAAU,QAAQ,CAAC,MAA2C;IAClE,MAAM,KAAK,GAAG,MAAM,EAAE,KAAK,IAAI,EAAE,CAAA;IACjC,OAAO,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;AAClG,CAAC;AAED,yFAAyF;AACzF,MAAM,UAAU,iBAAiB,CAAC,SAAiB,EAAE,YAAoB;IACvE,MAAM,UAAU,GAAG,kBAAkB,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;IACxE,OAAO,GAAG,UAAU,qBAAqB,kBAAkB,CAAC,SAAS,CAAC,IAAI,kBAAkB,CAAC,YAAY,CAAC,EAAE,CAAA;AAC9G,CAAC","sourcesContent":["/*\n * What a conversation accepts as attachments - the screen's side of the server rule\n * (server/service/chat-session/attachment-policy.ts, design/ai/shared-dock.md §9-1).\n *\n * The screen checks first so the person hears \"no\" before anything is sent; the door checks again and is\n * the authority. `test/attachment-policy-agree.test.ts` runs both over one table so they cannot drift.\n *\n * The screen's check is the one file-picking rule (@operato/utils `sortPickedFiles`, ADR-0061 2026-10-17): the mode's\n * kinds become an `accept` (the table below, the one place), its size and count become limits, narrowed by the\n * server's upload limits. What stays here is the mode's words: kinds, and a spreadsheet read into text.\n */\nimport { narrowLimits, sortPickedFiles, type FileUploadLimits } from '@operato/utils/file-acceptance.js'\n\nimport { DOCUMENT_ACCEPT } from './document-text.js'\n\n/*\n * 'spreadsheet' and 'document' are kinds a mode opens, never files the door receives: the screen reads each .xlsx\n * sheet into CSV text (spreadsheet-text.ts), and each PDF, .docx and .pptx into text (document-text.ts) before\n * sending, so a mode that takes them takes that text - and a scanned PDF page as an image.\n */\nexport type AttachmentKind = 'image' | 'text' | 'spreadsheet' | 'document'\n\nexport interface AttachmentPolicy {\n kinds: AttachmentKind[]\n maxBytes?: number\n maxFiles?: number\n /** Per text file, the characters the model reads - a sheet read into text longer than this is refused, not cut. */\n maxChars?: number\n}\n\nexport const DEFAULT_MAX_BYTES = 5 * 1024 * 1024\nexport const DEFAULT_MAX_FILES = 5\n/** How much of a text file reaches the model - the server's TEXT_CHARS_FOR_MODEL. */\nexport const TEXT_CHARS_FOR_MODEL = 20_000\n\nconst TEXT_TYPES = ['text/plain', 'text/csv', 'text/markdown', 'application/json']\nconst TEXT_EXTENSIONS = ['.txt', '.csv', '.md', '.json']\nconst XLSX_TYPE = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'\n\n/** Each kind as `accept` patterns - the one table from the mode's kinds to what a picker takes. */\nconst KIND_ACCEPT: Record<AttachmentKind, string[]> = {\n image: ['image/*'],\n text: [...TEXT_EXTENSIONS, ...TEXT_TYPES],\n spreadsheet: ['.xlsx', XLSX_TYPE],\n document: DOCUMENT_ACCEPT\n}\n\n/** The kinds that are read into text on the screen - they arrive as text. */\nconst READ_INTO_TEXT: AttachmentKind[] = ['spreadsheet', 'document']\n\n/** A kind the policy takes - text also when it takes spreadsheets, which arrive as the text of their sheets. */\nconst acceptFor = (kinds: AttachmentKind[]) => [...new Set(kinds.flatMap(kind => KIND_ACCEPT[kind]))].join(',')\n\nexport type AttachmentRefusal =\n | { code: 'attachments-not-accepted' }\n | { code: 'attachment-kind-not-accepted'; name: string; kinds: AttachmentKind[] }\n | { code: 'attachment-too-large'; name: string; maxBytes: number }\n | { code: 'too-many-attachments'; maxFiles: number }\n\n/** The characters of a text file the model reads under this policy. */\nexport function textCharsOf(policy: AttachmentPolicy | null | undefined): number {\n return policy?.maxChars ?? TEXT_CHARS_FOR_MODEL\n}\n\n/** The mode's size and count as picker limits. */\nexport function limitsOf(policy: AttachmentPolicy | null | undefined): FileUploadLimits {\n return { maxFileSize: policy?.maxBytes ?? DEFAULT_MAX_BYTES, maxFiles: policy?.maxFiles ?? DEFAULT_MAX_FILES }\n}\n\n/**\n * Whether these files may go, by the one picking rule. `server` is the server's upload limit (shell\n * `fileUploadLimits`); the tighter of it and the mode's policy applies. The first reason, by name: file by file, its\n * kind, then its size, then whether it is one too many - the door says them in the same order.\n */\nexport function refuseAttachments(\n policy: AttachmentPolicy | null | undefined,\n files: { name?: string; type?: string; size?: number }[],\n server?: FileUploadLimits\n): AttachmentRefusal | null {\n if (!files.length) return null\n if (!policy || !policy.kinds?.length) return { code: 'attachments-not-accepted' }\n\n /* What is sent: a spreadsheet or a document arrives as its text. */\n const sent = policy.kinds.map(kind => (READ_INTO_TEXT.includes(kind) ? 'text' : kind))\n const limits = narrowLimits(limitsOf(policy), server)\n const { refused } = sortPickedFiles(files, { accept: acceptFor(sent), limits })\n if (!refused.length) return null\n\n const [first] = refused\n if (first.reason === 'count') return { code: 'too-many-attachments', maxFiles: limits.maxFiles! }\n return first.reason === 'type'\n ? { code: 'attachment-kind-not-accepted', name: first.file.name || '', kinds: policy.kinds }\n : { code: 'attachment-too-large', name: first.file.name || '', maxBytes: limits.maxFileSize! }\n}\n\n/** The file picker's `accept` for a policy - a spreadsheet or a document as the person picks it (.xlsx, .pdf, ...). */\nexport function acceptOf(policy: AttachmentPolicy | null | undefined): string {\n const kinds = policy?.kinds ?? []\n return acceptFor(kinds.some(kind => READ_INTO_TEXT.includes(kind)) ? [...kinds, 'text'] : kinds)\n}\n\n/** Where a conversation's file opens - the gated route, under the page's domain path. */\nexport function chatAttachmentUrl(sessionId: string, attachmentId: string): string {\n const domainPath = /^\\/domain\\/[^/]+/.exec(location.pathname)?.[0] ?? ''\n return `${domainPath}/chat-attachments/${encodeURIComponent(sessionId)}/${encodeURIComponent(attachmentId)}`\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"composer-frame.js","sourceRoot":"","sources":["../../client/utils/composer-frame.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,8EAA8E;AAC9E,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAA;AAElC,gEAAgE;AAChE,MAAM,UAAU,cAAc,CAAC,OAAe,EAAE,IAAY,EAAE,OAAe;IAC3E,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,eAAe,CAAC,CAAC,CAAA;IACjE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,OAAO,GAAG,GAAG,EAAE,CAAA;AACtF,CAAC;AAID;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAC/B,CAAc,EACd,IAAa,EACb,MAAgD,EAAE;IAElD,IAAI,CAAC,CAAC,GAAG,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,MAAM,IAAI,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,UAAU,EAAE,IAAI,EAAE,EAAE,CAAC;QACnH,OAAO,iBAAiB,CAAA;IAC1B,CAAC;IACD,IAAI,CAAC,CAAC,GAAG,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAA;IACrD,IAAI,CAAC,CAAC,GAAG,KAAK,OAAO,IAAI,CAAC,CAAC,MAAM;QAAE,OAAO,IAAI,CAAA;IAC9C,IAAI,CAAC,CAAC,OAAO,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CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAA;IACnF,OAAO,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAA;AAChE,CAAC","sourcesContent":["/*\n * The composer's frame (operato-application/design/ai/shared-dock.md §10) - how tall it stands, what Enter does,\n * and what a pasted table gives back as words. Pure: the chat hands in its measures and the key.\n *\n * - The box grows with its text up to 40% of the chat's height, then scrolls. It never stands under its resting\n * height, and on a chat too short for 40% to hold that height the resting height wins.\n * - The wide box (넓게 쓰기) covers the conversation inside the dock; the page beside it stays where it was.\n * - In the small box Enter sends and Shift+Enter breaks the line, as in every chat. In the wide box Enter breaks\n * the line - long writing is made of lines - and Ctrl/Cmd+Enter sends. Ctrl/Cmd+Enter sends in both.\n */\n\n/** The part of the chat's height the small box may take before it scrolls. */\nexport const COMPOSER_GROWTH = 0.4\n\n/** The box's height for its content, both border-box pixels. */\nexport function composerHeight(content: number, chat: number, resting: number): { height: number; scrolls: boolean } {\n const cap = Math.max(resting, Math.floor(chat * COMPOSER_GROWTH))\n return { height: Math.min(Math.max(content, resting), cap), scrolls: content > cap }\n}\n\nexport type ComposerKey = { key: string; shiftKey?: boolean; ctrlKey?: boolean; metaKey?: boolean; altKey?: boolean }\n\n/**\n * What a key does in the box: send, close the wide box, take the suggestion, or nothing of ours (the textarea keeps\n * it). The words shown in an empty box are a request the screen suggests - a plain Tab writes them in, so the person\n * does not have to type what the screen already said.\n */\nexport function composerKeyAction(\n e: ComposerKey,\n wide: boolean,\n box: { empty?: boolean; suggestion?: string } = {}\n): 'send' | 'narrow' | 'take-suggestion' | null {\n if (e.key === 'Tab' && !e.shiftKey && !e.ctrlKey && !e.metaKey && !e.altKey && box.empty && box.suggestion?.trim()) {\n return 'take-suggestion'\n }\n if (e.key === 'Escape') return wide ? 'narrow' : null\n if (e.key !== 'Enter' || e.altKey) return null\n if (e.ctrlKey || e.metaKey) return 'send'\n if (wide || e.shiftKey) return null\n return 'send'\n}\n\n/** The shortcut the wide box's send button names, in the keys of this machine. */\nexport function sendShortcut(platform: string | undefined): string {\n return /mac|iphone|ipad/i.test(platform ?? '') ? '⌘ Enter' : 'Ctrl+Enter'\n}\n\n/**\n * A pasted table given back as words: what the clipboard held as text, or - when it held only HTML - the rows with\n * a tab between cells, as a spreadsheet copies them.\n */\nexport function tableAsWords(table: { rows: string[][]; text?: string | null }): string {\n const text = (table.text ?? '').replace(/\\r\\n?/g, '\\n').replace(/\\n+$/, '')\n return text.trim() ? text : table.rows.map(row => row.join('\\t')).join('\\n')\n}\n\n/** The words appended to what is already written - on a line of their own. */\nexport function appendWords(written: string, words: string): string {\n return written.trim() ? `${written.replace(/\\s+$/, '')}\\n${words}` : words\n}\n\n/**\n * The request the empty box suggests, which a Tab writes in (design/ai/screen-pattern.md §4-1). Before anything is\n * said it is the conversation's first example request, its own before the host's; after an answer it is the next\n * request that answer named. A placeholder is how to write, not a request, so it is never the suggestion.\n */\nexport function composerSuggestion(input: {\n started: boolean\n modeExamples?: Array<{ items: string[] }>\n hostExamples?: Array<{ items: string[] }>\n /** The next request the last answer named. */\n answered?: string\n}): string | undefined {\n if (input.started) return input.answered?.trim() || undefined\n const groups = input.modeExamples?.length ? input.modeExamples : input.hostExamples\n return groups?.find(group => group.items.length > 0)?.items[0]\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"document-text.js","sourceRoot":"","sources":["../../client/utils/document-text.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,MAAM,QAAQ,GAAG,iBAAiB,CAAA;AAClC,MAAM,SAAS,GAAG,yEAAyE,CAAA;AAC3F,MAAM,SAAS,GAAG,2EAA2E,CAAA;AAC7F,MAAM,QAAQ,GAAG,oBAAoB,CAAA;AACrC,MAAM,QAAQ,GAAG,+BAA+B,CAAA;AAEhD,2CAA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O,MAAM,CAAC,QAAQ,EAAE,GAAG,cAAc,CAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;AACzG,CAAC","sourcesContent":["/*\n * A document read into text the conversation can carry (design/ai/shared-dock.md §9-6) - PDF, Word (.docx) and\n * PowerPoint (.pptx), as a spreadsheet is (spreadsheet-text.ts): the door takes images and text only, so a mode that\n * opens 'document' has the screen read the file before sending (2026-10-28, the user: 「pdf, word, ppt 파일은 처리할\n * 수 없는가?」).\n *\n * - Every page and slide is marked with its own number, so an answer can say \"page 3\" or \"slide 5\" and be checked.\n * - A PDF page with no text on it is a scan: it is drawn into an image and sent beside the text, named by its page.\n * - The old binary .doc and .ppt are refused by name, as .xls is - nothing here opens them.\n * - The limit is on the text after reading. A document over it is refused, never cut: a cut contract is read as the\n * whole contract.\n * - Word keeps no pages (they are laid out when printed), so a .docx is read in order with its headings marked.\n */\n\nexport type DocumentKind = 'pdf' | 'docx' | 'pptx' | 'doc' | 'ppt'\n\nconst PDF_TYPE = 'application/pdf'\nconst DOCX_TYPE = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'\nconst PPTX_TYPE = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'\nconst DOC_TYPE = 'application/msword'\nconst PPT_TYPE = 'application/vnd.ms-powerpoint'\n\n/** The picker's `accept` for documents. */\nexport const DOCUMENT_ACCEPT = ['.pdf', PDF_TYPE, '.docx', DOCX_TYPE, '.pptx', PPTX_TYPE]\n\n/** A document by its type, or by its name when the browser did not know the type. */\nexport function documentKindOf(file: { type?: string; name?: string }): DocumentKind | null {\n const type = (file.type || '').toLowerCase()\n const name = (file.name || '').toLowerCase()\n if (type === PDF_TYPE || name.endsWith('.pdf')) return 'pdf'\n if (type === DOCX_TYPE || name.endsWith('.docx')) return 'docx'\n if (type === PPTX_TYPE || name.endsWith('.pptx')) return 'pptx'\n if (type === DOC_TYPE || name.endsWith('.doc')) return 'doc'\n if (type === PPT_TYPE || name.endsWith('.ppt')) return 'ppt'\n return null\n}\n\nexport type DocumentRefusal =\n | { code: 'attachment-old-office-not-read'; name: string }\n | { code: 'attachment-document-unreadable'; name: string }\n | { code: 'attachment-document-empty'; name: string }\n | { code: 'attachment-document-too-long'; name: string; maxChars: number }\n | { code: 'attachment-scan-needs-images'; name: string }\n | { code: 'attachment-scan-too-many-pages'; name: string; pages: number; max: number }\n\n/** What a document becomes: one text file, and the scanned pages of a PDF as images. */\nexport interface DocumentFiles {\n text: { name: string; text: string }\n images: { name: string; page: number; blob: Blob }[]\n}\n\n/** The file name the text travels under - \"계약서.pdf\" → \"계약서.pdf.txt\", so the source stays readable. */\nexport const documentTextName = (fileName: string) => `${fileName}.txt`\n\n/** The file name a scanned page travels under - \"계약서.pdf\" page 3 → \"계약서.pdf - p3.jpg\". */\nexport const scannedPageName = (fileName: string, page: number) => `${fileName} - p${page}.jpg`\n\n/* ── OOXML, read without a DOM: a small pull reader over the tags the text lives in ─────────────────────────── */\n\nexport interface XmlToken {\n kind: 'open' | 'close' | 'empty' | 'text'\n name?: string\n attrs?: string\n text?: string\n}\n\nconst ENTITIES: Record<string, string> = { amp: '&', lt: '<', gt: '>', quot: '\"', apos: \"'\" }\n\nexport function xmlDecode(text: string): string {\n return text.replace(/&(#x[0-9a-f]+|#\\d+|[a-z]+);/gi, (whole, code: string) => {\n if (code[0] === '#') {\n const n = code[1] === 'x' || code[1] === 'X' ? parseInt(code.slice(2), 16) : parseInt(code.slice(1), 10)\n return Number.isFinite(n) ? String.fromCodePoint(n) : whole\n }\n return ENTITIES[code.toLowerCase()] ?? whole\n })\n}\n\n/** Tags and text in document order. Comments, declarations and processing instructions are skipped. */\nexport function* xmlTokens(xml: string): Generator<XmlToken> {\n const pattern = /<!--[\\s\\S]*?-->|<\\?[\\s\\S]*?\\?>|<!\\[CDATA\\[([\\s\\S]*?)\\]\\]>|<!(?:[^>]*)>|<(\\/?)([\\w:.-]+)([^>]*?)(\\/?)>|([^<]+)/g\n for (const match of xml.matchAll(pattern)) {\n const [, cdata, slash, name, attrs, selfClose, text] = match\n if (cdata !== undefined) yield { kind: 'text', text: cdata }\n else if (name) yield { kind: slash ? 'close' : selfClose ? 'empty' : 'open', name, attrs }\n else if (text !== undefined) yield { kind: 'text', text: xmlDecode(text) }\n }\n}\n\nconst attrOf = (attrs: string | undefined, name: string) => new RegExp(`\\\\b${name}=\"([^\"]*)\"`).exec(attrs ?? '')?.[1]\n\n/**\n * A Word body as text: paragraphs in order, a heading led by \"#\" for its level, a table as one line per row with its\n * cells between \" | \". Text inside a table cell is joined with spaces, so a row stays one line.\n */\nexport function docxText(xml: string): string {\n const lines: string[] = []\n let paragraph = ''\n let heading = 0\n let inText = false\n let tableDepth = 0\n let row: string[] | null = null\n let cell: string[] | null = null\n\n for (const token of xmlTokens(xml)) {\n const name = token.name\n if (token.kind === 'text') {\n if (inText) paragraph += token.text\n continue\n }\n if (name === 'w:t') inText = token.kind === 'open'\n else if (name === 'w:tab' && token.kind !== 'close') paragraph += '\\t'\n else if ((name === 'w:br' || name === 'w:cr') && token.kind !== 'close') paragraph += '\\n'\n else if (name === 'w:pStyle') {\n const level = /^heading\\s*(\\d)$/i.exec(attrOf(token.attrs, 'w:val') ?? '')?.[1] ?? (/^title$/i.test(attrOf(token.attrs, 'w:val') ?? '') ? '1' : '')\n heading = level ? Number(level) : 0\n } else if (name === 'w:p' && token.kind === 'open') {\n paragraph = ''\n heading = 0\n } else if (name === 'w:p' && token.kind !== 'open') {\n const text = paragraph.replace(/[ ]+$/g, '')\n if (cell) cell.push(text.trim())\n else if (text.trim()) lines.push(heading ? `${'#'.repeat(heading)} ${text.trim()}` : text)\n paragraph = ''\n } else if (name === 'w:tbl') {\n tableDepth += token.kind === 'open' ? 1 : token.kind === 'close' ? -1 : 0\n } else if (name === 'w:tr' && tableDepth === 1) {\n if (token.kind === 'open') row = []\n else if (row) {\n if (row.some(one => one)) lines.push(`| ${row.join(' | ')} |`)\n row = null\n }\n } else if (name === 'w:tc' && tableDepth === 1) {\n if (token.kind === 'open') cell = []\n else if (cell) {\n row?.push(cell.filter(Boolean).join(' '))\n cell = null\n }\n }\n }\n return lines.join('\\n')\n}\n\n/* What a slide or its notes repeat on every page - its number, date, footer, header - is not its content. */\nconst REPEATED_PLACEHOLDERS = ['sldNum', 'dt', 'ftr', 'hdr']\n\n/** The text of one slide or notes part: each paragraph on its own line, the repeated placeholders left out. */\nexport function drawingText(xml: string): string[] {\n const lines: string[] = []\n let paragraph = ''\n let inText = false\n let repeated = false\n for (const token of xmlTokens(xml)) {\n if (token.kind === 'text') {\n if (inText) paragraph += token.text\n continue\n }\n if (token.name === 'p:sp' && token.kind === 'open') repeated = false\n else if (token.name === 'p:ph' && token.kind !== 'close') repeated = REPEATED_PLACEHOLDERS.includes(attrOf(token.attrs, 'type') ?? '')\n else if (token.name === 'a:t') inText = token.kind === 'open'\n else if (token.name === 'a:br' && token.kind !== 'close') paragraph += '\\n'\n else if (token.name === 'a:p' && token.kind !== 'open') {\n if (paragraph.trim() && !repeated) lines.push(paragraph.trim())\n paragraph = ''\n }\n }\n return lines\n}\n\n/** The slides in the order the presentation shows them - its slide list read through its relationships. */\nexport function slideOrder(presentationXml: string, relsXml: string): string[] {\n const targets = new Map<string, string>()\n for (const token of xmlTokens(relsXml)) {\n if (token.name !== 'Relationship') continue\n const id = attrOf(token.attrs, 'Id')\n const target = attrOf(token.attrs, 'Target')\n if (id && target) targets.set(id, target.replace(/^\\/?ppt\\//, '').replace(/^\\.\\//, ''))\n }\n const order: string[] = []\n for (const token of xmlTokens(presentationXml)) {\n if (token.name !== 'p:sldId') continue\n const target = targets.get(attrOf(token.attrs, 'r:id') ?? '')\n if (target) order.push(`ppt/${target}`)\n }\n return order\n}\n\n/** The notes part a slide points at, if it has one. */\nexport function notesTarget(slidePath: string, slideRelsXml: string): string | null {\n for (const token of xmlTokens(slideRelsXml)) {\n if (token.name !== 'Relationship' || !/notesSlide$/.test(attrOf(token.attrs, 'Type') ?? '')) continue\n const target = attrOf(token.attrs, 'Target')\n if (!target) continue\n const base = slidePath.split('/').slice(0, -1)\n for (const part of target.split('/')) {\n if (part === '..') base.pop()\n else if (part !== '.') base.push(part)\n }\n return base.join('/')\n }\n return null\n}\n\n/** One slide as text: its paragraphs, then its speaker notes. */\nexport function slideText(number: number, slide: string[], notes: string[]): string {\n return [`--- slide ${number} ---`, ...slide, ...(notes.length ? ['notes:', ...notes] : [])].join('\\n')\n}\n\n/** One PDF page's text items as lines - pdf.js marks the end of a line on the item that ends it. */\nexport function pdfPageText(items: { str?: string; hasEOL?: boolean }[]): string {\n let text = ''\n for (const item of items) {\n text += item.str ?? ''\n if (item.hasEOL) text += '\\n'\n }\n return text\n .split('\\n')\n .map(line => line.replace(/[ \\t]+/g, ' ').trim())\n .filter(Boolean)\n .join('\\n')\n}\n\n/** A page with fewer letters than this is a scan - its text is a page number or a stray mark, not its content. */\nexport const SCANNED_PAGE_LETTERS = 16\n\nexport const isScannedPage = (text: string) => text.replace(/\\s/g, '').length < SCANNED_PAGE_LETTERS\n\n/** The header line of a document's text - what it was and how it is marked. */\nexport function documentHeader(fileName: string, kind: 'pdf' | 'docx' | 'pptx', count?: number): string {\n const many = (word: string) => `${count} ${word}${count === 1 ? '' : 's'}`\n if (kind === 'pdf') return `# ${fileName} · PDF · ${many('page')} · each page begins with \"--- page N ---\", N its own page number`\n if (kind === 'pptx') return `# ${fileName} · PowerPoint · ${many('slide')} · each slide begins with \"--- slide N ---\", its notes after \"notes:\"`\n return `# ${fileName} · Word · read in order, headings led by \"#\", table rows between \"|\"`\n}\n\n/** A finished text checked against the limit and for emptiness - the same three answers for every kind. */\nfunction settle(fileName: string, text: string, body: string, maxChars: number, images: DocumentFiles['images'] = []): { files: DocumentFiles } | { refusal: DocumentRefusal } {\n if (!body.trim() && !images.length) return { refusal: { code: 'attachment-document-empty', name: fileName } }\n if (text.length > maxChars) return { refusal: { code: 'attachment-document-too-long', name: fileName, maxChars } }\n return { files: { text: { name: documentTextName(fileName), text }, images } }\n}\n\n/** What reads a zip - JSZip, passed in so the screen loads it only when a document is attached. */\nexport interface ZipReader {\n loadAsync(data: ArrayBuffer | Uint8Array): Promise<{ file(path: string): { async(type: 'string'): Promise<string> } | null }>\n}\n\nexport async function readDocx(data: ArrayBuffer | Uint8Array, fileName: string, maxChars: number, zip: ZipReader) {\n let body: string\n try {\n const archive = await zip.loadAsync(data)\n const part = archive.file('word/document.xml')\n if (!part) return { refusal: { code: 'attachment-document-unreadable', name: fileName } as DocumentRefusal }\n body = docxText(await part.async('string'))\n } catch {\n return { refusal: { code: 'attachment-document-unreadable', name: fileName } as DocumentRefusal }\n }\n return settle(fileName, `${documentHeader(fileName, 'docx')}\\n${body}\\n`, body, maxChars)\n}\n\nexport async function readPptx(data: ArrayBuffer | Uint8Array, fileName: string, maxChars: number, zip: ZipReader) {\n const slides: string[] = []\n try {\n const archive = await zip.loadAsync(data)\n const read = async (path: string) => (await archive.file(path)?.async('string')) ?? null\n const presentation = await read('ppt/presentation.xml')\n const rels = await read('ppt/_rels/presentation.xml.rels')\n if (!presentation || !rels) return { refusal: { code: 'attachment-document-unreadable', name: fileName } as DocumentRefusal }\n const order = slideOrder(presentation, rels)\n for (const [index, path] of order.entries()) {\n const slide = await read(path)\n if (slide === null) continue\n const slideRels = await read(path.replace(/slides\\/(slide\\d+\\.xml)$/, 'slides/_rels/$1.rels'))\n const notesPath = slideRels ? notesTarget(path, slideRels) : null\n const notes = notesPath ? await read(notesPath) : null\n slides.push(slideText(index + 1, drawingText(slide), notes ? drawingText(notes) : []))\n }\n } catch {\n return { refusal: { code: 'attachment-document-unreadable', name: fileName } as DocumentRefusal }\n }\n const body = slides.join('\\n')\n const said = slides.some(slide => slide.split('\\n').length > 1)\n return settle(fileName, `${documentHeader(fileName, 'pptx', slides.length)}\\n${body}\\n`, said ? body : '', maxChars)\n}\n\n/** What reads a PDF - pdf.js's document, narrowed to what is used, so a test can hand in pages. */\nexport interface PdfSource {\n numPages: number\n getPage(number: number): Promise<{ getTextContent(): Promise<{ items: any[] }> }>\n}\n\n/**\n * Every page of a PDF as text, its scanned pages drawn as images by `drawPage` (the screen's canvas). A scan cannot be\n * read unless the mode takes images, and no more scanned pages are drawn than the message may carry - both refused by\n * name, never dropped.\n */\nexport async function readPdf(\n open: () => Promise<PdfSource>,\n fileName: string,\n maxChars: number,\n scans: { allowed: boolean; max: number },\n drawPage: (number: number) => Promise<Blob>\n): Promise<{ files: DocumentFiles } | { refusal: DocumentRefusal }> {\n const pages: string[] = []\n const scanned: number[] = []\n let count = 0\n try {\n const pdf = await open()\n count = pdf.numPages\n for (let number = 1; number <= count; number++) {\n const page = await pdf.getPage(number)\n const text = pdfPageText((await page.getTextContent()).items)\n if (isScannedPage(text)) {\n scanned.push(number)\n pages.push(`--- page ${number} ---\\n(no text on this page - a scan, sent as the image \"${scannedPageName(fileName, number)}\")`)\n } else pages.push(`--- page ${number} ---\\n${text}`)\n }\n } catch {\n return { refusal: { code: 'attachment-document-unreadable', name: fileName } }\n }\n if (scanned.length && !scans.allowed) return { refusal: { code: 'attachment-scan-needs-images', name: fileName } }\n if (scanned.length > scans.max) return { refusal: { code: 'attachment-scan-too-many-pages', name: fileName, pages: scanned.length, max: scans.max } }\n const images: DocumentFiles['images'] = []\n try {\n for (const page of scanned) images.push({ name: scannedPageName(fileName, page), page, blob: await drawPage(page) })\n } catch {\n return { refusal: { code: 'attachment-document-unreadable', name: fileName } }\n }\n const body = pages.join('\\n')\n const read = scanned.length < count ? body : ''\n return settle(fileName, `${documentHeader(fileName, 'pdf', count)}\\n${body}\\n`, read, maxChars, images)\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"entry-hash.js","sourceRoot":"","sources":["../../client/utils/entry-hash.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,SAAS,GAAG,CAAC,KAAc,EAAU,EAAE;IAC3C,IAAI,KAAK,K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AG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;QAC1B,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,CAAA;IAC1C,CAAC;IACD,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAA;AAC5E,CAAC","sourcesContent":["/*\n * One 입력안's fingerprint - what the AI 작업 패널 showed and what the card enters are the same proposal\n * (operato-application/design/ai/workspace.md §6-1). The screen's copy and the server's are one rule;\n * `test/entry-hash-agree.test.ts` runs both over one table.\n *\n * It covers what is entered: the key, the target, create or change, and each row's index, record and values.\n */\n\nconst canonical = (value: unknown): string => {\n if (value === null || value === undefined) return 'null'\n if (Array.isArray(value)) return `[${value.map(canonical).join(',')}]`\n if (typeof value === 'object')\n return `{${Object.keys(value as object)\n .filter(name => (value as any)[name] !== undefined)\n .sort()\n .map(name => `${JSON.stringify(name)}:${canonical((value as any)[name])}`)\n .join(',')}}`\n return JSON.stringify(value)\n}\n\n/** FNV-1a over the canonical text - a fingerprint to compare, not a secret. */\nexport function entryProposalHash(proposal: any): string {\n const text = canonical({\n key: proposal?.key,\n target: proposal?.target,\n op: proposal?.op ?? 'create',\n rows: (proposal?.rows ?? []).map((row: any) => ({ index: row?.index, id: row?.id, values: row?.values ?? {} }))\n })\n let hash = 0x811c9dc5\n for (let i = 0; i < text.length; i++) {\n hash ^= text.charCodeAt(i)\n hash = Math.imul(hash, 0x01000193) >>> 0\n }\n return `${hash.toString(16).padStart(8, '0')}-${text.length.toString(16)}`\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"entry-proposal.js","sourceRoot":"","sources":["../../client/utils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AC,GAAG,CAAC,IAAI,GAAG,CAAC,GAAG;gBAAE,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAA;IAC9I,OAAO,MAAM,CAAA;AACf,CAAC;AAED,yGAAyG;AACzG,MAAM,UAAU,YAAY,CAAC,QAAa;IACxC,OAAO,GAAG,QAAQ,EAAE,MAAM,IAAI,QAAQ,EAAE,EAAE,IAAI,QAAQ,EAAE,CAAA;AAC1D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,QAAa,EAAE,CAAyC;IACjF,MAAM,IAAI,GAAG,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,CAAA;IAC/E,OAAO,QAAQ,EAAE,EAAE,KAAK,QAAQ;QAC9B,CAAC,CAAC,CAAC,CAAC,iCAAiC,EAAE,EAAE,YAAY,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC;QAClF,CAAC,CAAC,CAAC,CAAC,iCAAiC,EAAE,EAAE,YAAY,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAA;AACrF,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,QAAa;IAC5C,OAAO,eAAe,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,EAAE,KAAK,QAAQ,CAAA;AAC9D,CAAC","sourcesContent":["/*\n * The data entry card's rules and its handler (operato-application/design/ai/data-entry.md §5).\n *\n * The card is a review, not an editor: a correction is said in the conversation and the model proposes\n * again - the newer card replaces the older one. Pressing asks the server to enter the stored rows; the\n * screen sends no rows of its own.\n */\nimport { encodeListQuery } from '@operato/utils/list-query.js'\n\nimport type { ProposalContext, ProposalOutcome } from './assistant-proposals.js'\nimport { reviewedHashOf, reviewStillHolds } from './entry-workspace.js'\n\nexport interface EntryIssueView {\n field?: string\n code: string\n messageKey?: string\n params?: Record<string, unknown>\n paramKeys?: Record<string, string>\n blocking: boolean\n}\n\nexport interface EntryRowView {\n index: number\n values: Record<string, unknown>\n sources: { attachmentId?: string; where?: string; person?: boolean }[]\n issues: EntryIssueView[]\n /** The server found this row's numbers and dates together on this line of the cited file. */\n evidence?: { attachmentId: string; line: number }\n}\n\nexport interface EntryTotalView {\n field: string\n all: number\n ready: number\n declared?: number\n declaredFound?: boolean\n difference?: number\n declaredBy?: 'model' | 'file'\n}\n\nexport interface EntryRowResult {\n index: number\n ok: boolean\n id?: string\n label?: string\n error?: string\n}\n\nexport interface EntryApplyAnswer extends ProposalOutcome {\n rows?: EntryRowResult[]\n refusal?: { message: string; extensions: Record<string, unknown>; path: string[] }\n /** Set by the handler from the card - which words the conversation line uses. */\n op?: string\n /** Set by the handler from the card - which card and record kind the entered ids belong to. */\n key?: string\n target?: string\n}\n\nexport function isEntryProposal(proposal: any): boolean {\n return proposal?.kind === 'entry' && Array.isArray(proposal?.rows)\n}\n\nexport function entryReadyCount(proposal: any): number {\n const rows: EntryRowView[] = proposal?.rows ?? []\n const blocked = (row: EntryRowView) => row.issues?.some(issue => issue.blocking)\n if (!proposal?.groupBy) return rows.filter(row => !blocked(row)).length\n /* Lines of one record go in together - a record with a line kept out is kept out whole, and its lines do not count. */\n const keyOf = (row: EntryRowView) => {\n const value: any = row.values?.[proposal.groupBy]\n return value === undefined || value === null || value === '' ? `row-${row.index}` : String(typeof value === 'object' ? value.id ?? value.text : value)\n }\n const out = new Set(rows.filter(blocked).map(keyOf))\n return rows.filter(row => !out.has(keyOf(row))).length\n}\n\n/** The i18n key of an issue - the target's own, or the framework's by code. */\nexport function entryIssueKey(issue: EntryIssueView): string {\n return issue.messageKey || `ai-assistant.entry.issue.${issue.code}`\n}\n\n/** The issues of one cell, and of the row as a whole (no field). */\nexport function entryCellIssues(row: EntryRowView, field?: string): EntryIssueView[] {\n return (row.issues ?? []).filter(issue => (field ? issue.field === field : !issue.field))\n}\n\n/** What stays in the conversation - the model reads it on its next turn, and the person sees what went in. */\nexport function entryOutcomeNote(answer: EntryApplyAnswer, t: (key: string, options?: any) => string): string {\n const refused = (answer.rows ?? []).filter(row => !row.ok)\n const head = answer.op === 'update'\n ? answer.applied\n ? t('ai-assistant.entry.changed', { defaultValue: 'changed {count} records.', count: answer.applied })\n : t('ai-assistant.entry.changed-none', { defaultValue: 'no record was changed.' })\n : answer.applied\n ? t('ai-assistant.entry.entered', { defaultValue: 'entered {count} rows.', count: answer.applied })\n : t('ai-assistant.entry.entered-none', { defaultValue: 'no row was entered.' })\n const lines = refused.slice(0, 20).map(row => t('ai-assistant.entry.row-refused', { defaultValue: 'row {n}: {reason}', n: row.index + 1, reason: row.error || '' }))\n const more = refused.length > 20 ? [t('ai-assistant.entry.more-refused', { defaultValue: '{count} more rows were not entered.', count: refused.length - 20 })] : []\n const records = entryRecordsLine(answer)\n return [head, ...appliedNames(answer, t), ...lines, ...more, ...(records ? [records] : [])].join('\\n')\n}\n\n/**\n * The line of an entry note that names the records a card entered - for the card, which opens them on their screen, and\n * for the model. The conversation does not draw it. Not `[keys]`: that line is the person's selection, and a card's\n * records must not replace what \"these\" means.\n */\nexport const ENTRY_RECORDS_PREFIX = '[records]'\n\nconst enteredIds = (answer: EntryApplyAnswer): string[] => [...new Set((answer.rows ?? []).filter(row => row.ok && row.id).map(row => row.id as string))]\n\nfunction entryRecordsLine(answer: EntryApplyAnswer): string {\n const ids = enteredIds(answer)\n return ids.length && answer.key && answer.target ? `${ENTRY_RECORDS_PREFIX} ${answer.key} ${answer.target} ${ids.join(' ')}` : ''\n}\n\n/** The card key, record kind and ids of an entry note's records line - undefined for any other content. */\nexport function entryRecordsOf(content: string): { key: string; target: string; ids: string[] } | undefined {\n const line = (content ?? '').split('\\n').find(one => one.startsWith(`${ENTRY_RECORDS_PREFIX} `))\n const [key, target, ...ids] = line ? line.slice(ENTRY_RECORDS_PREFIX.length).trim().split(/\\s+/) : []\n return key && target && ids.length ? { key, target, ids } : undefined\n}\n\n/** At most this many ids narrow a list in its address - more open the list as it is. */\nexport const ENTRY_SCREEN_IDS = 50\n\n/**\n * Where the card's \"see on the screen\" goes. One record of a kind with a 360 opens that 360 beside its list; records\n * of the list the screen shows narrow it to them, a condition the person sees and removes; otherwise the screen as it is.\n */\nexport function entryScreenAddress(proposal: any, ids: string[] | undefined, has360: (kind: string) => boolean): string {\n const screen: string = proposal?.screen\n const kind = String(proposal?.target ?? '').split('.')[1] ?? ''\n if (ids?.length === 1 && kind && has360(kind)) return `${screen}?${new URLSearchParams({ f: `${kind}:${ids[0]}` })}`\n if (ids?.length && ids.length <= ENTRY_SCREEN_IDS && proposal?.screenLists)\n return `${screen}?${encodeListQuery({ filters: [{ name: 'id', operator: 'in', value: ids }] })}`\n return screen\n}\n\n/*\n * Which records went in, by name - the person finds them on the screen by it, and the model reads which ones they were.\n * Lines of one record share its name; a record without one is only counted.\n */\nfunction appliedNames(answer: EntryApplyAnswer, t: (key: string, options?: any) => string): string[] {\n const names = [...new Set((answer.rows ?? []).filter(row => row.ok && row.label).map(row => row.label as string))]\n if (!names.length) return []\n const shown = names.slice(0, 10).join(', ')\n return [names.length > 10 ? `${shown} ${t('ai-assistant.entry.more-applied', { defaultValue: 'and {count} more', count: names.length - 10 })}` : shown]\n}\n\n/** The handler every entry card runs - built with the mutation so the rules are tested without a server. */\nexport function entryProposalHandler(\n apply: (sessionId: string, proposalKey: string, reviewedHash?: string) => Promise<EntryApplyAnswer>,\n t: (key: string, options?: any) => string,\n reviewedOf: (key: string) => string | undefined = reviewedHashOf,\n reportRefusal: (notification: { level: 'error'; message: string; ex: NonNullable<EntryApplyAnswer['refusal']>[] }) => void | Promise<void> = async notification => {\n /* The generic toast transport. auth-ui alone interprets the refusal and offers an access request. */\n const { notify } = await import('@operato/layout')\n notify(notification)\n }\n) {\n return async (proposal: any, context: ProposalContext): Promise<ProposalOutcome> => {\n if (!context.sessionId || !proposal?.key) return { verdict: 'unavailable', errorCode: 'no-conversation' }\n /* Reviewed in the 작업 패널: entered only as it was shown there (design/ai/workspace.md §6-1) - here, and again at the server. */\n const reviewed = reviewedOf(proposal.key)\n if (!reviewStillHolds(proposal, reviewed)) return { verdict: 'refused', errorCode: 'review-stale', note: t('ai-assistant.entry.review-stale', { defaultValue: 'this proposal changed after it was reviewed in the workspace - review it again before entering.' }) } as any\n const answer = { ...(await apply(context.sessionId, proposal.key, reviewed)), op: proposal.op, key: proposal.key, target: proposal.target }\n if (answer.verdict === 'refused' && answer.errorCode === 'door-closed' && answer.refusal) {\n try {\n await reportRefusal({ level: 'error', message: answer.refusal.message, ex: [answer.refusal] })\n } catch {\n /* Notification delivery is best-effort; it never changes the stored proposal's refusal. */\n }\n }\n if (answer.errorCode === 'review-stale')\n return { verdict: 'refused', errorCode: 'review-stale', applied: 0, missed: 0, note: t('ai-assistant.entry.review-stale', { defaultValue: 'this proposal changed after it was reviewed in the workspace - review it again before entering.' }) }\n return {\n verdict: answer.verdict,\n ...(answer.errorCode ? { errorCode: answer.errorCode } : {}),\n applied: answer.applied ?? 0,\n missed: answer.missed ?? 0,\n note: entryOutcomeNote(answer, t),\n records: enteredIds(answer)\n }\n }\n}\n\n/**\n * The newest card per record, over the conversation's proposals in order - an older one is replaced and\n * cannot be entered (the server refuses it as `superseded`; the card says so before anyone presses).\n */\nexport function latestEntryKeys(proposalsInOrder: any[][]): Map<string, string> {\n const latest = new Map<string, string>()\n for (const list of proposalsInOrder) for (const one of list ?? []) if (isEntryProposal(one) && one.key) latest.set(entryGroupOf(one), one.key)\n return latest\n}\n\n/** A 입력안 and a 수정안 of one record are counted apart - a newer one of the same kind replaces the older. */\nexport function entryGroupOf(proposal: any): string {\n return `${proposal?.target}:${proposal?.op ?? 'create'}`\n}\n\n/**\n * The card's title - the record's name from the target (`부서`, `거래처`) and the kind of card from here, so a\n * 수정안 is never titled as a 입력안.\n */\nexport function entryTitle(proposal: any, t: (key: string, options?: any) => string): string {\n const name = proposal?.labelKey ? t(proposal.labelKey) : proposal?.target ?? ''\n return proposal?.op === 'update'\n ? t('ai-assistant.entry.title-update', { defaultValue: '{name} to change', name })\n : t('ai-assistant.entry.title-create', { defaultValue: '{name} to enter', name })\n}\n\nexport function isChangeProposal(proposal: any): boolean {\n return isEntryProposal(proposal) && proposal.op === 'update'\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"entry-workspace.js","sourceRoot":"","sources":["../../client/utils/entry-workspace.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAEnD,6DAA6D;AAC7D,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAA;AAChC,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAA;AAElC,MAAM,UAAU,qBAAqB,CAAC,QAAa;IACjD,OAAO,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,cAAc,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,iBAAiB,CAAA;AAC/G,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,SAAiB,EAAE,WAAmB;IACvE,OAAO,uBAAuB,IAAI,eAAe,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAA;AAC5G,CAAC;AAED,2HAA2H;AAC3H,MAAM,UAAU,cAAc,CAAC,QAA4E,EAAE,GAAW;IACtH,IAAI,EAAE,GAAG,CAAC,CAAC,CAAA;IACX,IAAI,QAAa,CAAA;IACjB,IAAI,SAA6B,CAAA;IACjC,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE;QAC9B,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,aAAa,IAAI,EAAE;YAAE,IAAI,GAAG,EAAE,IAAI,KAAK,OAAO,IAAI,GAAG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I,SAAS,CAAA;IACjD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,gBAAgB,CAAC,QAAa,EAAE,QAA4B;IAC1E,OAAO,CAAC,QAAQ,IAAI,QAAQ,KAAK,iBAAiB,CAAC,QAAQ,CAAC,CAAA;AAC9D,CAAC;AAED,SAAS,WAAW;IAClB,IAAI,CAAC;QACH,OAAO,OAAO,cAAc,KAAK,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,CAAA;IAC3E,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC","sourcesContent":["/*\n * Reviewing a 입력안 in the AI 작업 패널 (operato-application/design/ai/workspace.md §6-1). Pure but for the\n * session store - tested without a browser.\n *\n * The page is read-only: every column and every row, sorted as stored, issues marked. The one place that enters\n * is the dock's card. What the page showed is remembered by its fingerprint, and the card sends it - a proposal\n * that changed in between is refused, and the person reviews it again.\n */\nimport { entryProposalHash } from './entry-hash.js'\n\n/** A card wide or long enough not to be read in the dock. */\nexport const WORKSPACE_ROWS = 20\nexport const WORKSPACE_COLUMNS = 6\n\nexport function offersWorkspaceReview(proposal: any): boolean {\n return (proposal?.rows?.length ?? 0) > WORKSPACE_ROWS || (proposal?.columns?.length ?? 0) > WORKSPACE_COLUMNS\n}\n\nexport function entryReviewAddress(sessionId: string, proposalKey: string): string {\n return `assistant-workspace?${new URLSearchParams({ session: sessionId, entry: proposalKey }).toString()}`\n}\n\n/** The proposal of that key among the conversation's messages, and whether a newer card of the same record replaced it. */\nexport function entryForReview(messages: { id: string; createdAt?: string; proposalsJson?: any[] | null }[], key: string): { proposal?: any; createdAt?: string; superseded: boolean } {\n let at = -1\n let proposal: any\n let createdAt: string | undefined\n messages.forEach((message, i) => {\n for (const one of message.proposalsJson ?? []) if (one?.kind === 'entry' && one?.key === key) (at = i), (proposal = one), (createdAt = message.createdAt)\n })\n if (!proposal) return { superseded: false }\n const superseded = messages\n .slice(at + 1)\n .some(message => (message.proposalsJson ?? []).some(one => one?.kind === 'entry' && one?.target === proposal.target && (one?.op ?? 'create') === (proposal.op ?? 'create')))\n return { proposal, createdAt, superseded }\n}\n\nconst STORE = 'ai-assistant.entry-reviewed:'\n\n/** Remembers what the page showed for this key. A browser that keeps nothing keeps nothing - the card then sends no fingerprint. */\nexport function rememberReviewed(proposal: any, store: Pick<Storage, 'setItem'> | undefined = safeSession()): string {\n const hash = entryProposalHash(proposal)\n try {\n store?.setItem(STORE + proposal.key, hash)\n } catch {\n /* private window or blocked storage */\n }\n return hash\n}\n\nexport function reviewedHashOf(key: string, store: Pick<Storage, 'getItem'> | undefined = safeSession()): string | undefined {\n try {\n return store?.getItem(STORE + key) ?? undefined\n } catch {\n return undefined\n }\n}\n\n/** Whether the card may be pressed: not reviewed, or reviewed as it stands now. */\nexport function reviewStillHolds(proposal: any, reviewed: string | undefined): boolean {\n return !reviewed || reviewed === entryProposalHash(proposal)\n}\n\nfunction safeSession(): Storage | undefined {\n try {\n return typeof sessionStorage === 'undefined' ? undefined : sessionStorage\n } catch {\n return undefined\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"invite-proposal-register.js","sourceRoot":"","sources":["../../client/utils/invite-proposal-register.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAEzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAA;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AAE5D,uBAAuB,CACrB,eAAe,EACf,qBAAqB,CACnB,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE;IAC3B,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC;QACjC,QAAQ,EAAE,GAAG,CAAA;;;;SAIZ;QACD,SAAS,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE;KAC7C,CAAC,CAAA;IACF,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;IACpE,OAAO,MAAM,CAAC,IAAI,EAAE,iBAAiB,IAAI,EAAE,CAAA;AAC7C,CAAC,EACD,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAClD,CACF,CAAA","sourcesContent":["/*\n * Pressing an invite card seats the person through the invite door, as the one who pressed (ADR-0073 decision 3).\n * The card is ai-assistant's own tool (server: people/invite-tools.ts), so its handler is registered here, by the\n * package that declared it - the dock knows no proposal kind (design/ai/shared-dock.md §4).\n */\nimport gql from 'graphql-tag'\n\nimport { i18next } from '@operato/i18n'\nimport { client } from '@operato/graphql'\n\nimport { registerProposalHandler } from './assistant-proposals.js'\nimport { inviteProposalHandler } from './invite-proposal.js'\n\nregisterProposalHandler(\n 'proposeInvite',\n inviteProposalHandler(\n async (sessionId, userIds) => {\n const result = await client.mutate({\n mutation: gql`\n mutation ($id: String!, $users: [String!]!) {\n inviteToAISession(sessionId: $id, userIds: $users)\n }\n `,\n variables: { id: sessionId, users: userIds }\n })\n if (result.errors?.length) throw new Error(result.errors[0].message)\n return result.data?.inviteToAISession ?? []\n },\n (key, options) => String(i18next.t(key, options))\n )\n)\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"invite-proposal.js","sourceRoot":"","sources":["../../client/utils/invite-proposal.ts"],"names":[],"mappings":"AAgBA,MAAM,UAAU,gBAAgB,CAAC,QAAa;IAC5C,OAAO,QAA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YAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAA;QACvF,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;QAC7E,IAAI,CAAC,MAAM,CAAC,MAAM;YAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,cAAc,EAAE,CAAA;QAC5E,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC/F,OAAO;YACL,OAAO,EAAE,UAAU;YACnB,OAAO,EAAE,MAAM,CAAC,MAAM;YACtB,IAAI,EAAE,CAAC,CAAC,6BAA6B,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,gDAAgD,EAAE,CAAC;SAClH,CAAA;IACH,CAAC,CAAA;AACH,CAAC","sourcesContent":["/*\n * The invite card (server: people/invite-tools.ts) - who it offers, and what pressing it does.\n *\n * Pressing is the person's act: the dock calls `inviteToAISession` with their own request, and the door decides\n * whether they may seat anyone here (`maySeat`). The model's card seats nobody by itself. A card with several people\n * of one name is pressed on one of them - the press carries `chosen`; nothing is guessed.\n */\nimport type { ProposalHandler } from './assistant-proposals.js'\n\nexport interface InvitePerson {\n userId: string\n name: string\n department?: string\n position?: string\n}\n\nexport function isInviteProposal(proposal: any): boolean {\n return proposal?.kind === 'invite' && proposal?.tool === 'proposeInvite' && Array.isArray(proposal?.people) && proposal.people.length > 0\n}\n\n/** The people a press brings in: the one picked, or the only one on the card. */\nexport function invitedBy(proposal: any): InvitePerson[] {\n const people: InvitePerson[] = Array.isArray(proposal?.people) ? proposal.people.filter((one: any) => one?.userId) : []\n if (proposal?.chosen) return people.filter(one => one.userId === proposal.chosen)\n return people.length === 1 ? people : []\n}\n\n/** One line under a person's name - where they work. */\nexport function personLine(person: InvitePerson): string {\n return [person.department, person.position].filter(Boolean).join(' · ')\n}\n\n/**\n * Presses the card through the invite door. `invite` is the door - `inviteToAISession(sessionId, userIds)`, answering the\n * ids seated now; it throws the door's refusal, which the dock reports as `refused` with that message.\n */\nexport function inviteProposalHandler(\n invite: (sessionId: string, userIds: string[]) => Promise<string[]>,\n t: (key: string, options: Record<string, unknown>) => string\n): ProposalHandler {\n return async (proposal, context) => {\n const people = invitedBy(proposal)\n if (!people.length) return { verdict: 'refused', errorCode: 'no-person-chosen' }\n if (!context.sessionId) return { verdict: 'unavailable', errorCode: 'no-conversation' }\n const seated = await invite(context.sessionId, people.map(one => one.userId))\n if (!seated.length) return { verdict: 'refused', errorCode: 'already-here' }\n const names = people.filter(one => seated.includes(one.userId)).map(one => one.name).join(', ')\n return {\n verdict: 'accepted',\n applied: seated.length,\n note: t('ai-assistant.people.invited', { names, defaultValue: '{names} joined this conversation and was told.' })\n }\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { inviteProposalHandler, invitedBy, isInviteProposal } from './invite-proposal';
|
|
2
|
-
const card = (people, extra = {}) => ({ tool: 'proposeInvite', kind: 'invite', people, ...extra });
|
|
3
|
-
const kim = { userId: 'u-1', name: '정연희', department: 'Sales' };
|
|
4
|
-
const lee = { userId: 'u-2', name: '정연희', department: 'Finance' };
|
|
5
|
-
const t = (_key, options) => String(options.defaultValue).replace('{names}', options.names);
|
|
6
|
-
const context = (sessionId) => ({ sessionId, confirm: async () => true, notify: () => { } });
|
|
7
|
-
describe('the invite card', () => {
|
|
8
|
-
it('is the invite tool\'s card with someone on it', () => {
|
|
9
|
-
expect(isInviteProposal(card([kim]))).toBe(true);
|
|
10
|
-
expect(isInviteProposal(card([]))).toBe(false);
|
|
11
|
-
expect(isInviteProposal({ ...card([kim]), tool: 'proposeAction' })).toBe(false);
|
|
12
|
-
});
|
|
13
|
-
it('★ one person: pressing invites them; several: only the one picked - nothing is guessed', () => {
|
|
14
|
-
expect(invitedBy(card([kim]))).toEqual([kim]);
|
|
15
|
-
expect(invitedBy(card([kim, lee]))).toEqual([]);
|
|
16
|
-
expect(invitedBy(card([kim, lee], { chosen: 'u-2' }))).toEqual([lee]);
|
|
17
|
-
});
|
|
18
|
-
it('★ pressing calls the invite door with the conversation and the person picked', async () => {
|
|
19
|
-
const calls = [];
|
|
20
|
-
const handler = inviteProposalHandler(async (sessionId, userIds) => (calls.push([sessionId, userIds]), userIds), t);
|
|
21
|
-
expect(await handler(card([kim, lee], { chosen: 'u-2' }), context('s1'))).toMatchObject({ verdict: 'accepted', applied: 1, note: '정연희 joined this conversation and was told.' });
|
|
22
|
-
expect(calls).toEqual([['s1', ['u-2']]]);
|
|
23
|
-
});
|
|
24
|
-
it('no pick, no conversation, or nobody seated - said, never accepted', async () => {
|
|
25
|
-
const handler = inviteProposalHandler(async (_s, userIds) => userIds, t);
|
|
26
|
-
expect(await handler(card([kim, lee]), context('s1'))).toEqual({ verdict: 'refused', errorCode: 'no-person-chosen' });
|
|
27
|
-
expect(await handler(card([kim]), context())).toEqual({ verdict: 'unavailable', errorCode: 'no-conversation' });
|
|
28
|
-
expect(await inviteProposalHandler(async () => [], t)(card([kim]), context('s1'))).toEqual({ verdict: 'refused', errorCode: 'already-here' });
|
|
29
|
-
});
|
|
30
|
-
it("the door's refusal is not swallowed - it is thrown to the dock, which reports it", async () => {
|
|
31
|
-
const handler = inviteProposalHandler(async () => { throw new Error('only the person who started this group conversation can bring people in.'); }, t);
|
|
32
|
-
await expect(handler(card([kim]), context('s1'))).rejects.toThrow(/only the person who started/);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
//# sourceMappingURL=invite-proposal.test.js.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C,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAAA;IAClG,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { inviteProposalHandler, invitedBy, isInviteProposal } from './invite-proposal'\n\nconst card = (people: any[], extra: any = {}) => ({ tool: 'proposeInvite', kind: 'invite', people, ...extra })\nconst kim = { userId: 'u-1', name: '정연희', department: 'Sales' }\nconst lee = { userId: 'u-2', name: '정연희', department: 'Finance' }\nconst t = (_key: string, options: any) => String(options.defaultValue).replace('{names}', options.names)\nconst context = (sessionId?: string) => ({ sessionId, confirm: async () => true, notify: () => {} }) as any\n\ndescribe('the invite card', () => {\n it('is the invite tool\\'s card with someone on it', () => {\n expect(isInviteProposal(card([kim]))).toBe(true)\n expect(isInviteProposal(card([]))).toBe(false)\n expect(isInviteProposal({ ...card([kim]), tool: 'proposeAction' })).toBe(false)\n })\n\n it('★ one person: pressing invites them; several: only the one picked - nothing is guessed', () => {\n expect(invitedBy(card([kim]))).toEqual([kim])\n expect(invitedBy(card([kim, lee]))).toEqual([])\n expect(invitedBy(card([kim, lee], { chosen: 'u-2' }))).toEqual([lee])\n })\n\n it('★ pressing calls the invite door with the conversation and the person picked', async () => {\n const calls: any[] = []\n const handler = inviteProposalHandler(async (sessionId, userIds) => (calls.push([sessionId, userIds]), userIds), t)\n expect(await handler(card([kim, lee], { chosen: 'u-2' }), context('s1'))).toMatchObject({ verdict: 'accepted', applied: 1, note: '정연희 joined this conversation and was told.' })\n expect(calls).toEqual([['s1', ['u-2']]])\n })\n\n it('no pick, no conversation, or nobody seated - said, never accepted', async () => {\n const handler = inviteProposalHandler(async (_s, userIds) => userIds, t)\n expect(await handler(card([kim, lee]), context('s1'))).toEqual({ verdict: 'refused', errorCode: 'no-person-chosen' })\n expect(await handler(card([kim]), context())).toEqual({ verdict: 'unavailable', errorCode: 'no-conversation' })\n expect(await inviteProposalHandler(async () => [], t)(card([kim]), context('s1'))).toEqual({ verdict: 'refused', errorCode: 'already-here' })\n })\n\n it(\"the door's refusal is not swallowed - it is thrown to the dock, which reports it\", async () => {\n const handler = inviteProposalHandler(async () => { throw new Error('only the person who started this group conversation can bring people in.') }, t)\n await expect(handler(card([kim]), context('s1'))).rejects.toThrow(/only the person who started/)\n })\n})\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"menu-room.js","sourceRoot":"","sources":["../../client/utils/menu-room.ts"],"names":[],"mappings":"AAUA,MAAM,UAAU,WAAW,CAAC,IAA0B;IACpD,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,SAAS;QAAE,OAAO,KAAK,CAAA;IACzC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAA;IACrB,OAAO,IAAI,CAAA;AACb,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAA0B,EAAE,YAAqB;IAC/E,IAAI,CAAC,IAAI,IAAI,CAAC,YAAY,IAAI,CAAC,IAAI,CAAC,SAAS;QAAE,OAAM;IACrD,IAAI,CAAC,SAAS,GAAG,KAAK,CAAA;AACxB,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,QAAQ,CAAC,OAA8B,QAAQ;IAC7D,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,cAAc,CAAoC,CAAA;IACnF,IAAI,KAAK;QAAE,OAAO,KAAK,CAAA;IACvB,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC;QACjD,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;YACvB,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;YAC1C,IAAI,KAAK;gBAAE,OAAO,KAAK,CAAA;QACzB,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC","sourcesContent":["/**\n * The page's menu gives the dock its room (2026-10-12). When the dock opens beside the page, the left menu folds to its\n * icons; when the dock closes, the menu opens again - only if it is still folded the way the dock left it. A menu the\n * person folded themselves stays folded, and the dock's fold is never saved as the person's choice: it sets the menu's\n * state without the menu's own `setCollapsed`, which stores it.\n */\nexport interface MenuLike {\n collapsed: boolean\n}\n\nexport function foldForDock(menu: MenuLike | undefined): boolean {\n if (!menu || menu.collapsed) return false\n menu.collapsed = true\n return true\n}\n\nexport function unfoldAfterDock(menu: MenuLike | undefined, foldedByDock: boolean): void {\n if (!menu || !foldedByDock || !menu.collapsed) return\n menu.collapsed = false\n}\n\n/** The framework's menu (`ox-menu-part` of @operato/menu), wherever the layout put it. */\nexport function findMenu(root: Document | ShadowRoot = document): (HTMLElement & MenuLike) | undefined {\n const found = root.querySelector('ox-menu-part') as (HTMLElement & MenuLike) | null\n if (found) return found\n for (const element of root.querySelectorAll('*')) {\n if (element.shadowRoot) {\n const inner = findMenu(element.shadowRoot)\n if (inner) return inner\n }\n }\n return undefined\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"open-page.js","sourceRoot":"","sources":["../../client/utils/open-page.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,gFAAgF;AAChF,MAAM,UAAU,YAAY,CAAC,IAAa;IACxC,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;AAChI,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,QAAa;IAC9C,OAAO,QAAQ,EAAE,IAAI,KAAK,WAAW,IAAI,YAAY,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;AACvE,CAAC;AAED,8GAA8G;AAC9G,MAAM,UAAU,YAAY,CAAC,QAAa,EAAE,CAAyC;IACnF,MAAM,OAAO,GAAa,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAA;IACpG,OAAO,OAAO,CAAC,MAAM;QACnB,CAAC,CAAC,CAAC,CAAC,iCAAiC,EAAE,EAAE,YAAY,EAAE,wCAAwC,EAAE,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAClI,CAAC,CAAC,EAAE,CAAA;AACR,CAAC","sourcesContent":["/*\n * The card that opens an application's list screen with the conditions of a question (design/ai/read-targets.md §5).\n * It reads nothing and runs nothing - the person presses it and the page opens beside the dock.\n */\n\n/** An address inside the application - never another origin, never a script. */\nexport function isAppAddress(href: unknown): href is string {\n return typeof href === 'string' && !!href.trim() && !/^[a-z][a-z0-9+.-]*:/i.test(href.trim()) && !href.trim().startsWith('//')\n}\n\nexport function isOpenPageProposal(proposal: any): boolean {\n return proposal?.kind === 'open-page' && isAppAddress(proposal?.href)\n}\n\n/** The line under the card's title - the conditions the screen does not take, said, never dropped quietly. */\nexport function openPageNote(proposal: any, t: (key: string, options?: any) => string): string {\n const missing: string[] = Array.isArray(proposal?.notAppliedLabels) ? proposal.notAppliedLabels : []\n return missing.length\n ? t('ai-assistant.screen.not-applied', { defaultValue: 'the screen does not take: {conditions}', conditions: missing.join(', ') })\n : ''\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pasted-table.js","sourceRoot":"","sources":["../../client/utils/pasted-table.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,WAAW,EAAyB,MAAM,wBAAwB,CAAA;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAOhD,sFAAsF;AACtF,MAAM,qBAAqB,GAAG,EAAE,CAAA;AAEhC,MAAM,QAAQ,GAA2B,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AAI,CAAC,GAAG,IAAI,CAAA;AACvI,CAAC;AAID;;;GAGG;AACH,MAAM,UAAU,eAAe,CAC7B,SAAyD,EACzD,MAA2C,EAC3C,MAAgC;IAEhC,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,aAAa,CAAC;QAAE,OAAO,IAAI,CAAA;IACxF,MAAM,KAAK,GAAG,WAAW,CAAC,SAAS,CAAC,CAAA;IACpC,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAA;IACvB,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACtC,MAAM,IAAI,GAAG,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IACzC,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,CAAC,CAAA;IACpC,IAAI,IAAI,CAAC,MAAM,GAAG,QAAQ;QAAE,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,2BAA2B,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,CAAA;IACxH,OAAO,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;AAC3E,CAAC","sourcesContent":["/*\n * A table pasted into the composer, carried as a file (design/ai/data-entry.md §4-1, design/ai/shared-dock.md §9-5).\n *\n * Rows copied from a spreadsheet or a web page are what an AI 입력 is made from most often. Pasted as words they\n * reach the model as something the person said, and the entry card cannot check a row against them nor read a\n * printed total. Carried as a CSV file they are a source like an attached sheet: each row is found on its line.\n *\n * - The HTML of the clipboard is read first when it holds a table - a spreadsheet and a browser both put one there,\n * and it keeps a cell that holds a line break or a tab whole. A web page whose words lie mostly outside the table\n * is not a table paste; it is left as words.\n * - Otherwise the plain text is a table when its lines are tab-separated (a spreadsheet's own text).\n * - The file has the shape of a read sheet: a line naming it, then every row led by its own number.\n * - The limit is on the text, as for a sheet - a table over it is refused, never cut.\n *\n * Pure: the screen hands in the clipboard's strings.\n */\nimport { textCharsOf, type AttachmentPolicy } from './attachment-policy.js'\nimport { csvField } from './spreadsheet-text.js'\n\nexport interface PastedTable {\n rows: string[][]\n columns: number\n}\n\n/** Words outside the table beyond this are a page that holds a table, not a table. */\nconst WORDS_OUTSIDE_A_TABLE = 20\n\nconst ENTITIES: Record<string, string> = { nbsp: ' ', amp: '&', lt: '<', gt: '>', quot: '\"', apos: \"'\", '#39': \"'\" }\n\nfunction decodeEntities(text: string): string {\n return text.replace(/&(#x[0-9a-f]+|#\\d+|[a-z]+\\d*|#39);/gi, (whole, name: string) => {\n const lower = name.toLowerCase()\n if (lower in ENTITIES) return ENTITIES[lower]\n if (lower.startsWith('#x')) return String.fromCodePoint(parseInt(lower.slice(2), 16))\n if (lower.startsWith('#')) return String.fromCodePoint(parseInt(lower.slice(1), 10))\n return whole\n })\n}\n\n/** What a piece of HTML shows as words - a line break and a cell's own breaks become one space. */\nfunction wordsOf(html: string): string {\n return decodeEntities(html.replace(/<br\\s*\\/?>/gi, ' ').replace(/<[^>]*>/g, ''))\n .replace(/\\s+/g, ' ')\n .trim()\n}\n\n/** What the clipboard's HTML shows, without what is never shown - comments, styles, scripts, the head. */\nfunction shownHtml(html: string): string {\n return html\n .replace(/<!--[\\s\\S]*?-->/g, '')\n .replace(/<(style|script|head)\\b[\\s\\S]*?<\\/\\1\\s*>/gi, '')\n}\n\n/** The rows of the tables in the clipboard's HTML, or null when it holds none or is mostly not a table. */\nexport function tableOfHtml(html: string | null | undefined): string[][] | null {\n if (!html || !/<table\\b/i.test(html)) return null\n const shown = shownHtml(html)\n const outside = wordsOf(shown.replace(/<table\\b[\\s\\S]*?<\\/table\\s*>/gi, ' '))\n if (outside.replace(/\\s/g, '').length > WORDS_OUTSIDE_A_TABLE) return null\n\n const rows: string[][] = []\n for (const part of shown.split(/<tr\\b[^>]*>/i).slice(1)) {\n const body = part.split(/<\\/table\\s*>/i)[0]\n const row: string[] = []\n for (const cell of body.matchAll(/<(td|th)\\b([^>]*)>([\\s\\S]*?)(?=<\\/?(?:td|th|tr)\\b|$)/gi)) {\n row.push(wordsOf(cell[3]))\n const span = Number(/\\bcolspan\\s*=\\s*[\"']?(\\d+)/i.exec(cell[2])?.[1] ?? 1)\n for (let more = 1; more < Math.min(span, 100); more++) row.push('')\n }\n if (row.some(text => text !== '')) rows.push(row)\n }\n return rows.length ? rows : null\n}\n\n/** The rows of a spreadsheet's plain text - tab-separated lines, a cell with a break or a tab in quotes. */\nexport function tableOfText(text: string | null | undefined): string[][] | null {\n if (!text || !text.includes('\\t')) return null\n const rows: string[][] = []\n let row: string[] = []\n let cell = ''\n let quoted = false\n for (let at = 0; at < text.length; at++) {\n const c = text[at]\n if (quoted) {\n if (c === '\"' && text[at + 1] === '\"') (cell += '\"'), at++\n else if (c === '\"') quoted = false\n else cell += c\n } else if (c === '\"' && cell === '') quoted = true\n else if (c === '\\t') row.push(cell), (cell = '')\n else if (c === '\\n' || c === '\\r') {\n if (c === '\\r' && text[at + 1] === '\\n') at++\n row.push(cell), rows.push(row), (row = []), (cell = '')\n } else cell += c\n }\n if (cell !== '' || row.length) row.push(cell), rows.push(row)\n const kept = rows.map(one => one.map(text => text.replace(/\\s+/g, ' ').trim())).filter(one => one.some(text => text !== ''))\n /* One tab in a sentence is not a table - most lines must be split into columns. */\n if (kept.filter(one => one.length > 1).length < Math.max(2, Math.ceil(kept.length / 2))) return null\n return kept\n}\n\n/** The table a paste holds, or null for words - at least two rows of at least two columns. */\nexport function pastedTable(clipboard: { html?: string | null; text?: string | null }): PastedTable | null {\n const fromHtml = tableOfHtml(clipboard.html)\n /* A page the HTML shows to be mostly words stays words - its plain text would read the table out of it anyway. */\n if (!fromHtml && clipboard.html && /<table\\b/i.test(clipboard.html)) return null\n for (const rows of [fromHtml, tableOfText(clipboard.text)]) {\n if (!rows) continue\n const trimmed = rows.map(row => {\n let cells = row\n while (cells.length && cells[cells.length - 1] === '') cells = cells.slice(0, -1)\n return cells\n })\n const columns = Math.max(...trimmed.map(row => row.length))\n if (trimmed.length >= 2 && columns >= 2) return { rows: trimmed, columns }\n }\n return null\n}\n\n/** The table as the text of its file: a line naming it, then every row led by its own number. */\nexport function pastedTableText(table: PastedTable, name: string): string {\n const lines = table.rows.map((row, i) => [String(i + 1), ...row].map(csvField).join(','))\n return [`# ${name} · a table the person pasted · the first column is the row number in the pasted table`, ...lines].join('\\n') + '\\n'\n}\n\nexport type PasteRefusal = { code: 'attachment-paste-too-long'; rows: number; maxChars: number }\n\n/**\n * What a paste becomes in a conversation under this policy: a table file, a refusal, or null - the paste stays words\n * (no table in it, or a conversation that takes no text files).\n */\nexport function pastedTableFile(\n clipboard: { html?: string | null; text?: string | null },\n policy: AttachmentPolicy | null | undefined,\n nameOf: (rows: number) => string\n): { name: string; text: string; table: PastedTable } | { refusal: PasteRefusal } | null {\n if (!policy?.kinds?.some(kind => kind === 'text' || kind === 'spreadsheet')) return null\n const table = pastedTable(clipboard)\n if (!table) return null\n const name = nameOf(table.rows.length)\n const text = pastedTableText(table, name)\n const maxChars = textCharsOf(policy)\n if (text.length > maxChars) return { refusal: { code: 'attachment-paste-too-long', rows: table.rows.length, maxChars } }\n return { name: `${name.replace(/[\\\\/:*?\"<>|]/g, '_')}.csv`, text, table }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pdf-pages.js","sourceRoot":"","sources":["../../client/utils/pdf-pages.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,4GAA4G;AAC5G,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAA;AAEnC,kCAAkC;AAClC,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,GAAQ,EAAE,MAAc;IACxD,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,M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\n * A PDF page drawn into an image - for a scanned page, whose text has to be read from its picture. The PDF is opened\n * through @operato/utils pdf-loader (document-text.ts reads the pages' text).\n */\n\n/** The longest side of a drawn page, in pixels - enough for a model to read print, small enough to send. */\nexport const PAGE_IMAGE_SIDE = 1600\n\n/** One page drawn into a JPEG. */\nexport async function drawPdfPage(pdf: any, number: number): Promise<Blob> {\n const page = await pdf.getPage(number)\n const base = page.getViewport({ scale: 1 })\n const viewport = page.getViewport({ scale: Math.min(2, PAGE_IMAGE_SIDE / Math.max(base.width, base.height)) })\n const canvas = document.createElement('canvas')\n canvas.width = Math.ceil(viewport.width)\n canvas.height = Math.ceil(viewport.height)\n const context = canvas.getContext('2d')!\n /* A page draws on transparent pixels; a JPEG would turn them black. */\n context.fillStyle = '#ffffff'\n context.fillRect(0, 0, canvas.width, canvas.height)\n await page.render({ canvas, canvasContext: context, viewport }).promise\n return await new Promise<Blob>((resolve, reject) =>\n canvas.toBlob(blob => (blob ? resolve(blob) : reject(new Error('the page could not be drawn'))), 'image/jpeg', 0.85)\n )\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spreadsheet-text.js","sourceRoot":"","sources":["../../client/utils/spreadsheet-text.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,MAAM,SAAS,GAAG,mEAAmE,CAAA;AACrF,MAAM,QAAQ,GAAG,0BAA0B,CAAA;AAE3C,wFAAwF;AACxF,MAAM,UAAU,iBAAiB,CAAC,IAAsC;IACtE,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAA;IAC5C,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAA;IAC5C,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;QAAE,OAAO,MAAM,CAAA;IAC/D,IAAI,IAA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et read into text the conversation can carry (design/ai/shared-dock.md §9-5).\n *\n * The door takes images and text only; a mode that opens 'spreadsheet' has the screen read each .xlsx sheet into\n * CSV before sending, so the model reads the sheet and the entry card can name where a row came from.\n *\n * - Read with exceljs. The old binary .xls is not read - it is refused by name (exceljs cannot open it, and the\n * npm SheetJS that can has unfixed flaws; a file a person uploads is not opened with it).\n * - A cell is its value - a formula as its computed result, a date as ISO, rich text as its text.\n * - Every line carries the sheet's own row number. Empty rows are left out, never renumbered, so \"sheet · row\" on a\n * card is the row the person sees in Excel.\n * - The limit is on the text after reading - a small .xlsx can be a long text. A sheet over it is refused, never cut:\n * a cut ledger is read as the whole ledger.\n */\n\nexport type SpreadsheetKind = 'xlsx' | 'xls'\n\nconst XLSX_TYPE = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'\nconst XLS_TYPE = 'application/vnd.ms-excel'\n\n/** A spreadsheet by its type, or by its name when the browser did not know the type. */\nexport function spreadsheetKindOf(file: { type?: string; name?: string }): SpreadsheetKind | null {\n const type = (file.type || '').toLowerCase()\n const name = (file.name || '').toLowerCase()\n if (type === XLSX_TYPE || name.endsWith('.xlsx')) return 'xlsx'\n if (type === XLS_TYPE || name.endsWith('.xls')) return 'xls'\n return null\n}\n\n/** The picker's `accept` for spreadsheets. */\nexport const SPREADSHEET_ACCEPT = ['.xlsx', XLSX_TYPE]\n\nconst pad = (n: number) => String(n).padStart(2, '0')\n\n/** One cell as text - what Excel shows as the value, not how it is stored. */\nexport function cellText(value: unknown): string {\n if (value === null || value === undefined) return ''\n if (value instanceof Date) {\n if (isNaN(value.getTime())) return ''\n const day = `${value.getUTCFullYear()}-${pad(value.getUTCMonth() + 1)}-${pad(value.getUTCDate())}`\n const h = value.getUTCHours()\n const m = value.getUTCMinutes()\n const s = value.getUTCSeconds()\n return h || m || s ? `${day}T${pad(h)}:${pad(m)}:${pad(s)}` : day\n }\n if (typeof value === 'object') {\n const v = value as any\n if ('result' in v) return cellText(v.result)\n if ('formula' in v || 'sharedFormula' in v) return ''\n if (Array.isArray(v.richText)) return v.richText.map((part: any) => part?.text ?? '').join('')\n if ('text' in v) return cellText(v.text)\n if ('error' in v) return String(v.error)\n return ''\n }\n return String(value)\n}\n\n/** One CSV field - quoted when it holds a comma, a quote or a line break. */\nexport const csvField = (text: string) => (/[\",\\n\\r]/.test(text) ? `\"${text.replace(/\"/g, '\"\"')}\"` : text)\n\nexport interface SheetRow {\n /** The row number in the sheet - 1 for Excel's first row. */\n number: number\n cells: unknown[]\n}\n\n/** One sheet as CSV: a line naming the file and sheet, then every non-empty row led by its own row number. */\nexport function sheetText(fileName: string, sheetName: string, rows: SheetRow[]): string {\n const lines = rows\n .map(row => ({ number: row.number, cells: row.cells.map(cellText) }))\n .filter(row => row.cells.some(cell => cell.trim() !== ''))\n .map(row => {\n let cells = row.cells\n while (cells.length && cells[cells.length - 1] === '') cells = cells.slice(0, -1)\n return [String(row.number), ...cells].map(csvField).join(',')\n })\n return [`# ${fileName} · sheet \"${sheetName}\" · the first column is the sheet's own row number`, ...lines].join('\\n') + '\\n'\n}\n\nexport interface SheetFile {\n name: string\n text: string\n}\n\nexport type SpreadsheetRefusal = { code: 'attachment-xls-not-read'; name: string } | { code: 'attachment-sheet-too-long'; name: string; maxChars: number } | { code: 'attachment-sheet-unreadable'; name: string }\n | { code: 'attachment-sheet-empty'; name: string }\n\n/** The file name a sheet travels under - \"거래내역.xlsx\" sheet \"9월\" → \"거래내역 - 9월.csv\". */\nexport function sheetFileName(fileName: string, sheetName: string): string {\n return `${fileName.replace(/\\.xlsx?$/i, '')} - ${sheetName.replace(/[\\\\/:*?\"<>|]/g, '_')}.csv`\n}\n\n/**\n * Every non-empty sheet of an .xlsx as text, or why not. `load` is exceljs's Workbook - passed in so the screen\n * loads the library only when a spreadsheet is attached.\n */\nexport async function readSpreadsheet(\n data: ArrayBuffer | Uint8Array,\n fileName: string,\n maxChars: number,\n Workbook: new () => any\n): Promise<{ files: SheetFile[] } | { refusal: SpreadsheetRefusal }> {\n const workbook = new Workbook()\n try {\n await workbook.xlsx.load(data)\n } catch {\n return { refusal: { code: 'attachment-sheet-unreadable', name: fileName } }\n }\n const files: SheetFile[] = []\n for (const sheet of workbook.worksheets) {\n const rows: SheetRow[] = []\n sheet.eachRow({ includeEmpty: false }, (row: any, number: number) => {\n const values = Array.isArray(row.values) ? row.values.slice(1) : []\n rows.push({ number, cells: values })\n })\n if (!rows.length) continue\n const text = sheetText(fileName, sheet.name, rows)\n const name = sheetFileName(fileName, sheet.name)\n if (text.length > maxChars) return { refusal: { code: 'attachment-sheet-too-long', name: `${fileName} · ${sheet.name}`, maxChars } }\n files.push({ name, text })\n }\n /* A workbook with nothing in it is said, not dropped: the person would think it was sent. */\n if (!files.length) return { refusal: { code: 'attachment-sheet-empty', name: fileName } }\n return { files }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"workspace.js","sourceRoot":"","sources":["../../client/utils/workspace.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAsBH,MAAM,UAAU,mBAAmB,CAAC,QAAa;IAC/C,OAAO,QAAQ,EAAE,IAAI,KAAK,WAAW,IAAI,CAAC,CAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAA;AACtE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAA4E,EAAE,IAAY;IAC1H,MAAM,QAAQ,GAAuB,EAAE,CAAA;IACvC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,KAAK,MAAM,QAAQ,IAAI,OAAO,CAAC,aAAa,IAAI,EAAE,EAAE,CAAC;YACnD,IAAI,mBAAmB,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,SAAS,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;gBACtE,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,EAAE,S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AG,CAAC,CAAC,CAAC,IAAI,CAAA;AACvE,CAAC,CAAA;AAED,oGAAoG;AACpG,MAAM,UAAU,QAAQ,CAAC,OAA2C,EAAE,IAA2B;IAC/F,MAAM,KAAK,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;IACrK,OAAO,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;AACjC,CAAC","sourcesContent":["/*\n * The AI 작업 패널 on the screen - which versions a workspace has, and the table's sort and CSV\n * (operato-application/design/ai/workspace.md). Pure - tested without a browser.\n */\n\nexport interface WorkspaceBlockView {\n kind: string\n [key: string]: any\n}\n\nexport interface WorkspaceView {\n name: string\n title: string\n summary?: string\n blocks: WorkspaceBlockView[]\n}\n\nexport interface WorkspaceVersion {\n /** 1-based, in the order the conversation made them. */\n version: number\n messageId: string\n createdAt?: string\n workspace: WorkspaceView\n}\n\nexport function isWorkspaceProposal(proposal: any): boolean {\n return proposal?.kind === 'workspace' && !!proposal?.workspace?.name\n}\n\n/**\n * Every version of the named workspace in a conversation, oldest first. A message the reader may not see\n * comes back redacted without its proposals, so a version behind a door is simply not among them.\n */\nexport function workspaceVersions(messages: { id: string; createdAt?: string; proposalsJson?: any[] | null }[], name: string): WorkspaceVersion[] {\n const versions: WorkspaceVersion[] = []\n for (const message of messages) {\n for (const proposal of message.proposalsJson ?? []) {\n if (isWorkspaceProposal(proposal) && proposal.workspace.name === name) {\n versions.push({ version: versions.length + 1, messageId: message.id, createdAt: message.createdAt, workspace: proposal.workspace })\n }\n }\n }\n return versions\n}\n\n/** The version of a card within its conversation - \"2 of 3\" on the card and on the page. */\nexport function versionOfCard(proposalsInOrder: any[][], name: string, key: string): { version: number; of: number } {\n let version = 0\n let of = 0\n for (const list of proposalsInOrder)\n for (const one of list ?? []) {\n if (!isWorkspaceProposal(one) || one.workspace.name !== name) continue\n of += 1\n if (one.key === key) version = of\n }\n return { version, of }\n}\n\nexport function workspaceAddress(sessionId: string, name: string, version?: number): string {\n const query = new URLSearchParams({ session: sessionId, name })\n if (version) query.set('version', String(version))\n return `assistant-workspace?${query.toString()}`\n}\n\n/** Sorts by one column - numbers as numbers, empty last, the rest by the reader's collation. */\nexport function sortRows(rows: Record<string, any>[], column: string, direction: 'asc' | 'desc', locale?: string): Record<string, any>[] {\n const factor = direction === 'asc' ? 1 : -1\n const collator = new Intl.Collator(locale, { numeric: true })\n return [...rows].sort((a, b) => {\n const x = a[column]\n const y = b[column]\n const emptyX = x === null || x === undefined || x === ''\n const emptyY = y === null || y === undefined || y === ''\n if (emptyX || emptyY) return emptyX === emptyY ? 0 : emptyX ? 1 : -1\n if (typeof x === 'number' && typeof y === 'number') return (x - y) * factor\n return collator.compare(String(x), String(y)) * factor\n })\n}\n\nconst csvCell = (value: unknown) => {\n const text = value === null || value === undefined ? '' : String(value)\n return /[\",\\n\\r]/.test(text) ? `\"${text.replace(/\"/g, '\"\"')}\"` : text\n}\n\n/** The table as CSV - the heading row in the column labels, a BOM so a spreadsheet reads Korean. */\nexport function tableCsv(columns: { name: string; label?: string }[], rows: Record<string, any>[]): string {\n const lines = [columns.map(column => csvCell(column.label || column.name)).join(','), ...rows.map(row => columns.map(column => csvCell(row[column.name])).join(','))]\n return '' + lines.join('\\r\\n')\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"door-declaration-report.js","sourceRoot":"","sources":["../server/door-declaration-report.ts"],"names":[],"mappings":";;AA4B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AAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAA;QAC5C,KAAK,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC,CAAA;QAC/C,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;IACjC,CAAC;IACD,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,kBAAkB,IAAI,KAAK,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AAC3G,CAAC","sourcesContent":["/*\n * 도구가 적어 둔 문이 **스키마에 있는 문인가** — 부팅에서 한 번 묻는다.\n *\n * ── 왜 등록기가 아니라 여기인가 ───────────────────────────────────────────\n * 이 물음은 AUTH 의 필드→권한 표(`privilegeOfField`, ADR-0072 결정 5)가 있어야 답할 수 있고, 그 표는\n * **스키마를 지은 뒤에** 찬다. 등록기는 모듈이 올라오는 동안 도니 그때는 표가 비어 있다. 부팅 보고는\n * 모든 모듈이 등록을 마치고 스키마가 선 뒤에 도는 자리다.\n *\n * ── 무엇을 가르나 ─────────────────────────────────────────────────────────\n * `tool-door-not-in-schema` 그런 루트 필드가 없다. 도구가 이름을 틀리게 적은 것이다 — 그 도구로\n * 만든 답은 **아무도 못 읽는다**(ADR-0073 판정 1 은 모르는 문을 닫는다).\n * 오타 하나가 그 대화의 답을 통째로 가린다.\n * `tool-door-has-no-privilege` 필드는 있고 아무것도 선언하지 않았다. 그 문이 열려 있으므로 그 답도\n * 도메인 안에서 열린다. 결함이 아니라 **사실**이고, 문의 차례다.\n *\n * 등록기의 같은 이름 경고와 묻는 것이 다르다. 등록기는 「도구가 문의 권한을 베껴 적었나」를 물었고,\n * 그 베끼기는 표가 서면서 없어진다(ADR-0072 결정 5). 여기서는 **문에 직접** 묻는다.\n */\nimport { getAllToolSpecs } from '@things-factory/ai-client-base'\nimport { privilegeOfField } from '@things-factory/auth-base'\n\nexport interface DoorDeclarationWarning {\n code: 'tool-door-not-in-schema' | 'tool-door-has-no-privilege'\n tool: string\n door: string\n}\n\n/** 등록된 도구들이 적어 둔 문을 스키마에 대어 본다. 스키마가 선 뒤에만 뜻이 있다. */\nexport function doorDeclarationWarnings(\n specs: ReadonlyArray<any> = getAllToolSpecs(),\n lookup: (typeName: string, fieldName: string) => { known: false } | { known: true; gate: unknown } = privilegeOfField\n): DoorDeclarationWarning[] {\n const out: DoorDeclarationWarning[] = []\n\n for (const spec of specs) {\n for (const door of spec?.doors ?? []) {\n const match = /^(Query|Mutation|Subscription)\\.([A-Za-z_][A-Za-z0-9_]*)$/.exec(String(door))\n if (!match) {\n out.push({ code: 'tool-door-not-in-schema', tool: spec.name, door: String(door) })\n continue\n }\n\n const asked = lookup(match[1], match[2])\n if (!asked.known) out.push({ code: 'tool-door-not-in-schema', tool: spec.name, door })\n else if (asked.gate === null) out.push({ code: 'tool-door-has-no-privilege', tool: spec.name, door })\n }\n }\n\n return out\n}\n\n/** 코드마다 한 줄 — 몇이고 어느 도구의 어느 문인가. */\nexport function formatDoorDeclarationWarnings(warnings: ReadonlyArray<DoorDeclarationWarning>): string[] {\n const byCode = new Map<string, string[]>()\n for (const warning of warnings) {\n const found = byCode.get(warning.code) ?? []\n found.push(`${warning.tool} → ${warning.door}`)\n byCode.set(warning.code, found)\n }\n return [...byCode].map(([code, found]) => `[ai-assistant] ${code} ×${found.length}: ${found.join(', ')}`)\n}\n"]}
|
package/dist-server/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,6DAAkC;AAClC,0CAAuC;AACvC,6HAA6H;AAC7H,yDAAsD;AAEtD,yDAA4D;AAC5D,mDAA4C;AAE5C,KAAK,MAAM,IAAI,IAAI,0BAAU;IAAE,IAAA,4BAAgB,EAAC,IAAI,CAAC,CAAA","sourcesContent":["/**\n * `@things-factory/ai-assistant` — **AI 대화의 집.**\n *\n * 세션·메시지·참가자·인박스·구독. 도메인을 모른다: 보드도, 공장도, 자산도.\n *\n * ── 왜 board-ai 에서 나왔나 (2026-09-10) ────────────────────────────────────\n * 시작한 물음은 하나였다. **「왜 board-ai 에 종속되어 있는가.」** 공장에 「지금 몇 대 밀렸나」를\n * 묻는 화면이 보드 편집 권한을 요구했고, 그 문 뒤에 스물다섯이 있는데 쓰는 것은 하나였다.\n *\n * 재 보니 문제는 「공통이냐 아니냐」가 아니었다 — `board-ui` 를 지나 **아홉 개 앱**이 이미 이\n * 기계를 싣고 있었다. 이미 공통이었고, 이름과 게이트만 보드 편집기의 것이었다.\n *\n * ── 자르는 선 ───────────────────────────────────────────────────────────────\n * 물음 하나로 줄였다: **「이것이 보드가 없는 제품에서도 뜻이 있나.」**\n *\n * 여기 세션·메시지·참가자·인박스·구독 인증·앵커\n * board-ai 보드 편집기 — assistant · 패치 · 프리팹 · 컴포넌트 트리 · 스타일링\n *\n * `assistant.ts`(113KB)는 **안 옮겼다.** 거의 전부 보드 편집이다. 가장 큰 파일이 제자리에 있다는\n * 뜻이고, 그래서 이 분리는 생각보다 작았다.\n *\n * ── 의존은 한쪽이다 ─────────────────────────────────────────────────────────\n * `board-ai → ai-assistant`. 반대는 없다. 그것을 위해 두 변을 먼저 끊었다 — `ChatSession` 의\n * 보드 패치 관계와, 리졸버 안에 섞여 있던 보드 op 여섯.\n *\n * 설계 정본은 `things-factory/docs/design/ai-modules.md`.\n */\nexport * from './service/index.js'\nimport './tool-registry-boot-report.js'\n/* The site, an application's home and a board are named without an application's help (design/ai/screen-pattern.md §2-1). */\nimport './service/assistant-mode/fallback-subjects.js'\n\nimport { registerRoleTask } from '@things-factory/auth-base'\nimport { ROLE_TASKS } from './role-tasks.js'\n\nfor (const task of ROLE_TASKS) registerRoleTask(task)\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"role-tasks.js","sourceRoot":"","sources":["../server/role-tasks.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAIU,QAAA,UAAU,GAAe;IACpC,EAAE,EAAE,EAAE,kBAAkB,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,CAAC,EAAE;CAChG,CAAA","sourcesContent":["/*\n * The work this module names, for the seats applications build (ADR-0139 decision 11).\n *\n * A task holds whole privileges: each opens everything its doors open, and the words under `task.<id>` in this\n * module's translations say what that is. Seats are put together by applications (`RoleTemplate.tasks`).\n *\n * Data only - `server/index.ts` registers it - so an application's tests read it without starting the framework.\n */\n\nimport type { RoleTask } from '@things-factory/auth-base'\n\nexport const ROLE_TASKS: RoleTask[] = [\n { id: 'ai-assistant.use', grants: [{ category: 'ai-assistant', axes: ['query', 'mutation'] }] }\n]\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ai-agent-resolver.js","sourceRoot":"","sources":["../../server/service/ai-agent-resolver.ts"],"names":[],"mappings":";;;;AAAA;;;;;;GAMG;AACH,+CAAmI;AACnI,qCAAkC;AAClC,iDAAqD;AACrD,mEAQuC;AAGvC,IAAM,aAAa,GAAnB,MAAM,aAAa;CAMlB,CAAA;AAJC;IADC,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,iBAAE,EAAE,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC;;yCACrC;AAGV;IADC,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC;;2CAC3B;AALR,aAAa;IADlB,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,2BAA2B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C,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM;QACzB,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAE;QACrC,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC;QACtC,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,cAAc;QAC3C,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;KAC5C,CAAA;AACH,CAAC","sourcesContent":["/*\n * The doors of a domain's AI agents (design/ai/agent-settings.md).\n *\n * The settings card reads and saves the agents of the domain it is in; the dock reads the agents a person may pick.\n * Everything here is a thin door over ai-client-base, which owns the agents, their keys and their usage. A key never\n * leaves the server: reads carry a hint of this domain's own key and nothing of a key from above.\n */\nimport { Arg, Ctx, Directive, Field, ID, InputType, Int, Mutation, ObjectType, Query, Resolver, UseMiddleware } from 'type-graphql'\nimport '@things-factory/auth-base'\nimport { SpeakRefusals } from '@things-factory/shell'\nimport {\n type AiAgentEntry,\n capabilityOf,\n listProviderModels,\n readAgentUsersBelow,\n readAiAgentDirectory,\n saveAiAgents,\n summarizeAiUsage\n} from '@things-factory/ai-client-base'\n\n@ObjectType({ description: 'A domain, by id and name.' })\nclass AiAgentDomain {\n @Field(() => ID, { description: 'Domain id.' })\n id: string\n\n @Field({ description: 'Domain name.' })\n name: string\n}\n\n@ObjectType({ description: 'One AI agent as the settings card shows it. The key itself is never here.' })\nclass AiAgentView {\n @Field(() => ID, { description: 'Agent id.' })\n id: string\n\n @Field({ description: 'The name a person picks it by.' })\n name: string\n\n @Field({ description: 'openai, anthropic or gemini.' })\n provider: string\n\n @Field({ description: 'The model it answers with.' })\n model: string\n\n @Field({ nullable: true, description: 'A gateway or proxy the provider is reached through.' })\n baseURL?: string\n\n @Field({ nullable: true, description: 'OpenAI organization.' })\n organization?: string\n\n @Field({ description: 'Off takes it out of this domain and every domain below.' })\n active: boolean\n\n @Field(() => AiAgentDomain, { description: 'The domain that declared it.' })\n owner: AiAgentDomain\n\n @Field({ description: 'Declared by a domain above. Read-only here.' })\n inherited: boolean\n\n @Field({ description: 'An inherited agent this domain does not use.' })\n turnedOff: boolean\n\n @Field({ description: 'own, inherited, overridden or missing - where the key that answers comes from.' })\n keyState: string\n\n @Field(() => AiAgentDomain, { nullable: true, description: 'The domain whose key answers.' })\n keyDomain?: AiAgentDomain\n\n @Field({ nullable: true, description: 'A hint of this domain\\'s own key, such as ••••abcd. Never given for a key from above.' })\n keyHint?: string\n\n @Field({ description: 'Active, used here, and has a key - a person can pick it.' })\n usable: boolean\n\n @Field({ description: 'The agent a person gets before picking one.' })\n isDefault: boolean\n\n @Field(() => [AiAgentDomain], { description: 'For this domain\\'s own agents: the domains below that use it.' })\n usedBelow: AiAgentDomain[]\n}\n\n@ObjectType({ description: 'A domain\\'s AI agents and how its AI stands.' })\nclass AiAgentSettings {\n @Field(() => [AiAgentDomain], { description: 'This domain and the domains above it, closest first.' })\n chain: AiAgentDomain[]\n\n @Field(() => [AiAgentView], { description: 'This domain\\'s agents, then each domain above\\'s, closest first.' })\n agents: AiAgentView[]\n\n @Field({ nullable: true, description: 'The agent a person gets before picking one.' })\n defaultAgentId?: string\n\n @Field({ description: 'own, inherited, first or none - how the default was decided.' })\n defaultFrom: string\n\n @Field({ description: 'configured or not-configured.' })\n state: string\n\n @Field({ nullable: true, description: 'Why it is not configured: no-agent, no-agent-key or no-usable-agent.' })\n reason?: string\n}\n\n@ObjectType({ description: 'An AI agent a person may pick in the dock.' })\nclass AiAgentChoice {\n @Field(() => ID, { description: 'Agent id - what assistantChat takes as agentId.' })\n id: string\n\n @Field({ description: 'The name a person picks it by.' })\n name: string\n\n @Field({ description: 'openai, anthropic or gemini.' })\n provider: string\n\n @Field({ description: 'The model it answers with.' })\n model: string\n\n @Field({ description: 'The agent a person gets before picking one.' })\n isDefault: boolean\n}\n\n@InputType({ description: 'One of this domain\\'s own agents as the settings card saves it.' })\nclass AiAgentInput {\n @Field(() => ID, { nullable: true, description: 'Empty for a new agent.' })\n id?: string\n\n @Field({ description: 'The name a person picks it by.' })\n name: string\n\n @Field({ description: 'openai, anthropic or gemini.' })\n provider: string\n\n @Field({ description: 'A model from aiProviderModels.' })\n model: string\n\n @Field({ nullable: true, description: 'A gateway or proxy the provider is reached through.' })\n baseURL?: string\n\n @Field({ nullable: true, description: 'OpenAI organization.' })\n organization?: string\n\n @Field({ description: 'Off takes it out of this domain and every domain below.' })\n active: boolean\n\n @Field({ nullable: true, description: 'A new API key. Left out, the stored key stays.' })\n apiKey?: string\n}\n\n@InputType({ description: 'This domain\\'s key for an agent it inherits.' })\nclass InheritedKeyInput {\n @Field(() => ID, { description: 'The inherited agent.' })\n agentId: string\n\n @Field({ nullable: true, description: 'A key of this domain to answer the agent with.' })\n apiKey?: string\n\n @Field({ nullable: true, description: 'Go back to the key of the domain above.' })\n clear?: boolean\n}\n\n@InputType({ description: 'A domain\\'s agents as the settings card saves them.' })\nclass AiAgentsInput {\n @Field(() => [AiAgentInput], { description: 'The whole list of this domain\\'s own agents. One left out is deleted.' })\n agents: AiAgentInput[]\n\n @Field({ nullable: true, description: 'This domain\\'s default - its own agent or an inherited one.' })\n defaultAgentId?: string\n\n @Field(() => [String], { nullable: true, description: 'Inherited agents this domain does not use.' })\n turnedOff?: string[]\n\n @Field(() => [InheritedKeyInput], { nullable: true, description: 'This domain\\'s keys for inherited agents.' })\n inheritedKeys?: InheritedKeyInput[]\n}\n\n@ObjectType({ description: 'AI usage of one bucket, agent and person.' })\nclass AiUsageBucket {\n @Field({ description: 'The hour, day or month in the domain\\'s time zone.' })\n bucket: string\n\n @Field({ nullable: true, description: 'Agent id.' })\n agentId?: string\n\n @Field({ nullable: true, description: 'Agent name. Empty for a deleted agent.' })\n agentName?: string\n\n @Field({ description: 'openai, anthropic or gemini.' })\n provider: string\n\n @Field({ description: 'The model the provider reported.' })\n model: string\n\n @Field({ description: 'The domain the calls were made in.' })\n domainId: string\n\n @Field({ description: 'Its name.' })\n domainName: string\n\n @Field({ nullable: true, description: 'The person. Empty for a domain below and for calls with no person.' })\n userId?: string\n\n @Field({ nullable: true, description: 'The person\\'s name.' })\n userName?: string\n\n @Field(() => Int, { description: 'Provider requests.' })\n calls: number\n\n @Field(() => Int, { description: 'Input tokens.' })\n inputTokens: number\n\n @Field(() => Int, { description: 'Output tokens.' })\n outputTokens: number\n\n @Field(() => Int, { description: 'Requests that failed.' })\n failures: number\n}\n\n@Resolver()\n@UseMiddleware(SpeakRefusals)\nexport class AiAgentResolver {\n @Query(() => AiAgentSettings, { description: 'This domain\\'s AI agents, the ones it inherits, and how its AI stands.' })\n @Directive('@privilege(category: \"setting\", privilege: \"query\", domainOwnerGranted: true)')\n async aiAgentSettings(@Ctx() context: ResolverContext): Promise<AiAgentSettings> {\n const { domain } = context.state\n const directory = await readAiAgentDirectory(domain)\n const nameOf = new Map(directory.chain.map(one => [one.id, one.name]))\n const ownIds = directory.entries.filter(one => !one.inherited).map(one => one.spec.id)\n const usedBelow = await readAgentUsersBelow(domain, ownIds)\n const capability = capabilityOf(directory)\n\n return {\n chain: directory.chain,\n agents: directory.entries.map(entry => agentView(entry, directory.defaultAgentId, nameOf, usedBelow.get(entry.spec.id) ?? [])),\n defaultAgentId: directory.defaultAgentId,\n defaultFrom: directory.defaultFrom,\n state: capability.state,\n reason: capability.reason\n }\n }\n\n @Query(() => [AiAgentChoice], { description: 'The AI agents a person may pick in the dock - usable ones only.' })\n @Directive('@privilege(category: \"ai-assistant\", privilege: \"query\", domainOwnerGranted: true)')\n async aiAgentChoices(@Ctx() context: ResolverContext): Promise<AiAgentChoice[]> {\n const directory = await readAiAgentDirectory(context.state.domain)\n return directory.entries\n .filter(one => one.usable)\n .map(one => ({\n id: one.spec.id,\n name: one.spec.name,\n provider: one.spec.provider,\n model: one.spec.model,\n isDefault: one.spec.id === directory.defaultAgentId\n }))\n }\n\n @Query(() => [String], {\n description:\n 'The conversation models a provider offers to a key - a typed key, or the stored key of one of this domain\\'s agents. A model is only ever picked from this list.'\n })\n @Directive('@privilege(category: \"setting\", privilege: \"query\", domainOwnerGranted: true)')\n async aiProviderModels(\n @Arg('provider') provider: string,\n @Arg('apiKey', { nullable: true }) apiKey: string,\n @Arg('agentId', { nullable: true }) agentId: string,\n @Arg('baseURL', { nullable: true }) baseURL: string,\n @Arg('organization', { nullable: true }) organization: string,\n @Ctx() context: ResolverContext\n ): Promise<string[]> {\n let key = apiKey?.trim()\n if (!key && agentId) {\n const directory = await readAiAgentDirectory(context.state.domain)\n key = directory.entries.find(one => one.spec.id === agentId && !one.inherited)?.apiKey\n }\n return listProviderModels({ provider, apiKey: key ?? '', baseURL, organization })\n }\n\n @Mutation(() => Boolean, {\n description: 'Saves this domain\\'s AI agents and their keys in one transaction. Read aiAgentSettings again for how they now stand.'\n })\n @Directive('@transaction')\n @Directive('@privilege(category: \"setting\", privilege: \"mutation\", domainOwnerGranted: true)')\n async saveAiAgents(@Arg('input', () => AiAgentsInput) input: AiAgentsInput, @Ctx() context: ResolverContext): Promise<boolean> {\n const { tx, domain, user } = context.state\n await saveAiAgents(input, { tx, domain, user })\n return true\n }\n\n @Query(() => [AiUsageBucket], {\n description:\n 'AI usage per bucket, agent and person, in this domain\\'s time zone. With includeDescendants, what the domains below did with this domain\\'s agents is added - per domain, without their people.'\n })\n @Directive('@privilege(category: \"setting\", privilege: \"query\", domainOwnerGranted: true)')\n async aiUsageSummary(\n @Arg('from') from: Date,\n @Arg('to') to: Date,\n @Arg('bucket', { defaultValue: 'day' }) bucket: string,\n @Arg('agentIds', () => [String], { nullable: true }) agentIds: string[],\n @Arg('userIds', () => [String], { nullable: true }) userIds: string[],\n @Arg('includeDescendants', { nullable: true }) includeDescendants: boolean,\n @Ctx() context: ResolverContext\n ): Promise<AiUsageBucket[]> {\n const size = bucket === 'hour' || bucket === 'month' ? bucket : 'day'\n return summarizeAiUsage(context.state.domain, { from, to, bucket: size, agentIds, userIds, includeDescendants: !!includeDescendants })\n }\n}\n\nfunction agentView(\n entry: AiAgentEntry,\n defaultAgentId: string | undefined,\n nameOf: Map<string, string>,\n usedBelow: { id: string; name: string }[]\n): AiAgentView {\n const domainOf = (id?: string) => (id ? { id, name: nameOf.get(id) ?? id } : undefined)\n return {\n id: entry.spec.id,\n name: entry.spec.name,\n provider: entry.spec.provider,\n model: entry.spec.model,\n baseURL: entry.spec.baseURL,\n organization: entry.spec.organization,\n active: entry.spec.active,\n owner: domainOf(entry.ownerDomainId)!,\n inherited: entry.inherited,\n turnedOff: entry.turnedOff,\n keyState: entry.keyState,\n keyDomain: domainOf(entry.keyDomainId),\n keyHint: entry.keyHint,\n usable: entry.usable,\n isDefault: entry.spec.id === defaultAgentId,\n usedBelow: entry.inherited ? [] : usedBelow\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"assistant-capability-resolver.js","sourceRoot":"","sources":["../../server/service/assistant-capability-resolver.ts"],"names":[],"mappings":";;;;AAAA;;;;;;;;;;GAUG;AACH,+CAAiF;AACjF,qDAA6C;AAC7C,qCAAkC;AAElC,mEAAsF;AAEtF,wDAAoE;AAGpE,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;CAS1B,CAAA;AAPC;IADC,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,iEAAiE,EAAE,CAAC;;mDAC9E;AAGZ;IADC,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,6BAAW,EAAE,EAAE,WAAW,EAAE,+DAA+D,EAAE,CAAC;;qDAChG;AAGX;IADC,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,6DAA6D,EAAE,CAAC;;sDACvE;AARX,qBAAqB;IAD1B,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,QAAQ,EAAsB,CAAA;IACxD,CAAC;CACF,CAAA;AAfY,kEAA2B;AAKhC;IAJL,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,gBAAgB,EAAE;QAC7B,WAAW,EAAE,iKAAiK;KAC/K,CAAC;IACD,IAAA,wBAAS,EAAC,oFAAoF,CAAC;IAC5E,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;+DASxB;sCAdU,2BAA2B;IADvC,IAAA,uBAAQ,GAAE;GACE,2BAA2B,CAevC","sourcesContent":["/*\n * One window for one question: what state is this deployment's AI in.\n *\n * Two things were being answered by failure or by a log line — whether a provider is configured at\n * all (standard A7-a), and which registrations are not yet what the contracts ask for (A1 stage one,\n * and the modes' `/` sentences). They are the same question asked by different people, so they come\n * back together, as codes.\n *\n * A screen reads this **before** offering to ask the assistant. It is a query: reading what a\n * deployment can do is reading.\n */\nimport { Ctx, Directive, Field, ObjectType, Query, Resolver } from 'type-graphql'\nimport { GraphQLJSON } from 'graphql-scalars'\nimport '@things-factory/auth-base'\n\nimport { aiCapability, getToolRegistryWarnings } from '@things-factory/ai-client-base'\n\nimport { getAssistantModeWarnings } from './assistant-mode/index.js'\n\n@ObjectType({ description: 'A registration that was accepted but is not yet what the contract asks for.' })\nclass AiRegistrationWarning {\n @Field({ description: 'What is missing, as a code — never prose a screen has to parse.' })\n code: string\n\n @Field(() => GraphQLJSON, { description: 'Which registration it is about (category, tool, mode, slash).' })\n params: any\n\n @Field({ description: 'The same thing in a sentence, for whoever reads a boot log.' })\n message: string\n}\n\n@ObjectType({ description: \"Whether this domain has an AI, and what the registrations are missing.\" })\nclass AiCapabilityView {\n @Field({ description: \"'configured' or 'not-configured'. A screen that has not asked yet knows a third state of its own: it does not know.\" })\n state: string\n\n @Field({ nullable: true, description: 'The provider of the domain\\'s default AI agent.' })\n provider?: string\n\n @Field({ nullable: true, description: 'The model of the domain\\'s default AI agent.' })\n model?: string\n\n @Field({ nullable: true, description: 'Why it is not configured: no-agent · no-agent-key · no-usable-agent.' })\n reason?: string\n\n @Field(() => [AiRegistrationWarning], { description: 'Tools with no declared privilege, and modes offering work their tools cannot do.' })\n warnings: AiRegistrationWarning[]\n}\n\n@Resolver()\nexport class AssistantCapabilityResolver {\n @Query(() => AiCapabilityView, {\n description: 'Whether this domain has a usable AI agent, and which registrations are incomplete. Read this before offering to ask the assistant — do not find out by failing.'\n })\n @Directive('@privilege(category: \"ai-assistant\", privilege: \"query\", domainOwnerGranted: true)')\n async aiCapability(@Ctx() context: any): Promise<AiCapabilityView> {\n const capability = await aiCapability(context.state.domain)\n const warnings = [...getToolRegistryWarnings(), ...getAssistantModeWarnings()].map(warning => ({\n code: warning.code,\n params: warning.params,\n message: warning.message\n }))\n\n return { ...capability, warnings } as AiCapabilityView\n }\n}\n"]}
|