@mastra/factory 0.26.0-alpha.0 → 0.26.0-alpha.2

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 (242) hide show
  1. package/README.md +158 -57
  2. package/dist/auth.d.ts.map +1 -1
  3. package/dist/boards/card-facts.d.ts +5 -0
  4. package/dist/boards/card-facts.d.ts.map +1 -0
  5. package/dist/boards/card-facts.js +19 -0
  6. package/dist/boards/card-facts.js.map +1 -0
  7. package/dist/boards/define-board.d.ts +109 -13
  8. package/dist/boards/define-board.d.ts.map +1 -1
  9. package/dist/boards/define-board.js +163 -21
  10. package/dist/boards/define-board.js.map +1 -1
  11. package/dist/boards/index.d.ts +4 -3
  12. package/dist/boards/index.d.ts.map +1 -1
  13. package/dist/boards/index.js +3 -2
  14. package/dist/boards/index.js.map +1 -1
  15. package/dist/boards/legacy-plan-role.d.ts +14 -0
  16. package/dist/boards/legacy-plan-role.d.ts.map +1 -0
  17. package/dist/boards/legacy-plan-role.js +32 -0
  18. package/dist/boards/legacy-plan-role.js.map +1 -0
  19. package/dist/boards/phase-automation.d.ts +13 -0
  20. package/dist/boards/phase-automation.d.ts.map +1 -0
  21. package/dist/boards/phase-automation.js +25 -0
  22. package/dist/boards/phase-automation.js.map +1 -0
  23. package/dist/boards/phase-runner.d.ts +13 -0
  24. package/dist/boards/phase-runner.d.ts.map +1 -0
  25. package/dist/boards/phase-runner.js +44 -0
  26. package/dist/boards/phase-runner.js.map +1 -0
  27. package/dist/boards/relocate.d.ts.map +1 -1
  28. package/dist/boards/relocate.js +2 -0
  29. package/dist/boards/relocate.js.map +1 -1
  30. package/dist/boards/review.d.ts +1 -1
  31. package/dist/boards/review.d.ts.map +1 -1
  32. package/dist/boards/review.js +18 -18
  33. package/dist/boards/review.js.map +1 -1
  34. package/dist/boards/semantics.d.ts.map +1 -1
  35. package/dist/boards/semantics.js +11 -7
  36. package/dist/boards/semantics.js.map +1 -1
  37. package/dist/boards/transition-policy.d.ts +10 -10
  38. package/dist/boards/work-tool-rules.d.ts +3 -3
  39. package/dist/boards/work-tool-rules.d.ts.map +1 -1
  40. package/dist/boards/work-tool-rules.js +1 -1
  41. package/dist/boards/work-tool-rules.js.map +1 -1
  42. package/dist/boards/work.d.ts +3 -3
  43. package/dist/boards/work.d.ts.map +1 -1
  44. package/dist/boards/work.js +31 -29
  45. package/dist/boards/work.js.map +1 -1
  46. package/dist/environment/build-runner.d.ts +4 -4
  47. package/dist/environment/build-runner.d.ts.map +1 -1
  48. package/dist/environment/build-workflow.d.ts +6 -6
  49. package/dist/environment/build-workflow.js +1 -1
  50. package/dist/environment/build.d.ts +2 -2
  51. package/dist/environment/build.d.ts.map +1 -1
  52. package/dist/environment/build.js +2 -0
  53. package/dist/environment/build.js.map +1 -1
  54. package/dist/factory.d.ts +8 -0
  55. package/dist/factory.d.ts.map +1 -1
  56. package/dist/factory.js +8 -2
  57. package/dist/factory.js.map +1 -1
  58. package/dist/index.d.ts +3 -2
  59. package/dist/index.d.ts.map +1 -1
  60. package/dist/index.js +2 -2
  61. package/dist/integrations/github/app-identity.d.ts.map +1 -1
  62. package/dist/integrations/github/default-rules.d.ts +71 -71
  63. package/dist/integrations/github/default-rules.d.ts.map +1 -1
  64. package/dist/integrations/github/integration.d.ts +5 -4
  65. package/dist/integrations/github/integration.d.ts.map +1 -1
  66. package/dist/integrations/github/integration.js +10 -8
  67. package/dist/integrations/github/integration.js.map +1 -1
  68. package/dist/integrations/github/reconcile-worker.d.ts.map +1 -1
  69. package/dist/integrations/github/rules.d.ts.map +1 -1
  70. package/dist/integrations/github/sandbox.d.ts +2 -2
  71. package/dist/integrations/github/sandbox.d.ts.map +1 -1
  72. package/dist/integrations/github/sandbox.js +6 -1
  73. package/dist/integrations/github/sandbox.js.map +1 -1
  74. package/dist/integrations/gitlab/api.d.ts.map +1 -1
  75. package/dist/integrations/gitlab/default-rules.d.ts +38 -38
  76. package/dist/integrations/gitlab/default-rules.d.ts.map +1 -1
  77. package/dist/integrations/gitlab/integration.d.ts.map +1 -1
  78. package/dist/integrations/gitlab/rules.d.ts.map +1 -1
  79. package/dist/integrations/incidentio/api.d.ts.map +1 -1
  80. package/dist/integrations/incidentio/default-rules.d.ts +3 -3
  81. package/dist/integrations/incidentio/default-rules.d.ts.map +1 -1
  82. package/dist/integrations/incidentio/integration.d.ts.map +1 -1
  83. package/dist/integrations/incidentio/rules.d.ts.map +1 -1
  84. package/dist/integrations/issue-reconcile-worker.d.ts.map +1 -1
  85. package/dist/integrations/jira/api.d.ts +1 -1
  86. package/dist/integrations/jira/api.d.ts.map +1 -1
  87. package/dist/integrations/jira/default-rules.d.ts +3 -3
  88. package/dist/integrations/jira/default-rules.d.ts.map +1 -1
  89. package/dist/integrations/jira/integration.d.ts.map +1 -1
  90. package/dist/integrations/jira/rules.d.ts.map +1 -1
  91. package/dist/integrations/linear/default-rules.d.ts +8 -8
  92. package/dist/integrations/linear/default-rules.d.ts.map +1 -1
  93. package/dist/integrations/linear/integration.d.ts.map +1 -1
  94. package/dist/integrations/linear/rules.d.ts.map +1 -1
  95. package/dist/integrations/platform/api-client.d.ts.map +1 -1
  96. package/dist/integrations/platform/github/event-worker.d.ts.map +1 -1
  97. package/dist/integrations/platform/github/integration.d.ts +5 -0
  98. package/dist/integrations/platform/github/integration.d.ts.map +1 -1
  99. package/dist/integrations/platform/github/integration.js +7 -0
  100. package/dist/integrations/platform/github/integration.js.map +1 -1
  101. package/dist/integrations/platform/gitlab/event-worker.d.ts.map +1 -1
  102. package/dist/integrations/platform/gitlab/integration.d.ts.map +1 -1
  103. package/dist/integrations/platform/incidentio/integration.d.ts.map +1 -1
  104. package/dist/integrations/platform/jira/integration.d.ts.map +1 -1
  105. package/dist/integrations/platform/linear/event-worker.d.ts.map +1 -1
  106. package/dist/integrations/platform/linear/integration.d.ts.map +1 -1
  107. package/dist/integrations/slack/channel-reply-processor.d.ts.map +1 -1
  108. package/dist/integrations/slack/channel-session-link-processor.d.ts.map +1 -1
  109. package/dist/integrations/slack/feed-publisher.d.ts.map +1 -1
  110. package/dist/integrations/slack/integration.d.ts.map +1 -1
  111. package/dist/integrations/slack/reply-reminder-processor.d.ts.map +1 -1
  112. package/dist/integrations/slack/reply-tool.d.ts.map +1 -1
  113. package/dist/integrations/slack/slack.d.ts.map +1 -1
  114. package/dist/integrations/workos/integration.d.ts.map +1 -1
  115. package/dist/mcp/events.d.ts +3 -3
  116. package/dist/mcp/routes.js +1 -1
  117. package/dist/routes/attention-activity.d.ts +1 -1
  118. package/dist/routes/attention-activity.d.ts.map +1 -1
  119. package/dist/routes/attention-parked.d.ts +1 -1
  120. package/dist/routes/attention-parked.d.ts.map +1 -1
  121. package/dist/routes/attention-providers.d.ts +1 -1
  122. package/dist/routes/attention-providers.d.ts.map +1 -1
  123. package/dist/routes/automation-runs.d.ts.map +1 -1
  124. package/dist/routes/config.d.ts.map +1 -1
  125. package/dist/routes/contracts.d.ts +159 -136
  126. package/dist/routes/contracts.d.ts.map +1 -1
  127. package/dist/routes/contracts.js +23 -0
  128. package/dist/routes/contracts.js.map +1 -1
  129. package/dist/routes/fs.d.ts.map +1 -1
  130. package/dist/routes/fs.js +24 -0
  131. package/dist/routes/fs.js.map +1 -1
  132. package/dist/routes/intake.d.ts.map +1 -1
  133. package/dist/routes/knowledge.d.ts.map +1 -1
  134. package/dist/routes/oauth.d.ts.map +1 -1
  135. package/dist/routes/projects.d.ts.map +1 -1
  136. package/dist/routes/route.d.ts.map +1 -1
  137. package/dist/routes/skills.d.ts +3 -0
  138. package/dist/routes/skills.d.ts.map +1 -1
  139. package/dist/routes/skills.js +1 -1
  140. package/dist/routes/skills.js.map +1 -1
  141. package/dist/routes/surface.d.ts +3 -0
  142. package/dist/routes/surface.d.ts.map +1 -1
  143. package/dist/routes/surface.js +24 -22
  144. package/dist/routes/surface.js.map +1 -1
  145. package/dist/routes/telemetry.d.ts.map +1 -1
  146. package/dist/routes/tenant-credentials.d.ts.map +1 -1
  147. package/dist/routes/work-items.d.ts.map +1 -1
  148. package/dist/routes/work-items.js +19 -3
  149. package/dist/routes/work-items.js.map +1 -1
  150. package/dist/rules/decision-applicability.d.ts.map +1 -1
  151. package/dist/rules/decision-applicability.js +3 -1
  152. package/dist/rules/decision-applicability.js.map +1 -1
  153. package/dist/rules/dispatch-errors.d.ts.map +1 -1
  154. package/dist/rules/dispatch-errors.js +4 -0
  155. package/dist/rules/dispatch-errors.js.map +1 -1
  156. package/dist/rules/dispatcher.d.ts.map +1 -1
  157. package/dist/rules/dispatcher.js +17 -3
  158. package/dist/rules/dispatcher.js.map +1 -1
  159. package/dist/rules/processor.d.ts.map +1 -1
  160. package/dist/rules/processor.js +4 -2
  161. package/dist/rules/processor.js.map +1 -1
  162. package/dist/rules/rule-group.d.ts +29 -0
  163. package/dist/rules/rule-group.d.ts.map +1 -0
  164. package/dist/rules/rule-group.js +141 -0
  165. package/dist/rules/rule-group.js.map +1 -0
  166. package/dist/rules/start-coordinator.d.ts.map +1 -1
  167. package/dist/rules/terminal-cleanup.d.ts.map +1 -1
  168. package/dist/rules/tools.d.ts +1 -1
  169. package/dist/rules/tools.d.ts.map +1 -1
  170. package/dist/rules/transition-service.d.ts.map +1 -1
  171. package/dist/rules/transition-service.js +5 -3
  172. package/dist/rules/transition-service.js.map +1 -1
  173. package/dist/rules/types.d.ts +25 -14
  174. package/dist/rules/types.d.ts.map +1 -1
  175. package/dist/rules/types.js.map +1 -1
  176. package/dist/rules/validation.d.ts +2 -0
  177. package/dist/rules/validation.d.ts.map +1 -1
  178. package/dist/rules/validation.js +6 -3
  179. package/dist/rules/validation.js.map +1 -1
  180. package/dist/sandbox/callback-factory-sandbox.d.ts.map +1 -1
  181. package/dist/sandbox/local-factory-sandbox.d.ts +4 -1
  182. package/dist/sandbox/local-factory-sandbox.d.ts.map +1 -1
  183. package/dist/sandbox/local-factory-sandbox.js +1 -1
  184. package/dist/sandbox/local-factory-sandbox.js.map +1 -1
  185. package/dist/sandbox/session-retirement.d.ts.map +1 -1
  186. package/dist/session/environment-state-processor.d.ts.map +1 -1
  187. package/dist/session/factory-session.d.ts.map +1 -1
  188. package/dist/session/live-sessions.d.ts.map +1 -1
  189. package/dist/session/reply-credential-processor.d.ts.map +1 -1
  190. package/dist/session/run-audit.d.ts +1 -1
  191. package/dist/session/run-audit.d.ts.map +1 -1
  192. package/dist/skills/app-skills.d.ts +11 -0
  193. package/dist/skills/app-skills.d.ts.map +1 -0
  194. package/dist/skills/app-skills.js +37 -0
  195. package/dist/skills/app-skills.js.map +1 -0
  196. package/dist/skills/catalog.d.ts +9 -3
  197. package/dist/skills/catalog.d.ts.map +1 -1
  198. package/dist/skills/catalog.js +35 -19
  199. package/dist/skills/catalog.js.map +1 -1
  200. package/dist/skills/service.d.ts.map +1 -1
  201. package/dist/spa-static.d.ts.map +1 -1
  202. package/dist/storage/domains/audit/actions.d.ts +6 -6
  203. package/dist/storage/domains/audit/actions.d.ts.map +1 -1
  204. package/dist/storage/domains/audit/actors.d.ts +1 -1
  205. package/dist/storage/domains/audit/actors.d.ts.map +1 -1
  206. package/dist/storage/domains/audit/base.d.ts.map +1 -1
  207. package/dist/storage/domains/audit/domain.d.ts.map +1 -1
  208. package/dist/storage/domains/channel-identity/base.d.ts.map +1 -1
  209. package/dist/storage/domains/comments/base.d.ts.map +1 -1
  210. package/dist/storage/domains/comments/domain.d.ts.map +1 -1
  211. package/dist/storage/domains/comments/feed-context.d.ts.map +1 -1
  212. package/dist/storage/domains/credentials/base.d.ts.map +1 -1
  213. package/dist/storage/domains/custom-providers/base.d.ts.map +1 -1
  214. package/dist/storage/domains/filesystem/base.d.ts.map +1 -1
  215. package/dist/storage/domains/intake/base.d.ts.map +1 -1
  216. package/dist/storage/domains/integrations/base.d.ts.map +1 -1
  217. package/dist/storage/domains/memory-settings/base.d.ts.map +1 -1
  218. package/dist/storage/domains/model-defaults/base.d.ts.map +1 -1
  219. package/dist/storage/domains/projects/base.d.ts +1 -1
  220. package/dist/storage/domains/projects/base.d.ts.map +1 -1
  221. package/dist/storage/domains/queue-health/base.d.ts.map +1 -1
  222. package/dist/storage/domains/source-control/base.d.ts.map +1 -1
  223. package/dist/storage/domains/source-control/inmemory.d.ts +5 -5
  224. package/dist/storage/domains/source-control/inmemory.d.ts.map +1 -1
  225. package/dist/storage/domains/work-items/base.d.ts +2 -2
  226. package/dist/storage/domains/work-items/base.d.ts.map +1 -1
  227. package/dist/storage/domains/work-items/base.js +1 -0
  228. package/dist/storage/domains/work-items/base.js.map +1 -1
  229. package/dist/storage/domains/work-items/board-version.d.ts.map +1 -1
  230. package/dist/telemetry-types.d.ts +1 -1
  231. package/dist/telemetry-types.d.ts.map +1 -1
  232. package/dist/timing.d.ts.map +1 -1
  233. package/dist/tools/session-tools.d.ts.map +1 -1
  234. package/dist/tools/session-tools.js +3 -1
  235. package/dist/tools/session-tools.js.map +1 -1
  236. package/dist/tools/sessions-state-processor.d.ts.map +1 -1
  237. package/dist/tools/work-item-tools.js +1 -1
  238. package/dist/workspace.d.ts +15 -6
  239. package/dist/workspace.d.ts.map +1 -1
  240. package/dist/workspace.js +79 -18
  241. package/dist/workspace.js.map +1 -1
  242. package/package.json +9 -9
