@paretools/shared 0.6.0 → 0.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/dist/index.d.ts CHANGED
@@ -4,5 +4,6 @@ export { stripAnsi } from "./ansi.js";
4
4
  export { assertNoFlagInjection, assertAllowedCommand } from "./validation.js";
5
5
  export { INPUT_LIMITS } from "./limits.js";
6
6
  export { sanitizeErrorOutput } from "./sanitize.js";
7
+ export { shouldRegisterTool } from "./tool-filter.js";
7
8
  export type { ToolOutput } from "./types.js";
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -4,4 +4,5 @@ export { stripAnsi } from "./ansi.js";
4
4
  export { assertNoFlagInjection, assertAllowedCommand } from "./validation.js";
5
5
  export { INPUT_LIMITS } from "./limits.js";
6
6
  export { sanitizeErrorOutput } from "./sanitize.js";
7
+ export { shouldRegisterTool } from "./tool-filter.js";
7
8
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,GAAG,EAAE,YAAY,EAAmC,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,GAAG,EAAE,YAAY,EAAmC,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC"}
package/dist/runner.d.ts CHANGED
@@ -3,6 +3,10 @@ export interface RunOptions {
3
3
  cwd?: string;
4
4
  timeout?: number;
5
5
  env?: Record<string, string>;
6
+ /** Data to write to the child process's stdin. Useful for piping content
7
+ * (e.g., `git commit --file -`) instead of passing it as a command arg,
8
+ * which avoids cmd.exe argument-length and newline limitations on Windows. */
9
+ stdin?: string;
6
10
  }
7
11
  /** Result of a command execution, containing the exit code and ANSI-stripped stdout/stderr. */
