@mastra/factory 0.29.0-alpha.4 → 0.29.0-alpha.6
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 +172 -89
- package/dist/boards/board-events.d.ts +89 -9
- package/dist/boards/board-events.d.ts.map +1 -1
- package/dist/boards/board-events.js +176 -13
- package/dist/boards/board-events.js.map +1 -1
- package/dist/boards/board-writes.d.ts.map +1 -1
- package/dist/boards/board-writes.js +14 -1
- package/dist/boards/board-writes.js.map +1 -1
- package/dist/boards/busy-card.d.ts +11 -0
- package/dist/boards/busy-card.d.ts.map +1 -0
- package/dist/boards/busy-card.js +15 -0
- package/dist/boards/busy-card.js.map +1 -0
- package/dist/boards/card-facts.d.ts.map +1 -1
- package/dist/boards/card-facts.js +18 -4
- package/dist/boards/card-facts.js.map +1 -1
- package/dist/boards/index.d.ts +2 -1
- package/dist/boards/index.d.ts.map +1 -1
- package/dist/boards/index.js +3 -2
- package/dist/boards/intake-dry-run.d.ts +109 -0
- package/dist/boards/intake-dry-run.d.ts.map +1 -0
- package/dist/boards/intake-dry-run.js +158 -0
- package/dist/boards/intake-dry-run.js.map +1 -0
- package/dist/boards/intake-lookup.d.ts +32 -0
- package/dist/boards/intake-lookup.d.ts.map +1 -0
- package/dist/boards/intake-lookup.js +12 -0
- package/dist/boards/intake-lookup.js.map +1 -0
- package/dist/boards/intake-order.d.ts +32 -0
- package/dist/boards/intake-order.d.ts.map +1 -0
- package/dist/boards/intake-order.js +60 -0
- package/dist/boards/intake-order.js.map +1 -0
- package/dist/boards/intake-routing.d.ts +246 -35
- package/dist/boards/intake-routing.d.ts.map +1 -1
- package/dist/boards/intake-routing.js +437 -52
- package/dist/boards/intake-routing.js.map +1 -1
- package/dist/boards/reroute.d.ts +7 -3
- package/dist/boards/reroute.d.ts.map +1 -1
- package/dist/boards/reroute.js +21 -4
- package/dist/boards/reroute.js.map +1 -1
- package/dist/boards/semantics.d.ts +8 -28
- package/dist/boards/semantics.d.ts.map +1 -1
- package/dist/boards/semantics.js +14 -40
- package/dist/boards/semantics.js.map +1 -1
- package/dist/boards/work-routes.d.ts +31 -11
- package/dist/boards/work-routes.d.ts.map +1 -1
- package/dist/boards/work-routes.js +104 -20
- package/dist/boards/work-routes.js.map +1 -1
- package/dist/factory.d.ts +37 -1
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +127 -48
- package/dist/factory.js.map +1 -1
- package/dist/integrations/base.d.ts +9 -0
- package/dist/integrations/base.d.ts.map +1 -1
- package/dist/integrations/dependabot/rules.js +1 -1
- package/dist/integrations/dependabot/rules.js.map +1 -1
- package/dist/integrations/github/default-rules.d.ts +22 -1
- package/dist/integrations/github/default-rules.d.ts.map +1 -1
- package/dist/integrations/github/default-rules.js +23 -5
- package/dist/integrations/github/default-rules.js.map +1 -1
- package/dist/integrations/github/intake-lookup.d.ts +16 -0
- package/dist/integrations/github/intake-lookup.d.ts.map +1 -0
- package/dist/integrations/github/intake-lookup.js +76 -0
- package/dist/integrations/github/intake-lookup.js.map +1 -0
- package/dist/integrations/github/integration.d.ts +19 -5
- package/dist/integrations/github/integration.d.ts.map +1 -1
- package/dist/integrations/github/integration.js +21 -6
- package/dist/integrations/github/integration.js.map +1 -1
- package/dist/integrations/github/issue-intake.d.ts +15 -0
- package/dist/integrations/github/issue-intake.d.ts.map +1 -0
- package/dist/integrations/github/issue-intake.js +50 -0
- package/dist/integrations/github/issue-intake.js.map +1 -0
- package/dist/integrations/github/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/github/issue-reconciler.js +10 -1
- package/dist/integrations/github/issue-reconciler.js.map +1 -1
- package/dist/integrations/github/review-status-reporter.js +1 -1
- package/dist/integrations/github/routes.d.ts.map +1 -1
- package/dist/integrations/github/routes.js +14 -2
- package/dist/integrations/github/routes.js.map +1 -1
- package/dist/integrations/github/rules.d.ts +14 -1
- package/dist/integrations/github/rules.d.ts.map +1 -1
- package/dist/integrations/github/rules.js +221 -30
- package/dist/integrations/github/rules.js.map +1 -1
- package/dist/integrations/github/sandbox.d.ts.map +1 -1
- package/dist/integrations/github/sandbox.js +30 -4
- package/dist/integrations/github/sandbox.js.map +1 -1
- package/dist/integrations/gitlab/default-rules.d.ts.map +1 -1
- package/dist/integrations/gitlab/default-rules.js +19 -3
- package/dist/integrations/gitlab/default-rules.js.map +1 -1
- package/dist/integrations/gitlab/intake-lookup.d.ts +17 -0
- package/dist/integrations/gitlab/intake-lookup.d.ts.map +1 -0
- package/dist/integrations/gitlab/intake-lookup.js +85 -0
- package/dist/integrations/gitlab/intake-lookup.js.map +1 -0
- package/dist/integrations/gitlab/integration.d.ts +5 -0
- package/dist/integrations/gitlab/integration.d.ts.map +1 -1
- package/dist/integrations/gitlab/integration.js +21 -1
- package/dist/integrations/gitlab/integration.js.map +1 -1
- package/dist/integrations/gitlab/rules.d.ts +20 -0
- package/dist/integrations/gitlab/rules.d.ts.map +1 -1
- package/dist/integrations/gitlab/rules.js +108 -12
- package/dist/integrations/gitlab/rules.js.map +1 -1
- package/dist/integrations/incidentio/rules.d.ts.map +1 -1
- package/dist/integrations/incidentio/rules.js +14 -4
- package/dist/integrations/incidentio/rules.js.map +1 -1
- package/dist/integrations/jira/rules.d.ts.map +1 -1
- package/dist/integrations/jira/rules.js +12 -2
- package/dist/integrations/jira/rules.js.map +1 -1
- package/dist/integrations/linear/rules.d.ts.map +1 -1
- package/dist/integrations/linear/rules.js +13 -2
- package/dist/integrations/linear/rules.js.map +1 -1
- package/dist/integrations/platform/connect/routes.d.ts +43 -1
- package/dist/integrations/platform/connect/routes.d.ts.map +1 -1
- package/dist/integrations/platform/connect/routes.js +82 -7
- 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 -1
- package/dist/integrations/platform/connect/session-tools.js +28 -10
- package/dist/integrations/platform/connect/session-tools.js.map +1 -1
- package/dist/integrations/platform/github/event-worker.js +9 -1
- package/dist/integrations/platform/github/event-worker.js.map +1 -1
- package/dist/integrations/platform/github/integration.d.ts +6 -6
- package/dist/integrations/platform/github/integration.d.ts.map +1 -1
- package/dist/integrations/platform/github/integration.js +22 -3
- package/dist/integrations/platform/github/integration.js.map +1 -1
- package/dist/integrations/platform/vanta/integration.d.ts.map +1 -1
- package/dist/integrations/platform/vanta/integration.js +3 -3
- package/dist/integrations/platform/vanta/integration.js.map +1 -1
- package/dist/integrations/pull-request-head.d.ts +1 -1
- package/dist/integrations/pull-request-head.d.ts.map +1 -1
- package/dist/integrations/pull-request-head.js +5 -0
- package/dist/integrations/pull-request-head.js.map +1 -1
- package/dist/integrations/vanta/rules.js +1 -1
- package/dist/integrations/vanta/rules.js.map +1 -1
- package/dist/integrations/vanta/sync.d.ts +9 -0
- package/dist/integrations/vanta/sync.d.ts.map +1 -1
- package/dist/integrations/vanta/sync.js +10 -1
- package/dist/integrations/vanta/sync.js.map +1 -1
- package/dist/routes/board-snapshot.d.ts +13 -6
- package/dist/routes/board-snapshot.d.ts.map +1 -1
- package/dist/routes/board-snapshot.js +42 -20
- package/dist/routes/board-snapshot.js.map +1 -1
- package/dist/routes/boards.js.map +1 -1
- package/dist/routes/config.d.ts +17 -2
- package/dist/routes/config.d.ts.map +1 -1
- package/dist/routes/config.js +247 -77
- package/dist/routes/config.js.map +1 -1
- package/dist/routes/contracts.d.ts +1294 -7
- package/dist/routes/contracts.d.ts.map +1 -1
- package/dist/routes/contracts.js +603 -20
- package/dist/routes/contracts.js.map +1 -1
- package/dist/routes/custom-endpoint-url.d.ts +8 -0
- package/dist/routes/custom-endpoint-url.d.ts.map +1 -0
- package/dist/routes/custom-endpoint-url.js +45 -0
- package/dist/routes/custom-endpoint-url.js.map +1 -0
- package/dist/routes/custom-provider-source.d.ts +24 -8
- package/dist/routes/custom-provider-source.d.ts.map +1 -1
- package/dist/routes/custom-provider-source.js +93 -43
- package/dist/routes/custom-provider-source.js.map +1 -1
- package/dist/routes/intake-check.d.ts +92 -0
- package/dist/routes/intake-check.d.ts.map +1 -0
- package/dist/routes/intake-check.js +322 -0
- package/dist/routes/intake-check.js.map +1 -0
- package/dist/routes/intake-routes.d.ts +10 -2
- package/dist/routes/intake-routes.d.ts.map +1 -1
- package/dist/routes/intake-routes.js +292 -11
- package/dist/routes/intake-routes.js.map +1 -1
- package/dist/routes/intake.d.ts +6 -0
- package/dist/routes/intake.d.ts.map +1 -1
- package/dist/routes/intake.js +20 -0
- package/dist/routes/intake.js.map +1 -1
- package/dist/routes/mastra-gateway.d.ts.map +1 -1
- package/dist/routes/mastra-gateway.js +3 -2
- package/dist/routes/mastra-gateway.js.map +1 -1
- package/dist/routes/project-sessions.d.ts +61 -0
- package/dist/routes/project-sessions.d.ts.map +1 -0
- package/dist/routes/project-sessions.js +135 -0
- package/dist/routes/project-sessions.js.map +1 -0
- package/dist/routes/projects.d.ts +6 -1
- package/dist/routes/projects.d.ts.map +1 -1
- package/dist/routes/projects.js +19 -3
- package/dist/routes/projects.js.map +1 -1
- package/dist/routes/provider-credentials.d.ts +10 -1
- package/dist/routes/provider-credentials.d.ts.map +1 -1
- package/dist/routes/provider-credentials.js +13 -16
- package/dist/routes/provider-credentials.js.map +1 -1
- package/dist/routes/run-queue.d.ts +6 -6
- package/dist/routes/run-queue.d.ts.map +1 -1
- package/dist/routes/run-queue.js +28 -8
- package/dist/routes/run-queue.js.map +1 -1
- package/dist/routes/session-rows.d.ts +30 -0
- package/dist/routes/session-rows.d.ts.map +1 -0
- package/dist/routes/session-rows.js +94 -0
- package/dist/routes/session-rows.js.map +1 -0
- package/dist/routes/source-control-sessions.d.ts +4 -5
- package/dist/routes/source-control-sessions.d.ts.map +1 -1
- package/dist/routes/source-control-sessions.js +8 -87
- package/dist/routes/source-control-sessions.js.map +1 -1
- package/dist/routes/surface.d.ts +16 -1
- package/dist/routes/surface.d.ts.map +1 -1
- package/dist/routes/surface.js +41 -30
- package/dist/routes/surface.js.map +1 -1
- package/dist/routes/tenant-credentials.d.ts.map +1 -1
- package/dist/routes/tenant-credentials.js +4 -4
- package/dist/routes/tenant-credentials.js.map +1 -1
- package/dist/routes/work-item-starters.d.ts +1 -0
- package/dist/routes/work-item-starters.d.ts.map +1 -1
- package/dist/routes/work-item-starters.js +14 -2
- package/dist/routes/work-item-starters.js.map +1 -1
- package/dist/routes/work-items.d.ts +22 -3
- package/dist/routes/work-items.d.ts.map +1 -1
- package/dist/routes/work-items.js +124 -48
- package/dist/routes/work-items.js.map +1 -1
- package/dist/rules/binding-context.d.ts +5 -0
- package/dist/rules/binding-context.d.ts.map +1 -1
- package/dist/rules/binding-context.js +51 -5
- package/dist/rules/binding-context.js.map +1 -1
- package/dist/rules/dispatch-errors.js +1 -1
- package/dist/rules/dispatch-errors.js.map +1 -1
- package/dist/rules/dispatcher.d.ts +39 -7
- package/dist/rules/dispatcher.d.ts.map +1 -1
- package/dist/rules/dispatcher.js +363 -123
- package/dist/rules/dispatcher.js.map +1 -1
- package/dist/rules/event-rules.d.ts +69 -1
- package/dist/rules/event-rules.d.ts.map +1 -1
- package/dist/rules/event-rules.js +151 -5
- package/dist/rules/event-rules.js.map +1 -1
- package/dist/rules/review-source-tool.js +1 -1
- package/dist/rules/rule-group.d.ts +18 -1
- package/dist/rules/rule-group.d.ts.map +1 -1
- package/dist/rules/rule-group.js +52 -8
- package/dist/rules/rule-group.js.map +1 -1
- package/dist/rules/run-bearing.d.ts +8 -0
- package/dist/rules/run-bearing.d.ts.map +1 -0
- package/dist/rules/run-bearing.js +11 -0
- package/dist/rules/run-bearing.js.map +1 -0
- package/dist/rules/start-coordinator.d.ts +2 -3
- package/dist/rules/start-coordinator.d.ts.map +1 -1
- package/dist/rules/start-coordinator.js +25 -38
- package/dist/rules/start-coordinator.js.map +1 -1
- package/dist/rules/tools.js +2 -1
- package/dist/rules/tools.js.map +1 -1
- package/dist/rules/transition-service.d.ts +16 -0
- package/dist/rules/transition-service.d.ts.map +1 -1
- package/dist/rules/transition-service.js +34 -10
- package/dist/rules/transition-service.js.map +1 -1
- package/dist/rules/types.d.ts +18 -5
- package/dist/rules/types.d.ts.map +1 -1
- package/dist/rules/types.js +2 -1
- package/dist/rules/types.js.map +1 -1
- package/dist/rules/update-fold.d.ts +32 -0
- package/dist/rules/update-fold.d.ts.map +1 -0
- package/dist/rules/update-fold.js +60 -0
- package/dist/rules/update-fold.js.map +1 -0
- package/dist/rules/validation.d.ts.map +1 -1
- package/dist/rules/validation.js +54 -6
- package/dist/rules/validation.js.map +1 -1
- package/dist/sandbox/session-retirement.d.ts +6 -0
- package/dist/sandbox/session-retirement.d.ts.map +1 -1
- package/dist/sandbox/session-retirement.js +17 -0
- package/dist/sandbox/session-retirement.js.map +1 -1
- package/dist/session/factory-session.d.ts.map +1 -1
- package/dist/session/factory-session.js +2 -1
- package/dist/session/factory-session.js.map +1 -1
- package/dist/session/live-sessions.d.ts +6 -1
- package/dist/session/live-sessions.d.ts.map +1 -1
- package/dist/session/live-sessions.js +4 -0
- package/dist/session/live-sessions.js.map +1 -1
- package/dist/session/resource-migration.d.ts.map +1 -1
- package/dist/session/resource-migration.js +2 -3
- package/dist/session/resource-migration.js.map +1 -1
- package/dist/session/run-audit.d.ts +10 -1
- package/dist/session/run-audit.d.ts.map +1 -1
- package/dist/session/run-audit.js +9 -1
- package/dist/session/run-audit.js.map +1 -1
- package/dist/session/self-review-gate.d.ts +26 -2
- package/dist/session/self-review-gate.d.ts.map +1 -1
- package/dist/session/self-review-gate.js +60 -10
- package/dist/session/self-review-gate.js.map +1 -1
- package/dist/session/session-row-query.d.ts +25 -0
- package/dist/session/session-row-query.d.ts.map +1 -0
- package/dist/session/session-row-query.js +47 -0
- package/dist/session/session-row-query.js.map +1 -0
- package/dist/session/session-row-status.d.ts +16 -0
- package/dist/session/session-row-status.d.ts.map +1 -0
- package/dist/session/session-row-status.js +14 -0
- package/dist/session/session-row-status.js.map +1 -0
- package/dist/session/session-row-view.d.ts +13 -0
- package/dist/session/session-row-view.d.ts.map +1 -0
- package/dist/session/session-row-view.js +118 -0
- package/dist/session/session-row-view.js.map +1 -0
- package/dist/session/session-rows.d.ts +60 -0
- package/dist/session/session-rows.d.ts.map +1 -0
- package/dist/session/session-rows.js +307 -0
- package/dist/session/session-rows.js.map +1 -0
- package/dist/session/session-threads.d.ts.map +1 -1
- package/dist/session/session-threads.js +1 -0
- package/dist/session/session-threads.js.map +1 -1
- package/dist/session/session-unloader.d.ts +101 -0
- package/dist/session/session-unloader.d.ts.map +1 -0
- package/dist/session/session-unloader.js +278 -0
- package/dist/session/session-unloader.js.map +1 -0
- package/dist/session/source-control-tools.d.ts +14 -7
- package/dist/session/source-control-tools.d.ts.map +1 -1
- package/dist/session/source-control-tools.js +10 -2
- package/dist/session/source-control-tools.js.map +1 -1
- package/dist/session/work-item-repository.d.ts +49 -1
- package/dist/session/work-item-repository.d.ts.map +1 -1
- package/dist/session/work-item-repository.js +118 -15
- package/dist/session/work-item-repository.js.map +1 -1
- package/dist/session/work-item-state-processor.d.ts.map +1 -1
- package/dist/session/work-item-state-processor.js +44 -8
- package/dist/session/work-item-state-processor.js.map +1 -1
- package/dist/session-list-changes.d.ts +9 -0
- package/dist/session-list-changes.d.ts.map +1 -0
- package/dist/session-list-changes.js +54 -0
- package/dist/session-list-changes.js.map +1 -0
- package/dist/storage/announced-lists.d.ts +14 -0
- package/dist/storage/announced-lists.d.ts.map +1 -0
- package/dist/storage/announced-lists.js +78 -0
- package/dist/storage/announced-lists.js.map +1 -0
- package/dist/storage/domains/audit/actions.d.ts +2 -1
- package/dist/storage/domains/audit/actions.d.ts.map +1 -1
- package/dist/storage/domains/audit/actions.js +3 -1
- package/dist/storage/domains/audit/actions.js.map +1 -1
- package/dist/storage/domains/boards/base.d.ts +163 -15
- package/dist/storage/domains/boards/base.d.ts.map +1 -1
- package/dist/storage/domains/boards/base.js +440 -48
- package/dist/storage/domains/boards/base.js.map +1 -1
- package/dist/storage/domains/boards/schemas.d.ts +6 -0
- package/dist/storage/domains/boards/schemas.d.ts.map +1 -1
- package/dist/storage/domains/boards/schemas.js +95 -1
- package/dist/storage/domains/boards/schemas.js.map +1 -1
- package/dist/storage/domains/custom-providers/base.d.ts +62 -19
- package/dist/storage/domains/custom-providers/base.d.ts.map +1 -1
- package/dist/storage/domains/custom-providers/base.js +131 -100
- package/dist/storage/domains/custom-providers/base.js.map +1 -1
- package/dist/storage/domains/intake/base.d.ts +25 -7
- package/dist/storage/domains/intake/base.d.ts.map +1 -1
- package/dist/storage/domains/intake/base.js +83 -19
- package/dist/storage/domains/intake/base.js.map +1 -1
- package/dist/storage/domains/projects/base.d.ts.map +1 -1
- package/dist/storage/domains/projects/base.js +19 -10
- package/dist/storage/domains/projects/base.js.map +1 -1
- package/dist/storage/domains/source-control/base.d.ts +8 -0
- package/dist/storage/domains/source-control/base.d.ts.map +1 -1
- package/dist/storage/domains/source-control/base.js +110 -61
- package/dist/storage/domains/source-control/base.js.map +1 -1
- package/dist/storage/domains/source-control/inmemory.d.ts +4 -0
- package/dist/storage/domains/source-control/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/source-control/inmemory.js +8 -5
- package/dist/storage/domains/source-control/inmemory.js.map +1 -1
- package/dist/storage/domains/work-items/base.d.ts +57 -18
- package/dist/storage/domains/work-items/base.d.ts.map +1 -1
- package/dist/storage/domains/work-items/base.js +168 -83
- package/dist/storage/domains/work-items/base.js.map +1 -1
- package/dist/storage/domains/work-items/cards.d.ts +3 -2
- package/dist/storage/domains/work-items/cards.d.ts.map +1 -1
- package/dist/storage/domains/work-items/cards.js +4 -2
- package/dist/storage/domains/work-items/cards.js.map +1 -1
- package/dist/tools/audit-events-tool.d.ts +2 -2
- package/dist/tools/read-tools.d.ts +9 -5
- package/dist/tools/read-tools.d.ts.map +1 -1
- package/dist/tools/read-tools.js +61 -54
- package/dist/tools/read-tools.js.map +1 -1
- package/dist/tools/session-tools.d.ts +0 -13
- package/dist/tools/session-tools.d.ts.map +1 -1
- package/dist/tools/session-tools.js +128 -341
- package/dist/tools/session-tools.js.map +1 -1
- package/dist/tools/work-item-tools.d.ts +3 -0
- package/dist/tools/work-item-tools.d.ts.map +1 -1
- package/dist/tools/work-item-tools.js +99 -27
- package/dist/tools/work-item-tools.js.map +1 -1
- package/dist/work-item-branch.d.ts +4 -0
- package/dist/work-item-branch.d.ts.map +1 -1
- package/dist/work-item-branch.js +7 -1
- package/dist/work-item-branch.js.map +1 -1
- package/dist/work-items/card-context-sessions.d.ts +50 -0
- package/dist/work-items/card-context-sessions.d.ts.map +1 -0
- package/dist/work-items/card-context-sessions.js +84 -0
- package/dist/work-items/card-context-sessions.js.map +1 -0
- package/dist/work-items/card-reference.d.ts +21 -0
- package/dist/work-items/card-reference.d.ts.map +1 -0
- package/dist/work-items/card-reference.js +58 -0
- package/dist/work-items/card-reference.js.map +1 -0
- package/dist/work-items/change-requests.d.ts +87 -0
- package/dist/work-items/change-requests.d.ts.map +1 -0
- package/dist/work-items/change-requests.js +134 -0
- package/dist/work-items/change-requests.js.map +1 -0
- package/dist/work-items/create-work-item.d.ts +7 -2
- package/dist/work-items/create-work-item.d.ts.map +1 -1
- package/dist/work-items/create-work-item.js +44 -13
- package/dist/work-items/create-work-item.js.map +1 -1
- package/dist/work-items/list-related-cards.d.ts.map +1 -1
- package/dist/work-items/list-related-cards.js +1 -1
- package/dist/work-items/list-related-cards.js.map +1 -1
- package/dist/work-items/providers/github.d.ts.map +1 -1
- package/dist/work-items/providers/github.js +1 -0
- package/dist/work-items/providers/github.js.map +1 -1
- package/factory-skills/factory-build/SKILL.md +1 -1
- package/factory-skills/factory-plan/SKILL.md +5 -3
- package/factory-skills/factory-self-review/SKILL.md +2 -0
- package/factory-skills/factory-triage/SKILL.md +1 -1
- package/package.json +10 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-control-tools.js","names":[],"sources":["../../src/session/source-control-tools.ts"],"sourcesContent":["import type { AgentControllerRequestContext } from '@mastra/core/agent-controller';\nimport type { RequestContext } from '@mastra/core/request-context';\nimport { createTool } from '@mastra/core/tools';\nimport type { WorkspaceSandbox } from '@mastra/core/workspace';\nimport { z } from 'zod';\n\nimport { getFactoryAuthOrgId, getFactoryAuthUserFromContext, getFactoryAuthUserId } from '../auth.js';\nimport type { CommitCheck, CommitCheckStatus, VersionControl } from '../capabilities/version-control.js';\nimport type { IntegrationTools } from '../integrations/base.js';\nimport {\n ensureLocalBranch,\n isCheckoutOf,\n pushRepositoryBranch,\n refreshMergeRequestCheckout,\n} from '../integrations/github/sandbox.js';\nimport { normalizedVerdictLine } from '../review-verdict.js';\nimport type { ExecutableSandbox } from '../sandbox/materialization.js';\nimport { resolveSessionWorkdir } from '../sandbox/session-sandbox.js';\nimport type { AuditAgentEmitter } from '../storage/domains/audit/domain.js';\nimport type {\n ProjectRepository,\n SourceControlRepository,\n SourceControlSession,\n SourceControlStorageHandle,\n} from '../storage/domains/source-control/base.js';\nimport { mergeRequestNumberFromBranch } from '../work-item-branch.js';\nimport { environmentSlugs, findEnvironmentRepository, resolveSessionRepositories } from './environment-repositories.js';\nimport { updateSessionEnvironmentRepository } from './environment-state-processor.js';\n\ntype RepositorySessionState = {\n factoryProjectId?: string;\n projectRepositoryId?: string;\n};\n\nexport interface SourceControlToolProvider {\n id: string;\n storage: SourceControlStorageHandle;\n versionControl: VersionControl;\n}\n\ninterface SessionTarget {\n context: AgentControllerRequestContext<RepositorySessionState>;\n provider: SourceControlToolProvider;\n session: SourceControlSession;\n projectRepository: ProjectRepository;\n repository: SourceControlRepository;\n orgId: string;\n userId: string;\n /** True when the target is the link the session is filed under, the default. */\n ownRepository: boolean;\n}\n\ntype ReviewEvent = 'approve' | 'request-changes' | 'comment';\n\n/** Returns why a review's leading `Verdict:` line contradicts the submitted event, if it does. */\nexport function verdictEventMismatch(event: ReviewEvent, body: string | undefined): string | undefined {\n const match = /^verdict: ?(approve|request changes|changes requested)\\b/.exec(normalizedVerdictLine(body) ?? '');\n if (!match) return undefined;\n const verdict = match[1] === 'approve' ? 'approve' : 'request changes';\n // GitLab has no request-changes state, so a blocking verdict is published as a comment review.\n const allowed: ReviewEvent[] = verdict === 'approve' ? ['approve'] : ['request-changes', 'comment'];\n if (allowed.includes(event)) return undefined;\n return `Review body opens with \"Verdict: ${verdict}\" but event is \"${event}\". Nothing was posted. Use event ${allowed\n .map(e => `\"${e}\"`)\n .join(' or ')} for this body, or regenerate the body for the verdict you intend.`;\n}\n\nconst REVIEWED_HEAD_LINE = /^[\\s*_>-]*reviewed head[*_]*:[*_]*\\s*(.*)$/gim;\nconst FULL_SHA = /^`?([0-9a-f]{40}|[0-9a-f]{64})`?(?:\\s|$)/i;\n\n/**\n * Returns the full SHA named by the body's `Reviewed head:` lines, `null` when any line is malformed or the lines\n * disagree, or `undefined` when absent.\n */\nexport function reviewedHeadFromBody(body: string | undefined): string | null | undefined {\n const shas = new Set(\n [...(body ?? '').matchAll(REVIEWED_HEAD_LINE)].map(\n line => FULL_SHA.exec(line[1]!.trim())?.[1]?.toLowerCase() ?? null,\n ),\n );\n if (shas.size === 0) return undefined;\n if (shas.size > 1) return null;\n return [...shas][0];\n}\n\nfunction authIdentity(requestContext: RequestContext) {\n const user = getFactoryAuthUserFromContext(requestContext);\n return { orgId: getFactoryAuthOrgId(user), userId: getFactoryAuthUserId(user) };\n}\n\nasync function resolveProviderSession(\n sessionId: string,\n providers: readonly SourceControlToolProvider[],\n): Promise<{ provider: SourceControlToolProvider; session: SourceControlSession }> {\n const matches = (\n await Promise.all(\n providers.map(async provider => ({\n provider,\n session: await provider.storage.sessions.getBySessionId(sessionId),\n })),\n )\n ).filter(\n (match): match is { provider: SourceControlToolProvider; session: SourceControlSession } => match.session !== null,\n );\n if (matches.length !== 1) {\n throw new Error(\n matches.length === 0\n ? 'The active session is not backed by a source-control repository.'\n : 'The active session is ambiguous across source-control providers.',\n );\n }\n return matches[0]!;\n}\n\nasync function resolveSessionTarget(\n requestContext: RequestContext,\n providers: readonly SourceControlToolProvider[],\n options: { repository?: string } = {},\n): Promise<SessionTarget> {\n const context = requestContext.get('controller') as AgentControllerRequestContext<RepositorySessionState> | undefined;\n const { orgId, userId } = authIdentity(requestContext);\n if (!context?.sessionId || !orgId || !userId) {\n throw new Error('Source-control tools require an authenticated repository session.');\n }\n\n const { provider, session } = await resolveProviderSession(context.sessionId, providers);\n if (session.orgId !== orgId || (session.visibility === 'private' && session.userId !== userId)) {\n throw new Error('The active source-control session is not available to the authenticated user.');\n }\n const ownRepository = session.projectRepositoryId\n ? await provider.storage.projectRepositories.get({ orgId, id: session.projectRepositoryId })\n : null;\n if (!ownRepository) throw new Error('The active project repository was not found.');\n const state = context.getState();\n if (state.projectRepositoryId && state.projectRepositoryId !== ownRepository.id) {\n throw new Error('The active source-control session does not match its controller repository.');\n }\n const ownConnection = await provider.storage.connections.get({ orgId, id: ownRepository.connectionId });\n if (!ownConnection) throw new Error('The active source-control connection was not found.');\n if (state.factoryProjectId && state.factoryProjectId !== ownConnection.factoryProjectId) {\n throw new Error('The active source-control session does not match its Factory project.');\n }\n\n if (options.repository !== undefined) {\n const candidates = await resolveSessionRepositories({ sourceControl: provider.storage, session });\n const match = findEnvironmentRepository(candidates, options.repository);\n if (!match) {\n throw new Error(\n `Repository '${options.repository}' is not in this Factory's environment. Valid repositories: ${environmentSlugs(candidates).join(', ')}.`,\n );\n }\n return {\n context,\n provider,\n session,\n projectRepository: match.link,\n repository: match.repository,\n orgId,\n userId,\n ownRepository: match.link.id === ownRepository.id,\n };\n }\n\n const repository = await provider.storage.repositories.get({ orgId, id: ownRepository.repositoryId });\n if (!repository) throw new Error('The active source-control repository was not found.');\n return {\n context,\n provider,\n session,\n projectRepository: ownRepository,\n repository,\n orgId,\n userId,\n ownRepository: true,\n };\n}\n\n/**\n * The slugs a session may target and the one it is filed under, for the tool\n * descriptions. `undefined` when the session cannot be resolved; the tools\n * then describe the default without naming it.\n */\nasync function describeSessionRepositories(\n sessionId: string,\n providers: readonly SourceControlToolProvider[],\n): Promise<{ slugs: string[]; own: string | undefined } | undefined> {\n try {\n const { provider, session } = await resolveProviderSession(sessionId, providers);\n const repositories = await resolveSessionRepositories({ sourceControl: provider.storage, session });\n const own = repositories.find(candidate => candidate.link.id === session.projectRepositoryId);\n return { slugs: environmentSlugs(repositories), own: own?.repository.slug };\n } catch {\n return undefined;\n }\n}\n\nfunction repositoryArgumentDescription(described: { slugs: string[]; own: string | undefined } | undefined): string {\n if (!described || described.slugs.length === 0) {\n return \"Optional `repository` (owner/name) selects another repository of this Factory's environment; defaults to this session's repository.\";\n }\n const fallback = described.own ? `${described.own}, this session's repository` : \"this session's repository\";\n return `Optional \\`repository\\` (owner/name) selects one of this Factory's environment repositories: ${described.slugs.join(', ')}. Defaults to ${fallback}.`;\n}\n\nfunction changeRequestId(value: string | number): string {\n return String(value);\n}\n\nfunction executableSandbox(value: unknown): WorkspaceSandbox & ExecutableSandbox {\n const sandbox = value as Partial<ExecutableSandbox> | undefined;\n if (!sandbox?.executeCommand) throw new Error('The active Factory workspace has no executable sandbox.');\n return sandbox as WorkspaceSandbox & ExecutableSandbox;\n}\n\nasync function emitAgentAudit(\n audit: AuditAgentEmitter,\n requestContext: RequestContext,\n input: Parameters<AuditAgentEmitter['emitAgent']>[0]['input'],\n): Promise<void> {\n try {\n await audit.emitAgent({ requestContext, input });\n } catch (error) {\n console.warn('[Audit] Failed to record brokered source-control action', {\n action: input.action,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n}\n\nconst repositorySchema = z.object({ repository: z.string().trim().min(1).optional() });\nconst changeRequestSchema = repositorySchema.extend({\n changeRequestId: z.union([z.string().trim().min(1), z.number().int().positive()]),\n});\n\nexport async function createSourceControlTools({\n requestContext,\n providers,\n audit,\n selfReviewApprovedHead,\n}: {\n requestContext: RequestContext;\n providers: readonly SourceControlToolProvider[];\n audit: AuditAgentEmitter;\n /**\n * Self-review gate for opening a change request. `undefined` means the session\n * is not gated (no Work item, or its change request predates Self-review);\n * `null` means Self-review has not approved; a SHA is the approved head.\n */\n selfReviewApprovedHead?: () => Promise<string | null | undefined>;\n}): Promise<IntegrationTools> {\n if (!requestContext || typeof (requestContext as { get?: unknown }).get !== 'function') return {};\n const controller = requestContext.get('controller') as\n | AgentControllerRequestContext<RepositorySessionState>\n | undefined;\n const identity = authIdentity(requestContext);\n if (!controller?.sessionId || !identity.orgId || !identity.userId || providers.length === 0) return {};\n\n const repositoryArgument = repositoryArgumentDescription(\n await describeSessionRepositories(controller.sessionId, providers),\n );\n const withTarget = (options?: { repository?: string }) => resolveSessionTarget(requestContext, providers, options);\n const targetFor = (input: { repository?: string }) =>\n withTarget(input.repository !== undefined ? { repository: input.repository } : undefined);\n const reference = async (target: SessionTarget) => ({\n ...(await target.provider.versionControl.getRepositoryTarget({\n orgId: target.orgId,\n repositoryId: target.repository.id,\n })),\n actingUserId: target.userId,\n });\n\n return {\n source_control_refresh_change_request_checkout: createTool({\n id: 'source_control_refresh_change_request_checkout',\n description:\n 'Refresh the active GitLab review session checkout to its current MR head. The MR, repository, branch, and credential are resolved server-side; no provider credentials enter the agent workspace.',\n inputSchema: z.object({}),\n execute: async (_input, { workspace }) => {\n const target = await withTarget();\n const mergeRequestNumber = mergeRequestNumberFromBranch(target.session.branch);\n if (target.provider.id !== 'gitlab' || mergeRequestNumber === undefined) {\n throw new Error('Checkout refresh is only available in a bound GitLab merge-request review session.');\n }\n const ref = await reference(target);\n const mergeRequest = await target.provider.versionControl.getPullRequest({\n ...ref,\n pullRequestId: String(mergeRequestNumber),\n });\n if (!mergeRequest || mergeRequest.state !== 'open' || mergeRequest.merged) {\n throw new Error('The bound GitLab merge request is no longer open.');\n }\n const sandbox = executableSandbox(workspace?.sandbox);\n const workdir = await resolveSessionWorkdir(target.session.id, sandbox, target.repository.slug);\n const access = await target.provider.versionControl.getRepositoryAccess({\n orgId: target.orgId,\n repositoryId: target.repository.id,\n });\n const result = await refreshMergeRequestCheckout(sandbox, workdir, {\n branch: target.session.branch,\n mergeRequestNumber,\n expectedHeadSha: mergeRequest.headSha,\n access,\n });\n return result;\n },\n }),\n source_control_push_branch: createTool({\n id: 'source_control_push_branch',\n description: `Push the active Factory session branch to its connected source-control provider. Credentials are resolved and scrubbed server-side; this tool takes no token, remote, or branch arguments. ${repositoryArgument}`,\n inputSchema: repositorySchema,\n execute: async (input, { workspace }) => {\n const target = await targetFor(input);\n const sandbox = executableSandbox(workspace?.sandbox);\n const workdir = await resolveSessionWorkdir(target.session.id, sandbox, target.repository.slug);\n const access = await target.provider.versionControl.getRepositoryAccess({\n orgId: target.orgId,\n repositoryId: target.repository.id,\n });\n // Another environment repository's directory may not be its checkout:\n // a boot skips a link whose directory name collides with another's, and\n // a session that booted single-repository has no siblings at all.\n if (!target.ownRepository && !(await isCheckoutOf(sandbox, workdir, access.cloneUrl))) {\n throw new Error(`There is no checkout of ${target.repository.slug} in this session.`);\n }\n const branch = target.session.branch;\n // Materialize the session branch at the active HEAD without discarding\n // session-only commits, so the push includes the agent's current work.\n await ensureLocalBranch(sandbox, workdir, branch);\n await pushRepositoryBranch(sandbox, workdir, branch, access, target.repository.slug);\n await target.provider.storage.sessionRepositories.upsert({\n sessionId: target.session.sessionId,\n projectRepositoryId: target.projectRepository.id,\n branch,\n });\n updateSessionEnvironmentRepository(target.session.sessionId, target.repository.slug, { branch });\n await emitAgentAudit(audit, requestContext, {\n action: 'factory.agent.push',\n targets: [{ type: 'repository', id: target.repository.slug }],\n metadata: { branch, provider: target.provider.id, repository: target.repository.slug },\n });\n return { pushed: true, branch, repository: target.repository.slug };\n },\n }),\n source_control_get_change_request: createTool({\n id: 'source_control_get_change_request',\n description: `Read a pull request or merge request in the active Factory repository by its numeric repository-local ID. ${repositoryArgument}`,\n inputSchema: changeRequestSchema,\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.getPullRequest({\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n });\n },\n }),\n source_control_list_change_request_reviews: createTool({\n id: 'source_control_list_change_request_reviews',\n description: `List submitted reviews and approvals on a pull request or merge request in the active repository. ${repositoryArgument}`,\n inputSchema: changeRequestSchema.extend({ cursor: z.string().trim().min(1).optional() }),\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.listReviews({\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n ...(input.cursor !== undefined ? { cursor: input.cursor } : {}),\n });\n },\n }),\n source_control_create_change_request: createTool({\n id: 'source_control_create_change_request',\n description: `Open a pull request or merge request from the active Factory session branch into the repository's base branch (the session's persisted base branch in its own repository, the linked or default branch elsewhere). Push the branch with source_control_push_branch first. ${repositoryArgument}`,\n inputSchema: repositorySchema.extend({\n title: z.string().trim().min(1),\n body: z.string().optional(),\n draft: z.boolean().optional(),\n }),\n execute: async (input, execution) => {\n const target = await targetFor(input);\n const approvedHead = target.ownRepository ? await selfReviewApprovedHead?.() : undefined;\n if (approvedHead === null) {\n throw new Error(\n 'Self-review has not approved this branch. Move the work item to Self-review; the change request opens after it approves.',\n );\n }\n const baseBranch = target.ownRepository\n ? target.session.baseBranch\n : (target.projectRepository.branch ?? target.repository.defaultBranch);\n const created = await target.provider.versionControl.createPullRequest({\n ...(await reference(target)),\n title: input.title,\n ...(input.body !== undefined ? { body: input.body } : {}),\n baseBranch,\n headBranch: target.session.branch,\n ...(input.draft !== undefined ? { draft: input.draft } : {}),\n });\n if (approvedHead !== undefined && created.headSha.toLowerCase() !== approvedHead.toLowerCase()) {\n await target.provider.versionControl.closePullRequest({\n ...(await reference(target)),\n pullRequestId: created.id,\n });\n throw new Error(\n `Self-review approved ${approvedHead}, but the pushed branch is at ${created.headSha}; the change request was closed. Push the approved head, or move the work item back to Self-review to review the new commits.`,\n );\n }\n await target.provider.storage.sessionRepositories.upsert({\n sessionId: target.session.sessionId,\n projectRepositoryId: target.projectRepository.id,\n // Opening a change request pushes nothing: an existing row keeps its\n // `pushedAt`; the branch only seeds a row no push wrote yet.\n fallbackBranch: target.session.branch,\n changeRequestId: changeRequestId(created.id),\n changeRequestUrl: created.url,\n });\n updateSessionEnvironmentRepository(target.session.sessionId, target.repository.slug, {\n changeRequestUrl: created.url,\n });\n await emitAgentAudit(audit, requestContext, {\n action: 'factory.agent.pr_opened',\n targets: [\n { type: 'pull_request', id: created.url },\n { type: 'repository', id: target.repository.slug },\n ],\n metadata: { url: created.url, provider: target.provider.id, repository: target.repository.slug },\n });\n return created;\n },\n }),\n source_control_update_change_request: createTool({\n id: 'source_control_update_change_request',\n description: `Update the title, body, target branch, or open/closed state of a change request. ${repositoryArgument}`,\n inputSchema: changeRequestSchema.extend({\n title: z.string().trim().min(1).optional(),\n body: z.string().nullable().optional(),\n baseBranch: z.string().trim().min(1).optional(),\n state: z.enum(['open', 'closed']).optional(),\n }),\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.updatePullRequest({\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n ...(input.title !== undefined ? { title: input.title } : {}),\n ...(input.body !== undefined ? { body: input.body } : {}),\n ...(input.baseBranch !== undefined ? { baseBranch: input.baseBranch } : {}),\n ...(input.state !== undefined ? { state: input.state } : {}),\n });\n },\n }),\n source_control_comment_change_request: createTool({\n id: 'source_control_comment_change_request',\n description: `Add a top-level comment to a pull request or merge request in the active repository. ${repositoryArgument}`,\n inputSchema: changeRequestSchema.extend({ body: z.string().trim().min(1) }),\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.createComment({\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n body: input.body,\n });\n },\n }),\n source_control_list_change_request_comments: createTool({\n id: 'source_control_list_change_request_comments',\n description: `List top-level comments on a pull request or merge request in the active repository. ${repositoryArgument}`,\n inputSchema: changeRequestSchema.extend({ cursor: z.string().trim().min(1).optional() }),\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.listComments({\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n ...(input.cursor !== undefined ? { cursor: input.cursor } : {}),\n });\n },\n }),\n source_control_update_change_request_comment: createTool({\n id: 'source_control_update_change_request_comment',\n description: `Edit a top-level pull-request or merge-request comment in the active repository. ${repositoryArgument}`,\n inputSchema: repositorySchema.extend({ commentId: z.string().trim().min(1), body: z.string().trim().min(1) }),\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.updateComment({\n ...(await reference(target)),\n commentId: input.commentId,\n body: input.body,\n });\n },\n }),\n source_control_delete_change_request_comment: createTool({\n id: 'source_control_delete_change_request_comment',\n description: `Delete a top-level pull-request or merge-request comment in the active repository. ${repositoryArgument}`,\n inputSchema: repositorySchema.extend({ commentId: z.string().trim().min(1) }),\n execute: async input => {\n const target = await targetFor(input);\n await target.provider.versionControl.deleteComment({\n ...(await reference(target)),\n commentId: input.commentId,\n });\n return { deleted: true };\n },\n }),\n source_control_list_diff_comments: createTool({\n id: 'source_control_list_diff_comments',\n description: `List line-anchored review comments and discussion replies on a pull request or merge request in the active repository. ${repositoryArgument}`,\n inputSchema: changeRequestSchema.extend({ cursor: z.string().trim().min(1).optional() }),\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.listReviewComments({\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n ...(input.cursor !== undefined ? { cursor: input.cursor } : {}),\n });\n },\n }),\n source_control_create_diff_comment: createTool({\n id: 'source_control_create_diff_comment',\n description: `Create a line-anchored review comment or reply to an existing diff discussion. Use replyToId alone for a reply; otherwise provide commitId, path, line, and side. ${repositoryArgument}`,\n // A root-level union is not representable as provider function parameters, which must be\n // an object schema, so both modes share one object shape and a refinement.\n inputSchema: changeRequestSchema\n .extend({\n body: z.string().trim().min(1),\n replyToId: z.string().trim().min(1).optional(),\n commitId: z.string().trim().min(1).optional(),\n path: z.string().trim().min(1).optional(),\n line: z.number().int().positive().optional(),\n side: z.enum(['left', 'right']).optional(),\n startLine: z.number().int().positive().optional(),\n startSide: z.enum(['left', 'right']).optional(),\n })\n .refine(\n input => {\n const anchorFields = [input.commitId, input.path, input.line, input.side];\n const anchor = anchorFields.every(field => field !== undefined);\n const reply = input.replyToId !== undefined;\n return (\n (reply ? anchorFields.every(field => field === undefined) : anchor) &&\n (input.startLine === undefined) === (input.startSide === undefined)\n );\n },\n {\n message:\n 'Provide replyToId alone to reply to a diff thread, or commitId, path, line, and side to start one. startLine and startSide must be provided together.',\n },\n ),\n execute: async input => {\n const target = await targetFor(input);\n const base = {\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n body: input.body,\n };\n if (input.replyToId !== undefined) {\n return target.provider.versionControl.createReviewComment({ ...base, replyToId: input.replyToId });\n }\n if (\n input.commitId === undefined ||\n input.path === undefined ||\n input.line === undefined ||\n input.side === undefined\n ) {\n throw new Error('commitId, path, line, and side are required to start a new diff thread.');\n }\n return target.provider.versionControl.createReviewComment({\n ...base,\n commitId: input.commitId,\n path: input.path,\n line: input.line,\n side: input.side,\n ...(input.startLine !== undefined && input.startSide !== undefined\n ? { startLine: input.startLine, startSide: input.startSide }\n : {}),\n });\n },\n }),\n source_control_update_diff_comment: createTool({\n id: 'source_control_update_diff_comment',\n description: `Edit a line-anchored review comment or discussion reply in the active repository. ${repositoryArgument}`,\n inputSchema: repositorySchema.extend({ commentId: z.string().trim().min(1), body: z.string().trim().min(1) }),\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.updateReviewComment({\n ...(await reference(target)),\n commentId: input.commentId,\n body: input.body,\n });\n },\n }),\n source_control_delete_diff_comment: createTool({\n id: 'source_control_delete_diff_comment',\n description: `Delete a line-anchored review comment or discussion reply in the active repository. ${repositoryArgument}`,\n inputSchema: repositorySchema.extend({ commentId: z.string().trim().min(1) }),\n execute: async input => {\n const target = await targetFor(input);\n await target.provider.versionControl.deleteReviewComment({\n ...(await reference(target)),\n commentId: input.commentId,\n });\n return { deleted: true };\n },\n }),\n source_control_resolve_diff_thread: createTool({\n id: 'source_control_resolve_diff_thread',\n description: `Resolve or reopen the review thread containing a diff comment. Providers without resolvable threads return an explicit limitation. ${repositoryArgument}`,\n inputSchema: repositorySchema.extend({\n commentId: z.string().trim().min(1),\n resolved: z.boolean().default(true),\n }),\n execute: async input => {\n const target = await targetFor(input);\n const resolveReviewThread = target.provider.versionControl.resolveReviewThread;\n if (!resolveReviewThread) {\n throw new Error(`${target.provider.id} does not support resolving review threads.`);\n }\n await resolveReviewThread({\n ...(await reference(target)),\n commentId: input.commentId,\n resolved: input.resolved,\n });\n return { resolved: input.resolved };\n },\n }),\n source_control_review_change_request: createTool({\n id: 'source_control_review_change_request',\n description: `Submit an approve, request-changes, or comment review to a change request. Provider limitations are returned explicitly. ${repositoryArgument}`,\n inputSchema: changeRequestSchema\n .extend({\n event: z.enum(['approve', 'request-changes', 'comment']),\n body: z.string().optional(),\n commitId: z.string().trim().min(1).optional(),\n })\n .refine(input => input.event === 'approve' || Boolean(input.body?.trim()), {\n path: ['body'],\n message: 'request-changes and comment reviews require a body.',\n })\n .superRefine((input, ctx) => {\n const mismatch = verdictEventMismatch(input.event, input.body);\n if (mismatch) ctx.addIssue({ code: 'custom', path: ['body'], message: mismatch });\n const reviewedHead = reviewedHeadFromBody(input.body);\n if (reviewedHead === null) {\n ctx.addIssue({\n code: 'custom',\n path: ['body'],\n message: 'Every \"Reviewed head:\" line must name the same full 40- or 64-character commit SHA.',\n });\n } else if (reviewedHead && input.commitId && input.commitId.toLowerCase() !== reviewedHead) {\n ctx.addIssue({\n code: 'custom',\n path: ['commitId'],\n message: `Review body says \"Reviewed head: ${reviewedHead}\" but commitId is ${input.commitId}. Nothing was posted. Re-review the current head and regenerate the body before publishing.`,\n });\n }\n }),\n execute: async input => {\n const target = await targetFor(input);\n const reviewedHead = reviewedHeadFromBody(input.body);\n if (reviewedHead) {\n const pullRequest = await target.provider.versionControl.getPullRequest({\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n });\n if (!pullRequest) {\n throw new Error(`Change request ${input.changeRequestId} was not found; nothing was posted.`);\n }\n if (pullRequest.headSha && pullRequest.headSha.toLowerCase() !== reviewedHead) {\n throw new Error(\n `Review body says \"Reviewed head: ${reviewedHead}\" but the current change-request head is ${pullRequest.headSha}. Nothing was posted. Re-review the current head and regenerate the body before publishing.`,\n );\n }\n }\n const base = {\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n ...(input.commitId !== undefined\n ? { commitId: input.commitId }\n : reviewedHead\n ? { commitId: reviewedHead }\n : {}),\n };\n if (input.event === 'approve') {\n return target.provider.versionControl.createReview({\n ...base,\n event: 'approve',\n ...(input.body !== undefined ? { body: input.body } : {}),\n });\n }\n return target.provider.versionControl.createReview({ ...base, event: input.event, body: input.body! });\n },\n }),\n source_control_request_reviewers: createTool({\n id: 'source_control_request_reviewers',\n description: `Request individual or team reviewers on a pull request or merge request. Provider limitations are returned explicitly. ${repositoryArgument}`,\n inputSchema: changeRequestSchema.extend({\n users: z.array(z.string().trim().min(1)).default([]),\n teams: z.array(z.string().trim().min(1)).default([]),\n }),\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.requestReviewers({\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n users: input.users,\n teams: input.teams,\n });\n },\n }),\n source_control_merge_change_request: createTool({\n id: 'source_control_merge_change_request',\n description: `Merge a pull request or merge request using the requested provider-supported merge method. ${repositoryArgument}`,\n inputSchema: changeRequestSchema.extend({\n method: z.enum(['merge', 'squash', 'rebase']).optional(),\n commitTitle: z.string().optional(),\n commitMessage: z.string().optional(),\n }),\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.mergePullRequest({\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n ...(input.method !== undefined ? { method: input.method } : {}),\n ...(input.commitTitle !== undefined ? { commitTitle: input.commitTitle } : {}),\n ...(input.commitMessage !== undefined ? { commitMessage: input.commitMessage } : {}),\n });\n },\n }),\n };\n}\n\n/** The change request a Review run reviews, as `MastraFactory.reviewedChangeRequest()` returns it to an app tool. */\nexport interface ReviewedChangeRequest {\n /** Source-control integration id, such as `github` or `gitlab`. */\n provider: string;\n /** Repository slug, such as `acme/app`. */\n repository: string;\n /** The pull request or merge request number. */\n changeRequestId: string;\n /** The change request's head when it was read. */\n headSha: string;\n headBranch: string;\n /**\n * Publish a commit check on `headSha`. Refused, with nothing published, when\n * the change request is no longer open, `headSha` is not its current head, or\n * the provider cannot publish commit checks.\n */\n publishCommitCheck(input: PublishReviewedCommitCheckInput): Promise<CommitCheck>;\n}\n\nexport interface PublishReviewedCommitCheckInput {\n /** Full commit SHA you tested. */\n headSha: string;\n /** Publishing again with the same name updates the check. */\n name: string;\n status: CommitCheckStatus;\n title: string;\n summary: string;\n details?: string;\n}\n\n/**\n * The change request the session's Review run is bound to, read from its\n * provider. `undefined` when the session is not a Review run bound to a\n * change request.\n */\nexport async function resolveReviewedChangeRequest({\n requestContext,\n providers,\n boundChangeRequestId,\n}: {\n requestContext: RequestContext;\n providers: readonly SourceControlToolProvider[];\n boundChangeRequestId: () => Promise<string | undefined>;\n}): Promise<ReviewedChangeRequest | undefined> {\n const changeRequestId = await boundChangeRequestId();\n if (changeRequestId === undefined) return undefined;\n const target = await resolveSessionTarget(requestContext, providers);\n const ref = {\n ...(await target.provider.versionControl.getRepositoryTarget({\n orgId: target.orgId,\n repositoryId: target.repository.id,\n })),\n actingUserId: target.userId,\n };\n const read = async () => {\n const pullRequest = await target.provider.versionControl.getPullRequest({ ...ref, pullRequestId: changeRequestId });\n if (!pullRequest || pullRequest.state !== 'open') {\n throw new Error(`Change request ${changeRequestId} is not open; nothing was published.`);\n }\n return pullRequest;\n };\n const opened = await read();\n return {\n provider: target.provider.id,\n repository: target.repository.slug,\n changeRequestId,\n headSha: opened.headSha.toLowerCase(),\n headBranch: opened.headBranch,\n publishCommitCheck: async input => {\n const publish = target.provider.versionControl.publishCommitCheck;\n if (!publish) {\n throw new Error(`${target.provider.id} does not support publishing commit checks; nothing was published.`);\n }\n const current = await read();\n const headSha = input.headSha.toLowerCase();\n if (current.headSha.toLowerCase() !== headSha) {\n throw new Error(\n `headSha ${headSha} is not the current change-request head ${current.headSha}. Nothing was published.`,\n );\n }\n return publish({\n connection: ref.connection,\n sourceId: ref.sourceId,\n actingUserId: ref.actingUserId,\n headSha,\n ref: current.headBranch,\n name: input.name,\n status: input.status,\n title: input.title,\n summary: input.summary,\n ...(input.details !== undefined ? { details: input.details } : {}),\n });\n },\n };\n}\n"],"mappings":";;;;;;;;;;;AAuDA,SAAgB,qBAAqB,OAAoB,MAA8C;CACrG,MAAM,QAAQ,2DAA2D,KAAK,sBAAsB,IAAI,KAAK,EAAE;CAC/G,IAAI,CAAC,OAAO,OAAO,KAAA;CACnB,MAAM,UAAU,MAAM,OAAO,YAAY,YAAY;CAErD,MAAM,UAAyB,YAAY,YAAY,CAAC,SAAS,IAAI,CAAC,mBAAmB,SAAS;CAClG,IAAI,QAAQ,SAAS,KAAK,GAAG,OAAO,KAAA;CACpC,OAAO,oCAAoC,QAAQ,kBAAkB,MAAM,mCAAmC,QAC3G,KAAI,MAAK,IAAI,EAAE,EAAE,CAAC,CAClB,KAAK,MAAM,EAAE;AAClB;AAEA,MAAM,qBAAqB;AAC3B,MAAM,WAAW;;;;;AAMjB,SAAgB,qBAAqB,MAAqD;CACxF,MAAM,OAAO,IAAI,IACf,CAAC,IAAI,QAAQ,GAAA,CAAI,SAAS,kBAAkB,CAAC,CAAC,CAAC,KAC7C,SAAQ,SAAS,KAAK,KAAK,EAAE,CAAE,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,YAAY,KAAK,IAChE,CACF;CACA,IAAI,KAAK,SAAS,GAAG,OAAO,KAAA;CAC5B,IAAI,KAAK,OAAO,GAAG,OAAO;CAC1B,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;AACnB;AAEA,SAAS,aAAa,gBAAgC;CACpD,MAAM,OAAO,8BAA8B,cAAc;CACzD,OAAO;EAAE,OAAO,oBAAoB,IAAI;EAAG,QAAQ,qBAAqB,IAAI;CAAE;AAChF;AAEA,eAAe,uBACb,WACA,WACiF;CACjF,MAAM,WACJ,MAAM,QA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AAC,eAAe,YAAY,UAAU,QACxC,MAAM,IAAI,MAAM,kBAAkB,gBAAgB,qCAAqC;EAEzF,OAAO;CACT;CACA,MAAM,SAAS,MAAM,KAAK;CAC1B,OAAO;EACL,UAAU,OAAO,SAAS;EAC1B,YAAY,OAAO,WAAW;EAC9B;EACA,SAAS,OAAO,QAAQ,YAAY;EACpC,YAAY,OAAO;EACnB,oBAAoB,OAAM,UAAS;GACjC,MAAM,UAAU,OAAO,SAAS,eAAe;GAC/C,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,GAAG,OAAO,SAAS,GAAG,mEAAmE;GAE3G,MAAM,UAAU,MAAM,KAAK;GAC3B,MAAM,UAAU,MAAM,QAAQ,YAAY;GAC1C,IAAI,QAAQ,QAAQ,YAAY,MAAM,SACpC,MAAM,IAAI,MACR,WAAW,QAAQ,0CAA0C,QAAQ,QAAQ,yBAC/E;GAEF,OAAO,QAAQ;IACb,YAAY,IAAI;IAChB,UAAU,IAAI;IACd,cAAc,IAAI;IAClB;IACA,KAAK,QAAQ;IACb,MAAM,MAAM;IACZ,QAAQ,MAAM;IACd,OAAO,MAAM;IACb,SAAS,MAAM;IACf,GAAI,MAAM,YAAY,KAAA,IAAY,EAAE,SAAS,MAAM,QAAQ,IAAI,CAAC;GAClE,CAAC;EACH;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"source-control-tools.js","names":[],"sources":["../../src/session/source-control-tools.ts"],"sourcesContent":["import type { AgentControllerRequestContext } from '@mastra/core/agent-controller';\nimport type { RequestContext } from '@mastra/core/request-context';\nimport { createTool } from '@mastra/core/tools';\nimport type { WorkspaceSandbox } from '@mastra/core/workspace';\nimport { z } from 'zod';\n\nimport { getFactoryAuthOrgId, getFactoryAuthUserFromContext, getFactoryAuthUserId } from '../auth.js';\nimport type { CommitCheck, CommitCheckStatus, VersionControl } from '../capabilities/version-control.js';\nimport type { IntegrationTools } from '../integrations/base.js';\nimport {\n ensureLocalBranch,\n isCheckoutOf,\n pushRepositoryBranch,\n refreshMergeRequestCheckout,\n} from '../integrations/github/sandbox.js';\nimport { normalizedVerdictLine } from '../review-verdict.js';\nimport type { ExecutableSandbox } from '../sandbox/materialization.js';\nimport { resolveSessionWorkdir } from '../sandbox/session-sandbox.js';\nimport type { AuditAgentEmitter } from '../storage/domains/audit/domain.js';\nimport type {\n ProjectRepository,\n SourceControlRepository,\n SourceControlSession,\n SourceControlStorageHandle,\n} from '../storage/domains/source-control/base.js';\nimport { mergeRequestNumberFromBranch } from '../work-item-branch.js';\nimport { environmentSlugs, findEnvironmentRepository, resolveSessionRepositories } from './environment-repositories.js';\nimport { updateSessionEnvironmentRepository } from './environment-state-processor.js';\nimport type { ChangeTarget } from './self-review-gate.js';\n\ntype RepositorySessionState = {\n factoryProjectId?: string;\n projectRepositoryId?: string;\n};\n\nexport interface SourceControlToolProvider {\n id: string;\n storage: SourceControlStorageHandle;\n versionControl: VersionControl;\n}\n\ninterface SessionTarget {\n context: AgentControllerRequestContext<RepositorySessionState>;\n provider: SourceControlToolProvider;\n session: SourceControlSession;\n projectRepository: ProjectRepository;\n repository: SourceControlRepository;\n orgId: string;\n userId: string;\n /** True when the target is the link the session is filed under, the default. */\n ownRepository: boolean;\n}\n\ntype ReviewEvent = 'approve' | 'request-changes' | 'comment';\n\n/** Returns why a review's leading `Verdict:` line contradicts the submitted event, if it does. */\nexport function verdictEventMismatch(event: ReviewEvent, body: string | undefined): string | undefined {\n const match = /^verdict: ?(approve|request changes|changes requested)\\b/.exec(normalizedVerdictLine(body) ?? '');\n if (!match) return undefined;\n const verdict = match[1] === 'approve' ? 'approve' : 'request changes';\n // GitLab has no request-changes state, so a blocking verdict is published as a comment review.\n const allowed: ReviewEvent[] = verdict === 'approve' ? ['approve'] : ['request-changes', 'comment'];\n if (allowed.includes(event)) return undefined;\n return `Review body opens with \"Verdict: ${verdict}\" but event is \"${event}\". Nothing was posted. Use event ${allowed\n .map(e => `\"${e}\"`)\n .join(' or ')} for this body, or regenerate the body for the verdict you intend.`;\n}\n\nconst REVIEWED_HEAD_LINE = /^[\\s*_>-]*reviewed head[*_]*:[*_]*\\s*(.*)$/gim;\nconst FULL_SHA = /^`?([0-9a-f]{40}|[0-9a-f]{64})`?(?:\\s|$)/i;\n\n/**\n * Returns the full SHA named by the body's `Reviewed head:` lines, `null` when any line is malformed or the lines\n * disagree, or `undefined` when absent.\n */\nexport function reviewedHeadFromBody(body: string | undefined): string | null | undefined {\n const shas = new Set(\n [...(body ?? '').matchAll(REVIEWED_HEAD_LINE)].map(\n line => FULL_SHA.exec(line[1]!.trim())?.[1]?.toLowerCase() ?? null,\n ),\n );\n if (shas.size === 0) return undefined;\n if (shas.size > 1) return null;\n return [...shas][0];\n}\n\nfunction authIdentity(requestContext: RequestContext) {\n const user = getFactoryAuthUserFromContext(requestContext);\n return { orgId: getFactoryAuthOrgId(user), userId: getFactoryAuthUserId(user) };\n}\n\nasync function resolveProviderSession(\n sessionId: string,\n providers: readonly SourceControlToolProvider[],\n): Promise<{ provider: SourceControlToolProvider; session: SourceControlSession }> {\n const matches = (\n await Promise.all(\n providers.map(async provider => ({\n provider,\n session: await provider.storage.sessions.getBySessionId(sessionId),\n })),\n )\n ).filter(\n (match): match is { provider: SourceControlToolProvider; session: SourceControlSession } => match.session !== null,\n );\n if (matches.length !== 1) {\n throw new Error(\n matches.length === 0\n ? 'The active session is not backed by a source-control repository.'\n : 'The active session is ambiguous across source-control providers.',\n );\n }\n return matches[0]!;\n}\n\nasync function resolveSessionTarget(\n requestContext: RequestContext,\n providers: readonly SourceControlToolProvider[],\n options: { repository?: string } = {},\n): Promise<SessionTarget> {\n const context = requestContext.get('controller') as AgentControllerRequestContext<RepositorySessionState> | undefined;\n const { orgId, userId } = authIdentity(requestContext);\n if (!context?.sessionId || !orgId || !userId) {\n throw new Error('Source-control tools require an authenticated repository session.');\n }\n\n const { provider, session } = await resolveProviderSession(context.sessionId, providers);\n if (session.orgId !== orgId || (session.visibility === 'private' && session.userId !== userId)) {\n throw new Error('The active source-control session is not available to the authenticated user.');\n }\n const ownRepository = session.projectRepositoryId\n ? await provider.storage.projectRepositories.get({ orgId, id: session.projectRepositoryId })\n : null;\n if (!ownRepository) throw new Error('The active project repository was not found.');\n const state = context.getState();\n if (state.projectRepositoryId && state.projectRepositoryId !== ownRepository.id) {\n throw new Error('The active source-control session does not match its controller repository.');\n }\n const ownConnection = await provider.storage.connections.get({ orgId, id: ownRepository.connectionId });\n if (!ownConnection) throw new Error('The active source-control connection was not found.');\n if (state.factoryProjectId && state.factoryProjectId !== ownConnection.factoryProjectId) {\n throw new Error('The active source-control session does not match its Factory project.');\n }\n\n if (options.repository !== undefined) {\n const candidates = await resolveSessionRepositories({ sourceControl: provider.storage, session });\n const match = findEnvironmentRepository(candidates, options.repository);\n if (!match) {\n throw new Error(\n `Repository '${options.repository}' is not in this Factory's environment. Valid repositories: ${environmentSlugs(candidates).join(', ')}.`,\n );\n }\n return {\n context,\n provider,\n session,\n projectRepository: match.link,\n repository: match.repository,\n orgId,\n userId,\n ownRepository: match.link.id === ownRepository.id,\n };\n }\n\n const repository = await provider.storage.repositories.get({ orgId, id: ownRepository.repositoryId });\n if (!repository) throw new Error('The active source-control repository was not found.');\n return {\n context,\n provider,\n session,\n projectRepository: ownRepository,\n repository,\n orgId,\n userId,\n ownRepository: true,\n };\n}\n\n/**\n * The slugs a session may target and the one it is filed under, for the tool\n * descriptions. `undefined` when the session cannot be resolved; the tools\n * then describe the default without naming it.\n */\nasync function describeSessionRepositories(\n sessionId: string,\n providers: readonly SourceControlToolProvider[],\n): Promise<{ slugs: string[]; own: string | undefined } | undefined> {\n try {\n const { provider, session } = await resolveProviderSession(sessionId, providers);\n const repositories = await resolveSessionRepositories({ sourceControl: provider.storage, session });\n const own = repositories.find(candidate => candidate.link.id === session.projectRepositoryId);\n return { slugs: environmentSlugs(repositories), own: own?.repository.slug };\n } catch {\n return undefined;\n }\n}\n\nfunction repositoryArgumentDescription(described: { slugs: string[]; own: string | undefined } | undefined): string {\n if (!described || described.slugs.length === 0) {\n return \"Optional `repository` (owner/name) selects another repository of this Factory's environment; defaults to this session's repository.\";\n }\n const fallback = described.own ? `${described.own}, this session's repository` : \"this session's repository\";\n return `Optional \\`repository\\` (owner/name) selects one of this Factory's environment repositories: ${described.slugs.join(', ')}. Defaults to ${fallback}.`;\n}\n\nfunction changeRequestId(value: string | number): string {\n return String(value);\n}\n\nfunction executableSandbox(value: unknown): WorkspaceSandbox & ExecutableSandbox {\n const sandbox = value as Partial<ExecutableSandbox> | undefined;\n if (!sandbox?.executeCommand) throw new Error('The active Factory workspace has no executable sandbox.');\n return sandbox as WorkspaceSandbox & ExecutableSandbox;\n}\n\nasync function emitAgentAudit(\n audit: AuditAgentEmitter,\n requestContext: RequestContext,\n input: Parameters<AuditAgentEmitter['emitAgent']>[0]['input'],\n): Promise<void> {\n try {\n await audit.emitAgent({ requestContext, input });\n } catch (error) {\n console.warn('[Audit] Failed to record brokered source-control action', {\n action: input.action,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n}\n\nfunction changeTarget(target: SessionTarget): ChangeTarget {\n return { slug: target.repository.slug, ownRepository: target.ownRepository };\n}\n\nconst repositorySchema = z.object({ repository: z.string().trim().min(1).optional() });\nconst changeRequestSchema = repositorySchema.extend({\n changeRequestId: z.union([z.string().trim().min(1), z.number().int().positive()]),\n});\n\nexport async function createSourceControlTools({\n requestContext,\n providers,\n audit,\n workItem,\n}: {\n requestContext: RequestContext;\n providers: readonly SourceControlToolProvider[];\n audit: AuditAgentEmitter;\n /** The session's card, when it is bound to one. */\n workItem?: {\n /**\n * Self-review gate for opening a change request in `target`. `undefined` means\n * it is not gated (no Work item, another repository than the card's, or its\n * change request predates Self-review); `null` means Self-review has not\n * approved; a SHA is the approved head.\n */\n selfReviewApprovedHead(target: ChangeTarget): Promise<string | null | undefined>;\n /** Records `target` as the card's repository when the card names none. */\n recordRepository(sourceControl: SourceControlStorageHandle, target: ChangeTarget): Promise<void>;\n };\n}): Promise<IntegrationTools> {\n if (!requestContext || typeof (requestContext as { get?: unknown }).get !== 'function') return {};\n const controller = requestContext.get('controller') as\n | AgentControllerRequestContext<RepositorySessionState>\n | undefined;\n const identity = authIdentity(requestContext);\n if (!controller?.sessionId || !identity.orgId || !identity.userId || providers.length === 0) return {};\n\n const repositoryArgument = repositoryArgumentDescription(\n await describeSessionRepositories(controller.sessionId, providers),\n );\n const withTarget = (options?: { repository?: string }) => resolveSessionTarget(requestContext, providers, options);\n const targetFor = (input: { repository?: string }) =>\n withTarget(input.repository !== undefined ? { repository: input.repository } : undefined);\n const reference = async (target: SessionTarget) => ({\n ...(await target.provider.versionControl.getRepositoryTarget({\n orgId: target.orgId,\n repositoryId: target.repository.id,\n })),\n actingUserId: target.userId,\n });\n\n return {\n source_control_refresh_change_request_checkout: createTool({\n id: 'source_control_refresh_change_request_checkout',\n description:\n 'Refresh the active GitLab review session checkout to its current MR head. The MR, repository, branch, and credential are resolved server-side; no provider credentials enter the agent workspace.',\n inputSchema: z.object({}),\n execute: async (_input, { workspace }) => {\n const target = await withTarget();\n const mergeRequestNumber = mergeRequestNumberFromBranch(target.session.branch);\n if (target.provider.id !== 'gitlab' || mergeRequestNumber === undefined) {\n throw new Error('Checkout refresh is only available in a bound GitLab merge-request review session.');\n }\n const ref = await reference(target);\n const mergeRequest = await target.provider.versionControl.getPullRequest({\n ...ref,\n pullRequestId: String(mergeRequestNumber),\n });\n if (!mergeRequest || mergeRequest.state !== 'open' || mergeRequest.merged) {\n throw new Error('The bound GitLab merge request is no longer open.');\n }\n const sandbox = executableSandbox(workspace?.sandbox);\n const workdir = await resolveSessionWorkdir(target.session.id, sandbox, target.repository.slug);\n const access = await target.provider.versionControl.getRepositoryAccess({\n orgId: target.orgId,\n repositoryId: target.repository.id,\n });\n const result = await refreshMergeRequestCheckout(sandbox, workdir, {\n branch: target.session.branch,\n mergeRequestNumber,\n expectedHeadSha: mergeRequest.headSha,\n access,\n });\n return result;\n },\n }),\n source_control_push_branch: createTool({\n id: 'source_control_push_branch',\n description: `Push the active Factory session branch to its connected source-control provider. Credentials are resolved and scrubbed server-side; this tool takes no token, remote, or branch arguments. ${repositoryArgument}`,\n inputSchema: repositorySchema,\n execute: async (input, { workspace }) => {\n const target = await targetFor(input);\n const sandbox = executableSandbox(workspace?.sandbox);\n const workdir = await resolveSessionWorkdir(target.session.id, sandbox, target.repository.slug);\n const access = await target.provider.versionControl.getRepositoryAccess({\n orgId: target.orgId,\n repositoryId: target.repository.id,\n });\n // Another environment repository's directory may not be its checkout:\n // a boot skips a link whose directory name collides with another's, and\n // a session that booted single-repository has no siblings at all.\n if (!target.ownRepository && !(await isCheckoutOf(sandbox, workdir, access.cloneUrl))) {\n throw new Error(`There is no checkout of ${target.repository.slug} in this session.`);\n }\n const branch = target.session.branch;\n // Materialize the session branch at the active HEAD without discarding\n // session-only commits, so the push includes the agent's current work.\n await ensureLocalBranch(sandbox, workdir, branch);\n await pushRepositoryBranch(sandbox, workdir, branch, access, target.repository.slug);\n await target.provider.storage.sessionRepositories.upsert({\n sessionId: target.session.sessionId,\n projectRepositoryId: target.projectRepository.id,\n branch,\n });\n updateSessionEnvironmentRepository(target.session.sessionId, target.repository.slug, { branch });\n await workItem?.recordRepository(target.provider.storage, changeTarget(target));\n await emitAgentAudit(audit, requestContext, {\n action: 'factory.agent.push',\n targets: [{ type: 'repository', id: target.repository.slug }],\n metadata: { branch, provider: target.provider.id, repository: target.repository.slug },\n });\n return { pushed: true, branch, repository: target.repository.slug };\n },\n }),\n source_control_get_change_request: createTool({\n id: 'source_control_get_change_request',\n description: `Read a pull request or merge request in the active Factory repository by its numeric repository-local ID. ${repositoryArgument}`,\n inputSchema: changeRequestSchema,\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.getPullRequest({\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n });\n },\n }),\n source_control_list_change_request_reviews: createTool({\n id: 'source_control_list_change_request_reviews',\n description: `List submitted reviews and approvals on a pull request or merge request in the active repository. ${repositoryArgument}`,\n inputSchema: changeRequestSchema.extend({ cursor: z.string().trim().min(1).optional() }),\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.listReviews({\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n ...(input.cursor !== undefined ? { cursor: input.cursor } : {}),\n });\n },\n }),\n source_control_create_change_request: createTool({\n id: 'source_control_create_change_request',\n description: `Open a pull request or merge request from the active Factory session branch into the repository's base branch (the session's persisted base branch in its own repository, the linked or default branch elsewhere). Push the branch with source_control_push_branch first. ${repositoryArgument}`,\n inputSchema: repositorySchema.extend({\n title: z.string().trim().min(1),\n body: z.string().optional(),\n draft: z.boolean().optional(),\n }),\n execute: async (input, execution) => {\n const target = await targetFor(input);\n const approvedHead = await workItem?.selfReviewApprovedHead(changeTarget(target));\n if (approvedHead === null) {\n throw new Error(\n 'Self-review has not approved this branch. Move the work item to Self-review; the change request opens after it approves.',\n );\n }\n const baseBranch = target.ownRepository\n ? target.session.baseBranch\n : (target.projectRepository.branch ?? target.repository.defaultBranch);\n const created = await target.provider.versionControl.createPullRequest({\n ...(await reference(target)),\n title: input.title,\n ...(input.body !== undefined ? { body: input.body } : {}),\n baseBranch,\n headBranch: target.session.branch,\n ...(input.draft !== undefined ? { draft: input.draft } : {}),\n });\n if (approvedHead !== undefined && created.headSha.toLowerCase() !== approvedHead.toLowerCase()) {\n await target.provider.versionControl.closePullRequest({\n ...(await reference(target)),\n pullRequestId: created.id,\n });\n throw new Error(\n `Self-review approved ${approvedHead}, but the pushed branch is at ${created.headSha}; the change request was closed. Push the approved head, or move the work item back to Self-review to review the new commits.`,\n );\n }\n await target.provider.storage.sessionRepositories.upsert({\n sessionId: target.session.sessionId,\n projectRepositoryId: target.projectRepository.id,\n // Opening a change request pushes nothing: an existing row keeps its\n // `pushedAt`; the branch only seeds a row no push wrote yet.\n fallbackBranch: target.session.branch,\n changeRequestId: changeRequestId(created.id),\n changeRequestUrl: created.url,\n });\n updateSessionEnvironmentRepository(target.session.sessionId, target.repository.slug, {\n changeRequestUrl: created.url,\n });\n await workItem?.recordRepository(target.provider.storage, changeTarget(target));\n await emitAgentAudit(audit, requestContext, {\n action: 'factory.agent.pr_opened',\n targets: [\n { type: 'pull_request', id: created.url },\n { type: 'repository', id: target.repository.slug },\n ],\n metadata: { url: created.url, provider: target.provider.id, repository: target.repository.slug },\n });\n return created;\n },\n }),\n source_control_update_change_request: createTool({\n id: 'source_control_update_change_request',\n description: `Update the title, body, target branch, or open/closed state of a change request. ${repositoryArgument}`,\n inputSchema: changeRequestSchema.extend({\n title: z.string().trim().min(1).optional(),\n body: z.string().nullable().optional(),\n baseBranch: z.string().trim().min(1).optional(),\n state: z.enum(['open', 'closed']).optional(),\n }),\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.updatePullRequest({\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n ...(input.title !== undefined ? { title: input.title } : {}),\n ...(input.body !== undefined ? { body: input.body } : {}),\n ...(input.baseBranch !== undefined ? { baseBranch: input.baseBranch } : {}),\n ...(input.state !== undefined ? { state: input.state } : {}),\n });\n },\n }),\n source_control_comment_change_request: createTool({\n id: 'source_control_comment_change_request',\n description: `Add a top-level comment to a pull request or merge request in the active repository. ${repositoryArgument}`,\n inputSchema: changeRequestSchema.extend({ body: z.string().trim().min(1) }),\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.createComment({\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n body: input.body,\n });\n },\n }),\n source_control_list_change_request_comments: createTool({\n id: 'source_control_list_change_request_comments',\n description: `List top-level comments on a pull request or merge request in the active repository. ${repositoryArgument}`,\n inputSchema: changeRequestSchema.extend({ cursor: z.string().trim().min(1).optional() }),\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.listComments({\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n ...(input.cursor !== undefined ? { cursor: input.cursor } : {}),\n });\n },\n }),\n source_control_update_change_request_comment: createTool({\n id: 'source_control_update_change_request_comment',\n description: `Edit a top-level pull-request or merge-request comment in the active repository. ${repositoryArgument}`,\n inputSchema: repositorySchema.extend({ commentId: z.string().trim().min(1), body: z.string().trim().min(1) }),\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.updateComment({\n ...(await reference(target)),\n commentId: input.commentId,\n body: input.body,\n });\n },\n }),\n source_control_delete_change_request_comment: createTool({\n id: 'source_control_delete_change_request_comment',\n description: `Delete a top-level pull-request or merge-request comment in the active repository. ${repositoryArgument}`,\n inputSchema: repositorySchema.extend({ commentId: z.string().trim().min(1) }),\n execute: async input => {\n const target = await targetFor(input);\n await target.provider.versionControl.deleteComment({\n ...(await reference(target)),\n commentId: input.commentId,\n });\n return { deleted: true };\n },\n }),\n source_control_list_diff_comments: createTool({\n id: 'source_control_list_diff_comments',\n description: `List line-anchored review comments and discussion replies on a pull request or merge request in the active repository. ${repositoryArgument}`,\n inputSchema: changeRequestSchema.extend({ cursor: z.string().trim().min(1).optional() }),\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.listReviewComments({\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n ...(input.cursor !== undefined ? { cursor: input.cursor } : {}),\n });\n },\n }),\n source_control_create_diff_comment: createTool({\n id: 'source_control_create_diff_comment',\n description: `Create a line-anchored review comment or reply to an existing diff discussion. Use replyToId alone for a reply; otherwise provide commitId, path, line, and side. ${repositoryArgument}`,\n // A root-level union is not representable as provider function parameters, which must be\n // an object schema, so both modes share one object shape and a refinement.\n inputSchema: changeRequestSchema\n .extend({\n body: z.string().trim().min(1),\n replyToId: z.string().trim().min(1).optional(),\n commitId: z.string().trim().min(1).optional(),\n path: z.string().trim().min(1).optional(),\n line: z.number().int().positive().optional(),\n side: z.enum(['left', 'right']).optional(),\n startLine: z.number().int().positive().optional(),\n startSide: z.enum(['left', 'right']).optional(),\n })\n .refine(\n input => {\n const anchorFields = [input.commitId, input.path, input.line, input.side];\n const anchor = anchorFields.every(field => field !== undefined);\n const reply = input.replyToId !== undefined;\n return (\n (reply ? anchorFields.every(field => field === undefined) : anchor) &&\n (input.startLine === undefined) === (input.startSide === undefined)\n );\n },\n {\n message:\n 'Provide replyToId alone to reply to a diff thread, or commitId, path, line, and side to start one. startLine and startSide must be provided together.',\n },\n ),\n execute: async input => {\n const target = await targetFor(input);\n const base = {\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n body: input.body,\n };\n if (input.replyToId !== undefined) {\n return target.provider.versionControl.createReviewComment({ ...base, replyToId: input.replyToId });\n }\n if (\n input.commitId === undefined ||\n input.path === undefined ||\n input.line === undefined ||\n input.side === undefined\n ) {\n throw new Error('commitId, path, line, and side are required to start a new diff thread.');\n }\n return target.provider.versionControl.createReviewComment({\n ...base,\n commitId: input.commitId,\n path: input.path,\n line: input.line,\n side: input.side,\n ...(input.startLine !== undefined && input.startSide !== undefined\n ? { startLine: input.startLine, startSide: input.startSide }\n : {}),\n });\n },\n }),\n source_control_update_diff_comment: createTool({\n id: 'source_control_update_diff_comment',\n description: `Edit a line-anchored review comment or discussion reply in the active repository. ${repositoryArgument}`,\n inputSchema: repositorySchema.extend({ commentId: z.string().trim().min(1), body: z.string().trim().min(1) }),\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.updateReviewComment({\n ...(await reference(target)),\n commentId: input.commentId,\n body: input.body,\n });\n },\n }),\n source_control_delete_diff_comment: createTool({\n id: 'source_control_delete_diff_comment',\n description: `Delete a line-anchored review comment or discussion reply in the active repository. ${repositoryArgument}`,\n inputSchema: repositorySchema.extend({ commentId: z.string().trim().min(1) }),\n execute: async input => {\n const target = await targetFor(input);\n await target.provider.versionControl.deleteReviewComment({\n ...(await reference(target)),\n commentId: input.commentId,\n });\n return { deleted: true };\n },\n }),\n source_control_resolve_diff_thread: createTool({\n id: 'source_control_resolve_diff_thread',\n description: `Resolve or reopen the review thread containing a diff comment. Providers without resolvable threads return an explicit limitation. ${repositoryArgument}`,\n inputSchema: repositorySchema.extend({\n commentId: z.string().trim().min(1),\n resolved: z.boolean().default(true),\n }),\n execute: async input => {\n const target = await targetFor(input);\n const resolveReviewThread = target.provider.versionControl.resolveReviewThread;\n if (!resolveReviewThread) {\n throw new Error(`${target.provider.id} does not support resolving review threads.`);\n }\n await resolveReviewThread({\n ...(await reference(target)),\n commentId: input.commentId,\n resolved: input.resolved,\n });\n return { resolved: input.resolved };\n },\n }),\n source_control_review_change_request: createTool({\n id: 'source_control_review_change_request',\n description: `Submit an approve, request-changes, or comment review to a change request. Provider limitations are returned explicitly. ${repositoryArgument}`,\n inputSchema: changeRequestSchema\n .extend({\n event: z.enum(['approve', 'request-changes', 'comment']),\n body: z.string().optional(),\n commitId: z.string().trim().min(1).optional(),\n })\n .refine(input => input.event === 'approve' || Boolean(input.body?.trim()), {\n path: ['body'],\n message: 'request-changes and comment reviews require a body.',\n })\n .superRefine((input, ctx) => {\n const mismatch = verdictEventMismatch(input.event, input.body);\n if (mismatch) ctx.addIssue({ code: 'custom', path: ['body'], message: mismatch });\n const reviewedHead = reviewedHeadFromBody(input.body);\n if (reviewedHead === null) {\n ctx.addIssue({\n code: 'custom',\n path: ['body'],\n message: 'Every \"Reviewed head:\" line must name the same full 40- or 64-character commit SHA.',\n });\n } else if (reviewedHead && input.commitId && input.commitId.toLowerCase() !== reviewedHead) {\n ctx.addIssue({\n code: 'custom',\n path: ['commitId'],\n message: `Review body says \"Reviewed head: ${reviewedHead}\" but commitId is ${input.commitId}. Nothing was posted. Re-review the current head and regenerate the body before publishing.`,\n });\n }\n }),\n execute: async input => {\n const target = await targetFor(input);\n const reviewedHead = reviewedHeadFromBody(input.body);\n if (reviewedHead) {\n const pullRequest = await target.provider.versionControl.getPullRequest({\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n });\n if (!pullRequest) {\n throw new Error(`Change request ${input.changeRequestId} was not found; nothing was posted.`);\n }\n if (pullRequest.headSha && pullRequest.headSha.toLowerCase() !== reviewedHead) {\n throw new Error(\n `Review body says \"Reviewed head: ${reviewedHead}\" but the current change-request head is ${pullRequest.headSha}. Nothing was posted. Re-review the current head and regenerate the body before publishing.`,\n );\n }\n }\n const base = {\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n ...(input.commitId !== undefined\n ? { commitId: input.commitId }\n : reviewedHead\n ? { commitId: reviewedHead }\n : {}),\n };\n if (input.event === 'approve') {\n return target.provider.versionControl.createReview({\n ...base,\n event: 'approve',\n ...(input.body !== undefined ? { body: input.body } : {}),\n });\n }\n return target.provider.versionControl.createReview({ ...base, event: input.event, body: input.body! });\n },\n }),\n source_control_request_reviewers: createTool({\n id: 'source_control_request_reviewers',\n description: `Request individual or team reviewers on a pull request or merge request. Provider limitations are returned explicitly. ${repositoryArgument}`,\n inputSchema: changeRequestSchema.extend({\n users: z.array(z.string().trim().min(1)).default([]),\n teams: z.array(z.string().trim().min(1)).default([]),\n }),\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.requestReviewers({\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n users: input.users,\n teams: input.teams,\n });\n },\n }),\n source_control_merge_change_request: createTool({\n id: 'source_control_merge_change_request',\n description: `Merge a pull request or merge request using the requested provider-supported merge method. ${repositoryArgument}`,\n inputSchema: changeRequestSchema.extend({\n method: z.enum(['merge', 'squash', 'rebase']).optional(),\n commitTitle: z.string().optional(),\n commitMessage: z.string().optional(),\n }),\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.mergePullRequest({\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n ...(input.method !== undefined ? { method: input.method } : {}),\n ...(input.commitTitle !== undefined ? { commitTitle: input.commitTitle } : {}),\n ...(input.commitMessage !== undefined ? { commitMessage: input.commitMessage } : {}),\n });\n },\n }),\n };\n}\n\n/** The change request a Review run reviews, as `MastraFactory.reviewedChangeRequest()` returns it to an app tool. */\nexport interface ReviewedChangeRequest {\n /** Source-control integration id, such as `github` or `gitlab`. */\n provider: string;\n /** Repository slug, such as `acme/app`. */\n repository: string;\n /** The pull request or merge request number. */\n changeRequestId: string;\n /** The change request's head when it was read. */\n headSha: string;\n headBranch: string;\n /**\n * Publish a commit check on `headSha`. Refused, with nothing published, when\n * the change request is no longer open, `headSha` is not its current head, or\n * the provider cannot publish commit checks.\n */\n publishCommitCheck(input: PublishReviewedCommitCheckInput): Promise<CommitCheck>;\n}\n\nexport interface PublishReviewedCommitCheckInput {\n /** Full commit SHA you tested. */\n headSha: string;\n /** Publishing again with the same name updates the check. */\n name: string;\n status: CommitCheckStatus;\n title: string;\n summary: string;\n details?: string;\n}\n\n/**\n * The change request the session's Review run is bound to, read from its\n * provider. `undefined` when the session is not a Review run bound to a\n * change request.\n */\nexport async function resolveReviewedChangeRequest({\n requestContext,\n providers,\n boundChangeRequestId,\n}: {\n requestContext: RequestContext;\n providers: readonly SourceControlToolProvider[];\n boundChangeRequestId: () => Promise<string | undefined>;\n}): Promise<ReviewedChangeRequest | undefined> {\n const changeRequestId = await boundChangeRequestId();\n if (changeRequestId === undefined) return undefined;\n const target = await resolveSessionTarget(requestContext, providers);\n const ref = {\n ...(await target.provider.versionControl.getRepositoryTarget({\n orgId: target.orgId,\n repositoryId: target.repository.id,\n })),\n actingUserId: target.userId,\n };\n const read = async () => {\n const pullRequest = await target.provider.versionControl.getPullRequest({ ...ref, pullRequestId: changeRequestId });\n if (!pullRequest || pullRequest.state !== 'open') {\n throw new Error(`Change request ${changeRequestId} is not open; nothing was published.`);\n }\n return pullRequest;\n };\n const opened = await read();\n return {\n provider: target.provider.id,\n repository: target.repository.slug,\n changeRequestId,\n headSha: opened.headSha.toLowerCase(),\n headBranch: opened.headBranch,\n publishCommitCheck: async input => {\n const publish = target.provider.versionControl.publishCommitCheck;\n if (!publish) {\n throw new Error(`${target.provider.id} does not support publishing commit checks; nothing was published.`);\n }\n const current = await read();\n const headSha = input.headSha.toLowerCase();\n if (current.headSha.toLowerCase() !== headSha) {\n throw new Error(\n `headSha ${headSha} is not the current change-request head ${current.headSha}. Nothing was published.`,\n );\n }\n return publish({\n connection: ref.connection,\n sourceId: ref.sourceId,\n actingUserId: ref.actingUserId,\n headSha,\n ref: current.headBranch,\n name: input.name,\n status: input.status,\n title: input.title,\n summary: input.summary,\n ...(input.details !== undefined ? { details: input.details } : {}),\n });\n },\n };\n}\n"],"mappings":";;;;;;;;;;;AAwDA,SAAgB,qBAAqB,OAAoB,MAA8C;CACrG,MAAM,QAAQ,2DAA2D,KAAK,sBAAsB,IAAI,KAAK,EAAE;CAC/G,IAAI,CAAC,OAAO,OAAO,KAAA;CACnB,MAAM,UAAU,MAAM,OAAO,YAAY,YAAY;CAErD,MAAM,UAAyB,YAAY,YAAY,CAAC,SAAS,IAAI,CAAC,mBAAmB,SAAS;CAClG,IAAI,QAAQ,SAAS,KAAK,GAAG,OAAO,KAAA;CACpC,OAAO,oCAAoC,QAAQ,kBAAkB,MAAM,mCAAmC,QAC3G,KAAI,MAAK,IAAI,EAAE,EAAE,CAAC,CAClB,KAAK,MAAM,EAAE;AAClB;AAEA,MAAM,qBAAqB;AAC3B,MAAM,WAAW;;;;;AAMjB,SAAgB,qBAAqB,MAAqD;CACxF,MAAM,OAAO,IAAI,IACf,CAAC,IAAI,QAAQ,GAAA,CAAI,SAAS,kBAAkB,CAAC,CAAC,CAAC,KAC7C,SAAQ,SAAS,KAAK,KAAK,EAAE,CAAE,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,YAAY,KAAK,IAChE,CACF;CACA,IAAI,KAAK,SAAS,GAAG,OAAO,KAAA;CAC5B,IAAI,KAAK,OAAO,GAAG,OAAO;CAC1B,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;AACnB;AAEA,SAAS,aAAa,gBAAgC;CACpD,MAAM,OAAO,8BAA8B,cAAc;CACzD,OAAO;EAAE,OAAO,oBAAoB,IAAI;EAAG,QAAQ,qBAAqB,IAAI;CAAE;AAChF;AAEA,eAAe,u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ACnE,MAAM,MAAM;EACV,GAAI,MAAM,OAAO,SAAS,eAAe,oBAAoB;GAC3D,OAAO,OAAO;GACd,cAAc,OAAO,WAAW;EAClC,CAAC;EACD,cAAc,OAAO;CACvB;CACA,MAAM,OAAO,YAAY;EACvB,MAAM,cAAc,MAAM,OAAO,SAAS,eAAe,eAAe;GAAE,GAAG;GAAK,eAAe;EAAgB,CAAC;EAClH,IAAI,CAAC,eAAe,YAAY,UAAU,QACxC,MAAM,IAAI,MAAM,kBAAkB,gBAAgB,qCAAqC;EAEzF,OAAO;CACT;CACA,MAAM,SAAS,MAAM,KAAK;CAC1B,OAAO;EACL,UAAU,OAAO,SAAS;EAC1B,YAAY,OAAO,WAAW;EAC9B;EACA,SAAS,OAAO,QAAQ,YAAY;EACpC,YAAY,OAAO;EACnB,oBAAoB,OAAM,UAAS;GACjC,MAAM,UAAU,OAAO,SAAS,eAAe;GAC/C,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,GAAG,OAAO,SAAS,GAAG,mEAAmE;GAE3G,MAAM,UAAU,MAAM,KAAK;GAC3B,MAAM,UAAU,MAAM,QAAQ,YAAY;GAC1C,IAAI,QAAQ,QAAQ,YAAY,MAAM,SACpC,MAAM,IAAI,MACR,WAAW,QAAQ,0CAA0C,QAAQ,QAAQ,yBAC/E;GAEF,OAAO,QAAQ;IACb,YAAY,IAAI;IAChB,UAAU,IAAI;IACd,cAAc,IAAI;IAClB;IACA,KAAK,QAAQ;IACb,MAAM,MAAM;IACZ,QAAQ,MAAM;IACd,OAAO,MAAM;IACb,SAAS,MAAM;IACf,GAAI,MAAM,YAAY,KAAA,IAAY,EAAE,SAAS,MAAM,QAAQ,IAAI,CAAC;GAClE,CAAC;EACH;CACF;AACF"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { IntakeStorage } from '../storage/domains/intake/base.js';
|
|
1
2
|
import type { SourceControlStorageHandle } from '../storage/domains/source-control/base.js';
|
|
2
3
|
import type { Card } from '../storage/domains/work-items/base.js';
|
|
3
4
|
export type WorkItemRepositoryResolution = {
|
|
@@ -16,8 +17,55 @@ export declare function resolveWorkItemRepository(args: {
|
|
|
16
17
|
orgId: string;
|
|
17
18
|
factoryProjectId: string;
|
|
18
19
|
item: Pick<Card, 'metadata'> & {
|
|
19
|
-
workItem: Pick<Card['workItem'], 'metadata'
|
|
20
|
+
workItem: Pick<Card['workItem'], 'metadata'> & {
|
|
21
|
+
url?: string | null;
|
|
22
|
+
};
|
|
20
23
|
};
|
|
21
24
|
linearRepositoryMap?: Record<string, string>;
|
|
22
25
|
}): Promise<WorkItemRepositoryResolution>;
|
|
26
|
+
export type RunRepositoryResolution = {
|
|
27
|
+
status: 'resolved';
|
|
28
|
+
projectRepositoryId: string;
|
|
29
|
+
slug: string;
|
|
30
|
+
/**
|
|
31
|
+
* Set when the card names no repository: the sandbox repositories its
|
|
32
|
+
* agent chooses among. The run is filed under `slug` until it does.
|
|
33
|
+
*/
|
|
34
|
+
unnamed?: {
|
|
35
|
+
repositories: string[];
|
|
36
|
+
};
|
|
37
|
+
} | {
|
|
38
|
+
status: 'unlinked';
|
|
39
|
+
hint: string;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Where a run on `item` is filed. A card that names its repository resolves
|
|
43
|
+
* exactly as {@link resolveWorkItemRepository} does. A card that names none
|
|
44
|
+
* among several repositories is not refused: the sandbox holds every
|
|
45
|
+
* environment repository, so the run stays in `boundProjectRepositoryId` (the
|
|
46
|
+
* session already working on the card) or else in the environment's first
|
|
47
|
+
* repository, and its agent determines which repository the card belongs to.
|
|
48
|
+
*/
|
|
49
|
+
export declare function resolveRunRepository(args: Parameters<typeof resolveWorkItemRepository>[0] & {
|
|
50
|
+
boundProjectRepositoryId?: string;
|
|
51
|
+
}): Promise<RunRepositoryResolution>;
|
|
52
|
+
export declare function resolveRunRepositoryFromIntake(intake: Pick<IntakeStorage, 'getConfig'> | undefined, args: Omit<Parameters<typeof resolveRunRepository>[0], 'linearRepositoryMap'>): Promise<RunRepositoryResolution>;
|
|
53
|
+
/** Card metadata recording the `repository` a run chose for a card that named none. */
|
|
54
|
+
export declare const REPOSITORY_CHOICE_KEY = "repositoryChoice";
|
|
55
|
+
/**
|
|
56
|
+
* Whether a run recorded `slug` as the card's repository. Every role session
|
|
57
|
+
* on the card was filed before it named a repository, so under another one;
|
|
58
|
+
* they may keep working on the card, in `slug`. A repository set any other
|
|
59
|
+
* way (intake, a person) no longer matches the recorded choice and still
|
|
60
|
+
* refuses a session filed elsewhere.
|
|
61
|
+
*/
|
|
62
|
+
export declare function repositoryChosenByRun(item: Pick<Card, 'metadata'>, slug: string): boolean;
|
|
63
|
+
/** The plugin instruction telling a run's agent which repository it works in. */
|
|
64
|
+
export declare function runRepositoryInstruction(repository: {
|
|
65
|
+
slug: string;
|
|
66
|
+
unnamed?: {
|
|
67
|
+
repositories: string[];
|
|
68
|
+
};
|
|
69
|
+
}, ownSlug: string): string;
|
|
70
|
+
export declare function isRunRepositoryInstruction(instruction: string): boolean;
|
|
23
71
|
//# sourceMappingURL=work-item-repository.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"work-item-repository.d.ts","sourceRoot":"","sources":["../../src/session/work-item-repository.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"work-item-repository.d.ts","sourceRoot":"","sources":["../../src/session/work-item-repository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAEvE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AAC5F,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uCAAuC,CAAC;AAGlE,MAAM,MAAM,4BAA4B,GACpC;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,mBAAmB,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACjE;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,MA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EAAE,qBAAqB,CAAC,GAC5E,OAAO,CAAC,uBAAuB,CAAC,CAGlC;AAED,uFAAuF;AACvF,eAAO,MAAM,qBAAqB,qBAAqB,CAAC;AAExD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAIzF;AAID,iFAAiF;AACjF,wBAAgB,wBAAwB,CACtC,UAAU,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE;QAAE,YAAY,EAAE,MAAM,EAAE,CAAA;KAAE,CAAA;CAAE,EAClE,OAAO,EAAE,MAAM,GACd,MAAM,CASR;AAED,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAEvE"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SourceControlConnectionNotFoundError } from "../storage/domains/source-control/base.js";
|
|
2
|
+
import { resolveEnvironmentRepositories } from "./environment-repositories.js";
|
|
2
3
|
// src/session/work-item-repository.ts
|
|
3
4
|
async function listLinkedRepositories(args) {
|
|
4
5
|
const { sourceControl, orgId, factoryProjectId } = args;
|
|
@@ -30,19 +31,21 @@ async function listLinkedRepositories(args) {
|
|
|
30
31
|
}
|
|
31
32
|
return linked;
|
|
32
33
|
}
|
|
34
|
+
const PROVIDER_REPOSITORY_IDS = /* @__PURE__ */ new Map([["github", {
|
|
35
|
+
key: "githubRepositoryId",
|
|
36
|
+
label: "GitHub"
|
|
37
|
+
}], ["gitlab", {
|
|
38
|
+
key: "gitlabProjectId",
|
|
39
|
+
label: "GitLab"
|
|
40
|
+
}]]);
|
|
33
41
|
function getExternalRepositoryId(integrationId, metadata) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
case "github":
|
|
37
|
-
id = metadata.githubRepositoryId;
|
|
38
|
-
break;
|
|
39
|
-
case "gitlab":
|
|
40
|
-
id = metadata.gitlabProjectId;
|
|
41
|
-
break;
|
|
42
|
-
default: return;
|
|
43
|
-
}
|
|
42
|
+
const provider = PROVIDER_REPOSITORY_IDS.get(integrationId);
|
|
43
|
+
const id = provider ? metadata[provider.key] : void 0;
|
|
44
44
|
return id == null ? void 0 : String(id);
|
|
45
45
|
}
|
|
46
|
+
function otherProviderLabel(integrationId, metadata) {
|
|
47
|
+
for (const [id, provider] of PROVIDER_REPOSITORY_IDS) if (id !== integrationId && metadata[provider.key] != null) return provider.label;
|
|
48
|
+
}
|
|
46
49
|
/**
|
|
47
50
|
* The one link among `matches` a run can use. A repository can be linked more
|
|
48
51
|
* than once (a provider-app reinstall adds a second link for the same slug),
|
|
@@ -65,6 +68,10 @@ function resolvedRepository(repository) {
|
|
|
65
68
|
slug: repository.slug
|
|
66
69
|
};
|
|
67
70
|
}
|
|
71
|
+
const PROVIDER_ITEM_URL = /^https?:\/\/[^/]+\/(.+?)(?:\/-)?\/(?:issues|pull|merge_requests)\/\d+(?:[/?#]|$)/;
|
|
72
|
+
function repositoryNameFromUrl(url) {
|
|
73
|
+
return url ? PROVIDER_ITEM_URL.exec(url)?.[1] : void 0;
|
|
74
|
+
}
|
|
68
75
|
async function resolveWorkItemRepository(args) {
|
|
69
76
|
const { sourceControl, item, linearRepositoryMap } = args;
|
|
70
77
|
const metadata = item.workItem.metadata ?? {};
|
|
@@ -77,6 +84,11 @@ async function resolveWorkItemRepository(args) {
|
|
|
77
84
|
const match = pickLink(linked.filter((repository) => repository.externalId === externalRepositorySignal));
|
|
78
85
|
if (match) return resolvedRepository(match);
|
|
79
86
|
}
|
|
87
|
+
const otherProvider = externalRepositorySignal === void 0 ? otherProviderLabel(sourceControl.integrationId, metadata) : void 0;
|
|
88
|
+
if (otherProvider !== void 0) return {
|
|
89
|
+
status: "unlinked",
|
|
90
|
+
hint: `This card comes from ${otherProvider}, and no ${otherProvider} repository is linked to this Factory.`
|
|
91
|
+
};
|
|
80
92
|
if (repositorySignal) {
|
|
81
93
|
const match = findRepositoryBySlug(linked, repositorySignal);
|
|
82
94
|
return match ? resolvedRepository(match) : {
|
|
@@ -84,10 +96,13 @@ async function resolveWorkItemRepository(args) {
|
|
|
84
96
|
hint: `Repository ${repositorySignal} is not linked to this Factory.`
|
|
85
97
|
};
|
|
86
98
|
}
|
|
87
|
-
if (externalRepositorySignal !== void 0)
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
99
|
+
if (externalRepositorySignal !== void 0) {
|
|
100
|
+
const name = repositoryNameFromUrl(item.workItem.url);
|
|
101
|
+
return {
|
|
102
|
+
status: "unlinked",
|
|
103
|
+
hint: name ? `Repository ${name} is not linked to this Factory.` : `Source-control repository ${externalRepositorySignal} is not linked to this Factory.`
|
|
104
|
+
};
|
|
105
|
+
}
|
|
91
106
|
if (mappedRepository) {
|
|
92
107
|
const match = findRepositoryBySlug(linked, mappedRepository);
|
|
93
108
|
return match ? resolvedRepository(match) : {
|
|
@@ -107,6 +122,94 @@ async function resolveWorkItemRepository(args) {
|
|
|
107
122
|
candidates
|
|
108
123
|
};
|
|
109
124
|
}
|
|
110
|
-
|
|
125
|
+
/**
|
|
126
|
+
* Where a run on `item` is filed. A card that names its repository resolves
|
|
127
|
+
* exactly as {@link resolveWorkItemRepository} does. A card that names none
|
|
128
|
+
* among several repositories is not refused: the sandbox holds every
|
|
129
|
+
* environment repository, so the run stays in `boundProjectRepositoryId` (the
|
|
130
|
+
* session already working on the card) or else in the environment's first
|
|
131
|
+
* repository, and its agent determines which repository the card belongs to.
|
|
132
|
+
*/
|
|
133
|
+
async function resolveRunRepository(args) {
|
|
134
|
+
const resolution = await resolveWorkItemRepository(args);
|
|
135
|
+
if (resolution.status !== "ambiguous") return resolution;
|
|
136
|
+
const { sourceControl, orgId, factoryProjectId, boundProjectRepositoryId } = args;
|
|
137
|
+
const environment = await resolveEnvironmentRepositories({
|
|
138
|
+
sourceControl,
|
|
139
|
+
orgId,
|
|
140
|
+
factoryProjectId
|
|
141
|
+
});
|
|
142
|
+
const unnamed = { repositories: environment.map((entry) => entry.repository.slug) };
|
|
143
|
+
if (boundProjectRepositoryId !== void 0) {
|
|
144
|
+
const link = await sourceControl.projectRepositories.get({
|
|
145
|
+
orgId,
|
|
146
|
+
id: boundProjectRepositoryId
|
|
147
|
+
});
|
|
148
|
+
const linked = link && await sourceControl.repositories.get({
|
|
149
|
+
orgId,
|
|
150
|
+
id: link.repositoryId
|
|
151
|
+
});
|
|
152
|
+
const currentLinks = link ? await sourceControl.projectRepositories.list({
|
|
153
|
+
orgId,
|
|
154
|
+
connectionId: link.connectionId
|
|
155
|
+
}) : [];
|
|
156
|
+
if (!linked || !resolution.candidates.includes(linked.slug) || !currentLinks.some((candidate) => candidate.id === boundProjectRepositoryId)) return {
|
|
157
|
+
status: "unlinked",
|
|
158
|
+
hint: "The existing session repository is not linked to this Factory."
|
|
159
|
+
};
|
|
160
|
+
return {
|
|
161
|
+
status: "resolved",
|
|
162
|
+
projectRepositoryId: boundProjectRepositoryId,
|
|
163
|
+
slug: linked.slug,
|
|
164
|
+
unnamed
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
const primary = environment[0];
|
|
168
|
+
if (!primary) return {
|
|
169
|
+
status: "unlinked",
|
|
170
|
+
hint: "None of the repositories linked to this Factory is in its environment."
|
|
171
|
+
};
|
|
172
|
+
return {
|
|
173
|
+
status: "resolved",
|
|
174
|
+
projectRepositoryId: primary.link.id,
|
|
175
|
+
slug: primary.repository.slug,
|
|
176
|
+
unnamed
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
async function resolveRunRepositoryFromIntake(intake, args) {
|
|
180
|
+
const intakeConfig = await intake?.getConfig({
|
|
181
|
+
orgId: args.orgId,
|
|
182
|
+
integrationIds: ["linear"]
|
|
183
|
+
});
|
|
184
|
+
return resolveRunRepository({
|
|
185
|
+
...args,
|
|
186
|
+
linearRepositoryMap: intakeConfig?.linear?.repositoryByLinearProject
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
/** Card metadata recording the `repository` a run chose for a card that named none. */
|
|
190
|
+
const REPOSITORY_CHOICE_KEY = "repositoryChoice";
|
|
191
|
+
/**
|
|
192
|
+
* Whether a run recorded `slug` as the card's repository. Every role session
|
|
193
|
+
* on the card was filed before it named a repository, so under another one;
|
|
194
|
+
* they may keep working on the card, in `slug`. A repository set any other
|
|
195
|
+
* way (intake, a person) no longer matches the recorded choice and still
|
|
196
|
+
* refuses a session filed elsewhere.
|
|
197
|
+
*/
|
|
198
|
+
function repositoryChosenByRun(item, slug) {
|
|
199
|
+
const choice = item.metadata?.[REPOSITORY_CHOICE_KEY];
|
|
200
|
+
if (typeof choice !== "object" || choice === null) return false;
|
|
201
|
+
return item.metadata?.repository === slug && choice.slug === slug;
|
|
202
|
+
}
|
|
203
|
+
const UNNAMED_REPOSITORY_INSTRUCTION = "This card names no repository.";
|
|
204
|
+
/** The plugin instruction telling a run's agent which repository it works in. */
|
|
205
|
+
function runRepositoryInstruction(repository, ownSlug) {
|
|
206
|
+
if (repository.unnamed) return `${UNNAMED_REPOSITORY_INSTRUCTION} This session's sandbox holds ${repository.unnamed.repositories.join(", ")}. Before editing files, determine from the card which of them it belongs to and work in that repository's checkout; pass it as \`repository\` to the source_control_* tools (they default to ${ownSlug}). The first push or change request records it on the card. If the card belongs to none of them, stop and say so.`;
|
|
207
|
+
const elsewhere = repository.slug === ownSlug ? "" : ` This session is filed under ${ownSlug}, so pass \`repository: ${repository.slug}\` to the source_control_* tools.`;
|
|
208
|
+
return `Target repository: ${repository.slug}. Before editing files or creating a pull request, verify this session's checkout matches the target repository.${elsewhere}`;
|
|
209
|
+
}
|
|
210
|
+
function isRunRepositoryInstruction(instruction) {
|
|
211
|
+
return instruction.startsWith("Target repository: ") || instruction.startsWith(UNNAMED_REPOSITORY_INSTRUCTION);
|
|
212
|
+
}
|
|
213
|
+
export { REPOSITORY_CHOICE_KEY, isRunRepositoryInstruction, repositoryChosenByRun, resolveRunRepository, resolveRunRepositoryFromIntake, resolveWorkItemRepository, runRepositoryInstruction };
|
|
111
214
|
|
|
112
215
|
//# sourceMappingURL=work-item-repository.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"work-item-repository.js","names":[],"sources":["../../src/session/work-item-repository.ts"],"sourcesContent":["import { SourceControlConnectionNotFoundError } from '../storage/domains/source-control/base.js';\nimport type { SourceControlStorageHandle } from '../storage/domains/source-control/base.js';\nimport type { Card } from '../storage/domains/work-items/base.js';\n\nexport type WorkItemRepositoryResolution =\n | { status: 'resolved'; projectRepositoryId: string; slug: string }\n | { status: 'unlinked'; hint: string }\n | { status: 'ambiguous'; candidates: string[] };\n\ninterface LinkedRepository {\n projectRepositoryId: string;\n externalId: string;\n slug: string;\n inEnvironment: boolean;\n}\n\nasync function listLinkedRepositories(args: {\n sourceControl: SourceControlStorageHandle;\n orgId: string;\n factoryProjectId: string;\n}): Promise<LinkedRepository[]> {\n const { sourceControl, orgId, factoryProjectId } = args;\n const connections = await sourceControl.connections.list({ orgId, factoryProjectId });\n const linked: LinkedRepository[] = [];\n\n for (const connection of connections.filter(candidate => candidate.integrationId === sourceControl.integrationId)) {\n try {\n const projectRepositories = await sourceControl.projectRepositories.list({ orgId, connectionId: connection.id });\n const repositories = await Promise.all(\n projectRepositories.map(async projectRepository => ({\n projectRepository,\n repository: await sourceControl.repositories.get({ orgId, id: projectRepository.repositoryId }),\n })),\n );\n for (const { projectRepository, repository } of repositories) {\n if (repository) {\n linked.push({\n projectRepositoryId: projectRepository.id,\n externalId: repository.externalId,\n slug: repository.slug,\n inEnvironment: projectRepository.inEnvironment,\n });\n }\n }\n } catch (error) {\n if (!(error instanceof SourceControlConnectionNotFoundError)) throw error;\n // A stale provider connection must not hide healthy linked repositories.\n }\n }\n\n return linked;\n}\n\nfunction getExternalRepositoryId(integrationId: string, metadata: Record<string, unknown>): string | undefined {\n let id: unknown;\n switch (integrationId) {\n case 'github':\n id = metadata.githubRepositoryId;\n break;\n case 'gitlab':\n id = metadata.gitlabProjectId;\n break;\n default:\n return undefined;\n }\n return id == null ? undefined : String(id);\n}\n\n/**\n * The one link among `matches` a run can use. A repository can be linked more\n * than once (a provider-app reinstall adds a second link for the same slug),\n * but only one of those links is in the environment, and only an environment\n * link can start a session, so it wins over its out-of-environment duplicates.\n */\nfunction pickLink(matches: LinkedRepository[]): LinkedRepository | undefined {\n if (matches.length === 1) return matches[0];\n const inEnvironment = matches.filter(repository => repository.inEnvironment);\n return inEnvironment.length === 1 ? inEnvironment[0] : undefined;\n}\n\nfunction findRepositoryBySlug(repositories: LinkedRepository[], slug: string) {\n const matches = repositories.filter(repository => repository.slug === slug);\n return pickLink(matches) ?? matches[0];\n}\n\nfunction resolvedRepository(repository: LinkedRepository): WorkItemRepositoryResolution {\n return { status: 'resolved', projectRepositoryId: repository.projectRepositoryId, slug: repository.slug };\n}\n\nexport async function resolveWorkItemRepository(args: {\n sourceControl: SourceControlStorageHandle;\n orgId: string;\n factoryProjectId: string;\n item: Pick<Card, 'metadata'> & { workItem: Pick<Card['workItem'], 'metadata'> };\n linearRepositoryMap?: Record<string, string>;\n}): Promise<WorkItemRepositoryResolution> {\n const { sourceControl, item, linearRepositoryMap } = args;\n const metadata = item.workItem.metadata ?? {};\n const linked = await listLinkedRepositories(args);\n const repositorySignal = typeof item.metadata?.repository === 'string' ? item.metadata.repository : undefined;\n const externalRepositorySignal = getExternalRepositoryId(sourceControl.integrationId, metadata);\n const linearProjectId = typeof metadata.linearProjectId === 'string' ? metadata.linearProjectId : undefined;\n const mappedRepository = linearProjectId ? linearRepositoryMap?.[linearProjectId] : undefined;\n\n // The provider id survives repository renames, so it outranks a possibly stale slug.\n if (externalRepositorySignal !== undefined) {\n const match = pickLink(linked.filter(repository => repository.externalId === externalRepositorySignal));\n if (match) return resolvedRepository(match);\n }\n\n if (repositorySignal) {\n const match = findRepositoryBySlug(linked, repositorySignal);\n return match\n ? resolvedRepository(match)\n : { status: 'unlinked', hint: `Repository ${repositorySignal} is not linked to this Factory.` };\n }\n\n if (externalRepositorySignal !== undefined) {\n return {\n status: 'unlinked',\n hint: `Source-control repository ${externalRepositorySignal} is not linked to this Factory.`,\n };\n }\n\n if (mappedRepository) {\n const match = findRepositoryBySlug(linked, mappedRepository);\n return match\n ? resolvedRepository(match)\n : { status: 'unlinked', hint: `Mapped repository ${mappedRepository} is not linked to this Factory.` };\n }\n\n const candidates = [...new Set(linked.map(repository => repository.slug))].sort();\n if (candidates.length === 0) {\n return { status: 'unlinked', hint: 'This Factory has no linked source-control repositories.' };\n }\n // Every link shares the one slug here, so prefer the environment link among them.\n const onlyRepository = candidates.length === 1 ? (pickLink(linked) ?? linked[0]) : undefined;\n if (onlyRepository) return resolvedRepository(onlyRepository);\n return { status: 'ambiguous', candidates };\n}\n"],"mappings":";;AAgBA,eAAe,uBAAuB,MAIN;CAC9B,MAAM,EAAE,eAAe,OAAO,qBAAqB;CACnD,MAAM,cAAc,MAAM,cAAc,YAAY,KAAK;EAAE;EAAO;CAAiB,CAAC;CACpF,MAAM,SAA6B,CAAC;CAEpC,KAAK,MAAM,cAAc,YAAY,QAAO,cAAa,UAAU,kBAAkB,cAAc,aAAa,GAC9G,IAAI;EACF,MAAM,sBAAsB,MAAM,cAAc,oBAAoB,KAAK;GAAE;GAAO,cAAc,WAAW;EAAG,CAAC;EAC/G,MAAM,eAAe,MAAM,QAAQ,IACjC,oBAAoB,IAAI,OAAM,uBAAsB;GAClD;GACA,YAAY,MAAM,cAAc,aAAa,IAAI;IAAE;IAAO,IAAI,kBAAkB;GAAa,CAAC;EAChG,EAAE,CACJ;EACA,KAAK,MAAM,EAAE,mBAAmB,gBAAgB,cAC9C,IAAI,YACF,OAAO,KAAK;GACV,qBAAqB,kBAAkB;GACvC,YAAY,WAAW;GACvB,MAAM,WAAW;GACjB,eAAe,kBAAkB;EACnC,CAAC;CAGP,SAAS,OAAO;EACd,IAAI,EAAE,iBAAiB,uCAAuC,MAAM;CAEtE;CAGF,OAAO;AACT;AAEA,SAAS,wBAAwB,eAAuB,UAA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,IACxB;GAAE,QAAQ;GAAY,MAAM,cAAc,iBAAiB;EAAiC;CAClG;CAEA,IAAI,6BAA6B,KAAA,GAC/B,OAAO;EACL,QAAQ;EACR,MAAM,6BAA6B,yBAAyB;CAC9D;CAGF,IAAI,kBAAkB;EACpB,MAAM,QAAQ,qBAAqB,QAAQ,gBAAgB;EAC3D,OAAO,QACH,mBAAmB,KAAK,IACxB;GAAE,QAAQ;GAAY,MAAM,qBAAqB,iBAAiB;EAAiC;CACzG;CAEA,MAAM,aAAa,CAAC,GAAG,IAAI,IAAI,OAAO,KAAI,eAAc,WAAW,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK;CAChF,IAAI,WAAW,WAAW,GACxB,OAAO;EAAE,QAAQ;EAAY,MAAM;CAA0D;CAG/F,MAAM,iBAAiB,WAAW,WAAW,IAAK,SAAS,MAAM,KAAK,OAAO,KAAM,KAAA;CACnF,IAAI,gBAAgB,OAAO,mBAAmB,cAAc;CAC5D,OAAO;EAAE,QAAQ;EAAa;CAAW;AAC3C"}
|
|
1
|
+
{"version":3,"file":"work-item-repository.js","names":[],"sources":["../../src/session/work-item-repository.ts"],"sourcesContent":["import type { IntakeStorage } from '../storage/domains/intake/base.js';\nimport { SourceControlConnectionNotFoundError } from '../storage/domains/source-control/base.js';\nimport type { SourceControlStorageHandle } from '../storage/domains/source-control/base.js';\nimport type { Card } from '../storage/domains/work-items/base.js';\nimport { resolveEnvironmentRepositories } from './environment-repositories.js';\n\nexport type WorkItemRepositoryResolution =\n | { status: 'resolved'; projectRepositoryId: string; slug: string }\n | { status: 'unlinked'; hint: string }\n | { status: 'ambiguous'; candidates: string[] };\n\ninterface LinkedRepository {\n projectRepositoryId: string;\n externalId: string;\n slug: string;\n inEnvironment: boolean;\n}\n\nasync function listLinkedRepositories(args: {\n sourceControl: SourceControlStorageHandle;\n orgId: string;\n factoryProjectId: string;\n}): Promise<LinkedRepository[]> {\n const { sourceControl, orgId, factoryProjectId } = args;\n const connections = await sourceControl.connections.list({ orgId, factoryProjectId });\n const linked: LinkedRepository[] = [];\n\n for (const connection of connections.filter(candidate => candidate.integrationId === sourceControl.integrationId)) {\n try {\n const projectRepositories = await sourceControl.projectRepositories.list({ orgId, connectionId: connection.id });\n const repositories = await Promise.all(\n projectRepositories.map(async projectRepository => ({\n projectRepository,\n repository: await sourceControl.repositories.get({ orgId, id: projectRepository.repositoryId }),\n })),\n );\n for (const { projectRepository, repository } of repositories) {\n if (repository) {\n linked.push({\n projectRepositoryId: projectRepository.id,\n externalId: repository.externalId,\n slug: repository.slug,\n inEnvironment: projectRepository.inEnvironment,\n });\n }\n }\n } catch (error) {\n if (!(error instanceof SourceControlConnectionNotFoundError)) throw error;\n // A stale provider connection must not hide healthy linked repositories.\n }\n }\n\n return linked;\n}\n\nconst PROVIDER_REPOSITORY_IDS = new Map([\n ['github', { key: 'githubRepositoryId', label: 'GitHub' }],\n ['gitlab', { key: 'gitlabProjectId', label: 'GitLab' }],\n]);\n\nfunction getExternalRepositoryId(integrationId: string, metadata: Record<string, unknown>): string | undefined {\n const provider = PROVIDER_REPOSITORY_IDS.get(integrationId);\n const id = provider ? metadata[provider.key] : undefined;\n return id == null ? undefined : String(id);\n}\n\nfunction otherProviderLabel(integrationId: string, metadata: Record<string, unknown>): string | undefined {\n for (const [id, provider] of PROVIDER_REPOSITORY_IDS) {\n if (id !== integrationId && metadata[provider.key] != null) return provider.label;\n }\n return undefined;\n}\n\n/**\n * The one link among `matches` a run can use. A repository can be linked more\n * than once (a provider-app reinstall adds a second link for the same slug),\n * but only one of those links is in the environment, and only an environment\n * link can start a session, so it wins over its out-of-environment duplicates.\n */\nfunction pickLink(matches: LinkedRepository[]): LinkedRepository | undefined {\n if (matches.length === 1) return matches[0];\n const inEnvironment = matches.filter(repository => repository.inEnvironment);\n return inEnvironment.length === 1 ? inEnvironment[0] : undefined;\n}\n\nfunction findRepositoryBySlug(repositories: LinkedRepository[], slug: string) {\n const matches = repositories.filter(repository => repository.slug === slug);\n return pickLink(matches) ?? matches[0];\n}\n\nfunction resolvedRepository(repository: LinkedRepository): WorkItemRepositoryResolution {\n return { status: 'resolved', projectRepositoryId: repository.projectRepositoryId, slug: repository.slug };\n}\n\nconst PROVIDER_ITEM_URL = /^https?:\\/\\/[^/]+\\/(.+?)(?:\\/-)?\\/(?:issues|pull|merge_requests)\\/\\d+(?:[/?#]|$)/;\n\nfunction repositoryNameFromUrl(url: string | null | undefined): string | undefined {\n return url ? PROVIDER_ITEM_URL.exec(url)?.[1] : undefined;\n}\n\nexport async function resolveWorkItemRepository(args: {\n sourceControl: SourceControlStorageHandle;\n orgId: string;\n factoryProjectId: string;\n item: Pick<Card, 'metadata'> & { workItem: Pick<Card['workItem'], 'metadata'> & { url?: string | null } };\n linearRepositoryMap?: Record<string, string>;\n}): Promise<WorkItemRepositoryResolution> {\n const { sourceControl, item, linearRepositoryMap } = args;\n const metadata = item.workItem.metadata ?? {};\n const linked = await listLinkedRepositories(args);\n const repositorySignal = typeof item.metadata?.repository === 'string' ? item.metadata.repository : undefined;\n const externalRepositorySignal = getExternalRepositoryId(sourceControl.integrationId, metadata);\n const linearProjectId = typeof metadata.linearProjectId === 'string' ? metadata.linearProjectId : undefined;\n const mappedRepository = linearProjectId ? linearRepositoryMap?.[linearProjectId] : undefined;\n\n // The provider id survives repository renames, so it outranks a possibly stale slug.\n if (externalRepositorySignal !== undefined) {\n const match = pickLink(linked.filter(repository => repository.externalId === externalRepositorySignal));\n if (match) return resolvedRepository(match);\n }\n\n const otherProvider =\n externalRepositorySignal === undefined ? otherProviderLabel(sourceControl.integrationId, metadata) : undefined;\n if (otherProvider !== undefined) {\n return {\n status: 'unlinked',\n hint: `This card comes from ${otherProvider}, and no ${otherProvider} repository is linked to this Factory.`,\n };\n }\n\n if (repositorySignal) {\n const match = findRepositoryBySlug(linked, repositorySignal);\n return match\n ? resolvedRepository(match)\n : { status: 'unlinked', hint: `Repository ${repositorySignal} is not linked to this Factory.` };\n }\n\n if (externalRepositorySignal !== undefined) {\n const name = repositoryNameFromUrl(item.workItem.url);\n return {\n status: 'unlinked',\n hint: name\n ? `Repository ${name} is not linked to this Factory.`\n : `Source-control repository ${externalRepositorySignal} is not linked to this Factory.`,\n };\n }\n\n if (mappedRepository) {\n const match = findRepositoryBySlug(linked, mappedRepository);\n return match\n ? resolvedRepository(match)\n : { status: 'unlinked', hint: `Mapped repository ${mappedRepository} is not linked to this Factory.` };\n }\n\n const candidates = [...new Set(linked.map(repository => repository.slug))].sort();\n if (candidates.length === 0) {\n return { status: 'unlinked', hint: 'This Factory has no linked source-control repositories.' };\n }\n // Every link shares the one slug here, so prefer the environment link among them.\n const onlyRepository = candidates.length === 1 ? (pickLink(linked) ?? linked[0]) : undefined;\n if (onlyRepository) return resolvedRepository(onlyRepository);\n return { status: 'ambiguous', candidates };\n}\n\nexport type RunRepositoryResolution =\n | {\n status: 'resolved';\n projectRepositoryId: string;\n slug: string;\n /**\n * Set when the card names no repository: the sandbox repositories its\n * agent chooses among. The run is filed under `slug` until it does.\n */\n unnamed?: { repositories: string[] };\n }\n | { status: 'unlinked'; hint: string };\n\n/**\n * Where a run on `item` is filed. A card that names its repository resolves\n * exactly as {@link resolveWorkItemRepository} does. A card that names none\n * among several repositories is not refused: the sandbox holds every\n * environment repository, so the run stays in `boundProjectRepositoryId` (the\n * session already working on the card) or else in the environment's first\n * repository, and its agent determines which repository the card belongs to.\n */\nexport async function resolveRunRepository(\n args: Parameters<typeof resolveWorkItemRepository>[0] & { boundProjectRepositoryId?: string },\n): Promise<RunRepositoryResolution> {\n const resolution = await resolveWorkItemRepository(args);\n if (resolution.status !== 'ambiguous') return resolution;\n const { sourceControl, orgId, factoryProjectId, boundProjectRepositoryId } = args;\n const environment = await resolveEnvironmentRepositories({ sourceControl, orgId, factoryProjectId });\n const unnamed = { repositories: environment.map(entry => entry.repository.slug) };\n if (boundProjectRepositoryId !== undefined) {\n const link = await sourceControl.projectRepositories.get({ orgId, id: boundProjectRepositoryId });\n const linked = link && (await sourceControl.repositories.get({ orgId, id: link.repositoryId }));\n const currentLinks = link\n ? await sourceControl.projectRepositories.list({ orgId, connectionId: link.connectionId })\n : [];\n if (\n !linked ||\n !resolution.candidates.includes(linked.slug) ||\n !currentLinks.some(candidate => candidate.id === boundProjectRepositoryId)\n ) {\n return { status: 'unlinked', hint: 'The existing session repository is not linked to this Factory.' };\n }\n return { status: 'resolved', projectRepositoryId: boundProjectRepositoryId, slug: linked.slug, unnamed };\n }\n const primary = environment[0];\n if (!primary) {\n return { status: 'unlinked', hint: 'None of the repositories linked to this Factory is in its environment.' };\n }\n return { status: 'resolved', projectRepositoryId: primary.link.id, slug: primary.repository.slug, unnamed };\n}\n\nexport async function resolveRunRepositoryFromIntake(\n intake: Pick<IntakeStorage, 'getConfig'> | undefined,\n args: Omit<Parameters<typeof resolveRunRepository>[0], 'linearRepositoryMap'>,\n): Promise<RunRepositoryResolution> {\n const intakeConfig = await intake?.getConfig({ orgId: args.orgId, integrationIds: ['linear'] });\n return resolveRunRepository({ ...args, linearRepositoryMap: intakeConfig?.linear?.repositoryByLinearProject });\n}\n\n/** Card metadata recording the `repository` a run chose for a card that named none. */\nexport const REPOSITORY_CHOICE_KEY = 'repositoryChoice';\n\n/**\n * Whether a run recorded `slug` as the card's repository. Every role session\n * on the card was filed before it named a repository, so under another one;\n * they may keep working on the card, in `slug`. A repository set any other\n * way (intake, a person) no longer matches the recorded choice and still\n * refuses a session filed elsewhere.\n */\nexport function repositoryChosenByRun(item: Pick<Card, 'metadata'>, slug: string): boolean {\n const choice = item.metadata?.[REPOSITORY_CHOICE_KEY];\n if (typeof choice !== 'object' || choice === null) return false;\n return item.metadata?.repository === slug && (choice as Record<string, unknown>).slug === slug;\n}\n\nconst UNNAMED_REPOSITORY_INSTRUCTION = 'This card names no repository.';\n\n/** The plugin instruction telling a run's agent which repository it works in. */\nexport function runRepositoryInstruction(\n repository: { slug: string; unnamed?: { repositories: string[] } },\n ownSlug: string,\n): string {\n if (repository.unnamed) {\n return `${UNNAMED_REPOSITORY_INSTRUCTION} This session's sandbox holds ${repository.unnamed.repositories.join(', ')}. Before editing files, determine from the card which of them it belongs to and work in that repository's checkout; pass it as \\`repository\\` to the source_control_* tools (they default to ${ownSlug}). The first push or change request records it on the card. If the card belongs to none of them, stop and say so.`;\n }\n const elsewhere =\n repository.slug === ownSlug\n ? ''\n : ` This session is filed under ${ownSlug}, so pass \\`repository: ${repository.slug}\\` to the source_control_* tools.`;\n return `Target repository: ${repository.slug}. Before editing files or creating a pull request, verify this session's checkout matches the target repository.${elsewhere}`;\n}\n\nexport function isRunRepositoryInstruction(instruction: string): boolean {\n return instruction.startsWith('Target repository: ') || instruction.startsWith(UNNAMED_REPOSITORY_INSTRUCTION);\n}\n"],"mappings":";;;AAkBA,eAAe,uBAAuB,MAIN;CAC9B,MAAM,EAAE,eAAe,OAAO,qBAAqB;CACnD,MAAM,cAAc,MAAM,cAAc,YAAY,KAAK;EAAE;EAAO;CAAiB,CAAC;CACpF,MAAM,SAA6B,CAAC;CAEpC,KAAK,MAAM,cAAc,YAAY,QAAO,cAAa,UAAU,kBAAkB,cAAc,aAAa,GAC9G,IAAI;EACF,MAAM,sBAAsB,MAAM,cAAc,oBAAoB,KAAK;GAAE;GAAO,cAAc,WAAW;EAAG,CAAC;EAC/G,MAAM,eAAe,MAAM,QAAQ,IACjC,oBAAoB,IAAI,OAAM,uBAAsB;GAClD;GACA,YAAY,MAAM,cAAc,aAAa,IAAI;IAAE;IAAO,IAAI,kBAAkB;GAAa,CAAC;EAChG,EAAE,CACJ;EACA,KAAK,MAAM,EAAE,mBAAmB,gBAAgB,cAC9C,IAAI,YACF,OAAO,KAAK;GACV,qBAAqB,kBAAkB;GACvC,YAAY,WAAW;GACvB,MAAM,WAAW;GACjB,eAAe,kBAAkB;EACnC,CAAC;CAGP,SAAS,OAAO;EACd,IAAI,EAAE,iBAAiB,uCAAuC,MAAM;CAEtE;CAGF,OAAO;AACT;AAEA,MAAM,0CAA0B,IAAI,IAAI,CACtC,C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