@mastra/server 1.6.0 → 1.7.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 +22 -0
- package/dist/{chunk-P4O7OBGH.cjs → chunk-3BKGGOC6.cjs} +3 -3
- package/dist/{chunk-P4O7OBGH.cjs.map → chunk-3BKGGOC6.cjs.map} +1 -1
- package/dist/{chunk-CMYJ32N3.js → chunk-EFKPTKKF.js} +51 -15
- package/dist/chunk-EFKPTKKF.js.map +1 -0
- package/dist/{chunk-NC6UUX6D.js → chunk-KTGIAURI.js} +3 -2
- package/dist/chunk-KTGIAURI.js.map +1 -0
- package/dist/{chunk-NGFAF6WW.cjs → chunk-MJLQLQ6K.cjs} +51 -15
- package/dist/chunk-MJLQLQ6K.cjs.map +1 -0
- package/dist/{chunk-VHBLYGH7.js → chunk-PGB5HYV7.js} +3 -3
- package/dist/{chunk-VHBLYGH7.js.map → chunk-PGB5HYV7.js.map} +1 -1
- package/dist/{chunk-GPRCK7GP.cjs → chunk-ZE4IJKQD.cjs} +3 -2
- package/dist/chunk-ZE4IJKQD.cjs.map +1 -0
- package/dist/{observational-memory-ZNTAIUGT-565A3END.cjs → observational-memory-AJWSMZVP-HI6EWRCH.cjs} +29 -12
- package/dist/observational-memory-AJWSMZVP-HI6EWRCH.cjs.map +1 -0
- package/dist/{observational-memory-ZNTAIUGT-VIXA4SKE.js → observational-memory-AJWSMZVP-J3OYOGXO.js} +29 -12
- package/dist/observational-memory-AJWSMZVP-J3OYOGXO.js.map +1 -0
- package/dist/server/handlers/agent-builder.cjs +16 -16
- package/dist/server/handlers/agent-builder.js +1 -1
- package/dist/server/handlers/prompt-block-versions.cjs +8 -8
- package/dist/server/handlers/prompt-block-versions.d.ts +6 -0
- package/dist/server/handlers/prompt-block-versions.d.ts.map +1 -1
- package/dist/server/handlers/prompt-block-versions.js +1 -1
- package/dist/server/handlers/stored-prompt-blocks.cjs +6 -6
- package/dist/server/handlers/stored-prompt-blocks.d.ts +16 -4
- package/dist/server/handlers/stored-prompt-blocks.d.ts.map +1 -1
- package/dist/server/handlers/stored-prompt-blocks.js +1 -1
- package/dist/server/handlers.cjs +2 -2
- package/dist/server/handlers.js +1 -1
- package/dist/server/schemas/prompt-block-versions.d.ts +27 -0
- package/dist/server/schemas/prompt-block-versions.d.ts.map +1 -1
- package/dist/server/schemas/stored-prompt-blocks.d.ts +44 -4
- package/dist/server/schemas/stored-prompt-blocks.d.ts.map +1 -1
- package/dist/server/server-adapter/index.cjs +30 -30
- package/dist/server/server-adapter/index.js +3 -3
- package/package.json +6 -6
- package/dist/chunk-CMYJ32N3.js.map +0 -1
- package/dist/chunk-GPRCK7GP.cjs.map +0 -1
- package/dist/chunk-NC6UUX6D.js.map +0 -1
- package/dist/chunk-NGFAF6WW.cjs.map +0 -1
- package/dist/docs/SKILL.md +0 -28
- package/dist/docs/assets/SOURCE_MAP.json +0 -6
- package/dist/docs/references/docs-server-custom-adapters.md +0 -374
- package/dist/docs/references/reference-server-create-route.md +0 -260
- package/dist/docs/references/reference-server-mastra-server.md +0 -298
- package/dist/docs/references/reference-server-routes.md +0 -306
- package/dist/observational-memory-ZNTAIUGT-565A3END.cjs.map +0 -1
- package/dist/observational-memory-ZNTAIUGT-VIXA4SKE.js.map +0 -1
|
@@ -16,7 +16,7 @@ var storageOrderBySchema = z.object({
|
|
|
16
16
|
});
|
|
17
17
|
var listStoredPromptBlocksQuerySchema = createPagePaginationSchema(100).extend({
|
|
18
18
|
orderBy: storageOrderBySchema.optional(),
|
|
19
|
-
status: z.enum(["draft", "published", "archived"]).optional().
|
|
19
|
+
status: z.enum(["draft", "published", "archived"]).optional().describe("Filter prompt blocks by status. When omitted, returns all prompt blocks regardless of status"),
|
|
20
20
|
authorId: z.string().optional().describe("Filter prompt blocks by author identifier"),
|
|
21
21
|
metadata: z.record(z.string(), z.unknown()).optional().describe("Filter prompt blocks by metadata key-value pairs")
|
|
22
22
|
});
|
|
@@ -24,7 +24,8 @@ var snapshotConfigSchema = z.object({
|
|
|
24
24
|
name: z.string().describe("Display name of the prompt block"),
|
|
25
25
|
description: z.string().optional().describe("Purpose description"),
|
|
26
26
|
content: z.string().describe("Template content with {{variable}} interpolation"),
|
|
27
|
-
rules: ruleGroupSchema.optional().describe("Rules for conditional inclusion")
|
|
27
|
+
rules: ruleGroupSchema.optional().describe("Rules for conditional inclusion"),
|
|
28
|
+
requestContextSchema: z.record(z.string(), z.unknown()).optional().describe("JSON Schema defining available variables for {{variableName}} interpolation and conditions")
|
|
28
29
|
});
|
|
29
30
|
var createStoredPromptBlockBodySchema = z.object({
|
|
30
31
|
id: z.string().optional().describe("Unique identifier. If not provided, derived from name."),
|
|
@@ -39,6 +40,7 @@ var storedPromptBlockSchema = z.object({
|
|
|
39
40
|
id: z.string(),
|
|
40
41
|
status: z.string().describe("Prompt block status: draft, published, or archived"),
|
|
41
42
|
activeVersionId: z.string().optional(),
|
|
43
|
+
hasDraft: z.boolean().optional().describe("Whether the prompt block has unpublished draft changes"),
|
|
42
44
|
authorId: z.string().optional(),
|
|
43
45
|
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
44
46
|
createdAt: z.coerce.date(),
|
|
@@ -46,7 +48,8 @@ var storedPromptBlockSchema = z.object({
|
|
|
46
48
|
name: z.string().describe("Display name of the prompt block"),
|
|
47
49
|
description: z.string().optional().describe("Purpose description"),
|
|
48
50
|
content: z.string().describe("Template content with {{variable}} interpolation"),
|
|
49
|
-
rules: ruleGroupSchema.optional().describe("Rules for conditional inclusion")
|
|
51
|
+
rules: ruleGroupSchema.optional().describe("Rules for conditional inclusion"),
|
|
52
|
+
requestContextSchema: z.record(z.string(), z.unknown()).optional().describe("JSON Schema defining available variables for {{variableName}} interpolation and conditions")
|
|
50
53
|
});
|
|
51
54
|
var listStoredPromptBlocksResponseSchema = paginationInfoSchema.extend({
|
|
52
55
|
promptBlocks: z.array(storedPromptBlockSchema)
|
|
@@ -71,7 +74,16 @@ var deleteStoredPromptBlockResponseSchema = z.object({
|
|
|
71
74
|
});
|
|
72
75
|
|
|
73
76
|
// src/server/handlers/stored-prompt-blocks.ts
|
|
74
|
-
var PROMPT_BLOCK_SNAPSHOT_CONFIG_FIELDS = [
|
|
77
|
+
var PROMPT_BLOCK_SNAPSHOT_CONFIG_FIELDS = [
|
|
78
|
+
"name",
|
|
79
|
+
"description",
|
|
80
|
+
"content",
|
|
81
|
+
"rules",
|
|
82
|
+
"requestContextSchema"
|
|
83
|
+
];
|
|
84
|
+
function computeHasDraft(latestVersion, activeVersionId) {
|
|
85
|
+
return !!(latestVersion && (!activeVersionId || latestVersion.id !== activeVersionId));
|
|
86
|
+
}
|
|
75
87
|
var LIST_STORED_PROMPT_BLOCKS_ROUTE = createRoute({
|
|
76
88
|
method: "GET",
|
|
77
89
|
path: "/stored/prompt-blocks",
|
|
@@ -100,7 +112,13 @@ var LIST_STORED_PROMPT_BLOCKS_ROUTE = createRoute({
|
|
|
100
112
|
authorId,
|
|
101
113
|
metadata
|
|
102
114
|
});
|
|
103
|
-
|
|
115
|
+
const promptBlocks = await Promise.all(
|
|
116
|
+
result.promptBlocks.map(async (block) => {
|
|
117
|
+
const latestVersion = await promptBlockStore.getLatestVersion(block.id);
|
|
118
|
+
return { ...block, hasDraft: computeHasDraft(latestVersion, block.activeVersionId) };
|
|
119
|
+
})
|
|
120
|
+
);
|
|
121
|
+
return { ...result, promptBlocks };
|
|
104
122
|
} catch (error) {
|
|
105
123
|
return handleError(error, "Error listing stored prompt blocks");
|
|
106
124
|
}
|
|
@@ -131,7 +149,8 @@ var GET_STORED_PROMPT_BLOCK_ROUTE = createRoute({
|
|
|
131
149
|
if (!promptBlock) {
|
|
132
150
|
throw new HTTPException(404, { message: `Stored prompt block with id ${storedPromptBlockId} not found` });
|
|
133
151
|
}
|
|
134
|
-
|
|
152
|
+
const latestVersion = await promptBlockStore.getLatestVersion(storedPromptBlockId);
|
|
153
|
+
return { ...promptBlock, hasDraft: computeHasDraft(latestVersion, promptBlock.activeVersionId) };
|
|
135
154
|
} catch (error) {
|
|
136
155
|
return handleError(error, "Error getting stored prompt block");
|
|
137
156
|
}
|
|
@@ -147,7 +166,17 @@ var CREATE_STORED_PROMPT_BLOCK_ROUTE = createRoute({
|
|
|
147
166
|
description: "Creates a new prompt block in storage with the provided configuration",
|
|
148
167
|
tags: ["Stored Prompt Blocks"],
|
|
149
168
|
requiresAuth: true,
|
|
150
|
-
handler: async ({
|
|
169
|
+
handler: async ({
|
|
170
|
+
mastra,
|
|
171
|
+
id: providedId,
|
|
172
|
+
authorId,
|
|
173
|
+
metadata,
|
|
174
|
+
name,
|
|
175
|
+
description,
|
|
176
|
+
content,
|
|
177
|
+
rules,
|
|
178
|
+
requestContextSchema
|
|
179
|
+
}) => {
|
|
151
180
|
try {
|
|
152
181
|
const storage = mastra.getStorage();
|
|
153
182
|
if (!storage) {
|
|
@@ -175,14 +204,17 @@ var CREATE_STORED_PROMPT_BLOCK_ROUTE = createRoute({
|
|
|
175
204
|
name,
|
|
176
205
|
description,
|
|
177
206
|
content,
|
|
178
|
-
rules
|
|
207
|
+
rules,
|
|
208
|
+
requestContextSchema
|
|
179
209
|
}
|
|
180
210
|
});
|
|
181
211
|
const resolved = await promptBlockStore.getByIdResolved(id, { status: "draft" });
|
|
182
212
|
if (!resolved) {
|
|
183
213
|
throw new HTTPException(500, { message: "Failed to resolve created prompt block" });
|
|
184
214
|
}
|
|
185
|
-
|
|
215
|
+
const latestVersion = await promptBlockStore.getLatestVersion(id);
|
|
216
|
+
const hasDraft = !!(latestVersion && (!resolved.activeVersionId || latestVersion.id !== resolved.activeVersionId));
|
|
217
|
+
return { ...resolved, hasDraft };
|
|
186
218
|
} catch (error) {
|
|
187
219
|
return handleError(error, "Error creating stored prompt block");
|
|
188
220
|
}
|
|
@@ -209,7 +241,8 @@ var UPDATE_STORED_PROMPT_BLOCK_ROUTE = createRoute({
|
|
|
209
241
|
name,
|
|
210
242
|
description,
|
|
211
243
|
content,
|
|
212
|
-
rules
|
|
244
|
+
rules,
|
|
245
|
+
requestContextSchema
|
|
213
246
|
}) => {
|
|
214
247
|
try {
|
|
215
248
|
const storage = mastra.getStorage();
|
|
@@ -231,9 +264,10 @@ var UPDATE_STORED_PROMPT_BLOCK_ROUTE = createRoute({
|
|
|
231
264
|
name,
|
|
232
265
|
description,
|
|
233
266
|
content,
|
|
234
|
-
rules
|
|
267
|
+
rules,
|
|
268
|
+
requestContextSchema
|
|
235
269
|
});
|
|
236
|
-
const configFields = { name, description, content, rules };
|
|
270
|
+
const configFields = { name, description, content, rules, requestContextSchema };
|
|
237
271
|
const providedConfigFields = Object.fromEntries(Object.entries(configFields).filter(([_, v]) => v !== void 0));
|
|
238
272
|
await handleAutoVersioning(
|
|
239
273
|
promptBlockStore,
|
|
@@ -248,7 +282,9 @@ var UPDATE_STORED_PROMPT_BLOCK_ROUTE = createRoute({
|
|
|
248
282
|
if (!resolved) {
|
|
249
283
|
throw new HTTPException(500, { message: "Failed to resolve updated prompt block" });
|
|
250
284
|
}
|
|
251
|
-
|
|
285
|
+
const latestVersion = await promptBlockStore.getLatestVersion(storedPromptBlockId);
|
|
286
|
+
const hasDraft = !!(latestVersion && (!resolved.activeVersionId || latestVersion.id !== resolved.activeVersionId));
|
|
287
|
+
return { ...resolved, hasDraft };
|
|
252
288
|
} catch (error) {
|
|
253
289
|
return handleError(error, "Error updating stored prompt block");
|
|
254
290
|
}
|
|
@@ -290,5 +326,5 @@ var DELETE_STORED_PROMPT_BLOCK_ROUTE = createRoute({
|
|
|
290
326
|
});
|
|
291
327
|
|
|
292
328
|
export { CREATE_STORED_PROMPT_BLOCK_ROUTE, DELETE_STORED_PROMPT_BLOCK_ROUTE, GET_STORED_PROMPT_BLOCK_ROUTE, LIST_STORED_PROMPT_BLOCKS_ROUTE, UPDATE_STORED_PROMPT_BLOCK_ROUTE };
|
|
293
|
-
//# sourceMappingURL=chunk-
|
|
294
|
-
//# sourceMappingURL=chunk-
|
|
329
|
+
//# sourceMappingURL=chunk-EFKPTKKF.js.map
|
|
330
|
+
//# sourceMappingURL=chunk-EFKPTKKF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/server/schemas/stored-prompt-blocks.ts","../src/server/handlers/stored-prompt-blocks.ts"],"names":[],"mappings":";;;;;;;;;AASO,IAAM,6BAAA,GAAgC,EAAE,MAAA,CAAO;AAAA,EACpD,mBAAA,EAAqB,CAAA,CAAE,MAAA,EAAO,CAAE,SAAS,+CAA+C;AAC1F,CAAC,CAAA;AAMD,IAAM,oBAAA,GAAuB,EAAE,MAAA,CAAO;AAAA,EACpC,KAAA,EAAO,EAAE,IAAA,CAAK,CAAC,aAAa,WAAW,CAAC,EAAE,QAAA,EAAS;AAAA,EACnD,SAAA,EAAW,EAAE,IAAA,CAAK,CAAC,OAAO,MAAM,CAAC,EAAE,QAAA;AACrC,CAAC,CAAA;AAIM,IAAM,iCAAA,GAAoC,0BAAA,CAA2B,GAAG,CAAA,CAAE,MAAA,CAAO;AAAA,EACtF,OAAA,EAAS,qBAAqB,QAAA,EAAS;AAAA,EACvC,MAAA,EAAQ,CAAA,CACL,IAAA,CAAK,CAAC,OAAA,EAAS,WAAA,EAAa,UAAU,CAAC,CAAA,CACvC,QAAA,EAAS,CACT,QAAA,CAAS,8FAA8F,CAAA;AAAA,EAC1G,UAAU,CAAA,CAAE,MAAA,GAAS,QAAA,EAAS,CAAE,SAAS,2CAA2C,CAAA;AAAA,EACpF,QAAA,EAAU,CAAA,CAAE,MAAA,CAAO,CAAA,CAAE,MAAA,EAAO,EAAG,CAAA,CAAE,OAAA,EAAS,CAAA,CAAE,QAAA,EAAS,CAAE,SAAS,kDAAkD;AACpH,CAAC,CAAA;AAMD,IAAM,oBAAA,GAAuB,EAAE,MAAA,CAAO;AAAA,EACpC,IAAA,EAAM,CAAA,CAAE,MAAA,EAAO,CAAE,SAAS,kCAAkC,CAAA;AAAA,EAC5D,aAAa,CAAA,CAAE,MAAA,GAAS,QAAA,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AAM,CAAC,sBAAsB,CAAA;AAAA,EAC7B,YAAA,EAAc,IAAA;AAAA,EACd,OAAA,EAAS,OAAO,EAAE,MAAA,EAAQ,qBAAoB,KAAM;AAClD,IAAA,IAAI;AACF,MAAA,MAAM,OAAA,GAAU,OAAO,UAAA,EAAW;AAElC,MAAA,IAAI,CAAC,OAAA,EAAS;AACZ,QAAA,MAAM,IAAI,aAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,6BAA6B,CAAA;AAAA,MACvE;AAEA,MAAA,MAAM,gBAAA,GAAmB,MAAM,OAAA,CAAQ,QAAA,CAAS,cAAc,CAAA;AAC9D,MAAA,IAAI,CAAC,gBAAA,EAAkB;AACrB,QAAA,MAAM,IAAI,aAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,iDAAiD,CAAA;AAAA,MAC3F;AAGA,MAAA,MAAM,QAAA,GAAW,MAAM,gBAAA,CAAiB,OAAA,CAAQ,mBAAmB,CAAA;AACnE,MAAA,IAAI,CAAC,QAAA,EAAU;AACb,QAAA,MAAM,IAAI,cAAc,GAAA,EAAK,EAAE,SAAS,CAAA,4BAAA,EAA+B,mBAAmB,cAAc,CAAA;AAAA,MAC1G;AAEA,MAAA,MAAM,gBAAA,CAAiB,OAAO,mBAAmB,CAAA;AAEjD,MAAA,OAAO;AAAA,QACL,OAAA,EAAS,IAAA;AAAA,QACT,OAAA,EAAS,gBAAgB,mBAAmB,CAAA,qBAAA;AAAA,OAC9C;AAAA,IACF,SAAS,KAAA,EAAO;AACd,MAAA,OAAO,WAAA,CAAY,OAAO,oCAAoC,CAAA;AAAA,IAChE;AAAA,EACF;AACF,CAAC","file":"chunk-EFKPTKKF.js","sourcesContent":["import z from 'zod';\n\nimport { paginationInfoSchema, createPagePaginationSchema, statusQuerySchema } from './common';\nimport { ruleGroupSchema } from './rule-group';\n\n// ============================================================================\n// Path Parameter Schemas\n// ============================================================================\n\nexport const storedPromptBlockIdPathParams = z.object({\n storedPromptBlockId: z.string().describe('Unique identifier for the stored prompt block'),\n});\n\n// ============================================================================\n// Query Parameter Schemas\n// ============================================================================\n\nconst storageOrderBySchema = z.object({\n field: z.enum(['createdAt', 'updatedAt']).optional(),\n direction: z.enum(['ASC', 'DESC']).optional(),\n});\n\nexport { statusQuerySchema };\n\nexport const listStoredPromptBlocksQuerySchema = createPagePaginationSchema(100).extend({\n orderBy: storageOrderBySchema.optional(),\n status: z\n .enum(['draft', 'published', 'archived'])\n .optional()\n .describe('Filter prompt blocks by status. When omitted, returns all prompt blocks regardless of status'),\n authorId: z.string().optional().describe('Filter prompt blocks by author identifier'),\n metadata: z.record(z.string(), z.unknown()).optional().describe('Filter prompt blocks by metadata key-value pairs'),\n});\n\n// ============================================================================\n// Body Parameter Schemas\n// ============================================================================\n\nconst snapshotConfigSchema = z.object({\n name: z.string().describe('Display name of the prompt block'),\n description: z.string().optional().describe('Purpose description'),\n content: z.string().describe('Template content with {{variable}} interpolation'),\n rules: ruleGroupSchema.optional().describe('Rules for conditional inclusion'),\n requestContextSchema: z\n .record(z.string(), z.unknown())\n .optional()\n .describe('JSON Schema defining available variables for {{variableName}} interpolation and conditions'),\n});\n\nexport const createStoredPromptBlockBodySchema = z\n .object({\n id: z.string().optional().describe('Unique identifier. If not provided, derived from name.'),\n authorId: z.string().optional().describe('Author identifier for multi-tenant filtering'),\n metadata: z.record(z.string(), z.unknown()).optional().describe('Additional metadata for the prompt block'),\n })\n .merge(snapshotConfigSchema);\n\nexport const updateStoredPromptBlockBodySchema = z\n .object({\n authorId: z.string().optional(),\n metadata: z.record(z.string(), z.unknown()).optional(),\n })\n .merge(snapshotConfigSchema.partial());\n\n// ============================================================================\n// Response Schemas\n// ============================================================================\n\nexport const storedPromptBlockSchema = z.object({\n id: z.string(),\n status: z.string().describe('Prompt block status: draft, published, or archived'),\n activeVersionId: z.string().optional(),\n hasDraft: z.boolean().optional().describe('Whether the prompt block has unpublished draft changes'),\n authorId: z.string().optional(),\n metadata: z.record(z.string(), z.unknown()).optional(),\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n name: z.string().describe('Display name of the prompt block'),\n description: z.string().optional().describe('Purpose description'),\n content: z.string().describe('Template content with {{variable}} interpolation'),\n rules: ruleGroupSchema.optional().describe('Rules for conditional inclusion'),\n requestContextSchema: z\n .record(z.string(), z.unknown())\n .optional()\n .describe('JSON Schema defining available variables for {{variableName}} interpolation and conditions'),\n});\n\nexport const listStoredPromptBlocksResponseSchema = paginationInfoSchema.extend({\n promptBlocks: z.array(storedPromptBlockSchema),\n});\n\nexport const getStoredPromptBlockResponseSchema = storedPromptBlockSchema;\nexport const createStoredPromptBlockResponseSchema = storedPromptBlockSchema;\n\nexport const updateStoredPromptBlockResponseSchema = z.union([\n z.object({\n id: z.string(),\n status: z.string(),\n activeVersionId: z.string().optional(),\n authorId: z.string().optional(),\n metadata: z.record(z.string(), z.unknown()).optional(),\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n }),\n storedPromptBlockSchema,\n]);\n\nexport const deleteStoredPromptBlockResponseSchema = z.object({\n success: z.boolean(),\n message: z.string(),\n});\n","import { HTTPException } from '../http-exception';\nimport {\n storedPromptBlockIdPathParams,\n statusQuerySchema,\n listStoredPromptBlocksQuerySchema,\n createStoredPromptBlockBodySchema,\n updateStoredPromptBlockBodySchema,\n listStoredPromptBlocksResponseSchema,\n getStoredPromptBlockResponseSchema,\n createStoredPromptBlockResponseSchema,\n updateStoredPromptBlockResponseSchema,\n deleteStoredPromptBlockResponseSchema,\n} from '../schemas/stored-prompt-blocks';\nimport { createRoute } from '../server-adapter/routes/route-builder';\nimport { toSlug } from '../utils';\n\nimport { handleError } from './error';\nimport { handleAutoVersioning } from './version-helpers';\nimport type { VersionedStoreInterface } from './version-helpers';\n\nconst PROMPT_BLOCK_SNAPSHOT_CONFIG_FIELDS = [\n 'name',\n 'description',\n 'content',\n 'rules',\n 'requestContextSchema',\n] as const;\n\n/** Computes whether a prompt block has an unpublished draft version. */\nfunction computeHasDraft(\n latestVersion: { id: string } | null | undefined,\n activeVersionId: string | null | undefined,\n): boolean {\n return !!(latestVersion && (!activeVersionId || latestVersion.id !== activeVersionId));\n}\n\n// ============================================================================\n// Route Definitions\n// ============================================================================\n\n/**\n * GET /stored/prompt-blocks - List all stored prompt blocks\n */\nexport const LIST_STORED_PROMPT_BLOCKS_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/prompt-blocks',\n responseType: 'json',\n queryParamSchema: listStoredPromptBlocksQuerySchema,\n responseSchema: listStoredPromptBlocksResponseSchema,\n summary: 'List stored prompt blocks',\n description: 'Returns a paginated list of all prompt blocks stored in the database',\n tags: ['Stored Prompt Blocks'],\n requiresAuth: true,\n handler: async ({ mastra, page, perPage, orderBy, status, authorId, metadata }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n const result = await promptBlockStore.listResolved({\n page,\n perPage,\n orderBy,\n status,\n authorId,\n metadata,\n });\n\n // For each block, fetch the latest version to compute hasDraft.\n // resolvedVersionId from listResolved defaults to 'published' resolution,\n // so we need the actual latest version to detect unpublished drafts.\n const promptBlocks = await Promise.all(\n result.promptBlocks.map(async (block: (typeof result.promptBlocks)[number]) => {\n const latestVersion = await promptBlockStore.getLatestVersion(block.id);\n return { ...block, hasDraft: computeHasDraft(latestVersion, block.activeVersionId) };\n }),\n );\n\n return { ...result, promptBlocks };\n } catch (error) {\n return handleError(error, 'Error listing stored prompt blocks');\n }\n },\n});\n\n/**\n * GET /stored/prompt-blocks/:storedPromptBlockId - Get a stored prompt block by ID\n */\nexport const GET_STORED_PROMPT_BLOCK_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/prompt-blocks/:storedPromptBlockId',\n responseType: 'json',\n pathParamSchema: storedPromptBlockIdPathParams,\n queryParamSchema: statusQuerySchema,\n responseSchema: getStoredPromptBlockResponseSchema,\n summary: 'Get stored prompt block by ID',\n description:\n 'Returns a specific prompt block from storage by its unique identifier. Use ?status=draft to resolve with the latest (draft) version, or ?status=published (default) for the active published version.',\n tags: ['Stored Prompt Blocks'],\n requiresAuth: true,\n handler: async ({ mastra, storedPromptBlockId, status }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n const promptBlock = await promptBlockStore.getByIdResolved(storedPromptBlockId, { status });\n\n if (!promptBlock) {\n throw new HTTPException(404, { message: `Stored prompt block with id ${storedPromptBlockId} not found` });\n }\n\n const latestVersion = await promptBlockStore.getLatestVersion(storedPromptBlockId);\n\n return { ...promptBlock, hasDraft: computeHasDraft(latestVersion, promptBlock.activeVersionId) };\n } catch (error) {\n return handleError(error, 'Error getting stored prompt block');\n }\n },\n});\n\n/**\n * POST /stored/prompt-blocks - Create a new stored prompt block\n */\nexport const CREATE_STORED_PROMPT_BLOCK_ROUTE = createRoute({\n method: 'POST',\n path: '/stored/prompt-blocks',\n responseType: 'json',\n bodySchema: createStoredPromptBlockBodySchema,\n responseSchema: createStoredPromptBlockResponseSchema,\n summary: 'Create stored prompt block',\n description: 'Creates a new prompt block in storage with the provided configuration',\n tags: ['Stored Prompt Blocks'],\n requiresAuth: true,\n handler: async ({\n mastra,\n id: providedId,\n authorId,\n metadata,\n name,\n description,\n content,\n rules,\n requestContextSchema,\n }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n // Derive ID from name if not explicitly provided\n const id = providedId || toSlug(name);\n\n if (!id) {\n throw new HTTPException(400, {\n message: 'Could not derive prompt block ID from name. Please provide an explicit id.',\n });\n }\n\n // Check if prompt block with this ID already exists\n const existing = await promptBlockStore.getById(id);\n if (existing) {\n throw new HTTPException(409, { message: `Prompt block with id ${id} already exists` });\n }\n\n await promptBlockStore.create({\n promptBlock: {\n id,\n authorId,\n metadata,\n name,\n description,\n content,\n rules,\n requestContextSchema,\n },\n });\n\n // Return the resolved prompt block (thin record + version config)\n // Use draft status since newly created entities start as drafts\n const resolved = await promptBlockStore.getByIdResolved(id, { status: 'draft' });\n if (!resolved) {\n throw new HTTPException(500, { message: 'Failed to resolve created prompt block' });\n }\n\n const latestVersion = await promptBlockStore.getLatestVersion(id);\n const hasDraft = !!(\n latestVersion &&\n (!resolved.activeVersionId || latestVersion.id !== resolved.activeVersionId)\n );\n\n return { ...resolved, hasDraft };\n } catch (error) {\n return handleError(error, 'Error creating stored prompt block');\n }\n },\n});\n\n/**\n * PATCH /stored/prompt-blocks/:storedPromptBlockId - Update a stored prompt block\n */\nexport const UPDATE_STORED_PROMPT_BLOCK_ROUTE = createRoute({\n method: 'PATCH',\n path: '/stored/prompt-blocks/:storedPromptBlockId',\n responseType: 'json',\n pathParamSchema: storedPromptBlockIdPathParams,\n bodySchema: updateStoredPromptBlockBodySchema,\n responseSchema: updateStoredPromptBlockResponseSchema,\n summary: 'Update stored prompt block',\n description: 'Updates an existing prompt block in storage with the provided fields',\n tags: ['Stored Prompt Blocks'],\n requiresAuth: true,\n handler: async ({\n mastra,\n storedPromptBlockId,\n // Metadata-level fields\n authorId,\n metadata,\n // Config fields (snapshot-level)\n name,\n description,\n content,\n rules,\n requestContextSchema,\n }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n // Check if prompt block exists\n const existing = await promptBlockStore.getById(storedPromptBlockId);\n if (!existing) {\n throw new HTTPException(404, { message: `Stored prompt block with id ${storedPromptBlockId} not found` });\n }\n\n // Update the prompt block with both metadata-level and config-level fields\n const updatedPromptBlock = await promptBlockStore.update({\n id: storedPromptBlockId,\n authorId,\n metadata,\n name,\n description,\n content,\n rules,\n requestContextSchema,\n });\n\n // Build the snapshot config for auto-versioning comparison\n const configFields = { name, description, content, rules, requestContextSchema };\n\n // Filter out undefined values to get only the config fields that were provided\n const providedConfigFields = Object.fromEntries(Object.entries(configFields).filter(([_, v]) => v !== undefined));\n\n // Handle auto-versioning with retry logic for race conditions\n // This creates a new version if there are meaningful config changes.\n // It does NOT update activeVersionId — the version stays as a draft until explicitly published.\n await handleAutoVersioning(\n promptBlockStore as unknown as VersionedStoreInterface,\n storedPromptBlockId,\n 'blockId',\n PROMPT_BLOCK_SNAPSHOT_CONFIG_FIELDS,\n existing,\n updatedPromptBlock,\n providedConfigFields,\n );\n\n // Return the resolved prompt block with the latest (draft) version so the UI sees its edits\n const resolved = await promptBlockStore.getByIdResolved(storedPromptBlockId, { status: 'draft' });\n if (!resolved) {\n throw new HTTPException(500, { message: 'Failed to resolve updated prompt block' });\n }\n\n const latestVersion = await promptBlockStore.getLatestVersion(storedPromptBlockId);\n const hasDraft = !!(\n latestVersion &&\n (!resolved.activeVersionId || latestVersion.id !== resolved.activeVersionId)\n );\n\n return { ...resolved, hasDraft };\n } catch (error) {\n return handleError(error, 'Error updating stored prompt block');\n }\n },\n});\n\n/**\n * DELETE /stored/prompt-blocks/:storedPromptBlockId - Delete a stored prompt block\n */\nexport const DELETE_STORED_PROMPT_BLOCK_ROUTE = createRoute({\n method: 'DELETE',\n path: '/stored/prompt-blocks/:storedPromptBlockId',\n responseType: 'json',\n pathParamSchema: storedPromptBlockIdPathParams,\n responseSchema: deleteStoredPromptBlockResponseSchema,\n summary: 'Delete stored prompt block',\n description: 'Deletes a prompt block from storage by its unique identifier',\n tags: ['Stored Prompt Blocks'],\n requiresAuth: true,\n handler: async ({ mastra, storedPromptBlockId }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n // Check if prompt block exists\n const existing = await promptBlockStore.getById(storedPromptBlockId);\n if (!existing) {\n throw new HTTPException(404, { message: `Stored prompt block with id ${storedPromptBlockId} not found` });\n }\n\n await promptBlockStore.delete(storedPromptBlockId);\n\n return {\n success: true,\n message: `Prompt block ${storedPromptBlockId} deleted successfully`,\n };\n } catch (error) {\n return handleError(error, 'Error deleting stored prompt block');\n }\n },\n});\n"]}
|
|
@@ -25,6 +25,7 @@ var promptBlockVersionSchema = z.object({
|
|
|
25
25
|
description: z.string().optional().describe("Purpose description"),
|
|
26
26
|
content: z.string().describe("Template content with {{variable}} interpolation"),
|
|
27
27
|
rules: ruleGroupSchema.optional().describe("Rules for conditional inclusion"),
|
|
28
|
+
requestContextSchema: z.record(z.string(), z.unknown()).optional().describe("JSON Schema defining available variables for {{variableName}} interpolation and conditions"),
|
|
28
29
|
// Version metadata
|
|
29
30
|
changedFields: z.array(z.string()).optional().describe("Array of field names that changed from the previous version"),
|
|
30
31
|
changeMessage: z.string().optional().describe("Optional message describing the changes"),
|
|
@@ -416,5 +417,5 @@ var COMPARE_PROMPT_BLOCK_VERSIONS_ROUTE = createRoute({
|
|
|
416
417
|
});
|
|
417
418
|
|
|
418
419
|
export { ACTIVATE_PROMPT_BLOCK_VERSION_ROUTE, COMPARE_PROMPT_BLOCK_VERSIONS_ROUTE, CREATE_PROMPT_BLOCK_VERSION_ROUTE, DELETE_PROMPT_BLOCK_VERSION_ROUTE, GET_PROMPT_BLOCK_VERSION_ROUTE, LIST_PROMPT_BLOCK_VERSIONS_ROUTE, RESTORE_PROMPT_BLOCK_VERSION_ROUTE };
|
|
419
|
-
//# sourceMappingURL=chunk-
|
|
420
|
-
//# sourceMappingURL=chunk-
|
|
420
|
+
//# sourceMappingURL=chunk-KTGIAURI.js.map
|
|
421
|
+
//# sourceMappingURL=chunk-KTGIAURI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/server/schemas/prompt-block-versions.ts","../src/server/handlers/prompt-block-versions.ts"],"names":[],"mappings":";;;;;;;;AAcO,IAAM,kCAAA,GAAqC,uBAAA;AAC3C,IAAM,qCAAA,GAAwC,0BAAA;AAC9C,IAAM,kCAAA,GAAqC,uBAAA;AAM3C,IAAM,4BAAA,GAA+B,EAAE,MAAA,CAAO;AAAA,EACnD,aAAA,EAAe,CAAA,CAAE,MAAA,EAAO,CAAE,SAAS,+CAA+C;AACpF,CAAC,CAAA;AAEM,IAAM,8BAAA,GAAiC,EAAE,MAAA,CAAO;AAAA,EACrD,aAAA,EAAe,CAAA,CAAE,MAAA,EAAO,CAAE,SAAS,+CAA+C,CAAA;AAAA,EAClF,SAAA,EAAW,CAAA,CAAE,MAAA,EAAO,CAAE,SAAS,0CAA0C;AAC3E,CAAC,CAAA;AAMM,IAAM,wBAAA,GAA2B,EAAE,MAAA,CAAO;AAAA,EAC/C,EAAA,EAAI,CAAA,CAAE,MAAA,EAAO,CAAE,SAAS,0CAA0C,CAAA;AAAA,EAClE,OAAA,EAAS,CAAA,CAAE,MAAA,EAAO,CAAE,SAAS,gDAAgD,CAAA;AAAA,EAC7E,aAAA,EAAe,CAAA,CAAE,MAAA,EAAO,CAAE,SAAS,0CAA0C,CAAA;AAAA;AAAA,EAE7E,IAAA,EAAM,CAAA,CAAE,MAAA,EAAO,CAAE,SAAS,kCAAkC,CAAA;AAAA,EAC5D,aAAa,CAAA,CAAE,MAAA,GAAS,QAAA,EAAS,CAAE,SAAS,qBAAqB,CAAA;AAAA,EACjE,OAAA,EAAS,CAAA,CAAE,MAAA,EAAO,CAAE,SAAS,kDAAkD,CAAA;AAAA,EAC/E,KAAA,EAAO,eAAA,CAAgB,QAAA,E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chunk-KTGIAURI.js","sourcesContent":["import z from 'zod';\nimport { ruleGroupSchema } from './rule-group';\nimport {\n listVersionsQuerySchema,\n compareVersionsQuerySchema,\n createVersionBodySchema,\n activateVersionResponseSchema,\n deleteVersionResponseSchema,\n versionDiffEntrySchema,\n createListVersionsResponseSchema,\n createCompareVersionsResponseSchema,\n} from './version-common';\n\n// Re-export shared schemas under domain-specific names\nexport const listPromptBlockVersionsQuerySchema = listVersionsQuerySchema;\nexport const comparePromptBlockVersionsQuerySchema = compareVersionsQuerySchema;\nexport const createPromptBlockVersionBodySchema = createVersionBodySchema;\n\n// ============================================================================\n// Path Parameter Schemas\n// ============================================================================\n\nexport const promptBlockVersionPathParams = z.object({\n promptBlockId: z.string().describe('Unique identifier for the stored prompt block'),\n});\n\nexport const promptBlockVersionIdPathParams = z.object({\n promptBlockId: z.string().describe('Unique identifier for the stored prompt block'),\n versionId: z.string().describe('Unique identifier for the version (UUID)'),\n});\n\n// ============================================================================\n// Response Schemas\n// ============================================================================\n\nexport const promptBlockVersionSchema = z.object({\n id: z.string().describe('Unique identifier for the version (UUID)'),\n blockId: z.string().describe('ID of the prompt block this version belongs to'),\n versionNumber: z.number().describe('Sequential version number (1, 2, 3, ...)'),\n // Snapshot config fields\n name: z.string().describe('Display name of the prompt block'),\n description: z.string().optional().describe('Purpose description'),\n content: z.string().describe('Template content with {{variable}} interpolation'),\n rules: ruleGroupSchema.optional().describe('Rules for conditional inclusion'),\n requestContextSchema: z\n .record(z.string(), z.unknown())\n .optional()\n .describe('JSON Schema defining available variables for {{variableName}} interpolation and conditions'),\n // Version metadata\n changedFields: z.array(z.string()).optional().describe('Array of field names that changed from the previous version'),\n changeMessage: z.string().optional().describe('Optional message describing the changes'),\n createdAt: z.coerce.date().describe('When this version was created'),\n});\n\nexport const listPromptBlockVersionsResponseSchema = createListVersionsResponseSchema(promptBlockVersionSchema);\n\nexport const getPromptBlockVersionResponseSchema = promptBlockVersionSchema;\n\nexport const createPromptBlockVersionResponseSchema = promptBlockVersionSchema.partial().merge(\n z.object({\n id: z.string(),\n blockId: z.string(),\n versionNumber: z.number(),\n createdAt: z.coerce.date(),\n }),\n);\n\nexport const activatePromptBlockVersionResponseSchema = activateVersionResponseSchema;\n\nexport const restorePromptBlockVersionResponseSchema = promptBlockVersionSchema;\n\nexport const deletePromptBlockVersionResponseSchema = deleteVersionResponseSchema;\n\nexport const comparePromptBlockVersionsResponseSchema = createCompareVersionsResponseSchema(promptBlockVersionSchema);\n\nexport { versionDiffEntrySchema };\n","import { HTTPException } from '../http-exception';\nimport {\n promptBlockVersionPathParams,\n promptBlockVersionIdPathParams,\n listPromptBlockVersionsQuerySchema,\n createPromptBlockVersionBodySchema,\n comparePromptBlockVersionsQuerySchema,\n listPromptBlockVersionsResponseSchema,\n getPromptBlockVersionResponseSchema,\n createPromptBlockVersionResponseSchema,\n activatePromptBlockVersionResponseSchema,\n restorePromptBlockVersionResponseSchema,\n deletePromptBlockVersionResponseSchema,\n comparePromptBlockVersionsResponseSchema,\n} from '../schemas/prompt-block-versions';\nimport { createRoute } from '../server-adapter/routes/route-builder';\n\nimport { handleError } from './error';\nimport {\n extractConfigFromVersion,\n calculateChangedFields,\n computeVersionDiffs,\n createVersionWithRetry,\n enforceRetentionLimit,\n} from './version-helpers';\nimport type { VersionedStoreInterface } from './version-helpers';\n\nconst SNAPSHOT_CONFIG_FIELDS = ['name', 'description', 'content', 'rules'] as const;\n\n/**\n * GET /stored/prompt-blocks/:promptBlockId/versions - List all versions for a prompt block\n */\nexport const LIST_PROMPT_BLOCK_VERSIONS_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/prompt-blocks/:promptBlockId/versions',\n requiresAuth: true,\n responseType: 'json',\n pathParamSchema: promptBlockVersionPathParams,\n queryParamSchema: listPromptBlockVersionsQuerySchema,\n responseSchema: listPromptBlockVersionsResponseSchema,\n summary: 'List prompt block versions',\n description: 'Returns a paginated list of all versions for a stored prompt block',\n tags: ['Prompt Block Versions'],\n handler: async ({ mastra, promptBlockId, page, perPage, orderBy }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n const promptBlock = await promptBlockStore.getById(promptBlockId);\n if (!promptBlock) {\n throw new HTTPException(404, { message: `Prompt block with id ${promptBlockId} not found` });\n }\n\n const result = await promptBlockStore.listVersions({\n blockId: promptBlockId,\n page,\n perPage,\n orderBy,\n });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error listing prompt block versions');\n }\n },\n});\n\n/**\n * POST /stored/prompt-blocks/:promptBlockId/versions - Create a new version snapshot\n */\nexport const CREATE_PROMPT_BLOCK_VERSION_ROUTE = createRoute({\n method: 'POST',\n path: '/stored/prompt-blocks/:promptBlockId/versions',\n requiresAuth: true,\n responseType: 'json',\n pathParamSchema: promptBlockVersionPathParams,\n bodySchema: createPromptBlockVersionBodySchema,\n responseSchema: createPromptBlockVersionResponseSchema,\n summary: 'Create prompt block version',\n description: 'Creates a new version snapshot of the current prompt block configuration',\n tags: ['Prompt Block Versions'],\n handler: async ({ mastra, promptBlockId, changeMessage }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n const promptBlock = await promptBlockStore.getById(promptBlockId);\n if (!promptBlock) {\n throw new HTTPException(404, { message: `Prompt block with id ${promptBlockId} not found` });\n }\n\n let currentConfig: Record<string, unknown> = {};\n if (promptBlock.activeVersionId) {\n const activeVersion = await promptBlockStore.getVersion(promptBlock.activeVersionId);\n if (activeVersion) {\n currentConfig = extractConfigFromVersion(\n activeVersion as unknown as Record<string, unknown>,\n SNAPSHOT_CONFIG_FIELDS,\n );\n }\n }\n\n const latestVersion = await promptBlockStore.getLatestVersion(promptBlockId);\n\n // If no activeVersionId, fall back to latest version config\n if (!promptBlock.activeVersionId && latestVersion) {\n currentConfig = extractConfigFromVersion(\n latestVersion as unknown as Record<string, unknown>,\n SNAPSHOT_CONFIG_FIELDS,\n );\n }\n const previousConfig = latestVersion\n ? extractConfigFromVersion(latestVersion as unknown as Record<string, unknown>, SNAPSHOT_CONFIG_FIELDS)\n : null;\n\n const changedFields = calculateChangedFields(previousConfig, currentConfig);\n\n const { versionId } = await createVersionWithRetry(\n promptBlockStore as unknown as VersionedStoreInterface,\n promptBlockId,\n 'blockId',\n currentConfig,\n changedFields,\n { changeMessage },\n );\n\n const version = await promptBlockStore.getVersion(versionId);\n if (!version) {\n throw new HTTPException(500, { message: 'Failed to retrieve created version' });\n }\n\n await enforceRetentionLimit(\n promptBlockStore as unknown as VersionedStoreInterface,\n promptBlockId,\n 'blockId',\n promptBlock.activeVersionId,\n );\n\n return version;\n } catch (error) {\n return handleError(error, 'Error creating prompt block version');\n }\n },\n});\n\n/**\n * GET /stored/prompt-blocks/:promptBlockId/versions/:versionId - Get a specific version\n */\nexport const GET_PROMPT_BLOCK_VERSION_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/prompt-blocks/:promptBlockId/versions/:versionId',\n requiresAuth: true,\n responseType: 'json',\n pathParamSchema: promptBlockVersionIdPathParams,\n responseSchema: getPromptBlockVersionResponseSchema,\n summary: 'Get prompt block version',\n description: 'Returns a specific version of a prompt block by its version ID',\n tags: ['Prompt Block Versions'],\n handler: async ({ mastra, promptBlockId, versionId }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n const version = await promptBlockStore.getVersion(versionId);\n\n if (!version) {\n throw new HTTPException(404, { message: `Version with id ${versionId} not found` });\n }\n\n if (version.blockId !== promptBlockId) {\n throw new HTTPException(404, {\n message: `Version with id ${versionId} not found for prompt block ${promptBlockId}`,\n });\n }\n\n return version;\n } catch (error) {\n return handleError(error, 'Error getting prompt block version');\n }\n },\n});\n\n/**\n * POST /stored/prompt-blocks/:promptBlockId/versions/:versionId/activate - Set a version as active\n */\nexport const ACTIVATE_PROMPT_BLOCK_VERSION_ROUTE = createRoute({\n method: 'POST',\n path: '/stored/prompt-blocks/:promptBlockId/versions/:versionId/activate',\n requiresAuth: true,\n responseType: 'json',\n pathParamSchema: promptBlockVersionIdPathParams,\n responseSchema: activatePromptBlockVersionResponseSchema,\n summary: 'Activate prompt block version',\n description: 'Sets a specific version as the active version for the prompt block',\n tags: ['Prompt Block Versions'],\n handler: async ({ mastra, promptBlockId, versionId }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n const promptBlock = await promptBlockStore.getById(promptBlockId);\n if (!promptBlock) {\n throw new HTTPException(404, { message: `Prompt block with id ${promptBlockId} not found` });\n }\n\n const version = await promptBlockStore.getVersion(versionId);\n if (!version) {\n throw new HTTPException(404, { message: `Version with id ${versionId} not found` });\n }\n if (version.blockId !== promptBlockId) {\n throw new HTTPException(404, {\n message: `Version with id ${versionId} not found for prompt block ${promptBlockId}`,\n });\n }\n\n await promptBlockStore.update({\n id: promptBlockId,\n activeVersionId: versionId,\n status: 'published',\n });\n\n // Clear the editor cache so subsequent requests see the new active version\n mastra.getEditor()?.prompt.clearCache(promptBlockId);\n\n return {\n success: true,\n message: `Version ${version.versionNumber} is now active`,\n activeVersionId: versionId,\n };\n } catch (error) {\n return handleError(error, 'Error activating prompt block version');\n }\n },\n});\n\n/**\n * POST /stored/prompt-blocks/:promptBlockId/versions/:versionId/restore - Restore prompt block to a version\n */\nexport const RESTORE_PROMPT_BLOCK_VERSION_ROUTE = createRoute({\n method: 'POST',\n path: '/stored/prompt-blocks/:promptBlockId/versions/:versionId/restore',\n requiresAuth: true,\n responseType: 'json',\n pathParamSchema: promptBlockVersionIdPathParams,\n responseSchema: restorePromptBlockVersionResponseSchema,\n summary: 'Restore prompt block version',\n description: 'Restores the prompt block configuration from a version, creating a new version',\n tags: ['Prompt Block Versions'],\n handler: async ({ mastra, promptBlockId, versionId }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n const promptBlock = await promptBlockStore.getById(promptBlockId);\n if (!promptBlock) {\n throw new HTTPException(404, { message: `Prompt block with id ${promptBlockId} not found` });\n }\n\n const versionToRestore = await promptBlockStore.getVersion(versionId);\n if (!versionToRestore) {\n throw new HTTPException(404, { message: `Version with id ${versionId} not found` });\n }\n if (versionToRestore.blockId !== promptBlockId) {\n throw new HTTPException(404, {\n message: `Version with id ${versionId} not found for prompt block ${promptBlockId}`,\n });\n }\n\n const restoredConfig = extractConfigFromVersion(\n versionToRestore as unknown as Record<string, unknown>,\n SNAPSHOT_CONFIG_FIELDS,\n );\n\n await promptBlockStore.update({\n id: promptBlockId,\n ...restoredConfig,\n });\n\n const latestVersion = await promptBlockStore.getLatestVersion(promptBlockId);\n const previousConfig = latestVersion\n ? extractConfigFromVersion(latestVersion as unknown as Record<string, unknown>, SNAPSHOT_CONFIG_FIELDS)\n : null;\n\n const changedFields = calculateChangedFields(previousConfig, restoredConfig);\n\n const { versionId: newVersionId } = await createVersionWithRetry(\n promptBlockStore as unknown as VersionedStoreInterface,\n promptBlockId,\n 'blockId',\n restoredConfig,\n changedFields,\n {\n changeMessage: `Restored from version ${versionToRestore.versionNumber}`,\n },\n );\n\n const newVersion = await promptBlockStore.getVersion(newVersionId);\n if (!newVersion) {\n throw new HTTPException(500, { message: 'Failed to retrieve created version' });\n }\n\n await enforceRetentionLimit(\n promptBlockStore as unknown as VersionedStoreInterface,\n promptBlockId,\n 'blockId',\n promptBlock.activeVersionId,\n );\n\n // Clear the editor cache so subsequent requests see the updated config\n mastra.getEditor()?.prompt.clearCache(promptBlockId);\n\n return newVersion;\n } catch (error) {\n return handleError(error, 'Error restoring prompt block version');\n }\n },\n});\n\n/**\n * DELETE /stored/prompt-blocks/:promptBlockId/versions/:versionId - Delete a version\n */\nexport const DELETE_PROMPT_BLOCK_VERSION_ROUTE = createRoute({\n method: 'DELETE',\n path: '/stored/prompt-blocks/:promptBlockId/versions/:versionId',\n requiresAuth: true,\n responseType: 'json',\n pathParamSchema: promptBlockVersionIdPathParams,\n responseSchema: deletePromptBlockVersionResponseSchema,\n summary: 'Delete prompt block version',\n description: 'Deletes a specific version (cannot delete the active version)',\n tags: ['Prompt Block Versions'],\n handler: async ({ mastra, promptBlockId, versionId }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n const promptBlock = await promptBlockStore.getById(promptBlockId);\n if (!promptBlock) {\n throw new HTTPException(404, { message: `Prompt block with id ${promptBlockId} not found` });\n }\n\n const version = await promptBlockStore.getVersion(versionId);\n if (!version) {\n throw new HTTPException(404, { message: `Version with id ${versionId} not found` });\n }\n if (version.blockId !== promptBlockId) {\n throw new HTTPException(404, {\n message: `Version with id ${versionId} not found for prompt block ${promptBlockId}`,\n });\n }\n\n if (promptBlock.activeVersionId === versionId) {\n throw new HTTPException(400, {\n message: 'Cannot delete the active version. Activate a different version first.',\n });\n }\n\n await promptBlockStore.deleteVersion(versionId);\n\n // Clear the editor cache so subsequent requests see the updated config\n mastra.getEditor()?.prompt.clearCache(promptBlockId);\n\n return {\n success: true,\n message: `Version ${version.versionNumber} deleted successfully`,\n };\n } catch (error) {\n return handleError(error, 'Error deleting prompt block version');\n }\n },\n});\n\n/**\n * GET /stored/prompt-blocks/:promptBlockId/versions/compare - Compare two versions\n */\nexport const COMPARE_PROMPT_BLOCK_VERSIONS_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/prompt-blocks/:promptBlockId/versions/compare',\n requiresAuth: true,\n responseType: 'json',\n pathParamSchema: promptBlockVersionPathParams,\n queryParamSchema: comparePromptBlockVersionsQuerySchema,\n responseSchema: comparePromptBlockVersionsResponseSchema,\n summary: 'Compare prompt block versions',\n description: 'Compares two versions and returns the differences between them',\n tags: ['Prompt Block Versions'],\n handler: async ({ mastra, promptBlockId, from, to }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n const fromVersion = await promptBlockStore.getVersion(from);\n if (!fromVersion) {\n throw new HTTPException(404, { message: `Version with id ${from} not found` });\n }\n if (fromVersion.blockId !== promptBlockId) {\n throw new HTTPException(404, {\n message: `Version with id ${from} not found for prompt block ${promptBlockId}`,\n });\n }\n\n const toVersion = await promptBlockStore.getVersion(to);\n if (!toVersion) {\n throw new HTTPException(404, { message: `Version with id ${to} not found` });\n }\n if (toVersion.blockId !== promptBlockId) {\n throw new HTTPException(404, {\n message: `Version with id ${to} not found for prompt block ${promptBlockId}`,\n });\n }\n\n const fromConfig = extractConfigFromVersion(\n fromVersion as unknown as Record<string, unknown>,\n SNAPSHOT_CONFIG_FIELDS,\n );\n const toConfig = extractConfigFromVersion(\n toVersion as unknown as Record<string, unknown>,\n SNAPSHOT_CONFIG_FIELDS,\n );\n\n const diffs = computeVersionDiffs(fromConfig, toConfig);\n\n return {\n diffs,\n fromVersion,\n toVersion,\n };\n } catch (error) {\n return handleError(error, 'Error comparing prompt block versions');\n }\n },\n});\n"]}
|
|
@@ -22,7 +22,7 @@ var storageOrderBySchema = z__default.default.object({
|
|
|
22
22
|
});
|
|
23
23
|
var listStoredPromptBlocksQuerySchema = chunkRWLJZWDL_cjs.createPagePaginationSchema(100).extend({
|
|
24
24
|
orderBy: storageOrderBySchema.optional(),
|
|
25
|
-
status: z__default.default.enum(["draft", "published", "archived"]).optional().
|
|
25
|
+
status: z__default.default.enum(["draft", "published", "archived"]).optional().describe("Filter prompt blocks by status. When omitted, returns all prompt blocks regardless of status"),
|
|
26
26
|
authorId: z__default.default.string().optional().describe("Filter prompt blocks by author identifier"),
|
|
27
27
|
metadata: z__default.default.record(z__default.default.string(), z__default.default.unknown()).optional().describe("Filter prompt blocks by metadata key-value pairs")
|
|
28
28
|
});
|
|
@@ -30,7 +30,8 @@ var snapshotConfigSchema = z__default.default.object({
|
|
|
30
30
|
name: z__default.default.string().describe("Display name of the prompt block"),
|
|
31
31
|
description: z__default.default.string().optional().describe("Purpose description"),
|
|
32
32
|
content: z__default.default.string().describe("Template content with {{variable}} interpolation"),
|
|
33
|
-
rules: chunkA7CIMRJQ_cjs.ruleGroupSchema.optional().describe("Rules for conditional inclusion")
|
|
33
|
+
rules: chunkA7CIMRJQ_cjs.ruleGroupSchema.optional().describe("Rules for conditional inclusion"),
|
|
34
|
+
requestContextSchema: z__default.default.record(z__default.default.string(), z__default.default.unknown()).optional().describe("JSON Schema defining available variables for {{variableName}} interpolation and conditions")
|
|
34
35
|
});
|
|
35
36
|
var createStoredPromptBlockBodySchema = z__default.default.object({
|
|
36
37
|
id: z__default.default.string().optional().describe("Unique identifier. If not provided, derived from name."),
|
|
@@ -45,6 +46,7 @@ var storedPromptBlockSchema = z__default.default.object({
|
|
|
45
46
|
id: z__default.default.string(),
|
|
46
47
|
status: z__default.default.string().describe("Prompt block status: draft, published, or archived"),
|
|
47
48
|
activeVersionId: z__default.default.string().optional(),
|
|
49
|
+
hasDraft: z__default.default.boolean().optional().describe("Whether the prompt block has unpublished draft changes"),
|
|
48
50
|
authorId: z__default.default.string().optional(),
|
|
49
51
|
metadata: z__default.default.record(z__default.default.string(), z__default.default.unknown()).optional(),
|
|
50
52
|
createdAt: z__default.default.coerce.date(),
|
|
@@ -52,7 +54,8 @@ var storedPromptBlockSchema = z__default.default.object({
|
|
|
52
54
|
name: z__default.default.string().describe("Display name of the prompt block"),
|
|
53
55
|
description: z__default.default.string().optional().describe("Purpose description"),
|
|
54
56
|
content: z__default.default.string().describe("Template content with {{variable}} interpolation"),
|
|
55
|
-
rules: chunkA7CIMRJQ_cjs.ruleGroupSchema.optional().describe("Rules for conditional inclusion")
|
|
57
|
+
rules: chunkA7CIMRJQ_cjs.ruleGroupSchema.optional().describe("Rules for conditional inclusion"),
|
|
58
|
+
requestContextSchema: z__default.default.record(z__default.default.string(), z__default.default.unknown()).optional().describe("JSON Schema defining available variables for {{variableName}} interpolation and conditions")
|
|
56
59
|
});
|
|
57
60
|
var listStoredPromptBlocksResponseSchema = chunkRWLJZWDL_cjs.paginationInfoSchema.extend({
|
|
58
61
|
promptBlocks: z__default.default.array(storedPromptBlockSchema)
|
|
@@ -77,7 +80,16 @@ var deleteStoredPromptBlockResponseSchema = z__default.default.object({
|
|
|
77
80
|
});
|
|
78
81
|
|
|
79
82
|
// src/server/handlers/stored-prompt-blocks.ts
|
|
80
|
-
var PROMPT_BLOCK_SNAPSHOT_CONFIG_FIELDS = [
|
|
83
|
+
var PROMPT_BLOCK_SNAPSHOT_CONFIG_FIELDS = [
|
|
84
|
+
"name",
|
|
85
|
+
"description",
|
|
86
|
+
"content",
|
|
87
|
+
"rules",
|
|
88
|
+
"requestContextSchema"
|
|
89
|
+
];
|
|
90
|
+
function computeHasDraft(latestVersion, activeVersionId) {
|
|
91
|
+
return !!(latestVersion && (!activeVersionId || latestVersion.id !== activeVersionId));
|
|
92
|
+
}
|
|
81
93
|
var LIST_STORED_PROMPT_BLOCKS_ROUTE = chunk4LVJBXI2_cjs.createRoute({
|
|
82
94
|
method: "GET",
|
|
83
95
|
path: "/stored/prompt-blocks",
|
|
@@ -106,7 +118,13 @@ var LIST_STORED_PROMPT_BLOCKS_ROUTE = chunk4LVJBXI2_cjs.createRoute({
|
|
|
106
118
|
authorId,
|
|
107
119
|
metadata
|
|
108
120
|
});
|
|
109
|
-
|
|
121
|
+
const promptBlocks = await Promise.all(
|
|
122
|
+
result.promptBlocks.map(async (block) => {
|
|
123
|
+
const latestVersion = await promptBlockStore.getLatestVersion(block.id);
|
|
124
|
+
return { ...block, hasDraft: computeHasDraft(latestVersion, block.activeVersionId) };
|
|
125
|
+
})
|
|
126
|
+
);
|
|
127
|
+
return { ...result, promptBlocks };
|
|
110
128
|
} catch (error) {
|
|
111
129
|
return chunkSUKFO7UM_cjs.handleError(error, "Error listing stored prompt blocks");
|
|
112
130
|
}
|
|
@@ -137,7 +155,8 @@ var GET_STORED_PROMPT_BLOCK_ROUTE = chunk4LVJBXI2_cjs.createRoute({
|
|
|
137
155
|
if (!promptBlock) {
|
|
138
156
|
throw new chunk64ITUOXI_cjs.HTTPException(404, { message: `Stored prompt block with id ${storedPromptBlockId} not found` });
|
|
139
157
|
}
|
|
140
|
-
|
|
158
|
+
const latestVersion = await promptBlockStore.getLatestVersion(storedPromptBlockId);
|
|
159
|
+
return { ...promptBlock, hasDraft: computeHasDraft(latestVersion, promptBlock.activeVersionId) };
|
|
141
160
|
} catch (error) {
|
|
142
161
|
return chunkSUKFO7UM_cjs.handleError(error, "Error getting stored prompt block");
|
|
143
162
|
}
|
|
@@ -153,7 +172,17 @@ var CREATE_STORED_PROMPT_BLOCK_ROUTE = chunk4LVJBXI2_cjs.createRoute({
|
|
|
153
172
|
description: "Creates a new prompt block in storage with the provided configuration",
|
|
154
173
|
tags: ["Stored Prompt Blocks"],
|
|
155
174
|
requiresAuth: true,
|
|
156
|
-
handler: async ({
|
|
175
|
+
handler: async ({
|
|
176
|
+
mastra,
|
|
177
|
+
id: providedId,
|
|
178
|
+
authorId,
|
|
179
|
+
metadata,
|
|
180
|
+
name,
|
|
181
|
+
description,
|
|
182
|
+
content,
|
|
183
|
+
rules,
|
|
184
|
+
requestContextSchema
|
|
185
|
+
}) => {
|
|
157
186
|
try {
|
|
158
187
|
const storage = mastra.getStorage();
|
|
159
188
|
if (!storage) {
|
|
@@ -181,14 +210,17 @@ var CREATE_STORED_PROMPT_BLOCK_ROUTE = chunk4LVJBXI2_cjs.createRoute({
|
|
|
181
210
|
name,
|
|
182
211
|
description,
|
|
183
212
|
content,
|
|
184
|
-
rules
|
|
213
|
+
rules,
|
|
214
|
+
requestContextSchema
|
|
185
215
|
}
|
|
186
216
|
});
|
|
187
217
|
const resolved = await promptBlockStore.getByIdResolved(id, { status: "draft" });
|
|
188
218
|
if (!resolved) {
|
|
189
219
|
throw new chunk64ITUOXI_cjs.HTTPException(500, { message: "Failed to resolve created prompt block" });
|
|
190
220
|
}
|
|
191
|
-
|
|
221
|
+
const latestVersion = await promptBlockStore.getLatestVersion(id);
|
|
222
|
+
const hasDraft = !!(latestVersion && (!resolved.activeVersionId || latestVersion.id !== resolved.activeVersionId));
|
|
223
|
+
return { ...resolved, hasDraft };
|
|
192
224
|
} catch (error) {
|
|
193
225
|
return chunkSUKFO7UM_cjs.handleError(error, "Error creating stored prompt block");
|
|
194
226
|
}
|
|
@@ -215,7 +247,8 @@ var UPDATE_STORED_PROMPT_BLOCK_ROUTE = chunk4LVJBXI2_cjs.createRoute({
|
|
|
215
247
|
name,
|
|
216
248
|
description,
|
|
217
249
|
content,
|
|
218
|
-
rules
|
|
250
|
+
rules,
|
|
251
|
+
requestContextSchema
|
|
219
252
|
}) => {
|
|
220
253
|
try {
|
|
221
254
|
const storage = mastra.getStorage();
|
|
@@ -237,9 +270,10 @@ var UPDATE_STORED_PROMPT_BLOCK_ROUTE = chunk4LVJBXI2_cjs.createRoute({
|
|
|
237
270
|
name,
|
|
238
271
|
description,
|
|
239
272
|
content,
|
|
240
|
-
rules
|
|
273
|
+
rules,
|
|
274
|
+
requestContextSchema
|
|
241
275
|
});
|
|
242
|
-
const configFields = { name, description, content, rules };
|
|
276
|
+
const configFields = { name, description, content, rules, requestContextSchema };
|
|
243
277
|
const providedConfigFields = Object.fromEntries(Object.entries(configFields).filter(([_, v]) => v !== void 0));
|
|
244
278
|
await chunkZNA56PTW_cjs.handleAutoVersioning(
|
|
245
279
|
promptBlockStore,
|
|
@@ -254,7 +288,9 @@ var UPDATE_STORED_PROMPT_BLOCK_ROUTE = chunk4LVJBXI2_cjs.createRoute({
|
|
|
254
288
|
if (!resolved) {
|
|
255
289
|
throw new chunk64ITUOXI_cjs.HTTPException(500, { message: "Failed to resolve updated prompt block" });
|
|
256
290
|
}
|
|
257
|
-
|
|
291
|
+
const latestVersion = await promptBlockStore.getLatestVersion(storedPromptBlockId);
|
|
292
|
+
const hasDraft = !!(latestVersion && (!resolved.activeVersionId || latestVersion.id !== resolved.activeVersionId));
|
|
293
|
+
return { ...resolved, hasDraft };
|
|
258
294
|
} catch (error) {
|
|
259
295
|
return chunkSUKFO7UM_cjs.handleError(error, "Error updating stored prompt block");
|
|
260
296
|
}
|
|
@@ -300,5 +336,5 @@ exports.DELETE_STORED_PROMPT_BLOCK_ROUTE = DELETE_STORED_PROMPT_BLOCK_ROUTE;
|
|
|
300
336
|
exports.GET_STORED_PROMPT_BLOCK_ROUTE = GET_STORED_PROMPT_BLOCK_ROUTE;
|
|
301
337
|
exports.LIST_STORED_PROMPT_BLOCKS_ROUTE = LIST_STORED_PROMPT_BLOCKS_ROUTE;
|
|
302
338
|
exports.UPDATE_STORED_PROMPT_BLOCK_ROUTE = UPDATE_STORED_PROMPT_BLOCK_ROUTE;
|
|
303
|
-
//# sourceMappingURL=chunk-
|
|
304
|
-
//# sourceMappingURL=chunk-
|
|
339
|
+
//# sourceMappingURL=chunk-MJLQLQ6K.cjs.map
|
|
340
|
+
//# sourceMappingURL=chunk-MJLQLQ6K.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/server/schemas/stored-prompt-blocks.ts","../src/server/handlers/stored-prompt-blocks.ts"],"names":["z","createPagePaginationSchema","ruleGroupSchema","paginationInfoSchema","createRoute","HTTPException","handleError","statusQuerySchema","toSlug","handleAutoVersioning"],"mappings":";;;;;;;;;;;;;;;AASO,IAAM,6BAAA,GAAgCA,mBAAE,MAAA,CAAO;AAAA,EACpD,mBAAA,EAAqBA,kBAAA,CAAE,MAAA,EAAO,CAAE,SAAS,+CAA+C;AAC1F,CAAC,CAAA;AAMD,IAAM,oBAAA,GAAuBA,mBAAE,MAAA,CAAO;AAAA,EACpC,KAAA,EAAOA,mBAAE,IAAA,CAAK,CAAC,aAAa,WAAW,CAAC,EAAE,QAAA,EAAS;AAAA,EACnD,SAAA,EAAWA,mBAAE,IAAA,CAAK,CAAC,OAAO,MAAM,CAAC,EAAE,QAAA;AACrC,CAAC,CAAA;AAIM,IAAM,iCAAA,GAAoCC,4CAAA,CAA2B,GAAG,CAAA,CAAE,MAAA,CAAO;AAAA,EACtF,OAAA,EAAS,qBAAqB,QAAA,EAAS;AAAA,EACvC,MAAA,EAAQD,kBAAA,CACL,IAAA,CAAK,CAAC,OAAA,EAAS,WAAA,EAAa,UAAU,CAAC,CAAA,CACvC,QAAA,EAAS,CACT,QAAA,CAAS,8FAA8F,CAAA;AAAA,EAC1G,UAAUA,kBAAA,CAAE,MAAA,GAAS,QAAA,EAAS,CAAE,SAAS,2CAA2C,CAAA;AAAA,EACpF,QAAA,EAAUA,kBAAA,CAAE,MAAA,CAAOA,kBAAA,CAAE,MAAA,EAAO,EAAGA,kBAAA,CAAE,OAAA,EAAS,CAAA,CAAE,QAAA,EAAS,CAAE,SAAS,kDAAkD;AACpH,CAAC,CAAA;AAMD,IAAM,oBAAA,GAAuBA,mBAAE,MAAA,CAAO;AAAA,EACpC,IAAA,EAAMA,kBAAA,CAAE,MAAA,EAAO,CAAE,SAAS,kCAAkC,CAAA;AAAA,EAC5D,aAA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F,CAAC","file":"chunk-MJLQLQ6K.cjs","sourcesContent":["import z from 'zod';\n\nimport { paginationInfoSchema, createPagePaginationSchema, statusQuerySchema } from './common';\nimport { ruleGroupSchema } from './rule-group';\n\n// ============================================================================\n// Path Parameter Schemas\n// ============================================================================\n\nexport const storedPromptBlockIdPathParams = z.object({\n storedPromptBlockId: z.string().describe('Unique identifier for the stored prompt block'),\n});\n\n// ============================================================================\n// Query Parameter Schemas\n// ============================================================================\n\nconst storageOrderBySchema = z.object({\n field: z.enum(['createdAt', 'updatedAt']).optional(),\n direction: z.enum(['ASC', 'DESC']).optional(),\n});\n\nexport { statusQuerySchema };\n\nexport const listStoredPromptBlocksQuerySchema = createPagePaginationSchema(100).extend({\n orderBy: storageOrderBySchema.optional(),\n status: z\n .enum(['draft', 'published', 'archived'])\n .optional()\n .describe('Filter prompt blocks by status. When omitted, returns all prompt blocks regardless of status'),\n authorId: z.string().optional().describe('Filter prompt blocks by author identifier'),\n metadata: z.record(z.string(), z.unknown()).optional().describe('Filter prompt blocks by metadata key-value pairs'),\n});\n\n// ============================================================================\n// Body Parameter Schemas\n// ============================================================================\n\nconst snapshotConfigSchema = z.object({\n name: z.string().describe('Display name of the prompt block'),\n description: z.string().optional().describe('Purpose description'),\n content: z.string().describe('Template content with {{variable}} interpolation'),\n rules: ruleGroupSchema.optional().describe('Rules for conditional inclusion'),\n requestContextSchema: z\n .record(z.string(), z.unknown())\n .optional()\n .describe('JSON Schema defining available variables for {{variableName}} interpolation and conditions'),\n});\n\nexport const createStoredPromptBlockBodySchema = z\n .object({\n id: z.string().optional().describe('Unique identifier. If not provided, derived from name.'),\n authorId: z.string().optional().describe('Author identifier for multi-tenant filtering'),\n metadata: z.record(z.string(), z.unknown()).optional().describe('Additional metadata for the prompt block'),\n })\n .merge(snapshotConfigSchema);\n\nexport const updateStoredPromptBlockBodySchema = z\n .object({\n authorId: z.string().optional(),\n metadata: z.record(z.string(), z.unknown()).optional(),\n })\n .merge(snapshotConfigSchema.partial());\n\n// ============================================================================\n// Response Schemas\n// ============================================================================\n\nexport const storedPromptBlockSchema = z.object({\n id: z.string(),\n status: z.string().describe('Prompt block status: draft, published, or archived'),\n activeVersionId: z.string().optional(),\n hasDraft: z.boolean().optional().describe('Whether the prompt block has unpublished draft changes'),\n authorId: z.string().optional(),\n metadata: z.record(z.string(), z.unknown()).optional(),\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n name: z.string().describe('Display name of the prompt block'),\n description: z.string().optional().describe('Purpose description'),\n content: z.string().describe('Template content with {{variable}} interpolation'),\n rules: ruleGroupSchema.optional().describe('Rules for conditional inclusion'),\n requestContextSchema: z\n .record(z.string(), z.unknown())\n .optional()\n .describe('JSON Schema defining available variables for {{variableName}} interpolation and conditions'),\n});\n\nexport const listStoredPromptBlocksResponseSchema = paginationInfoSchema.extend({\n promptBlocks: z.array(storedPromptBlockSchema),\n});\n\nexport const getStoredPromptBlockResponseSchema = storedPromptBlockSchema;\nexport const createStoredPromptBlockResponseSchema = storedPromptBlockSchema;\n\nexport const updateStoredPromptBlockResponseSchema = z.union([\n z.object({\n id: z.string(),\n status: z.string(),\n activeVersionId: z.string().optional(),\n authorId: z.string().optional(),\n metadata: z.record(z.string(), z.unknown()).optional(),\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n }),\n storedPromptBlockSchema,\n]);\n\nexport const deleteStoredPromptBlockResponseSchema = z.object({\n success: z.boolean(),\n message: z.string(),\n});\n","import { HTTPException } from '../http-exception';\nimport {\n storedPromptBlockIdPathParams,\n statusQuerySchema,\n listStoredPromptBlocksQuerySchema,\n createStoredPromptBlockBodySchema,\n updateStoredPromptBlockBodySchema,\n listStoredPromptBlocksResponseSchema,\n getStoredPromptBlockResponseSchema,\n createStoredPromptBlockResponseSchema,\n updateStoredPromptBlockResponseSchema,\n deleteStoredPromptBlockResponseSchema,\n} from '../schemas/stored-prompt-blocks';\nimport { createRoute } from '../server-adapter/routes/route-builder';\nimport { toSlug } from '../utils';\n\nimport { handleError } from './error';\nimport { handleAutoVersioning } from './version-helpers';\nimport type { VersionedStoreInterface } from './version-helpers';\n\nconst PROMPT_BLOCK_SNAPSHOT_CONFIG_FIELDS = [\n 'name',\n 'description',\n 'content',\n 'rules',\n 'requestContextSchema',\n] as const;\n\n/** Computes whether a prompt block has an unpublished draft version. */\nfunction computeHasDraft(\n latestVersion: { id: string } | null | undefined,\n activeVersionId: string | null | undefined,\n): boolean {\n return !!(latestVersion && (!activeVersionId || latestVersion.id !== activeVersionId));\n}\n\n// ============================================================================\n// Route Definitions\n// ============================================================================\n\n/**\n * GET /stored/prompt-blocks - List all stored prompt blocks\n */\nexport const LIST_STORED_PROMPT_BLOCKS_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/prompt-blocks',\n responseType: 'json',\n queryParamSchema: listStoredPromptBlocksQuerySchema,\n responseSchema: listStoredPromptBlocksResponseSchema,\n summary: 'List stored prompt blocks',\n description: 'Returns a paginated list of all prompt blocks stored in the database',\n tags: ['Stored Prompt Blocks'],\n requiresAuth: true,\n handler: async ({ mastra, page, perPage, orderBy, status, authorId, metadata }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n const result = await promptBlockStore.listResolved({\n page,\n perPage,\n orderBy,\n status,\n authorId,\n metadata,\n });\n\n // For each block, fetch the latest version to compute hasDraft.\n // resolvedVersionId from listResolved defaults to 'published' resolution,\n // so we need the actual latest version to detect unpublished drafts.\n const promptBlocks = await Promise.all(\n result.promptBlocks.map(async (block: (typeof result.promptBlocks)[number]) => {\n const latestVersion = await promptBlockStore.getLatestVersion(block.id);\n return { ...block, hasDraft: computeHasDraft(latestVersion, block.activeVersionId) };\n }),\n );\n\n return { ...result, promptBlocks };\n } catch (error) {\n return handleError(error, 'Error listing stored prompt blocks');\n }\n },\n});\n\n/**\n * GET /stored/prompt-blocks/:storedPromptBlockId - Get a stored prompt block by ID\n */\nexport const GET_STORED_PROMPT_BLOCK_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/prompt-blocks/:storedPromptBlockId',\n responseType: 'json',\n pathParamSchema: storedPromptBlockIdPathParams,\n queryParamSchema: statusQuerySchema,\n responseSchema: getStoredPromptBlockResponseSchema,\n summary: 'Get stored prompt block by ID',\n description:\n 'Returns a specific prompt block from storage by its unique identifier. Use ?status=draft to resolve with the latest (draft) version, or ?status=published (default) for the active published version.',\n tags: ['Stored Prompt Blocks'],\n requiresAuth: true,\n handler: async ({ mastra, storedPromptBlockId, status }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n const promptBlock = await promptBlockStore.getByIdResolved(storedPromptBlockId, { status });\n\n if (!promptBlock) {\n throw new HTTPException(404, { message: `Stored prompt block with id ${storedPromptBlockId} not found` });\n }\n\n const latestVersion = await promptBlockStore.getLatestVersion(storedPromptBlockId);\n\n return { ...promptBlock, hasDraft: computeHasDraft(latestVersion, promptBlock.activeVersionId) };\n } catch (error) {\n return handleError(error, 'Error getting stored prompt block');\n }\n },\n});\n\n/**\n * POST /stored/prompt-blocks - Create a new stored prompt block\n */\nexport const CREATE_STORED_PROMPT_BLOCK_ROUTE = createRoute({\n method: 'POST',\n path: '/stored/prompt-blocks',\n responseType: 'json',\n bodySchema: createStoredPromptBlockBodySchema,\n responseSchema: createStoredPromptBlockResponseSchema,\n summary: 'Create stored prompt block',\n description: 'Creates a new prompt block in storage with the provided configuration',\n tags: ['Stored Prompt Blocks'],\n requiresAuth: true,\n handler: async ({\n mastra,\n id: providedId,\n authorId,\n metadata,\n name,\n description,\n content,\n rules,\n requestContextSchema,\n }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n // Derive ID from name if not explicitly provided\n const id = providedId || toSlug(name);\n\n if (!id) {\n throw new HTTPException(400, {\n message: 'Could not derive prompt block ID from name. Please provide an explicit id.',\n });\n }\n\n // Check if prompt block with this ID already exists\n const existing = await promptBlockStore.getById(id);\n if (existing) {\n throw new HTTPException(409, { message: `Prompt block with id ${id} already exists` });\n }\n\n await promptBlockStore.create({\n promptBlock: {\n id,\n authorId,\n metadata,\n name,\n description,\n content,\n rules,\n requestContextSchema,\n },\n });\n\n // Return the resolved prompt block (thin record + version config)\n // Use draft status since newly created entities start as drafts\n const resolved = await promptBlockStore.getByIdResolved(id, { status: 'draft' });\n if (!resolved) {\n throw new HTTPException(500, { message: 'Failed to resolve created prompt block' });\n }\n\n const latestVersion = await promptBlockStore.getLatestVersion(id);\n const hasDraft = !!(\n latestVersion &&\n (!resolved.activeVersionId || latestVersion.id !== resolved.activeVersionId)\n );\n\n return { ...resolved, hasDraft };\n } catch (error) {\n return handleError(error, 'Error creating stored prompt block');\n }\n },\n});\n\n/**\n * PATCH /stored/prompt-blocks/:storedPromptBlockId - Update a stored prompt block\n */\nexport const UPDATE_STORED_PROMPT_BLOCK_ROUTE = createRoute({\n method: 'PATCH',\n path: '/stored/prompt-blocks/:storedPromptBlockId',\n responseType: 'json',\n pathParamSchema: storedPromptBlockIdPathParams,\n bodySchema: updateStoredPromptBlockBodySchema,\n responseSchema: updateStoredPromptBlockResponseSchema,\n summary: 'Update stored prompt block',\n description: 'Updates an existing prompt block in storage with the provided fields',\n tags: ['Stored Prompt Blocks'],\n requiresAuth: true,\n handler: async ({\n mastra,\n storedPromptBlockId,\n // Metadata-level fields\n authorId,\n metadata,\n // Config fields (snapshot-level)\n name,\n description,\n content,\n rules,\n requestContextSchema,\n }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n // Check if prompt block exists\n const existing = await promptBlockStore.getById(storedPromptBlockId);\n if (!existing) {\n throw new HTTPException(404, { message: `Stored prompt block with id ${storedPromptBlockId} not found` });\n }\n\n // Update the prompt block with both metadata-level and config-level fields\n const updatedPromptBlock = await promptBlockStore.update({\n id: storedPromptBlockId,\n authorId,\n metadata,\n name,\n description,\n content,\n rules,\n requestContextSchema,\n });\n\n // Build the snapshot config for auto-versioning comparison\n const configFields = { name, description, content, rules, requestContextSchema };\n\n // Filter out undefined values to get only the config fields that were provided\n const providedConfigFields = Object.fromEntries(Object.entries(configFields).filter(([_, v]) => v !== undefined));\n\n // Handle auto-versioning with retry logic for race conditions\n // This creates a new version if there are meaningful config changes.\n // It does NOT update activeVersionId — the version stays as a draft until explicitly published.\n await handleAutoVersioning(\n promptBlockStore as unknown as VersionedStoreInterface,\n storedPromptBlockId,\n 'blockId',\n PROMPT_BLOCK_SNAPSHOT_CONFIG_FIELDS,\n existing,\n updatedPromptBlock,\n providedConfigFields,\n );\n\n // Return the resolved prompt block with the latest (draft) version so the UI sees its edits\n const resolved = await promptBlockStore.getByIdResolved(storedPromptBlockId, { status: 'draft' });\n if (!resolved) {\n throw new HTTPException(500, { message: 'Failed to resolve updated prompt block' });\n }\n\n const latestVersion = await promptBlockStore.getLatestVersion(storedPromptBlockId);\n const hasDraft = !!(\n latestVersion &&\n (!resolved.activeVersionId || latestVersion.id !== resolved.activeVersionId)\n );\n\n return { ...resolved, hasDraft };\n } catch (error) {\n return handleError(error, 'Error updating stored prompt block');\n }\n },\n});\n\n/**\n * DELETE /stored/prompt-blocks/:storedPromptBlockId - Delete a stored prompt block\n */\nexport const DELETE_STORED_PROMPT_BLOCK_ROUTE = createRoute({\n method: 'DELETE',\n path: '/stored/prompt-blocks/:storedPromptBlockId',\n responseType: 'json',\n pathParamSchema: storedPromptBlockIdPathParams,\n responseSchema: deleteStoredPromptBlockResponseSchema,\n summary: 'Delete stored prompt block',\n description: 'Deletes a prompt block from storage by its unique identifier',\n tags: ['Stored Prompt Blocks'],\n requiresAuth: true,\n handler: async ({ mastra, storedPromptBlockId }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n // Check if prompt block exists\n const existing = await promptBlockStore.getById(storedPromptBlockId);\n if (!existing) {\n throw new HTTPException(404, { message: `Stored prompt block with id ${storedPromptBlockId} not found` });\n }\n\n await promptBlockStore.delete(storedPromptBlockId);\n\n return {\n success: true,\n message: `Prompt block ${storedPromptBlockId} deleted successfully`,\n };\n } catch (error) {\n return handleError(error, 'Error deleting stored prompt block');\n }\n },\n});\n"]}
|
|
@@ -29262,7 +29262,7 @@ Notes:
|
|
|
29262
29262
|
"Observational memory async buffering is enabled by default but the installed version of @mastra/core does not support it. Either upgrade @mastra/core, @mastra/memory, and your storage adapter (@mastra/libsql, @mastra/pg, or @mastra/mongodb) to the latest version, or explicitly disable async buffering by setting `observation: { bufferTokens: false }` in your observationalMemory config."
|
|
29263
29263
|
);
|
|
29264
29264
|
}
|
|
29265
|
-
const { ObservationalMemory } = await import('./observational-memory-
|
|
29265
|
+
const { ObservationalMemory } = await import('./observational-memory-AJWSMZVP-J3OYOGXO.js');
|
|
29266
29266
|
return new ObservationalMemory({
|
|
29267
29267
|
storage: memoryStore,
|
|
29268
29268
|
scope: omConfig.scope,
|
|
@@ -40165,5 +40165,5 @@ var OBSERVE_STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE = createRoute({
|
|
|
40165
40165
|
});
|
|
40166
40166
|
|
|
40167
40167
|
export { CANCEL_AGENT_BUILDER_ACTION_RUN_ROUTE, CREATE_AGENT_BUILDER_ACTION_RUN_ROUTE, GET_AGENT_BUILDER_ACTION_BY_ID_ROUTE, GET_AGENT_BUILDER_ACTION_RUN_BY_ID_ROUTE, LIST_AGENT_BUILDER_ACTIONS_ROUTE, LIST_AGENT_BUILDER_ACTION_RUNS_ROUTE, OBSERVE_STREAM_AGENT_BUILDER_ACTION_ROUTE, OBSERVE_STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE, RESUME_AGENT_BUILDER_ACTION_ROUTE, RESUME_ASYNC_AGENT_BUILDER_ACTION_ROUTE, RESUME_STREAM_AGENT_BUILDER_ACTION_ROUTE, START_AGENT_BUILDER_ACTION_RUN_ROUTE, START_ASYNC_AGENT_BUILDER_ACTION_ROUTE, STREAM_AGENT_BUILDER_ACTION_ROUTE, STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE, agent_builder_exports };
|
|
40168
|
-
//# sourceMappingURL=chunk-
|
|
40169
|
-
//# sourceMappingURL=chunk-
|
|
40168
|
+
//# sourceMappingURL=chunk-PGB5HYV7.js.map
|
|
40169
|
+
//# sourceMappingURL=chunk-PGB5HYV7.js.map
|