@mastra/factory 0.2.1-alpha.3 → 0.2.1
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 +36 -0
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +3503 -3585
- package/dist/factory.js.map +1 -1
- package/dist/index.js +3503 -3585
- package/dist/index.js.map +1 -1
- package/dist/integrations/base.d.ts +13 -25
- package/dist/integrations/base.d.ts.map +1 -1
- package/dist/integrations/github/integration.d.ts.map +1 -1
- package/dist/integrations/github/integration.js +625 -217
- package/dist/integrations/github/integration.js.map +1 -1
- package/dist/integrations/github/routes.d.ts +1 -4
- package/dist/integrations/github/routes.d.ts.map +1 -1
- package/dist/integrations/github/routes.js +113 -203
- package/dist/integrations/github/routes.js.map +1 -1
- package/dist/integrations/github/rules.d.ts +30 -0
- package/dist/integrations/github/rules.d.ts.map +1 -0
- package/dist/{rules/github-service.js → integrations/github/rules.js} +27 -8
- package/dist/integrations/github/rules.js.map +1 -0
- package/dist/integrations/linear/agent-tools.js.map +1 -1
- package/dist/integrations/linear/integration.d.ts.map +1 -1
- package/dist/integrations/linear/integration.js +352 -3
- package/dist/integrations/linear/integration.js.map +1 -1
- package/dist/integrations/linear/routes.d.ts +2 -2
- package/dist/integrations/linear/routes.d.ts.map +1 -1
- package/dist/integrations/linear/routes.js +2 -2
- package/dist/integrations/linear/routes.js.map +1 -1
- package/dist/integrations/linear/rules.d.ts +42 -0
- package/dist/integrations/linear/rules.d.ts.map +1 -0
- package/dist/{rules/linear-service.js → integrations/linear/rules.js} +14 -4
- package/dist/integrations/linear/rules.js.map +1 -0
- package/dist/integrations/platform/github/integration.d.ts.map +1 -1
- package/dist/integrations/platform/github/integration.js +626 -218
- package/dist/integrations/platform/github/integration.js.map +1 -1
- package/dist/integrations/platform/linear/integration.d.ts.map +1 -1
- package/dist/integrations/platform/linear/integration.js +353 -3
- package/dist/integrations/platform/linear/integration.js.map +1 -1
- package/dist/routes/oauth.js +47 -41
- package/dist/routes/oauth.js.map +1 -1
- package/dist/routes/surface.d.ts +3 -1
- package/dist/routes/surface.d.ts.map +1 -1
- package/dist/routes/surface.js +271 -621
- package/dist/routes/surface.js.map +1 -1
- package/dist/routes/work-items.js.map +1 -1
- package/dist/storage/domains/work-items/base.d.ts.map +1 -1
- package/dist/storage/domains/work-items/base.js +74 -75
- package/dist/storage/domains/work-items/base.js.map +1 -1
- package/dist/storage/domains/work-items/metrics.js.map +1 -1
- package/package.json +7 -7
- package/dist/integrations/github/project-lock.d.ts +0 -100
- package/dist/integrations/github/project-lock.d.ts.map +0 -1
- package/dist/integrations/github/project-lock.js +0 -103
- package/dist/integrations/github/project-lock.js.map +0 -1
- package/dist/rules/github-service.d.ts +0 -29
- package/dist/rules/github-service.d.ts.map +0 -1
- package/dist/rules/github-service.js.map +0 -1
- package/dist/rules/linear-service.d.ts +0 -27
- package/dist/rules/linear-service.d.ts.map +0 -1
- package/dist/rules/linear-service.js.map +0 -1
package/dist/routes/oauth.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 path = `$.metadata.${key}`;
|
|
11027
|
+
conditions.push(`CASE WHEN json_valid(content) THEN json_type(content, ?) IS NOT NULL ELSE 0 END`);
|
|
11028
|
+
params.push(path);
|
|
11029
|
+
addSqliteMetadataValuePredicate(conditions, params, path, value);
|
|
11030
|
+
}
|
|
11031
|
+
}
|
|
11032
|
+
function addSqliteMetadataValuePredicate(conditions, params, path, value) {
|
|
11033
|
+
if (value === null) {
|
|
11034
|
+
conditions.push(`CASE WHEN json_valid(content) THEN json_type(content, ?) = 'null' ELSE 0 END`);
|
|
11035
|
+
params.push(path);
|
|
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(path, path, 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(path, path, 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(path, value ? "true" : "false", path, value ? 1 : 0);
|
|
11056
|
+
}
|
|
11023
11057
|
function parseJson2(value) {
|
|
11024
11058
|
if (value == null) return void 0;
|
|
11025
11059
|
if (typeof value === "string") {
|
|
@@ -11628,29 +11662,14 @@ var init_dist = __esm({
|
|
|
11628
11662
|
this.vectorIndexes = this.isMemoryDb ? Promise.resolve(/* @__PURE__ */ new Set()) : this.discoverVectorIndexes();
|
|
11629
11663
|
}
|
|
11630
11664
|
/**
|
|
11631
|
-
* Closes the underlying libsql client, releasing
|
|
11632
|
-
*
|
|
11633
|
-
* For local file databases, first runs PRAGMA wal_checkpoint(TRUNCATE) and
|
|
11634
|
-
* switches back to journal_mode=DELETE so the -wal and -shm sidecar files
|
|
11635
|
-
* are released promptly (mirrors LibSQLStore.close()).
|
|
11636
|
-
*
|
|
11637
|
-
* Remote (Turso) databases skip the WAL pragmas and just close the client.
|
|
11665
|
+
* Closes the underlying libsql client, releasing this vector store's OS file handles.
|
|
11638
11666
|
*
|
|
11639
11667
|
* Safe to call more than once; subsequent calls are no-ops.
|
|
11640
11668
|
*/
|
|
11641
11669
|
async close() {
|
|
11642
|
-
if (this.turso.closed) {
|
|
11643
|
-
|
|
11644
|
-
}
|
|
11645
|
-
if (this.turso.protocol === "file" && !this.isMemoryDb) {
|
|
11646
|
-
try {
|
|
11647
|
-
await this.turso.execute("PRAGMA wal_checkpoint(TRUNCATE);");
|
|
11648
|
-
await this.turso.execute("PRAGMA journal_mode=DELETE;");
|
|
11649
|
-
} catch (err) {
|
|
11650
|
-
this.logger.warn("LibSQLVector: Failed to checkpoint WAL before close.", err);
|
|
11651
|
-
}
|
|
11670
|
+
if (!this.turso.closed) {
|
|
11671
|
+
this.turso.close();
|
|
11652
11672
|
}
|
|
11653
|
-
this.turso.close();
|
|
11654
11673
|
}
|
|
11655
11674
|
async discoverVectorIndexes() {
|
|
11656
11675
|
try {
|
|
@@ -17844,6 +17863,7 @@ Note: This migration may take some time for large tables.
|
|
|
17844
17863
|
}
|
|
17845
17864
|
const perPage = normalizePerPage(perPageInput, 40);
|
|
17846
17865
|
const { offset, perPage: perPageForResponse } = calculatePagination(page, perPageInput, perPage);
|
|
17866
|
+
const metadataFilter = validateStorageMetadataFilter(filter?.metadata);
|
|
17847
17867
|
try {
|
|
17848
17868
|
const { field, direction } = this.parseOrderBy(orderBy, "ASC");
|
|
17849
17869
|
const orderByStatement = `ORDER BY "${field}" ${direction}`;
|
|
@@ -17868,6 +17888,7 @@ Note: This migration may take some time for large tables.
|
|
|
17868
17888
|
filter.dateRange.end instanceof Date ? filter.dateRange.end.toISOString() : filter.dateRange.end
|
|
17869
17889
|
);
|
|
17870
17890
|
}
|
|
17891
|
+
addSqliteMetadataFilter(conditions, queryParams, metadataFilter);
|
|
17871
17892
|
const whereClause = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
17872
17893
|
if (perPage === 0 && (!include || include.length === 0)) {
|
|
17873
17894
|
return { messages: [], total: 0, page, perPage: perPageForResponse, hasMore: false };
|
|
@@ -17897,6 +17918,7 @@ Note: This migration may take some time for large tables.
|
|
|
17897
17918
|
args: [...queryParams, limitValue, offset]
|
|
17898
17919
|
});
|
|
17899
17920
|
const messages = (dataResult.rows || []).map((row) => this.parseRow(row));
|
|
17921
|
+
const paginatedCount = messages.length;
|
|
17900
17922
|
if (total === 0 && messages.length === 0 && (!include || include.length === 0)) {
|
|
17901
17923
|
return {
|
|
17902
17924
|
messages: [],
|
|
@@ -17925,7 +17947,7 @@ Note: This migration may take some time for large tables.
|
|
|
17925
17947
|
finalMessages.filter((m) => m.threadId && threadIdSet.has(m.threadId)).map((m) => m.id)
|
|
17926
17948
|
);
|
|
17927
17949
|
const allThreadMessagesReturned = returnedThreadMessageIds.size >= total;
|
|
17928
|
-
const hasMore = perPageInput !== false && !allThreadMessagesReturned && offset + perPage < total;
|
|
17950
|
+
const hasMore = metadataFilter ? perPageInput !== false && offset + paginatedCount < total : perPageInput !== false && !allThreadMessagesReturned && offset + perPage < total;
|
|
17929
17951
|
return {
|
|
17930
17952
|
messages: finalMessages,
|
|
17931
17953
|
total,
|
|
@@ -17983,6 +18005,7 @@ Note: This migration may take some time for large tables.
|
|
|
17983
18005
|
}
|
|
17984
18006
|
const perPage = normalizePerPage(perPageInput, 40);
|
|
17985
18007
|
const { offset, perPage: perPageForResponse } = calculatePagination(page, perPageInput, perPage);
|
|
18008
|
+
const metadataFilter = validateStorageMetadataFilter(filter?.metadata);
|
|
17986
18009
|
try {
|
|
17987
18010
|
const { field, direction } = this.parseOrderBy(orderBy, "ASC");
|
|
17988
18011
|
const orderByStatement = `ORDER BY "${field}" ${direction}`;
|
|
@@ -18004,6 +18027,7 @@ Note: This migration may take some time for large tables.
|
|
|
18004
18027
|
filter.dateRange.end instanceof Date ? filter.dateRange.end.toISOString() : filter.dateRange.end
|
|
18005
18028
|
);
|
|
18006
18029
|
}
|
|
18030
|
+
addSqliteMetadataFilter(conditions, queryParams, metadataFilter);
|
|
18007
18031
|
const whereClause = `WHERE ${conditions.join(" AND ")}`;
|
|
18008
18032
|
if (perPage === 0 && (!include || include.length === 0)) {
|
|
18009
18033
|
return { messages: [], total: 0, page, perPage: perPageForResponse, hasMore: false };
|
|
@@ -24409,32 +24433,14 @@ ${unreflectedContent}` : bufferedReflection;
|
|
|
24409
24433
|
await this.initDomainsSequentially();
|
|
24410
24434
|
}
|
|
24411
24435
|
/**
|
|
24412
|
-
* Closes the underlying libsql client, releasing
|
|
24413
|
-
*
|
|
24414
|
-
* For local file databases, first runs PRAGMA wal_checkpoint(TRUNCATE) and
|
|
24415
|
-
* switches back to journal_mode=DELETE so that Windows releases the -wal
|
|
24416
|
-
* and -shm sidecar files promptly. Without this, the handles stay open
|
|
24417
|
-
* until process exit, causing EBUSY errors when callers try to fs.rm the
|
|
24418
|
-
* storage directory after Mastra.shutdown().
|
|
24419
|
-
*
|
|
24420
|
-
* Remote (Turso) databases skip the WAL pragmas and just close the client.
|
|
24436
|
+
* Closes the underlying libsql client, releasing this store's OS file handles.
|
|
24421
24437
|
*
|
|
24422
24438
|
* Safe to call more than once; subsequent calls are no-ops.
|
|
24423
24439
|
*/
|
|
24424
24440
|
async close() {
|
|
24425
|
-
if (this.client.closed) {
|
|
24426
|
-
|
|
24427
|
-
}
|
|
24428
|
-
const isLocalFileDb = this.isLocalDb || this.client.protocol === "file";
|
|
24429
|
-
if (isLocalFileDb) {
|
|
24430
|
-
try {
|
|
24431
|
-
await this.client.execute("PRAGMA wal_checkpoint(TRUNCATE);");
|
|
24432
|
-
await this.client.execute("PRAGMA journal_mode=DELETE;");
|
|
24433
|
-
} catch (err) {
|
|
24434
|
-
this.logger.warn("LibSQLStore: Failed to checkpoint WAL before close.", err);
|
|
24435
|
-
}
|
|
24441
|
+
if (!this.client.closed) {
|
|
24442
|
+
this.client.close();
|
|
24436
24443
|
}
|
|
24437
|
-
this.client.close();
|
|
24438
24444
|
}
|
|
24439
24445
|
};
|
|
24440
24446
|
LIBSQL_PROMPT = `When querying LibSQL Vector, you can ONLY use the operators listed below. Any other operators will be rejected.
|