@things-factory/ai-assistant 10.1.278 → 10.1.279
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-client/bootstrap.d.ts +4 -4
- package/dist-client/bootstrap.js +4 -8
- package/dist-client/components/ai-model-price-table.d.ts +32 -0
- package/dist-client/components/ai-model-price-table.js +311 -0
- package/dist-client/components/ai-usage-table.d.ts +17 -0
- package/dist-client/components/ai-usage-table.js +151 -0
- package/dist-client/index.d.ts +1 -0
- package/dist-client/index.js +2 -0
- package/dist-client/pages/ai-model-price-page.d.ts +37 -0
- package/dist-client/pages/ai-model-price-page.js +312 -0
- package/dist-client/route.d.ts +1 -1
- package/dist-client/route.js +4 -0
- package/dist-client/settings/ai-agent-setting-let.js +11 -0
- package/dist-client/utils/model-price-model.d.ts +31 -0
- package/dist-client/utils/model-price-model.js +30 -0
- package/dist-client/utils/usage-charts.d.ts +21 -0
- package/dist-client/utils/usage-charts.js +45 -0
- package/dist-client/utils/usage-model.d.ts +44 -0
- package/dist-client/utils/usage-model.js +44 -0
- package/dist-server/service/ai-agent-resolver.d.ts +46 -0
- package/dist-server/service/ai-agent-resolver.js +252 -0
- package/package.json +25 -10
- package/things-factory.config.js +4 -1
- package/translations/en.json +46 -4
- package/translations/es.json +43 -1
- package/translations/ja.json +43 -1
- package/translations/ko.json +46 -4
- package/translations/ms.json +43 -1
- package/translations/zh.json +43 -1
- package/client/bootstrap.ts +0 -27
- package/client/components/assistant-chat.test.ts +0 -149
- package/client/components/assistant-chat.ts +0 -5599
- package/client/components/assistant-dock.ts +0 -1036
- package/client/components/assistant-invite.ts +0 -138
- package/client/components/assistant-mode.test.ts +0 -119
- package/client/components/assistant-mode.ts +0 -174
- package/client/components/assistant-selection-bar.test.ts +0 -167
- package/client/components/assistant-selection-bar.ts +0 -178
- package/client/components/assistant-session-manager.ts +0 -915
- package/client/components/assistant-session-toolbar.ts +0 -80
- package/client/components/chat-defaults.ts +0 -64
- package/client/components/chat-echo-dedup.test.ts +0 -253
- package/client/components/chat-echo-dedup.ts +0 -190
- package/client/components/chat-input-builder.test.ts +0 -86
- package/client/components/chat-input-builder.ts +0 -133
- package/client/components/chat-proposal-survival.test.ts +0 -73
- package/client/components/entry-review.ts +0 -346
- package/client/components/markdown.test.ts +0 -518
- package/client/components/markdown.ts +0 -508
- package/client/components/mention-popup-helpers.ts +0 -433
- package/client/components/mention-popup.test.ts +0 -588
- package/client/components/mention-popup.ts +0 -261
- package/client/components/panel-aria.test.ts +0 -59
- package/client/components/proposal-outcome-line.ts +0 -74
- package/client/components/proposal-request.test.ts +0 -73
- package/client/components/reply-message.test.ts +0 -15
- package/client/components/reply-message.ts +0 -11
- package/client/components/roster-identity.test.ts +0 -8
- package/client/components/roster-identity.ts +0 -4
- package/client/components/workspace-view.ts +0 -486
- package/client/index.ts +0 -36
- package/client/pages/assistant-workspace-page.ts +0 -317
- package/client/route.ts +0 -9
- package/client/settings/agent-settings-model.ts +0 -164
- package/client/settings/ai-agent-setting-let.ts +0 -667
- package/client/settings/ai-usage-setting-let.ts +0 -240
- package/client/settings/usage-model.ts +0 -46
- package/client/setup-assistant-dock.ts +0 -177
- package/client/tsconfig.json +0 -13
- package/client/utils/addressed-draft.test.ts +0 -31
- package/client/utils/agent-choice.ts +0 -56
- package/client/utils/applied-screens.ts +0 -36
- package/client/utils/assistant-activity.ts +0 -122
- package/client/utils/assistant-ask.test.ts +0 -38
- package/client/utils/assistant-ask.ts +0 -93
- package/client/utils/assistant-capability-read.ts +0 -24
- package/client/utils/assistant-capability.test.ts +0 -17
- package/client/utils/assistant-capability.ts +0 -19
- package/client/utils/assistant-navigation.test.ts +0 -66
- package/client/utils/assistant-navigation.ts +0 -11
- package/client/utils/assistant-proposals.ts +0 -85
- package/client/utils/assistant-request-context.ts +0 -63
- package/client/utils/assistant-selection.test.ts +0 -54
- package/client/utils/assistant-selection.ts +0 -75
- package/client/utils/assistant-session-actions.ts +0 -32
- package/client/utils/assistant-session-admin.ts +0 -239
- package/client/utils/assistant-session-controller.test.ts +0 -75
- package/client/utils/assistant-session-controller.ts +0 -208
- package/client/utils/assistant-session-transport.ts +0 -46
- package/client/utils/assistant-surface.ts +0 -178
- package/client/utils/assistant-typing.test.ts +0 -33
- package/client/utils/assistant-typing.ts +0 -53
- package/client/utils/attachment-policy.ts +0 -106
- package/client/utils/composer-frame.ts +0 -77
- package/client/utils/document-text.ts +0 -332
- package/client/utils/entry-hash.ts +0 -35
- package/client/utils/entry-proposal.ts +0 -215
- package/client/utils/entry-workspace.ts +0 -70
- package/client/utils/invite-proposal-register.ts +0 -31
- package/client/utils/invite-proposal.test.ts +0 -40
- package/client/utils/invite-proposal.ts +0 -54
- package/client/utils/menu-room.ts +0 -33
- package/client/utils/open-page.ts +0 -21
- package/client/utils/pasted-table.ts +0 -145
- package/client/utils/pdf-pages.ts +0 -25
- package/client/utils/spreadsheet-text.ts +0 -125
- package/client/utils/workspace.ts +0 -89
- package/dist-client/bootstrap.js.map +0 -1
- package/dist-client/components/assistant-chat.js.map +0 -1
- package/dist-client/components/assistant-chat.test.d.ts +0 -1
- package/dist-client/components/assistant-chat.test.js +0 -138
- package/dist-client/components/assistant-chat.test.js.map +0 -1
- package/dist-client/components/assistant-dock.js.map +0 -1
- package/dist-client/components/assistant-invite.js.map +0 -1
- package/dist-client/components/assistant-mode.js.map +0 -1
- package/dist-client/components/assistant-mode.test.d.ts +0 -1
- package/dist-client/components/assistant-mode.test.js +0 -100
- package/dist-client/components/assistant-mode.test.js.map +0 -1
- package/dist-client/components/assistant-selection-bar.js.map +0 -1
- package/dist-client/components/assistant-selection-bar.test.d.ts +0 -1
- package/dist-client/components/assistant-selection-bar.test.js +0 -148
- package/dist-client/components/assistant-selection-bar.test.js.map +0 -1
- package/dist-client/components/assistant-session-manager.js.map +0 -1
- package/dist-client/components/assistant-session-toolbar.js.map +0 -1
- package/dist-client/components/chat-defaults.js.map +0 -1
- package/dist-client/components/chat-echo-dedup.js.map +0 -1
- package/dist-client/components/chat-echo-dedup.test.d.ts +0 -1
- package/dist-client/components/chat-echo-dedup.test.js +0 -223
- package/dist-client/components/chat-echo-dedup.test.js.map +0 -1
- package/dist-client/components/chat-input-builder.js.map +0 -1
- package/dist-client/components/chat-input-builder.test.d.ts +0 -1
- package/dist-client/components/chat-input-builder.test.js +0 -70
- package/dist-client/components/chat-input-builder.test.js.map +0 -1
- package/dist-client/components/chat-proposal-survival.test.d.ts +0 -1
- package/dist-client/components/chat-proposal-survival.test.js +0 -61
- package/dist-client/components/chat-proposal-survival.test.js.map +0 -1
- package/dist-client/components/entry-review.js.map +0 -1
- package/dist-client/components/markdown.js.map +0 -1
- package/dist-client/components/markdown.test.d.ts +0 -1
- package/dist-client/components/markdown.test.js +0 -418
- package/dist-client/components/markdown.test.js.map +0 -1
- package/dist-client/components/mention-popup-helpers.js.map +0 -1
- package/dist-client/components/mention-popup.js.map +0 -1
- package/dist-client/components/mention-popup.test.d.ts +0 -1
- package/dist-client/components/mention-popup.test.js +0 -474
- package/dist-client/components/mention-popup.test.js.map +0 -1
- package/dist-client/components/panel-aria.test.d.ts +0 -1
- package/dist-client/components/panel-aria.test.js +0 -53
- package/dist-client/components/panel-aria.test.js.map +0 -1
- package/dist-client/components/proposal-outcome-line.js.map +0 -1
- package/dist-client/components/proposal-request.test.d.ts +0 -1
- package/dist-client/components/proposal-request.test.js +0 -63
- package/dist-client/components/proposal-request.test.js.map +0 -1
- package/dist-client/components/reply-message.js.map +0 -1
- package/dist-client/components/reply-message.test.d.ts +0 -1
- package/dist-client/components/reply-message.test.js +0 -16
- package/dist-client/components/reply-message.test.js.map +0 -1
- package/dist-client/components/roster-identity.js.map +0 -1
- package/dist-client/components/roster-identity.test.d.ts +0 -1
- package/dist-client/components/roster-identity.test.js +0 -9
- package/dist-client/components/roster-identity.test.js.map +0 -1
- package/dist-client/components/workspace-view.js.map +0 -1
- package/dist-client/index.js.map +0 -1
- package/dist-client/pages/assistant-workspace-page.js.map +0 -1
- package/dist-client/route.js.map +0 -1
- package/dist-client/settings/agent-settings-model.js.map +0 -1
- package/dist-client/settings/ai-agent-setting-let.js.map +0 -1
- package/dist-client/settings/ai-usage-setting-let.d.ts +0 -25
- package/dist-client/settings/ai-usage-setting-let.js +0 -258
- package/dist-client/settings/ai-usage-setting-let.js.map +0 -1
- package/dist-client/settings/usage-model.d.ts +0 -32
- package/dist-client/settings/usage-model.js +0 -25
- package/dist-client/settings/usage-model.js.map +0 -1
- package/dist-client/setup-assistant-dock.js.map +0 -1
- package/dist-client/tsconfig.tsbuildinfo +0 -1
- package/dist-client/utils/addressed-draft.test.d.ts +0 -1
- package/dist-client/utils/addressed-draft.test.js +0 -27
- package/dist-client/utils/addressed-draft.test.js.map +0 -1
- package/dist-client/utils/agent-choice.js.map +0 -1
- package/dist-client/utils/applied-screens.js.map +0 -1
- package/dist-client/utils/assistant-activity.js.map +0 -1
- package/dist-client/utils/assistant-ask.js.map +0 -1
- package/dist-client/utils/assistant-ask.test.d.ts +0 -1
- package/dist-client/utils/assistant-ask.test.js +0 -40
- package/dist-client/utils/assistant-ask.test.js.map +0 -1
- package/dist-client/utils/assistant-capability-read.js.map +0 -1
- package/dist-client/utils/assistant-capability.js.map +0 -1
- package/dist-client/utils/assistant-capability.test.d.ts +0 -1
- package/dist-client/utils/assistant-capability.test.js +0 -16
- package/dist-client/utils/assistant-capability.test.js.map +0 -1
- package/dist-client/utils/assistant-navigation.js.map +0 -1
- package/dist-client/utils/assistant-navigation.test.d.ts +0 -1
- package/dist-client/utils/assistant-navigation.test.js +0 -63
- package/dist-client/utils/assistant-navigation.test.js.map +0 -1
- package/dist-client/utils/assistant-proposals.js.map +0 -1
- package/dist-client/utils/assistant-request-context.js.map +0 -1
- package/dist-client/utils/assistant-selection.js.map +0 -1
- package/dist-client/utils/assistant-selection.test.d.ts +0 -1
- package/dist-client/utils/assistant-selection.test.js +0 -46
- package/dist-client/utils/assistant-selection.test.js.map +0 -1
- package/dist-client/utils/assistant-session-actions.js.map +0 -1
- package/dist-client/utils/assistant-session-admin.js.map +0 -1
- package/dist-client/utils/assistant-session-controller.js.map +0 -1
- package/dist-client/utils/assistant-session-controller.test.d.ts +0 -1
- package/dist-client/utils/assistant-session-controller.test.js +0 -56
- package/dist-client/utils/assistant-session-controller.test.js.map +0 -1
- package/dist-client/utils/assistant-session-transport.js.map +0 -1
- package/dist-client/utils/assistant-surface.js.map +0 -1
- package/dist-client/utils/assistant-typing.js.map +0 -1
- package/dist-client/utils/assistant-typing.test.d.ts +0 -1
- package/dist-client/utils/assistant-typing.test.js +0 -30
- package/dist-client/utils/assistant-typing.test.js.map +0 -1
- package/dist-client/utils/attachment-policy.js.map +0 -1
- package/dist-client/utils/composer-frame.js.map +0 -1
- package/dist-client/utils/document-text.js.map +0 -1
- package/dist-client/utils/entry-hash.js.map +0 -1
- package/dist-client/utils/entry-proposal.js.map +0 -1
- package/dist-client/utils/entry-workspace.js.map +0 -1
- package/dist-client/utils/invite-proposal-register.js.map +0 -1
- package/dist-client/utils/invite-proposal.js.map +0 -1
- package/dist-client/utils/invite-proposal.test.d.ts +0 -1
- package/dist-client/utils/invite-proposal.test.js +0 -35
- package/dist-client/utils/invite-proposal.test.js.map +0 -1
- package/dist-client/utils/menu-room.js.map +0 -1
- package/dist-client/utils/open-page.js.map +0 -1
- package/dist-client/utils/pasted-table.js.map +0 -1
- package/dist-client/utils/pdf-pages.js.map +0 -1
- package/dist-client/utils/spreadsheet-text.js.map +0 -1
- package/dist-client/utils/workspace.js.map +0 -1
- package/dist-server/door-declaration-report.js.map +0 -1
- package/dist-server/index.js.map +0 -1
- package/dist-server/role-tasks.js.map +0 -1
- package/dist-server/service/ai-agent-resolver.js.map +0 -1
- package/dist-server/service/assistant-capability-resolver.js.map +0 -1
- package/dist-server/service/assistant-chat-resolver.js.map +0 -1
- package/dist-server/service/assistant-mode/assistant-mode-resolver.js.map +0 -1
- package/dist-server/service/assistant-mode/fallback-subjects.js.map +0 -1
- package/dist-server/service/assistant-mode/index.js.map +0 -1
- package/dist-server/service/assistant-mode/mode-categories.js.map +0 -1
- package/dist-server/service/assistant-mode/record-subject.js.map +0 -1
- package/dist-server/service/assistant-mode/registry.js.map +0 -1
- package/dist-server/service/assistant-mode/resolve.js.map +0 -1
- package/dist-server/service/assistant-mode/screen-rules.js.map +0 -1
- package/dist-server/service/assistant-mode/turn-lines.js.map +0 -1
- package/dist-server/service/assistant-mode/types.js.map +0 -1
- package/dist-server/service/chat-message/carried-turns.js.map +0 -1
- package/dist-server/service/chat-message/chat-message-broadcast.js.map +0 -1
- package/dist-server/service/chat-message/chat-message-publish.js.map +0 -1
- package/dist-server/service/chat-message/chat-message-room.js.map +0 -1
- package/dist-server/service/chat-message/chat-message-subscription.js.map +0 -1
- package/dist-server/service/chat-message/chat-message.js.map +0 -1
- package/dist-server/service/chat-message/chat-typing-subscription.js.map +0 -1
- package/dist-server/service/chat-message/chat-typing.js.map +0 -1
- package/dist-server/service/chat-message/door-access.js.map +0 -1
- package/dist-server/service/chat-message/fold-history.js.map +0 -1
- package/dist-server/service/chat-message/fold-session-history.js.map +0 -1
- package/dist-server/service/chat-message/history-summary.js.map +0 -1
- package/dist-server/service/chat-message/index.js.map +0 -1
- package/dist-server/service/chat-message/llm-history.js.map +0 -1
- package/dist-server/service/chat-message/message-doors.js.map +0 -1
- package/dist-server/service/chat-message/proposal-outcome.js.map +0 -1
- package/dist-server/service/chat-message/reader-gate.js.map +0 -1
- package/dist-server/service/chat-message/room-message.js.map +0 -1
- package/dist-server/service/chat-message/room-turn.js.map +0 -1
- package/dist-server/service/chat-message/used-tools.js.map +0 -1
- package/dist-server/service/chat-session/attachment-policy.js.map +0 -1
- package/dist-server/service/chat-session/attachment-route.js.map +0 -1
- package/dist-server/service/chat-session/attachment-tool-result.js.map +0 -1
- package/dist-server/service/chat-session/attachment-tools.js.map +0 -1
- package/dist-server/service/chat-session/chat-session.js.map +0 -1
- package/dist-server/service/chat-session/index.js.map +0 -1
- package/dist-server/service/chat-session/session-activity-broadcast.js.map +0 -1
- package/dist-server/service/chat-session/session-activity-publish.js.map +0 -1
- package/dist-server/service/chat-session/session-activity-subscription.js.map +0 -1
- package/dist-server/service/chat-session/session-anchor.js.map +0 -1
- package/dist-server/service/chat-session/session-attachments.js.map +0 -1
- package/dist-server/service/chat-session/session-cleanup.js.map +0 -1
- package/dist-server/service/chat-session/session-inbox.js.map +0 -1
- package/dist-server/service/chat-session/session-kind.js.map +0 -1
- package/dist-server/service/chat-session/session-name.js.map +0 -1
- package/dist-server/service/chat-session/session-purge.js.map +0 -1
- package/dist-server/service/chat-session/session-retention.js.map +0 -1
- package/dist-server/service/chat-session/session-visibility.js.map +0 -1
- package/dist-server/service/chat-session/session-write-gate.js.map +0 -1
- package/dist-server/service/chat-session/station-session-guard.js.map +0 -1
- package/dist-server/service/chat-session/turn-attachments.js.map +0 -1
- package/dist-server/service/chat-session-participant/chat-session-participant.js.map +0 -1
- package/dist-server/service/chat-session-participant/index.js.map +0 -1
- package/dist-server/service/chat-session-participant/invite-notification.js.map +0 -1
- package/dist-server/service/chat-session-participant/mention-invite.js.map +0 -1
- package/dist-server/service/chat-session-participant/participant-lookup-roles.js.map +0 -1
- package/dist-server/service/chat-session-participant/participant-lookup.js.map +0 -1
- package/dist-server/service/chat-session-participant/presence.js.map +0 -1
- package/dist-server/service/chat-session-participant/read-roster.js.map +0 -1
- package/dist-server/service/chat-session-resolver.js.map +0 -1
- package/dist-server/service/data-entry/entry-apply.js.map +0 -1
- package/dist-server/service/data-entry/entry-hash.js.map +0 -1
- package/dist-server/service/data-entry/entry-refusal.js.map +0 -1
- package/dist-server/service/data-entry/entry-resolver.js.map +0 -1
- package/dist-server/service/data-entry/entry-screen.js.map +0 -1
- package/dist-server/service/data-entry/entry-sources.js.map +0 -1
- package/dist-server/service/data-entry/entry-target.js.map +0 -1
- package/dist-server/service/data-entry/entry-tools.js.map +0 -1
- package/dist-server/service/data-entry/entry-update.js.map +0 -1
- package/dist-server/service/data-read/list-read.js.map +0 -1
- package/dist-server/service/data-read/read-target.js.map +0 -1
- package/dist-server/service/data-read/read-tools.js.map +0 -1
- package/dist-server/service/grounding-sources.js.map +0 -1
- package/dist-server/service/help-documents/help-keys.js.map +0 -1
- package/dist-server/service/help-documents/help-tools.js.map +0 -1
- package/dist-server/service/index.js.map +0 -1
- package/dist-server/service/people/index.js.map +0 -1
- package/dist-server/service/people/invite-tools.js.map +0 -1
- package/dist-server/service/people/people-keys.js.map +0 -1
- package/dist-server/service/people/people-read.js.map +0 -1
- package/dist-server/service/people/person-subject.js.map +0 -1
- package/dist-server/service/request-translator.js.map +0 -1
- package/dist-server/service/testing/conversation-script.js.map +0 -1
- package/dist-server/service/testing/mode-conformance.js.map +0 -1
- package/dist-server/service/tool-access.js.map +0 -1
- package/dist-server/service/types.js.map +0 -1
- package/dist-server/service/unattended-run/assistant-run.js.map +0 -1
- package/dist-server/service/unattended-run/index.js.map +0 -1
- package/dist-server/service/unattended-run/limits.js.map +0 -1
- package/dist-server/service/unattended-run/run-as.js.map +0 -1
- package/dist-server/service/unattended-run/run-budget.js.map +0 -1
- package/dist-server/service/unattended-run/run-ledger.js.map +0 -1
- package/dist-server/service/unattended-run/run-outcome.js.map +0 -1
- package/dist-server/service/unattended-run/run-store.js.map +0 -1
- package/dist-server/service/unattended-run/run-unattended.js.map +0 -1
- package/dist-server/service/unattended-run/unattended-prompt.js.map +0 -1
- package/dist-server/service/workspace/workspace-blocks.js.map +0 -1
- package/dist-server/service/workspace/workspace-tools.js.map +0 -1
- package/dist-server/tool-registry-boot-report.js.map +0 -1
- package/dist-server/tsconfig.tsbuildinfo +0 -1
- package/docs/session-controller.md +0 -52
- package/server/door-declaration-report.test.ts +0 -53
- package/server/door-declaration-report.ts +0 -61
- package/server/explicit-graphql-types.test.ts +0 -56
- package/server/index.ts +0 -36
- package/server/role-tasks.ts +0 -14
- package/server/service/ai-agent-resolver.ts +0 -330
- package/server/service/assistant-capability-resolver.ts +0 -66
- package/server/service/assistant-chat-resolver.ts +0 -640
- package/server/service/assistant-mode/assistant-mode-resolver.ts +0 -101
- package/server/service/assistant-mode/conversation-category.test.ts +0 -48
- package/server/service/assistant-mode/fallback-subjects.ts +0 -36
- package/server/service/assistant-mode/index.ts +0 -22
- package/server/service/assistant-mode/mode-categories.ts +0 -178
- package/server/service/assistant-mode/mode-front.test.ts +0 -183
- package/server/service/assistant-mode/one-conversation-per-subject.test.ts +0 -37
- package/server/service/assistant-mode/open-subject-door.test.ts +0 -52
- package/server/service/assistant-mode/record-subject.test.ts +0 -41
- package/server/service/assistant-mode/record-subject.ts +0 -44
- package/server/service/assistant-mode/registry.test.ts +0 -171
- package/server/service/assistant-mode/registry.ts +0 -139
- package/server/service/assistant-mode/resolve.test.ts +0 -129
- package/server/service/assistant-mode/resolve.ts +0 -113
- package/server/service/assistant-mode/screen-rules.test.ts +0 -99
- package/server/service/assistant-mode/screen-rules.ts +0 -103
- package/server/service/assistant-mode/turn-lines.ts +0 -43
- package/server/service/assistant-mode/types.ts +0 -138
- package/server/service/chat-message/carried-turns.test.ts +0 -80
- package/server/service/chat-message/carried-turns.ts +0 -112
- package/server/service/chat-message/chat-message-broadcast.integration.test.ts +0 -73
- package/server/service/chat-message/chat-message-broadcast.test.ts +0 -40
- package/server/service/chat-message/chat-message-broadcast.ts +0 -70
- package/server/service/chat-message/chat-message-publish.ts +0 -22
- package/server/service/chat-message/chat-message-room.test.ts +0 -145
- package/server/service/chat-message/chat-message-room.ts +0 -50
- package/server/service/chat-message/chat-message-subscription.ts +0 -77
- package/server/service/chat-message/chat-message.ts +0 -289
- package/server/service/chat-message/chat-typing-subscription.ts +0 -52
- package/server/service/chat-message/chat-typing.test.ts +0 -45
- package/server/service/chat-message/chat-typing.ts +0 -48
- package/server/service/chat-message/door-access.test.ts +0 -72
- package/server/service/chat-message/door-access.ts +0 -65
- package/server/service/chat-message/fold-history-window.test.ts +0 -184
- package/server/service/chat-message/fold-history.test.ts +0 -98
- package/server/service/chat-message/fold-history.ts +0 -77
- package/server/service/chat-message/fold-session-history.test.ts +0 -116
- package/server/service/chat-message/fold-session-history.ts +0 -115
- package/server/service/chat-message/history-summary.test.ts +0 -127
- package/server/service/chat-message/history-summary.ts +0 -100
- package/server/service/chat-message/index.ts +0 -13
- package/server/service/chat-message/llm-history.test.ts +0 -245
- package/server/service/chat-message/llm-history.ts +0 -182
- package/server/service/chat-message/message-doors.test.ts +0 -124
- package/server/service/chat-message/message-doors.ts +0 -132
- package/server/service/chat-message/proposal-outcome.test.ts +0 -111
- package/server/service/chat-message/proposal-outcome.ts +0 -99
- package/server/service/chat-message/reader-gate.ts +0 -44
- package/server/service/chat-message/room-message.test.ts +0 -21
- package/server/service/chat-message/room-message.ts +0 -22
- package/server/service/chat-message/room-turn.ts +0 -42
- package/server/service/chat-message/used-tools.test.ts +0 -19
- package/server/service/chat-message/used-tools.ts +0 -25
- package/server/service/chat-session/attachment-policy.test.ts +0 -42
- package/server/service/chat-session/attachment-policy.ts +0 -91
- package/server/service/chat-session/attachment-route.ts +0 -45
- package/server/service/chat-session/attachment-tool-result.test.ts +0 -63
- package/server/service/chat-session/attachment-tool-result.ts +0 -37
- package/server/service/chat-session/attachment-tools.ts +0 -66
- package/server/service/chat-session/chat-session.ts +0 -244
- package/server/service/chat-session/group-room.test.ts +0 -233
- package/server/service/chat-session/index.ts +0 -5
- package/server/service/chat-session/session-activity-broadcast.ts +0 -77
- package/server/service/chat-session/session-activity-publish.ts +0 -49
- package/server/service/chat-session/session-activity-receivers.test.ts +0 -26
- package/server/service/chat-session/session-activity-subscription.ts +0 -66
- package/server/service/chat-session/session-anchor.ts +0 -142
- package/server/service/chat-session/session-attachments.ts +0 -90
- package/server/service/chat-session/session-cleanup.test.ts +0 -83
- package/server/service/chat-session/session-cleanup.ts +0 -69
- package/server/service/chat-session/session-inbox.test.ts +0 -273
- package/server/service/chat-session/session-inbox.ts +0 -240
- package/server/service/chat-session/session-kind.test.ts +0 -24
- package/server/service/chat-session/session-kind.ts +0 -32
- package/server/service/chat-session/session-name.ts +0 -32
- package/server/service/chat-session/session-purge.test.ts +0 -24
- package/server/service/chat-session/session-purge.ts +0 -117
- package/server/service/chat-session/session-retention.ts +0 -17
- package/server/service/chat-session/session-visibility.test.ts +0 -130
- package/server/service/chat-session/session-visibility.ts +0 -68
- package/server/service/chat-session/session-write-gate.test.ts +0 -59
- package/server/service/chat-session/session-write-gate.ts +0 -31
- package/server/service/chat-session/station-session-guard.ts +0 -25
- package/server/service/chat-session/turn-attachments.test.ts +0 -106
- package/server/service/chat-session/turn-attachments.ts +0 -45
- package/server/service/chat-session-participant/chat-session-participant.ts +0 -135
- package/server/service/chat-session-participant/index.ts +0 -8
- package/server/service/chat-session-participant/invite-notification.test.ts +0 -80
- package/server/service/chat-session-participant/invite-notification.ts +0 -118
- package/server/service/chat-session-participant/mention-invite.test.ts +0 -173
- package/server/service/chat-session-participant/mention-invite.ts +0 -180
- package/server/service/chat-session-participant/participant-lookup-roles.ts +0 -6
- package/server/service/chat-session-participant/participant-lookup.ts +0 -22
- package/server/service/chat-session-participant/presence.test.ts +0 -39
- package/server/service/chat-session-participant/presence.ts +0 -21
- package/server/service/chat-session-participant/read-roster.test.ts +0 -27
- package/server/service/chat-session-participant/read-roster.ts +0 -17
- package/server/service/chat-session-resolver.ts +0 -1455
- package/server/service/data-entry/data-entry-update.test.ts +0 -378
- package/server/service/data-entry/data-entry.test.ts +0 -494
- package/server/service/data-entry/entry-apply.ts +0 -247
- package/server/service/data-entry/entry-hash.ts +0 -35
- package/server/service/data-entry/entry-refusal.test.ts +0 -73
- package/server/service/data-entry/entry-refusal.ts +0 -20
- package/server/service/data-entry/entry-resolver.ts +0 -74
- package/server/service/data-entry/entry-screen.ts +0 -14
- package/server/service/data-entry/entry-sources.ts +0 -39
- package/server/service/data-entry/entry-target.ts +0 -774
- package/server/service/data-entry/entry-tools.ts +0 -282
- package/server/service/data-entry/entry-update.ts +0 -238
- package/server/service/data-read/data-read.test.ts +0 -395
- package/server/service/data-read/detail-lists.test.ts +0 -61
- package/server/service/data-read/list-missing.test.ts +0 -49
- package/server/service/data-read/list-read.ts +0 -146
- package/server/service/data-read/list-status.test.ts +0 -46
- package/server/service/data-read/read-target.ts +0 -509
- package/server/service/data-read/read-tools.ts +0 -334
- package/server/service/data-read/read-words.test.ts +0 -99
- package/server/service/data-read/record-keys.test.ts +0 -42
- package/server/service/grounding-sources.test.ts +0 -55
- package/server/service/grounding-sources.ts +0 -46
- package/server/service/help-documents/help-keys.ts +0 -2
- package/server/service/help-documents/help-tools.test.ts +0 -40
- package/server/service/help-documents/help-tools.ts +0 -88
- package/server/service/index.ts +0 -99
- package/server/service/people/index.ts +0 -15
- package/server/service/people/invite-tools.ts +0 -159
- package/server/service/people/invite.test.ts +0 -159
- package/server/service/people/people-keys.ts +0 -16
- package/server/service/people/people-read.test.ts +0 -82
- package/server/service/people/people-read.ts +0 -56
- package/server/service/people/person-subject.test.ts +0 -161
- package/server/service/people/person-subject.ts +0 -83
- package/server/service/request-translator.test.ts +0 -45
- package/server/service/request-translator.ts +0 -33
- package/server/service/session-anchor.test.ts +0 -198
- package/server/service/station-session-guard.test.ts +0 -31
- package/server/service/testing/conversation-scenario.test.ts +0 -164
- package/server/service/testing/conversation-script.test.ts +0 -133
- package/server/service/testing/conversation-script.ts +0 -296
- package/server/service/testing/mode-conformance.test.ts +0 -61
- package/server/service/testing/mode-conformance.ts +0 -165
- package/server/service/tool-access.test.ts +0 -96
- package/server/service/tool-access.ts +0 -36
- package/server/service/types.ts +0 -15
- package/server/service/unattended-run/assistant-run.ts +0 -199
- package/server/service/unattended-run/index.ts +0 -10
- package/server/service/unattended-run/limits.ts +0 -24
- package/server/service/unattended-run/run-as.ts +0 -38
- package/server/service/unattended-run/run-budget.ts +0 -58
- package/server/service/unattended-run/run-ledger.ts +0 -31
- package/server/service/unattended-run/run-outcome.ts +0 -43
- package/server/service/unattended-run/run-store-race.pg.test.ts +0 -83
- package/server/service/unattended-run/run-store.ts +0 -162
- package/server/service/unattended-run/run-unattended.test.ts +0 -478
- package/server/service/unattended-run/run-unattended.ts +0 -248
- package/server/service/unattended-run/unattended-prompt.ts +0 -24
- package/server/service/workspace/workspace-blocks.ts +0 -134
- package/server/service/workspace/workspace-tools.ts +0 -108
- package/server/service/workspace/workspace.test.ts +0 -74
- package/server/tool-registry-boot-report.test.ts +0 -41
- package/server/tool-registry-boot-report.ts +0 -63
- package/test/ai-agent-settings.test.ts +0 -123
- package/test/applied-screens.test.ts +0 -65
- package/test/assistant-chat-call-sites.test.ts +0 -92
- package/test/assistant-dock.test.ts +0 -294
- package/test/assistant-request-context.test.ts +0 -72
- package/test/assistant-session-controller.test.ts +0 -87
- package/test/assistant-session-manager.test.ts +0 -186
- package/test/assistant-session-toolbar.test.ts +0 -43
- package/test/attachment-one-rule.test.ts +0 -46
- package/test/attachment-policy-agree.test.ts +0 -38
- package/test/composer-frame.test.ts +0 -173
- package/test/document-text.test.ts +0 -175
- package/test/entry-card-styles.test.ts +0 -18
- package/test/entry-proposal.test.ts +0 -186
- package/test/entry-workspace.test.ts +0 -89
- package/test/menu-room.test.ts +0 -33
- package/test/open-doors.test.ts +0 -164
- package/test/open-page.test.ts +0 -31
- package/test/pasted-table.test.ts +0 -147
- package/test/refusals-in-korean.test.ts +0 -80
- package/test/session-discovery.test.ts +0 -43
- package/test/spreadsheet-text.test.ts +0 -92
- package/test/translations.test.ts +0 -80
- package/test/workspace.test.ts +0 -54
- package/tsconfig.json +0 -9
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/service/index.ts"],"names":[],"mappings":";;;;AAAA,yEAAgE;AAChE,6EAAoE;AACpE,4FAAmF;AACnF,yFAAgF;AAChF,iEAAwD;AACxD,sGAA+F;AAC/F,8FAAqF;AACrF,4FAAmF;AACnF,sDAAyE;AACzE,sDAAyE;AACzE,kEAAgG;AAChG,8CAA2C;AAC3C,2CAAwC;AACxC,8CAA2C;AAC3C,sEAAsE;AACtE,0C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G,mBAAmB,EAAE,GAAG,mBAAmB,EAAE,GAAG,mBAA8B,EAAE,GAAG,mBAAqB,CAAC,CAAA;AAExH,QAAA,MAAM,GAAG;IACpB,eAAe,EAAE;QACf,8CAAmB;QACnB,sDAAsD;QACtD,kDAAqB;QACrB,uDAAuD;QACvD,kDAAqB;QACrB,wDAAwD;QACxD,8DAA2B;QAC3B,mGAAmG;QACnG,sCAAe;QACf,sDAAuB;QACvB,wDAAwD;QACxD,oDAAsB;QACtB,qDAAqD;QACrD,gEAA6B;QAC7B,mDAAmD;QACnD,yCAAqB;KACtB;CACF,CAAA","sourcesContent":["import { ChatSessionResolver } from './chat-session-resolver.js'\nimport { AssistantChatResolver } from './assistant-chat-resolver.js'\nimport { AssistantModeResolver } from './assistant-mode/assistant-mode-resolver.js'\nimport { AssistantCapabilityResolver } from './assistant-capability-resolver.js'\nimport { AiAgentResolver } from './ai-agent-resolver.js'\nimport { MySessionActivitySubscription } from './chat-session/session-activity-subscription.js'\nimport { ChatMessageSubscription } from './chat-message/chat-message-subscription.js'\nimport { ChatTypingSubscription } from './chat-message/chat-typing-subscription.js'\nimport { entities as ChatSessionEntities } from './chat-session/index.js'\nimport { entities as ChatMessageEntities } from './chat-message/index.js'\nimport { entities as ChatSessionParticipantEntities } from './chat-session-participant/index.js'\nimport './chat-session/attachment-tools.js'\nimport './chat-session/session-purge.js'\nimport './chat-session/attachment-route.js'\nimport { EntryProposalResolver } from './data-entry/entry-resolver.js'\nimport './workspace/workspace-tools.js'\nimport './help-documents/help-tools.js'\n/* Who works here, and the card that brings one of them into a conversation - every conversation carries both. */\nimport './people/index.js'\nimport { entities as UnattendedRunEntities } from './unattended-run/index.js'\n\nexport * from './types.js'\nexport * from './chat-session-resolver.js'\nexport * from './assistant-chat-resolver.js'\n/* The mode registry — each app server declares what its conversations are (ADR-0061 decision 7). */\nexport * from './assistant-mode/index.js'\nexport { requestTranslator } from './request-translator.js'\nexport * from './assistant-capability-resolver.js'\n/*\n * 대화 각본 하네스는 **런타임 export 에서 뺀다**(ADR-0070 A15 결정 ④) — 시험 도구가 서버 번들에\n * 실린다. 시험은 경로로 가져온다: `…/service/testing/conversation-script.js`.\n */\nexport * from './tool-access.js'\n/* Data entry from material - an app registers what it can enter; a mode names it (design/ai/data-entry.md). */\nexport * from './data-entry/entry-target.js'\nexport { registerEntryTarget, entryCategoryOf, runAsCaller } from './data-entry/entry-tools.js'\n/* An application's tool that prepares many changes at once makes the same change card the model's would (2026-10-24). */\nexport { proposeChanges, MAX_CHANGES } from './data-entry/entry-update.js'\n/* Reading an application's lists - an app registers what it lets read; a mode names it (design/ai/read-targets.md). */\nexport * from './data-read/read-target.js'\nexport { registerReadTarget, readCategoryOf, registerDetailRead, detailCategoryOf, runDetail, type DetailRun } from './data-read/read-tools.js'\nexport * from './data-read/list-read.js'\nexport * from './people/index.js'\n/* The AI 작업 패널 - large results on a page of their own (design/ai/workspace.md). */\nexport * from './workspace/workspace-blocks.js'\n/* 무엇이 근거인가 — 도구 결과 밖의 셋(프롬프트 · 대화 · 화면 스냅숏). */\nexport * from './grounding-sources.js'\n/* 앵커 순수 로직 — 호스트가 앵커 종류를 참조한다(리졸버는 데코레이터 때문에 무겁다). */\nexport * from './chat-session/session-anchor.js'\n/* Who may read a conversation — one rule, also asked by doors outside this package (board-ai's revertPatch). */\nexport * from './chat-session/session-visibility.js'\nexport * from './chat-session/index.js'\n/* 순수 로직들 — 호스트(board-ai 등)가 같은 규칙을 쓰라고 공개한다. 베끼면 한쪽만 고쳐진다. */\nexport * from './chat-session/session-inbox.js'\nexport * from './chat-session/attachment-policy.js'\nexport * from './chat-session/session-purge.js'\nexport * from './chat-session/session-activity-publish.js'\nexport * from './chat-session/session-activity-broadcast.js'\nexport * from './chat-message/llm-history.js'\nexport * from './chat-message/history-summary.js'\nexport * from './chat-message/fold-history.js'\n/* 상한 밖으로 밀려난 앞부분을 요약으로 접는 orchestration — 중립 문이 부른다. */\nexport * from './chat-message/fold-session-history.js'\nexport * from './chat-message/chat-message-publish.js'\nexport * from './chat-message/chat-message-broadcast.js'\nexport * from './chat-session-participant/invite-notification.js'\n/* 멘션이 사람을 불러들이는 자리 — 사람의 말을 저장하는 문만 부른다(ADR-0071 결정 1). */\nexport * from './chat-session-participant/mention-invite.js'\nexport * from './chat-session-participant/presence.js'\nexport * from './chat-message/index.js'\nexport * from './chat-session-participant/index.js'\n/* Reading the stored proposals of a conversation and whether one is answered - a package that applies its own card reads them as entry does. */\nexport { PROPOSAL_OUTCOME_PREFIX } from './chat-message/proposal-outcome.js'\nexport { assertMayWriteSession } from './chat-session/session-write-gate.js'\n/* A mode run with no person in it - a scheduled draft (operato-application/design/ai/unattended-run.md). */\nexport * from './unattended-run/index.js'\n\nexport const entities = [...ChatSessionEntities, ...ChatMessageEntities, ...ChatSessionParticipantEntities, ...UnattendedRunEntities]\n\nexport const schema = {\n resolverClasses: [\n ChatSessionResolver,\n /* 문서를 갖지 않은 표면의 대화 — board 를 안 싣는 제품이 물어볼 수 있는 자리. */\n AssistantChatResolver,\n /* 화면이 자기 대화가 무엇을 주는지 묻는 자리 — 문구는 서버가 요청 로케일로 옮겨 낸다. */\n AssistantModeResolver,\n /* 「이 배포에 AI 가 있나 · 무엇이 선언 없이 등록됐나」 — 창구 하나(표준 A7-a). */\n AssistantCapabilityResolver,\n /* A domain's AI agents - the settings card and the dock's picker (design/ai/agent-settings.md). */\n AiAgentResolver,\n ChatMessageSubscription,\n /* 「입력 중」 — 저장하지 않는 방의 한 줄. 듣는 사람은 메시지와 같은 방 판정을 지난다. */\n ChatTypingSubscription,\n /* 내가 참여한 모든 세션의 활동 — 창을 닫아 둔 표면이 배지·목록을 갱신할 수 있게. */\n MySessionActivitySubscription,\n /* 사람이 누른 입력 제안을 쓰는 자리 — 행마다 앱의 코드로, 그 사람의 권한으로. */\n EntryProposalResolver\n ]\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/people/index.ts"],"names":[],"mappings":";;;;AAAA;;;GAGG;AACH,8DAA+D;AAC/D,qDAAmD;AACnD,6BAA0B;AAC1B,+BAA4B;AAE5B,IAAA,kCAAkB,EAAC,IAAA,iCAAgB,GAAE,CAAC,CAAA;AAEtC,2DAAgC;AAChC,mDAAqE;AAA5D,kHAAA,gBAAgB,OAAA;AAAE,kHAAA,gBAAgB,OAAA;AAC3C,yDAAwI;AAA/H,gHAAA,WAAW,OAAA;AAAE,wHAAA,mBAAmB,OAAA;AAAE,oHAAA,eAAe,OAAA;AAAE,mHAAA,cAAc,OAAA;AAAE,iHAAA,YAAY,OAAA;AAAE,sHAAA,iBAAiB,OAAA;AAC3G,qDAA+H;AAAtH,gHAAA,aAAa,OAAA;AAAE,kHAAA,eAAe,OAAA;AAAE,iHAAA,cAAc,OAAA;AAAE,wHAAA,qBAAqB,OAAA","sourcesContent":["/*\n * The people tools every conversation carries - the people list (people-read.ts) and the invite card (invite-tools.ts).\n * Registered once, at boot, as the AI 작업 패널 is.\n */\nimport { registerReadTarget } from '../data-read/read-tools.js'\nimport { peopleReadTarget } from './people-read.js'\nimport './invite-tools.js'\nimport './person-subject.js'\n\nregisterReadTarget(peopleReadTarget())\n\nexport * from './people-keys.js'\nexport { peopleReadTarget, PEOPLE_SELECTION } from './people-read.js'\nexport { PERSON_AXIS, PERSON_QUESTION_KEY, PERSON_GUIDANCE, personOfAnchor, personSeatOf, personRoomRefusal } from './person-subject.js'\nexport { proposeInvite, findPeopleNamed, inviteCategory, MAX_INVITE_CANDIDATES, type InviteCandidate } from './invite-tools.js'\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"invite-tools.js","sourceRoot":"","sources":["../../../server/service/people/invite-tools.ts"],"names":[],"mappings":";;;AAsDA,0CAUC;AASD,sCAqDC;AA9HD;;;;;;;;;;;GAWG;AACH,mEAAuG;AACvG,iDAAqD;AAErD,iEAA0D;AAE1D,qEAA6D;AAC7D,iFAA+D;AAC/D,yGAAg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,EAAE,CAAC,MAAM,CAAC;KACnB;IACD,OAAO,EAAE,CAAC,IAAS,EAAE,OAAY,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC;CACvD,CAAA;AAEA,QAAA,cAAc,GAAiB;IAC1C,IAAI,EAAE,gCAAe;IACrB,WAAW,EAAE,kEAAkE;IAC/E,QAAQ,EAAE;QACR,0KAA0K;QAC1K,kGAAkG;KACnG,CAAC,IAAI,CAAC,IAAI,CAAC;IACZ,KAAK,EAAE,CAAC,IAAI,CAAC;CACd,CAAA;AAED,IAAA,qCAAoB,EAAC,sBAAc,CAAC,CAAA","sourcesContent":["/*\n * proposeInvite - the model offers a card that brings someone into this conversation (ADR-0073 decision 3).\n *\n * The card is a proposal: the model seats nobody. What an assistant writes must not seat people (mention-invite.ts,\n * rule ①), so the seat is given when a person presses the card - the dock calls `inviteToAISession` with that\n * person's request, and the door asks `maySeat` with their seat. This tool only finds who is meant and says whether\n * this person could press it here.\n *\n * Who is meant is the server's to settle, never the model's memory: the name is looked up in the organization's own\n * list as the person (the read people-read.ts opens), so a user id the model made up is never on a card. One person\n * by that name - the card invites them. Several - the card lists each and the person picks one; the model does not ask.\n */\nimport { registerToolCategory, type ToolCategory, type ToolSpec } from '@things-factory/ai-client-base'\nimport { getRepository } from '@things-factory/shell'\n\nimport { runAsCaller } from '../data-entry/entry-tools.js'\nimport type { GraphqlRunner } from '../data-entry/entry-update.js'\nimport { ChatSession } from '../chat-session/chat-session.js'\nimport { maySeat } from '../chat-session/session-visibility.js'\nimport { ChatSessionParticipant } from '../chat-session-participant/chat-session-participant.js'\nimport { isRoomRole } from '../chat-session-participant/participant-lookup-roles.js'\nimport { PEOPLE_SELECTION } from './people-read.js'\nimport { INVITE_CATEGORY } from './people-keys.js'\n\n/** At most this many people on one card - a name that matches more is too broad to pick from. */\nexport const MAX_INVITE_CANDIDATES = 8\n\nexport interface InviteCandidate {\n userId: string\n name: string\n department?: string\n position?: string\n}\n\nconst PEOPLE_QUERY =\n 'query ($filters: [Filter!], $pagination: Pagination, $search: String) ' +\n `{ employees(filters: $filters, pagination: $pagination, search: $search) { items { ${PEOPLE_SELECTION} } total } }`\n\nconst ACTIVE = { name: 'active', operator: 'eq', value: true }\n\nconst candidateOf = (row: any): InviteCandidate | undefined =>\n row?.user?.id\n ? {\n userId: String(row.user.id),\n name: String(row.name ?? ''),\n ...(row.department?.name ? { department: String(row.department.name) } : {}),\n ...(row.jobPosition ? { position: String(row.jobPosition) } : {})\n }\n : undefined\n\n/**\n * The people a name means, as the person may see them: the exact name first, then the name as a search term. Only\n * people with an account - an invite seats a user.\n */\nexport async function findPeopleNamed(run: GraphqlRunner, name: string): Promise<{ people: InviteCandidate[]; error?: string }> {\n const ask = async (variables: Record<string, unknown>) => {\n const answer = await run(PEOPLE_QUERY, { pagination: { page: 1, limit: MAX_INVITE_CANDIDATES + 1 }, ...variables })\n if (answer.errors?.length) return { error: answer.errors.map(one => one.message).join('; ') }\n return { rows: (answer.data?.employees?.items ?? []) as any[] }\n }\n const exact = await ask({ filters: [ACTIVE, { name: 'name', operator: 'eq', value: name }] })\n if ('error' in exact) return { people: [], error: exact.error }\n const rows = exact.rows!.length ? exact.rows! : ((await ask({ filters: [ACTIVE], search: name })) as any).rows ?? []\n return { people: rows.map(candidateOf).filter(Boolean) as InviteCandidate[] }\n}\n\n/** Why this person cannot bring anyone into this room, in their words - or nothing when they can. */\nfunction seatRefusal(visibility: string | null | undefined, t: (key: string, options: any) => string): string | undefined {\n if (visibility === 'private')\n return t('ai-assistant.text.invite-private-refused', { defaultValue: 'a private conversation is yours alone. make it a group to bring people in.' })\n return t('ai-assistant.text.invite-owner-only', { defaultValue: 'only the person who started this group conversation can bring people in.' })\n}\n\nexport async function proposeInvite(args: any, context: any, run: GraphqlRunner = runAsCaller(context)) {\n const t = (key: string, options: any) => (typeof context?.t === 'function' ? context.t(key, options) : String(options?.defaultValue ?? key))\n const { domain, user } = context?.state ?? {}\n const name = typeof args?.name === 'string' ? args.name.trim() : ''\n const wanted = typeof args?.userId === 'string' ? args.userId.trim() : ''\n if (!name) return { rejected: true, error: 'no-name', message: 'say whom to invite - the name the person used.' }\n\n const conversationId = context?.conversation?.id\n const session: any = conversationId && domain?.id ? await getRepository(ChatSession).findOne({ where: { id: conversationId, domain: { id: domain.id } } as any }) : undefined\n if (!session) return { rejected: true, error: 'no-conversation', message: 'this conversation is not stored yet, so nobody can be brought into it.' }\n\n /* Asked before anyone is looked up: the card must be one this person can press here. */\n const seats = await getRepository(ChatSessionParticipant).find({ where: { domain: { id: domain.id }, session: { id: session.id } } as any })\n const mine = seats.find((seat: any) => seat.userId === user?.id)?.role\n if (!maySeat(session.visibility, mine)) {\n /* Who reads the conversation is the person's to change, in the conversation list - the model has no tool for it (2026-10-24: it offered 「그룹 대화로 바꿔줘」). */\n return {\n rejected: true,\n error: 'may-not-invite',\n message: `${seatRefusal(session.visibility, t)} Say so in one line - do not offer a card. Who reads this conversation is changed by the person who started it, from the conversation list (⋯); you cannot change it, so never offer to or suggest asking you.`\n }\n }\n\n const found = await findPeopleNamed(run, name)\n if (found.error) return { rejected: true, error: 'people-unreadable', message: `the people list could not be read: ${found.error}` }\n const here = new Set(seats.filter((seat: any) => isRoomRole(seat.role)).map((seat: any) => seat.userId))\n const already = found.people.filter(one => here.has(one.userId))\n let people = found.people.filter(one => !here.has(one.userId) && one.userId !== user?.id)\n if (wanted) people = people.filter(one => one.userId === wanted)\n\n if (!people.length) {\n return already.length\n ? { rejected: true, error: 'already-here', message: `${already.map(one => one.name).join(', ')} is already in this conversation.` }\n : { rejected: true, error: 'not-found', message: `no one named \"${name}\" with an account is in the people list this person may see.` }\n }\n if (people.length > MAX_INVITE_CANDIDATES) {\n return { rejected: true, error: 'too-many', message: `more than ${MAX_INVITE_CANDIDATES} people match \"${name}\" - ask for the full name or the department.` }\n }\n\n const one = people.length === 1 ? people[0] : undefined\n return {\n proposed: true,\n kind: 'invite',\n icon: 'person_add',\n label: one\n ? t('ai-assistant.people.invite-one', { name: one.name, defaultValue: 'Invite {name} to this conversation' })\n : t('ai-assistant.people.invite-pick', { name, count: people.length, defaultValue: '{count} people named {name} - pick whom to invite' }),\n ...(one && (one.department || one.position) ? { reason: [one.department, one.position].filter(Boolean).join(' · ') } : {}),\n people,\n message: one\n ? `the card invites ${one.name}${one.department ? ` (${one.department})` : ''}. The person presses it; they are told when they join. Say that in one line.`\n : `${people.length} people match \"${name}\"; the card lists each with department and position and the person picks one. Do not ask which - the card does.`\n }\n}\n\nconst spec = {\n kind: 'read',\n name: 'proposeInvite',\n /* It reads people through the organization's list - the same door that list has, so it is offered where that list is. */\n doors: ['Query.employees'],\n description:\n 'Offer a card that brings someone into this conversation. Give the name the person used; the server finds them in ' +\n \"the organization's people list and puts them on the card (several people by that name: the card lists each, the \" +\n 'person picks). The person presses the card - nobody joins until then. One call per person.',\n schema: {\n type: 'object',\n properties: {\n name: { type: 'string', description: 'The name of the person to invite, as the person said it.' },\n userId: { type: 'string', description: 'The user id from the people list, when it was read already and the person meant that one.' }\n },\n required: ['name']\n },\n builder: (args: any, context: any) => proposeInvite(args, context)\n} as ToolSpec\n\nexport const inviteCategory: ToolCategory = {\n name: INVITE_CATEGORY,\n description: 'bring someone into this conversation - a card the person presses',\n guidance: [\n '- When the person asks to invite, add or bring someone into this conversation, call proposeInvite with that name in the same turn. Never send them to a screen to do it.',\n '- To answer who someone is or who works where, read the people list (queryOrganizationEmployee).'\n ].join('\\n'),\n specs: [spec]\n}\n\nregisterToolCategory(inviteCategory)\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"people-keys.js","sourceRoot":"","sources":["../../../server/service/people/people-keys.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,8GAA8G;AACjG,QAAA,eAAe,GAAG,uBAAuB,CAAA;AAEtD,6EAA6E;AAChE,QAAA,oBAAoB,GAAG,aAAa,uBAAe,EAAE,CAAA;AAElE,gFAAgF;AACnE,QAAA,eAAe,GAAG,aAAa,CAAA;AAE5C,oFAAoF;AACvE,QAAA,iBAAiB,GAAG,CAAC,4BAAoB,EAAE,uBAAe,CAAC,CAAA","sourcesContent":["/*\n * The names of the people tools - every conversation carries them (mode-categories.ts), so they live apart from the\n * tools themselves and the categories can be named without loading them.\n */\n\n/** The organization's people as a read target - its `employees` list, read as the person (people-read.ts). */\nexport const PEOPLE_READ_KEY = 'organization.employee'\n\n/** The category of that read - `data-read:<key>`, as every read target's. */\nexport const PEOPLE_READ_CATEGORY = `data-read:${PEOPLE_READ_KEY}`\n\n/** The invite card - bring someone into this conversation (invite-tools.ts). */\nexport const INVITE_CATEGORY = 'chat-invite'\n\n/** Both, in the order a turn puts them in front: find the person, then the card. */\nexport const PEOPLE_CATEGORIES = [PEOPLE_READ_CATEGORY, INVITE_CATEGORY]\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"people-read.js","sourceRoot":"","sources":["../../../server/service/people/people-read.ts"],"names":[],"mappings":";;;AAmBA,4CAoCC;AAvDD;;;;;;;;;;;GAWG;AACH,4DAA0D;AAE1D,qDAAkD;AAElD,0EAA0E;AAC7D,QAAA,gBAAgB,GAAG,gFAAgF,CAAA;AAEhH,SAAgB,gBAAgB;IAC9B,MAAM,MAAM,GAAG,IAAA,6BAAc,EAAC;QAC5B,GAAG,EAAE,gCAAe;QACpB,KAAK,EAAE,2BAA2B;QAClC,IAAI,EAAE,4BAA4B;QAClC,SAAS,EAAE,WAAW;QACtB,mHAAmH;QACnH,YAAY,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QAC/D,SAAS,EAAE,wBAAgB;QAC3B,OAAO,EAAE;YACP,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,0BAA0B,EAAE;YACtE,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,E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A+G;YAC/G,mIAAmI;KACtI,CAAA;AACH,CAAC","sourcesContent":["/*\n * Who works here - the organization's `employees` list opened to every conversation as a read target\n * (operato-application/design/ai/read-targets.md), the way an application opens its own lists.\n *\n * Asked to bring 정연희 into a group conversation, the model answered that it had no tool to look up people and\n * sent the person to search a screen (2026-10-24). The list existed; no conversation could read it.\n *\n * Nothing new is built: the read runs the organization module's own query as the person, so its door\n * (`employee` query, or the domain owner) decides who may read people, and an application without the organization\n * module has no such door - the tool is not offered there. The selection is the projection: name, department,\n * position and the user an invite takes. No phone, e-mail, address, bank account or emergency contact is read.\n */\nimport { listReadTarget } from '../data-read/list-read.js'\nimport type { ReadTarget } from '../data-read/read-target.js'\nimport { PEOPLE_READ_KEY } from './people-keys.js'\n\n/** The fields read of each person - the answer may carry nothing else. */\nexport const PEOPLE_SELECTION = 'id name alias jobPosition jobResponsibility department { id name } user { id }'\n\nexport function peopleReadTarget(): ReadTarget {\n const target = listReadTarget({\n key: PEOPLE_READ_KEY,\n title: 'ai-assistant.people.title',\n name: 'people of the organization',\n listQuery: 'employees',\n /* People who left are not offered - an invite, a mention or an answer about who does what is about who is here. */\n fixedFilters: [{ name: 'active', operator: 'eq', value: true }],\n selection: PEOPLE_SELECTION,\n columns: [\n { name: 'name', type: 'string', labelKey: 'ai-assistant.people.name' },\n { name: 'department', type: 'string', path: 'department.name', labelKey: 'ai-assistant.people.department' },\n { name: 'position', type: 'string', path: 'jobPosition', labelKey: 'ai-assistant.people.position' },\n { name: 'responsibility', type: 'string', path: 'jobResponsibility', labelKey: 'ai-assistant.people.responsibility' },\n { name: 'userId', type: 'string', path: 'user.id', labelKey: 'ai-assistant.people.user' }\n ],\n search: 'name, employee number and alias'\n })\n /*\n * Who holds a position, who is in a team - asked 「프로 직책인 사람은 누구야?」 the model put the position into the search\n * term, which matches names, numbers and aliases only, and answered that nobody held it (2026-10-24).\n */\n const contains = (name: string) => (value: any) => ({ name, operator: 'i_like', value })\n return {\n ...target,\n criteria: [\n ...target.criteria,\n { name: 'department', type: 'string', labelKey: 'ai-assistant.people.department', description: \"part of the department's name\", filter: contains('departmentName') },\n { name: 'position', type: 'string', labelKey: 'ai-assistant.people.position', description: 'part of the position (직책)', filter: contains('jobPosition') },\n { name: 'responsibility', type: 'string', labelKey: 'ai-assistant.people.responsibility', description: 'part of what they are responsible for (담당)', filter: contains('jobResponsibility') }\n ],\n description:\n 'the people who work here, as the organization lists them - name, department, position, responsibility, and the user id ' +\n 'an invite into a conversation takes (empty when the person has no account). Read only who the asker may see. ' +\n 'The text condition finds by name, employee number or alias only - a department, position or responsibility has its own condition.'\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"person-subject.js","sourceRoot":"","sources":["../../../server/service/people/person-subject.ts"],"names":[],"mappings":";;;AAuBA,wCAGC;AAMD,oCAGC;AAKD,8CASC;AAkBD,wDAaC;AAhFD;;;;;;GAMG;AACH,yDAAgD;AAChD,yGAAwG;AACxG,mEAAyG;AACzG,iDAAqD;AAErD,mEAA6D;AAE7D,qDAAqD;AACxC,QAAA,WAAW,GAAG,QAAQ,CAAA;AAEnC;;GAEG;AACU,QAAA,mBAAmB,GAAG,0BAA0B,CAAA;AAE7D,+FAA+F;AAC/F,SAAgB,cAAc,CAAC,UAAqC,EAAE,QAAmC;IACvG,IAAI,UAAU,KAAK,SAAS,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,mBAAW,GAAG,CAAC;QAAE,OAAO,SAAS,CAAA;IACzH,OAAO,QAAQ,CAAC,KAAK,CAAC,mBAAW,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,SAAS,CAAA;AAC5D,CAAC;AAED;;;GAGG;AACH,SAAgB,YAAY,CAAC,UAAqC,EAAE,QAAmC,EAAE,OAA2C;IAClJ,MAAM,MAAM,GAAG,cAAc,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;IACnD,OAAO,MAAM,IAAI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AAI,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,CAAA;YACzE,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,MAAM,YAAY,CAAC,MAAa,EAAE,IAAI,CAAC,CAAC;gBAAE,OAAO,SAAS,CAAA;YACzE,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,IAAI,EAAE,CAAA;YAC1C,OAAO,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,uBAAe,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;QAC/E,CAAC;KACF,CAAA;AACH,CAAC;AAED,IAAA,yCAAwB,EAAC,sBAAsB,EAAE,CAAC,CAAA","sourcesContent":["/*\n * Centralize rules for sessions anchored to subject / person:<user id> (ADR-0200). Identify the person in\n * model context and require record sources and timestamps; do not infer personality, intent, mood or\n * ability, or speak on their behalf. Add the subject as a participant and preserve group visibility and\n * membership. Requests requiring their decision become assigned tasks. Self-anchored sessions use ordinary\n * conversation rules.\n */\nimport { User } from '@things-factory/auth-base'\nimport { entersDomainAsAssignee } from '@things-factory/auth-base/dist-server/utils/get-domain-users.js'\nimport { registerAssistantSubject, type AssistantSubjectDescriber } from '@things-factory/ai-client-base'\nimport { getRepository } from '@things-factory/shell'\n\nimport { entryToolName } from '../data-entry/entry-target.js'\n\n/** The 360 kind of a person - auth-ui's `person`. */\nexport const PERSON_AXIS = 'person'\n\n/**\n * Response-request card registered by worklist to create an assigned task (ADR-0200).\n */\nexport const PERSON_QUESTION_KEY = 'worklist.person-question'\n\n/** The person a conversation is about, by its anchor - `undefined` when it is about no one. */\nexport function personOfAnchor(anchorType: string | null | undefined, anchorId: string | null | undefined): string | undefined {\n if (anchorType !== 'subject' || typeof anchorId !== 'string' || !anchorId.startsWith(`${PERSON_AXIS}:`)) return undefined\n return anchorId.slice(PERSON_AXIS.length + 1) || undefined\n}\n\n/**\n * Add the subject user to a new group conversation unless the creator is the subject. Private sessions have\n * no additional participants; public sessions are domain-readable.\n */\nexport function personSeatOf(anchorType: string | null | undefined, anchorId: string | null | undefined, starter: { id?: string } | null | undefined): { userId: string; visibility: 'group' } | undefined {\n const userId = personOfAnchor(anchorType, anchorId)\n return userId && userId !== starter?.id ? { userId, visibility: 'group' } : undefined\n}\n\n/**\n * Return the reason a person-conversation update is invalid, or no reason when allowed.\n */\nexport function personRoomRefusal(\n session: { anchorType?: string | null; anchorId?: string | null; creatorId?: string | null },\n change: { visibility?: string; removing?: string }\n): 'person-room-group-only' | 'person-room-keeps-person' | undefined {\n const userId = personOfAnchor(session.anchorType, session.anchorId)\n if (!userId || userId === session.creatorId) return undefined\n if (change.visibility && change.visibility !== 'group') return 'person-room-group-only'\n if (change.removing && change.removing === userId) return 'person-room-keeps-person'\n return undefined\n}\n\n/** The words of a refusal above. */\nexport const PERSON_ROOM_REFUSALS: Record<string, string> = {\n 'person-room-group-only': 'a conversation about someone stays a group they read - it cannot be opened to everyone or made private.',\n 'person-room-keeps-person': 'the person this conversation is about always reads it - they cannot be sent out. they can hide it from their own list.'\n}\n\n/**\n * Model guidance appended after the subject name on each conversation turn.\n */\nexport const PERSON_GUIDANCE = [\n 'This conversation is about that person, and they read it. Rules:',\n \"- Answer from the records the read tools return about them. Say which record each fact comes from and when it was last changed; when a record is missing or old, say so.\",\n '- Never guess their character, intent, mood or ability, never judge their performance, and never speak as them - say \"their weekly report says\", never \"I\".',\n `- What would bind them - whether something can be done, a deadline, an agreement, a refusal, their opinion - is theirs to say. Say it needs their confirmation and offer the confirmation card (${entryToolName(PERSON_QUESTION_KEY)}): the question, what the records already answered, what they must decide, and a draft answer drawn only from their records.`\n].join('\\n')\n\nexport function personSubjectDescriber(entersDomain = entersDomainAsAssignee): AssistantSubjectDescriber {\n return {\n anchorType: 'subject',\n axis: PERSON_AXIS,\n async describe({ anchorId, domain }) {\n const userId = personOfAnchor('subject', anchorId)\n if (!userId) return undefined\n const user = await getRepository(User).findOne({ where: { id: userId } })\n if (!user || !(await entersDomain(domain as any, user))) return undefined\n const name = user.name || user.email || ''\n return name ? { noun: 'person', name, guidance: PERSON_GUIDANCE } : undefined\n }\n }\n}\n\nregisterAssistantSubject(personSubjectDescriber())\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"request-translator.js","sourceRoot":"","sources":["../../server/service/request-translator.ts"],"names":[],"mappings":";;AAgBA,8CAWC;AAXD,SAAgB,iBAAiB,CAAC,OAAY;IAC5C,OAAO,CAAC,GAAW,EAAE,MAA4B,EAAE,EAAE;QACnD;;;;WAIG;QACH,IAAI,OAAO,OAAO,EAAE,CAAC,KAAK,UAAU;YAAE,OAAO,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,IAAI,GAAG,CAAC,EAAE,MAAM,CAAC,CAAA;QAErG,OAAO,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,MAAM,IAAI,EAAE,CAAC,CAAA;IACrC,CAAC,CAAA;AACH,CAAC;AAED,8CAA8C;AAC9C,SAAS,WAAW,CAAC,IAAY,EAAE,MAA4B;IAC7D,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,IAAI,IAAI,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAA;AAC/G,CAAC","sourcesContent":["/*\n * The request's translator, in a shape that keeps the request's language.\n *\n * `ctx.t` sets the detected language **on an options object**: it walks its arguments and writes\n * `lng` into the first object it finds (`i18n-base/server/middlewares/koa-i18next`). Called with\n * one argument it appends `{}` itself and everything works — but called as `ctx.t(key, undefined)`,\n * which is what a wrapper with an optional `params` does, there is an argument and it is not an\n * object, so no `lng` is written and i18next answers in its default language.\n *\n * Found 2026-09-18 on the running twin: the mode query handed a Korean screen English `/` sentences\n * while `GET /translations/translate/ko/...` returned the Korean. Every sentence this package\n * writes for a person goes through here now, so the omission cannot come back one call site at a\n * time.\n */\nexport type Translate = (key: string, params?: Record<string, any>) => string\n\nexport function requestTranslator(context: any): Translate {\n return (key: string, params?: Record<string, any>) => {\n /*\n * 구독(websocket)에는 koa 요청이 없어 `ctx.t` 가 없다. 방송 한 줄 때문에 터뜨리지 않는다 —\n * 그때는 `defaultValue` 를 그대로 채워 쓴다. i18next 자신의 fallbackLng 이 'en' 이므로 이것은\n * 프레임워크가 하는 것과 같은 답이다. 키만 내보내면 화면에 키가 뜬다.\n */\n if (typeof context?.t !== 'function') return interpolate(String(params?.defaultValue ?? key), params)\n\n return context.t(key, params ?? {})\n }\n}\n\n/** 프레임워크와 같은 single brace 자리표 — `{doors}`. */\nfunction interpolate(text: string, params?: Record<string, any>): string {\n return text.replace(/\\{(\\w+)\\}/g, (whole, name) => (params && name in params ? String(params[name]) : whole))\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conversation-script.js","sourceRoot":"","sources":["../../../server/service/testing/conversation-script.ts"],"names":[],"mappings":";;AAqFA,wCA+BC;AA2CD,oCAwIC;AAvSD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,mEAAsE;AAEtE,mEAAiF;AACjF,6EAAqG;AACrG,qEAAiE;AACjE,qFAAoF;AAoDpF;;;;;GAKG;AACH,SAAgB,cAAc,CAC5B,UAAoB,CAAC,IAAI,CAAC,EAC1B,YAAmD,EAAE;IAErD,MAAM,KAAK,GAAmB,EAAE,CAAA;IAChC,IAAI,IAAI,GAAG,CAAC,CAAA;IACZ,IAAI,SAAS,GAAG,CAAC,CAAA;IAEjB,MAAM,MAAM,GAAG;QACb,EAAE,EAAE,gBAAgB;QACpB,KAAK,CAAC,aAAa,CAAC,QAAe,EAAE,KAAY,EAAE,OAAY;YAC7D,MAAM,KAAK,GAAG,IAAI,EAAE,CAAA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AC,SAAS,IAAI,EAAE;oBAAE,SAAS,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAA;YACzG,CAAC;YAED,OAAO;gBACL,KAAK,EAAE,KAAK,CAAC,KAAK;gBAClB,OAAO;gBACP,SAAS;gBACT,IAAI;gBACJ,YAAY,EAAE,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;gBACzF,OAAO;aACR,CAAA;QACH,CAAC;KACF,CAAA;IAED,OAAO,GAAG,CAAA;AACZ,CAAC","sourcesContent":["/*\n * A conversation with several people in it, written as a script, so a test can say what the\n * assistant should have heard and what it should have done.\n *\n * ── Why a harness (standard A15) ───────────────────────────────────────────────\n * A shared session carries two kinds of talk: people talking to each other, and people talking to\n * the assistant. Everything a person types is stored the same way, and the model reads all of it.\n * So the questions a test must be able to ask are:\n *\n * 누가 말했나 · 누구에게 한 말인가 · 그 턴에 모델을 불렀나 · 모델이 무엇을 읽었나 ·\n * 무엇을 쓸 수 있었나 · 답과 제안은 누구 것인가\n *\n * Those are hard to see from a resolver test, because the interesting part is what the model was\n * handed — and that is a string built from stored rows. The script keeps the rows, builds the same\n * history the door builds, and records every model call.\n *\n * ── What this does not do ──────────────────────────────────────────────────────\n * No database, no GraphQL, no provider. It drives the same two pieces the door drives\n * (`buildLlmHistory` and `registryAssistantChat`) with a recording client, so a failure names a\n * rule rather than a stack. Anything that only the resolver does — storing, broadcasting, session\n * activity — is out of scope here and belongs in a resolver test.\n */\nimport { registryAssistantChat } from '@things-factory/ai-client-base'\n\nimport { buildLlmHistory, type HistoryRow } from '../chat-message/llm-history.js'\nimport { formatProposalOutcomeLine, type ProposalOutcome } from '../chat-message/proposal-outcome.js'\nimport { roomMessageBody } from '../chat-message/room-message.js'\nimport { inviteMentionedUsers } from '../chat-session-participant/mention-invite.js'\n\n/** Who a turn was meant for. The room hears everything; only the assistant answers. */\nexport type Addressee = 'room' | 'assistant'\n\nexport interface ScriptedTurn {\n speaker: string\n addressee: Addressee\n content: string\n /** `mention` 이 부른 사람 — 본문에는 마커로 실린다. */\n mentions?: string[]\n /** 호스트가 카드에 답한 것 — 사람의 말이 아니라 기록이다. */\n outcome?: { proposalKey: string; outcome: ProposalOutcome }\n}\n\n/** One model call, exactly as the provider saw it. */\nexport interface RecordedCall {\n systemPrompt: string\n /** The conversation handed over, newest last. */\n messages: { role: string; content: any }[]\n /** Tool names offered this turn. */\n tools: string[]\n}\n\nexport interface ScriptResult {\n /** Every model call, in order. A room turn must not produce one. */\n calls: RecordedCall[]\n /** What the assistant answered, one per `ask`. */\n replies: string[]\n /** Proposals returned, paired with the turn that asked for them. */\n proposals: { askedBy: string; proposal: any }[]\n /** The rows as they stand, in the order they were said. */\n rows: HistoryRow[]\n /** Who is in the room now, and what each of them may do. */\n participants: ScriptParticipant[]\n /** What each `mention` did — who joined, or why nobody did. */\n invites: { by: string; invited: string[]; notSeated?: string[] }[]\n}\n\n/** A person in the room. `read` is how far they have read — the fact others see as a badge. */\nexport interface ScriptParticipant {\n userId: string\n role: 'owner' | 'member' | 'viewer'\n read?: number\n}\n\n/** A provider that answers with a fixed script and records what it was given. */\nexport interface RecordingModel {\n client: any\n calls: RecordedCall[]\n}\n\n/**\n * A model that answers each call with the next canned reply, and records what it saw.\n *\n * `toolCalls` lets a script make the model ask for a tool on a given turn — the harness then\n * exercises the dispatch path rather than only the prompt.\n */\nexport function recordingModel(\n replies: string[] = ['ok'],\n toolCalls: { name: string; arguments?: any }[][] = []\n): RecordingModel {\n const calls: RecordedCall[] = []\n let turn = 0\n let replyTurn = 0\n\n const client = {\n id: 'recording:test',\n async chatWithTools(messages: any[], tools: any[], options: any) {\n const index = turn++\n calls.push({\n systemPrompt: options?.systemPrompt ?? '',\n messages: messages.map(m => ({ role: m.role, content: m.content })),\n tools: (tools ?? []).map(t => t.name)\n })\n /* The loop asks again after a tool answers, so only the first call of a turn asks for tools. */\n const wanted = toolCalls[index] ?? []\n if (wanted.length > 0) {\n return {\n text: '',\n toolCalls: wanted.map((c, i) => ({ id: `call-${index}-${i}`, name: c.name, arguments: c.arguments ?? {} })),\n stopReason: 'tool_use'\n }\n }\n return { text: replies[Math.min(replyTurn++, replies.length - 1)] ?? 'ok', toolCalls: [], stopReason: 'end_turn' }\n }\n }\n\n return { client, calls }\n}\n\nexport interface ConversationOptions {\n /**\n * Who is in the room when the script starts, and as what.\n *\n * A conversation always has an owner — the person who started it — and `createAISession` puts\n * them there. Since ADR-0073 a mention grants nothing, so the roster no longer decides who may\n * name whom; it still decides who the room reaches and who is already seated.\n */\n participants?: ScriptParticipant[]\n /** 이 대화가 공개인가 — 기본은 공개(ADR-0073 판정 2). 'private' 이면 멘션이 사람을 앉히지 않는다. */\n visibility?: 'open' | 'group' | 'private'\n /** Who the assistant is on this surface — in real use it comes from the registered mode. */\n systemPrompt?: string\n /** Which registered categories this conversation may use. Omitted allows none. */\n toolCategories?: string[]\n /**\n * Which doors this script's speaker may pass (ADR-0071 decision 2). A tool is offered when the\n * caller passes every door it names, so a script that says nothing here is written as someone who\n * passes them all — the permission axis belongs to `tool-access`, not to a conversation script.\n * Name the doors to write the other case: a person the tool is not offered to.\n */\n toolAccess?: (door: string) => Promise<boolean>\n /** Request state the tools receive (domain, user). */\n state?: any\n /** What the surface is looking at — reaches tools as `ctx.host`, never the model. */\n hostContext?: any\n /** Passed through to the runner; a live-state surface makes the model read first. */\n requireToolOnFirstTurn?: boolean\n}\n\n/**\n * Write the conversation, then run it.\n *\n * ```ts\n * const result = await conversation({ toolCategories: ['twin-ops'] })\n * .say('alice', '3 라인이 멈춘 것 같아요')\n * .say('bob', '아까부터 그랬어')\n * .ask('alice', '왜 멈췄는지 확인해줘')\n * .run(recordingModel(['확인했습니다']))\n * ```\n */\nexport function conversation(options: ConversationOptions = {}) {\n const turns: ScriptedTurn[] = []\n\n const api = {\n /** Someone speaks to the room. Nobody calls the assistant; it reads this next time it is asked. */\n say(speaker: string, content: string) {\n turns.push({ speaker, addressee: 'room', content })\n return api\n },\n /** Someone asks the assistant. This is the turn that makes a model call. */\n ask(speaker: string, content: string) {\n turns.push({ speaker, addressee: 'assistant', content })\n return api\n },\n /**\n * Someone asks the assistant **and names a colleague** — the way a second person joins.\n *\n * The marker is what the browser puts in the text when a name is picked from `@`, and the door\n * reads it from the stored turn. Only a person already in the room may bring another in.\n */\n mention(speaker: string, userIds: string[], content: string) {\n const marked = [...userIds.map(id => `@${id}{userId:${id}}`), content].join(' ')\n turns.push({ speaker, addressee: 'assistant', content: marked, mentions: userIds })\n return api\n },\n\n /** The assistant's own answer, when a script needs one already in the history. */\n answered(content: string) {\n turns.push({ speaker: 'assistant', addressee: 'room', content })\n return api\n },\n\n /**\n * The host says what it did with a proposal — the card's state and the model's next turn both\n * read this row (ADR-0070 A12-a).\n */\n outcome(proposalKey: string, outcome: ProposalOutcome) {\n turns.push({ speaker: 'system', addressee: 'room', content: '', outcome: { proposalKey, outcome } })\n return api\n },\n\n async run(model: RecordingModel = recordingModel()): Promise<ScriptResult> {\n const rows: HistoryRow[] = []\n const replies: string[] = []\n const proposals: { askedBy: string; proposal: any }[] = []\n const invites: { by: string; invited: string[]; notSeated?: string[] }[] = []\n\n /* 참여자 저장소 — 실제 문이 쓰는 것과 같은 규칙을 지나되, 기억에만 둔다. */\n const roster: any[] = (options.participants ?? [{ userId: 'alice', role: 'owner' }]).map((person, index) => ({\n id: `participant-${index + 1}`,\n userId: person.userId,\n role: person.role,\n read: person.read\n }))\n const participants = {\n find: async () => roster,\n save: async (row: any) => {\n roster.push({ id: `participant-${roster.length + 1}`, userId: row.user.id, role: row.role })\n },\n update: async (id: string, patch: any) => {\n const found = roster.find(row => row.id === id)\n if (found) Object.assign(found, patch)\n }\n }\n\n for (const turn of turns) {\n /* 호스트의 답은 사람의 말이 아니다 — 서버가 쓰는 `system` 행이다. */\n if (turn.outcome) {\n rows.push({\n id: `row-${rows.length + 1}`,\n role: 'system',\n content: formatProposalOutcomeLine(turn.outcome.proposalKey, turn.outcome.outcome)\n })\n continue\n }\n\n /* 빈 말은 저장되지 않는다 — 문이 지키는 규칙과 같은 것을 쓴다. */\n const body = roomMessageBody(turn.content)\n if (!body) continue\n\n rows.push({\n id: `row-${rows.length + 1}`,\n role: turn.speaker === 'assistant' ? 'assistant' : 'user',\n content: body,\n senderId: turn.speaker,\n senderName: turn.speaker,\n /* 사람의 말에만 대상이 있다 — 문이 찍는 값과 같은 자리다(ADR-0070 A15 결정 ①). */\n addressee: turn.speaker === 'assistant' ? undefined : turn.addressee\n })\n\n /* 멘션은 사람의 말을 저장하는 문에서만 사람을 불러들인다(ADR-0071 결정 1 ①). */\n if (turn.speaker !== 'assistant') {\n const invite = await inviteMentionedUsers({\n content: body,\n sessionId: 'script-session',\n domainId: 'script-domain',\n inviter: { id: turn.speaker },\n participants,\n visibility: options.visibility\n })\n if (invite.invited.length > 0 || invite.notSeated) {\n invites.push({ by: turn.speaker, invited: invite.invited, notSeated: invite.notSeated })\n }\n }\n\n /* Only a turn addressed to the assistant runs it. Room talk is context for the next one. */\n if (turn.addressee !== 'assistant') continue\n\n const result = await registryAssistantChat({\n client: model.client,\n messages: buildLlmHistory(rows, {}) as any,\n systemPrompt: options.systemPrompt ?? 'you are a test assistant',\n toolCategories: options.toolCategories,\n toolAccess: options.toolAccess ?? (async () => true),\n hostContext: options.hostContext,\n state: options.state ?? { domain: { id: 'dom-1' }, user: { id: 'u-1' } },\n requireToolOnFirstTurn: options.requireToolOnFirstTurn\n })\n\n replies.push(result.reply)\n rows.push({ id: `row-${rows.length + 1}`, role: 'assistant', content: result.reply })\n for (const proposal of result.loop.proposals ?? []) proposals.push({ askedBy: turn.speaker, proposal })\n }\n\n return {\n calls: model.calls,\n replies,\n proposals,\n rows,\n participants: roster.map(row => ({ userId: row.userId, role: row.role, read: row.read })),\n invites\n }\n }\n }\n\n return api\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mode-conformance.js","sourceRoot":"","sources":["../../../server/service/testing/mode-conformance.ts"],"names":[],"mappings":";;;AAwCA,8CAqCC;AAcD,kCAUC;AAGD,wCAuBC;AAGD,4DAIC;AAQD,wDAUC;AAGD,oDAIC;AAGD,gDAEC;AApKD;;;;;;;;;;;;;GAaG;AACH,mEAAuF;AAEvF,+DAA0F;AAC1F,6DAAqG;AACrG,6EAA2F;AAc3F,yDAAyD;AAClD,MAAM,gBAAgB,GAAc,GAAG,CAAC,EAAE,CAAC,GAAG,CAAA;AAAxC,QAAA,gBAAgB,oBAAwB;AAErD;;;;GAIG;AACI,KAAK,UAAU,iBAAiB,CACrC,IAAY,EACZ,UAAkH,EAAS;IAE3H,MAAM,QAAQ,GAAG,IAAA,gCAAmB,EAAC,EAAE,IAAI,EAAE,EAAE,wBAAgB,CAAC,CAAA;IAChE,IAAI,uBAAuB,GAAG,KAAK,CAAA;IAEnC,MAAM,MAAM,GAAG,MAAM,IAAA,sCAAqB,EAAC;QACzC,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,CAAQ;QACnD,YAAY,EAAE,QAAQ,CAAC,YAAY;QACnC,cAAc,EAAE,QAAQ,CAAC,cAAc;QACvC,uIAAuI;QACvI,KAAK,EAAE,EAAE,UAAU,EAAE,IAAA,wCAAmB,EAAC,IAAA,8BAAgB,EAAC,IAAI,CAAC,IAAI,EAAE,EAAE,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,EAAE;QAC9F,sBAAsB,EAAE,CAAC,uBAAuB,GAAG,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAC,CAAC;QAC5F,WAAW,EAAE,QAAQ,CAAC,WAAW;QACjC,SAAS,EAAE,QAAQ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M,CAAC,OAAO,CAAC,CAAC,CAAA;AACnD,CAAC;AAED,8GAA8G;AAC9G,SAAgB,kBAAkB,CAAC,UAAkB,EAAE,QAAgB,EAAE,QAAgB,EAAE,KAAW;IACpG,OAAO,IAAA,gCAAe,EAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;AACnF,CAAC","sourcesContent":["/*\n * 등록된 모드가 **선언한 대로 도는가** — 글자가 아니라 문을 지나서 본다.\n *\n * 모드 선언은 소스에 적힌 값이고, 사람이 만나는 것은 그 값이 문을 지나 만들어 낸 것이다. 그 둘이\n * 어긋나는 자리가 오늘 하루에만 여럿 나왔다: 범주에 없는 도구를 프롬프트가 부르라고 했고, 키는 있는데\n * 번역이 없었고, 부품에 규칙이 있는데 부르는 쪽이 없었다. 전부 「선언은 맞는데 돌지 않는」 모양이다.\n *\n * 그래서 앱의 시험이 이것으로 **자기 모드를 실제로 돌려 본다**:\n * · 그 이름으로 모드가 서는가\n * · 그 모드가 여는 도구가 무엇인가 — 모델에게 실제로 건네지는 목록\n * · 첫 턴 도구 호출을 강제하는가\n * · 화면에 낼 말이 **키가 아니라 문장**으로 나오는가\n * · 슬래시가 가리키는 도구가 그 모드 안에 있는가\n */\nimport { openSubjectLine, registryAssistantChat } from '@things-factory/ai-client-base'\n\nimport { getAssistantMode, getAssistantModeWarnings } from '../assistant-mode/registry.js'\nimport { assistantModeView, resolveModeSettings, type Translate } from '../assistant-mode/resolve.js'\nimport { modeFrontCategories, type TurnScreen } from '../assistant-mode/mode-categories.js'\n\nexport interface ModeRunResult {\n /** 이 모드가 모델에게 실제로 건넨 도구 이름. */\n offeredTools: string[]\n /** 건네지 않았지만 모델이 openTools 로 꺼낼 수 있던 도구 — 둘을 합치면 이 모드로 쓸 수 있는 전부(ADR-0061 결정 9). */\n openableTools: string[]\n /** 모델이 받은 시스템 프롬프트 — 서버의 것인지 확인할 수 있다. */\n systemPrompt: string\n /** 첫 턴에 도구를 강제했는가. */\n requiredToolOnFirstTurn: boolean\n reply: string\n}\n\n/** 시험용 번역기 — 키를 그대로 돌려준다. 문장이 나와야 할 자리에 키가 나오면 눈에 띈다. */\nexport const keyEchoTranslate: Translate = key => key\n\n/**\n * 등록된 모드로 한 턴을 돌린다 — 프롬프트도 도구도 **등록에서** 나온다.\n *\n * 시험이 자기 값을 넘기면 그 시험은 선언을 안 본 것이다. 그래서 여기서는 `kind` 만 받는다.\n */\nexport async function runRegisteredMode(\n kind: string,\n options: { client: any; hostContext?: any; state?: any; toolAccess?: any; reply?: string; screen?: TurnScreen } = {} as any\n): Promise<ModeRunResult> {\n const settings = resolveModeSettings({ kind }, keyEchoTranslate)\n let requiredToolOnFirstTurn = false\n\n const result = await registryAssistantChat({\n client: options.client,\n messages: [{ role: 'user', content: '한 턴' }] as any,\n systemPrompt: settings.systemPrompt,\n toolCategories: settings.toolCategories,\n /* What the door puts in front on that screen (ADR-0061 decision 9) - a mode too large for one call is offered as a person meets it. */\n front: { categories: modeFrontCategories(getAssistantMode(kind) ?? {}, options.screen ?? {}) },\n requireToolOnFirstTurn: (requiredToolOnFirstTurn = Boolean(settings.requireToolOnFirstTurn)),\n temperature: settings.temperature,\n maxTokens: settings.maxTokens,\n hostContext: options.hostContext,\n /*\n * This harness asks about **the mode** — \"what does this mode open\", not \"does this person pass the\n * doors\". Since the gate moved onto `doors` (ADR-0071 decision 2), passing no check closes every tool\n * that names a door, and an app's conformance test would quietly lose **exactly the tools that read\n * real data**. So the default is someone who passes every door; an app that wants the other case\n * writes `toolAccess`. The permission axis has its own tests (`tool-access.test.ts` ·\n * `tool-scope.test.ts`).\n */\n toolAccess: options.toolAccess ?? (async () => true),\n state: options.state ?? { domain: { id: 'dom-1' }, user: { id: 'u-1' } }\n })\n\n return {\n offeredTools: [...result.offeredTools],\n openableTools: [...result.openableTools],\n systemPrompt: settings.systemPrompt,\n requiredToolOnFirstTurn,\n reply: result.reply\n }\n}\n\nexport interface ModeWording {\n placeholder?: string\n /** 빈 대화의 제목과 한 줄 — 없으면 공용 대화창이 보드 제품의 글을 낸다. */\n intro?: { title: string; subtitle: string }\n /** 빈 대화의 예시 — 이 대화가 실제로 할 수 있는 말. */\n examples?: Array<{ label: string; items: string[] }>\n slash: { name: string; description: string; template: string }[]\n footerNotice?: string\n stagedNotice?: string\n}\n\n/** 화면에 낼 말 — 주어진 사전으로 옮긴 결과. 키가 그대로 남으면 사전에 없는 것이다. */\nexport function modeWording(kind: string, dictionary: Record<string, string>): ModeWording {\n const view = assistantModeView(kind, key => dictionary[key] ?? key)\n return {\n placeholder: view.placeholder,\n intro: view.intro,\n examples: view.examples,\n slash: view.slashTemplates,\n footerNotice: view.footerNotice,\n stagedNotice: view.stagedNotice\n }\n}\n\n/** 사전에 없어서 키가 그대로 화면에 나갈 말들. 비어 있어야 한다. */\nexport function missingWording(kind: string, dictionary: Record<string, string>): string[] {\n const missing: string[] = []\n const spec = getAssistantMode(kind)\n if (!spec) return [`mode:${kind}`]\n\n for (const key of [spec.placeholderKey, spec.footerNoticeKey, spec.stagedNoticeKey]) {\n if (key && !(key in dictionary)) missing.push(key)\n }\n /* 빈 대화의 말도 사전에 있어야 한다 — 없으면 화면에 키가 그대로 찍힌다. */\n for (const key of [spec.introKeys?.title, spec.introKeys?.subtitle]) {\n if (key && !(key in dictionary)) missing.push(key)\n }\n for (const group of spec.exampleKeys ?? []) {\n for (const key of [group.labelKey, ...group.itemKeys]) {\n if (!(key in dictionary)) missing.push(key)\n }\n }\n for (const slash of spec.slashTemplates ?? []) {\n for (const key of [slash.descriptionKey, slash.templateKey]) {\n if (!(key in dictionary)) missing.push(key)\n }\n }\n return missing\n}\n\n/** 이 모드가 자기 도구로 못 하는 일을 제안하는가 — 부팅 보고와 같은 답. */\nexport function modePromisesItCannotKeep(kind: string): string[] {\n return getAssistantModeWarnings()\n .filter(warning => warning.params.kind === kind)\n .map(warning => `${warning.code}:${warning.params.slash}→${warning.params.tool}`)\n}\n\n/**\n * What an app's prompt carries that every conversation already gets (design/ai/screen-pattern.md §6 · §7).\n *\n * The absence rule is added by the door to every conversation. A copy in an app's prompt says it twice, and the\n * copies drift - five apps had five spellings of it.\n */\nexport function modeCarriesSharedRules(kind: string): string[] {\n const prompt = String(getAssistantMode(kind)?.systemPrompt ?? '')\n const found: string[] = []\n if (/name our plumbing|do not describe our machinery/i.test(prompt)) found.push('absence-rule-copy')\n if (/^\\s*Next:/im.test(prompt) || /end the reply with one last line/i.test(prompt)) found.push('next-request-rule-copy')\n if (/finish what was asked in this turn|never ask whether to propose/i.test(prompt)) found.push('finish-rule-copy')\n if (/\\[writer → addressee\\]/.test(prompt)) found.push('speaker-rule-copy')\n /* The picked records' note is the framework's form (SELECTION_RULE) - an app reading its own form of it is a copy. */\n if (/explicit-page-selection|\\[keys\\]/i.test(prompt)) found.push('selection-rule-copy')\n return found\n}\n\n/** Subjects that more than one conversation names - a screen has one (design/ai/screen-pattern.md §3). */\nexport function subjectsClaimedTwice(): string[] {\n return getAssistantModeWarnings()\n .filter(warning => warning.code === 'assistant-mode-subject-claimed-twice')\n .map(warning => String(warning.params.subject))\n}\n\n/** The line the model reads for an open subject - an app's test checks its describer names its own record. */\nexport function openSubjectLineFor(anchorType: string, anchorId: string, domainId: string, state?: any): Promise<string | undefined> {\n return openSubjectLine({ anchorType, anchorId, domain: { id: domainId }, state })\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool-access.js","sourceRoot":"","sources":["../../server/service/tool-access.ts"],"names":[],"mappings":";;AAsBA,sCAaC;AAnCD;;;;;;;;;;;;;;;;GAgBG;AACH,yDAA6E;AAG7E,kEAAyD;AAEzD,SAAgB,aAAa,CAAC,OAAoC;IAChE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,oBAAoB,EAAE,GAAG,OAAO,EAAE,KAAK,IAAI,EAAE,CAAA;IAE7E,MAAM,MAAM,GAAG,IAAA,0BAAS,EAAC;QACvB,MAAM,EAAE,4BAAgB;QACxB,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,IAAA,2BAAe,EAAC,IAAW,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,oBAAoB,CAAC;KAC5F,CAAC,CAAA;IAEF,OAAO,KAAK,EAAE,IAAY,EAAE,EAAE;QAC5B,+EAA+E;QAC/E,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM;YAAE,OAAO,KAAK,CAAA;QAClC,OAAO,MAAM,MAAM,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC,CAAA;AACH,CAAC","sourcesContent":["/*\n * Who may use a registered tool — the request's answer to `ToolAccessCheck`.\n *\n * `ai-client-base` decides *which* tools a conversation may use but does not know auth, so the\n * conversation doors hand it this. A tool names the GraphQL doors it reaches (ADR-0071 decision 2);\n * this resolves each one against AUTH's field table (`privilegeOfField`, ADR-0072 decision 5) and\n * asks `checkPermission` exactly what `@privilege` on that field asks — the same user, domain,\n * address safety and prohibited list. Asking anything looser here would make the tool a second,\n * softer way into that door.\n *\n * **The declaration is the door's, and it is read, not copied.** Until 2026-09-18 a tool carried its\n * own `{ category, privilege }` and this asked that copy. A copy drifts from the door it mirrors and\n * the looser of the two wins; the table removed the need for one.\n *\n * The three answers of the table are read exactly as the reader's gate reads them (`door-access.ts`)\n * — an unknown field closes, a field with no declaration opens as far as that field opens.\n */\nimport { checkPermission, privilegeOfField } from '@things-factory/auth-base'\nimport type { ToolAccessCheck } from '@things-factory/ai-client-base'\n\nimport { doorCheck } from './chat-message/door-access.js'\n\nexport function toolAccessFor(context: { state?: any } | undefined): ToolAccessCheck {\n const { domain, user, unsafeIP, prohibitedPrivileges } = context?.state ?? {}\n\n const passes = doorCheck({\n lookup: privilegeOfField,\n permits: gate => checkPermission(gate as any, user, domain, unsafeIP, prohibitedPrivileges)\n })\n\n return async (door: string) => {\n /* No caller, no answer — a request without a user or domain passes no door. */\n if (!user || !domain) return false\n return await passes(door)\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../server/service/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG","sourcesContent":["/*\n * 대화 한 줄 — 도메인을 모르는 가장 작은 모양.\n *\n * `board-ai/types.ts` 에 있었고, 그래서 대화 이력을 다루는 순수 함수(`llm-history`)가 보드 편집기의\n * 타입 파일을 봐야 했다. 그 파일은 `BoardComponent`·`BoardModel` 을 들고 있다 — 이력을 접는 일과\n * 아무 상관이 없다.\n *\n * 옮겨도 소비처는 그대로다: `board-ai` 가 이 이름을 재수출한다.\n */\n\n/** 모델과 주고받는 한 줄. `system` 은 여기 없다 — 그것은 프롬프트이지 대화가 아니다. */\nexport interface LLMMessage {\n role: 'user' | 'assistant'\n content: string\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"assistant-run.js","sourceRoot":"","sources":["../../../server/service/unattended-run/assistant-run.ts"],"names":[],"mappings":";;;;AAAA;;;;;;GAMG;AACH,qCAAkI;AAClI,+CAAyD;AACzD,qDAA6C;AAE7C,iDAA8C;AAC9C,yDAAgD;AAChD,6CAA4C;AAE5C,MAAM,SAAS,GAAG,YAAM,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;AAC7C,MAAM,aAAa,GAAG,SAAS,CAAC,IAAI,CAAA;AAEpC,MAAM,SAAS,GAAG;IAChB,IAAI,EACF,aAAa,IAAI,OAAO,IAAI,aAAa,IAAI,SAAS;QACpD,CAAC,CAAC,UAAU;QACZ,CAAC,CAAC,aAAa,IAAI,QAAQ;YACzB,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,aAAa,IAAI,OAAO;gBACxB,CAAC,CAAC,UAAU;gBACZ,CAAC,CAAC,MAAM;IAChB,MAAM,EAAE,aAAa,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;IACpD,QAAQ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C3C,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,eAAe,EAAE,CAAC;sCAC5D,gBAAI;6CAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,GAAiB,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC;;+CAC7B;AAIlB;IAFC,IAAA,0BAAgB,GAAE;IAClB,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,qBAAqB,EAAE,CAAC;sCAClD,IAAI;+CAAA;AAIhB;IAFC,IAAA,0BAAgB,GAAE;IAClB,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,wBAAwB,EAAE,CAAC;sCACrD,IAAI;+CAAA;uBAxJL,YAAY;IALxB,IAAA,gBAAM,GAAE;IACT,iGAAiG;;IAChG,IAAA,eAAK,EAAC,oBAAoB,EAAE,CAAC,GAAiB,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC5H,IAAA,eAAK,EAAC,oBAAoB,EAAE,CAAC,GAAiB,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC;IACxG,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,qFAAqF,EAAE,CAAC;GACtG,YAAY,CAyJxB","sourcesContent":["/**\n * AssistantRun — one occurrence of a mode run with no person in it, and what it left (design/ai/unattended-run.md).\n *\n * The one place the facts of an AI run are kept: its attempts, its state, the draft, the reads the draft rested on,\n * what it spent and the doors behind it. The application that scheduled it keeps its own facts and points here by\n * (source, subject, scheduledAt) or by id - it does not copy these (chief architect ruling, 2026-10-20).\n */\nimport { Column, CreateDateColumn, Entity, Index, ManyToOne, PrimaryGeneratedColumn, RelationId, UpdateDateColumn } from 'typeorm'\nimport { Field, ID, Int, ObjectType } from 'type-graphql'\nimport { GraphQLJSON } from 'graphql-scalars'\n\nimport { Domain } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { config } from '@things-factory/env'\n\nconst ORMCONFIG = config.get('ormconfig', {})\nconst DATABASE_TYPE = ORMCONFIG.type\n\nconst LONG_TEXT = {\n type:\n DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n ? 'longtext'\n : DATABASE_TYPE == 'oracle'\n ? 'clob'\n : DATABASE_TYPE == 'mssql'\n ? 'nvarchar'\n : 'text',\n length: DATABASE_TYPE == 'mssql' ? 'MAX' : undefined,\n nullable: true\n} as const\n\nconst parsed = (text?: string | null) => {\n if (!text) return null\n try {\n return JSON.parse(text)\n } catch {\n return null\n }\n}\n\n@Entity()\n/* One occurrence, one row - two first calls at once make one row and the other reads it (§5). */\n@Index('ix_assistant_run_0', (run: AssistantRun) => [run.domain, run.source, run.subject, run.scheduledAt], { unique: true })\n@Index('ix_assistant_run_1', (run: AssistantRun) => [run.domain, run.source, run.subject, run.createdAt])\n@ObjectType({ description: 'One scheduled run of an assistant mode with no person in it, and the draft it left.' })\nexport class AssistantRun {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID, { description: 'Run id.' })\n readonly id?: string\n\n @ManyToOne(type => Domain)\n @Field(type => Domain, { nullable: true, description: 'The domain the run is in.' })\n domain?: Domain\n\n @RelationId((run: AssistantRun) => run.domain)\n domainId?: string\n\n @Column()\n @Field({ description: 'Readable name of the occurrence - source, subject and time.' })\n name: string\n\n @Column({ type: 'text', nullable: true })\n @Field({ nullable: true, description: 'Description.' })\n description?: string\n\n @Column({ length: 64 })\n @Field({ description: \"Who scheduled it - '<app>.<work>', e.g. 'office.strategy-review'.\" })\n source: string\n\n @Column({ length: 64 })\n @Field({ description: \"What it is about in the source's terms, e.g. a policy id.\" })\n subject: string\n\n @Column()\n @Field({ description: 'The occurrence this run is.' })\n scheduledAt: Date\n\n @Column({ length: 64 })\n @Field({ description: 'The assistant mode that ran.' })\n modeKind: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'What the mode was about.' })\n modeTarget?: string\n\n @ManyToOne(type => User)\n @Field(type => User, { nullable: true, description: 'The person the run acted as - its privileges and doors were theirs.' })\n runAs?: User\n\n @RelationId((run: AssistantRun) => run.runAs)\n runAsId?: string\n\n @Column({ length: 16 })\n @Field({ description: \"'running' | 'succeeded' | 'failed' | 'refused'.\" })\n status: string\n\n @Column({ type: 'int', default: 1 })\n @Field(type => Int, { description: 'Which attempt at this occurrence the row holds, from 1.' })\n attempt: number\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'When this attempt started.' })\n startedAt?: Date\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Past this a running attempt is taken as gone and the next call takes the occurrence over.' })\n deadlineAt?: Date\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'When this attempt ended.' })\n finishedAt?: Date\n\n @Column(LONG_TEXT as any)\n @Field({ nullable: true, description: 'The draft - only when the run succeeded.' })\n draft?: string\n\n /** Each call of the run as the audit digests it (`ToolCallRecord`, never raw values), as JSON. */\n @Column(LONG_TEXT as any)\n reads?: string\n\n @Field(() => GraphQLJSON, { nullable: true, description: 'The reads the draft rested on: tool, category, ids, rows, hash, ok or the error code.' })\n get readsJson(): any {\n return parsed(this.reads)\n }\n\n @Column({ type: 'simple-array', nullable: true })\n @Field(() => [String], { nullable: true, description: 'GraphQL doors the reads went through. A reader of the draft must pass all of them.' })\n doors?: string[]\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Why it failed or was refused - a code; the screen says it.' })\n outcomeCode?: string\n\n @Column({ type: 'text', nullable: true })\n outcomeParams?: string\n\n @Field(() => GraphQLJSON, { nullable: true, description: 'Values of the outcome code.' })\n get outcomeParamsJson(): any {\n return parsed(this.outcomeParams)\n }\n\n /** The earlier attempts' endings, `[{ attempt, status, outcomeCode, startedAt, finishedAt }]`, as JSON. */\n @Column({ type: 'text', nullable: true })\n attempts?: string\n\n @Field(() => GraphQLJSON, { nullable: true, description: 'How the earlier attempts ended.' })\n get attemptsJson(): any {\n return parsed(this.attempts)\n }\n\n @Column({ type: 'text', nullable: true })\n groundingWarnings?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'The AI agent that answered.' })\n agentId?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'provider:model.' })\n clientId?: string\n\n @Column({ type: 'int', default: 0 })\n @Field(type => Int, { description: 'Model requests of this attempt.' })\n modelCalls: number\n\n @Column({ type: 'int', default: 0 })\n @Field(type => Int, { description: 'Input tokens of this attempt.' })\n inputTokens: number\n\n @Column({ type: 'int', default: 0 })\n @Field(type => Int, { description: 'Output tokens of this attempt.' })\n outputTokens: number\n\n @Column({ type: 'int', default: 0 })\n @Field(type => Int, { description: 'Cards a read offered that were not kept - there was no person to press them.' })\n cardsDropped: number\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'Creator.' })\n creator?: User\n\n @RelationId((run: AssistantRun) => run.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'Last updater.' })\n updater?: User\n\n @RelationId((run: AssistantRun) => run.updater)\n updaterId?: string\n\n @CreateDateColumn()\n @Field({ nullable: true, description: 'Creation timestamp.' })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true, description: 'Last update timestamp.' })\n updatedAt?: Date\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/unattended-run/index.ts"],"names":[],"mappings":";;;AAAA,yDAAiD;AAExC,6FAFA,+BAAY,OAEA;AACrB,yDAA8E;AAArE,2HAAA,sBAAsB,OAAA;AAAE,qHAAA,gBAAgB,OAAA;AAEjD,yCAAiD;AAAxC,gHAAA,mBAAmB,OAAA;AAC5B,mDAAyF;AAAhF,yHAAA,uBAAuB,OAAA;AAAE,+HAAA,6BAA6B,OAAA;AAGlD,QAAA,QAAQ,GAAG,CAAC,+BAAY,CAAC,CAAA","sourcesContent":["import { AssistantRun } from './assistant-run.js'\n\nexport { AssistantRun }\nexport { runAssistantUnattended, findAssistantRun } from './run-unattended.js'\nexport type { UnattendedRunInput, UnattendedRunDeps } from './run-unattended.js'\nexport { UNATTENDED_DEFAULTS } from './limits.js'\nexport { assistantRunOutcomeText, ASSISTANT_RUN_OUTCOME_ENGLISH } from './run-outcome.js'\nexport type { AssistantRunStatus } from './run-ledger.js'\n\nexport const entities = [AssistantRun]\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"limits.js","sourceRoot":"","sources":["../../../server/service/unattended-run/limits.ts"],"names":[],"mappings":";;;AAgBA,4CAOC;AApBY,QAAA,mBAAmB,GAA+B;IAC7D,aAAa,EAAE,CAAC;IAChB,SAAS,EAAE,KAAK;IAChB,SAAS,EAAE,MAAM;CAClB,CAAA;AAED;;;GAGG;AACU,QAAA,iBAAiB,GAAG,KAAK,CAAA;AAEtC,qEAAqE;AACrE,SAAgB,gBAAgB,CAAC,QAAsC;IACrE,MAAM,IAAI,GAAG,CAAC,KAAc,EAAE,QAAgB,EAAE,EAAE,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA;IACxI,OAAO;QACL,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,aAAa,EAAE,2BAAmB,CAAC,aAAa,CAAC,CAAC;QAC3F,SAAS,EAAE,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,2BAAmB,CAAC,SAAS,CAAC;QACnE,SAAS,EAAE,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,2BAAmB,CAAC,SAAS,CAAC;KACpE,CAAA;AACH,CAAC","sourcesContent":["/* Pure. What one unattended run of a mode may spend (design/ai/unattended-run.md §4). */\nimport type { UnattendedLimits } from '../assistant-mode/types.js'\n\nexport const UNATTENDED_DEFAULTS: Required<UnattendedLimits> = {\n maxModelCalls: 8,\n maxTokens: 60000,\n timeoutMs: 120000\n}\n\n/**\n * How long past its time limit a running attempt is still taken as alive. A server that died mid-run leaves the row\n * `running`; past this the next call takes the occurrence over (§5).\n */\nexport const ABANDON_MARGIN_MS = 30000\n\n/** The mode's limits, each absent or unusable one at its default. */\nexport function unattendedLimits(declared: UnattendedLimits | undefined): Required<UnattendedLimits> {\n const pick = (value: unknown, fallback: number) => (typeof value === 'number' && Number.isFinite(value) && value > 0 ? value : fallback)\n return {\n maxModelCalls: Math.floor(pick(declared?.maxModelCalls, UNATTENDED_DEFAULTS.maxModelCalls)),\n maxTokens: pick(declared?.maxTokens, UNATTENDED_DEFAULTS.maxTokens),\n timeoutMs: pick(declared?.timeoutMs, UNATTENDED_DEFAULTS.timeoutMs)\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run-as.js","sourceRoot":"","sources":["../../../server/service/unattended-run/run-as.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAqBH,gCAWC;AA9BD,4EAA4E;AAC/D,QAAA,kBAAkB,GAAG,EAAE,QAAQ,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,CAAA;AAiBlG,wFAAwF;AACjF,KAAK,UAAU,UAAU,CAC9B,IAA8B,EAC9B,MAAe,EACf,MAAqD;IAErD,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,OAAO,EAAE,0BAA0B,EAAE,CAAA;IACzD,gHAAgH;IAChH,IAAI,IAAI,CAAC,MAAM,KAAK,WAAW;QAAE,OAAO,EAAE,OAAO,EAAE,2BAA2B,EAAE,CAAA;IAChF,IAAI,CAAC,CAAC,MAAM,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAAE,OAAO,EAAE,OAAO,EAAE,6BAA6B,EAAE,CAAA;IAC/F,IAAI,CAAC,CAAC,MAAM,MAAM,CAAC,OAAO,CAAC,0BAAkB,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAAE,OAAO,EAAE,OAAO,EAAE,gCAAgC,EAAE,CAAA;IACnH,OAAO,EAAE,IAAI,EAAE,CAAA;AACjB,CAAC","sourcesContent":["/*\n * Who the run is - judged again at every run (design/ai/unattended-run.md §2, ADR-0142 §8.1).\n *\n * The run acts for the policy owner and for no one else. There is no second user to fall back to: a refused owner\n * means a refused run, never one under an administrator.\n */\n\n/** The same door a person passes to ask the assistant (`assistantChat`). */\nexport const ASK_ASSISTANT_GATE = { category: 'ai-assistant', privilege: 'mutation', owner: true }\n\nexport type RunAsRefusal =\n | 'assistant-run-as-unknown'\n | 'assistant-run-as-inactive'\n | 'assistant-run-as-not-member'\n | 'assistant-run-as-not-permitted'\n\nexport interface RunAsChecks<TUser, TDomain> {\n /** The user as stored now - not as the caller last saw them. */\n findUser: (id: string) => Promise<TUser | undefined | null>\n /** Whether they can enter this domain - auth-base `canUserCheckinDomain`. */\n mayCheckin: (user: TUser, domain: TDomain) => Promise<boolean>\n /** auth-base `checkPermission`, with no address and no prohibitions: there is no request. */\n permits: (gate: typeof ASK_ASSISTANT_GATE, user: TUser, domain: TDomain) => Promise<boolean>\n}\n\n/** `user` is the account as `findUser` read it just now - absent when there is none. */\nexport async function judgeRunAs<TUser extends { id?: string; status?: string }, TDomain>(\n user: TUser | undefined | null,\n domain: TDomain,\n checks: Omit<RunAsChecks<TUser, TDomain>, 'findUser'>\n): Promise<{ user: TUser } | { refused: RunAsRefusal }> {\n if (!user) return { refused: 'assistant-run-as-unknown' }\n /* Only an account that can sign in now. Locked, banned, deleted, or one waiting for a password reset is not. */\n if (user.status !== 'activated') return { refused: 'assistant-run-as-inactive' }\n if (!(await checks.mayCheckin(user, domain))) return { refused: 'assistant-run-as-not-member' }\n if (!(await checks.permits(ASK_ASSISTANT_GATE, user, domain))) return { refused: 'assistant-run-as-not-permitted' }\n return { user }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run-budget.js","sourceRoot":"","sources":["../../../server/service/unattended-run/run-budget.ts"],"names":[],"mappings":";;;AAwBA,wCAiCC;AAxCD,MAAa,iBAAkB,SAAQ,KAAK;IAE1C,YAAqB,MAAyC;QAC5D,KAAK,CAAC,uBAAuB,MAAM,CAAC,KAAK,WAAW,MAAM,CAAC,IAAI,OAAO,MAAM,CAAC,GAAG,GAAG,CAAC,CAAA;QADjE,WAAM,GAAN,MAAM,CAAmC;QADrD,SAAI,GAAG,+BAA+B,CAAA;IAG/C,CAAC;CACF;AALD,8CAKC;AAED,SAAgB,cAAc,CAAC,MAAmB,EAAE,MAAoD;IACtG,MAAM,KAAK,GAAa,EAAE,UAAU,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,CAAA;IAE1E,MAAM,KAAK,GAAG,GAAG,EAAE;QACjB,IAAI,KAAK,CAAC,UAAU,IAAI,MAAM,CAAC,aAAa,EAAE,CAAC;YAC7C,KAAK,CAAC,QAAQ,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,CAAC,aAAa,EAAE,IAAI,EAAE,KAAK,CAAC,UAAU,EAAE,CAAA;QAChG,CAAC;aAAM,IAAI,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,YAAY,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;YACtE,KAAK,CAAC,QAAQ,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,WAAW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U,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE;KACvB,CAAA;IAChB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,CAAA;AACnC,CAAC","sourcesContent":["/*\n * The client one unattended run talks through - it counts what the run spends and refuses the request past the limit\n * (design/ai/unattended-run.md §4).\n *\n * It wraps the domain's metered client, so every request still writes its AiUsage row at the provider boundary\n * (ADR-0061 decision 6); this only adds the run's own ceiling.\n */\nimport type { AgentClient } from '@things-factory/ai-client-base'\n\nexport interface RunSpend {\n modelCalls: number\n inputTokens: number\n outputTokens: number\n /** Set once a request was refused, with the limit it hit. */\n exceeded?: { limit: 'model-calls' | 'tokens'; max: number; used: number }\n}\n\nexport class RunBudgetExceeded extends Error {\n readonly code = 'assistant-run-budget-exceeded'\n constructor(readonly params: NonNullable<RunSpend['exceeded']>) {\n super(`the run reached its ${params.limit} limit (${params.used} of ${params.max})`)\n }\n}\n\nexport function budgetedClient(client: AgentClient, limits: { maxModelCalls: number; maxTokens: number }): { client: AgentClient; spend: RunSpend } {\n const spend: RunSpend = { modelCalls: 0, inputTokens: 0, outputTokens: 0 }\n\n const admit = () => {\n if (spend.modelCalls >= limits.maxModelCalls) {\n spend.exceeded ??= { limit: 'model-calls', max: limits.maxModelCalls, used: spend.modelCalls }\n } else if (spend.inputTokens + spend.outputTokens >= limits.maxTokens) {\n spend.exceeded ??= { limit: 'tokens', max: limits.maxTokens, used: spend.inputTokens + spend.outputTokens }\n }\n if (spend.exceeded) throw new RunBudgetExceeded(spend.exceeded)\n spend.modelCalls++\n }\n\n const counted = (options: any) => ({\n ...options,\n onUsage: (usage: any) => {\n spend.inputTokens += Number(usage?.inputTokens) || 0\n spend.outputTokens += Number(usage?.outputTokens) || 0\n options?.onUsage?.(usage)\n }\n })\n\n const wrapped: AgentClient = {\n id: client.id,\n agent: client.agent,\n chat: (messages, options) => (admit(), client.chat(messages, counted(options))),\n generateJSON: (prompt, options) => (admit(), client.generateJSON(prompt, counted(options))),\n ...(client.chatWithTools && {\n chatWithTools: (messages, tools, options) => (admit(), client.chatWithTools!(messages, tools, counted(options)))\n }),\n listModels: () => client.listModels()\n } as AgentClient\n return { client: wrapped, spend }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run-ledger.js","sourceRoot":"","sources":["../../../server/service/unattended-run/run-ledger.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAgBH,4BASC;AAhBD;;;;;;GAMG;AACH,SAAgB,QAAQ,CAAC,GAAc,EAAE,GAAS;IAChD,IAAI,GAAG,CAAC,MAAM,KAAK,WAAW;QAAE,OAAO,QAAQ,CAAA;IAC/C,IAAI,GAAG,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAC7B,MAAM,QAAQ,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,GAAG,CAAA;QAC1E,kHAAkH;QAClH,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC;YAAE,OAAO,QAAQ,CAAA;QAC/C,OAAO,QAAQ,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAA;IACvD,CAAC;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC","sourcesContent":["/*\n * Pure. What a call for an occurrence that already has a row does (design/ai/unattended-run.md §5).\n *\n * One row is one occurrence - (domain, source, subject, scheduledAt). scheduler-client calls again when an answer came\n * late or failed; a second call must not run the model a second time while the first is alive or after it succeeded.\n */\n\nexport type AssistantRunStatus = 'running' | 'succeeded' | 'failed' | 'refused'\n\nexport interface LedgerRow {\n status: AssistantRunStatus | string\n deadlineAt?: Date | string | null\n}\n\n/**\n * `return` - hand the stored row back, run nothing. `retake` - start the next attempt on the same row.\n *\n * A succeeded run is the answer. A running one is left alone until its deadline; past it the server that held it is\n * taken as gone. A failed or refused one runs again - a retry is for exactly that, and how many retries there are is\n * the caller's limit (scheduler-client `max_retry_count`), not this one's.\n */\nexport function nextStep(row: LedgerRow, now: Date): 'return' | 'retake' {\n if (row.status === 'succeeded') return 'return'\n if (row.status === 'running') {\n const deadline = row.deadlineAt ? new Date(row.deadlineAt).valueOf() : NaN\n /* A running row with no readable deadline is not taken over - two runs at once is the one thing this prevents. */\n if (!Number.isFinite(deadline)) return 'return'\n return deadline > now.valueOf() ? 'return' : 'retake'\n }\n return 'retake'\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run-outcome.js","sourceRoot":"","sources":["../../../server/service/unattended-run/run-outcome.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAwBH,0DAYC;AAlCM,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,oBAAoB,IAAI,EAAE,CAAA;AAAzD,QAAA,UAAU,cAA+C;AAEzD,QAAA,6BAA6B,GAA2B;IACnE,0BAA0B,EAAE,mDAAmD;IAC/E,2BAA2B,EAAE,8DAA8D;IAC3F,6BAA6B,EAAE,sEAAsE;IACrG,gCAAgC,EAAE,yEAAyE;IAC3G,+BAA+B,EAAE,0DAA0D;IAC3F,wBAAwB,EAAE,2CAA2C;IACrE,+BAA+B,EAAE,kEAAkE;IACnG,0BAA0B,EAAE,8CAA8C;IAC1E,uBAAuB,EAAE,+CAA+C;IACxE,2BAA2B,EAAE,wCAAwC;IACrE,2BAA2B,EAAE,qCAAqC;IAClE,yBAAyB,EAAE,gDAAgD;IAC3E,mBAAmB,EAAE,mCAAmC;IACxD,wBAAwB,EAAE,yDAAyD;CACpF,CAAA;AAID,+FAA+F;AAC/F,SAAgB,uBAAuB,CAAC,GAAmE,EAAE,CAAa;IACxH,MAAM,IAAI,GAAG,GAAG,EAAE,WAAW,CAAA;IAC7B,IAAI,CAAC,IAAI;QAAE,OAAO,SAAS,CAAA;IAC3B,IAAI,MAAM,GAA4B,EAAE,CAAA;IACxC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IACjE,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,GAAG,EAAE,CAAA;IACb,CAAC;IACD,MAAM,OAAO,GAAG,qCAA6B,CAAC,IAAI,CAAC,IAAI,IAAI,CAAA;IAC3D,MAAM,IAAI,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;IACzI,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAA,kBAAU,EAAC,IAAI,CAAC,EAAE,EAAE,GAAG,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;AACtF,CAAC","sourcesContent":["/*\n * Why a run failed or was refused, as a person reads it (design/ai/unattended-run.md §7).\n *\n * The run keeps a code and its values (ADR-0054); the sentence is made where it is shown, under this package's key\n * `ai-assistant.run.<code>` - an outcome is a stored value, not a thrown refusal. The English below is the sentence\n * when no translation has the key; the application that shows a run does not write its own.\n */\n\nexport const outcomeKey = (code: string) => `ai-assistant.run.${code}`\n\nexport const ASSISTANT_RUN_OUTCOME_ENGLISH: Record<string, string> = {\n 'assistant-run-as-unknown': 'the account the run was to act as does not exist.',\n 'assistant-run-as-inactive': \"the owner's account is not active, so the run did not start.\",\n 'assistant-run-as-not-member': 'the owner can no longer enter this domain, so the run did not start.',\n 'assistant-run-as-not-permitted': 'the owner may no longer ask the AI assistant, so the run did not start.',\n 'assistant-mode-not-unattended': 'the assistant mode {kind} does not run without a person.',\n 'unknown-assistant-mode': 'this server has no assistant mode {kind}.',\n 'assistant-run-budget-exceeded': 'the run reached its {limit} limit ({used} of {max}) and stopped.',\n 'assistant-run-step-limit': 'the run did not finish within {steps} steps.',\n 'assistant-run-timeout': 'the run did not finish within {timeoutMs} ms.',\n 'assistant-run-empty-draft': 'the run ended without writing a draft.',\n 'assistant-run-model-error': 'the AI model failed during the run.',\n 'assistant-run-abandoned': 'the run stopped partway and was started again.',\n 'ai-not-configured': 'AI is not set up for this domain.',\n 'ai-agent-not-available': 'the AI agent picked for this run is not available here.'\n}\n\ntype Translate = (key: string, options?: Record<string, unknown>) => string\n\n/** The sentence for a run's outcome, or undefined when it has none (running, or succeeded). */\nexport function assistantRunOutcomeText(run: { outcomeCode?: string | null; outcomeParams?: string | null }, t?: Translate): string | undefined {\n const code = run?.outcomeCode\n if (!code) return undefined\n let params: Record<string, unknown> = {}\n try {\n params = run.outcomeParams ? JSON.parse(run.outcomeParams) : {}\n } catch {\n params = {}\n }\n const english = ASSISTANT_RUN_OUTCOME_ENGLISH[code] ?? code\n const fill = (text: string) => text.replace(/\\{(\\w+)\\}/g, (_, name) => (params[name] === undefined ? `{${name}}` : String(params[name])))\n return t ? t(outcomeKey(code), { ...params, defaultValue: english }) : fill(english)\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run-store.js","sourceRoot":"","sources":["../../../server/service/unattended-run/run-store.ts"],"names":[],"mappings":";;AAqFA,0CA4EC;AAxJD,yDAAiD;AACjD,mDAA0C;AA8C1C,2EAA2E;AAC3E,MAAM,OAAO,GAAG;IACd,UAAU,EAAE,IAAI;IAChB,KAAK,EAAE,IAAI;IACX,KAAK,EAAE,IAAI;IACX,KAAK,EAAE,IAAI;IACX,WAAW,EAAE,IAAI;IACjB,aAAa,EAAE,IAAI;IACnB,iBAAiB,EAAE,IAAI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AAC,MAAM,IAAI,CAAC,QAAQ,CAAC,CAAE,EAAE,CAAA;QACxD,CAAC;QAED,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM;YACvB,MAAM,UAAU,EAAE;iBACf,kBAAkB,EAAE;iBACpB,MAAM,CAAC,+BAAY,CAAC;iBACpB,GAAG,CAAC,MAAa,CAAC;iBAClB,KAAK,CAAC,sDAAsD,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;iBACxH,OAAO,EAAE,CAAA;YACZ,OAAO,CAAC,MAAM,UAAU,EAAE,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAS,EAAE,CAAC,CAAE,CAAA;QACzE,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["/*\n * Where runs are kept - one row per occurrence, attempts on the same row (design/ai/unattended-run.md §5).\n *\n * Two calls for one occurrence at once are parted by the unique index: one insert wins, the other reads the row it\n * made. Taking an occurrence over is one update guarded by the attempt it saw, so two servers cannot both take it.\n * Finishing is guarded the same way: an attempt that was taken over and ends late does not write over the next one.\n */\nimport type { Repository } from 'typeorm'\n\nimport { AssistantRun } from './assistant-run.js'\nimport { nextStep } from './run-ledger.js'\n\nexport interface RunIdentity {\n domainId: string\n source: string\n subject: string\n scheduledAt: Date\n}\n\nexport interface RunStart {\n name: string\n modeKind: string\n modeTarget?: string\n /** Absent when the account named does not exist - the row still says the run was refused. */\n runAsId?: string\n startedAt: Date\n deadlineAt: Date\n}\n\nexport type RunEnding = Partial<\n Pick<\n AssistantRun,\n | 'status'\n | 'finishedAt'\n | 'draft'\n | 'reads'\n | 'doors'\n | 'outcomeCode'\n | 'outcomeParams'\n | 'groundingWarnings'\n | 'agentId'\n | 'clientId'\n | 'modelCalls'\n | 'inputTokens'\n | 'outputTokens'\n | 'cardsDropped'\n >\n>\n\nexport interface RunStore {\n /** The row of this occurrence, and whether this call holds its attempt now. */\n claim(identity: RunIdentity, start: RunStart, now: Date): Promise<{ claimed: boolean; row: AssistantRun }>\n /** Ends the attempt the caller holds. A later attempt's row is returned untouched. */\n finish(held: { id: string; attempt: number }, ending: RunEnding): Promise<AssistantRun>\n}\n\n/** What a fresh attempt starts with - nothing of the attempt before it. */\nconst CLEARED = {\n finishedAt: null,\n draft: null,\n reads: null,\n doors: null,\n outcomeCode: null,\n outcomeParams: null,\n groundingWarnings: null,\n agentId: null,\n clientId: null,\n modelCalls: 0,\n inputTokens: 0,\n outputTokens: 0,\n cardsDropped: 0\n}\n\nfunction endingOf(row: AssistantRun) {\n /* A running attempt being taken over did not end by itself - it is closed as abandoned. */\n const abandoned = row.status === 'running'\n return {\n attempt: row.attempt,\n status: abandoned ? 'failed' : row.status,\n outcomeCode: abandoned ? 'assistant-run-abandoned' : row.outcomeCode ?? null,\n startedAt: row.startedAt ?? null,\n finishedAt: abandoned ? null : row.finishedAt ?? null\n }\n}\n\nexport function typeormRunStore(repository: () => Repository<AssistantRun>): RunStore {\n const where = (identity: RunIdentity) => ({\n domain: { id: identity.domainId },\n source: identity.source,\n subject: identity.subject,\n scheduledAt: identity.scheduledAt\n })\n\n const read = (identity: RunIdentity) => repository().findOne({ where: where(identity) as any })\n\n async function retake(row: AssistantRun, start: RunStart): Promise<boolean> {\n const history = [...((row as any).attemptsJson ?? []), endingOf(row)]\n const result = await repository()\n .createQueryBuilder()\n .update(AssistantRun)\n .set({\n ...CLEARED,\n status: 'running',\n attempt: row.attempt + 1,\n attempts: JSON.stringify(history),\n startedAt: start.startedAt,\n deadlineAt: start.deadlineAt,\n modeKind: start.modeKind,\n modeTarget: start.modeTarget ?? null,\n runAs: start.runAsId ? { id: start.runAsId } : null,\n updater: start.runAsId ? { id: start.runAsId } : null\n } as any)\n .where('id = :id AND attempt = :attempt AND status = :status', { id: row.id, attempt: row.attempt, status: row.status })\n .execute()\n return result.affected === 1\n }\n\n return {\n async claim(identity, start, now) {\n let row = await read(identity)\n if (!row) {\n try {\n await repository().insert({\n ...where(identity),\n name: start.name,\n modeKind: start.modeKind,\n modeTarget: start.modeTarget,\n ...(start.runAsId ? { runAs: { id: start.runAsId }, creator: { id: start.runAsId }, updater: { id: start.runAsId } } : {}),\n status: 'running',\n attempt: 1,\n startedAt: start.startedAt,\n deadlineAt: start.deadlineAt,\n modelCalls: 0,\n inputTokens: 0,\n outputTokens: 0,\n cardsDropped: 0\n } as any)\n return { claimed: true, row: (await read(identity))! }\n } catch (error) {\n /* Another call made the row first - the unique index said so. Anything else is not that and is thrown. */\n row = await read(identity)\n if (!row) throw error\n return { claimed: false, row }\n }\n }\n\n if (nextStep(row, now) === 'return') return { claimed: false, row }\n const took = await retake(row, start)\n return { claimed: took, row: (await read(identity))! }\n },\n\n async finish(held, ending) {\n await repository()\n .createQueryBuilder()\n .update(AssistantRun)\n .set(ending as any)\n .where('id = :id AND attempt = :attempt AND status = :status', { id: held.id, attempt: held.attempt, status: 'running' })\n .execute()\n return (await repository().findOne({ where: { id: held.id } as any }))!\n }\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run-unattended.js","sourceRoot":"","sources":["../../../server/service/unattended-run/run-unattended.ts"],"names":[],"mappings":";;AA6GA,wDAiIC;AAGD,4CAMC;AAvPD;;;;;;;;;;;;;;GAcG;AACH,mEAAoL;AACpL,yDAAuF;AACvF,iDAAqD;AAErD,+DAAgE;AAChE,6EAA+E;AAC/E,uEAAiE;AACjE,kEAA6D;AAC7D,sDAAiD;AACjD,yDAAiD;AACjD,2CAAiE;AACjE,mDAAmE;AACnE,2CAA0D;AAC1D,iDAA+E;AAC/E,iEAAyD;AAkCzD,MAAM,GAAG,GAAG,oCAAoC,CAAA;AAEhD,SAAS,OAAO,CAAC,KAAa;IAC5B,MAAM,KAAK,GAAQ,IAAI,KAAK,CAAC,4BAA4B,KAAK,4BAA4B,CAAC,CAAA;IAC3F,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,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,IAAI;QACrG,GAAG,KAAK,EAAE;KACJ,CAAC,CAAA;AACX,CAAC;AAED,wHAAwH;AACjH,KAAK,UAAU,gBAAgB,CAAC,QAAmG;IACxI,MAAM,UAAU,GAAG,IAAA,qBAAa,EAAC,+BAAY,CAAC,CAAA;IAC9C,IAAI,IAAI,IAAI,QAAQ;QAAE,OAAO,UAAU,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;IAC/E,OAAO,UAAU,CAAC,OAAO,CAAC;QACxB,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,QAAQ,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,WAAW,EAAE,QAAQ,CAAC,WAAW,EAAS;KAC3I,CAAC,CAAA;AACJ,CAAC","sourcesContent":["/*\n * Run an assistant mode with no person in it, for scheduled work, and keep what it wrote as a draft\n * (operato-application/design/ai/unattended-run.md, ADR-0142 §8.1, user ruling C 2026-10-20).\n *\n * A server function and no GraphQL door: a door would let a person name someone else as `runAs`. The caller is a\n * server's scheduled task - Office's periodic strategy review is the first.\n *\n * identity (domain, source, subject, scheduledAt) is one row - a retry hands the stored run back (§5)\n * who the run-as user, judged again now; refused when they cannot ask the assistant themselves (§2)\n * tools the mode's read tools behind that user's own doors; no 입력안, no cards kept (§3)\n * limits the mode's: model requests, tokens, wall time (§4)\n * outcome succeeded with a draft, failed or refused with a code - never an empty success (§7)\n *\n * Every tool call goes through the registry door, so the recorders write it down as they do a turn's (§6).\n */\nimport { aiClientFor, findToolSpec, registryAssistantChat, type AgentClient, type AiClientRequest, type ToolAccessCheck, type ToolCallRecord } from '@things-factory/ai-client-base'\nimport { User, canUserCheckinDomain, checkPermission } from '@things-factory/auth-base'\nimport { getRepository } from '@things-factory/shell'\n\nimport { getAssistantMode } from '../assistant-mode/registry.js'\nimport { unattendedToolCategories } from '../assistant-mode/mode-categories.js'\nimport { doorsForAnswer } from '../chat-message/message-doors.js'\nimport { groundingSourcesFor } from '../grounding-sources.js'\nimport { toolAccessFor } from '../tool-access.js'\nimport { AssistantRun } from './assistant-run.js'\nimport { ABANDON_MARGIN_MS, unattendedLimits } from './limits.js'\nimport { budgetedClient, RunBudgetExceeded } from './run-budget.js'\nimport { judgeRunAs, type RunAsChecks } from './run-as.js'\nimport { typeormRunStore, type RunEnding, type RunStore } from './run-store.js'\nimport { unattendedPrompt } from './unattended-prompt.js'\n\nexport interface UnattendedRunInput {\n /** The domain the run is in, as loaded - its parent and owner decide who can enter it. */\n domain: { id: string; [key: string]: any }\n /** The user the run acts as - the policy owner. Their privileges and doors only. */\n runAs: string\n /** Which occurrence this is. The same three again is the same run. */\n run: {\n /** Who scheduled it - `<app>.<work>`, e.g. `office.strategy-review`. */\n source: string\n /** What it is about in the source's terms - a policy id. */\n subject: string\n scheduledAt: Date\n }\n /** A registered mode that declares `unattended`. */\n mode: { kind: string; target?: string }\n /** What this occurrence is asked to do - the caller server's text, read by the model (English). */\n instruction: string\n /** What the run is about, for the tools. Filled by the caller's server; still never used for authorization. */\n hostContext?: Record<string, any>\n /** The language of the draft - the owner's. Absent: their account's locale. */\n lng?: string\n}\n\n/** What the run reaches outside itself. The defaults are the server's; the tests hand their own. */\nexport interface UnattendedRunDeps {\n store: RunStore\n runAs: RunAsChecks<any, any>\n clientFor: (request: AiClientRequest) => Promise<AgentClient>\n toolAccess: (state: any) => ToolAccessCheck\n now: () => Date\n}\n\nconst KEY = /^[a-z][a-z0-9-]*\\.[a-z][a-z0-9-]*$/\n\nfunction invalid(field: string): Error {\n const error: any = new Error(`runAssistantUnattended: '${field}' is missing or not usable`)\n error.code = 'assistant-run-input-invalid'\n error.params = { field }\n return error\n}\n\nfunction checkInput(input: UnattendedRunInput) {\n if (!input?.domain?.id) throw invalid('domain')\n if (!input.runAs) throw invalid('runAs')\n if (!KEY.test(String(input.run?.source ?? '')) || input.run.source.length > 64) throw invalid('run.source')\n if (!String(input.run.subject ?? '').trim() || String(input.run.subject).length > 64) throw invalid('run.subject')\n if (!(input.run.scheduledAt instanceof Date) || !Number.isFinite(input.run.scheduledAt.valueOf())) throw invalid('run.scheduledAt')\n if (!input.mode?.kind) throw invalid('mode.kind')\n if (!String(input.instruction ?? '').trim()) throw invalid('instruction')\n}\n\nfunction defaultDeps(): UnattendedRunDeps {\n return {\n store: typeormRunStore(() => getRepository(AssistantRun)),\n runAs: {\n findUser: id => getRepository(User).findOne({ where: { id } }),\n mayCheckin: (user, domain) => canUserCheckinDomain(user, domain),\n /* No request: no address to refuse from, and no license prohibition - those cover writes this run never makes. */\n permits: (gate, user, domain) => checkPermission(gate as any, user, domain, false, [])\n },\n clientFor: aiClientFor,\n toolAccess: state => toolAccessFor({ state }),\n now: () => new Date()\n }\n}\n\n/** Why the loop stopped, as the run's code. Only a clean end with text is a draft. */\nfunction failureOf(loop: any, baseText: string): { code: string; params?: any } | undefined {\n const abort = loop?.abortReason\n if (abort?.type === 'max_iterations') return { code: 'assistant-run-step-limit', params: { steps: abort.iter } }\n if (abort?.type === 'provider_error') return { code: 'assistant-run-model-error', params: { message: String(abort.message ?? '').slice(0, 500) } }\n if (abort) return { code: 'assistant-run-model-error', params: { stopped: abort.type } }\n if (!baseText.trim()) return { code: 'assistant-run-empty-draft' }\n return undefined\n}\n\nconst TIMED_OUT = Symbol('timed-out')\n\nexport async function runAssistantUnattended(input: UnattendedRunInput, deps: UnattendedRunDeps = defaultDeps()): Promise<AssistantRun> {\n checkInput(input)\n const { domain, run } = input\n const mode = getAssistantMode(input.mode.kind)\n const limits = unattendedLimits(mode?.unattended)\n const startedAt = deps.now()\n /* The account as stored now - read once, and judged after the occurrence is held. */\n const account = await deps.runAs.findUser(input.runAs)\n\n const { claimed, row } = await deps.store.claim(\n { domainId: domain.id, source: run.source, subject: run.subject, scheduledAt: run.scheduledAt },\n {\n name: `${run.source} ${run.subject} ${run.scheduledAt.toISOString()}`,\n modeKind: input.mode.kind,\n modeTarget: input.mode.target,\n runAsId: account?.id,\n startedAt,\n deadlineAt: new Date(startedAt.valueOf() + limits.timeoutMs + ABANDON_MARGIN_MS)\n },\n startedAt\n )\n /* Succeeded, or running elsewhere and still alive - the caller gets that row and the model is not called again. */\n if (!claimed) return row\n\n const held = { id: row.id!, attempt: row.attempt }\n const end = (ending: RunEnding) => deps.store.finish(held, { finishedAt: deps.now(), ...ending })\n const refuse = (code: string, params?: any) => end({ status: 'refused', outcomeCode: code, outcomeParams: params ? JSON.stringify(params) : null } as any)\n const fail = (code: string, params?: any, spent?: RunEnding) =>\n end({ status: 'failed', outcomeCode: code, outcomeParams: params ? JSON.stringify(params) : null, ...spent } as any)\n\n if (!mode) return refuse('unknown-assistant-mode', { kind: input.mode.kind })\n if (!mode.unattended) return refuse('assistant-mode-not-unattended', { kind: mode.kind })\n\n const judged = await judgeRunAs(account, domain, deps.runAs)\n if ('refused' in judged) return refuse(judged.refused, { userId: input.runAs })\n const user = judged.user\n\n let agentClient: AgentClient\n try {\n agentClient = await deps.clientFor({ domain: domain as any, user, modeKind: mode.kind })\n } catch (error: any) {\n /* No AI here, or not the agent asked for - nothing ran. Its own code, as the conversation door says it. */\n if (error?.code) return refuse(String(error.code), error.params)\n return fail('assistant-run-model-error', { message: String(error?.message ?? error).slice(0, 500) })\n }\n\n const { client, spend } = budgetedClient(agentClient, limits)\n const reads: ToolCallRecord[] = []\n let over = false\n const state: any = { domain, user, lng: input.lng ?? user.locale, aiAgentId: agentClient.agent.id }\n const categories = unattendedToolCategories(mode)\n const systemPrompt = unattendedPrompt(mode.systemPrompt, state.lng)\n const messages = [{ role: 'user' as const, content: input.instruction }]\n\n const abort = new AbortController()\n let timer: ReturnType<typeof setTimeout> | undefined\n const timeout = new Promise<typeof TIMED_OUT>(resolve => {\n timer = setTimeout(() => {\n abort.abort()\n resolve(TIMED_OUT)\n }, limits.timeoutMs)\n })\n\n const spent = (): RunEnding => ({\n reads: JSON.stringify(reads),\n agentId: agentClient.agent.id,\n clientId: agentClient.id,\n modelCalls: spend.modelCalls,\n inputTokens: spend.inputTokens,\n outputTokens: spend.outputTokens\n })\n\n let result: any\n try {\n result = await Promise.race([\n registryAssistantChat({\n client,\n messages,\n systemPrompt,\n toolCategories: categories,\n /* No screen and no conversation - the mode's own tools in front, the lists opened as the run needs (ADR-0061 decision 9). */\n front: { categories: mode.toolCategories ?? [] },\n mode: { kind: mode.kind, ...(input.mode.target ? { target: input.mode.target } : {}) },\n toolAccess: deps.toolAccess(state),\n hostContext: input.hostContext,\n state,\n temperature: mode.temperature,\n maxTokens: mode.maxTokens,\n requireToolOnFirstTurn: mode.requireToolOnFirstTurn,\n /* Each step is one request. A run that reaches the last step without an answer failed - no wrap-up call (§4). */\n maxIterations: limits.maxModelCalls,\n salvageOnMaxIterations: false,\n signal: abort.signal,\n onToolCall: record => {\n if (!over) reads.push(record)\n },\n run: { id: held.id, source: run.source, subject: run.subject, scheduledAt: run.scheduledAt.toISOString() },\n groundingSources: groundingSourcesFor({ systemPrompt, messages: messages as any, hostContext: input.hostContext })\n }),\n timeout\n ])\n } catch (error: any) {\n over = true\n clearTimeout(timer)\n if (error instanceof RunBudgetExceeded) return fail(error.code, error.params, spent())\n return fail('assistant-run-model-error', { message: String(error?.message ?? error).slice(0, 500) }, spent())\n }\n over = true\n clearTimeout(timer)\n\n if (result === TIMED_OUT) return fail('assistant-run-timeout', { timeoutMs: limits.timeoutMs }, spent())\n /* The loop turns a refused request into a provider error; the budget says which limit it was. */\n if (spend.exceeded) return fail('assistant-run-budget-exceeded', spend.exceeded, spent())\n\n const failure = failureOf(result.loop, result.baseText ?? '')\n if (failure) return fail(failure.code, failure.params, spent())\n\n const doors = doorsForAnswer(\n result.loop.toolUsages ?? [],\n name => (findToolSpec(name, categories) as any)?.doors\n )\n return end({\n status: 'succeeded',\n draft: result.baseText,\n doors,\n cardsDropped: result.loop.proposals?.length ?? 0,\n groundingWarnings: result.groundingWarnings?.length ? JSON.stringify(result.groundingWarnings) : null,\n ...spent()\n } as any)\n}\n\n/** The stored run of an occurrence, for the application that scheduled it - read behind that application's own door. */\nexport async function findAssistantRun(identity: { domainId: string; source: string; subject: string; scheduledAt: Date } | { id: string }): Promise<AssistantRun | null> {\n const repository = getRepository(AssistantRun)\n if ('id' in identity) return repository.findOne({ where: { id: identity.id } })\n return repository.findOne({\n where: { domain: { id: identity.domainId }, source: identity.source, subject: identity.subject, scheduledAt: identity.scheduledAt } as any\n })\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unattended-prompt.js","sourceRoot":"","sources":["../../../server/service/unattended-run/unattended-prompt.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,oCAIC;AAUD,4CAEC;AAlBD,MAAM,SAAS,GAA2B,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,YAAY,EAAE,CAAA;AAEvI,SAAgB,YAAY,CAAC,GAAuB;IAClD,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAA;IACnD,IAAI,CAAC,IAAI;QAAE,OAAO,SAAS,CAAA;IAC3B,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,2BAA2B,IAAI,GAAG,CAAA;AAClG,CAAC;AAEY,QAAA,gBAAgB,GAAG;IAC9B,mIAAmI;IACnI,mGAAmG;IACnG,qIAAqI;IACrI,iHAAiH;IACjH,+FAA+F;CAChG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAEZ,SAAgB,gBAAgB,CAAC,OAAe,EAAE,GAAuB;IACvE,OAAO,GAAG,OAAO,OAAO,wBAAgB,0BAA0B,YAAY,CAAC,GAAG,CAAC,GAAG,CAAA;AACxF,CAAC","sourcesContent":["/*\n * The rules every unattended run follows, after the mode's persona (design/ai/unattended-run.md §3). The reader is the\n * model, so the text is English (ADR-0061 A11); the draft is written in the owner's language.\n */\n\nconst LANGUAGES: Record<string, string> = { ko: 'Korean', en: 'English', ja: 'Japanese', zh: 'Chinese', ms: 'Malay', vi: 'Vietnamese' }\n\nexport function languageName(lng: string | undefined): string {\n const code = String(lng ?? '').trim().toLowerCase()\n if (!code) return 'English'\n return LANGUAGES[code] ?? LANGUAGES[code.split(/[-_]/)[0]] ?? `the language of locale \"${code}\"`\n}\n\nexport const UNATTENDED_RULES = [\n 'No person is reading this as it is written. It runs on a schedule, and your answer is kept as a draft that its owner reads later.',\n '- Read before you write. Every figure and fact in the draft comes from a tool result of this run.',\n '- A read that failed or was refused is said as failed, with what the draft cannot say because of it. Never write it as \"no change\".',\n '- Nothing you call is shown to anyone: there are no cards and no screens to open. Put what matters in the text.',\n '- Do not ask questions - nobody will answer. Where something is missing, say what is missing.'\n].join('\\n')\n\nexport function unattendedPrompt(persona: string, lng: string | undefined): string {\n return `${persona}\\n\\n${UNATTENDED_RULES}\\n- Write the draft in ${languageName(lng)}.`\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"workspace-blocks.js","sourceRoot":"","sources":["../../../server/service/workspace/workspace-blocks.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AA2BH,sCASC;AA2ED,gDAQC;AAGD,8CAIC;AA5HY,QAAA,qBAAqB,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAU,CAAA;AAG1F,QAAA,UAAU,GAAG,EAAE,CAAA;AACf,QAAA,cAAc,GAAG,IAAI,CAAA;AACrB,QAAA,UAAU,GAAG,CAAC,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C,IAAI,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,iBAAiB,EAAE,GAAG,EAAE,KAAK,CAAC,MAAM,GAAG,kBAAU,EAAE,CAAC,CAAA;IACxI,OAAO,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,CAAA;AAC5J,CAAC;AAED,sFAAsF;AACtF,SAAgB,iBAAiB,CAAC,SAAoB;IACpD,MAAM,MAAM,GAA2B,EAAE,CAAA;IACzC,KAAK,MAAM,GAAG,IAAI,SAAS,CAAC,MAAM;QAAE,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAA;IACjJ,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["/*\n * The AI 작업 패널 - what a workspace is made of (operato-application/design/ai/workspace.md §3).\n *\n * The model does not write HTML. A workspace is a list of blocks of known kinds; the screen draws each, so\n * theme, language and accessibility are the framework's. A block that does not fit is not dropped: it is\n * kept as a fact in its place (\"a block that cannot be drawn\"), so the person sees that something was meant\n * to be there. Pure - tested without a server.\n */\n\nexport const WORKSPACE_BLOCK_KINDS = ['heading', 'text', 'metrics', 'table', 'chart', 'steps'] as const\nexport type WorkspaceBlockKind = (typeof WORKSPACE_BLOCK_KINDS)[number]\n\nexport const MAX_BLOCKS = 40\nexport const MAX_TABLE_ROWS = 1000\nexport const MAX_SERIES = 8\nconst MAX_TEXT = 20_000\n\nexport interface WorkspaceBlock {\n kind: WorkspaceBlockKind | 'unreadable'\n [key: string]: unknown\n}\n\nexport interface Workspace {\n name: string\n title: string\n summary?: string\n blocks: WorkspaceBlock[]\n}\n\nconst text = (value: unknown, max = 500): string | undefined => (typeof value === 'string' && value.trim() ? value.trim().slice(0, max) : undefined)\nconst scalar = (value: unknown): string | number | boolean | null =>\n value === null || value === undefined ? null : typeof value === 'number' || typeof value === 'boolean' ? value : String(value).slice(0, 500)\n\n/** A short key of the workspace - the same name in one conversation is the same workspace, a new version. */\nexport function workspaceName(name: unknown, title: string): string {\n const given = typeof name === 'string' ? name.trim().toLowerCase() : ''\n if (/^[a-z0-9][a-z0-9-]{0,63}$/.test(given)) return given\n const slug = (given || title)\n .toLowerCase()\n .replace(/[^a-z0-9가-힣]+/g, '-')\n .replace(/^-+|-+$/g, '')\n .slice(0, 64)\n return slug || 'workspace'\n}\n\nfunction unreadable(kind: unknown, reason: string): WorkspaceBlock {\n return { kind: 'unreadable', was: typeof kind === 'string' ? kind.slice(0, 40) : null, reason }\n}\n\nfunction block(raw: any): WorkspaceBlock {\n const kind = raw?.kind\n switch (kind) {\n case 'heading': {\n const value = text(raw.text, 200)\n if (!value) return unreadable(kind, 'no-text')\n const level = [1, 2, 3].includes(raw.level) ? raw.level : 2\n return { kind, text: value, level }\n }\n case 'text': {\n const value = text(raw.markdown ?? raw.text, MAX_TEXT)\n return value ? { kind, markdown: value } : unreadable(kind, 'no-text')\n }\n case 'metrics': {\n const items = (Array.isArray(raw.items) ? raw.items : [])\n .filter((one: any) => text(one?.label) && one?.value !== undefined && one?.value !== null)\n .slice(0, 12)\n .map((one: any) => ({ label: text(one.label, 80), value: scalar(one.value), ...(text(one.unit, 20) ? { unit: text(one.unit, 20) } : {}), ...(text(one.note, 200) ? { note: text(one.note, 200) } : {}) }))\n return items.length ? { kind, items } : unreadable(kind, 'no-items')\n }\n case 'table': {\n const columns = (Array.isArray(raw.columns) ? raw.columns : [])\n .filter((one: any) => text(one?.name, 80))\n .slice(0, 30)\n .map((one: any) => ({ name: text(one.name, 80)!, ...(text(one.label, 80) ? { label: text(one.label, 80) } : {}), type: ['number', 'date', 'string'].includes(one.type) ? one.type : 'string' }))\n if (!columns.length) return unreadable(kind, 'no-columns')\n const given = Array.isArray(raw.rows) ? raw.rows : []\n /* A row is an object by column name, or an array in column order - models write both. */\n /* A number column reads \"12,400\" as 12400 - cells come as text from a model told one type per field. */\n const cell = (column: any, value: unknown) => {\n const read = scalar(value)\n if (column.type !== 'number' || typeof read !== 'string') return read\n const number = Number(read.replace(/[,\\s₩$€]/g, ''))\n return read.trim() && Number.isFinite(number) ? number : read\n }\n const rows = given.slice(0, MAX_TABLE_ROWS).map((row: any) =>\n Object.fromEntries(columns.map((column: any, i: number) => [column.name, cell(column, Array.isArray(row) ? row[i] : row?.[column.name])]))\n )\n return { kind, columns, rows, ...(text(raw.caption, 300) ? { caption: text(raw.caption, 300) } : {}), ...(given.length > MAX_TABLE_ROWS ? { cut: given.length - MAX_TABLE_ROWS } : {}) }\n }\n case 'chart': {\n const x = (Array.isArray(raw.x) ? raw.x : []).slice(0, 200).map((one: unknown) => String(one ?? '').slice(0, 60))\n const series = (Array.isArray(raw.series) ? raw.series : [])\n .filter((one: any) => text(one?.name, 60) && Array.isArray(one?.values))\n .map((one: any) => ({ name: text(one.name, 60)!, values: x.map((_: unknown, i: number) => (typeof one.values[i] === 'number' && Number.isFinite(one.values[i]) ? one.values[i] : null)) }))\n if (!x.length || !series.length) return unreadable(kind, 'no-series')\n /* Never a ninth hue: past eight, the first seven stay and the rest fold into one \"other\". */\n const shown =\n series.length > MAX_SERIES\n ? [\n ...series.slice(0, MAX_SERIES - 1),\n { name: 'other', other: true, values: x.map((_: unknown, i: number) => series.slice(MAX_SERIES - 1).reduce((acc: number, one: any) => acc + (one.values[i] ?? 0), 0)) }\n ]\n : series\n return { kind, chart: raw.chart === 'line' || raw.type === 'line' || raw.shape === 'line' ? 'line' : 'bar', x, series: shown, ...(text(raw.unit, 20) ? { unit: text(raw.unit, 20) } : {}), ...(text(raw.caption, 300) ? { caption: text(raw.caption, 300) } : {}) }\n }\n case 'steps': {\n const items = (Array.isArray(raw.items) ? raw.items : [])\n .filter((one: any) => text(one?.label, 200))\n .slice(0, 50)\n .map((one: any) => ({ label: text(one.label, 200), state: ['done', 'doing', 'todo', 'failed'].includes(one.state) ? one.state : 'todo', ...(text(one.note, 300) ? { note: text(one.note, 300) } : {}) }))\n return items.length ? { kind, items } : unreadable(kind, 'no-items')\n }\n default:\n return unreadable(kind, 'unknown-kind')\n }\n}\n\n/** The workspace as the screen reads it. */\nexport function normalizeWorkspace(args: any): { workspace?: Workspace; error?: string } {\n const title = text(args?.title, 200)\n if (!title) return { error: 'no-title' }\n const given = Array.isArray(args?.blocks) ? args.blocks : []\n if (!given.length) return { error: 'no-blocks' }\n const blocks = given.slice(0, MAX_BLOCKS).map(block)\n if (given.length > MAX_BLOCKS) blocks.push({ kind: 'unreadable', was: null, reason: 'too-many-blocks', cut: given.length - MAX_BLOCKS })\n return { workspace: { name: workspaceName(args?.name, title), title, ...(text(args?.summary, 500) ? { summary: text(args.summary, 500) } : {}), blocks } }\n}\n\n/** One line of what is in it - for the card in the conversation and for the model. */\nexport function workspaceContents(workspace: Workspace): Record<string, number> {\n const counts: Record<string, number> = {}\n for (const one of workspace.blocks) if (['table', 'chart', 'metrics', 'steps'].includes(one.kind)) counts[one.kind] = (counts[one.kind] ?? 0) + 1\n return counts\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"workspace-tools.js","sourceRoot":"","sources":["../../../server/service/workspace/workspace-tools.ts"],"names":[],"mappings":";;;AAcA,0CAaC;AA3BD;;;;;;;GAOG;AACH,mEAAuG;AAEvG,+DAAoG;AAEvF,QAAA,kBAAkB,GAAG,qBA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AAE,MAAM,EAAE,QAAQ,CAAC,EAAE,EAAE,EAAE;yBAC7J;wBACD,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,8CAA8C,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE;wBACzI,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,oCAAoC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;wBAClG,MAAM,EAAE;4BACN,IAAI,EAAE,OAAO;4BACb,WAAW,EAAE,OAAO;4BACpB,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE;yBAC1H;qBACF;oBACD,QAAQ,EAAE,CAAC,MAAM,CAAC;iBACnB;aACF;SACF;QACD,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC;KACtC;IACD,OAAO,EAAE,CAAC,IAAS,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC;CAClC,CAAA;AAEA,QAAA,iBAAiB,GAAiB;IAC7C,IAAI,EAAE,0BAAkB;IACxB,WAAW,EAAE,sEAAsE;IACnF,QAAQ,EAAE;QACR,qNAAqN;QACrN,6GAA6G;QAC7G,6HAA6H;QAC7H,2FAA2F;KAC5F,CAAC,IAAI,CAAC,IAAI,CAAC;IACZ,KAAK,EAAE,CAAC,IAAI,CAAC;CACd,CAAA;AAED,IAAA,qCAAoB,EAAC,yBAAiB,CAAC,CAAA","sourcesContent":["/*\n * showInWorkspace - the model puts a large result on the AI 작업 패널 (operato-application/design/ai/workspace.md §5).\n *\n * The result rides on the answer as a proposal of kind 'workspace', so the conversation's gates hold for it:\n * who may read the conversation reads the workspace, and a value behind a door the reader cannot pass hides\n * it with the answer (ADR-0073). The tool itself reaches no door - what it carries came from the turn's other\n * tools, whose doors the answer row collects.\n */\nimport { registerToolCategory, type ToolCategory, type ToolSpec } from '@things-factory/ai-client-base'\n\nimport { normalizeWorkspace, workspaceContents, WORKSPACE_BLOCK_KINDS } from './workspace-blocks.js'\n\nexport const WORKSPACE_CATEGORY = 'assistant-workspace'\n\nexport function showInWorkspace(args: any) {\n const { workspace, error } = normalizeWorkspace(args)\n if (!workspace) return { rejected: true, error, message: 'a workspace needs a title and at least one block.' }\n const contents = workspaceContents(workspace)\n return {\n proposed: true,\n kind: 'workspace',\n icon: 'dashboard',\n label: workspace.title,\n workspace,\n contents,\n message: `put \"${workspace.title}\" on the workspace (${workspace.blocks.length} blocks). The person opens it from the card - say in one line what it holds; do not repeat its tables in the answer.`\n }\n}\n\nconst spec = {\n kind: 'read',\n name: 'showInWorkspace',\n doors: [],\n description:\n 'Put a large result on the AI workspace - a page the person opens from a card, beside the conversation. Blocks: ' +\n 'heading{text,level}, text{markdown}, metrics{items:[{label,value,unit,note}]}, table{columns:[{name,label,type:number|date|string}],rows,caption}, ' +\n 'chart{chart:bar|line, x:[labels], series:[{name,values:[numbers]}], unit, caption}, steps{items:[{label,state:done|doing|todo|failed,note}]}.',\n schema: {\n type: 'object',\n properties: {\n name: { type: 'string', description: 'A short key, lowercase with dashes (\"contracts-by-customer\"). The same name again makes a new version of the same workspace.' },\n title: { type: 'string' },\n summary: { type: 'string', description: 'One line under the title.' },\n /*\n * Every field of every block is declared, each with one type: Gemini's function schema (an OpenAPI 3.0\n * subset) refuses a list of types and may leave out a field it was not told of (2026-10-01).\n */\n blocks: {\n type: 'array',\n items: {\n type: 'object',\n properties: {\n kind: { type: 'string', enum: [...WORKSPACE_BLOCK_KINDS] },\n text: { type: 'string', description: 'heading' },\n level: { type: 'integer', description: 'heading: 1-3' },\n markdown: { type: 'string', description: 'text' },\n caption: { type: 'string', description: 'table, chart' },\n unit: { type: 'string', description: 'chart' },\n chart: { type: 'string', enum: ['bar', 'line'], description: 'chart' },\n items: {\n type: 'array',\n description: 'metrics: {label,value,unit,note}; steps: {label,state,note}',\n items: {\n type: 'object',\n properties: {\n label: { type: 'string' },\n value: { type: 'string' },\n unit: { type: 'string' },\n note: { type: 'string' },\n state: { type: 'string', enum: ['done', 'doing', 'todo', 'failed'] }\n }\n }\n },\n columns: {\n type: 'array',\n description: 'table',\n items: { type: 'object', properties: { name: { type: 'string' }, label: { type: 'string' }, type: { type: 'string', enum: ['number', 'date', 'string'] } } }\n },\n rows: { type: 'array', description: 'table: each row is its cells in column order', items: { type: 'array', items: { type: 'string' } } },\n x: { type: 'array', description: 'chart: the labels along the bottom', items: { type: 'string' } },\n series: {\n type: 'array',\n description: 'chart',\n items: { type: 'object', properties: { name: { type: 'string' }, values: { type: 'array', items: { type: 'number' } } } }\n }\n },\n required: ['kind']\n }\n }\n },\n required: ['name', 'title', 'blocks']\n },\n builder: (args: any) => showInWorkspace(args)\n} as ToolSpec\n\nexport const workspaceCategory: ToolCategory = {\n name: WORKSPACE_CATEGORY,\n description: 'the AI workspace - a page for results too large for the conversation',\n guidance: [\n '- When a result is more than a short table (over 20 rows, or two or more tables or charts), or the person asks for a page, call showInWorkspace. Keep the answer short: the point, and that it is on the workspace.',\n '- Every number in a block comes from a tool result in this conversation - never computed or guessed by you.',\n '- To change a workspace, call showInWorkspace again with the same name and the whole new content; it becomes a new version.',\n '- Never say something is on the workspace unless you called showInWorkspace in this turn.'\n ].join('\\n'),\n specs: [spec]\n}\n\nregisterToolCategory(workspaceCategory)\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool-registry-boot-report.js","sourceRoot":"","sources":["../server/tool-registry-boot-report.ts"],"names":[],"mappings":";;AAmBA,gEASC;AAgBD,kEAIC;AAhDD;;;;;;;;;;;GAWG;AACH,6CAA4C;AA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,CAAC;AACH,CAAC;AAED,qEAAqE;AACrE,SAAgB,2BAA2B,CAAC,QAA6C;IACvF,MAAM,MAAM,GAAG,IAAI,GAAG,EAAoB,CAAA;IAC1C,KAAK,MAAM,OAAO,IAAI,QAAQ;QAAE,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IAClH,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,kBAAkB,IAAI,KAAK,OAAO,CAAC,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AACjH,CAAC;AAED;;;GAGG;AACH,OAAO,CAAC,EAAE,CAAC,wBAA+B,EAAE,GAAG,EAAE;IAC/C,KAAK,MAAM,IAAI,IAAI,0BAA0B,CAAC,IAAA,wCAAuB,GAAE,CAAC;QAAE,YAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC3F,KAAK,MAAM,IAAI,IAAI,2BAA2B,CAAC,IAAA,mCAAwB,GAAE,CAAC;QAAE,YAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC7F;;;OAGG;IACH,KAAK,MAAM,IAAI,IAAI,IAAA,0DAA6B,EAAC,IAAA,oDAAuB,GAAE,CAAC;QAAE,YAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAChG,CAAC,CAAC,CAAA","sourcesContent":["/*\n * At boot, say what registered but is not yet what the contracts require — tools that named no doors\n * (ADR-0071 decision 2) and modes offering `/` sentences their tools cannot answer (ADR-0058\n * decision 3).\n *\n * One window, because it is one question: what state is this deployment's AI in (standard A7-a).\n *\n * A tool that names no doors still registers; refusing at registration would stop a whole app from\n * booting over one omission. It is the **gate** that refuses it, tool by tool — such a tool is\n * offered to no conversation (`resolveToolScope`). So this list is not a soft warning about\n * something that still works: it names the tools that are not working, and why.\n */\nimport { logger } from '@things-factory/env'\nimport { getToolRegistryWarnings, type ToolRegistryWarning } from '@things-factory/ai-client-base'\n\nimport { getAssistantModeWarnings, type AssistantModeWarning } from './service/assistant-mode/index.js'\nimport { doorDeclarationWarnings, formatDoorDeclarationWarnings } from './door-declaration-report.js'\n\n/** One line per code: the code, how many, and which tools. Empty when there is nothing to report. */\nexport function formatToolRegistryWarnings(warnings: ReadonlyArray<ToolRegistryWarning>): string[] {\n const byCode = new Map<string, string[]>()\n for (const warning of warnings) {\n const tools = byCode.get(warning.code) ?? []\n /* 문 이름이 있으면 함께 적는다 — 「어느 문이 아직 선언이 없나」가 다음에 할 일이다. */\n tools.push(`${warning.params.category}/${warning.params.tool}(${warning.params.kind})`)\n byCode.set(warning.code, tools)\n }\n return [...byCode].map(([code, tools]) => `[ai-assistant] ${code} ×${tools.length}: ${tools.join(', ')}`)\n}\n\n/** What one warning is about, in the words its code needs - a subject claimed twice names the subject and both. */\nfunction detailOf(warning: AssistantModeWarning): string {\n const { kind, slash, tool, subject, kinds, target } = warning.params\n switch (warning.code) {\n case 'assistant-mode-subject-claimed-twice':\n return `${subject}:${(kinds ?? []).join('+')}`\n case 'assistant-mode-entry-target-unknown':\n return `${kind}→${target}`\n default:\n return `${kind}:/${slash}→${tool}`\n }\n}\n\n/** One line per code: the code, how many, and what each is about. */\nexport function formatAssistantModeWarnings(warnings: ReadonlyArray<AssistantModeWarning>): string[] {\n const byCode = new Map<string, string[]>()\n for (const warning of warnings) byCode.set(warning.code, [...(byCode.get(warning.code) ?? []), detailOf(warning)])\n return [...byCode].map(([code, details]) => `[ai-assistant] ${code} ×${details.length}: ${details.join(', ')}`)\n}\n\n/*\n * After every module has registered: a mode may declare its slash sentences before the package\n * that registers the tools they need, so this cannot be checked when the mode registers.\n */\nprocess.on('bootstrap-module-start' as any, () => {\n for (const line of formatToolRegistryWarnings(getToolRegistryWarnings())) logger.warn(line)\n for (const line of formatAssistantModeWarnings(getAssistantModeWarnings())) logger.warn(line)\n /*\n * 이 자리에서만 물을 수 있는 것 — 적어 둔 문이 스키마에 있나. AUTH 의 필드 표는 스키마를 지은 뒤에\n * 차고, 이 훅은 그 뒤에 돈다(`builtSchema` 를 함께 받는다).\n */\n for (const line of formatDoorDeclarationWarnings(doorDeclarationWarnings())) logger.warn(line)\n})\n"]}
|