8
12
  export interface RunResult {
@@ -13,19 +17,21 @@ export interface RunResult {
13
17
  /**
14
18
  * Escapes a single argument for safe use with cmd.exe on Windows.
15
19
  *
16
- * When `shell: true` is used with `execFile` on Windows, Node.js wraps each
17
- * argument in double quotes. Inside double quotes cmd.exe still interprets:
18
- * - `%VAR%` for environment variable expansion
19
- * - `^` as the escape character itself
20
- * - `&`, `|`, `<`, `>` as pipeline / redirection operators
20
+ * When `shell: true` is used with `execFile` on Windows, Node.js joins the
21
+ * command and args with spaces to build a cmd.exe command line. It does NOT
22
+ * automatically quote individual arguments, so args containing spaces would
23
+ * be split into multiple tokens by cmd.exe.
21
24
  *
22
- * We neutralise these by:
23
- * 1. Replacing `%` with `%%` (disables env-var expansion inside quotes).
24
- * 2. Prefixing `^`, `&`, `|`, `<`, `>`, `!` with the cmd.exe escape char `^`.
25
- * (`!` must be escaped to prevent delayed expansion of `!VAR!`.)
25
+ * Strategy:
26
+ * - Args with spaces, tabs, or double quotes are wrapped in double quotes.
27
+ * Inside double quotes cmd.exe treats `&`, `|`, `<`, `>`, `^` as literal,
28
+ * so only `%` needs escaping (`%%`). Internal `"` chars are doubled (`""`).
29
+ * - Args without spaces are left unquoted, with cmd.exe metacharacters
30
+ * escaped via the caret (`^`) prefix.
31
+ * - `%` → `%%` is applied unconditionally (active in both quoted/unquoted).
26
32
  *
27
- * Parentheses `(` `)` are NOT escaped here because inside double-quoted
28
- * strings they are literal characters and do not affect grouping.
33
+ * Parentheses `(` `)` are NOT escaped because inside double-quoted strings
34
+ * they are literal, and outside quotes they rarely appear in tool args.
29
35
  */
30
36
  export declare function escapeCmdArg(arg: string): string;
31
37
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAIA,uGAAuG;AACvG,MAAM,WAAW,UAAU;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAED,+FAA+F;AAC/F,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAiBhD;AAED;;;;;;;;GAQG;AACH,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,CAkEtF"}
1
+ {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAIA,uGAAuG;AACvG,MAAM,WAAW,UAAU;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B;;mFAE+E;IAC/E,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,+FAA+F;AAC/F,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CA8BhD;AAED;;;;;;;;GAQG;AACH,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,CAyEtF"}
package/dist/runner.js CHANGED
@@ -4,32 +4,46 @@ import { sanitizeErrorOutput } from "./sanitize.js";
4
4
  /**
5
5
  * Escapes a single argument for safe use with cmd.exe on Windows.
6
6
  *
7
- * When `shell: true` is used with `execFile` on Windows, Node.js wraps each
8
- * argument in double quotes. Inside double quotes cmd.exe still interprets:
9
- * - `%VAR%` for environment variable expansion
10
- * - `^` as the escape character itself
11
- * - `&`, `|`, `<`, `>` as pipeline / redirection operators
7
+ * When `shell: true` is used with `execFile` on Windows, Node.js joins the
8
+ * command and args with spaces to build a cmd.exe command line. It does NOT
9
+ * automatically quote individual arguments, so args containing spaces would
10
+ * be split into multiple tokens by cmd.exe.
12
11
  *
13
- * We neutralise these by:
14
- * 1. Replacing `%` with `%%` (disables env-var expansion inside quotes).
15
- * 2. Prefixing `^`, `&`, `|`, `<`, `>`, `!` with the cmd.exe escape char `^`.
16
- * (`!` must be escaped to prevent delayed expansion of `!VAR!`.)
12
+ * Strategy:
13
+ * - Args with spaces, tabs, or double quotes are wrapped in double quotes.
14
+ * Inside double quotes cmd.exe treats `&`, `|`, `<`, `>`, `^` as literal,
15
+ * so only `%` needs escaping (`%%`). Internal `"` chars are doubled (`""`).
16
+ * - Args without spaces are left unquoted, with cmd.exe metacharacters
17
+ * escaped via the caret (`^`) prefix.
18
+ * - `%` → `%%` is applied unconditionally (active in both quoted/unquoted).
17
19
  *
18
- * Parentheses `(` `)` are NOT escaped here because inside double-quoted
19
- * strings they are literal characters and do not affect grouping.
20
+ * Parentheses `(` `)` are NOT escaped because inside double-quoted strings
21
+ * they are literal, and outside quotes they rarely appear in tool args.
20
22
  */
21
23
  export function escapeCmdArg(arg) {
22
- // Step 1: Escape % → %% to prevent %VAR% expansion
24
+ // Step 1: Escape % → %% to prevent %VAR% expansion (works quoted & unquoted)
23
25
  let escaped = arg.replace(/%/g, "%%");
24
- // Step 2: Caret-escape cmd.exe metacharacters that are dangerous
25
- // even inside double quotes. The caret itself must be escaped first
26
- // so that carets we insert are not themselves re-escaped.
26
+ // Step 2: If the arg contains spaces, tabs, or double quotes, wrap it in
27
+ // double quotes so cmd.exe keeps it as a single token.
28
+ if (/[ \t"]/.test(arg)) {
29
+ // Replace newlines with spaces — cmd.exe treats \n as a command-line
30
+ // terminator even inside double quotes, so literal newlines cannot be
31
+ // passed via command args. Tools that need newline-preserving input
32
+ // should use RunOptions.stdin instead (e.g., git commit --file -).
33
+ escaped = escaped.replace(/\r?\n/g, " ");
34
+ // Escape internal double quotes by doubling them
35
+ escaped = escaped.replace(/"/g, '""');
36
+ return `"${escaped}"`;
37
+ }
38
+ // Step 3: For unquoted args, caret-escape cmd.exe metacharacters.
39
+ // The caret itself must be escaped first so that carets we insert
40
+ // are not themselves re-escaped.
27
41
  escaped = escaped.replace(/\^/g, "^^");
28
42
  escaped = escaped.replace(/&/g, "^&");
29
43
  escaped = escaped.replace(/\|/g, "^|");
30
44
  escaped = escaped.replace(/</g, "^<");
31
45
  escaped = escaped.replace(/>/g, "^>");
32
- // Step 3: Escape ! to prevent delayed expansion (!VAR!)
46
+ // Step 4: Escape ! to prevent delayed expansion (!VAR!)
33
47
  escaped = escaped.replace(/!/g, "^!");
34
48
  return escaped;
35
49
  }
@@ -48,7 +62,7 @@ export function run(cmd, args, opts) {
48
62
  // environment variable expansion and command injection via special chars.
49
63
  // See escapeCmdArg() for details on what is escaped and why.
50
64
  const safeArgs = process.platform === "win32" ? args.map(escapeCmdArg) : args;
51
- execFile(cmd, safeArgs, {
65
+ const child = execFile(cmd, safeArgs, {
52
66
  cwd: opts?.cwd,
53
67
  timeout: opts?.timeout ?? 60_000,
54
68
  env: opts?.env ? { ...process.env, ...opts.env } : undefined,
@@ -85,6 +99,12 @@ export function run(cmd, args, opts) {
85
99
  stderr: sanitizeErrorOutput(stripAnsi(stderr)),
86
100
  });
87
101
  });
102
+ // Pipe stdin data if provided, then close the stream so the child
103
+ // process knows input is complete (e.g., `git commit --file -`).
104
+ if (opts?.stdin != null) {
105
+ child.stdin?.write(opts.stdin);
106
+ child.stdin?.end();
107
+ }
88
108
  });
89
109
  }
90
110
  //# sourceMappingURL=runner.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"runner.js","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAgBpD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW;IACtC,mDAAmD;IACnD,IAAI,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAEtC,iEAAiE;IACjE,oEAAoE;IACpE,0DAA0D;IAC1D,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACvC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACtC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACvC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACtC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAEtC,wDAAwD;IACxD,OA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K,CAAC,MAAM,IAAI,CAClG,CACF,CAAC;oBACF,OAAO;gBACT,CAAC;gBAED,4DAA4D;gBAC5D,MAAM,WAAW,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;gBACtC,IAAI,WAAW,CAAC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAAC;oBAC9C,MAAM,CACJ,IAAI,KAAK,CACP,uBAAuB,GAAG,uDAAuD,CAClF,CACF,CAAC;oBACF,OAAO;gBACT,CAAC;YACH,CAAC;YAED,OAAO,CAAC;gBACN,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACvE,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC;gBACzB,MAAM,EAAE,mBAAmB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;aAC/C,CAAC,CAAC;QACL,CAAC,CACF,CAAC;QAEF,kEAAkE;QAClE,iEAAiE;QACjE,IAAI,IAAI,EAAE,KAAK,IAAI,IAAI,EAAE,CAAC;YACxB,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC/B,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC;QACrB,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Granular tool selection — allows users to enable/disable individual tools
3
+ * via environment variables.
4
+ *
5
+ * Environment variable precedence:
6
+ * 1. `PARE_TOOLS` — universal filter across all servers.
7
+ * Format: comma-separated `server:tool` pairs.
8
+ * Example: `PARE_TOOLS=git:status,git:log,npm:install`
9
+ *
10
+ * 2. `PARE_{SERVER}_TOOLS` — per-server filter.
11
+ * Format: comma-separated tool names.
12
+ * Example: `PARE_GIT_TOOLS=status,log`
13
+ *
14
+ * 3. No env vars → all tools enabled (default).
15
+ *
16
+ * Universal (`PARE_TOOLS`) takes precedence over per-server env vars.
17
+ */
18
+ /**
19
+ * Determines whether a tool should be registered based on environment variables.
20
+ *
21
+ * @param serverName - The server identifier (e.g., "git", "npm", "docker").
22
+ * @param toolName - The tool name (e.g., "status", "log", "install").
23
+ * @returns `true` if the tool should be registered, `false` if filtered out.
24
+ */
25
+ export declare function shouldRegisterTool(serverName: string, toolName: string): boolean;
26
+ //# sourceMappingURL=tool-filter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-filter.d.ts","sourceRoot":"","sources":["../src/tool-filter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAiBhF"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Granular tool selection — allows users to enable/disable individual tools
3
+ * via environment variables.
4
+ *
5
+ * Environment variable precedence:
6
+ * 1. `PARE_TOOLS` — universal filter across all servers.
7
+ * Format: comma-separated `server:tool` pairs.
8
+ * Example: `PARE_TOOLS=git:status,git:log,npm:install`
9
+ *
10
+ * 2. `PARE_{SERVER}_TOOLS` — per-server filter.
11
+ * Format: comma-separated tool names.
12
+ * Example: `PARE_GIT_TOOLS=status,log`
13
+ *
14
+ * 3. No env vars → all tools enabled (default).
15
+ *
16
+ * Universal (`PARE_TOOLS`) takes precedence over per-server env vars.
17
+ */
18
+ /**
19
+ * Determines whether a tool should be registered based on environment variables.
20
+ *
21
+ * @param serverName - The server identifier (e.g., "git", "npm", "docker").
22
+ * @param toolName - The tool name (e.g., "status", "log", "install").
23
+ * @returns `true` if the tool should be registered, `false` if filtered out.
24
+ */
25
+ export function shouldRegisterTool(serverName, toolName) {
26
+ const universal = process.env.PARE_TOOLS;
27
+ if (universal !== undefined) {
28
+ if (universal.trim() === "")
29
+ return false;
30
+ const allowed = universal.split(",").map((s) => s.trim());
31
+ return allowed.includes(`${serverName}:${toolName}`);
32
+ }
33
+ const envKey = `PARE_${serverName.toUpperCase().replace(/-/g, "_")}_TOOLS`;
34
+ const perServer = process.env[envKey];
35
+ if (perServer !== undefined) {
36
+ if (perServer.trim() === "")
37
+ return false;
38
+ const allowed = perServer.split(",").map((s) => s.trim());
39
+ return allowed.includes(toolName);
40
+ }
41
+ return true;
42
+ }
43
+ //# sourceMappingURL=tool-filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-filter.js","sourceRoot":"","sources":["../src/tool-filter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,UAAkB,EAAE,QAAgB;IACrE,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;IACzC,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC5B,IAAI,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE;YAAE,OAAO,KAAK,CAAC;QAC1C,MAAM,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QAC1D,OAAO,OAAO,CAAC,QAAQ,CAAC,GAAG,UAAU,IAAI,QAAQ,EAAE,CAAC,CAAC;IACvD,CAAC;IAED,MAAM,MAAM,GAAG,QAAQ,UAAU,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,QAAQ,CAAC;IAC3E,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACtC,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC5B,IAAI,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE;YAAE,OAAO,KAAK,CAAC;QAC1C,MAAM,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QAC1D,OAAO,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACpC,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paretools/shared",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Shared utilities for Pare MCP servers",
5
5
  "license": "MIT",
6
6
  "keywords": [