@mastra/factory 0.24.0-alpha.2 → 0.24.0-alpha.4

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.
Files changed (113) hide show
  1. package/README.md +23 -0
  2. package/dist/auth.d.ts +6 -0
  3. package/dist/auth.d.ts.map +1 -1
  4. package/dist/auth.js +31 -9
  5. package/dist/auth.js.map +1 -1
  6. package/dist/factory.d.ts +8 -0
  7. package/dist/factory.d.ts.map +1 -1
  8. package/dist/factory.js +50 -31
  9. package/dist/factory.js.map +1 -1
  10. package/dist/integrations/github/default-rules.d.ts.map +1 -1
  11. package/dist/integrations/github/default-rules.js +1 -16
  12. package/dist/integrations/github/default-rules.js.map +1 -1
  13. package/dist/integrations/github/sandbox-release.d.ts +15 -3
  14. package/dist/integrations/github/sandbox-release.d.ts.map +1 -1
  15. package/dist/integrations/github/sandbox-release.js +20 -3
  16. package/dist/integrations/github/sandbox-release.js.map +1 -1
  17. package/dist/integrations/github/webhook.d.ts +4 -2
  18. package/dist/integrations/github/webhook.d.ts.map +1 -1
  19. package/dist/integrations/github/webhook.js +59 -36
  20. package/dist/integrations/github/webhook.js.map +1 -1
  21. package/dist/integrations/gitlab/api.d.ts +1 -1
  22. package/dist/integrations/gitlab/api.d.ts.map +1 -1
  23. package/dist/integrations/gitlab/api.js.map +1 -1
  24. package/dist/integrations/incidentio/intake.d.ts +1 -1
  25. package/dist/integrations/incidentio/intake.d.ts.map +1 -1
  26. package/dist/integrations/incidentio/intake.js.map +1 -1
  27. package/dist/integrations/platform/connect/routes.d.ts +1 -1
  28. package/dist/integrations/platform/connect/routes.d.ts.map +1 -1
  29. package/dist/integrations/platform/connect/routes.js.map +1 -1
  30. package/dist/integrations/platform/incidentio/integration.d.ts +1 -1
  31. package/dist/integrations/platform/incidentio/integration.d.ts.map +1 -1
  32. package/dist/integrations/platform/incidentio/integration.js.map +1 -1
  33. package/dist/integrations/platform/jira/integration.d.ts +1 -1
  34. package/dist/integrations/platform/jira/integration.d.ts.map +1 -1
  35. package/dist/integrations/platform/jira/integration.js.map +1 -1
  36. package/dist/integrations/platform/linear/event-worker.d.ts +1 -1
  37. package/dist/integrations/platform/linear/event-worker.d.ts.map +1 -1
  38. package/dist/integrations/platform/linear/event-worker.js.map +1 -1
  39. package/dist/mcp/disconnect.d.ts +10 -0
  40. package/dist/mcp/disconnect.d.ts.map +1 -0
  41. package/dist/mcp/disconnect.js +44 -0
  42. package/dist/mcp/disconnect.js.map +1 -0
  43. package/dist/mcp/routes.d.ts +46 -0
  44. package/dist/mcp/routes.d.ts.map +1 -0
  45. package/dist/mcp/routes.js +243 -0
  46. package/dist/mcp/routes.js.map +1 -0
  47. package/dist/review-verdict.d.ts +11 -0
  48. package/dist/review-verdict.d.ts.map +1 -1
  49. package/dist/review-verdict.js +16 -1
  50. package/dist/review-verdict.js.map +1 -1
  51. package/dist/routes/source-control-sessions.d.ts +7 -0
  52. package/dist/routes/source-control-sessions.d.ts.map +1 -1
  53. package/dist/routes/source-control-sessions.js +121 -3
  54. package/dist/routes/source-control-sessions.js.map +1 -1
  55. package/dist/routes/surface.d.ts +2 -2
  56. package/dist/routes/surface.d.ts.map +1 -1
  57. package/dist/routes/surface.js +5 -3
  58. package/dist/routes/surface.js.map +1 -1
  59. package/dist/routes/work-items.js +6 -6
  60. package/dist/rules/dispatcher.d.ts.map +1 -1
  61. package/dist/rules/dispatcher.js +12 -3
  62. package/dist/rules/dispatcher.js.map +1 -1
  63. package/dist/rules/types.d.ts +0 -4
  64. package/dist/rules/types.d.ts.map +1 -1
  65. package/dist/rules/types.js +1 -4
  66. package/dist/rules/types.js.map +1 -1
  67. package/dist/sandbox/session-retirement.d.ts +27 -3
  68. package/dist/sandbox/session-retirement.d.ts.map +1 -1
  69. package/dist/sandbox/session-retirement.js +158 -20
  70. package/dist/sandbox/session-retirement.js.map +1 -1
  71. package/dist/session/credential-policy.d.ts +1 -1
  72. package/dist/session/credential-policy.d.ts.map +1 -1
  73. package/dist/session/credential-policy.js.map +1 -1
  74. package/dist/session/factory-session.d.ts +1 -1
  75. package/dist/session/factory-session.d.ts.map +1 -1
  76. package/dist/session/factory-session.js.map +1 -1
  77. package/dist/session/work-item-repository.d.ts +1 -1
  78. package/dist/session/work-item-repository.d.ts.map +1 -1
  79. package/dist/session/work-item-repository.js.map +1 -1
  80. package/dist/storage/domains/audit/domain.js +1 -1
  81. package/dist/storage/domains/filesystem/base.d.ts +4 -0
  82. package/dist/storage/domains/filesystem/base.d.ts.map +1 -1
  83. package/dist/storage/domains/filesystem/base.js +5 -0
  84. package/dist/storage/domains/filesystem/base.js.map +1 -1
  85. package/dist/storage/domains/work-items/base.d.ts +7 -5
  86. package/dist/storage/domains/work-items/base.d.ts.map +1 -1
  87. package/dist/storage/domains/work-items/base.js +5 -5
  88. package/dist/storage/domains/work-items/base.js.map +1 -1
  89. package/dist/timing.d.ts +23 -0
  90. package/dist/timing.d.ts.map +1 -1
  91. package/dist/timing.js +85 -6
  92. package/dist/timing.js.map +1 -1
  93. package/dist/tools/annotations.d.ts +7 -0
  94. package/dist/tools/annotations.d.ts.map +1 -0
  95. package/dist/tools/annotations.js +102 -0
  96. package/dist/tools/annotations.js.map +1 -0
  97. package/dist/tools/reports.d.ts +11 -0
  98. package/dist/tools/reports.d.ts.map +1 -1
  99. package/dist/tools/reports.js +20 -1
  100. package/dist/tools/reports.js.map +1 -1
  101. package/dist/tools/run-watch.d.ts +1 -1
  102. package/dist/tools/run-watch.d.ts.map +1 -1
  103. package/dist/tools/run-watch.js.map +1 -1
  104. package/dist/tools/session-tools.d.ts +1 -1
  105. package/dist/tools/session-tools.d.ts.map +1 -1
  106. package/dist/tools/session-tools.js +3 -3
  107. package/dist/tools/session-tools.js.map +1 -1
  108. package/dist/tools/work-item-tools.js +2 -2
  109. package/dist/workspace.d.ts +1 -1
  110. package/dist/workspace.d.ts.map +1 -1
  111. package/dist/workspace.js +10 -4
  112. package/dist/workspace.js.map +1 -1
  113. package/package.json +14 -14
@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C,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;CACtC;AAED;;;;GAIG;AACH,MAAM,WAAW,kCAAmC,SAAQ,yBAAyB;IACnF,IAAI,EAAE,qBAAqB,CAAC;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,MAAM,qBAAqB,GAC7B,yBAAyB,GACzB,kCAAkC,GAClC,mCAAmC,GACnC,0BAA0B,GAC1B,0BAA0B,GAC1B,qBAAqB,CAAC;AAE1B,MAAM,MAAM,mBAAmB,GAAG,yBAAyB,GAAG,qBAAqB,CAAC;AAEpF,MAAM,WAAW,+BAA+B;IAC9C,MAAM,EAAE,UAAU,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,gBAAgB,CAAC;IACxB,SAAS,EAAE,qBAAqB,EAAE,CAAC;CACpC;AAED,MAAM,WAAW,+BAA+B;IAC9C,MAAM,EAAE,UAAU,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,wBAAwB,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,uBAAuB,GAAG,+BAA+B,GAAG,+BAA+B,CAAC;AAExG,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,cAAc,GAAG,iBAAiB,CAmBtF"}
@@ -35,9 +35,6 @@ function externallyAuthored(item) {
35
35
  if (item.metadata?.factoryAuthored === true) return false;
36
36
  return item.metadata?.authorTrusted !== true;
37
37
  }
