feat(versioning): version scenarios and snippets, bump to 1.16.0
- snapshot scenario and snippet content into version tables on every
content change; live tables keep holding the latest version
- record the scenario version on each run and copy its steps into the
run steps, so runs execute and show the version they were created with
- keep run step history when a step is deleted (FK set null)
- pin a snippet version with runSnippet('alias@N')
- add version picker to the run modal and version info across the UI
- add version list/get endpoints and MCP tools
- include version in exports and require it on import, restoring the
exact version by id + version
This commit is contained in:
1 parent
a328ef5ea7
commit
ff83b6c7da
40 files changed
+1457
-137
No files matched your search
@@ -946,15 +946,24 @@ export class McpService {
|
||||
.describe(
|
||||
"Playwright trace recording: on (keep every trace), retain-on-failure, or off. Defaults to the server's PLAYWRIGHT_TRACE_MODE",
|
||||
),
|
||||
version: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.optional()
|
||||
.describe(
|
||||
"Scenario version to run (see list_scenario_versions). Defaults to the latest",
|
||||
),
|
||||
},
|
||||
},
|
||||
async ({ id, environmentId, saveSession, traceMode }) => {
|
||||
async ({ id, environmentId, saveSession, traceMode, version }) => {
|
||||
try {
|
||||
const run = await this.scenarioService.createRun(
|
||||
id,
|
||||
environmentId,
|
||||
saveSession,
|
||||
traceMode,
|
||||
version,
|
||||
);
|
||||
return {
|
||||
content: [{ type: "text" as const, text: JSON.stringify(run) }],
|
||||
@@ -1155,19 +1164,74 @@ export class McpService {
|
||||
);
|
||||
|
||||
server.registerTool(
|
||||
"export_scenario",
|
||||
"list_scenario_versions",
|
||||
{
|
||||
description:
|
||||
"Export a scenario as a portable JSON payload (name + steps)",
|
||||
"List a scenario's versions, newest first. Each version holds the scenario content and steps as of that version",
|
||||
inputSchema: {
|
||||
id: z.uuid().describe("Scenario ID to export"),
|
||||
id: z.uuid().describe("Scenario ID"),
|
||||
},
|
||||
},
|
||||
async ({ id }) => {
|
||||
try {
|
||||
const versions = await this.scenarioService.listVersions(id);
|
||||
return {
|
||||
content: [{ type: "text" as const, text: JSON.stringify(versions) }],
|
||||
};
|
||||
} catch (err) {
|
||||
return {
|
||||
isError: true,
|
||||
content: [{ type: "text" as const, text: (err as Error).message }],
|
||||
};
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
server.registerTool(
|
||||
"get_scenario_version",
|
||||
{
|
||||
description: "Get one version of a scenario, with its steps",
|
||||
inputSchema: {
|
||||
id: z.uuid().describe("Scenario ID"),
|
||||
version: z.number().int().min(1).describe("Scenario version"),
|
||||
},
|
||||
},
|
||||
async ({ id, version }) => {
|
||||
try {
|
||||
const row = await this.scenarioService.findVersion(id, version);
|
||||
return {
|
||||
content: [{ type: "text" as const, text: JSON.stringify(row) }],
|
||||
};
|
||||
} catch (err) {
|
||||
return {
|
||||
isError: true,
|
||||
content: [{ type: "text" as const, text: (err as Error).message }],
|
||||
};
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
server.registerTool(
|
||||
"export_scenario",
|
||||
{
|
||||
description:
|
||||
"Export one version of a scenario as a portable JSON payload (version, name + steps)",
|
||||
inputSchema: {
|
||||
id: z.uuid().describe("Scenario ID to export"),
|
||||
version: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.optional()
|
||||
.describe("Scenario version to export. Defaults to the latest"),
|
||||
},
|
||||
},
|
||||
async ({ id, version }) => {
|
||||
try {
|
||||
const exported = await this.scenarioService.exportScenario(id, {
|
||||
includeEnvironment: false,
|
||||
credentialIds: [],
|
||||
version,
|
||||
});
|
||||
return {
|
||||
content: [
|
||||
@@ -1187,8 +1251,17 @@ export class McpService {
|
||||
"import_scenario",
|
||||
{
|
||||
description:
|
||||
"Import a scenario from an export payload, creating a new scenario with all its steps",
|
||||
"Import one scenario version from an export payload. Upserts by id + version: an existing version is left untouched; a new one is stored under its number and becomes the latest when higher than the current latest. Without an id a new scenario is created",
|
||||
inputSchema: {
|
||||
id: z
|
||||
.uuid()
|
||||
.optional()
|
||||
.describe("Scenario ID to import into (from the export)"),
|
||||
version: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.describe("Scenario version the payload holds (from the export)"),
|
||||
name: z.string().describe("Scenario name"),
|
||||
description: z
|
||||
.string()
|
||||
@@ -1210,10 +1283,12 @@ export class McpService {
|
||||
.describe("Ordered list of steps"),
|
||||
},
|
||||
},
|
||||
async ({ name, description, steps }) => {
|
||||
async ({ id, version, name, description, steps }) => {
|
||||
try {
|
||||
const scenario = await this.scenarioService.importScenario({
|
||||
kind: "scenario",
|
||||
id,
|
||||
version,
|
||||
name,
|
||||
description,
|
||||
steps: steps as { title: string | null; execCode: string | null }[],
|
||||
@@ -1595,7 +1670,7 @@ export class McpService {
|
||||
alias: z
|
||||
.string()
|
||||
.describe(
|
||||
"Unique identifier used to invoke the snippet via context.runSnippet(alias, ...args)",
|
||||
"Unique identifier used to invoke the snippet via context.runSnippet(alias, ...args). Use 'alias@<version>' to pin a specific version instead of the latest",
|
||||
),
|
||||
title: z.string().describe("Human-readable title"),
|
||||
description: z
|
||||
@@ -1664,6 +1739,54 @@ export class McpService {
|
||||
},
|
||||
);
|
||||
|
||||
server.registerTool(
|
||||
"list_snippet_versions",
|
||||
{
|
||||
description:
|
||||
"List a snippet's versions, newest first. Step code pins a version with context.runSnippet('alias@<version>')",
|
||||
inputSchema: {
|
||||
id: z.uuid().describe("Snippet ID"),
|
||||
},
|
||||
},
|
||||
async ({ id }) => {
|
||||
try {
|
||||
const versions = await this.snippetService.listVersions(id);
|
||||
return {
|
||||
content: [{ type: "text" as const, text: JSON.stringify(versions) }],
|
||||
};
|
||||
} catch (err) {
|
||||
return {
|
||||
isError: true,
|
||||
content: [{ type: "text" as const, text: (err as Error).message }],
|
||||
};
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
server.registerTool(
|
||||
"get_snippet_version",
|
||||
{
|
||||
description: "Get one version of a snippet",
|
||||
inputSchema: {
|
||||
id: z.uuid().describe("Snippet ID"),
|
||||
version: z.number().int().min(1).describe("Snippet version"),
|
||||
},
|
||||
},
|
||||
async ({ id, version }) => {
|
||||
try {
|
||||
const row = await this.snippetService.findVersion(id, version);
|
||||
return {
|
||||
content: [{ type: "text" as const, text: JSON.stringify(row) }],
|
||||
};
|
||||
} catch (err) {
|
||||
return {
|
||||
isError: true,
|
||||
content: [{ type: "text" as const, text: (err as Error).message }],
|
||||
};
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
server.registerTool(
|
||||
"delete_snippet",
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user