@apicircle/mcp-server 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -41,10 +41,34 @@ var import_zod = require("zod");
41
41
  // package.json
42
42
  var package_default = {
43
43
  name: "@apicircle/mcp-server",
44
- version: "1.0.5",
44
+ version: "1.0.7",
45
45
  private: false,
46
46
  type: "module",
47
47
  description: "Model Context Protocol server exposing API Circle Studio's workspace as a tool catalog. Used by Claude Desktop, ChatGPT, Cursor, GitHub Copilot, and any other MCP-compatible AI client.",
48
+ keywords: [
49
+ "apicircle",
50
+ "api",
51
+ "api-circle",
52
+ "mcp",
53
+ "mcp-server",
54
+ "model-context-protocol",
55
+ "ai",
56
+ "llm",
57
+ "agent",
58
+ "tool-catalog",
59
+ "claude",
60
+ "claude-desktop",
61
+ "chatgpt",
62
+ "cursor",
63
+ "copilot",
64
+ "continue",
65
+ "cline",
66
+ "zed",
67
+ "windsurf",
68
+ "openapi",
69
+ "postman",
70
+ "api-tools"
71
+ ],
48
72
  license: "SEE LICENSE IN LICENSE",
49
73
  repository: {
50
74
  type: "git",
@@ -565,6 +589,7 @@ var workspaceListTool = {
565
589
  // src/tools/crud.ts
566
590
  var import_zod5 = require("zod");
567
591
  var import_shared2 = require("@apicircle/shared");
592
+ var import_core2 = require("@apicircle/core");
568
593
  var HTTP_METHOD = import_zod5.z.enum(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]);
569
594
  var requestCreateTool = {
570
595
  name: "request.create",
@@ -809,55 +834,136 @@ var environmentSetPriorityTool = {
809
834
  };
810
835
  var environmentExportTool = {
811
836
  name: "environment.export",
812
- description: "Serialize an environment to a portable JSON string. Encrypted variables drop their value (only `secretKeyId` survives) so the export can be safely pasted elsewhere \u2014 re-attach secrets locally on the receiving side.",
837
+ description: "Serialize an environment to a portable JSON string (envelope v2). Encrypted variables now carry their ciphertext, slot label, and per-slot salt \u2014 the destination decrypts with its local slot value at request-execute time, matching the Git push/pull contract. The plaintext slot value never leaves the device, but the ciphertext does. v1 envelopes (no ciphertext) still parse on import for back-compat.",
813
838
  inputSchema: import_zod5.z.object({ name: import_zod5.z.string() }),
814
839
  async handler(input, ctx) {
815
840
  const state = await ctx.workspace.read();
816
841
  const env = state.synced.environments.items[input.name];
817
842
  if (!env) return { ok: false, error: "environment not found" };
818
843
  const payload = {
819
- apicircleEnvironment: 1,
844
+ apicircleEnvironment: 2,
820
845
  name: env.name,
821
- variables: env.variables.map(
822
- (v) => v.encrypted && v.secretKeyId ? { key: v.key, encrypted: true, secretKeyId: v.secretKeyId } : { key: v.key, value: v.value, encrypted: false }
823
- )
846
+ variables: env.variables.map((v) => {
847
+ if (v.encrypted && v.secretKeyId) {
848
+ const slot = state.synced.secretKeys?.[v.secretKeyId];
849
+ const label = slot?.label ?? v.key;
850
+ const value = typeof v.value === "string" && v.value.startsWith("enc:") ? v.value : "";
851
+ return {
852
+ key: v.key,
853
+ encrypted: true,
854
+ value,
855
+ secretKeyId: v.secretKeyId,
856
+ secret: { label, salt: slot?.salt ?? null }
857
+ };
858
+ }
859
+ return { key: v.key, value: v.value, encrypted: false };
860
+ })
824
861
  };
825
862
  return { ok: true, json: JSON.stringify(payload, null, 2) };
826
863
  }
827
864
  };
828
865
  var environmentImportTool = {
829
866
  name: "environment.import",
830
- description: "Import an environment from the JSON shape produced by `environment.export`. When a target with the same name exists, pass `overwrite: true` to replace it, otherwise the import is rejected.",
867
+ description: "Import an environment from the JSON shape produced by `environment.export`. v2 envelopes carry the row ciphertext + per-slot salt, so the destination decrypts at request-execute time with its local slot value (same model as Git push/pull); when no destination slot matches the source's salt, a new slot is minted via `secretKey.upsert` and surfaced in `mintedSlots` so the caller can provide values via `secret.addLocal`. v1 envelopes carry only metadata, so unmatched rows come back as `pendingBindings` for the caller to prompt-and-bind via `secret.addLocal` + `environment.bindSecret`. Pass `overwrite: true` to replace a same-name destination env.",
831
868
  inputSchema: import_zod5.z.object({
832
869
  json: import_zod5.z.string().min(1),
833
870
  overwrite: import_zod5.z.boolean().default(false)
834
871
  }),
835
872
  async handler(input, ctx) {
836
- let parsed;
873
+ let raw;
837
874
  try {
838
- parsed = JSON.parse(input.json);
875
+ raw = JSON.parse(input.json);
839
876
  } catch {
840
877
  return { ok: false, error: "invalid JSON" };
841
878
  }
842
- const obj = parsed;
843
- if (obj.apicircleEnvironment !== 1 || typeof obj.name !== "string" || !Array.isArray(obj.variables)) {
844
- return { ok: false, error: "unsupported export shape" };
879
+ let parsed;
880
+ try {
881
+ parsed = (0, import_core2.parseApicircleEnvironmentDoc)(raw);
882
+ } catch (err) {
883
+ return {
884
+ ok: false,
885
+ error: err instanceof Error ? err.message : "unsupported export shape"
886
+ };
845
887
  }
846
888
  const state = await ctx.workspace.read();
847
- if (state.synced.environments.items[obj.name] && !input.overwrite) {
889
+ if (state.synced.environments.items[parsed.name] && !input.overwrite) {
848
890
  return {
849
891
  ok: false,
850
892
  error: "environment already exists; pass overwrite:true"
851
893
  };
852
894
  }
853
- const env = {
854
- name: obj.name,
855
- variables: obj.variables.map(
856
- (v) => v.encrypted ? { key: v.key, value: "", encrypted: true, secretKeyId: v.secretKeyId } : { key: v.key, value: v.value, encrypted: false }
857
- )
858
- };
895
+ const destSlots = state.synced.secretKeys ?? {};
896
+ const labelToSlotId = /* @__PURE__ */ new Map();
897
+ for (const slot of Object.values(destSlots)) {
898
+ if (!labelToSlotId.has(slot.label)) labelToSlotId.set(slot.label, slot.id);
899
+ }
900
+ const resolvedVariables = [];
901
+ const pendingBindings = [];
902
+ const mintedSlots = [];
903
+ const knownDestIds = new Set(Object.keys(destSlots));
904
+ let hintCursor = 0;
905
+ for (const v of parsed.variables) {
906
+ if (!v.encrypted) {
907
+ resolvedVariables.push(v);
908
+ continue;
909
+ }
910
+ const hint = parsed.encryptedBindingHints[hintCursor];
911
+ hintCursor += 1;
912
+ if (hint && hint.ciphertext && hint.salt) {
913
+ if (hint.originSecretKeyId && destSlots[hint.originSecretKeyId]?.salt === hint.salt) {
914
+ resolvedVariables.push({ ...v, secretKeyId: hint.originSecretKeyId });
915
+ continue;
916
+ }
917
+ const labelMatch = labelToSlotId.get(hint.label);
918
+ if (labelMatch && destSlots[labelMatch]?.salt === hint.salt) {
919
+ resolvedVariables.push({ ...v, secretKeyId: labelMatch });
920
+ continue;
921
+ }
922
+ const mintedId = hint.originSecretKeyId && !knownDestIds.has(hint.originSecretKeyId) ? hint.originSecretKeyId : (0, import_shared2.generateId)();
923
+ knownDestIds.add(mintedId);
924
+ if (!labelToSlotId.has(hint.label)) labelToSlotId.set(hint.label, mintedId);
925
+ mintedSlots.push({
926
+ id: mintedId,
927
+ label: hint.label,
928
+ salt: hint.salt,
929
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
930
+ });
931
+ resolvedVariables.push({ ...v, secretKeyId: mintedId });
932
+ continue;
933
+ }
934
+ if (hint?.originSecretKeyId && destSlots[hint.originSecretKeyId]) {
935
+ resolvedVariables.push({ ...v, secretKeyId: hint.originSecretKeyId });
936
+ continue;
937
+ }
938
+ if (hint?.label) {
939
+ const matchId = labelToSlotId.get(hint.label);
940
+ if (matchId) {
941
+ resolvedVariables.push({ ...v, secretKeyId: matchId });
942
+ continue;
943
+ }
944
+ }
945
+ resolvedVariables.push(v);
946
+ if (hint) {
947
+ pendingBindings.push({
948
+ varKey: hint.varKey,
949
+ label: hint.label,
950
+ labelFromFallback: hint.labelFromFallback
951
+ });
952
+ }
953
+ }
954
+ for (const meta of mintedSlots) {
955
+ await ctx.workspace.apply({ kind: "secretKey.upsert", meta });
956
+ }
957
+ const env = { name: parsed.name, variables: resolvedVariables };
859
958
  const out = await ctx.workspace.apply({ kind: "environment.upsert", environment: env });
860
- return { ok: true, name: env.name, changedIds: out.changedIds };
959
+ return {
960
+ ok: true,
961
+ name: env.name,
962
+ changedIds: out.changedIds,
963
+ pendingBindings,
964
+ mintedSlots: mintedSlots.map((s) => ({ id: s.id, label: s.label })),
965
+ warnings: parsed.warnings
966
+ };
861
967
  }
862
968
  };
863
969
  var PLAN_STEP = import_zod5.z.object({
@@ -1188,17 +1294,100 @@ var workspaceWriteTool = {
1188
1294
  }
1189
1295
  };
1190
1296
 
1191
- // src/tools/history.ts
1297
+ // src/tools/folderExchange.ts
1192
1298
  var import_zod6 = require("zod");
1299
+ var import_core3 = require("@apicircle/core");
1300
+ var folderExportJsonTool = {
1301
+ name: "folder.export_json",
1302
+ description: "Export an existing folder (and its subtree) to the API Circle exchange JSON format. Embeds JSON Schema + GraphQL dependencies inline. Auth credentials are redacted by default \u2014 pass `includeCredentialIds` to keep specific fields verbatim (the report from `collectFolderExport` enumerates the available ids).",
1303
+ inputSchema: import_zod6.z.object({
1304
+ folderId: import_zod6.z.string().min(1, "folderId is required"),
1305
+ /**
1306
+ * Subset of credential ids to KEEP in the output. Anything not in
1307
+ * this list (and every detected credential when this is empty)
1308
+ * gets blanked. Use the report-side ids surfaced by the export
1309
+ * report (`<scope>:<ownerId>.<authType>.<field>`).
1310
+ */
1311
+ includeCredentialIds: import_zod6.z.array(import_zod6.z.string()).optional()
1312
+ }),
1313
+ async handler(input, ctx) {
1314
+ const state = await ctx.workspace.read();
1315
+ const collected = (0, import_core3.collectFolderExport)({
1316
+ synced: state.synced,
1317
+ folderId: input.folderId
1318
+ });
1319
+ if (!collected) {
1320
+ return {
1321
+ error: "folder_not_found",
1322
+ message: `No folder with id "${input.folderId}" exists in the active workspace.`
1323
+ };
1324
+ }
1325
+ const includeIds = new Set(input.includeCredentialIds ?? []);
1326
+ const redacted = (0, import_core3.redactFolderExportCredentials)(collected.envelope, includeIds);
1327
+ return {
1328
+ envelope: redacted,
1329
+ json: (0, import_core3.serializeFolderExport)(redacted),
1330
+ filename: (0, import_core3.suggestFolderExportFilename)(redacted),
1331
+ report: collected.report
1332
+ };
1333
+ }
1334
+ };
1335
+ var folderImportJsonTool = {
1336
+ name: "folder.import_json",
1337
+ description: "Import an `apicircle.folder/v1` envelope into the active workspace. Folder + request ids are reminted, dependency references are remapped, and JSON Schema / GraphQL definitions that match an existing global asset (by name + content) are reused.",
1338
+ inputSchema: import_zod6.z.object({
1339
+ /** Either a JSON string or the already-parsed envelope object. */
1340
+ json: import_zod6.z.string().min(1).optional(),
1341
+ envelope: import_zod6.z.record(import_zod6.z.unknown()).optional(),
1342
+ parentFolderId: import_zod6.z.string().nullable().optional()
1343
+ }),
1344
+ async handler(input, ctx) {
1345
+ if (!input.json && !input.envelope) {
1346
+ return {
1347
+ error: "invalid_input",
1348
+ message: "Pass either `json` (string) or `envelope` (object)."
1349
+ };
1350
+ }
1351
+ const text = input.json !== void 0 ? input.json : JSON.stringify(input.envelope);
1352
+ let parsed;
1353
+ try {
1354
+ parsed = (0, import_core3.parseApicircleFolderExport)(text);
1355
+ } catch (err) {
1356
+ return {
1357
+ error: "invalid_envelope",
1358
+ message: err instanceof Error ? err.message : String(err)
1359
+ };
1360
+ }
1361
+ const out = await ctx.workspace.apply({
1362
+ kind: "folder.import_apicircle",
1363
+ parsed,
1364
+ parentFolderId: input.parentFolderId ?? null
1365
+ });
1366
+ return {
1367
+ rootFolderId: parsed.rootFolder.id,
1368
+ rootFolderName: parsed.rootFolder.name,
1369
+ counts: {
1370
+ folders: parsed.subfolders.length + 1,
1371
+ requests: parsed.requests.length
1372
+ },
1373
+ filesRequiringReattachment: parsed.dependencies.files.map((f) => f.id),
1374
+ warnings: parsed.warnings,
1375
+ changedIds: out.changedIds
1376
+ };
1377
+ }
1378
+ };
1379
+
1380
+ // src/tools/history.ts
1381
+ var import_zod7 = require("zod");
1193
1382
  var historyListRunsTool = {
1194
1383
  name: "history.list_runs",
1195
1384
  description: "List request-run history rows in reverse-chronological order. Filter by `requestId`, `ok` (success/failure), or `since`/`until` ISO timestamps. `limit` caps the result set; default 100.",
1196
- inputSchema: import_zod6.z.object({
1197
- requestId: import_zod6.z.string().optional(),
1198
- ok: import_zod6.z.boolean().optional(),
1199
- since: import_zod6.z.string().optional(),
1200
- until: import_zod6.z.string().optional(),
1201
- limit: import_zod6.z.number().int().positive().max(500).default(100)
1385
+ inputSchema: import_zod7.z.object({
1386
+ requestId: import_zod7.z.string().optional(),
1387
+ ok: import_zod7.z.boolean().optional(),
1388
+ since: import_zod7.z.string().optional(),
1389
+ until: import_zod7.z.string().optional(),
1390
+ limit: import_zod7.z.number().int().positive().max(500).default(100)
1202
1391
  }),
1203
1392
  async handler(input, ctx) {
1204
1393
  const state = await ctx.workspace.read();
@@ -1232,7 +1421,7 @@ var historyListRunsTool = {
1232
1421
  var historyGetRunTool = {
1233
1422
  name: "history.get_run",
1234
1423
  description: "Fetch a single history row in full (headers, body preview, assertion results).",
1235
- inputSchema: import_zod6.z.object({ id: import_zod6.z.string() }),
1424
+ inputSchema: import_zod7.z.object({ id: import_zod7.z.string() }),
1236
1425
  async handler(input, ctx) {
1237
1426
  const state = await ctx.workspace.read();
1238
1427
  const run = state.local.history.requestRuns.find((r) => r.id === input.id);
@@ -1243,7 +1432,7 @@ var historyGetRunTool = {
1243
1432
  var historyDeleteRunTool = {
1244
1433
  name: "history.delete_run",
1245
1434
  description: "Delete a single request-run row by id.",
1246
- inputSchema: import_zod6.z.object({ id: import_zod6.z.string() }),
1435
+ inputSchema: import_zod7.z.object({ id: import_zod7.z.string() }),
1247
1436
  async handler(input, ctx) {
1248
1437
  const out = await ctx.workspace.apply({ kind: "history.delete_run", runId: input.id });
1249
1438
  return { deleted: out.changedIds.length, changedIds: out.changedIds };
@@ -1252,8 +1441,8 @@ var historyDeleteRunTool = {
1252
1441
  var historyPurgeTool = {
1253
1442
  name: "history.purge_by_age",
1254
1443
  description: "Drop every request-run + plan-run older than `olderThanDays` days. Pass 0 to clear all history.",
1255
- inputSchema: import_zod6.z.object({
1256
- olderThanDays: import_zod6.z.number().nonnegative()
1444
+ inputSchema: import_zod7.z.object({
1445
+ olderThanDays: import_zod7.z.number().nonnegative()
1257
1446
  }),
1258
1447
  async handler(input, ctx) {
1259
1448
  const olderThanMs = input.olderThanDays * 24 * 60 * 60 * 1e3;
@@ -1263,15 +1452,15 @@ var historyPurgeTool = {
1263
1452
  };
1264
1453
 
1265
1454
  // src/tools/codebase.ts
1266
- var import_zod7 = require("zod");
1455
+ var import_zod8 = require("zod");
1267
1456
  var HTTP_METHODS = ["get", "post", "put", "patch", "delete", "options", "head"];
1268
1457
  var codebaseExtractCollectionTool = {
1269
1458
  name: "codebase.extract_collection",
1270
1459
  description: "Scan source code for HTTP route definitions (Express, FastAPI, NestJS, Spring) and return candidate requests for the user to confirm before import.",
1271
- inputSchema: import_zod7.z.object({
1272
- source: import_zod7.z.string().min(1),
1460
+ inputSchema: import_zod8.z.object({
1461
+ source: import_zod8.z.string().min(1),
1273
1462
  /** Hint to limit which framework patterns to apply. Empty = try all. */
1274
- frameworks: import_zod7.z.array(import_zod7.z.enum(["express", "fastapi", "nest", "spring"])).default([])
1463
+ frameworks: import_zod8.z.array(import_zod8.z.enum(["express", "fastapi", "nest", "spring"])).default([])
1275
1464
  }),
1276
1465
  async handler(input) {
1277
1466
  const enabled = new Set(
@@ -1352,18 +1541,18 @@ var codebaseExtractCollectionTool = {
1352
1541
  };
1353
1542
 
1354
1543
  // src/tools/prompt.ts
1355
- var import_zod8 = require("zod");
1544
+ var import_zod9 = require("zod");
1356
1545
  var import_shared3 = require("@apicircle/shared");
1357
1546
  var promptCreateEnvironmentTool = {
1358
1547
  name: "prompt.create_environment",
1359
1548
  description: "Create a new environment from an LLM-shaped JSON envelope. The model produces { name, variables: [{ key, value, encrypted }] }; this tool validates and persists it.",
1360
- inputSchema: import_zod8.z.object({
1361
- name: import_zod8.z.string(),
1362
- variables: import_zod8.z.array(
1363
- import_zod8.z.object({
1364
- key: import_zod8.z.string(),
1365
- value: import_zod8.z.string(),
1366
- encrypted: import_zod8.z.boolean().default(false)
1549
+ inputSchema: import_zod9.z.object({
1550
+ name: import_zod9.z.string(),
1551
+ variables: import_zod9.z.array(
1552
+ import_zod9.z.object({
1553
+ key: import_zod9.z.string(),
1554
+ value: import_zod9.z.string(),
1555
+ encrypted: import_zod9.z.boolean().default(false)
1367
1556
  })
1368
1557
  )
1369
1558
  }),
@@ -1376,13 +1565,13 @@ var promptCreateEnvironmentTool = {
1376
1565
  var promptCreateAssertionTool = {
1377
1566
  name: "prompt.create_assertion",
1378
1567
  description: 'Add an assertion to a request from an LLM-shaped JSON envelope. Useful when the user asks "assert that the response status is 200 and body.id matches".',
1379
- inputSchema: import_zod8.z.object({
1380
- requestId: import_zod8.z.string(),
1381
- assertion: import_zod8.z.object({
1382
- kind: import_zod8.z.enum(["status", "header", "json-path", "duration"]),
1383
- op: import_zod8.z.enum(["equals", "not-equals", "contains", "lt", "gt", "matches"]),
1384
- target: import_zod8.z.string().optional(),
1385
- expected: import_zod8.z.union([import_zod8.z.string(), import_zod8.z.number()])
1568
+ inputSchema: import_zod9.z.object({
1569
+ requestId: import_zod9.z.string(),
1570
+ assertion: import_zod9.z.object({
1571
+ kind: import_zod9.z.enum(["status", "header", "json-path", "duration"]),
1572
+ op: import_zod9.z.enum(["equals", "not-equals", "contains", "lt", "gt", "matches"]),
1573
+ target: import_zod9.z.string().optional(),
1574
+ expected: import_zod9.z.union([import_zod9.z.string(), import_zod9.z.number()])
1386
1575
  })
1387
1576
  }),
1388
1577
  async handler(input, ctx) {
@@ -1401,10 +1590,10 @@ var promptCreateAssertionTool = {
1401
1590
  var promptCreatePlanTool = {
1402
1591
  name: "prompt.create_plan",
1403
1592
  description: "Create an execution plan from an LLM-shaped JSON envelope. The model produces { name, stepRequestIds: [...] } and the tool validates that each id exists in the workspace before persisting.",
1404
- inputSchema: import_zod8.z.object({
1405
- name: import_zod8.z.string(),
1406
- stepRequestIds: import_zod8.z.array(import_zod8.z.string()).default([]),
1407
- envPriorityOrder: import_zod8.z.array(import_zod8.z.string()).default([])
1593
+ inputSchema: import_zod9.z.object({
1594
+ name: import_zod9.z.string(),
1595
+ stepRequestIds: import_zod9.z.array(import_zod9.z.string()).default([]),
1596
+ envPriorityOrder: import_zod9.z.array(import_zod9.z.string()).default([])
1408
1597
  }),
1409
1598
  async handler(input, ctx) {
1410
1599
  const state = await ctx.workspace.read();
@@ -1433,51 +1622,51 @@ var promptCreatePlanTool = {
1433
1622
  return { ok: true, id, changedIds: out.changedIds };
1434
1623
  }
1435
1624
  };
1436
- var HTTP_METHOD2 = import_zod8.z.enum(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]);
1437
- var HEADER_OR_QUERY = import_zod8.z.object({
1438
- key: import_zod8.z.string(),
1439
- value: import_zod8.z.string(),
1440
- enabled: import_zod8.z.boolean().default(true)
1625
+ var HTTP_METHOD2 = import_zod9.z.enum(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]);
1626
+ var HEADER_OR_QUERY = import_zod9.z.object({
1627
+ key: import_zod9.z.string(),
1628
+ value: import_zod9.z.string(),
1629
+ enabled: import_zod9.z.boolean().default(true)
1441
1630
  });
1442
- var REQUEST_BODY = import_zod8.z.object({
1443
- type: import_zod8.z.enum(["none", "json", "text", "xml", "graphql", "urlencoded"]).default("none"),
1444
- content: import_zod8.z.string().default(""),
1445
- variables: import_zod8.z.string().optional()
1631
+ var REQUEST_BODY = import_zod9.z.object({
1632
+ type: import_zod9.z.enum(["none", "json", "text", "xml", "graphql", "urlencoded"]).default("none"),
1633
+ content: import_zod9.z.string().default(""),
1634
+ variables: import_zod9.z.string().optional()
1446
1635
  });
1447
- var PROMPT_AUTH = import_zod8.z.discriminatedUnion("type", [
1448
- import_zod8.z.object({ type: import_zod8.z.literal("none") }),
1449
- import_zod8.z.object({ type: import_zod8.z.literal("inherit") }),
1450
- import_zod8.z.object({ type: import_zod8.z.literal("bearer"), token: import_zod8.z.string().default("") }),
1451
- import_zod8.z.object({
1452
- type: import_zod8.z.literal("basic"),
1453
- username: import_zod8.z.string().default(""),
1454
- password: import_zod8.z.string().default("")
1636
+ var PROMPT_AUTH = import_zod9.z.discriminatedUnion("type", [
1637
+ import_zod9.z.object({ type: import_zod9.z.literal("none") }),
1638
+ import_zod9.z.object({ type: import_zod9.z.literal("inherit") }),
1639
+ import_zod9.z.object({ type: import_zod9.z.literal("bearer"), token: import_zod9.z.string().default("") }),
1640
+ import_zod9.z.object({
1641
+ type: import_zod9.z.literal("basic"),
1642
+ username: import_zod9.z.string().default(""),
1643
+ password: import_zod9.z.string().default("")
1455
1644
  }),
1456
- import_zod8.z.object({
1457
- type: import_zod8.z.literal("api-key"),
1458
- key: import_zod8.z.string().default(""),
1459
- value: import_zod8.z.string().default(""),
1460
- addTo: import_zod8.z.enum(["header", "query", "cookie"]).default("header")
1645
+ import_zod9.z.object({
1646
+ type: import_zod9.z.literal("api-key"),
1647
+ key: import_zod9.z.string().default(""),
1648
+ value: import_zod9.z.string().default(""),
1649
+ addTo: import_zod9.z.enum(["header", "query", "cookie"]).default("header")
1461
1650
  }),
1462
- import_zod8.z.object({
1463
- type: import_zod8.z.literal("custom-header"),
1464
- key: import_zod8.z.string().default(""),
1465
- value: import_zod8.z.string().default("")
1651
+ import_zod9.z.object({
1652
+ type: import_zod9.z.literal("custom-header"),
1653
+ key: import_zod9.z.string().default(""),
1654
+ value: import_zod9.z.string().default("")
1466
1655
  })
1467
1656
  ]);
1468
- var PROMPT_ASSERTION = import_zod8.z.object({
1469
- kind: import_zod8.z.enum(["status", "header", "json-path", "duration"]),
1470
- op: import_zod8.z.enum(["equals", "not-equals", "contains", "lt", "gt", "matches"]),
1471
- target: import_zod8.z.string().optional(),
1472
- expected: import_zod8.z.union([import_zod8.z.string(), import_zod8.z.number()])
1657
+ var PROMPT_ASSERTION = import_zod9.z.object({
1658
+ kind: import_zod9.z.enum(["status", "header", "json-path", "duration"]),
1659
+ op: import_zod9.z.enum(["equals", "not-equals", "contains", "lt", "gt", "matches"]),
1660
+ target: import_zod9.z.string().optional(),
1661
+ expected: import_zod9.z.union([import_zod9.z.string(), import_zod9.z.number()])
1473
1662
  });
1474
- var ENDPOINT_RESPONSE = import_zod8.z.object({
1475
- status: import_zod8.z.number().int().min(100).max(599).default(200),
1476
- jsonBody: import_zod8.z.string().default("{}"),
1477
- contentType: import_zod8.z.string().default("application/json")
1663
+ var ENDPOINT_RESPONSE = import_zod9.z.object({
1664
+ status: import_zod9.z.number().int().min(100).max(599).default(200),
1665
+ jsonBody: import_zod9.z.string().default("{}"),
1666
+ contentType: import_zod9.z.string().default("application/json")
1478
1667
  });
1479
- var VALIDATION_RULE_NL = import_zod8.z.object({
1480
- kind: import_zod8.z.enum([
1668
+ var VALIDATION_RULE_NL = import_zod9.z.object({
1669
+ kind: import_zod9.z.enum([
1481
1670
  "header-required",
1482
1671
  "header-equals",
1483
1672
  "header-matches",
@@ -1488,50 +1677,50 @@ var VALIDATION_RULE_NL = import_zod8.z.object({
1488
1677
  "body-required",
1489
1678
  "content-type-equals"
1490
1679
  ]),
1491
- target: import_zod8.z.string().default(""),
1492
- expected: import_zod8.z.string().optional(),
1493
- message: import_zod8.z.string().optional(),
1494
- enabled: import_zod8.z.boolean().default(true),
1495
- failResponse: import_zod8.z.object({
1496
- status: import_zod8.z.number().int().min(100).max(599).default(400),
1497
- jsonBody: import_zod8.z.string().default('{"error":"validation failed"}')
1680
+ target: import_zod9.z.string().default(""),
1681
+ expected: import_zod9.z.string().optional(),
1682
+ message: import_zod9.z.string().optional(),
1683
+ enabled: import_zod9.z.boolean().default(true),
1684
+ failResponse: import_zod9.z.object({
1685
+ status: import_zod9.z.number().int().min(100).max(599).default(400),
1686
+ jsonBody: import_zod9.z.string().default('{"error":"validation failed"}')
1498
1687
  }).default({})
1499
1688
  });
1500
- var CONDITION_CLAUSE_NL = import_zod8.z.object({
1501
- scope: import_zod8.z.enum(["query", "pathParam", "header", "cookie", "body-json-path"]),
1502
- target: import_zod8.z.string(),
1503
- op: import_zod8.z.enum(["equals", "not-equals", "matches", "gt", "lt", "gte", "lte", "present", "absent"]),
1504
- value: import_zod8.z.string().optional()
1689
+ var CONDITION_CLAUSE_NL = import_zod9.z.object({
1690
+ scope: import_zod9.z.enum(["query", "pathParam", "header", "cookie", "body-json-path"]),
1691
+ target: import_zod9.z.string(),
1692
+ op: import_zod9.z.enum(["equals", "not-equals", "matches", "gt", "lt", "gte", "lte", "present", "absent"]),
1693
+ value: import_zod9.z.string().optional()
1505
1694
  });
1506
- var RESPONSE_RULE_NL = import_zod8.z.object({
1507
- name: import_zod8.z.string(),
1508
- enabled: import_zod8.z.boolean().default(true),
1509
- when: import_zod8.z.array(CONDITION_CLAUSE_NL).default([]),
1510
- response: import_zod8.z.object({
1511
- status: import_zod8.z.number().int().min(100).max(599).default(200),
1512
- jsonBody: import_zod8.z.string().default("{}")
1695
+ var RESPONSE_RULE_NL = import_zod9.z.object({
1696
+ name: import_zod9.z.string(),
1697
+ enabled: import_zod9.z.boolean().default(true),
1698
+ when: import_zod9.z.array(CONDITION_CLAUSE_NL).default([]),
1699
+ response: import_zod9.z.object({
1700
+ status: import_zod9.z.number().int().min(100).max(599).default(200),
1701
+ jsonBody: import_zod9.z.string().default("{}")
1513
1702
  }).default({})
1514
1703
  });
1515
- var MULTIPLIER_NL = import_zod8.z.object({
1516
- name: import_zod8.z.string().optional(),
1517
- source: import_zod8.z.object({
1518
- kind: import_zod8.z.enum(["query", "pathParam", "header", "body-json-path"]),
1519
- key: import_zod8.z.string()
1704
+ var MULTIPLIER_NL = import_zod9.z.object({
1705
+ name: import_zod9.z.string().optional(),
1706
+ source: import_zod9.z.object({
1707
+ kind: import_zod9.z.enum(["query", "pathParam", "header", "body-json-path"]),
1708
+ key: import_zod9.z.string()
1520
1709
  }),
1521
- targetJsonPath: import_zod8.z.string(),
1522
- defaultCount: import_zod8.z.number().int().nonnegative().default(0),
1523
- min: import_zod8.z.number().int().nonnegative().optional(),
1524
- max: import_zod8.z.number().int().nonnegative().optional()
1710
+ targetJsonPath: import_zod9.z.string(),
1711
+ defaultCount: import_zod9.z.number().int().nonnegative().default(0),
1712
+ min: import_zod9.z.number().int().nonnegative().optional(),
1713
+ max: import_zod9.z.number().int().nonnegative().optional()
1525
1714
  });
1526
- var ENDPOINT_INPUT = import_zod8.z.object({
1715
+ var ENDPOINT_INPUT = import_zod9.z.object({
1527
1716
  method: HTTP_METHOD2,
1528
- pathPattern: import_zod8.z.string().min(1),
1529
- name: import_zod8.z.string().optional(),
1530
- description: import_zod8.z.string().optional(),
1717
+ pathPattern: import_zod9.z.string().min(1),
1718
+ name: import_zod9.z.string().optional(),
1719
+ description: import_zod9.z.string().optional(),
1531
1720
  response: ENDPOINT_RESPONSE.optional(),
1532
- validationRules: import_zod8.z.array(VALIDATION_RULE_NL).default([]),
1533
- responseRules: import_zod8.z.array(RESPONSE_RULE_NL).default([]),
1534
- multipliers: import_zod8.z.array(MULTIPLIER_NL).default([])
1721
+ validationRules: import_zod9.z.array(VALIDATION_RULE_NL).default([]),
1722
+ responseRules: import_zod9.z.array(RESPONSE_RULE_NL).default([]),
1723
+ multipliers: import_zod9.z.array(MULTIPLIER_NL).default([])
1535
1724
  });
1536
1725
  function buildRequestBody(input) {
1537
1726
  if (!input) return { type: "none", content: "" };
@@ -1624,17 +1813,17 @@ function patchEndpoint(mock, endpointId, patcher) {
1624
1813
  var promptCreateRequestTool = {
1625
1814
  name: "prompt.create_request",
1626
1815
  description: "Create a fully-shaped request from an LLM-shaped JSON envelope: method, url, headers, query params, body, auth, and inline assertions. The model produces a flat object; this tool generates the request id, normalizes auth (defaults to `inherit` so folder auth wins), and persists.",
1627
- inputSchema: import_zod8.z.object({
1628
- name: import_zod8.z.string().default("New request"),
1816
+ inputSchema: import_zod9.z.object({
1817
+ name: import_zod9.z.string().default("New request"),
1629
1818
  method: HTTP_METHOD2.default("GET"),
1630
- url: import_zod8.z.string().default(""),
1631
- folderId: import_zod8.z.string().nullable().optional(),
1632
- headers: import_zod8.z.array(HEADER_OR_QUERY).default([]),
1633
- queryParams: import_zod8.z.array(HEADER_OR_QUERY).default([]),
1634
- pathParams: import_zod8.z.record(import_zod8.z.string(), import_zod8.z.string()).optional(),
1819
+ url: import_zod9.z.string().default(""),
1820
+ folderId: import_zod9.z.string().nullable().optional(),
1821
+ headers: import_zod9.z.array(HEADER_OR_QUERY).default([]),
1822
+ queryParams: import_zod9.z.array(HEADER_OR_QUERY).default([]),
1823
+ pathParams: import_zod9.z.record(import_zod9.z.string(), import_zod9.z.string()).optional(),
1635
1824
  body: REQUEST_BODY.optional(),
1636
1825
  auth: PROMPT_AUTH.optional(),
1637
- assertions: import_zod8.z.array(PROMPT_ASSERTION).default([])
1826
+ assertions: import_zod9.z.array(PROMPT_ASSERTION).default([])
1638
1827
  }),
1639
1828
  async handler(input, ctx) {
1640
1829
  const now = (/* @__PURE__ */ new Date()).toISOString();
@@ -1664,19 +1853,19 @@ var promptCreateRequestTool = {
1664
1853
  var promptUpdateRequestTool = {
1665
1854
  name: "prompt.update_request",
1666
1855
  description: "Patch an existing request from an LLM-shaped JSON envelope. Provided fields replace the existing values; omitted fields are left untouched. Arrays (headers, queryParams, assertions) are full replacements when supplied. Returns `{ ok: false, error }` when the id does not resolve.",
1667
- inputSchema: import_zod8.z.object({
1668
- id: import_zod8.z.string(),
1669
- patch: import_zod8.z.object({
1670
- name: import_zod8.z.string().optional(),
1856
+ inputSchema: import_zod9.z.object({
1857
+ id: import_zod9.z.string(),
1858
+ patch: import_zod9.z.object({
1859
+ name: import_zod9.z.string().optional(),
1671
1860
  method: HTTP_METHOD2.optional(),
1672
- url: import_zod8.z.string().optional(),
1673
- folderId: import_zod8.z.string().nullable().optional(),
1674
- headers: import_zod8.z.array(HEADER_OR_QUERY).optional(),
1675
- queryParams: import_zod8.z.array(HEADER_OR_QUERY).optional(),
1676
- pathParams: import_zod8.z.record(import_zod8.z.string(), import_zod8.z.string()).optional(),
1861
+ url: import_zod9.z.string().optional(),
1862
+ folderId: import_zod9.z.string().nullable().optional(),
1863
+ headers: import_zod9.z.array(HEADER_OR_QUERY).optional(),
1864
+ queryParams: import_zod9.z.array(HEADER_OR_QUERY).optional(),
1865
+ pathParams: import_zod9.z.record(import_zod9.z.string(), import_zod9.z.string()).optional(),
1677
1866
  body: REQUEST_BODY.optional(),
1678
1867
  auth: PROMPT_AUTH.optional(),
1679
- assertions: import_zod8.z.array(PROMPT_ASSERTION).optional()
1868
+ assertions: import_zod9.z.array(PROMPT_ASSERTION).optional()
1680
1869
  }).strict()
1681
1870
  }),
1682
1871
  async handler(input, ctx) {
@@ -1704,17 +1893,17 @@ var promptUpdateRequestTool = {
1704
1893
  return { ok: true, changedIds: out.changedIds };
1705
1894
  }
1706
1895
  };
1707
- var FOLDER_TREE_NODE = import_zod8.z.lazy(
1708
- () => import_zod8.z.object({
1709
- name: import_zod8.z.string(),
1710
- children: import_zod8.z.array(FOLDER_TREE_NODE).optional()
1896
+ var FOLDER_TREE_NODE = import_zod9.z.lazy(
1897
+ () => import_zod9.z.object({
1898
+ name: import_zod9.z.string(),
1899
+ children: import_zod9.z.array(FOLDER_TREE_NODE).optional()
1711
1900
  })
1712
1901
  );
1713
1902
  var promptCreateFolderTreeTool = {
1714
1903
  name: "prompt.create_folder_tree",
1715
1904
  description: "Create a recursive folder hierarchy from an LLM-shaped JSON envelope. The model produces `{ parentId?, tree: { name, children?: [...] } }` and this tool walks the tree, generating ids and persisting one folder per node. Returns the list of created ids in pre-order.",
1716
- inputSchema: import_zod8.z.object({
1717
- parentId: import_zod8.z.string().nullable().optional(),
1905
+ inputSchema: import_zod9.z.object({
1906
+ parentId: import_zod9.z.string().nullable().optional(),
1718
1907
  tree: FOLDER_TREE_NODE
1719
1908
  }),
1720
1909
  async handler(input, ctx) {
@@ -1740,9 +1929,9 @@ var promptCreateFolderTreeTool = {
1740
1929
  var promptAddPlanStepsTool = {
1741
1930
  name: "prompt.add_plan_steps",
1742
1931
  description: "Append one or more steps to an existing execution plan from an LLM-shaped JSON envelope. The model produces `{ planId, requestIds: [...] }`; each id is validated against the workspace before any step is appended. Order in the input list is preserved.",
1743
- inputSchema: import_zod8.z.object({
1744
- planId: import_zod8.z.string(),
1745
- requestIds: import_zod8.z.array(import_zod8.z.string()).min(1)
1932
+ inputSchema: import_zod9.z.object({
1933
+ planId: import_zod9.z.string(),
1934
+ requestIds: import_zod9.z.array(import_zod9.z.string()).min(1)
1746
1935
  }),
1747
1936
  async handler(input, ctx) {
1748
1937
  const state = await ctx.workspace.read();
@@ -1772,9 +1961,9 @@ var promptAddPlanStepsTool = {
1772
1961
  var promptSetPlanVariablesTool = {
1773
1962
  name: "prompt.set_plan_variables",
1774
1963
  description: "Replace the plan-scoped variables on an execution plan from an LLM-shaped JSON envelope. The model produces `{ planId, variables: [{ key, value }] }`. Empty array clears all plan variables.",
1775
- inputSchema: import_zod8.z.object({
1776
- planId: import_zod8.z.string(),
1777
- variables: import_zod8.z.array(import_zod8.z.object({ key: import_zod8.z.string(), value: import_zod8.z.string() }))
1964
+ inputSchema: import_zod9.z.object({
1965
+ planId: import_zod9.z.string(),
1966
+ variables: import_zod9.z.array(import_zod9.z.object({ key: import_zod9.z.string(), value: import_zod9.z.string() }))
1778
1967
  }),
1779
1968
  async handler(input, ctx) {
1780
1969
  const state = await ctx.workspace.read();
@@ -1790,10 +1979,10 @@ var promptSetPlanVariablesTool = {
1790
1979
  var promptCreateMockServerTool = {
1791
1980
  name: "prompt.create_mock_server",
1792
1981
  description: "Create a manual-mode mock server with optional inline endpoints from an LLM-shaped JSON envelope. The model produces `{ name, defaultPort?, endpoints: [{ method, pathPattern, name?, response?, validationRules?, responseRules?, multipliers? }] }`; this tool generates ids for the server and every endpoint / rule, then persists in one shot.",
1793
- inputSchema: import_zod8.z.object({
1794
- name: import_zod8.z.string().min(1),
1795
- defaultPort: import_zod8.z.number().int().positive().nullable().optional(),
1796
- endpoints: import_zod8.z.array(ENDPOINT_INPUT).default([])
1982
+ inputSchema: import_zod9.z.object({
1983
+ name: import_zod9.z.string().min(1),
1984
+ defaultPort: import_zod9.z.number().int().positive().nullable().optional(),
1985
+ endpoints: import_zod9.z.array(ENDPOINT_INPUT).default([])
1797
1986
  }),
1798
1987
  async handler(input, ctx) {
1799
1988
  const now = (/* @__PURE__ */ new Date()).toISOString();
@@ -1820,16 +2009,16 @@ var promptCreateMockServerTool = {
1820
2009
  var promptAddMockEndpointTool = {
1821
2010
  name: "prompt.add_mock_endpoint",
1822
2011
  description: "Append a new endpoint (with optional inline validation rules, response rules, and multipliers) to an existing mock server from an LLM-shaped JSON envelope. All ids are auto-generated; the existing endpoints stay in place.",
1823
- inputSchema: import_zod8.z.object({
1824
- mockId: import_zod8.z.string(),
2012
+ inputSchema: import_zod9.z.object({
2013
+ mockId: import_zod9.z.string(),
1825
2014
  method: HTTP_METHOD2,
1826
- pathPattern: import_zod8.z.string().min(1),
1827
- name: import_zod8.z.string().optional(),
1828
- description: import_zod8.z.string().optional(),
2015
+ pathPattern: import_zod9.z.string().min(1),
2016
+ name: import_zod9.z.string().optional(),
2017
+ description: import_zod9.z.string().optional(),
1829
2018
  response: ENDPOINT_RESPONSE.optional(),
1830
- validationRules: import_zod8.z.array(VALIDATION_RULE_NL).default([]),
1831
- responseRules: import_zod8.z.array(RESPONSE_RULE_NL).default([]),
1832
- multipliers: import_zod8.z.array(MULTIPLIER_NL).default([])
2019
+ validationRules: import_zod9.z.array(VALIDATION_RULE_NL).default([]),
2020
+ responseRules: import_zod9.z.array(RESPONSE_RULE_NL).default([]),
2021
+ multipliers: import_zod9.z.array(MULTIPLIER_NL).default([])
1833
2022
  }),
1834
2023
  async handler(input, ctx) {
1835
2024
  const state = await ctx.workspace.read();
@@ -1851,10 +2040,10 @@ var promptAddMockEndpointTool = {
1851
2040
  var promptSetEndpointValidationRulesTool = {
1852
2041
  name: "prompt.set_endpoint_validation_rules",
1853
2042
  description: "Replace an endpoint's validation rules with an LLM-shaped list. Every rule gets a fresh id; the existing rules are dropped. Empty array clears all validation rules.",
1854
- inputSchema: import_zod8.z.object({
1855
- mockId: import_zod8.z.string(),
1856
- endpointId: import_zod8.z.string(),
1857
- rules: import_zod8.z.array(VALIDATION_RULE_NL)
2043
+ inputSchema: import_zod9.z.object({
2044
+ mockId: import_zod9.z.string(),
2045
+ endpointId: import_zod9.z.string(),
2046
+ rules: import_zod9.z.array(VALIDATION_RULE_NL)
1858
2047
  }),
1859
2048
  async handler(input, ctx) {
1860
2049
  const state = await ctx.workspace.read();
@@ -1885,10 +2074,10 @@ var promptSetEndpointValidationRulesTool = {
1885
2074
  var promptSetEndpointResponseRulesTool = {
1886
2075
  name: "prompt.set_endpoint_response_rules",
1887
2076
  description: "Replace an endpoint's conditional response rules with an LLM-shaped list. Rules fire in order, first match wins. Every rule + clause gets a fresh id. Empty array falls back to defaultResponse.",
1888
- inputSchema: import_zod8.z.object({
1889
- mockId: import_zod8.z.string(),
1890
- endpointId: import_zod8.z.string(),
1891
- rules: import_zod8.z.array(RESPONSE_RULE_NL)
2077
+ inputSchema: import_zod9.z.object({
2078
+ mockId: import_zod9.z.string(),
2079
+ endpointId: import_zod9.z.string(),
2080
+ rules: import_zod9.z.array(RESPONSE_RULE_NL)
1892
2081
  }),
1893
2082
  async handler(input, ctx) {
1894
2083
  const state = await ctx.workspace.read();
@@ -1923,10 +2112,10 @@ var promptSetEndpointResponseRulesTool = {
1923
2112
  var promptSetEndpointMultipliersTool = {
1924
2113
  name: "prompt.set_endpoint_multipliers",
1925
2114
  description: "Replace the response multipliers on an endpoint's defaultResponse with an LLM-shaped list. Multipliers expand an array at `targetJsonPath` to a count derived from a request value. Every multiplier gets a fresh id. Empty array clears all multipliers.",
1926
- inputSchema: import_zod8.z.object({
1927
- mockId: import_zod8.z.string(),
1928
- endpointId: import_zod8.z.string(),
1929
- multipliers: import_zod8.z.array(MULTIPLIER_NL)
2115
+ inputSchema: import_zod9.z.object({
2116
+ mockId: import_zod9.z.string(),
2117
+ endpointId: import_zod9.z.string(),
2118
+ multipliers: import_zod9.z.array(MULTIPLIER_NL)
1930
2119
  }),
1931
2120
  async handler(input, ctx) {
1932
2121
  const state = await ctx.workspace.read();
@@ -1955,7 +2144,7 @@ var promptSetEndpointMultipliersTool = {
1955
2144
  };
1956
2145
 
1957
2146
  // src/tools/mocks.ts
1958
- var import_zod9 = require("zod");
2147
+ var import_zod10 = require("zod");
1959
2148
  var import_shared4 = require("@apicircle/shared");
1960
2149
  var import_mock_server_core2 = require("@apicircle/mock-server-core");
1961
2150
  async function ingestSource(source, name) {
@@ -1978,10 +2167,10 @@ async function ingestSource(source, name) {
1978
2167
  var mockCreateFromOpenApiTool = {
1979
2168
  name: "mock.create_from_openapi",
1980
2169
  description: "Create a mock server from an OpenAPI / Swagger spec (YAML or JSON).",
1981
- inputSchema: import_zod9.z.object({
1982
- name: import_zod9.z.string(),
1983
- spec: import_zod9.z.string().min(1),
1984
- format: import_zod9.z.enum(["json", "yaml"]).default("json")
2170
+ inputSchema: import_zod10.z.object({
2171
+ name: import_zod10.z.string(),
2172
+ spec: import_zod10.z.string().min(1),
2173
+ format: import_zod10.z.enum(["json", "yaml"]).default("json")
1985
2174
  }),
1986
2175
  async handler(input, ctx) {
1987
2176
  const { mock, warnings } = await ingestSource(
@@ -2000,7 +2189,7 @@ var mockCreateFromOpenApiTool = {
2000
2189
  var mockCreateFromPostmanTool = {
2001
2190
  name: "mock.create_from_postman",
2002
2191
  description: "Create a mock server from a Postman v2/v2.1 collection.",
2003
- inputSchema: import_zod9.z.object({ name: import_zod9.z.string(), collection: import_zod9.z.string().min(1) }),
2192
+ inputSchema: import_zod10.z.object({ name: import_zod10.z.string(), collection: import_zod10.z.string().min(1) }),
2004
2193
  async handler(input, ctx) {
2005
2194
  const { mock, warnings } = await ingestSource(
2006
2195
  { kind: "postman", collection: input.collection },
@@ -2018,7 +2207,7 @@ var mockCreateFromPostmanTool = {
2018
2207
  var mockCreateFromInsomniaTool = {
2019
2208
  name: "mock.create_from_insomnia",
2020
2209
  description: "Create a mock server from an Insomnia v4 export.",
2021
- inputSchema: import_zod9.z.object({ name: import_zod9.z.string(), export: import_zod9.z.string().min(1) }),
2210
+ inputSchema: import_zod10.z.object({ name: import_zod10.z.string(), export: import_zod10.z.string().min(1) }),
2022
2211
  async handler(input, ctx) {
2023
2212
  const { mock, warnings } = await ingestSource(
2024
2213
  { kind: "insomnia", export: input.export },
@@ -2036,7 +2225,7 @@ var mockCreateFromInsomniaTool = {
2036
2225
  var mockImportPostmanMockCollectionTool = {
2037
2226
  name: "mock.import_postman_mock_collection",
2038
2227
  description: "Import a Postman Mock Collection (collections previously hosted on Postman's mock service). Same parser as a regular Postman collection but marked as a mock import.",
2039
- inputSchema: import_zod9.z.object({ name: import_zod9.z.string(), collection: import_zod9.z.string().min(1) }),
2228
+ inputSchema: import_zod10.z.object({ name: import_zod10.z.string(), collection: import_zod10.z.string().min(1) }),
2040
2229
  async handler(input, ctx) {
2041
2230
  const { mock, warnings } = await ingestSource(
2042
2231
  { kind: "postman", collection: input.collection },
@@ -2054,7 +2243,7 @@ var mockImportPostmanMockCollectionTool = {
2054
2243
  var mockListTool = {
2055
2244
  name: "mock.list",
2056
2245
  description: "List all mock servers in the workspace plus their runtime status (running / stopped, port).",
2057
- inputSchema: import_zod9.z.object({}),
2246
+ inputSchema: import_zod10.z.object({}),
2058
2247
  async handler(_input, ctx) {
2059
2248
  const state = await ctx.workspace.read();
2060
2249
  const running = await ctx.mock.list();
@@ -2076,9 +2265,9 @@ var mockListTool = {
2076
2265
  var mockStartTool = {
2077
2266
  name: "mock.start",
2078
2267
  description: "Start a mock server by id. Returns the bound port. Errors if the mock is already running or the requested port is in use.",
2079
- inputSchema: import_zod9.z.object({
2080
- id: import_zod9.z.string(),
2081
- port: import_zod9.z.number().int().positive().optional()
2268
+ inputSchema: import_zod10.z.object({
2269
+ id: import_zod10.z.string(),
2270
+ port: import_zod10.z.number().int().positive().optional()
2082
2271
  }),
2083
2272
  async handler(input, ctx) {
2084
2273
  const state = await ctx.workspace.read();
@@ -2095,7 +2284,7 @@ var mockStartTool = {
2095
2284
  var mockStopTool = {
2096
2285
  name: "mock.stop",
2097
2286
  description: "Stop a running mock server by id (no-op if not running).",
2098
- inputSchema: import_zod9.z.object({ id: import_zod9.z.string() }),
2287
+ inputSchema: import_zod10.z.object({ id: import_zod10.z.string() }),
2099
2288
  async handler(input, ctx) {
2100
2289
  try {
2101
2290
  await ctx.mock.stop(input.id);
@@ -2108,7 +2297,7 @@ var mockStopTool = {
2108
2297
  var mockDeleteTool = {
2109
2298
  name: "mock.delete",
2110
2299
  description: "Delete a mock server definition. Stops it first if it's running.",
2111
- inputSchema: import_zod9.z.object({ id: import_zod9.z.string() }),
2300
+ inputSchema: import_zod10.z.object({ id: import_zod10.z.string() }),
2112
2301
  async handler(input, ctx) {
2113
2302
  try {
2114
2303
  await ctx.mock.stop(input.id);
@@ -2118,13 +2307,13 @@ var mockDeleteTool = {
2118
2307
  return { ok: true, changedIds: out.changedIds };
2119
2308
  }
2120
2309
  };
2121
- var HTTP_METHOD3 = import_zod9.z.enum(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]);
2310
+ var HTTP_METHOD3 = import_zod10.z.enum(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]);
2122
2311
  var mockCreateManualTool = {
2123
2312
  name: "mock.create_manual",
2124
2313
  description: "Create an empty manual-mode mock server. Use `mock.add_endpoint` afterward to populate it. CORS defaults to off (same-origin only); enable + list explicit origins via `mock.update_cors` if cross-origin access is needed.",
2125
- inputSchema: import_zod9.z.object({
2126
- name: import_zod9.z.string().min(1),
2127
- defaultPort: import_zod9.z.number().int().positive().nullable().optional()
2314
+ inputSchema: import_zod10.z.object({
2315
+ name: import_zod10.z.string().min(1),
2316
+ defaultPort: import_zod10.z.number().int().positive().nullable().optional()
2128
2317
  }),
2129
2318
  async handler(input, ctx) {
2130
2319
  const now = (/* @__PURE__ */ new Date()).toISOString();
@@ -2147,7 +2336,7 @@ var mockCreateManualTool = {
2147
2336
  var mockListEndpointsTool = {
2148
2337
  name: "mock.list_endpoints",
2149
2338
  description: "List endpoints for a mock server (id, method, path, name).",
2150
- inputSchema: import_zod9.z.object({ mockId: import_zod9.z.string() }),
2339
+ inputSchema: import_zod10.z.object({ mockId: import_zod10.z.string() }),
2151
2340
  async handler(input, ctx) {
2152
2341
  const state = await ctx.workspace.read();
2153
2342
  const mock = state.synced.mockServers[input.mockId];
@@ -2166,10 +2355,10 @@ var mockListEndpointsTool = {
2166
2355
  };
2167
2356
  }
2168
2357
  };
2169
- var ENDPOINT_RESPONSE2 = import_zod9.z.object({
2170
- status: import_zod9.z.number().int().min(100).max(599).default(200),
2171
- jsonBody: import_zod9.z.string().default("{}"),
2172
- contentType: import_zod9.z.string().default("application/json")
2358
+ var ENDPOINT_RESPONSE2 = import_zod10.z.object({
2359
+ status: import_zod10.z.number().int().min(100).max(599).default(200),
2360
+ jsonBody: import_zod10.z.string().default("{}"),
2361
+ contentType: import_zod10.z.string().default("application/json")
2173
2362
  });
2174
2363
  function buildDefaultEndpoint(args) {
2175
2364
  const response = args.response ?? {
@@ -2198,12 +2387,12 @@ function buildDefaultEndpoint(args) {
2198
2387
  var mockAddEndpointTool = {
2199
2388
  name: "mock.add_endpoint",
2200
2389
  description: "Append a new endpoint to a mock server. Defaults to a 200 JSON response of `{}`. Returns the new endpoint id.",
2201
- inputSchema: import_zod9.z.object({
2202
- mockId: import_zod9.z.string(),
2390
+ inputSchema: import_zod10.z.object({
2391
+ mockId: import_zod10.z.string(),
2203
2392
  method: HTTP_METHOD3,
2204
- pathPattern: import_zod9.z.string().min(1),
2205
- name: import_zod9.z.string().optional(),
2206
- description: import_zod9.z.string().optional(),
2393
+ pathPattern: import_zod10.z.string().min(1),
2394
+ name: import_zod10.z.string().optional(),
2395
+ description: import_zod10.z.string().optional(),
2207
2396
  response: ENDPOINT_RESPONSE2.optional()
2208
2397
  }),
2209
2398
  async handler(input, ctx) {
@@ -2226,13 +2415,13 @@ var mockAddEndpointTool = {
2226
2415
  var mockUpdateEndpointTool = {
2227
2416
  name: "mock.update_endpoint",
2228
2417
  description: "Patch fields on a single mock endpoint (method, pathPattern, name, description, defaultResponse status / contentType / json body). Pass only the fields you want to change.",
2229
- inputSchema: import_zod9.z.object({
2230
- mockId: import_zod9.z.string(),
2231
- endpointId: import_zod9.z.string(),
2418
+ inputSchema: import_zod10.z.object({
2419
+ mockId: import_zod10.z.string(),
2420
+ endpointId: import_zod10.z.string(),
2232
2421
  method: HTTP_METHOD3.optional(),
2233
- pathPattern: import_zod9.z.string().optional(),
2234
- name: import_zod9.z.string().optional(),
2235
- description: import_zod9.z.string().optional(),
2422
+ pathPattern: import_zod10.z.string().optional(),
2423
+ name: import_zod10.z.string().optional(),
2424
+ description: import_zod10.z.string().optional(),
2236
2425
  response: ENDPOINT_RESPONSE2.partial().optional()
2237
2426
  }),
2238
2427
  async handler(input, ctx) {
@@ -2273,7 +2462,7 @@ var mockUpdateEndpointTool = {
2273
2462
  var mockDeleteEndpointTool = {
2274
2463
  name: "mock.delete_endpoint",
2275
2464
  description: "Remove an endpoint from a mock server.",
2276
- inputSchema: import_zod9.z.object({ mockId: import_zod9.z.string(), endpointId: import_zod9.z.string() }),
2465
+ inputSchema: import_zod10.z.object({ mockId: import_zod10.z.string(), endpointId: import_zod10.z.string() }),
2277
2466
  async handler(input, ctx) {
2278
2467
  const state = await ctx.workspace.read();
2279
2468
  const mock = state.synced.mockServers[input.mockId];
@@ -2293,9 +2482,9 @@ var mockDeleteEndpointTool = {
2293
2482
  return { ok: true, changedIds: out.changedIds };
2294
2483
  }
2295
2484
  };
2296
- var VALIDATION_RULE = import_zod9.z.object({
2297
- id: import_zod9.z.string().optional(),
2298
- kind: import_zod9.z.enum([
2485
+ var VALIDATION_RULE = import_zod10.z.object({
2486
+ id: import_zod10.z.string().optional(),
2487
+ kind: import_zod10.z.enum([
2299
2488
  "header-required",
2300
2489
  "header-equals",
2301
2490
  "header-matches",
@@ -2306,43 +2495,43 @@ var VALIDATION_RULE = import_zod9.z.object({
2306
2495
  "body-required",
2307
2496
  "content-type-equals"
2308
2497
  ]),
2309
- target: import_zod9.z.string().default(""),
2310
- expected: import_zod9.z.string().optional(),
2311
- message: import_zod9.z.string().optional(),
2312
- enabled: import_zod9.z.boolean().default(true),
2313
- failResponse: import_zod9.z.object({
2314
- status: import_zod9.z.number().int().min(100).max(599).default(400),
2315
- jsonBody: import_zod9.z.string().default('{"error":"validation failed"}')
2498
+ target: import_zod10.z.string().default(""),
2499
+ expected: import_zod10.z.string().optional(),
2500
+ message: import_zod10.z.string().optional(),
2501
+ enabled: import_zod10.z.boolean().default(true),
2502
+ failResponse: import_zod10.z.object({
2503
+ status: import_zod10.z.number().int().min(100).max(599).default(400),
2504
+ jsonBody: import_zod10.z.string().default('{"error":"validation failed"}')
2316
2505
  }).default({})
2317
2506
  });
2318
- var CONDITION_CLAUSE = import_zod9.z.object({
2319
- id: import_zod9.z.string().optional(),
2320
- scope: import_zod9.z.enum(["query", "pathParam", "header", "cookie", "body-json-path"]),
2321
- target: import_zod9.z.string(),
2322
- op: import_zod9.z.enum(["equals", "not-equals", "matches", "gt", "lt", "gte", "lte", "present", "absent"]),
2323
- value: import_zod9.z.string().optional()
2507
+ var CONDITION_CLAUSE = import_zod10.z.object({
2508
+ id: import_zod10.z.string().optional(),
2509
+ scope: import_zod10.z.enum(["query", "pathParam", "header", "cookie", "body-json-path"]),
2510
+ target: import_zod10.z.string(),
2511
+ op: import_zod10.z.enum(["equals", "not-equals", "matches", "gt", "lt", "gte", "lte", "present", "absent"]),
2512
+ value: import_zod10.z.string().optional()
2324
2513
  });
2325
- var RESPONSE_RULE = import_zod9.z.object({
2326
- id: import_zod9.z.string().optional(),
2327
- name: import_zod9.z.string(),
2328
- enabled: import_zod9.z.boolean().default(true),
2329
- when: import_zod9.z.array(CONDITION_CLAUSE).default([]),
2330
- response: import_zod9.z.object({
2331
- status: import_zod9.z.number().int().min(100).max(599).default(200),
2332
- jsonBody: import_zod9.z.string().default("{}")
2514
+ var RESPONSE_RULE = import_zod10.z.object({
2515
+ id: import_zod10.z.string().optional(),
2516
+ name: import_zod10.z.string(),
2517
+ enabled: import_zod10.z.boolean().default(true),
2518
+ when: import_zod10.z.array(CONDITION_CLAUSE).default([]),
2519
+ response: import_zod10.z.object({
2520
+ status: import_zod10.z.number().int().min(100).max(599).default(200),
2521
+ jsonBody: import_zod10.z.string().default("{}")
2333
2522
  }).default({})
2334
2523
  });
2335
- var MULTIPLIER = import_zod9.z.object({
2336
- id: import_zod9.z.string().optional(),
2337
- name: import_zod9.z.string().optional(),
2338
- source: import_zod9.z.object({
2339
- kind: import_zod9.z.enum(["query", "pathParam", "header", "body-json-path"]),
2340
- key: import_zod9.z.string()
2524
+ var MULTIPLIER = import_zod10.z.object({
2525
+ id: import_zod10.z.string().optional(),
2526
+ name: import_zod10.z.string().optional(),
2527
+ source: import_zod10.z.object({
2528
+ kind: import_zod10.z.enum(["query", "pathParam", "header", "body-json-path"]),
2529
+ key: import_zod10.z.string()
2341
2530
  }),
2342
- targetJsonPath: import_zod9.z.string(),
2343
- defaultCount: import_zod9.z.number().int().nonnegative().default(0),
2344
- min: import_zod9.z.number().int().nonnegative().optional(),
2345
- max: import_zod9.z.number().int().nonnegative().optional()
2531
+ targetJsonPath: import_zod10.z.string(),
2532
+ defaultCount: import_zod10.z.number().int().nonnegative().default(0),
2533
+ min: import_zod10.z.number().int().nonnegative().optional(),
2534
+ max: import_zod10.z.number().int().nonnegative().optional()
2346
2535
  });
2347
2536
  function defaultJsonResponseConfig(args) {
2348
2537
  return {
@@ -2367,10 +2556,10 @@ function patchEndpoint2(mock, endpointId, patcher) {
2367
2556
  var mockSetValidationRulesTool = {
2368
2557
  name: "mock.set_validation_rules",
2369
2558
  description: "Replace an endpoint's validation rules. Rules without an `id` get a fresh one; existing rules can keep theirs to preserve client-side selection state. Empty array clears all rules.",
2370
- inputSchema: import_zod9.z.object({
2371
- mockId: import_zod9.z.string(),
2372
- endpointId: import_zod9.z.string(),
2373
- rules: import_zod9.z.array(VALIDATION_RULE)
2559
+ inputSchema: import_zod10.z.object({
2560
+ mockId: import_zod10.z.string(),
2561
+ endpointId: import_zod10.z.string(),
2562
+ rules: import_zod10.z.array(VALIDATION_RULE)
2374
2563
  }),
2375
2564
  async handler(input, ctx) {
2376
2565
  const state = await ctx.workspace.read();
@@ -2397,10 +2586,10 @@ var mockSetValidationRulesTool = {
2397
2586
  var mockSetResponseRulesTool = {
2398
2587
  name: "mock.set_response_rules",
2399
2588
  description: "Replace an endpoint's conditional response rules. Rules fire in order; the first whose every clause matches wins. Disabled rules are skipped. Empty array falls back to defaultResponse.",
2400
- inputSchema: import_zod9.z.object({
2401
- mockId: import_zod9.z.string(),
2402
- endpointId: import_zod9.z.string(),
2403
- rules: import_zod9.z.array(RESPONSE_RULE)
2589
+ inputSchema: import_zod10.z.object({
2590
+ mockId: import_zod10.z.string(),
2591
+ endpointId: import_zod10.z.string(),
2592
+ rules: import_zod10.z.array(RESPONSE_RULE)
2404
2593
  }),
2405
2594
  async handler(input, ctx) {
2406
2595
  const state = await ctx.workspace.read();
@@ -2431,10 +2620,10 @@ var mockSetResponseRulesTool = {
2431
2620
  var mockSetMultipliersTool = {
2432
2621
  name: "mock.set_multipliers",
2433
2622
  description: "Replace the response multipliers on an endpoint's defaultResponse. Multipliers expand an array at `targetJsonPath` to a count derived from a request value. Empty array clears all multipliers.",
2434
- inputSchema: import_zod9.z.object({
2435
- mockId: import_zod9.z.string(),
2436
- endpointId: import_zod9.z.string(),
2437
- multipliers: import_zod9.z.array(MULTIPLIER)
2623
+ inputSchema: import_zod10.z.object({
2624
+ mockId: import_zod10.z.string(),
2625
+ endpointId: import_zod10.z.string(),
2626
+ multipliers: import_zod10.z.array(MULTIPLIER)
2438
2627
  }),
2439
2628
  async handler(input, ctx) {
2440
2629
  const state = await ctx.workspace.read();
@@ -2481,6 +2670,8 @@ var TOOL_REGISTRY = [
2481
2670
  folderReadTool,
2482
2671
  folderUpdateTool,
2483
2672
  folderDeleteTool,
2673
+ folderExportJsonTool,
2674
+ folderImportJsonTool,
2484
2675
  environmentCreateTool,
2485
2676
  environmentReadTool,
2486
2677
  environmentUpdateTool,
@@ -2599,7 +2790,7 @@ var WorkspaceNotFoundError = class extends Error {
2599
2790
  };
2600
2791
 
2601
2792
  // src/providers/InMemoryWorkspaceProvider.ts
2602
- var import_core2 = require("@apicircle/core");
2793
+ var import_core4 = require("@apicircle/core");
2603
2794
  var InMemoryWorkspaceProvider = class {
2604
2795
  state;
2605
2796
  constructor(initial) {
@@ -2609,7 +2800,7 @@ var InMemoryWorkspaceProvider = class {
2609
2800
  return this.state;
2610
2801
  }
2611
2802
  async apply(patch) {
2612
- const out = (0, import_core2.applyMutation)(this.state, patch);
2803
+ const out = (0, import_core4.applyMutation)(this.state, patch);
2613
2804
  this.state = out.next;
2614
2805
  return { state: this.state, changedIds: out.changedIds };
2615
2806
  }
@@ -2623,7 +2814,7 @@ var InMemoryWorkspaceProvider = class {
2623
2814
  };
2624
2815
 
2625
2816
  // src/providers/FileBackedWorkspaceProvider.ts
2626
- var import_core3 = require("@apicircle/core");
2817
+ var import_core5 = require("@apicircle/core");
2627
2818
  var import_file_backed = require("@apicircle/core/workspace/file-backed");
2628
2819
  var FileBackedWorkspaceProvider = class {
2629
2820
  constructor(dir) {
@@ -2640,7 +2831,7 @@ var FileBackedWorkspaceProvider = class {
2640
2831
  async apply(patch) {
2641
2832
  let captured = null;
2642
2833
  await (0, import_file_backed.withWorkspace)(this.dir, async (state) => {
2643
- const result = (0, import_core3.applyMutation)(state, patch);
2834
+ const result = (0, import_core5.applyMutation)(state, patch);
2644
2835
  captured = { state: result.next, changedIds: result.changedIds };
2645
2836
  return { next: result.next };
2646
2837
  });