@morphllm/morphsdk 0.2.202 → 0.2.204

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 (246) hide show
  1. package/README.md +101 -0
  2. package/dist/chunk-2GMG5XKU.js +100 -0
  3. package/dist/chunk-2PPYWRMZ.js +3 -4
  4. package/dist/chunk-3HAHJYZQ.cjs +74 -0
  5. package/dist/{chunk-2XU3XXUE.js → chunk-3JROKKS4.js} +3 -25
  6. package/dist/{chunk-26K5EJD3.js → chunk-43JBUEIX.js} +4 -18
  7. package/dist/chunk-44OIEPIO.js +4 -23
  8. package/dist/chunk-4EQQGUZ7.cjs +104 -0
  9. package/dist/chunk-4OUGA3KS.js +1 -5
  10. package/dist/{chunk-VQDDL3UH.js → chunk-4TZBUFVP.js} +2 -8
  11. package/dist/{chunk-YAM6P5OQ.js → chunk-564XJOQP.js} +2 -6
  12. package/dist/chunk-5H3FKFOI.cjs +77 -0
  13. package/dist/chunk-5TTZQF4X.cjs +110 -0
  14. package/dist/chunk-6HAYJA6M.cjs +317 -0
  15. package/dist/chunk-6TZCVTW5.js +3 -4
  16. package/dist/chunk-6WP7EA4F.js +2 -4
  17. package/dist/chunk-74A4HLIO.cjs +42 -0
  18. package/dist/chunk-75ZPJI57.cjs +9 -0
  19. package/dist/chunk-7PJYY46L.cjs +2 -0
  20. package/dist/chunk-AWFZKS27.cjs +11 -0
  21. package/dist/chunk-BJBWWIZV.cjs +2 -0
  22. package/dist/chunk-DLYDIYDK.cjs +305 -0
  23. package/dist/{chunk-65TUD7JV.js → chunk-DYCMPDPV.js} +13 -29
  24. package/dist/{chunk-3CPI6ZIC.js → chunk-DZP7BR66.js} +22 -43
  25. package/dist/chunk-E63OPKP7.js +96 -0
  26. package/dist/chunk-E6V75LI6.cjs +334 -0
  27. package/dist/{chunk-XPHNS7NW.js → chunk-EJ6ID24K.js} +3 -12
  28. package/dist/chunk-EJTL2BOZ.cjs +42 -0
  29. package/dist/chunk-ETBRAKVV.js +1 -5
  30. package/dist/chunk-F633IVQA.cjs +91 -0
  31. package/dist/chunk-FBOZIVVQ.js +1 -0
  32. package/dist/{chunk-UKXCGQPS.js → chunk-FGA6EYC2.js} +35 -37
  33. package/dist/{chunk-CAWQEHKP.js → chunk-G4RODMXA.js} +4 -19
  34. package/dist/chunk-GUNGJC6X.cjs +256 -0
  35. package/dist/chunk-GYE3FY6Z.js +8 -0
  36. package/dist/chunk-HDP4QAZL.js +1 -4
  37. package/dist/chunk-HNMEBYIS.cjs +86 -0
  38. package/dist/chunk-HP3PCOTW.cjs +81 -0
  39. package/dist/{chunk-ICCGLO6V.js → chunk-IGXNLXPN.js} +12 -17
  40. package/dist/chunk-IPJA3ZS6.cjs +10 -0
  41. package/dist/chunk-JHC2R3HU.cjs +317 -0
  42. package/dist/{chunk-IBRBSDLT.js → chunk-JVMIFGZY.js} +5 -8
  43. package/dist/chunk-KF6S3EPJ.cjs +100 -0
  44. package/dist/chunk-KVGZ2TSG.cjs +274 -0
  45. package/dist/{chunk-6OYJC4TZ.js → chunk-L5SCKZVK.js} +13 -22
  46. package/dist/chunk-LDM7RNNN.js +1 -0
  47. package/dist/{chunk-UAZKHSEU.js → chunk-LQST3NW2.js} +5 -15
  48. package/dist/chunk-M34E2AMK.js +1 -5
  49. package/dist/chunk-MF56KEI4.js +1 -4
  50. package/dist/chunk-MLKGABMK.js +1 -3
  51. package/dist/chunk-MLPZKUCO.js +4 -5
  52. package/dist/chunk-MMX5PUGC.cjs +242 -0
  53. package/dist/chunk-MWXJ6DZ2.cjs +21 -0
  54. package/dist/chunk-NJWOWXUR.cjs +137 -0
  55. package/dist/chunk-NNKBKENK.cjs +15 -0
  56. package/dist/chunk-NRG6QX3L.js +1 -3
  57. package/dist/chunk-OCKEEEYE.cjs +433 -0
  58. package/dist/chunk-OENJO7YW.js +306 -0
  59. package/dist/chunk-OKLAYEBC.cjs +2 -0
  60. package/dist/chunk-OPDWMD4Q.js +1 -3
  61. package/dist/{chunk-D6YJ5X3C.js → chunk-OX5GN2KB.js} +26 -14
  62. package/dist/{chunk-JEVLCA5C.js → chunk-OYBOP47A.js} +18 -19
  63. package/dist/chunk-OZHCHPIE.js +1 -0
  64. package/dist/chunk-PA3UTI4A.js +1 -4
  65. package/dist/chunk-QEEAIXL5.cjs +74 -0
  66. package/dist/chunk-QT5LGZG3.cjs +10 -0
  67. package/dist/chunk-R3TUE7O2.cjs +107 -0
  68. package/dist/chunk-RYVW7RUM.js +2 -6
  69. package/dist/{chunk-LVKKICOB.js → chunk-SOQYE5A4.js} +36 -69
  70. package/dist/chunk-ST2OXLT5.cjs +91 -0
  71. package/dist/{chunk-SIFDK4AA.js → chunk-TH4MG73B.js} +3 -24
  72. package/dist/{chunk-OSL4CNSO.js → chunk-TLMAMVAW.js} +7 -23
  73. package/dist/chunk-TPZHMD7J.cjs +72 -0
  74. package/dist/{chunk-PDSIWL7I.js → chunk-U4PYAGNR.js} +6 -19
  75. package/dist/chunk-UAPK3AIJ.js +1 -10
  76. package/dist/chunk-UF5IKELS.cjs +26 -0
  77. package/dist/chunk-UHFVWYSP.cjs +408 -0
  78. package/dist/chunk-UKBSXYKE.cjs +280 -0
  79. package/dist/chunk-UNX7V6P6.cjs +60 -0
  80. package/dist/chunk-UZMMJ47A.cjs +107 -0
  81. package/dist/chunk-VHD7CW5O.cjs +43 -0
  82. package/dist/chunk-VL4QNALG.cjs +50 -0
  83. package/dist/chunk-VYE7O4FM.cjs +51 -0
  84. package/dist/chunk-WIYVT4UO.cjs +173 -0
  85. package/dist/chunk-WJHHO24M.cjs +91 -0
  86. package/dist/chunk-WR7LSUIR.cjs +213 -0
  87. package/dist/chunk-XE6D4J63.cjs +72 -0
  88. package/dist/chunk-YAUXTFIN.cjs +21 -0
  89. package/dist/{chunk-NFPRKZQ5.js → chunk-YJUCGZNN.js} +5 -22
  90. package/dist/chunk-ZSHVXDA2.js +4 -10
  91. package/dist/chunk-ZX6T3LNG.js +302 -0
  92. package/dist/{client-BWhi-vSj.d.ts → client-DSXbcxII.d.ts} +10 -1
  93. package/dist/client.cjs +44 -4360
  94. package/dist/client.d.ts +4 -2
  95. package/dist/client.js +36 -37
  96. package/dist/core/client.cjs +14 -476
  97. package/dist/core/client.d.ts +8 -0
  98. package/dist/core/client.js +10 -11
  99. package/dist/core/error.cjs +8 -251
  100. package/dist/core/error.js +4 -9
  101. package/dist/core/index.cjs +27 -491
  102. package/dist/core/index.d.ts +2 -0
  103. package/dist/core/index.js +12 -19
  104. package/dist/core/resource.cjs +9 -33
  105. package/dist/core/resource.d.ts +2 -0
  106. package/dist/core/resource.js +2 -7
  107. package/dist/edge.cjs +74 -1111
  108. package/dist/edge.d.ts +3 -0
  109. package/dist/edge.js +14 -42
  110. package/dist/guard-CvW03v4u.d.ts +59 -0
  111. package/dist/index.cjs +140 -4431
  112. package/dist/index.d.ts +6 -2
  113. package/dist/index.js +44 -87
  114. package/dist/modelrouter/core.cjs +35 -651
  115. package/dist/modelrouter/core.d.ts +2 -0
  116. package/dist/modelrouter/core.js +12 -21
  117. package/dist/modelrouter/index.cjs +35 -651
  118. package/dist/modelrouter/index.d.ts +2 -0
  119. package/dist/modelrouter/index.js +12 -21
  120. package/dist/modelrouter/types.cjs +1 -17
  121. package/dist/modelrouter/types.d.ts +5 -0
  122. package/dist/modelrouter/types.js +1 -0
  123. package/dist/subagents/anthropic.cjs +31 -2784
  124. package/dist/subagents/anthropic.d.ts +3 -1
  125. package/dist/subagents/anthropic.js +23 -24
  126. package/dist/subagents/index.cjs +14 -95
  127. package/dist/subagents/index.d.ts +3 -1
  128. package/dist/subagents/index.js +2 -11
  129. package/dist/subagents/prompts.cjs +14 -93
  130. package/dist/subagents/prompts.d.ts +3 -1
  131. package/dist/subagents/prompts.js +2 -11
  132. package/dist/subagents/types.cjs +1 -17
  133. package/dist/subagents/types.d.ts +3 -1
  134. package/dist/subagents/types.js +1 -0
  135. package/dist/subagents/vercel.cjs +31 -2761
  136. package/dist/subagents/vercel.d.ts +3 -1
  137. package/dist/subagents/vercel.js +23 -24
  138. package/dist/tools/compact/core.cjs +20 -552
  139. package/dist/tools/compact/core.d.ts +2 -0
  140. package/dist/tools/compact/core.js +12 -13
  141. package/dist/tools/compact/index.cjs +24 -598
  142. package/dist/tools/compact/index.d.ts +3 -1
  143. package/dist/tools/compact/index.js +13 -17
  144. package/dist/tools/compact/types.cjs +1 -17
  145. package/dist/tools/compact/types.d.ts +4 -4
  146. package/dist/tools/compact/types.js +1 -0
  147. package/dist/tools/fastapply/anthropic.cjs +39 -899
  148. package/dist/tools/fastapply/anthropic.d.ts +2 -0
  149. package/dist/tools/fastapply/anthropic.js +15 -24
  150. package/dist/tools/fastapply/apply.cjs +32 -672
  151. package/dist/tools/fastapply/apply.d.ts +2 -0
  152. package/dist/tools/fastapply/apply.js +8 -19
  153. package/dist/tools/fastapply/core.cjs +49 -1069
  154. package/dist/tools/fastapply/core.d.ts +3 -0
  155. package/dist/tools/fastapply/core.js +13 -29
  156. package/dist/tools/fastapply/index.cjs +56 -1052
  157. package/dist/tools/fastapply/index.d.ts +2 -0
  158. package/dist/tools/fastapply/index.js +18 -44
  159. package/dist/tools/fastapply/openai.cjs +45 -910
  160. package/dist/tools/fastapply/openai.d.ts +2 -0
  161. package/dist/tools/fastapply/openai.js +15 -26
  162. package/dist/tools/fastapply/prompts.cjs +10 -62
  163. package/dist/tools/fastapply/prompts.js +2 -9
  164. package/dist/tools/fastapply/types.cjs +1 -17
  165. package/dist/tools/fastapply/types.d.ts +9 -4
  166. package/dist/tools/fastapply/types.js +1 -0
  167. package/dist/tools/fastapply/vercel.cjs +37 -905
  168. package/dist/tools/fastapply/vercel.d.ts +2 -0
  169. package/dist/tools/fastapply/vercel.js +15 -22
  170. package/dist/tools/index.cjs +56 -1052
  171. package/dist/tools/index.d.ts +2 -0
  172. package/dist/tools/index.js +18 -44
  173. package/dist/tools/pii/index.cjs +47 -0
  174. package/dist/tools/pii/index.d.ts +4 -0
  175. package/dist/tools/pii/index.js +6 -0
  176. package/dist/tools/pii/model.cjs +45 -0
  177. package/dist/tools/pii/model.d.ts +83 -0
  178. package/dist/tools/pii/model.js +4 -0
  179. package/dist/tools/pii/patterns.cjs +15 -0
  180. package/dist/tools/pii/patterns.d.ts +31 -0
  181. package/dist/tools/pii/patterns.js +2 -0
  182. package/dist/tools/pii/regex.cjs +32 -0
  183. package/dist/tools/pii/regex.d.ts +48 -0
  184. package/dist/tools/pii/regex.js +3 -0
  185. package/dist/tools/pii/types.cjs +2 -0
  186. package/dist/tools/pii/types.d.ts +108 -0
  187. package/dist/tools/pii/types.js +1 -0
  188. package/dist/tools/utils/resilience.cjs +15 -312
  189. package/dist/tools/utils/resilience.js +3 -12
  190. package/dist/tools/warp_grep/agent/config.cjs +16 -127
  191. package/dist/tools/warp_grep/agent/config.js +2 -11
  192. package/dist/tools/warp_grep/agent/formatter.cjs +12 -48
  193. package/dist/tools/warp_grep/agent/formatter.js +2 -9
  194. package/dist/tools/warp_grep/agent/parser.cjs +16 -83
  195. package/dist/tools/warp_grep/agent/parser.d.ts +2 -0
  196. package/dist/tools/warp_grep/agent/parser.js +2 -11
  197. package/dist/tools/warp_grep/agent/runner.cjs +19 -1081
  198. package/dist/tools/warp_grep/agent/runner.d.ts +2 -0
  199. package/dist/tools/warp_grep/agent/runner.js +11 -14
  200. package/dist/tools/warp_grep/agent/types.cjs +1 -17
  201. package/dist/tools/warp_grep/agent/types.d.ts +4 -0
  202. package/dist/tools/warp_grep/agent/types.js +1 -0
  203. package/dist/tools/warp_grep/anthropic.cjs +51 -2561
  204. package/dist/tools/warp_grep/anthropic.d.ts +3 -1
  205. package/dist/tools/warp_grep/anthropic.js +23 -35
  206. package/dist/tools/warp_grep/client.cjs +53 -2471
  207. package/dist/tools/warp_grep/client.d.ts +3 -1
  208. package/dist/tools/warp_grep/client.js +21 -34
  209. package/dist/tools/warp_grep/gemini.cjs +52 -2490
  210. package/dist/tools/warp_grep/gemini.d.ts +3 -1
  211. package/dist/tools/warp_grep/gemini.js +25 -41
  212. package/dist/tools/warp_grep/harness.cjs +81 -936
  213. package/dist/tools/warp_grep/harness.d.ts +2 -0
  214. package/dist/tools/warp_grep/harness.js +12 -51
  215. package/dist/tools/warp_grep/index.cjs +128 -2575
  216. package/dist/tools/warp_grep/index.d.ts +3 -1
  217. package/dist/tools/warp_grep/index.js +28 -87
  218. package/dist/tools/warp_grep/openai.cjs +57 -2575
  219. package/dist/tools/warp_grep/openai.d.ts +3 -1
  220. package/dist/tools/warp_grep/openai.js +23 -37
  221. package/dist/tools/warp_grep/providers/code_storage_http.cjs +12 -65
  222. package/dist/tools/warp_grep/providers/code_storage_http.d.ts +3 -1
  223. package/dist/tools/warp_grep/providers/code_storage_http.js +2 -9
  224. package/dist/tools/warp_grep/providers/local.cjs +10 -589
  225. package/dist/tools/warp_grep/providers/local.js +6 -11
  226. package/dist/tools/warp_grep/providers/remote.cjs +8 -331
  227. package/dist/tools/warp_grep/providers/remote.d.ts +3 -1
  228. package/dist/tools/warp_grep/providers/remote.js +3 -8
  229. package/dist/tools/warp_grep/providers/types.cjs +1 -17
  230. package/dist/tools/warp_grep/providers/types.js +1 -0
  231. package/dist/tools/warp_grep/utils/files.cjs +9 -42
  232. package/dist/tools/warp_grep/utils/files.js +2 -7
  233. package/dist/tools/warp_grep/utils/github.cjs +9 -43
  234. package/dist/tools/warp_grep/utils/github.js +2 -7
  235. package/dist/tools/warp_grep/utils/paths.cjs +28 -104
  236. package/dist/tools/warp_grep/utils/paths.js +2 -17
  237. package/dist/tools/warp_grep/utils/ripgrep.cjs +9 -103
  238. package/dist/tools/warp_grep/utils/ripgrep.js +2 -7
  239. package/dist/tools/warp_grep/vercel.cjs +57 -2557
  240. package/dist/tools/warp_grep/vercel.d.ts +3 -1
  241. package/dist/tools/warp_grep/vercel.js +23 -37
  242. package/dist/{types-DxZLPogx.d.ts → types-BKhXjDCB.d.ts} +6 -1
  243. package/dist/version.cjs +7 -225
  244. package/dist/version.js +2 -7
  245. package/package.json +11 -2
  246. package/dist/chunk-E6TL6MIH.js +0 -203
