@mastra/libsql 1.9.0 → 1.9.1-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 +9 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-memory-working-memory.md +1 -1
- package/dist/docs/references/reference-core-mastra-class.md +2 -0
- package/dist/docs/references/reference-storage-composite.md +5 -3
- package/dist/index.cjs +146 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +147 -2
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/channels/index.d.ts +20 -0
- package/dist/storage/domains/channels/index.d.ts.map +1 -0
- package/dist/storage/index.d.ts +2 -1
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createClient } from '@libsql/client';
|
|
2
2
|
import { MastraError, ErrorCategory, ErrorDomain } from '@mastra/core/error';
|
|
3
|
-
import { createVectorErrorId, AgentsStorage, AGENTS_SCHEMA, TABLE_AGENTS, AGENT_VERSIONS_SCHEMA, TABLE_AGENT_VERSIONS, createStorageErrorId, normalizePerPage, calculatePagination, BackgroundTasksStorage, TABLE_SCHEMAS, TABLE_BACKGROUND_TASKS, BlobStore, TABLE_SKILL_BLOBS, SKILL_BLOBS_SCHEMA, DatasetsStorage, DATASETS_SCHEMA, TABLE_DATASETS, DATASET_ITEMS_SCHEMA, TABLE_DATASET_ITEMS, DATASET_VERSIONS_SCHEMA, TABLE_DATASET_VERSIONS, ensureDate, safelyParseJSON, TABLE_EXPERIMENT_RESULTS, TABLE_EXPERIMENTS, ExperimentsStorage, EXPERIMENTS_SCHEMA, EXPERIMENT_RESULTS_SCHEMA, 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_MESSAGES, TABLE_RESOURCES, ObservabilityStorage, SPAN_SCHEMA, TABLE_SPANS, listTracesArgsSchema, toTraceSpans, PromptBlocksStorage, PROMPT_BLOCKS_SCHEMA, TABLE_PROMPT_BLOCKS, PROMPT_BLOCK_VERSIONS_SCHEMA, TABLE_PROMPT_BLOCK_VERSIONS, ScorerDefinitionsStorage, SCORER_DEFINITIONS_SCHEMA, TABLE_SCORER_DEFINITIONS, SCORER_DEFINITION_VERSIONS_SCHEMA, TABLE_SCORER_DEFINITION_VERSIONS, ScoresStorage, SCORERS_SCHEMA, TABLE_SCORERS, transformScoreRow, SkillsStorage, SKILLS_SCHEMA, TABLE_SKILLS, SKILL_VERSIONS_SCHEMA, TABLE_SKILL_VERSIONS, WorkflowsStorage, TABLE_WORKFLOW_SNAPSHOT, WorkspacesStorage, WORKSPACES_SCHEMA, TABLE_WORKSPACES, WORKSPACE_VERSIONS_SCHEMA, TABLE_WORKSPACE_VERSIONS, MastraCompositeStore, getSqlType, TraceStatus } from '@mastra/core/storage';
|
|
3
|
+
import { createVectorErrorId, AgentsStorage, AGENTS_SCHEMA, TABLE_AGENTS, AGENT_VERSIONS_SCHEMA, TABLE_AGENT_VERSIONS, createStorageErrorId, normalizePerPage, calculatePagination, BackgroundTasksStorage, TABLE_SCHEMAS, TABLE_BACKGROUND_TASKS, 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, ensureDate, safelyParseJSON, TABLE_EXPERIMENT_RESULTS, TABLE_EXPERIMENTS, ExperimentsStorage, EXPERIMENTS_SCHEMA, EXPERIMENT_RESULTS_SCHEMA, 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_MESSAGES, TABLE_RESOURCES, ObservabilityStorage, SPAN_SCHEMA, TABLE_SPANS, listTracesArgsSchema, toTraceSpans, PromptBlocksStorage, PROMPT_BLOCKS_SCHEMA, TABLE_PROMPT_BLOCKS, PROMPT_BLOCK_VERSIONS_SCHEMA, TABLE_PROMPT_BLOCK_VERSIONS, ScorerDefinitionsStorage, SCORER_DEFINITIONS_SCHEMA, TABLE_SCORER_DEFINITIONS, SCORER_DEFINITION_VERSIONS_SCHEMA, TABLE_SCORER_DEFINITION_VERSIONS, ScoresStorage, SCORERS_SCHEMA, TABLE_SCORERS, transformScoreRow, SkillsStorage, SKILLS_SCHEMA, TABLE_SKILLS, SKILL_VERSIONS_SCHEMA, TABLE_SKILL_VERSIONS, WorkflowsStorage, TABLE_WORKFLOW_SNAPSHOT, WorkspacesStorage, WORKSPACES_SCHEMA, TABLE_WORKSPACES, WORKSPACE_VERSIONS_SCHEMA, TABLE_WORKSPACE_VERSIONS, MastraCompositeStore, getSqlType, TraceStatus } from '@mastra/core/storage';
|
|
4
4
|
import { parseSqlIdentifier, parseFieldKey } from '@mastra/core/utils';
|
|
5
5
|
import { MastraVector, validateTopK, validateUpsertInput } from '@mastra/core/vector';
|
|
6
6
|
import { BaseFilterTranslator } from '@mastra/core/vector/filter';
|
|
@@ -3278,6 +3278,149 @@ var BlobsLibSQL = class extends BlobStore {
|
|
|
3278
3278
|
};
|
|
3279
3279
|
}
|
|
3280
3280
|
};
|
|
3281
|
+
var ChannelsLibSQL = class extends ChannelsStorage {
|
|
3282
|
+
#db;
|
|
3283
|
+
#client;
|
|
3284
|
+
static MANAGED_TABLES = [TABLE_CHANNEL_INSTALLATIONS, TABLE_CHANNEL_CONFIG];
|
|
3285
|
+
constructor(config) {
|
|
3286
|
+
super();
|
|
3287
|
+
const client = resolveClient(config);
|
|
3288
|
+
this.#client = client;
|
|
3289
|
+
this.#db = new LibSQLDB({ client, maxRetries: config.maxRetries, initialBackoffMs: config.initialBackoffMs });
|
|
3290
|
+
}
|
|
3291
|
+
async init() {
|
|
3292
|
+
await this.#db.createTable({
|
|
3293
|
+
tableName: TABLE_CHANNEL_INSTALLATIONS,
|
|
3294
|
+
schema: TABLE_SCHEMAS[TABLE_CHANNEL_INSTALLATIONS]
|
|
3295
|
+
});
|
|
3296
|
+
await this.#db.createTable({
|
|
3297
|
+
tableName: TABLE_CHANNEL_CONFIG,
|
|
3298
|
+
schema: TABLE_SCHEMAS[TABLE_CHANNEL_CONFIG]
|
|
3299
|
+
});
|
|
3300
|
+
await this.#client.execute(
|
|
3301
|
+
`CREATE UNIQUE INDEX IF NOT EXISTS idx_channel_installations_webhook ON "${TABLE_CHANNEL_INSTALLATIONS}" ("webhookId")`
|
|
3302
|
+
);
|
|
3303
|
+
await this.#client.execute(
|
|
3304
|
+
`CREATE INDEX IF NOT EXISTS idx_channel_installations_platform_agent ON "${TABLE_CHANNEL_INSTALLATIONS}" ("platform", "agentId")`
|
|
3305
|
+
);
|
|
3306
|
+
}
|
|
3307
|
+
async dangerouslyClearAll() {
|
|
3308
|
+
await this.#db.deleteData({ tableName: TABLE_CHANNEL_INSTALLATIONS });
|
|
3309
|
+
await this.#db.deleteData({ tableName: TABLE_CHANNEL_CONFIG });
|
|
3310
|
+
}
|
|
3311
|
+
async saveInstallation(installation) {
|
|
3312
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3313
|
+
await this.#client.execute({
|
|
3314
|
+
sql: `
|
|
3315
|
+
INSERT INTO "${TABLE_CHANNEL_INSTALLATIONS}" (id, platform, agentId, status, webhookId, data, configHash, error, createdAt, updatedAt)
|
|
3316
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
3317
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
3318
|
+
platform = excluded.platform,
|
|
3319
|
+
agentId = excluded.agentId,
|
|
3320
|
+
status = excluded.status,
|
|
3321
|
+
webhookId = excluded.webhookId,
|
|
3322
|
+
data = excluded.data,
|
|
3323
|
+
configHash = excluded.configHash,
|
|
3324
|
+
error = excluded.error,
|
|
3325
|
+
updatedAt = excluded.updatedAt
|
|
3326
|
+
`,
|
|
3327
|
+
args: [
|
|
3328
|
+
installation.id,
|
|
3329
|
+
installation.platform,
|
|
3330
|
+
installation.agentId,
|
|
3331
|
+
installation.status,
|
|
3332
|
+
installation.webhookId ?? null,
|
|
3333
|
+
JSON.stringify(installation.data),
|
|
3334
|
+
installation.configHash ?? null,
|
|
3335
|
+
installation.error ?? null,
|
|
3336
|
+
installation.createdAt?.toISOString() ?? now,
|
|
3337
|
+
now
|
|
3338
|
+
]
|
|
3339
|
+
});
|
|
3340
|
+
}
|
|
3341
|
+
async getInstallation(id) {
|
|
3342
|
+
const result = await this.#client.execute({
|
|
3343
|
+
sql: `SELECT * FROM "${TABLE_CHANNEL_INSTALLATIONS}" WHERE id = ?`,
|
|
3344
|
+
args: [id]
|
|
3345
|
+
});
|
|
3346
|
+
const row = result.rows?.[0];
|
|
3347
|
+
return row ? this.#parseInstallationRow(row) : null;
|
|
3348
|
+
}
|
|
3349
|
+
async getInstallationByAgent(platform, agentId) {
|
|
3350
|
+
const result = await this.#client.execute({
|
|
3351
|
+
sql: `SELECT * FROM "${TABLE_CHANNEL_INSTALLATIONS}" WHERE platform = ? AND agentId = ? ORDER BY CASE status WHEN 'active' THEN 0 WHEN 'pending' THEN 1 ELSE 2 END, updatedAt DESC LIMIT 1`,
|
|
3352
|
+
args: [platform, agentId]
|
|
3353
|
+
});
|
|
3354
|
+
const row = result.rows?.[0];
|
|
3355
|
+
return row ? this.#parseInstallationRow(row) : null;
|
|
3356
|
+
}
|
|
3357
|
+
async getInstallationByWebhookId(webhookId) {
|
|
3358
|
+
const result = await this.#client.execute({
|
|
3359
|
+
sql: `SELECT * FROM "${TABLE_CHANNEL_INSTALLATIONS}" WHERE webhookId = ?`,
|
|
3360
|
+
args: [webhookId]
|
|
3361
|
+
});
|
|
3362
|
+
const row = result.rows?.[0];
|
|
3363
|
+
return row ? this.#parseInstallationRow(row) : null;
|
|
3364
|
+
}
|
|
3365
|
+
async listInstallations(platform) {
|
|
3366
|
+
const result = await this.#client.execute({
|
|
3367
|
+
sql: `SELECT * FROM "${TABLE_CHANNEL_INSTALLATIONS}" WHERE platform = ? ORDER BY createdAt DESC`,
|
|
3368
|
+
args: [platform]
|
|
3369
|
+
});
|
|
3370
|
+
return result.rows.map((row) => this.#parseInstallationRow(row));
|
|
3371
|
+
}
|
|
3372
|
+
async deleteInstallation(id) {
|
|
3373
|
+
await this.#client.execute({
|
|
3374
|
+
sql: `DELETE FROM "${TABLE_CHANNEL_INSTALLATIONS}" WHERE id = ?`,
|
|
3375
|
+
args: [id]
|
|
3376
|
+
});
|
|
3377
|
+
}
|
|
3378
|
+
async saveConfig(config) {
|
|
3379
|
+
await this.#client.execute({
|
|
3380
|
+
sql: `
|
|
3381
|
+
INSERT INTO "${TABLE_CHANNEL_CONFIG}" (platform, data, updatedAt)
|
|
3382
|
+
VALUES (?, ?, ?)
|
|
3383
|
+
ON CONFLICT(platform) DO UPDATE SET
|
|
3384
|
+
data = excluded.data,
|
|
3385
|
+
updatedAt = excluded.updatedAt
|
|
3386
|
+
`,
|
|
3387
|
+
args: [config.platform, JSON.stringify(config.data), config.updatedAt.toISOString()]
|
|
3388
|
+
});
|
|
3389
|
+
}
|
|
3390
|
+
async getConfig(platform) {
|
|
3391
|
+
const result = await this.#client.execute({
|
|
3392
|
+
sql: `SELECT * FROM "${TABLE_CHANNEL_CONFIG}" WHERE platform = ?`,
|
|
3393
|
+
args: [platform]
|
|
3394
|
+
});
|
|
3395
|
+
const row = result.rows?.[0];
|
|
3396
|
+
if (!row) return null;
|
|
3397
|
+
return {
|
|
3398
|
+
platform: row.platform,
|
|
3399
|
+
data: JSON.parse(row.data || "{}"),
|
|
3400
|
+
updatedAt: new Date(row.updatedAt)
|
|
3401
|
+
};
|
|
3402
|
+
}
|
|
3403
|
+
async deleteConfig(platform) {
|
|
3404
|
+
await this.#client.execute({
|
|
3405
|
+
sql: `DELETE FROM "${TABLE_CHANNEL_CONFIG}" WHERE platform = ?`,
|
|
3406
|
+
args: [platform]
|
|
3407
|
+
});
|
|
3408
|
+
}
|
|
3409
|
+
#parseInstallationRow(row) {
|
|
3410
|
+
return {
|
|
3411
|
+
id: row.id,
|
|
3412
|
+
platform: row.platform,
|
|
3413
|
+
agentId: row.agentId,
|
|
3414
|
+
status: row.status,
|
|
3415
|
+
webhookId: row.webhookId || void 0,
|
|
3416
|
+
data: JSON.parse(row.data || "{}"),
|
|
3417
|
+
configHash: row.configHash || void 0,
|
|
3418
|
+
error: row.error || void 0,
|
|
3419
|
+
createdAt: new Date(row.createdAt),
|
|
3420
|
+
updatedAt: new Date(row.updatedAt)
|
|
3421
|
+
};
|
|
3422
|
+
}
|
|
3423
|
+
};
|
|
3281
3424
|
function jsonbArg(value) {
|
|
3282
3425
|
return value === void 0 || value === null ? null : JSON.stringify(value);
|
|
3283
3426
|
}
|
|
@@ -10971,6 +11114,7 @@ var LibSQLStore = class extends MastraCompositeStore {
|
|
|
10971
11114
|
const memory = new MemoryLibSQL(domainConfig);
|
|
10972
11115
|
const observability = new ObservabilityLibSQL(domainConfig);
|
|
10973
11116
|
const agents = new AgentsLibSQL(domainConfig);
|
|
11117
|
+
const channels = new ChannelsLibSQL(domainConfig);
|
|
10974
11118
|
const datasets = new DatasetsLibSQL(domainConfig);
|
|
10975
11119
|
const experiments = new ExperimentsLibSQL(domainConfig);
|
|
10976
11120
|
const promptBlocks = new PromptBlocksLibSQL(domainConfig);
|
|
@@ -10987,6 +11131,7 @@ var LibSQLStore = class extends MastraCompositeStore {
|
|
|
10987
11131
|
memory,
|
|
10988
11132
|
observability,
|
|
10989
11133
|
agents,
|
|
11134
|
+
channels,
|
|
10990
11135
|
datasets,
|
|
10991
11136
|
experiments,
|
|
10992
11137
|
promptBlocks,
|
|
@@ -11100,6 +11245,6 @@ Example Complex Query:
|
|
|
11100
11245
|
]
|
|
11101
11246
|
}`;
|
|
11102
11247
|
|
|
11103
|
-
export { AgentsLibSQL, BackgroundTasksLibSQL, BlobsLibSQL, DatasetsLibSQL, LibSQLStore as DefaultStorage, ExperimentsLibSQL, LIBSQL_PROMPT, LibSQLStore, LibSQLVector, MCPClientsLibSQL, MCPServersLibSQL, MemoryLibSQL, ObservabilityLibSQL, PromptBlocksLibSQL, ScorerDefinitionsLibSQL, ScoresLibSQL, SkillsLibSQL, WorkflowsLibSQL, WorkspacesLibSQL };
|
|
11248
|
+
export { AgentsLibSQL, BackgroundTasksLibSQL, BlobsLibSQL, ChannelsLibSQL, DatasetsLibSQL, LibSQLStore as DefaultStorage, ExperimentsLibSQL, LIBSQL_PROMPT, LibSQLStore, LibSQLVector, MCPClientsLibSQL, MCPServersLibSQL, MemoryLibSQL, ObservabilityLibSQL, PromptBlocksLibSQL, ScorerDefinitionsLibSQL, ScoresLibSQL, SkillsLibSQL, WorkflowsLibSQL, WorkspacesLibSQL };
|
|
11104
11249
|
//# sourceMappingURL=index.js.map
|
|
11105
11250
|
//# sourceMappingURL=index.js.map
|