@mastra/factory 0.28.0-alpha.0 → 0.28.0-alpha.10
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/README.md +528 -161
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +12 -6
- package/dist/auth.js.map +1 -1
- package/dist/boards/board-events.d.ts +54 -0
- package/dist/boards/board-events.d.ts.map +1 -0
- package/dist/boards/board-events.js +87 -0
- package/dist/boards/board-events.js.map +1 -0
- package/dist/boards/board-writes.d.ts +86 -0
- package/dist/boards/board-writes.d.ts.map +1 -0
- package/dist/boards/board-writes.js +266 -0
- package/dist/boards/board-writes.js.map +1 -0
- package/dist/boards/card-facts.d.ts +3 -1
- package/dist/boards/card-facts.d.ts.map +1 -1
- package/dist/boards/card-facts.js +30 -4
- package/dist/boards/card-facts.js.map +1 -1
- package/dist/boards/default-board.d.ts +7 -0
- package/dist/boards/default-board.d.ts.map +1 -0
- package/dist/boards/default-board.js +10 -0
- package/dist/boards/default-board.js.map +1 -0
- package/dist/boards/define-board.d.ts +56 -23
- package/dist/boards/define-board.d.ts.map +1 -1
- package/dist/boards/define-board.js +89 -45
- package/dist/boards/define-board.js.map +1 -1
- package/dist/boards/index.d.ts +6 -9
- package/dist/boards/index.d.ts.map +1 -1
- package/dist/boards/index.js +6 -20
- package/dist/boards/intake-routing.d.ts +55 -11
- package/dist/boards/intake-routing.d.ts.map +1 -1
- package/dist/boards/intake-routing.js +109 -19
- package/dist/boards/intake-routing.js.map +1 -1
- package/dist/boards/legacy-plan-role.d.ts.map +1 -1
- package/dist/boards/legacy-plan-role.js +14 -5
- package/dist/boards/legacy-plan-role.js.map +1 -1
- package/dist/boards/phase-automation.d.ts +7 -0
- package/dist/boards/phase-automation.d.ts.map +1 -1
- package/dist/boards/phase-automation.js +19 -3
- package/dist/boards/phase-automation.js.map +1 -1
- package/dist/boards/phase-runner.d.ts +18 -10
- package/dist/boards/phase-runner.d.ts.map +1 -1
- package/dist/boards/phase-runner.js +39 -34
- package/dist/boards/phase-runner.js.map +1 -1
- package/dist/boards/project-boards.d.ts +65 -8
- package/dist/boards/project-boards.d.ts.map +1 -1
- package/dist/boards/project-boards.js +217 -26
- package/dist/boards/project-boards.js.map +1 -1
- package/dist/boards/registry.d.ts +7 -1
- package/dist/boards/registry.d.ts.map +1 -1
- package/dist/boards/registry.js +19 -4
- package/dist/boards/registry.js.map +1 -1
- package/dist/boards/relocate.d.ts +1 -1
- package/dist/boards/relocate.d.ts.map +1 -1
- package/dist/boards/relocate.js +3 -2
- package/dist/boards/relocate.js.map +1 -1
- package/dist/boards/review.d.ts +5 -2
- package/dist/boards/review.d.ts.map +1 -1
- package/dist/boards/review.js +12 -11
- package/dist/boards/review.js.map +1 -1
- package/dist/boards/semantics.d.ts +160 -20
- package/dist/boards/semantics.d.ts.map +1 -1
- package/dist/boards/semantics.js +255 -23
- package/dist/boards/semantics.js.map +1 -1
- package/dist/boards/stored-board.d.ts +73 -1
- package/dist/boards/stored-board.d.ts.map +1 -1
- package/dist/boards/stored-board.js +157 -11
- package/dist/boards/stored-board.js.map +1 -1
- package/dist/boards/work-migrations.d.ts +43 -0
- package/dist/boards/work-migrations.d.ts.map +1 -0
- package/dist/boards/work-migrations.js +353 -0
- package/dist/boards/work-migrations.js.map +1 -0
- package/dist/boards/work-routes.d.ts +58 -0
- package/dist/boards/work-routes.d.ts.map +1 -0
- package/dist/boards/work-routes.js +270 -0
- package/dist/boards/work-routes.js.map +1 -0
- package/dist/boards/work-seeds.d.ts +9 -0
- package/dist/boards/work-seeds.d.ts.map +1 -0
- package/dist/boards/work-seeds.js +56 -0
- package/dist/boards/work-seeds.js.map +1 -0
- package/dist/boards/work.d.ts +8 -19
- package/dist/boards/work.d.ts.map +1 -1
- package/dist/boards/work.js +33 -281
- package/dist/boards/work.js.map +1 -1
- package/dist/environment/build-runner.d.ts.map +1 -1
- package/dist/environment/build-runner.js +2 -2
- package/dist/environment/build-runner.js.map +1 -1
- package/dist/environment/build-workflow.d.ts.map +1 -1
- package/dist/environment/build-workflow.js +6 -5
- package/dist/environment/build-workflow.js.map +1 -1
- package/dist/environment/build.d.ts +15 -2
- package/dist/environment/build.d.ts.map +1 -1
- package/dist/environment/build.js +32 -9
- package/dist/environment/build.js.map +1 -1
- package/dist/factory.d.ts +90 -9
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +334 -141
- package/dist/factory.js.map +1 -1
- package/dist/feed-events.d.ts +4 -4
- package/dist/feed-events.d.ts.map +1 -1
- package/dist/feed-events.js +6 -6
- package/dist/feed-events.js.map +1 -1
- package/dist/index.d.ts +10 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -4
- package/dist/integrations/base.d.ts +12 -13
- package/dist/integrations/base.d.ts.map +1 -1
- package/dist/integrations/closing-references.d.ts +15 -0
- package/dist/integrations/closing-references.d.ts.map +1 -0
- package/dist/integrations/closing-references.js +69 -0
- package/dist/integrations/closing-references.js.map +1 -0
- package/dist/integrations/github/acceptance-labels.d.ts +4 -0
- package/dist/integrations/github/acceptance-labels.d.ts.map +1 -1
- package/dist/integrations/github/acceptance-labels.js +1 -1
- package/dist/integrations/github/acceptance-labels.js.map +1 -1
- package/dist/integrations/github/default-rules.d.ts +17 -75
- package/dist/integrations/github/default-rules.d.ts.map +1 -1
- package/dist/integrations/github/default-rules.js +134 -77
- package/dist/integrations/github/default-rules.js.map +1 -1
- package/dist/integrations/github/integration.d.ts.map +1 -1
- package/dist/integrations/github/integration.js +7 -3
- package/dist/integrations/github/integration.js.map +1 -1
- package/dist/integrations/github/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/github/issue-reconciler.js +21 -3
- package/dist/integrations/github/issue-reconciler.js.map +1 -1
- package/dist/integrations/github/provenance.js +1 -1
- package/dist/integrations/github/provenance.js.map +1 -1
- package/dist/integrations/github/pull-request-source.d.ts +8 -0
- package/dist/integrations/github/pull-request-source.d.ts.map +1 -0
- package/dist/integrations/github/pull-request-source.js +17 -0
- package/dist/integrations/github/pull-request-source.js.map +1 -0
- package/dist/integrations/github/reconcile-worker.d.ts +5 -1
- package/dist/integrations/github/reconcile-worker.d.ts.map +1 -1
- package/dist/integrations/github/reconcile-worker.js +39 -6
- package/dist/integrations/github/reconcile-worker.js.map +1 -1
- package/dist/integrations/github/review-status-comment.d.ts +61 -0
- package/dist/integrations/github/review-status-comment.d.ts.map +1 -0
- package/dist/integrations/github/review-status-comment.js +217 -0
- package/dist/integrations/github/review-status-comment.js.map +1 -0
- package/dist/integrations/github/review-status-reporter.d.ts +42 -0
- package/dist/integrations/github/review-status-reporter.d.ts.map +1 -0
- package/dist/integrations/github/review-status-reporter.js +104 -0
- package/dist/integrations/github/review-status-reporter.js.map +1 -0
- package/dist/integrations/github/review-status.d.ts +28 -0
- package/dist/integrations/github/review-status.d.ts.map +1 -0
- package/dist/integrations/github/review-status.js +95 -0
- package/dist/integrations/github/review-status.js.map +1 -0
- package/dist/integrations/github/routes.d.ts +4 -3
- package/dist/integrations/github/routes.d.ts.map +1 -1
- package/dist/integrations/github/routes.js +11 -91
- package/dist/integrations/github/routes.js.map +1 -1
- package/dist/integrations/github/rules.d.ts +92 -8
- package/dist/integrations/github/rules.d.ts.map +1 -1
- package/dist/integrations/github/rules.js +498 -103
- package/dist/integrations/github/rules.js.map +1 -1
- package/dist/integrations/github/sandbox.d.ts +10 -2
- package/dist/integrations/github/sandbox.d.ts.map +1 -1
- package/dist/integrations/github/sandbox.js +20 -4
- package/dist/integrations/github/sandbox.js.map +1 -1
- package/dist/integrations/github/session-subscriptions.js +2 -2
- package/dist/integrations/github/session-subscriptions.js.map +1 -1
- package/dist/integrations/github/token-refresh.d.ts +2 -1
- package/dist/integrations/github/token-refresh.d.ts.map +1 -1
- package/dist/integrations/github/token-refresh.js.map +1 -1
- package/dist/integrations/gitlab/agent-tools.js +1 -1
- package/dist/integrations/gitlab/default-rules.d.ts +96 -39
- package/dist/integrations/gitlab/default-rules.d.ts.map +1 -1
- package/dist/integrations/gitlab/default-rules.js +109 -46
- package/dist/integrations/gitlab/default-rules.js.map +1 -1
- package/dist/integrations/gitlab/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/gitlab/issue-reconciler.js +2 -1
- package/dist/integrations/gitlab/issue-reconciler.js.map +1 -1
- package/dist/integrations/gitlab/merge-request-reconciler.d.ts.map +1 -1
- package/dist/integrations/gitlab/merge-request-reconciler.js +12 -5
- package/dist/integrations/gitlab/merge-request-reconciler.js.map +1 -1
- package/dist/integrations/gitlab/routes.d.ts.map +1 -1
- package/dist/integrations/gitlab/routes.js +2 -6
- package/dist/integrations/gitlab/routes.js.map +1 -1
- package/dist/integrations/gitlab/rules.d.ts +22 -1
- package/dist/integrations/gitlab/rules.d.ts.map +1 -1
- package/dist/integrations/gitlab/rules.js +188 -34
- package/dist/integrations/gitlab/rules.js.map +1 -1
- package/dist/integrations/gitlab/session-subscriptions.js +1 -1
- package/dist/integrations/incidentio/agent-tools.js +6 -6
- package/dist/integrations/incidentio/agent-tools.js.map +1 -1
- package/dist/integrations/incidentio/default-rules.d.ts +1 -9
- package/dist/integrations/incidentio/default-rules.d.ts.map +1 -1
- package/dist/integrations/incidentio/default-rules.js +6 -7
- package/dist/integrations/incidentio/default-rules.js.map +1 -1
- package/dist/integrations/incidentio/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/incidentio/issue-reconciler.js +2 -1
- package/dist/integrations/incidentio/issue-reconciler.js.map +1 -1
- package/dist/integrations/incidentio/routes.d.ts +2 -2
- package/dist/integrations/incidentio/routes.d.ts.map +1 -1
- package/dist/integrations/incidentio/routes.js +11 -17
- package/dist/integrations/incidentio/routes.js.map +1 -1
- package/dist/integrations/incidentio/rules.d.ts +11 -4
- package/dist/integrations/incidentio/rules.d.ts.map +1 -1
- package/dist/integrations/incidentio/rules.js +52 -16
- package/dist/integrations/incidentio/rules.js.map +1 -1
- package/dist/integrations/issue-reconciler.js +1 -1
- package/dist/integrations/issue-reconciler.js.map +1 -1
- package/dist/integrations/jira/agent-tools.js +1 -1
- package/dist/integrations/jira/binding-scope.d.ts +5 -6
- package/dist/integrations/jira/binding-scope.d.ts.map +1 -1
- package/dist/integrations/jira/binding-scope.js +9 -11
- package/dist/integrations/jira/binding-scope.js.map +1 -1
- package/dist/integrations/jira/default-rules.d.ts +1 -9
- package/dist/integrations/jira/default-rules.d.ts.map +1 -1
- package/dist/integrations/jira/default-rules.js +6 -7
- package/dist/integrations/jira/default-rules.js.map +1 -1
- package/dist/integrations/jira/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/jira/issue-reconciler.js +2 -1
- package/dist/integrations/jira/issue-reconciler.js.map +1 -1
- package/dist/integrations/jira/routes.d.ts.map +1 -1
- package/dist/integrations/jira/routes.js +4 -9
- package/dist/integrations/jira/routes.js.map +1 -1
- package/dist/integrations/jira/rules.d.ts +11 -4
- package/dist/integrations/jira/rules.d.ts.map +1 -1
- package/dist/integrations/jira/rules.js +52 -16
- package/dist/integrations/jira/rules.js.map +1 -1
- package/dist/integrations/linear/agent-tools.d.ts +9 -1
- package/dist/integrations/linear/agent-tools.d.ts.map +1 -1
- package/dist/integrations/linear/agent-tools.js +81 -3
- package/dist/integrations/linear/agent-tools.js.map +1 -1
- package/dist/integrations/linear/default-rules.d.ts +1 -9
- package/dist/integrations/linear/default-rules.d.ts.map +1 -1
- package/dist/integrations/linear/default-rules.js +6 -7
- package/dist/integrations/linear/default-rules.js.map +1 -1
- package/dist/integrations/linear/integration.d.ts +4 -1
- package/dist/integrations/linear/integration.d.ts.map +1 -1
- package/dist/integrations/linear/integration.js +21 -1
- package/dist/integrations/linear/integration.js.map +1 -1
- package/dist/integrations/linear/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/linear/issue-reconciler.js +2 -1
- package/dist/integrations/linear/issue-reconciler.js.map +1 -1
- package/dist/integrations/linear/routes.d.ts +2 -1
- package/dist/integrations/linear/routes.d.ts.map +1 -1
- package/dist/integrations/linear/routes.js +16 -21
- package/dist/integrations/linear/routes.js.map +1 -1
- package/dist/integrations/linear/rules.d.ts +11 -4
- package/dist/integrations/linear/rules.d.ts.map +1 -1
- package/dist/integrations/linear/rules.js +50 -17
- package/dist/integrations/linear/rules.js.map +1 -1
- package/dist/integrations/platform/connect/routes.d.ts +7 -1
- package/dist/integrations/platform/connect/routes.d.ts.map +1 -1
- package/dist/integrations/platform/connect/routes.js +42 -5
- package/dist/integrations/platform/connect/routes.js.map +1 -1
- package/dist/integrations/platform/connect/session-tools.d.ts +12 -0
- package/dist/integrations/platform/connect/session-tools.d.ts.map +1 -0
- package/dist/integrations/platform/connect/session-tools.js +35 -0
- package/dist/integrations/platform/connect/session-tools.js.map +1 -0
- package/dist/integrations/platform/github/event-worker.d.ts +4 -1
- package/dist/integrations/platform/github/event-worker.d.ts.map +1 -1
- package/dist/integrations/platform/github/event-worker.js +39 -3
- package/dist/integrations/platform/github/event-worker.js.map +1 -1
- package/dist/integrations/platform/github/integration.d.ts +8 -0
- package/dist/integrations/platform/github/integration.d.ts.map +1 -1
- package/dist/integrations/platform/github/integration.js +132 -90
- package/dist/integrations/platform/github/integration.js.map +1 -1
- package/dist/integrations/platform/jira/agent-tools.js +1 -1
- package/dist/integrations/platform/jira/routes.d.ts.map +1 -1
- package/dist/integrations/platform/jira/routes.js +4 -9
- package/dist/integrations/platform/jira/routes.js.map +1 -1
- package/dist/integrations/platform/linear/event-worker.d.ts +1 -1
- package/dist/integrations/platform/linear/event-worker.d.ts.map +1 -1
- package/dist/integrations/platform/linear/event-worker.js +10 -1
- package/dist/integrations/platform/linear/event-worker.js.map +1 -1
- package/dist/integrations/platform/linear/integration.d.ts +1 -1
- package/dist/integrations/platform/linear/integration.d.ts.map +1 -1
- package/dist/integrations/platform/linear/integration.js +7 -8
- package/dist/integrations/platform/linear/integration.js.map +1 -1
- package/dist/integrations/slack/channel-reply-processor.d.ts +2 -0
- package/dist/integrations/slack/channel-reply-processor.d.ts.map +1 -1
- package/dist/integrations/slack/channel-reply-processor.js +6 -1
- package/dist/integrations/slack/channel-reply-processor.js.map +1 -1
- package/dist/integrations/slack/chat-tools.js +1 -1
- package/dist/integrations/slack/connect-route.d.ts.map +1 -1
- package/dist/integrations/slack/connect-route.js +1 -1
- package/dist/integrations/slack/connect-route.js.map +1 -1
- package/dist/integrations/slack/integration.d.ts +0 -2
- package/dist/integrations/slack/integration.d.ts.map +1 -1
- package/dist/integrations/slack/integration.js +2 -5
- package/dist/integrations/slack/integration.js.map +1 -1
- package/dist/integrations/slack/reply-tool.js +1 -1
- package/dist/integrations/slack/run-error-card.js +1 -0
- package/dist/integrations/slack/run-error-card.js.map +1 -1
- package/dist/integrations/slack/share-file-tool.js +1 -1
- package/dist/integrations/slack/slack.d.ts +23 -30
- package/dist/integrations/slack/slack.d.ts.map +1 -1
- package/dist/integrations/slack/slack.js +131 -125
- package/dist/integrations/slack/slack.js.map +1 -1
- package/dist/integrations/slack/voice-clips.d.ts +32 -0
- package/dist/integrations/slack/voice-clips.d.ts.map +1 -0
- package/dist/integrations/slack/voice-clips.js +201 -0
- package/dist/integrations/slack/voice-clips.js.map +1 -0
- package/dist/integrations/workos/integration.d.ts.map +1 -1
- package/dist/integrations/workos/integration.js +1 -3
- package/dist/integrations/workos/integration.js.map +1 -1
- package/dist/links.d.ts +1 -2
- package/dist/links.d.ts.map +1 -1
- package/dist/links.js +4 -4
- package/dist/links.js.map +1 -1
- package/dist/mcp/routes.js +2 -2
- package/dist/mcp/routes.js.map +1 -1
- package/dist/packages/_internals/workspace/dist/index.js +1 -1
- package/dist/provider-display-name.d.ts.map +1 -1
- package/dist/provider-display-name.js +1 -0
- package/dist/provider-display-name.js.map +1 -1
- package/dist/routes/attention-parked.d.ts +1 -0
- package/dist/routes/attention-parked.d.ts.map +1 -1
- package/dist/routes/attention-parked.js +2 -2
- package/dist/routes/attention-parked.js.map +1 -1
- package/dist/routes/attention-providers.d.ts +0 -25
- package/dist/routes/attention-providers.d.ts.map +1 -1
- package/dist/routes/attention-providers.js +3 -151
- package/dist/routes/attention-providers.js.map +1 -1
- package/dist/routes/attention.d.ts +0 -2
- package/dist/routes/attention.d.ts.map +1 -1
- package/dist/routes/attention.js +2 -13
- package/dist/routes/attention.js.map +1 -1
- package/dist/routes/automation-runs.d.ts +5 -1
- package/dist/routes/automation-runs.d.ts.map +1 -1
- package/dist/routes/automation-runs.js +16 -4
- package/dist/routes/automation-runs.js.map +1 -1
- package/dist/routes/board-snapshot.d.ts +15 -0
- package/dist/routes/board-snapshot.d.ts.map +1 -0
- package/dist/routes/board-snapshot.js +41 -0
- package/dist/routes/board-snapshot.js.map +1 -0
- package/dist/routes/boards.d.ts +9 -7
- package/dist/routes/boards.d.ts.map +1 -1
- package/dist/routes/boards.js +59 -145
- package/dist/routes/boards.js.map +1 -1
- package/dist/routes/config.d.ts +11 -1
- package/dist/routes/config.d.ts.map +1 -1
- package/dist/routes/config.js +122 -29
- package/dist/routes/config.js.map +1 -1
- package/dist/routes/contracts.d.ts +366 -34
- package/dist/routes/contracts.d.ts.map +1 -1
- package/dist/routes/contracts.js +179 -51
- package/dist/routes/contracts.js.map +1 -1
- package/dist/routes/feed-events.d.ts +15 -0
- package/dist/routes/feed-events.d.ts.map +1 -0
- package/dist/routes/feed-events.js +68 -0
- package/dist/routes/feed-events.js.map +1 -0
- package/dist/routes/fs.d.ts +4 -0
- package/dist/routes/fs.d.ts.map +1 -1
- package/dist/routes/fs.js +9 -8
- package/dist/routes/fs.js.map +1 -1
- package/dist/routes/intake-routes.d.ts.map +1 -1
- package/dist/routes/intake-routes.js +25 -13
- package/dist/routes/intake-routes.js.map +1 -1
- package/dist/routes/intake.d.ts +0 -23
- package/dist/routes/intake.d.ts.map +1 -1
- package/dist/routes/intake.js +16 -314
- package/dist/routes/intake.js.map +1 -1
- package/dist/routes/knowledge.d.ts.map +1 -1
- package/dist/routes/knowledge.js +2 -5
- package/dist/routes/knowledge.js.map +1 -1
- package/dist/routes/mastra-gateway.d.ts +19 -0
- package/dist/routes/mastra-gateway.d.ts.map +1 -0
- package/dist/routes/mastra-gateway.js +120 -0
- package/dist/routes/mastra-gateway.js.map +1 -0
- package/dist/routes/oauth.d.ts.map +1 -1
- package/dist/routes/oauth.js +1 -4
- package/dist/routes/oauth.js.map +1 -1
- package/dist/routes/projects.d.ts +3 -0
- package/dist/routes/projects.d.ts.map +1 -1
- package/dist/routes/projects.js +80 -61
- package/dist/routes/projects.js.map +1 -1
- package/dist/routes/provider-credentials.d.ts +6 -1
- package/dist/routes/provider-credentials.d.ts.map +1 -1
- package/dist/routes/provider-credentials.js +44 -3
- package/dist/routes/provider-credentials.js.map +1 -1
- package/dist/routes/route.d.ts +8 -0
- package/dist/routes/route.d.ts.map +1 -1
- package/dist/routes/route.js +5 -1
- package/dist/routes/route.js.map +1 -1
- package/dist/routes/running-packages.d.ts +13 -0
- package/dist/routes/running-packages.d.ts.map +1 -0
- package/dist/routes/running-packages.js +45 -0
- package/dist/routes/running-packages.js.map +1 -0
- package/dist/routes/sandbox-envs.d.ts +26 -0
- package/dist/routes/sandbox-envs.d.ts.map +1 -0
- package/dist/routes/sandbox-envs.js +180 -0
- package/dist/routes/sandbox-envs.js.map +1 -0
- package/dist/routes/session-access.d.ts.map +1 -1
- package/dist/routes/session-access.js +12 -3
- package/dist/routes/session-access.js.map +1 -1
- package/dist/routes/skills.d.ts.map +1 -1
- package/dist/routes/skills.js +1 -4
- package/dist/routes/skills.js.map +1 -1
- package/dist/routes/source-control-sessions.d.ts.map +1 -1
- package/dist/routes/source-control-sessions.js +1 -3
- package/dist/routes/source-control-sessions.js.map +1 -1
- package/dist/routes/source-control-settings.d.ts.map +1 -1
- package/dist/routes/source-control-settings.js +3 -2
- package/dist/routes/source-control-settings.js.map +1 -1
- package/dist/routes/surface.d.ts +13 -9
- package/dist/routes/surface.d.ts.map +1 -1
- package/dist/routes/surface.js +116 -43
- package/dist/routes/surface.js.map +1 -1
- package/dist/routes/tenant-credentials.d.ts.map +1 -1
- package/dist/routes/tenant-credentials.js +5 -1
- package/dist/routes/tenant-credentials.js.map +1 -1
- package/dist/routes/voice.d.ts +48 -0
- package/dist/routes/voice.d.ts.map +1 -0
- package/dist/routes/voice.js +248 -0
- package/dist/routes/voice.js.map +1 -0
- package/dist/routes/work-items.d.ts +0 -3
- package/dist/routes/work-items.d.ts.map +1 -1
- package/dist/routes/work-items.js +39 -14
- package/dist/routes/work-items.js.map +1 -1
- package/dist/rules/binding-context.d.ts.map +1 -1
- package/dist/rules/binding-context.js +1 -0
- package/dist/rules/binding-context.js.map +1 -1
- package/dist/rules/decision-applicability.js +1 -1
- package/dist/rules/dispatcher.d.ts +28 -9
- package/dist/rules/dispatcher.d.ts.map +1 -1
- package/dist/rules/dispatcher.js +734 -143
- package/dist/rules/dispatcher.js.map +1 -1
- package/dist/rules/event-rules.d.ts +71 -1
- package/dist/rules/event-rules.d.ts.map +1 -1
- package/dist/rules/event-rules.js +94 -1
- package/dist/rules/event-rules.js.map +1 -1
- package/dist/rules/index.d.ts +2 -4
- package/dist/rules/index.d.ts.map +1 -1
- package/dist/rules/index.js +2 -3
- package/dist/rules/phase-goal.d.ts +54 -0
- package/dist/rules/phase-goal.d.ts.map +1 -0
- package/dist/rules/phase-goal.js +70 -0
- package/dist/rules/phase-goal.js.map +1 -0
- package/dist/rules/phase-tools.d.ts +11 -0
- package/dist/rules/phase-tools.d.ts.map +1 -0
- package/dist/rules/phase-tools.js +19 -0
- package/dist/rules/phase-tools.js.map +1 -0
- package/dist/rules/processor.d.ts.map +1 -1
- package/dist/rules/processor.js +116 -15
- package/dist/rules/processor.js.map +1 -1
- package/dist/rules/review-source-tool.d.ts +4 -1
- package/dist/rules/review-source-tool.d.ts.map +1 -1
- package/dist/rules/review-source-tool.js +24 -4
- package/dist/rules/review-source-tool.js.map +1 -1
- package/dist/rules/rule-group.d.ts +1 -1
- package/dist/rules/rule-group.d.ts.map +1 -1
- package/dist/rules/rule-group.js +15 -6
- package/dist/rules/rule-group.js.map +1 -1
- package/dist/rules/start-coordinator.d.ts +5 -1
- package/dist/rules/start-coordinator.d.ts.map +1 -1
- package/dist/rules/start-coordinator.js +9 -3
- package/dist/rules/start-coordinator.js.map +1 -1
- package/dist/rules/tools.d.ts.map +1 -1
- package/dist/rules/tools.js +39 -28
- package/dist/rules/tools.js.map +1 -1
- package/dist/rules/transition-service.d.ts +10 -7
- package/dist/rules/transition-service.d.ts.map +1 -1
- package/dist/rules/transition-service.js +63 -55
- package/dist/rules/transition-service.js.map +1 -1
- package/dist/rules/types.d.ts +140 -39
- package/dist/rules/types.d.ts.map +1 -1
- package/dist/rules/types.js +7 -41
- package/dist/rules/types.js.map +1 -1
- package/dist/rules/validation.d.ts.map +1 -1
- package/dist/rules/validation.js +89 -4
- package/dist/rules/validation.js.map +1 -1
- package/dist/run-error.d.ts +1 -1
- package/dist/run-error.d.ts.map +1 -1
- package/dist/run-error.js +38 -5
- package/dist/run-error.js.map +1 -1
- package/dist/sandbox/sandbox-env-cache.d.ts +33 -0
- package/dist/sandbox/sandbox-env-cache.d.ts.map +1 -0
- package/dist/sandbox/sandbox-env-cache.js +140 -0
- package/dist/sandbox/sandbox-env-cache.js.map +1 -0
- package/dist/sandbox/sandbox-env.d.ts +77 -0
- package/dist/sandbox/sandbox-env.d.ts.map +1 -0
- package/dist/sandbox/sandbox-env.js +130 -0
- package/dist/sandbox/sandbox-env.js.map +1 -0
- package/dist/secret-encryption.d.ts +21 -0
- package/dist/secret-encryption.d.ts.map +1 -1
- package/dist/secret-encryption.js +31 -4
- package/dist/secret-encryption.js.map +1 -1
- package/dist/session/credential-policy.d.ts +2 -2
- package/dist/session/credential-policy.d.ts.map +1 -1
- package/dist/session/credential-policy.js +3 -3
- package/dist/session/credential-policy.js.map +1 -1
- package/dist/session/default-model-hydration.d.ts +2 -2
- package/dist/session/default-model-hydration.d.ts.map +1 -1
- package/dist/session/default-model-hydration.js +4 -4
- package/dist/session/default-model-hydration.js.map +1 -1
- package/dist/session/live-sessions.d.ts +11 -4
- package/dist/session/live-sessions.d.ts.map +1 -1
- package/dist/session/live-sessions.js +31 -10
- package/dist/session/live-sessions.js.map +1 -1
- package/dist/session/self-review-gate.d.ts +6 -4
- package/dist/session/self-review-gate.d.ts.map +1 -1
- package/dist/session/self-review-gate.js +9 -12
- package/dist/session/self-review-gate.js.map +1 -1
- package/dist/session/session-threads.d.ts +10 -3
- package/dist/session/session-threads.d.ts.map +1 -1
- package/dist/session/session-threads.js +11 -1
- package/dist/session/session-threads.js.map +1 -1
- package/dist/session/source-control-tools.d.ts +39 -13
- package/dist/session/source-control-tools.d.ts.map +1 -1
- package/dist/session/source-control-tools.js +55 -61
- package/dist/session/source-control-tools.js.map +1 -1
- package/dist/session/work-item-state-processor.d.ts +24 -0
- package/dist/session/work-item-state-processor.d.ts.map +1 -0
- package/dist/session/work-item-state-processor.js +275 -0
- package/dist/session/work-item-state-processor.js.map +1 -0
- package/dist/skills/catalog.js +1 -1
- package/dist/storage/domains/audit/actions.d.ts +3 -2
- package/dist/storage/domains/audit/actions.d.ts.map +1 -1
- package/dist/storage/domains/audit/actions.js +7 -5
- package/dist/storage/domains/audit/actions.js.map +1 -1
- package/dist/storage/domains/audit/domain.d.ts.map +1 -1
- package/dist/storage/domains/audit/domain.js +1 -3
- package/dist/storage/domains/audit/domain.js.map +1 -1
- package/dist/storage/domains/boards/base.d.ts +107 -23
- package/dist/storage/domains/boards/base.d.ts.map +1 -1
- package/dist/storage/domains/boards/base.js +201 -65
- package/dist/storage/domains/boards/base.js.map +1 -1
- package/dist/storage/domains/boards/schemas.d.ts.map +1 -1
- package/dist/storage/domains/boards/schemas.js +25 -1
- package/dist/storage/domains/boards/schemas.js.map +1 -1
- package/dist/storage/domains/channel-identity/base.d.ts +0 -4
- package/dist/storage/domains/channel-identity/base.d.ts.map +1 -1
- package/dist/storage/domains/channel-identity/base.js +0 -7
- package/dist/storage/domains/channel-identity/base.js.map +1 -1
- package/dist/storage/domains/intake/base.d.ts +5 -45
- package/dist/storage/domains/intake/base.d.ts.map +1 -1
- package/dist/storage/domains/intake/base.js +11 -89
- package/dist/storage/domains/intake/base.js.map +1 -1
- package/dist/storage/domains/memory-settings/base.d.ts +0 -8
- package/dist/storage/domains/memory-settings/base.d.ts.map +1 -1
- package/dist/storage/domains/memory-settings/base.js +1 -11
- package/dist/storage/domains/memory-settings/base.js.map +1 -1
- package/dist/storage/domains/projects/base.d.ts +23 -9
- package/dist/storage/domains/projects/base.d.ts.map +1 -1
- package/dist/storage/domains/projects/base.js +24 -8
- package/dist/storage/domains/projects/base.js.map +1 -1
- package/dist/storage/domains/sandbox-envs/base.d.ts +70 -0
- package/dist/storage/domains/sandbox-envs/base.d.ts.map +1 -0
- package/dist/storage/domains/sandbox-envs/base.js +227 -0
- package/dist/storage/domains/sandbox-envs/base.js.map +1 -0
- package/dist/storage/domains/voice-settings/base.d.ts +31 -0
- package/dist/storage/domains/voice-settings/base.d.ts.map +1 -0
- package/dist/storage/domains/voice-settings/base.js +81 -0
- package/dist/storage/domains/voice-settings/base.js.map +1 -0
- package/dist/storage/domains/work-items/base.d.ts +93 -24
- package/dist/storage/domains/work-items/base.d.ts.map +1 -1
- package/dist/storage/domains/work-items/base.js +413 -188
- package/dist/storage/domains/work-items/base.js.map +1 -1
- package/dist/storage/domains/work-items/board-version.d.ts +6 -2
- package/dist/storage/domains/work-items/board-version.d.ts.map +1 -1
- package/dist/storage/domains/work-items/board-version.js +20 -9
- package/dist/storage/domains/work-items/board-version.js.map +1 -1
- package/dist/storage/domains/work-items/cards.d.ts +33 -5
- package/dist/storage/domains/work-items/cards.d.ts.map +1 -1
- package/dist/storage/domains/work-items/cards.js +208 -25
- package/dist/storage/domains/work-items/cards.js.map +1 -1
- package/dist/storage/domains/work-items/legacy-review.d.ts +63 -0
- package/dist/storage/domains/work-items/legacy-review.d.ts.map +1 -0
- package/dist/storage/domains/work-items/legacy-review.js +109 -0
- package/dist/storage/domains/work-items/legacy-review.js.map +1 -0
- package/dist/storage/domains/work-items/metrics.d.ts +12 -4
- package/dist/storage/domains/work-items/metrics.d.ts.map +1 -1
- package/dist/storage/domains/work-items/metrics.js +14 -32
- package/dist/storage/domains/work-items/metrics.js.map +1 -1
- package/dist/storage/domains/work-items/work-item-schema.d.ts +6 -2
- package/dist/storage/domains/work-items/work-item-schema.d.ts.map +1 -1
- package/dist/storage/domains/work-items/work-item-schema.js +83 -27
- package/dist/storage/domains/work-items/work-item-schema.js.map +1 -1
- package/dist/timing.d.ts +1 -0
- package/dist/timing.d.ts.map +1 -1
- package/dist/timing.js +1 -1
- package/dist/timing.js.map +1 -1
- package/dist/tools/approval-tools.d.ts.map +1 -1
- package/dist/tools/approval-tools.js +28 -9
- package/dist/tools/approval-tools.js.map +1 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/messaging-tools.d.ts +3 -0
- package/dist/tools/messaging-tools.d.ts.map +1 -1
- package/dist/tools/messaging-tools.js +2 -1
- package/dist/tools/messaging-tools.js.map +1 -1
- package/dist/tools/read-tools.d.ts +10 -6
- package/dist/tools/read-tools.d.ts.map +1 -1
- package/dist/tools/read-tools.js +89 -39
- package/dist/tools/read-tools.js.map +1 -1
- package/dist/tools/reports.d.ts +1 -0
- package/dist/tools/reports.d.ts.map +1 -1
- package/dist/tools/reports.js +2 -1
- package/dist/tools/reports.js.map +1 -1
- package/dist/tools/run-watch.d.ts +1 -1
- package/dist/tools/run-watch.d.ts.map +1 -1
- package/dist/tools/run-watch.js +1 -0
- package/dist/tools/run-watch.js.map +1 -1
- package/dist/tools/sandbox-tools.js +1 -1
- package/dist/tools/session-tools.d.ts +1 -1
- package/dist/tools/session-tools.d.ts.map +1 -1
- package/dist/tools/session-tools.js +1 -1
- package/dist/tools/session-tools.js.map +1 -1
- package/dist/tools/sessions-state-processor.d.ts +3 -1
- package/dist/tools/sessions-state-processor.d.ts.map +1 -1
- package/dist/tools/sessions-state-processor.js +13 -4
- package/dist/tools/sessions-state-processor.js.map +1 -1
- package/dist/tools/side-sessions.d.ts +2 -0
- package/dist/tools/side-sessions.d.ts.map +1 -1
- package/dist/tools/side-sessions.js +2 -1
- package/dist/tools/side-sessions.js.map +1 -1
- package/dist/tools/work-item-tools.d.ts +0 -3
- package/dist/tools/work-item-tools.d.ts.map +1 -1
- package/dist/tools/work-item-tools.js +10 -20
- package/dist/tools/work-item-tools.js.map +1 -1
- package/dist/voice/rate-limit.d.ts +13 -0
- package/dist/voice/rate-limit.d.ts.map +1 -0
- package/dist/voice/rate-limit.js +36 -0
- package/dist/voice/rate-limit.js.map +1 -0
- package/dist/voice/realtime.d.ts +13 -0
- package/dist/voice/realtime.d.ts.map +1 -0
- package/dist/voice/realtime.js +56 -0
- package/dist/voice/realtime.js.map +1 -0
- package/dist/voice/transcription.d.ts +51 -0
- package/dist/voice/transcription.d.ts.map +1 -0
- package/dist/voice/transcription.js +112 -0
- package/dist/voice/transcription.js.map +1 -0
- package/dist/work-item-branch.d.ts +13 -0
- package/dist/work-item-branch.d.ts.map +1 -1
- package/dist/work-item-branch.js +16 -1
- package/dist/work-item-branch.js.map +1 -1
- package/dist/work-items/create-work-item.d.ts +6 -0
- package/dist/work-items/create-work-item.d.ts.map +1 -1
- package/dist/work-items/create-work-item.js +28 -3
- package/dist/work-items/create-work-item.js.map +1 -1
- package/dist/work-items/description-context.d.ts +5 -0
- package/dist/work-items/description-context.d.ts.map +1 -0
- package/dist/work-items/description-context.js +17 -0
- package/dist/work-items/description-context.js.map +1 -0
- package/dist/work-items/providers/base.d.ts +4 -1
- package/dist/work-items/providers/base.d.ts.map +1 -1
- package/dist/work-items/providers/base.js +6 -1
- package/dist/work-items/providers/base.js.map +1 -1
- package/dist/work-items/providers/github.d.ts.map +1 -1
- package/dist/work-items/providers/github.js +2 -1
- package/dist/work-items/providers/github.js.map +1 -1
- package/dist/work-items/providers/gitlab.d.ts.map +1 -1
- package/dist/work-items/providers/gitlab.js +2 -1
- package/dist/work-items/providers/gitlab.js.map +1 -1
- package/dist/work-items/providers/jira.d.ts.map +1 -1
- package/dist/work-items/providers/jira.js +3 -2
- package/dist/work-items/providers/jira.js.map +1 -1
- package/dist/work-items/providers/linear.d.ts.map +1 -1
- package/dist/work-items/providers/linear.js +3 -2
- package/dist/work-items/providers/linear.js.map +1 -1
- package/dist/work-items/providers/types.d.ts +6 -0
- package/dist/work-items/providers/types.d.ts.map +1 -1
- package/dist/work-items/split-backfill.d.ts +13 -0
- package/dist/work-items/split-backfill.d.ts.map +1 -0
- package/dist/work-items/split-backfill.js +32 -0
- package/dist/work-items/split-backfill.js.map +1 -0
- package/dist/work-items/split-migration.d.ts +39 -2
- package/dist/work-items/split-migration.d.ts.map +1 -1
- package/dist/work-items/split-migration.js +178 -70
- package/dist/work-items/split-migration.js.map +1 -1
- package/dist/workspace.d.ts +3 -1
- package/dist/workspace.d.ts.map +1 -1
- package/dist/workspace.js +118 -34
- package/dist/workspace.js.map +1 -1
- package/factory-skills/configure-factory-rules/SKILL.md +13 -11
- package/factory-skills/factory-build/SKILL.md +64 -0
- package/factory-skills/factory-gitlab-rereview/SKILL.md +4 -4
- package/factory-skills/factory-gitlab-review/SKILL.md +6 -6
- package/factory-skills/factory-plan/SKILL.md +8 -10
- package/factory-skills/factory-rereview/SKILL.md +74 -28
- package/factory-skills/factory-review/SKILL.md +85 -29
- package/factory-skills/factory-self-review/SKILL.md +32 -13
- package/factory-skills/factory-triage/SKILL.md +36 -32
- package/package.json +12 -11
- package/dist/boards/index.js.map +0 -1
- package/dist/boards/pull-request-review.d.ts +0 -14
- package/dist/boards/pull-request-review.d.ts.map +0 -1
- package/dist/boards/pull-request-review.js +0 -81
- package/dist/boards/pull-request-review.js.map +0 -1
- package/dist/boards/work-tool-rules.d.ts +0 -8
- package/dist/boards/work-tool-rules.d.ts.map +0 -1
- package/dist/boards/work-tool-rules.js +0 -19
- package/dist/boards/work-tool-rules.js.map +0 -1
- package/dist/integrations/slack/emoji-shortcodes.generated.d.ts +0 -8
- package/dist/integrations/slack/emoji-shortcodes.generated.d.ts.map +0 -1
- package/dist/integrations/slack/emoji-shortcodes.generated.js +0 -1984
- package/dist/integrations/slack/emoji-shortcodes.generated.js.map +0 -1
- package/dist/integrations/slack/emoji.d.ts +0 -3
- package/dist/integrations/slack/emoji.d.ts.map +0 -1
- package/dist/integrations/slack/emoji.js +0 -11
- package/dist/integrations/slack/emoji.js.map +0 -1
- package/dist/integrations/slack/feed-publisher.d.ts +0 -26
- package/dist/integrations/slack/feed-publisher.d.ts.map +0 -1
- package/dist/integrations/slack/feed-publisher.js +0 -43
- package/dist/integrations/slack/feed-publisher.js.map +0 -1
- package/dist/routes/attention-activity.d.ts +0 -23
- package/dist/routes/attention-activity.d.ts.map +0 -1
- package/dist/routes/attention-activity.js +0 -154
- package/dist/routes/attention-activity.js.map +0 -1
- package/dist/rules/resolve.d.ts +0 -15
- package/dist/rules/resolve.d.ts.map +0 -1
- package/dist/rules/resolve.js +0 -22
- package/dist/rules/resolve.js.map +0 -1
- package/dist/storage/domains/comments/activity.d.ts +0 -40
- package/dist/storage/domains/comments/activity.d.ts.map +0 -1
- package/dist/storage/domains/comments/activity.js +0 -93
- package/dist/storage/domains/comments/activity.js.map +0 -1
- package/dist/storage/domains/comments/actor.d.ts +0 -51
- package/dist/storage/domains/comments/actor.d.ts.map +0 -1
- package/dist/storage/domains/comments/actor.js +0 -37
- package/dist/storage/domains/comments/actor.js.map +0 -1
- package/dist/storage/domains/comments/base.d.ts +0 -245
- package/dist/storage/domains/comments/base.d.ts.map +0 -1
- package/dist/storage/domains/comments/base.js +0 -539
- package/dist/storage/domains/comments/base.js.map +0 -1
- package/dist/storage/domains/comments/domain.d.ts +0 -135
- package/dist/storage/domains/comments/domain.d.ts.map +0 -1
- package/dist/storage/domains/comments/domain.js +0 -284
- package/dist/storage/domains/comments/domain.js.map +0 -1
- package/dist/storage/domains/comments/feed-context.d.ts +0 -22
- package/dist/storage/domains/comments/feed-context.d.ts.map +0 -1
- package/dist/storage/domains/comments/feed-context.js +0 -88
- package/dist/storage/domains/comments/feed-context.js.map +0 -1
- package/dist/storage/domains/comments/feed-sync.d.ts +0 -21
- package/dist/storage/domains/comments/feed-sync.d.ts.map +0 -1
- package/dist/storage/domains/comments/feed-sync.js +0 -1
- package/dist/storage/domains/comments/parse.d.ts +0 -23
- package/dist/storage/domains/comments/parse.d.ts.map +0 -1
- package/dist/storage/domains/comments/parse.js +0 -89
- package/dist/storage/domains/comments/parse.js.map +0 -1
- package/dist/storage/domains/comments/routes.d.ts +0 -24
- package/dist/storage/domains/comments/routes.d.ts.map +0 -1
- package/dist/storage/domains/comments/routes.js +0 -301
- package/dist/storage/domains/comments/routes.js.map +0 -1
- package/dist/storage/domains/comments/schema.d.ts +0 -5
- package/dist/storage/domains/comments/schema.d.ts.map +0 -1
- package/dist/storage/domains/comments/schema.js +0 -178
- package/dist/storage/domains/comments/schema.js.map +0 -1
- package/dist/storage/domains/comments/wire.d.ts +0 -40
- package/dist/storage/domains/comments/wire.d.ts.map +0 -1
- package/dist/storage/domains/comments/wire.js +0 -36
- package/dist/storage/domains/comments/wire.js.map +0 -1
- package/factory-skills/factory-complete-issue/SKILL.md +0 -24
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messaging-tools.js","names":[],"sources":["../../src/tools/messaging-tools.ts"],"sourcesContent":["/**\n * Messages between Factory sessions. A user session can message any session in\n * its Factory it can see; the receiver answers that exact message. Both\n * directions are `factory-session` notifications on the receiver's stored thread.\n */\n\nimport type {\n NotificationPriority,\n NotificationRecord,\n NotificationsStorage,\n SendNotificationSignalInput,\n} from '@mastra/core/notifications';\nimport { createTool } from '@mastra/core/tools';\nimport { z } from 'zod';\n\nimport type { IntegrationTools } from '../integrations/base.js';\nimport type { SourceControlSessionLookup } from '../session/factory-session.js';\nimport type { AuditRecorder } from '../storage/domains/audit/domain.js';\nimport type { SourceControlSession } from '../storage/domains/source-control/base.js';\nimport type { WorkItemsStorage } from '../storage/domains/work-items/base.js';\nimport {\n FACTORY_SESSION_NOTIFICATION_SOURCE,\n deliverFactorySessionNotification,\n resolveSessionThread,\n} from './deliver.js';\nimport type { FactoryDeliveryController, FactoryDeliveryResult } from './deliver.js';\nimport { workItemNumber } from './read-tools.js';\nimport { reportNotification, workItemReportAttributes, workItemReportRecipients } from './reports.js';\nimport { requirePerson } from './scope.js';\nimport type { FactoryToolScope } from './scope.js';\nimport { listSideSessions, sessionModel } from './side-sessions.js';\n\n/** Messages plus replies, per sender session, per target thread, per window. */\nexport const SIGNAL_RATE_LIMIT = 10;\nexport const SIGNAL_RATE_WINDOW_MS = 10 * 60 * 1000;\n/** How many recent `factory-session` notifications on a thread the rate and duplicate checks read. */\nconst RECENT_SCAN = 100;\n/** How often a waiting queue is reconsidered. Delivery still waits for a free slot in the window. */\nconst QUEUE_FLUSH_MS = 1000;\n\n/** A message accepted past the delivery cap, held until the window has a free slot. */\ninterface PendingMessage {\n notification: Omit<SendNotificationSignalInput, 'source'>;\n /** When the sender handed it over. Oldest goes first. */\n acceptedAt: number;\n actor: { actorId: string; actorType: 'human' | 'agent' };\n}\n\ninterface QueuedDelivery extends PendingMessage {\n /** The moment a slot in the window is expected to free. Set once, when it joins the queue. */\n deliverAt: number;\n target: { sessionId: string; threadId: string };\n}\n\n/**\n * Waiting messages, per sender session and target thread, oldest first.\n * Process-local: a restart drops what was still waiting, the same as a message\n * that had not been handed to the tool yet. Delivered messages live in the\n * notification store and are unaffected.\n */\nconst pendingQueues = new Map<string, QueuedDelivery[]>();\nconst flushTimers = new Map<string, ReturnType<typeof setTimeout>>();\n\nconst queueOwners = new WeakMap<object, number>();\nlet nextQueueOwnerId = 0;\n\nconst queueKey = (owner: object, senderSessionId: string, threadId: string): string => {\n let id = queueOwners.get(owner);\n if (id === undefined) {\n nextQueueOwnerId += 1;\n id = nextQueueOwnerId;\n queueOwners.set(owner, id);\n }\n return `${id}\\0${senderSessionId}\\0${threadId}`;\n};\nexport interface FactoryMessaging {\n controller: FactoryDeliveryController;\n notifications: Pick<NotificationsStorage, 'listNotifications' | 'getNotification'>;\n}\n\nexport interface FactoryMessagingToolDependencies {\n sessions: Pick<SourceControlSessionLookup, 'getBySessionId' | 'listByOrigin' | 'setOriginMuted'>;\n workItems: Pick<\n WorkItemsStorage,\n | 'findActiveRunBindingForSession'\n | 'getForProject'\n | 'hasRunBindingForSession'\n | 'listSessionSubscriptions'\n | 'listRunBindings'\n | 'listWorkItemSubscribers'\n >;\n auditRecorder: AuditRecorder;\n /** The live controller and notifications store; resolved per call because they exist only once the mount is up. */\n messaging: () => Promise<FactoryMessaging | null>;\n}\n\nconst message = z.string().trim().min(1).max(4000);\n\nfunction senderAttributes(scope: FactoryToolScope) {\n return {\n 'from-session': scope.sessionId,\n 'from-thread': scope.threadId,\n 'from-user': scope.userId,\n };\n}\n\nfunction unavailable(result: Extract<FactoryDeliveryResult, { delivered: 'skipped' }>) {\n return new Error(`The session is not available (${result.reason}).`);\n}\n\nexport function createFactoryMessagingTools(\n scope: FactoryToolScope,\n deps: FactoryMessagingToolDependencies,\n): IntegrationTools {\n const requireMessaging = async () => {\n const messaging = await deps.messaging();\n if (!messaging) throw new Error('Session messaging is not available on this server.');\n return messaging;\n };\n // Only a user-session turn the person started is the person's act. Workers\n // (even when someone types into one) and turns nobody signed in started\n // (wakes, webhooks) act as the thread's agent.\n const human = scope.kind === 'user' && scope.interactive;\n const audit = (input: { targetSessionId: string; priority: NotificationPriority; kind: string; delivery: string }) =>\n deps.auditRecorder.record({\n orgId: scope.orgId,\n actorId: human ? scope.userId : `agent:${scope.threadId}`,\n actorType: human ? 'human' : 'agent',\n action: 'factory.agent.signaled',\n factoryProjectId: scope.factoryProjectId,\n targets: [{ type: 'session', id: input.targetSessionId }],\n metadata: {\n targetSessionId: input.targetSessionId,\n priority: input.priority,\n kind: input.kind,\n delivery: input.delivery,\n },\n });\n /** Why this session can't reach `row`, or null when it can: the rule for message targets and reply targets alike. */\n const unreachable = (row: SourceControlSession | null): 'not-found' | 'private' | null => {\n if (!row || row.orgId !== scope.orgId || row.factoryProjectId !== scope.factoryProjectId) return 'not-found';\n if (row.visibility === 'private' && row.userId !== scope.userId) return 'private';\n return null;\n };\n const overRateLimit = (records: NotificationRecord[]) => countedInWindow(records).length >= SIGNAL_RATE_LIMIT;\n /** This session's delivered messages on the thread that still sit inside the window, oldest first. */\n const countedInWindow = (records: NotificationRecord[]): NotificationRecord[] => {\n const since = Date.now() - SIGNAL_RATE_WINDOW_MS;\n return records\n .filter(\n record =>\n // Everything this session sends counts except coalescing progress updates.\n record.kind !== 'progress' &&\n record.kind !== 'stage' &&\n record.attributes?.['from-session'] === scope.sessionId &&\n record.createdAt.getTime() >= since,\n )\n .sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());\n };\n /**\n * When the next message can be delivered: one window after the oldest message\n * that has to age out to free a slot, given how many are already waiting.\n */\n const nextDeliveryAt = (counted: NotificationRecord[], waiting: number): number => {\n const blocking = counted[counted.length + waiting - SIGNAL_RATE_LIMIT];\n return (blocking ? blocking.createdAt.getTime() : Date.now()) + SIGNAL_RATE_WINDOW_MS;\n };\n const queuedResult = (deliverAt: number) => ({\n delivered: 'queued' as const,\n deliverAt: new Date(deliverAt).toISOString(),\n note: `Queued; it will be delivered at about ${new Date(deliverAt).toISOString()}. Do not send it again.`,\n });\n const recent = (notifications: FactoryMessaging['notifications'], threadId: string) =>\n notifications.listNotifications({ threadId, source: FACTORY_SESSION_NOTIFICATION_SOURCE, limit: RECENT_SCAN });\n\n const actor = (): QueuedDelivery['actor'] => ({\n actorId: human ? scope.userId : `agent:${scope.threadId}`,\n actorType: human ? 'human' : 'agent',\n });\n\n /**\n * Deliver now, or hold until the window has a slot. The cap limits how fast\n * messages are delivered, not whether they are accepted.\n */\n const accept = async (\n messaging: FactoryMessaging,\n target: { sessionId: string; threadId: string },\n notification: Omit<SendNotificationSignalInput, 'source'>,\n ): Promise<\n { notificationId: string; delivered: FactoryDeliveryResult['delivered'] } | ReturnType<typeof queuedResult>\n > => {\n const counted = countedInWindow(await recent(messaging.notifications, target.threadId));\n if (counted.length < SIGNAL_RATE_LIMIT) {\n const result = await deliverFactorySessionNotification({\n controller: messaging.controller,\n sessions: deps.sessions,\n runs: deps.workItems,\n target,\n notification,\n });\n if (result.delivered === 'skipped') throw unavailable(result);\n await audit({\n targetSessionId: target.sessionId,\n priority: notification.priority ?? 'medium',\n kind: notification.kind,\n delivery: result.delivered,\n });\n return { notificationId: result.notificationId, delivered: result.delivered };\n }\n const key = queueKey(deps, scope.sessionId, target.threadId);\n const waiting = pendingQueues.get(key)?.length ?? 0;\n const deliverAt = nextDeliveryAt(counted, waiting);\n enqueue(key, {\n notification,\n acceptedAt: Date.now(),\n actor: actor(),\n deliverAt,\n target,\n });\n return queuedResult(deliverAt);\n };\n\n const enqueue = (key: string, delivery: QueuedDelivery): void => {\n const queue = pendingQueues.get(key) ?? [];\n queue.push(delivery);\n queue.sort((a, b) => a.acceptedAt - b.acceptedAt);\n pendingQueues.set(key, queue);\n scheduleFlush(key);\n };\n\n /**\n * Deliver the oldest waiting message once the window has a free slot, then\n * the next, in the order they were accepted. A target that is gone by then\n * is dropped and recorded, the same way an undeliverable live message is.\n */\n const flush = async (key: string): Promise<void> => {\n flushTimers.delete(key);\n const queue = pendingQueues.get(key);\n if (!queue || queue.length === 0) {\n pendingQueues.delete(key);\n return;\n }\n const messaging = await deps.messaging();\n if (!messaging) {\n scheduleFlush(key);\n return;\n }\n const head = queue[0];\n if (!head || head.deliverAt > Date.now()) {\n scheduleFlush(key);\n return;\n }\n const counted = countedInWindow(await recent(messaging.notifications, head.target.threadId));\n if (counted.length >= SIGNAL_RATE_LIMIT) {\n scheduleFlush(key);\n return;\n }\n queue.shift();\n if (queue.length === 0) pendingQueues.delete(key);\n const result = await deliverFactorySessionNotification({\n controller: messaging.controller,\n sessions: deps.sessions,\n runs: deps.workItems,\n target: head.target,\n notification: head.notification,\n });\n await deps.auditRecorder.record({\n orgId: scope.orgId,\n actorId: head.actor.actorId,\n actorType: head.actor.actorType,\n action: 'factory.agent.signaled',\n factoryProjectId: scope.factoryProjectId,\n targets: [{ type: 'session', id: head.target.sessionId }],\n metadata: {\n targetSessionId: head.target.sessionId,\n priority: head.notification.priority ?? 'medium',\n kind: head.notification.kind,\n delivery: result.delivered === 'skipped' ? 'dropped' : result.delivered,\n ...(result.delivered === 'skipped' ? { reason: result.reason } : {}),\n },\n });\n if (queue.length > 0) scheduleFlush(key);\n };\n\n function scheduleFlush(key: string): void {\n if (flushTimers.has(key)) return;\n if (!pendingQueues.get(key)?.[0]) return;\n const timer = setTimeout(() => {\n flushTimers.delete(key);\n void flush(key).catch(() => {\n // A failed flush leaves the rest of the queue waiting; the next tick retries the head.\n if ((pendingQueues.get(key)?.length ?? 0) > 0) scheduleFlush(key);\n });\n }, QUEUE_FLUSH_MS);\n // Keep the wait on the real clock. A fake clock that jumps the window would\n // skip a timer scheduled for the old deadline, and the message would sit.\n timer.unref?.();\n flushTimers.set(key, timer);\n }\n\n /** On turns nobody signed in started, only sessions working on items this session follows. */\n const followedWorkers = async () => {\n const project = { orgId: scope.orgId, factoryProjectId: scope.factoryProjectId };\n const follows = await deps.workItems.listSessionSubscriptions({ ...project, sessionId: scope.sessionId });\n const bindings = await Promise.all(\n follows.map(follow => deps.workItems.listRunBindings(scope.orgId, scope.factoryProjectId, follow.workItemId)),\n );\n const sideSessions = await deps.sessions.listByOrigin({ orgId: scope.orgId, originSessionId: scope.sessionId });\n return new Set([\n ...bindings\n .flat()\n .filter(binding => binding.status === 'active')\n .map(binding => binding.sessionId),\n ...sideSessions.map(session => session.sessionId),\n ]);\n };\n\n const workItemAttribute = async (sessionId: string, orgId: string, factoryProjectId: string) => {\n const binding = await deps.workItems.findActiveRunBindingForSession({ orgId, factoryProjectId, sessionId });\n if (!binding) return {};\n const item = await deps.workItems.getForProject(orgId, factoryProjectId, binding.workItemId);\n if (!item) return {};\n const number = workItemNumber(item);\n return { 'work-item': number === null ? item.id : `#${number}` };\n };\n\n const signal = createTool({\n id: 'factory_signal_session',\n description: [\n 'Send a message to another session in this Factory: a work item role session, or a teammate session you can see.',\n 'Replies come back to this session as `factory-session` notifications with kind `reply` and an `in-reply-to` attribute naming your message.',\n 'Priority `medium` (default) wakes an idle session and waits for a busy one to finish its step; use `urgent` only to make it stop and change course.',\n '`delivered` is `woken` when the session was idle and is now running, `mid-run` when it was already busy and will read the message when its run next checks in.',\n ...(scope.interactive\n ? []\n : ['On this turn you can only message your side sessions and sessions working on items this session follows.']),\n ].join(' '),\n inputSchema: z\n .object({\n sessionId: z.string().trim().min(1).max(200).describe('The session to message.'),\n message: message.describe('What to say. It arrives as-is, so make it self-contained.'),\n priority: z.enum(['low', 'medium', 'high', 'urgent']).default('medium'),\n })\n .strict(),\n execute: async ({ sessionId, message: text, priority }) => {\n if (sessionId === scope.sessionId) throw new Error(\"You can't message your own session.\");\n const row = await deps.sessions.getBySessionId(sessionId);\n const blocked = unreachable(row);\n if (blocked === 'not-found' || !row) throw new Error(`No session ${sessionId} was found in this Factory.`);\n if (blocked === 'private') throw new Error(`Session ${sessionId} is private to its owner.`);\n if (!scope.interactive && !(await followedWorkers()).has(sessionId)) {\n throw new Error(\n `On this turn you can only message this session's side sessions and sessions working on items it follows; ${sessionId} isn't one.`,\n );\n }\n\n const messaging = await requireMessaging();\n const threadId = await resolveSessionThread({\n controller: messaging.controller,\n sessions: deps.sessions,\n workItems: deps.workItems,\n sessionId,\n });\n if (!threadId) throw new Error('The session is not available (thread-not-found).');\n\n return accept(\n messaging,\n { sessionId, threadId },\n {\n kind: 'message',\n priority,\n summary: text,\n payload: { message: text },\n sourceId: scope.sessionId,\n attributes: {\n ...(await workItemAttribute(sessionId, row.orgId, scope.factoryProjectId)),\n ...senderAttributes(scope),\n },\n },\n );\n },\n });\n\n const reply = createTool({\n id: 'factory_message_origin',\n description: [\n 'Answer a message another Factory session sent you, or report on your work.',\n 'With `inReplyTo` (the id of a `factory-session` notification of kind `message`) the answer goes back to the session and thread that sent it; each message can be answered once.',\n 'Without it, the report goes to whoever follows your work: the session that started you, or everyone following your work item.',\n \"Set `status`: `progress` for an update, `blocked` when you need an answer to go on, `done` when finished, `failed` when you can't finish. Send one `done` or `failed` when you finish.\",\n ].join(' '),\n inputSchema: z\n .object({\n message: message.describe('Your answer.'),\n inReplyTo: z\n .string()\n .trim()\n .min(1)\n .max(200)\n .optional()\n .describe('Id of the message notification you are answering.'),\n status: z.enum(['progress', 'blocked', 'done', 'failed']).optional(),\n })\n .strict(),\n execute: async ({ message: text, inReplyTo, status }) => {\n if (!inReplyTo) return report(text, status);\n const messaging = await requireMessaging();\n // Only a message that reached this session's own thread can be answered,\n // and the answer goes where that message came from: never to an address\n // the model supplies.\n const original: NotificationRecord | null = await messaging.notifications.getNotification({\n threadId: scope.threadId,\n id: inReplyTo,\n });\n if (!original || original.source !== FACTORY_SESSION_NOTIFICATION_SOURCE) {\n throw new Error(`No message ${inReplyTo} was sent to this session.`);\n }\n if (original.kind !== 'message') {\n throw new Error(`Only messages can be answered; ${inReplyTo} is a ${original.kind}.`);\n }\n const fromSession = original.attributes?.['from-session'];\n const fromThread = original.attributes?.['from-thread'];\n if (typeof fromSession !== 'string' || typeof fromThread !== 'string' || original.sourceId !== fromSession) {\n throw new Error(`Message ${inReplyTo} doesn't say which session sent it.`);\n }\n // Notification records can be written outside these tools, so the\n // sender they name gets the same checks a message to it would.\n const blocked = unreachable(await deps.sessions.getBySessionId(fromSession));\n if (blocked === 'not-found') throw new Error(`Message ${inReplyTo} didn't come from a session in this Factory.`);\n if (blocked === 'private') {\n throw new Error(`Message ${inReplyTo} came from a private session this session can't answer.`);\n }\n const onSenderThread = await recent(messaging.notifications, fromThread);\n // Replies count toward the same cap as messages, so records written to\n // this session can't turn it into an unlimited high-priority sender.\n const answered = onSenderThread.some(\n record =>\n record.kind === 'reply' &&\n record.attributes?.['in-reply-to'] === inReplyTo &&\n record.attributes?.['from-session'] === scope.sessionId,\n );\n if (answered) throw new Error(`You already answered ${inReplyTo}.`);\n\n return accept(\n messaging,\n { sessionId: fromSession, threadId: fromThread },\n {\n kind: 'reply',\n priority: 'high',\n summary: text,\n payload: { message: text },\n sourceId: scope.sessionId,\n attributes: {\n ...senderAttributes(scope),\n 'in-reply-to': inReplyTo,\n ...(status ? { status } : {}),\n },\n },\n );\n },\n });\n\n /** A report with no message to answer: to the origin, else to the item's followers. */\n async function report(text: string, status: 'progress' | 'blocked' | 'done' | 'failed' | undefined) {\n const sender = { sessionId: scope.sessionId, threadId: scope.threadId, userId: scope.userId };\n let recipients: Array<{ sessionId: string; threadId: string }>;\n let attributes: Record<string, string> = {};\n if (scope.origin) {\n // The origin can mute this side session; the session keeps working, its reports just stop.\n // Blocked reports still go through, since the session cannot go on until the origin answers.\n const row = await deps.sessions.getBySessionId(scope.sessionId);\n if (row?.originMutedAt && status !== 'blocked') {\n return { delivered: 0, recipients: [], muted: true, note: 'Your origin muted your reports; keep working.' };\n }\n recipients = [scope.origin];\n } else {\n const binding = await deps.workItems.findActiveRunBindingForSession({\n orgId: scope.orgId,\n factoryProjectId: scope.factoryProjectId,\n sessionId: scope.sessionId,\n });\n if (!binding) throw new Error('Nothing started this session; pass inReplyTo to answer a message.');\n recipients = await workItemReportRecipients(deps.workItems, {\n orgId: scope.orgId,\n workItemId: binding.workItemId,\n senderSessionId: scope.sessionId,\n });\n ({ attributes } = await workItemReportAttributes(deps.workItems, {\n orgId: scope.orgId,\n factoryProjectId: scope.factoryProjectId,\n workItemId: binding.workItemId,\n role: binding.role,\n }));\n }\n if (recipients.length === 0) return { delivered: 0, recipients: [] };\n\n const messaging = await requireMessaging();\n const notification = reportNotification({ sender, status, message: text, attributes });\n const results: Array<{\n sessionId: string;\n delivered: FactoryDeliveryResult['delivered'] | 'queued';\n reason?: string;\n deliverAt?: string;\n }> = [];\n for (const recipient of recipients) {\n // Progress replaces itself while unread; anything else can wake a follower, so it counts.\n if (status !== 'progress' && overRateLimit(await recent(messaging.notifications, recipient.threadId))) {\n const counted = countedInWindow(await recent(messaging.notifications, recipient.threadId));\n const key = queueKey(deps, scope.sessionId, recipient.threadId);\n const waiting = pendingQueues.get(key)?.length ?? 0;\n const at = nextDeliveryAt(counted, waiting);\n enqueue(key, {\n notification,\n acceptedAt: Date.now(),\n actor: actor(),\n deliverAt: at,\n target: recipient,\n });\n results.push({\n sessionId: recipient.sessionId,\n delivered: 'queued',\n deliverAt: new Date(at).toISOString(),\n });\n continue;\n }\n const result = await deliverFactorySessionNotification({\n controller: messaging.controller,\n sessions: deps.sessions,\n runs: deps.workItems,\n target: recipient,\n notification,\n });\n results.push({ sessionId: recipient.sessionId, delivered: result.delivered });\n if (result.delivered === 'skipped') continue;\n await audit({\n targetSessionId: recipient.sessionId,\n priority: notification.priority ?? 'high',\n kind: notification.kind,\n delivery: result.delivered,\n });\n }\n const delivered = results.filter(result => result.delivered !== 'skipped' && result.delivered !== 'queued').length;\n const queued = results.filter(result => result.delivered === 'queued').length;\n return {\n delivered,\n recipients: results,\n ...(queued > 0\n ? {\n queued,\n note: 'Queued past the delivery cap. It will be delivered when the window allows. Do not send it again.',\n }\n : {}),\n };\n }\n\n const listSide = createTool({\n id: 'factory_list_side_sessions',\n description: [\n 'List the side sessions this session started with factory_start_session: state (running, parked waiting on an answer, idle), last report, whether you muted it, its model, and the work item it works on.',\n 'Use the session ids with factory_signal_session and factory_switch_session_model. On a turn a person started, also with factory_answer_approval, factory_unsubscribe_session and factory_subscribe_session.',\n ].join(' '),\n inputSchema: z\n .object({\n state: z.enum(['running', 'parked', 'idle']).optional().describe('Only sessions in this state.'),\n muted: z.boolean().optional().describe('true for only muted sessions, false for only unmuted ones.'),\n })\n .strict(),\n execute: async ({ state, muted }) => {\n const messaging = await deps.messaging();\n const sessions = await listSideSessions(\n {\n sessions: deps.sessions,\n workItems: deps.workItems,\n notifications: messaging?.notifications ?? null,\n isRunning: async sessionId => (await messaging?.controller.getSession(sessionId))?.stream.isActive() ?? false,\n model: messaging\n ? sessionId => sessionModel(messaging.controller, deps.sessions, deps.workItems, sessionId)\n : undefined,\n },\n scope,\n );\n return {\n sessions: sessions.filter(\n row => (!state || row.state === state) && (muted === undefined || (row.mutedAt !== null) === muted),\n ),\n };\n },\n });\n\n /** A side session this session started, or an error naming why it isn't one. */\n const ownSideSession = async (sessionId: string) => {\n const row = await deps.sessions.getBySessionId(sessionId);\n if (\n !row ||\n row.orgId !== scope.orgId ||\n row.factoryProjectId !== scope.factoryProjectId ||\n row.originSessionId !== scope.sessionId\n ) {\n throw new Error(`Session ${sessionId} is not a side session you started; see factory_list_side_sessions.`);\n }\n return row;\n };\n const sideSessionId = z\n .string()\n .trim()\n .min(1)\n .max(200)\n .describe('The side session, from factory_list_side_sessions.');\n\n const unsubscribe = createTool({\n id: 'factory_unsubscribe_session',\n description:\n \"Mute a side session you started: its reports and run-end notices stop reaching you, but it keeps working. Approval requests and blocked reports still arrive, since the session can't go on without an answer. Undo with factory_subscribe_session. Only on a turn a person started.\",\n inputSchema: z.object({ sessionId: sideSessionId }).strict(),\n execute: async ({ sessionId }) => {\n requirePerson(scope, 'mute a side session');\n const row = await ownSideSession(sessionId);\n if (row.originMutedAt) return { sessionId, muted: true, mutedAt: row.originMutedAt.toISOString() };\n await deps.sessions.setOriginMuted({ sessionId, muted: true });\n const updated = await deps.sessions.getBySessionId(sessionId);\n return { sessionId, muted: true, mutedAt: updated?.originMutedAt?.toISOString() ?? null };\n },\n });\n\n const subscribe = createTool({\n id: 'factory_subscribe_session',\n description:\n 'Unmute a side session you muted with factory_unsubscribe_session, so its reports reach you again. Reports it sent while muted are not replayed. Only on a turn a person started.',\n inputSchema: z.object({ sessionId: sideSessionId }).strict(),\n execute: async ({ sessionId }) => {\n requirePerson(scope, 'unmute a side session');\n const row = await ownSideSession(sessionId);\n if (row.originMutedAt) await deps.sessions.setOriginMuted({ sessionId, muted: false });\n return { sessionId, muted: false };\n },\n });\n\n if (scope.kind === 'worker') return { factory_message_origin: reply };\n return {\n factory_signal_session: signal,\n factory_message_origin: reply,\n factory_list_side_sessions: listSide,\n factory_unsubscribe_session: unsubscribe,\n factory_subscrib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,KAAK;GAAK;EAC1F;CACF,CAAC;CAED,MAAM,YAAY,WAAW;EAC3B,IAAI;EACJ,aACE;EACF,aAAa,EAAE,OAAO,EAAE,WAAW,cAAc,CAAC,CAAC,CAAC,OAAO;EAC3D,SAAS,OAAO,EAAE,gBAAgB;GAChC,cAAc,OAAO,uBAAuB;GAE5C,KAAI,MADc,eAAe,SAAS,EAAA,CAClC,eAAe,MAAM,KAAK,SAAS,eAAe;IAAE;IAAW,OAAO;GAAM,CAAC;GACrF,OAAO;IAAE;IAAW,OAAO;GAAM;EACnC;CACF,CAAC;CAED,IAAI,MAAM,SAAS,UAAU,OAAO,EAAE,wBAAwB,MAAM;CACpE,OAAO;EACL,wBAAwB;EACxB,wBAAwB;EACxB,4BAA4B;EAC5B,6BAA6B;EAC7B,2BAA2B;CAC7B;AACF"}
|
|
1
|
+
{"version":3,"file":"messaging-tools.js","names":[],"sources":["../../src/tools/messaging-tools.ts"],"sourcesContent":["/**\n * Messages between Factory sessions. A user session can message any session in\n * its Factory it can see; the receiver answers that exact message. Both\n * directions are `factory-session` notifications on the receiver's stored thread.\n */\n\nimport type {\n NotificationPriority,\n NotificationRecord,\n NotificationsStorage,\n SendNotificationSignalInput,\n} from '@mastra/core/notifications';\nimport { createTool } from '@mastra/core/tools';\nimport { z } from 'zod';\n\nimport type { IntegrationTools } from '../integrations/base.js';\nimport type { SourceControlSessionLookup } from '../session/factory-session.js';\nimport type { LiveSessions } from '../session/live-sessions.js';\nimport type { AuditRecorder } from '../storage/domains/audit/domain.js';\nimport type { SourceControlSession } from '../storage/domains/source-control/base.js';\nimport type { WorkItemsStorage } from '../storage/domains/work-items/base.js';\nimport {\n FACTORY_SESSION_NOTIFICATION_SOURCE,\n deliverFactorySessionNotification,\n resolveSessionThread,\n} from './deliver.js';\nimport type { FactoryDeliveryController, FactoryDeliveryResult } from './deliver.js';\nimport { workItemNumber } from './read-tools.js';\nimport { reportNotification, workItemReportAttributes, workItemReportRecipients } from './reports.js';\nimport { requirePerson } from './scope.js';\nimport type { FactoryToolScope } from './scope.js';\nimport { listSideSessions, sessionModel } from './side-sessions.js';\n\n/** Messages plus replies, per sender session, per target thread, per window. */\nexport const SIGNAL_RATE_LIMIT = 10;\nexport const SIGNAL_RATE_WINDOW_MS = 10 * 60 * 1000;\n/** How many recent `factory-session` notifications on a thread the rate and duplicate checks read. */\nconst RECENT_SCAN = 100;\n/** How often a waiting queue is reconsidered. Delivery still waits for a free slot in the window. */\nconst QUEUE_FLUSH_MS = 1000;\n\n/** A message accepted past the delivery cap, held until the window has a free slot. */\ninterface PendingMessage {\n notification: Omit<SendNotificationSignalInput, 'source'>;\n /** When the sender handed it over. Oldest goes first. */\n acceptedAt: number;\n actor: { actorId: string; actorType: 'human' | 'agent' };\n}\n\ninterface QueuedDelivery extends PendingMessage {\n /** The moment a slot in the window is expected to free. Set once, when it joins the queue. */\n deliverAt: number;\n target: { sessionId: string; threadId: string };\n}\n\n/**\n * Waiting messages, per sender session and target thread, oldest first.\n * Process-local: a restart drops what was still waiting, the same as a message\n * that had not been handed to the tool yet. Delivered messages live in the\n * notification store and are unaffected.\n */\nconst pendingQueues = new Map<string, QueuedDelivery[]>();\nconst flushTimers = new Map<string, ReturnType<typeof setTimeout>>();\n\nconst queueOwners = new WeakMap<object, number>();\nlet nextQueueOwnerId = 0;\n\nconst queueKey = (owner: object, senderSessionId: string, threadId: string): string => {\n let id = queueOwners.get(owner);\n if (id === undefined) {\n nextQueueOwnerId += 1;\n id = nextQueueOwnerId;\n queueOwners.set(owner, id);\n }\n return `${id}\\0${senderSessionId}\\0${threadId}`;\n};\nexport interface FactoryMessaging {\n controller: FactoryDeliveryController;\n notifications: Pick<NotificationsStorage, 'listNotifications' | 'getNotification'>;\n}\n\nexport interface FactoryMessagingToolDependencies {\n sessions: Pick<SourceControlSessionLookup, 'getBySessionId' | 'listByOrigin' | 'setOriginMuted'>;\n workItems: Pick<\n WorkItemsStorage,\n | 'findActiveRunBindingForSession'\n | 'getForProject'\n | 'hasRunBindingForSession'\n | 'listSessionSubscriptions'\n | 'listRunBindings'\n | 'listWorkItemSubscribers'\n >;\n auditRecorder: AuditRecorder;\n /** The live controller and notifications store; resolved per call because they exist only once the mount is up. */\n messaging: () => Promise<FactoryMessaging | null>;\n /** Which live sessions are parked on a tool prompt; absent before the mount is up. */\n liveSessions?: () => Pick<LiveSessions, 'parked' | 'parkedIn'> | undefined;\n}\n\nconst message = z.string().trim().min(1).max(4000);\n\nfunction senderAttributes(scope: FactoryToolScope) {\n return {\n 'from-session': scope.sessionId,\n 'from-thread': scope.threadId,\n 'from-user': scope.userId,\n };\n}\n\nfunction unavailable(result: Extract<FactoryDeliveryResult, { delivered: 'skipped' }>) {\n return new Error(`The session is not available (${result.reason}).`);\n}\n\nexport function createFactoryMessagingTools(\n scope: FactoryToolScope,\n deps: FactoryMessagingToolDependencies,\n): IntegrationTools {\n const requireMessaging = async () => {\n const messaging = await deps.messaging();\n if (!messaging) throw new Error('Session messaging is not available on this server.');\n return messaging;\n };\n // Only a user-session turn the person started is the person's act. Workers\n // (even when someone types into one) and turns nobody signed in started\n // (wakes, webhooks) act as the thread's agent.\n const human = scope.kind === 'user' && scope.interactive;\n const audit = (input: { targetSessionId: string; priority: NotificationPriority; kind: string; delivery: string }) =>\n deps.auditRecorder.record({\n orgId: scope.orgId,\n actorId: human ? scope.userId : `agent:${scope.threadId}`,\n actorType: human ? 'human' : 'agent',\n action: 'factory.agent.signaled',\n factoryProjectId: scope.factoryProjectId,\n targets: [{ type: 'session', id: input.targetSessionId }],\n metadata: {\n targetSessionId: input.targetSessionId,\n priority: input.priority,\n kind: input.kind,\n delivery: input.delivery,\n },\n });\n /** Why this session can't reach `row`, or null when it can: the rule for message targets and reply targets alike. */\n const unreachable = (row: SourceControlSession | null): 'not-found' | 'private' | null => {\n if (!row || row.orgId !== scope.orgId || row.factoryProjectId !== scope.factoryProjectId) return 'not-found';\n if (row.visibility === 'private' && row.userId !== scope.userId) return 'private';\n return null;\n };\n const overRateLimit = (records: NotificationRecord[]) => countedInWindow(records).length >= SIGNAL_RATE_LIMIT;\n /** This session's delivered messages on the thread that still sit inside the window, oldest first. */\n const countedInWindow = (records: NotificationRecord[]): NotificationRecord[] => {\n const since = Date.now() - SIGNAL_RATE_WINDOW_MS;\n return records\n .filter(\n record =>\n // Everything this session sends counts except coalescing progress updates.\n record.kind !== 'progress' &&\n record.kind !== 'stage' &&\n record.attributes?.['from-session'] === scope.sessionId &&\n record.createdAt.getTime() >= since,\n )\n .sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());\n };\n /**\n * When the next message can be delivered: one window after the oldest message\n * that has to age out to free a slot, given how many are already waiting.\n */\n const nextDeliveryAt = (counted: NotificationRecord[], waiting: number): number => {\n const blocking = counted[counted.length + waiting - SIGNAL_RATE_LIMIT];\n return (blocking ? blocking.createdAt.getTime() : Date.now()) + SIGNAL_RATE_WINDOW_MS;\n };\n const queuedResult = (deliverAt: number) => ({\n delivered: 'queued' as const,\n deliverAt: new Date(deliverAt).toISOString(),\n note: `Queued; it will be delivered at about ${new Date(deliverAt).toISOString()}. Do not send it again.`,\n });\n const recent = (notifications: FactoryMessaging['notifications'], threadId: string) =>\n notifications.listNotifications({ threadId, source: FACTORY_SESSION_NOTIFICATION_SOURCE, limit: RECENT_SCAN });\n\n const actor = (): QueuedDelivery['actor'] => ({\n actorId: human ? scope.userId : `agent:${scope.threadId}`,\n actorType: human ? 'human' : 'agent',\n });\n\n /**\n * Deliver now, or hold until the window has a slot. The cap limits how fast\n * messages are delivered, not whether they are accepted.\n */\n const accept = async (\n messaging: FactoryMessaging,\n target: { sessionId: string; threadId: string },\n notification: Omit<SendNotificationSignalInput, 'source'>,\n ): Promise<\n { notificationId: string; delivered: FactoryDeliveryResult['delivered'] } | ReturnType<typeof queuedResult>\n > => {\n const counted = countedInWindow(await recent(messaging.notifications, target.threadId));\n if (counted.length < SIGNAL_RATE_LIMIT) {\n const result = await deliverFactorySessionNotification({\n controller: messaging.controller,\n sessions: deps.sessions,\n runs: deps.workItems,\n target,\n notification,\n });\n if (result.delivered === 'skipped') throw unavailable(result);\n await audit({\n targetSessionId: target.sessionId,\n priority: notification.priority ?? 'medium',\n kind: notification.kind,\n delivery: result.delivered,\n });\n return { notificationId: result.notificationId, delivered: result.delivered };\n }\n const key = queueKey(deps, scope.sessionId, target.threadId);\n const waiting = pendingQueues.get(key)?.length ?? 0;\n const deliverAt = nextDeliveryAt(counted, waiting);\n enqueue(key, {\n notification,\n acceptedAt: Date.now(),\n actor: actor(),\n deliverAt,\n target,\n });\n return queuedResult(deliverAt);\n };\n\n const enqueue = (key: string, delivery: QueuedDelivery): void => {\n const queue = pendingQueues.get(key) ?? [];\n queue.push(delivery);\n queue.sort((a, b) => a.acceptedAt - b.acceptedAt);\n pendingQueues.set(key, queue);\n scheduleFlush(key);\n };\n\n /**\n * Deliver the oldest waiting message once the window has a free slot, then\n * the next, in the order they were accepted. A target that is gone by then\n * is dropped and recorded, the same way an undeliverable live message is.\n */\n const flush = async (key: string): Promise<void> => {\n flushTimers.delete(key);\n const queue = pendingQueues.get(key);\n if (!queue || queue.length === 0) {\n pendingQueues.delete(key);\n return;\n }\n const messaging = await deps.messaging();\n if (!messaging) {\n scheduleFlush(key);\n return;\n }\n const head = queue[0];\n if (!head || head.deliverAt > Date.now()) {\n scheduleFlush(key);\n return;\n }\n const counted = countedInWindow(await recent(messaging.notifications, head.target.threadId));\n if (counted.length >= SIGNAL_RATE_LIMIT) {\n scheduleFlush(key);\n return;\n }\n queue.shift();\n if (queue.length === 0) pendingQueues.delete(key);\n const result = await deliverFactorySessionNotification({\n controller: messaging.controller,\n sessions: deps.sessions,\n runs: deps.workItems,\n target: head.target,\n notification: head.notification,\n });\n await deps.auditRecorder.record({\n orgId: scope.orgId,\n actorId: head.actor.actorId,\n actorType: head.actor.actorType,\n action: 'factory.agent.signaled',\n factoryProjectId: scope.factoryProjectId,\n targets: [{ type: 'session', id: head.target.sessionId }],\n metadata: {\n targetSessionId: head.target.sessionId,\n priority: head.notification.priority ?? 'medium',\n kind: head.notification.kind,\n delivery: result.delivered === 'skipped' ? 'dropped' : result.delivered,\n ...(result.delivered === 'skipped' ? { reason: result.reason } : {}),\n },\n });\n if (queue.length > 0) scheduleFlush(key);\n };\n\n function scheduleFlush(key: string): void {\n if (flushTimers.has(key)) return;\n if (!pendingQueues.get(key)?.[0]) return;\n const timer = setTimeout(() => {\n flushTimers.delete(key);\n void flush(key).catch(() => {\n // A failed flush leaves the rest of the queue waiting; the next tick retries the head.\n if ((pendingQueues.get(key)?.length ?? 0) > 0) scheduleFlush(key);\n });\n }, QUEUE_FLUSH_MS);\n // Keep the wait on the real clock. A fake clock that jumps the window would\n // skip a timer scheduled for the old deadline, and the message would sit.\n timer.unref?.();\n flushTimers.set(key, timer);\n }\n\n /** On turns nobody signed in started, only sessions working on items this session follows. */\n const followedWorkers = async () => {\n const project = { orgId: scope.orgId, factoryProjectId: scope.factoryProjectId };\n const follows = await deps.workItems.listSessionSubscriptions({ ...project, sessionId: scope.sessionId });\n const bindings = await Promise.all(\n follows.map(follow => deps.workItems.listRunBindings(scope.orgId, scope.factoryProjectId, follow.workItemId)),\n );\n const sideSessions = await deps.sessions.listByOrigin({ orgId: scope.orgId, originSessionId: scope.sessionId });\n return new Set([\n ...bindings\n .flat()\n .filter(binding => binding.status === 'active')\n .map(binding => binding.sessionId),\n ...sideSessions.map(session => session.sessionId),\n ]);\n };\n\n const workItemAttribute = async (sessionId: string, orgId: string, factoryProjectId: string) => {\n const binding = await deps.workItems.findActiveRunBindingForSession({ orgId, factoryProjectId, sessionId });\n if (!binding) return {};\n const item = await deps.workItems.getForProject(orgId, factoryProjectId, binding.workItemId);\n if (!item) return {};\n const number = workItemNumber(item);\n return { 'work-item': number === null ? item.id : `#${number}` };\n };\n\n const signal = createTool({\n id: 'factory_signal_session',\n description: [\n 'Send a message to another session in this Factory: a work item role session, or a teammate session you can see.',\n 'Replies come back to this session as `factory-session` notifications with kind `reply` and an `in-reply-to` attribute naming your message.',\n 'Priority `medium` (default) wakes an idle session and waits for a busy one to finish its step; use `urgent` only to make it stop and change course.',\n '`delivered` is `woken` when the session was idle and is now running, `mid-run` when it was already busy and will read the message when its run next checks in.',\n ...(scope.interactive\n ? []\n : ['On this turn you can only message your side sessions and sessions working on items this session follows.']),\n ].join(' '),\n inputSchema: z\n .object({\n sessionId: z.string().trim().min(1).max(200).describe('The session to message.'),\n message: message.describe('What to say. It arrives as-is, so make it self-contained.'),\n priority: z.enum(['low', 'medium', 'high', 'urgent']).default('medium'),\n })\n .strict(),\n execute: async ({ sessionId, message: text, priority }) => {\n if (sessionId === scope.sessionId) throw new Error(\"You can't message your own session.\");\n const row = await deps.sessions.getBySessionId(sessionId);\n const blocked = unreachable(row);\n if (blocked === 'not-found' || !row) throw new Error(`No session ${sessionId} was found in this Factory.`);\n if (blocked === 'private') throw new Error(`Session ${sessionId} is private to its owner.`);\n if (!scope.interactive && !(await followedWorkers()).has(sessionId)) {\n throw new Error(\n `On this turn you can only message this session's side sessions and sessions working on items it follows; ${sessionId} isn't one.`,\n );\n }\n\n const messaging = await requireMessaging();\n const threadId = await resolveSessionThread({\n controller: messaging.controller,\n sessions: deps.sessions,\n workItems: deps.workItems,\n sessionId,\n });\n if (!threadId) throw new Error('The session is not available (thread-not-found).');\n\n return accept(\n messaging,\n { sessionId, threadId },\n {\n kind: 'message',\n priority,\n summary: text,\n payload: { message: text },\n sourceId: scope.sessionId,\n attributes: {\n ...(await workItemAttribute(sessionId, row.orgId, scope.factoryProjectId)),\n ...senderAttributes(scope),\n },\n },\n );\n },\n });\n\n const reply = createTool({\n id: 'factory_message_origin',\n description: [\n 'Answer a message another Factory session sent you, or report on your work.',\n 'With `inReplyTo` (the id of a `factory-session` notification of kind `message`) the answer goes back to the session and thread that sent it; each message can be answered once.',\n 'Without it, the report goes to whoever follows your work: the session that started you, or everyone following your work item.',\n \"Set `status`: `progress` for an update, `blocked` when you need an answer to go on, `done` when finished, `failed` when you can't finish. Send one `done` or `failed` when you finish.\",\n ].join(' '),\n inputSchema: z\n .object({\n message: message.describe('Your answer.'),\n inReplyTo: z\n .string()\n .trim()\n .min(1)\n .max(200)\n .optional()\n .describe('Id of the message notification you are answering.'),\n status: z.enum(['progress', 'blocked', 'done', 'failed']).optional(),\n })\n .strict(),\n execute: async ({ message: text, inReplyTo, status }) => {\n if (!inReplyTo) return report(text, status);\n const messaging = await requireMessaging();\n // Only a message that reached this session's own thread can be answered,\n // and the answer goes where that message came from: never to an address\n // the model supplies.\n const original: NotificationRecord | null = await messaging.notifications.getNotification({\n threadId: scope.threadId,\n id: inReplyTo,\n });\n if (!original || original.source !== FACTORY_SESSION_NOTIFICATION_SOURCE) {\n throw new Error(`No message ${inReplyTo} was sent to this session.`);\n }\n if (original.kind !== 'message') {\n throw new Error(`Only messages can be answered; ${inReplyTo} is a ${original.kind}.`);\n }\n const fromSession = original.attributes?.['from-session'];\n const fromThread = original.attributes?.['from-thread'];\n if (typeof fromSession !== 'string' || typeof fromThread !== 'string' || original.sourceId !== fromSession) {\n throw new Error(`Message ${inReplyTo} doesn't say which session sent it.`);\n }\n // Notification records can be written outside these tools, so the\n // sender they name gets the same checks a message to it would.\n const blocked = unreachable(await deps.sessions.getBySessionId(fromSession));\n if (blocked === 'not-found') throw new Error(`Message ${inReplyTo} didn't come from a session in this Factory.`);\n if (blocked === 'private') {\n throw new Error(`Message ${inReplyTo} came from a private session this session can't answer.`);\n }\n const onSenderThread = await recent(messaging.notifications, fromThread);\n // Replies count toward the same cap as messages, so records written to\n // this session can't turn it into an unlimited high-priority sender.\n const answered = onSenderThread.some(\n record =>\n record.kind === 'reply' &&\n record.attributes?.['in-reply-to'] === inReplyTo &&\n record.attributes?.['from-session'] === scope.sessionId,\n );\n if (answered) throw new Error(`You already answered ${inReplyTo}.`);\n\n return accept(\n messaging,\n { sessionId: fromSession, threadId: fromThread },\n {\n kind: 'reply',\n priority: 'high',\n summary: text,\n payload: { message: text },\n sourceId: scope.sessionId,\n attributes: {\n ...senderAttributes(scope),\n 'in-reply-to': inReplyTo,\n ...(status ? { status } : {}),\n },\n },\n );\n },\n });\n\n /** A report with no message to answer: to the origin, else to the item's followers. */\n async function report(text: string, status: 'progress' | 'blocked' | 'done' | 'failed' | undefined) {\n const sender = { sessionId: scope.sessionId, threadId: scope.threadId, userId: scope.userId };\n let recipients: Array<{ sessionId: string; threadId: string }>;\n let attributes: Record<string, string> = {};\n if (scope.origin) {\n // The origin can mute this side session; the session keeps working, its reports just stop.\n // Blocked reports still go through, since the session cannot go on until the origin answers.\n const row = await deps.sessions.getBySessionId(scope.sessionId);\n if (row?.originMutedAt && status !== 'blocked') {\n return { delivered: 0, recipients: [], muted: true, note: 'Your origin muted your reports; keep working.' };\n }\n recipients = [scope.origin];\n } else {\n const binding = await deps.workItems.findActiveRunBindingForSession({\n orgId: scope.orgId,\n factoryProjectId: scope.factoryProjectId,\n sessionId: scope.sessionId,\n });\n if (!binding) throw new Error('Nothing started this session; pass inReplyTo to answer a message.');\n recipients = await workItemReportRecipients(deps.workItems, {\n orgId: scope.orgId,\n workItemId: binding.workItemId,\n senderSessionId: scope.sessionId,\n });\n ({ attributes } = await workItemReportAttributes(deps.workItems, {\n orgId: scope.orgId,\n factoryProjectId: scope.factoryProjectId,\n workItemId: binding.workItemId,\n role: binding.role,\n }));\n }\n if (recipients.length === 0) return { delivered: 0, recipients: [] };\n\n const messaging = await requireMessaging();\n const notification = reportNotification({ sender, status, message: text, attributes });\n const results: Array<{\n sessionId: string;\n delivered: FactoryDeliveryResult['delivered'] | 'queued';\n reason?: string;\n deliverAt?: string;\n }> = [];\n for (const recipient of recipients) {\n // Progress replaces itself while unread; anything else can wake a follower, so it counts.\n if (status !== 'progress' && overRateLimit(await recent(messaging.notifications, recipient.threadId))) {\n const counted = countedInWindow(await recent(messaging.notifications, recipient.threadId));\n const key = queueKey(deps, scope.sessionId, recipient.threadId);\n const waiting = pendingQueues.get(key)?.length ?? 0;\n const at = nextDeliveryAt(counted, waiting);\n enqueue(key, {\n notification,\n acceptedAt: Date.now(),\n actor: actor(),\n deliverAt: at,\n target: recipient,\n });\n results.push({\n sessionId: recipient.sessionId,\n delivered: 'queued',\n deliverAt: new Date(at).toISOString(),\n });\n continue;\n }\n const result = await deliverFactorySessionNotification({\n controller: messaging.controller,\n sessions: deps.sessions,\n runs: deps.workItems,\n target: recipient,\n notification,\n });\n results.push({ sessionId: recipient.sessionId, delivered: result.delivered });\n if (result.delivered === 'skipped') continue;\n await audit({\n targetSessionId: recipient.sessionId,\n priority: notification.priority ?? 'high',\n kind: notification.kind,\n delivery: result.delivered,\n });\n }\n const delivered = results.filter(result => result.delivered !== 'skipped' && result.delivered !== 'queued').length;\n const queued = results.filter(result => result.delivered === 'queued').length;\n return {\n delivered,\n recipients: results,\n ...(queued > 0\n ? {\n queued,\n note: 'Queued past the delivery cap. It will be delivered when the window allows. Do not send it again.',\n }\n : {}),\n };\n }\n\n const listSide = createTool({\n id: 'factory_list_side_sessions',\n description: [\n 'List the side sessions this session started with factory_start_session: state (running, parked waiting on an answer, idle), last report, whether you muted it, its model, and the work item it works on.',\n 'Use the session ids with factory_signal_session and factory_switch_session_model. On a turn a person started, also with factory_answer_approval, factory_unsubscribe_session and factory_subscribe_session.',\n ].join(' '),\n inputSchema: z\n .object({\n state: z.enum(['running', 'parked', 'idle']).optional().describe('Only sessions in this state.'),\n muted: z.boolean().optional().describe('true for only muted sessions, false for only unmuted ones.'),\n })\n .strict(),\n execute: async ({ state, muted }) => {\n const messaging = await deps.messaging();\n const sessions = await listSideSessions(\n {\n sessions: deps.sessions,\n workItems: deps.workItems,\n notifications: messaging?.notifications ?? null,\n isRunning: async sessionId => (await messaging?.controller.getSession(sessionId))?.stream.isActive() ?? false,\n isParked: sessionId => deps.liveSessions?.()?.parked(sessionId) !== undefined,\n model: messaging\n ? sessionId => sessionModel(messaging.controller, deps.sessions, deps.workItems, sessionId)\n : undefined,\n },\n scope,\n );\n return {\n sessions: sessions.filter(\n row => (!state || row.state === state) && (muted === undefined || (row.mutedAt !== null) === muted),\n ),\n };\n },\n });\n\n /** A side session this session started, or an error naming why it isn't one. */\n const ownSideSession = async (sessionId: string) => {\n const row = await deps.sessions.getBySessionId(sessionId);\n if (\n !row ||\n row.orgId !== scope.orgId ||\n row.factoryProjectId !== scope.factoryProjectId ||\n row.originSessionId !== scope.sessionId\n ) {\n throw new Error(`Session ${sessionId} is not a side session you started; see factory_list_side_sessions.`);\n }\n return row;\n };\n const sideSessionId = z\n .string()\n .trim()\n .min(1)\n .max(200)\n .describe('The side session, from factory_list_side_sessions.');\n\n const unsubscribe = createTool({\n id: 'factory_unsubscribe_session',\n description:\n \"Mute a side session you started: its reports and run-end notices stop reaching you, but it keeps working. Approval requests and blocked reports still arrive, since the session can't go on without an answer. Undo with factory_subscribe_session. Only on a turn a person started.\",\n inputSchema: z.object({ sessionId: sideSessionId }).strict(),\n execute: async ({ sessionId }) => {\n requirePerson(scope, 'mute a side session');\n const row = await ownSideSession(sessionId);\n if (row.originMutedAt) return { sessionId, muted: true, mutedAt: row.originMutedAt.toISOString() };\n await deps.sessions.setOriginMuted({ sessionId, muted: true });\n const updated = await deps.sessions.getBySessionId(sessionId);\n return { sessionId, muted: true, mutedAt: updated?.originMutedAt?.toISOString() ?? null };\n },\n });\n\n const subscribe = createTool({\n id: 'factory_subscribe_session',\n description:\n 'Unmute a side session you muted with factory_unsubscribe_session, so its reports reach you again. Reports it sent while muted are not replayed. Only on a turn a person started.',\n inputSchema: z.object({ sessionId: sideSessionId }).strict(),\n execute: async ({ sessionId }) => {\n requirePerson(scope, 'unmute a side session');\n const row = await ownSideSession(sessionId);\n if (row.originMutedAt) await deps.sessions.setOriginMuted({ sessionId, muted: false });\n return { sessionId, muted: false };\n },\n });\n\n if (scope.kind === 'worker') return { factory_message_origin: reply };\n return {\n factory_signal_session: signal,\n factory_message_origin: reply,\n factory_list_side_sessions: listSide,\n factory_unsubscribe_session: unsubscribe,\n factory_subscribe_session: subscribe,\n };\n}\n"],"m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K,SAAS,eAAe,SAAS,EAAA,EACT,eAAe,YAAY,KAAK;GAAK;EAC1F;CACF,CAAC;CAED,MAAM,YAAY,WAAW;EAC3B,IAAI;EACJ,aACE;EACF,aAAa,EAAE,OAAO,EAAE,WAAW,cAAc,CAAC,CAAC,CAAC,OAAO;EAC3D,SAAS,OAAO,EAAE,gBAAgB;GAChC,cAAc,OAAO,uBAAuB;GAE5C,KAAI,MADc,eAAe,SAAS,EAAA,CAClC,eAAe,MAAM,KAAK,SAAS,eAAe;IAAE;IAAW,OAAO;GAAM,CAAC;GACrF,OAAO;IAAE;IAAW,OAAO;GAAM;EACnC;CACF,CAAC;CAED,IAAI,MAAM,SAAS,UAAU,OAAO,EAAE,wBAAwB,MAAM;CACpE,OAAO;EACL,wBAAwB;EACxB,wBAAwB;EACxB,4BAA4B;EAC5B,6BAA6B;EAC7B,2BAA2B;CAC7B;AACF"}
|
|
@@ -2,8 +2,9 @@ import { z } from 'zod';
|
|
|
2
2
|
import type { BoardRegistry } from '../boards/index.js';
|
|
3
3
|
import type { ProjectBoardSource } from '../boards/project-boards.js';
|
|
4
4
|
import type { IntegrationTools } from '../integrations/base.js';
|
|
5
|
+
import type { SourceControlSessionLookup } from '../session/factory-session.js';
|
|
6
|
+
import type { LiveSessions } from '../session/live-sessions.js';
|
|
5
7
|
import type { AuditStorage } from '../storage/domains/audit/base.js';
|
|
6
|
-
import type { WorkItemCommentsStorage } from '../storage/domains/comments/base.js';
|
|
7
8
|
import type { Card, WorkItemsStorage } from '../storage/domains/work-items/base.js';
|
|
8
9
|
import type { FactoryMessaging } from './messaging-tools.js';
|
|
9
10
|
import type { FactoryToolScope } from './scope.js';
|
|
@@ -11,22 +12,25 @@ export declare const MAX_TEXT = 600;
|
|
|
11
12
|
export declare const MAX_ERROR = 400;
|
|
12
13
|
export declare const MAX_LIST = 50;
|
|
13
14
|
export interface FactoryReadToolDependencies {
|
|
14
|
-
workItems: Pick<WorkItemsStorage, '
|
|
15
|
-
comments: Pick<WorkItemCommentsStorage, 'listRecent'>;
|
|
15
|
+
workItems: Pick<WorkItemsStorage, 'listShared' | 'getForProject' | 'listRunBindings' | 'listDeferredDecisions' | 'listByIds' | 'listDecisionsForEvaluations' | 'listWorkItemSubscribers' | 'listSessionSubscriptions'>;
|
|
16
16
|
audit: Pick<AuditStorage, 'list'>;
|
|
17
17
|
/** A fixed registry, or the per-project boards. */
|
|
18
18
|
boards: BoardRegistry | ProjectBoardSource;
|
|
19
19
|
/** The live controller, for whether a session is mid-run and when it last moved; absent before the mount is up. */
|
|
20
20
|
messaging?: () => Promise<Pick<FactoryMessaging, 'controller'> | null>;
|
|
21
|
+
/** Finds the caller session's source-control provider, to tell which cards can't pick a repository. */
|
|
22
|
+
sessions?: Pick<SourceControlSessionLookup, 'getSourceControlBySessionId'>;
|
|
23
|
+
/** Which live sessions are parked on a tool prompt; absent before the mount is up. */
|
|
24
|
+
liveSessions?: () => Pick<LiveSessions, 'parked' | 'parkedIn'> | undefined;
|
|
21
25
|
}
|
|
22
26
|
export declare function truncate(text: string, max: number): string;
|
|
23
|
-
/** The number a person sees on the card: the issue or PR number the item was filed from. */
|
|
24
|
-
export declare function workItemNumber(item: Pick<Card, 'workItem'>): number | null;
|
|
27
|
+
/** The number a person sees on the card: the issue or PR number the item was filed from, or the project's own number for a card filed by hand. */
|
|
28
|
+
export declare function workItemNumber(item: Pick<Card, 'workItem' | 'metadata'>): number | null;
|
|
25
29
|
export declare function workItemStage(item: Pick<Card, 'stages'>): string;
|
|
26
30
|
/** A work item id or its card number; anything else can't name an item. */
|
|
27
31
|
export declare const workItemRefSchema: z.ZodString;
|
|
28
32
|
/** Resolve `<uuid>` or `#123` to an item in this Factory only. Pass a ref validated by `workItemRefSchema`. */
|
|
29
|
-
export declare function findWorkItem(workItems: Pick<WorkItemsStorage, '
|
|
33
|
+
export declare function findWorkItem(workItems: Pick<WorkItemsStorage, 'listShared' | 'getForProject'>, scope: Pick<FactoryToolScope, 'orgId' | 'factoryProjectId'>, ref: string): Promise<Card | null>;
|
|
30
34
|
export declare function workItemNotFound(ref: string): Error;
|
|
31
35
|
export declare function createFactoryReadTools(scope: FactoryToolScope, deps: FactoryReadToolDependencies): IntegrationTools;
|
|
32
36
|
//# sourceMappingURL=read-tools.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-tools.d.ts","sourceRoot":"","sources":["../../src/tools/read-tools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"read-tools.d.ts","sourceRoot":"","sources":["../../src/tools/read-tools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAMhE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,KAAK,EAGV,IAAI,EACJ,gBAAgB,EACjB,MAAM,uCAAuC,CAAC;AAI/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,eAAO,MAAM,QAAQ,MAAM,CAAC;AAC5B,eAAO,MAAM,SAAS,MAAM,CAAC;AAC7B,eAAO,MAAM,QAAQ,KAAK,CAAC;AAG3B,MAAM,WAAW,2BAA2B;IAC1C,SAAS,EAAE,IAAI,CACb,gBAAgB,EACd,YAAY,GACZ,eAAe,GACf,iBAAiB,GACjB,uBAAuB,GACvB,W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AE,gBAAgB,EAAE,IAAI,EAAE,2BAA2B,GAAG,gBAAgB,CA4PnH"}
|
package/dist/tools/read-tools.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import "../boards/index.js";
|
|
2
|
+
import { awaitsAcceptance, boardFlow, boardForWorkItem, isTerminalWorkItem, pullRequestSourceNumber, pullRequestSources } from "../boards/semantics.js";
|
|
2
3
|
import { toBoardSource } from "../boards/project-boards.js";
|
|
3
|
-
import { boardForWorkItem } from "../boards/semantics.js";
|
|
4
4
|
import { factorySessionUrl, factoryWorkItemUrl } from "../links.js";
|
|
5
|
+
import { parkedRunLabel } from "../routes/attention-parked.js";
|
|
5
6
|
import { decisionRetryable, overtakenDecisionIds } from "../rules/decision-applicability.js";
|
|
6
7
|
import { factoryDispatchFailureMetadata } from "../rules/dispatch-errors.js";
|
|
7
8
|
import { needsApproval } from "../rules/types.js";
|
|
9
|
+
import { resolveWorkItemRepository } from "../session/work-item-repository.js";
|
|
10
|
+
import "../work-items/create-work-item.js";
|
|
8
11
|
import { sessionActivity } from "./deliver.js";
|
|
9
|
-
import { z } from "zod";
|
|
10
12
|
import { createTool } from "@mastra/core/tools";
|
|
13
|
+
import { z } from "zod";
|
|
11
14
|
// src/tools/read-tools.ts
|
|
12
15
|
const MAX_TEXT = 600;
|
|
13
16
|
const MAX_ERROR = 400;
|
|
@@ -21,9 +24,9 @@ function iso(value) {
|
|
|
21
24
|
const date = value instanceof Date ? value : new Date(value);
|
|
22
25
|
return Number.isFinite(date.getTime()) ? date.toISOString() : null;
|
|
23
26
|
}
|
|
24
|
-
/** The number a person sees on the card: the issue or PR number the item was filed from. */
|
|
27
|
+
/** The number a person sees on the card: the issue or PR number the item was filed from, or the project's own number for a card filed by hand. */
|
|
25
28
|
function workItemNumber(item) {
|
|
26
|
-
const number = item.workItem.metadata?.number ?? item.workItem.metadata?.githubIssueNumber ?? item.workItem.metadata?.githubPullRequestNumber;
|
|
29
|
+
const number = item.workItem.metadata?.number ?? item.workItem.metadata?.githubIssueNumber ?? item.workItem.metadata?.githubPullRequestNumber ?? item.metadata?.["cardNumber"];
|
|
27
30
|
return typeof number === "number" ? number : null;
|
|
28
31
|
}
|
|
29
32
|
function workItemStage(item) {
|
|
@@ -36,8 +39,20 @@ async function findWorkItem(workItems, scope, ref) {
|
|
|
36
39
|
const trimmed = ref.trim();
|
|
37
40
|
const number = /^#?(\d+)$/.exec(trimmed)?.[1];
|
|
38
41
|
if (number === void 0) return workItems.getForProject(scope.orgId, scope.factoryProjectId, trimmed);
|
|
39
|
-
const
|
|
40
|
-
|
|
42
|
+
const items = await workItems.listShared(scope);
|
|
43
|
+
const matches = items.filter((item) => workItemNumber(item) === Number(number));
|
|
44
|
+
const workCards = matches.filter((item) => item.externalSource?.type !== "pull-request");
|
|
45
|
+
refuseAmbiguous(number, workCards);
|
|
46
|
+
const match = workCards[0] ?? matches[0];
|
|
47
|
+
if (match) return structuredClone(match);
|
|
48
|
+
const carriers = items.filter((item) => pullRequestSources(item).some((source) => pullRequestSourceNumber(source) === Number(number)));
|
|
49
|
+
refuseAmbiguous(number, carriers);
|
|
50
|
+
return carriers[0] ? structuredClone(carriers[0]) : null;
|
|
51
|
+
}
|
|
52
|
+
function refuseAmbiguous(number, items) {
|
|
53
|
+
if (items.length <= 1) return;
|
|
54
|
+
const candidates = items.map((item) => `${item.id} (${item.title})`).join(", ");
|
|
55
|
+
throw new Error(`#${number} matches more than one work item; use its id instead: ${candidates}.`);
|
|
41
56
|
}
|
|
42
57
|
function workItemNotFound(ref) {
|
|
43
58
|
return /* @__PURE__ */ new Error(`No work item ${ref} was found in this Factory.`);
|
|
@@ -88,20 +103,20 @@ function summarizeDecision(decision, overtaken = false) {
|
|
|
88
103
|
updatedAt: iso(decision.updatedAt)
|
|
89
104
|
};
|
|
90
105
|
}
|
|
91
|
-
const PAST_TRIAGE = /* @__PURE__ */ new Set([
|
|
92
|
-
"planning",
|
|
93
|
-
"execute",
|
|
94
|
-
"review"
|
|
95
|
-
]);
|
|
96
106
|
/**
|
|
97
|
-
* Held: a
|
|
98
|
-
*
|
|
99
|
-
*
|
|
107
|
+
* Held: a card triage left resting (or whose source asks for approval), until a person moves it
|
|
108
|
+
* on. A card that has been past triage since (parked by self-review, or dragged back) resumes
|
|
109
|
+
* instead, matching the board's held state.
|
|
100
110
|
*/
|
|
101
|
-
function isHeld(item) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
111
|
+
function isHeld(boards, item) {
|
|
112
|
+
const board = boards.get(boardForWorkItem(item));
|
|
113
|
+
const stage = item.stages.length === 1 ? item.stages[0] : void 0;
|
|
114
|
+
if (!board || !stage || board.phaseKind(stage) !== "resting") return false;
|
|
115
|
+
if (needsApproval(item, (phase) => awaitsAcceptance(board, phase))) return true;
|
|
116
|
+
const triage = boardFlow(board).triage;
|
|
117
|
+
const triageRole = triage ? board.roleForPhase(triage) : void 0;
|
|
118
|
+
if (!triageRole || item.sessions[triageRole] === void 0) return false;
|
|
119
|
+
return !item.stageHistory.some((entry) => entry.stage !== triage && board.isWorking(entry.stage));
|
|
105
120
|
}
|
|
106
121
|
const listInputSchema = z.object({
|
|
107
122
|
query: z.string().trim().min(1).max(200).optional().describe("Case-insensitive text in the title, or an exact card number like \"#123\"."),
|
|
@@ -118,6 +133,37 @@ function createFactoryReadTools(scope, deps) {
|
|
|
118
133
|
orgId: scope.orgId,
|
|
119
134
|
factoryProjectId: scope.factoryProjectId
|
|
120
135
|
};
|
|
136
|
+
/**
|
|
137
|
+
* Of `cards` filed by hand, those that name no repository while the Factory
|
|
138
|
+
* links several, so a run on them refuses to start until someone picks one.
|
|
139
|
+
*/
|
|
140
|
+
const cardsWithoutRepository = async (cards) => {
|
|
141
|
+
const unnamed = cards.filter((card) => typeof card.metadata?.repository !== "string");
|
|
142
|
+
if (unnamed.length === 0 || !deps.sessions) return {
|
|
143
|
+
items: [],
|
|
144
|
+
candidates: []
|
|
145
|
+
};
|
|
146
|
+
const sourceControl = await deps.sessions.getSourceControlBySessionId(scope.sessionId);
|
|
147
|
+
if (!sourceControl) return {
|
|
148
|
+
items: [],
|
|
149
|
+
candidates: []
|
|
150
|
+
};
|
|
151
|
+
const resolution = await resolveWorkItemRepository({
|
|
152
|
+
sourceControl,
|
|
153
|
+
...project,
|
|
154
|
+
item: {
|
|
155
|
+
metadata: null,
|
|
156
|
+
workItem: { metadata: null }
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
return resolution.status === "ambiguous" ? {
|
|
160
|
+
items: unnamed,
|
|
161
|
+
candidates: resolution.candidates
|
|
162
|
+
} : {
|
|
163
|
+
items: [],
|
|
164
|
+
candidates: []
|
|
165
|
+
};
|
|
166
|
+
};
|
|
121
167
|
return {
|
|
122
168
|
factory_list_work_items: createTool({
|
|
123
169
|
id: "factory_list_work_items",
|
|
@@ -125,7 +171,7 @@ function createFactoryReadTools(scope, deps) {
|
|
|
125
171
|
inputSchema: listInputSchema,
|
|
126
172
|
execute: async (input) => {
|
|
127
173
|
const [items, bindings, followed] = await Promise.all([
|
|
128
|
-
deps.workItems.
|
|
174
|
+
deps.workItems.listShared(project),
|
|
129
175
|
deps.workItems.listRunBindings(scope.orgId, scope.factoryProjectId),
|
|
130
176
|
input.subscribed === void 0 ? void 0 : deps.workItems.listSessionSubscriptions({
|
|
131
177
|
...project,
|
|
@@ -165,24 +211,19 @@ function createFactoryReadTools(scope, deps) {
|
|
|
165
211
|
}),
|
|
166
212
|
factory_inspect_work_item: createTool({
|
|
167
213
|
id: "factory_inspect_work_item",
|
|
168
|
-
description: "Everything the Factory knows about one work item: stage history, sessions by role (with whether each is mid-run and when its thread last moved), decisions with errors, recent audit events,
|
|
214
|
+
description: "Everything the Factory knows about one work item: its description, stage history, sessions by role (with whether each is mid-run and when its thread last moved), decisions with errors, recent audit events, labels, linked items and the sessions following it. Use it to explain why an item is where it is.",
|
|
169
215
|
inputSchema: z.object({ workItem: workItemRefSchema }).strict(),
|
|
170
216
|
execute: async ({ workItem }) => {
|
|
171
217
|
const item = await findWorkItem(deps.workItems, scope, workItem);
|
|
172
218
|
if (!item) throw workItemNotFound(workItem);
|
|
173
|
-
const [bindings, decisions, audit,
|
|
219
|
+
const [bindings, decisions, audit, all, subscribers] = await Promise.all([
|
|
174
220
|
deps.workItems.listRunBindings(scope.orgId, scope.factoryProjectId, item.id),
|
|
175
221
|
deps.workItems.listDeferredDecisions(scope.orgId, scope.factoryProjectId, { workItemId: item.id }),
|
|
176
222
|
deps.audit.list({
|
|
177
223
|
...project,
|
|
178
224
|
limit: 200
|
|
179
225
|
}),
|
|
180
|
-
deps.
|
|
181
|
-
...project,
|
|
182
|
-
workItemId: item.id,
|
|
183
|
-
limit: 10
|
|
184
|
-
}),
|
|
185
|
-
deps.workItems.list(project),
|
|
226
|
+
deps.workItems.listShared(project),
|
|
186
227
|
deps.workItems.listWorkItemSubscribers({
|
|
187
228
|
orgId: scope.orgId,
|
|
188
229
|
workItemId: item.id
|
|
@@ -214,6 +255,7 @@ function createFactoryReadTools(scope, deps) {
|
|
|
214
255
|
return {
|
|
215
256
|
item: {
|
|
216
257
|
...summarizeItem(item, bindings),
|
|
258
|
+
description: item.description,
|
|
217
259
|
source: item.externalSource ? `${item.externalSource.integrationId}:${item.externalSource.type}` : "manual",
|
|
218
260
|
sourceUrl: typeof item.workItem.url === "string" ? item.workItem.url : null,
|
|
219
261
|
revision: item.revision
|
|
@@ -233,13 +275,6 @@ function createFactoryReadTools(scope, deps) {
|
|
|
233
275
|
actorType: event.actorType,
|
|
234
276
|
occurredAt: iso(event.occurredAt)
|
|
235
277
|
})),
|
|
236
|
-
feed: feed.map((comment) => ({
|
|
237
|
-
id: comment.id,
|
|
238
|
-
kind: comment.kind,
|
|
239
|
-
author: comment.author,
|
|
240
|
-
occurredAt: iso(comment.occurredAt),
|
|
241
|
-
body: truncate(comment.body, 600)
|
|
242
|
-
})),
|
|
243
278
|
parent: parent ? summarizeItem(parent, bindings) : null,
|
|
244
279
|
children: children.slice(0, 50).map((child) => summarizeItem(child, bindings)),
|
|
245
280
|
subscribers: subscribers.slice(0, 50).map((subscription) => ({
|
|
@@ -252,10 +287,10 @@ function createFactoryReadTools(scope, deps) {
|
|
|
252
287
|
}),
|
|
253
288
|
factory_list_attention: createTool({
|
|
254
289
|
id: "factory_list_attention",
|
|
255
|
-
description: "What in this Factory needs a person: failed decisions grouped by failure code and error (one incident per group), proposals waiting for approval,
|
|
290
|
+
description: "What in this Factory needs a person: failed decisions grouped by failure code and error (one incident per group), proposals waiting for approval, runs parked on a tool prompt (a plan to review, a question to answer) while still in flight, Work cards triage left in Intake for a person to move on, and open cards filed by hand that need a repository set (factory_update_work_item) before a run can start.",
|
|
256
291
|
inputSchema: z.object({ limit: z.number().int().min(1).max(50).optional() }).strict(),
|
|
257
292
|
execute: async ({ limit = DEFAULT_LIST }) => {
|
|
258
|
-
const [decisions, items] = await Promise.all([deps.workItems.listDeferredDecisions(scope.orgId, scope.factoryProjectId, { statuses: ["failed", "proposed"] }), deps.workItems.
|
|
293
|
+
const [decisions, items] = await Promise.all([deps.workItems.listDeferredDecisions(scope.orgId, scope.factoryProjectId, { statuses: ["failed", "proposed"] }), deps.workItems.listShared(project)]);
|
|
259
294
|
const itemsById = new Map(items.map((item) => [item.id, item]));
|
|
260
295
|
const failed = decisions.filter((decision) => decision.status === "failed");
|
|
261
296
|
const groups = /* @__PURE__ */ new Map();
|
|
@@ -284,9 +319,13 @@ function createFactoryReadTools(scope, deps) {
|
|
|
284
319
|
...group,
|
|
285
320
|
shown: group.decisions.slice(0, limit)
|
|
286
321
|
}));
|
|
287
|
-
const
|
|
322
|
+
const boards = await toBoardSource(deps.boards).load(project);
|
|
323
|
+
const overtaken = await overtakenDecisionIds(deps.workItems, boards, project, incidents.flatMap((group) => group.shown));
|
|
288
324
|
const proposals = decisions.filter((decision) => decision.status === "proposed");
|
|
289
|
-
const held = items.filter(isHeld);
|
|
325
|
+
const held = items.filter((item) => isHeld(boards, item));
|
|
326
|
+
const unplaced = await cardsWithoutRepository(items.filter((item) => !item.externalSource && !isTerminalWorkItem(boards, item)));
|
|
327
|
+
const needsRepository = unplaced.items;
|
|
328
|
+
const waiting = (deps.liveSessions?.()?.parkedIn(scope.factoryProjectId) ?? []).sort((a, b) => a.run.suspendedAt - b.run.suspendedAt);
|
|
290
329
|
return {
|
|
291
330
|
incidents: incidents.map((group) => ({
|
|
292
331
|
failureCode: group.failureCode,
|
|
@@ -304,11 +343,22 @@ function createFactoryReadTools(scope, deps) {
|
|
|
304
343
|
...summarizeDecision(decision),
|
|
305
344
|
...ref(decision.workItemId)
|
|
306
345
|
})),
|
|
346
|
+
waiting: waiting.slice(0, limit).map(({ sessionId, run }) => ({
|
|
347
|
+
sessionId,
|
|
348
|
+
toolName: run.toolName,
|
|
349
|
+
label: parkedRunLabel(run.toolName),
|
|
350
|
+
waitingSince: new Date(run.suspendedAt).toISOString()
|
|
351
|
+
})),
|
|
307
352
|
held: held.slice(0, limit).map((item) => ({
|
|
308
353
|
...ref(item.id),
|
|
309
354
|
stage: workItemStage(item)
|
|
310
355
|
})),
|
|
311
|
-
|
|
356
|
+
needsRepository: needsRepository.slice(0, limit).map((item) => ({
|
|
357
|
+
...ref(item.id),
|
|
358
|
+
stage: workItemStage(item)
|
|
359
|
+
})),
|
|
360
|
+
...needsRepository.length > 0 ? { linkedRepositories: unplaced.candidates } : {},
|
|
361
|
+
truncated: allIncidents.length > limit || incidents.some((group) => group.shown.length < group.decisions.length) || proposals.length > limit || waiting.length > limit || held.length > limit || needsRepository.length > limit
|
|
312
362
|
};
|
|
313
363
|
}
|
|
314
364
|
})
|