@swifty.js/swifty 0.0.33 → 0.0.35

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.
Files changed (71) hide show
  1. package/dist/acp-A4KRKOHD.js +14 -0
  2. package/dist/agent-VDWIGFIV.js +4 -0
  3. package/dist/{anthropic-FXRRA63E.js → anthropic-AR2Y4FBR.js} +1 -1
  4. package/dist/bwrap-4KOC7P3X.js +4 -0
  5. package/dist/{chunk-IKQTIDRL.js → chunk-325L2ILZ.js} +1 -1
  6. package/dist/chunk-44LPRRYU.js +60 -0
  7. package/dist/chunk-4B4SGVJH.js +164 -0
  8. package/dist/chunk-5W2TCASL.js +4 -0
  9. package/dist/{chunk-FUKVR3XO.js → chunk-F4FOFPKL.js} +126 -123
  10. package/dist/{chunk-4PQYUHSN.js → chunk-H56UQALW.js} +1 -1
  11. package/dist/{providers-WNYZUMZ3.js → chunk-IOLGXPUQ.js} +3 -3
  12. package/dist/chunk-IXCJZNBB.js +5 -0
  13. package/dist/chunk-JC44NVST.js +4 -0
  14. package/dist/chunk-NDPYUGE5.js +5 -0
  15. package/dist/chunk-PH643I2P.js +4 -0
  16. package/dist/{chunk-PXQD6GWP.js → chunk-TOM34LJB.js} +7 -7
  17. package/dist/{chunk-4C3KJLJV.js → chunk-UJGMTIYO.js} +1 -1
  18. package/dist/chunk-YBS5ATGZ.js +4 -0
  19. package/dist/esm-VBV56AO5.js +229 -0
  20. package/dist/lib/agent-TC4HSVMS.js +16 -0
  21. package/dist/lib/{anthropic-B33M2AVN.js → anthropic-FKIGL7NL.js} +6 -5
  22. package/dist/lib/bwrap-2OL7VPSO.js +7 -0
  23. package/dist/lib/{chunk-FODSMOWP.js → chunk-6V7RW6HA.js} +34 -16
  24. package/dist/lib/{chunk-TJLAJGG4.js → chunk-ALQHMYOZ.js} +14 -3
  25. package/dist/lib/{chunk-XT67KGWE.js → chunk-BQFVUVLI.js} +12 -2
  26. package/dist/lib/chunk-FFM2LB4C.js +132 -0
  27. package/dist/lib/{chunk-VUD72RTY.js → chunk-FLKB4BK7.js} +16 -5
  28. package/dist/lib/{chunk-3OFLDUAW.js → chunk-HQSYRTER.js} +96 -49
  29. package/dist/lib/{chunk-LDWFI6MR.js → chunk-LRN4MOQ3.js} +25 -1
  30. package/dist/lib/chunk-MLKGABMK.js +9 -0
  31. package/dist/lib/{providers-UJEWP7C7.js → chunk-OJTISIYU.js} +46 -3
  32. package/dist/lib/{chunk-BCBD34D2.js → chunk-OLFXCZVH.js} +25 -7
  33. package/dist/lib/{chunk-CFYAZWDA.js → chunk-RUDYC7OS.js} +33 -55
  34. package/dist/lib/{chunk-AFYPVA5C.js → chunk-S5VWPTME.js} +940 -109
  35. package/dist/lib/chunk-YIWNQ7OA.js +47 -0
  36. package/dist/lib/{chunk-3XCGUKGJ.js → chunk-ZPIF7IJN.js} +219 -6
  37. package/dist/lib/index.d.ts +3427 -1380
  38. package/dist/lib/index.js +12767 -12281
  39. package/dist/lib/{openai-C2PZFGJ2.js → openai-ZWIYIBLC.js} +4 -3
  40. package/dist/lib/{checker-UPY4CXUL.js → permissions-BW4QPZXV.js} +4 -3
  41. package/dist/lib/providers-ROWSB6ND.js +9 -0
  42. package/dist/lib/sandbox-runtime-CCQ3X3SM.js +9 -0
  43. package/dist/lib/seatbelt-WO7YWKLR.js +7 -0
  44. package/dist/lib/{tool-filter-BFEINZIA.js → tool-filter-QU4LOZII.js} +2 -1
  45. package/dist/main.js +227 -194
  46. package/dist/{openai-WPEICAZ4.js → openai-7LMX5HKW.js} +1 -1
  47. package/dist/permissions-74IHQW76.js +4 -0
  48. package/dist/providers-2J4JJYQD.js +4 -0
  49. package/dist/sandbox-runtime-RVW4BK3L.js +4 -0
  50. package/dist/seatbelt-GMQUP6SV.js +4 -0
  51. package/dist/server-ZYK4L22D.js +4 -0
  52. package/dist/{tool-filter-X6IYME2K.js → tool-filter-U5SSL3LR.js} +1 -1
  53. package/package.json +6 -3
  54. package/dist/acp-5WRTN2LL.js +0 -14
  55. package/dist/agent-3CAPJCPD.js +0 -4
  56. package/dist/bwrap-ZTS67W2K.js +0 -4
  57. package/dist/checker-3O7QF7XV.js +0 -4
  58. package/dist/chunk-4HSQBZBI.js +0 -4
  59. package/dist/chunk-C5WLP3DH.js +0 -5
  60. package/dist/chunk-I7XJSLRI.js +0 -4
  61. package/dist/chunk-LHSUYZO5.js +0 -4
  62. package/dist/chunk-NAAAN2TD.js +0 -60
  63. package/dist/chunk-YIKI3EPG.js +0 -150
  64. package/dist/esm-4DBD7ONK.js +0 -229
  65. package/dist/lib/agent-NNYCUIOF.js +0 -10
  66. package/dist/lib/bwrap-QRGPUP4J.js +0 -6
  67. package/dist/lib/chunk-GTHYQZRL.js +0 -31
  68. package/dist/lib/chunk-ORSYNBMM.js +0 -38
  69. package/dist/lib/seatbelt-FT5IY73W.js +0 -6
  70. package/dist/seatbelt-PSPJ5LBR.js +0 -5
  71. package/dist/server-YPBLBRDN.js +0 -4
