@morphllm/morphsdk 0.2.203 → 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-NDUC7OV6.cjs → chunk-3HAHJYZQ.cjs} +3 -3
- package/dist/{chunk-AJBZA23L.js → chunk-3JROKKS4.js} +1 -1
- package/dist/{chunk-J56Q6C4Y.js → chunk-43JBUEIX.js} +1 -1
- package/dist/{chunk-E7FLETFO.js → chunk-4TZBUFVP.js} +1 -1
- package/dist/{chunk-EI2M567U.js → chunk-564XJOQP.js} +1 -1
- package/dist/{chunk-7NA7X7W2.cjs → chunk-5H3FKFOI.cjs} +8 -8
- package/dist/{chunk-65W4I66Q.cjs → chunk-5TTZQF4X.cjs} +16 -9
- package/dist/chunk-6HAYJA6M.cjs +317 -0
- package/dist/chunk-DLYDIYDK.cjs +305 -0
- package/dist/{chunk-LLQH6CCB.js → chunk-DYCMPDPV.js} +5 -3
- package/dist/{chunk-66THRMD7.js → chunk-DZP7BR66.js} +16 -12
- package/dist/chunk-E63OPKP7.js +96 -0
- package/dist/{chunk-IUM6CQYX.js → chunk-EJ6ID24K.js} +1 -1
- package/dist/{chunk-AFF6XYKL.cjs → chunk-F633IVQA.cjs} +28 -8
- package/dist/{chunk-GIQAIHUI.js → chunk-FGA6EYC2.js} +29 -6
- package/dist/{chunk-GDFPZ3NJ.js → chunk-G4RODMXA.js} +1 -1
- package/dist/{chunk-B3FD67F2.cjs → chunk-GUNGJC6X.cjs} +3 -3
- package/dist/{chunk-OCCGJ4S6.js → chunk-GYE3FY6Z.js} +1 -1
- package/dist/{chunk-OXXMTDOY.cjs → chunk-HNMEBYIS.cjs} +2 -2
- package/dist/{chunk-JNQKQKHS.cjs → chunk-HP3PCOTW.cjs} +3 -3
- package/dist/{chunk-KLVJIC2O.js → chunk-IGXNLXPN.js} +10 -3
- package/dist/{chunk-UUCRWJJR.cjs → chunk-JHC2R3HU.cjs} +20 -16
- package/dist/{chunk-N7UKZ5X7.js → chunk-JVMIFGZY.js} +4 -3
- package/dist/chunk-KF6S3EPJ.cjs +100 -0
- package/dist/{chunk-EZ2OFDBJ.js → chunk-L5SCKZVK.js} +10 -5
- package/dist/{chunk-E3XNKAMI.js → chunk-LQST3NW2.js} +1 -1
- package/dist/{chunk-GSUQGDCL.cjs → chunk-MMX5PUGC.cjs} +47 -40
- package/dist/{chunk-JBTR3FQD.cjs → chunk-NJWOWXUR.cjs} +8 -6
- package/dist/{chunk-HMLYJVZM.cjs → chunk-OCKEEEYE.cjs} +30 -7
- package/dist/chunk-OENJO7YW.js +306 -0
- package/dist/chunk-OKLAYEBC.cjs +2 -0
- package/dist/{chunk-H3HRSRR5.js → chunk-OX5GN2KB.js} +24 -4
- package/dist/{chunk-JUGNTIVU.js → chunk-OYBOP47A.js} +13 -1
- package/dist/chunk-OZHCHPIE.js +1 -0
- package/dist/{chunk-TL34BLQD.cjs → chunk-QT5LGZG3.cjs} +1 -1
- package/dist/chunk-R3TUE7O2.cjs +107 -0
- package/dist/{chunk-AXEKIRRY.js → chunk-SOQYE5A4.js} +27 -20
- package/dist/{chunk-KSZYOX6S.cjs → chunk-ST2OXLT5.cjs} +8 -8
- package/dist/{chunk-2UIOCSVJ.js → chunk-TH4MG73B.js} +1 -1
- package/dist/{chunk-NLACTMZT.js → chunk-U4PYAGNR.js} +1 -1
- package/dist/{chunk-VDFLPO7B.cjs → chunk-UHFVWYSP.cjs} +14 -2
- package/dist/{chunk-4R5MDGL6.cjs → chunk-UKBSXYKE.cjs} +3 -3
- package/dist/{chunk-S6QBPXBI.cjs → chunk-UZMMJ47A.cjs} +5 -5
- package/dist/{chunk-ODY2NKQU.cjs → chunk-VYE7O4FM.cjs} +5 -4
- package/dist/{chunk-JOZC4T6C.cjs → chunk-WIYVT4UO.cjs} +16 -11
- package/dist/{chunk-OM5ZSXQW.cjs → chunk-WJHHO24M.cjs} +2 -2
- package/dist/{chunk-ZLG2M2I4.cjs → chunk-YAUXTFIN.cjs} +2 -2
- package/dist/{chunk-JY6COF3X.js → chunk-YJUCGZNN.js} +1 -1
- package/dist/chunk-ZX6T3LNG.js +302 -0
- package/dist/{client-BWhi-vSj.d.ts → client-DSXbcxII.d.ts} +10 -1
- package/dist/client.cjs +27 -23
- package/dist/client.d.ts +4 -2
- package/dist/client.js +26 -22
- package/dist/core/client.cjs +9 -5
- package/dist/core/client.d.ts +8 -0
- package/dist/core/client.js +8 -4
- package/dist/core/error.cjs +4 -4
- package/dist/core/error.js +3 -3
- package/dist/core/index.cjs +10 -6
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +8 -4
- package/dist/core/resource.d.ts +2 -0
- package/dist/edge.cjs +43 -31
- package/dist/edge.d.ts +3 -0
- package/dist/edge.js +11 -7
- package/dist/guard-CvW03v4u.d.ts +59 -0
- package/dist/index.cjs +73 -48
- package/dist/index.d.ts +6 -2
- package/dist/index.js +30 -25
- package/dist/modelrouter/core.cjs +14 -10
- package/dist/modelrouter/core.d.ts +2 -0
- package/dist/modelrouter/core.js +9 -5
- package/dist/modelrouter/index.cjs +14 -10
- package/dist/modelrouter/index.d.ts +2 -0
- package/dist/modelrouter/index.js +9 -5
- package/dist/modelrouter/types.d.ts +5 -0
- package/dist/subagents/anthropic.cjs +16 -12
- package/dist/subagents/anthropic.d.ts +3 -1
- package/dist/subagents/anthropic.js +15 -11
- package/dist/subagents/index.d.ts +3 -1
- package/dist/subagents/prompts.d.ts +3 -1
- package/dist/subagents/types.d.ts +3 -1
- package/dist/subagents/vercel.cjs +16 -12
- package/dist/subagents/vercel.d.ts +3 -1
- package/dist/subagents/vercel.js +15 -11
- package/dist/tools/compact/core.cjs +10 -6
- package/dist/tools/compact/core.d.ts +2 -0
- package/dist/tools/compact/core.js +9 -5
- package/dist/tools/compact/index.cjs +12 -8
- package/dist/tools/compact/index.d.ts +3 -1
- package/dist/tools/compact/index.js +10 -6
- package/dist/tools/compact/types.d.ts +4 -4
- package/dist/tools/fastapply/anthropic.cjs +16 -12
- package/dist/tools/fastapply/anthropic.d.ts +2 -0
- package/dist/tools/fastapply/anthropic.js +11 -7
- package/dist/tools/fastapply/apply.cjs +12 -8
- package/dist/tools/fastapply/apply.d.ts +2 -0
- package/dist/tools/fastapply/apply.js +6 -2
- package/dist/tools/fastapply/core.cjs +18 -14
- package/dist/tools/fastapply/core.d.ts +3 -0
- package/dist/tools/fastapply/core.js +10 -6
- package/dist/tools/fastapply/index.cjs +22 -18
- package/dist/tools/fastapply/index.d.ts +2 -0
- package/dist/tools/fastapply/index.js +13 -9
- package/dist/tools/fastapply/openai.cjs +17 -13
- package/dist/tools/fastapply/openai.d.ts +2 -0
- package/dist/tools/fastapply/openai.js +11 -7
- package/dist/tools/fastapply/types.d.ts +9 -4
- package/dist/tools/fastapply/vercel.cjs +15 -11
- package/dist/tools/fastapply/vercel.d.ts +2 -0
- package/dist/tools/fastapply/vercel.js +11 -7
- package/dist/tools/index.cjs +22 -18
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.js +13 -9
- 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 +5 -5
- package/dist/tools/utils/resilience.js +2 -2
- package/dist/tools/warp_grep/agent/parser.d.ts +2 -0
- package/dist/tools/warp_grep/agent/runner.cjs +9 -5
- package/dist/tools/warp_grep/agent/runner.d.ts +2 -0
- package/dist/tools/warp_grep/agent/runner.js +7 -3
- package/dist/tools/warp_grep/agent/types.d.ts +4 -0
- package/dist/tools/warp_grep/anthropic.cjs +21 -17
- package/dist/tools/warp_grep/anthropic.d.ts +3 -1
- package/dist/tools/warp_grep/anthropic.js +15 -11
- package/dist/tools/warp_grep/client.cjs +21 -17
- package/dist/tools/warp_grep/client.d.ts +3 -1
- package/dist/tools/warp_grep/client.js +14 -10
- package/dist/tools/warp_grep/gemini.cjs +22 -18
- package/dist/tools/warp_grep/gemini.d.ts +3 -1
- package/dist/tools/warp_grep/gemini.js +15 -11
- package/dist/tools/warp_grep/harness.cjs +16 -16
- package/dist/tools/warp_grep/harness.d.ts +2 -0
- package/dist/tools/warp_grep/harness.js +4 -4
- package/dist/tools/warp_grep/index.cjs +30 -26
- package/dist/tools/warp_grep/index.d.ts +3 -1
- package/dist/tools/warp_grep/index.js +17 -13
- package/dist/tools/warp_grep/openai.cjs +22 -18
- package/dist/tools/warp_grep/openai.d.ts +3 -1
- package/dist/tools/warp_grep/openai.js +15 -11
- package/dist/tools/warp_grep/providers/code_storage_http.d.ts +3 -1
- package/dist/tools/warp_grep/providers/local.cjs +3 -3
- package/dist/tools/warp_grep/providers/local.js +2 -2
- package/dist/tools/warp_grep/providers/remote.d.ts +3 -1
- package/dist/tools/warp_grep/vercel.cjs +22 -18
- package/dist/tools/warp_grep/vercel.d.ts +3 -1
- package/dist/tools/warp_grep/vercel.js +15 -11
- package/dist/{types-DxZLPogx.d.ts → types-BKhXjDCB.d.ts} +6 -1
- package/dist/version.cjs +2 -2
- package/dist/version.js +1 -1
- package/package.json +11 -2
- package/dist/{chunk-OOEORM7H.cjs → chunk-E6V75LI6.cjs} +1 -1
- package/dist/{chunk-OSL4CNSO.js → chunk-TLMAMVAW.js} +1 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkVL4QNALG_cjs = require('./chunk-VL4QNALG.cjs');
|
|
4
|
-
var
|
|
4
|
+
var chunkKF6S3EPJ_cjs = require('./chunk-KF6S3EPJ.cjs');
|
|
5
|
+
var chunkQT5LGZG3_cjs = require('./chunk-QT5LGZG3.cjs');
|
|
5
6
|
var diff = require('diff');
|
|
6
7
|
var OpenAI = require('openai');
|
|
7
8
|
|
|
@@ -250,6 +251,17 @@ function countChanges(original, modified) {
|
|
|
250
251
|
};
|
|
251
252
|
}
|
|
252
253
|
async function callMorphAPI(originalCode, codeEdit, instructions, filepath, config) {
|
|
254
|
+
const pii = chunkKF6S3EPJ_cjs.resolvePIIGuard(config.redactPII)?.session();
|
|
255
|
+
if (pii) {
|
|
256
|
+
const [code, edit, instr] = await Promise.all([
|
|
257
|
+
pii.redact(originalCode),
|
|
258
|
+
pii.redact(codeEdit),
|
|
259
|
+
pii.redact(instructions)
|
|
260
|
+
]);
|
|
261
|
+
chunkVL4QNALG_cjs.logger.debug("FastApply", "pii_redacted", { values: pii.size });
|
|
262
|
+
const merged = await callMorphAPI(code, edit, instr, filepath, { ...config, redactPII: void 0 });
|
|
263
|
+
return { ...merged, content: pii.restoreStrict(merged.content) };
|
|
264
|
+
}
|
|
253
265
|
const apiKey = config.morphApiKey || (typeof process !== "undefined" ? process.env?.MORPH_API_KEY : void 0);
|
|
254
266
|
const apiUrl = config.morphApiUrl || DEFAULT_API_URL;
|
|
255
267
|
const useLarge = config.large ?? (typeof process !== "undefined" ? process.env?.MORPH_LARGE_APPLY !== "false" : true);
|
|
@@ -286,7 +298,7 @@ async function callMorphAPI(originalCode, codeEdit, instructions, filepath, conf
|
|
|
286
298
|
timeout,
|
|
287
299
|
maxRetries: config.retryConfig?.maxRetries ?? 3,
|
|
288
300
|
defaultHeaders: {
|
|
289
|
-
"X-Morph-SDK-Version":
|
|
301
|
+
"X-Morph-SDK-Version": chunkQT5LGZG3_cjs.SDK_VERSION,
|
|
290
302
|
...anchorPlan ? { "X-Morph-Apply-Context": "extralong" } : {}
|
|
291
303
|
}
|
|
292
304
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkJHC2R3HU_cjs = require('./chunk-JHC2R3HU.cjs');
|
|
4
4
|
var chunkTPZHMD7J_cjs = require('./chunk-TPZHMD7J.cjs');
|
|
5
5
|
|
|
6
6
|
// subagents/anthropic.ts
|
|
@@ -28,7 +28,7 @@ function createExploreSubagent(config) {
|
|
|
28
28
|
if (!config.repoRoot) {
|
|
29
29
|
throw new Error("repoRoot is required for Explore subagent");
|
|
30
30
|
}
|
|
31
|
-
const warpGrep = new
|
|
31
|
+
const warpGrep = new chunkJHC2R3HU_cjs.WarpGrepClient({
|
|
32
32
|
morphApiKey: config.morphApiKey
|
|
33
33
|
});
|
|
34
34
|
const thoroughness = config.thoroughness ?? "medium";
|
|
@@ -103,7 +103,7 @@ function createExploreSubagent(config) {
|
|
|
103
103
|
toolResults.push({
|
|
104
104
|
type: "tool_result",
|
|
105
105
|
tool_use_id: block.id,
|
|
106
|
-
content:
|
|
106
|
+
content: chunkJHC2R3HU_cjs.formatResult(warpResult)
|
|
107
107
|
});
|
|
108
108
|
} else if (block.name === "send_message") {
|
|
109
109
|
const input = block.input;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkEJTL2BOZ_cjs = require('./chunk-EJTL2BOZ.cjs');
|
|
4
|
-
var
|
|
4
|
+
var chunkJHC2R3HU_cjs = require('./chunk-JHC2R3HU.cjs');
|
|
5
5
|
var ai = require('ai');
|
|
6
6
|
var zod = require('zod');
|
|
7
7
|
|
|
@@ -17,7 +17,7 @@ var warpGrepJsonSchema = {
|
|
|
17
17
|
additionalProperties: false
|
|
18
18
|
};
|
|
19
19
|
async function execute(input, config) {
|
|
20
|
-
return
|
|
20
|
+
return chunkJHC2R3HU_cjs.executeToolCall(input, config);
|
|
21
21
|
}
|
|
22
22
|
function createWarpGrepTool(config) {
|
|
23
23
|
const schema = config.inputSchema ?? zod.z.object({
|
|
@@ -28,7 +28,7 @@ function createWarpGrepTool(config) {
|
|
|
28
28
|
inputSchema: schema,
|
|
29
29
|
execute: async (params) => {
|
|
30
30
|
const steps = [];
|
|
31
|
-
const generator =
|
|
31
|
+
const generator = chunkJHC2R3HU_cjs.executeToolCallStreaming(params, config);
|
|
32
32
|
let result;
|
|
33
33
|
for (; ; ) {
|
|
34
34
|
const { value, done } = await generator.next();
|
|
@@ -52,7 +52,7 @@ function createWarpGrepTool(config) {
|
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
function createGitHubSearchTool(config) {
|
|
55
|
-
const client = new
|
|
55
|
+
const client = new chunkJHC2R3HU_cjs.WarpGrepClient(config);
|
|
56
56
|
return ai.tool({
|
|
57
57
|
description: chunkEJTL2BOZ_cjs.GITHUB_SEARCH_DESCRIPTION,
|
|
58
58
|
inputSchema: zod.z.object({
|
|
@@ -89,7 +89,7 @@ function createGitHubReadFileTool(config) {
|
|
|
89
89
|
branch: zod.z.string().optional().describe("Branch to read from (defaults to repo default branch)")
|
|
90
90
|
}),
|
|
91
91
|
execute: async (params) => {
|
|
92
|
-
const result = await
|
|
92
|
+
const result = await chunkJHC2R3HU_cjs.executeGitHubReadFile(params, config);
|
|
93
93
|
if (!result.success) {
|
|
94
94
|
throw new Error(`GitHub read file failed: ${result.error}`);
|
|
95
95
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkF633IVQA_cjs = require('./chunk-F633IVQA.cjs');
|
|
4
4
|
|
|
5
5
|
// tools/compact/utils.ts
|
|
6
|
-
async function compactFileContexts(files, query, apiKey, apiUrl, maxTokens = 1e4, maxConcurrency = 3) {
|
|
6
|
+
async function compactFileContexts(files, query, apiKey, apiUrl, maxTokens = 1e4, maxConcurrency = 3, redactPII) {
|
|
7
7
|
const totalLength = files.reduce((sum, file) => sum + file.content.length, 0);
|
|
8
8
|
const estimatedTokens = totalLength / 3;
|
|
9
9
|
if (estimatedTokens <= maxTokens) {
|
|
@@ -11,9 +11,10 @@ async function compactFileContexts(files, query, apiKey, apiUrl, maxTokens = 1e4
|
|
|
11
11
|
}
|
|
12
12
|
let compressionRatio = maxTokens / estimatedTokens;
|
|
13
13
|
compressionRatio = Math.max(0.3, Math.min(0.99, compressionRatio));
|
|
14
|
-
const client = new
|
|
14
|
+
const client = new chunkF633IVQA_cjs.CompactClient({
|
|
15
15
|
morphApiKey: apiKey,
|
|
16
|
-
morphApiUrl: apiUrl
|
|
16
|
+
morphApiUrl: apiUrl,
|
|
17
|
+
redactPII
|
|
17
18
|
});
|
|
18
19
|
const results = [];
|
|
19
20
|
const inProgress = /* @__PURE__ */ new Set();
|
|
@@ -1,30 +1,35 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk5TTZQF4X_cjs = require('./chunk-5TTZQF4X.cjs');
|
|
4
4
|
var chunkVL4QNALG_cjs = require('./chunk-VL4QNALG.cjs');
|
|
5
|
-
var
|
|
5
|
+
var chunkWJHHO24M_cjs = require('./chunk-WJHHO24M.cjs');
|
|
6
6
|
var chunkAWFZKS27_cjs = require('./chunk-AWFZKS27.cjs');
|
|
7
7
|
|
|
8
8
|
// modelrouter/core.ts
|
|
9
9
|
var DEFAULT_API_URL = "https://api.morphllm.com";
|
|
10
10
|
var DEFAULT_TIMEOUT = 5e3;
|
|
11
11
|
function resolveClient(clientOrConfig) {
|
|
12
|
-
if (clientOrConfig instanceof
|
|
13
|
-
return new
|
|
12
|
+
if (clientOrConfig instanceof chunk5TTZQF4X_cjs.MorphAPIClient) return clientOrConfig;
|
|
13
|
+
return new chunk5TTZQF4X_cjs.MorphAPIClient({
|
|
14
14
|
apiKey: clientOrConfig.apiKey,
|
|
15
15
|
baseURL: clientOrConfig.apiUrl ?? DEFAULT_API_URL,
|
|
16
16
|
timeout: clientOrConfig.timeout ?? DEFAULT_TIMEOUT,
|
|
17
17
|
retryConfig: clientOrConfig.retryConfig,
|
|
18
|
-
debug: clientOrConfig.debug
|
|
18
|
+
debug: clientOrConfig.debug,
|
|
19
|
+
redactPII: clientOrConfig.redactPII
|
|
19
20
|
});
|
|
20
21
|
}
|
|
22
|
+
async function redactInput(client, input) {
|
|
23
|
+
const pii = client.pii?.session();
|
|
24
|
+
return pii && typeof input === "string" ? await pii.redact(input) : input;
|
|
25
|
+
}
|
|
21
26
|
var BaseRouter = class extends chunkAWFZKS27_cjs.APIResource {
|
|
22
27
|
provider;
|
|
23
28
|
timeout;
|
|
24
29
|
constructor(provider, clientOrConfig = {}) {
|
|
25
30
|
super(resolveClient(clientOrConfig));
|
|
26
31
|
this.provider = provider;
|
|
27
|
-
const cfg = clientOrConfig instanceof
|
|
32
|
+
const cfg = clientOrConfig instanceof chunk5TTZQF4X_cjs.MorphAPIClient ? {} : clientOrConfig;
|
|
28
33
|
this.timeout = cfg.timeout ?? DEFAULT_TIMEOUT;
|
|
29
34
|
}
|
|
30
35
|
/** Throw the historical "API key is required" message when no key is resolvable. */
|
|
@@ -39,11 +44,11 @@ var BaseRouter = class extends chunkAWFZKS27_cjs.APIResource {
|
|
|
39
44
|
async route(provider, input) {
|
|
40
45
|
try {
|
|
41
46
|
return await this._client.post(`/v1/router/${provider}`, {
|
|
42
|
-
body: { input: input.input, mode: input.mode || "balanced" },
|
|
47
|
+
body: { input: await redactInput(this._client, input.input), mode: input.mode || "balanced" },
|
|
43
48
|
timeout: this.timeout
|
|
44
49
|
});
|
|
45
50
|
} catch (error) {
|
|
46
|
-
if (error instanceof
|
|
51
|
+
if (error instanceof chunkWJHHO24M_cjs.MorphError) {
|
|
47
52
|
throw new Error(`Router API error (${error.statusCode}): ${error.message}`);
|
|
48
53
|
}
|
|
49
54
|
throw error;
|
|
@@ -130,7 +135,7 @@ var RouterClassifier = class extends chunkAWFZKS27_cjs.APIResource {
|
|
|
130
135
|
timeout;
|
|
131
136
|
constructor(clientOrConfig = {}) {
|
|
132
137
|
super(resolveClient(clientOrConfig));
|
|
133
|
-
const cfg = clientOrConfig instanceof
|
|
138
|
+
const cfg = clientOrConfig instanceof chunk5TTZQF4X_cjs.MorphAPIClient ? {} : clientOrConfig;
|
|
134
139
|
this.timeout = cfg.timeout ?? DEFAULT_TIMEOUT;
|
|
135
140
|
}
|
|
136
141
|
/** Classify an input across the requested axes (all three by default). */
|
|
@@ -143,7 +148,7 @@ var RouterClassifier = class extends chunkAWFZKS27_cjs.APIResource {
|
|
|
143
148
|
chunkVL4QNALG_cjs.logger.debug("RouterClassifier", "request", { classes: input.classes ?? "all" });
|
|
144
149
|
try {
|
|
145
150
|
const res = await this._client.post("/v1/router/classify", {
|
|
146
|
-
body: { input: input.input, ...input.classes ? { classes: input.classes } : {} },
|
|
151
|
+
body: { input: await redactInput(this._client, input.input), ...input.classes ? { classes: input.classes } : {} },
|
|
147
152
|
timeout: this.timeout
|
|
148
153
|
});
|
|
149
154
|
chunkVL4QNALG_cjs.logger.debug("RouterClassifier", "classified", {
|
|
@@ -153,7 +158,7 @@ var RouterClassifier = class extends chunkAWFZKS27_cjs.APIResource {
|
|
|
153
158
|
});
|
|
154
159
|
return res.classifications;
|
|
155
160
|
} catch (error) {
|
|
156
|
-
if (error instanceof
|
|
161
|
+
if (error instanceof chunkWJHHO24M_cjs.MorphError) {
|
|
157
162
|
throw new Error(`Router API error (${error.statusCode}): ${error.message}`);
|
|
158
163
|
}
|
|
159
164
|
throw error;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkQT5LGZG3_cjs = require('./chunk-QT5LGZG3.cjs');
|
|
4
4
|
|
|
5
5
|
// tools/utils/resilience.ts
|
|
6
6
|
var DEFAULT_RETRY_CONFIG = {
|
|
@@ -21,7 +21,7 @@ async function fetchWithRetry(url, options, retryConfig = {}) {
|
|
|
21
21
|
} = retryConfig;
|
|
22
22
|
let lastError = null;
|
|
23
23
|
let delay = initialDelay;
|
|
24
|
-
options = { ...options, headers: { "X-Morph-SDK-Version":
|
|
24
|
+
options = { ...options, headers: { "X-Morph-SDK-Version": chunkQT5LGZG3_cjs.SDK_VERSION, ...options.headers } };
|
|
25
25
|
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
26
26
|
try {
|
|
27
27
|
const response = await fetch(url, options);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkWJHHO24M_cjs = require('./chunk-WJHHO24M.cjs');
|
|
4
4
|
|
|
5
5
|
// core/error.ts
|
|
6
6
|
async function toMorphError(response) {
|
|
@@ -15,7 +15,7 @@ async function toMorphError(response) {
|
|
|
15
15
|
if (response.status === 401) code = "authentication_error";
|
|
16
16
|
if (response.status === 429) code = "rate_limit_exceeded";
|
|
17
17
|
const retryable = response.status === 429 || response.status === 503;
|
|
18
|
-
return new
|
|
18
|
+
return new chunkWJHHO24M_cjs.MorphError(message, code, response.status, retryable);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
exports.toMorphError = toMorphError;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WARP_GREP_DESCRIPTION, GITHUB_SEARCH_DESCRIPTION, GITHUB_READ_FILE_DESCRIPTION } from './chunk-UAPK3AIJ.js';
|
|
2
|
-
import { executeToolCall, executeToolCallStreaming, WarpGrepClient, executeGitHubReadFile } from './chunk-
|
|
2
|
+
import { executeToolCall, executeToolCallStreaming, WarpGrepClient, executeGitHubReadFile } from './chunk-DZP7BR66.js';
|
|
3
3
|
import { tool } from 'ai';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
|
|
@@ -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 };
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { RetryConfig } from './tools/utils/resilience.js';
|
|
2
|
+
import { R as RedactPIIOption } from './guard-CvW03v4u.js';
|
|
2
3
|
import { MorphAPIClient } from './core/client.js';
|
|
3
4
|
import { FastApplyClient } from './tools/fastapply/core.js';
|
|
4
5
|
import { WarpGrepClient } from './tools/warp_grep/client.js';
|
|
5
6
|
import { CompactClient } from './tools/compact/core.js';
|
|
6
7
|
import { OpenAIRouter, AnthropicRouter, GeminiRouter, RawRouter, RouterClassifier } from './modelrouter/core.js';
|
|
7
8
|
import { EditFileConfig, EditFileInput, EditFileResult, EditChanges } from './tools/fastapply/types.js';
|
|
8
|
-
import { d as WarpGrepToolConfig, b as WarpGrepResult,
|
|
9
|
+
import { d as WarpGrepToolConfig, b as WarpGrepResult, g as GitHubSearchToolConfig, c as WarpGrepContext } from './types-BKhXjDCB.js';
|
|
9
10
|
import * as openai_resources_index_mjs from 'openai/resources/index.mjs';
|
|
10
11
|
import { ExploreSubagentConfig, ExploreResult, ExploreSession, ExploreEvent } from './subagents/types.js';
|
|
11
12
|
import * as _anthropic_ai_sdk_resources_messages_mjs from '@anthropic-ai/sdk/resources/messages.mjs';
|
|
@@ -287,6 +288,14 @@ interface MorphClientConfig {
|
|
|
287
288
|
timeout?: number;
|
|
288
289
|
/** Retry configuration for failed requests */
|
|
289
290
|
retryConfig?: RetryConfig;
|
|
291
|
+
/**
|
|
292
|
+
* Keep PII and secrets on this machine. Content sent by FastApply, WarpGrep, Compact and
|
|
293
|
+
* the routers has each sensitive value replaced with a token before it leaves the
|
|
294
|
+
* process, and the tokens in Morph's response are replaced with the original values, so
|
|
295
|
+
* results are unchanged. `true` uses the regex detector; pass a config to choose types,
|
|
296
|
+
* an allowlist, or `mode: 'model'`.
|
|
297
|
+
*/
|
|
298
|
+
redactPII?: RedactPIIOption;
|
|
290
299
|
}
|
|
291
300
|
/**
|
|
292
301
|
* Unified Morph SDK Client
|
package/dist/client.cjs
CHANGED
|
@@ -1,35 +1,39 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
5
|
-
require('./chunk-
|
|
6
|
-
require('./chunk-
|
|
3
|
+
var chunkMMX5PUGC_cjs = require('./chunk-MMX5PUGC.cjs');
|
|
4
|
+
require('./chunk-UZMMJ47A.cjs');
|
|
5
|
+
require('./chunk-5H3FKFOI.cjs');
|
|
6
|
+
require('./chunk-ST2OXLT5.cjs');
|
|
7
7
|
require('./chunk-EJTL2BOZ.cjs');
|
|
8
|
-
require('./chunk-
|
|
9
|
-
require('./chunk-
|
|
10
|
-
require('./chunk-
|
|
8
|
+
require('./chunk-GUNGJC6X.cjs');
|
|
9
|
+
require('./chunk-HNMEBYIS.cjs');
|
|
10
|
+
require('./chunk-HP3PCOTW.cjs');
|
|
11
|
+
require('./chunk-3HAHJYZQ.cjs');
|
|
11
12
|
require('./chunk-74A4HLIO.cjs');
|
|
12
|
-
require('./chunk-
|
|
13
|
-
require('./chunk-
|
|
14
|
-
require('./chunk-
|
|
15
|
-
require('./chunk-UUCRWJJR.cjs');
|
|
16
|
-
require('./chunk-VHD7CW5O.cjs');
|
|
13
|
+
require('./chunk-NJWOWXUR.cjs');
|
|
14
|
+
require('./chunk-UKBSXYKE.cjs');
|
|
15
|
+
require('./chunk-JHC2R3HU.cjs');
|
|
17
16
|
require('./chunk-WR7LSUIR.cjs');
|
|
18
17
|
require('./chunk-MWXJ6DZ2.cjs');
|
|
19
|
-
require('./chunk-
|
|
18
|
+
require('./chunk-OCKEEEYE.cjs');
|
|
19
|
+
require('./chunk-VHD7CW5O.cjs');
|
|
20
20
|
require('./chunk-KVGZ2TSG.cjs');
|
|
21
|
-
require('./chunk-4EQQGUZ7.cjs');
|
|
22
21
|
require('./chunk-UNX7V6P6.cjs');
|
|
23
|
-
require('./chunk-
|
|
22
|
+
require('./chunk-4EQQGUZ7.cjs');
|
|
23
|
+
require('./chunk-VYE7O4FM.cjs');
|
|
24
24
|
require('./chunk-TPZHMD7J.cjs');
|
|
25
|
-
require('./chunk-
|
|
26
|
-
require('./chunk-
|
|
27
|
-
require('./chunk-
|
|
28
|
-
require('./chunk-
|
|
25
|
+
require('./chunk-WIYVT4UO.cjs');
|
|
26
|
+
require('./chunk-UHFVWYSP.cjs');
|
|
27
|
+
require('./chunk-F633IVQA.cjs');
|
|
28
|
+
require('./chunk-5TTZQF4X.cjs');
|
|
29
29
|
require('./chunk-VL4QNALG.cjs');
|
|
30
|
-
require('./chunk-
|
|
31
|
-
require('./chunk-
|
|
32
|
-
require('./chunk-
|
|
30
|
+
require('./chunk-KF6S3EPJ.cjs');
|
|
31
|
+
require('./chunk-6HAYJA6M.cjs');
|
|
32
|
+
require('./chunk-R3TUE7O2.cjs');
|
|
33
|
+
require('./chunk-DLYDIYDK.cjs');
|
|
34
|
+
require('./chunk-YAUXTFIN.cjs');
|
|
35
|
+
require('./chunk-WJHHO24M.cjs');
|
|
36
|
+
require('./chunk-QT5LGZG3.cjs');
|
|
33
37
|
require('./chunk-AWFZKS27.cjs');
|
|
34
38
|
require('./chunk-75ZPJI57.cjs');
|
|
35
39
|
|
|
@@ -37,5 +41,5 @@ require('./chunk-75ZPJI57.cjs');
|
|
|
37
41
|
|
|
38
42
|
Object.defineProperty(exports, "MorphClient", {
|
|
39
43
|
enumerable: true,
|
|
40
|
-
get: function () { return
|
|
44
|
+
get: function () { return chunkMMX5PUGC_cjs.MorphClient; }
|
|
41
45
|
});
|