synartesis 0.3.4 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/proxy.js CHANGED
@@ -19,12 +19,12 @@ import {
19
19
  runRead,
20
20
  toPayload,
21
21
  verifyAgainstServers
22
- } from "./chunk-LNR5GXPG.js";
22
+ } from "./chunk-FOA4UIDE.js";
23
23
  import {
24
24
  SnapshotError,
25
25
  UpstreamError,
26
26
  describe
27
- } from "./chunk-WNLRMSDB.js";
27
+ } from "./chunk-YVOO3PTV.js";
28
28
 
29
29
  // src/proxy/stdio.ts
30
30
  import { resolve } from "path";
@@ -356,6 +356,24 @@ async function drain(fetch) {
356
356
  } while (cursor !== void 0);
357
357
  return collected;
358
358
  }
359
+ function withoutDialect(schema, seen) {
360
+ if (typeof schema !== "object" || schema === null || Array.isArray(schema)) {
361
+ return schema;
362
+ }
363
+ const entries = Object.entries(schema);
364
+ const declared = entries.find(([key]) => key === "$schema")?.[1];
365
+ if (typeof declared !== "string" || declared.includes("2020-12")) {
366
+ return schema;
367
+ }
368
+ seen(declared);
369
+ return Object.fromEntries(entries.filter(([key]) => key !== "$schema"));
370
+ }
371
+ function compatible(tool, seen) {
372
+ if (tool["outputSchema"] === void 0) {
373
+ return tool;
374
+ }
375
+ return { ...tool, outputSchema: withoutDialect(tool["outputSchema"], seen) };
376
+ }
359
377
  function createProxyServer(options) {
360
378
  const { upstreams, manifest, journal } = options;
361
379
  const router = createRouter(upstreams, manifest);
@@ -515,7 +533,11 @@ function createProxyServer(options) {
515
533
  });
516
534
  for (const tool of items) {
517
535
  tools.push({
518
- ...tool,
536
+ ...compatible(tool, (dialect) => {
537
+ log?.warn(
538
+ `${upstream.name}.${tool.name} declares JSON Schema ${dialect}; the dialect was dropped so clients that only accept 2020-12 can call it`
539
+ );
540
+ }),
519
541
  name: router.expose(upstream.name, tool.name)
520
542
  });
521
543
  }
@@ -965,7 +987,7 @@ function parseArgv(argv) {
965
987
  const at = argv.indexOf(flag);
966
988
  return at === -1 ? void 0 : argv[at + 1];
967
989
  };
968
- const known = ["--manifest", "--journal", "--gate-timeout", "--log-level", "--http", "--http-host", "--http-idle", "--token"];
990
+ const known = ["--manifest", "--journal", "--server", "--gate-timeout", "--log-level", "--http", "--http-host", "--http-idle", "--token"];
969
991
  const unknown = argv.find((token) => token.startsWith("--") && !known.includes(token));
970
992
  if (unknown !== void 0) {
971
993
  throw new Error(`unknown flag ${unknown}; expected one of ${known.join(", ")}`);
@@ -999,10 +1021,15 @@ function parseArgv(argv) {
999
1021
  }
1000
1022
  http = { port, host: read("--http-host") ?? "127.0.0.1", token, idleSeconds };
1001
1023
  }
1024
+ const server = read("--server");
1025
+ if (argv.includes("--server") && (server === void 0 || server.startsWith("--"))) {
1026
+ throw new Error("--server needs the name of a server declared in the manifest");
1027
+ }
1002
1028
  const manifest = findManifest(read("--manifest"));
1003
1029
  return {
1004
1030
  manifest,
1005
1031
  journal: findJournal(read("--journal"), manifest),
1032
+ ...server === void 0 ? {} : { server },
1006
1033
  gateTimeoutMs: seconds === void 0 ? DEFAULT_GATE_TIMEOUT_MS : seconds * 1e3,
1007
1034
  gateTimeoutGiven: seconds !== void 0,
1008
1035
  ...http === void 0 ? {} : { http },
@@ -1022,8 +1049,15 @@ async function main() {
1022
1049
  }
1023
1050
  const manifest = loadManifest(argv.manifest);
1024
1051
  const journal = openJournal(argv.journal);
1052
+ const declared = Object.entries(manifest.servers);
1053
+ const wanted = argv.server === void 0 ? declared : declared.filter(([name]) => name === argv.server);
1054
+ if (wanted.length === 0) {
1055
+ throw new Error(
1056
+ `--server ${String(argv.server)} is not declared in ${argv.manifest}; it has: ${declared.map(([name]) => name).join(", ")}`
1057
+ );
1058
+ }
1025
1059
  const upstreams = [];
1026
- for (const [name, spec] of Object.entries(manifest.servers)) {
1060
+ for (const [name, spec] of wanted) {
1027
1061
  upstreams.push(
1028
1062
  await connectStdioUpstream({
1029
1063
  name,
@@ -1033,7 +1067,13 @@ async function main() {
1033
1067
  })
1034
1068
  );
1035
1069
  }
1036
- await verifyAgainstServers(upstreams, manifest);
1070
+ await verifyAgainstServers(
1071
+ upstreams,
1072
+ argv.server === void 0 ? manifest : {
1073
+ ...manifest,
1074
+ tools: manifest.tools.filter((rule) => rule.match.startsWith(`${String(argv.server)}.`))
1075
+ }
1076
+ );
1037
1077
  log.info(
1038
1078
  {
1039
1079
  manifest: argv.manifest,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "synartesis",
3
- "version": "0.3.4",
3
+ "version": "0.4.1",
4
4
  "description": "An undo layer for AI agents.",
5
5
  "type": "module",
6
6
  "private": false,