@@ -1 +1 @@
1
- {"version":3,"file":"validation.js","names":[],"sources":["../../src/rules/validation.ts"],"sourcesContent":["import type { BoardRegistry } from '../boards/registry.js';\nimport type {\n FactoryCommitDecision,\n FactoryRuleDecision,\n FactoryRuleJsonValue,\n FactoryRuleRejectionCode,\n WorkItemSource,\n} from './types.js';\n\nexport const MAX_FACTORY_RULE_CAUSAL_DEPTH = 8;\n\nconst MAX_VERSION_LENGTH = 128;\nconst MAX_IDEMPOTENCY_KEY_LENGTH = 256;\nconst MAX_REASON_LENGTH = 512;\nconst MAX_TITLE_LENGTH = 512;\nconst MAX_MESSAGE_LENGTH = 8_192;\nconst MAX_ARGUMENTS_LENGTH = 4_096;\nexport const MAX_ROLE_LENGTH = 32;\nexport const MAX_TOOL_NAME_LENGTH = 128;\nconst MAX_SKILL_NAME_LENGTH = 128;\nconst MAX_SOURCE_KEY_LENGTH = 256;\nconst MAX_URL_LENGTH = 2_048;\nconst MAX_METADATA_JSON_LENGTH = 16_384;\nconst MAX_JSON_DEPTH = 8;\nconst MAX_JSON_COLLECTION_SIZE = 100;\n\nexport const MAX_BOARD_IDENTIFIER_LENGTH = 128;\nexport const IDENTIFIER_RE = /^[a-z0-9][a-z0-9_-]*$/i;\nexport const BOARD_IDENTIFIER_RE = IDENTIFIER_RE;\nconst SKILL_NAME_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;\nconst SENSITIVE_KEY_RE = /(?:authorization|cookie|credential|password|secret|token)/i;\nconst WORK_ITEM_SOURCES: readonly 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];\nconst REJECTION_CODES: readonly FactoryRuleRejectionCode[] = [\n 'forbidden',\n 'invalid_transition',\n 'missing_binding',\n 'stale',\n 'timeout',\n 'rule_error',\n 'causal_depth_exceeded',\n 'repeated_transition',\n];\n\nexport class FactoryRuleValidationError extends Error {\n readonly code = 'invalid_factory_rule';\n\n constructor(message: string) {\n super(message);\n this.name = 'FactoryRuleValidationError';\n }\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) return false;\n const prototype = Object.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n}\n\nfunction assertExactKeys(value: Record<string, unknown>, keys: readonly string[], label: string): void {\n const allowed = new Set(keys);\n if (Object.keys(value).some(key => !allowed.has(key))) {\n throw new FactoryRuleValidationError(`${label} contains an unsupported field.`);\n }\n}\n\nfunction boundedString(value: unknown, label: string, max: number, pattern?: RegExp): string {\n if (typeof value !== 'string') throw new FactoryRuleValidationError(`${label} must be a string.`);\n const normalized = value.trim();\n if (normalized.length === 0 || normalized.length > max || (pattern && !pattern.test(normalized))) {\n throw new FactoryRuleValidationError(`${label} is invalid.`);\n }\n return normalized;\n}\n\nexport function isBoardIdentifier(value: unknown): value is string {\n return typeof value === 'string' && value.length <= MAX_BOARD_IDENTIFIER_LENGTH && BOARD_IDENTIFIER_RE.test(value);\n}\n\nfunction boardIdentifier(value: unknown, label: string): string {\n if (!isBoardIdentifier(value)) {\n throw new FactoryRuleValidationError(`${label} is invalid.`);\n }\n return value;\n}\n\nexport function assertFactoryDecisionTarget(\n decision: FactoryRuleDecision,\n boards: BoardRegistry,\n itemBoard?: string | null,\n): void {\n if (decision.type !== 'transition' && decision.type !== 'upsertLinkedWorkItem') return;\n const board = boards.get(decision.board);\n if (!board) throw new FactoryRuleValidationError('Factory decision target board is not installed.');\n if (!Object.hasOwn(board.phases, decision.stage)) {\n throw new FactoryRuleValidationError('Factory decision target phase is not defined on its board.');\n }\n if (decision.type === 'transition' && itemBoard !== undefined && itemBoard !== decision.board) {\n throw new FactoryRuleValidationError('Factory transition cannot change the item board.');\n }\n}\n\nfunction optionalBoundedString(value: unknown, label: string, max: number): string | undefined {\n if (value === undefined) return undefined;\n return boundedString(value, label, max);\n}\n\nfunction enumValue<T extends string>(value: unknown, allowed: readonly T[], label: string): T {\n if (typeof value !== 'string' || !allowed.includes(value as T)) {\n throw new FactoryRuleValidationError(`${label} is invalid.`);\n }\n return value as T;\n}\n\nexport function normalizeFactoryRuleJsonValue(\n value: unknown,\n depth = 0,\n seen = new Set<object>(),\n): FactoryRuleJsonValue {\n if (value === null || typeof value === 'boolean' || typeof value === 'string') return value;\n if (typeof value === 'number') {\n if (!Number.isFinite(value)) throw new FactoryRuleValidationError('Rule metadata must contain finite numbers.');\n return value;\n }\n if (depth >= MAX_JSON_DEPTH || (typeof value !== 'object' && !Array.isArray(value))) {\n throw new FactoryRuleValidationError('Rule metadata is not bounded JSON.');\n }\n if (seen.has(value as object)) throw new FactoryRuleValidationError('Rule metadata must not contain cycles.');\n seen.add(value as object);\n try {\n if (Array.isArray(value)) {\n if (value.length > MAX_JSON_COLLECTION_SIZE) {\n throw new FactoryRuleValidationError('Rule metadata contains too many entries.');\n }\n return value.map(entry => normalizeFactoryRuleJsonValue(entry, depth + 1, seen));\n }\n if (!isPlainObject(value)) throw new FactoryRuleValidationError('Rule metadata must use plain objects.');\n const entries = Object.entries(value);\n if (entries.length > MAX_JSON_COLLECTION_SIZE) {\n throw new FactoryRuleValidationError('Rule metadata contains too many fields.');\n }\n const sanitized: Record<string, FactoryRuleJsonValue> = {};\n for (const [key, entry] of entries) {\n const normalizedKey = boundedString(key, 'Rule metadata key', 128, IDENTIFIER_RE);\n sanitized[normalizedKey] = SENSITIVE_KEY_RE.test(normalizedKey)\n ? '[REDACTED]'\n : normalizeFactoryRuleJsonValue(entry, depth + 1, seen);\n }\n return sanitized;\n } finally {\n seen.delete(value as object);\n }\n}\n\nfunction sanitizeMetadata(value: unknown): Record<string, FactoryRuleJsonValue> | undefined {\n if (value === undefined) return undefined;\n const sanitized = normalizeFactoryRuleJsonValue(value);\n if (!isPlainObject(sanitized)) throw new FactoryRuleValidationError('Rule metadata must be an object.');\n if (JSON.stringify(sanitized).length > MAX_METADATA_JSON_LENGTH) {\n throw new FactoryRuleValidationError('Rule metadata is too large.');\n }\n return sanitized;\n}\n\nexport const DEFAULT_FACTORY_CONFIG_VERSION = 'factory-config-v1';\n\n/** Operator-maintained provenance label stamped on transition audit and deferred-decision rows. */\nexport function assertFactoryConfigVersion(value: unknown): string {\n return boundedString(value, 'Factory configVersion', MAX_VERSION_LENGTH);\n}\n\nfunction commonCommitFields(value: Record<string, unknown>): { idempotencyKey: string } {\n return {\n idempotencyKey: boundedString(value.idempotencyKey, 'Factory decision idempotencyKey', MAX_IDEMPOTENCY_KEY_LENGTH),\n };\n}\n\nexport function validateFactoryRuleDecision(value: unknown, causalDepth = 0): FactoryRuleDecision {\n if (causalDepth > MAX_FACTORY_RULE_CAUSAL_DEPTH) {\n throw new FactoryRuleValidationError('Factory rule causal depth exceeded.');\n }\n if (!isPlainObject(value)) throw new FactoryRuleValidationError('Factory rule decision must be an object.');\n const type = value.type;\n if (typeof type !== 'string') throw new FactoryRuleValidationError('Factory rule decision type is required.');\n\n switch (type) {\n case 'reject': {\n assertExactKeys(value, ['type', 'code', 'reason'], 'Factory reject decision');\n return {\n type,\n code: enumValue(value.code, REJECTION_CODES, 'Factory rejection code'),\n reason: boundedString(value.reason, 'Factory rejection reason', MAX_REASON_LENGTH),\n };\n }\n case 'transition': {\n assertExactKeys(\n value,\n ['type', 'idempotencyKey', 'board', 'stage', 'message', 'reenter'],\n 'Factory transition decision',\n );\n if (value.reenter !== undefined && typeof value.reenter !== 'boolean') {\n throw new FactoryRuleValidationError('Factory transition reenter must be a boolean.');\n }\n let message: { text: string; role?: string } | undefined;\n if (value.message !== undefined) {\n if (!isPlainObject(value.message)) {\n throw new FactoryRuleValidationError('Factory transition message must be an object.');\n }\n assertExactKeys(value.message, ['text', 'role'], 'Factory transition message');\n const role =\n value.message.role === undefined\n ? undefined\n : boundedString(value.message.role, 'Factory transition message role', MAX_ROLE_LENGTH, IDENTIFIER_RE);\n message = {\n text: boundedString(value.message.text, 'Factory transition message text', MAX_MESSAGE_LENGTH),\n ...(role ? { role } : {}),\n };\n }\n return {\n type,\n ...commonCommitFields(value),\n board: boardIdentifier(value.board, 'Factory transition board'),\n stage: boardIdentifier(value.stage, 'Factory transition stage'),\n ...(message ? { message } : {}),\n ...(value.reenter === true ? { reenter: true } : {}),\n };\n }\n case 'upsertLinkedWorkItem': {\n assertExactKeys(\n value,\n [\n 'type',\n 'idempotencyKey',\n 'board',\n 'source',\n 'sourceKey',\n 'claimKey',\n 'title',\n 'url',\n 'stage',\n 'skipRules',\n 'metadata',\n ],\n 'Factory linked work item decision',\n );\n if (value.skipRules !== undefined && typeof value.skipRules !== 'boolean') {\n throw new FactoryRuleValidationError('Factory linked work item skipRules must be a boolean.');\n }\n const claimKey = optionalBoundedString(\n value.claimKey,\n 'Factory linked work item claimKey',\n MAX_SOURCE_KEY_LENGTH,\n );\n const url = value.url;\n if (url !== null && (typeof url !== 'string' || url.length > MAX_URL_LENGTH || !/^https?:\\/\\//.test(url))) {\n throw new FactoryRuleValidationError('Factory linked work item URL is invalid.');\n }\n const metadata = sanitizeMetadata(value.metadata);\n return {\n type,\n ...commonCommitFields(value),\n board: boardIdentifier(value.board, 'Factory linked work item board'),\n source: enumValue(value.source, WORK_ITEM_SOURCES, 'Factory linked work item source'),\n sourceKey: boundedString(value.sourceKey, 'Factory linked work item sourceKey', MAX_SOURCE_KEY_LENGTH),\n ...(claimKey ? { claimKey } : {}),\n title: boundedString(value.title, 'Factory linked work item title', MAX_TITLE_LENGTH),\n url,\n stage: boardIdentifier(value.stage, 'Factory linked work item stage'),\n ...(value.skipRules === true ? { skipRules: true } : {}),\n ...(metadata ? { metadata } : {}),\n };\n }\n case 'invokeSkill': {\n assertExactKeys(\n value,\n [\n 'type',\n 'idempotencyKey',\n 'role',\n 'skillName',\n 'prompt',\n 'arguments',\n 'precedingMessage',\n 'cancelInFlight',\n 'resume',\n ],\n 'Factory invoke skill decision',\n );\n // A run activates a skill or carries a prompt, never both: they are two\n // ways to author the same kickoff message, so accepting both would leave\n // the dispatcher picking a winner.\n if ((value.skillName === undefined) === (value.prompt === undefined)) {\n throw new FactoryRuleValidationError('Factory skill invocation needs exactly one of skillName or prompt.');\n }\n const args = optionalBoundedString(value.arguments, 'Factory skill arguments', MAX_ARGUMENTS_LENGTH);\n const precedingMessage = optionalBoundedString(\n value.precedingMessage,\n 'Factory skill preceding message',\n MAX_MESSAGE_LENGTH,\n );\n if (value.cancelInFlight !== undefined && typeof value.cancelInFlight !== 'boolean') {\n throw new FactoryRuleValidationError('Factory skill cancelInFlight must be a boolean.');\n }\n if (value.resume !== undefined && typeof value.resume !== 'boolean') {\n throw new FactoryRuleValidationError('Factory skill resume must be a boolean.');\n }\n // Resume continues an already-active skill by name; a plain prompt run has no\n // skill to resume, so the dispatcher would silently ignore the flag.\n if (value.resume === true && value.skillName === undefined) {\n throw new FactoryRuleValidationError('Factory skill resume requires skillName.');\n }\n return {\n type,\n ...commonCommitFields(value),\n role: boundedString(value.role, 'Factory skill role', MAX_ROLE_LENGTH, IDENTIFIER_RE),\n ...(value.skillName === undefined\n ? { prompt: boundedString(value.prompt, 'Factory skill prompt', MAX_MESSAGE_LENGTH) }\n : {\n skillName: boundedString(value.skillName, 'Factory skill name', MAX_SKILL_NAME_LENGTH, SKILL_NAME_RE),\n ...(value.resume === true ? { resume: true } : {}),\n }),\n ...(args ? { arguments: args } : {}),\n ...(precedingMessage ? { precedingMessage } : {}),\n ...(value.cancelInFlight === true ? { cancelInFlight: true } : {}),\n };\n }\n case 'sendMessage': {\n assertExactKeys(\n value,\n ['type', 'idempotencyKey', 'role', 'message', 'priority', 'idleBehavior', 'prepareBinding'],\n 'Factory send message decision',\n );\n const priority =\n value.priority === undefined\n ? undefined\n : enumValue(value.priority, ['medium', 'high', 'urgent'] as const, 'Factory message priority');\n const idleBehavior =\n value.idleBehavior === undefined\n ? undefined\n : enumValue(value.idleBehavior, ['persist', 'wake'] as const, 'Factory message idle behavior');\n if (value.prepareBinding !== undefined && typeof value.prepareBinding !== 'boolean') {\n throw new FactoryRuleValidationError('Factory message prepareBinding must be a boolean.');\n }\n if (value.prepareBinding === true && value.role === undefined) {\n throw new FactoryRuleValidationError('Factory message prepareBinding requires a role.');\n }\n const role =\n value.role === undefined\n ? undefined\n : boundedString(value.role, 'Factory message role', MAX_ROLE_LENGTH, IDENTIFIER_RE);\n return {\n type,\n ...commonCommitFields(value),\n ...(role ? { role } : {}),\n message: boundedString(value.message, 'Factory message', MAX_MESSAGE_LENGTH),\n ...(priority ? { priority } : {}),\n ...(idleBehavior ? { idleBehavior } : {}),\n ...(value.prepareBinding === true ? { prepareBinding: true } : {}),\n };\n }\n case 'notify': {\n assertExactKeys(value, ['type', 'idempotencyKey', 'title', 'body', 'level'], 'Factory notify decision');\n const body = optionalBoundedString(value.body, 'Factory notification body', MAX_MESSAGE_LENGTH);\n const level =\n value.level === undefined\n ? undefined\n : enumValue(value.level, ['info', 'warning', 'error'] as const, 'Factory notification level');\n return {\n type,\n ...commonCommitFields(value),\n title: boundedString(value.title, 'Factory notification title', MAX_TITLE_LENGTH),\n ...(body ? { body } : {}),\n ...(level ? { level } : {}),\n };\n }\n case 'dismissStaleReviews': {\n assertExactKeys(\n value,\n [\n 'type',\n 'idempotencyKey',\n 'installationId',\n 'repository',\n 'pullRequestNumber',\n 'approvingReviewId',\n 'approvingAuthor',\n ],\n 'Factory dismiss stale reviews decision',\n );\n for (const key of ['installationId', 'pullRequestNumber'] as const) {\n if (!Number.isSafeInteger(value[key]) || (value[key] as number) <= 0) {\n throw new FactoryRuleValidationError(`Factory dismiss stale reviews ${key} must be a positive integer.`);\n }\n }\n return {\n type,\n ...commonCommitFields(value),\n installationId: value.installationId as number,\n repository: boundedString(value.repository, 'Factory dismiss stale reviews repository', MAX_TITLE_LENGTH),\n pullRequestNumber: value.pullRequestNumber as number,\n approvingReviewId: boundedString(value.approvingReviewId, 'Factory approving review id', MAX_TITLE_LENGTH),\n approvingAuthor: boundedString(value.approvingAuthor, 'Factory approving review author', MAX_TITLE_LENGTH),\n };\n }\n default:\n throw new FactoryRuleValidationError('Factory rule decision type is unsupported.');\n }\n}\n\nexport function validateFactoryRuleDecisions(values: readonly unknown[], causalDepth = 0): FactoryCommitDecision[] {\n if (values.length > MAX_JSON_COLLECTION_SIZE) {\n throw new FactoryRuleValidationError('Factory rule produced too many decisions.');\n }\n const decisions: FactoryCommitDecision[] = [];\n for (const value of values) {\n const decision = validateFactoryRuleDecision(value, causalDepth);\n if (decision.type === 'reject') {\n throw new FactoryRuleValidationError('A rejection cannot be persisted with commit decisions.');\n }\n decisions.push(decision);\n }\n const keys = decisions.map(decision => decision.idempotencyKey);\n if (new Set(keys).size !== keys.length) {\n throw new FactoryRuleValidationError('Factory decisions require unique idempotency keys.');\n }\n return decisions;\n}\n"],"mappings":";AASA,MAAa,gCAAgC;AAE7C,MAAM,qBAAqB;AAC3B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AM;IACzB,mBAAmB,cAAc,MAAM,mBAAmB,+BAA+B,gBAAgB;IACzG,iBAAiB,cAAc,MAAM,iBAAiB,mCAAmC,gBAAgB;GAC3G;EAEF,SACE,MAAM,IAAI,2BAA2B,4CAA4C;CACrF;AACF;AAEA,SAAgB,6BAA6B,QAA4B,cAAc,GAA4B;CACjH,IAAI,OAAO,SAAS,0BAClB,MAAM,IAAI,2BAA2B,2CAA2C;CAElF,MAAM,YAAqC,CAAC;CAC5C,KAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,WAAW,4BAA4B,OAAO,WAAW;EAC/D,IAAI,SAAS,SAAS,UACpB,MAAM,IAAI,2BAA2B,wDAAwD;EAE/F,UAAU,KAAK,QAAQ;CACzB;CACA,MAAM,OAAO,UAAU,KAAI,aAAY,SAAS,cAAc;CAC9D,IAAI,IAAI,IAAI,IAAI,CAAC,CAAC,SAAS,KAAK,QAC9B,MAAM,IAAI,2BAA2B,oDAAoD;CAE3F,OAAO;AACT"}
1
+ {"version":3,"file":"validation.js","names":[],"sources":["../../src/rules/validation.ts"],"sourcesContent":["import type { BoardRegistry } from '../boards/registry.js';\nimport type {\n FactoryCommitDecision,\n FactoryRuleDecision,\n FactoryRuleJsonValue,\n FactoryRuleRejectionCode,\n WorkItemSource,\n} from './types.js';\n\nexport const MAX_FACTORY_RULE_CAUSAL_DEPTH = 8;\n\nconst MAX_VERSION_LENGTH = 128;\nconst MAX_IDEMPOTENCY_KEY_LENGTH = 256;\nconst MAX_REASON_LENGTH = 512;\nconst MAX_TITLE_LENGTH = 512;\nconst MAX_MESSAGE_LENGTH = 8_192;\nconst MAX_ARGUMENTS_LENGTH = 4_096;\nexport const MAX_ROLE_LENGTH = 32;\nexport const MAX_TOOL_NAME_LENGTH = 128;\nexport const MAX_SKILL_NAME_LENGTH = 128;\nconst MAX_SOURCE_KEY_LENGTH = 256;\nconst MAX_URL_LENGTH = 2_048;\nconst MAX_METADATA_JSON_LENGTH = 16_384;\nconst MAX_JSON_DEPTH = 8;\nconst MAX_JSON_COLLECTION_SIZE = 100;\n\nexport const MAX_BOARD_IDENTIFIER_LENGTH = 128;\nexport const IDENTIFIER_RE = /^[a-z0-9][a-z0-9_-]*$/i;\nexport const BOARD_IDENTIFIER_RE = IDENTIFIER_RE;\nexport const SKILL_NAME_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;\nconst SENSITIVE_KEY_RE = /(?:authorization|cookie|credential|password|secret|token)/i;\nconst WORK_ITEM_SOURCES: readonly 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];\nconst REJECTION_CODES: readonly FactoryRuleRejectionCode[] = [\n 'forbidden',\n 'invalid_transition',\n 'missing_binding',\n 'stale',\n 'timeout',\n 'rule_error',\n 'causal_depth_exceeded',\n 'repeated_transition',\n];\n\nexport class FactoryRuleValidationError extends Error {\n readonly code = 'invalid_factory_rule';\n\n constructor(message: string) {\n super(message);\n this.name = 'FactoryRuleValidationError';\n }\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) return false;\n const prototype = Object.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n}\n\nfunction assertExactKeys(value: Record<string, unknown>, keys: readonly string[], label: string): void {\n const allowed = new Set(keys);\n if (Object.keys(value).some(key => !allowed.has(key))) {\n throw new FactoryRuleValidationError(`${label} contains an unsupported field.`);\n }\n}\n\nfunction boundedString(value: unknown, label: string, max: number, pattern?: RegExp): string {\n if (typeof value !== 'string') throw new FactoryRuleValidationError(`${label} must be a string.`);\n const normalized = value.trim();\n if (normalized.length === 0 || normalized.length > max || (pattern && !pattern.test(normalized))) {\n throw new FactoryRuleValidationError(`${label} is invalid.`);\n }\n return normalized;\n}\n\nexport function isBoardIdentifier(value: unknown): value is string {\n return typeof value === 'string' && value.length <= MAX_BOARD_IDENTIFIER_LENGTH && BOARD_IDENTIFIER_RE.test(value);\n}\n\nfunction boardIdentifier(value: unknown, label: string): string {\n if (!isBoardIdentifier(value)) {\n throw new FactoryRuleValidationError(`${label} is invalid.`);\n }\n return value;\n}\n\nexport function assertFactoryDecisionTarget(\n decision: FactoryRuleDecision,\n boards: BoardRegistry,\n itemBoard?: string | null,\n): void {\n if (decision.type !== 'transition' && decision.type !== 'upsertLinkedWorkItem') return;\n const board = boards.get(decision.board);\n if (!board) throw new FactoryRuleValidationError('Factory decision target board is not installed.');\n if (!Object.hasOwn(board.phases, decision.stage)) {\n throw new FactoryRuleValidationError('Factory decision target phase is not defined on its board.');\n }\n if (decision.type === 'transition' && itemBoard !== undefined && itemBoard !== decision.board) {\n throw new FactoryRuleValidationError('Factory transition cannot change the item board.');\n }\n}\n\nfunction optionalBoundedString(value: unknown, label: string, max: number): string | undefined {\n if (value === undefined) return undefined;\n return boundedString(value, label, max);\n}\n\nfunction enumValue<T extends string>(value: unknown, allowed: readonly T[], label: string): T {\n if (typeof value !== 'string' || !allowed.includes(value as T)) {\n throw new FactoryRuleValidationError(`${label} is invalid.`);\n }\n return value as T;\n}\n\nexport function normalizeFactoryRuleJsonValue(\n value: unknown,\n depth = 0,\n seen = new Set<object>(),\n): FactoryRuleJsonValue {\n if (value === null || typeof value === 'boolean' || typeof value === 'string') return value;\n if (typeof value === 'number') {\n if (!Number.isFinite(value)) throw new FactoryRuleValidationError('Rule metadata must contain finite numbers.');\n return value;\n }\n if (depth >= MAX_JSON_DEPTH || (typeof value !== 'object' && !Array.isArray(value))) {\n throw new FactoryRuleValidationError('Rule metadata is not bounded JSON.');\n }\n if (seen.has(value as object)) throw new FactoryRuleValidationError('Rule metadata must not contain cycles.');\n seen.add(value as object);\n try {\n if (Array.isArray(value)) {\n if (value.length > MAX_JSON_COLLECTION_SIZE) {\n throw new FactoryRuleValidationError('Rule metadata contains too many entries.');\n }\n return value.map(entry => normalizeFactoryRuleJsonValue(entry, depth + 1, seen));\n }\n if (!isPlainObject(value)) throw new FactoryRuleValidationError('Rule metadata must use plain objects.');\n const entries = Object.entries(value);\n if (entries.length > MAX_JSON_COLLECTION_SIZE) {\n throw new FactoryRuleValidationError('Rule metadata contains too many fields.');\n }\n const sanitized: Record<string, FactoryRuleJsonValue> = {};\n for (const [key, entry] of entries) {\n const normalizedKey = boundedString(key, 'Rule metadata key', 128, IDENTIFIER_RE);\n sanitized[normalizedKey] = SENSITIVE_KEY_RE.test(normalizedKey)\n ? '[REDACTED]'\n : normalizeFactoryRuleJsonValue(entry, depth + 1, seen);\n }\n return sanitized;\n } finally {\n seen.delete(value as object);\n }\n}\n\nfunction sanitizeMetadata(value: unknown): Record<string, FactoryRuleJsonValue> | undefined {\n if (value === undefined) return undefined;\n const sanitized = normalizeFactoryRuleJsonValue(value);\n if (!isPlainObject(sanitized)) throw new FactoryRuleValidationError('Rule metadata must be an object.');\n if (JSON.stringify(sanitized).length > MAX_METADATA_JSON_LENGTH) {\n throw new FactoryRuleValidationError('Rule metadata is too large.');\n }\n return sanitized;\n}\n\nexport const DEFAULT_FACTORY_CONFIG_VERSION = 'factory-config-v1';\n\n/** Operator-maintained provenance label stamped on transition audit and deferred-decision rows. */\nexport function assertFactoryConfigVersion(value: unknown): string {\n return boundedString(value, 'Factory configVersion', MAX_VERSION_LENGTH);\n}\n\nfunction commonCommitFields(value: Record<string, unknown>): { idempotencyKey: string } {\n return {\n idempotencyKey: boundedString(value.idempotencyKey, 'Factory decision idempotencyKey', MAX_IDEMPOTENCY_KEY_LENGTH),\n };\n}\n\nexport function validateFactoryRuleDecision(value: unknown, causalDepth = 0): FactoryRuleDecision {\n if (causalDepth > MAX_FACTORY_RULE_CAUSAL_DEPTH) {\n throw new FactoryRuleValidationError('Factory rule causal depth exceeded.');\n }\n if (!isPlainObject(value)) throw new FactoryRuleValidationError('Factory rule decision must be an object.');\n const type = value.type;\n if (typeof type !== 'string') throw new FactoryRuleValidationError('Factory rule decision type is required.');\n\n switch (type) {\n case 'reject': {\n assertExactKeys(value, ['type', 'code', 'reason'], 'Factory reject decision');\n return {\n type,\n code: enumValue(value.code, REJECTION_CODES, 'Factory rejection code'),\n reason: boundedString(value.reason, 'Factory rejection reason', MAX_REASON_LENGTH),\n };\n }\n case 'transition': {\n assertExactKeys(\n value,\n ['type', 'idempotencyKey', 'board', 'stage', 'message', 'reenter'],\n 'Factory transition decision',\n );\n if (value.reenter !== undefined && typeof value.reenter !== 'boolean') {\n throw new FactoryRuleValidationError('Factory transition reenter must be a boolean.');\n }\n let message: { text: string; role?: string } | undefined;\n if (value.message !== undefined) {\n if (!isPlainObject(value.message)) {\n throw new FactoryRuleValidationError('Factory transition message must be an object.');\n }\n assertExactKeys(value.message, ['text', 'role'], 'Factory transition message');\n const role =\n value.message.role === undefined\n ? undefined\n : boundedString(value.message.role, 'Factory transition message role', MAX_ROLE_LENGTH, IDENTIFIER_RE);\n message = {\n text: boundedString(value.message.text, 'Factory transition message text', MAX_MESSAGE_LENGTH),\n ...(role ? { role } : {}),\n };\n }\n return {\n type,\n ...commonCommitFields(value),\n board: boardIdentifier(value.board, 'Factory transition board'),\n stage: boardIdentifier(value.stage, 'Factory transition stage'),\n ...(message ? { message } : {}),\n ...(value.reenter === true ? { reenter: true } : {}),\n };\n }\n case 'upsertLinkedWorkItem': {\n assertExactKeys(\n value,\n [\n 'type',\n 'idempotencyKey',\n 'board',\n 'source',\n 'sourceKey',\n 'claimKey',\n 'title',\n 'url',\n 'stage',\n 'skipRules',\n 'metadata',\n ],\n 'Factory linked work item decision',\n );\n if (value.skipRules !== undefined && typeof value.skipRules !== 'boolean') {\n throw new FactoryRuleValidationError('Factory linked work item skipRules must be a boolean.');\n }\n const claimKey = optionalBoundedString(\n value.claimKey,\n 'Factory linked work item claimKey',\n MAX_SOURCE_KEY_LENGTH,\n );\n const url = value.url;\n if (url !== null && (typeof url !== 'string' || url.length > MAX_URL_LENGTH || !/^https?:\\/\\//.test(url))) {\n throw new FactoryRuleValidationError('Factory linked work item URL is invalid.');\n }\n const metadata = sanitizeMetadata(value.metadata);\n return {\n type,\n ...commonCommitFields(value),\n board: boardIdentifier(value.board, 'Factory linked work item board'),\n source: enumValue(value.source, WORK_ITEM_SOURCES, 'Factory linked work item source'),\n sourceKey: boundedString(value.sourceKey, 'Factory linked work item sourceKey', MAX_SOURCE_KEY_LENGTH),\n ...(claimKey ? { claimKey } : {}),\n title: boundedString(value.title, 'Factory linked work item title', MAX_TITLE_LENGTH),\n url,\n stage: boardIdentifier(value.stage, 'Factory linked work item stage'),\n ...(value.skipRules === true ? { skipRules: true } : {}),\n ...(metadata ? { metadata } : {}),\n };\n }\n case 'invokeSkill': {\n assertExactKeys(\n value,\n [\n 'type',\n 'idempotencyKey',\n 'role',\n 'skillName',\n 'prompt',\n 'arguments',\n 'precedingMessage',\n 'cancelInFlight',\n 'startsAfterOwnMove',\n 'resume',\n ],\n 'Factory invoke skill decision',\n );\n // A run activates a skill or carries a prompt, never both: they are two\n // ways to author the same kickoff message, so accepting both would leave\n // the dispatcher picking a winner.\n if ((value.skillName === undefined) === (value.prompt === undefined)) {\n throw new FactoryRuleValidationError('Factory skill invocation needs exactly one of skillName or prompt.');\n }\n const args = optionalBoundedString(value.arguments, 'Factory skill arguments', MAX_ARGUMENTS_LENGTH);\n const precedingMessage = optionalBoundedString(\n value.precedingMessage,\n 'Factory skill preceding message',\n MAX_MESSAGE_LENGTH,\n );\n if (value.cancelInFlight !== undefined && typeof value.cancelInFlight !== 'boolean') {\n throw new FactoryRuleValidationError('Factory skill cancelInFlight must be a boolean.');\n }\n if (value.startsAfterOwnMove !== undefined && typeof value.startsAfterOwnMove !== 'boolean') {\n throw new FactoryRuleValidationError('Factory skill startsAfterOwnMove must be a boolean.');\n }\n if (value.resume !== undefined && typeof value.resume !== 'boolean') {\n throw new FactoryRuleValidationError('Factory skill resume must be a boolean.');\n }\n // Resume continues an already-active skill by name; a plain prompt run has no\n // skill to resume, so the dispatcher would silently ignore the flag.\n if (value.resume === true && value.skillName === undefined) {\n throw new FactoryRuleValidationError('Factory skill resume requires skillName.');\n }\n return {\n type,\n ...commonCommitFields(value),\n role: boundedString(value.role, 'Factory skill role', MAX_ROLE_LENGTH, IDENTIFIER_RE),\n ...(value.skillName === undefined\n ? { prompt: boundedString(value.prompt, 'Factory skill prompt', MAX_MESSAGE_LENGTH) }\n : {\n skillName: boundedString(value.skillName, 'Factory skill name', MAX_SKILL_NAME_LENGTH, SKILL_NAME_RE),\n ...(value.resume === true ? { resume: true } : {}),\n }),\n ...(args ? { arguments: args } : {}),\n ...(precedingMessage ? { precedingMessage } : {}),\n ...(value.cancelInFlight === true ? { cancelInFlight: true } : {}),\n ...(value.startsAfterOwnMove === true ? { startsAfterOwnMove: true } : {}),\n };\n }\n case 'sendMessage': {\n assertExactKeys(\n value,\n ['type', 'idempotencyKey', 'role', 'message', 'priority', 'idleBehavior', 'prepareBinding'],\n 'Factory send message decision',\n );\n const priority =\n value.priority === undefined\n ? undefined\n : enumValue(value.priority, ['medium', 'high', 'urgent'] as const, 'Factory message priority');\n const idleBehavior =\n value.idleBehavior === undefined\n ? undefined\n : enumValue(value.idleBehavior, ['persist', 'wake'] as const, 'Factory message idle behavior');\n if (value.prepareBinding !== undefined && typeof value.prepareBinding !== 'boolean') {\n throw new FactoryRuleValidationError('Factory message prepareBinding must be a boolean.');\n }\n if (value.prepareBinding === true && value.role === undefined) {\n throw new FactoryRuleValidationError('Factory message prepareBinding requires a role.');\n }\n const role =\n value.role === undefined\n ? undefined\n : boundedString(value.role, 'Factory message role', MAX_ROLE_LENGTH, IDENTIFIER_RE);\n return {\n type,\n ...commonCommitFields(value),\n ...(role ? { role } : {}),\n message: boundedString(value.message, 'Factory message', MAX_MESSAGE_LENGTH),\n ...(priority ? { priority } : {}),\n ...(idleBehavior ? { idleBehavior } : {}),\n ...(value.prepareBinding === true ? { prepareBinding: true } : {}),\n };\n }\n case 'notify': {\n assertExactKeys(value, ['type', 'idempotencyKey', 'title', 'body', 'level'], 'Factory notify decision');\n const body = optionalBoundedString(value.body, 'Factory notification body', MAX_MESSAGE_LENGTH);\n const level =\n value.level === undefined\n ? undefined\n : enumValue(value.level, ['info', 'warning', 'error'] as const, 'Factory notification level');\n return {\n type,\n ...commonCommitFields(value),\n title: boundedString(value.title, 'Factory notification title', MAX_TITLE_LENGTH),\n ...(body ? { body } : {}),\n ...(level ? { level } : {}),\n };\n }\n case 'dismissStaleReviews': {\n assertExactKeys(\n value,\n [\n 'type',\n 'idempotencyKey',\n 'installationId',\n 'repository',\n 'pullRequestNumber',\n 'approvingReviewId',\n 'approvingAuthor',\n ],\n 'Factory dismiss stale reviews decision',\n );\n for (const key of ['installationId', 'pullRequestNumber'] as const) {\n if (!Number.isSafeInteger(value[key]) || (value[key] as number) <= 0) {\n throw new FactoryRuleValidationError(`Factory dismiss stale reviews ${key} must be a positive integer.`);\n }\n }\n return {\n type,\n ...commonCommitFields(value),\n installationId: value.installationId as number,\n repository: boundedString(value.repository, 'Factory dismiss stale reviews repository', MAX_TITLE_LENGTH),\n pullRequestNumber: value.pullRequestNumber as number,\n approvingReviewId: boundedString(value.approvingReviewId, 'Factory approving review id', MAX_TITLE_LENGTH),\n approvingAuthor: boundedString(value.approvingAuthor, 'Factory approving review author', MAX_TITLE_LENGTH),\n };\n }\n default:\n throw new FactoryRuleValidationError('Factory rule decision type is unsupported.');\n }\n}\n\nexport function validateFactoryRuleDecisions(values: readonly unknown[], causalDepth = 0): FactoryCommitDecision[] {\n if (values.length > MAX_JSON_COLLECTION_SIZE) {\n throw new FactoryRuleValidationError('Factory rule produced too many decisions.');\n }\n const decisions: FactoryCommitDecision[] = [];\n for (const value of values) {\n const decision = validateFactoryRuleDecision(value, causalDepth);\n if (decision.type === 'reject') {\n throw new FactoryRuleValidationError('A rejection cannot be persisted with commit decisions.');\n }\n decisions.push(decision);\n }\n const keys = decisions.map(decision => decision.idempotencyKey);\n if (new Set(keys).size !== keys.length) {\n throw new FactoryRuleValidationError('Factory decisions require unique idempotency keys.');\n }\n return decisions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IAC/E,QAAQ,CAAC,QAAQ,YAAY;gBAIjB,QAAQ,EAAE,0BAA0B;IAKhD,MAAM,CAAC,GAAG,EAAE,qBAAqB,GAAG,aAAa;CAGlD"}
1
+ {"version":3,"file":"callback-factory-sandbox.d.ts","sourceRoot":"","sources":["../../src/sandbox/callback-factory-sandbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEnF,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAEvE;;;;GAIG;AACH,qBAAa,sBAAuB,SAAQ,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;;IAC/E,QAAQ,CAAC,QAAQ,YAAY;IAI7B,YAAY,QAAQ,EAAE,0BAA0B,EAG/C;IAED,MAAM,CAAC,GAAG,EAAE,qBAAqB,GAAG,aAAa,CAEhD;CACF"}
@@ -11,8 +11,11 @@ export interface LocalFactorySandboxOptions {
11
11
  * host variables that keep git and TLS working (HOME, USER, SHELL, locale,
12
12
  * SSL_CERT_*, …), so app secrets never reach commands run against untrusted
13
13
  * repository checkouts. PATH is always added by LocalSandbox itself.
14
+ *
15
+ * A function receives each session's context, so a credential can go to one
16
+ * factory's sessions only: `ctx => (ctx.factoryId === id ? { TOKEN } : {})`.
14
17
  */
15
- env?: Record<string, string>;
18
+ env?: Record<string, string> | ((ctx: FactorySandboxContext) => Record<string, string>);
16
19
  }
17
20
  /**
18
21
  * Sessions run on the host machine: each session's sandbox is a LocalSandbox
@@ -1 +1 @@
1
- {"version":3,"file":"local-factory-sandbox.d.ts","sourceRoot":"","sources":["../../src/sandbox/local-factory-sandbox.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAEpE,MAAM,WAAW,0BAA0B;IACzC;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;OAKG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AA2BD;;;;GAIG;AACH,qBAAa,mBAAoB,SAAQ,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;;IAC5E,QAAQ,CAAC,QAAQ,WAAW;gBAKhB,OAAO,GAAE,0BAA+B;IAQpD,MAAM,CAAC,GAAG,EAAE,qBAAqB,GAAG,YAAY;CAQjD"}
1
+ {"version":3,"file":"local-factory-sandbox.d.ts","sourceRoot":"","sources":["../../src/sandbox/local-factory-sandbox.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAEpE,MAAM,WAAW,0BAA0B;IACzC;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;;;OAQG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,qBAAqB,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACzF;AA2BD;;;;GAIG;AACH,qBAAa,mBAAoB,SAAQ,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;;IAC5E,QAAQ,CAAC,QAAQ,WAAW;IAK5B,YAAY,OAAO,GAAE,0BAA+B,EAMnD;IAED,MAAM,CAAC,GAAG,EAAE,qBAAqB,GAAG,YAAY,CAO/C;CACF"}
@@ -44,7 +44,7 @@ var LocalFactorySandbox = class extends FactorySandbox {
44
44
  id: ctx.sessionId,
45
45
  timeout: 3e4,
46
46
  workingDirectory: join(this.#root, ctx.sessionId),
47
- env: this.#env
47
+ env: typeof this.#env === "function" ? this.#env(ctx) : this.#env
48
48
  });
49
49
  }
50
50
  };
@@ -1 +1 @@
1
- {"version":3,"file":"local-factory-sandbox.js","names":[],"sources":["../../src/sandbox/local-factory-sandbox.ts"],"sourcesContent":["import { homedir } from 'node:os';\nimport { join } from 'node:path';\nimport { FactorySandbox, LocalSandbox } from '@mastra/core/workspace';\nimport type { FactorySandboxContext } from '@mastra/core/workspace';\n\nexport interface LocalFactorySandboxOptions {\n /**\n * Directory under which every session gets its own working directory.\n * Defaults to `MASTRACODE_LOCAL_SANDBOX_ROOT`, else `~/.mastracode/web/sandboxes`.\n */\n root?: string;\n /**\n * Environment for commands run in the sandbox. Defaults to an allow-list of\n * host variables that keep git and TLS working (HOME, USER, SHELL, locale,\n * SSL_CERT_*, …), so app secrets never reach commands run against untrusted\n * repository checkouts. PATH is always added by LocalSandbox itself.\n */\n env?: Record<string, string>;\n}\n\nconst HOST_ENV_KEYS = [\n 'HOME',\n 'USER',\n 'LOGNAME',\n 'SHELL',\n 'TMPDIR',\n 'LANG',\n 'LC_ALL',\n 'TERM',\n 'TZ',\n 'GIT_EXEC_PATH',\n 'GIT_TEMPLATE_DIR',\n 'SSL_CERT_FILE',\n 'SSL_CERT_DIR',\n] as const;\n\nfunction hostEnv(): Record<string, string> {\n const env: Record<string, string> = {};\n for (const key of HOST_ENV_KEYS) {\n const value = process.env[key];\n if (value) env[key] = value;\n }\n return env;\n}\n\n/**\n * Sessions run on the host machine: each session's sandbox is a LocalSandbox\n * rooted at `join(root, sessionId)`, where the repository checks out as a\n * subdirectory. No template and no user-tunable settings.\n */\nexport class LocalFactorySandbox extends FactorySandbox<Record<string, never>> {\n readonly provider = 'local';\n\n readonly #root: string;\n readonly #env: Record<string, string>;\n\n constructor(options: LocalFactorySandboxOptions = {}) {\n super();\n this.#root =\n options.root ??\n (process.env.MASTRACODE_LOCAL_SANDBOX_ROOT?.trim() || join(homedir(), '.mastracode', 'web', 'sandboxes'));\n this.#env = options.env ?? hostEnv();\n }\n\n create(ctx: FactorySandboxContext): LocalSandbox {\n return new LocalSandbox({\n id: ctx.sessionId,\n timeout: 30_000,\n workingDirectory: join(this.#root, ctx.sessionId),\n env: this.#env,\n });\n }\n}\n"],"mappings":";;;;AAoBA,MAAM,gBAAgB;CACpB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAS,UAAkC;CACzC,MAAM,MAA8B,CAAC;CACrC,KAAK,MAAM,OAAO,eAAe;EAC/B,MAAM,QAAQ,QAAQ,IAAI;EAC1B,IAAI,OAAO,IAAI,OAAO;CACxB;CACA,OAAO;AACT;;;;;;AAOA,IAAa,sBAAb,cAAyC,eAAsC;CAC7E,WAAoB;CAEpB;CACA;CAEA,YAAY,UAAsC,CAAC,GAAG;EACpD,MAAM;EACN,KAAK,QACH,QAAQ,SACP,QAAQ,IAAI,+BAA+B,KAAK,KAAK,KAAK,QAAQ,GAAG,eAAe,OAAO,WAAW;EACzG,KAAK,OAAO,QAAQ,OAAO,QAAQ;CACrC;CAEA,OAAO,KAA0C;EAC/C,OAAO,IAAI,aAAa;GACtB,IAAI,IAAI;GACR,SAAS;GACT,kBAAkB,KAAK,KAAK,OAAO,IAAI,SAAS;GAChD,KAAK,KAAK;EACZ,CAAC;CACH;AACF"}
1
+ {"version":3,"file":"local-factory-sandbox.js","names":[],"sources":["../../src/sandbox/local-factory-sandbox.ts"],"sourcesContent":["import { homedir } from 'node:os';\nimport { join } from 'node:path';\nimport { FactorySandbox, LocalSandbox } from '@mastra/core/workspace';\nimport type { FactorySandboxContext } from '@mastra/core/workspace';\n\nexport interface LocalFactorySandboxOptions {\n /**\n * Directory under which every session gets its own working directory.\n * Defaults to `MASTRACODE_LOCAL_SANDBOX_ROOT`, else `~/.mastracode/web/sandboxes`.\n */\n root?: string;\n /**\n * Environment for commands run in the sandbox. Defaults to an allow-list of\n * host variables that keep git and TLS working (HOME, USER, SHELL, locale,\n * SSL_CERT_*, …), so app secrets never reach commands run against untrusted\n * repository checkouts. PATH is always added by LocalSandbox itself.\n *\n * A function receives each session's context, so a credential can go to one\n * factory's sessions only: `ctx => (ctx.factoryId === id ? { TOKEN } : {})`.\n */\n env?: Record<string, string> | ((ctx: FactorySandboxContext) => Record<string, string>);\n}\n\nconst HOST_ENV_KEYS = [\n 'HOME',\n 'USER',\n 'LOGNAME',\n 'SHELL',\n 'TMPDIR',\n 'LANG',\n 'LC_ALL',\n 'TERM',\n 'TZ',\n 'GIT_EXEC_PATH',\n 'GIT_TEMPLATE_DIR',\n 'SSL_CERT_FILE',\n 'SSL_CERT_DIR',\n] as const;\n\nfunction hostEnv(): Record<string, string> {\n const env: Record<string, string> = {};\n for (const key of HOST_ENV_KEYS) {\n const value = process.env[key];\n if (value) env[key] = value;\n }\n return env;\n}\n\n/**\n * Sessions run on the host machine: each session's sandbox is a LocalSandbox\n * rooted at `join(root, sessionId)`, where the repository checks out as a\n * subdirectory. No template and no user-tunable settings.\n */\nexport class LocalFactorySandbox extends FactorySandbox<Record<string, never>> {\n readonly provider = 'local';\n\n readonly #root: string;\n readonly #env: NonNullable<LocalFactorySandboxOptions['env']>;\n\n constructor(options: LocalFactorySandboxOptions = {}) {\n super();\n this.#root =\n options.root ??\n (process.env.MASTRACODE_LOCAL_SANDBOX_ROOT?.trim() || join(homedir(), '.mastracode', 'web', 'sandboxes'));\n this.#env = options.env ?? hostEnv();\n }\n\n create(ctx: FactorySandboxContext): LocalSandbox {\n return new LocalSandbox({\n id: ctx.sessionId,\n timeout: 30_000,\n workingDirectory: join(this.#root, ctx.sessionId),\n env: typeof this.#env === 'function' ? this.#env(ctx) : this.#env,\n });\n }\n}\n"],"mappings":";;;;AAuBA,MAAM,gBAAgB;CACpB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAS,UAAkC;CACzC,MAAM,MAA8B,CAAC;CACrC,KAAK,MAAM,OAAO,eA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AAG,WAAW,CAAC,CAEnG;IAED;;;;;;;;;OASG;IACG,mBAAmB,CAAC,KAAK,EAAE,2BAA2B,GAAG,OAAO,CAAC,OAAO,GAAG,WAAW,GAAG,UAAU,CAAC,CAEzG;IAaK,sBAAsB,CAAC,OAAO,EAAE;QACpC,SAAS,EAAE,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;QACzC,aAAa,EAAE,0BAA0B,CAAC;QAC1C,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,IAAI,CAAC,CAchB;IAEK,+BAA+B,CAAC,OAAO,EAAE;QAC7C,aAAa,EAAE,0BAA0B,CAAC;QAC1C,SAAS,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,wBAAwB,CAAC,CAAC;QAC7D,KAAK,EAAE,MAAM,CAAC;QACd,mBAAmB,EAAE,MAAM,CAAC;KAC7B,GAAG,OAAO,CAAC,IAAI,CAAC,CAehB;CA8QF"}
@@ -1 +1 @@
1
- {"version":3,"file":"environment-state-processor.d.ts","sourceRoot":"","sources":["../../src/session/environment-state-processor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAK3G,MAAM,MAAM,gCAAgC,GAAG,IAAI,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE3E,4GAA4G;AAC5G,MAAM,WAAW,iCAAiC;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,mEAAmE;IACnE,GAAG,EAAE,MAAM,CAAC;IACZ,kFAAkF;IAClF,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,gGAAgG;IAChG,WAAW,EAAE,gCAAgC,CAAC;IAC9C,6EAA6E;IAC7E,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,uBAAuB;IACtC,wFAAwF;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Q,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CACxE;AAED,2EAA2E;AAC3E,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACrB;AASD;;;;;;;;;;;;GAYG;AACH,qBAAa,YAAY;;IAMvB,YAAY,UAAU,EAAE,eAAe,EAStC;IAmBD,gEAAgE;IAChE,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAEpC;IAED,0FAA0F;IAC1F,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAS/C;IAED,wFAAwF;IACxF,QAAQ,CAAC,gBAAgB,EAAE,MAAM,GAAG,KAAK,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,SAAS,CAAA;KAAE,CAAC,CAQ/E;IAED,uGAAuG;IACvG,eAAe,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,GAAG,MAAM,IAAI,CAGpE;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"reply-credential-processor.d.ts","sourceRoot":"","sources":["../../src/session/reply-credential-processor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAInE,yFAAyF;AACzF,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,kGAAkG;AAClG,wBAAgB,aAAa,CAAC,cAAc,EAAE,cAAc,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAUrH;AAED;;;;;;;GAOG;AACH,qBAAa,+BAAgC,YAAW,SAAS;IAC/D,QAAQ,CAAC,EAAE,8BAA8B;IACzC,QAAQ,CAAC,IAAI,8BAA8B;IAE3C,iBAAiB,CAAC,EAAE,WAAW,EAAE,cAAc,EAAE,EAAE,qBAAqB;CAYzE"}
1
+ {"version":3,"file":"reply-credential-processor.d.ts","sourceRoot":"","sources":["../../src/session/reply-credential-processor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAInE,yFAAyF;AACzF,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,kGAAkG;AAClG,wBAAgB,aAAa,CAAC,cAAc,EAAE,cAAc,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAUrH;AAED;;;;;;;GAOG;AACH,qBAAa,+BAAgC,YAAW,SAAS;IAC/D,QAAQ,CAAC,EAAE,8BAA8B;IACzC,QAAQ,CAAC,IAAI,8BAA8B;IAE3C,iBAAiB,CAAC,EAAE,WAAW,EAAE,cAAc,EAAE,EAAE,qBAAqB,4CAWvE;CACF"}
@@ -44,7 +44,7 @@ type RunEndReason = Extract<AgentControllerEvent, {
44
44
  * later steps are dropped (and counted) instead; totals always cover every step.
45
45
  */
46
46
  export declare const FACTORY_RUN_USAGE_STEPS_JSON_BUDGET = 2400;
47
- declare const USAGE_FIELDS: readonly ["promptTokens", "completionTokens", "totalTokens", "reasoningTokens", "cachedInputTokens", "cacheCreationInputTokens", "cacheCreationInputTokens5m", "cacheCreationInputTokens1h"];
47
+ declare const USAGE_FIELDS: readonly ['promptTokens', 'completionTokens', 'totalTokens', 'reasoningTokens', 'cachedInputTokens', 'cacheCreationInputTokens', 'cacheCreationInputTokens5m', 'cacheCreationInputTokens1h'];
48
48
  type UsageCounts = Partial<Record<(typeof USAGE_FIELDS)[number], number>>;
49
49
  /**
50
50
  * Token usage attached to a run's `factory.run.ended` audit record.
@@ -1 +1 @@
1
- {"version":3,"file":"run-audit.d.ts","sourceRoot":"","sources":["../../src/session/run-audit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAExE,eAAO,MAAM,yBAAyB,oBAAoB,CAAC;AAE3D,QAAA,MAAM,oBAAoB;;;;;;;;;;;;;;;iBAuBxB,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,6GAA6G;AAC7G,eAAO,MAAM,yBAAyB,QAAS,CAAC;AAEhD,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,SAAa,GAAG,OAAO,CAOtG;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,MAAM,EAAE;QACf,UAAU,CAAC,IAAI,EAAE;YAAE,GAAG,EAAE,MAAM,CAAA;SAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;QACpD,UAAU,CAAC,IAAI,EAAE;YAAE,GAAG,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,OAAO,CAAA;SAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;KAClE,CAAC;IACF,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CACxE;AAED,KAAK,YAAY,GAAG,OAAO,CAAC,oBAAoB,EAAE;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,CAAC,CAAC,QAAQ,CAAC,CAAC;AAInF;;;;GAIG;AACH,eAAO,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AE,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,aAAa,CAAA;CAAE,GAAG,MAAM,IAAI,CAcnH"}
@@ -0,0 +1,11 @@
1
+ import type { InlineSkill } from '@mastra/core/skills';
2
+ import type { BoardRegistry } from '../boards/index.js';
3
+ /** Check `MastraFactory({ skills })`: each entry must come from `createSkill()` and names must be unique. */
4
+ export declare function assertFactorySkills(skills: unknown): readonly InlineSkill[];
5
+ /**
6
+ * Problems with the skills board phases name in `runner.skill`, found at
7
+ * startup instead of when a card first enters the phase. A skill is found when
8
+ * it is a code skill, a folder skill in the app's `factory-skills/`, or bundled.
9
+ */
10
+ export declare function findBoardSkillProblems(boards: BoardRegistry, codeSkills: readonly InlineSkill[], localSkillsPath?: string | undefined): string[];
11
+ //# sourceMappingURL=app-skills.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-skills.d.ts","sourceRoot":"","sources":["../../src/skills/app-skills.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGxD,6GAA6G;AAC7G,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,WAAW,EAAE,CAkB3E;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,SAAS,WAAW,EAAE,EAClC,eAAe,GAAE,MAAM,GAAG,SAA2C,GACpE,MAAM,EAAE,CAwBV"}
@@ -0,0 +1,37 @@
1
+ import { FACTORY_SKILL_NAMES, REVIEW_ONLY_FACTORY_SKILLS, resolveLocalFactorySkillsPath } from "../workspace.js";
2
+ import { existsSync } from "fs";
3
+ import { join } from "path";
4
+ import { isInlineSkill } from "@mastra/core/skills";
5
+ // src/skills/app-skills.ts
6
+ /** Check `MastraFactory({ skills })`: each entry must come from `createSkill()` and names must be unique. */
7
+ function assertFactorySkills(skills) {
8
+ if (skills === void 0) return [];
9
+ if (!Array.isArray(skills)) throw new Error("MastraFactory: 'skills' must be an array of createSkill() results.");
10
+ const names = /* @__PURE__ */ new Set();
11
+ for (const skill of skills) {
12
+ if (!isInlineSkill(skill)) throw new Error("MastraFactory: every entry in 'skills' must be created with createSkill() from '@mastra/core/skills'.");
13
+ if (names.has(skill.name)) throw new Error(`MastraFactory: duplicate skill name '${skill.name}' in 'skills'.`);
14
+ names.add(skill.name);
15
+ }
16
+ return Object.freeze([...skills]);
17
+ }
18
+ /**
19
+ * Problems with the skills board phases name in `runner.skill`, found at
20
+ * startup instead of when a card first enters the phase. A skill is found when
21
+ * it is a code skill, a folder skill in the app's `factory-skills/`, or bundled.
22
+ */
23
+ function findBoardSkillProblems(boards, codeSkills, localSkillsPath = resolveLocalFactorySkillsPath()) {
24
+ const codeNames = new Set(codeSkills.map((skill) => skill.name));
25
+ const problems = [];
26
+ for (const [boardId, board] of boards) for (const [phaseId, phase] of Object.entries(board.phases)) {
27
+ if (phase.kind !== "working" || !phase.runner.skill) continue;
28
+ const { skill, context } = phase.runner;
29
+ const where = `Board '${boardId}' phase '${phaseId}'`;
30
+ if (!(codeNames.has(skill) || FACTORY_SKILL_NAMES.has(skill) || localSkillsPath !== void 0 && existsSync(join(localSkillsPath, skill, "SKILL.md")))) problems.push(`${where} runs skill '${skill}', but no such skill exists. Pass it in MastraFactory({ skills }) or add factory-skills/${skill}/SKILL.md.`);
31
+ else if (REVIEW_ONLY_FACTORY_SKILLS.has(skill) && context !== "review") problems.push(`${where} runs review skill '${skill}' in the '${context}' context; review skills only load in the 'review' context.`);
32
+ }
33
+ return problems;
34
+ }
35
+ export { assertFactorySkills, findBoardSkillProblems };
36
+
37
+ //# sourceMappingURL=app-skills.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-skills.js","names":[],"sources":["../../src/skills/app-skills.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { join } from 'node:path';\n\nimport { isInlineSkill } from '@mastra/core/skills';\nimport type { InlineSkill } from '@mastra/core/skills';\n\nimport type { BoardRegistry } from '../boards/index.js';\nimport { FACTORY_SKILL_NAMES, resolveLocalFactorySkillsPath, REVIEW_ONLY_FACTORY_SKILLS } from '../workspace.js';\n\n/** Check `MastraFactory({ skills })`: each entry must come from `createSkill()` and names must be unique. */\nexport function assertFactorySkills(skills: unknown): readonly InlineSkill[] {\n if (skills === undefined) return [];\n if (!Array.isArray(skills)) {\n throw new Error(\"MastraFactory: 'skills' must be an array of createSkill() results.\");\n }\n const names = new Set<string>();\n for (const skill of skills) {\n if (!isInlineSkill(skill)) {\n throw new Error(\n \"MastraFactory: every entry in 'skills' must be created with createSkill() from '@mastra/core/skills'.\",\n );\n }\n if (names.has(skill.name)) {\n throw new Error(`MastraFactory: duplicate skill name '${skill.name}' in 'skills'.`);\n }\n names.add(skill.name);\n }\n return Object.freeze([...skills]);\n}\n\n/**\n * Problems with the skills board phases name in `runner.skill`, found at\n * startup instead of when a card first enters the phase. A skill is found when\n * it is a code skill, a folder skill in the app's `factory-skills/`, or bundled.\n */\nexport function findBoardSkillProblems(\n boards: BoardRegistry,\n codeSkills: readonly InlineSkill[],\n localSkillsPath: string | undefined = resolveLocalFactorySkillsPath(),\n): string[] {\n const codeNames = new Set(codeSkills.map(skill => skill.name));\n const problems: string[] = [];\n for (const [boardId, board] of boards) {\n for (const [phaseId, phase] of Object.entries(board.phases)) {\n if (phase.kind !== 'working' || !phase.runner.skill) continue;\n const { skill, context } = phase.runner;\n const where = `Board '${boardId}' phase '${phaseId}'`;\n const found =\n codeNames.has(skill) ||\n FACTORY_SKILL_NAMES.has(skill) ||\n (localSkillsPath !== undefined && existsSync(join(localSkillsPath, skill, 'SKILL.md')));\n if (!found) {\n problems.push(\n `${where} runs skill '${skill}', but no such skill exists. Pass it in MastraFactory({ skills }) or add factory-skills/${skill}/SKILL.md.`,\n );\n } else if (REVIEW_ONLY_FACTORY_SKILLS.has(skill) && context !== 'review') {\n problems.push(\n `${where} runs review skill '${skill}' in the '${context}' context; review skills only load in the 'review' context.`,\n );\n }\n }\n }\n return problems;\n}\n"],"mappings":";;;;;;AAUA,SAAgB,oBAAoB,QAAyC;CAC3E,IAAI,WAAW,KAAA,GAAW,OAAO,CAAC;CAClC,IAAI,CAAC,MAAM,QAAQ,MAAM,GACvB,MAAM,IAAI,MAAM,oEAAoE;CAEtF,MAAM,wBAAQ,IAAI,IAAY;CAC9B,KAAK,MAAM,SAAS,QAAQ;EAC1B,IAAI,CAAC,cAAc,KAAK,GACtB,MAAM,IAAI,MACR,uGACF;EAEF,IAAI,MAAM,IAAI,MAAM,IAAI,GACtB,MAAM,IAAI,MAAM,wCAAwC,MAAM,KAAK,eAAe;EAEpF,MAAM,IAAI,MAAM,IAAI;CACtB;CACA,OAAO,OAAO,OAAO,CAAC,GAAG,MAAM,CAAC;AAClC;;;;;;AAOA,SAAgB,uBACd,QACA,YACA,kBAAsC,8BAA8B,GAC1D;CACV,MAAM,YAAY,IAAI,IAAI,WAAW,KAAI,UAAS,MAAM,IAAI,CAAC;CAC7D,MAAM,WAAqB,CAAC;CAC5B,KAAK,MAAM,CAAC,SAAS,UAAU,QAC7B,KAAK,MAAM,CAAC,SAAS,UAAU,OAAO,QAAQ,MAAM,MAAM,GAAG;EAC3D,IAAI,MAAM,SAAS,aAAa,CAAC,MAAM,OAAO,OAAO;EACrD,MAAM,EAAE,OAAO,YAAY,MAAM;EACjC,MAAM,QAAQ,UAAU,QAAQ,WAAW,QAAQ;EAKnD,IAAI,EAHF,UAAU,IAAI,KAAK,KACnB,oBAAoB,IAAI,KAAK,KAC5B,oBAAoB,KAAA,KAAa,WAAW,KAAK,iBAAiB,OAAO,UAAU,CAAC,IAErF,SAAS,KACP,GAAG,MAAM,eAAe,MAAM,0FAA0F,MAAM,WAChI;OACK,IAAI,2BAA2B,IAAI,KAAK,KAAK,YAAY,UAC9D,SAAS,KACP,GAAG,MAAM,sBAAsB,MAAM,YAAY,QAAQ,4DAC3D;CAEJ;CAEF,OAAO;AACT"}
@@ -1,14 +1,20 @@
1
+ import type { InlineSkill } from '@mastra/core/skills';
2
+ /** Where a skill comes from: shipped with Factory, the app's `factory-skills/` folder, or `MastraFactory({ skills })`. */
3
+ export type FactorySkillOrigin = 'bundled' | 'folder' | 'code';
1
4
  export interface FactorySkillInfo {
2
5
  name: string;
3
6
  description: string;
4
7
  /** SKILL.md body with the frontmatter block removed. */
5
8
  content: string;
9
+ origin: FactorySkillOrigin;
10
+ /** True for the skills Factory ships, including when the app overrides one. */
11
+ builtIn: boolean;
6
12
  /** Set when the SKILL.md fails the runtime's parsing/validation, so the agent will not be able to load it. */
7
13
  error?: string;
8
14
  }
9
15
  /**
10
- * List the Factory skills, preferring repo-local versions over bundled ones and
11
- * skipping any skill missing from both roots.
16
+ * List the skills the Factory skill mount serves, sorted by name. Code skills
17
+ * win over folder skills, which win over bundled skills of the same name.
12
18
  */
13
- export declare function listFactorySkills(): Promise<FactorySkillInfo[]>;
19
+ export declare function listFactorySkills(codeSkills?: readonly InlineSkill[]): Promise<FactorySkillInfo[]>;
14
20
  //# sourceMappingURL=catalog.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/skills/catalog.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,wDAAwD;IACxD,OAAO,EAAE,MAAM,CAAC;IAChB,8GAA8G;IAC9G,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAkBD;;;GAGG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAmBrE"}
1
+ {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/skills/catalog.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAWvD,0HAA0H;AAC1H,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE/D,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,wDAAwD;IACxD,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,kBAAkB,CAAC;IAC3B,+EAA+E;IAC/E,OAAO,EAAE,OAAO,CAAC;IACjB,8GAA8G;IAC9G,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AA6BD;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,UAAU,GAAE,SAAS,WAAW,EAAO,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAqB5G"}
@@ -1,15 +1,17 @@
1
- import { BUNDLED_FACTORY_SKILLS_PATH, FACTORY_SKILL_NAMES, resolveLocalFactorySkillsPath } from "../workspace.js";
1
+ import { FACTORY_SKILLS_MOUNT, FACTORY_SKILL_NAMES, FactorySkillSource, resolveLocalFactorySkillsPath } from "../workspace.js";
2
+ import { existsSync } from "fs";
2
3
  import { join } from "path";
3
- import { readFile } from "fs/promises";
4
4
  import { validateSkillContent } from "@mastra/core/skills";
5
5
  // src/skills/catalog.ts
6
6
  /**
7
7
  * Read-only catalog of the Factory skills.
8
8
  *
9
- * These are the built-in skills the Factory pipeline invokes at each stage
10
- * (triage, plan, review, …). The catalog reads each `SKILL.md` (repo-local
11
- * override first, then bundled) so the settings UI can show users exactly what
12
- * each skill instructs the agent to do — and whether the runtime can load it.
9
+ * Lists every skill the Factory skill mount serves — the built-in skills the
10
+ * pipeline invokes at each stage (triage, plan, review, …) and the app's own
11
+ * skills from `MastraFactory({ skills })` or its `factory-skills/` folder. It
12
+ * reads them through the same `FactorySkillSource` sessions use, so the
13
+ * settings UI shows exactly what each skill instructs the agent to do — and
14
+ * whether the runtime can load it.
13
15
  */
14
16
  function parseSkillMarkdown(name, raw) {
15
17
  const result = validateSkillContent({
@@ -19,13 +21,11 @@ function parseSkillMarkdown(name, raw) {
19
21
  const description = typeof result.metadata?.description === "string" ? result.metadata.description : "";
20
22
  const content = result.instructions ?? stripFrontmatter(raw);
21
23
  if (!result.valid) return {
22
- name,
23
24
  description,
24
25
  content,
25
26
  error: result.errors.join("\n")
26
27
  };
27
28
  return {
28
- name,
29
29
  description,
30
30
  content
31
31
  };
@@ -35,24 +35,40 @@ function stripFrontmatter(raw) {
35
35
  const match = raw.match(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/);
36
36
  return (match ? raw.slice(match[0].length) : raw).trim();
37
37
  }
38
+ const NO_REPOSITORY_SKILLS = {
39
+ exists: async () => false,
40
+ stat: async (path) => {
41
+ throw new Error(`ENOENT: no such file or directory, '${path}'`);
42
+ },
43
+ readFile: async (path) => {
44
+ throw new Error(`ENOENT: no such file or directory, '${path}'`);
45
+ },
46
+ readdir: async () => []
47
+ };
38
48
  /**
39
- * List the Factory skills, preferring repo-local versions over bundled ones and
40
- * skipping any skill missing from both roots.
49
+ * List the skills the Factory skill mount serves, sorted by name. Code skills
50
+ * win over folder skills, which win over bundled skills of the same name.
41
51
  */
42
- async function listFactorySkills() {
43
- const skills = [];
52
+ async function listFactorySkills(codeSkills = []) {
44
53
  const localRoot = resolveLocalFactorySkillsPath();
45
- const roots = localRoot ? [localRoot, BUNDLED_FACTORY_SKILLS_PATH] : [BUNDLED_FACTORY_SKILLS_PATH];
46
- for (const name of [...FACTORY_SKILL_NAMES].sort()) {
54
+ const source = new FactorySkillSource(NO_REPOSITORY_SKILLS, [], localRoot, async () => true, codeSkills);
55
+ const codeNames = new Set(codeSkills.map((skill) => skill.name));
56
+ const entries = (await source.readdir(FACTORY_SKILLS_MOUNT)).filter((entry) => entry.type === "directory");
57
+ const skills = [];
58
+ for (const name of entries.map((entry) => entry.name).sort()) {
47
59
  let raw;
48
- for (const root of roots) try {
49
- raw = await readFile(join(root, name, "SKILL.md"), "utf8");
50
- break;
60
+ try {
61
+ raw = String(await source.readFile(join(FACTORY_SKILLS_MOUNT, name, "SKILL.md")));
51
62
  } catch {
52
63
  continue;
53
64
  }
54
- if (raw === void 0) continue;
55
- skills.push(parseSkillMarkdown(name, raw));
65
+ const origin = codeNames.has(name) ? "code" : localRoot && existsSync(join(localRoot, name, "SKILL.md")) ? "folder" : "bundled";
66
+ skills.push({
67
+ name,
68
+ ...parseSkillMarkdown(name, raw),
69
+ origin,
70
+ builtIn: FACTORY_SKILL_NAMES.has(name)
71
+ });
56
72
  }
57
73
  return skills;
58
74
  }
@@ -1 +1 @@
1
- {"version":3,"file":"catalog.js","names":[],"sources":["../../src/skills/catalog.ts"],"sourcesContent":["/**\n * Read-only catalog of the Factory skills.\n *\n * These are the built-in skills the Factory pipeline invokes at each stage\n * (triage, plan, review, …). The catalog reads each `SKILL.md` (repo-local\n * override first, then bundled) so the settings UI can show users exactly what\n * each skill instructs the agent to do — and whether the runtime can load it.\n */\nimport { readFile } from 'node:fs/promises';\nimport { join } from 'node:path';\n\nimport { validateSkillContent } from '@mastra/core/skills';\n\nimport { BUNDLED_FACTORY_SKILLS_PATH, FACTORY_SKILL_NAMES, resolveLocalFactorySkillsPath } from '../workspace.js';\n\nexport interface FactorySkillInfo {\n name: string;\n description: string;\n /** SKILL.md body with the frontmatter block removed. */\n content: string;\n /** Set when the SKILL.md fails the runtime's parsing/validation, so the agent will not be able to load it. */\n error?: string;\n}\n\nfunction parseSkillMarkdown(name: string, raw: string): FactorySkillInfo {\n // Use the same parser and validation the runtime applies when loading skills,\n // so the catalog never shows a skill as healthy that the agent will drop.\n const result = validateSkillContent({ content: raw, directoryName: name });\n const description = typeof result.metadata?.description === 'string' ? result.metadata.description : '';\n const content = result.instructions ?? stripFrontmatter(raw);\n if (!result.valid) return { name, description, content, error: result.errors.join('\\n') };\n return { name, description, content };\n}\n\n/** Best-effort body extraction when the frontmatter cannot be parsed, so users can still read the file they need to fix. */\nfunction stripFrontmatter(raw: string): string {\n const match = raw.match(/^---\\r?\\n[\\s\\S]*?\\r?\\n---\\r?\\n?/);\n return (match ? raw.slice(match[0].length) : raw).trim();\n}\n\n/**\n * List the Factory skills, preferring repo-local versions over bundled ones and\n * skipping any skill missing from both roots.\n */\nexport async function listFactorySkills(): Promise<FactorySkillInfo[]> {\n const skills: FactorySkillInfo[] = [];\n const localRoot = resolveLocalFactorySkillsPath();\n const roots = localRoot ? [localRoot, BUNDLED_FACTORY_SKILLS_PATH] : [BUNDLED_FACTORY_SKILLS_PATH];\n for (const name of [...FACTORY_SKILL_NAMES].sort()) {\n let raw: string | undefined;\n // Repo-local skills override the bundled versions, matching runtime resolution.\n for (const root of roots) {\n try {\n raw = await readFile(join(root, name, 'SKILL.md'), 'utf8');\n break;\n } catch {\n continue;\n }\n }\n if (raw === undefined) continue;\n skills.push(parseSkillMarkdown(name, raw));\n }\n return skills;\n}\n"],"mappings":";;;;;;;;;;;;;AAwBA,SAAS,mBAAmB,MAAc,KAA+B;CAGvE,MAAM,SAAS,qBAAqB;EAAE,SAAS;EAAK,eAAe;CAAK,CAAC;CACzE,MAAM,cAAc,OAAO,OAAO,UAAU,gBAAgB,WAAW,OAAO,SAAS,cAAc;CACrG,MAAM,UAAU,OAAO,gBAAgB,iBAAiB,GAAG;CAC3D,IAAI,CAAC,OAAO,OAAO,OAAO;EAAE;EAAM;EAAa;EAAS,OAAO,OAAO,OAAO,KAAK,IAAI;CAAE;CACxF,OAAO;EAAE;EAAM;EAAa;CAAQ;AACtC;;AAGA,SAAS,iBAAiB,KAAqB;CAC7C,MAAM,QAAQ,IAAI,MAAM,iCAAiC;CACzD,QAAQ,QAAQ,IAAI,MAAM,MAAM,EAAE,CAAC,MAAM,IAAI,IAAA,CAAK,KAAK;AACzD;;;;;AAMA,eAAsB,oBAAiD;CACrE,MAAM,SAA6B,CAAC;CACpC,MAAM,YAAY,8BAA8B;CAChD,MAAM,QAAQ,YAAY,CAAC,WAAW,2BAA2B,IAAI,CAAC,2BAA2B;CACjG,KAAK,MAAM,QAAQ,CAAC,GAAG,mBAAmB,CAAC,CAAC,KAAK,GAAG;EAClD,IAAI;EAEJ,KAAK,MAAM,QAAQ,OACjB,IAAI;GACF,MAAM,MAAM,SAAS,KAAK,MAAM,MAAM,UAAU,GAAG,MAAM;GACzD;EACF,QAAQ;GACN;EACF;EAEF,IAAI,QAAQ,KAAA,GAAW;EACvB,OAAO,KAAK,mBAAmB,MAAM,GAAG,CAAC;CAC3C;CACA,OAAO;AACT"}
1
+ {"version":3,"file":"catalog.js","names":[],"sources":["../../src/skills/catalog.ts"],"sourcesContent":["/**\n * Read-only catalog of the Factory skills.\n *\n * Lists every skill the Factory skill mount serves — the built-in skills the\n * pipeline invokes at each stage (triage, plan, review, …) and the app's own\n * skills from `MastraFactory({ skills })` or its `factory-skills/` folder. It\n * reads them through the same `FactorySkillSource` sessions use, so the\n * settings UI shows exactly what each skill instructs the agent to do — and\n * whether the runtime can load it.\n */\nimport { existsSync } from 'node:fs';\nimport { join } from 'node:path';\n\nimport type { InlineSkill } from '@mastra/core/skills';\nimport { validateSkillContent } from '@mastra/core/skills';\nimport type { SkillSource } from '@mastra/core/workspace';\n\nimport {\n FACTORY_SKILL_NAMES,\n FACTORY_SKILLS_MOUNT,\n FactorySkillSource,\n resolveLocalFactorySkillsPath,\n} from '../workspace.js';\n\n/** Where a skill comes from: shipped with Factory, the app's `factory-skills/` folder, or `MastraFactory({ skills })`. */\nexport type FactorySkillOrigin = 'bundled' | 'folder' | 'code';\n\nexport interface FactorySkillInfo {\n name: string;\n description: string;\n /** SKILL.md body with the frontmatter block removed. */\n content: string;\n origin: FactorySkillOrigin;\n /** True for the skills Factory ships, including when the app overrides one. */\n builtIn: boolean;\n /** Set when the SKILL.md fails the runtime's parsing/validation, so the agent will not be able to load it. */\n error?: string;\n}\n\nfunction parseSkillMarkdown(name: string, raw: string): Pick<FactorySkillInfo, 'description' | 'content' | 'error'> {\n // Use the same parser and validation the runtime applies when loading skills,\n // so the catalog never shows a skill as healthy that the agent will drop.\n const result = validateSkillContent({ content: raw, directoryName: name });\n const description = typeof result.metadata?.description === 'string' ? result.metadata.description : '';\n const content = result.instructions ?? stripFrontmatter(raw);\n if (!result.valid) return { description, content, error: result.errors.join('\\n') };\n return { description, content };\n}\n\n/** Best-effort body extraction when the frontmatter cannot be parsed, so users can still read the file they need to fix. */\nfunction stripFrontmatter(raw: string): string {\n const match = raw.match(/^---\\r?\\n[\\s\\S]*?\\r?\\n---\\r?\\n?/);\n return (match ? raw.slice(match[0].length) : raw).trim();\n}\n\nconst NO_REPOSITORY_SKILLS: SkillSource = {\n exists: async () => false,\n stat: async path => {\n throw new Error(`ENOENT: no such file or directory, '${path}'`);\n },\n readFile: async path => {\n throw new Error(`ENOENT: no such file or directory, '${path}'`);\n },\n readdir: async () => [],\n};\n\n/**\n * List the skills the Factory skill mount serves, sorted by name. Code skills\n * win over folder skills, which win over bundled skills of the same name.\n */\nexport async function listFactorySkills(codeSkills: readonly InlineSkill[] = []): Promise<FactorySkillInfo[]> {\n const localRoot = resolveLocalFactorySkillsPath();\n const source = new FactorySkillSource(NO_REPOSITORY_SKILLS, [], localRoot, async () => true, codeSkills);\n const codeNames = new Set(codeSkills.map(skill => skill.name));\n const entries = (await source.readdir(FACTORY_SKILLS_MOUNT)).filter(entry => entry.type === 'directory');\n const skills: FactorySkillInfo[] = [];\n for (const name of entries.map(entry => entry.name).sort()) {\n let raw: string;\n try {\n raw = String(await source.readFile(join(FACTORY_SKILLS_MOUNT, name, 'SKILL.md')));\n } catch {\n continue;\n }\n const origin: FactorySkillOrigin = codeNames.has(name)\n ? 'code'\n : localRoot && existsSync(join(localRoot, name, 'SKILL.md'))\n ? 'folder'\n : 'bundled';\n skills.push({ name, ...parseSkillMarkdown(name, raw), origin, builtIn: FACTORY_SKILL_NAMES.has(name) });\n }\n return skills;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAuCA,SAAS,mBAAmB,MAAc,KAA0E;CAGlH,MAAM,SAAS,qBAAqB;EAAE,SAAS;EAAK,eAAe;CAAK,CAAC;CACzE,M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,GAC1B,OAAO,CAAC;IAAE,OAAO,EAAE,YAAY,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAgBzE"}
@@ -1 +1 @@
1
- {"version":3,"file":"spa-static.d.ts","sourceRoot":"","sources":["../src/spa-static.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAOH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AA2BpC;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,SAAS,CAarD;AAmBD;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,MAAM,IACxC,GAAG,OAAO,EAAE,MAAM,MAAM,OAAO,CAAC,IAAI,CAAC,KAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAuB/E"}
1
+ {"version":3,"file":"spa-static.d.ts","sourceRoot":"","sources":["../src/spa-static.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAOH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AA2BpC;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,SAAS,CAarD;AAmBD;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,MAAM,OACrC,OAAO,QAAQ,MAAM,OAAO,CAAC,IAAI,CAAC,KAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAuB/E"}
@@ -3,12 +3,12 @@
3
3
  * WorkOS dashboard under Audit Logs → Events before the mirror accepts them.
4
4
  */
5
5
  export declare const AUDIT_ACTIONS: {
6
- readonly work_item: readonly ["created", "updated", "deleted", "stage_moved", "transition_rejected", "comment_created", "comment_edited", "comment_deleted", "comment_mentioned", "labels_reconciled"];
7
- readonly run: readonly ["started", "ended", "approved", "dismissed", "retry", "queued", "rejected"];
8
- readonly git: readonly ["commit", "push", "pr_opened"];
9
- readonly agent: readonly ["commit", "push", "pr_opened", "signaled"];
10
- readonly intake: readonly ["config_updated", "binding_updated", "label_route_updated"];
11
- readonly session: readonly ["owner_transferred"];
6
+ readonly work_item: readonly ['created', 'updated', 'deleted', 'stage_moved', 'transition_rejected', 'comment_created', 'comment_edited', 'comment_deleted', 'comment_mentioned', 'labels_reconciled'];
7
+ readonly run: readonly ['started', 'ended', 'approved', 'dismissed', 'retry', 'queued', 'rejected'];
8
+ readonly git: readonly ['commit', 'push', 'pr_opened'];
9
+ readonly agent: readonly ['commit', 'push', 'pr_opened', 'signaled'];
10
+ readonly intake: readonly ['config_updated', 'binding_updated', 'label_route_updated'];
11
+ readonly session: readonly ['owner_transferred'];
12
12
  };
13
13
  export type AuditNamespace = keyof typeof AUDIT_ACTIONS;
14
14
  export type AuditAction = {
@@ -1 +1 @@
1
- {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/audit/actions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;;;;CAkBhB,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,aAAa,CAAC;AAExD,MAAM,MAAM,WAAW,GAAG;KACvB,SAAS,IAAI,cAAc,GAAG,WAAW,SAAS,IAAI,CAAC,OAAO,aAAa,CAAC,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,EAAE;CACnG,CAAC,cAAc,CAAC,CAAC;AAElB,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,cAAc,CAEvE;AAED,wBAAgB,eAAe,IAAI,cAAc,EAAE,CAElD;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,SAAS,EAAE,cAAc,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAIxG;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,WAAW,CAGjE;AAED,wBA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,EAAE,SAAS,cAAc,EAAE,GAAG,MAAM,EAAE,CAExF"}
@@ -1,4 +1,4 @@
1
- export declare const AUDIT_ACTOR_TYPES: readonly ["human", "agent", "system"];
1
+ export declare const AUDIT_ACTOR_TYPES: readonly ['human', 'agent', 'system'];
2
2
  export type AuditActorType = (typeof AUDIT_ACTOR_TYPES)[number];
3
3
  export declare function isAuditActorType(value: unknown): value is AuditActorType;
4
4
  export declare function isHumanActorId(actorId: string | undefined): actorId is string;
@@ -1 +1 @@
1
- {"version":3,"file":"actors.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/audit/actors.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,uCAAwC,CAAC;AAEvE,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhE,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAExE;AAWD,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,IAAI,MAAM,CAG7E"}
1
+ {"version":3,"file":"actors.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/audit/actors.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,YAAI,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAU,CAAC;AAEvE,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhE,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAExE;AAWD,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,IAAI,MAAM,CAG7E"}
@@ -1 +1 @@
1
- {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/audit/base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,o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