@mastra/factory 0.28.0-alpha.9 → 0.29.0-alpha.0
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 +67 -46
- package/dist/boards/board-writes.d.ts +3 -3
- package/dist/boards/board-writes.d.ts.map +1 -1
- package/dist/boards/board-writes.js +24 -20
- package/dist/boards/board-writes.js.map +1 -1
- package/dist/boards/project-boards.d.ts +20 -0
- package/dist/boards/project-boards.d.ts.map +1 -1
- package/dist/boards/project-boards.js +35 -11
- package/dist/boards/project-boards.js.map +1 -1
- package/dist/boards/registry.d.ts.map +1 -1
- package/dist/boards/registry.js +0 -3
- package/dist/boards/registry.js.map +1 -1
- package/dist/boards/reroute.d.ts +31 -0
- package/dist/boards/reroute.d.ts.map +1 -0
- package/dist/boards/reroute.js +71 -0
- package/dist/boards/reroute.js.map +1 -0
- package/dist/capabilities/version-control.d.ts +6 -1
- package/dist/capabilities/version-control.d.ts.map +1 -1
- package/dist/environment/build-runner.d.ts +13 -2
- package/dist/environment/build-runner.d.ts.map +1 -1
- package/dist/environment/build-runner.js +42 -0
- package/dist/environment/build-runner.js.map +1 -1
- package/dist/environment/build-schedule.js +1 -1
- package/dist/environment/build-schedule.js.map +1 -1
- package/dist/environment/build-workflow.d.ts +6 -4
- package/dist/environment/build-workflow.d.ts.map +1 -1
- package/dist/environment/build-workflow.js +70 -66
- package/dist/environment/build-workflow.js.map +1 -1
- package/dist/environment/build.d.ts +22 -7
- package/dist/environment/build.d.ts.map +1 -1
- package/dist/environment/build.js +73 -15
- package/dist/environment/build.js.map +1 -1
- package/dist/environment/heads.d.ts +1 -1
- package/dist/environment/heads.d.ts.map +1 -1
- package/dist/environment/heads.js +4 -1
- package/dist/environment/heads.js.map +1 -1
- package/dist/environment/repository-access.d.ts +15 -0
- package/dist/environment/repository-access.d.ts.map +1 -0
- package/dist/environment/repository-access.js +60 -0
- package/dist/environment/repository-access.js.map +1 -0
- package/dist/factory.d.ts +5 -2
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +40 -30
- package/dist/factory.js.map +1 -1
- package/dist/integrations/base.d.ts +8 -0
- package/dist/integrations/base.d.ts.map +1 -1
- package/dist/integrations/dependabot/default-rules.d.ts +38 -0
- package/dist/integrations/dependabot/default-rules.d.ts.map +1 -0
- package/dist/integrations/dependabot/default-rules.js +63 -0
- package/dist/integrations/dependabot/default-rules.js.map +1 -0
- package/dist/integrations/dependabot/rules.d.ts +42 -0
- package/dist/integrations/dependabot/rules.d.ts.map +1 -0
- package/dist/integrations/dependabot/rules.js +187 -0
- package/dist/integrations/dependabot/rules.js.map +1 -0
- package/dist/integrations/dependabot/sync.d.ts +76 -0
- package/dist/integrations/dependabot/sync.d.ts.map +1 -0
- package/dist/integrations/dependabot/sync.js +111 -0
- package/dist/integrations/dependabot/sync.js.map +1 -0
- package/dist/integrations/github/routes.d.ts.map +1 -1
- package/dist/integrations/github/routes.js +7 -2
- package/dist/integrations/github/routes.js.map +1 -1
- package/dist/integrations/github/sandbox-release.d.ts +12 -0
- package/dist/integrations/github/sandbox-release.d.ts.map +1 -1
- package/dist/integrations/github/sandbox-release.js +16 -1
- package/dist/integrations/github/sandbox-release.js.map +1 -1
- package/dist/integrations/github/sandbox.d.ts +12 -0
- package/dist/integrations/github/sandbox.d.ts.map +1 -1
- package/dist/integrations/github/sandbox.js +22 -1
- package/dist/integrations/github/sandbox.js.map +1 -1
- package/dist/integrations/platform/connect/routes.d.ts.map +1 -1
- package/dist/integrations/platform/connect/routes.js +4 -0
- package/dist/integrations/platform/connect/routes.js.map +1 -1
- package/dist/integrations/platform/github/event-worker.d.ts +5 -0
- package/dist/integrations/platform/github/event-worker.d.ts.map +1 -1
- package/dist/integrations/platform/github/event-worker.js +33 -2
- package/dist/integrations/platform/github/event-worker.js.map +1 -1
- package/dist/integrations/platform/github/integration.d.ts +19 -1
- package/dist/integrations/platform/github/integration.d.ts.map +1 -1
- package/dist/integrations/platform/github/integration.js +183 -105
- package/dist/integrations/platform/github/integration.js.map +1 -1
- package/dist/integrations/platform/jira/integration.d.ts.map +1 -1
- package/dist/integrations/platform/jira/integration.js +5 -1
- package/dist/integrations/platform/jira/integration.js.map +1 -1
- package/dist/integrations/platform/vanta/integration.d.ts +33 -0
- package/dist/integrations/platform/vanta/integration.d.ts.map +1 -0
- package/dist/integrations/platform/vanta/integration.js +133 -0
- package/dist/integrations/platform/vanta/integration.js.map +1 -0
- package/dist/integrations/slack/integration.d.ts.map +1 -1
- package/dist/integrations/slack/integration.js +7 -4
- package/dist/integrations/slack/integration.js.map +1 -1
- package/dist/integrations/vanta/default-rules.d.ts +34 -0
- package/dist/integrations/vanta/default-rules.d.ts.map +1 -0
- package/dist/integrations/vanta/default-rules.js +61 -0
- package/dist/integrations/vanta/default-rules.js.map +1 -0
- package/dist/integrations/vanta/rules.d.ts +40 -0
- package/dist/integrations/vanta/rules.d.ts.map +1 -0
- package/dist/integrations/vanta/rules.js +208 -0
- package/dist/integrations/vanta/rules.js.map +1 -0
- package/dist/integrations/vanta/sync.d.ts +36 -0
- package/dist/integrations/vanta/sync.d.ts.map +1 -0
- package/dist/integrations/vanta/sync.js +73 -0
- package/dist/integrations/vanta/sync.js.map +1 -0
- package/dist/mcp/routes.d.ts.map +1 -1
- package/dist/mcp/routes.js +3 -5
- package/dist/mcp/routes.js.map +1 -1
- package/dist/routes/board-snapshot.d.ts +24 -1
- package/dist/routes/board-snapshot.d.ts.map +1 -1
- package/dist/routes/board-snapshot.js +75 -7
- package/dist/routes/board-snapshot.js.map +1 -1
- package/dist/routes/boards.d.ts +2 -3
- package/dist/routes/boards.d.ts.map +1 -1
- package/dist/routes/boards.js.map +1 -1
- package/dist/routes/contracts.d.ts +307 -0
- package/dist/routes/contracts.d.ts.map +1 -1
- package/dist/routes/contracts.js +253 -9
- package/dist/routes/contracts.js.map +1 -1
- package/dist/routes/intake-routes.d.ts +3 -0
- package/dist/routes/intake-routes.d.ts.map +1 -1
- package/dist/routes/intake-routes.js +44 -0
- package/dist/routes/intake-routes.js.map +1 -1
- package/dist/routes/knowledge.d.ts.map +1 -1
- package/dist/routes/knowledge.js +3 -2
- package/dist/routes/knowledge.js.map +1 -1
- package/dist/routes/projects.d.ts.map +1 -1
- package/dist/routes/projects.js +5 -0
- package/dist/routes/projects.js.map +1 -1
- package/dist/routes/sandbox-envs.d.ts +2 -0
- package/dist/routes/sandbox-envs.d.ts.map +1 -1
- package/dist/routes/sandbox-envs.js +3 -0
- package/dist/routes/sandbox-envs.js.map +1 -1
- package/dist/routes/source-control-sessions.d.ts +1 -1
- package/dist/routes/source-control-sessions.d.ts.map +1 -1
- package/dist/routes/source-control-sessions.js +109 -3
- package/dist/routes/source-control-sessions.js.map +1 -1
- package/dist/routes/source-control-settings.d.ts +2 -0
- package/dist/routes/source-control-settings.d.ts.map +1 -1
- package/dist/routes/source-control-settings.js +5 -0
- package/dist/routes/source-control-settings.js.map +1 -1
- package/dist/routes/surface.d.ts +8 -1
- package/dist/routes/surface.d.ts.map +1 -1
- package/dist/routes/surface.js +74 -10
- package/dist/routes/surface.js.map +1 -1
- package/dist/routes/work-item-activity.d.ts +11 -0
- package/dist/routes/work-item-activity.d.ts.map +1 -0
- package/dist/routes/work-item-activity.js +25 -0
- package/dist/routes/work-item-activity.js.map +1 -0
- package/dist/routes/work-item-selection.d.ts +14 -0
- package/dist/routes/work-item-selection.d.ts.map +1 -0
- package/dist/routes/work-item-selection.js +44 -0
- package/dist/routes/work-item-selection.js.map +1 -0
- package/dist/routes/work-item-starters.d.ts +29 -0
- package/dist/routes/work-item-starters.d.ts.map +1 -0
- package/dist/routes/work-item-starters.js +152 -0
- package/dist/routes/work-item-starters.js.map +1 -0
- package/dist/routes/work-items.d.ts.map +1 -1
- package/dist/routes/work-items.js +239 -16
- package/dist/routes/work-items.js.map +1 -1
- package/dist/rules/dispatch-errors.d.ts +3 -0
- package/dist/rules/dispatch-errors.d.ts.map +1 -1
- package/dist/rules/dispatch-errors.js +9 -0
- package/dist/rules/dispatch-errors.js.map +1 -1
- package/dist/rules/dispatcher.d.ts +4 -1
- package/dist/rules/dispatcher.d.ts.map +1 -1
- package/dist/rules/dispatcher.js +122 -33
- package/dist/rules/dispatcher.js.map +1 -1
- package/dist/rules/index.d.ts +2 -2
- package/dist/rules/index.d.ts.map +1 -1
- package/dist/rules/index.js +2 -2
- package/dist/rules/processor.d.ts +2 -0
- package/dist/rules/processor.d.ts.map +1 -1
- package/dist/rules/processor.js +18 -4
- package/dist/rules/processor.js.map +1 -1
- package/dist/rules/start-coordinator.d.ts +6 -1
- package/dist/rules/start-coordinator.d.ts.map +1 -1
- package/dist/rules/start-coordinator.js +6 -2
- package/dist/rules/start-coordinator.js.map +1 -1
- package/dist/rules/transition-service.d.ts +20 -2
- package/dist/rules/transition-service.d.ts.map +1 -1
- package/dist/rules/transition-service.js +43 -20
- package/dist/rules/transition-service.js.map +1 -1
- package/dist/rules/types.d.ts +71 -3
- package/dist/rules/types.d.ts.map +1 -1
- package/dist/rules/types.js +10 -2
- package/dist/rules/types.js.map +1 -1
- package/dist/rules/validation.d.ts.map +1 -1
- package/dist/rules/validation.js +5 -0
- package/dist/rules/validation.js.map +1 -1
- package/dist/sandbox/context-sandboxes.d.ts +70 -0
- package/dist/sandbox/context-sandboxes.d.ts.map +1 -0
- package/dist/sandbox/context-sandboxes.js +120 -0
- package/dist/sandbox/context-sandboxes.js.map +1 -0
- package/dist/sandbox/session-retirement.d.ts +11 -4
- package/dist/sandbox/session-retirement.d.ts.map +1 -1
- package/dist/sandbox/session-retirement.js +39 -13
- package/dist/sandbox/session-retirement.js.map +1 -1
- package/dist/session/factory-session.d.ts +20 -5
- package/dist/session/factory-session.d.ts.map +1 -1
- package/dist/session/factory-session.js +20 -6
- package/dist/session/factory-session.js.map +1 -1
- package/dist/session/live-sessions.d.ts +1 -1
- package/dist/session/live-sessions.d.ts.map +1 -1
- package/dist/session/live-sessions.js +12 -2
- package/dist/session/live-sessions.js.map +1 -1
- package/dist/storage/domains/audit/actions.d.ts +1 -1
- package/dist/storage/domains/audit/actions.d.ts.map +1 -1
- package/dist/storage/domains/audit/actions.js +2 -1
- package/dist/storage/domains/audit/actions.js.map +1 -1
- package/dist/storage/domains/audit/actors.d.ts.map +1 -1
- package/dist/storage/domains/audit/actors.js +1 -1
- package/dist/storage/domains/audit/actors.js.map +1 -1
- package/dist/storage/domains/boards/base.d.ts +25 -5
- package/dist/storage/domains/boards/base.d.ts.map +1 -1
- package/dist/storage/domains/boards/base.js +57 -20
- package/dist/storage/domains/boards/base.js.map +1 -1
- package/dist/storage/domains/intake/base.d.ts +1 -1
- package/dist/storage/domains/intake/base.js +2 -2
- package/dist/storage/domains/intake/base.js.map +1 -1
- package/dist/storage/domains/projects/base.d.ts +16 -2
- package/dist/storage/domains/projects/base.d.ts.map +1 -1
- package/dist/storage/domains/projects/base.js +32 -5
- package/dist/storage/domains/projects/base.js.map +1 -1
- package/dist/storage/domains/work-items/base.d.ts +60 -8
- package/dist/storage/domains/work-items/base.d.ts.map +1 -1
- package/dist/storage/domains/work-items/base.js +180 -18
- package/dist/storage/domains/work-items/base.js.map +1 -1
- package/dist/storage/domains/work-items/cards.d.ts +1 -0
- package/dist/storage/domains/work-items/cards.d.ts.map +1 -1
- package/dist/storage/domains/work-items/cards.js +32 -8
- package/dist/storage/domains/work-items/cards.js.map +1 -1
- package/dist/storage/domains/work-items/legacy-review.d.ts +19 -1
- package/dist/storage/domains/work-items/legacy-review.d.ts.map +1 -1
- package/dist/storage/domains/work-items/legacy-review.js +62 -3
- package/dist/storage/domains/work-items/legacy-review.js.map +1 -1
- package/dist/storage/domains/work-items/work-item-schema.d.ts +1 -0
- package/dist/storage/domains/work-items/work-item-schema.d.ts.map +1 -1
- package/dist/storage/domains/work-items/work-item-schema.js +46 -18
- package/dist/storage/domains/work-items/work-item-schema.js.map +1 -1
- package/dist/tools/annotations.d.ts.map +1 -1
- package/dist/tools/annotations.js +4 -0
- package/dist/tools/annotations.js.map +1 -1
- package/dist/tools/approval-tools.d.ts +20 -0
- package/dist/tools/approval-tools.d.ts.map +1 -1
- package/dist/tools/approval-tools.js +79 -30
- package/dist/tools/approval-tools.js.map +1 -1
- package/dist/tools/audit-events-tool.d.ts +29 -0
- package/dist/tools/audit-events-tool.d.ts.map +1 -0
- package/dist/tools/audit-events-tool.js +180 -0
- package/dist/tools/audit-events-tool.js.map +1 -0
- package/dist/tools/index.d.ts +2 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +2 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/messaging-tools.d.ts.map +1 -1
- package/dist/tools/messaging-tools.js +1 -1
- package/dist/tools/messaging-tools.js.map +1 -1
- package/dist/tools/permissions.d.ts.map +1 -1
- package/dist/tools/permissions.js +1 -0
- package/dist/tools/permissions.js.map +1 -1
- package/dist/tools/read-tools.d.ts +0 -2
- package/dist/tools/read-tools.d.ts.map +1 -1
- package/dist/tools/read-tools.js +2 -7
- package/dist/tools/read-tools.js.map +1 -1
- package/dist/tools/reports.d.ts +3 -0
- package/dist/tools/reports.d.ts.map +1 -1
- package/dist/tools/reports.js +3 -3
- package/dist/tools/reports.js.map +1 -1
- package/dist/tools/run-watch.d.ts +14 -2
- package/dist/tools/run-watch.d.ts.map +1 -1
- package/dist/tools/run-watch.js +24 -4
- package/dist/tools/run-watch.js.map +1 -1
- package/dist/tools/session-tools.d.ts.map +1 -1
- package/dist/tools/session-tools.js +17 -6
- package/dist/tools/session-tools.js.map +1 -1
- package/dist/tools/sessions-state-processor.js +1 -1
- package/dist/tools/sessions-state-processor.js.map +1 -1
- package/dist/tools/side-sessions.d.ts.map +1 -1
- package/dist/tools/side-sessions.js +1 -1
- package/dist/tools/side-sessions.js.map +1 -1
- package/dist/tools/work-item-tools.d.ts.map +1 -1
- package/dist/tools/work-item-tools.js +12 -2
- package/dist/tools/work-item-tools.js.map +1 -1
- package/dist/work-item-branch.d.ts +1 -1
- package/dist/work-item-branch.d.ts.map +1 -1
- package/dist/work-item-branch.js +2 -0
- package/dist/work-item-branch.js.map +1 -1
- package/dist/work-items/board-check.d.ts +11 -0
- package/dist/work-items/board-check.d.ts.map +1 -0
- package/dist/work-items/board-check.js +20 -0
- package/dist/work-items/board-check.js.map +1 -0
- package/dist/work-items/board-filter-options.d.ts +5 -0
- package/dist/work-items/board-filter-options.d.ts.map +1 -0
- package/dist/work-items/board-filter-options.js +27 -0
- package/dist/work-items/board-filter-options.js.map +1 -0
- package/dist/work-items/board-phases.d.ts +28 -0
- package/dist/work-items/board-phases.d.ts.map +1 -0
- package/dist/work-items/board-phases.js +165 -0
- package/dist/work-items/board-phases.js.map +1 -0
- package/dist/work-items/card-facts.d.ts +24 -0
- package/dist/work-items/card-facts.d.ts.map +1 -0
- package/dist/work-items/card-facts.js +75 -0
- package/dist/work-items/card-facts.js.map +1 -0
- package/dist/work-items/card-labels.d.ts +5 -0
- package/dist/work-items/card-labels.d.ts.map +1 -0
- package/dist/work-items/card-labels.js +13 -0
- package/dist/work-items/card-labels.js.map +1 -0
- package/dist/work-items/card-number.d.ts +10 -0
- package/dist/work-items/card-number.d.ts.map +1 -0
- package/dist/work-items/card-number.js +15 -0
- package/dist/work-items/card-number.js.map +1 -0
- package/dist/work-items/card-people.d.ts +25 -0
- package/dist/work-items/card-people.d.ts.map +1 -0
- package/dist/work-items/card-people.js +100 -0
- package/dist/work-items/card-people.js.map +1 -0
- package/dist/work-items/card-search-text.d.ts +4 -0
- package/dist/work-items/card-search-text.d.ts.map +1 -0
- package/dist/work-items/card-search-text.js +15 -0
- package/dist/work-items/card-search-text.js.map +1 -0
- package/dist/work-items/card-source-filters.d.ts +23 -0
- package/dist/work-items/card-source-filters.d.ts.map +1 -0
- package/dist/work-items/card-source-filters.js +25 -0
- package/dist/work-items/card-source-filters.js.map +1 -0
- package/dist/work-items/create-work-item.d.ts +0 -6
- package/dist/work-items/create-work-item.d.ts.map +1 -1
- package/dist/work-items/create-work-item.js +2 -7
- package/dist/work-items/create-work-item.js.map +1 -1
- package/dist/work-items/list-related-cards.d.ts +4 -0
- package/dist/work-items/list-related-cards.d.ts.map +1 -0
- package/dist/work-items/list-related-cards.js +24 -0
- package/dist/work-items/list-related-cards.js.map +1 -0
- package/dist/work-items/related-cards.d.ts +21 -0
- package/dist/work-items/related-cards.d.ts.map +1 -0
- package/dist/work-items/related-cards.js +45 -0
- package/dist/work-items/related-cards.js.map +1 -0
- package/dist/work-items/search-words.d.ts +5 -0
- package/dist/work-items/search-words.d.ts.map +1 -0
- package/dist/work-items/search-words.js +12 -0
- package/dist/work-items/search-words.js.map +1 -0
- package/dist/work-items/split-migration.d.ts.map +1 -1
- package/dist/work-items/split-migration.js +6 -2
- package/dist/work-items/split-migration.js.map +1 -1
- package/dist/workspace.d.ts +0 -1
- package/dist/workspace.d.ts.map +1 -1
- package/dist/workspace.js +140 -78
- package/dist/workspace.js.map +1 -1
- package/factory-skills/factory-build/SKILL.md +1 -1
- package/factory-skills/factory-self-review/SKILL.md +1 -1
- package/factory-skills/factory-triage/SKILL.md +4 -4
- package/package.json +17 -16
package/dist/rules/dispatcher.js
CHANGED
|
@@ -6,8 +6,8 @@ import { boardFlow, boardForWorkItem, cardBoardFlow, hasPullRequest, intakeTarge
|
|
|
6
6
|
import { autoApprovedExitTool, startsInAutoPhase } from "../boards/phase-automation.js";
|
|
7
7
|
import { toBoardSource } from "../boards/project-boards.js";
|
|
8
8
|
import { moveCardToBoard } from "../boards/relocate.js";
|
|
9
|
-
import { cardRuleFacts } from "../boards/card-facts.js";
|
|
10
9
|
import { FACTORY_OPEN_RUN_STALE_MS, heartbeatSessionOpenRun, isOpenRunLiveElsewhere, listSessionOpenRuns, recordSessionRunStart, waitForSessionRunAudit } from "../session/run-audit.js";
|
|
10
|
+
import { cardRuleFacts } from "../boards/card-facts.js";
|
|
11
11
|
import { resolvePromptInvocation, resolveSkillInvocation, resolveSkillResumeInvocation } from "../skills/service.js";
|
|
12
12
|
import { isHumanActorId } from "../storage/domains/audit/actors.js";
|
|
13
13
|
import { FACTORY_RULE_MATERIALIZATION_KEY, WorkItemSourceConflictError, WorkItemUpdateConflictError, externalSourceKey } from "../storage/domains/work-items/base.js";
|
|
@@ -88,7 +88,8 @@ function reviewSeatSkill(decision) {
|
|
|
88
88
|
return value.type === "invokeSkill" && value.role === "review" ? value : void 0;
|
|
89
89
|
}
|
|
90
90
|
function isTerminalFailure(attempts, failureCode) {
|
|
91
|
-
|
|
91
|
+
const failure = factoryDispatchFailureMetadata(failureCode);
|
|
92
|
+
return attempts >= (failureCode === "run_incomplete" ? 2 : MAX_ATTEMPTS) || !failure.canRetry || failure.autoRetry === false;
|
|
92
93
|
}
|
|
93
94
|
/**
|
|
94
95
|
* Conservative check for observational-memory failures that a retry cannot fix:
|
|
@@ -101,12 +102,14 @@ function isPermanentProviderRejection(error) {
|
|
|
101
102
|
const normalized = error.toLowerCase();
|
|
102
103
|
return /\bhttp(?:\/\d(?:\.\d)?)?\s*400\b/.test(normalized) || /\bstatus(?:\s*code)?\s*[:=]?\s*400\b/.test(normalized) || /\b400\s*(?:bad request|status)\b/.test(normalized) || normalized.includes("model not supported") || normalized.includes("model is not supported") || normalized.includes("unsupported model") || normalized.includes("not supported with") || normalized.includes("unauthorized") || normalized.includes("authentication") || normalized.includes("invalid") && normalized.includes("model");
|
|
103
104
|
}
|
|
104
|
-
function watchRun(session, { timeoutMs,
|
|
105
|
+
function watchRun(session, { timeoutMs, autoApprovedTool, autoApproving, requestContext, onAgentEnd, label, runStillActive }) {
|
|
105
106
|
let resolveAgentEnd;
|
|
106
107
|
let agentEnd;
|
|
107
108
|
let endReason;
|
|
108
109
|
let supersededAtEnd;
|
|
109
110
|
let parked;
|
|
111
|
+
let approvals = 0;
|
|
112
|
+
const announced = /* @__PURE__ */ new Set();
|
|
110
113
|
let omFailure;
|
|
111
114
|
let runError;
|
|
112
115
|
const arm = () => {
|
|
@@ -139,6 +142,10 @@ function watchRun(session, { timeoutMs, approvePlans, requestContext, onAgentEnd
|
|
|
139
142
|
toolName: event.toolName,
|
|
140
143
|
toolCallId: event.toolCallId
|
|
141
144
|
};
|
|
145
|
+
if (event.toolName === autoApprovedTool && approvals < MAX_PLAN_APPROVALS) {
|
|
146
|
+
announced.add(event.toolCallId);
|
|
147
|
+
autoApproving?.add(event.toolCallId);
|
|
148
|
+
}
|
|
142
149
|
return;
|
|
143
150
|
}
|
|
144
151
|
if (event.type === "tool_suspension_cancelled" && parked?.toolCallId === event.toolCallId) parked = void 0;
|
|
@@ -159,19 +166,27 @@ function watchRun(session, { timeoutMs, approvePlans, requestContext, onAgentEnd
|
|
|
159
166
|
endReason: () => endReason,
|
|
160
167
|
/** The tool the run is parked on, when it ended suspended. */
|
|
161
168
|
parked: () => parked,
|
|
162
|
-
close:
|
|
169
|
+
close: () => {
|
|
170
|
+
for (const toolCallId of announced) autoApproving?.delete(toolCallId);
|
|
171
|
+
unsubscribe();
|
|
172
|
+
},
|
|
163
173
|
/** The run's own verdict, thrown as what the dispatcher should record. */
|
|
164
174
|
async settle() {
|
|
165
175
|
let observed = await wait();
|
|
166
|
-
|
|
176
|
+
while (autoApprovedTool && parked?.toolName === autoApprovedTool && approvals < MAX_PLAN_APPROVALS) {
|
|
167
177
|
const { toolCallId } = parked;
|
|
168
178
|
parked = void 0;
|
|
179
|
+
approvals += 1;
|
|
169
180
|
arm();
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
181
|
+
try {
|
|
182
|
+
await session.respondToToolSuspension({
|
|
183
|
+
resumeData: { action: "approved" },
|
|
184
|
+
toolCallId,
|
|
185
|
+
requestContext
|
|
186
|
+
});
|
|
187
|
+
} finally {
|
|
188
|
+
autoApproving?.delete(toolCallId);
|
|
189
|
+
}
|
|
175
190
|
observed = await wait();
|
|
176
191
|
}
|
|
177
192
|
if (!observed) throw new FactoryDispatchError("run_terminal_event_missing", `${label} terminal event was not observed before timeout.`);
|
|
@@ -321,7 +336,9 @@ var FactoryDecisionDispatcher = class {
|
|
|
321
336
|
#intakeRoutes;
|
|
322
337
|
#storage;
|
|
323
338
|
#ownerId;
|
|
339
|
+
#autoApproving = /* @__PURE__ */ new Set();
|
|
324
340
|
#reconcileToolResults;
|
|
341
|
+
#reconcileRunBinding;
|
|
325
342
|
#prepareBinding;
|
|
326
343
|
#primeCredentials;
|
|
327
344
|
#reportRunEnd;
|
|
@@ -375,6 +392,7 @@ var FactoryDecisionDispatcher = class {
|
|
|
375
392
|
this.#storage = options.storage;
|
|
376
393
|
this.#ownerId = options.ownerId ?? `factory-dispatcher:${globalThis.crypto.randomUUID()}`;
|
|
377
394
|
this.#reconcileToolResults = options.reconcileToolResults;
|
|
395
|
+
this.#reconcileRunBinding = options.reconcileRunBinding;
|
|
378
396
|
this.#prepareBinding = options.prepareBinding;
|
|
379
397
|
this.#primeCredentials = options.primeCredentials;
|
|
380
398
|
this.#reportRunEnd = options.reportRunEnd;
|
|
@@ -661,7 +679,6 @@ var FactoryDecisionDispatcher = class {
|
|
|
661
679
|
if (runStillActive()) {
|
|
662
680
|
const run = watchRun(session, {
|
|
663
681
|
timeoutMs: this.#skillCompletionObservationTimeoutMs,
|
|
664
|
-
approvePlans: false,
|
|
665
682
|
label: "Factory skill run",
|
|
666
683
|
runStillActive
|
|
667
684
|
});
|
|
@@ -921,7 +938,10 @@ var FactoryDecisionDispatcher = class {
|
|
|
921
938
|
orgId: record.orgId,
|
|
922
939
|
userId: startedBy
|
|
923
940
|
});
|
|
924
|
-
const session = await this.#requireSession(binding
|
|
941
|
+
const session = await this.#requireSession(binding, {
|
|
942
|
+
userId: startedBy,
|
|
943
|
+
orgId: record.orgId
|
|
944
|
+
});
|
|
925
945
|
const requestContext = factoryRequestContext({
|
|
926
946
|
session,
|
|
927
947
|
binding,
|
|
@@ -940,7 +960,10 @@ var FactoryDecisionDispatcher = class {
|
|
|
940
960
|
name: decision.skillName,
|
|
941
961
|
arguments: decision.arguments
|
|
942
962
|
});
|
|
943
|
-
await this.#switchThread(session, binding
|
|
963
|
+
await this.#switchThread(session, binding, {
|
|
964
|
+
userId: startedBy,
|
|
965
|
+
orgId: record.orgId
|
|
966
|
+
});
|
|
944
967
|
const deliveryId = record.deliveryGeneration === 0 ? record.id : `${record.id}:retry:${record.deliveryGeneration}`;
|
|
945
968
|
const kickoffLanded = async () => (await session.thread.listActiveMessages()).some((message) => message.id === deliveryId);
|
|
946
969
|
const kickoffStale = async () => await this.#roleSuperseded(record, decision.role) || (await this.#findBinding(record, decision.role))?.id !== binding.id || await this.#decisionOvertaken(record, decision.role);
|
|
@@ -992,9 +1015,22 @@ var FactoryDecisionDispatcher = class {
|
|
|
992
1015
|
}
|
|
993
1016
|
const goal = decision.goal ? await this.#setPhaseGoal(record, decision.goal, session, binding) : void 0;
|
|
994
1017
|
const since = /* @__PURE__ */ new Date();
|
|
1018
|
+
const runItem = record.workItemId ? await this.#storage.get({
|
|
1019
|
+
orgId: record.orgId,
|
|
1020
|
+
id: record.workItemId
|
|
1021
|
+
}) : null;
|
|
1022
|
+
const boards = runItem ? await this.#boards.load(record) : null;
|
|
1023
|
+
const stage = runItem?.stages.length === 1 ? runItem.stages[0] : void 0;
|
|
1024
|
+
const phase = stage && runItem ? boards?.get(boardForWorkItem(runItem))?.phases[stage] : void 0;
|
|
1025
|
+
const workingRevision = phase?.kind === "working" && (phase.runner.goal || phase.exitTool) && phase.runner.context === decision.role && phase.runner.skill === decision.skillName ? runItem.revision : null;
|
|
1026
|
+
const existingLinkedReviewIds = new Set(workingRevision === null || !runItem ? [] : (await this.#storage.listLinked({
|
|
1027
|
+
item: runItem,
|
|
1028
|
+
limit: 100
|
|
1029
|
+
})).map((card) => card.id));
|
|
995
1030
|
const run = watchRun(session, {
|
|
996
1031
|
timeoutMs: this.#skillCompletionObservationTimeoutMs,
|
|
997
|
-
|
|
1032
|
+
autoApprovedTool: await this.#autoApprovedExitTool(record),
|
|
1033
|
+
autoApproving: this.#autoApproving,
|
|
998
1034
|
requestContext,
|
|
999
1035
|
onAgentEnd: () => this.#roleSuperseded(record, decision.role),
|
|
1000
1036
|
label: "Factory skill run",
|
|
@@ -1036,7 +1072,26 @@ var FactoryDecisionDispatcher = class {
|
|
|
1036
1072
|
since,
|
|
1037
1073
|
attempts: record.attempts,
|
|
1038
1074
|
superseded: async () => await run.supersededAtEnd() ?? await this.#roleSuperseded(record, decision.role)
|
|
1039
|
-
},
|
|
1075
|
+
}, async () => {
|
|
1076
|
+
await this.#withOpenRunHeartbeat(session, deliveryId, () => run.settle());
|
|
1077
|
+
if (run.endReason() !== "complete" || workingRevision === null || await run.supersededAtEnd()) return;
|
|
1078
|
+
await this.#reconcileRunBinding?.(binding);
|
|
1079
|
+
const after = await this.#storage.get({
|
|
1080
|
+
orgId: record.orgId,
|
|
1081
|
+
id: record.workItemId
|
|
1082
|
+
});
|
|
1083
|
+
if (after?.revision === workingRevision && !await kickoffStale()) {
|
|
1084
|
+
if ((await this.#storage.listLinked({
|
|
1085
|
+
item: after,
|
|
1086
|
+
limit: 100
|
|
1087
|
+
})).some((card) => {
|
|
1088
|
+
if (card.parentWorkItemId !== after.id || existingLinkedReviewIds.has(card.id) || card.externalSource?.integrationId !== "github" || card.externalSource.type !== "pull-request" || card.stages.length !== 1) return false;
|
|
1089
|
+
const review = boards?.get(boardForWorkItem(card))?.phases[card.stages[0]];
|
|
1090
|
+
return review?.kind === "working" && review.runner.context === "review";
|
|
1091
|
+
})) return;
|
|
1092
|
+
throw new FactoryDispatchError("run_incomplete", "Factory skill run ended before completing the working phase.");
|
|
1093
|
+
}
|
|
1094
|
+
});
|
|
1040
1095
|
if (await run.supersededAtEnd()) {
|
|
1041
1096
|
this.#reviewWatched.delete(record);
|
|
1042
1097
|
await this.#reviewStatus(record, decision, {
|
|
@@ -1070,7 +1125,10 @@ var FactoryDecisionDispatcher = class {
|
|
|
1070
1125
|
orgId: record.orgId,
|
|
1071
1126
|
userId: startedBy
|
|
1072
1127
|
});
|
|
1073
|
-
const session = await this.#requireSession(binding
|
|
1128
|
+
const session = await this.#requireSession(binding, {
|
|
1129
|
+
userId: startedBy,
|
|
1130
|
+
orgId: record.orgId
|
|
1131
|
+
});
|
|
1074
1132
|
const requestContext = factoryRequestContext({
|
|
1075
1133
|
session,
|
|
1076
1134
|
binding,
|
|
@@ -1110,7 +1168,10 @@ var FactoryDecisionDispatcher = class {
|
|
|
1110
1168
|
orgId: record.orgId,
|
|
1111
1169
|
userId: startedBy
|
|
1112
1170
|
});
|
|
1113
|
-
const session = await this.#requireSession(binding
|
|
1171
|
+
const session = await this.#requireSession(binding, {
|
|
1172
|
+
userId: startedBy,
|
|
1173
|
+
orgId: record.orgId
|
|
1174
|
+
});
|
|
1114
1175
|
const requestContext = factoryRequestContext({
|
|
1115
1176
|
session,
|
|
1116
1177
|
binding,
|
|
@@ -1214,6 +1275,7 @@ var FactoryDecisionDispatcher = class {
|
|
|
1214
1275
|
externalSource: externalSourceForDecision(decision),
|
|
1215
1276
|
parentWorkItemId,
|
|
1216
1277
|
title: decision.title,
|
|
1278
|
+
...decision.description ? { description: decision.description } : {},
|
|
1217
1279
|
board: decision.board,
|
|
1218
1280
|
stages: [entryStage],
|
|
1219
1281
|
sessions: {},
|
|
@@ -1632,7 +1694,15 @@ var FactoryDecisionDispatcher = class {
|
|
|
1632
1694
|
}
|
|
1633
1695
|
if (!first.board.isTerminal(first.route.phase)) {
|
|
1634
1696
|
const binding = await this.#findBinding(record);
|
|
1635
|
-
const
|
|
1697
|
+
const startedBy = binding ? first.item.sessions[binding.role]?.startedBy : void 0;
|
|
1698
|
+
if (startedBy) await this.#primeCredentials?.({
|
|
1699
|
+
orgId: record.orgId,
|
|
1700
|
+
userId: startedBy
|
|
1701
|
+
});
|
|
1702
|
+
const session = binding && startedBy ? await this.#findSession(binding, {
|
|
1703
|
+
userId: startedBy,
|
|
1704
|
+
orgId: record.orgId
|
|
1705
|
+
}) : void 0;
|
|
1636
1706
|
if (binding && session && await this.#hasRunInFlight(session, binding)) throw new FactoryDecisionPostponed();
|
|
1637
1707
|
}
|
|
1638
1708
|
const { item, board, route } = first;
|
|
@@ -1718,7 +1788,10 @@ var FactoryDecisionDispatcher = class {
|
|
|
1718
1788
|
orgId: record.orgId,
|
|
1719
1789
|
userId: startedBy
|
|
1720
1790
|
});
|
|
1721
|
-
const session = await this.#requireSession(binding
|
|
1791
|
+
const session = await this.#requireSession(binding, {
|
|
1792
|
+
userId: startedBy,
|
|
1793
|
+
orgId: record.orgId
|
|
1794
|
+
});
|
|
1722
1795
|
const author = decision.author ? `@${decision.author}${decision.authorTrusted ? "" : " (untrusted author)"}` : decision.authorTrusted ? void 0 : "an untrusted author";
|
|
1723
1796
|
const message = decision.event === "work_item.commented" ? `New comment${author ? ` by ${author}` : ""} on ${decision.reference}: ${decision.url}` : `${decision.reference} was edited${author ? ` by ${author}` : ""}: ${decision.url}`;
|
|
1724
1797
|
const wakes = decision.authorTrusted && decision.idleBehavior !== "persist";
|
|
@@ -1797,25 +1870,29 @@ var FactoryDecisionDispatcher = class {
|
|
|
1797
1870
|
});
|
|
1798
1871
|
return this.#requireBinding(record, role);
|
|
1799
1872
|
}
|
|
1800
|
-
async #findSession(binding) {
|
|
1873
|
+
async #findSession(binding, owner) {
|
|
1801
1874
|
const session = await this.#controller.getSession(binding.sessionId);
|
|
1802
1875
|
if (!session) return void 0;
|
|
1803
|
-
await this.#switchThread(session, binding);
|
|
1876
|
+
await this.#switchThread(session, binding, owner);
|
|
1804
1877
|
return session;
|
|
1805
1878
|
}
|
|
1806
1879
|
/**
|
|
1807
|
-
*
|
|
1808
|
-
*
|
|
1880
|
+
* The tool whose pauses the run answers itself: the exit tool of the card's phase, where the
|
|
1881
|
+
* board approves it without a person for this card. Any other pause waits for a person.
|
|
1809
1882
|
*/
|
|
1810
|
-
async #
|
|
1883
|
+
async #autoApprovedExitTool({ orgId, factoryProjectId, workItemId }) {
|
|
1811
1884
|
const item = workItemId ? await this.#storage.get({
|
|
1812
1885
|
orgId,
|
|
1813
1886
|
id: workItemId
|
|
1814
1887
|
}) : null;
|
|
1815
|
-
return item
|
|
1888
|
+
return item ? autoApprovedExitTool(await this.#boards.load({
|
|
1816
1889
|
orgId,
|
|
1817
1890
|
factoryProjectId
|
|
1818
|
-
}), item)
|
|
1891
|
+
}), item) : void 0;
|
|
1892
|
+
}
|
|
1893
|
+
/** Whether a run this dispatcher watches is about to approve `toolCallId` itself, so no person needs asking. */
|
|
1894
|
+
autoApproves(toolCallId) {
|
|
1895
|
+
return this.#autoApproving.has(toolCallId);
|
|
1819
1896
|
}
|
|
1820
1897
|
/**
|
|
1821
1898
|
* Whether a run is in flight on `binding`: live here, or live on another dispatcher. An open-run
|
|
@@ -1833,7 +1910,6 @@ var FactoryDecisionDispatcher = class {
|
|
|
1833
1910
|
while (true) {
|
|
1834
1911
|
const openRun = watchRun(session, {
|
|
1835
1912
|
timeoutMs: this.#skillCompletionObservationTimeoutMs,
|
|
1836
|
-
approvePlans: false,
|
|
1837
1913
|
label,
|
|
1838
1914
|
runStillActive
|
|
1839
1915
|
});
|
|
@@ -1849,14 +1925,23 @@ var FactoryDecisionDispatcher = class {
|
|
|
1849
1925
|
await waitForSessionRunAudit(session);
|
|
1850
1926
|
}
|
|
1851
1927
|
}
|
|
1852
|
-
async #requireSession(binding) {
|
|
1853
|
-
const session = await this.#findSession(binding);
|
|
1928
|
+
async #requireSession(binding, owner) {
|
|
1929
|
+
const session = await this.#findSession(binding, owner);
|
|
1854
1930
|
if (!session) throw new FactoryDispatchError("session_unavailable", "Bound Factory session not found.");
|
|
1855
1931
|
return session;
|
|
1856
1932
|
}
|
|
1857
|
-
async #switchThread(session, binding) {
|
|
1933
|
+
async #switchThread(session, binding, owner) {
|
|
1858
1934
|
if (session.thread.requireId() === binding.threadId) return;
|
|
1859
|
-
|
|
1935
|
+
const requestContext = factoryRequestContext({
|
|
1936
|
+
session,
|
|
1937
|
+
binding,
|
|
1938
|
+
userId: owner.userId,
|
|
1939
|
+
orgId: owner.orgId
|
|
1940
|
+
});
|
|
1941
|
+
await session.thread.switch({
|
|
1942
|
+
threadId: binding.threadId,
|
|
1943
|
+
requestContext
|
|
1944
|
+
});
|
|
1860
1945
|
}
|
|
1861
1946
|
async #withBindingSkillRun(bindingId, effect) {
|
|
1862
1947
|
const run = (this.#bindingSkillRuns.get(bindingId) ?? Promise.resolve()).catch(() => {}).then(effect);
|
|
@@ -1978,7 +2063,10 @@ var FactoryDecisionDispatcher = class {
|
|
|
1978
2063
|
orgId: record.orgId,
|
|
1979
2064
|
userId: startedBy
|
|
1980
2065
|
});
|
|
1981
|
-
const session = await this.#requireSession(binding
|
|
2066
|
+
const session = await this.#requireSession(binding, {
|
|
2067
|
+
userId: startedBy,
|
|
2068
|
+
orgId: record.orgId
|
|
2069
|
+
});
|
|
1982
2070
|
const requestContext = factoryRequestContext({
|
|
1983
2071
|
session,
|
|
1984
2072
|
binding,
|
|
@@ -1988,10 +2076,11 @@ var FactoryDecisionDispatcher = class {
|
|
|
1988
2076
|
const since = /* @__PURE__ */ new Date();
|
|
1989
2077
|
const run = watchRun(session, {
|
|
1990
2078
|
timeoutMs: this.#skillCompletionObservationTimeoutMs,
|
|
1991
|
-
|
|
2079
|
+
autoApprovedTool: await this.#autoApprovedExitTool({
|
|
1992
2080
|
...record,
|
|
1993
2081
|
workItemId: binding.workItemId
|
|
1994
2082
|
}),
|
|
2083
|
+
autoApproving: this.#autoApproving,
|
|
1995
2084
|
requestContext,
|
|
1996
2085
|
label: "Factory kickoff run",
|
|
1997
2086
|
runStillActive: () => this.#controller.listActiveThreadRuns().some((active) => active.threadId === binding.threadId)
|