@mastra/factory 0.30.0-alpha.4 → 0.31.0-alpha.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 +32 -10
- package/dist/factory.d.ts +12 -1
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +72 -31
- package/dist/factory.js.map +1 -1
- package/dist/integrations/gitlab/api.d.ts +3 -2
- package/dist/integrations/gitlab/api.d.ts.map +1 -1
- package/dist/integrations/gitlab/api.js +12 -9
- package/dist/integrations/gitlab/api.js.map +1 -1
- package/dist/integrations/issue-reconcile-worker.d.ts +5 -0
- package/dist/integrations/issue-reconcile-worker.d.ts.map +1 -1
- package/dist/integrations/issue-reconcile-worker.js +17 -1
- package/dist/integrations/issue-reconcile-worker.js.map +1 -1
- package/dist/integrations/platform/connect/routes.d.ts +22 -13
- package/dist/integrations/platform/connect/routes.d.ts.map +1 -1
- package/dist/integrations/platform/connect/routes.js +63 -64
- package/dist/integrations/platform/connect/routes.js.map +1 -1
- package/dist/integrations/platform/foundation/connect-binding.d.ts +125 -0
- package/dist/integrations/platform/foundation/connect-binding.d.ts.map +1 -0
- package/dist/integrations/platform/foundation/connect-binding.js +252 -0
- package/dist/integrations/platform/foundation/connect-binding.js.map +1 -0
- package/dist/integrations/platform/foundation/connect-event-poller.d.ts +49 -0
- package/dist/integrations/platform/foundation/connect-event-poller.d.ts.map +1 -0
- package/dist/integrations/platform/foundation/connect-event-poller.js +304 -0
- package/dist/integrations/platform/foundation/connect-event-poller.js.map +1 -0
- package/dist/integrations/platform/foundation/connect-events.d.ts +31 -0
- package/dist/integrations/platform/foundation/connect-events.d.ts.map +1 -0
- package/dist/integrations/platform/foundation/connect-events.js +7 -0
- package/dist/integrations/platform/foundation/connect-events.js.map +1 -0
- package/dist/integrations/platform/foundation/index.d.ts +10 -0
- package/dist/integrations/platform/foundation/index.d.ts.map +1 -0
- package/dist/integrations/platform/foundation/index.js +6 -0
- package/dist/integrations/platform/foundation/intake.d.ts +39 -0
- package/dist/integrations/platform/foundation/intake.d.ts.map +1 -0
- package/dist/integrations/platform/foundation/intake.js +45 -0
- package/dist/integrations/platform/foundation/intake.js.map +1 -0
- package/dist/integrations/platform/foundation/integration.d.ts +84 -0
- package/dist/integrations/platform/foundation/integration.d.ts.map +1 -0
- package/dist/integrations/platform/foundation/integration.js +107 -0
- package/dist/integrations/platform/foundation/integration.js.map +1 -0
- package/dist/integrations/platform/github/event-worker.d.ts +2 -2
- package/dist/integrations/platform/github/event-worker.d.ts.map +1 -1
- package/dist/integrations/platform/github/event-worker.js +4 -8
- package/dist/integrations/platform/github/event-worker.js.map +1 -1
- package/dist/integrations/platform/github/integration.d.ts +3 -0
- package/dist/integrations/platform/github/integration.d.ts.map +1 -1
- package/dist/integrations/platform/github/integration.js +131 -70
- package/dist/integrations/platform/github/integration.js.map +1 -1
- package/dist/integrations/platform/gitlab/connect-events.d.ts +22 -0
- package/dist/integrations/platform/gitlab/connect-events.d.ts.map +1 -0
- package/dist/integrations/platform/gitlab/connect-events.js +49 -0
- package/dist/integrations/platform/gitlab/connect-events.js.map +1 -0
- package/dist/integrations/platform/gitlab/integration.d.ts +24 -15
- package/dist/integrations/platform/gitlab/integration.d.ts.map +1 -1
- package/dist/integrations/platform/gitlab/integration.js +61 -26
- package/dist/integrations/platform/gitlab/integration.js.map +1 -1
- package/dist/integrations/platform/incidentio/intake.d.ts +33 -0
- package/dist/integrations/platform/incidentio/intake.d.ts.map +1 -0
- package/dist/integrations/platform/incidentio/intake.js +271 -0
- package/dist/integrations/platform/incidentio/intake.js.map +1 -0
- package/dist/integrations/platform/incidentio/integration.d.ts +11 -23
- package/dist/integrations/platform/incidentio/integration.d.ts.map +1 -1
- package/dist/integrations/platform/incidentio/integration.js +27 -297
- package/dist/integrations/platform/incidentio/integration.js.map +1 -1
- package/dist/integrations/platform/jira/intake.d.ts +60 -0
- package/dist/integrations/platform/jira/intake.d.ts.map +1 -0
- package/dist/integrations/platform/jira/intake.js +445 -0
- package/dist/integrations/platform/jira/intake.js.map +1 -0
- package/dist/integrations/platform/jira/integration.d.ts +13 -37
- package/dist/integrations/platform/jira/integration.d.ts.map +1 -1
- package/dist/integrations/platform/jira/integration.js +29 -468
- package/dist/integrations/platform/jira/integration.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 +5 -9
- package/dist/integrations/platform/linear/event-worker.js.map +1 -1
- package/dist/integrations/platform/linear/integration.d.ts +3 -1
- package/dist/integrations/platform/linear/integration.d.ts.map +1 -1
- package/dist/integrations/platform/linear/integration.js +9 -9
- package/dist/integrations/platform/linear/integration.js.map +1 -1
- package/dist/integrations/platform/logging.d.ts +6 -0
- package/dist/integrations/platform/logging.d.ts.map +1 -0
- package/dist/integrations/platform/logging.js +25 -0
- package/dist/integrations/platform/logging.js.map +1 -0
- package/dist/integrations/platform/platform-connect.d.ts +38 -0
- package/dist/integrations/platform/platform-connect.d.ts.map +1 -0
- package/dist/integrations/platform/platform-connect.js +109 -0
- package/dist/integrations/platform/platform-connect.js.map +1 -0
- package/dist/integrations/platform/vanta/integration.d.ts +12 -18
- package/dist/integrations/platform/vanta/integration.d.ts.map +1 -1
- package/dist/integrations/platform/vanta/integration.js +38 -38
- package/dist/integrations/platform/vanta/integration.js.map +1 -1
- package/dist/memory-embedder.d.ts +11 -0
- package/dist/memory-embedder.d.ts.map +1 -0
- package/dist/memory-embedder.js +19 -0
- package/dist/memory-embedder.js.map +1 -0
- package/dist/metrics/config.d.ts +1 -1
- package/dist/metrics/config.d.ts.map +1 -1
- package/dist/metrics/config.js +1 -0
- package/dist/metrics/config.js.map +1 -1
- package/dist/metrics/index.js +2 -2
- package/dist/metrics/index.js.map +1 -1
- package/dist/metrics/sandbox.d.ts +3 -3
- package/dist/metrics/sandbox.js +13 -13
- package/dist/metrics/sandbox.js.map +1 -1
- package/dist/metrics/session.d.ts +28 -0
- package/dist/metrics/session.d.ts.map +1 -0
- package/dist/metrics/session.js +76 -0
- package/dist/metrics/session.js.map +1 -0
- package/dist/routes/source-control-sessions.d.ts +5 -0
- package/dist/routes/source-control-sessions.d.ts.map +1 -1
- package/dist/routes/source-control-sessions.js +65 -7
- package/dist/routes/source-control-sessions.js.map +1 -1
- package/dist/routes/surface.d.ts +5 -0
- package/dist/routes/surface.d.ts.map +1 -1
- package/dist/routes/surface.js +1 -0
- package/dist/routes/surface.js.map +1 -1
- package/dist/rules/dispatcher.d.ts.map +1 -1
- package/dist/rules/dispatcher.js.map +1 -1
- package/dist/rules/processor.d.ts +29 -1
- package/dist/rules/processor.d.ts.map +1 -1
- package/dist/rules/processor.js +156 -23
- package/dist/rules/processor.js.map +1 -1
- package/dist/rules/public-failure-reason.js +1 -1
- package/dist/rules/public-failure-reason.js.map +1 -1
- package/dist/rules/transition-service.d.ts.map +1 -1
- package/dist/rules/transition-service.js +33 -9
- package/dist/rules/transition-service.js.map +1 -1
- package/dist/storage/domains/work-items/base.d.ts +2 -0
- package/dist/storage/domains/work-items/base.d.ts.map +1 -1
- package/dist/storage/domains/work-items/base.js +4 -2
- package/dist/storage/domains/work-items/base.js.map +1 -1
- package/dist/work-item-branch.d.ts +7 -1
- package/dist/work-item-branch.d.ts.map +1 -1
- package/dist/work-item-branch.js +9 -1
- package/dist/work-item-branch.js.map +1 -1
- package/dist/work-items/card-facts.d.ts.map +1 -1
- package/dist/work-items/card-facts.js +2 -2
- package/dist/work-items/card-facts.js.map +1 -1
- package/package.json +13 -13
- package/dist/integrations/platform/api-client.d.ts +0 -34
- package/dist/integrations/platform/api-client.d.ts.map +0 -1
- package/dist/integrations/platform/api-client.js +0 -186
- package/dist/integrations/platform/api-client.js.map +0 -1
- package/dist/integrations/platform/gitlab/event-worker.d.ts +0 -64
- package/dist/integrations/platform/gitlab/event-worker.d.ts.map +0 -1
- package/dist/integrations/platform/gitlab/event-worker.js +0 -304
- package/dist/integrations/platform/gitlab/event-worker.js.map +0 -1
package/README.md
CHANGED
|
@@ -96,7 +96,7 @@ See [Health metrics](https://factory.mastra.ai/configure/metrics) for what each
|
|
|
96
96
|
new MastraFactory({
|
|
97
97
|
// ...
|
|
98
98
|
metrics: {
|
|
99
|
-
groups: ['process', 'postgres', 'sandbox'], // or 'all'
|
|
99
|
+
groups: ['process', 'postgres', 'sandbox', 'session'], // or 'all'
|
|
100
100
|
intervalMs: 60_000, // default 60s, minimum 15s
|
|
101
101
|
maxRecordsPerMinute: 500, // default 500 per process
|
|
102
102
|
},
|
|
@@ -113,15 +113,16 @@ Env vars override the code option:
|
|
|
113
113
|
|
|
114
114
|
A group that's off does nothing: no timers, no probes, no connections, no records. Unknown group names are logged once at boot.
|
|
115
115
|
|
|
116
|
-
| Group | Series (all prefixed `mastra_factory_`)
|
|
117
|
-
| ---------- |
|
|
118
|
-
| `process` | `event_loop_delay_ms{stat}`, `event_loop_utilization`, `gc_ms{kind=major\|incremental}`, `process_memory_bytes{kind=rss\|heap_used\|heap_limit}`, `process_heap_utilization` (heap used ÷ limit, 0 to 1), `process_cpu_cores` (cores used across all threads, can exceed 1; compare with `process_cpu_limit_cores`), `process_cpu_limit_cores`, `process_uptime_ms`
|
|
119
|
-
| `postgres` | `db_pool{pool,state}`, `probe_duration_ms` / `probe_failures_total` for `db_<pool>` (a pool that closed its idle connections opens one for the probe, so its duration can include connecting), `db_sessions{state}`, `db_longest_ms{kind}`; the statements that used the most time are logged every 10 minutes when `pg_stat_statements` is installed (other users' statements need the `pg_read_all_stats` role)
|
|
120
|
-
| `redis` | `probe_duration_ms{component=redis}`, `redis_memory_bytes{kind=used\|max}` (`max` only when `maxmemory` is set), `redis_memory_utilization` (used ÷ `maxmemory`, only when set), `redis_clients`, `redis_evicted_keys_total`, `redis_stream_backlog{topic,kind}`; only with `RedisStreamsPubSub`, and only the probe on a cluster
|
|
121
|
-
| `sandbox` | `
|
|
122
|
-
| `
|
|
116
|
+
| Group | Series (all prefixed `mastra_factory_`) |
|
|
117
|
+
| ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
118
|
+
| `process` | `event_loop_delay_ms{stat}`, `event_loop_utilization`, `gc_ms{kind=major\|incremental}`, `process_memory_bytes{kind=rss\|heap_used\|heap_limit}`, `process_heap_utilization` (heap used ÷ limit, 0 to 1), `process_cpu_cores` (cores used across all threads, can exceed 1; compare with `process_cpu_limit_cores`), `process_cpu_limit_cores`, `process_uptime_ms` |
|
|
119
|
+
| `postgres` | `db_pool{pool,state}`, `probe_duration_ms` / `probe_failures_total` for `db_<pool>` (a pool that closed its idle connections opens one for the probe, so its duration can include connecting), `db_sessions{state}`, `db_longest_ms{kind}`; the statements that used the most time are logged every 10 minutes when `pg_stat_statements` is installed (other users' statements need the `pg_read_all_stats` role) |
|
|
120
|
+
| `redis` | `probe_duration_ms{component=redis}`, `redis_memory_bytes{kind=used\|max}` (`max` only when `maxmemory` is set), `redis_memory_utilization` (used ÷ `maxmemory`, only when set), `redis_clients`, `redis_evicted_keys_total`, `redis_stream_backlog{topic,kind}`; only with `RedisStreamsPubSub`, and only the probe on a cluster |
|
|
121
|
+
| `sandbox` | `sandbox_ready_ms{kind=first\|resume,outcome}` (a sandbox start, from the first request to the end of the onStart hook, so the provider plus repository setup; failures included), `sandbox_wait_ms{kind,outcome}` (how long the first caller other than the eager start waited for it), `sandboxes_starting` and `sandbox_start_oldest_age_ms` (starts in flight, sent every interval), `sandbox_start_ms{sandbox_provider,outcome}`, `sandbox_start_failures_total{sandbox_provider,cause}` (sent as 0 once a sandbox has been created), `sandbox_phase_ms{phase,outcome}`, `sandbox_command_ms{step,outcome}`, `sandbox_recreated_total{kind}`, `sandbox_retired_total`, `sandboxes_active` |
|
|
122
|
+
| `session` | `session_first_output_ms{turn=first\|later,outcome=ok\|no_output,first=text\|reasoning\|tool_call}`: how long a message sent to an idle session waits for the model's first output of any kind, so it includes waiting for the thread, building tools, memory and the model's own time to first token. `turn=first` is the first run since the process loaded the session; `outcome=no_output` is a run that ended before the model said anything (no `first` label). A message sent while a run is in flight joins that run and isn't timed |
|
|
123
|
+
| `intake` | `intake_events_total{source,outcome}` (`committed` and `error` sent as 0 for each configured GitHub or Linear integration), `intake_replayed_total{source,kind}` (each one is a missed webhook), `intake_sweep_failures_total{source,kind}` (sent as 0 once the sweep worker starts), `intake_last_sweep_age_ms{source,kind}` (counted from when the sweep worker starts; no series means no sweep worker runs in that process) |
|
|
123
124
|
|
|
124
|
-
Counts and timings are aggregated in the process and sent once per interval: a counter is one record per series, a timing is `stat=avg|p95|max` on its `_ms` series, which is always in milliseconds, plus a `<name>_count` series with the number of observations (for example `
|
|
125
|
+
Counts and timings are aggregated in the process and sent once per interval: a counter is one record per series, a timing is `stat=avg|p95|max` on its `_ms` series, which is always in milliseconds, plus a `<name>_count` series with the number of observations (for example `sandbox_ready_ms_count`). Those stats are per interval and per process: p95 values can't be averaged across intervals or processes, so chart the worst p95 per time bucket, use `max` for the worst case and `_count` to weight averages. `event_loop_delay_ms` has the same shape, where `event_loop_delay_ms_count` is the number of delay samples. Every duration is in milliseconds. Event counts and timings are sent before gauges, so the cap drops gauges first. Records past the per-minute cap are dropped and counted in `mastra_factory_metrics_dropped_total`. Labels only take values from fixed lists; IDs, paths and repository names are never sent.
|
|
125
126
|
|
|
126
127
|
Every record has a `service` label read from `MASTRA_WORKERS`: `api` when it's `false`, `worker` when it's set to anything else, `all` when unset. On a split deployment (API plus worker service) the database-wide and Redis-wide stats (`db_sessions`, `db_longest_ms`, slow statements, `redis_memory_bytes`, `redis_clients`, `redis_evicted_keys_total`, `redis_stream_backlog`) run only on `worker`, so they aren't reported twice. `intake_last_sweep_age_ms` only advances on the process that ran the sweep, so take the minimum across processes.
|
|
127
128
|
|
|
@@ -761,6 +762,27 @@ Change the timeout and check interval with `idleSessionUnload`. `idleMs: 0` turn
|
|
|
761
762
|
const factory = new MastraFactory({ storage, idleSessionUnload: { idleMs: 60 * 60_000, sweepIntervalMs: 5 * 60_000 } });
|
|
762
763
|
```
|
|
763
764
|
|
|
765
|
+
### Recall embedder
|
|
766
|
+
|
|
767
|
+
With a `vector` store, agent memory embeds thread text for recall search. By default it embeds locally with fastembed (bge-small, 384 dimensions) in a worker process on the Factory host, so it shares the host's CPU with the server. Set `embedder` to embed with a hosted model instead:
|
|
768
|
+
|
|
769
|
+
```ts
|
|
770
|
+
const factory = new MastraFactory({
|
|
771
|
+
storage,
|
|
772
|
+
vector,
|
|
773
|
+
// Reads OPENAI_API_KEY
|
|
774
|
+
embedder: 'openai/text-embedding-3-small',
|
|
775
|
+
});
|
|
776
|
+
```
|
|
777
|
+
|
|
778
|
+
`embedder` takes any `provider/model` embedding id the model router knows, such as `openai/text-embedding-3-small` or `google/gemini-embedding-001`, which reads that provider's key from the server environment. A Mastra gateway id such as `mastra/openai/text-embedding-3-small` reads `MASTRA_GATEWAY_API_KEY`. Any AI SDK embedding model also works. To pass a key directly, use `new ModelRouterEmbeddingModel({ id, apiKey })` from `@mastra/core/llm`. `embedderOptions` is passed to every embedding call.
|
|
779
|
+
|
|
780
|
+
- **One model per deployment.** Every agent's memory in the deployment uses this embedder, because all tenants share one vector index.
|
|
781
|
+
- **Whose key it is.** The embedder runs on the operator's key, outside tenant credential resolution. Accounts never use the server's provider keys, but a server `MASTRA_GATEWAY_API_KEY` also lets every account without its own gateway key run `mastra/` chat models on your credits. Use a provider id to keep the embedding key out of chat.
|
|
782
|
+
- **Checked at startup.** `new MastraFactory()` throws when `embedder` is set without `vector`, or when a router string's provider key is missing.
|
|
783
|
+
- **Thread text leaves the host.** A hosted embedder sends thread text to that provider. Tenants that need a different provider need their own deployment and vector store.
|
|
784
|
+
- **Switching models.** Vector indexes are named by dimension, so a model with a different dimension starts an empty index, and recall doesn't find content observed before the switch. Earlier content isn't re-embedded. Don't switch between two models with the same dimension on one vector store, including from the default fastembed to a 384-dimension model: their vectors would share an index, can't be compared, and recall would return wrong results without an error.
|
|
785
|
+
|
|
764
786
|
### The `factory-work-item` signal
|
|
765
787
|
|
|
766
788
|
Every session bound to a card gets a `<factory-work-item>` state signal describing it, re-rendered only when the card, its sources or the binding change. It carries the card's key, title, URL, board and phase, next phases, labels, author and whether they're trusted, and the session's branch; its sources (issue and each pull or merge request, with state, head commit, a head branch that passes Factory's branch-name check, and the tool to fetch details); and Factory's state: whether the plan was approved, self-review rounds used, the last self-review and PR review verdicts with the commits they covered and findings, and the card's open change request. The session that reviews a pull request also gets the procedure to follow, the checkout steps and the pull request head to review. The source description is included, inside an `<untrusted-source-description>` block when an outside author wrote it. Comment threads are not included.
|
|
@@ -1345,7 +1367,7 @@ In Platform mode, issue, note, merge request and push events reach Factory by po
|
|
|
1345
1367
|
| `MASTRA_PLATFORM_GITLAB_POLLING_ENABLED` | `true` | Set `false` to stop polling the Platform event log for GitLab events. |
|
|
1346
1368
|
| `MASTRA_PLATFORM_GITLAB_POLLING_INTERVAL_MS` | `20000` | Positive polling interval in milliseconds. |
|
|
1347
1369
|
|
|
1348
|
-
These sit next to `MASTRA_PLATFORM_GITHUB_POLLING_ENABLED` and `MASTRA_PLATFORM_GITHUB_POLLING_INTERVAL_MS` and follow the same rules.
|
|
1370
|
+
These sit next to `MASTRA_PLATFORM_GITHUB_POLLING_ENABLED` and `MASTRA_PLATFORM_GITHUB_POLLING_INTERVAL_MS` and follow the same rules. The reads are done by the deployment's Platform Connect event poller, which every Platform integration that reads a connection event log shares; it reads at the shortest interval any of them asks for. One replica polls at a time. Each connection's cursor is stored in the integration settings table and advances past an event once its handler finishes. A handler that still fails after three attempts is skipped and its integration reconciles. A connection read for the first time starts at the present, and its integration reconciles once to cover what came before. `diagnostics()` reports `pollingEnabled` and `pollingIntervalMs`.
|
|
1349
1371
|
|
|
1350
1372
|
### incident.io intake
|
|
1351
1373
|
|
package/dist/factory.d.ts
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
* and the storage domains those capabilities require.
|
|
20
20
|
*/
|
|
21
21
|
import type { MastraCodeConfig } from '@mastra/code-sdk';
|
|
22
|
+
import type { MemoryEmbedder } from '@mastra/code-sdk/agents/memory';
|
|
22
23
|
import type { BuiltinToolId } from '@mastra/core/agent-controller';
|
|
23
24
|
import type { MastraBrowser } from '@mastra/core/browser';
|
|
24
25
|
import type { PubSub } from '@mastra/core/events';
|
|
@@ -28,7 +29,7 @@ import { RequestContext } from '@mastra/core/request-context';
|
|
|
28
29
|
import type { IMastraAuthProvider } from '@mastra/core/server';
|
|
29
30
|
import type { InlineSkill } from '@mastra/core/skills';
|
|
30
31
|
import type { FactoryStorage } from '@mastra/core/storage';
|
|
31
|
-
import type { MastraVector } from '@mastra/core/vector';
|
|
32
|
+
import type { MastraEmbeddingOptions, MastraVector } from '@mastra/core/vector';
|
|
32
33
|
import type { FactorySandboxDescription } from '@mastra/core/workspace';
|
|
33
34
|
import type { InstalledBoard } from './boards/index.js';
|
|
34
35
|
import type { FactoryIntegration, IntegrationTools } from './integrations/base.js';
|
|
@@ -90,6 +91,16 @@ export interface MastraFactoryConfig {
|
|
|
90
91
|
* store resolution applies.
|
|
91
92
|
*/
|
|
92
93
|
vector?: MastraVector;
|
|
94
|
+
/**
|
|
95
|
+
* Embedder for recall vectors, shared by every agent's memory in this deployment: a
|
|
96
|
+
* `provider/model` string (e.g. `'openai/text-embedding-3-small'`), a Mastra gateway id or an AI
|
|
97
|
+
* SDK embedding model. Requires `vector`. Built once at construction on the operator's key,
|
|
98
|
+
* so a missing provider key throws here. Omitted → local `fastembed.small` (bge-small, 384
|
|
99
|
+
* dimensions) on this host. See "Recall embedder" in the README.
|
|
100
|
+
*/
|
|
101
|
+
embedder?: MemoryEmbedder;
|
|
102
|
+
/** Options passed to every embedding call, e.g. provider options or headers. */
|
|
103
|
+
embedderOptions?: MastraEmbeddingOptions;
|
|
93
104
|
/**
|
|
94
105
|
* Host-owned Knowledge runtime. Factory registers this exact instance under its `id` and uses that
|
|
95
106
|
* key for its read surfaces; pass `{ key, instance }` to register it under another key. Omitted,
|
package/dist/factory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAMH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAMH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAGrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAqB,MAAM,sBAAsB,CAAC;AAE9E,OAAO,KAAK,EAAwB,sBAAsB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGtG,OAAO,KAAK,EAAkB,yBAAyB,EAAoB,MAAM,wBAAwB,CAAC;AAsB1G,OAAO,KAAK,EAAiB,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAQvE,OAAO,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AAE,gBAAgB,EAAE,CAAC;QAAC,SAAS,EAAE,gBAAgB,EAAE,CAAA;KAAE,CAAC,CA+CvG;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,qBAAqB,CAAC,cAAc,EAAE,cAAc,GAAG,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAKtG;IAED;;;;OAIG;IACG,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC,CA23DnC;IAED;;;;OAIG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CA0B9B;IAiBD,oGAAoG;IAC9F,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAqD9B;CACF"}
|
package/dist/factory.js
CHANGED
|
@@ -19,15 +19,19 @@ import { createGithubReviewStatusReporter, reviewStatusAnimationFromEnv } from "
|
|
|
19
19
|
import { isFactoryGithubLogin, trustedCollaborator } from "./integrations/github/rules.js";
|
|
20
20
|
import { dismissStaleFactoryReviews } from "./integrations/github/stale-reviews.js";
|
|
21
21
|
import { KeptCards } from "./integrations/kept-cards.js";
|
|
22
|
-
import {
|
|
23
|
-
import { buildConnectToolListRoute, buildConnectToolsRoute, buildPlatformConnectRoutes } from "./integrations/platform/connect/routes.js";
|
|
22
|
+
import { buildConnectToolListRoute, buildConnectToolsRoute, buildPlatformConnectRoutes, isPlatformConnectProviderSource } from "./integrations/platform/connect/routes.js";
|
|
24
23
|
import { platformConnectTools, projectConnectTools, resolveToolsInTime } from "./integrations/platform/connect/session-tools.js";
|
|
24
|
+
import { PLATFORM_CONNECT_EVENT_POLLER_STORAGE_ID, PlatformConnectEventPoller } from "./integrations/platform/foundation/connect-event-poller.js";
|
|
25
|
+
import { isPlatformConnectEventSource } from "./integrations/platform/foundation/connect-events.js";
|
|
26
|
+
import { createPlatformConnectClient } from "./integrations/platform/platform-connect.js";
|
|
25
27
|
import { logIntegrationSummary } from "./integrations/startup-summary.js";
|
|
26
28
|
import { createSessionAsRowOwner, prepareSessionRunContext } from "./integrations/subscription-session.js";
|
|
27
29
|
import { SELECT_VANTA_VULNERABILITIES_MIGRATION, vantaOrgsSyncingWithoutSource } from "./integrations/vanta/sync.js";
|
|
28
30
|
import { shareLinkedRepositoryChanges } from "./linked-repositories-changed.js";
|
|
29
31
|
import { buildFactoryMcpRoutes, resolveMcpAuthorizationServers } from "./mcp/routes.js";
|
|
32
|
+
import { resolveFactoryEmbedder } from "./memory-embedder.js";
|
|
30
33
|
import { startFactoryMetrics } from "./metrics/index.js";
|
|
34
|
+
import { instrumentSessionFirstOutput } from "./metrics/session.js";
|
|
31
35
|
import { resolveDeploymentModelProviders } from "./routes/config.js";
|
|
32
36
|
import { createCustomProvidersPrimer, primeCustomProvidersForRequestContext, registerCustomProvidersSource } from "./routes/custom-provider-source.js";
|
|
33
37
|
import { buildFeedEventsRoutes } from "./routes/feed-events.js";
|
|
@@ -46,20 +50,20 @@ import { FactoryPhaseStateProcessor, reportMemorySettingsUnavailable } from "./r
|
|
|
46
50
|
import { createReviewSourceTool, resolveReviewSourceUiOrigin } from "./rules/review-source-tool.js";
|
|
47
51
|
import { createTerminalStageCleanup } from "./rules/terminal-cleanup.js";
|
|
48
52
|
import { createFactoryTransitionTools } from "./rules/tools.js";
|
|
53
|
+
import { resolveFactoryToolScope } from "./tools/scope.js";
|
|
49
54
|
import { FactoryTransitionService } from "./rules/transition-service.js";
|
|
50
55
|
import { assertFactoryConfigVersion } from "./rules/validation.js";
|
|
51
|
-
import { resolveFactoryToolScope } from "./tools/scope.js";
|
|
52
56
|
import { CallbackFactorySandbox } from "./sandbox/callback-factory-sandbox.js";
|
|
53
57
|
import { controllerRunInFlight, createContextSandboxStops, createTerminalSandboxStops } from "./sandbox/context-sandboxes.js";
|
|
54
58
|
import { isValidGitRef } from "./sandbox/git-ref.js";
|
|
55
59
|
import { LocalFactorySandbox } from "./sandbox/local-factory-sandbox.js";
|
|
60
|
+
import { applyFactoryToolPermissions } from "./tools/permissions.js";
|
|
56
61
|
import { CachedSandboxEnvs } from "./sandbox/sandbox-env-cache.js";
|
|
57
62
|
import { SessionRetirementCoordinator } from "./sandbox/session-retirement.js";
|
|
58
|
-
import { applyFactoryToolPermissions } from "./tools/permissions.js";
|
|
59
63
|
import { peekSessionSandbox } from "./sandbox/session-sandbox.js";
|
|
60
64
|
import { createPlaintextFactorySecretEncryption } from "./secret-encryption.js";
|
|
61
|
-
import { handleServerError } from "./server-error.js";
|
|
62
65
|
import { metricsService, resolveMetricsConfig } from "./metrics/config.js";
|
|
66
|
+
import { handleServerError } from "./server-error.js";
|
|
63
67
|
import { resolveFactoryCredentialTenant, resolveFactoryModelPolicy } from "./session/credential-policy.js";
|
|
64
68
|
import { hydrateSessionDefaultModel } from "./session/default-model-hydration.js";
|
|
65
69
|
import { environmentSlugs, resolveSessionRepositories } from "./session/environment-repositories.js";
|
|
@@ -124,6 +128,7 @@ import { resolveKnowledgeSessionScopes } from "@mastra/code-sdk/knowledge-scope"
|
|
|
124
128
|
import { getGlobalMcpPath } from "@mastra/code-sdk/mcp/config";
|
|
125
129
|
import { AgentControllerChannels } from "@mastra/core/channels";
|
|
126
130
|
import { Knowledge } from "@mastra/core/knowledge";
|
|
131
|
+
import { TITLE_PINNED_THREAD_METADATA_KEY } from "@mastra/core/memory";
|
|
127
132
|
import { readObjective, resolveGoalStore, writeObjective } from "@mastra/core/tools";
|
|
128
133
|
import { describeFactorySandbox, isFactorySandbox } from "@mastra/core/workspace";
|
|
129
134
|
// src/factory.ts
|
|
@@ -264,6 +269,8 @@ var MastraFactory = class {
|
|
|
264
269
|
#boardStore;
|
|
265
270
|
#skills;
|
|
266
271
|
#configVersion;
|
|
272
|
+
/** Recall embedder, built once from `config.embedder`. Undefined → the SDK's local fastembed. */
|
|
273
|
+
#embedder;
|
|
267
274
|
#prepared;
|
|
268
275
|
#dispatcher;
|
|
269
276
|
/** Names this replica on the dispatch-wake topic so it can skip its own echoes. */
|
|
@@ -302,6 +309,7 @@ var MastraFactory = class {
|
|
|
302
309
|
this.#forcedIntake = intakeEvaluatorFrom(process.env);
|
|
303
310
|
for (const problem of findBoardSkillProblems(this.#boards, this.#skills)) console.warn(`[factory] ${problem}`);
|
|
304
311
|
this.#configVersion = assertFactoryConfigVersion(config.configVersion ?? "factory-config-v1");
|
|
312
|
+
this.#embedder = resolveFactoryEmbedder(config);
|
|
305
313
|
this.#config = {
|
|
306
314
|
...config,
|
|
307
315
|
...config.scopes && { scopes: [...config.scopes] }
|
|
@@ -439,6 +447,10 @@ var MastraFactory = class {
|
|
|
439
447
|
const allowedOrigins = (this.#config.allowedOrigins ?? []).map((o) => o.replace(/\/+$/, "")).filter(Boolean);
|
|
440
448
|
const storage = instrumentAsyncMethods(this.#config.storage, "storage");
|
|
441
449
|
const vector = this.#config.vector;
|
|
450
|
+
const embedding = {
|
|
451
|
+
embedder: this.#embedder,
|
|
452
|
+
embedderOptions: this.#config.embedderOptions
|
|
453
|
+
};
|
|
442
454
|
const pubsub = this.#config.pubsub;
|
|
443
455
|
const eventBus = pubsub ?? new EventEmitterPubSub();
|
|
444
456
|
const configuredAuth = this.#config.auth;
|
|
@@ -706,7 +718,7 @@ var MastraFactory = class {
|
|
|
706
718
|
const mastraStorage = storage.getMastraStorage();
|
|
707
719
|
const memory = await mastraStorage.getStore("memory");
|
|
708
720
|
if (!memory) return false;
|
|
709
|
-
const sessionMemory = getDynamicMemory(mastraStorage, vector);
|
|
721
|
+
const sessionMemory = getDynamicMemory(mastraStorage, vector, void 0, embedding);
|
|
710
722
|
const report = await migrateSessionResources({
|
|
711
723
|
sessions: sourceControlStorage,
|
|
712
724
|
workItems: workItemsStorage,
|
|
@@ -1030,6 +1042,7 @@ var MastraFactory = class {
|
|
|
1030
1042
|
loadMemorySettings,
|
|
1031
1043
|
defaultThinkingLevel: resolveDefaultThinkingLevel,
|
|
1032
1044
|
onBoundThreadRun: () => this.#dispatcher?.noteBoundThreadRun(),
|
|
1045
|
+
isThreadRunning: (threadId) => this.#prepared?.base.controller.listActiveThreadRuns().some((run) => run.threadId === threadId) ?? false,
|
|
1033
1046
|
...transitionService ? { transitionService } : {},
|
|
1034
1047
|
...githubIntegration ? { recordPullRequestProvenance: (input) => recordFactoryPullRequestProvenance(githubIntegration, sourceControlStorage.forIntegration("github"), integrationStorage.forIntegration("github"), workItemsStorage, input) } : {},
|
|
1035
1048
|
messageReader: { listMessages: async (input) => {
|
|
@@ -1082,7 +1095,7 @@ var MastraFactory = class {
|
|
|
1082
1095
|
const sessionTools = this.#config.tools ?? ("projectId" in connectSetup ? platformConnectTools(connectSetup.projectId) : void 0);
|
|
1083
1096
|
const configuredTools = this.#config.tools;
|
|
1084
1097
|
const connectToolsList = "projectId" in connectSetup ? {
|
|
1085
|
-
client:
|
|
1098
|
+
client: createPlatformConnectClient(),
|
|
1086
1099
|
projectId: connectSetup.projectId,
|
|
1087
1100
|
toolsSource: connectToolsSource,
|
|
1088
1101
|
resolveTools: configuredTools === void 0 ? projectConnectTools(connectSetup.projectId) : async ({ requestContext }) => resolveToolsInTime(Promise.resolve(typeof configuredTools === "function" ? configuredTools({ requestContext }) : configuredTools))
|
|
@@ -1248,7 +1261,10 @@ var MastraFactory = class {
|
|
|
1248
1261
|
];
|
|
1249
1262
|
},
|
|
1250
1263
|
outputProcessors: [...integrations.flatMap((integration) => integration.processors?.output ?? []), new FactoryReplyCredentialProcessor()],
|
|
1251
|
-
...vector ? {
|
|
1264
|
+
...vector ? {
|
|
1265
|
+
vector,
|
|
1266
|
+
...embedding
|
|
1267
|
+
} : {},
|
|
1252
1268
|
extraTools: async ({ requestContext }) => {
|
|
1253
1269
|
const tools = {};
|
|
1254
1270
|
const toolOwners = /* @__PURE__ */ new Map();
|
|
@@ -1328,7 +1344,11 @@ var MastraFactory = class {
|
|
|
1328
1344
|
} catch {
|
|
1329
1345
|
continue;
|
|
1330
1346
|
}
|
|
1331
|
-
if (integration.agentTools)
|
|
1347
|
+
if (integration.agentTools) try {
|
|
1348
|
+
mergeTools(integration.id, await integration.agentTools({ requestContext }));
|
|
1349
|
+
} catch (error) {
|
|
1350
|
+
console.warn(`[factory] ${integration.id} tools are unavailable for this run: ${error instanceof Error ? error.message : String(error)}`);
|
|
1351
|
+
}
|
|
1332
1352
|
if (integration.sessionTools) mergeTools(integration.id, integration.sessionTools({ requestContext }));
|
|
1333
1353
|
}
|
|
1334
1354
|
if (sessionTools) {
|
|
@@ -1413,13 +1433,20 @@ var MastraFactory = class {
|
|
|
1413
1433
|
} : {},
|
|
1414
1434
|
sessionRetirement,
|
|
1415
1435
|
moveThread: async ({ threadId, resourceId }) => {
|
|
1416
|
-
const sessionMemory = getDynamicMemory(storage.getMastraStorage(), vector);
|
|
1436
|
+
const sessionMemory = getDynamicMemory(storage.getMastraStorage(), vector, void 0, embedding);
|
|
1417
1437
|
await sessionMemory({ requestContext: new RequestContext() }).updateThreadResourceId({
|
|
1418
1438
|
threadId,
|
|
1419
1439
|
resourceId
|
|
1420
1440
|
});
|
|
1421
1441
|
await sessionMemory.settled();
|
|
1422
1442
|
},
|
|
1443
|
+
renameThread: async ({ threadId, title }) => {
|
|
1444
|
+
await getDynamicMemory(storage.getMastraStorage(), vector, void 0, embedding)({ requestContext: new RequestContext() }).updateThread({
|
|
1445
|
+
id: threadId,
|
|
1446
|
+
title,
|
|
1447
|
+
metadata: { [TITLE_PINNED_THREAD_METADATA_KEY]: true }
|
|
1448
|
+
});
|
|
1449
|
+
},
|
|
1423
1450
|
factoryStorage: storage,
|
|
1424
1451
|
integrationStorage,
|
|
1425
1452
|
sourceControlStorage,
|
|
@@ -1474,7 +1501,7 @@ var MastraFactory = class {
|
|
|
1474
1501
|
id: factoryProjectId
|
|
1475
1502
|
}) !== null;
|
|
1476
1503
|
},
|
|
1477
|
-
reconcileToolResults: () => factoryProcessor?.
|
|
1504
|
+
reconcileToolResults: () => factoryProcessor?.reconcileBoundThreads() ?? Promise.resolve(),
|
|
1478
1505
|
reconcileRunBinding: (binding) => factoryProcessor?.reconcileBinding(binding) ?? Promise.resolve(),
|
|
1479
1506
|
prepareBinding,
|
|
1480
1507
|
...githubIntegration ? {
|
|
@@ -1533,7 +1560,7 @@ var MastraFactory = class {
|
|
|
1533
1560
|
...auditDomain.routes(),
|
|
1534
1561
|
...hasPlatformCredentials() ? buildPlatformConnectRoutes({
|
|
1535
1562
|
auth: routeAuth,
|
|
1536
|
-
|
|
1563
|
+
providers: integrations.flatMap((integration) => isPlatformConnectProviderSource(integration) ? integration.platformConnectProviders() : [])
|
|
1537
1564
|
}) : [],
|
|
1538
1565
|
buildConnectToolsRoute(routeAuth, connectToolsList),
|
|
1539
1566
|
buildConnectToolListRoute(routeAuth, connectToolsList)
|
|
@@ -1630,6 +1657,7 @@ var MastraFactory = class {
|
|
|
1630
1657
|
answersItself: (toolCallId) => this.#dispatcher?.autoApproves(toolCallId) ?? false
|
|
1631
1658
|
});
|
|
1632
1659
|
observeSessionThreadStamp(session);
|
|
1660
|
+
instrumentSessionFirstOutput(session);
|
|
1633
1661
|
});
|
|
1634
1662
|
prepared.base.controller.onSessionCreated((session) => hydrateSessionMemorySettings(session, { sourceControl: { sessions: sourceControlSessions } }), { blocking: true });
|
|
1635
1663
|
prepared.base.controller.onSessionCreated((session) => hydrateSessionDefaultModel(session, {
|
|
@@ -1676,25 +1704,38 @@ var MastraFactory = class {
|
|
|
1676
1704
|
if (disconnect) this.#channelShutdowns.push(() => disconnect.call(adapter));
|
|
1677
1705
|
}
|
|
1678
1706
|
}
|
|
1679
|
-
const
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1707
|
+
const readyContexts = integrationRegistrations.filter(({ ready }) => ready).map(({ integration }) => ({
|
|
1708
|
+
integration,
|
|
1709
|
+
context: buildIntegrationContext({
|
|
1710
|
+
controller: prepared.base.controller,
|
|
1711
|
+
publicOrigin,
|
|
1712
|
+
auth: routeAuth,
|
|
1713
|
+
stateSigner,
|
|
1714
|
+
sandbox: sandboxConfig,
|
|
1715
|
+
factoryStorage: storage,
|
|
1716
|
+
integrationStorage,
|
|
1717
|
+
sourceControlStorage,
|
|
1718
|
+
integrations: integrationRegistrations,
|
|
1719
|
+
configVersion,
|
|
1720
|
+
boardRegistry: this.#projectBoards ?? this.#boards,
|
|
1721
|
+
...this.#keptCards ? { keptCards: this.#keptCards } : {},
|
|
1722
|
+
...this.#projectBoards ? { notRouted: storedBoardsStorage } : {},
|
|
1723
|
+
factoryReady,
|
|
1724
|
+
domains,
|
|
1725
|
+
...this.#environmentBuilds ? { onRepositoryPush: this.#environmentBuilds.onRepositoryPush } : {},
|
|
1726
|
+
...githubIntegration ? { sourceControlOwnerId: "github" } : {}
|
|
1727
|
+
}, integration.id)
|
|
1728
|
+
}));
|
|
1729
|
+
const integrationWorkers = readyContexts.flatMap(({ integration, context }) => integration.workers ? integration.workers(context) : []);
|
|
1730
|
+
const eventRoutes = readyContexts.flatMap(({ integration, context }) => {
|
|
1731
|
+
if (!isPlatformConnectEventSource(integration)) return [];
|
|
1732
|
+
const route = integration.connectEventRoute(context);
|
|
1733
|
+
return route ? [route] : [];
|
|
1734
|
+
});
|
|
1735
|
+
if (eventRoutes.length > 0) integrationWorkers.push(new PlatformConnectEventPoller({
|
|
1736
|
+
storage: integrationStorage.forIntegration(PLATFORM_CONNECT_EVENT_POLLER_STORAGE_ID),
|
|
1737
|
+
routes: eventRoutes
|
|
1738
|
+
}));
|
|
1698
1739
|
return {
|
|
1699
1740
|
...prepared.mastraArgs,
|
|
1700
1741
|
...auth ? { studio: { auth } } : {},
|