@mastra/factory 0.0.0 → 0.1.0-alpha.3

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 (287) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/LICENSE.md +30 -0
  3. package/dist/auth.d.ts +181 -0
  4. package/dist/auth.d.ts.map +1 -0
  5. package/dist/auth.js +370 -0
  6. package/dist/auth.js.map +1 -0
  7. package/dist/capabilities/connection.d.ts +9 -0
  8. package/dist/capabilities/connection.d.ts.map +1 -0
  9. package/dist/capabilities/connection.js +1 -0
  10. package/dist/capabilities/connection.js.map +1 -0
  11. package/dist/capabilities/intake.d.ts +93 -0
  12. package/dist/capabilities/intake.d.ts.map +1 -0
  13. package/dist/capabilities/intake.js +1 -0
  14. package/dist/capabilities/intake.js.map +1 -0
  15. package/dist/capabilities/version-control.d.ts +239 -0
  16. package/dist/capabilities/version-control.d.ts.map +1 -0
  17. package/dist/capabilities/version-control.js +1 -0
  18. package/dist/capabilities/version-control.js.map +1 -0
  19. package/dist/factory.d.ts +145 -0
  20. package/dist/factory.d.ts.map +1 -0
  21. package/dist/factory.js +38245 -0
  22. package/dist/factory.js.map +1 -0
  23. package/dist/index.d.ts +3 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +38245 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/integrations/base.d.ts +197 -0
  28. package/dist/integrations/base.d.ts.map +1 -0
  29. package/dist/integrations/base.js +1 -0
  30. package/dist/integrations/base.js.map +1 -0
  31. package/dist/integrations/github/config.d.ts +60 -0
  32. package/dist/integrations/github/config.d.ts.map +1 -0
  33. package/dist/integrations/github/config.js +28 -0
  34. package/dist/integrations/github/config.js.map +1 -0
  35. package/dist/integrations/github/factory-session.d.ts +12 -0
  36. package/dist/integrations/github/factory-session.d.ts.map +1 -0
  37. package/dist/integrations/github/factory-session.js +41 -0
  38. package/dist/integrations/github/factory-session.js.map +1 -0
  39. package/dist/integrations/github/integration.d.ts +191 -0
  40. package/dist/integrations/github/integration.d.ts.map +1 -0
  41. package/dist/integrations/github/integration.js +3001 -0
  42. package/dist/integrations/github/integration.js.map +1 -0
  43. package/dist/integrations/github/issue-triage.d.ts +27 -0
  44. package/dist/integrations/github/issue-triage.d.ts.map +1 -0
  45. package/dist/integrations/github/issue-triage.js +82 -0
  46. package/dist/integrations/github/issue-triage.js.map +1 -0
  47. package/dist/integrations/github/project-lock.d.ts +78 -0
  48. package/dist/integrations/github/project-lock.d.ts.map +1 -0
  49. package/dist/integrations/github/project-lock.js +70 -0
  50. package/dist/integrations/github/project-lock.js.map +1 -0
  51. package/dist/integrations/github/provenance.d.ts +27 -0
  52. package/dist/integrations/github/provenance.d.ts.map +1 -0
  53. package/dist/integrations/github/provenance.js +104 -0
  54. package/dist/integrations/github/provenance.js.map +1 -0
  55. package/dist/integrations/github/routes.d.ts +72 -0
  56. package/dist/integrations/github/routes.d.ts.map +1 -0
  57. package/dist/integrations/github/routes.js +1834 -0
  58. package/dist/integrations/github/routes.js.map +1 -0
  59. package/dist/integrations/github/sandbox.d.ts +268 -0
  60. package/dist/integrations/github/sandbox.d.ts.map +1 -0
  61. package/dist/integrations/github/sandbox.js +381 -0
  62. package/dist/integrations/github/sandbox.js.map +1 -0
  63. package/dist/integrations/github/session-subscriptions.d.ts +23 -0
  64. package/dist/integrations/github/session-subscriptions.d.ts.map +1 -0
  65. package/dist/integrations/github/session-subscriptions.js +190 -0
  66. package/dist/integrations/github/session-subscriptions.js.map +1 -0
  67. package/dist/integrations/github/subscriptions.d.ts +54 -0
  68. package/dist/integrations/github/subscriptions.d.ts.map +1 -0
  69. package/dist/integrations/github/subscriptions.js +70 -0
  70. package/dist/integrations/github/subscriptions.js.map +1 -0
  71. package/dist/integrations/github/webhook.d.ts +87 -0
  72. package/dist/integrations/github/webhook.d.ts.map +1 -0
  73. package/dist/integrations/github/webhook.js +381 -0
  74. package/dist/integrations/github/webhook.js.map +1 -0
  75. package/dist/integrations/linear/agent-tools.d.ts +34 -0
  76. package/dist/integrations/linear/agent-tools.d.ts.map +1 -0
  77. package/dist/integrations/linear/agent-tools.js +108 -0
  78. package/dist/integrations/linear/agent-tools.js.map +1 -0
  79. package/dist/integrations/linear/integration.d.ts +233 -0
  80. package/dist/integrations/linear/integration.d.ts.map +1 -0
  81. package/dist/integrations/linear/integration.js +962 -0
  82. package/dist/integrations/linear/integration.js.map +1 -0
  83. package/dist/integrations/linear/routes.d.ts +61 -0
  84. package/dist/integrations/linear/routes.d.ts.map +1 -0
  85. package/dist/integrations/linear/routes.js +242 -0
  86. package/dist/integrations/linear/routes.js.map +1 -0
  87. package/dist/integrations/linear/storage.d.ts +65 -0
  88. package/dist/integrations/linear/storage.d.ts.map +1 -0
  89. package/dist/integrations/linear/storage.js +1 -0
  90. package/dist/integrations/linear/storage.js.map +1 -0
  91. package/dist/integrations/platform/api-client.d.ts +24 -0
  92. package/dist/integrations/platform/api-client.d.ts.map +1 -0
  93. package/dist/integrations/platform/api-client.js +153 -0
  94. package/dist/integrations/platform/api-client.js.map +1 -0
  95. package/dist/integrations/platform/github/event-worker.d.ts +44 -0
  96. package/dist/integrations/platform/github/event-worker.d.ts.map +1 -0
  97. package/dist/integrations/platform/github/event-worker.js +585 -0
  98. package/dist/integrations/platform/github/event-worker.js.map +1 -0
  99. package/dist/integrations/platform/github/integration.d.ts +36 -0
  100. package/dist/integrations/platform/github/integration.d.ts.map +1 -0
  101. package/dist/integrations/platform/github/integration.js +3253 -0
  102. package/dist/integrations/platform/github/integration.js.map +1 -0
  103. package/dist/integrations/platform/linear/integration.d.ts +46 -0
  104. package/dist/integrations/platform/linear/integration.d.ts.map +1 -0
  105. package/dist/integrations/platform/linear/integration.js +891 -0
  106. package/dist/integrations/platform/linear/integration.js.map +1 -0
  107. package/dist/integrations/workos/integration.d.ts +39 -0
  108. package/dist/integrations/workos/integration.d.ts.map +1 -0
  109. package/dist/integrations/workos/integration.js +96 -0
  110. package/dist/integrations/workos/integration.js.map +1 -0
  111. package/dist/routes/config.d.ts +220 -0
  112. package/dist/routes/config.d.ts.map +1 -0
  113. package/dist/routes/config.js +770 -0
  114. package/dist/routes/config.js.map +1 -0
  115. package/dist/routes/fs.d.ts +105 -0
  116. package/dist/routes/fs.d.ts.map +1 -0
  117. package/dist/routes/fs.js +294 -0
  118. package/dist/routes/fs.js.map +1 -0
  119. package/dist/routes/intake.d.ts +23 -0
  120. package/dist/routes/intake.d.ts.map +1 -0
  121. package/dist/routes/intake.js +179 -0
  122. package/dist/routes/intake.js.map +1 -0
  123. package/dist/routes/oauth.d.ts +43 -0
  124. package/dist/routes/oauth.d.ts.map +1 -0
  125. package/dist/routes/oauth.js +25058 -0
  126. package/dist/routes/oauth.js.map +1 -0
  127. package/dist/routes/projects.d.ts +19 -0
  128. package/dist/routes/projects.d.ts.map +1 -0
  129. package/dist/routes/projects.js +395 -0
  130. package/dist/routes/projects.js.map +1 -0
  131. package/dist/routes/provider-credentials.d.ts +81 -0
  132. package/dist/routes/provider-credentials.d.ts.map +1 -0
  133. package/dist/routes/provider-credentials.js +68 -0
  134. package/dist/routes/provider-credentials.js.map +1 -0
  135. package/dist/routes/route.d.ts +48 -0
  136. package/dist/routes/route.d.ts.map +1 -0
  137. package/dist/routes/route.js +11 -0
  138. package/dist/routes/route.js.map +1 -0
  139. package/dist/routes/skills.d.ts +30 -0
  140. package/dist/routes/skills.d.ts.map +1 -0
  141. package/dist/routes/skills.js +181 -0
  142. package/dist/routes/skills.js.map +1 -0
  143. package/dist/routes/surface.d.ts +83 -0
  144. package/dist/routes/surface.d.ts.map +1 -0
  145. package/dist/routes/surface.js +28519 -0
  146. package/dist/routes/surface.js.map +1 -0
  147. package/dist/routes/tenant-credentials.d.ts +74 -0
  148. package/dist/routes/tenant-credentials.d.ts.map +1 -0
  149. package/dist/routes/tenant-credentials.js +181 -0
  150. package/dist/routes/tenant-credentials.js.map +1 -0
  151. package/dist/routes/work-items.d.ts +40 -0
  152. package/dist/routes/work-items.d.ts.map +1 -0
  153. package/dist/routes/work-items.js +902 -0
  154. package/dist/routes/work-items.js.map +1 -0
  155. package/dist/rules/binding-context.d.ts +5 -0
  156. package/dist/rules/binding-context.d.ts.map +1 -0
  157. package/dist/rules/binding-context.js +40 -0
  158. package/dist/rules/binding-context.js.map +1 -0
  159. package/dist/rules/defaults.d.ts +9 -0
  160. package/dist/rules/defaults.d.ts.map +1 -0
  161. package/dist/rules/defaults.js +334 -0
  162. package/dist/rules/defaults.js.map +1 -0
  163. package/dist/rules/dispatcher.d.ts +40 -0
  164. package/dist/rules/dispatcher.d.ts.map +1 -0
  165. package/dist/rules/dispatcher.js +695 -0
  166. package/dist/rules/dispatcher.js.map +1 -0
  167. package/dist/rules/github-service.d.ts +29 -0
  168. package/dist/rules/github-service.d.ts.map +1 -0
  169. package/dist/rules/github-service.js +474 -0
  170. package/dist/rules/github-service.js.map +1 -0
  171. package/dist/rules/index.d.ts +7 -0
  172. package/dist/rules/index.d.ts.map +1 -0
  173. package/dist/rules/index.js +583 -0
  174. package/dist/rules/index.js.map +1 -0
  175. package/dist/rules/linear-service.d.ts +27 -0
  176. package/dist/rules/linear-service.d.ts.map +1 -0
  177. package/dist/rules/linear-service.js +343 -0
  178. package/dist/rules/linear-service.js.map +1 -0
  179. package/dist/rules/processor.d.ts +54 -0
  180. package/dist/rules/processor.d.ts.map +1 -0
  181. package/dist/rules/processor.js +629 -0
  182. package/dist/rules/processor.js.map +1 -0
  183. package/dist/rules/resolve.d.ts +17 -0
  184. package/dist/rules/resolve.d.ts.map +1 -0
  185. package/dist/rules/resolve.js +27 -0
  186. package/dist/rules/resolve.js.map +1 -0
  187. package/dist/rules/start-coordinator.d.ts +58 -0
  188. package/dist/rules/start-coordinator.d.ts.map +1 -0
  189. package/dist/rules/start-coordinator.js +136 -0
  190. package/dist/rules/start-coordinator.js.map +1 -0
  191. package/dist/rules/tools.d.ts +10 -0
  192. package/dist/rules/tools.d.ts.map +1 -0
  193. package/dist/rules/tools.js +93 -0
  194. package/dist/rules/tools.js.map +1 -0
  195. package/dist/rules/transition-service.d.ts +32 -0
  196. package/dist/rules/transition-service.d.ts.map +1 -0
  197. package/dist/rules/transition-service.js +474 -0
  198. package/dist/rules/transition-service.js.map +1 -0
  199. package/dist/rules/types.d.ts +225 -0
  200. package/dist/rules/types.d.ts.map +1 -0
  201. package/dist/rules/types.js +33 -0
  202. package/dist/rules/types.js.map +1 -0
  203. package/dist/rules/validation.d.ts +11 -0
  204. package/dist/rules/validation.d.ts.map +1 -0
  205. package/dist/rules/validation.js +310 -0
  206. package/dist/rules/validation.js.map +1 -0
  207. package/dist/sandbox/fleet.d.ts +208 -0
  208. package/dist/sandbox/fleet.d.ts.map +1 -0
  209. package/dist/sandbox/fleet.js +259 -0
  210. package/dist/sandbox/fleet.js.map +1 -0
  211. package/dist/sandbox/reattach.d.ts +3 -0
  212. package/dist/sandbox/reattach.d.ts.map +1 -0
  213. package/dist/sandbox/reattach.js +9 -0
  214. package/dist/sandbox/reattach.js.map +1 -0
  215. package/dist/server-error.d.ts +12 -0
  216. package/dist/server-error.d.ts.map +1 -0
  217. package/dist/server-error.js +20 -0
  218. package/dist/server-error.js.map +1 -0
  219. package/dist/skills/service.d.ts +48 -0
  220. package/dist/skills/service.d.ts.map +1 -0
  221. package/dist/skills/service.js +45 -0
  222. package/dist/skills/service.js.map +1 -0
  223. package/dist/spa-static.d.ts +34 -0
  224. package/dist/spa-static.d.ts.map +1 -0
  225. package/dist/spa-static.js +73 -0
  226. package/dist/spa-static.js.map +1 -0
  227. package/dist/state-signing.d.ts +48 -0
  228. package/dist/state-signing.d.ts.map +1 -0
  229. package/dist/state-signing.js +48 -0
  230. package/dist/state-signing.js.map +1 -0
  231. package/dist/storage/domains/audit/agent-audit.d.ts +27 -0
  232. package/dist/storage/domains/audit/agent-audit.d.ts.map +1 -0
  233. package/dist/storage/domains/audit/agent-audit.js +65 -0
  234. package/dist/storage/domains/audit/agent-audit.js.map +1 -0
  235. package/dist/storage/domains/audit/base.d.ts +140 -0
  236. package/dist/storage/domains/audit/base.d.ts.map +1 -0
  237. package/dist/storage/domains/audit/base.js +127 -0
  238. package/dist/storage/domains/audit/base.js.map +1 -0
  239. package/dist/storage/domains/audit/domain.d.ts +69 -0
  240. package/dist/storage/domains/audit/domain.d.ts.map +1 -0
  241. package/dist/storage/domains/audit/domain.js +165 -0
  242. package/dist/storage/domains/audit/domain.js.map +1 -0
  243. package/dist/storage/domains/credentials/base.d.ts +134 -0
  244. package/dist/storage/domains/credentials/base.d.ts.map +1 -0
  245. package/dist/storage/domains/credentials/base.js +257 -0
  246. package/dist/storage/domains/credentials/base.js.map +1 -0
  247. package/dist/storage/domains/intake/base.d.ts +38 -0
  248. package/dist/storage/domains/intake/base.d.ts.map +1 -0
  249. package/dist/storage/domains/intake/base.js +62 -0
  250. package/dist/storage/domains/intake/base.js.map +1 -0
  251. package/dist/storage/domains/integrations/base.d.ts +126 -0
  252. package/dist/storage/domains/integrations/base.d.ts.map +1 -0
  253. package/dist/storage/domains/integrations/base.js +252 -0
  254. package/dist/storage/domains/integrations/base.js.map +1 -0
  255. package/dist/storage/domains/model-packs/base.d.ts +49 -0
  256. package/dist/storage/domains/model-packs/base.d.ts.map +1 -0
  257. package/dist/storage/domains/model-packs/base.js +95 -0
  258. package/dist/storage/domains/model-packs/base.js.map +1 -0
  259. package/dist/storage/domains/projects/base.d.ts +55 -0
  260. package/dist/storage/domains/projects/base.d.ts.map +1 -0
  261. package/dist/storage/domains/projects/base.js +99 -0
  262. package/dist/storage/domains/projects/base.js.map +1 -0
  263. package/dist/storage/domains/queue-health/base.d.ts +52 -0
  264. package/dist/storage/domains/queue-health/base.d.ts.map +1 -0
  265. package/dist/storage/domains/queue-health/base.js +87 -0
  266. package/dist/storage/domains/queue-health/base.js.map +1 -0
  267. package/dist/storage/domains/source-control/base.d.ts +288 -0
  268. package/dist/storage/domains/source-control/base.d.ts.map +1 -0
  269. package/dist/storage/domains/source-control/base.js +722 -0
  270. package/dist/storage/domains/source-control/base.js.map +1 -0
  271. package/dist/storage/domains/source-control/inmemory.d.ts +158 -0
  272. package/dist/storage/domains/source-control/inmemory.d.ts.map +1 -0
  273. package/dist/storage/domains/source-control/inmemory.js +348 -0
  274. package/dist/storage/domains/source-control/inmemory.js.map +1 -0
  275. package/dist/storage/domains/work-items/base.d.ts +412 -0
  276. package/dist/storage/domains/work-items/base.d.ts.map +1 -0
  277. package/dist/storage/domains/work-items/base.js +1174 -0
  278. package/dist/storage/domains/work-items/base.js.map +1 -0
  279. package/dist/storage/domains/work-items/metrics.d.ts +101 -0
  280. package/dist/storage/domains/work-items/metrics.d.ts.map +1 -0
  281. package/dist/storage/domains/work-items/metrics.js +203 -0
  282. package/dist/storage/domains/work-items/metrics.js.map +1 -0
  283. package/dist/workspace.d.ts +20 -0
  284. package/dist/workspace.d.ts.map +1 -0
  285. package/dist/workspace.js +364 -0
  286. package/dist/workspace.js.map +1 -0
  287. package/package.json +19 -19