@@ -3,9 +3,30 @@ import {
3
3
  asRecord,
4
4
  createChildLogger,
5
5
  strArg
6
- } from "./chunk-3XCGUKGJ.js";
6
+ } from "./chunk-ZPIF7IJN.js";
7
+ import {
8
+ __export
9
+ } from "./chunk-MLKGABMK.js";
10
+
11
+ // src/tools/mcp-call.ts
12
+ var mcp_call_exports = {};
13
+ __export(mcp_call_exports, {
14
+ McpCallTool: () => McpCallTool,
15
+ coerceBySchema: () => coerceBySchema,
16
+ isMcpToolLike: () => isMcpToolLike,
17
+ mcpCallPermissionContent: () => mcpCallPermissionContent
18
+ });
7
19
 
8
20
  // src/mcp/tool-wrapper.ts
21
+ var tool_wrapper_exports = {};
22
+ __export(tool_wrapper_exports, {
23
+ MCPToolWrapper: () => MCPToolWrapper,
24
+ MCP_NAME_SEP: () => MCP_NAME_SEP,
25
+ MCP_TOOL_PREFIX: () => MCP_TOOL_PREFIX,
26
+ buildMcpToolName: () => buildMcpToolName,
27
+ mcpToolNamePrefix: () => mcpToolNamePrefix,
28
+ sanitizeSegment: () => sanitizeSegment
29
+ });
9
30
  var log = createChildLogger({ module: "mcp" });
10
31
  var MCP_TOOL_PREFIX = "mcp__";
11
32
  var MCP_NAME_SEP = "__";
