@mastra/factory 0.2.1-alpha.4 → 0.2.2-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/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # @mastra/factory
2
2
 
3
+ ## 0.2.2-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`0dca9d0`](https://github.com/mastra-ai/mastra/commit/0dca9d0b1356024a53b72ea6f040db528b126caa)]:
8
+ - @mastra/core@1.54.0-alpha.0
9
+ - @mastra/code-sdk@1.0.3-alpha.0
10
+
11
+ ## 0.2.1
12
+
13
+ ### Patch Changes
14
+
15
+ - Removed Git and GitHub route locking that held database transactions open during sandbox and network operations. ([#20135](https://github.com/mastra-ai/mastra/pull/20135))
16
+
17
+ - Improved Platform GitHub event polling efficiency and added event-count and latency logging for each poll. ([#20123](https://github.com/mastra-ai/mastra/pull/20123))
18
+
19
+ - Bound the `withProjectLock` / `withDbAdvisoryLock` critical section with an `AbortSignal` timeout (default 60s, configurable via `timeoutMs`). Previously, an unbounded outbound call inside the lock could keep the transaction open for up to Neon's `idle_in_transaction_session_timeout` (5 minutes), pinning the pool connection and the advisory lock the entire time. On timeout the wrapper aborts the `fn`'s signal, rolls the transaction back, releases the connection, and throws `ProjectLockTimeoutError`. ([#20129](https://github.com/mastra-ai/mastra/pull/20129))
20
+
21
+ - Improved Factory work-item concurrency by replacing distributed advisory locks with atomic claims, idempotent replay, and serializable relationship transactions. ([#20135](https://github.com/mastra-ai/mastra/pull/20135))
22
+
23
+ - Fixed the workspace files panel in Factory web returning "Path is outside the browsable root" for Factory sessions. The workspace file endpoints now recognize a session id, reattach to that session's sandbox, and list and read rendered files (like .artifacts) directly from the sandbox, so session artifacts render on deployed factories. ([#20101](https://github.com/mastra-ai/mastra/pull/20101))
24
+
25
+ - Added an updateIssue capability to the Intake surface so Factory can change the state of external issues (open/closed on GitHub, workflow state on Linear) as a side effect of stage transitions. Adapters cover the direct GitHub, direct Linear, platform GitHub, and platform Linear integrations. GitHub adapters reject pull-request targets. Linear adapters resolve the target workflow state per team and skip when the issue is already in the desired state. The platform Linear adapter degrades to a no-op (returns null) when the platform workflow-states endpoint is not yet deployed, so this change is safe to ship ahead of the platform companion route. This is a plumbing change: no rule currently emits the new decision, so behavior is unchanged. ([#20111](https://github.com/mastra-ai/mastra/pull/20111))
26
+
27
+ - Fixed Factory integrations so GitHub and Linear attach their own event rules. This restores work-item rule ingestion for Platform-backed Linear intake and for the Platform GitHub issue poller. ([#20169](https://github.com/mastra-ai/mastra/pull/20169))
28
+
29
+ - Updated dependencies [[`c8d8a01`](https://github.com/mastra-ai/mastra/commit/c8d8a010ee2efe2b7bf4d07707382c34c87b14e4), [`f497717`](https://github.com/mastra-ai/mastra/commit/f497717304ad76043f689711ccc044f0cd51ba41), [`df6a9ce`](https://github.com/mastra-ai/mastra/commit/df6a9ce87214f7aadb2edfe62f67605fe998a0a4), [`73839cb`](https://github.com/mastra-ai/mastra/commit/73839cb58322679c170627d1015669ede5f619aa), [`371cf60`](https://github.com/mastra-ai/mastra/commit/371cf6075cef88ac6919a08d59a82e485397364a), [`8e4dc79`](https://github.com/mastra-ai/mastra/commit/8e4dc793dcf035ea506f9ce79f56d2d501a4be14), [`2db93cc`](https://github.com/mastra-ai/mastra/commit/2db93ccd0b872e4de7853a93383efe0647901df8), [`094ab61`](https://github.com/mastra-ai/mastra/commit/094ab6129a1a3ecf6eeb86decac17d5faea4e02a), [`fe80944`](https://github.com/mastra-ai/mastra/commit/fe80944f3ef6681fea6eae8200fce387b7bb3c2f), [`cadd3a2`](https://github.com/mastra-ai/mastra/commit/cadd3a276f8e0026e3c84cffe935538419cb890c), [`263d2ca`](https://github.com/mastra-ai/mastra/commit/263d2cac80ba3b03b9c0f008db6f1f1b9eb0278c), [`75f843d`](https://github.com/mastra-ai/mastra/commit/75f843d09f758223e6eeb321321bdcc5c7e779d0), [`e51e166`](https://github.com/mastra-ai/mastra/commit/e51e166c52e220abc9b64554ce37359dca8544b1)]:
30
+ - @mastra/core@1.53.0
31
+ - @mastra/code-sdk@1.0.2
32
+
3
33
  ## 0.2.1-alpha.4
4
34
 
5
35
  ### Patch Changes
package/dist/factory.js CHANGED
@@ -10404,7 +10404,7 @@ __export(dist_exports, {
10404
10404
  WorkspacesLibSQL: () => WorkspacesLibSQL
10405
10405
  });
10406
10406
  import { MastraError, ErrorCategory, ErrorDomain } from "@mastra/core/error";
10407
- import { createVectorErrorId, AgentsStorage, AGENTS_SCHEMA, TABLE_AGENTS, AGENT_VERSIONS_SCHEMA, TABLE_AGENT_VERSIONS, createStorageErrorId, normalizePerPage, calculatePagination, BackgroundTasksStorage, TABLE_BACKGROUND_TASKS, TABLE_SCHEMAS, BlobStore, TABLE_SKILL_BLOBS, SKILL_BLOBS_SCHEMA, ChannelsStorage, TABLE_CHANNEL_INSTALLATIONS, TABLE_CHANNEL_CONFIG, DatasetsStorage, DATASETS_SCHEMA, TABLE_DATASETS, DATASET_ITEMS_SCHEMA, TABLE_DATASET_ITEMS, DATASET_VERSIONS_SCHEMA, TABLE_DATASET_VERSIONS, TABLE_EXPERIMENTS, TABLE_EXPERIMENT_RESULTS, ensureDate, safelyParseJSON, hasErrorCode, ExperimentsStorage, EXPERIMENTS_SCHEMA, EXPERIMENT_RESULTS_SCHEMA, FavoritesStorage, FAVORITES_SCHEMA, TABLE_FAVORITES, TABLE_SKILLS, HarnessStorage, TABLE_HARNESS_SESSIONS, MCPClientsStorage, MCP_CLIENTS_SCHEMA, TABLE_MCP_CLIENTS, MCP_CLIENT_VERSIONS_SCHEMA, TABLE_MCP_CLIENT_VERSIONS, MCPServersStorage, MCP_SERVERS_SCHEMA, TABLE_MCP_SERVERS, MCP_SERVER_VERSIONS_SCHEMA, TABLE_MCP_SERVER_VERSIONS, MemoryStorage, TABLE_THREADS, TABLE_RESOURCES, TABLE_MESSAGES, OBSERVATIONAL_MEMORY_TABLE_SCHEMA, NotificationsStorage, TABLE_NOTIFICATIONS, ObservabilityStorage, TABLE_SPANS, SPAN_SCHEMA, listTracesArgsSchema, toTraceSpans, PromptBlocksStorage, PROMPT_BLOCKS_SCHEMA, TABLE_PROMPT_BLOCKS, PROMPT_BLOCK_VERSIONS_SCHEMA, TABLE_PROMPT_BLOCK_VERSIONS, SchedulesStorage, TABLE_SCHEDULE_TRIGGERS, TABLE_SCHEDULES, ScorerDefinitionsStorage, SCORER_DEFINITIONS_SCHEMA, TABLE_SCORER_DEFINITIONS, SCORER_DEFINITION_VERSIONS_SCHEMA, TABLE_SCORER_DEFINITION_VERSIONS, ScoresStorage, TABLE_SCORERS, SCORERS_SCHEMA, transformScoreRow, SkillsStorage, SKILLS_SCHEMA, SKILL_VERSIONS_SCHEMA, TABLE_SKILL_VERSIONS, ThreadStateStorage, TABLE_THREAD_STATE, THREAD_STATE_SCHEMA, ToolProviderConnectionsStorage, TOOL_PROVIDER_CONNECTIONS_SCHEMA, TABLE_TOOL_PROVIDER_CONNECTIONS, WorkflowsStorage, TABLE_WORKFLOW_SNAPSHOT, WorkspacesStorage, WORKSPACES_SCHEMA, TABLE_WORKSPACES, WORKSPACE_VERSIONS_SCHEMA, TABLE_WORKSPACE_VERSIONS, FactoryStorage, MastraCompositeStore, getSqlType, parseDuration, normalizeScheduleTarget, UniqueViolationError as UniqueViolationError2, TraceStatus, mergeWorkflowStepResult } from "@mastra/core/storage";
10407
+ import { createVectorErrorId, AgentsStorage, AGENTS_SCHEMA, TABLE_AGENTS, AGENT_VERSIONS_SCHEMA, TABLE_AGENT_VERSIONS, createStorageErrorId, normalizePerPage, calculatePagination, BackgroundTasksStorage, TABLE_BACKGROUND_TASKS, TABLE_SCHEMAS, BlobStore, TABLE_SKILL_BLOBS, SKILL_BLOBS_SCHEMA, ChannelsStorage, TABLE_CHANNEL_INSTALLATIONS, TABLE_CHANNEL_CONFIG, DatasetsStorage, DATASETS_SCHEMA, TABLE_DATASETS, DATASET_ITEMS_SCHEMA, TABLE_DATASET_ITEMS, DATASET_VERSIONS_SCHEMA, TABLE_DATASET_VERSIONS, TABLE_EXPERIMENTS, TABLE_EXPERIMENT_RESULTS, ensureDate, safelyParseJSON, hasErrorCode, ExperimentsStorage, EXPERIMENTS_SCHEMA, EXPERIMENT_RESULTS_SCHEMA, FavoritesStorage, FAVORITES_SCHEMA, TABLE_FAVORITES, TABLE_SKILLS, HarnessStorage, TABLE_HARNESS_SESSIONS, MCPClientsStorage, MCP_CLIENTS_SCHEMA, TABLE_MCP_CLIENTS, MCP_CLIENT_VERSIONS_SCHEMA, TABLE_MCP_CLIENT_VERSIONS, MCPServersStorage, MCP_SERVERS_SCHEMA, TABLE_MCP_SERVERS, MCP_SERVER_VERSIONS_SCHEMA, TABLE_MCP_SERVER_VERSIONS, MemoryStorage, TABLE_THREADS, TABLE_RESOURCES, TABLE_MESSAGES, OBSERVATIONAL_MEMORY_TABLE_SCHEMA, validateStorageMetadataFilter, NotificationsStorage, TABLE_NOTIFICATIONS, ObservabilityStorage, TABLE_SPANS, SPAN_SCHEMA, listTracesArgsSchema, toTraceSpans, PromptBlocksStorage, PROMPT_BLOCKS_SCHEMA, TABLE_PROMPT_BLOCKS, PROMPT_BLOCK_VERSIONS_SCHEMA, TABLE_PROMPT_BLOCK_VERSIONS, SchedulesStorage, TABLE_SCHEDULE_TRIGGERS, TABLE_SCHEDULES, ScorerDefinitionsStorage, SCORER_DEFINITIONS_SCHEMA, TABLE_SCORER_DEFINITIONS, SCORER_DEFINITION_VERSIONS_SCHEMA, TABLE_SCORER_DEFINITION_VERSIONS, ScoresStorage, TABLE_SCORERS, SCORERS_SCHEMA, transformScoreRow, SkillsStorage, SKILLS_SCHEMA, SKILL_VERSIONS_SCHEMA, TABLE_SKILL_VERSIONS, ThreadStateStorage, TABLE_THREAD_STATE, THREAD_STATE_SCHEMA, ToolProviderConnectionsStorage, TOOL_PROVIDER_CONNECTIONS_SCHEMA, TABLE_TOOL_PROVIDER_CONNECTIONS, WorkflowsStorage, TABLE_WORKFLOW_SNAPSHOT, WorkspacesStorage, WORKSPACES_SCHEMA, TABLE_WORKSPACES, WORKSPACE_VERSIONS_SCHEMA, TABLE_WORKSPACE_VERSIONS, FactoryStorage, MastraCompositeStore, getSqlType, parseDuration, normalizeScheduleTarget, UniqueViolationError as UniqueViolationError2, TraceStatus, mergeWorkflowStepResult } from "@mastra/core/storage";
10408
10408
  import { parseSqlIdentifier, parseFieldKey } from "@mastra/core/utils";
10409
10409
  import { MastraVector, validateTopK, validateUpsertInput } from "@mastra/core/vector";
10410
10410
  import { BaseFilterTranslator } from "@mastra/core/vector/filter";
@@ -11020,6 +11020,40 @@ function sessionToRecord(record) {
11020
11020
  deletedAt: record.deletedAt ?? null
11021
11021
  };
11022
11022
  }
11023
+ function addSqliteMetadataFilter(conditions, params, metadataFilter) {
11024
+ if (!metadataFilter) return;
11025
+ for (const [key, value] of Object.entries(metadataFilter)) {
11026
+ const path3 = `$.metadata.${key}`;
11027
+ conditions.push(`CASE WHEN json_valid(content) THEN json_type(content, ?) IS NOT NULL ELSE 0 END`);
11028
+ params.push(path3);
11029
+ addSqliteMetadataValuePredicate(conditions, params, path3, value);
11030
+ }
11031
+ }
11032
+ function addSqliteMetadataValuePredicate(conditions, params, path3, value) {
11033
+ if (value === null) {
11034
+ conditions.push(`CASE WHEN json_valid(content) THEN json_type(content, ?) = 'null' ELSE 0 END`);
11035
+ params.push(path3);
11036
+ return;
11037
+ }
11038
+ if (typeof value === "string") {
11039
+ conditions.push(
11040
+ `CASE WHEN json_valid(content) THEN json_type(content, ?) = 'text' AND json_extract(content, ?) = ? ELSE 0 END`
11041
+ );
11042
+ params.push(path3, path3, value);
11043
+ return;
11044
+ }
11045
+ if (typeof value === "number") {
11046
+ conditions.push(
11047
+ `CASE WHEN json_valid(content) THEN json_type(content, ?) IN ('integer', 'real') AND json_extract(content, ?) = ? ELSE 0 END`
11048
+ );
11049
+ params.push(path3, path3, value);
11050
+ return;
11051
+ }
11052
+ conditions.push(
11053
+ `CASE WHEN json_valid(content) THEN json_type(content, ?) = ? AND json_extract(content, ?) = ? ELSE 0 END`
11054
+ );
11055
+ params.push(path3, value ? "true" : "false", path3, value ? 1 : 0);
11056
+ }
11023
11057
  function parseJson2(value) {
11024
11058
  if (value == null) return void 0;
11025
11059
  if (typeof value === "string") {
@@ -17829,6 +17863,7 @@ Note: This migration may take some time for large tables.
17829
17863
  }
17830
17864
  const perPage = normalizePerPage(perPageInput, 40);
17831
17865
  const { offset, perPage: perPageForResponse } = calculatePagination(page, perPageInput, perPage);
17866
+ const metadataFilter = validateStorageMetadataFilter(filter?.metadata);
17832
17867
  try {
17833
17868
  const { field, direction } = this.parseOrderBy(orderBy, "ASC");
17834
17869
  const orderByStatement = `ORDER BY "${field}" ${direction}`;
@@ -17853,6 +17888,7 @@ Note: This migration may take some time for large tables.
17853
17888
  filter.dateRange.end instanceof Date ? filter.dateRange.end.toISOString() : filter.dateRange.end
17854
17889
  );
17855
17890
  }
17891
+ addSqliteMetadataFilter(conditions, queryParams, metadataFilter);
17856
17892
  const whereClause = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
17857
17893
  if (perPage === 0 && (!include || include.length === 0)) {
17858
17894
  return { messages: [], total: 0, page, perPage: perPageForResponse, hasMore: false };
@@ -17882,6 +17918,7 @@ Note: This migration may take some time for large tables.
17882
17918
  args: [...queryParams, limitValue, offset]
17883
17919
  });
17884
17920
  const messages = (dataResult.rows || []).map((row) => this.parseRow(row));
17921
+ const paginatedCount = messages.length;
17885
17922
  if (total === 0 && messages.length === 0 && (!include || include.length === 0)) {
17886
17923
  return {
17887
17924
  messages: [],
@@ -17910,7 +17947,7 @@ Note: This migration may take some time for large tables.
17910
17947
  finalMessages.filter((m) => m.threadId && threadIdSet.has(m.threadId)).map((m) => m.id)
17911
17948
  );
17912
17949
  const allThreadMessagesReturned = returnedThreadMessageIds.size >= total;
17913
- const hasMore = perPageInput !== false && !allThreadMessagesReturned && offset + perPage < total;
17950
+ const hasMore = metadataFilter ? perPageInput !== false && offset + paginatedCount < total : perPageInput !== false && !allThreadMessagesReturned && offset + perPage < total;
17914
17951
  return {
17915
17952
  messages: finalMessages,
17916
17953
  total,
@@ -17968,6 +18005,7 @@ Note: This migration may take some time for large tables.
17968
18005
  }
17969
18006
  const perPage = normalizePerPage(perPageInput, 40);
17970
18007
  const { offset, perPage: perPageForResponse } = calculatePagination(page, perPageInput, perPage);
18008
+ const metadataFilter = validateStorageMetadataFilter(filter?.metadata);
17971
18009
  try {
17972
18010
  const { field, direction } = this.parseOrderBy(orderBy, "ASC");
17973
18011
  const orderByStatement = `ORDER BY "${field}" ${direction}`;
@@ -17989,6 +18027,7 @@ Note: This migration may take some time for large tables.
17989
18027
  filter.dateRange.end instanceof Date ? filter.dateRange.end.toISOString() : filter.dateRange.end
17990
18028
  );
17991
18029
  }
18030
+ addSqliteMetadataFilter(conditions, queryParams, metadataFilter);
17992
18031
  const whereClause = `WHERE ${conditions.join(" AND ")}`;
17993
18032
  if (perPage === 0 && (!include || include.length === 0)) {
17994
18033
  return { messages: [], total: 0, page, perPage: perPageForResponse, hasMore: false };