@mastra/libsql 1.1.0-alpha.0 → 1.1.0-alpha.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/dist/index.js CHANGED
@@ -2081,21 +2081,9 @@ var AgentsLibSQL = class extends AgentsStorage {
2081
2081
  parseRow(row) {
2082
2082
  return {
2083
2083
  id: row.id,
2084
- name: row.name,
2085
- description: row.description,
2086
- instructions: row.instructions,
2087
- model: this.parseJson(row.model, "model"),
2088
- tools: this.parseJson(row.tools, "tools"),
2089
- defaultOptions: this.parseJson(row.defaultOptions, "defaultOptions"),
2090
- workflows: this.parseJson(row.workflows, "workflows"),
2091
- agents: this.parseJson(row.agents, "agents"),
2092
- inputProcessors: this.parseJson(row.inputProcessors, "inputProcessors"),
2093
- outputProcessors: this.parseJson(row.outputProcessors, "outputProcessors"),
2094
- memory: this.parseJson(row.memory, "memory"),
2095
- scorers: this.parseJson(row.scorers, "scorers"),
2096
- integrationTools: this.parseJson(row.integrationTools, "integrationTools"),
2097
- ownerId: row.ownerId,
2084
+ status: row.status,
2098
2085
  activeVersionId: row.activeVersionId,
2086
+ authorId: row.authorId,
2099
2087
  metadata: this.parseJson(row.metadata, "metadata"),
2100
2088
  createdAt: new Date(row.createdAt),
2101
2089
  updatedAt: new Date(row.updatedAt)
@@ -2127,32 +2115,48 @@ var AgentsLibSQL = class extends AgentsStorage {
2127
2115
  tableName: TABLE_AGENTS,
2128
2116
  record: {
2129
2117
  id: agent.id,
2130
- name: agent.name,
2131
- description: agent.description ?? null,
2132
- instructions: agent.instructions,
2133
- model: agent.model,
2134
- tools: agent.tools ?? null,
2135
- defaultOptions: agent.defaultOptions ?? null,
2136
- workflows: agent.workflows ?? null,
2137
- agents: agent.agents ?? null,
2138
- inputProcessors: agent.inputProcessors ?? null,
2139
- outputProcessors: agent.outputProcessors ?? null,
2140
- memory: agent.memory ?? null,
2141
- scorers: agent.scorers ?? null,
2142
- integrationTools: agent.integrationTools ?? null,
2143
- ownerId: agent.ownerId ?? null,
2144
- activeVersionId: agent.activeVersionId ?? null,
2118
+ status: "draft",
2119
+ activeVersionId: null,
2120
+ authorId: agent.authorId ?? null,
2145
2121
  metadata: agent.metadata ?? null,
2146
2122
  createdAt: now,
2147
2123
  updatedAt: now
2148
2124
  }
2149
2125
  });
2150
- return {
2151
- ...agent,
2152
- createdAt: now,
2153
- updatedAt: now
2154
- };
2126
+ const { id: _id, authorId: _authorId, metadata: _metadata, ...snapshotConfig } = agent;
2127
+ const versionId = crypto.randomUUID();
2128
+ await this.createVersion({
2129
+ id: versionId,
2130
+ agentId: agent.id,
2131
+ versionNumber: 1,
2132
+ ...snapshotConfig,
2133
+ changedFields: Object.keys(snapshotConfig),
2134
+ changeMessage: "Initial version"
2135
+ });
2136
+ await this.#db.update({
2137
+ tableName: TABLE_AGENTS,
2138
+ keys: { id: agent.id },
2139
+ data: {
2140
+ activeVersionId: versionId,
2141
+ status: "published",
2142
+ updatedAt: /* @__PURE__ */ new Date()
2143
+ }
2144
+ });
2145
+ const created = await this.getAgentById({ id: agent.id });
2146
+ if (!created) {
2147
+ throw new MastraError({
2148
+ id: createStorageErrorId("LIBSQL", "CREATE_AGENT", "NOT_FOUND_AFTER_CREATE"),
2149
+ domain: ErrorDomain.STORAGE,
2150
+ category: ErrorCategory.SYSTEM,
2151
+ text: `Agent ${agent.id} not found after creation`,
2152
+ details: { agentId: agent.id }
2153
+ });
2154
+ }
2155
+ return created;
2155
2156
  } catch (error) {
2157
+ if (error instanceof MastraError) {
2158
+ throw error;
2159
+ }
2156
2160
  throw new MastraError(
2157
2161
  {
2158
2162
  id: createStorageErrorId("LIBSQL", "CREATE_AGENT", "FAILED"),
@@ -2179,21 +2183,11 @@ var AgentsLibSQL = class extends AgentsStorage {
2179
2183
  const data = {
2180
2184
  updatedAt: /* @__PURE__ */ new Date()
2181
2185
  };
2182
- if (updates.name !== void 0) data.name = updates.name;
2183
- if (updates.description !== void 0) data.description = updates.description;
2184
- if (updates.instructions !== void 0) data.instructions = updates.instructions;
2185
- if (updates.model !== void 0) data.model = updates.model;
2186
- if (updates.tools !== void 0) data.tools = updates.tools;
2187
- if (updates.defaultOptions !== void 0) data.defaultOptions = updates.defaultOptions;
2188
- if (updates.workflows !== void 0) data.workflows = updates.workflows;
2189
- if (updates.agents !== void 0) data.agents = updates.agents;
2190
- if (updates.inputProcessors !== void 0) data.inputProcessors = updates.inputProcessors;
2191
- if (updates.outputProcessors !== void 0) data.outputProcessors = updates.outputProcessors;
2192
- if (updates.memory !== void 0) data.memory = updates.memory;
2193
- if (updates.scorers !== void 0) data.scorers = updates.scorers;
2194
- if (updates.integrationTools !== void 0) data.integrationTools = updates.integrationTools;
2195
- if (updates.ownerId !== void 0) data.ownerId = updates.ownerId;
2196
- if (updates.activeVersionId !== void 0) data.activeVersionId = updates.activeVersionId;
2186
+ if (updates.authorId !== void 0) data.authorId = updates.authorId;
2187
+ if (updates.activeVersionId !== void 0) {
2188
+ data.activeVersionId = updates.activeVersionId;
2189
+ data.status = "published";
2190
+ }
2197
2191
  if (updates.metadata !== void 0) {
2198
2192
  data.metadata = { ...existingAgent.metadata, ...updates.metadata };
2199
2193
  }
@@ -2315,7 +2309,18 @@ var AgentsLibSQL = class extends AgentsStorage {
2315
2309
  agentId: input.agentId,
2316
2310
  versionNumber: input.versionNumber,
2317
2311
  name: input.name ?? null,
2318
- snapshot: input.snapshot,
2312
+ description: input.description ?? null,
2313
+ instructions: input.instructions,
2314
+ model: input.model,
2315
+ tools: input.tools ?? null,
2316
+ defaultOptions: input.defaultOptions ?? null,
2317
+ workflows: input.workflows ?? null,
2318
+ agents: input.agents ?? null,
2319
+ integrationTools: input.integrationTools ?? null,
2320
+ inputProcessors: input.inputProcessors ?? null,
2321
+ outputProcessors: input.outputProcessors ?? null,
2322
+ memory: input.memory ?? null,
2323
+ scorers: input.scorers ?? null,
2319
2324
  changedFields: input.changedFields ?? null,
2320
2325
  changeMessage: input.changeMessage ?? null,
2321
2326
  createdAt: now
@@ -2552,7 +2557,18 @@ var AgentsLibSQL = class extends AgentsStorage {
2552
2557
  agentId: row.agentId,
2553
2558
  versionNumber: row.versionNumber,
2554
2559
  name: row.name,
2555
- snapshot: this.parseJson(row.snapshot, "snapshot"),
2560
+ description: row.description,
2561
+ instructions: row.instructions,
2562
+ model: this.parseJson(row.model, "model"),
2563
+ tools: this.parseJson(row.tools, "tools"),
2564
+ defaultOptions: this.parseJson(row.defaultOptions, "defaultOptions"),
2565
+ workflows: this.parseJson(row.workflows, "workflows"),
2566
+ agents: this.parseJson(row.agents, "agents"),
2567
+ integrationTools: this.parseJson(row.integrationTools, "integrationTools"),
2568
+ inputProcessors: this.parseJson(row.inputProcessors, "inputProcessors"),
2569
+ outputProcessors: this.parseJson(row.outputProcessors, "outputProcessors"),
2570
+ memory: this.parseJson(row.memory, "memory"),
2571
+ scorers: this.parseJson(row.scorers, "scorers"),
2556
2572
  changedFields: this.parseJson(row.changedFields, "changedFields"),
2557
2573
  changeMessage: row.changeMessage,
2558
2574
  createdAt: new Date(row.createdAt)