@mastra/factory 0.13.0-alpha.9 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +232 -10
- package/dist/auth.d.ts +2 -0
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +29 -4
- package/dist/auth.js.map +1 -1
- package/dist/boards/define-board.d.ts +36 -2
- package/dist/boards/define-board.d.ts.map +1 -1
- package/dist/boards/define-board.js +58 -1
- package/dist/boards/define-board.js.map +1 -1
- package/dist/boards/index.d.ts +4 -2
- package/dist/boards/index.d.ts.map +1 -1
- package/dist/boards/index.js +2 -1
- package/dist/boards/index.js.map +1 -1
- package/dist/boards/relocate.d.ts +17 -0
- package/dist/boards/relocate.d.ts.map +1 -0
- package/dist/boards/relocate.js +53 -0
- package/dist/boards/relocate.js.map +1 -0
- package/dist/boards/review.d.ts +1 -1
- package/dist/boards/review.d.ts.map +1 -1
- package/dist/boards/review.js +17 -4
- package/dist/boards/review.js.map +1 -1
- package/dist/boards/semantics.d.ts +28 -0
- package/dist/boards/semantics.d.ts.map +1 -0
- package/dist/boards/semantics.js +41 -0
- package/dist/boards/semantics.js.map +1 -0
- package/dist/boards/work-tool-rules.d.ts +8 -0
- package/dist/boards/work-tool-rules.d.ts.map +1 -0
- package/dist/boards/work-tool-rules.js +20 -0
- package/dist/boards/work-tool-rules.js.map +1 -0
- package/dist/boards/work.d.ts +1 -1
- package/dist/boards/work.d.ts.map +1 -1
- package/dist/boards/work.js +13 -0
- package/dist/boards/work.js.map +1 -1
- package/dist/capabilities/intake.d.ts +2 -0
- package/dist/capabilities/intake.d.ts.map +1 -1
- package/dist/factory.d.ts +5 -6
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +41 -12
- package/dist/factory.js.map +1 -1
- package/dist/integrations/base.d.ts +7 -4
- package/dist/integrations/base.d.ts.map +1 -1
- package/dist/integrations/github/default-rules.d.ts +2 -2
- package/dist/integrations/github/default-rules.d.ts.map +1 -1
- package/dist/integrations/github/default-rules.js +2 -2
- package/dist/integrations/github/default-rules.js.map +1 -1
- package/dist/integrations/github/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/github/issue-reconciler.js +4 -3
- package/dist/integrations/github/issue-reconciler.js.map +1 -1
- package/dist/integrations/github/rules.d.ts +6 -2
- package/dist/integrations/github/rules.d.ts.map +1 -1
- package/dist/integrations/github/rules.js +96 -15
- package/dist/integrations/github/rules.js.map +1 -1
- package/dist/integrations/github/sandbox.d.ts +6 -3
- package/dist/integrations/github/sandbox.d.ts.map +1 -1
- package/dist/integrations/github/sandbox.js +21 -2
- package/dist/integrations/github/sandbox.js.map +1 -1
- package/dist/integrations/issue-reconciler.d.ts +2 -0
- package/dist/integrations/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/issue-reconciler.js +1 -3
- package/dist/integrations/issue-reconciler.js.map +1 -1
- package/dist/integrations/linear/agent-tools.d.ts.map +1 -1
- package/dist/integrations/linear/agent-tools.js.map +1 -1
- package/dist/integrations/linear/default-rules.d.ts +2 -2
- package/dist/integrations/linear/default-rules.d.ts.map +1 -1
- package/dist/integrations/linear/default-rules.js +2 -2
- package/dist/integrations/linear/default-rules.js.map +1 -1
- package/dist/integrations/linear/integration.js +1 -0
- package/dist/integrations/linear/integration.js.map +1 -1
- package/dist/integrations/linear/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/linear/issue-reconciler.js +9 -4
- package/dist/integrations/linear/issue-reconciler.js.map +1 -1
- package/dist/integrations/linear/reconciliation-config.d.ts.map +1 -1
- package/dist/integrations/linear/reconciliation-config.js.map +1 -1
- package/dist/integrations/linear/routes.d.ts.map +1 -1
- package/dist/integrations/linear/routes.js +19 -26
- package/dist/integrations/linear/routes.js.map +1 -1
- package/dist/integrations/linear/rules.d.ts +7 -2
- package/dist/integrations/linear/rules.d.ts.map +1 -1
- package/dist/integrations/linear/rules.js +20 -8
- package/dist/integrations/linear/rules.js.map +1 -1
- package/dist/integrations/platform/api-client.d.ts.map +1 -1
- package/dist/integrations/platform/api-client.js +25 -4
- package/dist/integrations/platform/api-client.js.map +1 -1
- package/dist/integrations/platform/github/integration.d.ts +1 -0
- package/dist/integrations/platform/github/integration.d.ts.map +1 -1
- package/dist/integrations/platform/github/integration.js +5 -0
- package/dist/integrations/platform/github/integration.js.map +1 -1
- package/dist/integrations/platform/linear/integration.d.ts.map +1 -1
- package/dist/integrations/platform/linear/integration.js +5 -2
- package/dist/integrations/platform/linear/integration.js.map +1 -1
- package/dist/integrations/slack/emoji-shortcodes.generated.d.ts +8 -0
- package/dist/integrations/slack/emoji-shortcodes.generated.d.ts.map +1 -0
- package/dist/integrations/slack/emoji-shortcodes.generated.js +1985 -0
- package/dist/integrations/slack/emoji-shortcodes.generated.js.map +1 -0
- package/dist/integrations/slack/emoji.d.ts +3 -0
- package/dist/integrations/slack/emoji.d.ts.map +1 -0
- package/dist/integrations/slack/emoji.js +12 -0
- package/dist/integrations/slack/emoji.js.map +1 -0
- package/dist/integrations/slack/integration.js +1 -1
- package/dist/integrations/slack/integration.js.map +1 -1
- package/dist/integrations/slack/slack.d.ts.map +1 -1
- package/dist/integrations/slack/slack.js +16 -2
- package/dist/integrations/slack/slack.js.map +1 -1
- package/dist/routes/attention-activity.d.ts +2 -3
- package/dist/routes/attention-activity.d.ts.map +1 -1
- package/dist/routes/attention-activity.js +12 -3
- package/dist/routes/attention-activity.js.map +1 -1
- package/dist/routes/attention-parked.d.ts +22 -0
- package/dist/routes/attention-parked.d.ts.map +1 -0
- package/dist/routes/attention-parked.js +136 -0
- package/dist/routes/attention-parked.js.map +1 -0
- package/dist/routes/attention-providers.js +8 -8
- package/dist/routes/attention-providers.js.map +1 -1
- package/dist/routes/attention.d.ts +2 -0
- package/dist/routes/attention.d.ts.map +1 -1
- package/dist/routes/attention.js +47 -118
- package/dist/routes/attention.js.map +1 -1
- package/dist/routes/contracts.d.ts +627 -0
- package/dist/routes/contracts.d.ts.map +1 -0
- package/dist/routes/contracts.js +468 -0
- package/dist/routes/contracts.js.map +1 -0
- package/dist/routes/intake.d.ts +18 -0
- package/dist/routes/intake.d.ts.map +1 -1
- package/dist/routes/intake.js +265 -15
- package/dist/routes/intake.js.map +1 -1
- package/dist/routes/projects.d.ts.map +1 -1
- package/dist/routes/projects.js +26 -76
- package/dist/routes/projects.js.map +1 -1
- package/dist/routes/supervisor.d.ts +2 -0
- package/dist/routes/supervisor.d.ts.map +1 -1
- package/dist/routes/supervisor.js +7 -6
- package/dist/routes/supervisor.js.map +1 -1
- package/dist/routes/surface.d.ts +7 -4
- package/dist/routes/surface.d.ts.map +1 -1
- package/dist/routes/surface.js +17 -11
- package/dist/routes/surface.js.map +1 -1
- package/dist/routes/telemetry.d.ts +13 -0
- package/dist/routes/telemetry.d.ts.map +1 -0
- package/dist/routes/telemetry.js +60 -0
- package/dist/routes/telemetry.js.map +1 -0
- package/dist/routes/work-items.d.ts +3 -3
- package/dist/routes/work-items.d.ts.map +1 -1
- package/dist/routes/work-items.js +134 -250
- package/dist/routes/work-items.js.map +1 -1
- package/dist/rules/dispatch-errors.d.ts +2 -2
- package/dist/rules/dispatch-errors.d.ts.map +1 -1
- package/dist/rules/dispatch-errors.js +10 -6
- package/dist/rules/dispatch-errors.js.map +1 -1
- package/dist/rules/dispatcher.d.ts +9 -2
- package/dist/rules/dispatcher.d.ts.map +1 -1
- package/dist/rules/dispatcher.js +76 -23
- package/dist/rules/dispatcher.js.map +1 -1
- package/dist/rules/index.d.ts +4 -5
- package/dist/rules/index.d.ts.map +1 -1
- package/dist/rules/index.js +3 -4
- package/dist/rules/processor.d.ts +3 -3
- package/dist/rules/processor.d.ts.map +1 -1
- package/dist/rules/processor.js +24 -31
- package/dist/rules/processor.js.map +1 -1
- package/dist/rules/resolve.d.ts +1 -3
- package/dist/rules/resolve.d.ts.map +1 -1
- package/dist/rules/resolve.js +1 -4
- package/dist/rules/resolve.js.map +1 -1
- package/dist/rules/start-coordinator.d.ts.map +1 -1
- package/dist/rules/start-coordinator.js +3 -1
- package/dist/rules/start-coordinator.js.map +1 -1
- package/dist/rules/tools.d.ts.map +1 -1
- package/dist/rules/tools.js +20 -10
- package/dist/rules/tools.js.map +1 -1
- package/dist/rules/transition-service.d.ts +7 -7
- package/dist/rules/transition-service.d.ts.map +1 -1
- package/dist/rules/transition-service.js +21 -25
- package/dist/rules/transition-service.js.map +1 -1
- package/dist/rules/types.d.ts +16 -11
- package/dist/rules/types.d.ts.map +1 -1
- package/dist/rules/types.js.map +1 -1
- package/dist/rules/validation.d.ts +12 -2
- package/dist/rules/validation.d.ts.map +1 -1
- package/dist/rules/validation.js +29 -20
- package/dist/rules/validation.js.map +1 -1
- package/dist/session/live-sessions.d.ts +33 -3
- package/dist/session/live-sessions.d.ts.map +1 -1
- package/dist/session/live-sessions.js +67 -5
- package/dist/session/live-sessions.js.map +1 -1
- package/dist/storage/domains/intake/base.d.ts +54 -1
- package/dist/storage/domains/intake/base.d.ts.map +1 -1
- package/dist/storage/domains/intake/base.js +136 -4
- package/dist/storage/domains/intake/base.js.map +1 -1
- package/dist/storage/domains/work-items/base.d.ts +22 -7
- package/dist/storage/domains/work-items/base.d.ts.map +1 -1
- package/dist/storage/domains/work-items/base.js +41 -26
- package/dist/storage/domains/work-items/base.js.map +1 -1
- package/dist/supervisor/health-worker.d.ts +2 -0
- package/dist/supervisor/health-worker.d.ts.map +1 -1
- package/dist/supervisor/health-worker.js +3 -1
- package/dist/supervisor/health-worker.js.map +1 -1
- package/dist/supervisor/health.d.ts +12 -14
- package/dist/supervisor/health.d.ts.map +1 -1
- package/dist/supervisor/health.js +24 -52
- package/dist/supervisor/health.js.map +1 -1
- package/dist/supervisor/instructions.d.ts +1 -1
- package/dist/supervisor/instructions.d.ts.map +1 -1
- package/dist/supervisor/instructions.js +10 -8
- package/dist/supervisor/instructions.js.map +1 -1
- package/dist/supervisor/read-tools.d.ts +2 -0
- package/dist/supervisor/read-tools.d.ts.map +1 -1
- package/dist/supervisor/read-tools.js +2 -2
- package/dist/supervisor/read-tools.js.map +1 -1
- package/dist/supervisor/write-tools.d.ts.map +1 -1
- package/dist/supervisor/write-tools.js +6 -4
- package/dist/supervisor/write-tools.js.map +1 -1
- package/dist/telemetry-types.d.ts +7 -0
- package/dist/telemetry-types.d.ts.map +1 -0
- package/dist/telemetry-types.js +24 -0
- package/dist/telemetry-types.js.map +1 -0
- package/dist/telemetry.d.ts +9 -0
- package/dist/telemetry.d.ts.map +1 -0
- package/dist/telemetry.js +47 -0
- package/dist/telemetry.js.map +1 -0
- package/dist/work-item-branch.d.ts +2 -0
- package/dist/work-item-branch.d.ts.map +1 -1
- package/dist/work-item-branch.js +6 -1
- package/dist/work-item-branch.js.map +1 -1
- package/dist/workspace.d.ts.map +1 -1
- package/dist/workspace.js +3 -1
- package/dist/workspace.js.map +1 -1
- package/factory-skills/configure-factory-rules/SKILL.md +30 -10
- package/package.json +12 -10
- package/dist/rules/defaults.d.ts +0 -9
- package/dist/rules/defaults.d.ts.map +0 -1
- package/dist/rules/defaults.js +0 -50
- package/dist/rules/defaults.js.map +0 -1
package/dist/rules/validation.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { FACTORY_RULE_BOARDS, FACTORY_RULE_STAGES } from "./types.js";
|
|
2
1
|
//#region src/rules/validation.ts
|
|
3
2
|
const MAX_FACTORY_RULE_CAUSAL_DEPTH = 8;
|
|
4
3
|
const MAX_VERSION_LENGTH = 128;
|
|
@@ -8,13 +7,16 @@ const MAX_TITLE_LENGTH = 512;
|
|
|
8
7
|
const MAX_MESSAGE_LENGTH = 8192;
|
|
9
8
|
const MAX_ARGUMENTS_LENGTH = 4096;
|
|
10
9
|
const MAX_ROLE_LENGTH = 32;
|
|
10
|
+
const MAX_TOOL_NAME_LENGTH = 128;
|
|
11
11
|
const MAX_SKILL_NAME_LENGTH = 128;
|
|
12
12
|
const MAX_SOURCE_KEY_LENGTH = 256;
|
|
13
13
|
const MAX_URL_LENGTH = 2048;
|
|
14
14
|
const MAX_METADATA_JSON_LENGTH = 16384;
|
|
15
15
|
const MAX_JSON_DEPTH = 8;
|
|
16
16
|
const MAX_JSON_COLLECTION_SIZE = 100;
|
|
17
|
+
const MAX_BOARD_IDENTIFIER_LENGTH = 128;
|
|
17
18
|
const IDENTIFIER_RE = /^[a-z0-9][a-z0-9_-]*$/i;
|
|
19
|
+
const BOARD_IDENTIFIER_RE = IDENTIFIER_RE;
|
|
18
20
|
const SKILL_NAME_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
19
21
|
const SENSITIVE_KEY_RE = /(?:authorization|cookie|credential|password|secret|token)/i;
|
|
20
22
|
const WORK_ITEM_SOURCES = [
|
|
@@ -55,6 +57,20 @@ function boundedString(value, label, max, pattern) {
|
|
|
55
57
|
if (normalized.length === 0 || normalized.length > max || pattern && !pattern.test(normalized)) throw new FactoryRuleValidationError(`${label} is invalid.`);
|
|
56
58
|
return normalized;
|
|
57
59
|
}
|
|
60
|
+
function isBoardIdentifier(value) {
|
|
61
|
+
return typeof value === "string" && value.length <= 128 && BOARD_IDENTIFIER_RE.test(value);
|
|
62
|
+
}
|
|
63
|
+
function boardIdentifier(value, label) {
|
|
64
|
+
if (!isBoardIdentifier(value)) throw new FactoryRuleValidationError(`${label} is invalid.`);
|
|
65
|
+
return value;
|
|
66
|
+
}
|
|
67
|
+
function assertFactoryDecisionTarget(decision, boards, itemBoard) {
|
|
68
|
+
if (decision.type !== "transition" && decision.type !== "upsertLinkedWorkItem") return;
|
|
69
|
+
const board = boards.get(decision.board);
|
|
70
|
+
if (!board) throw new FactoryRuleValidationError("Factory decision target board is not installed.");
|
|
71
|
+
if (!Object.hasOwn(board.phases, decision.stage)) throw new FactoryRuleValidationError("Factory decision target phase is not defined on its board.");
|
|
72
|
+
if (decision.type === "transition" && itemBoard !== void 0 && itemBoard !== decision.board) throw new FactoryRuleValidationError("Factory transition cannot change the item board.");
|
|
73
|
+
}
|
|
58
74
|
function optionalBoundedString(value, label, max) {
|
|
59
75
|
if (value === void 0) return void 0;
|
|
60
76
|
return boundedString(value, label, max);
|
|
@@ -97,17 +113,10 @@ function sanitizeMetadata(value) {
|
|
|
97
113
|
if (JSON.stringify(sanitized).length > MAX_METADATA_JSON_LENGTH) throw new FactoryRuleValidationError("Rule metadata is too large.");
|
|
98
114
|
return sanitized;
|
|
99
115
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
boundedString(
|
|
104
|
-
if (!isPlainObject(rules.tools)) throw new FactoryRuleValidationError("Factory rules.tools must be an object.");
|
|
105
|
-
for (const [toolName, leaf] of Object.entries(rules.tools)) {
|
|
106
|
-
boundedString(toolName, "Factory tool name", 128, IDENTIFIER_RE);
|
|
107
|
-
if (!isPlainObject(leaf)) throw new FactoryRuleValidationError(`Factory rules.tools.${toolName} must be an object.`);
|
|
108
|
-
assertExactKeys(leaf, ["onResult"], `Factory rules.tools.${toolName}`);
|
|
109
|
-
if (leaf.onResult !== void 0 && typeof leaf.onResult !== "function") throw new FactoryRuleValidationError(`Factory rules.tools.${toolName}.onResult must be a function.`);
|
|
110
|
-
}
|
|
116
|
+
const DEFAULT_FACTORY_CONFIG_VERSION = "factory-config-v1";
|
|
117
|
+
/** Operator-maintained provenance label stamped on transition audit and deferred-decision rows. */
|
|
118
|
+
function assertFactoryConfigVersion(value) {
|
|
119
|
+
return boundedString(value, "Factory configVersion", MAX_VERSION_LENGTH);
|
|
111
120
|
}
|
|
112
121
|
function commonCommitFields(value) {
|
|
113
122
|
return { idempotencyKey: boundedString(value.idempotencyKey, "Factory decision idempotencyKey", MAX_IDEMPOTENCY_KEY_LENGTH) };
|
|
@@ -143,7 +152,7 @@ function validateFactoryRuleDecision(value, causalDepth = 0) {
|
|
|
143
152
|
if (value.message !== void 0) {
|
|
144
153
|
if (!isPlainObject(value.message)) throw new FactoryRuleValidationError("Factory transition message must be an object.");
|
|
145
154
|
assertExactKeys(value.message, ["text", "role"], "Factory transition message");
|
|
146
|
-
const role = value.message.role === void 0 ? void 0 : boundedString(value.message.role, "Factory transition message role",
|
|
155
|
+
const role = value.message.role === void 0 ? void 0 : boundedString(value.message.role, "Factory transition message role", 32, IDENTIFIER_RE);
|
|
147
156
|
message = {
|
|
148
157
|
text: boundedString(value.message.text, "Factory transition message text", MAX_MESSAGE_LENGTH),
|
|
149
158
|
...role ? { role } : {}
|
|
@@ -152,8 +161,8 @@ function validateFactoryRuleDecision(value, causalDepth = 0) {
|
|
|
152
161
|
return {
|
|
153
162
|
type,
|
|
154
163
|
...commonCommitFields(value),
|
|
155
|
-
board:
|
|
156
|
-
stage:
|
|
164
|
+
board: boardIdentifier(value.board, "Factory transition board"),
|
|
165
|
+
stage: boardIdentifier(value.stage, "Factory transition stage"),
|
|
157
166
|
...message ? { message } : {},
|
|
158
167
|
...value.reenter === true ? { reenter: true } : {}
|
|
159
168
|
};
|
|
@@ -176,12 +185,12 @@ function validateFactoryRuleDecision(value, causalDepth = 0) {
|
|
|
176
185
|
return {
|
|
177
186
|
type,
|
|
178
187
|
...commonCommitFields(value),
|
|
179
|
-
board:
|
|
188
|
+
board: boardIdentifier(value.board, "Factory linked work item board"),
|
|
180
189
|
source: enumValue(value.source, WORK_ITEM_SOURCES, "Factory linked work item source"),
|
|
181
190
|
sourceKey: boundedString(value.sourceKey, "Factory linked work item sourceKey", MAX_SOURCE_KEY_LENGTH),
|
|
182
191
|
title: boundedString(value.title, "Factory linked work item title", MAX_TITLE_LENGTH),
|
|
183
192
|
url,
|
|
184
|
-
stage:
|
|
193
|
+
stage: boardIdentifier(value.stage, "Factory linked work item stage"),
|
|
185
194
|
...metadata ? { metadata } : {}
|
|
186
195
|
};
|
|
187
196
|
}
|
|
@@ -203,7 +212,7 @@ function validateFactoryRuleDecision(value, causalDepth = 0) {
|
|
|
203
212
|
return {
|
|
204
213
|
type,
|
|
205
214
|
...commonCommitFields(value),
|
|
206
|
-
role: boundedString(value.role, "Factory skill role",
|
|
215
|
+
role: boundedString(value.role, "Factory skill role", 32, IDENTIFIER_RE),
|
|
207
216
|
...value.skillName === void 0 ? { prompt: boundedString(value.prompt, "Factory skill prompt", MAX_MESSAGE_LENGTH) } : { skillName: boundedString(value.skillName, "Factory skill name", MAX_SKILL_NAME_LENGTH, SKILL_NAME_RE) },
|
|
208
217
|
...args ? { arguments: args } : {},
|
|
209
218
|
...precedingMessage ? { precedingMessage } : {},
|
|
@@ -228,7 +237,7 @@ function validateFactoryRuleDecision(value, causalDepth = 0) {
|
|
|
228
237
|
const idleBehavior = value.idleBehavior === void 0 ? void 0 : enumValue(value.idleBehavior, ["persist", "wake"], "Factory message idle behavior");
|
|
229
238
|
if (value.prepareBinding !== void 0 && typeof value.prepareBinding !== "boolean") throw new FactoryRuleValidationError("Factory message prepareBinding must be a boolean.");
|
|
230
239
|
if (value.prepareBinding === true && value.role === void 0) throw new FactoryRuleValidationError("Factory message prepareBinding requires a role.");
|
|
231
|
-
const role = value.role === void 0 ? void 0 : boundedString(value.role, "Factory message role",
|
|
240
|
+
const role = value.role === void 0 ? void 0 : boundedString(value.role, "Factory message role", 32, IDENTIFIER_RE);
|
|
232
241
|
return {
|
|
233
242
|
type,
|
|
234
243
|
...commonCommitFields(value),
|
|
@@ -277,6 +286,6 @@ function validateFactoryRuleDecisions(values, causalDepth = 0) {
|
|
|
277
286
|
return decisions;
|
|
278
287
|
}
|
|
279
288
|
//#endregion
|
|
280
|
-
export { FactoryRuleValidationError, MAX_FACTORY_RULE_CAUSAL_DEPTH,
|
|
289
|
+
export { BOARD_IDENTIFIER_RE, DEFAULT_FACTORY_CONFIG_VERSION, FactoryRuleValidationError, IDENTIFIER_RE, MAX_BOARD_IDENTIFIER_LENGTH, MAX_FACTORY_RULE_CAUSAL_DEPTH, MAX_ROLE_LENGTH, MAX_TOOL_NAME_LENGTH, assertFactoryConfigVersion, assertFactoryDecisionTarget, isBoardIdentifier, normalizeFactoryRuleJsonValue, validateFactoryRuleDecision, validateFactoryRuleDecisions };
|
|
281
290
|
|
|
282
291
|
//# sourceMappingURL=validation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","names":[],"sources":["../../src/rules/validation.ts"],"sourcesContent":["import { FACTORY_RULE_BOARDS, FACTORY_RULE_STAGES } from './types.js';\nimport type {\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\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', 'tools'], 'Factory rules');\n boundedString(rules.version, 'Factory rule version', MAX_VERSION_LENGTH);\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\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: enumValue(value.board, FACTORY_RULE_BOARDS, 'Factory transition board'),\n stage: enumValue(value.stage, FACTORY_RULE_STAGES, 'Factory transition stage'),\n ...(message ? { message } : {}),\n ...(value.reenter === true ? { reenter: true } : {}),\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', 'prompt', 'arguments', 'precedingMessage', 'cancelInFlight'],\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 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 : { skillName: boundedString(value.skillName, 'Factory skill name', MAX_SKILL_NAME_LENGTH, SKILL_NAME_RE) }),\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 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":";;AAUA,MAAa,gCAAgC;AAE7C,MAAM,qBAAqB;AAC3B,MAAM,6BAA6B;AACnC,MAAM,oBAAoB;AAC1B,MAAM,mBAAmB;AACzB,MAAM,qBAAqB;AAC3B,MAAM,uBAAuB;AAC7B,MAAM,kBAAkB;AACxB,MAAM,wBAAwB;AAC9B,MAAM,wBAAwB;AAC9B,MAAM,iBAAiB;AACvB,MAAM,2BAA2B;AACjC,MAAM,iBAAiB;AACvB,MAAM,2BAA2B;AAEjC,MAAM,gBAAgB;AACtB,MAAM,gBAAgB;AACtB,MAAM,mBAAmB;AACzB,MAAM,oBAA+C;CAAC;CAAgB;CAAa;CAAgB;AAAQ;AAC3G,MAAM,kBAAuD;CAC3D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,IAAa,6BAAb,cAAgD,MAAM;CACpD,OAAgB;CAEhB,YAAY,SAAiB;EAC3B,MAAM,OAAO;EACb,KAAK,OAAO;CACd;AACF;AAEA,SAAS,cAAc,OAAkD;CACvE,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,MAAM,QAAQ,KAAK,GAAG,OAAO;CAChF,MAAM,YAAY,OAAO,eAAe,KAAK;CAC7C,OAAO,cAAc,OAAO,aAAa,cAAc;AACzD;AAEA,SAAS,gBAAgB,OAAgC,MAAyB,OAAqB;CACrG,MAAM,UAAU,IAAI,IAAI,IAAI;CAC5B,IAAI,OAAO,KAAK,KAAK,CAAC,CAAC,MAAK,QAAO,CAAC,QAA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S,cAAc,MAAM,SAAS,mBAAmB,kBAAkB;IAC3E,GAAI,WAAW,EAAE,SAAS,IAAI,CAAC;IAC/B,GAAI,eAAe,EAAE,aAAa,IAAI,CAAC;IACvC,GAAI,MAAM,mBAAmB,OAAO,EAAE,gBAAgB,KAAK,IAAI,CAAC;GAClE;EACF;EACA,KAAK,UAAU;GACb,gBAAgB,OAAO;IAAC;IAAQ;IAAkB;IAAS;IAAQ;GAAO,GAAG,yBAAyB;GACtG,MAAM,OAAO,sBAAsB,MAAM,MAAM,6BAA6B,kBAAkB;GAC9F,MAAM,QACJ,MAAM,UAAU,KAAA,IACZ,KAAA,IACA,UAAU,MAAM,OAAO;IAAC;IAAQ;IAAW;GAAO,GAAY,4BAA4B;GAChG,OAAO;IACL;IACA,GAAG,mBAAmB,KAAK;IAC3B,OAAO,cAAc,MAAM,OAAO,8BAA8B,gBAAgB;IAChF,GAAI,OAAO,EAAE,KAAK,IAAI,CAAC;IACvB,GAAI,QAAQ,EAAE,MAAM,IAAI,CAAC;GAC3B;EACF;EACA,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;\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[] = ['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\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 ['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: 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 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 ...(metadata ? { metadata } : {}),\n };\n }\n case 'invokeSkill': {\n assertExactKeys(\n value,\n ['type', 'idempotencyKey', 'role', 'skillName', 'prompt', 'arguments', 'precedingMessage', 'cancelInFlight'],\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 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 : { skillName: boundedString(value.skillName, 'Factory skill name', MAX_SKILL_NAME_LENGTH, SKILL_NAME_RE) }),\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 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,MAAM,6BAA6B;AACnC,MAAM,oBAAoB;AAC1B,MAAM,mBAAmB;AACzB,MAAM,qBAAqB;AAC3B,MAAM,uBAAuB;AAC7B,MAAa,kBAAkB;AAC/B,MAAa,uBAAuB;AACpC,MAAM,wBAAwB;AAC9B,MAAM,wBAAwB;AAC9B,MAAM,iBAAiB;AACvB,MAAM,2BAA2B;AACjC,MAAM,iBAAiB;AACvB,MAAM,2BAA2B;AAEjC,MAAa,8BAA8B;AAC3C,MAAa,gBAAgB;AAC7B,MAAa,sBAAsB;AACnC,MAAM,gBAAgB;AACtB,MAAM,mBAAmB;AACzB,MAAM,oBAA+C;CAAC;CAAgB;CAAa;CAAgB;AAAQ;AAC3G,MAAM,kBAAuD;CAC3D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,IAAa,6BAAb,cAAgD,MAAM;CACpD,OAAgB;CAEhB,YAAY,SAAiB;EAC3B,MAAM,OAAO;EACb,KAAK,OAAO;CACd;AACF;AAEA,SAAS,cAAc,OAAkD;CACvE,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,MAAM,QAAQ,KAAK,GAAG,OAAO;CAChF,MAAM,YAAY,OAAO,eAAe,KAAK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;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,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import type { AgentControllerEvent } from '@mastra/core/agent-controller';
|
|
2
|
+
/** The slice of a live session this registry needs: its id, its run, its parked tools, and who it works for. */
|
|
2
3
|
export interface LiveSession {
|
|
3
4
|
readonly identity: {
|
|
4
5
|
getId(): string;
|
|
@@ -6,11 +7,30 @@ export interface LiveSession {
|
|
|
6
7
|
readonly run: {
|
|
7
8
|
isRunning(): boolean;
|
|
8
9
|
};
|
|
10
|
+
readonly state: {
|
|
11
|
+
get(): Readonly<{
|
|
12
|
+
factoryOrgId?: string;
|
|
13
|
+
factoryProjectId?: string;
|
|
14
|
+
}>;
|
|
15
|
+
};
|
|
16
|
+
readonly displayState: {
|
|
17
|
+
get(): {
|
|
18
|
+
pendingSuspensions: ReadonlyMap<string, {
|
|
19
|
+
toolName: string;
|
|
20
|
+
}>;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
subscribe(listener: (event: AgentControllerEvent) => void): () => void;
|
|
9
24
|
}
|
|
10
25
|
interface SessionNotifier {
|
|
11
26
|
onSessionCreated(listener: (session: LiveSession) => void): () => void;
|
|
12
27
|
onSessionDeleted(listener: (session: LiveSession) => void): () => void;
|
|
13
28
|
}
|
|
29
|
+
/** The tool a session has waited on longest, and since when (epoch ms). */
|
|
30
|
+
export interface ParkedRun {
|
|
31
|
+
toolName: string;
|
|
32
|
+
suspendedAt: number;
|
|
33
|
+
}
|
|
14
34
|
/**
|
|
15
35
|
* The sessions this process has materialized, by session id.
|
|
16
36
|
*
|
|
@@ -20,14 +40,24 @@ interface SessionNotifier {
|
|
|
20
40
|
* sandbox, minutes on a cold clone. Notifications only fire once a session
|
|
21
41
|
* exists, so a read never waits.
|
|
22
42
|
*
|
|
23
|
-
* Whether a session is *running* is read from the session itself,
|
|
24
|
-
* tracked here: no missed run event can leave the answer stuck.
|
|
43
|
+
* Whether a session is *running* or *parked* is read from the session itself,
|
|
44
|
+
* never tracked here: no missed run event can leave the answer stuck. Only the
|
|
45
|
+
* moment each suspension arrived is kept, since the session does not date them.
|
|
25
46
|
*/
|
|
26
47
|
export declare class LiveSessions {
|
|
27
48
|
#private;
|
|
28
49
|
constructor(controller: SessionNotifier);
|
|
29
50
|
/** Whether the session has an agent run in flight right now. */
|
|
30
51
|
isRunning(sessionId: string): boolean;
|
|
52
|
+
/** The tool the session is parked on, oldest first, or nothing when no answer is owed. */
|
|
53
|
+
parked(sessionId: string): ParkedRun | undefined;
|
|
54
|
+
/** Every parked session of a project, so the inbox reads no card when nothing waits. */
|
|
55
|
+
parkedIn(factoryProjectId: string): Array<{
|
|
56
|
+
sessionId: string;
|
|
57
|
+
run: ParkedRun;
|
|
58
|
+
}>;
|
|
59
|
+
/** Fires when a session parks, is answered, or finishes a turn: whoever shows parked runs re-reads. */
|
|
60
|
+
onParkedChanged(listener: (session: LiveSession) => void): () => void;
|
|
31
61
|
}
|
|
32
62
|
export {};
|
|
33
63
|
//# sourceMappingURL=live-sessions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"live-sessions.d.ts","sourceRoot":"","sources":["../../src/session/live-sessions.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"live-sessions.d.ts","sourceRoot":"","sources":["../../src/session/live-sessions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAE1E,gHAAgH;AAChH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,QAAQ,EAAE;QAAE,KAAK,IAAI,MAAM,CAAA;KAAE,CAAC;IACvC,QAAQ,CAAC,GAAG,EAAE;QAAE,SAAS,IAAI,OAAO,CAAA;KAAE,C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-8,18 +8,80 @@
|
|
|
8
8
|
* sandbox, minutes on a cold clone. Notifications only fire once a session
|
|
9
9
|
* exists, so a read never waits.
|
|
10
10
|
*
|
|
11
|
-
* Whether a session is *running* is read from the session itself,
|
|
12
|
-
* tracked here: no missed run event can leave the answer stuck.
|
|
11
|
+
* Whether a session is *running* or *parked* is read from the session itself,
|
|
12
|
+
* never tracked here: no missed run event can leave the answer stuck. Only the
|
|
13
|
+
* moment each suspension arrived is kept, since the session does not date them.
|
|
13
14
|
*/
|
|
14
15
|
var LiveSessions = class {
|
|
15
16
|
#byId = /* @__PURE__ */ new Map();
|
|
17
|
+
#parkedListeners = /* @__PURE__ */ new Set();
|
|
18
|
+
/** A park stamp doubles as the receipt key, so two suspensions in one millisecond must not share one. */
|
|
19
|
+
#lastParkStamp = 0;
|
|
16
20
|
constructor(controller) {
|
|
17
|
-
controller.onSessionCreated((session) => this.#
|
|
18
|
-
controller.onSessionDeleted((session) =>
|
|
21
|
+
controller.onSessionCreated((session) => this.#track(session));
|
|
22
|
+
controller.onSessionDeleted((session) => {
|
|
23
|
+
const id = session.identity.getId();
|
|
24
|
+
const wasParked = this.parked(id) !== void 0;
|
|
25
|
+
this.#byId.get(id)?.unsubscribe();
|
|
26
|
+
this.#byId.delete(id);
|
|
27
|
+
if (wasParked) for (const listener of this.#parkedListeners) listener(session);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
#nextParkStamp() {
|
|
31
|
+
this.#lastParkStamp = Math.max(Date.now(), this.#lastParkStamp + 1);
|
|
32
|
+
return this.#lastParkStamp;
|
|
33
|
+
}
|
|
34
|
+
#track(session) {
|
|
35
|
+
const suspendedAt = /* @__PURE__ */ new Map();
|
|
36
|
+
const unsubscribe = session.subscribe((event) => {
|
|
37
|
+
if (event.type === "tool_suspended") suspendedAt.set(event.toolCallId, this.#nextParkStamp());
|
|
38
|
+
else if (event.type === "tool_suspension_cancelled") suspendedAt.delete(event.toolCallId);
|
|
39
|
+
else if (event.type === "agent_end" && event.reason !== "suspended") suspendedAt.clear();
|
|
40
|
+
else return;
|
|
41
|
+
for (const listener of this.#parkedListeners) listener(session);
|
|
42
|
+
});
|
|
43
|
+
this.#byId.set(session.identity.getId(), {
|
|
44
|
+
session,
|
|
45
|
+
seenAt: Date.now(),
|
|
46
|
+
suspendedAt,
|
|
47
|
+
unsubscribe
|
|
48
|
+
});
|
|
19
49
|
}
|
|
20
50
|
/** Whether the session has an agent run in flight right now. */
|
|
21
51
|
isRunning(sessionId) {
|
|
22
|
-
return this.#byId.get(sessionId)?.run.isRunning() ?? false;
|
|
52
|
+
return this.#byId.get(sessionId)?.session.run.isRunning() ?? false;
|
|
53
|
+
}
|
|
54
|
+
/** The tool the session is parked on, oldest first, or nothing when no answer is owed. */
|
|
55
|
+
parked(sessionId) {
|
|
56
|
+
const tracked = this.#byId.get(sessionId);
|
|
57
|
+
if (!tracked) return void 0;
|
|
58
|
+
let oldest;
|
|
59
|
+
for (const [toolCallId, { toolName }] of tracked.session.displayState.get().pendingSuspensions) {
|
|
60
|
+
const suspendedAt = tracked.suspendedAt.get(toolCallId) ?? tracked.seenAt;
|
|
61
|
+
if (!oldest || suspendedAt < oldest.suspendedAt) oldest = {
|
|
62
|
+
toolName,
|
|
63
|
+
suspendedAt
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
return oldest;
|
|
67
|
+
}
|
|
68
|
+
/** Every parked session of a project, so the inbox reads no card when nothing waits. */
|
|
69
|
+
parkedIn(factoryProjectId) {
|
|
70
|
+
const parked = [];
|
|
71
|
+
for (const [sessionId, tracked] of this.#byId) {
|
|
72
|
+
if (tracked.session.state.get().factoryProjectId !== factoryProjectId) continue;
|
|
73
|
+
const run = this.parked(sessionId);
|
|
74
|
+
if (run) parked.push({
|
|
75
|
+
sessionId,
|
|
76
|
+
run
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return parked;
|
|
80
|
+
}
|
|
81
|
+
/** Fires when a session parks, is answered, or finishes a turn: whoever shows parked runs re-reads. */
|
|
82
|
+
onParkedChanged(listener) {
|
|
83
|
+
this.#parkedListeners.add(listener);
|
|
84
|
+
return () => this.#parkedListeners.delete(listener);
|
|
23
85
|
}
|
|
24
86
|
};
|
|
25
87
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"live-sessions.js","names":["#byId"],"sources":["../../src/session/live-sessions.ts"],"sourcesContent":["/** The slice of a live session this registry needs: its id, and
|
|
1
|
+
{"version":3,"file":"live-sessions.js","names":["#byId","#parkedListeners","#track","#lastParkStamp","#nextParkStamp"],"sources":["../../src/session/live-sessions.ts"],"sourcesContent":["import type { AgentControllerEvent } from '@mastra/core/agent-controller';\n\n/** The slice of a live session this registry needs: its id, its run, its parked tools, and who it works for. */\nexport interface LiveSession {\n readonly identity: { getId(): string };\n readonly run: { isRunning(): boolean };\n readonly state: { get(): Readonly<{ factoryOrgId?: string; factoryProjectId?: string }> };\n readonly displayState: { get(): { pendingSuspensions: ReadonlyMap<string, { toolName: string }> } };\n subscribe(listener: (event: AgentControllerEvent) => void): () => void;\n}\n\ninterface SessionNotifier {\n onSessionCreated(listener: (session: LiveSession) => void): () => void;\n onSessionDeleted(listener: (session: LiveSession) => void): () => void;\n}\n\n/** The tool a session has waited on longest, and since when (epoch ms). */\nexport interface ParkedRun {\n toolName: string;\n suspendedAt: number;\n}\n\ninterface TrackedSession {\n session: LiveSession;\n seenAt: number;\n suspendedAt: Map<string, number>;\n unsubscribe: () => void;\n}\n\n/**\n * The sessions this process has materialized, by session id.\n *\n * Membership comes from the controller's notifications rather than\n * `getSessionByResource`, which hands back the pending creation — awaiting it\n * from a request blocks for as long as the session takes to materialize its\n * sandbox, minutes on a cold clone. Notifications only fire once a session\n * exists, so a read never waits.\n *\n * Whether a session is *running* or *parked* is read from the session itself,\n * never tracked here: no missed run event can leave the answer stuck. Only the\n * moment each suspension arrived is kept, since the session does not date them.\n */\nexport class LiveSessions {\n readonly #byId = new Map<string, TrackedSession>();\n readonly #parkedListeners = new Set<(session: LiveSession) => void>();\n /** A park stamp doubles as the receipt key, so two suspensions in one millisecond must not share one. */\n #lastParkStamp = 0;\n\n constructor(controller: SessionNotifier) {\n controller.onSessionCreated(session => this.#track(session));\n controller.onSessionDeleted(session => {\n const id = session.identity.getId();\n const wasParked = this.parked(id) !== undefined;\n this.#byId.get(id)?.unsubscribe();\n this.#byId.delete(id);\n if (wasParked) for (const listener of this.#parkedListeners) listener(session);\n });\n }\n\n #nextParkStamp(): number {\n this.#lastParkStamp = Math.max(Date.now(), this.#lastParkStamp + 1);\n return this.#lastParkStamp;\n }\n\n #track(session: LiveSession): void {\n const suspendedAt = new Map<string, number>();\n const unsubscribe = session.subscribe(event => {\n if (event.type === 'tool_suspended') suspendedAt.set(event.toolCallId, this.#nextParkStamp());\n else if (event.type === 'tool_suspension_cancelled') suspendedAt.delete(event.toolCallId);\n else if (event.type === 'agent_end' && event.reason !== 'suspended') suspendedAt.clear();\n else return;\n for (const listener of this.#parkedListeners) listener(session);\n });\n this.#byId.set(session.identity.getId(), { session, seenAt: Date.now(), suspendedAt, unsubscribe });\n }\n\n /** Whether the session has an agent run in flight right now. */\n isRunning(sessionId: string): boolean {\n return this.#byId.get(sessionId)?.session.run.isRunning() ?? false;\n }\n\n /** The tool the session is parked on, oldest first, or nothing when no answer is owed. */\n parked(sessionId: string): ParkedRun | undefined {\n const tracked = this.#byId.get(sessionId);\n if (!tracked) return undefined;\n let oldest: ParkedRun | undefined;\n for (const [toolCallId, { toolName }] of tracked.session.displayState.get().pendingSuspensions) {\n const suspendedAt = tracked.suspendedAt.get(toolCallId) ?? tracked.seenAt;\n if (!oldest || suspendedAt < oldest.suspendedAt) oldest = { toolName, suspendedAt };\n }\n return oldest;\n }\n\n /** Every parked session of a project, so the inbox reads no card when nothing waits. */\n parkedIn(factoryProjectId: string): Array<{ sessionId: string; run: ParkedRun }> {\n const parked: Array<{ sessionId: string; run: ParkedRun }> = [];\n for (const [sessionId, tracked] of this.#byId) {\n if (tracked.session.state.get().factoryProjectId !== factoryProjectId) continue;\n const run = this.parked(sessionId);\n if (run) parked.push({ sessionId, run });\n }\n return parked;\n }\n\n /** Fires when a session parks, is answered, or finishes a turn: whoever shows parked runs re-reads. */\n onParkedChanged(listener: (session: LiveSession) => void): () => void {\n this.#parkedListeners.add(listener);\n return () => this.#parkedListeners.delete(listener);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AA0CA,IAAa,eAAb,MAA0B;CACxB,wBAAiB,IAAI,IAA4B;CACjD,mCAA4B,IAAI,IAAoC;;CAEpE,iBAAiB;CAEjB,YAAY,YAA6B;EACvC,WAAW,kBAAiB,YAAW,KAAKE,OAAO,OAAO,CAAC;EAC3D,WAAW,kBAAiB,YAAW;GACrC,MAAM,KAAK,QAAQ,SAAS,MAAM;GAClC,MAAM,YAAY,KAAK,OAAO,EAAE,MAAM,KAAA;GACtC,KAAKF,MAAM,IAAI,EAAE,CAAC,EAAE,YAAY;GAChC,KAAKA,MAAM,OAAO,EAAE;GACpB,IAAI,WAAW,KAAK,MAAM,YAAY,KAAKC,kBAAkB,SAAS,OAAO;EAC/E,CAAC;CACH;CAEA,iBAAyB;EACvB,KAAKE,iBAAiB,KAAK,IAAI,KAAK,IAAI,GAAG,KAAKA,iBAAiB,CAAC;EAClE,OAAO,KAAKA;CACd;CAEA,OAAO,SAA4B;EACjC,MAAM,8BAAc,IAAI,IAAoB;EAC5C,MAAM,cAAc,QAAQ,WAAU,UAAS;GAC7C,IAAI,MAAM,SAAS,kBAAkB,YAAY,IAAI,MAAM,YAAY,KAAKC,eAAe,CAAC;QACvF,IAAI,MAAM,SAAS,6BAA6B,YAAY,OAAO,MAAM,UAAU;QACnF,IAAI,MAAM,SAAS,eAAe,MAAM,WAAW,aAAa,YAAY,MAAM;QAClF;GACL,KAAK,MAAM,YAAY,KAAKH,kBAAkB,SAAS,OAAO;EAChE,CAAC;EACD,KAAKD,MAAM,IAAI,QAAQ,SAAS,MAAM,GAAG;GAAE;GAAS,QAAQ,KAAK,IAAI;GAAG;GAAa;EAAY,CAAC;CACpG;;CAGA,UAAU,WAA4B;EACpC,OAAO,KAAKA,MAAM,IAAI,SAAS,CAAC,EAAE,QAAQ,IAAI,UAAU,KAAK;CAC/D;;CAGA,OAAO,WAA0C;EAC/C,MAAM,UAAU,KAAKA,MAAM,IAAI,SAAS;EACxC,IAAI,CAAC,SAAS,OAAO,KAAA;EACrB,IAAI;EACJ,KAAK,MAAM,CAAC,YAAY,EAAE,eAAe,QAAQ,QAAQ,aAAa,IAAI,CAAC,CAAC,oBAAoB;GAC9F,MAAM,cAAc,QAAQ,YAAY,IAAI,UAAU,KAAK,QAAQ;GACnE,IAAI,CAAC,UAAU,cAAc,OAAO,aAAa,SAAS;IAAE;IAAU;GAAY;EACpF;EACA,OAAO;CACT;;CAGA,SAAS,kBAAwE;EAC/E,MAAM,SAAuD,CAAC;EAC9D,KAAK,MAAM,CAAC,WAAW,YAAY,KAAKA,OAAO;GAC7C,IAAI,QAAQ,QAAQ,MAAM,IAAI,CAAC,CAAC,qBAAqB,kBAAkB;GACvE,MAAM,MAAM,KAAK,OAAO,SAAS;GACjC,IAAI,KAAK,OAAO,KAAK;IAAE;IAAW;GAAI,CAAC;EACzC;EACA,OAAO;CACT;;CAGA,gBAAgB,UAAsD;EACpE,KAAKC,iBAAiB,IAAI,QAAQ;EAClC,aAAa,KAAKA,iBAAiB,OAAO,QAAQ;CACpD;AACF"}
|
|
@@ -28,7 +28,32 @@ export interface IntakeSourceBinding {
|
|
|
28
28
|
integrationId: string;
|
|
29
29
|
sourceId: string;
|
|
30
30
|
factoryProjectId: string;
|
|
31
|
+
/** Installed board the source feeds, or `null` for legacy source-type routing. */
|
|
32
|
+
board: string | null;
|
|
31
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Routes items carrying a label to an installed board, per Factory project.
|
|
36
|
+
*
|
|
37
|
+
* Repository-scoped providers (GitHub) already know which project an item
|
|
38
|
+
* belongs to, but one repository can feed several boards: an issue labelled
|
|
39
|
+
* `release` belongs on a release board while the rest stay on Work. Labels
|
|
40
|
+
* without a route fall back to the provider's built-in board.
|
|
41
|
+
*/
|
|
42
|
+
export declare const INTAKE_LABEL_ROUTES_SCHEMA: CollectionSchema;
|
|
43
|
+
export interface IntakeLabelRoute {
|
|
44
|
+
factoryProjectId: string;
|
|
45
|
+
integrationId: string;
|
|
46
|
+
label: string;
|
|
47
|
+
board: string;
|
|
48
|
+
}
|
|
49
|
+
/** Labels are matched the way GitHub treats them: case-insensitively. */
|
|
50
|
+
export declare function normalizeIntakeLabel(label: string): string;
|
|
51
|
+
/**
|
|
52
|
+
* The board a labelled item should land on under `routes`, or `undefined` when
|
|
53
|
+
* none of its labels is routed. Ties resolve to the first route in `routes`
|
|
54
|
+
* order, so callers should pass a deterministically ordered list.
|
|
55
|
+
*/
|
|
56
|
+
export declare function resolveIntakeLabelRoute(routes: readonly IntakeLabelRoute[], labels: readonly string[] | undefined): IntakeLabelRoute | undefined;
|
|
32
57
|
export declare class IntakeStorage extends FactoryStorageDomain {
|
|
33
58
|
#private;
|
|
34
59
|
constructor();
|
|
@@ -59,17 +84,45 @@ export declare class IntakeStorage extends FactoryStorageDomain {
|
|
|
59
84
|
integrationId: string;
|
|
60
85
|
factoryProjectId: string;
|
|
61
86
|
}): Promise<string[]>;
|
|
87
|
+
/** The binding for one source, or `null` when it is unbound. */
|
|
88
|
+
getBinding({ orgId, integrationId, sourceId, }: {
|
|
89
|
+
orgId: string;
|
|
90
|
+
integrationId: string;
|
|
91
|
+
sourceId: string;
|
|
92
|
+
}): Promise<IntakeSourceBinding | null>;
|
|
62
93
|
clearBinding({ orgId, integrationId, sourceId, }: {
|
|
63
94
|
orgId: string;
|
|
64
95
|
integrationId: string;
|
|
65
96
|
sourceId: string;
|
|
66
97
|
}): Promise<IntakeSourceBinding | null>;
|
|
67
|
-
setBinding({ orgId, integrationId, sourceId, factoryProjectId, userId, }: {
|
|
98
|
+
setBinding({ orgId, integrationId, sourceId, factoryProjectId, board, userId, }: {
|
|
68
99
|
orgId: string;
|
|
69
100
|
integrationId: string;
|
|
70
101
|
sourceId: string;
|
|
71
102
|
factoryProjectId: string;
|
|
103
|
+
board?: string | null;
|
|
72
104
|
userId?: string;
|
|
73
105
|
}): Promise<void>;
|
|
106
|
+
/** Label routes in the org, optionally narrowed to one project and/or integration. Sorted by label. */
|
|
107
|
+
listLabelRoutes({ orgId, factoryProjectId, integrationId, }: {
|
|
108
|
+
orgId: string;
|
|
109
|
+
factoryProjectId?: string;
|
|
110
|
+
integrationId?: string;
|
|
111
|
+
}): Promise<IntakeLabelRoute[]>;
|
|
112
|
+
setLabelRoute({ orgId, factoryProjectId, integrationId, label, board, userId, }: {
|
|
113
|
+
orgId: string;
|
|
114
|
+
factoryProjectId: string;
|
|
115
|
+
integrationId: string;
|
|
116
|
+
label: string;
|
|
117
|
+
board: string;
|
|
118
|
+
userId?: string;
|
|
119
|
+
}): Promise<void>;
|
|
120
|
+
/** Remove a label route; returns the route that was removed, or `null` when none existed. */
|
|
121
|
+
clearLabelRoute({ orgId, factoryProjectId, integrationId, label, }: {
|
|
122
|
+
orgId: string;
|
|
123
|
+
factoryProjectId: string;
|
|
124
|
+
integrationId: string;
|
|
125
|
+
label: string;
|
|
126
|
+
}): Promise<IntakeLabelRoute | null>;
|
|
74
127
|
}
|
|
75
128
|
//# sourceMappingURL=base.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/intake/base.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,oBAAoB,EAAwB,MAAM,sBAAsB,CAAC;AAClF,OAAO,KAAK,EAAE,gBAAgB,EAAqB,MAAM,sBAAsB,CAAC;AAEhF,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,mEAAmE;IACnE,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;CAC5B;AAED,MAA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