@tryvira/mcp 0.1.8 → 0.1.11
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/cli.js +29 -8
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -840,8 +840,8 @@ function createViraMcpServer(config) {
|
|
|
840
840
|
function createViraMcpOptions(config) {
|
|
841
841
|
if (!config.baseUrl?.trim() || !config.apiKey?.trim()) throw new Error("VIRA_MCP_CONFIG_REQUIRED");
|
|
842
842
|
const fetcher = config.fetcher ?? fetch;
|
|
843
|
-
const api = async (path, body, requestId) => {
|
|
844
|
-
const response = await fetcher(`${config.baseUrl.replace(/\/$/, "")}${path}`, { method: body ? "POST" : "GET", headers: { authorization: `Bearer ${config.apiKey}`, "content-type": "application/json", "idempotency-key": requestId }, ...body ? { body: JSON.stringify(body) } : {} });
|
|
843
|
+
const api = async (path, body, requestId, method) => {
|
|
844
|
+
const response = await fetcher(`${config.baseUrl.replace(/\/$/, "")}${path}`, { method: method ?? (body ? "POST" : "GET"), headers: { authorization: `Bearer ${config.apiKey}`, "content-type": "application/json", "idempotency-key": requestId }, ...body ? { body: JSON.stringify(body) } : {} });
|
|
845
845
|
const payload = await response.json().catch(() => null);
|
|
846
846
|
if (!response.ok) return { error: `VIRA_API_${response.status}`, result: payload };
|
|
847
847
|
return { result: payload };
|
|
@@ -912,6 +912,10 @@ function createViraMcpOptions(config) {
|
|
|
912
912
|
if (tool === "create_semantic_task") return api("/v1/semantic-tasks", args, `mcp:${tool}:${String(args.taskKey)}`);
|
|
913
913
|
if (tool === "list_behavior_points") return api("/v1/behavior-points", void 0, `mcp:${tool}:${config.scope.projectId}`);
|
|
914
914
|
if (tool === "create_behavior_point") return api("/v1/behavior-points", args, `mcp:${tool}:${String(args.key)}`);
|
|
915
|
+
if (tool === "delete_ai_system") return api(`/v1/ai-systems/${encodeURIComponent(String(args.systemId))}`, { confirm: args.confirm === true }, `mcp:${tool}:${String(args.systemId)}`, "DELETE");
|
|
916
|
+
if (tool === "delete_semantic_task") return api(`/v1/semantic-tasks/${encodeURIComponent(String(args.taskId))}`, { confirm: args.confirm === true }, `mcp:${tool}:${String(args.taskId)}`, "DELETE");
|
|
917
|
+
if (tool === "delete_behavior_point") return api(`/v1/behavior-points/${encodeURIComponent(String(args.pointId))}`, { confirm: args.confirm === true }, `mcp:${tool}:${String(args.pointId)}`, "DELETE");
|
|
918
|
+
if (tool === "delete_behavior_strategy") return api(`/v1/behavior-strategies/${encodeURIComponent(String(args.strategyId))}`, { confirm: args.confirm === true }, `mcp:${tool}:${String(args.strategyId)}`, "DELETE");
|
|
915
919
|
if (tool === "activate_behavior_strategy") return api(`/v1/behavior-strategies/${encodeURIComponent(String(args.strategyId))}/activate`, {}, `mcp:${tool}:${String(args.strategyId)}`);
|
|
916
920
|
return authoringTransport.call(input);
|
|
917
921
|
} };
|
|
@@ -984,6 +988,10 @@ var init_vira_server = __esm({
|
|
|
984
988
|
{ name: "continue_strategy_execution", description: "Continue a waiting Strategy execution with the same pinned artifact, state, and external references.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, executionId: { type: "string" }, authorityDigest: { type: "string" }, state: { type: "object", additionalProperties: true }, references: { type: "object", additionalProperties: true } }, required: ["organizationId", "projectId", "environmentId", "executionId"] } },
|
|
985
989
|
{ name: "cancel_strategy_execution", description: "Cancel a non-terminal scoped Strategy execution.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, executionId: { type: "string" } }, required: ["organizationId", "projectId", "environmentId", "executionId"] } },
|
|
986
990
|
{ name: "list_ai_systems", description: "Read connected AI systems in the configured scope.", inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" } }, required: ["organizationId", "projectId", "environmentId"] } },
|
|
991
|
+
{ name: "delete_ai_system", description: "Delete an unused scoped AI system after explicit confirmation.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, systemId: { type: "string" }, confirm: { type: "boolean" } }, required: ["organizationId", "projectId", "environmentId", "systemId", "confirm"] } },
|
|
992
|
+
{ name: "delete_semantic_task", description: "Delete an unused scoped Semantic Task after explicit confirmation.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, taskId: { type: "string" }, confirm: { type: "boolean" } }, required: ["organizationId", "projectId", "environmentId", "taskId", "confirm"] } },
|
|
993
|
+
{ name: "delete_behavior_point", description: "Delete an unused scoped BehaviorPoint after explicit confirmation.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, pointId: { type: "string" }, confirm: { type: "boolean" } }, required: ["organizationId", "projectId", "environmentId", "pointId", "confirm"] } },
|
|
994
|
+
{ name: "delete_behavior_strategy", description: "Delete a non-active unused scoped Behavior Strategy after explicit confirmation.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, strategyId: { type: "string" }, confirm: { type: "boolean" } }, required: ["organizationId", "projectId", "environmentId", "strategyId", "confirm"] } },
|
|
987
995
|
{ name: "list_discovery_candidates", description: "Read evidence-backed discovery candidates awaiting human review.", inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, reviewState: { type: "string" } }, required: ["organizationId", "projectId", "environmentId"] } },
|
|
988
996
|
{ name: "review_discovery_candidate", description: "Record a human review decision for a scoped discovery candidate.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, kind: { type: "string" }, key: { type: "string" }, decision: { type: "string" }, payload: { type: "object" } }, required: ["organizationId", "projectId", "environmentId", "kind", "key", "decision"] } },
|
|
989
997
|
{ name: "create_observation", description: "Submit one scoped observation for discovery; it does not publish behavior.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, id: { type: "string" }, content: { type: "object" }, consent: { type: "boolean" } }, required: ["organizationId", "projectId", "environmentId", "id", "content", "consent"] } },
|
|
@@ -1217,6 +1225,12 @@ DROP TRIGGER IF EXISTS worker_jobs_clear_lease ON worker_jobs;
|
|
|
1217
1225
|
CREATE TRIGGER worker_jobs_clear_lease BEFORE UPDATE OF state ON worker_jobs
|
|
1218
1226
|
FOR EACH ROW EXECUTE FUNCTION worker_jobs_clear_lease_fn();`;
|
|
1219
1227
|
}
|
|
1228
|
+
function migrationChecksums(sql) {
|
|
1229
|
+
const normalized = normalizePostgresMigrationSql(sql);
|
|
1230
|
+
const canonical3 = createHash6("sha256").update(normalized.replace(/\r\n?/g, "\n")).digest("hex");
|
|
1231
|
+
const legacy = createHash6("sha256").update(normalized.replace(/\r?\n/g, "\r\n")).digest("hex");
|
|
1232
|
+
return { canonical: canonical3, legacy };
|
|
1233
|
+
}
|
|
1220
1234
|
async function applyPostgresMigrations(client, migrations) {
|
|
1221
1235
|
if (!client || typeof client.query !== "function") throw new Error("POSTGRES_CLIENT_INVALID");
|
|
1222
1236
|
await client.query("BEGIN");
|
|
@@ -1234,10 +1248,13 @@ async function applyPostgresMigrations(client, migrations) {
|
|
|
1234
1248
|
const appliedIds = new Map(applied.rows.map((row) => [row.id, row.checksum]));
|
|
1235
1249
|
for (const migration of migrations) {
|
|
1236
1250
|
if (!migration.id.trim() || !migration.sql.trim()) throw new Error("POSTGRES_MIGRATION_INVALID");
|
|
1237
|
-
const checksum =
|
|
1251
|
+
const { canonical: checksum, legacy: legacyChecksum } = migrationChecksums(migration.sql);
|
|
1238
1252
|
if (appliedIds.has(migration.id)) {
|
|
1239
1253
|
const previous = appliedIds.get(migration.id);
|
|
1240
|
-
if (previous && previous !== checksum)
|
|
1254
|
+
if (previous && previous !== checksum) {
|
|
1255
|
+
if (previous !== legacyChecksum && !migration.legacyChecksums?.includes(previous)) throw new Error(`POSTGRES_MIGRATION_CHECKSUM_MISMATCH:${migration.id}`);
|
|
1256
|
+
await client.query("UPDATE vira_schema_migrations SET checksum=$1, code_version=$2 WHERE id=$3", [checksum, migration.codeVersion ?? process.env.VIRA_VERSION ?? null, migration.id]);
|
|
1257
|
+
}
|
|
1241
1258
|
if (!previous) await client.query("UPDATE vira_schema_migrations SET checksum=$1, code_version=$2 WHERE id=$3", [checksum, migration.codeVersion ?? process.env.VIRA_VERSION ?? null, migration.id]);
|
|
1242
1259
|
continue;
|
|
1243
1260
|
}
|
|
@@ -1269,7 +1286,11 @@ async function openPostgresRuntime(options = {}) {
|
|
|
1269
1286
|
try {
|
|
1270
1287
|
const migrations = [];
|
|
1271
1288
|
const migrationPaths = options.migrationPaths ?? [...defaultMigrationPaths, resolve(here, "../migrations/006_postgres_control_plane_repositories.sql")];
|
|
1272
|
-
for (const path of migrationPaths)
|
|
1289
|
+
for (const path of migrationPaths) {
|
|
1290
|
+
const id = path.split(/[\\/]/).pop().replace(/\.sql$/i, "");
|
|
1291
|
+
const legacyChecksums = id === "001_vnext_foundation" ? ["d1a175e1b8af20bcf9bc650fb299626513532e4d18da429569251eff69475427"] : void 0;
|
|
1292
|
+
migrations.push({ id, sql: await readFile(path, "utf8"), ...legacyChecksums ? { legacyChecksums } : {} });
|
|
1293
|
+
}
|
|
1273
1294
|
const client = await pool.connect();
|
|
1274
1295
|
try {
|
|
1275
1296
|
await applyPostgresMigrations(client, migrations);
|
|
@@ -1299,17 +1320,17 @@ var init_postgres_runtime = __esm({
|
|
|
1299
1320
|
resolve(here, "../migrations/008_postgres_identity_session_repositories.sql"),
|
|
1300
1321
|
resolve(here, "../migrations/009_postgres_runtime_repair.sql"),
|
|
1301
1322
|
resolve(here, "../migrations/010_postgres_receipt_lineage_repair.sql"),
|
|
1302
|
-
resolve(here, "../migrations/010_semantic_registry_task_index.sql"),
|
|
1303
1323
|
resolve(here, "../migrations/011_postgres_semantic_activation_receipts.sql"),
|
|
1304
1324
|
resolve(here, "../migrations/012_strategy_release_lineage.sql"),
|
|
1305
1325
|
resolve(here, "../migrations/013_strategy_variant_definition.sql"),
|
|
1306
1326
|
resolve(here, "../migrations/014_strategy_step_recovery_action.sql"),
|
|
1307
1327
|
resolve(here, "../migrations/015_strategy_total_recoveries.sql"),
|
|
1308
1328
|
resolve(here, "../migrations/016_postgres_studio_tenant_auth.sql"),
|
|
1309
|
-
resolve(here, "../migrations/016_unique_ai_system_names.sql"),
|
|
1310
1329
|
resolve(here, "../migrations/017_postgres_security_advisor_hardening.sql"),
|
|
1311
1330
|
resolve(here, "../migrations/018_postgres_foreign_key_indexes.sql"),
|
|
1312
|
-
resolve(here, "../migrations/019_postgres_explicit_public_deny_policies.sql")
|
|
1331
|
+
resolve(here, "../migrations/019_postgres_explicit_public_deny_policies.sql"),
|
|
1332
|
+
resolve(here, "../migrations/020_semantic_registry_task_index.sql"),
|
|
1333
|
+
resolve(here, "../migrations/021_unique_ai_system_names.sql")
|
|
1313
1334
|
];
|
|
1314
1335
|
}
|
|
1315
1336
|
});
|