@@ -0,0 +1,310 @@
1
+ // src/rules/types.ts
2
+ var FACTORY_RULE_STAGES = ["intake", "triage", "planning", "execute", "review", "done", "canceled"];
3
+ var FACTORY_RULE_BOARDS = ["work", "review"];
4
+ var FACTORY_RULE_SOURCES = ["issue", "pullRequest", "linearIssue", "manual"];
5
+ var FACTORY_GITHUB_EVENTS = [
6
+ "issueOpened",
7
+ "pullRequestOpened",
8
+ "pullRequestUpdated",
9
+ "pullRequestReviewRequested",
10
+ "pullRequestMerged"
11
+ ];
12
+ var FACTORY_LINEAR_EVENTS = ["issueObserved"];
13
+
14
+ // src/rules/validation.ts
15
+ var MAX_FACTORY_RULE_CAUSAL_DEPTH = 8;
16
+ var MAX_VERSION_LENGTH = 128;
17
+ var MAX_IDEMPOTENCY_KEY_LENGTH = 256;
18
+ var MAX_REASON_LENGTH = 512;
19
+ var MAX_TITLE_LENGTH = 512;
20
+ var MAX_MESSAGE_LENGTH = 8192;
21
+ var MAX_ARGUMENTS_LENGTH = 4096;
22
+ var MAX_ROLE_LENGTH = 32;
23
+ var MAX_SKILL_NAME_LENGTH = 128;
24
+ var MAX_SOURCE_KEY_LENGTH = 256;
25
+ var MAX_URL_LENGTH = 2048;
26
+ var MAX_METADATA_JSON_LENGTH = 16384;
27
+ var MAX_JSON_DEPTH = 8;
28
+ var MAX_JSON_COLLECTION_SIZE = 100;
29
+ var IDENTIFIER_RE = /^[a-z0-9][a-z0-9_-]*$/i;
30
+ var SKILL_NAME_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
31
+ var SENSITIVE_KEY_RE = /(?:authorization|cookie|credential|password|secret|token)/i;
32
+ var WORK_ITEM_SOURCES = ["github-issue", "github-pr", "linear-issue", "manual"];
33
+ var REJECTION_CODES = [
34
+ "forbidden",
35
+ "invalid_transition",
36
+ "missing_binding",
37
+ "stale",
38
+ "timeout",
39
+ "rule_error",
40
+ "causal_depth_exceeded",
41
+ "repeated_transition"
42
+ ];
43
+ var FactoryRuleValidationError = class extends Error {
44
+ code = "invalid_factory_rule";
45
+ constructor(message) {
46
+ super(message);
47
+ this.name = "FactoryRuleValidationError";
48
+ }
49
+ };
50
+ function isPlainObject(value) {
51
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
52
+ const prototype = Object.getPrototypeOf(value);
53
+ return prototype === Object.prototype || prototype === null;
54
+ }
55
+ function assertExactKeys(value, keys, label) {
56
+ const allowed = new Set(keys);
57
+ if (Object.keys(value).some((key) => !allowed.has(key))) {
58
+ throw new FactoryRuleValidationError(`${label} contains an unsupported field.`);
59
+ }
60
+ }
61
+ function boundedString(value, label, max, pattern) {
62
+ if (typeof value !== "string") throw new FactoryRuleValidationError(`${label} must be a string.`);
63
+ const normalized = value.trim();
64
+ if (normalized.length === 0 || normalized.length > max || pattern && !pattern.test(normalized)) {
65
+ throw new FactoryRuleValidationError(`${label} is invalid.`);
66
+ }
67
+ return normalized;
68
+ }
69
+ function optionalBoundedString(value, label, max) {
70
+ if (value === void 0) return void 0;
71
+ return boundedString(value, label, max);
72
+ }
73
+ function enumValue(value, allowed, label) {
74
+ if (typeof value !== "string" || !allowed.includes(value)) {
75
+ throw new FactoryRuleValidationError(`${label} is invalid.`);
76
+ }
77
+ return value;
78
+ }
79
+ function normalizeFactoryRuleJsonValue(value, depth = 0, seen = /* @__PURE__ */ new Set()) {
80
+ if (value === null || typeof value === "boolean" || typeof value === "string") return value;
81
+ if (typeof value === "number") {
82
+ if (!Number.isFinite(value)) throw new FactoryRuleValidationError("Rule metadata must contain finite numbers.");
83
+ return value;
84
+ }
85
+ if (depth >= MAX_JSON_DEPTH || typeof value !== "object" && !Array.isArray(value)) {
86
+ throw new FactoryRuleValidationError("Rule metadata is not bounded JSON.");
87
+ }
88
+ if (seen.has(value)) throw new FactoryRuleValidationError("Rule metadata must not contain cycles.");
89
+ seen.add(value);
90
+ try {
91
+ if (Array.isArray(value)) {
92
+ if (value.length > MAX_JSON_COLLECTION_SIZE) {
93
+ throw new FactoryRuleValidationError("Rule metadata contains too many entries.");
94
+ }
95
+ return value.map((entry) => normalizeFactoryRuleJsonValue(entry, depth + 1, seen));
96
+ }
97
+ if (!isPlainObject(value)) throw new FactoryRuleValidationError("Rule metadata must use plain objects.");
98
+ const entries = Object.entries(value);
99
+ if (entries.length > MAX_JSON_COLLECTION_SIZE) {
100
+ throw new FactoryRuleValidationError("Rule metadata contains too many fields.");
101
+ }
102
+ const sanitized = {};
103
+ for (const [key, entry] of entries) {
104
+ const normalizedKey = boundedString(key, "Rule metadata key", 128, IDENTIFIER_RE);
105
+ sanitized[normalizedKey] = SENSITIVE_KEY_RE.test(normalizedKey) ? "[REDACTED]" : normalizeFactoryRuleJsonValue(entry, depth + 1, seen);
106
+ }
107
+ return sanitized;
108
+ } finally {
109
+ seen.delete(value);
110
+ }
111
+ }
112
+ function sanitizeMetadata(value) {
113
+ if (value === void 0) return void 0;
114
+ const sanitized = normalizeFactoryRuleJsonValue(value);
115
+ if (!isPlainObject(sanitized)) throw new FactoryRuleValidationError("Rule metadata must be an object.");
116
+ if (JSON.stringify(sanitized).length > MAX_METADATA_JSON_LENGTH) {
117
+ throw new FactoryRuleValidationError("Rule metadata is too large.");
118
+ }
119
+ return sanitized;
120
+ }
121
+ function validateBoardRules(rules, label) {
122
+ if (!isPlainObject(rules)) throw new FactoryRuleValidationError(`${label} must be an object.`);
123
+ for (const [stage, sources] of Object.entries(rules)) {
124
+ enumValue(stage, FACTORY_RULE_STAGES, `${label} stage`);
125
+ if (!isPlainObject(sources)) throw new FactoryRuleValidationError(`${label}.${stage} must be an object.`);
126
+ for (const [source, leaf] of Object.entries(sources)) {
127
+ enumValue(source, FACTORY_RULE_SOURCES, `${label}.${stage} source`);
128
+ if (!isPlainObject(leaf)) throw new FactoryRuleValidationError(`${label}.${stage}.${source} must be an object.`);
129
+ assertExactKeys(leaf, ["onEnter", "onExit"], `${label}.${stage}.${source}`);
130
+ for (const handler of Object.values(leaf)) {
131
+ if (handler !== void 0 && typeof handler !== "function") {
132
+ throw new FactoryRuleValidationError(`${label}.${stage}.${source} handlers must be functions.`);
133
+ }
134
+ }
135
+ }
136
+ }
137
+ }
138
+ function assertFactoryRules(rules) {
139
+ if (!isPlainObject(rules)) throw new FactoryRuleValidationError("Factory rules must be an object.");
140
+ assertExactKeys(rules, ["version", "work", "review", "tools", "github", "linear"], "Factory rules");
141
+ boundedString(rules.version, "Factory rule version", MAX_VERSION_LENGTH);
142
+ validateBoardRules(rules.work, "Factory rules.work");
143
+ validateBoardRules(rules.review, "Factory rules.review");
144
+ if (!isPlainObject(rules.tools)) throw new FactoryRuleValidationError("Factory rules.tools must be an object.");
145
+ for (const [toolName, leaf] of Object.entries(rules.tools)) {
146
+ boundedString(toolName, "Factory tool name", 128, IDENTIFIER_RE);
147
+ if (!isPlainObject(leaf))
148
+ throw new FactoryRuleValidationError(`Factory rules.tools.${toolName} must be an object.`);
149
+ assertExactKeys(leaf, ["onResult"], `Factory rules.tools.${toolName}`);
150
+ if (leaf.onResult !== void 0 && typeof leaf.onResult !== "function") {
151
+ throw new FactoryRuleValidationError(`Factory rules.tools.${toolName}.onResult must be a function.`);
152
+ }
153
+ }
154
+ if (!isPlainObject(rules.github)) throw new FactoryRuleValidationError("Factory rules.github must be an object.");
155
+ for (const [event, leaf] of Object.entries(rules.github)) {
156
+ enumValue(event, FACTORY_GITHUB_EVENTS, "Factory GitHub event");
157
+ if (!isPlainObject(leaf)) throw new FactoryRuleValidationError(`Factory rules.github.${event} must be an object.`);
158
+ assertExactKeys(leaf, ["onEvent"], `Factory rules.github.${event}`);
159
+ if (leaf.onEvent !== void 0 && typeof leaf.onEvent !== "function") {
160
+ throw new FactoryRuleValidationError(`Factory rules.github.${event}.onEvent must be a function.`);
161
+ }
162
+ }
163
+ if (!isPlainObject(rules.linear)) throw new FactoryRuleValidationError("Factory rules.linear must be an object.");
164
+ for (const [event, leaf] of Object.entries(rules.linear)) {
165
+ enumValue(event, FACTORY_LINEAR_EVENTS, "Factory Linear event");
166
+ if (!isPlainObject(leaf)) throw new FactoryRuleValidationError(`Factory rules.linear.${event} must be an object.`);
167
+ assertExactKeys(leaf, ["onEvent"], `Factory rules.linear.${event}`);
168
+ if (leaf.onEvent !== void 0 && typeof leaf.onEvent !== "function") {
169
+ throw new FactoryRuleValidationError(`Factory rules.linear.${event}.onEvent must be a function.`);
170
+ }
171
+ }
172
+ }
173
+ function commonCommitFields(value) {
174
+ return {
175
+ idempotencyKey: boundedString(value.idempotencyKey, "Factory decision idempotencyKey", MAX_IDEMPOTENCY_KEY_LENGTH)
176
+ };
177
+ }
178
+ function validateFactoryRuleDecision(value, causalDepth = 0) {
179
+ if (causalDepth > MAX_FACTORY_RULE_CAUSAL_DEPTH) {
180
+ throw new FactoryRuleValidationError("Factory rule causal depth exceeded.");
181
+ }
182
+ if (!isPlainObject(value)) throw new FactoryRuleValidationError("Factory rule decision must be an object.");
183
+ const type = value.type;
184
+ if (typeof type !== "string") throw new FactoryRuleValidationError("Factory rule decision type is required.");
185
+ switch (type) {
186
+ case "reject": {
187
+ assertExactKeys(value, ["type", "code", "reason"], "Factory reject decision");
188
+ return {
189
+ type,
190
+ code: enumValue(value.code, REJECTION_CODES, "Factory rejection code"),
191
+ reason: boundedString(value.reason, "Factory rejection reason", MAX_REASON_LENGTH)
192
+ };
193
+ }
194
+ case "transition": {
195
+ assertExactKeys(value, ["type", "idempotencyKey", "board", "stage"], "Factory transition decision");
196
+ return {
197
+ type,
198
+ ...commonCommitFields(value),
199
+ board: enumValue(value.board, FACTORY_RULE_BOARDS, "Factory transition board"),
200
+ stage: enumValue(value.stage, FACTORY_RULE_STAGES, "Factory transition stage")
201
+ };
202
+ }
203
+ case "upsertLinkedWorkItem": {
204
+ assertExactKeys(
205
+ value,
206
+ ["type", "idempotencyKey", "board", "source", "sourceKey", "title", "url", "stage", "metadata"],
207
+ "Factory linked work item decision"
208
+ );
209
+ const url = value.url;
210
+ if (url !== null && (typeof url !== "string" || url.length > MAX_URL_LENGTH || !/^https?:\/\//.test(url))) {
211
+ throw new FactoryRuleValidationError("Factory linked work item URL is invalid.");
212
+ }
213
+ const metadata = sanitizeMetadata(value.metadata);
214
+ return {
215
+ type,
216
+ ...commonCommitFields(value),
217
+ board: enumValue(value.board, FACTORY_RULE_BOARDS, "Factory linked work item board"),
218
+ source: enumValue(value.source, WORK_ITEM_SOURCES, "Factory linked work item source"),
219
+ sourceKey: boundedString(value.sourceKey, "Factory linked work item sourceKey", MAX_SOURCE_KEY_LENGTH),
220
+ title: boundedString(value.title, "Factory linked work item title", MAX_TITLE_LENGTH),
221
+ url,
222
+ stage: enumValue(value.stage, FACTORY_RULE_STAGES, "Factory linked work item stage"),
223
+ ...metadata ? { metadata } : {}
224
+ };
225
+ }
226
+ case "invokeSkill": {
227
+ assertExactKeys(
228
+ value,
229
+ ["type", "idempotencyKey", "role", "skillName", "arguments", "precedingMessage"],
230
+ "Factory invoke skill decision"
231
+ );
232
+ const args = optionalBoundedString(value.arguments, "Factory skill arguments", MAX_ARGUMENTS_LENGTH);
233
+ const precedingMessage = optionalBoundedString(
234
+ value.precedingMessage,
235
+ "Factory skill preceding message",
236
+ MAX_MESSAGE_LENGTH
237
+ );
238
+ return {
239
+ type,
240
+ ...commonCommitFields(value),
241
+ role: boundedString(value.role, "Factory skill role", MAX_ROLE_LENGTH, IDENTIFIER_RE),
242
+ skillName: boundedString(value.skillName, "Factory skill name", MAX_SKILL_NAME_LENGTH, SKILL_NAME_RE),
243
+ ...args ? { arguments: args } : {},
244
+ ...precedingMessage ? { precedingMessage } : {}
245
+ };
246
+ }
247
+ case "sendMessage": {
248
+ assertExactKeys(
249
+ value,
250
+ ["type", "idempotencyKey", "role", "message", "priority", "idleBehavior", "prepareBinding"],
251
+ "Factory send message decision"
252
+ );
253
+ const priority = value.priority === void 0 ? void 0 : enumValue(value.priority, ["medium", "high", "urgent"], "Factory message priority");
254
+ const idleBehavior = value.idleBehavior === void 0 ? void 0 : enumValue(value.idleBehavior, ["persist", "wake"], "Factory message idle behavior");
255
+ if (value.prepareBinding !== void 0 && typeof value.prepareBinding !== "boolean") {
256
+ throw new FactoryRuleValidationError("Factory message prepareBinding must be a boolean.");
257
+ }
258
+ return {
259
+ type,
260
+ ...commonCommitFields(value),
261
+ role: boundedString(value.role, "Factory message role", MAX_ROLE_LENGTH, IDENTIFIER_RE),
262
+ message: boundedString(value.message, "Factory message", MAX_MESSAGE_LENGTH),
263
+ ...priority ? { priority } : {},
264
+ ...idleBehavior ? { idleBehavior } : {},
265
+ ...value.prepareBinding === true ? { prepareBinding: true } : {}
266
+ };
267
+ }
268
+ case "notify": {
269
+ assertExactKeys(value, ["type", "idempotencyKey", "title", "body", "level"], "Factory notify decision");
270
+ const body = optionalBoundedString(value.body, "Factory notification body", MAX_MESSAGE_LENGTH);
271
+ const level = value.level === void 0 ? void 0 : enumValue(value.level, ["info", "warning", "error"], "Factory notification level");
272
+ return {
273
+ type,
274
+ ...commonCommitFields(value),
275
+ title: boundedString(value.title, "Factory notification title", MAX_TITLE_LENGTH),
276
+ ...body ? { body } : {},
277
+ ...level ? { level } : {}
278
+ };
279
+ }
280
+ default:
281
+ throw new FactoryRuleValidationError("Factory rule decision type is unsupported.");
282
+ }
283
+ }
284
+ function validateFactoryRuleDecisions(values, causalDepth = 0) {
285
+ if (values.length > MAX_JSON_COLLECTION_SIZE) {
286
+ throw new FactoryRuleValidationError("Factory rule produced too many decisions.");
287
+ }
288
+ const decisions = [];
289
+ for (const value of values) {
290
+ const decision = validateFactoryRuleDecision(value, causalDepth);
291
+ if (decision.type === "reject") {
292
+ throw new FactoryRuleValidationError("A rejection cannot be persisted with commit decisions.");
293
+ }
294
+ decisions.push(decision);
295
+ }
296
+ const keys = decisions.map((decision) => decision.idempotencyKey);
297
+ if (new Set(keys).size !== keys.length) {
298
+ throw new FactoryRuleValidationError("Factory decisions require unique idempotency keys.");
299
+ }
300
+ return decisions;
301
+ }
302
+ export {
303
+ FactoryRuleValidationError,
304
+ MAX_FACTORY_RULE_CAUSAL_DEPTH,
305
+ assertFactoryRules,
306
+ normalizeFactoryRuleJsonValue,
307
+ validateFactoryRuleDecision,
308
+ validateFactoryRuleDecisions
309
+ };
310
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/rules/types.ts","../../src/rules/validation.ts"],"sourcesContent":["export type WorkItemSource = 'github-issue' | 'github-pr' | 'linear-issue' | 'manual';\n\nexport const FACTORY_RULE_STAGES = ['intake', 'triage', 'planning', 'execute', 'review', 'done', 'canceled'] as const;\nexport type FactoryRuleStage = (typeof FACTORY_RULE_STAGES)[number];\n\nexport const FACTORY_RULE_BOARDS = ['work', 'review'] as const;\nexport type FactoryRuleBoard = (typeof FACTORY_RULE_BOARDS)[number];\n\nexport const FACTORY_RULE_SOURCES = ['issue', 'pullRequest', 'linearIssue', 'manual'] as const;\nexport type FactoryRuleSource = (typeof FACTORY_RULE_SOURCES)[number];\n\nexport const FACTORY_GITHUB_EVENTS = [\n 'issueOpened',\n 'pullRequestOpened',\n 'pullRequestUpdated',\n 'pullRequestReviewRequested',\n 'pullRequestMerged',\n] as const;\nexport type FactoryGithubEventName = (typeof FACTORY_GITHUB_EVENTS)[number];\n\nexport const FACTORY_LINEAR_EVENTS = ['issueObserved'] as const;\nexport type FactoryLinearEventName = (typeof FACTORY_LINEAR_EVENTS)[number];\n\nexport type FactoryRuleJsonValue =\n null | boolean | number | string | FactoryRuleJsonValue[] | { [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}\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: 'system'; id: string };\n\nexport interface FactoryRuleIngressIdentity {\n type: 'human' | 'agent' | 'toolResult' | 'github' | 'linear' | 'rule';\n id: string;\n}\n\nexport interface FactoryRuleCausalEntry {\n ingressId: string;\n decisionType: FactoryCommitDecision['type'];\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 ruleSetVersion: 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}\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 event: FactoryGithubEventName;\n deliveryId: string;\n factory: { createdAt: string };\n repository: { id: number; fullName: string };\n issue?: { number: number; title: string; url: string; createdAt?: string };\n pullRequest?: {\n number: number;\n title: string;\n url: string;\n createdAt?: string;\n state: 'open' | 'closed';\n merged: 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 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 team: 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 interface FactoryToolRuleLeaf {\n onResult?: FactoryRuleHandler<FactoryToolResultRuleContext>;\n}\n\nexport interface FactoryGithubRuleLeaf {\n onEvent?: FactoryRuleHandler<FactoryGithubRuleContext>;\n}\n\nexport interface FactoryLinearRuleLeaf {\n onEvent?: FactoryRuleHandler<FactoryLinearRuleContext>;\n}\n\nexport type FactoryBoardRules = Partial<\n Record<FactoryRuleStage, Partial<Record<FactoryRuleSource, FactoryBoardRuleLeaf>>>\n>;\n\nexport interface FactoryRules {\n version: string;\n work: FactoryBoardRules;\n review: FactoryBoardRules;\n tools: Record<string, FactoryToolRuleLeaf>;\n github: Partial<Record<FactoryGithubEventName, FactoryGithubRuleLeaf>>;\n linear: Partial<Record<FactoryLinearEventName, FactoryLinearRuleLeaf>>;\n}\n\nexport interface FactoryRulesOverrides {\n work?: FactoryBoardRules;\n review?: FactoryBoardRules;\n tools?: Record<string, FactoryToolRuleLeaf>;\n github?: Partial<Record<FactoryGithubEventName, FactoryGithubRuleLeaf>>;\n linear?: Partial<Record<FactoryLinearEventName, FactoryLinearRuleLeaf>>;\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\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\nexport interface FactoryUpsertLinkedWorkItemDecision extends FactoryCommitDecisionBase {\n type: 'upsertLinkedWorkItem';\n board: FactoryRuleBoard;\n source: WorkItemSource;\n sourceKey: string;\n title: string;\n url: string | null;\n stage: FactoryRuleStage;\n metadata?: Record<string, FactoryRuleJsonValue>;\n}\n\nexport interface FactoryInvokeSkillDecision extends FactoryCommitDecisionBase {\n type: 'invokeSkill';\n role: string;\n skillName: string;\n arguments?: string;\n precedingMessage?: string;\n}\n\nexport interface FactorySendMessageDecision extends FactoryCommitDecisionBase {\n type: 'sendMessage';\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\nexport type FactoryCommitDecision =\n | FactoryTransitionDecision\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 'linear-issue':\n return 'linearIssue';\n case 'manual':\n return 'manual';\n }\n}\n","import {\n FACTORY_GITHUB_EVENTS,\n FACTORY_LINEAR_EVENTS,\n FACTORY_RULE_BOARDS,\n FACTORY_RULE_SOURCES,\n FACTORY_RULE_STAGES,\n} from './types.js';\nimport type {\n FactoryBoardRules,\n FactoryCommitDecision,\n FactoryRuleDecision,\n FactoryRuleJsonValue,\n FactoryRules,\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;\nconst MAX_ROLE_LENGTH = 32;\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\nconst IDENTIFIER_RE = /^[a-z0-9][a-z0-9_-]*$/i;\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[] = ['github-issue', 'github-pr', 'linear-issue', 'manual'];\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\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\nfunction validateBoardRules(rules: unknown, label: string): asserts rules is FactoryBoardRules {\n if (!isPlainObject(rules)) throw new FactoryRuleValidationError(`${label} must be an object.`);\n for (const [stage, sources] of Object.entries(rules)) {\n enumValue(stage, FACTORY_RULE_STAGES, `${label} stage`);\n if (!isPlainObject(sources)) throw new FactoryRuleValidationError(`${label}.${stage} must be an object.`);\n for (const [source, leaf] of Object.entries(sources)) {\n enumValue(source, FACTORY_RULE_SOURCES, `${label}.${stage} source`);\n if (!isPlainObject(leaf)) throw new FactoryRuleValidationError(`${label}.${stage}.${source} must be an object.`);\n assertExactKeys(leaf, ['onEnter', 'onExit'], `${label}.${stage}.${source}`);\n for (const handler of Object.values(leaf)) {\n if (handler !== undefined && typeof handler !== 'function') {\n throw new FactoryRuleValidationError(`${label}.${stage}.${source} handlers must be functions.`);\n }\n }\n }\n }\n}\n\nexport function assertFactoryRules(rules: unknown): asserts rules is FactoryRules {\n if (!isPlainObject(rules)) throw new FactoryRuleValidationError('Factory rules must be an object.');\n assertExactKeys(rules, ['version', 'work', 'review', 'tools', 'github', 'linear'], 'Factory rules');\n boundedString(rules.version, 'Factory rule version', MAX_VERSION_LENGTH);\n validateBoardRules(rules.work, 'Factory rules.work');\n validateBoardRules(rules.review, 'Factory rules.review');\n\n if (!isPlainObject(rules.tools)) throw new FactoryRuleValidationError('Factory rules.tools must be an object.');\n for (const [toolName, leaf] of Object.entries(rules.tools)) {\n boundedString(toolName, 'Factory tool name', 128, IDENTIFIER_RE);\n if (!isPlainObject(leaf))\n throw new FactoryRuleValidationError(`Factory rules.tools.${toolName} must be an object.`);\n assertExactKeys(leaf, ['onResult'], `Factory rules.tools.${toolName}`);\n if (leaf.onResult !== undefined && typeof leaf.onResult !== 'function') {\n throw new FactoryRuleValidationError(`Factory rules.tools.${toolName}.onResult must be a function.`);\n }\n }\n\n if (!isPlainObject(rules.github)) throw new FactoryRuleValidationError('Factory rules.github must be an object.');\n for (const [event, leaf] of Object.entries(rules.github)) {\n enumValue(event, FACTORY_GITHUB_EVENTS, 'Factory GitHub event');\n if (!isPlainObject(leaf)) throw new FactoryRuleValidationError(`Factory rules.github.${event} must be an object.`);\n assertExactKeys(leaf, ['onEvent'], `Factory rules.github.${event}`);\n if (leaf.onEvent !== undefined && typeof leaf.onEvent !== 'function') {\n throw new FactoryRuleValidationError(`Factory rules.github.${event}.onEvent must be a function.`);\n }\n }\n\n if (!isPlainObject(rules.linear)) throw new FactoryRuleValidationError('Factory rules.linear must be an object.');\n for (const [event, leaf] of Object.entries(rules.linear)) {\n enumValue(event, FACTORY_LINEAR_EVENTS, 'Factory Linear event');\n if (!isPlainObject(leaf)) throw new FactoryRuleValidationError(`Factory rules.linear.${event} must be an object.`);\n assertExactKeys(leaf, ['onEvent'], `Factory rules.linear.${event}`);\n if (leaf.onEvent !== undefined && typeof leaf.onEvent !== 'function') {\n throw new FactoryRuleValidationError(`Factory rules.linear.${event}.onEvent must be a function.`);\n }\n }\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(value, ['type', 'idempotencyKey', 'board', 'stage'], 'Factory transition decision');\n return {\n type,\n ...commonCommitFields(value),\n board: enumValue(value.board, FACTORY_RULE_BOARDS, 'Factory transition board'),\n stage: enumValue(value.stage, FACTORY_RULE_STAGES, 'Factory transition stage'),\n };\n }\n case 'upsertLinkedWorkItem': {\n assertExactKeys(\n value,\n ['type', 'idempotencyKey', 'board', 'source', 'sourceKey', 'title', 'url', 'stage', 'metadata'],\n 'Factory linked work item decision',\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: enumValue(value.board, FACTORY_RULE_BOARDS, '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 title: boundedString(value.title, 'Factory linked work item title', MAX_TITLE_LENGTH),\n url,\n stage: enumValue(value.stage, FACTORY_RULE_STAGES, 'Factory linked work item stage'),\n ...(metadata ? { metadata } : {}),\n };\n }\n case 'invokeSkill': {\n assertExactKeys(\n value,\n ['type', 'idempotencyKey', 'role', 'skillName', 'arguments', 'precedingMessage'],\n 'Factory invoke skill decision',\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 return {\n type,\n ...commonCommitFields(value),\n role: boundedString(value.role, 'Factory skill role', MAX_ROLE_LENGTH, IDENTIFIER_RE),\n skillName: boundedString(value.skillName, 'Factory skill name', MAX_SKILL_NAME_LENGTH, SKILL_NAME_RE),\n ...(args ? { arguments: args } : {}),\n ...(precedingMessage ? { precedingMessage } : {}),\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 return {\n type,\n ...commonCommitFields(value),\n role: boundedString(value.role, 'Factory message role', MAX_ROLE_LENGTH, IDENTIFIER_RE),\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 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":";AAEO,IAAM,sBAAsB,CAAC,UAAU,UAAU,YAAY,WAAW,UAAU,QAAQ,UAAU;AAGpG,IAAM,sBAAsB,CAAC,QAAQ,QAAQ;AAG7C,IAAM,uBAAuB,CAAC,SAAS,eAAe,eAAe,QAAQ;AAG7E,IAAM,wBAAwB;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGO,IAAM,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AAkB,SAAS,QAAQ,OAAO,GAAG,yBAAyB;AACtG,YAAM,OAAO,sBAAsB,MAAM,MAAM,6BAA6B,kBAAkB;AAC9F,YAAM,QACJ,MAAM,UAAU,SACZ,SACA,UAAU,MAAM,OAAO,CAAC,QAAQ,WAAW,OAAO,GAAY,4BAA4B;AAChG,aAAO;AAAA,QACL;AAAA,QACA,GAAG,mBAAmB,KAAK;AAAA,QAC3B,OAAO,cAAc,MAAM,OAAO,8BAA8B,gBAAgB;AAAA,QAChF,GAAI,OAAO,EAAE,KAAK,IAAI,CAAC;AAAA,QACvB,GAAI,QAAQ,EAAE,MAAM,IAAI,CAAC;AAAA,MAC3B;AAAA,IACF;AAAA,IACA;AACE,YAAM,IAAI,2BAA2B,4CAA4C;AAAA,EACrF;AACF;AAEO,SAAS,6BAA6B,QAA4B,cAAc,GAA4B;AACjH,MAAI,OAAO,SAAS,0BAA0B;AAC5C,UAAM,IAAI,2BAA2B,2CAA2C;AAAA,EAClF;AACA,QAAM,YAAqC,CAAC;AAC5C,aAAW,SAAS,QAAQ;AAC1B,UAAM,WAAW,4BAA4B,OAAO,WAAW;AAC/D,QAAI,SAAS,SAAS,UAAU;AAC9B,YAAM,IAAI,2BAA2B,wDAAwD;AAAA,IAC/F;AACA,cAAU,KAAK,QAAQ;AAAA,EACzB;AACA,QAAM,OAAO,UAAU,IAAI,cAAY,SAAS,cAAc;AAC9D,MAAI,IAAI,IAAI,IAAI,EAAE,SAAS,KAAK,QAAQ;AACtC,UAAM,IAAI,2BAA2B,oDAAoD;AAAA,EAC3F;AACA,SAAO;AACT;","names":[]}
@@ -0,0 +1,208 @@
1
+ /**
2
+ * Project sandbox fleet: provisioning, reattach, teardown, and budgeting.
3
+ *
4
+ * Server-hosted projects never run on the web host itself. Each project gets
5
+ * its own isolated sandbox (a `WorkspaceSandbox`, e.g. a Railway VM) `clone()`d
6
+ * from the machine the factory was configured with. This module owns everything
7
+ * about that fleet — which provider is active, where checkouts live inside a
8
+ * sandbox, the idle window, the per-replica budget, and the
9
+ * provision/reattach/teardown lifecycle — but knows nothing about what runs
10
+ * inside a sandbox (git materialization lives with its feature, e.g. the
11
+ * GitHub integration's `sandbox.ts`).
12
+ *
13
+ * The fleet is constructed once at boot with the machine config (or none, when
14
+ * sandboxes are disabled) and handed to consumers — no global registry.
15
+ * Persistence of the provider's reattach id is delegated to the caller via
16
+ * {@link SandboxBindingStore}, so the fleet stays storage-agnostic. Tests can
17
+ * swap the low-level construction via {@link SandboxFleet.setFactory}.
18
+ */
19
+ import type { WorkspaceSandbox } from '@mastra/core/workspace';
20
+ /** Minimal command result shape sandbox consumers depend on. */
21
+ export interface SandboxCommandResult {
22
+ exitCode: number;
23
+ stdout: string;
24
+ stderr: string;
25
+ }
26
+ /**
27
+ * Minimal live-sandbox surface fleet consumers need: an id, a way to start it,
28
+ * a way to learn the provider's reattach id, and command execution.
29
+ */
30
+ export interface MaterializationSandbox {
31
+ readonly id: string;
32
+ start(): Promise<void>;
33
+ getInfo(): Promise<{
34
+ metadata?: Record<string, unknown>;
35
+ }>;
36
+ executeCommand(command: string, args?: string[], options?: {
37
+ timeout?: number;
38
+ }): Promise<SandboxCommandResult>;
39
+ /** Tear down the underlying VM. Optional: providers without it are no-ops. */
40
+ stop?(): Promise<void>;
41
+ }
42
+ /** Options for building (or reattaching) one sandbox. */
43
+ export interface SandboxCreateOptions {
44
+ /** Reattach to this existing provider VM instead of provisioning a new one. */
45
+ providerSandboxId?: string;
46
+ /** Environment variables baked into the sandbox. */
47
+ env?: Record<string, string>;
48
+ /** Provider working directory for this sandbox. */
49
+ workingDirectory?: string;
50
+ /** Idle teardown window (minutes). The provider stops the VM after this idle period. */
51
+ idleTimeoutMinutes?: number;
52
+ /** Provider checkpoint used to seed and preserve this sandbox's filesystem. */
53
+ checkpointName?: string;
54
+ }
55
+ /**
56
+ * A coarse-grained step of the sandbox-preparation flow, reported as it happens
57
+ * so the UI can show the user what the server is doing instead of a static
58
+ * "Preparing…" toast. `phase` is a stable machine token; `message` is
59
+ * user-facing copy.
60
+ */
61
+ export interface PrepareProgress {
62
+ phase: 'reattaching' | 'provisioning' | 'preparing-workspace' | 'cloning' | 'pulling' | 'finalizing' | 'done';
63
+ message: string;
64
+ }
65
+ /** Callback invoked with each preparation step. Best-effort; never throws. */
66
+ export type ProgressFn = (event: PrepareProgress) => void;
67
+ /** Invoke a progress callback without letting it break the actual work. */
68
+ export declare function reportProgress(onProgress: ProgressFn | undefined, event: PrepareProgress): void;
69
+ /**
70
+ * Factory that builds a (not-yet-started) sandbox. When `providerSandboxId` is
71
+ * provided the sandbox should reattach to that existing VM instead of
72
+ * provisioning a new one.
73
+ */
74
+ export type SandboxFactory = (opts: SandboxCreateOptions) => MaterializationSandbox;
75
+ /** Raised when provisioning would exceed the per-replica sandbox budget. */
76
+ export declare class SandboxBudgetError extends Error {
77
+ readonly max: number;
78
+ readonly code: "sandbox-budget-exceeded";
79
+ constructor(max: number);
80
+ }
81
+ /** Optional knobs for provisioning/reattaching one sandbox. */
82
+ export interface EnsureSandboxOptions {
83
+ /** Provider working directory for this sandbox. */
84
+ workingDirectory?: string;
85
+ }
86
+ /**
87
+ * Where a feature persists its sandbox binding. The fleet reads the stored
88
+ * reattach id and writes updates through this seam so it stays agnostic of
89
+ * the owning table (GitHub projects today, anything else tomorrow).
90
+ */
91
+ export interface SandboxBindingStore {
92
+ /** Stored provider reattach id from a previous provisioning, if any. */
93
+ readonly sandboxId: string | null;
94
+ /** Provider checkpoint used to seed and preserve this sandbox's filesystem. */
95
+ readonly checkpointName?: string;
96
+ /** Persist a freshly provisioned provider id, or clear a stale one with `null`. */
97
+ setSandboxId(id: string | null): Promise<void>;
98
+ /** Clear all stored sandbox state (reattach id + materialization mark) on teardown. */
99
+ clear(): Promise<void>;
100
+ }
101
+ /** Resolve a workdir under `root`, refusing any path that escapes the configured root. */
102
+ export declare function resolveContainedLocalWorkdir(root: string, ...segments: string[]): string;
103
+ /**
104
+ * Factory-resolved sandbox runtime the fleet is constructed with: the machine
105
+ * projects clone their per-project sandboxes from, plus the knobs the factory
106
+ * resolved around it.
107
+ */
108
+ export interface SandboxFleetConfig {
109
+ /**
110
+ * Template machine (validated by the factory to implement `clone()`).
111
+ * Never started — acts purely as the credential/default holder that
112
+ * per-project sandboxes are cloned from.
113
+ */
114
+ machine: WorkspaceSandbox;
115
+ /** In-sandbox base directory repos check out under (no trailing slash). */
116
+ workdirBase: string;
117
+ /** Per-replica cap on concurrently provisioned sandboxes. 0 = unlimited. */
118
+ maxSandboxes?: number;
119
+ }
120
+ /**
121
+ * The sandbox fleet for one deployment. Constructed once at boot — with a
122
+ * config when a sandbox machine was configured, or without one when sandboxes
123
+ * are disabled (every provisioning entry point then throws and
124
+ * {@link enabled} reports `false` so features stay off).
125
+ */
126
+ export declare class SandboxFleet {
127
+ #private;
128
+ constructor(config?: SandboxFleetConfig);
129
+ /**
130
+ * True when a sandbox machine was configured. The factory validates the
131
+ * machine implements `clone()` at boot, so a configured fleet is usable —
132
+ * sandbox-backed projects stay off only when the slot was omitted.
133
+ */
134
+ get enabled(): boolean;
135
+ /**
136
+ * Name of the active sandbox provider — the configured machine's `provider`
137
+ * discriminator (`'railway'`, `'local'`, …), or `'none'` when the fleet was
138
+ * constructed without a config. Diagnostic only; feature gating goes
139
+ * through {@link enabled}.
140
+ */
141
+ get provider(): string;
142
+ /**
143
+ * Idle teardown window for provisioned sandboxes, in minutes; defaults to 30.
144
+ * Read back from the machine's own config when it exposes one
145
+ * (Railway's `idleTimeoutMinutes`) — the knob lives on the sandbox, the
146
+ * fleet only needs it to schedule GC and stamp sandbox clones. Advisory:
147
+ * providers without idle GC ignore it, and a re-open detects a torn-down VM
148
+ * and re-provisions cleanly.
149
+ */
150
+ get idleMinutes(): number;
151
+ /**
152
+ * Per-replica cap on concurrently *provisioned* sandboxes. 0 means unlimited.
153
+ * This is a lightweight per-process budget to keep a single replica from
154
+ * exhausting provider quota — it is not a global, cross-replica scheduler
155
+ * (that is a deferred follow-up).
156
+ */
157
+ get maxSandboxes(): number;
158
+ /**
159
+ * Count of sandboxes this fleet has freshly provisioned and not yet torn
160
+ * down. Reattaches to existing VMs do not count (they reuse an already-billed
161
+ * sandbox). Used to enforce {@link maxSandboxes}.
162
+ */
163
+ get liveCount(): number;
164
+ /** For tests: reset the live-sandbox counter to a known state. */
165
+ __resetLiveCount(value?: number): void;
166
+ /** Override the sandbox factory (tests). */
167
+ setFactory(factory: SandboxFactory): void;
168
+ /** Reset to the default machine-cloning factory. */
169
+ resetFactory(): void;
170
+ /**
171
+ * Compute the in-sandbox working directory for a repo: a nested
172
+ * `<base>/<owner>/<name>` layout under the factory-resolved checkout base.
173
+ * Nesting keeps same-name repos apart (`acme/api` vs `other/api`) — cloud
174
+ * sandboxes are one-per-project so it's merely tidy there, but local
175
+ * checkouts share one host root where it prevents collisions. Server-side
176
+ * only; never derived from client input.
177
+ */
178
+ computeWorkdir(repoFullName: string): string;
179
+ /**
180
+ * Compute the host working directory for a local GitHub session checkout.
181
+ * This is server-derived only: repo pieces are sanitized and the trusted
182
+ * session id is kept as a single path segment under the configured local root.
183
+ */
184
+ computeLocalSessionWorkdir(repoFullName: string, sessionId: string): string;
185
+ /**
186
+ * Provision a new sandbox (persisting its provider id on first open) or
187
+ * reattach to the stored one. Returns a started, live sandbox.
188
+ */
189
+ ensureSandbox(store: SandboxBindingStore, onProgress?: ProgressFn): Promise<MaterializationSandbox>;
190
+ ensureSandbox(store: SandboxBindingStore, env?: Record<string, string>, onProgress?: ProgressFn, options?: EnsureSandboxOptions): Promise<MaterializationSandbox>;
191
+ /**
192
+ * Tear down a sandbox binding: stop the live VM (best-effort) and clear the
193
+ * persisted state through the binding store so the next open re-provisions
194
+ * cleanly. Decrements the per-replica live-sandbox counter.
195
+ *
196
+ * @param store the binding to tear down
197
+ * @param sandbox an already-reattached live sandbox to stop, when available
198
+ */
199
+ teardownSandbox(store: SandboxBindingStore, sandbox?: MaterializationSandbox): Promise<void>;
200
+ /**
201
+ * Reattach to an already-provisioned sandbox by its provider id and start it.
202
+ * Used by the workspace seam when opening a project that was already
203
+ * materialized (sandbox id + workdir carried on controller state), so no DB
204
+ * round-trip is needed.
205
+ */
206
+ reattachSandbox(providerSandboxId: string, options?: EnsureSandboxOptions): Promise<MaterializationSandbox>;
207
+ }
208
+ //# sourceMappingURL=fleet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fleet.d.ts","sourceRoot":"","sources":["../../src/sandbox/fleet.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,gEAAgE;AAChE,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,OAAO,IAAI,OAAO,CAAC;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAC;IAC3D,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAChH,8EAA8E;IAC9E,IAAI,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED,yDAAyD;AACzD,MAAM,WAAW,oBAAoB;IACnC,+EAA+E;IAC/E,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,oDAAoD;IACpD,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,mDAAmD;IACnD,g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