@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,248 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Run an assistant mode with no person in it, for scheduled work, and keep what it wrote as a draft
|
|
3
|
-
* (operato-application/design/ai/unattended-run.md, ADR-0142 §8.1, user ruling C 2026-10-20).
|
|
4
|
-
*
|
|
5
|
-
* A server function and no GraphQL door: a door would let a person name someone else as `runAs`. The caller is a
|
|
6
|
-
* server's scheduled task - Office's periodic strategy review is the first.
|
|
7
|
-
*
|
|
8
|
-
* identity (domain, source, subject, scheduledAt) is one row - a retry hands the stored run back (§5)
|
|
9
|
-
* who the run-as user, judged again now; refused when they cannot ask the assistant themselves (§2)
|
|
10
|
-
* tools the mode's read tools behind that user's own doors; no 입력안, no cards kept (§3)
|
|
11
|
-
* limits the mode's: model requests, tokens, wall time (§4)
|
|
12
|
-
* outcome succeeded with a draft, failed or refused with a code - never an empty success (§7)
|
|
13
|
-
*
|
|
14
|
-
* Every tool call goes through the registry door, so the recorders write it down as they do a turn's (§6).
|
|
15
|
-
*/
|
|
16
|
-
import { aiClientFor, findToolSpec, registryAssistantChat, type AgentClient, type AiClientRequest, type ToolAccessCheck, type ToolCallRecord } from '@things-factory/ai-client-base'
|
|
17
|
-
import { User, canUserCheckinDomain, checkPermission } from '@things-factory/auth-base'
|
|
18
|
-
import { getRepository } from '@things-factory/shell'
|
|
19
|
-
|
|
20
|
-
import { getAssistantMode } from '../assistant-mode/registry.js'
|
|
21
|
-
import { unattendedToolCategories } from '../assistant-mode/mode-categories.js'
|
|
22
|
-
import { doorsForAnswer } from '../chat-message/message-doors.js'
|
|
23
|
-
import { groundingSourcesFor } from '../grounding-sources.js'
|
|
24
|
-
import { toolAccessFor } from '../tool-access.js'
|
|
25
|
-
import { AssistantRun } from './assistant-run.js'
|
|
26
|
-
import { ABANDON_MARGIN_MS, unattendedLimits } from './limits.js'
|
|
27
|
-
import { budgetedClient, RunBudgetExceeded } from './run-budget.js'
|
|
28
|
-
import { judgeRunAs, type RunAsChecks } from './run-as.js'
|
|
29
|
-
import { typeormRunStore, type RunEnding, type RunStore } from './run-store.js'
|
|
30
|
-
import { unattendedPrompt } from './unattended-prompt.js'
|
|
31
|
-
|
|
32
|
-
export interface UnattendedRunInput {
|
|
33
|
-
/** The domain the run is in, as loaded - its parent and owner decide who can enter it. */
|
|
34
|
-
domain: { id: string; [key: string]: any }
|
|
35
|
-
/** The user the run acts as - the policy owner. Their privileges and doors only. */
|
|
36
|
-
runAs: string
|
|
37
|
-
/** Which occurrence this is. The same three again is the same run. */
|
|
38
|
-
run: {
|
|
39
|
-
/** Who scheduled it - `<app>.<work>`, e.g. `office.strategy-review`. */
|
|
40
|
-
source: string
|
|
41
|
-
/** What it is about in the source's terms - a policy id. */
|
|
42
|
-
subject: string
|
|
43
|
-
scheduledAt: Date
|
|
44
|
-
}
|
|
45
|
-
/** A registered mode that declares `unattended`. */
|
|
46
|
-
mode: { kind: string; target?: string }
|
|
47
|
-
/** What this occurrence is asked to do - the caller server's text, read by the model (English). */
|
|
48
|
-
instruction: string
|
|
49
|
-
/** What the run is about, for the tools. Filled by the caller's server; still never used for authorization. */
|
|
50
|
-
hostContext?: Record<string, any>
|
|
51
|
-
/** The language of the draft - the owner's. Absent: their account's locale. */
|
|
52
|
-
lng?: string
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/** What the run reaches outside itself. The defaults are the server's; the tests hand their own. */
|
|
56
|
-
export interface UnattendedRunDeps {
|
|
57
|
-
store: RunStore
|
|
58
|
-
runAs: RunAsChecks<any, any>
|
|
59
|
-
clientFor: (request: AiClientRequest) => Promise<AgentClient>
|
|
60
|
-
toolAccess: (state: any) => ToolAccessCheck
|
|
61
|
-
now: () => Date
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const KEY = /^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*$/
|
|
65
|
-
|
|
66
|
-
function invalid(field: string): Error {
|
|
67
|
-
const error: any = new Error(`runAssistantUnattended: '${field}' is missing or not usable`)
|
|
68
|
-
error.code = 'assistant-run-input-invalid'
|
|
69
|
-
error.params = { field }
|
|
70
|
-
return error
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function checkInput(input: UnattendedRunInput) {
|
|
74
|
-
if (!input?.domain?.id) throw invalid('domain')
|
|
75
|
-
if (!input.runAs) throw invalid('runAs')
|
|
76
|
-
if (!KEY.test(String(input.run?.source ?? '')) || input.run.source.length > 64) throw invalid('run.source')
|
|
77
|
-
if (!String(input.run.subject ?? '').trim() || String(input.run.subject).length > 64) throw invalid('run.subject')
|
|
78
|
-
if (!(input.run.scheduledAt instanceof Date) || !Number.isFinite(input.run.scheduledAt.valueOf())) throw invalid('run.scheduledAt')
|
|
79
|
-
if (!input.mode?.kind) throw invalid('mode.kind')
|
|
80
|
-
if (!String(input.instruction ?? '').trim()) throw invalid('instruction')
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function defaultDeps(): UnattendedRunDeps {
|
|
84
|
-
return {
|
|
85
|
-
store: typeormRunStore(() => getRepository(AssistantRun)),
|
|
86
|
-
runAs: {
|
|
87
|
-
findUser: id => getRepository(User).findOne({ where: { id } }),
|
|
88
|
-
mayCheckin: (user, domain) => canUserCheckinDomain(user, domain),
|
|
89
|
-
/* No request: no address to refuse from, and no license prohibition - those cover writes this run never makes. */
|
|
90
|
-
permits: (gate, user, domain) => checkPermission(gate as any, user, domain, false, [])
|
|
91
|
-
},
|
|
92
|
-
clientFor: aiClientFor,
|
|
93
|
-
toolAccess: state => toolAccessFor({ state }),
|
|
94
|
-
now: () => new Date()
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/** Why the loop stopped, as the run's code. Only a clean end with text is a draft. */
|
|
99
|
-
function failureOf(loop: any, baseText: string): { code: string; params?: any } | undefined {
|
|
100
|
-
const abort = loop?.abortReason
|
|
101
|
-
if (abort?.type === 'max_iterations') return { code: 'assistant-run-step-limit', params: { steps: abort.iter } }
|
|
102
|
-
if (abort?.type === 'provider_error') return { code: 'assistant-run-model-error', params: { message: String(abort.message ?? '').slice(0, 500) } }
|
|
103
|
-
if (abort) return { code: 'assistant-run-model-error', params: { stopped: abort.type } }
|
|
104
|
-
if (!baseText.trim()) return { code: 'assistant-run-empty-draft' }
|
|
105
|
-
return undefined
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const TIMED_OUT = Symbol('timed-out')
|
|
109
|
-
|
|
110
|
-
export async function runAssistantUnattended(input: UnattendedRunInput, deps: UnattendedRunDeps = defaultDeps()): Promise<AssistantRun> {
|
|
111
|
-
checkInput(input)
|
|
112
|
-
const { domain, run } = input
|
|
113
|
-
const mode = getAssistantMode(input.mode.kind)
|
|
114
|
-
const limits = unattendedLimits(mode?.unattended)
|
|
115
|
-
const startedAt = deps.now()
|
|
116
|
-
/* The account as stored now - read once, and judged after the occurrence is held. */
|
|
117
|
-
const account = await deps.runAs.findUser(input.runAs)
|
|
118
|
-
|
|
119
|
-
const { claimed, row } = await deps.store.claim(
|
|
120
|
-
{ domainId: domain.id, source: run.source, subject: run.subject, scheduledAt: run.scheduledAt },
|
|
121
|
-
{
|
|
122
|
-
name: `${run.source} ${run.subject} ${run.scheduledAt.toISOString()}`,
|
|
123
|
-
modeKind: input.mode.kind,
|
|
124
|
-
modeTarget: input.mode.target,
|
|
125
|
-
runAsId: account?.id,
|
|
126
|
-
startedAt,
|
|
127
|
-
deadlineAt: new Date(startedAt.valueOf() + limits.timeoutMs + ABANDON_MARGIN_MS)
|
|
128
|
-
},
|
|
129
|
-
startedAt
|
|
130
|
-
)
|
|
131
|
-
/* Succeeded, or running elsewhere and still alive - the caller gets that row and the model is not called again. */
|
|
132
|
-
if (!claimed) return row
|
|
133
|
-
|
|
134
|
-
const held = { id: row.id!, attempt: row.attempt }
|
|
135
|
-
const end = (ending: RunEnding) => deps.store.finish(held, { finishedAt: deps.now(), ...ending })
|
|
136
|
-
const refuse = (code: string, params?: any) => end({ status: 'refused', outcomeCode: code, outcomeParams: params ? JSON.stringify(params) : null } as any)
|
|
137
|
-
const fail = (code: string, params?: any, spent?: RunEnding) =>
|
|
138
|
-
end({ status: 'failed', outcomeCode: code, outcomeParams: params ? JSON.stringify(params) : null, ...spent } as any)
|
|
139
|
-
|
|
140
|
-
if (!mode) return refuse('unknown-assistant-mode', { kind: input.mode.kind })
|
|
141
|
-
if (!mode.unattended) return refuse('assistant-mode-not-unattended', { kind: mode.kind })
|
|
142
|
-
|
|
143
|
-
const judged = await judgeRunAs(account, domain, deps.runAs)
|
|
144
|
-
if ('refused' in judged) return refuse(judged.refused, { userId: input.runAs })
|
|
145
|
-
const user = judged.user
|
|
146
|
-
|
|
147
|
-
let agentClient: AgentClient
|
|
148
|
-
try {
|
|
149
|
-
agentClient = await deps.clientFor({ domain: domain as any, user, modeKind: mode.kind })
|
|
150
|
-
} catch (error: any) {
|
|
151
|
-
/* No AI here, or not the agent asked for - nothing ran. Its own code, as the conversation door says it. */
|
|
152
|
-
if (error?.code) return refuse(String(error.code), error.params)
|
|
153
|
-
return fail('assistant-run-model-error', { message: String(error?.message ?? error).slice(0, 500) })
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
const { client, spend } = budgetedClient(agentClient, limits)
|
|
157
|
-
const reads: ToolCallRecord[] = []
|
|
158
|
-
let over = false
|
|
159
|
-
const state: any = { domain, user, lng: input.lng ?? user.locale, aiAgentId: agentClient.agent.id }
|
|
160
|
-
const categories = unattendedToolCategories(mode)
|
|
161
|
-
const systemPrompt = unattendedPrompt(mode.systemPrompt, state.lng)
|
|
162
|
-
const messages = [{ role: 'user' as const, content: input.instruction }]
|
|
163
|
-
|
|
164
|
-
const abort = new AbortController()
|
|
165
|
-
let timer: ReturnType<typeof setTimeout> | undefined
|
|
166
|
-
const timeout = new Promise<typeof TIMED_OUT>(resolve => {
|
|
167
|
-
timer = setTimeout(() => {
|
|
168
|
-
abort.abort()
|
|
169
|
-
resolve(TIMED_OUT)
|
|
170
|
-
}, limits.timeoutMs)
|
|
171
|
-
})
|
|
172
|
-
|
|
173
|
-
const spent = (): RunEnding => ({
|
|
174
|
-
reads: JSON.stringify(reads),
|
|
175
|
-
agentId: agentClient.agent.id,
|
|
176
|
-
clientId: agentClient.id,
|
|
177
|
-
modelCalls: spend.modelCalls,
|
|
178
|
-
inputTokens: spend.inputTokens,
|
|
179
|
-
outputTokens: spend.outputTokens
|
|
180
|
-
})
|
|
181
|
-
|
|
182
|
-
let result: any
|
|
183
|
-
try {
|
|
184
|
-
result = await Promise.race([
|
|
185
|
-
registryAssistantChat({
|
|
186
|
-
client,
|
|
187
|
-
messages,
|
|
188
|
-
systemPrompt,
|
|
189
|
-
toolCategories: categories,
|
|
190
|
-
/* No screen and no conversation - the mode's own tools in front, the lists opened as the run needs (ADR-0061 decision 9). */
|
|
191
|
-
front: { categories: mode.toolCategories ?? [] },
|
|
192
|
-
mode: { kind: mode.kind, ...(input.mode.target ? { target: input.mode.target } : {}) },
|
|
193
|
-
toolAccess: deps.toolAccess(state),
|
|
194
|
-
hostContext: input.hostContext,
|
|
195
|
-
state,
|
|
196
|
-
temperature: mode.temperature,
|
|
197
|
-
maxTokens: mode.maxTokens,
|
|
198
|
-
requireToolOnFirstTurn: mode.requireToolOnFirstTurn,
|
|
199
|
-
/* Each step is one request. A run that reaches the last step without an answer failed - no wrap-up call (§4). */
|
|
200
|
-
maxIterations: limits.maxModelCalls,
|
|
201
|
-
salvageOnMaxIterations: false,
|
|
202
|
-
signal: abort.signal,
|
|
203
|
-
onToolCall: record => {
|
|
204
|
-
if (!over) reads.push(record)
|
|
205
|
-
},
|
|
206
|
-
run: { id: held.id, source: run.source, subject: run.subject, scheduledAt: run.scheduledAt.toISOString() },
|
|
207
|
-
groundingSources: groundingSourcesFor({ systemPrompt, messages: messages as any, hostContext: input.hostContext })
|
|
208
|
-
}),
|
|
209
|
-
timeout
|
|
210
|
-
])
|
|
211
|
-
} catch (error: any) {
|
|
212
|
-
over = true
|
|
213
|
-
clearTimeout(timer)
|
|
214
|
-
if (error instanceof RunBudgetExceeded) return fail(error.code, error.params, spent())
|
|
215
|
-
return fail('assistant-run-model-error', { message: String(error?.message ?? error).slice(0, 500) }, spent())
|
|
216
|
-
}
|
|
217
|
-
over = true
|
|
218
|
-
clearTimeout(timer)
|
|
219
|
-
|
|
220
|
-
if (result === TIMED_OUT) return fail('assistant-run-timeout', { timeoutMs: limits.timeoutMs }, spent())
|
|
221
|
-
/* The loop turns a refused request into a provider error; the budget says which limit it was. */
|
|
222
|
-
if (spend.exceeded) return fail('assistant-run-budget-exceeded', spend.exceeded, spent())
|
|
223
|
-
|
|
224
|
-
const failure = failureOf(result.loop, result.baseText ?? '')
|
|
225
|
-
if (failure) return fail(failure.code, failure.params, spent())
|
|
226
|
-
|
|
227
|
-
const doors = doorsForAnswer(
|
|
228
|
-
result.loop.toolUsages ?? [],
|
|
229
|
-
name => (findToolSpec(name, categories) as any)?.doors
|
|
230
|
-
)
|
|
231
|
-
return end({
|
|
232
|
-
status: 'succeeded',
|
|
233
|
-
draft: result.baseText,
|
|
234
|
-
doors,
|
|
235
|
-
cardsDropped: result.loop.proposals?.length ?? 0,
|
|
236
|
-
groundingWarnings: result.groundingWarnings?.length ? JSON.stringify(result.groundingWarnings) : null,
|
|
237
|
-
...spent()
|
|
238
|
-
} as any)
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
/** The stored run of an occurrence, for the application that scheduled it - read behind that application's own door. */
|
|
242
|
-
export async function findAssistantRun(identity: { domainId: string; source: string; subject: string; scheduledAt: Date } | { id: string }): Promise<AssistantRun | null> {
|
|
243
|
-
const repository = getRepository(AssistantRun)
|
|
244
|
-
if ('id' in identity) return repository.findOne({ where: { id: identity.id } })
|
|
245
|
-
return repository.findOne({
|
|
246
|
-
where: { domain: { id: identity.domainId }, source: identity.source, subject: identity.subject, scheduledAt: identity.scheduledAt } as any
|
|
247
|
-
})
|
|
248
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The rules every unattended run follows, after the mode's persona (design/ai/unattended-run.md §3). The reader is the
|
|
3
|
-
* model, so the text is English (ADR-0061 A11); the draft is written in the owner's language.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
const LANGUAGES: Record<string, string> = { ko: 'Korean', en: 'English', ja: 'Japanese', zh: 'Chinese', ms: 'Malay', vi: 'Vietnamese' }
|
|
7
|
-
|
|
8
|
-
export function languageName(lng: string | undefined): string {
|
|
9
|
-
const code = String(lng ?? '').trim().toLowerCase()
|
|
10
|
-
if (!code) return 'English'
|
|
11
|
-
return LANGUAGES[code] ?? LANGUAGES[code.split(/[-_]/)[0]] ?? `the language of locale "${code}"`
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const UNATTENDED_RULES = [
|
|
15
|
-
'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.',
|
|
16
|
-
'- Read before you write. Every figure and fact in the draft comes from a tool result of this run.',
|
|
17
|
-
'- 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".',
|
|
18
|
-
'- Nothing you call is shown to anyone: there are no cards and no screens to open. Put what matters in the text.',
|
|
19
|
-
'- Do not ask questions - nobody will answer. Where something is missing, say what is missing.'
|
|
20
|
-
].join('\n')
|
|
21
|
-
|
|
22
|
-
export function unattendedPrompt(persona: string, lng: string | undefined): string {
|
|
23
|
-
return `${persona}\n\n${UNATTENDED_RULES}\n- Write the draft in ${languageName(lng)}.`
|
|
24
|
-
}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The AI 작업 패널 - what a workspace is made of (operato-application/design/ai/workspace.md §3).
|
|
3
|
-
*
|
|
4
|
-
* The model does not write HTML. A workspace is a list of blocks of known kinds; the screen draws each, so
|
|
5
|
-
* theme, language and accessibility are the framework's. A block that does not fit is not dropped: it is
|
|
6
|
-
* kept as a fact in its place ("a block that cannot be drawn"), so the person sees that something was meant
|
|
7
|
-
* to be there. Pure - tested without a server.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
export const WORKSPACE_BLOCK_KINDS = ['heading', 'text', 'metrics', 'table', 'chart', 'steps'] as const
|
|
11
|
-
export type WorkspaceBlockKind = (typeof WORKSPACE_BLOCK_KINDS)[number]
|
|
12
|
-
|
|
13
|
-
export const MAX_BLOCKS = 40
|
|
14
|
-
export const MAX_TABLE_ROWS = 1000
|
|
15
|
-
export const MAX_SERIES = 8
|
|
16
|
-
const MAX_TEXT = 20_000
|
|
17
|
-
|
|
18
|
-
export interface WorkspaceBlock {
|
|
19
|
-
kind: WorkspaceBlockKind | 'unreadable'
|
|
20
|
-
[key: string]: unknown
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface Workspace {
|
|
24
|
-
name: string
|
|
25
|
-
title: string
|
|
26
|
-
summary?: string
|
|
27
|
-
blocks: WorkspaceBlock[]
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const text = (value: unknown, max = 500): string | undefined => (typeof value === 'string' && value.trim() ? value.trim().slice(0, max) : undefined)
|
|
31
|
-
const scalar = (value: unknown): string | number | boolean | null =>
|
|
32
|
-
value === null || value === undefined ? null : typeof value === 'number' || typeof value === 'boolean' ? value : String(value).slice(0, 500)
|
|
33
|
-
|
|
34
|
-
/** A short key of the workspace - the same name in one conversation is the same workspace, a new version. */
|
|
35
|
-
export function workspaceName(name: unknown, title: string): string {
|
|
36
|
-
const given = typeof name === 'string' ? name.trim().toLowerCase() : ''
|
|
37
|
-
if (/^[a-z0-9][a-z0-9-]{0,63}$/.test(given)) return given
|
|
38
|
-
const slug = (given || title)
|
|
39
|
-
.toLowerCase()
|
|
40
|
-
.replace(/[^a-z0-9가-힣]+/g, '-')
|
|
41
|
-
.replace(/^-+|-+$/g, '')
|
|
42
|
-
.slice(0, 64)
|
|
43
|
-
return slug || 'workspace'
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function unreadable(kind: unknown, reason: string): WorkspaceBlock {
|
|
47
|
-
return { kind: 'unreadable', was: typeof kind === 'string' ? kind.slice(0, 40) : null, reason }
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function block(raw: any): WorkspaceBlock {
|
|
51
|
-
const kind = raw?.kind
|
|
52
|
-
switch (kind) {
|
|
53
|
-
case 'heading': {
|
|
54
|
-
const value = text(raw.text, 200)
|
|
55
|
-
if (!value) return unreadable(kind, 'no-text')
|
|
56
|
-
const level = [1, 2, 3].includes(raw.level) ? raw.level : 2
|
|
57
|
-
return { kind, text: value, level }
|
|
58
|
-
}
|
|
59
|
-
case 'text': {
|
|
60
|
-
const value = text(raw.markdown ?? raw.text, MAX_TEXT)
|
|
61
|
-
return value ? { kind, markdown: value } : unreadable(kind, 'no-text')
|
|
62
|
-
}
|
|
63
|
-
case 'metrics': {
|
|
64
|
-
const items = (Array.isArray(raw.items) ? raw.items : [])
|
|
65
|
-
.filter((one: any) => text(one?.label) && one?.value !== undefined && one?.value !== null)
|
|
66
|
-
.slice(0, 12)
|
|
67
|
-
.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) } : {}) }))
|
|
68
|
-
return items.length ? { kind, items } : unreadable(kind, 'no-items')
|
|
69
|
-
}
|
|
70
|
-
case 'table': {
|
|
71
|
-
const columns = (Array.isArray(raw.columns) ? raw.columns : [])
|
|
72
|
-
.filter((one: any) => text(one?.name, 80))
|
|
73
|
-
.slice(0, 30)
|
|
74
|
-
.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' }))
|
|
75
|
-
if (!columns.length) return unreadable(kind, 'no-columns')
|
|
76
|
-
const given = Array.isArray(raw.rows) ? raw.rows : []
|
|
77
|
-
/* A row is an object by column name, or an array in column order - models write both. */
|
|
78
|
-
/* A number column reads "12,400" as 12400 - cells come as text from a model told one type per field. */
|
|
79
|
-
const cell = (column: any, value: unknown) => {
|
|
80
|
-
const read = scalar(value)
|
|
81
|
-
if (column.type !== 'number' || typeof read !== 'string') return read
|
|
82
|
-
const number = Number(read.replace(/[,\s₩$€]/g, ''))
|
|
83
|
-
return read.trim() && Number.isFinite(number) ? number : read
|
|
84
|
-
}
|
|
85
|
-
const rows = given.slice(0, MAX_TABLE_ROWS).map((row: any) =>
|
|
86
|
-
Object.fromEntries(columns.map((column: any, i: number) => [column.name, cell(column, Array.isArray(row) ? row[i] : row?.[column.name])]))
|
|
87
|
-
)
|
|
88
|
-
return { kind, columns, rows, ...(text(raw.caption, 300) ? { caption: text(raw.caption, 300) } : {}), ...(given.length > MAX_TABLE_ROWS ? { cut: given.length - MAX_TABLE_ROWS } : {}) }
|
|
89
|
-
}
|
|
90
|
-
case 'chart': {
|
|
91
|
-
const x = (Array.isArray(raw.x) ? raw.x : []).slice(0, 200).map((one: unknown) => String(one ?? '').slice(0, 60))
|
|
92
|
-
const series = (Array.isArray(raw.series) ? raw.series : [])
|
|
93
|
-
.filter((one: any) => text(one?.name, 60) && Array.isArray(one?.values))
|
|
94
|
-
.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)) }))
|
|
95
|
-
if (!x.length || !series.length) return unreadable(kind, 'no-series')
|
|
96
|
-
/* Never a ninth hue: past eight, the first seven stay and the rest fold into one "other". */
|
|
97
|
-
const shown =
|
|
98
|
-
series.length > MAX_SERIES
|
|
99
|
-
? [
|
|
100
|
-
...series.slice(0, MAX_SERIES - 1),
|
|
101
|
-
{ 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)) }
|
|
102
|
-
]
|
|
103
|
-
: series
|
|
104
|
-
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) } : {}) }
|
|
105
|
-
}
|
|
106
|
-
case 'steps': {
|
|
107
|
-
const items = (Array.isArray(raw.items) ? raw.items : [])
|
|
108
|
-
.filter((one: any) => text(one?.label, 200))
|
|
109
|
-
.slice(0, 50)
|
|
110
|
-
.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) } : {}) }))
|
|
111
|
-
return items.length ? { kind, items } : unreadable(kind, 'no-items')
|
|
112
|
-
}
|
|
113
|
-
default:
|
|
114
|
-
return unreadable(kind, 'unknown-kind')
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/** The workspace as the screen reads it. */
|
|
119
|
-
export function normalizeWorkspace(args: any): { workspace?: Workspace; error?: string } {
|
|
120
|
-
const title = text(args?.title, 200)
|
|
121
|
-
if (!title) return { error: 'no-title' }
|
|
122
|
-
const given = Array.isArray(args?.blocks) ? args.blocks : []
|
|
123
|
-
if (!given.length) return { error: 'no-blocks' }
|
|
124
|
-
const blocks = given.slice(0, MAX_BLOCKS).map(block)
|
|
125
|
-
if (given.length > MAX_BLOCKS) blocks.push({ kind: 'unreadable', was: null, reason: 'too-many-blocks', cut: given.length - MAX_BLOCKS })
|
|
126
|
-
return { workspace: { name: workspaceName(args?.name, title), title, ...(text(args?.summary, 500) ? { summary: text(args.summary, 500) } : {}), blocks } }
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/** One line of what is in it - for the card in the conversation and for the model. */
|
|
130
|
-
export function workspaceContents(workspace: Workspace): Record<string, number> {
|
|
131
|
-
const counts: Record<string, number> = {}
|
|
132
|
-
for (const one of workspace.blocks) if (['table', 'chart', 'metrics', 'steps'].includes(one.kind)) counts[one.kind] = (counts[one.kind] ?? 0) + 1
|
|
133
|
-
return counts
|
|
134
|
-
}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* showInWorkspace - the model puts a large result on the AI 작업 패널 (operato-application/design/ai/workspace.md §5).
|
|
3
|
-
*
|
|
4
|
-
* The result rides on the answer as a proposal of kind 'workspace', so the conversation's gates hold for it:
|
|
5
|
-
* who may read the conversation reads the workspace, and a value behind a door the reader cannot pass hides
|
|
6
|
-
* it with the answer (ADR-0073). The tool itself reaches no door - what it carries came from the turn's other
|
|
7
|
-
* tools, whose doors the answer row collects.
|
|
8
|
-
*/
|
|
9
|
-
import { registerToolCategory, type ToolCategory, type ToolSpec } from '@things-factory/ai-client-base'
|
|
10
|
-
|
|
11
|
-
import { normalizeWorkspace, workspaceContents, WORKSPACE_BLOCK_KINDS } from './workspace-blocks.js'
|
|
12
|
-
|
|
13
|
-
export const WORKSPACE_CATEGORY = 'assistant-workspace'
|
|
14
|
-
|
|
15
|
-
export function showInWorkspace(args: any) {
|
|
16
|
-
const { workspace, error } = normalizeWorkspace(args)
|
|
17
|
-
if (!workspace) return { rejected: true, error, message: 'a workspace needs a title and at least one block.' }
|
|
18
|
-
const contents = workspaceContents(workspace)
|
|
19
|
-
return {
|
|
20
|
-
proposed: true,
|
|
21
|
-
kind: 'workspace',
|
|
22
|
-
icon: 'dashboard',
|
|
23
|
-
label: workspace.title,
|
|
24
|
-
workspace,
|
|
25
|
-
contents,
|
|
26
|
-
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.`
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const spec = {
|
|
31
|
-
kind: 'read',
|
|
32
|
-
name: 'showInWorkspace',
|
|
33
|
-
doors: [],
|
|
34
|
-
description:
|
|
35
|
-
'Put a large result on the AI workspace - a page the person opens from a card, beside the conversation. Blocks: ' +
|
|
36
|
-
'heading{text,level}, text{markdown}, metrics{items:[{label,value,unit,note}]}, table{columns:[{name,label,type:number|date|string}],rows,caption}, ' +
|
|
37
|
-
'chart{chart:bar|line, x:[labels], series:[{name,values:[numbers]}], unit, caption}, steps{items:[{label,state:done|doing|todo|failed,note}]}.',
|
|
38
|
-
schema: {
|
|
39
|
-
type: 'object',
|
|
40
|
-
properties: {
|
|
41
|
-
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.' },
|
|
42
|
-
title: { type: 'string' },
|
|
43
|
-
summary: { type: 'string', description: 'One line under the title.' },
|
|
44
|
-
/*
|
|
45
|
-
* Every field of every block is declared, each with one type: Gemini's function schema (an OpenAPI 3.0
|
|
46
|
-
* subset) refuses a list of types and may leave out a field it was not told of (2026-10-01).
|
|
47
|
-
*/
|
|
48
|
-
blocks: {
|
|
49
|
-
type: 'array',
|
|
50
|
-
items: {
|
|
51
|
-
type: 'object',
|
|
52
|
-
properties: {
|
|
53
|
-
kind: { type: 'string', enum: [...WORKSPACE_BLOCK_KINDS] },
|
|
54
|
-
text: { type: 'string', description: 'heading' },
|
|
55
|
-
level: { type: 'integer', description: 'heading: 1-3' },
|
|
56
|
-
markdown: { type: 'string', description: 'text' },
|
|
57
|
-
caption: { type: 'string', description: 'table, chart' },
|
|
58
|
-
unit: { type: 'string', description: 'chart' },
|
|
59
|
-
chart: { type: 'string', enum: ['bar', 'line'], description: 'chart' },
|
|
60
|
-
items: {
|
|
61
|
-
type: 'array',
|
|
62
|
-
description: 'metrics: {label,value,unit,note}; steps: {label,state,note}',
|
|
63
|
-
items: {
|
|
64
|
-
type: 'object',
|
|
65
|
-
properties: {
|
|
66
|
-
label: { type: 'string' },
|
|
67
|
-
value: { type: 'string' },
|
|
68
|
-
unit: { type: 'string' },
|
|
69
|
-
note: { type: 'string' },
|
|
70
|
-
state: { type: 'string', enum: ['done', 'doing', 'todo', 'failed'] }
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
columns: {
|
|
75
|
-
type: 'array',
|
|
76
|
-
description: 'table',
|
|
77
|
-
items: { type: 'object', properties: { name: { type: 'string' }, label: { type: 'string' }, type: { type: 'string', enum: ['number', 'date', 'string'] } } }
|
|
78
|
-
},
|
|
79
|
-
rows: { type: 'array', description: 'table: each row is its cells in column order', items: { type: 'array', items: { type: 'string' } } },
|
|
80
|
-
x: { type: 'array', description: 'chart: the labels along the bottom', items: { type: 'string' } },
|
|
81
|
-
series: {
|
|
82
|
-
type: 'array',
|
|
83
|
-
description: 'chart',
|
|
84
|
-
items: { type: 'object', properties: { name: { type: 'string' }, values: { type: 'array', items: { type: 'number' } } } }
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
required: ['kind']
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
required: ['name', 'title', 'blocks']
|
|
92
|
-
},
|
|
93
|
-
builder: (args: any) => showInWorkspace(args)
|
|
94
|
-
} as ToolSpec
|
|
95
|
-
|
|
96
|
-
export const workspaceCategory: ToolCategory = {
|
|
97
|
-
name: WORKSPACE_CATEGORY,
|
|
98
|
-
description: 'the AI workspace - a page for results too large for the conversation',
|
|
99
|
-
guidance: [
|
|
100
|
-
'- 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.',
|
|
101
|
-
'- Every number in a block comes from a tool result in this conversation - never computed or guessed by you.',
|
|
102
|
-
'- To change a workspace, call showInWorkspace again with the same name and the whole new content; it becomes a new version.',
|
|
103
|
-
'- Never say something is on the workspace unless you called showInWorkspace in this turn.'
|
|
104
|
-
].join('\n'),
|
|
105
|
-
specs: [spec]
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
registerToolCategory(workspaceCategory)
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The AI 작업 패널 (design/ai/workspace.md) - what a block may be, what happens to one that is not, and what the
|
|
3
|
-
* tool hands back.
|
|
4
|
-
*/
|
|
5
|
-
import { normalizeWorkspace, workspaceName, MAX_SERIES } from './workspace-blocks'
|
|
6
|
-
import { showInWorkspace, workspaceCategory } from './workspace-tools'
|
|
7
|
-
|
|
8
|
-
describe('the workspace', () => {
|
|
9
|
-
it('★ is blocks of known kinds - a block that does not fit stays in its place as a fact, never dropped silently', () => {
|
|
10
|
-
const { workspace } = normalizeWorkspace({
|
|
11
|
-
name: 'contracts',
|
|
12
|
-
title: '2026 contracts',
|
|
13
|
-
blocks: [{ kind: 'heading', text: 'By customer' }, { kind: 'html', html: '<script>x</script>' }, { kind: 'table', rows: [] }]
|
|
14
|
-
})
|
|
15
|
-
expect(workspace!.blocks).toEqual([
|
|
16
|
-
{ kind: 'heading', text: 'By customer', level: 2 },
|
|
17
|
-
{ kind: 'unreadable', was: 'html', reason: 'unknown-kind' },
|
|
18
|
-
{ kind: 'unreadable', was: 'table', reason: 'no-columns' }
|
|
19
|
-
])
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
it('reads a table row as an object by column or an array in column order, and cuts at the limit saying how many', () => {
|
|
23
|
-
const rows = [{ customer: 'A', amount: 10 }, ['B', 20], ...Array.from({ length: 1000 }, () => ({ customer: 'x', amount: 1 }))]
|
|
24
|
-
const table: any = normalizeWorkspace({ title: 't', blocks: [{ kind: 'table', columns: [{ name: 'customer' }, { name: 'amount', type: 'number' }], rows }] }).workspace!.blocks[0]
|
|
25
|
-
expect(table.rows.slice(0, 2)).toEqual([{ customer: 'A', amount: 10 }, { customer: 'B', amount: 20 }])
|
|
26
|
-
expect(table.rows).toHaveLength(1000)
|
|
27
|
-
expect(table.cut).toBe(2)
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
it('★ a chart never gets a ninth colour - past eight series the rest fold into "other"', () => {
|
|
31
|
-
const series = Array.from({ length: 10 }, (_, i) => ({ name: `s${i}`, values: [1, 2] }))
|
|
32
|
-
const chart: any = normalizeWorkspace({ title: 't', blocks: [{ kind: 'chart', x: ['Jan', 'Feb'], series }] }).workspace!.blocks[0]
|
|
33
|
-
expect(chart.series).toHaveLength(MAX_SERIES)
|
|
34
|
-
expect(chart.series[MAX_SERIES - 1]).toEqual({ name: 'other', other: true, values: [3, 6] })
|
|
35
|
-
expect(chart.chart).toBe('bar')
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
it('a value that is not a number is a gap in the chart, never a zero', () => {
|
|
39
|
-
const chart: any = normalizeWorkspace({ title: 't', blocks: [{ kind: 'chart', chart: 'line', x: ['a', 'b', 'c'], series: [{ name: 'n', values: [1, 'x', 3] }] }] }).workspace!.blocks[0]
|
|
40
|
-
expect(chart.series[0].values).toEqual([1, null, 3])
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
it('the same name is the same workspace - a name that is not a key is made one from it', () => {
|
|
44
|
-
expect(workspaceName('contracts-by-customer', 'x')).toBe('contracts-by-customer')
|
|
45
|
-
expect(workspaceName(undefined, '2026 Contracts / 고객사')).toBe('2026-contracts-고객사')
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
it('★ the tool hands back a proposal of kind workspace, so the answer row carries it - and the conversation gates it', () => {
|
|
49
|
-
const result: any = showInWorkspace({ name: 'c', title: 'Contracts', blocks: [{ kind: 'table', columns: [{ name: 'a' }], rows: [[1]] }, { kind: 'metrics', items: [{ label: 'n', value: 26 }] }] })
|
|
50
|
-
expect(result).toMatchObject({ proposed: true, kind: 'workspace', label: 'Contracts', contents: { table: 1, metrics: 1 } })
|
|
51
|
-
expect((workspaceCategory.specs[0] as any).doors).toEqual([])
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
it('no title or no blocks is refused, with what it needs', () => {
|
|
55
|
-
expect(showInWorkspace({ blocks: [{ kind: 'text', markdown: 'x' }] })).toMatchObject({ rejected: true, error: 'no-title' })
|
|
56
|
-
expect(showInWorkspace({ title: 'x', blocks: [] })).toMatchObject({ rejected: true, error: 'no-blocks' })
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
it('a number column reads the text a model writes - "12,400" is 12400, a word stays a word', () => {
|
|
60
|
-
const table: any = normalizeWorkspace({ title: 't', blocks: [{ kind: 'table', columns: [{ name: 'a', type: 'number' }], rows: [['12,400'], ['n/a']] }] }).workspace!.blocks[0]
|
|
61
|
-
expect(table.rows).toEqual([{ a: 12400 }, { a: 'n/a' }])
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
it('★ every field of the tool has one type, and every object says its fields - what Gemini accepts', () => {
|
|
65
|
-
const walk = (schema: any, path: string, out: string[]) => {
|
|
66
|
-
if (!schema || typeof schema !== 'object') return out
|
|
67
|
-
if (Array.isArray(schema.type)) out.push(`${path}: a list of types`)
|
|
68
|
-
if (schema.type === 'object' && !Object.keys(schema.properties ?? {}).length) out.push(`${path}: an object with no fields`)
|
|
69
|
-
for (const [key, value] of Object.entries(schema)) if (value && typeof value === 'object') walk(value, `${path}/${key}`, out)
|
|
70
|
-
return out
|
|
71
|
-
}
|
|
72
|
-
expect(walk((workspaceCategory.specs[0] as any).schema, '', [])).toEqual([])
|
|
73
|
-
})
|
|
74
|
-
})
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The boot report prints what registered but is not yet what the contracts require.
|
|
3
|
-
*
|
|
4
|
-
* It also asks the schema, through AUTH's field table, whether a door a tool names exists. That
|
|
5
|
-
* import is why this suite did not load from 2026-09-18 (`0c3a8ac939`) until 2026-09-24: the
|
|
6
|
-
* package root of auth-base brings shell and its ORM configuration with it, and jest has no module
|
|
7
|
-
* list to give that configuration. The table is a function of one field name, so it is stood in
|
|
8
|
-
* here — the door report has its own tests (`door-declaration-report.test.ts`).
|
|
9
|
-
*/
|
|
10
|
-
jest.mock('@things-factory/env', () => ({ logger: { warn: jest.fn() } }))
|
|
11
|
-
jest.mock('@things-factory/auth-base', () => ({ privilegeOfField: () => ({ known: false }) }))
|
|
12
|
-
/* ai-client-base keeps the AI usage table since 2026-10-12, so its root brings shell too - the same stand-in. */
|
|
13
|
-
jest.mock('@things-factory/ai-client-base', () => ({ getToolRegistryWarnings: () => [] }))
|
|
14
|
-
|
|
15
|
-
import { formatAssistantModeWarnings, formatToolRegistryWarnings } from './tool-registry-boot-report'
|
|
16
|
-
|
|
17
|
-
it('★ groups the recorded omissions by code and names every tool', () => {
|
|
18
|
-
const lines = formatToolRegistryWarnings([
|
|
19
|
-
{ code: 'tool-doors-undeclared', params: { category: 'twin-authoring', tool: 'getOpenScene', kind: 'read' }, message: '' },
|
|
20
|
-
{ code: 'tool-doors-undeclared', params: { category: 'x-ops', tool: 'runThing', kind: 'external' }, message: '' }
|
|
21
|
-
])
|
|
22
|
-
|
|
23
|
-
expect(lines).toEqual(['[ai-assistant] tool-doors-undeclared ×2: twin-authoring/getOpenScene(read), x-ops/runThing(external)'])
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
it('says nothing when every tool is declared', () => {
|
|
27
|
-
expect(formatToolRegistryWarnings([])).toEqual([])
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
describe('a screen with two conversations is reported by its subject (ADR-0072 rule, ruled 2026-10-13)', () => {
|
|
31
|
-
it('★ the boot line names the code, the subject and both conversations', () => {
|
|
32
|
-
const lines = formatAssistantModeWarnings([
|
|
33
|
-
{
|
|
34
|
-
code: 'assistant-mode-subject-claimed-twice',
|
|
35
|
-
params: { kind: 'twin.board', subject: 'board', kinds: ['twin.board', 'twin.space'] },
|
|
36
|
-
message: ''
|
|
37
|
-
}
|
|
38
|
-
])
|
|
39
|
-
expect(lines).toEqual(['[ai-assistant] assistant-mode-subject-claimed-twice ×1: board:twin.board+twin.space'])
|
|
40
|
-
})
|
|
41
|
-
})
|