@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
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk6HAYJA6M_cjs = require('./chunk-6HAYJA6M.cjs');
|
|
4
|
+
var chunkR3TUE7O2_cjs = require('./chunk-R3TUE7O2.cjs');
|
|
5
|
+
|
|
6
|
+
// tools/pii/guard.ts
|
|
7
|
+
var PIIRestoreError = class extends Error {
|
|
8
|
+
constructor(tokens) {
|
|
9
|
+
super(
|
|
10
|
+
`Morph returned ${tokens.length} PII placeholder(s) that do not match anything sent. The response was discarded so no placeholder is written in place of real data.`
|
|
11
|
+
);
|
|
12
|
+
this.tokens = tokens;
|
|
13
|
+
this.name = "PIIRestoreError";
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
var PIISession = class {
|
|
17
|
+
constructor(detect) {
|
|
18
|
+
this.detect = detect;
|
|
19
|
+
}
|
|
20
|
+
nonce = Math.random().toString(36).slice(2, 6).padEnd(4, "0");
|
|
21
|
+
tokenFor = /* @__PURE__ */ new Map();
|
|
22
|
+
valueFor = /* @__PURE__ */ new Map();
|
|
23
|
+
counters = /* @__PURE__ */ new Map();
|
|
24
|
+
cache = /* @__PURE__ */ new Map();
|
|
25
|
+
tokenPattern = new RegExp(`__PII_[A-Z0-9_]+?_\\d+_${this.nonce}__`, "g");
|
|
26
|
+
/** Number of distinct values redacted so far. */
|
|
27
|
+
get size() {
|
|
28
|
+
return this.valueFor.size;
|
|
29
|
+
}
|
|
30
|
+
token(type, value) {
|
|
31
|
+
const key = `${type}\0${value}`;
|
|
32
|
+
let token = this.tokenFor.get(key);
|
|
33
|
+
if (!token) {
|
|
34
|
+
const index = (this.counters.get(type) ?? 0) + 1;
|
|
35
|
+
this.counters.set(type, index);
|
|
36
|
+
token = `__PII_${type.replace(/[^A-Z0-9]+/gi, "_").toUpperCase()}_${index}_${this.nonce}__`;
|
|
37
|
+
this.tokenFor.set(key, token);
|
|
38
|
+
this.valueFor.set(token, value);
|
|
39
|
+
}
|
|
40
|
+
return token;
|
|
41
|
+
}
|
|
42
|
+
/** Replace sensitive values with tokens. Repeated text is answered from a cache. */
|
|
43
|
+
async redact(text) {
|
|
44
|
+
if (!text) return text;
|
|
45
|
+
const cached = this.cache.get(text);
|
|
46
|
+
if (cached !== void 0) return cached;
|
|
47
|
+
const entities = await this.detect(text);
|
|
48
|
+
const out = chunkR3TUE7O2_cjs.applyRedactions(
|
|
49
|
+
text,
|
|
50
|
+
entities,
|
|
51
|
+
(entity) => (
|
|
52
|
+
// One token per line, so the line count (and any line numbers Morph returns)
|
|
53
|
+
// is the same before and after redaction.
|
|
54
|
+
entity.value.split("\n").map((line) => line ? this.token(entity.type, line) : "").join("\n")
|
|
55
|
+
)
|
|
56
|
+
);
|
|
57
|
+
this.cache.set(text, out);
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
60
|
+
restore(text) {
|
|
61
|
+
if (!text || this.valueFor.size === 0) return text;
|
|
62
|
+
return text.replace(this.tokenPattern, (token) => this.valueFor.get(token) ?? token);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Like `restore`, but throws if the text holds a token this session did not issue, or a
|
|
66
|
+
* damaged one (a token that lost its head or its tail). Use it wherever the result is
|
|
67
|
+
* written somewhere durable.
|
|
68
|
+
*/
|
|
69
|
+
restoreStrict(text) {
|
|
70
|
+
const unknown = (text.match(this.tokenPattern) ?? []).filter((token) => !this.valueFor.has(token));
|
|
71
|
+
const restored = this.restore(text);
|
|
72
|
+
const tail = `_${this.nonce}__`;
|
|
73
|
+
if (this.valueFor.size > 0) {
|
|
74
|
+
if (restored.includes(tail)) unknown.push(tail);
|
|
75
|
+
for (const token of this.valueFor.keys()) {
|
|
76
|
+
const head = token.slice(0, -(this.nonce.length + 2));
|
|
77
|
+
if (restored.includes(head)) unknown.push(head);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (unknown.length) throw new PIIRestoreError([...new Set(unknown)]);
|
|
81
|
+
return restored;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
var guards = /* @__PURE__ */ new WeakMap();
|
|
85
|
+
var defaultGuard;
|
|
86
|
+
function build(config) {
|
|
87
|
+
const redactor = chunk6HAYJA6M_cjs.createPIIRedactor(config);
|
|
88
|
+
return { session: () => new PIISession((text) => redactor.detect(text)) };
|
|
89
|
+
}
|
|
90
|
+
function resolvePIIGuard(option) {
|
|
91
|
+
if (!option) return void 0;
|
|
92
|
+
if (option === true) return defaultGuard ??= build({});
|
|
93
|
+
let guard = guards.get(option);
|
|
94
|
+
if (!guard) guards.set(option, guard = build(option));
|
|
95
|
+
return guard;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
exports.PIIRestoreError = PIIRestoreError;
|
|
99
|
+
exports.PIISession = PIISession;
|
|
100
|
+
exports.resolvePIIGuard = resolvePIIGuard;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { MorphAPIClient } from './chunk-
|
|
1
|
+
import { MorphAPIClient } from './chunk-IGXNLXPN.js';
|
|
2
2
|
import { logger } from './chunk-6WP7EA4F.js';
|
|
3
|
-
import { MorphError } from './chunk-
|
|
3
|
+
import { MorphError } from './chunk-4TZBUFVP.js';
|
|
4
4
|
import { APIResource } from './chunk-NRG6QX3L.js';
|
|
5
5
|
|
|
6
6
|
// modelrouter/core.ts
|
|
@@ -13,9 +13,14 @@ function resolveClient(clientOrConfig) {
|
|
|
13
13
|
baseURL: clientOrConfig.apiUrl ?? DEFAULT_API_URL,
|
|
14
14
|
timeout: clientOrConfig.timeout ?? DEFAULT_TIMEOUT,
|
|
15
15
|
retryConfig: clientOrConfig.retryConfig,
|
|
16
|
-
debug: clientOrConfig.debug
|
|
16
|
+
debug: clientOrConfig.debug,
|
|
17
|
+
redactPII: clientOrConfig.redactPII
|
|
17
18
|
});
|
|
18
19
|
}
|
|
20
|
+
async function redactInput(client, input) {
|
|
21
|
+
const pii = client.pii?.session();
|
|
22
|
+
return pii && typeof input === "string" ? await pii.redact(input) : input;
|
|
23
|
+
}
|
|
19
24
|
var BaseRouter = class extends APIResource {
|
|
20
25
|
provider;
|
|
21
26
|
timeout;
|
|
@@ -37,7 +42,7 @@ var BaseRouter = class extends APIResource {
|
|
|
37
42
|
async route(provider, input) {
|
|
38
43
|
try {
|
|
39
44
|
return await this._client.post(`/v1/router/${provider}`, {
|
|
40
|
-
body: { input: input.input, mode: input.mode || "balanced" },
|
|
45
|
+
body: { input: await redactInput(this._client, input.input), mode: input.mode || "balanced" },
|
|
41
46
|
timeout: this.timeout
|
|
42
47
|
});
|
|
43
48
|
} catch (error) {
|
|
@@ -141,7 +146,7 @@ var RouterClassifier = class extends APIResource {
|
|
|
141
146
|
logger.debug("RouterClassifier", "request", { classes: input.classes ?? "all" });
|
|
142
147
|
try {
|
|
143
148
|
const res = await this._client.post("/v1/router/classify", {
|
|
144
|
-
body: { input: input.input, ...input.classes ? { classes: input.classes } : {} },
|
|
149
|
+
body: { input: await redactInput(this._client, input.input), ...input.classes ? { classes: input.classes } : {} },
|
|
145
150
|
timeout: this.timeout
|
|
146
151
|
});
|
|
147
152
|
logger.debug("RouterClassifier", "classified", {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WarpGrepClient, formatResult } from './chunk-
|
|
1
|
+
import { WarpGrepClient, formatResult } from './chunk-DZP7BR66.js';
|
|
2
2
|
import { SEND_MESSAGE_TOOL, CODEBASE_SEARCH_TOOL, getSystemPrompt } from './chunk-ETBRAKVV.js';
|
|
3
3
|
import { tool, generateText, stepCountIs } from 'ai';
|
|
4
4
|
import { z } from 'zod';
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
3
|
+
var chunkUZMMJ47A_cjs = require('./chunk-UZMMJ47A.cjs');
|
|
4
|
+
var chunk5H3FKFOI_cjs = require('./chunk-5H3FKFOI.cjs');
|
|
5
|
+
var chunkST2OXLT5_cjs = require('./chunk-ST2OXLT5.cjs');
|
|
6
|
+
var chunkGUNGJC6X_cjs = require('./chunk-GUNGJC6X.cjs');
|
|
7
|
+
var chunkHNMEBYIS_cjs = require('./chunk-HNMEBYIS.cjs');
|
|
8
|
+
var chunkHP3PCOTW_cjs = require('./chunk-HP3PCOTW.cjs');
|
|
9
|
+
var chunk3HAHJYZQ_cjs = require('./chunk-3HAHJYZQ.cjs');
|
|
10
|
+
var chunkNJWOWXUR_cjs = require('./chunk-NJWOWXUR.cjs');
|
|
11
|
+
var chunkUKBSXYKE_cjs = require('./chunk-UKBSXYKE.cjs');
|
|
12
|
+
var chunkJHC2R3HU_cjs = require('./chunk-JHC2R3HU.cjs');
|
|
13
|
+
var chunkWIYVT4UO_cjs = require('./chunk-WIYVT4UO.cjs');
|
|
14
|
+
var chunkF633IVQA_cjs = require('./chunk-F633IVQA.cjs');
|
|
15
|
+
var chunk5TTZQF4X_cjs = require('./chunk-5TTZQF4X.cjs');
|
|
16
16
|
var chunkVL4QNALG_cjs = require('./chunk-VL4QNALG.cjs');
|
|
17
17
|
|
|
18
18
|
// factories/openai.ts
|
|
@@ -27,9 +27,10 @@ var OpenAIToolFactory = class {
|
|
|
27
27
|
* @returns OpenAI ChatCompletionTool with execute and formatResult methods
|
|
28
28
|
*/
|
|
29
29
|
createWarpGrepTool(toolConfig) {
|
|
30
|
-
return
|
|
30
|
+
return chunkST2OXLT5_cjs.createWarpGrepTool({
|
|
31
31
|
...toolConfig,
|
|
32
|
-
morphApiKey: this.config.apiKey
|
|
32
|
+
morphApiKey: this.config.apiKey,
|
|
33
|
+
redactPII: toolConfig.redactPII ?? this.config.redactPII
|
|
33
34
|
});
|
|
34
35
|
}
|
|
35
36
|
/**
|
|
@@ -39,9 +40,10 @@ var OpenAIToolFactory = class {
|
|
|
39
40
|
* @returns OpenAI ChatCompletionTool with execute and formatResult methods
|
|
40
41
|
*/
|
|
41
42
|
createEditFileTool(toolConfig = {}) {
|
|
42
|
-
return
|
|
43
|
+
return chunkHNMEBYIS_cjs.createEditFileTool({
|
|
43
44
|
...toolConfig,
|
|
44
|
-
morphApiKey: this.config.apiKey
|
|
45
|
+
morphApiKey: this.config.apiKey,
|
|
46
|
+
redactPII: toolConfig.redactPII ?? this.config.redactPII
|
|
45
47
|
});
|
|
46
48
|
}
|
|
47
49
|
/**
|
|
@@ -51,7 +53,7 @@ var OpenAIToolFactory = class {
|
|
|
51
53
|
* @returns OpenAI ChatCompletionTool with execute and formatResult methods
|
|
52
54
|
*/
|
|
53
55
|
createGitHubSearchTool(toolConfig) {
|
|
54
|
-
return
|
|
56
|
+
return chunkST2OXLT5_cjs.createGitHubSearchTool({
|
|
55
57
|
...toolConfig,
|
|
56
58
|
morphApiKey: this.config.apiKey
|
|
57
59
|
});
|
|
@@ -70,9 +72,10 @@ var AnthropicToolFactory = class {
|
|
|
70
72
|
* @returns Anthropic Tool with execute and formatResult methods
|
|
71
73
|
*/
|
|
72
74
|
createWarpGrepTool(toolConfig) {
|
|
73
|
-
return
|
|
75
|
+
return chunk5H3FKFOI_cjs.createWarpGrepTool({
|
|
74
76
|
...toolConfig,
|
|
75
|
-
morphApiKey: this.config.apiKey
|
|
77
|
+
morphApiKey: this.config.apiKey,
|
|
78
|
+
redactPII: toolConfig.redactPII ?? this.config.redactPII
|
|
76
79
|
});
|
|
77
80
|
}
|
|
78
81
|
/**
|
|
@@ -82,9 +85,10 @@ var AnthropicToolFactory = class {
|
|
|
82
85
|
* @returns Anthropic Tool with execute and formatResult methods
|
|
83
86
|
*/
|
|
84
87
|
createEditFileTool(toolConfig = {}) {
|
|
85
|
-
return
|
|
88
|
+
return chunk3HAHJYZQ_cjs.createEditFileTool({
|
|
86
89
|
...toolConfig,
|
|
87
|
-
morphApiKey: this.config.apiKey
|
|
90
|
+
morphApiKey: this.config.apiKey,
|
|
91
|
+
redactPII: toolConfig.redactPII ?? this.config.redactPII
|
|
88
92
|
});
|
|
89
93
|
}
|
|
90
94
|
/**
|
|
@@ -94,7 +98,7 @@ var AnthropicToolFactory = class {
|
|
|
94
98
|
* @returns Anthropic Tool with execute and formatResult methods
|
|
95
99
|
*/
|
|
96
100
|
createGitHubSearchTool(toolConfig) {
|
|
97
|
-
return
|
|
101
|
+
return chunk5H3FKFOI_cjs.createGitHubSearchTool({
|
|
98
102
|
...toolConfig,
|
|
99
103
|
morphApiKey: this.config.apiKey
|
|
100
104
|
});
|
|
@@ -106,7 +110,7 @@ var AnthropicToolFactory = class {
|
|
|
106
110
|
* @returns Explore subagent with .tool, .run(), and .stream() methods
|
|
107
111
|
*/
|
|
108
112
|
createExploreSubagent(config) {
|
|
109
|
-
return
|
|
113
|
+
return chunkUKBSXYKE_cjs.createExploreSubagent({
|
|
110
114
|
...config,
|
|
111
115
|
morphApiKey: this.config.apiKey
|
|
112
116
|
});
|
|
@@ -125,9 +129,10 @@ var VercelToolFactory = class {
|
|
|
125
129
|
* @returns Vercel AI SDK tool
|
|
126
130
|
*/
|
|
127
131
|
createWarpGrepTool(toolConfig) {
|
|
128
|
-
return
|
|
132
|
+
return chunkUZMMJ47A_cjs.createWarpGrepTool({
|
|
129
133
|
...toolConfig,
|
|
130
|
-
morphApiKey: this.config.apiKey
|
|
134
|
+
morphApiKey: this.config.apiKey,
|
|
135
|
+
redactPII: toolConfig.redactPII ?? this.config.redactPII
|
|
131
136
|
});
|
|
132
137
|
}
|
|
133
138
|
/**
|
|
@@ -137,9 +142,10 @@ var VercelToolFactory = class {
|
|
|
137
142
|
* @returns Vercel AI SDK tool
|
|
138
143
|
*/
|
|
139
144
|
createEditFileTool(toolConfig = {}) {
|
|
140
|
-
return
|
|
145
|
+
return chunkHP3PCOTW_cjs.createEditFileTool({
|
|
141
146
|
...toolConfig,
|
|
142
|
-
morphApiKey: this.config.apiKey
|
|
147
|
+
morphApiKey: this.config.apiKey,
|
|
148
|
+
redactPII: toolConfig.redactPII ?? this.config.redactPII
|
|
143
149
|
});
|
|
144
150
|
}
|
|
145
151
|
/**
|
|
@@ -149,7 +155,7 @@ var VercelToolFactory = class {
|
|
|
149
155
|
* @returns Vercel AI SDK tool
|
|
150
156
|
*/
|
|
151
157
|
createGitHubSearchTool(toolConfig) {
|
|
152
|
-
return
|
|
158
|
+
return chunkUZMMJ47A_cjs.createGitHubSearchTool({
|
|
153
159
|
...toolConfig,
|
|
154
160
|
morphApiKey: this.config.apiKey
|
|
155
161
|
});
|
|
@@ -161,7 +167,7 @@ var VercelToolFactory = class {
|
|
|
161
167
|
* @returns Explore subagent with .tool, .run(), and .stream() methods
|
|
162
168
|
*/
|
|
163
169
|
createExploreSubagent(config) {
|
|
164
|
-
return
|
|
170
|
+
return chunkGUNGJC6X_cjs.createExploreSubagent({
|
|
165
171
|
...config,
|
|
166
172
|
morphApiKey: this.config.apiKey
|
|
167
173
|
});
|
|
@@ -169,7 +175,7 @@ var VercelToolFactory = class {
|
|
|
169
175
|
};
|
|
170
176
|
|
|
171
177
|
// client.ts
|
|
172
|
-
var MorphClient = class extends
|
|
178
|
+
var MorphClient = class extends chunk5TTZQF4X_cjs.MorphAPIClient {
|
|
173
179
|
/** Client configuration */
|
|
174
180
|
config;
|
|
175
181
|
/** FastApply tool for editing files with AI-powered merge */
|
|
@@ -205,23 +211,24 @@ var MorphClient = class extends chunk65W4I66Q_cjs.MorphAPIClient {
|
|
|
205
211
|
apiKey: config.apiKey,
|
|
206
212
|
timeout: config.timeout,
|
|
207
213
|
retryConfig: config.retryConfig,
|
|
208
|
-
debug: config.debug
|
|
214
|
+
debug: config.debug,
|
|
215
|
+
redactPII: config.redactPII
|
|
209
216
|
});
|
|
210
217
|
if (!config.apiKey) {
|
|
211
218
|
throw new Error("Morph API key is required. Pass it as { apiKey } when constructing MorphClient.");
|
|
212
219
|
}
|
|
213
220
|
this.config = config;
|
|
214
221
|
chunkVL4QNALG_cjs.logger.debug("MorphClient", "initialized", { debug: !!config.debug, timeout: config.timeout });
|
|
215
|
-
this.fastApply = new
|
|
216
|
-
this.warpGrep = new
|
|
222
|
+
this.fastApply = new chunkNJWOWXUR_cjs.FastApplyClient(this);
|
|
223
|
+
this.warpGrep = new chunkJHC2R3HU_cjs.WarpGrepClient(this);
|
|
217
224
|
this.routers = {
|
|
218
|
-
openai: new
|
|
219
|
-
anthropic: new
|
|
220
|
-
gemini: new
|
|
221
|
-
raw: new
|
|
222
|
-
classify: new
|
|
225
|
+
openai: new chunkWIYVT4UO_cjs.OpenAIRouter(this),
|
|
226
|
+
anthropic: new chunkWIYVT4UO_cjs.AnthropicRouter(this),
|
|
227
|
+
gemini: new chunkWIYVT4UO_cjs.GeminiRouter(this),
|
|
228
|
+
raw: new chunkWIYVT4UO_cjs.RawRouter(this),
|
|
229
|
+
classify: new chunkWIYVT4UO_cjs.RouterClassifier(this)
|
|
223
230
|
};
|
|
224
|
-
const compactClient = new
|
|
231
|
+
const compactClient = new chunkF633IVQA_cjs.CompactClient(this);
|
|
225
232
|
this.compact = compactClient.compact.bind(compactClient);
|
|
226
233
|
this.openai = new OpenAIToolFactory(config);
|
|
227
234
|
this.anthropic = new AnthropicToolFactory(config);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkUHFVWYSP_cjs = require('./chunk-UHFVWYSP.cjs');
|
|
4
|
+
var chunk5TTZQF4X_cjs = require('./chunk-5TTZQF4X.cjs');
|
|
5
5
|
var chunkVL4QNALG_cjs = require('./chunk-VL4QNALG.cjs');
|
|
6
6
|
var chunkAWFZKS27_cjs = require('./chunk-AWFZKS27.cjs');
|
|
7
7
|
var path = require('path');
|
|
@@ -14,13 +14,14 @@ var DEFAULT_CONFIG = {
|
|
|
14
14
|
var FastApplyClient = class extends chunkAWFZKS27_cjs.APIResource {
|
|
15
15
|
config;
|
|
16
16
|
constructor(clientOrConfig = {}) {
|
|
17
|
-
const isClient = clientOrConfig instanceof
|
|
17
|
+
const isClient = clientOrConfig instanceof chunk5TTZQF4X_cjs.MorphAPIClient;
|
|
18
18
|
super(
|
|
19
|
-
isClient ? clientOrConfig : new
|
|
19
|
+
isClient ? clientOrConfig : new chunk5TTZQF4X_cjs.MorphAPIClient({
|
|
20
20
|
apiKey: clientOrConfig.apiKey,
|
|
21
21
|
timeout: clientOrConfig.timeout ?? DEFAULT_CONFIG.timeout,
|
|
22
22
|
retryConfig: clientOrConfig.retryConfig,
|
|
23
|
-
debug: clientOrConfig.debug
|
|
23
|
+
debug: clientOrConfig.debug,
|
|
24
|
+
redactPII: clientOrConfig.redactPII
|
|
24
25
|
})
|
|
25
26
|
);
|
|
26
27
|
this.config = {
|
|
@@ -29,6 +30,7 @@ var FastApplyClient = class extends chunkAWFZKS27_cjs.APIResource {
|
|
|
29
30
|
debug: this._client.debug,
|
|
30
31
|
timeout: (isClient ? void 0 : clientOrConfig.timeout) ?? DEFAULT_CONFIG.timeout,
|
|
31
32
|
retryConfig: this._client.retryConfig,
|
|
33
|
+
redactPII: this._client.redactPII,
|
|
32
34
|
generateUdiff: DEFAULT_CONFIG.generateUdiff,
|
|
33
35
|
autoWrite: DEFAULT_CONFIG.autoWrite
|
|
34
36
|
};
|
|
@@ -118,7 +120,7 @@ async function executeEditFile(input, config = {}) {
|
|
|
118
120
|
};
|
|
119
121
|
} catch (error) {
|
|
120
122
|
const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
|
|
121
|
-
const structuredError = error instanceof
|
|
123
|
+
const structuredError = error instanceof chunkUHFVWYSP_cjs.FastApplyContextLengthError || error instanceof chunkUHFVWYSP_cjs.FastApplyAnchorIntegrityError ? error : void 0;
|
|
122
124
|
chunkVL4QNALG_cjs.logger.error("FastApply", "execute_error", { error: errorMessage, target_filepath: input.target_filepath, stack: error instanceof Error ? error.stack : void 0 });
|
|
123
125
|
return {
|
|
124
126
|
success: false,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkKVGZ2TSG_cjs = require('./chunk-KVGZ2TSG.cjs');
|
|
4
|
-
var chunk4EQQGUZ7_cjs = require('./chunk-4EQQGUZ7.cjs');
|
|
5
4
|
var chunkUNX7V6P6_cjs = require('./chunk-UNX7V6P6.cjs');
|
|
5
|
+
var chunk4EQQGUZ7_cjs = require('./chunk-4EQQGUZ7.cjs');
|
|
6
6
|
var chunkVL4QNALG_cjs = require('./chunk-VL4QNALG.cjs');
|
|
7
|
-
var
|
|
7
|
+
var chunkKF6S3EPJ_cjs = require('./chunk-KF6S3EPJ.cjs');
|
|
8
|
+
var chunkQT5LGZG3_cjs = require('./chunk-QT5LGZG3.cjs');
|
|
8
9
|
var OpenAI = require('openai');
|
|
9
10
|
var path = require('path');
|
|
10
11
|
|
|
@@ -121,6 +122,23 @@ var TOOL_SPECS = [
|
|
|
121
122
|
}
|
|
122
123
|
}
|
|
123
124
|
];
|
|
125
|
+
async function redactMessages(messages, pii) {
|
|
126
|
+
return Promise.all(
|
|
127
|
+
messages.map(async (message) => {
|
|
128
|
+
const out = { ...message };
|
|
129
|
+
if (typeof message.content === "string") out.content = await pii.redact(message.content);
|
|
130
|
+
if (message.role === "assistant" && out.role === "assistant" && message.tool_calls) {
|
|
131
|
+
out.tool_calls = await Promise.all(
|
|
132
|
+
message.tool_calls.map(async (tc) => ({
|
|
133
|
+
...tc,
|
|
134
|
+
function: { ...tc.function, arguments: await pii.redact(tc.function.arguments) }
|
|
135
|
+
}))
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
return out;
|
|
139
|
+
})
|
|
140
|
+
);
|
|
141
|
+
}
|
|
124
142
|
async function callModel(messages, model, options = {}) {
|
|
125
143
|
const baseUrl = options.morphApiUrl || DEFAULT_API_URL;
|
|
126
144
|
const apiKey = options.morphApiKey || process.env.MORPH_API_KEY || "";
|
|
@@ -132,9 +150,11 @@ async function callModel(messages, model, options = {}) {
|
|
|
132
150
|
baseURL,
|
|
133
151
|
maxRetries: 0,
|
|
134
152
|
timeout: timeoutMs,
|
|
135
|
-
defaultHeaders: { "X-Morph-SDK-Version":
|
|
153
|
+
defaultHeaders: { "X-Morph-SDK-Version": chunkQT5LGZG3_cjs.SDK_VERSION }
|
|
136
154
|
});
|
|
137
155
|
const MAX_EMPTY_RETRIES = 1;
|
|
156
|
+
const pii = options.pii;
|
|
157
|
+
const outgoing = pii ? await redactMessages(messages, pii) : messages;
|
|
138
158
|
chunkVL4QNALG_cjs.logger.debug("WarpGrep", "model_call", { url: baseURL, model, message_count: messages.length });
|
|
139
159
|
const callStartTime = Date.now();
|
|
140
160
|
for (let attempt = 0; attempt <= MAX_EMPTY_RETRIES; attempt++) {
|
|
@@ -144,7 +164,7 @@ async function callModel(messages, model, options = {}) {
|
|
|
144
164
|
model,
|
|
145
165
|
temperature: 0,
|
|
146
166
|
max_tokens: 2048,
|
|
147
|
-
messages,
|
|
167
|
+
messages: outgoing,
|
|
148
168
|
tools: TOOL_SPECS,
|
|
149
169
|
...options.search_type ? { search_type: options.search_type } : {}
|
|
150
170
|
});
|
|
@@ -174,11 +194,12 @@ async function callModel(messages, model, options = {}) {
|
|
|
174
194
|
const toolCalls = (message.tool_calls || []).map((tc) => ({
|
|
175
195
|
id: tc.id,
|
|
176
196
|
type: "function",
|
|
177
|
-
|
|
197
|
+
// Restore real values so grep patterns and file paths work against the local repo.
|
|
198
|
+
function: { name: tc.function.name, arguments: pii ? pii.restore(tc.function.arguments) : tc.function.arguments }
|
|
178
199
|
}));
|
|
179
200
|
if (message.content || toolCalls.length > 0) {
|
|
180
201
|
chunkVL4QNALG_cjs.logger.debug("WarpGrep", "model_call_complete", { latency_ms: Date.now() - callStartTime, tool_calls_count: toolCalls.length, finish_reason: choice?.finish_reason ?? "unknown" });
|
|
181
|
-
return { content: message.content ?? null, tool_calls: toolCalls };
|
|
202
|
+
return { content: pii ? pii.restore(message.content ?? null) ?? null : message.content ?? null, tool_calls: toolCalls };
|
|
182
203
|
}
|
|
183
204
|
if (attempt === MAX_EMPTY_RETRIES) {
|
|
184
205
|
const finishReason = choice?.finish_reason ?? "unknown";
|
|
@@ -247,6 +268,7 @@ async function* runWarpGrepStreaming(config) {
|
|
|
247
268
|
const repoRoot = config.repoRoot || process.cwd();
|
|
248
269
|
const model = config.model || chunk4EQQGUZ7_cjs.DEFAULT_MODEL;
|
|
249
270
|
const messages = [];
|
|
271
|
+
const pii = chunkKF6S3EPJ_cjs.resolvePIIGuard(config.redactPII)?.session();
|
|
250
272
|
const maxTurns = chunk4EQQGUZ7_cjs.AGENT_CONFIG.MAX_TURNS;
|
|
251
273
|
chunkVL4QNALG_cjs.logger.debug("WarpGrep", "session_start", { search_term: config.searchTerm, model, max_turns: maxTurns });
|
|
252
274
|
const initialStateStart = Date.now();
|
|
@@ -273,7 +295,8 @@ async function* runWarpGrepStreaming(config) {
|
|
|
273
295
|
morphApiUrl: config.morphApiUrl,
|
|
274
296
|
retryConfig: config.retryConfig,
|
|
275
297
|
timeout: timeoutMs,
|
|
276
|
-
search_type: config.search_type
|
|
298
|
+
search_type: config.search_type,
|
|
299
|
+
pii
|
|
277
300
|
}).catch((e) => {
|
|
278
301
|
const errMsg = e instanceof Error ? e.message : String(e);
|
|
279
302
|
console.error(`[warp_grep] Morph API call failed on turn ${turn}:`, errMsg);
|