38
- function knownExternalAuthor(item) {
39
- return externallyAuthored(item) && item.metadata?.authorTrusted === false;
40
- }
41
38
  function externallyAuthoredWorkItem(item) {
42
39
  return externallyAuthored({
43
40
  source: workItemSource(item.externalSource),
@@ -149,6 +146,6 @@ function factoryRuleSourceForWorkItem(source) {
149
146
  }
150
147
  }
151
148
  //#endregion
152
- export { AUTO_TRIAGED_LABEL, FACTORY_GITHUB_EVENTS, FACTORY_GITLAB_EVENTS, FACTORY_INCIDENTIO_EVENTS, FACTORY_JIRA_EVENTS, FACTORY_LINEAR_EVENTS, FACTORY_ROLE_STAGES, FACTORY_RULE_BOARDS, FACTORY_RULE_SOURCES, FACTORY_RULE_STAGES, FACTORY_TRIAGE_TYPES, NEEDS_APPROVAL_LABEL, externalSourceForWorkItem, externallyAuthored, externallyAuthoredWorkItem, factoryLaneForRole, factoryRuleSourceForWorkItem, factoryRuleStage, isFactoryRole, isFactoryRuleStage, isFactoryTriageType, isTerminalFactoryRuleStage, isWorkingFactoryRuleStage, knownExternalAuthor, needsApproval, workItemSource };
149
+ export { AUTO_TRIAGED_LABEL, FACTORY_GITHUB_EVENTS, FACTORY_GITLAB_EVENTS, FACTORY_INCIDENTIO_EVENTS, FACTORY_JIRA_EVENTS, FACTORY_LINEAR_EVENTS, FACTORY_ROLE_STAGES, FACTORY_RULE_BOARDS, FACTORY_RULE_SOURCES, FACTORY_RULE_STAGES, FACTORY_TRIAGE_TYPES, NEEDS_APPROVAL_LABEL, externalSourceForWorkItem, externallyAuthored, externallyAuthoredWorkItem, factoryLaneForRole, factoryRuleSourceForWorkItem, factoryRuleStage, isFactoryRole, isFactoryRuleStage, isFactoryTriageType, isTerminalFactoryRuleStage, isWorkingFactoryRuleStage, needsApproval, workItemSource };
153
150
 
154
151
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../src/rules/types.ts"],"sourcesContent":["import type { ExternalWorkItemSource } from '../storage/domains/work-items/base.js';\n\nexport type WorkItemSource =\n | 'github-issue'\n | 'github-pr'\n | 'gitlab-issue'\n | 'gitlab-pr'\n | 'linear-issue'\n | 'jira-issue'\n | 'incidentio-follow-up'\n | 'manual';\n\nexport function externalSourceForWorkItem(\n source: WorkItemSource,\n sourceKey: string,\n url?: string,\n): ExternalWorkItemSource {\n const [integrationId, type] =\n source === 'github-pr'\n ? ['github', 'pull-request']\n : source === 'github-issue'\n ? ['github', 'issue']\n : source === 'gitlab-pr'\n ? ['gitlab', 'pull-request']\n : source === 'gitlab-issue'\n ? ['gitlab', 'issue']\n : source === 'linear-issue'\n ? ['linear', 'issue']\n : source === 'jira-issue'\n ? ['jira', 'issue']\n : source === 'incidentio-follow-up'\n ? ['incidentio', 'issue']\n : ['factory', 'manual'];\n return { integrationId, type, externalId: sourceKey, ...(url ? { url } : {}) };\n}\n\n/** The source label that holds an issue at rest until a maintainer decides; compared lowercased. */\nexport const NEEDS_APPROVAL_LABEL = 'status: needs approval';\nexport const AUTO_TRIAGED_LABEL = 'status: auto-triaged';\n\n// The label only holds a card at rest: once a person accepted it, or it sits in a working\n// lane only a person could have moved it into, the label is stale until the source catches up.\nexport function needsApproval(item: {\n metadata: Record<string, unknown> | null;\n stages?: readonly string[];\n acceptedAt?: Date | string | null;\n}): boolean {\n const labels = item.metadata?.labels;\n if (!Array.isArray(labels)) return false;\n return (\n labels.some(label => typeof label === 'string' && label.toLowerCase() === NEEDS_APPROVAL_LABEL) &&\n !item.acceptedAt &&\n (item.stages ?? ['intake']).every(stage => stage === 'intake' || stage === 'triage')\n );\n}\n\nexport function workItemSource(source: ExternalWorkItemSource | null): WorkItemSource {\n if (!source) return 'manual';\n if (source.integrationId === 'linear') return 'linear-issue';\n if (source.integrationId === 'gitlab') return source.type === 'pull-request' ? 'gitlab-pr' : 'gitlab-issue';\n if (source.integrationId === 'jira') return 'jira-issue';\n if (source.integrationId === 'incidentio') return 'incidentio-follow-up';\n // Only GitHub, GitLab, Linear, Jira, and incident.io have provider-specific\n // rules; anything else (a Slack thread, say) is a plain work item, not a\n // mislabeled GitHub issue.\n if (source.integrationId !== 'github') return 'manual';\n return source.type === 'pull-request' ? 'github-pr' : 'github-issue';\n}\n\n// Authored outside the write-access circle: a missing trust stamp fails closed until\n// the reconcile sweep backfills it, and Factory's own PRs pass through `factoryAuthored`.\nexport function externallyAuthored(item: { source: string; metadata: Record<string, unknown> | null }): boolean {\n if (!['github-pr', 'github-issue', 'gitlab-pr', 'gitlab-issue'].includes(item.source)) return false;\n if (item.metadata?.factoryAuthored === true) return false;\n return item.metadata?.authorTrusted !== true;\n}\n\n// The board mark claims only what GitHub answered: a missing stamp is silence, not an outside contribution.\nexport function knownExternalAuthor(item: { source: string; metadata: Record<string, unknown> | null }): boolean {\n return externallyAuthored(item) && item.metadata?.authorTrusted === false;\n}\n\nexport function externallyAuthoredWorkItem(item: {\n externalSource: ExternalWorkItemSource | null;\n metadata: Record<string, unknown> | null;\n}): boolean {\n return externallyAuthored({ source: workItemSource(item.externalSource), metadata: item.metadata });\n}\n\nexport const FACTORY_RULE_STAGES = ['intake', 'triage', 'planning', 'execute', 'review', 'done', 'canceled'] as const;\nexport type FactoryRuleStage = (typeof FACTORY_RULE_STAGES)[number] | (string & {});\n\n// Each role and the working stage its run holds the card in. Key order is the\n// seat pipeline order — Resume depth derives from it.\nexport const FACTORY_ROLE_STAGES = {\n triage: 'triage',\n plan: 'planning',\n work: 'execute',\n review: 'review',\n} as const satisfies Record<string, FactoryRuleStage>;\nexport type FactoryRole = keyof typeof FACTORY_ROLE_STAGES;\n\nexport function isFactoryRole(value: string): value is FactoryRole {\n return value in FACTORY_ROLE_STAGES;\n}\n\nexport const FACTORY_TRIAGE_TYPES = [\n 'bug',\n 'feature request',\n 'docs',\n 'question/support',\n 'maintenance',\n 'duplicate',\n 'resolved',\n 'invalid',\n 'spam',\n 'out-of-scope',\n 'other',\n] as const;\nexport type FactoryTriageType = (typeof FACTORY_TRIAGE_TYPES)[number];\n\nexport function isFactoryTriageType(value: unknown): value is FactoryTriageType {\n return typeof value === 'string' && FACTORY_TRIAGE_TYPES.some(type => type === value);\n}\n\nexport function isFactoryRuleStage(value: unknown): value is FactoryRuleStage {\n return typeof value === 'string' && FACTORY_RULE_STAGES.some(stage => stage === value);\n}\n\nexport function factoryRuleStage(stages: readonly string[]): FactoryRuleStage | undefined {\n const stage = stages.length === 1 ? stages[0] : undefined;\n return typeof stage === 'string' && stage.length > 0 ? stage : undefined;\n}\n\nexport function isTerminalFactoryRuleStage(stages: readonly string[]): boolean {\n const stage = factoryRuleStage(stages);\n return stage === 'done' || stage === 'canceled';\n}\n\n/** Working lanes hold cards with a seat engaged; Intake, Done and Canceled rest them. */\nexport function isWorkingFactoryRuleStage(stage: FactoryRuleStage): boolean {\n return stage !== 'intake' && !isTerminalFactoryRuleStage([stage]);\n}\n\n// Consulted only for the Intake exit: roles don't own lanes, so a card already\n// in a working or terminal lane stays put when a run starts.\nexport function factoryLaneForRole(role: string): FactoryRuleStage | undefined {\n return isFactoryRole(role) ? FACTORY_ROLE_STAGES[role] : undefined;\n}\n\nexport const FACTORY_RULE_BOARDS = ['work', 'review'] as const;\nexport type FactoryRuleBoard = (typeof FACTORY_RULE_BOARDS)[number] | (string & {});\n\nexport const FACTORY_RULE_SOURCES = [\n 'issue',\n 'pullRequest',\n 'gitlabIssue',\n 'gitlabPullRequest',\n 'linearIssue',\n 'jiraIssue',\n 'incidentioFollowUp',\n 'manual',\n] as const;\nexport type FactoryRuleSource = (typeof FACTORY_RULE_SOURCES)[number];\n\nexport const FACTORY_GITHUB_EVENTS = [\n 'issueOpened',\n 'issueEdited',\n 'issueClosed',\n 'issueCommentCreated',\n 'issueCommentEdited',\n 'issueCommentDeleted',\n 'pullRequestOpened',\n 'pullRequestUpdated',\n 'pullRequestCommentCreated',\n 'pullRequestReviewRequested',\n 'pullRequestReviewSubmitted',\n 'pullRequestMerged',\n 'pullRequestClosed',\n] as const;\nexport type FactoryGithubEventName = (typeof FACTORY_GITHUB_EVENTS)[number];\n\nexport const FACTORY_GITLAB_EVENTS = [\n 'issueOpened',\n 'issueUpdated',\n 'issueClosed',\n 'issueCommented',\n 'mergeRequestOpened',\n 'mergeRequestUpdated',\n 'mergeRequestCommented',\n 'mergeRequestMerged',\n 'mergeRequestClosed',\n] as const;\nexport type FactoryGitLabEventName = (typeof FACTORY_GITLAB_EVENTS)[number];\n\nexport const FACTORY_LINEAR_EVENTS = ['issueObserved', 'issueClosed'] as const;\nexport type FactoryLinearEventName = (typeof FACTORY_LINEAR_EVENTS)[number];\n\nexport const FACTORY_JIRA_EVENTS = ['issueObserved', 'issueClosed'] as const;\nexport type FactoryJiraEventName = (typeof FACTORY_JIRA_EVENTS)[number];\n\nexport const FACTORY_INCIDENTIO_EVENTS = ['followUpObserved', 'followUpClosed'] as const;\nexport type FactoryIncidentioEventName = (typeof FACTORY_INCIDENTIO_EVENTS)[number];\n\nexport type FactoryRuleJsonValue =\n | null\n | boolean\n | number\n | string\n | FactoryRuleJsonValue[]\n | { [key: string]: FactoryRuleJsonValue };\n\nexport interface FactoryRuleItemContext {\n id: string;\n source: WorkItemSource;\n sourceKey: string | null;\n parentWorkItemId: string | null;\n title: string;\n url: string | null;\n stages: readonly string[];\n acceptedAt: Date | null;\n /** Intake-stamped facts about the source — repository id, reporter login, labels. */\n metadata: Record<string, unknown> | null;\n}\n\nexport type FactoryRuleActor =\n | { type: 'human'; id: string }\n | { type: 'agent'; bindingId: string; role: string }\n | { type: 'github'; login: string; trusted: boolean; factoryAuthored: boolean }\n | { type: 'gitlab'; username: string; trusted: boolean; factoryAuthored: boolean }\n | { type: 'system'; id: string };\n\nexport interface FactoryRuleIngressIdentity {\n type: 'human' | 'agent' | 'toolResult' | 'github' | 'gitlab' | 'linear' | 'jira' | 'incidentio' | 'rule';\n id: string;\n}\n\nexport interface FactoryRuleCausalEntry {\n ingressId: string;\n decisionType: FactoryCommitDecision['type'];\n}\n\n/** The phase a card sits in, as its board declares it. */\nexport interface FactoryRulePhaseContext {\n id: string;\n kind: 'resting' | 'working' | 'terminal';\n /** Seat carrying a working phase; absent for resting and terminal phases. */\n role?: string;\n /** Outcome names the phase declares, e.g. `approved` or `canceled`; empty when it declares none. */\n outcomes: readonly string[];\n}\n\nexport interface FactoryRuleContextBase {\n tenant: { orgId: string; projectId: string };\n actor: FactoryRuleActor;\n ingress: FactoryRuleIngressIdentity;\n cause: string;\n causalChain: readonly FactoryRuleCausalEntry[];\n configVersion: string;\n}\n\nexport interface FactoryBoundRuleContext extends FactoryRuleContextBase {\n item: FactoryRuleItemContext;\n board: FactoryRuleBoard;\n itemRevision: number;\n}\n\nexport interface FactoryStageRuleContext extends FactoryBoundRuleContext {\n source: FactoryRuleSource;\n stage: FactoryRuleStage;\n fromStage: FactoryRuleStage;\n toStage: FactoryRuleStage;\n /** Project switch: Work items get an independent self-review before the change request opens. Unset means off. */\n selfReviewEnabled?: boolean;\n}\n\nexport interface FactoryToolResultRuleContext extends FactoryBoundRuleContext {\n toolName: string;\n threadId: string;\n assistantMessageId: string;\n toolCallId: string;\n result: {\n status: 'success' | 'error';\n value: FactoryRuleJsonValue;\n };\n}\n\nexport interface FactoryGithubRuleContext extends FactoryRuleContextBase {\n item?: FactoryRuleItemContext;\n board?: FactoryRuleBoard;\n itemRevision?: number;\n /** Where the card's board sends it when its tracked source closes. */\n boardClosure?: FactoryRuleBoardClosure;\n /** What the card's current phase means on its board; absent without a card or when the board does not declare the phase. */\n phase?: FactoryRulePhaseContext;\n /**\n * Board an issue's labels route it to, when the project has a matching label route and that board\n * is installed. Absent for pull requests and for issues whose labels select nothing.\n */\n intake?: FactoryRuleIntakeTarget;\n /**\n * Set on the one evaluation per pull request delivery that files the pull\n * request's own Review card. Opening a pull request concerns two cards — that\n * Review card and the Work item that authored the pull request — so the rule\n * answers for the two separately: the arrival carries this flag and is\n * committed against the authoring item when resolution found one, which is\n * what links the new card to it, while the authoring item's own evaluation\n * leaves the flag unset.\n */\n pullRequestIntake?: boolean;\n event: FactoryGithubEventName;\n deliveryId: string;\n factory: { createdAt: string };\n /** `installationId` is the GitHub App installation the delivery arrived through. */\n repository: { id: number; fullName: string; installationId?: number };\n issue?: {\n number: number;\n title: string;\n url: string;\n createdAt?: string;\n updatedAt?: string;\n assignees?: string[];\n labels?: string[];\n state?: 'open' | 'closed';\n /** GitHub close reason: `completed`, `not_planned`, or `duplicate`. */\n stateReason?: string;\n };\n issueChange?: { title: boolean; body: boolean };\n issueComment?: {\n id: number;\n body?: string;\n url?: string;\n author?: string;\n authorType?: string;\n createdAt?: string;\n updatedAt?: string;\n };\n pullRequest?: {\n number: number;\n title: string;\n url: string;\n createdAt?: string;\n state: 'open' | 'closed';\n draft: boolean;\n merged: boolean;\n assignees?: string[];\n requestedReviewers?: string[];\n labels?: string[];\n author?: string;\n factoryAuthored: boolean;\n headBranch: string;\n baseBranch: string;\n };\n /** Present on `pullRequestReviewRequested`: who review was (re-)requested from. */\n reviewRequest?: { reviewer: string; factoryReviewer: boolean };\n /** Present when a PR comment uses Factory's exact review command. */\n reviewCommand?: { command: 'review' | 're-review'; target: string };\n /** Present on `pullRequestReviewSubmitted`: the review that was just posted. */\n review?: { id: number; state: string; url: string; author?: string; body?: string };\n}\n\n/**\n * Where an intake source binding says new items from this source should land.\n * Absent when the source is unbound or bound without a board (built-in routing).\n */\nexport interface FactoryRuleIntakeTarget {\n board: string;\n initialPhase: string;\n}\n\n/**\n * Where a source-closed rule moves the card, from the `sourceClosed` mapping its installed board\n * declares. Absent when the card's board is not installed or declares no mapping.\n */\nexport interface FactoryRuleBoardClosure {\n /** Title of the card's board, for messages. */\n boardTitle: string;\n /** Terminal phase for a source that was completed. */\n completed: FactoryRuleBoardClosurePhase;\n /** Terminal phase for a source that was canceled or not planned. */\n canceled: FactoryRuleBoardClosurePhase;\n /** Whether the card already sits in a terminal phase of its board. */\n itemTerminal: boolean;\n}\n\nexport interface FactoryRuleBoardClosurePhase {\n phase: string;\n title: string;\n}\n\nexport interface FactoryGitLabRuleContext extends FactoryRuleContextBase {\n item?: FactoryRuleItemContext;\n board?: FactoryRuleBoard;\n itemRevision?: number;\n /** Where the card's board sends it when its tracked source closes. */\n boardClosure?: FactoryRuleBoardClosure;\n /** What the card's current phase means on its board; absent without a card or when the board does not declare the phase. */\n phase?: FactoryRulePhaseContext;\n intake?: FactoryRuleIntakeTarget;\n event: FactoryGitLabEventName;\n deliveryId: string;\n factory: { createdAt: string };\n repository: { id: number; fullName: string; host: string };\n issue?: {\n number: number;\n sourceKey: string;\n title: string;\n url: string;\n createdAt?: string;\n updatedAt?: string;\n assignees?: string[];\n labels?: string[];\n labelColors?: Record<string, string>;\n state?: 'open' | 'closed';\n author?: string;\n authorTrusted: boolean;\n };\n note?: {\n id: number;\n body?: string;\n url?: string;\n author?: string;\n createdAt?: string;\n updatedAt?: string;\n };\n mergeRequest?: {\n number: number;\n sourceKey: string;\n title: string;\n url: string;\n createdAt?: string;\n state: 'open' | 'closed';\n draft: boolean;\n merged: boolean;\n assignees?: string[];\n reviewers?: string[];\n labels?: string[];\n labelColors?: Record<string, string>;\n author?: string;\n authorTrusted: boolean;\n factoryAuthored: boolean;\n headBranch: string;\n baseBranch: string;\n };\n}\n\nexport interface FactoryLinearRuleContext extends FactoryRuleContextBase {\n item?: FactoryRuleItemContext;\n board?: FactoryRuleBoard;\n itemRevision?: number;\n /** Where the card's board sends it when its tracked source closes. */\n boardClosure?: FactoryRuleBoardClosure;\n /** What the card's current phase means on its board; absent without a card or when the board does not declare the phase. */\n phase?: FactoryRulePhaseContext;\n /** Bound board for the source this issue came from, when one is configured and installed. */\n intake?: FactoryRuleIntakeTarget;\n event: FactoryLinearEventName;\n issue: {\n id: string;\n identifier: string;\n title: string;\n url: string;\n state: string;\n stateType: string;\n priorityLabel: string;\n assignee: string | null;\n creator: string | null;\n team: string | null;\n labels: readonly string[];\n createdAt: string;\n updatedAt: string;\n sourceId?: string | null;\n projectId?: string | null;\n };\n}\n\nexport interface FactoryJiraRuleContext extends FactoryRuleContextBase {\n item?: FactoryRuleItemContext;\n board?: FactoryRuleBoard;\n itemRevision?: number;\n /** Where the card's board sends it when its tracked source closes. */\n boardClosure?: FactoryRuleBoardClosure;\n /** What the card's current phase means on its board; absent without a card or when the board does not declare the phase. */\n phase?: FactoryRulePhaseContext;\n /** Bound board for the source this issue came from, when one is configured and installed. */\n intake?: FactoryRuleIntakeTarget;\n event: FactoryJiraEventName;\n issue: {\n /** Stable issue reference — the direct integration's Jira id or the Platform-encoded issue reference. */\n id: string;\n identifier: string;\n title: string;\n url: string;\n state: string;\n stateType: string;\n priorityLabel: string;\n assignee: string | null;\n author: string | null;\n project: string | null;\n site: string | null;\n labels: readonly string[];\n createdAt: string;\n updatedAt: string;\n };\n}\n\nexport interface FactoryIncidentioRuleContext extends FactoryRuleContextBase {\n item?: FactoryRuleItemContext;\n board?: FactoryRuleBoard;\n itemRevision?: number;\n /** Where the card's board sends it when its tracked source closes. */\n boardClosure?: FactoryRuleBoardClosure;\n /** What the card's current phase means on its board; absent without a card or when the board does not declare the phase. */\n phase?: FactoryRulePhaseContext;\n /** Bound board for the source this follow-up came from, when one is configured and installed. */\n intake?: FactoryRuleIntakeTarget;\n event: FactoryIncidentioEventName;\n issue: {\n /** Stable item reference — the prefixed incident.io follow-up id the intake feed serves as `id`. */\n id: string;\n identifier: string;\n title: string;\n url: string;\n state: string;\n stateType: string;\n priorityLabel: string;\n assignee: string | null;\n author: string | null;\n /** Reference of the incident this follow-up belongs to, when available. */\n incident: string | null;\n labels: readonly string[];\n createdAt: string;\n updatedAt: string;\n };\n}\n\nexport type FactoryRuleHandler<TContext> = (\n context: Readonly<TContext>,\n) => FactoryRuleDecision | void | Promise<FactoryRuleDecision | void>;\n\nexport interface FactoryBoardRuleLeaf {\n onEnter?: FactoryRuleHandler<FactoryStageRuleContext>;\n onExit?: FactoryRuleHandler<FactoryStageRuleContext>;\n}\n\nexport type FactoryRuleRejectionCode =\n | 'forbidden'\n | 'invalid_transition'\n | 'missing_binding'\n | 'stale'\n | 'timeout'\n | 'rule_error'\n | 'causal_depth_exceeded'\n | 'repeated_transition'\n | 'approval_required';\n\nexport interface FactoryRuleRejectDecision {\n type: 'reject';\n code: FactoryRuleRejectionCode;\n reason: string;\n}\n\ninterface FactoryCommitDecisionBase {\n idempotencyKey: string;\n}\n\nexport interface FactoryTransitionDecision extends FactoryCommitDecisionBase {\n type: 'transition';\n board: FactoryRuleBoard;\n stage: FactoryRuleStage;\n /**\n * Delivered to the item's active session (waking it if idle) after the\n * transition commits. Skipped when the item has no active run binding, so\n * informational messages never fail the transition.\n */\n message?: { text: string; role?: string };\n /**\n * Runs the stage's entry rules even when the item is already in that stage.\n * A transition to the current stage is normally inert, because most callers\n * are correcting a board into a state it already holds. Re-entry is for the\n * opposite case: the stage's work is in flight and has been invalidated, so\n * it has to start over.\n */\n reenter?: boolean;\n}\n\nexport interface FactoryUpsertLinkedWorkItemDecision extends FactoryCommitDecisionBase {\n type: 'upsertLinkedWorkItem';\n board: FactoryRuleBoard;\n source: WorkItemSource;\n sourceKey: string;\n /**\n * Org-wide ownership key for the external record, when one Factory at a time\n * may hold a live card for it (a stable Linear issue id, for instance). The\n * store enforces it with a unique index, so a second project's materialization\n * is refused rather than duplicated.\n */\n claimKey?: string;\n title: string;\n url: string | null;\n stage: FactoryRuleStage;\n /**\n * File the card at `stage` as its first entry and run none of the board's\n * phase rules for it — no arrival, no destination entry. The card is filed\n * (or, if it already exists, moved) and left parked for a person; nothing is\n * started for it. For external records that arrive already past the board's\n * first step: a GitHub issue whose triage is already recorded, for instance.\n *\n * Placement is the whole decision. An existing card it reaches is moved to\n * that stage through the same relocation the label routes use, and its\n * metadata is left alone.\n */\n skipRules?: boolean;\n metadata?: Record<string, FactoryRuleJsonValue>;\n}\n\ninterface FactoryInvokeSkillDecisionBase extends FactoryCommitDecisionBase {\n type: 'invokeSkill';\n role: string;\n arguments?: string;\n precedingMessage?: string;\n cancelInFlight?: boolean;\n}\n\n/**\n * Starting an agent run. Most runs activate a skill, because the skill carries\n * the handoff contract later rules match on. A run whose completion is already\n * signalled some other way — Building finishes by opening a pull request, which\n * arrives as its own event — needs no contract, so it can carry a plain prompt\n * instead of an otherwise empty skill.\n */\nexport type FactoryInvokeSkillDecision = FactoryInvokeSkillDecisionBase &\n (\n | {\n skillName: string;\n prompt?: never;\n /**\n * Same-stage re-entry: the skill is already active in the card's live session,\n * so deliver a compact continuation that references it by name and carries only\n * the fresh arguments, instead of re-pasting the whole skill document. Only valid\n * for named-skill decisions — a plain prompt run has no active skill to resume.\n */\n resume?: boolean;\n }\n | { prompt: string; skillName?: never; resume?: never }\n );\n\nexport interface FactorySendMessageDecision extends FactoryCommitDecisionBase {\n type: 'sendMessage';\n /** Omitted: the card's live session, whichever seat holds it. Required with `prepareBinding`. */\n role?: string;\n message: string;\n priority?: 'medium' | 'high' | 'urgent';\n idleBehavior?: 'persist' | 'wake';\n prepareBinding?: boolean;\n}\n\nexport interface FactoryNotifyDecision extends FactoryCommitDecisionBase {\n type: 'notify';\n title: string;\n body?: string;\n level?: 'info' | 'warning' | 'error';\n}\n\n/**\n * Dismisses Factory change requests an approval has superseded on a GitHub\n * pull request. Only reviews carrying Factory's `Verdict: request changes`\n * marker from an identity other than the approving one are dismissed.\n */\nexport interface FactoryDismissStaleReviewsDecision extends FactoryCommitDecisionBase {\n type: 'dismissStaleReviews';\n installationId: number;\n repository: string;\n pullRequestNumber: number;\n approvingReviewId: string;\n approvingAuthor: string;\n}\n\nexport type FactoryCommitDecision =\n | FactoryTransitionDecision\n | FactoryDismissStaleReviewsDecision\n | FactoryUpsertLinkedWorkItemDecision\n | FactoryInvokeSkillDecision\n | FactorySendMessageDecision\n | FactoryNotifyDecision;\n\nexport type FactoryRuleDecision = FactoryRuleRejectDecision | FactoryCommitDecision;\n\nexport interface FactoryTransitionResultAccepted {\n status: 'accepted';\n transitionId: string;\n itemId: string;\n revision: number;\n stage: FactoryRuleStage;\n decisions: FactoryCommitDecision[];\n}\n\nexport interface FactoryTransitionResultRejected {\n status: 'rejected';\n transitionId: string;\n itemId: string;\n code: FactoryRuleRejectionCode;\n reason: string;\n}\n\nexport type FactoryTransitionResult = FactoryTransitionResultAccepted | FactoryTransitionResultRejected;\n\nexport function factoryRuleSourceForWorkItem(source: WorkItemSource): FactoryRuleSource {\n switch (source) {\n case 'github-issue':\n return 'issue';\n case 'github-pr':\n return 'pullRequest';\n case 'gitlab-issue':\n return 'gitlabIssue';\n case 'gitlab-pr':\n return 'gitlabPullRequest';\n case 'linear-issue':\n return 'linearIssue';\n case 'jira-issue':\n return 'jiraIssue';\n case 'incidentio-follow-up':\n return 'incidentioFollowUp';\n case 'manual':\n return 'manual';\n }\n}\n"],"mappings":";AAYA,SAAgB,0BACd,QACA,WACA,KACwB;CACxB,MAAM,CAAC,eAAe,QACpB,WAAW,cACP,CAAC,UAAU,cAAc,IACzB,WAAW,iBACT,CAAC,UAAU,OAAO,IAClB,WAAW,cACT,CAAC,UAAU,cAAc,IACzB,WAAW,iBACT,CAAC,UAAU,OAAO,IAClB,WAAW,iBACT,CAAC,UAAU,OAAO,IAClB,WAAW,eACT,CAAC,QAAQ,OAAO,IAChB,WAAW,yBACT,CAAC,cAAc,OAAO,IACtB,CAAC,WAAW,QAAQ;CACtC,OAAO;EAAE;EAAe;EAAM,YAAY;EAAW,GAAI,MAAM,EAAE,IAAI,IAAI,CAAC;CAAG;AAC/E;;AAGA,MAAa,uBAAuB;AACpC,MAAa,qBAAqB;AAIlC,SAAgB,cAAc,MAIlB;CACV,MAAM,SAAS,KAAK,UAAU;CAC9B,IAAI,CAAC,MAAM,QAAQ,MAAM,GAAG,OAAO;CACnC,OACE,OAAO,MAAK,UAAS,OAAO,UAAU,YAAY,MAAM,YAAY,MAAA,wBAA0B,KAC9F,CAAC,KAAK,eACL,KAAK,UAAU,CAAC,QAAQ,EAAA,CAAG,OAAM,UAAS,UAAU,YAAY,UAAU,QAAQ;AAEvF;AAEA,SAAgB,eAAe,QAAuD;CACpF,IAAI,CAAC,QAAQ,OAAO;CACpB,IAAI,OAAO,kBAAkB,UAAU,OAAO;CAC9C,IAAI,OAAO,kBAAkB,UAAU,OAAO,OAAO,SAAS,iBAAiB,cA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;CAC7E,MAAM,QAAQ,iBAAiB,MAAM;CACrC,OAAO,UAAU,UAAU,UAAU;AACvC;;AAGA,SAAgB,0BAA0B,OAAkC;CAC1E,OAAO,UAAU,YAAY,CAAC,2BAA2B,CAAC,KAAK,CAAC;AAClE;AAIA,SAAgB,mBAAmB,MAA4C;CAC7E,OAAO,cAAc,IAAI,IAAI,oBAAoB,QAAQ,KAAA;AAC3D;AAEA,MAAa,sBAAsB,CAAC,QAAQ,QAAQ;AAGpD,MAAa,uBAAuB;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAGA,MAAa,wBAAwB;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAGA,MAAa,wBAAwB;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAGA,MAAa,wBAAwB,CAAC,iBAAiB,aAAa;AAGpE,MAAa,sBAAsB,CAAC,iBAAiB,aAAa;AAGlE,MAAa,4BAA4B,CAAC,oBAAoB,gBAAgB;AA0f9E,SAAgB,6BAA6B,QAA2C;CACtF,QAAQ,QAAR;EACE,KAAK,gBACH,OAAO;EACT,KAAK,aACH,OAAO;EACT,KAAK,gBACH,OAAO;EACT,KAAK,aACH,OAAO;EACT,KAAK,gBACH,OAAO;EACT,KAAK,cACH,OAAO;EACT,KAAK,wBACH,OAAO;EACT,KAAK,UACH,OAAO;CACX;AACF"}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../src/rules/types.ts"],"sourcesContent":["import type { ExternalWorkItemSource } from '../storage/domains/work-items/base.js';\n\nexport type WorkItemSource =\n | 'github-issue'\n | 'github-pr'\n | 'gitlab-issue'\n | 'gitlab-pr'\n | 'linear-issue'\n | 'jira-issue'\n | 'incidentio-follow-up'\n | 'manual';\n\nexport function externalSourceForWorkItem(\n source: WorkItemSource,\n sourceKey: string,\n url?: string,\n): ExternalWorkItemSource {\n const [integrationId, type] =\n source === 'github-pr'\n ? ['github', 'pull-request']\n : source === 'github-issue'\n ? ['github', 'issue']\n : source === 'gitlab-pr'\n ? ['gitlab', 'pull-request']\n : source === 'gitlab-issue'\n ? ['gitlab', 'issue']\n : source === 'linear-issue'\n ? ['linear', 'issue']\n : source === 'jira-issue'\n ? ['jira', 'issue']\n : source === 'incidentio-follow-up'\n ? ['incidentio', 'issue']\n : ['factory', 'manual'];\n return { integrationId, type, externalId: sourceKey, ...(url ? { url } : {}) };\n}\n\n/** The source label that holds an issue at rest until a maintainer decides; compared lowercased. */\nexport const NEEDS_APPROVAL_LABEL = 'status: needs approval';\nexport const AUTO_TRIAGED_LABEL = 'status: auto-triaged';\n\n// The label only holds a card at rest: once a person accepted it, or it sits in a working\n// lane only a person could have moved it into, the label is stale until the source catches up.\nexport function needsApproval(item: {\n metadata: Record<string, unknown> | null;\n stages?: readonly string[];\n acceptedAt?: Date | string | null;\n}): boolean {\n const labels = item.metadata?.labels;\n if (!Array.isArray(labels)) return false;\n return (\n labels.some(label => typeof label === 'string' && label.toLowerCase() === NEEDS_APPROVAL_LABEL) &&\n !item.acceptedAt &&\n (item.stages ?? ['intake']).every(stage => stage === 'intake' || stage === 'triage')\n );\n}\n\nexport function workItemSource(source: ExternalWorkItemSource | null): WorkItemSource {\n if (!source) return 'manual';\n if (source.integrationId === 'linear') return 'linear-issue';\n if (source.integrationId === 'gitlab') return source.type === 'pull-request' ? 'gitlab-pr' : 'gitlab-issue';\n if (source.integrationId === 'jira') return 'jira-issue';\n if (source.integrationId === 'incidentio') return 'incidentio-follow-up';\n // Only GitHub, GitLab, Linear, Jira, and incident.io have provider-specific\n // rules; anything else (a Slack thread, say) is a plain work item, not a\n // mislabeled GitHub issue.\n if (source.integrationId !== 'github') return 'manual';\n return source.type === 'pull-request' ? 'github-pr' : 'github-issue';\n}\n\n// Authored outside the write-access circle: a missing trust stamp fails closed until\n// the reconcile sweep backfills it, and Factory's own PRs pass through `factoryAuthored`.\nexport function externallyAuthored(item: { source: string; metadata: Record<string, unknown> | null }): boolean {\n if (!['github-pr', 'github-issue', 'gitlab-pr', 'gitlab-issue'].includes(item.source)) return false;\n if (item.metadata?.factoryAuthored === true) return false;\n return item.metadata?.authorTrusted !== true;\n}\n\nexport function externallyAuthoredWorkItem(item: {\n externalSource: ExternalWorkItemSource | null;\n metadata: Record<string, unknown> | null;\n}): boolean {\n return externallyAuthored({ source: workItemSource(item.externalSource), metadata: item.metadata });\n}\n\nexport const FACTORY_RULE_STAGES = ['intake', 'triage', 'planning', 'execute', 'review', 'done', 'canceled'] as const;\nexport type FactoryRuleStage = (typeof FACTORY_RULE_STAGES)[number] | (string & {});\n\n// Each role and the working stage its run holds the card in. Key order is the\n// seat pipeline order — Resume depth derives from it.\nexport const FACTORY_ROLE_STAGES = {\n triage: 'triage',\n plan: 'planning',\n work: 'execute',\n review: 'review',\n} as const satisfies Record<string, FactoryRuleStage>;\nexport type FactoryRole = keyof typeof FACTORY_ROLE_STAGES;\n\nexport function isFactoryRole(value: string): value is FactoryRole {\n return value in FACTORY_ROLE_STAGES;\n}\n\nexport const FACTORY_TRIAGE_TYPES = [\n 'bug',\n 'feature request',\n 'docs',\n 'question/support',\n 'maintenance',\n 'duplicate',\n 'resolved',\n 'invalid',\n 'spam',\n 'out-of-scope',\n 'other',\n] as const;\nexport type FactoryTriageType = (typeof FACTORY_TRIAGE_TYPES)[number];\n\nexport function isFactoryTriageType(value: unknown): value is FactoryTriageType {\n return typeof value === 'string' && FACTORY_TRIAGE_TYPES.some(type => type === value);\n}\n\nexport function isFactoryRuleStage(value: unknown): value is FactoryRuleStage {\n return typeof value === 'string' && FACTORY_RULE_STAGES.some(stage => stage === value);\n}\n\nexport function factoryRuleStage(stages: readonly string[]): FactoryRuleStage | undefined {\n const stage = stages.length === 1 ? stages[0] : undefined;\n return typeof stage === 'string' && stage.length > 0 ? stage : undefined;\n}\n\nexport function isTerminalFactoryRuleStage(stages: readonly string[]): boolean {\n const stage = factoryRuleStage(stages);\n return stage === 'done' || stage === 'canceled';\n}\n\n/** Working lanes hold cards with a seat engaged; Intake, Done and Canceled rest them. */\nexport function isWorkingFactoryRuleStage(stage: FactoryRuleStage): boolean {\n return stage !== 'intake' && !isTerminalFactoryRuleStage([stage]);\n}\n\n// Consulted only for the Intake exit: roles don't own lanes, so a card already\n// in a working or terminal lane stays put when a run starts.\nexport function factoryLaneForRole(role: string): FactoryRuleStage | undefined {\n return isFactoryRole(role) ? FACTORY_ROLE_STAGES[role] : undefined;\n}\n\nexport const FACTORY_RULE_BOARDS = ['work', 'review'] as const;\nexport type FactoryRuleBoard = (typeof FACTORY_RULE_BOARDS)[number] | (string & {});\n\nexport const FACTORY_RULE_SOURCES = [\n 'issue',\n 'pullRequest',\n 'gitlabIssue',\n 'gitlabPullRequest',\n 'linearIssue',\n 'jiraIssue',\n 'incidentioFollowUp',\n 'manual',\n] as const;\nexport type FactoryRuleSource = (typeof FACTORY_RULE_SOURCES)[number];\n\nexport const FACTORY_GITHUB_EVENTS = [\n 'issueOpened',\n 'issueEdited',\n 'issueClosed',\n 'issueCommentCreated',\n 'issueCommentEdited',\n 'issueCommentDeleted',\n 'pullRequestOpened',\n 'pullRequestUpdated',\n 'pullRequestCommentCreated',\n 'pullRequestReviewRequested',\n 'pullRequestReviewSubmitted',\n 'pullRequestMerged',\n 'pullRequestClosed',\n] as const;\nexport type FactoryGithubEventName = (typeof FACTORY_GITHUB_EVENTS)[number];\n\nexport const FACTORY_GITLAB_EVENTS = [\n 'issueOpened',\n 'issueUpdated',\n 'issueClosed',\n 'issueCommented',\n 'mergeRequestOpened',\n 'mergeRequestUpdated',\n 'mergeRequestCommented',\n 'mergeRequestMerged',\n 'mergeRequestClosed',\n] as const;\nexport type FactoryGitLabEventName = (typeof FACTORY_GITLAB_EVENTS)[number];\n\nexport const FACTORY_LINEAR_EVENTS = ['issueObserved', 'issueClosed'] as const;\nexport type FactoryLinearEventName = (typeof FACTORY_LINEAR_EVENTS)[number];\n\nexport const FACTORY_JIRA_EVENTS = ['issueObserved', 'issueClosed'] as const;\nexport type FactoryJiraEventName = (typeof FACTORY_JIRA_EVENTS)[number];\n\nexport const FACTORY_INCIDENTIO_EVENTS = ['followUpObserved', 'followUpClosed'] as const;\nexport type FactoryIncidentioEventName = (typeof FACTORY_INCIDENTIO_EVENTS)[number];\n\nexport type FactoryRuleJsonValue =\n | null\n | boolean\n | number\n | string\n | FactoryRuleJsonValue[]\n | { [key: string]: FactoryRuleJsonValue };\n\nexport interface FactoryRuleItemContext {\n id: string;\n source: WorkItemSource;\n sourceKey: string | null;\n parentWorkItemId: string | null;\n title: string;\n url: string | null;\n stages: readonly string[];\n acceptedAt: Date | null;\n /** Intake-stamped facts about the source — repository id, reporter login, labels. */\n metadata: Record<string, unknown> | null;\n}\n\nexport type FactoryRuleActor =\n | { type: 'human'; id: string }\n | { type: 'agent'; bindingId: string; role: string }\n | { type: 'github'; login: string; trusted: boolean; factoryAuthored: boolean }\n | { type: 'gitlab'; username: string; trusted: boolean; factoryAuthored: boolean }\n | { type: 'system'; id: string };\n\nexport interface FactoryRuleIngressIdentity {\n type: 'human' | 'agent' | 'toolResult' | 'github' | 'gitlab' | 'linear' | 'jira' | 'incidentio' | 'rule';\n id: string;\n}\n\nexport interface FactoryRuleCausalEntry {\n ingressId: string;\n decisionType: FactoryCommitDecision['type'];\n}\n\n/** The phase a card sits in, as its board declares it. */\nexport interface FactoryRulePhaseContext {\n id: string;\n kind: 'resting' | 'working' | 'terminal';\n /** Seat carrying a working phase; absent for resting and terminal phases. */\n role?: string;\n /** Outcome names the phase declares, e.g. `approved` or `canceled`; empty when it declares none. */\n outcomes: readonly string[];\n}\n\nexport interface FactoryRuleContextBase {\n tenant: { orgId: string; projectId: string };\n actor: FactoryRuleActor;\n ingress: FactoryRuleIngressIdentity;\n cause: string;\n causalChain: readonly FactoryRuleCausalEntry[];\n configVersion: string;\n}\n\nexport interface FactoryBoundRuleContext extends FactoryRuleContextBase {\n item: FactoryRuleItemContext;\n board: FactoryRuleBoard;\n itemRevision: number;\n}\n\nexport interface FactoryStageRuleContext extends FactoryBoundRuleContext {\n source: FactoryRuleSource;\n stage: FactoryRuleStage;\n fromStage: FactoryRuleStage;\n toStage: FactoryRuleStage;\n /** Project switch: Work items get an independent self-review before the change request opens. Unset means off. */\n selfReviewEnabled?: boolean;\n}\n\nexport interface FactoryToolResultRuleContext extends FactoryBoundRuleContext {\n toolName: string;\n threadId: string;\n assistantMessageId: string;\n toolCallId: string;\n result: {\n status: 'success' | 'error';\n value: FactoryRuleJsonValue;\n };\n}\n\nexport interface FactoryGithubRuleContext extends FactoryRuleContextBase {\n item?: FactoryRuleItemContext;\n board?: FactoryRuleBoard;\n itemRevision?: number;\n /** Where the card's board sends it when its tracked source closes. */\n boardClosure?: FactoryRuleBoardClosure;\n /** What the card's current phase means on its board; absent without a card or when the board does not declare the phase. */\n phase?: FactoryRulePhaseContext;\n /**\n * Board an issue's labels route it to, when the project has a matching label route and that board\n * is installed. Absent for pull requests and for issues whose labels select nothing.\n */\n intake?: FactoryRuleIntakeTarget;\n /**\n * Set on the one evaluation per pull request delivery that files the pull\n * request's own Review card. Opening a pull request concerns two cards — that\n * Review card and the Work item that authored the pull request — so the rule\n * answers for the two separately: the arrival carries this flag and is\n * committed against the authoring item when resolution found one, which is\n * what links the new card to it, while the authoring item's own evaluation\n * leaves the flag unset.\n */\n pullRequestIntake?: boolean;\n event: FactoryGithubEventName;\n deliveryId: string;\n factory: { createdAt: string };\n /** `installationId` is the GitHub App installation the delivery arrived through. */\n repository: { id: number; fullName: string; installationId?: number };\n issue?: {\n number: number;\n title: string;\n url: string;\n createdAt?: string;\n updatedAt?: string;\n assignees?: string[];\n labels?: string[];\n state?: 'open' | 'closed';\n /** GitHub close reason: `completed`, `not_planned`, or `duplicate`. */\n stateReason?: string;\n };\n issueChange?: { title: boolean; body: boolean };\n issueComment?: {\n id: number;\n body?: string;\n url?: string;\n author?: string;\n authorType?: string;\n createdAt?: string;\n updatedAt?: string;\n };\n pullRequest?: {\n number: number;\n title: string;\n url: string;\n createdAt?: string;\n state: 'open' | 'closed';\n draft: boolean;\n merged: boolean;\n assignees?: string[];\n requestedReviewers?: string[];\n labels?: string[];\n author?: string;\n factoryAuthored: boolean;\n headBranch: string;\n baseBranch: string;\n };\n /** Present on `pullRequestReviewRequested`: who review was (re-)requested from. */\n reviewRequest?: { reviewer: string; factoryReviewer: boolean };\n /** Present when a PR comment uses Factory's exact review command. */\n reviewCommand?: { command: 'review' | 're-review'; target: string };\n /** Present on `pullRequestReviewSubmitted`: the review that was just posted. */\n review?: { id: number; state: string; url: string; author?: string; body?: string };\n}\n\n/**\n * Where an intake source binding says new items from this source should land.\n * Absent when the source is unbound or bound without a board (built-in routing).\n */\nexport interface FactoryRuleIntakeTarget {\n board: string;\n initialPhase: string;\n}\n\n/**\n * Where a source-closed rule moves the card, from the `sourceClosed` mapping its installed board\n * declares. Absent when the card's board is not installed or declares no mapping.\n */\nexport interface FactoryRuleBoardClosure {\n /** Title of the card's board, for messages. */\n boardTitle: string;\n /** Terminal phase for a source that was completed. */\n completed: FactoryRuleBoardClosurePhase;\n /** Terminal phase for a source that was canceled or not planned. */\n canceled: FactoryRuleBoardClosurePhase;\n /** Whether the card already sits in a terminal phase of its board. */\n itemTerminal: boolean;\n}\n\nexport interface FactoryRuleBoardClosurePhase {\n phase: string;\n title: string;\n}\n\nexport interface FactoryGitLabRuleContext extends FactoryRuleContextBase {\n item?: FactoryRuleItemContext;\n board?: FactoryRuleBoard;\n itemRevision?: number;\n /** Where the card's board sends it when its tracked source closes. */\n boardClosure?: FactoryRuleBoardClosure;\n /** What the card's current phase means on its board; absent without a card or when the board does not declare the phase. */\n phase?: FactoryRulePhaseContext;\n intake?: FactoryRuleIntakeTarget;\n event: FactoryGitLabEventName;\n deliveryId: string;\n factory: { createdAt: string };\n repository: { id: number; fullName: string; host: string };\n issue?: {\n number: number;\n sourceKey: string;\n title: string;\n url: string;\n createdAt?: string;\n updatedAt?: string;\n assignees?: string[];\n labels?: string[];\n labelColors?: Record<string, string>;\n state?: 'open' | 'closed';\n author?: string;\n authorTrusted: boolean;\n };\n note?: {\n id: number;\n body?: string;\n url?: string;\n author?: string;\n createdAt?: string;\n updatedAt?: string;\n };\n mergeRequest?: {\n number: number;\n sourceKey: string;\n title: string;\n url: string;\n createdAt?: string;\n state: 'open' | 'closed';\n draft: boolean;\n merged: boolean;\n assignees?: string[];\n reviewers?: string[];\n labels?: string[];\n labelColors?: Record<string, string>;\n author?: string;\n authorTrusted: boolean;\n factoryAuthored: boolean;\n headBranch: string;\n baseBranch: string;\n };\n}\n\nexport interface FactoryLinearRuleContext extends FactoryRuleContextBase {\n item?: FactoryRuleItemContext;\n board?: FactoryRuleBoard;\n itemRevision?: number;\n /** Where the card's board sends it when its tracked source closes. */\n boardClosure?: FactoryRuleBoardClosure;\n /** What the card's current phase means on its board; absent without a card or when the board does not declare the phase. */\n phase?: FactoryRulePhaseContext;\n /** Bound board for the source this issue came from, when one is configured and installed. */\n intake?: FactoryRuleIntakeTarget;\n event: FactoryLinearEventName;\n issue: {\n id: string;\n identifier: string;\n title: string;\n url: string;\n state: string;\n stateType: string;\n priorityLabel: string;\n assignee: string | null;\n creator: string | null;\n team: string | null;\n labels: readonly string[];\n createdAt: string;\n updatedAt: string;\n sourceId?: string | null;\n projectId?: string | null;\n };\n}\n\nexport interface FactoryJiraRuleContext extends FactoryRuleContextBase {\n item?: FactoryRuleItemContext;\n board?: FactoryRuleBoard;\n itemRevision?: number;\n /** Where the card's board sends it when its tracked source closes. */\n boardClosure?: FactoryRuleBoardClosure;\n /** What the card's current phase means on its board; absent without a card or when the board does not declare the phase. */\n phase?: FactoryRulePhaseContext;\n /** Bound board for the source this issue came from, when one is configured and installed. */\n intake?: FactoryRuleIntakeTarget;\n event: FactoryJiraEventName;\n issue: {\n /** Stable issue reference — the direct integration's Jira id or the Platform-encoded issue reference. */\n id: string;\n identifier: string;\n title: string;\n url: string;\n state: string;\n stateType: string;\n priorityLabel: string;\n assignee: string | null;\n author: string | null;\n project: string | null;\n site: string | null;\n labels: readonly string[];\n createdAt: string;\n updatedAt: string;\n };\n}\n\nexport interface FactoryIncidentioRuleContext extends FactoryRuleContextBase {\n item?: FactoryRuleItemContext;\n board?: FactoryRuleBoard;\n itemRevision?: number;\n /** Where the card's board sends it when its tracked source closes. */\n boardClosure?: FactoryRuleBoardClosure;\n /** What the card's current phase means on its board; absent without a card or when the board does not declare the phase. */\n phase?: FactoryRulePhaseContext;\n /** Bound board for the source this follow-up came from, when one is configured and installed. */\n intake?: FactoryRuleIntakeTarget;\n event: FactoryIncidentioEventName;\n issue: {\n /** Stable item reference — the prefixed incident.io follow-up id the intake feed serves as `id`. */\n id: string;\n identifier: string;\n title: string;\n url: string;\n state: string;\n stateType: string;\n priorityLabel: string;\n assignee: string | null;\n author: string | null;\n /** Reference of the incident this follow-up belongs to, when available. */\n incident: string | null;\n labels: readonly string[];\n createdAt: string;\n updatedAt: string;\n };\n}\n\nexport type FactoryRuleHandler<TContext> = (\n context: Readonly<TContext>,\n) => FactoryRuleDecision | void | Promise<FactoryRuleDecision | void>;\n\nexport interface FactoryBoardRuleLeaf {\n onEnter?: FactoryRuleHandler<FactoryStageRuleContext>;\n onExit?: FactoryRuleHandler<FactoryStageRuleContext>;\n}\n\nexport type FactoryRuleRejectionCode =\n | 'forbidden'\n | 'invalid_transition'\n | 'missing_binding'\n | 'stale'\n | 'timeout'\n | 'rule_error'\n | 'causal_depth_exceeded'\n | 'repeated_transition'\n | 'approval_required';\n\nexport interface FactoryRuleRejectDecision {\n type: 'reject';\n code: FactoryRuleRejectionCode;\n reason: string;\n}\n\ninterface FactoryCommitDecisionBase {\n idempotencyKey: string;\n}\n\nexport interface FactoryTransitionDecision extends FactoryCommitDecisionBase {\n type: 'transition';\n board: FactoryRuleBoard;\n stage: FactoryRuleStage;\n /**\n * Delivered to the item's active session (waking it if idle) after the\n * transition commits. Skipped when the item has no active run binding, so\n * informational messages never fail the transition.\n */\n message?: { text: string; role?: string };\n /**\n * Runs the stage's entry rules even when the item is already in that stage.\n * A transition to the current stage is normally inert, because most callers\n * are correcting a board into a state it already holds. Re-entry is for the\n * opposite case: the stage's work is in flight and has been invalidated, so\n * it has to start over.\n */\n reenter?: boolean;\n}\n\nexport interface FactoryUpsertLinkedWorkItemDecision extends FactoryCommitDecisionBase {\n type: 'upsertLinkedWorkItem';\n board: FactoryRuleBoard;\n source: WorkItemSource;\n sourceKey: string;\n /**\n * Org-wide ownership key for the external record, when one Factory at a time\n * may hold a live card for it (a stable Linear issue id, for instance). The\n * store enforces it with a unique index, so a second project's materialization\n * is refused rather than duplicated.\n */\n claimKey?: string;\n title: string;\n url: string | null;\n stage: FactoryRuleStage;\n /**\n * File the card at `stage` as its first entry and run none of the board's\n * phase rules for it — no arrival, no destination entry. The card is filed\n * (or, if it already exists, moved) and left parked for a person; nothing is\n * started for it. For external records that arrive already past the board's\n * first step: a GitHub issue whose triage is already recorded, for instance.\n *\n * Placement is the whole decision. An existing card it reaches is moved to\n * that stage through the same relocation the label routes use, and its\n * metadata is left alone.\n */\n skipRules?: boolean;\n metadata?: Record<string, FactoryRuleJsonValue>;\n}\n\ninterface FactoryInvokeSkillDecisionBase extends FactoryCommitDecisionBase {\n type: 'invokeSkill';\n role: string;\n arguments?: string;\n precedingMessage?: string;\n cancelInFlight?: boolean;\n}\n\n/**\n * Starting an agent run. Most runs activate a skill, because the skill carries\n * the handoff contract later rules match on. A run whose completion is already\n * signalled some other way — Building finishes by opening a pull request, which\n * arrives as its own event — needs no contract, so it can carry a plain prompt\n * instead of an otherwise empty skill.\n */\nexport type FactoryInvokeSkillDecision = FactoryInvokeSkillDecisionBase &\n (\n | {\n skillName: string;\n prompt?: never;\n /**\n * Same-stage re-entry: the skill is already active in the card's live session,\n * so deliver a compact continuation that references it by name and carries only\n * the fresh arguments, instead of re-pasting the whole skill document. Only valid\n * for named-skill decisions — a plain prompt run has no active skill to resume.\n */\n resume?: boolean;\n }\n | { prompt: string; skillName?: never; resume?: never }\n );\n\nexport interface FactorySendMessageDecision extends FactoryCommitDecisionBase {\n type: 'sendMessage';\n /** Omitted: the card's live session, whichever seat holds it. Required with `prepareBinding`. */\n role?: string;\n message: string;\n priority?: 'medium' | 'high' | 'urgent';\n idleBehavior?: 'persist' | 'wake';\n prepareBinding?: boolean;\n}\n\nexport interface FactoryNotifyDecision extends FactoryCommitDecisionBase {\n type: 'notify';\n title: string;\n body?: string;\n level?: 'info' | 'warning' | 'error';\n}\n\n/**\n * Dismisses Factory change requests an approval has superseded on a GitHub\n * pull request. Only reviews carrying Factory's `Verdict: request changes`\n * marker from an identity other than the approving one are dismissed.\n */\nexport interface FactoryDismissStaleReviewsDecision extends FactoryCommitDecisionBase {\n type: 'dismissStaleReviews';\n installationId: number;\n repository: string;\n pullRequestNumber: number;\n approvingReviewId: string;\n approvingAuthor: string;\n}\n\nexport type FactoryCommitDecision =\n | FactoryTransitionDecision\n | FactoryDismissStaleReviewsDecision\n | FactoryUpsertLinkedWorkItemDecision\n | FactoryInvokeSkillDecision\n | FactorySendMessageDecision\n | FactoryNotifyDecision;\n\nexport type FactoryRuleDecision = FactoryRuleRejectDecision | FactoryCommitDecision;\n\nexport interface FactoryTransitionResultAccepted {\n status: 'accepted';\n transitionId: string;\n itemId: string;\n revision: number;\n stage: FactoryRuleStage;\n decisions: FactoryCommitDecision[];\n}\n\nexport interface FactoryTransitionResultRejected {\n status: 'rejected';\n transitionId: string;\n itemId: string;\n code: FactoryRuleRejectionCode;\n reason: string;\n}\n\nexport type FactoryTransitionResult = FactoryTransitionResultAccepted | FactoryTransitionResultRejected;\n\nexport function factoryRuleSourceForWorkItem(source: WorkItemSource): FactoryRuleSource {\n switch (source) {\n case 'github-issue':\n return 'issue';\n case 'github-pr':\n return 'pullRequest';\n case 'gitlab-issue':\n return 'gitlabIssue';\n case 'gitlab-pr':\n return 'gitlabPullRequest';\n case 'linear-issue':\n return 'linearIssue';\n case 'jira-issue':\n return 'jiraIssue';\n case 'incidentio-follow-up':\n return 'incidentioFollowU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,MAAa,wBAAwB;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAGA,MAAa,wBAAwB;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAGA,MAAa,wBAAwB,CAAC,iBAAiB,aAAa;AAGpE,MAAa,sBAAsB,CAAC,iBAAiB,aAAa;AAGlE,MAAa,4BAA4B,CAAC,oBAAoB,gBAAgB;AA0f9E,SAAgB,6BAA6B,QAA2C;CACtF,QAAQ,QAAR;EACE,KAAK,gBACH,OAAO;EACT,KAAK,aACH,OAAO;EACT,KAAK,gBACH,OAAO;EACT,KAAK,aACH,OAAO;EACT,KAAK,gBACH,OAAO;EACT,KAAK,cACH,OAAO;EACT,KAAK,wBACH,OAAO;EACT,KAAK,UACH,OAAO;CACX;AACF"}
@@ -1,9 +1,23 @@
1
+ import type { FactorySandbox } from '@mastra/core/workspace';
1
2
  import type { SourceControlStorageHandle } from '../storage/domains/source-control/base.js';
2
3
  import type { WorkItemsStorage } from '../storage/domains/work-items/base.js';
3
4
  type WarningLogger = (message: string, details: Record<string, unknown>) => void;
4
5
  export interface SessionRetirementCoordinatorOptions {
5
6
  invalidateSession?: (sessionId: string) => Promise<void> | void;
7
+ /**
8
+ * The deploy's sandbox configuration. Used to destroy a deleted session's
9
+ * VM by identity when this process never attached to it (after a restart,
10
+ * or on another replica). Recreate uses it the same way.
11
+ */
12
+ sandbox?: FactorySandbox;
6
13
  warn?: WarningLogger;
14
+ /** How long recreate waits on a started sandbox's lifecycle destroy before falling back. */
15
+ destroyTimeoutMs?: number;
16
+ }
17
+ export interface RecreateSessionSandboxInput {
18
+ sourceControl: SourceControlStorageHandle;
19
+ orgId: string;
20
+ sessionId: string;
7
21
  }
8
22
  export interface RetireSessionInput {
9
23
  sourceControl: SourceControlStorageHandle;
@@ -20,14 +34,24 @@ export interface RetireSessionInput {
20
34
  *
21
35
  * Sandbox identity is the session id: retirement stops (or, for deleted
22
36
  * sessions, destroys) the sandbox this process holds in the session memo.
23
- * Sessions opened on another replica have no memo entry here — their VMs are
24
- * left to the provider's idle lifecycle (pause / idle GC), which is the
25
- * provider-owned half of the contract.
37
+ * Sessions opened on another replica (or before a restart) have no memo entry
38
+ * here: stopping them is left to the provider's idle lifecycle, but deleting a
39
+ * materialized session destroys its VM by identity through the configured
40
+ * sandbox. Providers such as E2B keep paused VMs forever, so the row's
41
+ * deletion must never orphan one.
26
42
  */
27
43
  export declare class SessionRetirementCoordinator {
28
44
  #private;
29
45
  constructor(options?: SessionRetirementCoordinatorOptions);
30
46
  retireSession(input: RetireSessionInput): Promise<void>;
47
+ /**
48
+ * Destroy a session's sandbox so its next message boots a fresh VM from the
49
+ * template, keeping the session row, its conversation, and work-item refs.
50
+ * Skips teardown commands, and works without a memo entry in this process
51
+ * by destroying a detached instance built from the persisted `sandboxId`.
52
+ * A destroy failure keeps the persisted id so a retry can reach the VM.
53
+ */
54
+ recreateSessionSandbox(input: RecreateSessionSandboxInput): Promise<'recreated' | 'not-found'>;
31
55
  retireWorkItemSessions(options: {
32
56
  workItems: Pick<WorkItemsStorage, 'get'>;
33
57
  sourceControl: SourceControlStorageHandle;
@@ -1 +1 @@
1
- {"version":3,"file":"session-retirement.d.ts","sourceRoot":"","sources":["../../src/sandbox/session-retirement.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAGV,0BAA0B,EAC3B,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAI9E,KAAK,aAAa,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;AAEjF,MAAM,WAAW,mCAAmC;IAClD,iBAAiB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAChE,IAAI,CAAC,EAAE,aAAa,CAAC;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AC,gBAAgB,EAAE,wBAAwB,CAAC,CAAC;QAC7D,KAAK,EAAE,MAAM,CAAC;QACd,mBAAmB,EAAE,MAAM,CAAC;KAC7B,GAAG,OAAO,CAAC,IAAI,CAAC;CAkPlB"}
@@ -1,9 +1,21 @@
1
1
  import { DEFAULT_COMMAND_TIMEOUT_MS, runTeardownCommand } from "../integrations/github/sandbox.js";
2
2
  import { requireExec } from "./materialization.js";
3
- import { peekSessionSandbox } from "./session-sandbox.js";
3
+ import { evictSessionSandbox, peekSessionSandbox } from "./session-sandbox.js";
4
4
  import { peekSessionEnvironmentTeardown } from "../session/environment-state-processor.js";
5
- import { releaseSessionSandbox } from "../integrations/github/sandbox-release.js";
5
+ import { destroyDetachedSessionSandbox, releaseSessionSandbox } from "../integrations/github/sandbox-release.js";
6
6
  //#region src/sandbox/session-retirement.ts
7
+ const DEFAULT_DESTROY_TIMEOUT_MS = 3e4;
8
+ /**
9
+ * A provider error meaning the VM is already gone: 410, or a 404 the proxy
10
+ * marks `not_found` (or leaves uncoded). A routing 404 with another code is
11
+ * not proof the VM is gone.
12
+ */
13
+ function isSandboxGoneError(error) {
14
+ if (typeof error !== "object" || error === null) return false;
15
+ const { status, code } = error;
16
+ if (status === 410) return true;
17
+ return status === 404 && (code === void 0 || code === null || code === "not_found");
18
+ }
7
19
  function boundedError(error) {
8
20
  const detail = error instanceof Error ? error.message : String(error);
9
21
  if (detail.length <= 2e3) return detail;
@@ -16,25 +28,44 @@ function boundedError(error) {
16
28
  *
17
29
  * Sandbox identity is the session id: retirement stops (or, for deleted
18
30
  * sessions, destroys) the sandbox this process holds in the session memo.
19
- * Sessions opened on another replica have no memo entry here — their VMs are
20
- * left to the provider's idle lifecycle (pause / idle GC), which is the
21
- * provider-owned half of the contract.
31
+ * Sessions opened on another replica (or before a restart) have no memo entry
32
+ * here: stopping them is left to the provider's idle lifecycle, but deleting a
33
+ * materialized session destroys its VM by identity through the configured
34
+ * sandbox. Providers such as E2B keep paused VMs forever, so the row's
35
+ * deletion must never orphan one.
22
36
  */
23
37
  var SessionRetirementCoordinator = class {
24
38
  #invalidateSession;
39
+ #sandbox;
25
40
  #warn;
41
+ #destroyTimeoutMs;
26
42
  #locks = /* @__PURE__ */ new Map();
27
43
  constructor(options = {}) {
28
44
  this.#invalidateSession = options.invalidateSession ?? (() => {});
45
+ this.#sandbox = options.sandbox;
29
46
  this.#warn = options.warn ?? ((message, details) => console.warn(`[Mastra Factory] ${message}`, details));
47
+ this.#destroyTimeoutMs = options.destroyTimeoutMs ?? DEFAULT_DESTROY_TIMEOUT_MS;
30
48
  }
31
49
  async retireSession(input) {
32
- const current = (this.#locks.get(input.sessionId) ?? Promise.resolve()).catch(() => {}).then(() => this.#retireSession(input));
33
- this.#locks.set(input.sessionId, current);
50
+ await this.#withSessionLock(input.sessionId, () => this.#retireSession(input));
51
+ }
52
+ /**
53
+ * Destroy a session's sandbox so its next message boots a fresh VM from the
54
+ * template, keeping the session row, its conversation, and work-item refs.
55
+ * Skips teardown commands, and works without a memo entry in this process
56
+ * by destroying a detached instance built from the persisted `sandboxId`.
57
+ * A destroy failure keeps the persisted id so a retry can reach the VM.
58
+ */
59
+ async recreateSessionSandbox(input) {
60
+ return this.#withSessionLock(input.sessionId, () => this.#recreateSessionSandbox(input));
61
+ }
62
+ async #withSessionLock(sessionId, run) {
63
+ const current = (this.#locks.get(sessionId) ?? Promise.resolve()).catch(() => {}).then(run);
64
+ this.#locks.set(sessionId, current);
34
65
  try {
35
- await current;
66
+ return await current;
36
67
  } finally {
37
- if (this.#locks.get(input.sessionId) === current) this.#locks.delete(input.sessionId);
68
+ if (this.#locks.get(sessionId) === current) this.#locks.delete(sessionId);
38
69
  }
39
70
  }
40
71
  async retireWorkItemSessions(options) {
@@ -67,16 +98,7 @@ var SessionRetirementCoordinator = class {
67
98
  try {
68
99
  await this.#teardownSessionSandbox(input, session);
69
100
  } finally {
70
- try {
71
- await this.#invalidateSession(session.sessionId);
72
- } catch (error) {
73
- this.#warn("Factory session workspace cache invalidation failed", {
74
- orgId: session.orgId,
75
- sessionId: session.sessionId,
76
- projectRepositoryId: session.projectRepositoryId,
77
- error: boundedError(error)
78
- });
79
- }
101
+ await this.#invalidate(session);
80
102
  if (input.deleteSession) {
81
103
  await input.workItems?.clearSessionReferences({
82
104
  orgId: input.orgId,
@@ -88,7 +110,10 @@ var SessionRetirementCoordinator = class {
88
110
  }
89
111
  async #teardownSessionSandbox(input, session) {
90
112
  const entry = peekSessionSandbox(session.id);
91
- if (!entry) return;
113
+ if (!entry) {
114
+ await this.#destroyDetachedSandbox(input, session);
115
+ return;
116
+ }
92
117
  const environmentTeardown = peekSessionEnvironmentTeardown(session.sessionId);
93
118
  if (environmentTeardown.length > 0) {
94
119
  for (const repo of environmentTeardown) try {
@@ -131,6 +156,119 @@ var SessionRetirementCoordinator = class {
131
156
  }
132
157
  await this.#releaseSandbox(input, session);
133
158
  }
159
+ /**
160
+ * Destroy a deleted session's VM that this process never attached to. Only
161
+ * for sessions that materialized (a persisted `sandboxId`): nothing is
162
+ * started, no teardown command runs — the provider kills by identity.
163
+ */
164
+ async #destroyDetachedSandbox(input, session) {
165
+ if (!input.deleteSession || !session.sandboxId || !this.#sandbox) return;
166
+ try {
167
+ await destroyDetachedSessionSandbox({
168
+ sandbox: this.#sandbox,
169
+ session
170
+ });
171
+ } catch (error) {
172
+ this.#warn("Factory detached session sandbox destroy failed", {
173
+ orgId: session.orgId,
174
+ sessionId: session.sessionId,
175
+ projectRepositoryId: session.projectRepositoryId,
176
+ error: boundedError(error)
177
+ });
178
+ }
179
+ }
180
+ /** Bump the session's workspace generation; a failing unregister is logged, never fatal. */
181
+ async #invalidate(session) {
182
+ try {
183
+ await this.#invalidateSession(session.sessionId);
184
+ } catch (error) {
185
+ this.#warn("Factory session workspace cache invalidation failed", {
186
+ orgId: session.orgId,
187
+ sessionId: session.sessionId,
188
+ projectRepositoryId: session.projectRepositoryId,
189
+ error: boundedError(error)
190
+ });
191
+ }
192
+ }
193
+ async #recreateSessionSandbox(input) {
194
+ const session = await input.sourceControl.sessions.getBySessionId(input.sessionId);
195
+ if (!session || session.orgId !== input.orgId) return "not-found";
196
+ await this.#invalidate(session);
197
+ const entry = peekSessionSandbox(session.id);
198
+ evictSessionSandbox(session.id);
199
+ await this.#destroyForRecreate(session, entry?.sandbox);
200
+ await input.sourceControl.sessions.setSandbox({
201
+ id: session.id,
202
+ sandboxId: null,
203
+ sandboxWorkdir: ""
204
+ });
205
+ evictSessionSandbox(session.id);
206
+ await this.#invalidate(session);
207
+ return "recreated";
208
+ }
209
+ /**
210
+ * Destroy the session's VM. `_destroy()` silently no-ops on a never-started
211
+ * (`pending`) instance, so pending and detached instances call the
212
+ * provider's `destroy()` directly; a started instance goes through the
213
+ * lifecycle wrapper, bounded so a hung start can't hold the session lock.
214
+ */
215
+ async #destroyForRecreate(session, memo) {
216
+ const lifecycle = memo;
217
+ if (memo && memo.status !== "pending" && lifecycle?._destroy) {
218
+ const destroying = lifecycle._destroy.call(memo);
219
+ if (await this.#settledWithin(destroying)) {
220
+ memo.status = "destroyed";
221
+ return;
222
+ }
223
+ destroying.catch((error) => this.#warn("Factory sandbox destroy failed after recreate stopped waiting", {
224
+ orgId: session.orgId,
225
+ sessionId: session.sessionId,
226
+ error: boundedError(error)
227
+ }));
228
+ if (!this.#sandbox) throw new Error("Timed out destroying the session sandbox, and no sandbox provider is configured to retry by identity.");
229
+ await this.#destroyDetachedForRecreate(this.#sandbox, session);
230
+ memo.status = "destroyed";
231
+ return;
232
+ }
233
+ if (memo) {
234
+ await this.#destroyDirectly(memo);
235
+ memo.status = "destroyed";
236
+ return;
237
+ }
238
+ if (this.#sandbox) await this.#destroyDetachedForRecreate(this.#sandbox, session);
239
+ }
240
+ async #destroyDetachedForRecreate(sandbox, session) {
241
+ try {
242
+ await destroyDetachedSessionSandbox({
243
+ sandbox,
244
+ session
245
+ });
246
+ } catch (error) {
247
+ if (!isSandboxGoneError(error)) throw error;
248
+ }
249
+ }
250
+ /** True when the destroy finished in time; false on timeout. Gone-VM errors count as finished. */
251
+ async #settledWithin(destroying) {
252
+ let timer;
253
+ const timedOut = new Promise((resolve) => {
254
+ timer = setTimeout(() => resolve(false), this.#destroyTimeoutMs);
255
+ });
256
+ try {
257
+ return await Promise.race([destroying.then(() => true), timedOut]);
258
+ } catch (error) {
259
+ if (isSandboxGoneError(error)) return true;
260
+ throw error;
261
+ } finally {
262
+ clearTimeout(timer);
263
+ }
264
+ }
265
+ async #destroyDirectly(sandbox) {
266
+ try {
267
+ await sandbox.destroy?.();
268
+ } catch (error) {
269
+ if (!isSandboxGoneError(error)) throw error;
270
+ }
271
+ }
134
272
  async #releaseSandbox(input, session) {
135
273
  try {
136
274
  await releaseSessionSandbox({
@@ -1 +1 @@
1
- {"version":3,"file":"session-retirement.js","names":["#invalidateSession","#warn","#locks","#retireSession","#teardownSessionSandbox","#releaseSandbox"],"sources":["../../src/sandbox/session-retirement.ts"],"sourcesContent":["import { releaseSessionSandbox } from '../integrations/github/sandbox-release.js';\nimport { DEFAULT_COMMAND_TIMEOUT_MS, runTeardownCommand } from '../integrations/github/sandbox.js';\nimport { peekSessionEnvironmentTeardown } from '../session/environment-state-processor.js';\nimport type {\n ProjectRepository,\n SourceControlSession,\n SourceControlStorageHandle,\n} from '../storage/domains/source-control/base.js';\nimport type { WorkItemsStorage } from '../storage/domains/work-items/base.js';\nimport { requireExec } from './materialization.js';\nimport { peekSessionSandbox } from './session-sandbox.js';\n\ntype WarningLogger = (message: string, details: Record<string, unknown>) => void;\n\nexport interface SessionRetirementCoordinatorOptions {\n invalidateSession?: (sessionId: string) => Promise<void> | void;\n warn?: WarningLogger;\n}\n\nexport interface RetireSessionInput {\n sourceControl: SourceControlStorageHandle;\n /** When provided, deleting the session row also strips its work-item refs. */\n workItems?: Pick<WorkItemsStorage, 'clearSessionReferences'>;\n orgId: string;\n sessionId: string;\n deleteSession: boolean;\n}\n\nfunction boundedError(error: unknown): string {\n const detail = error instanceof Error ? error.message : String(error);\n if (detail.length <= 2000) return detail;\n return `${detail.slice(0, 200)}...${detail.slice(-1797)}`;\n}\n\n/**\n * Owns terminal and destructive session cleanup. Each session is serialized so\n * duplicate role bindings and competing deletion/transition requests cannot\n * run teardown concurrently.\n *\n * Sandbox identity is the session id: retirement stops (or, for deleted\n * sessions, destroys) the sandbox this process holds in the session memo.\n * Sessions opened on another replica have no memo entry here — their VMs are\n * left to the provider's idle lifecycle (pause / idle GC), which is the\n * provider-owned half of the contract.\n */\nexport class SessionRetirementCoordinator {\n readonly #invalidateSession: NonNullable<SessionRetirementCoordinatorOptions['invalidateSession']>;\n readonly #warn: WarningLogger;\n readonly #locks = new Map<string, Promise<void>>();\n\n constructor(options: SessionRetirementCoordinatorOptions = {}) {\n this.#invalidateSession = options.invalidateSession ?? (() => {});\n this.#warn = options.warn ?? ((message, details) => console.warn(`[Mastra Factory] ${message}`, details));\n }\n\n async retireSession(input: RetireSessionInput): Promise<void> {\n const previous = this.#locks.get(input.sessionId) ?? Promise.resolve();\n const current = previous.catch(() => {}).then(() => this.#retireSession(input));\n this.#locks.set(input.sessionId, current);\n try {\n await current;\n } finally {\n if (this.#locks.get(input.sessionId) === current) this.#locks.delete(input.sessionId);\n }\n }\n\n async retireWorkItemSessions(options: {\n workItems: Pick<WorkItemsStorage, 'get'>;\n sourceControl: SourceControlStorageHandle;\n orgId: string;\n workItemId: string;\n }): Promise<void> {\n const item = await options.workItems.get({ orgId: options.orgId, id: options.workItemId });\n if (!item) return;\n const sessionIds = [...new Set(Object.values(item.sessions).map(session => session.sessionId))];\n await Promise.all(\n sessionIds.map(sessionId =>\n this.retireSession({\n sourceControl: options.sourceControl,\n orgId: options.orgId,\n sessionId,\n deleteSession: false,\n }),\n ),\n );\n }\n\n async retireProjectRepositorySessions(options: {\n sourceControl: SourceControlStorageHandle;\n workItems?: Pick<WorkItemsStorage, 'clearSessionReferences'>;\n orgId: string;\n projectRepositoryId: string;\n }): Promise<void> {\n const sessions = await options.sourceControl.sessions.listByProjectRepository({\n projectRepositoryId: options.projectRepositoryId,\n });\n await Promise.all(\n sessions.map(session =>\n this.retireSession({\n sourceControl: options.sourceControl,\n ...(options.workItems ? { workItems: options.workItems } : {}),\n orgId: options.orgId,\n sessionId: session.sessionId,\n deleteSession: true,\n }),\n ),\n );\n }\n\n async #retireSession(input: RetireSessionInput): Promise<void> {\n const session = await input.sourceControl.sessions.getBySessionId(input.sessionId);\n if (!session || session.orgId !== input.orgId) return;\n\n try {\n await this.#teardownSessionSandbox(input, session);\n } finally {\n try {\n await this.#invalidateSession(session.sessionId);\n } catch (error) {\n this.#warn('Factory session workspace cache invalidation failed', {\n orgId: session.orgId,\n sessionId: session.sessionId,\n projectRepositoryId: session.projectRepositoryId,\n error: boundedError(error),\n });\n }\n\n if (input.deleteSession) {\n // Refs first: clearing again is a no-op, but refs on a deleted row would dangle forever.\n await input.workItems?.clearSessionReferences({ orgId: input.orgId, sessionId: input.sessionId });\n await input.sourceControl.sessions.delete(session.id);\n }\n }\n }\n\n async #teardownSessionSandbox(input: RetireSessionInput, session: SourceControlSession): Promise<void> {\n const entry = peekSessionSandbox(session.id);\n if (!entry) return;\n\n // A session booted from its factory environment tears every repository\n // down in position order, each in its own directory; a failure is logged\n // and the next repository still runs.\n const environmentTeardown = peekSessionEnvironmentTeardown(session.sessionId);\n if (environmentTeardown.length > 0) {\n for (const repo of environmentTeardown) {\n try {\n await runTeardownCommand(requireExec(entry.sandbox), repo.dir, repo.command, {\n timeoutMs: DEFAULT_COMMAND_TIMEOUT_MS,\n });\n } catch (error) {\n this.#warn('Factory teardown command failed', {\n orgId: session.orgId,\n sessionId: session.sessionId,\n projectRepositoryId: session.projectRepositoryId,\n repository: repo.slug,\n error: boundedError(error),\n });\n }\n }\n await this.#releaseSandbox(input, session);\n return;\n }\n\n let projectRepository: ProjectRepository | null | undefined;\n try {\n projectRepository = session.projectRepositoryId\n ? await input.sourceControl.projectRepositories.get({ orgId: input.orgId, id: session.projectRepositoryId })\n : null;\n } catch (error) {\n this.#warn('Factory repository settings could not be loaded for session retirement', {\n orgId: session.orgId,\n sessionId: session.sessionId,\n projectRepositoryId: session.projectRepositoryId,\n error: boundedError(error),\n });\n }\n\n // An unresolved workdir means the sandbox never started in this process:\n // nothing was set up, so there is nothing for a teardown command to undo.\n if (projectRepository?.teardownCommand && entry.workdir) {\n try {\n await runTeardownCommand(requireExec(entry.sandbox), entry.workdir, projectRepository.teardownCommand, {\n timeoutMs: DEFAULT_COMMAND_TIMEOUT_MS,\n });\n } catch (error) {\n this.#warn('Factory teardown command failed', {\n orgId: session.orgId,\n sessionId: session.sessionId,\n projectRepositoryId: session.projectRepositoryId,\n error: boundedError(error),\n });\n }\n }\n\n await this.#releaseSandbox(input, session);\n }\n\n async #releaseSandbox(input: RetireSessionInput, session: SourceControlSession): Promise<void> {\n try {\n await releaseSessionSandbox({ sessionId: session.id, destroy: input.deleteSession });\n } catch (error) {\n this.#warn('Factory session sandbox release failed', {\n orgId: session.orgId,\n sessionId: session.sessionId,\n projectRepositoryId: session.projectRepositoryId,\n error: boundedError(error),\n });\n }\n }\n}\n"],"mappings":";;;;;;AA4BA,SAAS,aAAa,OAAwB;CAC5C,MAAM,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;CACpE,IAAI,OAAO,UAAU,KAAM,OAAO;CAClC,OAAO,GAAG,OAAO,MAAM,GAAG,GAAG,EAAE,KAAK,OAAO,MAAM,KAAK;AACxD;;;;;;;;;;;;AAaA,IAAa,+BAAb,MAA0C;CACxC;CACA;CACA,yBAAkB,IAAI,IAA2B;CAEjD,YAAY,UAA+C,CAAC,GAAG;EAC7D,KAAKA,qBAAqB,QAAQ,4BAA4B,CAAC;EAC/D,KAAKC,QAAQ,QAAQ,UAAU,SAAS,YAAY,QAAQ,KAAK,oBAAoB,WAAW,OAAO;CACzG;CAEA,MAAM,cAAc,OAA0C;EAE5D,MAAM,WADW,KAAKC,OAAO,IAAI,MAAM,SAAS,KAAK,QAAQ,QAAQ,EAAA,C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AAiB,EACrG,WAAW,2BACb,CAAC;EACH,SAAS,OAAO;GACd,KAAKA,MAAM,mCAAmC;IAC5C,OAAO,QAAQ;IACf,WAAW,QAAQ;IACnB,qBAAqB,QAAQ;IAC7B,OAAO,aAAa,KAAK;GAC3B,CAAC;EACH;EAGF,MAAM,KAAKI,gBAAgB,OAAO,OAAO;CAC3C;CAEA,MAAMA,gBAAgB,OAA2B,SAA8C;EAC7F,IAAI;GACF,MAAM,sBAAsB;IAAE,WAAW,QAAQ;IAAI,SAAS,MAAM;GAAc,CAAC;EACrF,SAAS,OAAO;GACd,KAAKJ,MAAM,0CAA0C;IACnD,OAAO,QAAQ;IACf,WAAW,QAAQ;IACnB,qBAAqB,QAAQ;IAC7B,OAAO,aAAa,KAAK;GAC3B,CAAC;EACH;CACF;AACF"}
1
+ {"version":3,"file":"session-retirement.js","names":["#invalidateSession","#sandbox","#warn","#destroyTimeoutMs","#locks","#withSessionLock","#retireSession","#recreateSessionSandbox","#teardownSessionSandbox","#invalidate","#destroyDetachedSandbox","#releaseSandbox","#destroyForRecreate","#settledWithin","#destroyDetachedForRecreate","#destroyDirectly"],"sources":["../../src/sandbox/session-retirement.ts"],"sourcesContent":["import type { FactorySandbox, WorkspaceSandbox } from '@mastra/core/workspace';\n\nimport { destroyDetachedSessionSandbox, releaseSessionSandbox } from '../integrations/github/sandbox-release.js';\nimport { DEFAULT_COMMAND_TIMEOUT_MS, runTeardownCommand } from '../integrations/github/sandbox.js';\nimport { peekSessionEnvironmentTeardown } from '../session/environment-state-processor.js';\nimport type {\n ProjectRepository,\n SourceControlSession,\n SourceControlStorageHandle,\n} from '../storage/domains/source-control/base.js';\nimport type { WorkItemsStorage } from '../storage/domains/work-items/base.js';\nimport { requireExec } from './materialization.js';\nimport { evictSessionSandbox, peekSessionSandbox } from './session-sandbox.js';\n\ntype WarningLogger = (message: string, details: Record<string, unknown>) => void;\n\nexport interface SessionRetirementCoordinatorOptions {\n invalidateSession?: (sessionId: string) => Promise<void> | void;\n /**\n * The deploy's sandbox configuration. Used to destroy a deleted session's\n * VM by identity when this process never attached to it (after a restart,\n * or on another replica). Recreate uses it the same way.\n */\n sandbox?: FactorySandbox;\n warn?: WarningLogger;\n /** How long recreate waits on a started sandbox's lifecycle destroy before falling back. */\n destroyTimeoutMs?: number;\n}\n\nexport interface RecreateSessionSandboxInput {\n sourceControl: SourceControlStorageHandle;\n orgId: string;\n sessionId: string;\n}\n\nconst DEFAULT_DESTROY_TIMEOUT_MS = 30_000;\n\n/**\n * A provider error meaning the VM is already gone: 410, or a 404 the proxy\n * marks `not_found` (or leaves uncoded). A routing 404 with another code is\n * not proof the VM is gone.\n */\nfunction isSandboxGoneError(error: unknown): boolean {\n if (typeof error !== 'object' || error === null) return false;\n const { status, code } = error as { status?: unknown; code?: unknown };\n if (status === 410) return true;\n return status === 404 && (code === undefined || code === null || code === 'not_found');\n}\n\nexport interface RetireSessionInput {\n sourceControl: SourceControlStorageHandle;\n /** When provided, deleting the session row also strips its work-item refs. */\n workItems?: Pick<WorkItemsStorage, 'clearSessionReferences'>;\n orgId: string;\n sessionId: string;\n deleteSession: boolean;\n}\n\nfunction boundedError(error: unknown): string {\n const detail = error instanceof Error ? error.message : String(error);\n if (detail.length <= 2000) return detail;\n return `${detail.slice(0, 200)}...${detail.slice(-1797)}`;\n}\n\n/**\n * Owns terminal and destructive session cleanup. Each session is serialized so\n * duplicate role bindings and competing deletion/transition requests cannot\n * run teardown concurrently.\n *\n * Sandbox identity is the session id: retirement stops (or, for deleted\n * sessions, destroys) the sandbox this process holds in the session memo.\n * Sessions opened on another replica (or before a restart) have no memo entry\n * here: stopping them is left to the provider's idle lifecycle, but deleting a\n * materialized session destroys its VM by identity through the configured\n * sandbox. Providers such as E2B keep paused VMs forever, so the row's\n * deletion must never orphan one.\n */\nexport class SessionRetirementCoordinator {\n readonly #invalidateSession: NonNullable<SessionRetirementCoordinatorOptions['invalidateSession']>;\n readonly #sandbox: FactorySandbox | undefined;\n readonly #warn: WarningLogger;\n readonly #destroyTimeoutMs: number;\n readonly #locks = new Map<string, Promise<unknown>>();\n\n constructor(options: SessionRetirementCoordinatorOptions = {}) {\n this.#invalidateSession = options.invalidateSession ?? (() => {});\n this.#sandbox = options.sandbox;\n this.#warn = options.warn ?? ((message, details) => console.warn(`[Mastra Factory] ${message}`, details));\n this.#destroyTimeoutMs = options.destroyTimeoutMs ?? DEFAULT_DESTROY_TIMEOUT_MS;\n }\n\n async retireSession(input: RetireSessionInput): Promise<void> {\n await this.#withSessionLock(input.sessionId, () => this.#retireSession(input));\n }\n\n /**\n * Destroy a session's sandbox so its next message boots a fresh VM from the\n * template, keeping the session row, its conversation, and work-item refs.\n * Skips teardown commands, and works without a memo entry in this process\n * by destroying a detached instance built from the persisted `sandboxId`.\n * A destroy failure keeps the persisted id so a retry can reach the VM.\n */\n async recreateSessionSandbox(input: RecreateSessionSandboxInput): Promise<'recreated' | 'not-found'> {\n return this.#withSessionLock(input.sessionId, () => this.#recreateSessionSandbox(input));\n }\n\n async #withSessionLock<T>(sessionId: string, run: () => Promise<T>): Promise<T> {\n const previous = this.#locks.get(sessionId) ?? Promise.resolve();\n const current = previous.catch(() => {}).then(run);\n this.#locks.set(sessionId, current);\n try {\n return await current;\n } finally {\n if (this.#locks.get(sessionId) === current) this.#locks.delete(sessionId);\n }\n }\n\n async retireWorkItemSessions(options: {\n workItems: Pick<WorkItemsStorage, 'get'>;\n sourceControl: SourceControlStorageHandle;\n orgId: string;\n workItemId: string;\n }): Promise<void> {\n const item = await options.workItems.get({ orgId: options.orgId, id: options.workItemId });\n if (!item) return;\n const sessionIds = [...new Set(Object.values(item.sessions).map(session => session.sessionId))];\n await Promise.all(\n sessionIds.map(sessionId =>\n this.retireSession({\n sourceControl: options.sourceControl,\n orgId: options.orgId,\n sessionId,\n deleteSession: false,\n }),\n ),\n );\n }\n\n async retireProjectRepositorySessions(options: {\n sourceControl: SourceControlStorageHandle;\n workItems?: Pick<WorkItemsStorage, 'clearSessionReferences'>;\n orgId: string;\n projectRepositoryId: string;\n }): Promise<void> {\n const sessions = await options.sourceControl.sessions.listByProjectRepository({\n projectRepositoryId: options.projectRepositoryId,\n });\n await Promise.all(\n sessions.map(session =>\n this.retireSession({\n sourceControl: options.sourceControl,\n ...(options.workItems ? { workItems: options.workItems } : {}),\n orgId: options.orgId,\n sessionId: session.sessionId,\n deleteSession: true,\n }),\n ),\n );\n }\n\n async #retireSession(input: RetireSessionInput): Promise<void> {\n const session = await input.sourceControl.sessions.getBySessionId(input.sessionId);\n if (!session || session.orgId !== input.orgId) return;\n\n try {\n await this.#teardownSessionSandbox(input, session);\n } finally {\n await this.#invalidate(session);\n\n if (input.deleteSession) {\n // Refs first: clearing again is a no-op, but refs on a deleted row would dangle forever.\n await input.workItems?.clearSessionReferences({ orgId: input.orgId, sessionId: input.sessionId });\n await input.sourceControl.sessions.delete(session.id);\n }\n }\n }\n\n async #teardownSessionSandbox(input: RetireSessionInput, session: SourceControlSession): Promise<void> {\n const entry = peekSessionSandbox(session.id);\n if (!entry) {\n await this.#destroyDetachedSandbox(input, session);\n return;\n }\n\n // A session booted from its factory environment tears every repository\n // down in position order, each in its own directory; a failure is logged\n // and the next repository still runs.\n const environmentTeardown = peekSessionEnvironmentTeardown(session.sessionId);\n if (environmentTeardown.length > 0) {\n for (const repo of environmentTeardown) {\n try {\n await runTeardownCommand(requireExec(entry.sandbox), repo.dir, repo.command, {\n timeoutMs: DEFAULT_COMMAND_TIMEOUT_MS,\n });\n } catch (error) {\n this.#warn('Factory teardown command failed', {\n orgId: session.orgId,\n sessionId: session.sessionId,\n projectRepositoryId: session.projectRepositoryId,\n repository: repo.slug,\n error: boundedError(error),\n });\n }\n }\n await this.#releaseSandbox(input, session);\n return;\n }\n\n let projectRepository: ProjectRepository | null | undefined;\n try {\n projectRepository = session.projectRepositoryId\n ? await input.sourceControl.projectRepositories.get({ orgId: input.orgId, id: session.projectRepositoryId })\n : null;\n } catch (error) {\n this.#warn('Factory repository settings could not be loaded for session retirement', {\n orgId: session.orgId,\n sessionId: session.sessionId,\n projectRepositoryId: session.projectRepositoryId,\n error: boundedError(error),\n });\n }\n\n // An unresolved workdir means the sandbox never started in this process:\n // nothing was set up, so there is nothing for a teardown command to undo.\n if (projectRepository?.teardownCommand && entry.workdir) {\n try {\n await runTeardownCommand(requireExec(entry.sandbox), entry.workdir, projectRepository.teardownCommand, {\n timeoutMs: DEFAULT_COMMAND_TIMEOUT_MS,\n });\n } catch (error) {\n this.#warn('Factory teardown command failed', {\n orgId: session.orgId,\n sessionId: session.sessionId,\n projectRepositoryId: session.projectRepositoryId,\n error: boundedError(error),\n });\n }\n }\n\n await this.#releaseSandbox(input, session);\n }\n\n /**\n * Destroy a deleted session's VM that this process never attached to. Only\n * for sessions that materialized (a persisted `sandboxId`): nothing is\n * started, no teardown command runs — the provider kills by identity.\n */\n async #destroyDetachedSandbox(input: RetireSessionInput, session: SourceControlSession): Promise<void> {\n if (!input.deleteSession || !session.sandboxId || !this.#sandbox) return;\n try {\n await destroyDetachedSessionSandbox({ sandbox: this.#sandbox, session });\n } catch (error) {\n this.#warn('Factory detached session sandbox destroy failed', {\n orgId: session.orgId,\n sessionId: session.sessionId,\n projectRepositoryId: session.projectRepositoryId,\n error: boundedError(error),\n });\n }\n }\n\n /** Bump the session's workspace generation; a failing unregister is logged, never fatal. */\n async #invalidate(session: SourceControlSession): Promise<void> {\n try {\n await this.#invalidateSession(session.sessionId);\n } catch (error) {\n this.#warn('Factory session workspace cache invalidation failed', {\n orgId: session.orgId,\n sessionId: session.sessionId,\n projectRepositoryId: session.projectRepositoryId,\n error: boundedError(error),\n });\n }\n }\n\n async #recreateSessionSandbox(input: RecreateSessionSandboxInput): Promise<'recreated' | 'not-found'> {\n const session = await input.sourceControl.sessions.getBySessionId(input.sessionId);\n if (!session || session.orgId !== input.orgId) return 'not-found';\n\n // Bump the generation first so an in-flight start hook for the old\n // instance throws instead of republishing its sandbox id.\n await this.#invalidate(session);\n const entry = peekSessionSandbox(session.id);\n evictSessionSandbox(session.id);\n\n await this.#destroyForRecreate(session, entry?.sandbox);\n await input.sourceControl.sessions.setSandbox({ id: session.id, sandboxId: null, sandboxWorkdir: '' });\n\n // A resolve that ran between the eviction and clearing the id could have\n // built a fresh instance from the old `sandboxId`; drop it and fence it.\n evictSessionSandbox(session.id);\n await this.#invalidate(session);\n return 'recreated';\n }\n\n /**\n * Destroy the session's VM. `_destroy()` silently no-ops on a never-started\n * (`pending`) instance, so pending and detached instances call the\n * provider's `destroy()` directly; a started instance goes through the\n * lifecycle wrapper, bounded so a hung start can't hold the session lock.\n */\n async #destroyForRecreate(session: SourceControlSession, memo: WorkspaceSandbox | undefined): Promise<void> {\n const lifecycle = memo as { _destroy?: () => Promise<void> } | undefined;\n if (memo && memo.status !== 'pending' && lifecycle?._destroy) {\n const destroying = lifecycle._destroy.call(memo);\n if (await this.#settledWithin(destroying)) {\n memo.status = 'destroyed';\n return;\n }\n // Load-bearing: once the hung start settles, this destroy reaps any VM it\n // provisioned. Its rejection must never surface as unhandled.\n destroying.catch(error =>\n this.#warn('Factory sandbox destroy failed after recreate stopped waiting', {\n orgId: session.orgId,\n sessionId: session.sessionId,\n error: boundedError(error),\n }),\n );\n if (!this.#sandbox) {\n throw new Error(\n 'Timed out destroying the session sandbox, and no sandbox provider is configured to retry by identity.',\n );\n }\n await this.#destroyDetachedForRecreate(this.#sandbox, session);\n memo.status = 'destroyed';\n return;\n }\n\n if (memo) {\n await this.#destroyDirectly(memo);\n memo.status = 'destroyed';\n return;\n }\n\n // No instance in this process (restart, or another replica opened it):\n // destroy through a never-started instance carrying the persisted id.\n // Unlike retirement, this runs without a `sandboxId` too: E2B and Docker\n // find the VM by session identity, and Platform's destroy no-ops safely.\n if (this.#sandbox) await this.#destroyDetachedForRecreate(this.#sandbox, session);\n }\n\n async #destroyDetachedForRecreate(sandbox: FactorySandbox, session: SourceControlSession): Promise<void> {\n try {\n await destroyDetachedSessionSandbox({ sandbox, session });\n } catch (error) {\n if (!isSandboxGoneError(error)) throw error;\n }\n }\n\n /** True when the destroy finished in time; false on timeout. Gone-VM errors count as finished. */\n async #settledWithin(destroying: Promise<void>): Promise<boolean> {\n let timer: ReturnType<typeof setTimeout> | undefined;\n const timedOut = new Promise<false>(resolve => {\n timer = setTimeout(() => resolve(false), this.#destroyTimeoutMs);\n });\n try {\n return await Promise.race([destroying.then(() => true as const), timedOut]);\n } catch (error) {\n if (isSandboxGoneError(error)) return true;\n throw error;\n } finally {\n clearTimeout(timer);\n }\n }\n\n async #destroyDirectly(sandbox: WorkspaceSandbox): Promise<void> {\n try {\n await sandbox.destroy?.();\n } catch (error) {\n if (!isSandboxGoneError(error)) throw error;\n }\n }\n\n async #releaseSandbox(input: RetireSessionInput, session: SourceControlSession): Promise<void> {\n try {\n await releaseSessionSandbox({ sessionId: session.id, destroy: input.deleteSession });\n } catch (error) {\n this.#warn('Factory session sandbox release failed', {\n orgId: session.orgId,\n sessionId: session.sessionId,\n projectRepositoryId: session.projectRepositoryId,\n error: boundedError(error),\n });\n }\n }\n}\n"],"mappings":";;;;;;AAmCA,MAAM,6BAA6B;;;;;;AAOnC,SAAS,mBAAmB,OAAyB;CACnD,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO;CACxD,MAAM,EAAE,QAAQ,SAAS;CACzB,IAAI,WAAW,KAAK,OAAO;CAC3B,OAAO,WAAW,QAAQ,SAAS,KAAA,KAAa,SAAS,QAAQ,SAAS;AAC5E;AAWA,SAAS,aAAa,OAAwB;CAC5C,MAAM,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;CACpE,IAAI,OAAO,UAAU,KAAM,OAAO;CAClC,OAAO,GAAG,OAAO,MAAM,GAAG,GAAG,EAAE,KAAK,OAAO,MAAM,KAAK;AACxD;;;;;;;;;;;;;;AAeA,IAAa,+BAAb,MAA0C;CACxC;CACA;CACA;CACA;CACA,yBAAkB,IAAI,IAA8B;CAEpD,YAAY,UAA+C,CAAC,GAAG;EAC7D,KAAKA,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SAAe,YAAW;GAC7C,QAAQ,iBAAiB,QAAQ,KAAK,GAAG,KAAKV,iBAAiB;EACjE,CAAC;EACD,IAAI;GACF,OAAO,MAAM,QAAQ,KAAK,CAAC,WAAW,WAAW,IAAa,GAAG,QAAQ,CAAC;EAC5E,SAAS,OAAO;GACd,IAAI,mBAAmB,KAAK,GAAG,OAAO;GACtC,MAAM;EACR,UAAU;GACR,aAAa,KAAK;EACpB;CACF;CAEA,MAAMY,iBAAiB,SAA0C;EAC/D,IAAI;GACF,MAAM,QAAQ,UAAU;EAC1B,SAAS,OAAO;GACd,IAAI,CAAC,mBAAmB,KAAK,GAAG,MAAM;EACxC;CACF;CAEA,MAAMJ,gBAAgB,OAA2B,SAA8C;EAC7F,IAAI;GACF,MAAM,sBAAsB;IAAE,WAAW,QAAQ;IAAI,SAAS,MAAM;GAAc,CAAC;EACrF,SAAS,OAAO;GACd,KAAKT,MAAM,0CAA0C;IACnD,OAAO,QAAQ;IACf,WAAW,QAAQ;IACnB,qBAAqB,QAAQ;IAC7B,OAAO,aAAa,KAAK;GAC3B,CAAC;EACH;CACF;AACF"}
@@ -1,4 +1,4 @@
1
- import { type CredentialTenant } from '@mastra/code-sdk/agents/credential-resolver';
1
+ import type { CredentialTenant } from '@mastra/code-sdk/agents/credential-resolver';
2
2
  import type { RequestContext } from '@mastra/core/request-context';
3
3
  import type { FactoryProjectsStorage } from '../storage/domains/projects/base.js';
4
4
  import type { WorkItemsStorage } from '../storage/domains/work-items/base.js';
@@ -1 +1 @@
1
- {"version":3,"file":"credential-policy.d.ts","sourceRoot":"","sources":["../../src/session/credential-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,6CAA6C,CAAC;AAErD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAInE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAA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