@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.
- package/README.md +101 -0
- package/dist/chunk-2GMG5XKU.js +100 -0
- package/dist/chunk-2PPYWRMZ.js +3 -4
- package/dist/chunk-3HAHJYZQ.cjs +74 -0
- package/dist/{chunk-2XU3XXUE.js → chunk-3JROKKS4.js} +3 -25
- package/dist/{chunk-26K5EJD3.js → chunk-43JBUEIX.js} +4 -18
- package/dist/chunk-44OIEPIO.js +4 -23
- package/dist/chunk-4EQQGUZ7.cjs +104 -0
- package/dist/chunk-4OUGA3KS.js +1 -5
- package/dist/{chunk-VQDDL3UH.js → chunk-4TZBUFVP.js} +2 -8
- package/dist/{chunk-YAM6P5OQ.js → chunk-564XJOQP.js} +2 -6
- package/dist/chunk-5H3FKFOI.cjs +77 -0
- package/dist/chunk-5TTZQF4X.cjs +110 -0
- package/dist/chunk-6HAYJA6M.cjs +317 -0
- package/dist/chunk-6TZCVTW5.js +3 -4
- package/dist/chunk-6WP7EA4F.js +2 -4
- package/dist/chunk-74A4HLIO.cjs +42 -0
- package/dist/chunk-75ZPJI57.cjs +9 -0
- package/dist/chunk-7PJYY46L.cjs +2 -0
- package/dist/chunk-AWFZKS27.cjs +11 -0
- package/dist/chunk-BJBWWIZV.cjs +2 -0
- package/dist/chunk-DLYDIYDK.cjs +305 -0
- package/dist/{chunk-65TUD7JV.js → chunk-DYCMPDPV.js} +13 -29
- package/dist/{chunk-3CPI6ZIC.js → chunk-DZP7BR66.js} +22 -43
- package/dist/chunk-E63OPKP7.js +96 -0
- package/dist/chunk-E6V75LI6.cjs +334 -0
- package/dist/{chunk-XPHNS7NW.js → chunk-EJ6ID24K.js} +3 -12
- package/dist/chunk-EJTL2BOZ.cjs +42 -0
- package/dist/chunk-ETBRAKVV.js +1 -5
- package/dist/chunk-F633IVQA.cjs +91 -0
- package/dist/chunk-FBOZIVVQ.js +1 -0
- package/dist/{chunk-UKXCGQPS.js → chunk-FGA6EYC2.js} +35 -37
- package/dist/{chunk-CAWQEHKP.js → chunk-G4RODMXA.js} +4 -19
- package/dist/chunk-GUNGJC6X.cjs +256 -0
- package/dist/chunk-GYE3FY6Z.js +8 -0
- package/dist/chunk-HDP4QAZL.js +1 -4
- package/dist/chunk-HNMEBYIS.cjs +86 -0
- package/dist/chunk-HP3PCOTW.cjs +81 -0
- package/dist/{chunk-ICCGLO6V.js → chunk-IGXNLXPN.js} +12 -17
- package/dist/chunk-IPJA3ZS6.cjs +10 -0
- package/dist/chunk-JHC2R3HU.cjs +317 -0
- package/dist/{chunk-IBRBSDLT.js → chunk-JVMIFGZY.js} +5 -8
- package/dist/chunk-KF6S3EPJ.cjs +100 -0
- package/dist/chunk-KVGZ2TSG.cjs +274 -0
- package/dist/{chunk-6OYJC4TZ.js → chunk-L5SCKZVK.js} +13 -22
- package/dist/chunk-LDM7RNNN.js +1 -0
- package/dist/{chunk-UAZKHSEU.js → chunk-LQST3NW2.js} +5 -15
- package/dist/chunk-M34E2AMK.js +1 -5
- package/dist/chunk-MF56KEI4.js +1 -4
- package/dist/chunk-MLKGABMK.js +1 -3
- package/dist/chunk-MLPZKUCO.js +4 -5
- package/dist/chunk-MMX5PUGC.cjs +242 -0
- package/dist/chunk-MWXJ6DZ2.cjs +21 -0
- package/dist/chunk-NJWOWXUR.cjs +137 -0
- package/dist/chunk-NNKBKENK.cjs +15 -0
- package/dist/chunk-NRG6QX3L.js +1 -3
- package/dist/chunk-OCKEEEYE.cjs +433 -0
- package/dist/chunk-OENJO7YW.js +306 -0
- package/dist/chunk-OKLAYEBC.cjs +2 -0
- package/dist/chunk-OPDWMD4Q.js +1 -3
- package/dist/{chunk-D6YJ5X3C.js → chunk-OX5GN2KB.js} +26 -14
- package/dist/{chunk-JEVLCA5C.js → chunk-OYBOP47A.js} +18 -19
- package/dist/chunk-OZHCHPIE.js +1 -0
- package/dist/chunk-PA3UTI4A.js +1 -4
- package/dist/chunk-QEEAIXL5.cjs +74 -0
- package/dist/chunk-QT5LGZG3.cjs +10 -0
- package/dist/chunk-R3TUE7O2.cjs +107 -0
- package/dist/chunk-RYVW7RUM.js +2 -6
- package/dist/{chunk-LVKKICOB.js → chunk-SOQYE5A4.js} +36 -69
- package/dist/chunk-ST2OXLT5.cjs +91 -0
- package/dist/{chunk-SIFDK4AA.js → chunk-TH4MG73B.js} +3 -24
- package/dist/{chunk-OSL4CNSO.js → chunk-TLMAMVAW.js} +7 -23
- package/dist/chunk-TPZHMD7J.cjs +72 -0
- package/dist/{chunk-PDSIWL7I.js → chunk-U4PYAGNR.js} +6 -19
- package/dist/chunk-UAPK3AIJ.js +1 -10
- package/dist/chunk-UF5IKELS.cjs +26 -0
- package/dist/chunk-UHFVWYSP.cjs +408 -0
- package/dist/chunk-UKBSXYKE.cjs +280 -0
- package/dist/chunk-UNX7V6P6.cjs +60 -0
- package/dist/chunk-UZMMJ47A.cjs +107 -0
- package/dist/chunk-VHD7CW5O.cjs +43 -0
- package/dist/chunk-VL4QNALG.cjs +50 -0
- package/dist/chunk-VYE7O4FM.cjs +51 -0
- package/dist/chunk-WIYVT4UO.cjs +173 -0
- package/dist/chunk-WJHHO24M.cjs +91 -0
- package/dist/chunk-WR7LSUIR.cjs +213 -0
- package/dist/chunk-XE6D4J63.cjs +72 -0
- package/dist/chunk-YAUXTFIN.cjs +21 -0
- package/dist/{chunk-NFPRKZQ5.js → chunk-YJUCGZNN.js} +5 -22
- package/dist/chunk-ZSHVXDA2.js +4 -10
- package/dist/chunk-ZX6T3LNG.js +302 -0
- package/dist/{client-BWhi-vSj.d.ts → client-DSXbcxII.d.ts} +10 -1
- package/dist/client.cjs +44 -4360
- package/dist/client.d.ts +4 -2
- package/dist/client.js +36 -37
- package/dist/core/client.cjs +14 -476
- package/dist/core/client.d.ts +8 -0
- package/dist/core/client.js +10 -11
- package/dist/core/error.cjs +8 -251
- package/dist/core/error.js +4 -9
- package/dist/core/index.cjs +27 -491
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +12 -19
- package/dist/core/resource.cjs +9 -33
- package/dist/core/resource.d.ts +2 -0
- package/dist/core/resource.js +2 -7
- package/dist/edge.cjs +74 -1111
- package/dist/edge.d.ts +3 -0
- package/dist/edge.js +14 -42
- package/dist/guard-CvW03v4u.d.ts +59 -0
- package/dist/index.cjs +140 -4431
- package/dist/index.d.ts +6 -2
- package/dist/index.js +44 -87
- package/dist/modelrouter/core.cjs +35 -651
- package/dist/modelrouter/core.d.ts +2 -0
- package/dist/modelrouter/core.js +12 -21
- package/dist/modelrouter/index.cjs +35 -651
- package/dist/modelrouter/index.d.ts +2 -0
- package/dist/modelrouter/index.js +12 -21
- package/dist/modelrouter/types.cjs +1 -17
- package/dist/modelrouter/types.d.ts +5 -0
- package/dist/modelrouter/types.js +1 -0
- package/dist/subagents/anthropic.cjs +31 -2784
- package/dist/subagents/anthropic.d.ts +3 -1
- package/dist/subagents/anthropic.js +23 -24
- package/dist/subagents/index.cjs +14 -95
- package/dist/subagents/index.d.ts +3 -1
- package/dist/subagents/index.js +2 -11
- package/dist/subagents/prompts.cjs +14 -93
- package/dist/subagents/prompts.d.ts +3 -1
- package/dist/subagents/prompts.js +2 -11
- package/dist/subagents/types.cjs +1 -17
- package/dist/subagents/types.d.ts +3 -1
- package/dist/subagents/types.js +1 -0
- package/dist/subagents/vercel.cjs +31 -2761
- package/dist/subagents/vercel.d.ts +3 -1
- package/dist/subagents/vercel.js +23 -24
- package/dist/tools/compact/core.cjs +20 -552
- package/dist/tools/compact/core.d.ts +2 -0
- package/dist/tools/compact/core.js +12 -13
- package/dist/tools/compact/index.cjs +24 -598
- package/dist/tools/compact/index.d.ts +3 -1
- package/dist/tools/compact/index.js +13 -17
- package/dist/tools/compact/types.cjs +1 -17
- package/dist/tools/compact/types.d.ts +4 -4
- package/dist/tools/compact/types.js +1 -0
- package/dist/tools/fastapply/anthropic.cjs +39 -899
- package/dist/tools/fastapply/anthropic.d.ts +2 -0
- package/dist/tools/fastapply/anthropic.js +15 -24
- package/dist/tools/fastapply/apply.cjs +32 -672
- package/dist/tools/fastapply/apply.d.ts +2 -0
- package/dist/tools/fastapply/apply.js +8 -19
- package/dist/tools/fastapply/core.cjs +49 -1069
- package/dist/tools/fastapply/core.d.ts +3 -0
- package/dist/tools/fastapply/core.js +13 -29
- package/dist/tools/fastapply/index.cjs +56 -1052
- package/dist/tools/fastapply/index.d.ts +2 -0
- package/dist/tools/fastapply/index.js +18 -44
- package/dist/tools/fastapply/openai.cjs +45 -910
- package/dist/tools/fastapply/openai.d.ts +2 -0
- package/dist/tools/fastapply/openai.js +15 -26
- package/dist/tools/fastapply/prompts.cjs +10 -62
- package/dist/tools/fastapply/prompts.js +2 -9
- package/dist/tools/fastapply/types.cjs +1 -17
- package/dist/tools/fastapply/types.d.ts +9 -4
- package/dist/tools/fastapply/types.js +1 -0
- package/dist/tools/fastapply/vercel.cjs +37 -905
- package/dist/tools/fastapply/vercel.d.ts +2 -0
- package/dist/tools/fastapply/vercel.js +15 -22
- package/dist/tools/index.cjs +56 -1052
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.js +18 -44
- package/dist/tools/pii/index.cjs +47 -0
- package/dist/tools/pii/index.d.ts +4 -0
- package/dist/tools/pii/index.js +6 -0
- package/dist/tools/pii/model.cjs +45 -0
- package/dist/tools/pii/model.d.ts +83 -0
- package/dist/tools/pii/model.js +4 -0
- package/dist/tools/pii/patterns.cjs +15 -0
- package/dist/tools/pii/patterns.d.ts +31 -0
- package/dist/tools/pii/patterns.js +2 -0
- package/dist/tools/pii/regex.cjs +32 -0
- package/dist/tools/pii/regex.d.ts +48 -0
- package/dist/tools/pii/regex.js +3 -0
- package/dist/tools/pii/types.cjs +2 -0
- package/dist/tools/pii/types.d.ts +108 -0
- package/dist/tools/pii/types.js +1 -0
- package/dist/tools/utils/resilience.cjs +15 -312
- package/dist/tools/utils/resilience.js +3 -12
- package/dist/tools/warp_grep/agent/config.cjs +16 -127
- package/dist/tools/warp_grep/agent/config.js +2 -11
- package/dist/tools/warp_grep/agent/formatter.cjs +12 -48
- package/dist/tools/warp_grep/agent/formatter.js +2 -9
- package/dist/tools/warp_grep/agent/parser.cjs +16 -83
- package/dist/tools/warp_grep/agent/parser.d.ts +2 -0
- package/dist/tools/warp_grep/agent/parser.js +2 -11
- package/dist/tools/warp_grep/agent/runner.cjs +19 -1081
- package/dist/tools/warp_grep/agent/runner.d.ts +2 -0
- package/dist/tools/warp_grep/agent/runner.js +11 -14
- package/dist/tools/warp_grep/agent/types.cjs +1 -17
- package/dist/tools/warp_grep/agent/types.d.ts +4 -0
- package/dist/tools/warp_grep/agent/types.js +1 -0
- package/dist/tools/warp_grep/anthropic.cjs +51 -2561
- package/dist/tools/warp_grep/anthropic.d.ts +3 -1
- package/dist/tools/warp_grep/anthropic.js +23 -35
- package/dist/tools/warp_grep/client.cjs +53 -2471
- package/dist/tools/warp_grep/client.d.ts +3 -1
- package/dist/tools/warp_grep/client.js +21 -34
- package/dist/tools/warp_grep/gemini.cjs +52 -2490
- package/dist/tools/warp_grep/gemini.d.ts +3 -1
- package/dist/tools/warp_grep/gemini.js +25 -41
- package/dist/tools/warp_grep/harness.cjs +81 -936
- package/dist/tools/warp_grep/harness.d.ts +2 -0
- package/dist/tools/warp_grep/harness.js +12 -51
- package/dist/tools/warp_grep/index.cjs +128 -2575
- package/dist/tools/warp_grep/index.d.ts +3 -1
- package/dist/tools/warp_grep/index.js +28 -87
- package/dist/tools/warp_grep/openai.cjs +57 -2575
- package/dist/tools/warp_grep/openai.d.ts +3 -1
- package/dist/tools/warp_grep/openai.js +23 -37
- package/dist/tools/warp_grep/providers/code_storage_http.cjs +12 -65
- package/dist/tools/warp_grep/providers/code_storage_http.d.ts +3 -1
- package/dist/tools/warp_grep/providers/code_storage_http.js +2 -9
- package/dist/tools/warp_grep/providers/local.cjs +10 -589
- package/dist/tools/warp_grep/providers/local.js +6 -11
- package/dist/tools/warp_grep/providers/remote.cjs +8 -331
- package/dist/tools/warp_grep/providers/remote.d.ts +3 -1
- package/dist/tools/warp_grep/providers/remote.js +3 -8
- package/dist/tools/warp_grep/providers/types.cjs +1 -17
- package/dist/tools/warp_grep/providers/types.js +1 -0
- package/dist/tools/warp_grep/utils/files.cjs +9 -42
- package/dist/tools/warp_grep/utils/files.js +2 -7
- package/dist/tools/warp_grep/utils/github.cjs +9 -43
- package/dist/tools/warp_grep/utils/github.js +2 -7
- package/dist/tools/warp_grep/utils/paths.cjs +28 -104
- package/dist/tools/warp_grep/utils/paths.js +2 -17
- package/dist/tools/warp_grep/utils/ripgrep.cjs +9 -103
- package/dist/tools/warp_grep/utils/ripgrep.js +2 -7
- package/dist/tools/warp_grep/vercel.cjs +57 -2557
- package/dist/tools/warp_grep/vercel.d.ts +3 -1
- package/dist/tools/warp_grep/vercel.js +23 -37
- package/dist/{types-DxZLPogx.d.ts → types-BKhXjDCB.d.ts} +6 -1
- package/dist/version.cjs +7 -225
- package/dist/version.js +2 -7
- package/package.json +11 -2
- package/dist/chunk-E6TL6MIH.js +0 -203
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk4EQQGUZ7_cjs = require('./chunk-4EQQGUZ7.cjs');
|
|
4
|
+
|
|
5
|
+
// tools/warp_grep/providers/remote.ts
|
|
6
|
+
var SKIP_NAMES = /* @__PURE__ */ new Set([
|
|
7
|
+
// Version control
|
|
8
|
+
".git",
|
|
9
|
+
".svn",
|
|
10
|
+
".hg",
|
|
11
|
+
".bzr",
|
|
12
|
+
// Dependencies
|
|
13
|
+
"node_modules",
|
|
14
|
+
"bower_components",
|
|
15
|
+
".pnpm",
|
|
16
|
+
".yarn",
|
|
17
|
+
"vendor",
|
|
18
|
+
"Pods",
|
|
19
|
+
".bundle",
|
|
20
|
+
// Python
|
|
21
|
+
"__pycache__",
|
|
22
|
+
".pytest_cache",
|
|
23
|
+
".mypy_cache",
|
|
24
|
+
".ruff_cache",
|
|
25
|
+
".venv",
|
|
26
|
+
"venv",
|
|
27
|
+
".tox",
|
|
28
|
+
".nox",
|
|
29
|
+
".eggs",
|
|
30
|
+
// Build outputs
|
|
31
|
+
"dist",
|
|
32
|
+
"build",
|
|
33
|
+
"out",
|
|
34
|
+
"output",
|
|
35
|
+
"target",
|
|
36
|
+
"_build",
|
|
37
|
+
".next",
|
|
38
|
+
".nuxt",
|
|
39
|
+
".output",
|
|
40
|
+
".vercel",
|
|
41
|
+
".netlify",
|
|
42
|
+
// Cache
|
|
43
|
+
".cache",
|
|
44
|
+
".parcel-cache",
|
|
45
|
+
".turbo",
|
|
46
|
+
".nx",
|
|
47
|
+
".gradle",
|
|
48
|
+
// IDE
|
|
49
|
+
".idea",
|
|
50
|
+
".vscode",
|
|
51
|
+
".vs",
|
|
52
|
+
// Coverage
|
|
53
|
+
"coverage",
|
|
54
|
+
".coverage",
|
|
55
|
+
"htmlcov",
|
|
56
|
+
".nyc_output",
|
|
57
|
+
// Temp
|
|
58
|
+
"tmp",
|
|
59
|
+
"temp",
|
|
60
|
+
".tmp",
|
|
61
|
+
".temp",
|
|
62
|
+
// Lock files
|
|
63
|
+
"package-lock.json",
|
|
64
|
+
"yarn.lock",
|
|
65
|
+
"pnpm-lock.yaml",
|
|
66
|
+
"bun.lockb",
|
|
67
|
+
"Cargo.lock",
|
|
68
|
+
"Gemfile.lock",
|
|
69
|
+
"poetry.lock"
|
|
70
|
+
]);
|
|
71
|
+
var SKIP_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
72
|
+
".min.js",
|
|
73
|
+
".min.css",
|
|
74
|
+
".bundle.js",
|
|
75
|
+
".wasm",
|
|
76
|
+
".so",
|
|
77
|
+
".dll",
|
|
78
|
+
".pyc",
|
|
79
|
+
".map",
|
|
80
|
+
".js.map"
|
|
81
|
+
]);
|
|
82
|
+
function shouldSkip(name) {
|
|
83
|
+
if (SKIP_NAMES.has(name)) return true;
|
|
84
|
+
if (name.startsWith(".")) return true;
|
|
85
|
+
for (const ext of SKIP_EXTENSIONS) {
|
|
86
|
+
if (name.endsWith(ext)) return true;
|
|
87
|
+
}
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
var RemoteCommandsProvider = class {
|
|
91
|
+
constructor(repoRoot, commands) {
|
|
92
|
+
this.repoRoot = repoRoot;
|
|
93
|
+
this.commands = commands;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Run grep command and parse ripgrep output
|
|
97
|
+
*/
|
|
98
|
+
async grep(params) {
|
|
99
|
+
try {
|
|
100
|
+
const stdout = await this.commands.grep(params.pattern, params.path, params.glob);
|
|
101
|
+
const lines = (stdout || "").trim().split(/\r?\n/).filter((l) => l.length > 0);
|
|
102
|
+
if (lines.length > chunk4EQQGUZ7_cjs.AGENT_CONFIG.MAX_OUTPUT_LINES) {
|
|
103
|
+
const truncated = lines.slice(0, chunk4EQQGUZ7_cjs.AGENT_CONFIG.MAX_OUTPUT_LINES);
|
|
104
|
+
truncated.push(`... (output truncated at ${chunk4EQQGUZ7_cjs.AGENT_CONFIG.MAX_OUTPUT_LINES} of ${lines.length} lines)`);
|
|
105
|
+
return { lines: truncated };
|
|
106
|
+
}
|
|
107
|
+
return { lines };
|
|
108
|
+
} catch (error) {
|
|
109
|
+
return {
|
|
110
|
+
lines: [],
|
|
111
|
+
error: `[GREP ERROR] ${error instanceof Error ? error.message : String(error)}`
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Read file and add line numbers
|
|
117
|
+
*/
|
|
118
|
+
async read(params) {
|
|
119
|
+
const rawStart = params.start;
|
|
120
|
+
const rawEnd = params.end;
|
|
121
|
+
const startValid = rawStart === void 0 || Number.isFinite(rawStart) && rawStart > 0;
|
|
122
|
+
const endValid = rawEnd === void 0 || Number.isFinite(rawEnd) && rawEnd > 0;
|
|
123
|
+
const rangeValid = startValid && endValid && (rawStart === void 0 || rawEnd === void 0 || rawStart <= rawEnd);
|
|
124
|
+
const start = rangeValid && rawStart !== void 0 ? rawStart : 1;
|
|
125
|
+
const end = rangeValid && rawEnd !== void 0 ? rawEnd : 1e6;
|
|
126
|
+
try {
|
|
127
|
+
const stdout = await this.commands.read(params.path, start, end);
|
|
128
|
+
const contentLines = (stdout || "").split("\n");
|
|
129
|
+
if (contentLines.length > 0 && contentLines[contentLines.length - 1] === "") {
|
|
130
|
+
contentLines.pop();
|
|
131
|
+
}
|
|
132
|
+
const lines = contentLines.map((content, idx) => `${start + idx}|${content}`);
|
|
133
|
+
if (lines.length > chunk4EQQGUZ7_cjs.AGENT_CONFIG.MAX_READ_LINES) {
|
|
134
|
+
const truncated = lines.slice(0, chunk4EQQGUZ7_cjs.AGENT_CONFIG.MAX_READ_LINES);
|
|
135
|
+
truncated.push(`... (output truncated at ${chunk4EQQGUZ7_cjs.AGENT_CONFIG.MAX_READ_LINES} of ${lines.length} lines)`);
|
|
136
|
+
return { lines: truncated };
|
|
137
|
+
}
|
|
138
|
+
return { lines };
|
|
139
|
+
} catch (error) {
|
|
140
|
+
return {
|
|
141
|
+
lines: [],
|
|
142
|
+
error: `[READ ERROR] ${error instanceof Error ? error.message : String(error)}`
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* List directory and parse find output
|
|
148
|
+
*/
|
|
149
|
+
async listDirectory(params) {
|
|
150
|
+
const maxDepth = params.maxDepth ?? chunk4EQQGUZ7_cjs.AGENT_CONFIG.MAX_LIST_DEPTH;
|
|
151
|
+
const maxResults = params.maxResults ?? chunk4EQQGUZ7_cjs.AGENT_CONFIG.MAX_OUTPUT_LINES;
|
|
152
|
+
try {
|
|
153
|
+
const stdout = await this.commands.listDir(params.path, maxDepth);
|
|
154
|
+
const paths = (stdout || "").trim().split(/\r?\n/).filter((p) => p.length > 0);
|
|
155
|
+
const regex = params.pattern ? new RegExp(params.pattern) : null;
|
|
156
|
+
const entries = [];
|
|
157
|
+
for (const fullPath of paths) {
|
|
158
|
+
if (fullPath === params.path || fullPath === this.repoRoot) continue;
|
|
159
|
+
const name = fullPath.split("/").pop() || "";
|
|
160
|
+
if (shouldSkip(name)) continue;
|
|
161
|
+
if (regex && !regex.test(name)) continue;
|
|
162
|
+
let relativePath = fullPath;
|
|
163
|
+
if (fullPath.startsWith(this.repoRoot)) {
|
|
164
|
+
relativePath = fullPath.slice(this.repoRoot.length).replace(/^\//, "");
|
|
165
|
+
}
|
|
166
|
+
const depth = relativePath.split("/").filter(Boolean).length - 1;
|
|
167
|
+
const hasExtension = name.includes(".") && !name.startsWith(".");
|
|
168
|
+
const type = hasExtension ? "file" : "dir";
|
|
169
|
+
entries.push({
|
|
170
|
+
name,
|
|
171
|
+
path: relativePath,
|
|
172
|
+
type,
|
|
173
|
+
depth: Math.max(0, depth)
|
|
174
|
+
});
|
|
175
|
+
if (entries.length >= maxResults) break;
|
|
176
|
+
}
|
|
177
|
+
return entries;
|
|
178
|
+
} catch (error) {
|
|
179
|
+
return [];
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Glob search - finds files matching a pattern.
|
|
184
|
+
* Falls back to a grep --files approach via the listDir command.
|
|
185
|
+
*/
|
|
186
|
+
async glob(params) {
|
|
187
|
+
const searchPath = params.path || this.repoRoot;
|
|
188
|
+
try {
|
|
189
|
+
const stdout = await this.commands.listDir(searchPath, 10);
|
|
190
|
+
const allPaths = (stdout || "").trim().split(/\r?\n/).filter((p) => p.length > 0);
|
|
191
|
+
const globToRegex = (glob) => {
|
|
192
|
+
const escaped = glob.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*").replace(/\?/g, ".");
|
|
193
|
+
return new RegExp(escaped);
|
|
194
|
+
};
|
|
195
|
+
const regex = globToRegex(params.pattern);
|
|
196
|
+
const matched = allPaths.filter((p) => {
|
|
197
|
+
const name = p.split("/").pop() || "";
|
|
198
|
+
return regex.test(name) && !shouldSkip(name);
|
|
199
|
+
});
|
|
200
|
+
const totalFound = matched.length;
|
|
201
|
+
return { files: matched.slice(0, 100), searchDir: searchPath, totalFound };
|
|
202
|
+
} catch (error) {
|
|
203
|
+
return {
|
|
204
|
+
files: [],
|
|
205
|
+
searchDir: searchPath,
|
|
206
|
+
totalFound: 0,
|
|
207
|
+
error: `[GLOB ERROR] ${error instanceof Error ? error.message : String(error)}`
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
exports.RemoteCommandsProvider = RemoteCommandsProvider;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var child_process = require('child_process');
|
|
4
|
+
|
|
5
|
+
// tools/warp_grep/utils/ripgrep.ts
|
|
6
|
+
var resolvedRgPath = null;
|
|
7
|
+
var rgPathChecked = false;
|
|
8
|
+
function spawnRg(rgBinary, args, opts) {
|
|
9
|
+
return new Promise((resolve) => {
|
|
10
|
+
const child = child_process.spawn(rgBinary, args, {
|
|
11
|
+
cwd: opts?.cwd,
|
|
12
|
+
env: { ...process.env, ...opts?.env || {} },
|
|
13
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
14
|
+
});
|
|
15
|
+
let stdout = "";
|
|
16
|
+
let stderr = "";
|
|
17
|
+
child.stdout.on("data", (d) => stdout += d.toString());
|
|
18
|
+
child.stderr.on("data", (d) => stderr += d.toString());
|
|
19
|
+
child.on("close", (code) => {
|
|
20
|
+
resolve({ stdout, stderr, exitCode: typeof code === "number" ? code : -1 });
|
|
21
|
+
});
|
|
22
|
+
child.on("error", () => {
|
|
23
|
+
resolve({ stdout: "", stderr: "Failed to spawn ripgrep.", exitCode: -1 });
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
async function preferredRgPath() {
|
|
28
|
+
try {
|
|
29
|
+
return (await import('@vscode/ripgrep')).rgPath ?? "rg";
|
|
30
|
+
} catch {
|
|
31
|
+
return "rg";
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function isBinaryFailure(result) {
|
|
35
|
+
if (result.exitCode === -1) return true;
|
|
36
|
+
if (result.stderr.includes("jemalloc") || result.stderr.includes("Unsupported system page size")) return true;
|
|
37
|
+
if (result.exitCode === 134) return true;
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
async function runRipgrep(args, opts) {
|
|
41
|
+
if (rgPathChecked && resolvedRgPath) {
|
|
42
|
+
return spawnRg(resolvedRgPath, args, opts);
|
|
43
|
+
}
|
|
44
|
+
if (!rgPathChecked) {
|
|
45
|
+
const rgPath = await preferredRgPath();
|
|
46
|
+
const result = await spawnRg(rgPath, args, opts);
|
|
47
|
+
if (!isBinaryFailure(result)) {
|
|
48
|
+
resolvedRgPath = rgPath;
|
|
49
|
+
rgPathChecked = true;
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
const fallbackResult = await spawnRg("rg", args, opts);
|
|
53
|
+
if (!isBinaryFailure(fallbackResult)) {
|
|
54
|
+
resolvedRgPath = "rg";
|
|
55
|
+
rgPathChecked = true;
|
|
56
|
+
return fallbackResult;
|
|
57
|
+
}
|
|
58
|
+
rgPathChecked = true;
|
|
59
|
+
return {
|
|
60
|
+
stdout: "",
|
|
61
|
+
stderr: "Failed to spawn ripgrep. Neither bundled nor system rg is available.",
|
|
62
|
+
exitCode: -1
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
stdout: "",
|
|
67
|
+
stderr: "Failed to spawn ripgrep. Neither bundled nor system rg is available.",
|
|
68
|
+
exitCode: -1
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
exports.runRipgrep = runRipgrep;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkWJHHO24M_cjs = require('./chunk-WJHHO24M.cjs');
|
|
4
|
+
|
|
5
|
+
// core/error.ts
|
|
6
|
+
async function toMorphError(response) {
|
|
7
|
+
let message = `Morph API request failed (${response.status})`;
|
|
8
|
+
let code = "api_error";
|
|
9
|
+
try {
|
|
10
|
+
const body = await response.json();
|
|
11
|
+
message = body.error?.message ?? body.message ?? message;
|
|
12
|
+
code = body.error?.code ?? body.error?.type ?? code;
|
|
13
|
+
} catch {
|
|
14
|
+
}
|
|
15
|
+
if (response.status === 401) code = "authentication_error";
|
|
16
|
+
if (response.status === 429) code = "rate_limit_exceeded";
|
|
17
|
+
const retryable = response.status === 429 || response.status === 503;
|
|
18
|
+
return new chunkWJHHO24M_cjs.MorphError(message, code, response.status, retryable);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
exports.toMorphError = toMorphError;
|
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from "./chunk-UAPK3AIJ.js";
|
|
6
|
-
import {
|
|
7
|
-
WarpGrepClient,
|
|
8
|
-
executeGitHubReadFile,
|
|
9
|
-
executeToolCall,
|
|
10
|
-
executeToolCallStreaming
|
|
11
|
-
} from "./chunk-3CPI6ZIC.js";
|
|
1
|
+
import { WARP_GREP_DESCRIPTION, GITHUB_SEARCH_DESCRIPTION, GITHUB_READ_FILE_DESCRIPTION } from './chunk-UAPK3AIJ.js';
|
|
2
|
+
import { executeToolCall, executeToolCallStreaming, WarpGrepClient, executeGitHubReadFile } from './chunk-DZP7BR66.js';
|
|
3
|
+
import { tool } from 'ai';
|
|
4
|
+
import { z } from 'zod';
|
|
12
5
|
|
|
13
|
-
// tools/warp_grep/vercel.ts
|
|
14
|
-
import { tool } from "ai";
|
|
15
|
-
import { z } from "zod";
|
|
16
6
|
var warpGrepJsonSchema = {
|
|
17
7
|
type: "object",
|
|
18
8
|
properties: {
|
|
@@ -107,11 +97,4 @@ function createGitHubReadFileTool(config) {
|
|
|
107
97
|
}
|
|
108
98
|
var vercel_default = createWarpGrepTool;
|
|
109
99
|
|
|
110
|
-
export {
|
|
111
|
-
warpGrepJsonSchema,
|
|
112
|
-
execute,
|
|
113
|
-
createWarpGrepTool,
|
|
114
|
-
createGitHubSearchTool,
|
|
115
|
-
createGitHubReadFileTool,
|
|
116
|
-
vercel_default
|
|
117
|
-
};
|
|
100
|
+
export { createGitHubReadFileTool, createGitHubSearchTool, createWarpGrepTool, execute, vercel_default, warpGrepJsonSchema };
|
package/dist/chunk-ZSHVXDA2.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
1
4
|
// tools/warp_grep/utils/paths.ts
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import path from "path";
|
|
4
5
|
function resolveUnderRepo(repoRoot, targetPath) {
|
|
5
6
|
const absRoot = path.resolve(repoRoot);
|
|
6
7
|
const resolved = path.resolve(absRoot, targetPath);
|
|
@@ -58,11 +59,4 @@ function isTextualFile(filePath, maxBytes = 2e6) {
|
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
export {
|
|
62
|
-
resolveUnderRepo,
|
|
63
|
-
ensureWithinRepo,
|
|
64
|
-
toRepoRelative,
|
|
65
|
-
isSymlink,
|
|
66
|
-
fixPathRepetition,
|
|
67
|
-
isTextualFile
|
|
68
|
-
};
|
|
62
|
+
export { ensureWithinRepo, fixPathRepetition, isSymlink, isTextualFile, resolveUnderRepo, toRepoRelative };
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
// tools/pii/validators.ts
|
|
2
|
+
function digitCount(value) {
|
|
3
|
+
return value.replace(/\D/g, "").length;
|
|
4
|
+
}
|
|
5
|
+
function isRepeatedDigit(digits) {
|
|
6
|
+
return /^(\d)\1+$/.test(digits);
|
|
7
|
+
}
|
|
8
|
+
function luhn(value) {
|
|
9
|
+
const digits = value.replace(/\D/g, "");
|
|
10
|
+
if (digits.length < 13 || digits.length > 19) return false;
|
|
11
|
+
if (isRepeatedDigit(digits)) return false;
|
|
12
|
+
let sum = 0;
|
|
13
|
+
let double = false;
|
|
14
|
+
for (let i = digits.length - 1; i >= 0; i--) {
|
|
15
|
+
let d = digits.charCodeAt(i) - 48;
|
|
16
|
+
if (double) {
|
|
17
|
+
d *= 2;
|
|
18
|
+
if (d > 9) d -= 9;
|
|
19
|
+
}
|
|
20
|
+
sum += d;
|
|
21
|
+
double = !double;
|
|
22
|
+
}
|
|
23
|
+
return sum % 10 === 0;
|
|
24
|
+
}
|
|
25
|
+
var CARD_CUE = /\b(?:card|credit|debit|visa|mastercard|amex|american express|discover|maestro|jcb|diners)\b/i;
|
|
26
|
+
function isUncheckedCardNumber(value, before) {
|
|
27
|
+
if (isRepeatedDigit(value) || /0{8}/.test(value)) return false;
|
|
28
|
+
if (value.startsWith("123456789")) return false;
|
|
29
|
+
if (value.startsWith("90071992547")) return false;
|
|
30
|
+
const looksLikeTimestamp = /^1[5-9]/.test(value);
|
|
31
|
+
return !looksLikeTimestamp || CARD_CUE.test(before.slice(-48));
|
|
32
|
+
}
|
|
33
|
+
function ibanChecksum(value) {
|
|
34
|
+
const iban = value.replace(/\s/g, "");
|
|
35
|
+
if (iban.length < 15 || iban.length > 34) return false;
|
|
36
|
+
const rearranged = iban.slice(4) + iban.slice(0, 4);
|
|
37
|
+
let remainder = 0;
|
|
38
|
+
for (const ch of rearranged) {
|
|
39
|
+
const code = ch.charCodeAt(0);
|
|
40
|
+
const n = code >= 65 ? String(code - 55) : ch;
|
|
41
|
+
for (const digit of n) remainder = (remainder * 10 + (digit.charCodeAt(0) - 48)) % 97;
|
|
42
|
+
}
|
|
43
|
+
return remainder === 1;
|
|
44
|
+
}
|
|
45
|
+
function isRoutableIPv4(value) {
|
|
46
|
+
return !value.startsWith("127.") && value !== "0.0.0.0" && value !== "255.255.255.255";
|
|
47
|
+
}
|
|
48
|
+
function isIPv6(value) {
|
|
49
|
+
const parts = value.split("::");
|
|
50
|
+
if (parts.length > 2) return false;
|
|
51
|
+
const hextets = parts.flatMap((p) => p === "" ? [] : p.split(":"));
|
|
52
|
+
if (!hextets.every((h) => /^[0-9A-Fa-f]{1,4}$/.test(h))) return false;
|
|
53
|
+
return parts.length === 1 ? hextets.length === 8 : hextets.length >= 3 && hextets.length <= 7;
|
|
54
|
+
}
|
|
55
|
+
function isEmail(value, before) {
|
|
56
|
+
if (/@\dx\./i.test(value)) return false;
|
|
57
|
+
const insideUrlCredentials = /:\/\/[^\s/]*$/.test(before);
|
|
58
|
+
return !insideUrlCredentials;
|
|
59
|
+
}
|
|
60
|
+
function looksLikePassword(value) {
|
|
61
|
+
if (!/\p{L}/u.test(value)) return false;
|
|
62
|
+
if (!/[\d@#$!%^&+?~]/.test(value.replace(/[*:]+$/, ""))) return false;
|
|
63
|
+
if (/^\$|\$\{|^process\.|^os\.|^env\.|^self\.|^this\./.test(value)) return false;
|
|
64
|
+
if (value.startsWith("@")) return false;
|
|
65
|
+
if (/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)+$/.test(value)) return false;
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
function isRealUrlPassword(value) {
|
|
69
|
+
return !/^(?:pass(?:word)?|pwd|secret|x{3,}|\*+|<.*>|\$.*|\{.*\}|%.*%)$/i.test(value);
|
|
70
|
+
}
|
|
71
|
+
var NOT_A_STREET = new RegExp(
|
|
72
|
+
[
|
|
73
|
+
String.raw`\b(?:Hard|Flash|Disk|Disc|Google|Shared|Zip|USB|SSD|Test|Pen|Thumb|Tape|Network) Drive\b`,
|
|
74
|
+
String.raw`\b(?:Supreme|District|Appeals|High|Circuit|Federal|Tennis|Basketball|Food) Court\b`,
|
|
75
|
+
String.raw`\b(?:First|Second|Third|Last|Best|Only|Right|Wrong|Same|Other|Easy|Simple|Better) (?:Place|Way)\b`,
|
|
76
|
+
String.raw`\b(?:Event|Run|Main|Game|For|While|Feedback|Training|Agent|Control|Render|Read|Inner|Outer) Loop\b`
|
|
77
|
+
].join("|")
|
|
78
|
+
);
|
|
79
|
+
function isStreetAddress(value) {
|
|
80
|
+
return !NOT_A_STREET.test(value);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// tools/pii/patterns.ts
|
|
84
|
+
var CONTEXT_CHARS = 256;
|
|
85
|
+
function re(flags) {
|
|
86
|
+
return (strings, ...fragments) => new RegExp(String.raw(strings, ...fragments), flags);
|
|
87
|
+
}
|
|
88
|
+
var QUOTES = "\"'`";
|
|
89
|
+
var WORD_START = String.raw`(?<![\w-])`;
|
|
90
|
+
var WORD_END = String.raw`(?![\w-])`;
|
|
91
|
+
var NUMBER_START = String.raw`(?<![\w.-])`;
|
|
92
|
+
var NUMBER_END = String.raw`(?![\w-]|\.\d)`;
|
|
93
|
+
var LABEL_START = String.raw`(?<![A-Za-z])`;
|
|
94
|
+
var GAP = String.raw`[\s:=${QUOTES}*#,|–-]{0,10}(?:(?:is|was|of|on|to|as)\s+){0,2}[${QUOTES}]?`;
|
|
95
|
+
var VALUE_END = String.raw`[\s${QUOTES}<>{}()\[\],;]`;
|
|
96
|
+
var PASSWORD_VALUE = String.raw`([^\s${QUOTES}<>{}()\[\],;]{6,64}?)(?=[.:]*(?:${VALUE_END}|$))`;
|
|
97
|
+
var MONTH = "(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|Jun(?:e)?|Jul(?:y)?|Aug(?:ust)?|Sep(?:t(?:ember)?)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)";
|
|
98
|
+
var ORDINAL = "(?:st|nd|rd|th)";
|
|
99
|
+
var DATE = "(?:" + [
|
|
100
|
+
String.raw`\d{4}[-/.]\d{1,2}[-/.]\d{1,2}`,
|
|
101
|
+
String.raw`\d{1,2}[-/.]\d{1,2}[-/.]\d{2,4}`,
|
|
102
|
+
String.raw`${MONTH}\.? \d{1,2}${ORDINAL}?,? \d{4}`,
|
|
103
|
+
String.raw`\d{1,2}${ORDINAL}? (?:of )?${MONTH}\.?,? \d{4}`
|
|
104
|
+
].join("|") + ")";
|
|
105
|
+
var COMPASS = "(?:[NSEW]|[NS][EW]|North|South|East|West)";
|
|
106
|
+
var STREET_TYPES = "(?:Street|St|Road|Rd|Avenue|Ave|Drive|Dr|Lane|Ln|Boulevard|Blvd|Court|Ct|Circle|Cir|Way|Place|Pl|Terrace|Ter|Parkway|Pkwy|Highway|Hwy|Trail|Trl|Crescent|Cres|Loop|Pike)";
|
|
107
|
+
var STREET_NAME_WORD = String.raw`(?:[A-Z][\p{L}'.-]*|\d{1,3}${ORDINAL}?)`;
|
|
108
|
+
var UNIT = String.raw`(?:,? (?:Apt|Apartment|Suite|Ste|Unit|Floor|Fl)\.? ?#?[A-Za-z0-9-]+|,? #[A-Za-z0-9-]+)`;
|
|
109
|
+
var PROVIDER_KEYS = [
|
|
110
|
+
"sk-[A-Za-z0-9_-]{20,}",
|
|
111
|
+
// OpenAI, Anthropic, Morph
|
|
112
|
+
"morph-[A-Za-z0-9_-]{20,}",
|
|
113
|
+
"(?:sk|pk|rk)_(?:live|test)_[A-Za-z0-9]{16,}",
|
|
114
|
+
// Stripe
|
|
115
|
+
"gh[pousr]_[A-Za-z0-9]{36,}",
|
|
116
|
+
// GitHub
|
|
117
|
+
"github_pat_[A-Za-z0-9_]{40,}",
|
|
118
|
+
"glpat-[A-Za-z0-9_-]{20,}",
|
|
119
|
+
// GitLab
|
|
120
|
+
"(?:AKIA|ASIA)[A-Z0-9]{16}",
|
|
121
|
+
// AWS access key id
|
|
122
|
+
"xox[abeoprs]-[A-Za-z0-9-]{10,}",
|
|
123
|
+
// Slack
|
|
124
|
+
"AIza[A-Za-z0-9_-]{35}",
|
|
125
|
+
// Google
|
|
126
|
+
"hf_[A-Za-z0-9]{30,}",
|
|
127
|
+
// Hugging Face
|
|
128
|
+
"npm_[A-Za-z0-9]{36}"
|
|
129
|
+
].join("|");
|
|
130
|
+
var PII_PATTERNS = [
|
|
131
|
+
// --- Secrets -------------------------------------------------------------------
|
|
132
|
+
{
|
|
133
|
+
// PEM private key block. The body is capped (a 16384-bit RSA key is about 13 KB).
|
|
134
|
+
type: "SECRET",
|
|
135
|
+
regex: /-----BEGIN [A-Z ]{0,40}PRIVATE KEY-----[\s\S]{0,20000}?-----END [A-Z ]{0,40}PRIVATE KEY-----/g
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
// JSON Web Token: three base64url parts, the first two starting `eyJ`
|
|
139
|
+
type: "SECRET",
|
|
140
|
+
regex: /\beyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
type: "SECRET",
|
|
144
|
+
regex: re("g")`(?<![A-Za-z0-9_-])(?:${PROVIDER_KEYS})(?![A-Za-z0-9_-])`
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
// `Authorization: Bearer <token>`
|
|
148
|
+
type: "SECRET",
|
|
149
|
+
regex: /\bBearer\s+([A-Za-z0-9._~+/-]{20,}=*)/g,
|
|
150
|
+
group: 1
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
// Password in a URL: scheme://user:password@host
|
|
154
|
+
type: "SECRET",
|
|
155
|
+
regex: /\b[a-z][a-z0-9+.-]{0,30}:\/\/[^\s:@/]{1,256}:([^\s@/]{1,256})@/gi,
|
|
156
|
+
group: 1,
|
|
157
|
+
validate: isRealUrlPassword
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
// A value after a password label: `Password: hunter2!`, `the new password Rainbow@2023`
|
|
161
|
+
type: "SECRET",
|
|
162
|
+
regex: re("gi")`${WORD_START}(?:password|passphrase|passcode|pwd)${WORD_END}${GAP}${PASSWORD_VALUE}`,
|
|
163
|
+
group: 1,
|
|
164
|
+
validate: looksLikePassword
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
// `pass:` and `secret:` are common words, so they need an explicit separator
|
|
168
|
+
type: "SECRET",
|
|
169
|
+
regex: re("gi")`${WORD_START}(?:pass|secret)\s?[:=]\s?[${QUOTES}]?${PASSWORD_VALUE}`,
|
|
170
|
+
group: 1,
|
|
171
|
+
validate: looksLikePassword
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
// `login: alice / hunter2`
|
|
175
|
+
type: "SECRET",
|
|
176
|
+
regex: re("gi")`${WORD_START}(?:login|creds|credentials?)(?: (?:info(?:rmation)?|details))?\s?[:=]\s?(\S{1,128}\s{0,8}\/\s{0,8}\S{1,128})`,
|
|
177
|
+
group: 1
|
|
178
|
+
},
|
|
179
|
+
// --- Contact ---------------------------------------------------------------------
|
|
180
|
+
{
|
|
181
|
+
type: "EMAIL",
|
|
182
|
+
regex: /(?<![A-Za-z0-9._%+-])[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}(?![A-Za-z0-9])/g,
|
|
183
|
+
validate: isEmail
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
// International: +country code, then groups. +44 20 7946 0958
|
|
187
|
+
type: "PHONE",
|
|
188
|
+
regex: /(?<![\w.+])\+\d{1,3}[ .-]?(?:\(\d{1,4}\)[ .-]?)?\d{1,4}(?:[ .-]?\d{2,4}){1,4}(?!\w)/g,
|
|
189
|
+
validate: (value) => digitCount(value) >= 8 && digitCount(value) <= 15
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
// North American: (415) 555-0199, 415-555-0199, 415.555.0199
|
|
193
|
+
type: "PHONE",
|
|
194
|
+
regex: re("g")`${NUMBER_START}(?:\(\d{3}\)[ .-]?|\d{3}[.-])\d{3}[ .-]\d{4}${NUMBER_END}`
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
// National formats with a trunk zero or a bracketed area code:
|
|
198
|
+
// 0371-52754478, 043.0592407, (352) 9324865, 5607 341-2596
|
|
199
|
+
type: "PHONE",
|
|
200
|
+
regex: re("g")`${NUMBER_START}(?:0\d{2,4}[ .-]\d{6,8}|\(\d{3}\)[ .-]{0,2}\d{7}|\d{4}[ -]\d{3}-\d{4})${NUMBER_END}`
|
|
201
|
+
},
|
|
202
|
+
// --- Identifiers with a recognizable shape ---------------------------------------
|
|
203
|
+
{
|
|
204
|
+
// US SSN: 3-2-4 with one separator throughout, excluding ranges that are never issued
|
|
205
|
+
type: "SSN",
|
|
206
|
+
regex: re("g")`${NUMBER_START}(?!000|666|9\d\d)\d{3}([ .-])(?!00)\d{2}\1(?!0000)\d{4}${NUMBER_END}`
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
// Any digit run of card length, in any grouping, that passes the Luhn checksum
|
|
210
|
+
type: "CREDIT_CARD",
|
|
211
|
+
regex: re("g")`${WORD_START}\d(?:[ -]?\d){12,18}${WORD_END}`,
|
|
212
|
+
validate: luhn
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
// Written in card groups (4-4-4-4, or 4-6-5 for Amex): the shape is evidence enough,
|
|
216
|
+
// so a mistyped or masked-test number is redacted too.
|
|
217
|
+
type: "CREDIT_CARD",
|
|
218
|
+
regex: re("g")`${WORD_START}(?:\d{4}[ -]\d{4}[ -]\d{4}[ -]\d{4}|\d{4}[ -]\d{6}[ -]\d{4,5})${WORD_END}`,
|
|
219
|
+
validate: (value) => /[1-9]/.test(value)
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
// A bare 16-digit number that fails Luhn: kept unless it looks like a timestamp or a placeholder
|
|
223
|
+
type: "CREDIT_CARD",
|
|
224
|
+
regex: re("g")`${NUMBER_START}\d{16}${NUMBER_END}`,
|
|
225
|
+
validate: isUncheckedCardNumber
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
// GB29 NWBK 6016 1331 9268 19
|
|
229
|
+
type: "IBAN",
|
|
230
|
+
regex: /(?<!\w)[A-Z]{2}\d{2}(?: ?[A-Z0-9]{4}){2,7}(?: ?[A-Z0-9]{1,3})?(?!\w)/g,
|
|
231
|
+
validate: ibanChecksum
|
|
232
|
+
},
|
|
233
|
+
// --- Identifiers that need a label: the label is what makes the value sensitive ---
|
|
234
|
+
{
|
|
235
|
+
// `SSN: 123456789`, `social security number is 123 45 6789`
|
|
236
|
+
type: "SSN",
|
|
237
|
+
regex: re("gi")`${LABEL_START}(?:SSN|social security(?: (?:number|no\.?|#))?)${GAP}(\d[\d .-]{7,14}\d)${WORD_END}`,
|
|
238
|
+
group: 1
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
// Swiss AHV number (starts 756), with or without dots
|
|
242
|
+
type: "SSN",
|
|
243
|
+
regex: re("g")`${NUMBER_START}756(?:\.?\d{4}){2}(?:\.?\d{2})?${NUMBER_END}|${NUMBER_START}756\d{8}${NUMBER_END}`
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
// `account number: 12345678`, `routing no. 021000021`
|
|
247
|
+
type: "ACCOUNT_NUMBER",
|
|
248
|
+
regex: re("gi")`${LABEL_START}(?:account|acct|routing|a\/c)[ _-]?(?:number|no\.?|num|nr|#)${GAP}([A-Z]{0,4}-?\d[\d -]{4,24}\d)${WORD_END}`,
|
|
249
|
+
group: 1
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
// `MRN: A-448291`
|
|
253
|
+
type: "MEDICAL_RECORD",
|
|
254
|
+
regex: re("gi")`${LABEL_START}(?:MRN|medical records?(?: (?:number|no\.?|num|#))?)${GAP}([A-Za-z0-9][A-Za-z0-9-]{3,39})${WORD_END}`,
|
|
255
|
+
group: 1,
|
|
256
|
+
validate: (value) => /\d/.test(value)
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
// `DOB: 1990-04-12`, `born on April 12th, 1990`
|
|
260
|
+
type: "DATE_OF_BIRTH",
|
|
261
|
+
regex: re("gi")`${LABEL_START}(?:d\.?o\.?b\.?|date[ _-]?of[ _-]?birth|birth[ _-]?date|birthday|born)${GAP}(${DATE})${WORD_END}`,
|
|
262
|
+
group: 1
|
|
263
|
+
},
|
|
264
|
+
// --- Addresses -------------------------------------------------------------------
|
|
265
|
+
{
|
|
266
|
+
// House number, optional compass point, 1 to 4 name words, street type, optional unit.
|
|
267
|
+
// Case-sensitive on purpose: `42 Wallaby Way` matches, `2 simple ways` does not.
|
|
268
|
+
type: "LOCATION",
|
|
269
|
+
regex: re("gu")`(?<![\w.#-])\d{1,6}[A-Za-z]?(?: ${COMPASS}\.?)?(?: ${STREET_NAME_WORD}){1,4} ${STREET_TYPES}\b\.?${UNIT}?`,
|
|
270
|
+
validate: isStreetAddress
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
// `PO Box 1234`, `P.O. Box 9`
|
|
274
|
+
type: "LOCATION",
|
|
275
|
+
regex: /(?<!\w)P\.? ?O\.? ?Box \d+\b/gi
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
// Numbered street with no house number in front: `W 2nd Street`, `5th Avenue`
|
|
279
|
+
type: "LOCATION",
|
|
280
|
+
regex: re("g")`(?<![\w.#-])(?:${COMPASS}\.? )?\d{1,3}${ORDINAL} ${STREET_TYPES}\b\.?`
|
|
281
|
+
},
|
|
282
|
+
// --- Network ---------------------------------------------------------------------
|
|
283
|
+
{
|
|
284
|
+
// 00:1A:2B:3C:4D:5E, with one separator throughout
|
|
285
|
+
type: "MAC_ADDRESS",
|
|
286
|
+
regex: /(?<![\w:-])[0-9A-Fa-f]{2}([:-])(?:[0-9A-Fa-f]{2}\1){4}[0-9A-Fa-f]{2}(?![\w:-])/g
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
// IPv4, each octet 0 to 255
|
|
290
|
+
type: "IP_ADDRESS",
|
|
291
|
+
regex: /(?<![\w.])(?:(?:25[0-5]|2[0-4]\d|1?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|1?\d?\d)(?!\w|\.\d)/g,
|
|
292
|
+
validate: isRoutableIPv4
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
// IPv6, full or `::`-compressed; the validator counts the hextets
|
|
296
|
+
type: "IP_ADDRESS",
|
|
297
|
+
regex: /(?<![\w:.])(?:[0-9A-Fa-f]{1,4}:|::)[0-9A-Fa-f:]{2,37}(?![\w:])/g,
|
|
298
|
+
validate: isIPv6
|
|
299
|
+
}
|
|
300
|
+
];
|
|
301
|
+
|
|
302
|
+
export { CONTEXT_CHARS, PII_PATTERNS };
|