@@ -0,0 +1,110 @@
1
+ 'use strict';
2
+
3
+ var chunkVL4QNALG_cjs = require('./chunk-VL4QNALG.cjs');
4
+ var chunkKF6S3EPJ_cjs = require('./chunk-KF6S3EPJ.cjs');
5
+ var chunkYAUXTFIN_cjs = require('./chunk-YAUXTFIN.cjs');
6
+ var chunkWJHHO24M_cjs = require('./chunk-WJHHO24M.cjs');
7
+ var chunkQT5LGZG3_cjs = require('./chunk-QT5LGZG3.cjs');
8
+
9
+ // core/client.ts
10
+ var DEFAULT_BASE_URL = "https://api.morphllm.com";
11
+ var DEFAULT_REPOS_URL = "https://repos.morphllm.com";
12
+ var DEFAULT_TIMEOUT = 6e4;
13
+ var env = (name) => typeof process !== "undefined" ? process.env?.[name] : void 0;
14
+ var stripTrailingSlash = (url) => url.replace(/\/+$/, "");
15
+ var MorphAPIClient = class {
16
+ /** Explicit key as provided; resolved against env at request time. */
17
+ apiKey;
18
+ baseURL;
19
+ reposURL;
20
+ /** Explicit default timeout (ms), if set. The request default is applied lazily so
21
+ * resources can read an undefined value and supply their own fallback. */
22
+ timeout;
23
+ retryConfig;
24
+ debug;
25
+ /** The `redactPII` option as given, for resources that build their own HTTP client. */
26
+ redactPII;
27
+ /** Set when `redactPII` is on. Resources open a session per request or run. */
28
+ pii;
29
+ constructor(options = {}) {
30
+ this.apiKey = options.apiKey;
31
+ this.baseURL = stripTrailingSlash(options.baseURL ?? DEFAULT_BASE_URL);
32
+ this.reposURL = stripTrailingSlash(options.reposURL ?? env("MORPH_SEARCH_URL") ?? DEFAULT_REPOS_URL);
33
+ this.timeout = options.timeout;
34
+ this.retryConfig = options.retryConfig;
35
+ this.debug = options.debug ?? false;
36
+ this.redactPII = options.redactPII;
37
+ this.pii = chunkKF6S3EPJ_cjs.resolvePIIGuard(options.redactPII);
38
+ if (this.debug) chunkVL4QNALG_cjs.logger.enable();
39
+ }
40
+ /** The key actually used for requests: explicit, else `MORPH_API_KEY`. */
41
+ resolveApiKey() {
42
+ return this.apiKey ?? env("MORPH_API_KEY");
43
+ }
44
+ /** Headers shared with tools that bring their own HTTP client (FastApply/WarpGrep via the `openai` package). */
45
+ defaultHeaders() {
46
+ return { "X-Morph-SDK-Version": chunkQT5LGZG3_cjs.SDK_VERSION };
47
+ }
48
+ buildURL(path, baseURL) {
49
+ if (/^https?:\/\//i.test(path)) return path;
50
+ const base = stripTrailingSlash(baseURL ?? this.baseURL);
51
+ return `${base}${path.startsWith("/") ? "" : "/"}${path}`;
52
+ }
53
+ buildHeaders(apiKey, extra) {
54
+ return {
55
+ "Content-Type": "application/json",
56
+ "X-Morph-SDK-Version": chunkQT5LGZG3_cjs.SDK_VERSION,
57
+ Authorization: `Bearer ${apiKey}`,
58
+ ...extra
59
+ };
60
+ }
61
+ applyQuery(url, query) {
62
+ if (!query) return url;
63
+ const params = new URLSearchParams();
64
+ for (const [key, value] of Object.entries(query)) {
65
+ if (value !== void 0 && value !== null) params.set(key, String(value));
66
+ }
67
+ const qs = params.toString();
68
+ return qs ? `${url}${url.includes("?") ? "&" : "?"}${qs}` : url;
69
+ }
70
+ async request(method, path, opts = {}) {
71
+ const apiKey = this.resolveApiKey();
72
+ if (!apiKey) {
73
+ throw new chunkWJHHO24M_cjs.MorphError(
74
+ "Morph API key not found. Set the MORPH_API_KEY environment variable or pass apiKey in config.",
75
+ "missing_api_key",
76
+ 401
77
+ );
78
+ }
79
+ const url = this.applyQuery(this.buildURL(path, opts.baseURL), opts.query);
80
+ const timeout = opts.timeout ?? this.timeout ?? DEFAULT_TIMEOUT;
81
+ const init = {
82
+ method,
83
+ headers: this.buildHeaders(apiKey, opts.headers),
84
+ ...opts.body !== void 0 ? { body: JSON.stringify(opts.body) } : {},
85
+ ...opts.signal ? { signal: opts.signal } : {}
86
+ };
87
+ chunkVL4QNALG_cjs.logger.debug("MorphAPIClient", "request", { method, url });
88
+ const response = await chunkWJHHO24M_cjs.withTimeout(
89
+ chunkWJHHO24M_cjs.fetchWithRetry(url, init, this.retryConfig ?? {}),
90
+ timeout,
91
+ `Morph request to ${url} timed out after ${timeout}ms`
92
+ );
93
+ if (!response.ok) throw await chunkYAUXTFIN_cjs.toMorphError(response);
94
+ if (opts.stream) return response;
95
+ if (response.status === 204) return void 0;
96
+ const text = await response.text();
97
+ return text ? JSON.parse(text) : void 0;
98
+ }
99
+ get(path, opts) {
100
+ return this.request("GET", path, opts);
101
+ }
102
+ post(path, opts) {
103
+ return this.request("POST", path, opts);
104
+ }
105
+ delete(path, opts) {
106
+ return this.request("DELETE", path, opts);
107
+ }
108
+ };
109
+
110
+ exports.MorphAPIClient = MorphAPIClient;
@@ -0,0 +1,317 @@
1
+ 'use strict';
2
+
3
+ var chunkR3TUE7O2_cjs = require('./chunk-R3TUE7O2.cjs');
4
+
5
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
6
+ // tools/pii/model.ts
7
+ var DEFAULT_PII_MODEL = "onnx-community/bert-small-pii-detection-ONNX";
8
+ var DEFAULT_LABEL_MAP = {
9
+ EMAIL_ADDRESS: "EMAIL",
10
+ PHONE_NUMBER: "PHONE",
11
+ US_SSN: "SSN",
12
+ IBAN_CODE: "IBAN",
13
+ PASSWORD: "SECRET"
14
+ };
15
+ var DEFAULT_MODEL_EXCLUDED_TYPES = [
16
+ "ORGANIZATION",
17
+ "DATE_TIME",
18
+ "URL",
19
+ "TITLE",
20
+ "AGE",
21
+ "NRP",
22
+ "COORDINATE"
23
+ ];
24
+ var REGEX_OWNED_TYPES = ["EMAIL", "IP_ADDRESS", "MAC_ADDRESS"];
25
+ var DEFAULT_PII_ALLOW = [
26
+ "Claude",
27
+ "Sonnet",
28
+ "Opus",
29
+ "Haiku",
30
+ "Gemini",
31
+ "Llama",
32
+ "Mistral",
33
+ "Grok",
34
+ "Copilot",
35
+ "Codex",
36
+ "Siri",
37
+ "Alexa"
38
+ ];
39
+ var NAME_LIKE_TYPES = ["PERSON", "LOCATION", "ORGANIZATION"];
40
+ var IDENT_CHAR = /[\p{L}\p{N}_$]/u;
41
+ var JOINER = /[-./@#]/;
42
+ var NAME_PREFIX = /^(?:Mc|Mac|De|Di|Du|La|Le|Van|Von|Fitz|O)\p{Lu}/u;
43
+ function looksLikeIdentifier(text, start, end) {
44
+ if (/\s/.test(text.slice(start, end))) return false;
45
+ const grow = (from, step) => {
46
+ let edge = from;
47
+ for (; ; ) {
48
+ const at = step === 1 ? edge : edge - 1;
49
+ const ch = text[at];
50
+ if (ch === void 0) return edge;
51
+ const crossesJoiner = JOINER.test(ch) && IDENT_CHAR.test(text[at + step] ?? "");
52
+ if (!IDENT_CHAR.test(ch) && !crossesJoiner) return edge;
53
+ edge += step;
54
+ }
55
+ };
56
+ const tokenStart = grow(start, -1);
57
+ const tokenEnd = grow(end, 1);
58
+ const token = text.slice(tokenStart, tokenEnd);
59
+ if (text[tokenEnd] === "(") return true;
60
+ if (/[_$]/.test(token)) return true;
61
+ if (/\p{L}/u.test(token) && /\p{N}/u.test(token)) return true;
62
+ if (/[/@#]/.test(token)) return true;
63
+ if (token.includes(".") && !/^(?:\p{Lu}\.)+\p{Lu}?$/u.test(token)) return true;
64
+ if (token.includes("-") && token === token.toLowerCase()) return true;
65
+ return token.split("-").some(
66
+ (word) => /^\p{Ll}+\p{Lu}/u.test(word) || // camelCase
67
+ /^\p{Lu}\p{Ll}+\p{Lu}\p{Ll}/u.test(word) && !NAME_PREFIX.test(word)
68
+ // PascalCase
69
+ );
70
+ }
71
+ var DEFAULT_MIN_SCORE = 0.75;
72
+ var CHUNK_CHARS = 400;
73
+ var TRUNCATION_TOKENS = 500;
74
+ var MAX_TOKEN_GAP = 64;
75
+ var MIN_SPLIT_CHARS = 64;
76
+ function countTokens(classifier, text) {
77
+ const tokenizer = classifier.tokenizer;
78
+ if (typeof tokenizer !== "function") return void 0;
79
+ try {
80
+ const dims = tokenizer(text)?.input_ids?.dims;
81
+ return Array.isArray(dims) ? Number(dims[dims.length - 1]) : void 0;
82
+ } catch {
83
+ return void 0;
84
+ }
85
+ }
86
+ function maxTokens(classifier) {
87
+ const max = classifier.tokenizer?.model_max_length;
88
+ return typeof max === "number" && max > 0 && max < 1e5 ? max : 512;
89
+ }
90
+ var SPECIAL_TOKEN = /^(?:\[(?:CLS|SEP|PAD|UNK|MASK)\]|<\/?s>|<(?:pad|unk|mask)>)$/;
91
+ var WORD_CHAR = /[\p{L}\p{N}]/u;
92
+ function normalizeChar(ch) {
93
+ return ch.normalize("NFD").replace(/\p{M}/gu, "").toLowerCase();
94
+ }
95
+ function chunkText(text, size = CHUNK_CHARS) {
96
+ const chunks = [];
97
+ let start = 0;
98
+ while (start < text.length) {
99
+ let end = Math.min(start + size, text.length);
100
+ if (end < text.length) {
101
+ const window = text.slice(start, end);
102
+ const paragraph = window.lastIndexOf("\n\n");
103
+ const newline = window.lastIndexOf("\n");
104
+ const space = Math.max(window.lastIndexOf(" "), window.lastIndexOf(" "));
105
+ const cut = paragraph > 0 ? paragraph + 1 : newline > size / 2 ? newline : space > size / 2 ? space : -1;
106
+ if (cut > 0) end = start + cut + 1;
107
+ }
108
+ chunks.push([start, end]);
109
+ start = end;
110
+ }
111
+ return chunks;
112
+ }
113
+ function alignTokens(text, words) {
114
+ let norm = "";
115
+ const starts = [];
116
+ const ends = [];
117
+ let offset = 0;
118
+ for (const ch of text) {
119
+ const n = normalizeChar(ch);
120
+ norm += n;
121
+ for (let k = 0; k < n.length; k++) {
122
+ starts.push(offset);
123
+ ends.push(offset + ch.length);
124
+ }
125
+ offset += ch.length;
126
+ }
127
+ const spans = [];
128
+ let cursor = 0;
129
+ let afterUnknown = false;
130
+ for (const word of words) {
131
+ if (SPECIAL_TOKEN.test(word)) {
132
+ if (/unk/i.test(word)) afterUnknown = true;
133
+ spans.push(null);
134
+ continue;
135
+ }
136
+ const needle = Array.from(word.replace(/^##|^[▁Ġ]/, ""), normalizeChar).join("");
137
+ const at = needle ? norm.indexOf(needle, cursor) : -1;
138
+ if (at === -1 || !afterUnknown && at - cursor > MAX_TOKEN_GAP) {
139
+ spans.push(null);
140
+ continue;
141
+ }
142
+ spans.push([starts[at], ends[at + needle.length - 1]]);
143
+ cursor = at + needle.length;
144
+ afterUnknown = false;
145
+ }
146
+ return spans;
147
+ }
148
+ function tokensToEntities(text, tokens, minScore, labelMap) {
149
+ const spans = alignTokens(text, tokens.map((t) => t.word));
150
+ const groups = [];
151
+ let open;
152
+ for (let i = 0; i < tokens.length; i++) {
153
+ const token = tokens[i];
154
+ const span = spans[i];
155
+ const label = token.entity.replace(/^[BIES]-/, "");
156
+ if (label === "O") {
157
+ open = void 0;
158
+ continue;
159
+ }
160
+ if (!span) continue;
161
+ if (open && open.label === label && token.index === open.lastIndex + 1) {
162
+ open.end = span[1];
163
+ open.scores.push(token.score);
164
+ open.lastIndex = token.index;
165
+ continue;
166
+ }
167
+ open = { label, start: span[0], end: span[1], scores: [token.score], lastIndex: token.index };
168
+ groups.push(open);
169
+ }
170
+ const entities = [];
171
+ for (const group of groups) {
172
+ const score = group.scores.reduce((a, b) => a + b, 0) / group.scores.length;
173
+ if (score < minScore) continue;
174
+ let { start, end } = group;
175
+ while (start > 0 && WORD_CHAR.test(text[start - 1])) start--;
176
+ while (end < text.length && WORD_CHAR.test(text[end])) end++;
177
+ entities.push({
178
+ type: labelMap[group.label] ?? group.label,
179
+ start,
180
+ end,
181
+ value: text.slice(start, end),
182
+ source: "model",
183
+ score
184
+ });
185
+ }
186
+ return entities;
187
+ }
188
+ var TRANSFORMERS = "@huggingface/transformers";
189
+ var viaImport = (name) => import(
190
+ /* webpackIgnore: true */
191
+ /* @vite-ignore */
192
+ name
193
+ );
194
+ var viaRequire = async (name) => {
195
+ const nodeModule = "node:module";
196
+ const { createRequire } = await import(
197
+ /* webpackIgnore: true */
198
+ /* @vite-ignore */
199
+ nodeModule
200
+ );
201
+ return createRequire(typeof __filename === "string" ? __filename : (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-6HAYJA6M.cjs', document.baseURI).href)))(name);
202
+ };
203
+ function isNotInstalled(error, name) {
204
+ const { code, message } = error ?? {};
205
+ return (code === "ERR_MODULE_NOT_FOUND" || code === "MODULE_NOT_FOUND") && String(message).includes(name);
206
+ }
207
+ async function loadOptionalDependency(name, load = { viaImport, viaRequire }) {
208
+ let importError;
209
+ try {
210
+ return await load.viaImport(name);
211
+ } catch (error) {
212
+ importError = error;
213
+ }
214
+ if (!isNotInstalled(importError, name)) {
215
+ try {
216
+ return await load.viaRequire(name);
217
+ } catch (requireError) {
218
+ if (!isNotInstalled(requireError, name)) {
219
+ const reason = importError instanceof Error ? importError.message : String(importError);
220
+ throw new Error(
221
+ `PII model mode could not load '${name}' on Node ${process.versions.node}: ${reason}. It is installed but failed to load. Use a newer Node version, or pass your own \`classifier\`.`,
222
+ { cause: importError }
223
+ );
224
+ }
225
+ }
226
+ }
227
+ throw new Error(
228
+ `PII model mode needs the optional dependency '${name}'. Install it (npm install ${name}), or pass your own \`classifier\`.`,
229
+ { cause: importError }
230
+ );
231
+ }
232
+ async function loadClassifier(config) {
233
+ const transformers = await loadOptionalDependency(TRANSFORMERS);
234
+ const options = { dtype: config.dtype ?? "q8", device: "cpu" };
235
+ if (config.cacheDir) options.cache_dir = config.cacheDir;
236
+ return transformers.pipeline("token-classification", config.model ?? DEFAULT_PII_MODEL, options);
237
+ }
238
+ function createPIIRedactor(config = {}) {
239
+ const mode = config.mode ?? (config.classifier ? "model" : "regex");
240
+ const minScore = config.minScore ?? DEFAULT_MIN_SCORE;
241
+ const labelMap = { ...DEFAULT_LABEL_MAP, ...config.labelMap };
242
+ const modelFilter = config.types || config.excludeTypes ? config : { excludeTypes: DEFAULT_MODEL_EXCLUDED_TYPES };
243
+ const allow = config.allow ?? (mode === "model" ? DEFAULT_PII_ALLOW : void 0);
244
+ let classifier;
245
+ const getClassifier = () => {
246
+ if (!classifier) {
247
+ classifier = config.classifier ? Promise.resolve(config.classifier) : loadClassifier(config);
248
+ classifier.catch(() => {
249
+ classifier = void 0;
250
+ });
251
+ }
252
+ return classifier;
253
+ };
254
+ function splitPoint(text, start, end) {
255
+ return start + chunkText(text.slice(start, end), Math.ceil((end - start) / 2))[0][1];
256
+ }
257
+ async function classify(text, start, end) {
258
+ const piece = text.slice(start, end);
259
+ if (!piece.trim()) return [];
260
+ const run = await getClassifier();
261
+ const halves = async () => {
262
+ const middle = splitPoint(text, start, end);
263
+ return [...await classify(text, start, middle), ...await classify(text, middle, end)];
264
+ };
265
+ const splittable = piece.length > MIN_SPLIT_CHARS;
266
+ const count = countTokens(run, piece);
267
+ if (splittable && count !== void 0 && count > maxTokens(run)) return halves();
268
+ let output;
269
+ try {
270
+ output = await run(piece, { ignore_labels: [] });
271
+ } catch (error) {
272
+ if (splittable && count === void 0) return halves();
273
+ throw error;
274
+ }
275
+ const tokens = Array.isArray(output[0]) ? output[0] : output;
276
+ if (splittable && count === void 0 && tokens.length >= TRUNCATION_TOKENS) return halves();
277
+ return tokensToEntities(piece, tokens, minScore, labelMap).map((e) => ({
278
+ ...e,
279
+ start: e.start + start,
280
+ end: e.end + start
281
+ }));
282
+ }
283
+ async function detect(text) {
284
+ const entities = chunkR3TUE7O2_cjs.detectPII(text, { ...config, allow });
285
+ if (mode === "model") {
286
+ for (const [start, end] of chunkText(text)) {
287
+ for (const entity of await classify(text, start, end)) {
288
+ if (REGEX_OWNED_TYPES.includes(entity.type)) continue;
289
+ if (chunkR3TUE7O2_cjs.isAllowed(entity.value, allow)) continue;
290
+ if (NAME_LIKE_TYPES.includes(entity.type) && looksLikeIdentifier(text, entity.start, entity.end)) continue;
291
+ if (chunkR3TUE7O2_cjs.isTypeEnabled(entity.type, modelFilter)) entities.push(entity);
292
+ }
293
+ }
294
+ }
295
+ return chunkR3TUE7O2_cjs.mergeEntities(text, entities);
296
+ }
297
+ return {
298
+ detect,
299
+ async redact(text) {
300
+ const entities = await detect(text);
301
+ return { text: chunkR3TUE7O2_cjs.applyRedactions(text, entities, config.placeholder), entities };
302
+ },
303
+ async load() {
304
+ if (mode === "model") await getClassifier();
305
+ }
306
+ };
307
+ }
308
+
309
+ exports.DEFAULT_MODEL_EXCLUDED_TYPES = DEFAULT_MODEL_EXCLUDED_TYPES;
310
+ exports.DEFAULT_PII_ALLOW = DEFAULT_PII_ALLOW;
311
+ exports.DEFAULT_PII_MODEL = DEFAULT_PII_MODEL;
312
+ exports.alignTokens = alignTokens;
313
+ exports.chunkText = chunkText;
314
+ exports.createPIIRedactor = createPIIRedactor;
315
+ exports.loadOptionalDependency = loadOptionalDependency;
316
+ exports.looksLikeIdentifier = looksLikeIdentifier;
317
+ exports.tokensToEntities = tokensToEntities;
@@ -1,10 +1,9 @@
1
+ import fs from 'fs/promises';
2
+
1
3
  // tools/warp_grep/utils/files.ts
2
- import fs from "fs/promises";
3
4
  async function readAllLines(filePath) {
4
5
  const content = await fs.readFile(filePath, "utf8");
5
6
  return content.split(/\r?\n/);
6
7
  }
7
8
 
8
- export {
9
- readAllLines
10
- };
9
+ export { readAllLines };
@@ -9,7 +9,7 @@ var MorphLogger = class {
9
9
  this.fileStream = null;
10
10
  const f = typeof process !== "undefined" ? process.env.MORPH_LOG_FILE : void 0;
11
11
  if (f) {
12
- this.ready = import("fs").then((fs) => {
12
+ this.ready = import('fs').then((fs) => {
13
13
  this.fileStream = fs.createWriteStream(f, { flags: "a" });
14
14
  }).catch(() => {
15
15
  });
@@ -45,6 +45,4 @@ var MorphLogger = class {
45
45
  };
46
46
  var logger = new MorphLogger();
47
47
 
48
- export {
49
- logger
50
- };
48
+ export { logger };
@@ -0,0 +1,42 @@
1
+ 'use strict';
2
+
3
+ // tools/fastapply/prompts.ts
4
+ var EDIT_FILE_TOOL_DESCRIPTION = `Use this tool to make an edit to an existing file.
5
+
6
+ This will be read by a less intelligent model, which will quickly apply the edit. You should make it clear what the edit is, while also minimizing the unchanged code you write.
7
+
8
+ When writing the edit, you should specify each edit in sequence, with the special comment // ... existing code ... to represent unchanged code in between edited lines.
9
+
10
+ For example:
11
+
12
+ // ... existing code ...
13
+ FIRST_EDIT
14
+ // ... existing code ...
15
+ SECOND_EDIT
16
+ // ... existing code ...
17
+ THIRD_EDIT
18
+ // ... existing code ...
19
+
20
+ You should still bias towards repeating as few lines of the original file as possible to convey the change.
21
+ But, each edit should contain minimally sufficient context of unchanged lines around the code you're editing to resolve ambiguity.
22
+
23
+ DO NOT omit spans of pre-existing code (or comments) without using the // ... existing code ... comment to indicate its absence. If you omit the existing code comment, the model may inadvertently delete these lines.
24
+
25
+ If you plan on deleting a section, you must provide context before and after to delete it.
26
+
27
+ Make sure it is clear what the edit should be, and where it should be applied.
28
+ Make edits to a file in a single edit_file call instead of multiple edit_file calls to the same file. The apply model can handle many distinct edits at once.`;
29
+ var EDIT_FILE_SYSTEM_PROMPT = `When the user is asking for edits to their code, use the edit_file tool to highlight the changes necessary and add comments to indicate where unchanged code has been skipped. For example:
30
+
31
+ // ... existing code ...
32
+ {{ edit_1 }}
33
+ // ... existing code ...
34
+ {{ edit_2 }}
35
+ // ... existing code ...
36
+
37
+ Often this will mean that the start/end of the file will be skipped, but that's okay! Rewrite the entire file ONLY if specifically requested. Always provide a brief explanation of the updates, unless the user specifically requests only the code.
38
+
39
+ These edit codeblocks are also read by a less intelligent language model, colloquially called the apply model, to update the file. To help specify the edit to the apply model, you will be very careful when generating the codeblock to not introduce ambiguity. You will specify all unchanged regions (code and comments) of the file with "// ... existing code ..." comment markers. This will ensure the apply model will not delete existing unchanged code or comments when editing the file.`;
40
+
41
+ exports.EDIT_FILE_SYSTEM_PROMPT = EDIT_FILE_SYSTEM_PROMPT;
42
+ exports.EDIT_FILE_TOOL_DESCRIPTION = EDIT_FILE_TOOL_DESCRIPTION;
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __export = (target, all) => {
5
+ for (var name in all)
6
+ __defProp(target, name, { get: all[name], enumerable: true });
7
+ };
8
+
9
+ exports.__export = __export;
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ // core/resource.ts
4
+ var APIResource = class {
5
+ _client;
6
+ constructor(client) {
7
+ this._client = client;
8
+ }
9
+ };
10
+
11
+ exports.APIResource = APIResource;
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+