@mastra/factory 0.29.0-alpha.0 → 0.29.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -4
- package/dist/board-changes.d.ts +16 -0
- package/dist/board-changes.d.ts.map +1 -0
- package/dist/board-changes.js +40 -0
- package/dist/board-changes.js.map +1 -0
- package/dist/boards/index.js +2 -1
- package/dist/boards/semantics.d.ts +1 -3
- package/dist/boards/semantics.d.ts.map +1 -1
- package/dist/boards/semantics.js +1 -5
- package/dist/boards/semantics.js.map +1 -1
- package/dist/factory.d.ts +4 -0
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +51 -3
- package/dist/factory.js.map +1 -1
- package/dist/integrations/base.d.ts +9 -0
- package/dist/integrations/base.d.ts.map +1 -1
- package/dist/integrations/github/pull-request-source.js +2 -1
- package/dist/integrations/github/pull-request-source.js.map +1 -1
- package/dist/integrations/github/reconcile-worker.js +1 -1
- package/dist/integrations/github/reconcile-worker.js.map +1 -1
- package/dist/integrations/github/rules.d.ts +5 -2
- package/dist/integrations/github/rules.d.ts.map +1 -1
- package/dist/integrations/github/rules.js +16 -13
- package/dist/integrations/github/rules.js.map +1 -1
- package/dist/integrations/github/sandbox.js +2 -2
- package/dist/integrations/github/sandbox.js.map +1 -1
- package/dist/integrations/gitlab/default-rules.js +2 -1
- package/dist/integrations/gitlab/default-rules.js.map +1 -1
- package/dist/integrations/gitlab/discovery.d.ts +16 -0
- package/dist/integrations/gitlab/discovery.d.ts.map +1 -0
- package/dist/integrations/gitlab/discovery.js +107 -0
- package/dist/integrations/gitlab/discovery.js.map +1 -0
- package/dist/integrations/gitlab/integration.d.ts.map +1 -1
- package/dist/integrations/gitlab/integration.js +1 -2
- package/dist/integrations/gitlab/integration.js.map +1 -1
- package/dist/integrations/gitlab/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/gitlab/issue-reconciler.js +1 -0
- package/dist/integrations/gitlab/issue-reconciler.js.map +1 -1
- package/dist/integrations/gitlab/merge-request-reconciler.d.ts.map +1 -1
- package/dist/integrations/gitlab/merge-request-reconciler.js +26 -10
- package/dist/integrations/gitlab/merge-request-reconciler.js.map +1 -1
- package/dist/integrations/gitlab/reconciler.d.ts.map +1 -1
- package/dist/integrations/gitlab/reconciler.js +4 -2
- package/dist/integrations/gitlab/reconciler.js.map +1 -1
- package/dist/integrations/gitlab/reconciliation-config.d.ts +0 -1
- package/dist/integrations/gitlab/reconciliation-config.d.ts.map +1 -1
- package/dist/integrations/gitlab/reconciliation-config.js +2 -8
- package/dist/integrations/gitlab/reconciliation-config.js.map +1 -1
- package/dist/integrations/gitlab/routes.d.ts +17 -0
- package/dist/integrations/gitlab/routes.d.ts.map +1 -1
- package/dist/integrations/gitlab/routes.js +28 -22
- package/dist/integrations/gitlab/routes.js.map +1 -1
- package/dist/integrations/gitlab/rules.d.ts +10 -4
- package/dist/integrations/gitlab/rules.d.ts.map +1 -1
- package/dist/integrations/gitlab/rules.js +32 -8
- package/dist/integrations/gitlab/rules.js.map +1 -1
- package/dist/integrations/incidentio/integration.d.ts +2 -1
- package/dist/integrations/incidentio/integration.d.ts.map +1 -1
- package/dist/integrations/incidentio/integration.js +7 -7
- package/dist/integrations/incidentio/integration.js.map +1 -1
- package/dist/integrations/incidentio/issue-reconciler.d.ts +7 -0
- package/dist/integrations/incidentio/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/incidentio/issue-reconciler.js +36 -1
- package/dist/integrations/incidentio/issue-reconciler.js.map +1 -1
- package/dist/integrations/incidentio/reconciliation-config.d.ts +0 -1
- package/dist/integrations/incidentio/reconciliation-config.d.ts.map +1 -1
- package/dist/integrations/incidentio/reconciliation-config.js +2 -5
- package/dist/integrations/incidentio/reconciliation-config.js.map +1 -1
- package/dist/integrations/incidentio/routes.d.ts +24 -8
- package/dist/integrations/incidentio/routes.d.ts.map +1 -1
- package/dist/integrations/incidentio/routes.js +33 -35
- package/dist/integrations/incidentio/routes.js.map +1 -1
- package/dist/integrations/incidentio/rules.d.ts +0 -4
- package/dist/integrations/incidentio/rules.d.ts.map +1 -1
- package/dist/integrations/incidentio/rules.js +17 -14
- package/dist/integrations/incidentio/rules.js.map +1 -1
- package/dist/integrations/intake-discovery.d.ts +44 -0
- package/dist/integrations/intake-discovery.d.ts.map +1 -0
- package/dist/integrations/intake-discovery.js +60 -0
- package/dist/integrations/intake-discovery.js.map +1 -0
- package/dist/integrations/issue-reconcile-worker.js +1 -1
- package/dist/integrations/issue-reconcile-worker.js.map +1 -1
- package/dist/integrations/issue-reconciler.d.ts +7 -0
- package/dist/integrations/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/issue-reconciler.js +47 -12
- package/dist/integrations/issue-reconciler.js.map +1 -1
- package/dist/integrations/jira/integration.d.ts +3 -2
- package/dist/integrations/jira/integration.d.ts.map +1 -1
- package/dist/integrations/jira/integration.js +5 -7
- package/dist/integrations/jira/integration.js.map +1 -1
- package/dist/integrations/jira/issue-reconciler.d.ts +17 -1
- package/dist/integrations/jira/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/jira/issue-reconciler.js +34 -1
- package/dist/integrations/jira/issue-reconciler.js.map +1 -1
- package/dist/integrations/jira/reconciliation-config.d.ts +0 -1
- package/dist/integrations/jira/reconciliation-config.d.ts.map +1 -1
- package/dist/integrations/jira/reconciliation-config.js +2 -5
- package/dist/integrations/jira/reconciliation-config.js.map +1 -1
- package/dist/integrations/jira/routes.d.ts +0 -7
- package/dist/integrations/jira/routes.d.ts.map +1 -1
- package/dist/integrations/jira/routes.js +2 -12
- package/dist/integrations/jira/routes.js.map +1 -1
- package/dist/integrations/jira/rules.d.ts +0 -4
- package/dist/integrations/jira/rules.d.ts.map +1 -1
- package/dist/integrations/jira/rules.js +3 -13
- package/dist/integrations/jira/rules.js.map +1 -1
- package/dist/integrations/kept-cards.d.ts +49 -0
- package/dist/integrations/kept-cards.d.ts.map +1 -0
- package/dist/integrations/kept-cards.js +97 -0
- package/dist/integrations/kept-cards.js.map +1 -0
- package/dist/integrations/linear/intake-discovery.d.ts +34 -0
- package/dist/integrations/linear/intake-discovery.d.ts.map +1 -0
- package/dist/integrations/linear/intake-discovery.js +112 -0
- package/dist/integrations/linear/intake-discovery.js.map +1 -0
- package/dist/integrations/linear/integration.d.ts.map +1 -1
- package/dist/integrations/linear/integration.js +1 -4
- package/dist/integrations/linear/integration.js.map +1 -1
- package/dist/integrations/linear/issue-reconciler.d.ts +13 -4
- package/dist/integrations/linear/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/linear/issue-reconciler.js +24 -20
- package/dist/integrations/linear/issue-reconciler.js.map +1 -1
- package/dist/integrations/linear/reconciliation-config.d.ts +0 -1
- package/dist/integrations/linear/reconciliation-config.d.ts.map +1 -1
- package/dist/integrations/linear/reconciliation-config.js +2 -8
- package/dist/integrations/linear/reconciliation-config.js.map +1 -1
- package/dist/integrations/linear/routes.d.ts +0 -2
- package/dist/integrations/linear/routes.d.ts.map +1 -1
- package/dist/integrations/linear/routes.js +3 -9
- package/dist/integrations/linear/routes.js.map +1 -1
- package/dist/integrations/platform/api-client.d.ts +2 -0
- package/dist/integrations/platform/api-client.d.ts.map +1 -1
- package/dist/integrations/platform/api-client.js +6 -1
- package/dist/integrations/platform/api-client.js.map +1 -1
- package/dist/integrations/platform/connect/routes.js +4 -1
- package/dist/integrations/platform/connect/routes.js.map +1 -1
- package/dist/integrations/platform/github/event-worker.d.ts +12 -0
- package/dist/integrations/platform/github/event-worker.d.ts.map +1 -1
- package/dist/integrations/platform/github/event-worker.js +56 -5
- package/dist/integrations/platform/github/event-worker.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 +8 -3
- package/dist/integrations/platform/github/integration.js.map +1 -1
- package/dist/integrations/platform/gitlab/event-worker.js +1 -1
- package/dist/integrations/platform/gitlab/event-worker.js.map +1 -1
- package/dist/integrations/platform/incidentio/integration.d.ts +3 -2
- package/dist/integrations/platform/incidentio/integration.d.ts.map +1 -1
- package/dist/integrations/platform/incidentio/integration.js +7 -7
- package/dist/integrations/platform/incidentio/integration.js.map +1 -1
- package/dist/integrations/platform/jira/integration.d.ts.map +1 -1
- package/dist/integrations/platform/jira/integration.js +4 -7
- package/dist/integrations/platform/jira/integration.js.map +1 -1
- package/dist/integrations/platform/jira/routes.d.ts +0 -7
- package/dist/integrations/platform/jira/routes.d.ts.map +1 -1
- package/dist/integrations/platform/jira/routes.js +2 -12
- package/dist/integrations/platform/jira/routes.js.map +1 -1
- package/dist/integrations/platform/linear/event-worker.d.ts +2 -2
- package/dist/integrations/platform/linear/event-worker.d.ts.map +1 -1
- package/dist/integrations/platform/linear/event-worker.js +1 -1
- package/dist/integrations/platform/linear/event-worker.js.map +1 -1
- package/dist/integrations/platform/linear/integration.d.ts +1 -0
- package/dist/integrations/platform/linear/integration.d.ts.map +1 -1
- package/dist/integrations/platform/linear/integration.js +7 -7
- package/dist/integrations/platform/linear/integration.js.map +1 -1
- package/dist/integrations/platform/vanta/integration.d.ts +7 -2
- package/dist/integrations/platform/vanta/integration.d.ts.map +1 -1
- package/dist/integrations/platform/vanta/integration.js +22 -6
- package/dist/integrations/platform/vanta/integration.js.map +1 -1
- package/dist/integrations/reconciliation-config.d.ts +0 -1
- package/dist/integrations/reconciliation-config.d.ts.map +1 -1
- package/dist/integrations/reconciliation-config.js +1 -8
- package/dist/integrations/reconciliation-config.js.map +1 -1
- package/dist/integrations/slack/channel-reply-processor.js +1 -1
- package/dist/integrations/slack/channel-reply-processor.js.map +1 -1
- package/dist/integrations/startup-summary.d.ts +8 -0
- package/dist/integrations/startup-summary.d.ts.map +1 -0
- package/dist/integrations/startup-summary.js +36 -0
- package/dist/integrations/startup-summary.js.map +1 -0
- package/dist/integrations/vanta/sync.d.ts +9 -5
- package/dist/integrations/vanta/sync.d.ts.map +1 -1
- package/dist/integrations/vanta/sync.js +16 -8
- package/dist/integrations/vanta/sync.js.map +1 -1
- package/dist/linked-repositories-changed.d.ts +14 -0
- package/dist/linked-repositories-changed.d.ts.map +1 -0
- package/dist/linked-repositories-changed.js +48 -0
- package/dist/linked-repositories-changed.js.map +1 -0
- package/dist/routes/contracts.d.ts +117 -0
- package/dist/routes/contracts.d.ts.map +1 -1
- package/dist/routes/contracts.js +44 -1
- package/dist/routes/contracts.js.map +1 -1
- package/dist/routes/run-queue.d.ts +17 -0
- package/dist/routes/run-queue.d.ts.map +1 -0
- package/dist/routes/run-queue.js +69 -0
- package/dist/routes/run-queue.js.map +1 -0
- package/dist/routes/surface.d.ts +8 -0
- package/dist/routes/surface.d.ts.map +1 -1
- package/dist/routes/surface.js +4 -2
- package/dist/routes/surface.js.map +1 -1
- package/dist/routes/work-item-selection.d.ts +4 -1
- package/dist/routes/work-item-selection.d.ts.map +1 -1
- package/dist/routes/work-item-selection.js +7 -2
- package/dist/routes/work-item-selection.js.map +1 -1
- package/dist/routes/work-items.d.ts +5 -0
- package/dist/routes/work-items.d.ts.map +1 -1
- package/dist/routes/work-items.js +17 -0
- package/dist/routes/work-items.js.map +1 -1
- package/dist/rules/dispatcher.d.ts +13 -1
- package/dist/rules/dispatcher.d.ts.map +1 -1
- package/dist/rules/dispatcher.js +9 -2
- package/dist/rules/dispatcher.js.map +1 -1
- package/dist/rules/review-source-tool.js +2 -1
- package/dist/rules/review-source-tool.js.map +1 -1
- package/dist/rules/types.d.ts +2 -2
- package/dist/rules/types.d.ts.map +1 -1
- package/dist/rules/types.js +4 -1
- package/dist/rules/types.js.map +1 -1
- package/dist/rules/validation.d.ts.map +1 -1
- package/dist/rules/validation.js +1 -0
- package/dist/rules/validation.js.map +1 -1
- package/dist/storage/domains/projects/base.d.ts +2 -0
- package/dist/storage/domains/projects/base.d.ts.map +1 -1
- package/dist/storage/domains/projects/base.js +13 -1
- package/dist/storage/domains/projects/base.js.map +1 -1
- package/dist/storage/domains/source-control/base.d.ts +32 -0
- package/dist/storage/domains/source-control/base.d.ts.map +1 -1
- package/dist/storage/domains/source-control/base.js +54 -4
- package/dist/storage/domains/source-control/base.js.map +1 -1
- package/dist/storage/domains/source-control/inmemory.d.ts +3 -0
- package/dist/storage/domains/source-control/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/source-control/inmemory.js +17 -0
- package/dist/storage/domains/source-control/inmemory.js.map +1 -1
- package/dist/storage/domains/work-items/base.d.ts +1 -0
- package/dist/storage/domains/work-items/base.d.ts.map +1 -1
- package/dist/storage/domains/work-items/base.js +10 -1
- package/dist/storage/domains/work-items/base.js.map +1 -1
- package/dist/timing.d.ts +8 -1
- package/dist/timing.d.ts.map +1 -1
- package/dist/timing.js +10 -2
- package/dist/timing.js.map +1 -1
- package/dist/work-item-branch.d.ts +1 -1
- package/dist/work-item-branch.d.ts.map +1 -1
- package/dist/work-item-branch.js +1 -0
- package/dist/work-item-branch.js.map +1 -1
- package/dist/work-items/source-external-id.d.ts +4 -0
- package/dist/work-items/source-external-id.d.ts.map +1 -0
- package/dist/work-items/source-external-id.js +9 -0
- package/dist/work-items/source-external-id.js.map +1 -0
- package/package.json +9 -9
package/dist/timing.d.ts
CHANGED
|
@@ -11,6 +11,13 @@ import type { Context } from 'hono';
|
|
|
11
11
|
* commands). Off by default; enable per deployment with `FACTORY_TIMING=1`.
|
|
12
12
|
*/
|
|
13
13
|
export declare const factoryTimingEnabled: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Boot diagnostics (phase timings, integration config) are on by default so
|
|
16
|
+
* slow or misconfigured deployed boots stay visible. `mastra factory dev`
|
|
17
|
+
* (`MASTRA_FACTORY_DEV=true`) keeps first boot quiet unless run with
|
|
18
|
+
* `--debug` (`MASTRA_FACTORY_DEBUG=true`) or `FACTORY_TIMING` is set.
|
|
19
|
+
*/
|
|
20
|
+
export declare const bootDiagnosticsEnabled: boolean;
|
|
14
21
|
export declare function logTiming(line: string): void;
|
|
15
22
|
/** Run `fn`, logging its duration only when `FACTORY_TIMING` is enabled. */
|
|
16
23
|
export declare function timed<T>(phase: string, fn: () => Promise<T>): Promise<T>;
|
|
@@ -29,7 +36,7 @@ export declare function instrumentMethods<T extends object>(target: T, label: st
|
|
|
29
36
|
* when timing is disabled.
|
|
30
37
|
*/
|
|
31
38
|
export declare function instrumentAsyncMethods<T extends object>(target: T, label: string): T;
|
|
32
|
-
/** Run `fn`,
|
|
39
|
+
/** Run `fn`, logging its duration under `phase` when `bootDiagnosticsEnabled`. Boot-phase use. */
|
|
33
40
|
export declare function timedPhase<T>(phase: string, fn: () => Promise<T>): Promise<T>;
|
|
34
41
|
/**
|
|
35
42
|
* Run `fn`, logging only when it exceeds `thresholdMs`. Request-path use,
|
package/dist/timing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timing.d.ts","sourceRoot":"","sources":["../src/timing.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC;;;GAGG;AACH,eAAO,MAAM,oBAAoB,SAA2D,CAAC;AAE7F,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAE5C;AAED,4EAA4E;AAC5E,wBAAsB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAQ9E;AAED,kFAAkF;AAClF,wBAAgB,6BAA6B,QAC1B,OAAO,QAAQ,MAAM,OAAO,CAAC,IAAI,CAAC,KAAG,OAAO,CAAC,IAAI,CAAC,CAQpE;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,CAAC,CAgB3G;AAmBD;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,MAAM,EA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AE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAUjH"}
|
package/dist/timing.js
CHANGED
|
@@ -4,6 +4,13 @@
|
|
|
4
4
|
* commands). Off by default; enable per deployment with `FACTORY_TIMING=1`.
|
|
5
5
|
*/
|
|
6
6
|
const factoryTimingEnabled = /^(1|true|yes)$/i.test(process.env.FACTORY_TIMING ?? "");
|
|
7
|
+
/**
|
|
8
|
+
* Boot diagnostics (phase timings, integration config) are on by default so
|
|
9
|
+
* slow or misconfigured deployed boots stay visible. `mastra factory dev`
|
|
10
|
+
* (`MASTRA_FACTORY_DEV=true`) keeps first boot quiet unless run with
|
|
11
|
+
* `--debug` (`MASTRA_FACTORY_DEBUG=true`) or `FACTORY_TIMING` is set.
|
|
12
|
+
*/
|
|
13
|
+
const bootDiagnosticsEnabled = factoryTimingEnabled || process.env.MASTRA_FACTORY_DEV !== "true" || /^(1|true)$/i.test(process.env.MASTRA_FACTORY_DEBUG ?? "");
|
|
7
14
|
function logTiming(line) {
|
|
8
15
|
process.stderr.write(`[factory:timing] ${line}\n`);
|
|
9
16
|
}
|
|
@@ -85,8 +92,9 @@ function instrumentAsyncMethods(target, label) {
|
|
|
85
92
|
return fn;
|
|
86
93
|
} });
|
|
87
94
|
}
|
|
88
|
-
/** Run `fn`,
|
|
95
|
+
/** Run `fn`, logging its duration under `phase` when `bootDiagnosticsEnabled`. Boot-phase use. */
|
|
89
96
|
async function timedPhase(phase, fn) {
|
|
97
|
+
if (!bootDiagnosticsEnabled) return fn();
|
|
90
98
|
const start = performance.now();
|
|
91
99
|
try {
|
|
92
100
|
return await fn();
|
|
@@ -107,6 +115,6 @@ async function timedAboveThreshold(phase, thresholdMs, fn) {
|
|
|
107
115
|
if (elapsed > thresholdMs) process.stderr.write(`[factory:timing] slow ${phase} ${Math.round(elapsed)}ms\n`);
|
|
108
116
|
}
|
|
109
117
|
}
|
|
110
|
-
export { createRequestTimingMiddleware, factoryTimingEnabled, instrumentAsyncMethods, instrumentMethods, logTiming, timed, timedAboveThreshold, timedPhase };
|
|
118
|
+
export { bootDiagnosticsEnabled, createRequestTimingMiddleware, factoryTimingEnabled, instrumentAsyncMethods, instrumentMethods, logTiming, timed, timedAboveThreshold, timedPhase };
|
|
111
119
|
|
|
112
120
|
//# sourceMappingURL=timing.js.map
|
package/dist/timing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timing.js","names":[],"sources":["../src/timing.ts"],"sourcesContent":["/**\n * Lightweight phase timing for factory boot and hot request paths.\n *\n * Deliberately not a metrics framework: structured stderr lines that can be\n * grepped (`[factory:timing]`) and diffed across runs to localize slow boot\n * phases and slow per-request dependencies.\n */\n\nimport type { Context } from 'hono';\n\n/**\n * Verbose per-operation timing (HTTP requests, storage calls, sandbox\n * commands). Off by default; enable per deployment with `FACTORY_TIMING=1`.\n */\nexport const factoryTimingEnabled = /^(1|true|yes)$/i.test(process.env.FACTORY_TIMING ?? '');\n\nexport function logTiming(line: string): void {\n process.stderr.write(`[factory:timing] ${line}\\n`);\n}\n\n/** Run `fn`, logging its duration only when `FACTORY_TIMING` is enabled. */\nexport async function timed<T>(phase: string, fn: () => Promise<T>): Promise<T> {\n if (!factoryTimingEnabled) return fn();\n const start = performance.now();\n try {\n return await fn();\n } finally {\n logTiming(`${phase} ${Math.round(performance.now() - start)}ms`);\n }\n}\n\n/** Hono middleware logging method, path, status, and duration of each request. */\nexport function createRequestTimingMiddleware() {\n return async (c: Context, next: () => Promise<void>): Promise<void> => {\n const start = performance.now();\n try {\n await next();\n } finally {\n logTiming(`http ${c.req.method} ${c.req.path} ${c.res.status} ${Math.round(performance.now() - start)}ms`);\n }\n };\n}\n\n/**\n * Patch `methods` on `target` in place so each call logs `<label>.<method>`\n * duration. In-place (not a Proxy) so object identity is preserved.\n */\nexport function instrumentMethods<T extends object>(target: T, label: string, methods: readonly string[]): T {\n if (!factoryTimingEnabled) return target;\n const record = target as Record<string, unknown>;\n for (const name of methods) {\n const original = record[name];\n if (typeof original !== 'function') continue;\n record[name] = (...args: unknown[]) => {\n const start = performance.now();\n const result = original.apply(target, args);\n if (result instanceof Promise) {\n return result.finally(() => logTiming(`${label}.${name} ${Math.round(performance.now() - start)}ms`));\n }\n return result;\n };\n }\n return target;\n}\n\n/** Every method name on `target`'s prototype chain, excluding `Object.prototype`. */\nfunction prototypeMethodNames(target: object): string[] {\n const names = new Set<string>();\n for (\n let proto = Object.getPrototypeOf(target);\n proto && proto !== Object.prototype;\n proto = Object.getPrototypeOf(proto)\n ) {\n for (const name of Object.getOwnPropertyNames(proto)) {\n if (name === 'constructor') continue;\n const descriptor = Object.getOwnPropertyDescriptor(proto, name);\n if (typeof descriptor?.value === 'function') names.add(name);\n }\n }\n return [...names];\n}\n\n/**\n * Wrap every async method on `target` so each call logs `<label>.<method>`\n * duration. Domains passed to a `registerDomain` method are instrumented in\n * place as `<label>.<domain name>`, so the handle it returns and later\n * `getDomain` lookups are the same timed object. Returns `target` unchanged\n * when timing is disabled.\n */\nexport function instrumentAsyncMethods<T extends object>(target: T, label: string): T {\n if (!factoryTimingEnabled) return target;\n const wrapped = new Map<PropertyKey, unknown>();\n return new Proxy(target, {\n get(obj, prop, receiver) {\n const value = Reflect.get(obj, prop, receiver);\n if (typeof value !== 'function' || typeof prop === 'symbol' || prop === 'constructor') return value;\n const cached = wrapped.get(prop);\n if (cached) return cached;\n const fn = (...args: unknown[]) => {\n const start = performance.now();\n const result = value.apply(obj, args);\n if (prop === 'registerDomain' && result && typeof result === 'object' && !(result instanceof Promise)) {\n const name = (result as { name?: unknown }).name;\n return instrumentMethods(result, `${label}.${String(name)}`, prototypeMethodNames(result));\n }\n if (result instanceof Promise) {\n return result.finally(() => logTiming(`${label}.${prop} ${Math.round(performance.now() - start)}ms`));\n }\n return result;\n };\n wrapped.set(prop, fn);\n return fn;\n },\n });\n}\n\n/** Run `fn`,
|
|
1
|
+
{"version":3,"file":"timing.js","names":[],"sources":["../src/timing.ts"],"sourcesContent":["/**\n * Lightweight phase timing for factory boot and hot request paths.\n *\n * Deliberately not a metrics framework: structured stderr lines that can be\n * grepped (`[factory:timing]`) and diffed across runs to localize slow boot\n * phases and slow per-request dependencies.\n */\n\nimport type { Context } from 'hono';\n\n/**\n * Verbose per-operation timing (HTTP requests, storage calls, sandbox\n * commands). Off by default; enable per deployment with `FACTORY_TIMING=1`.\n */\nexport const factoryTimingEnabled = /^(1|true|yes)$/i.test(process.env.FACTORY_TIMING ?? '');\n\n/**\n * Boot diagnostics (phase timings, integration config) are on by default so\n * slow or misconfigured deployed boots stay visible. `mastra factory dev`\n * (`MASTRA_FACTORY_DEV=true`) keeps first boot quiet unless run with\n * `--debug` (`MASTRA_FACTORY_DEBUG=true`) or `FACTORY_TIMING` is set.\n */\nexport const bootDiagnosticsEnabled =\n factoryTimingEnabled ||\n process.env.MASTRA_FACTORY_DEV !== 'true' ||\n /^(1|true)$/i.test(process.env.MASTRA_FACTORY_DEBUG ?? '');\n\nexport function logTiming(line: string): void {\n process.stderr.write(`[factory:timing] ${line}\\n`);\n}\n\n/** Run `fn`, logging its duration only when `FACTORY_TIMING` is enabled. */\nexport async function timed<T>(phase: string, fn: () => Promise<T>): Promise<T> {\n if (!factoryTimingEnabled) return fn();\n const start = performance.now();\n try {\n return await fn();\n } finally {\n logTiming(`${phase} ${Math.round(performance.now() - start)}ms`);\n }\n}\n\n/** Hono middleware logging method, path, status, and duration of each request. */\nexport function createRequestTimingMiddleware() {\n return async (c: Context, next: () => Promise<void>): Promise<void> => {\n const start = performance.now();\n try {\n await next();\n } finally {\n logTiming(`http ${c.req.method} ${c.req.path} ${c.res.status} ${Math.round(performance.now() - start)}ms`);\n }\n };\n}\n\n/**\n * Patch `methods` on `target` in place so each call logs `<label>.<method>`\n * duration. In-place (not a Proxy) so object identity is preserved.\n */\nexport function instrumentMethods<T extends object>(target: T, label: string, methods: readonly string[]): T {\n if (!factoryTimingEnabled) return target;\n const record = target as Record<string, unknown>;\n for (const name of methods) {\n const original = record[name];\n if (typeof original !== 'function') continue;\n record[name] = (...args: unknown[]) => {\n const start = performance.now();\n const result = original.apply(target, args);\n if (result instanceof Promise) {\n return result.finally(() => logTiming(`${label}.${name} ${Math.round(performance.now() - start)}ms`));\n }\n return result;\n };\n }\n return target;\n}\n\n/** Every method name on `target`'s prototype chain, excluding `Object.prototype`. */\nfunction prototypeMethodNames(target: object): string[] {\n const names = new Set<string>();\n for (\n let proto = Object.getPrototypeOf(target);\n proto && proto !== Object.prototype;\n proto = Object.getPrototypeOf(proto)\n ) {\n for (const name of Object.getOwnPropertyNames(proto)) {\n if (name === 'constructor') continue;\n const descriptor = Object.getOwnPropertyDescriptor(proto, name);\n if (typeof descriptor?.value === 'function') names.add(name);\n }\n }\n return [...names];\n}\n\n/**\n * Wrap every async method on `target` so each call logs `<label>.<method>`\n * duration. Domains passed to a `registerDomain` method are instrumented in\n * place as `<label>.<domain name>`, so the handle it returns and later\n * `getDomain` lookups are the same timed object. Returns `target` unchanged\n * when timing is disabled.\n */\nexport function instrumentAsyncMethods<T extends object>(target: T, label: string): T {\n if (!factoryTimingEnabled) return target;\n const wrapped = new Map<PropertyKey, unknown>();\n return new Proxy(target, {\n get(obj, prop, receiver) {\n const value = Reflect.get(obj, prop, receiver);\n if (typeof value !== 'function' || typeof prop === 'symbol' || prop === 'constructor') return value;\n const cached = wrapped.get(prop);\n if (cached) return cached;\n const fn = (...args: unknown[]) => {\n const start = performance.now();\n const result = value.apply(obj, args);\n if (prop === 'registerDomain' && result && typeof result === 'object' && !(result instanceof Promise)) {\n const name = (result as { name?: unknown }).name;\n return instrumentMethods(result, `${label}.${String(name)}`, prototypeMethodNames(result));\n }\n if (result instanceof Promise) {\n return result.finally(() => logTiming(`${label}.${prop} ${Math.round(performance.now() - start)}ms`));\n }\n return result;\n };\n wrapped.set(prop, fn);\n return fn;\n },\n });\n}\n\n/** Run `fn`, logging its duration under `phase` when `bootDiagnosticsEnabled`. Boot-phase use. */\nexport async function timedPhase<T>(phase: string, fn: () => Promise<T>): Promise<T> {\n if (!bootDiagnosticsEnabled) return fn();\n const start = performance.now();\n try {\n return await fn();\n } finally {\n process.stderr.write(`[factory:timing] ${phase} ${Math.round(performance.now() - start)}ms\\n`);\n }\n}\n\n/**\n * Run `fn`, logging only when it exceeds `thresholdMs`. Request-path use,\n * where per-request logging would be noise but slow outliers must surface.\n */\nexport async function timedAboveThreshold<T>(phase: string, thresholdMs: number, fn: () => Promise<T>): Promise<T> {\n const start = performance.now();\n try {\n return await fn();\n } finally {\n const elapsed = performance.now() - start;\n if (elapsed > thresholdMs) {\n process.stderr.write(`[factory:timing] slow ${phase} ${Math.round(elapsed)}ms\\n`);\n }\n }\n}\n"],"mappings":";;;;;AAcA,MAAa,uBAAuB,kBAAkB,KAAK,QAAQ,IAAI,kBAAkB,EAAE;;;;;;;AAQ3F,MAAa,yBACX,wBACA,QAAQ,IAAI,uBAAuB,UACnC,cAAc,KAAK,QAAQ,IAAI,wBAAwB,EAAE;AAE3D,SAAgB,UAAU,MAAoB;CAC5C,QAAQ,OAAO,MAAM,oBAAoB,KAAK,GAAG;AACnD;;AAGA,eAAsB,MAAS,OAAe,IAAkC;CAC9E,IAAI,CAAC,sBAAsB,OAAO,GAAG;CACrC,MAAM,QAAQ,YAAY,IAAI;CAC9B,IAAI;EACF,OAAO,MAAM,GAAG;CAClB,UAAU;EACR,UAAU,GAAG,MAAM,GAAG,KAAK,MAAM,YAAY,IAAI,IAAI,KAAK,EAAE,GAAG;CACjE;AACF;;AAGA,SAAgB,gCAAgC;CAC9C,OAAO,OAAO,GAAY,SAA6C;EACrE,MAAM,QAAQ,YAAY,IAAI;EAC9B,IAAI;GACF,MAAM,KAAK;EACb,UAAU;GACR,UAAU,QAAQ,EAAE,IAAI,OAAO,GAAG,EAAE,IAAI,KAAK,GAAG,EAAE,IAAI,OAAO,GAAG,KAAK,MAAM,YAAY,IAAI,IAAI,KAAK,EAAE,GAAG;EAC3G;CACF;AACF;;;;;AA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AY,IAAI;GAC9B,MAAM,SAAS,MAAM,MAAM,KAAK,IAAI;GACpC,IAAI,SAAS,oBAAoB,UAAU,OAAO,WAAW,YAAY,EAAE,kBAAkB,UAAU;IACrG,MAAM,OAAQ,OAA8B;IAC5C,OAAO,kBAAkB,QAAQ,GAAG,MAAM,GAAG,OAAO,IAAI,KAAK,qBAAqB,MAAM,CAAC;GAC3F;GACA,IAAI,kBAAkB,SACpB,OAAO,OAAO,cAAc,UAAU,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,MAAM,YAAY,IAAI,IAAI,KAAK,EAAE,GAAG,CAAC;GAEtG,OAAO;EACT;EACA,QAAQ,IAAI,MAAM,EAAE;EACpB,OAAO;CACT,EACF,CAAC;AACH;;AAGA,eAAsB,WAAc,OAAe,IAAkC;CACnF,IAAI,CAAC,wBAAwB,OAAO,GAAG;CACvC,MAAM,QAAQ,YAAY,IAAI;CAC9B,IAAI;EACF,OAAO,MAAM,GAAG;CAClB,UAAU;EACR,QAAQ,OAAO,MAAM,oBAAoB,MAAM,GAAG,KAAK,MAAM,YAAY,IAAI,IAAI,KAAK,EAAE,KAAK;CAC/F;AACF;;;;;AAMA,eAAsB,oBAAuB,OAAe,aAAqB,IAAkC;CACjH,MAAM,QAAQ,YAAY,IAAI;CAC9B,IAAI;EACF,OAAO,MAAM,GAAG;CAClB,UAAU;EACR,MAAM,UAAU,YAAY,IAAI,IAAI;EACpC,IAAI,UAAU,aACZ,QAAQ,OAAO,MAAM,yBAAyB,MAAM,GAAG,KAAK,MAAM,OAAO,EAAE,KAAK;CAEpF;AACF"}
|
|
@@ -4,7 +4,7 @@ import type { ExternalWorkItemSource } from './storage/domains/work-items/base.j
|
|
|
4
4
|
* map their `externalSource` into this with {@link workItemBranchSource}; the
|
|
5
5
|
* board's own `WorkItem['source']` is already this union.
|
|
6
6
|
*/
|
|
7
|
-
export type WorkItemBranchSource = 'github-issue' | 'github-pr' | 'gitlab-issue' | 'gitlab-pr' | 'linear-issue' | 'jira-issue' | 'incidentio-follow-up' | 'github-dependabot-alert' | 'vanta-vulnerability' | 'slack-thread' | 'manual';
|
|
7
|
+
export type WorkItemBranchSource = 'github-issue' | 'github-pr' | 'gitlab-issue' | 'gitlab-pr' | 'linear-issue' | 'jira-issue' | 'incidentio-follow-up' | 'github-dependabot-alert' | 'vanta-vulnerability' | 'detail-finding' | 'slack-thread' | 'manual';
|
|
8
8
|
export interface WorkItemBranchInput {
|
|
9
9
|
id: string;
|
|
10
10
|
source: WorkItemBranchSource;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"work-item-branch.d.ts","sourceRoot":"","sources":["../src/work-item-branch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAEnF;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAC5B,cAAc,GACd,WAAW,GACX,cAAc,GACd,WAAW,GACX,cAAc,GACd,YAAY,GACZ,sBAAsB,GACtB,yBAAyB,GACzB,qBAAqB,GACrB,cAAc,GACd,QAAQ,CAAC;AAEb,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,oBAAoB,CAAC;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CAC3C;AAED,qFAAqF;AACrF,wBAAgB,oBAAoB,CAAC,cAAc,EAAE,sBAAsB,GAAG,IAAI,GAAG,SAAS,GAAG,oBAAoB,
|
|
1
|
+
{"version":3,"file":"work-item-branch.d.ts","sourceRoot":"","sources":["../src/work-item-branch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAEnF;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAC5B,cAAc,GACd,WAAW,GACX,cAAc,GACd,WAAW,GACX,cAAc,GACd,YAAY,GACZ,sBAAsB,GACtB,yBAAyB,GACzB,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AK,EAAE,MAAM,GAAG,OAAO,CAUvD"}
|
package/dist/work-item-branch.js
CHANGED
|
@@ -7,6 +7,7 @@ function workItemBranchSource(externalSource) {
|
|
|
7
7
|
if (externalSource.integrationId === "jira") return "jira-issue";
|
|
8
8
|
if (externalSource.integrationId === "incidentio") return "incidentio-follow-up";
|
|
9
9
|
if (externalSource.integrationId === "vanta") return "vanta-vulnerability";
|
|
10
|
+
if (externalSource.integrationId === "detail") return "detail-finding";
|
|
10
11
|
if (externalSource.integrationId !== "github") return "manual";
|
|
11
12
|
if (externalSource.type === "dependabot-alert") return "github-dependabot-alert";
|
|
12
13
|
return externalSource.type === "pull-request" ? "github-pr" : "github-issue";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"work-item-branch.js","names":[],"sources":["../src/work-item-branch.ts"],"sourcesContent":["import type { ExternalWorkItemSource } from './storage/domains/work-items/base.js';\n\n/**\n * Where a card came from, in the vocabulary branch naming reads. Server rows\n * map their `externalSource` into this with {@link workItemBranchSource}; the\n * board's own `WorkItem['source']` is already this union.\n */\nexport type WorkItemBranchSource =\n | 'github-issue'\n | 'github-pr'\n | 'gitlab-issue'\n | 'gitlab-pr'\n | 'linear-issue'\n | 'jira-issue'\n | 'incidentio-follow-up'\n | 'github-dependabot-alert'\n | 'vanta-vulnerability'\n | 'slack-thread'\n | 'manual';\n\nexport interface WorkItemBranchInput {\n id: string;\n source: WorkItemBranchSource;\n metadata?: Record<string, unknown> | null;\n}\n\n/** Map a stored item's provenance onto the source vocabulary branch naming reads. */\nexport function workItemBranchSource(externalSource: ExternalWorkItemSource | null | undefined): WorkItemBranchSource {\n if (!externalSource) return 'manual';\n if (externalSource.integrationId === 'linear') return 'linear-issue';\n if (externalSource.integrationId === 'gitlab') {\n return externalSource.type === 'pull-request' ? 'gitlab-pr' : 'gitlab-issue';\n }\n if (externalSource.integrationId === 'jira') return 'jira-issue';\n if (externalSource.integrationId === 'incidentio') return 'incidentio-follow-up';\n // Only GitHub, GitLab, Linear, Jira, and incident.io carry provider identities; anything\n // else (a Slack thread, say) is a plain work item rather than a mislabeled GitHub issue.\n if (externalSource.integrationId === 'vanta') return 'vanta-vulnerability';\n if (externalSource.integrationId !== 'github') return 'manual';\n if (externalSource.type === 'dependabot-alert') return 'github-dependabot-alert';\n return externalSource.type === 'pull-request' ? 'github-pr' : 'github-issue';\n}\n\nfunction branchNumber(metadata: Record<string, unknown>, key: string): number | undefined {\n const value = metadata[key] ?? metadata.number;\n return typeof value === 'number' && Number.isInteger(value) && value > 0 ? value : undefined;\n}\n\n/** The provider number a GitHub card carries — the `#12` its runs and thread titles name it by. */\nexport function workItemNumber(item: Pick<WorkItemBranchInput, 'source' | 'metadata'>): number | undefined {\n const metadata = item.metadata ?? {};\n if (item.source === 'github-issue') return branchNumber(metadata, 'githubIssueNumber');\n if (item.source === 'github-pr') return branchNumber(metadata, 'githubPullRequestNumber');\n if (item.source === 'gitlab-issue') return branchNumber(metadata, 'gitlabIssueIid');\n if (item.source === 'gitlab-pr') return branchNumber(metadata, 'gitlabMergeRequestIid');\n return undefined;\n}\n\n/** How a card names its thread: a Linear title already opens with its identifier, a GitHub card gets its number here. */\nexport function workItemThreadTitle(\n item: Pick<WorkItemBranchInput, 'source' | 'metadata'> & { title: string },\n): string {\n const number = workItemNumber(item);\n if (number === undefined) return item.title;\n const kind = item.source === 'github-pr' ? 'PR' : item.source === 'gitlab-pr' ? 'MR' : 'Issue';\n return `${kind} #${number}: ${item.title}`;\n}\n\n/**\n * The last twelve alphanumerics of a work item id: the per-item suffix that keeps\n * provider numbers from colliding across the repositories of one factory. Issue\n * #13 exists in every repository, and a factory's sessions are unique per\n * user and branch across all of its repositories, so a branch named by the\n * number alone can only be held once per factory.\n */\nfunction itemSuffix(id: string): string {\n return id\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '')\n .slice(-12);\n}\n\n/**\n * The git branch an item's runs and sessions share, one grammar for both sides\n * of the wire: the dispatcher names autonomous run branches with it and the\n * board opens card sessions on it, so both converge on one checkout per item.\n * Provider numbers are only unique within a repository, so GitHub and GitLab\n * branches carry the item suffix as well. Cards without a provider identity\n * (manual, Slack) and cards whose metadata lost their identifier fall back to\n * the id-derived branch.\n */\nexport function workItemBranch(item: WorkItemBranchInput): string {\n const metadata = item.metadata ?? {};\n const providerNumber = workItemNumber(item);\n if (providerNumber !== undefined && (item.source === 'github-issue' || item.source === 'github-pr')) {\n const suffix = itemSuffix(item.id);\n const kind = item.source === 'github-issue' ? 'issue' : 'pr';\n return suffix ? `factory/${kind}-${providerNumber}-${suffix}` : `factory/${kind}-${providerNumber}`;\n }\n if (\n (item.source === 'linear-issue' || item.source === 'jira-issue' || item.source === 'incidentio-follow-up') &&\n typeof metadata.identifier === 'string'\n ) {\n const identifier = metadata.identifier.trim();\n if (identifier) {\n const provider = item.source === 'linear-issue' ? 'linear' : item.source === 'jira-issue' ? 'jira' : 'incidentio';\n return `factory/${provider}-${identifier.toLowerCase()}`;\n }\n }\n if (item.source === 'gitlab-pr' && providerNumber !== undefined) {\n const uniqueSuffix = itemSuffix(item.id);\n if (uniqueSuffix) return `factory/gitlab-mr-${providerNumber}-${uniqueSuffix}`;\n }\n if (item.source === 'gitlab-issue' && typeof metadata.identifier === 'string') {\n const identifier = metadata.identifier\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9._-]+/g, '-');\n const uniqueSuffix = itemSuffix(item.id);\n if (identifier && uniqueSuffix) return `factory/gitlab-${identifier.slice(0, 60)}-${uniqueSuffix}`;\n }\n return `factory/item-${item.id}`;\n}\n\n/**\n * The branch a card's pull or merge request is reviewed on. A PR's own card gets\n * the same name {@link workItemBranch} gives it; an issue card reviewing a PR\n * attached to it gets a branch apart from its builder's issue branch, so the\n * reviewer and the builder never share a checkout.\n */\nexport function pullRequestBranch(input: { id: string; provider: 'github' | 'gitlab'; number: number }): string {\n const suffix = itemSuffix(input.id);\n if (input.provider === 'gitlab') {\n return suffix ? `factory/gitlab-mr-${input.number}-${suffix}` : `factory/item-${input.id}-mr-${input.number}`;\n }\n return suffix ? `factory/pr-${input.number}-${suffix}` : `factory/pr-${input.number}`;\n}\n\n/** The pre-suffix GitHub branch, for reusing sessions opened before card names were unique. */\nexport function legacyGithubWorkItemBranch(branch: string): string | undefined {\n const match = /^(factory\\/(?:issue|pr)-[1-9]\\d*)-[a-z0-9]{1,12}$/.exec(branch);\n return match?.[1];\n}\n\n/**\n * The pull request a `factory/pr-<number>-<item suffix>` branch was named after, the\n * inverse of {@link workItemBranch}. Branches from before the suffix (`factory/pr-<number>`)\n * still parse so existing checkouts can resolve their PR.\n */\nexport function pullRequestNumberFromBranch(branch: string): number | undefined {\n const match = /^factory\\/pr-([1-9]\\d*)(?:-[a-z0-9]{1,12})?$/.exec(branch);\n const number = match ? Number(match[1]) : undefined;\n return number !== undefined && Number.isSafeInteger(number) ? number : undefined;\n}\n\n/** The GitLab MR IID encoded in Factory's collision-resistant review branch. */\nexport function mergeRequestNumberFromBranch(branch: string): number | undefined {\n const match = /^factory\\/gitlab-mr-([1-9]\\d*)-[a-z0-9]{1,12}$/.exec(branch);\n const number = match ? Number(match[1]) : undefined;\n return number !== undefined && Number.isSafeInteger(number) ? number : undefined;\n}\n\n/** Whether a provider-reported branch name is safe to show an agent or pass to git. */\nexport function isSafeBranchName(value: string): boolean {\n return (\n /^[A-Za-z0-9][A-Za-z0-9._/@+-]*$/.test(value) &&\n !value.includes('..') &&\n !value.includes('//') &&\n !value.includes('@{') &&\n !value.endsWith('.') &&\n !value.endsWith('/') &&\n !value.endsWith('.lock')\n );\n}\n"],"mappings":";;AA2BA,SAAgB,qBAAqB,gBAAiF;CACpH,IAAI,CAAC,gBAAgB,OAAO;CAC5B,IAAI,eAAe,kBAAkB,UAAU,OAAO;CACtD,IAAI,eAAe,kBAAkB,UACnC,OAAO,eAAe,SAAS,iBAAiB,cAAc;CAEhE,IAAI,eAAe,kBAAkB,QAAQ,OAAO;CACpD,IAAI,eAAe,kBAAkB,cAAc,OAAO;CAG1D,IAA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ACzE;;AAGA,SAAgB,6BAA6B,QAAoC;CAC/E,MAAM,QAAQ,iDAAiD,KAAK,MAAM;CAC1E,MAAM,SAAS,QAAQ,OAAO,MAAM,EAAE,IAAI,KAAA;CAC1C,OAAO,WAAW,KAAA,KAAa,OAAO,cAAc,MAAM,IAAI,SAAS,KAAA;AACzE;;AAGA,SAAgB,iBAAiB,OAAwB;CACvD,OACE,kCAAkC,KAAK,KAAK,KAC5C,CAAC,MAAM,SAAS,IAAI,KACpB,CAAC,MAAM,SAAS,IAAI,KACpB,CAAC,MAAM,SAAS,IAAI,KACpB,CAAC,MAAM,SAAS,GAAG,KACnB,CAAC,MAAM,SAAS,GAAG,KACnB,CAAC,MAAM,SAAS,OAAO;AAE3B"}
|
|
1
|
+
{"version":3,"file":"work-item-branch.js","names":[],"sources":["../src/work-item-branch.ts"],"sourcesContent":["import type { ExternalWorkItemSource } from './storage/domains/work-items/base.js';\n\n/**\n * Where a card came from, in the vocabulary branch naming reads. Server rows\n * map their `externalSource` into this with {@link workItemBranchSource}; the\n * board's own `WorkItem['source']` is already this union.\n */\nexport type WorkItemBranchSource =\n | 'github-issue'\n | 'github-pr'\n | 'gitlab-issue'\n | 'gitlab-pr'\n | 'linear-issue'\n | 'jira-issue'\n | 'incidentio-follow-up'\n | 'github-dependabot-alert'\n | 'vanta-vulnerability'\n | 'detail-finding'\n | 'slack-thread'\n | 'manual';\n\nexport interface WorkItemBranchInput {\n id: string;\n source: WorkItemBranchSource;\n metadata?: Record<string, unknown> | null;\n}\n\n/** Map a stored item's provenance onto the source vocabulary branch naming reads. */\nexport function workItemBranchSource(externalSource: ExternalWorkItemSource | null | undefined): WorkItemBranchSource {\n if (!externalSource) return 'manual';\n if (externalSource.integrationId === 'linear') return 'linear-issue';\n if (externalSource.integrationId === 'gitlab') {\n return externalSource.type === 'pull-request' ? 'gitlab-pr' : 'gitlab-issue';\n }\n if (externalSource.integrationId === 'jira') return 'jira-issue';\n if (externalSource.integrationId === 'incidentio') return 'incidentio-follow-up';\n // Only GitHub, GitLab, Linear, Jira, and incident.io carry provider identities; anything\n // else (a Slack thread, say) is a plain work item rather than a mislabeled GitHub issue.\n if (externalSource.integrationId === 'vanta') return 'vanta-vulnerability';\n if (externalSource.integrationId === 'detail') return 'detail-finding';\n if (externalSource.integrationId !== 'github') return 'manual';\n if (externalSource.type === 'dependabot-alert') return 'github-dependabot-alert';\n return externalSource.type === 'pull-request' ? 'github-pr' : 'github-issue';\n}\n\nfunction branchNumber(metadata: Record<string, unknown>, key: string): number | undefined {\n const value = metadata[key] ?? metadata.number;\n return typeof value === 'number' && Number.isInteger(value) && value > 0 ? value : undefined;\n}\n\n/** The provider number a GitHub card carries — the `#12` its runs and thread titles name it by. */\nexport function workItemNumber(item: Pick<WorkItemBranchInput, 'source' | 'metadata'>): number | undefined {\n const metadata = item.metadata ?? {};\n if (item.source === 'github-issue') return branchNumber(metadata, 'githubIssueNumber');\n if (item.source === 'github-pr') return branchNumber(metadata, 'githubPullRequestNumber');\n if (item.source === 'gitlab-issue') return branchNumber(metadata, 'gitlabIssueIid');\n if (item.source === 'gitlab-pr') return branchNumber(metadata, 'gitlabMergeRequestIid');\n return undefined;\n}\n\n/** How a card names its thread: a Linear title already opens with its identifier, a GitHub card gets its number here. */\nexport function workItemThreadTitle(\n item: Pick<WorkItemBranchInput, 'source' | 'metadata'> & { title: string },\n): string {\n const number = workItemNumber(item);\n if (number === undefined) return item.title;\n const kind = item.source === 'github-pr' ? 'PR' : item.source === 'gitlab-pr' ? 'MR' : 'Issue';\n return `${kind} #${number}: ${item.title}`;\n}\n\n/**\n * The last twelve alphanumerics of a work item id: the per-item suffix that keeps\n * provider numbers from colliding across the repositories of one factory. Issue\n * #13 exists in every repository, and a factory's sessions are unique per\n * user and branch across all of its repositories, so a branch named by the\n * number alone can only be held once per factory.\n */\nfunction itemSuffix(id: string): string {\n return id\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '')\n .slice(-12);\n}\n\n/**\n * The git branch an item's runs and sessions share, one grammar for both sides\n * of the wire: the dispatcher names autonomous run branches with it and the\n * board opens card sessions on it, so both converge on one checkout per item.\n * Provider numbers are only unique within a repository, so GitHub and GitLab\n * branches carry the item suffix as well. Cards without a provider identity\n * (manual, Slack) and cards whose metadata lost their identifier fall back to\n * the id-derived branch.\n */\nexport function workItemBranch(item: WorkItemBranchInput): string {\n const metadata = item.metadata ?? {};\n const providerNumber = workItemNumber(item);\n if (providerNumber !== undefined && (item.source === 'github-issue' || item.source === 'github-pr')) {\n const suffix = itemSuffix(item.id);\n const kind = item.source === 'github-issue' ? 'issue' : 'pr';\n return suffix ? `factory/${kind}-${providerNumber}-${suffix}` : `factory/${kind}-${providerNumber}`;\n }\n if (\n (item.source === 'linear-issue' || item.source === 'jira-issue' || item.source === 'incidentio-follow-up') &&\n typeof metadata.identifier === 'string'\n ) {\n const identifier = metadata.identifier.trim();\n if (identifier) {\n const provider = item.source === 'linear-issue' ? 'linear' : item.source === 'jira-issue' ? 'jira' : 'incidentio';\n return `factory/${provider}-${identifier.toLowerCase()}`;\n }\n }\n if (item.source === 'gitlab-pr' && providerNumber !== undefined) {\n const uniqueSuffix = itemSuffix(item.id);\n if (uniqueSuffix) return `factory/gitlab-mr-${providerNumber}-${uniqueSuffix}`;\n }\n if (item.source === 'gitlab-issue' && typeof metadata.identifier === 'string') {\n const identifier = metadata.identifier\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9._-]+/g, '-');\n const uniqueSuffix = itemSuffix(item.id);\n if (identifier && uniqueSuffix) return `factory/gitlab-${identifier.slice(0, 60)}-${uniqueSuffix}`;\n }\n return `factory/item-${item.id}`;\n}\n\n/**\n * The branch a card's pull or merge request is reviewed on. A PR's own card gets\n * the same name {@link workItemBranch} gives it; an issue card reviewing a PR\n * attached to it gets a branch apart from its builder's issue branch, so the\n * reviewer and the builder never share a checkout.\n */\nexport function pullRequestBranch(input: { id: string; provider: 'github' | 'gitlab'; number: number }): string {\n const suffix = itemSuffix(input.id);\n if (input.provider === 'gitlab') {\n return suffix ? `factory/gitlab-mr-${input.number}-${suffix}` : `factory/item-${input.id}-mr-${input.number}`;\n }\n return suffix ? `factory/pr-${input.number}-${suffix}` : `factory/pr-${input.number}`;\n}\n\n/** The pre-suffix GitHub branch, for reusing sessions opened before card names were unique. */\nexport function legacyGithubWorkItemBranch(branch: string): string | undefined {\n const match = /^(factory\\/(?:issue|pr)-[1-9]\\d*)-[a-z0-9]{1,12}$/.exec(branch);\n return match?.[1];\n}\n\n/**\n * The pull request a `factory/pr-<number>-<item suffix>` branch was named after, the\n * inverse of {@link workItemBranch}. Branches from before the suffix (`factory/pr-<number>`)\n * still parse so existing checkouts can resolve their PR.\n */\nexport function pullRequestNumberFromBranch(branch: string): number | undefined {\n const match = /^factory\\/pr-([1-9]\\d*)(?:-[a-z0-9]{1,12})?$/.exec(branch);\n const number = match ? Number(match[1]) : undefined;\n return number !== undefined && Number.isSafeInteger(number) ? number : undefined;\n}\n\n/** The GitLab MR IID encoded in Factory's collision-resistant review branch. */\nexport function mergeRequestNumberFromBranch(branch: string): number | undefined {\n const match = /^factory\\/gitlab-mr-([1-9]\\d*)-[a-z0-9]{1,12}$/.exec(branch);\n const number = match ? Number(match[1]) : undefined;\n return number !== undefined && Number.isSafeInteger(number) ? number : undefined;\n}\n\n/** Whether a provider-reported branch name is safe to show an agent or pass to git. */\nexport function isSafeBranchName(value: string): boolean {\n return (\n /^[A-Za-z0-9][A-Za-z0-9._/@+-]*$/.test(value) &&\n !value.includes('..') &&\n !value.includes('//') &&\n !value.includes('@{') &&\n !value.endsWith('.') &&\n !value.endsWith('/') &&\n !value.endsWith('.lock')\n );\n}\n"],"mappings":";;AA4BA,SAAgB,qBAAqB,gBAAiF;CACpH,IAAI,CAAC,gBAAgB,OAAO;CAC5B,IAAI,eAAe,kBAAkB,UAAU,OAAO;CACtD,IAAI,eAAe,kBAAkB,UACnC,OAAO,eAAe,SAAS,iBAAiB,cAAc;CAEhE,IAAI,eAAe,kBAAkB,QAAQ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AO,MAAM,EAAE,IAAI,KAAA;CAC1C,OAAO,WAAW,KAAA,KAAa,OAAO,cAAc,MAAM,IAAI,SAAS,KAAA;AACzE;;AAGA,SAAgB,6BAA6B,QAAoC;CAC/E,MAAM,QAAQ,iDAAiD,KAAK,MAAM;CAC1E,MAAM,SAAS,QAAQ,OAAO,MAAM,EAAE,IAAI,KAAA;CAC1C,OAAO,WAAW,KAAA,KAAa,OAAO,cAAc,MAAM,IAAI,SAAS,KAAA;AACzE;;AAGA,SAAgB,iBAAiB,OAAwB;CACvD,OACE,kCAAkC,KAAK,KAAK,KAC5C,CAAC,MAAM,SAAS,IAAI,KACpB,CAAC,MAAM,SAAS,IAAI,KACpB,CAAC,MAAM,SAAS,IAAI,KACpB,CAAC,MAAM,SAAS,GAAG,KACnB,CAAC,MAAM,SAAS,GAAG,KACnB,CAAC,MAAM,SAAS,OAAO;AAE3B"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { WorkItemSourceRow } from '../storage/domains/work-items/work-item-schema.js';
|
|
2
|
+
/** A source row's external id without the type/workspace scope storage prefixes it with. */
|
|
3
|
+
export declare function sourceExternalId(source: Pick<WorkItemSourceRow, 'sourceType' | 'workspaceId' | 'externalId'>): string;
|
|
4
|
+
//# sourceMappingURL=source-external-id.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-external-id.d.ts","sourceRoot":"","sources":["../../src/work-items/source-external-id.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mDAAmD,CAAC;AAE3F,4FAA4F;AAC5F,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,iBAAiB,EAAE,YAAY,GAAG,aAAa,GAAG,YAAY,CAAC,GAAG,MAAM,CAGrH"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// src/work-items/source-external-id.ts
|
|
2
|
+
/** A source row's external id without the type/workspace scope storage prefixes it with. */
|
|
3
|
+
function sourceExternalId(source) {
|
|
4
|
+
const prefix = `${source.sourceType}:${source.workspaceId ? `${source.workspaceId}:` : ""}`;
|
|
5
|
+
return source.externalId.startsWith(prefix) ? source.externalId.slice(prefix.length) : source.externalId;
|
|
6
|
+
}
|
|
7
|
+
export { sourceExternalId };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=source-external-id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-external-id.js","names":[],"sources":["../../src/work-items/source-external-id.ts"],"sourcesContent":["import type { WorkItemSourceRow } from '../storage/domains/work-items/work-item-schema.js';\n\n/** A source row's external id without the type/workspace scope storage prefixes it with. */\nexport function sourceExternalId(source: Pick<WorkItemSourceRow, 'sourceType' | 'workspaceId' | 'externalId'>): string {\n const prefix = `${source.sourceType}:${source.workspaceId ? `${source.workspaceId}:` : ''}`;\n return source.externalId.startsWith(prefix) ? source.externalId.slice(prefix.length) : source.externalId;\n}\n"],"mappings":";;AAGA,SAAgB,iBAAiB,QAAsF;CACrH,MAAM,SAAS,GAAG,OAAO,WAAW,GAAG,OAAO,cAAc,GAAG,OAAO,YAAY,KAAK;CACvF,OAAO,OAAO,WAAW,WAAW,MAAM,IAAI,OAAO,WAAW,MAAM,OAAO,MAAM,IAAI,OAAO;AAChG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/factory",
|
|
3
|
-
"version": "0.29.0-alpha.
|
|
3
|
+
"version": "0.29.0-alpha.2",
|
|
4
4
|
"description": "Mastra Software Factory module: the server core behind the Mastra Software Factory — storage domains, integrations, and surfaces for agent-powered software delivery",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -60,9 +60,9 @@
|
|
|
60
60
|
"zod": "^4.6.7",
|
|
61
61
|
"@mastra/auth-studio": "1.4.0",
|
|
62
62
|
"@mastra/auth-workos": "1.6.9",
|
|
63
|
-
"@mastra/code-sdk": "1.19.1-alpha.
|
|
64
|
-
"@mastra/connect": "1.4.0",
|
|
65
|
-
"@mastra/core": "1.84.0-alpha.
|
|
63
|
+
"@mastra/code-sdk": "1.19.1-alpha.2",
|
|
64
|
+
"@mastra/connect": "1.4.1-alpha.0",
|
|
65
|
+
"@mastra/core": "1.84.0-alpha.2",
|
|
66
66
|
"@mastra/mcp": "2.9.0",
|
|
67
67
|
"@mastra/platform-workspace": "1.13.0",
|
|
68
68
|
"@mastra/slack": "1.9.0"
|
|
@@ -74,13 +74,13 @@
|
|
|
74
74
|
"tsdown": "0.23.1",
|
|
75
75
|
"typescript": "^6.0.3",
|
|
76
76
|
"vitest": "5.1.0",
|
|
77
|
-
"@internal/lint": "0.0.149",
|
|
78
77
|
"@internal/types-builder": "0.0.124",
|
|
78
|
+
"@internal/lint": "0.0.149",
|
|
79
79
|
"@internal/workspace": "0.0.21",
|
|
80
|
-
"@mastra/deployer": "1.84.0-alpha.
|
|
81
|
-
"@mastra/libsql": "1.30.0",
|
|
82
|
-
"@mastra/pg": "1.36.0",
|
|
83
|
-
"@mastra/server": "1.84.0-alpha.
|
|
80
|
+
"@mastra/deployer": "1.84.0-alpha.2",
|
|
81
|
+
"@mastra/libsql": "1.30.1-alpha.0",
|
|
82
|
+
"@mastra/pg": "1.36.1-alpha.0",
|
|
83
|
+
"@mastra/server": "1.84.0-alpha.2"
|
|
84
84
|
},
|
|
85
85
|
"engines": {
|
|
86
86
|
"node": ">=22.19.0"
|