@@ -225,13 +246,10 @@ var McpCallTool = class {
225
246
 
226
247
  export {
227
248
  MCP_TOOL_PREFIX,
228
- MCP_NAME_SEP,
229
- sanitizeSegment,
230
- mcpToolNamePrefix,
231
- buildMcpToolName,
232
249
  MCPToolWrapper,
233
- coerceBySchema,
250
+ tool_wrapper_exports,
234
251
  mcpCallPermissionContent,
235
252
  isMcpToolLike,
236
- McpCallTool
253
+ McpCallTool,
254
+ mcp_call_exports
237
255
  };
@@ -1,52 +1,32 @@
1
1
  import {
2
2
  mcpCallPermissionContent
3
- } from "./chunk-BCBD34D2.js";
3
+ } from "./chunk-OLFXCZVH.js";
4
4
  import {
5
+ canonicalPath,
5
6
  createChildLogger,
7
+ isPathWithin,
6
8
  isRecord,
7
9
  strArg
8
- } from "./chunk-3XCGUKGJ.js";
10
+ } from "./chunk-ZPIF7IJN.js";
11
+ import {
12
+ __export
13
+ } from "./chunk-MLKGABMK.js";
9
14
 
10
- // src/permissions/checker.ts
15
+ // src/permissions/index.ts
16
+ var permissions_exports = {};
17
+ __export(permissions_exports, {
18
+ PathSandbox: () => PathSandbox,
19
+ PermissionChecker: () => PermissionChecker,
20
+ RuleEngine: () => RuleEngine,
21
+ evaluateRules: () => evaluateRules,
22
+ extractContent: () => extractContent,
23
+ isSafeCommand: () => isSafeCommand
24
+ });
11
25
  import { readFileSync, writeFileSync, mkdirSync, statSync } from "fs";
12
- import { homedir as homedir2, tmpdir } from "os";
13
- import { join as join2, resolve as resolve2, dirname as dirname2 } from "path";
26
+ import { homedir, tmpdir } from "os";
27
+ import { join, resolve, dirname } from "path";
14
28
  import yaml from "js-yaml";
15
29
  import z, { parse } from "zod";
16
-
17
- // src/utils/paths.ts
18
- import { realpathSync } from "fs";
19
- import { homedir } from "os";
20
- import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "path";
21
- function canonicalPath(path) {
22
- let current = resolve(path);
23
- const missing = [];
24
- for (; ; ) {
25
- try {
26
- return join(realpathSync(current), ...missing);
27
- } catch (error) {
28
- if (!(error instanceof Error) || !("code" in error) || error.code !== "ENOENT" && error.code !== "ENOTDIR") {
29
- throw error;
30
- }
31
- const parent = dirname(current);
32
- if (parent === current) {
33
- return resolve(path);
34
- }
35
- missing.unshift(basename(current));
36
- current = parent;
37
- }
38
- }
39
- }
40
- function isPathWithin(root, path) {
41
- const child = relative(root, path);
42
- return child === "" || child !== ".." && !child.startsWith(`..${sep}`) && !isAbsolute(child);
43
- }
44
- function compactPath(path) {
45
- const home = homedir();
46
- return path === home ? "~" : path.startsWith(`${home}/`) ? `~/${path.slice(home.length + 1)}` : path;
47
- }
48
-
49
- // src/permissions/checker.ts
50
30
  var log = createChildLogger({ module: "permissions" });
51
31
  var DANGEROUS_PATTERNS = [];
52
32
  var SAFE_PREFIXES = [
@@ -267,23 +247,23 @@ var PathSandbox = class {
267
247
  denyWritePaths;
268
248
  projectDir;
269
249
  constructor(projectDir) {
270
- this.projectDir = resolve2(projectDir);
250
+ this.projectDir = resolve(projectDir);
271
251
  this.allowedRoots = [this.projectDir, tmpdir()];
272
- this.denyWritePaths = DEFAULT_DENY_WRITE.map((p) => join2(this.projectDir, p));
252
+ this.denyWritePaths = DEFAULT_DENY_WRITE.map((p) => join(this.projectDir, p));
273
253
  }
274
254
  addRoot(root) {
275
- this.allowedRoots.push(resolve2(root));
255
+ this.allowedRoots.push(resolve(root));
276
256
  }
277
257
  // Add custom deny-write paths
278
258
  addDenyWrite(path) {
279
- this.denyWritePaths.push(resolve2(path));
259
+ this.denyWritePaths.push(resolve(path));
280
260
  }
281
261
  /**
282
262
  * Check whether a path is in the deny-write list.
283
263
  * denyWrite has the highest priority — even if the path is within an allowed root, writes are still denied.
284
264
  */
285
265
  checkDenyWrite(filePath) {
286
- const absolute = resolve2(this.projectDir, filePath);
266
+ const absolute = resolve(this.projectDir, filePath);
287
267
  const canonical = canonicalPath(absolute);
288
268
  for (const denied of this.denyWritePaths) {
289
269
  if (isPathWithin(denied, absolute) || isPathWithin(canonicalPath(denied), canonical)) {
@@ -296,7 +276,7 @@ var PathSandbox = class {
296
276
  return null;
297
277
  }
298
278
  check(filePath) {
299
- const absolute = canonicalPath(resolve2(this.projectDir, filePath));
279
+ const absolute = canonicalPath(resolve(this.projectDir, filePath));
300
280
  for (const root of this.allowedRoots) {
301
281
  if (isPathWithin(canonicalPath(root), absolute)) {
302
282
  return null;
@@ -378,8 +358,8 @@ var RuleEngine = class {
378
358
  projectPath;
379
359
  cache = /* @__PURE__ */ new Map();
380
360
  constructor(workDir) {
381
- this.userPath = join2(homedir2(), ".swifty", "permissions.yaml");
382
- this.projectPath = join2(workDir, ".swifty", "permissions.yaml");
361
+ this.userPath = join(homedir(), ".swifty", "permissions.yaml");
362
+ this.projectPath = join(workDir, ".swifty", "permissions.yaml");
383
363
  }
384
364
  // Read a single rules file; skips disk I/O and parsing on cache hit.
385
365
  rulesFor(path) {
@@ -416,7 +396,7 @@ var RuleEngine = class {
416
396
  // Persists a rule to the project-level YAML file in the `Tool(pattern)`
417
397
  // format so "allow always" survives a restart.
418
398
  appendProjectRule(rule) {
419
- mkdirSync(dirname2(this.projectPath), { recursive: true });
399
+ mkdirSync(dirname(this.projectPath), { recursive: true });
420
400
  const rules = loadRulesFile(this.projectPath);
421
401
  const exists = rules.some(
422
402
  (r) => r.tool === rule.tool && r.pattern === rule.pattern && r.effect === rule.effect
@@ -501,7 +481,7 @@ var PermissionChecker = class _PermissionChecker {
501
481
  }
502
482
  if (this.mode === "plan" && (toolName === "WriteFile" || toolName === "EditFile")) {
503
483
  const path = strArg(args, "file_path", "");
504
- if (this.planFilePath && canonicalPath(resolve2(this.workDir, path)) === canonicalPath(resolve2(this.workDir, this.planFilePath)) && !this.sandbox.checkDenyWrite(path)) {
484
+ if (this.planFilePath && canonicalPath(resolve(this.workDir, path)) === canonicalPath(resolve(this.workDir, this.planFilePath)) && !this.sandbox.checkDenyWrite(path)) {
505
485
  return {
506
486
  effect: "allow",
507
487
  reason: "Plan file write allowed in plan mode"
@@ -584,13 +564,13 @@ var PermissionChecker = class _PermissionChecker {
584
564
  const isFilePath = toolName === "ReadFile" || toolName === "WriteFile" || toolName === "EditFile";
585
565
  let pattern;
586
566
  if (isFilePath && content) {
587
- const abs = resolve2(this.workDir, content);
567
+ const abs = resolve(this.workDir, content);
588
568
  let isDir = false;
589
569
  try {
590
570
  isDir = statSync(abs).isDirectory();
591
571
  } catch {
592
572
  }
593
- pattern = join2(isDir ? abs : dirname2(abs), "*");
573
+ pattern = join(isDir ? abs : dirname(abs), "*");
594
574
  } else {
595
575
  const words = content.trim().split(/\s+/).slice(0, 2);
596
576
  pattern = words.join(" ") + "*";
@@ -624,13 +604,11 @@ var PermissionChecker = class _PermissionChecker {
624
604
  };
625
605
 
626
606
  export {
627
- canonicalPath,
628
- isPathWithin,
629
- compactPath,
630
607
  extractContent,
631
608
  PathSandbox,
632
609
  evaluateRules,
633
610
  RuleEngine,
634
611
  isSafeCommand,
635
- PermissionChecker
612
+ PermissionChecker,
613
+ permissions_exports
636
614
  };