@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
package/README.md
CHANGED
|
@@ -21,6 +21,7 @@ export MORPH_API_KEY="sk-your-key-here"
|
|
|
21
21
|
- **🔍 WarpGrep** - Intelligent code search agent that explores your codebase with parallel grep/read operations
|
|
22
22
|
- **⚡ Fast Apply** - 98% 1st pass accuracy, AI-powered code editing at 10,500 tokens/s
|
|
23
23
|
- **📦 Repo Storage** - Agent native git with automatic code indexing and agent metadata
|
|
24
|
+
- **🛡️ PII Redaction** - Strip emails, keys, names and addresses from text locally, with regex or a small CPU model
|
|
24
25
|
- **🤖 Agent Tools** - Ready-to-use tools for Anthropic, OpenAI, Gemini, and Vercel AI SDK
|
|
25
26
|
|
|
26
27
|
## Quick Start
|
|
@@ -162,6 +163,106 @@ await morph.git.branch({ dir: './my-project', name: 'feature' });
|
|
|
162
163
|
await morph.git.checkout({ dir: './my-project', ref: 'main' });
|
|
163
164
|
```
|
|
164
165
|
|
|
166
|
+
## PII Redaction
|
|
167
|
+
|
|
168
|
+
Remove personal data and secrets from text before you log it, store it or send it to a model. Both modes run on your machine. No text is sent to Morph or anywhere else, and no API key is needed.
|
|
169
|
+
|
|
170
|
+
**Regex mode** has no dependencies and is synchronous. It also works from `@morphllm/morphsdk/edge`.
|
|
171
|
+
|
|
172
|
+
```typescript
|
|
173
|
+
import { redactPII } from '@morphllm/morphsdk';
|
|
174
|
+
|
|
175
|
+
const { text, entities } = redactPII(
|
|
176
|
+
'Mail sarah@example.com, key sk-proj-abc123def456ghi789jkl012, host 203.0.113.7'
|
|
177
|
+
);
|
|
178
|
+
// text: 'Mail [EMAIL], key [SECRET], host [IP_ADDRESS]'
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
It finds:
|
|
182
|
+
|
|
183
|
+
| Type | What it matches |
|
|
184
|
+
|------|-----------------|
|
|
185
|
+
| `EMAIL` | Email addresses |
|
|
186
|
+
| `PHONE` | International numbers with a `+` prefix, North American numbers, and national formats with a trunk zero or bracketed area code |
|
|
187
|
+
| `SSN` | US SSNs separated by dashes, dots or spaces; Swiss AHV numbers; any number after an `SSN` or `social security` label |
|
|
188
|
+
| `CREDIT_CARD` | Numbers that pass the Luhn checksum, numbers written in card groups (`4242 4242 4242 4241`), and bare 16-digit numbers |
|
|
189
|
+
| `IBAN` | IBANs with a valid checksum |
|
|
190
|
+
| `ACCOUNT_NUMBER` | A number after an `account number` or `routing number` label |
|
|
191
|
+
| `DATE_OF_BIRTH` | A date after `born`, `DOB`, `date of birth` or `birthday` |
|
|
192
|
+
| `MEDICAL_RECORD` | An identifier after `MRN` or `medical record number` |
|
|
193
|
+
| `LOCATION` | Street addresses (`42 Wallaby Way`, `W 2nd Street`) and PO boxes |
|
|
194
|
+
| `IP_ADDRESS`, `MAC_ADDRESS` | IPv4, IPv6 and MAC addresses |
|
|
195
|
+
| `SECRET` | Provider API keys, JWTs, bearer tokens, private key blocks, passwords in URLs, and values after a `password` or `secret` label |
|
|
196
|
+
|
|
197
|
+
Street addresses need a capitalized street name and a street-type word; cities, states, countries and people's names need model mode.
|
|
198
|
+
|
|
199
|
+
Matching time is linear in the input: a 600 KB minified JSON file takes about 25 ms. The patterns use regex lookbehind, so regex mode needs Node 10+, or Safari 16.4+ in a browser.
|
|
200
|
+
|
|
201
|
+
**Model mode** adds a small token-classification model that runs on CPU, so it also finds names, addresses and other free-text PII. Install the optional dependency first:
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
npm install @huggingface/transformers
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
```typescript
|
|
208
|
+
import { createPIIRedactor } from '@morphllm/morphsdk';
|
|
209
|
+
|
|
210
|
+
const redactor = createPIIRedactor({ mode: 'model' });
|
|
211
|
+
|
|
212
|
+
const { text } = await redactor.redact(
|
|
213
|
+
"I'm Sarah Connor, 42 Wallaby Way, Sydney. Reach me at sarah@example.com"
|
|
214
|
+
);
|
|
215
|
+
// text: "I'm [PERSON], [LOCATION]. Reach me at [EMAIL]"
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
The default model is [`onnx-community/bert-small-pii-detection-ONNX`](https://huggingface.co/onnx-community/bert-small-pii-detection-ONNX) (Apache 2.0, English, about 29 MB). It is downloaded from Hugging Face on the first call and cached; call `redactor.load()` to do that at startup. Model mode runs the regex detector too.
|
|
219
|
+
|
|
220
|
+
| Option | Default | What it does |
|
|
221
|
+
|--------|---------|--------------|
|
|
222
|
+
| `types` | all | Only redact these entity types |
|
|
223
|
+
| `excludeTypes` | none | Never redact these entity types |
|
|
224
|
+
| `placeholder` | `'type'` | `'type'` gives `[EMAIL]`; `'indexed'` gives `[EMAIL_1]`, the same value always getting the same index; or pass a function |
|
|
225
|
+
| `allow` | see below | Values that are never redacted: strings match a whole entity ignoring case, or pass a RegExp |
|
|
226
|
+
| `mode` | `'regex'` | `'regex'` or `'model'` |
|
|
227
|
+
| `model` | see above | Any Hugging Face token-classification model with ONNX weights |
|
|
228
|
+
| `minScore` | `0.75` | Drop model entities below this confidence |
|
|
229
|
+
| `classifier` | none | Your own transformers.js pipeline, for bundled or browser builds |
|
|
230
|
+
|
|
231
|
+
In model mode, `ORGANIZATION`, `DATE_TIME`, `URL`, `TITLE`, `AGE`, `NRP` and `COORDINATE` are skipped unless you list them in `types`.
|
|
232
|
+
|
|
233
|
+
Model mode is tuned for code and agent transcripts:
|
|
234
|
+
|
|
235
|
+
- A name-like hit shaped like a code identifier is ignored (`getWeather`, `StepHandler`, `claude-sonnet-4-5`, `fs.readFile`). A name inside code, such as `{ user: "Sarah Connor" }`, is still redacted.
|
|
236
|
+
- AI product names that read as human names (`Claude`, `Gemini`, `Llama` and a few more, exported as `DEFAULT_PII_ALLOW`) are not redacted. Pass `allow` to replace that list, for example `allow: [...DEFAULT_PII_ALLOW, 'Stripe', 'Vercel']`, or `allow: []` to turn it off.
|
|
237
|
+
|
|
238
|
+
Each entity in `entities` carries the original value. Treat that array as sensitive.
|
|
239
|
+
|
|
240
|
+
### Redact everything the client sends
|
|
241
|
+
|
|
242
|
+
Set `redactPII` on `MorphClient`. Fast Apply, WarpGrep, Compact and the routers then send tokens in place of sensitive values, and put the real values back in what they return.
|
|
243
|
+
|
|
244
|
+
```typescript
|
|
245
|
+
const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY, redactPII: true });
|
|
246
|
+
|
|
247
|
+
await morph.fastApply.execute({ target_filepath: 'src/config.ts', instructions, code_edit });
|
|
248
|
+
// Morph received: const owner = "__PII_EMAIL_1_k3x9__";
|
|
249
|
+
// Written to disk: const owner = "jane.doe@example.com";
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
`true` uses regex mode. Pass a config for anything else:
|
|
253
|
+
|
|
254
|
+
```typescript
|
|
255
|
+
new MorphClient({ redactPII: { mode: 'model' } }); // regex + local model
|
|
256
|
+
new MorphClient({ redactPII: { types: ['EMAIL', 'SECRET'] } }); // only these types
|
|
257
|
+
new MorphClient({ redactPII: { allow: ['support@acme.com'] } }); // never redact these
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
- Tokens are unique per request (per search for WarpGrep), so the same value always maps to the same token inside one call and never collides across calls.
|
|
261
|
+
- Fast Apply fails closed. If the merged code holds a token that was never sent, or a damaged one, the edit returns `success: false` and nothing is written.
|
|
262
|
+
- WarpGrep runs its tools locally against the real files. The model sees tokens; a grep for a token runs as a grep for the value.
|
|
263
|
+
- The tool factories (`morph.openai`, `morph.anthropic`, `morph.vercel`) inherit the option.
|
|
264
|
+
- Not covered: GitHub search, repo storage (`morph.git`), browser, subagents, and the `@morphllm/morphsdk/ai-sdk` provider. Redact those inputs yourself with `redactPII()`.
|
|
265
|
+
|
|
165
266
|
## Agent Tools
|
|
166
267
|
|
|
167
268
|
Ready-to-use tools for popular AI frameworks:
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { PII_PATTERNS, CONTEXT_CHARS } from './chunk-ZX6T3LNG.js';
|
|
2
|
+
|
|
3
|
+
// tools/pii/regex.ts
|
|
4
|
+
function isTypeEnabled(type, options) {
|
|
5
|
+
if (options.types && !options.types.includes(type)) return false;
|
|
6
|
+
if (options.excludeTypes?.includes(type)) return false;
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
function isAllowed(value, allow) {
|
|
10
|
+
if (!allow?.length) return false;
|
|
11
|
+
const lower = value.trim().toLowerCase();
|
|
12
|
+
return allow.some(
|
|
13
|
+
(entry) => typeof entry === "string" ? entry.toLowerCase() === lower : new RegExp(entry.source, entry.flags.replace(/[gy]/g, "")).test(value)
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
function mergeEntities(text, entities) {
|
|
17
|
+
const sorted = [...entities].sort(
|
|
18
|
+
(a, b) => a.start - b.start || b.end - a.end || (a.source === b.source ? 0 : a.source === "regex" ? -1 : 1)
|
|
19
|
+
);
|
|
20
|
+
const merged = [];
|
|
21
|
+
for (const entity of sorted) {
|
|
22
|
+
const last = merged[merged.length - 1];
|
|
23
|
+
if (last && entity.start < last.end) {
|
|
24
|
+
if (entity.end > last.end) {
|
|
25
|
+
const longer = entity.end - entity.start > last.end - last.start ? entity : last;
|
|
26
|
+
merged[merged.length - 1] = {
|
|
27
|
+
...longer,
|
|
28
|
+
start: last.start,
|
|
29
|
+
end: entity.end,
|
|
30
|
+
value: text.slice(last.start, entity.end)
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
merged.push(entity);
|
|
36
|
+
}
|
|
37
|
+
return merged;
|
|
38
|
+
}
|
|
39
|
+
function applyRedactions(text, entities, placeholder = "type") {
|
|
40
|
+
const indexes = /* @__PURE__ */ new Map();
|
|
41
|
+
const counters = /* @__PURE__ */ new Map();
|
|
42
|
+
let out = "";
|
|
43
|
+
let cursor = 0;
|
|
44
|
+
for (const entity of entities) {
|
|
45
|
+
let replacement;
|
|
46
|
+
if (typeof placeholder === "function") {
|
|
47
|
+
replacement = placeholder(entity);
|
|
48
|
+
} else if (placeholder === "indexed") {
|
|
49
|
+
const key = `${entity.type}\0${entity.value}`;
|
|
50
|
+
let index = indexes.get(key);
|
|
51
|
+
if (index === void 0) {
|
|
52
|
+
index = (counters.get(entity.type) ?? 0) + 1;
|
|
53
|
+
counters.set(entity.type, index);
|
|
54
|
+
indexes.set(key, index);
|
|
55
|
+
}
|
|
56
|
+
replacement = `[${entity.type}_${index}]`;
|
|
57
|
+
} else {
|
|
58
|
+
replacement = `[${entity.type}]`;
|
|
59
|
+
}
|
|
60
|
+
out += text.slice(cursor, entity.start) + replacement;
|
|
61
|
+
cursor = entity.end;
|
|
62
|
+
}
|
|
63
|
+
return out + text.slice(cursor);
|
|
64
|
+
}
|
|
65
|
+
function detectPII(text, options = {}) {
|
|
66
|
+
if (typeof text !== "string") {
|
|
67
|
+
throw new TypeError(`PII detection expects a string, got ${text === null ? "null" : typeof text}`);
|
|
68
|
+
}
|
|
69
|
+
const found = [];
|
|
70
|
+
for (const pattern of PII_PATTERNS) {
|
|
71
|
+
if (!isTypeEnabled(pattern.type, options)) continue;
|
|
72
|
+
for (const candidate of candidates(pattern, text)) {
|
|
73
|
+
if (!isAllowed(candidate.value, options.allow)) found.push(candidate);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return mergeEntities(text, found);
|
|
77
|
+
}
|
|
78
|
+
function* candidates(pattern, text) {
|
|
79
|
+
const { regex, group, validate, type } = pattern;
|
|
80
|
+
regex.lastIndex = 0;
|
|
81
|
+
let match;
|
|
82
|
+
while ((match = regex.exec(text)) !== null) {
|
|
83
|
+
if (match[0] === "") {
|
|
84
|
+
regex.lastIndex++;
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
const value = group ? match[group] : match[0];
|
|
88
|
+
if (!value) continue;
|
|
89
|
+
const start = group ? match.index + match[0].lastIndexOf(value) : match.index;
|
|
90
|
+
const before = text.slice(Math.max(0, match.index - CONTEXT_CHARS), match.index);
|
|
91
|
+
if (validate && !validate(value, before)) continue;
|
|
92
|
+
yield { type, start, end: start + value.length, value, source: "regex" };
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function redactPII(text, options = {}) {
|
|
96
|
+
const entities = detectPII(text, options);
|
|
97
|
+
return { text: applyRedactions(text, entities, options.placeholder), entities };
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export { applyRedactions, detectPII, isAllowed, isTypeEnabled, mergeEntities, redactPII };
|
package/dist/chunk-2PPYWRMZ.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
1
3
|
// tools/warp_grep/index.ts
|
|
2
|
-
import { z } from "zod";
|
|
3
4
|
var warpGrepInputSchema = z.object({
|
|
4
5
|
search_term: z.string().describe("Search problem statement that this subagent is supposed to research for")
|
|
5
6
|
});
|
|
6
7
|
|
|
7
|
-
export {
|
|
8
|
-
warpGrepInputSchema
|
|
9
|
-
};
|
|
8
|
+
export { warpGrepInputSchema };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk74A4HLIO_cjs = require('./chunk-74A4HLIO.cjs');
|
|
4
|
+
var chunkNJWOWXUR_cjs = require('./chunk-NJWOWXUR.cjs');
|
|
5
|
+
var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
|
|
6
|
+
|
|
7
|
+
// tools/fastapply/anthropic.ts
|
|
8
|
+
var anthropic_exports = {};
|
|
9
|
+
chunk75ZPJI57_cjs.__export(anthropic_exports, {
|
|
10
|
+
createEditFileTool: () => createEditFileTool,
|
|
11
|
+
editFileTool: () => editFileTool,
|
|
12
|
+
execute: () => execute,
|
|
13
|
+
formatResult: () => formatResult,
|
|
14
|
+
getSystemPrompt: () => getSystemPrompt
|
|
15
|
+
});
|
|
16
|
+
var editFileTool = {
|
|
17
|
+
name: "edit_file",
|
|
18
|
+
description: chunk74A4HLIO_cjs.EDIT_FILE_TOOL_DESCRIPTION,
|
|
19
|
+
input_schema: {
|
|
20
|
+
type: "object",
|
|
21
|
+
properties: {
|
|
22
|
+
target_filepath: {
|
|
23
|
+
type: "string",
|
|
24
|
+
description: "The path of the target file to modify"
|
|
25
|
+
},
|
|
26
|
+
instruction: {
|
|
27
|
+
type: "string",
|
|
28
|
+
description: "A single sentence written in the first person describing what the agent is changing. Used to help disambiguate uncertainty in the edit."
|
|
29
|
+
},
|
|
30
|
+
code_edit: {
|
|
31
|
+
type: "string",
|
|
32
|
+
description: "Specify ONLY the precise lines of code that you wish to edit. Use `// ... existing code ...` for unchanged sections."
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
required: ["target_filepath", "instruction", "code_edit"]
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
function formatResult(result) {
|
|
39
|
+
if (!result.success) {
|
|
40
|
+
return `Error editing file: ${result.error}`;
|
|
41
|
+
}
|
|
42
|
+
const { changes } = result;
|
|
43
|
+
return `Successfully applied changes to ${result.filepath}. Added ${changes.linesAdded}, removed ${changes.linesRemoved}, modified ${changes.linesModified}.`;
|
|
44
|
+
}
|
|
45
|
+
function createEditFileTool(config = {}) {
|
|
46
|
+
const toolDef = {
|
|
47
|
+
...editFileTool,
|
|
48
|
+
...config.description && { description: config.description }
|
|
49
|
+
};
|
|
50
|
+
return Object.assign({}, toolDef, {
|
|
51
|
+
execute: async (input) => {
|
|
52
|
+
return chunkNJWOWXUR_cjs.executeEditFile(input, config);
|
|
53
|
+
},
|
|
54
|
+
formatResult: (result) => {
|
|
55
|
+
return formatResult(result);
|
|
56
|
+
},
|
|
57
|
+
getSystemPrompt: () => {
|
|
58
|
+
return chunk74A4HLIO_cjs.EDIT_FILE_SYSTEM_PROMPT;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
async function execute(input, config) {
|
|
63
|
+
return chunkNJWOWXUR_cjs.executeEditFile(input, config);
|
|
64
|
+
}
|
|
65
|
+
function getSystemPrompt() {
|
|
66
|
+
return chunk74A4HLIO_cjs.EDIT_FILE_SYSTEM_PROMPT;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
exports.anthropic_exports = anthropic_exports;
|
|
70
|
+
exports.createEditFileTool = createEditFileTool;
|
|
71
|
+
exports.editFileTool = editFileTool;
|
|
72
|
+
exports.execute = execute;
|
|
73
|
+
exports.formatResult = formatResult;
|
|
74
|
+
exports.getSystemPrompt = getSystemPrompt;
|
|
@@ -1,20 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
GITHUB_READ_FILE_INPUT_SCHEMA,
|
|
4
|
-
GITHUB_READ_FILE_TOOL_NAME,
|
|
5
|
-
GITHUB_SEARCH_DESCRIPTION,
|
|
6
|
-
GITHUB_SEARCH_INPUT_SCHEMA,
|
|
7
|
-
GITHUB_SEARCH_TOOL_NAME,
|
|
8
|
-
WARP_GREP_DESCRIPTION,
|
|
9
|
-
WARP_GREP_TOOL_NAME
|
|
10
|
-
} from "./chunk-UAPK3AIJ.js";
|
|
11
|
-
import {
|
|
12
|
-
WarpGrepClient,
|
|
13
|
-
executeGitHubReadFile,
|
|
14
|
-
executeToolCall,
|
|
15
|
-
formatGitHubReadFileResult,
|
|
16
|
-
formatResult
|
|
17
|
-
} from "./chunk-3CPI6ZIC.js";
|
|
1
|
+
import { WARP_GREP_DESCRIPTION, WARP_GREP_TOOL_NAME, GITHUB_SEARCH_INPUT_SCHEMA, GITHUB_SEARCH_DESCRIPTION, GITHUB_SEARCH_TOOL_NAME, GITHUB_READ_FILE_INPUT_SCHEMA, GITHUB_READ_FILE_DESCRIPTION, GITHUB_READ_FILE_TOOL_NAME } from './chunk-UAPK3AIJ.js';
|
|
2
|
+
import { executeToolCall, formatResult, WarpGrepClient, formatGitHubReadFileResult, executeGitHubReadFile } from './chunk-DZP7BR66.js';
|
|
18
3
|
|
|
19
4
|
// tools/warp_grep/openai.ts
|
|
20
5
|
var TOOL_PARAMETERS = {
|
|
@@ -96,11 +81,4 @@ function createGitHubReadFileTool(config) {
|
|
|
96
81
|
}
|
|
97
82
|
var openai_default = warpGrepTool;
|
|
98
83
|
|
|
99
|
-
export {
|
|
100
|
-
warpGrepTool,
|
|
101
|
-
execute,
|
|
102
|
-
createWarpGrepTool,
|
|
103
|
-
createGitHubSearchTool,
|
|
104
|
-
createGitHubReadFileTool,
|
|
105
|
-
openai_default
|
|
106
|
-
};
|
|
84
|
+
export { createGitHubReadFileTool, createGitHubSearchTool, createWarpGrepTool, execute, openai_default, warpGrepTool };
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from "./chunk-PA3UTI4A.js";
|
|
5
|
-
import {
|
|
6
|
-
executeEditFile
|
|
7
|
-
} from "./chunk-65TUD7JV.js";
|
|
8
|
-
import {
|
|
9
|
-
__export
|
|
10
|
-
} from "./chunk-MLKGABMK.js";
|
|
1
|
+
import { EDIT_FILE_TOOL_DESCRIPTION, EDIT_FILE_SYSTEM_PROMPT } from './chunk-PA3UTI4A.js';
|
|
2
|
+
import { executeEditFile } from './chunk-DYCMPDPV.js';
|
|
3
|
+
import { __export } from './chunk-MLKGABMK.js';
|
|
11
4
|
|
|
12
5
|
// tools/fastapply/anthropic.ts
|
|
13
6
|
var anthropic_exports = {};
|
|
@@ -71,11 +64,4 @@ function getSystemPrompt() {
|
|
|
71
64
|
return EDIT_FILE_SYSTEM_PROMPT;
|
|
72
65
|
}
|
|
73
66
|
|
|
74
|
-
export {
|
|
75
|
-
editFileTool,
|
|
76
|
-
formatResult,
|
|
77
|
-
createEditFileTool,
|
|
78
|
-
execute,
|
|
79
|
-
getSystemPrompt,
|
|
80
|
-
anthropic_exports
|
|
81
|
-
};
|
|
67
|
+
export { anthropic_exports, createEditFileTool, editFileTool, execute, formatResult, getSystemPrompt };
|
package/dist/chunk-44OIEPIO.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-M34E2AMK.js";
|
|
1
|
+
import { AGENT_CONFIG } from './chunk-M34E2AMK.js';
|
|
2
|
+
import path from 'path';
|
|
4
3
|
|
|
5
4
|
// tools/warp_grep/agent/tools/grep.ts
|
|
6
5
|
async function toolGrep(provider, args) {
|
|
@@ -48,9 +47,6 @@ async function toolRead(provider, args) {
|
|
|
48
47
|
if (!res.lines.length) return "(empty file)";
|
|
49
48
|
return res.lines.join("\n");
|
|
50
49
|
}
|
|
51
|
-
|
|
52
|
-
// tools/warp_grep/agent/tools/list_directory.ts
|
|
53
|
-
import path from "path";
|
|
54
50
|
async function toolListDirectory(provider, args, repoRoot) {
|
|
55
51
|
const maxResults = args.maxResults ?? AGENT_CONFIG.MAX_LIST_RESULTS;
|
|
56
52
|
const maxDepth = args.maxDepth ?? AGENT_CONFIG.MAX_LIST_DEPTH;
|
|
@@ -153,9 +149,6 @@ function mergeRanges(ranges) {
|
|
|
153
149
|
merged.push([cs, ce]);
|
|
154
150
|
return merged;
|
|
155
151
|
}
|
|
156
|
-
|
|
157
|
-
// tools/warp_grep/agent/helpers.ts
|
|
158
|
-
import path2 from "path";
|
|
159
152
|
var TRUNCATED_MARKER = "[truncated for context limit]";
|
|
160
153
|
function getMessageSize(m) {
|
|
161
154
|
if (m.role === "tool") return m.content.length;
|
|
@@ -198,7 +191,7 @@ async function buildInitialState(repoRoot, searchTerm, provider, options) {
|
|
|
198
191
|
});
|
|
199
192
|
const lines = [absRoot];
|
|
200
193
|
for (const e of entries) {
|
|
201
|
-
lines.push(
|
|
194
|
+
lines.push(path.join(absRoot, e.path));
|
|
202
195
|
}
|
|
203
196
|
return `<repo_structure>
|
|
204
197
|
${lines.join("\n")}
|
|
@@ -262,16 +255,4 @@ function enforceContextLimit(messages, maxChars = AGENT_CONFIG.MAX_CONTEXT_CHARS
|
|
|
262
255
|
return messages;
|
|
263
256
|
}
|
|
264
257
|
|
|
265
|
-
export {
|
|
266
|
-
toolGrep,
|
|
267
|
-
toolRead,
|
|
268
|
-
toolListDirectory,
|
|
269
|
-
toolGlob,
|
|
270
|
-
normalizeFinishFiles,
|
|
271
|
-
readFinishFiles,
|
|
272
|
-
formatTurnMessage,
|
|
273
|
-
calculateContextBudget,
|
|
274
|
-
buildInitialState,
|
|
275
|
-
formatListDirectoryTree,
|
|
276
|
-
enforceContextLimit
|
|
277
|
-
};
|
|
258
|
+
export { buildInitialState, calculateContextBudget, enforceContextLimit, formatListDirectoryTree, formatTurnMessage, normalizeFinishFiles, readFinishFiles, toolGlob, toolGrep, toolListDirectory, toolRead };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// tools/warp_grep/agent/config.ts
|
|
4
|
+
var parseEnvTimeout = (envValue, defaultMs) => {
|
|
5
|
+
if (!envValue) return defaultMs;
|
|
6
|
+
const parsed = parseInt(envValue, 10);
|
|
7
|
+
return isNaN(parsed) || parsed <= 0 ? defaultMs : parsed;
|
|
8
|
+
};
|
|
9
|
+
var AGENT_CONFIG = {
|
|
10
|
+
MAX_TURNS: 6,
|
|
11
|
+
/** Default timeout for model calls. Can be overridden via MORPH_WARP_GREP_TIMEOUT env var (in ms) */
|
|
12
|
+
TIMEOUT_MS: parseEnvTimeout(process.env.MORPH_WARP_GREP_TIMEOUT, 6e4),
|
|
13
|
+
MAX_CONTEXT_CHARS: 321600,
|
|
14
|
+
MAX_OUTPUT_LINES: 200,
|
|
15
|
+
MAX_LIST_RESULTS: 500,
|
|
16
|
+
MAX_READ_LINES: 800,
|
|
17
|
+
MAX_LIST_DEPTH: 3,
|
|
18
|
+
LIST_TIMEOUT_MS: 2e3
|
|
19
|
+
};
|
|
20
|
+
var BUILTIN_EXCLUDES = [
|
|
21
|
+
// Version control
|
|
22
|
+
".git",
|
|
23
|
+
".svn",
|
|
24
|
+
".hg",
|
|
25
|
+
".bzr",
|
|
26
|
+
// Dependencies
|
|
27
|
+
"node_modules",
|
|
28
|
+
"bower_components",
|
|
29
|
+
".pnpm",
|
|
30
|
+
".yarn",
|
|
31
|
+
"vendor",
|
|
32
|
+
"packages",
|
|
33
|
+
"Pods",
|
|
34
|
+
".bundle",
|
|
35
|
+
// Python
|
|
36
|
+
"__pycache__",
|
|
37
|
+
".pytest_cache",
|
|
38
|
+
".mypy_cache",
|
|
39
|
+
".ruff_cache",
|
|
40
|
+
".venv",
|
|
41
|
+
"venv",
|
|
42
|
+
".tox",
|
|
43
|
+
".nox",
|
|
44
|
+
".eggs",
|
|
45
|
+
"*.egg-info",
|
|
46
|
+
// Build outputs
|
|
47
|
+
"dist",
|
|
48
|
+
"build",
|
|
49
|
+
"out",
|
|
50
|
+
"output",
|
|
51
|
+
"target",
|
|
52
|
+
"_build",
|
|
53
|
+
".next",
|
|
54
|
+
".nuxt",
|
|
55
|
+
".output",
|
|
56
|
+
".vercel",
|
|
57
|
+
".netlify",
|
|
58
|
+
// Cache directories
|
|
59
|
+
".cache",
|
|
60
|
+
".parcel-cache",
|
|
61
|
+
".turbo",
|
|
62
|
+
".nx",
|
|
63
|
+
".gradle",
|
|
64
|
+
// IDE/Editor
|
|
65
|
+
".idea",
|
|
66
|
+
".vscode",
|
|
67
|
+
".vs",
|
|
68
|
+
// Coverage
|
|
69
|
+
"coverage",
|
|
70
|
+
".coverage",
|
|
71
|
+
"htmlcov",
|
|
72
|
+
".nyc_output",
|
|
73
|
+
// Temporary
|
|
74
|
+
"tmp",
|
|
75
|
+
"temp",
|
|
76
|
+
".tmp",
|
|
77
|
+
".temp",
|
|
78
|
+
// Lock files
|
|
79
|
+
"package-lock.json",
|
|
80
|
+
"yarn.lock",
|
|
81
|
+
"pnpm-lock.yaml",
|
|
82
|
+
"bun.lockb",
|
|
83
|
+
"Cargo.lock",
|
|
84
|
+
"Gemfile.lock",
|
|
85
|
+
"poetry.lock",
|
|
86
|
+
// Binary/minified
|
|
87
|
+
"*.min.js",
|
|
88
|
+
"*.min.css",
|
|
89
|
+
"*.bundle.js",
|
|
90
|
+
"*.wasm",
|
|
91
|
+
"*.so",
|
|
92
|
+
"*.dll",
|
|
93
|
+
"*.pyc",
|
|
94
|
+
"*.map",
|
|
95
|
+
"*.js.map",
|
|
96
|
+
// Hidden directories catch-all
|
|
97
|
+
".*"
|
|
98
|
+
];
|
|
99
|
+
var DEFAULT_EXCLUDES = (process.env.MORPH_WARP_GREP_EXCLUDE || "").split(",").map((s) => s.trim()).filter(Boolean).concat(BUILTIN_EXCLUDES);
|
|
100
|
+
var DEFAULT_MODEL = "morph-warp-grep-v2.1";
|
|
101
|
+
|
|
102
|
+
exports.AGENT_CONFIG = AGENT_CONFIG;
|
|
103
|
+
exports.DEFAULT_EXCLUDES = DEFAULT_EXCLUDES;
|
|
104
|
+
exports.DEFAULT_MODEL = DEFAULT_MODEL;
|
package/dist/chunk-4OUGA3KS.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SDK_VERSION
|
|
3
|
-
} from "./chunk-E6TL6MIH.js";
|
|
1
|
+
import { SDK_VERSION } from './chunk-GYE3FY6Z.js';
|
|
4
2
|
|
|
5
3
|
// tools/utils/resilience.ts
|
|
6
4
|
var DEFAULT_RETRY_CONFIG = {
|
|
@@ -86,8 +84,4 @@ var MorphError = class extends Error {
|
|
|
86
84
|
}
|
|
87
85
|
};
|
|
88
86
|
|
|
89
|
-
export {
|
|
90
|
-
fetchWithRetry,
|
|
91
|
-
withTimeout,
|
|
92
|
-
MorphError
|
|
93
|
-
};
|
|
87
|
+
export { MorphError, fetchWithRetry, withTimeout };
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
MorphError
|
|
3
|
-
} from "./chunk-VQDDL3UH.js";
|
|
1
|
+
import { MorphError } from './chunk-4TZBUFVP.js';
|
|
4
2
|
|
|
5
3
|
// core/error.ts
|
|
6
4
|
async function toMorphError(response) {
|
|
@@ -18,6 +16,4 @@ async function toMorphError(response) {
|
|
|
18
16
|
return new MorphError(message, code, response.status, retryable);
|
|
19
17
|
}
|
|
20
18
|
|
|
21
|
-
export {
|
|
22
|
-
toMorphError
|
|
23
|
-
};
|
|
19
|
+
export { toMorphError };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkEJTL2BOZ_cjs = require('./chunk-EJTL2BOZ.cjs');
|
|
4
|
+
var chunkJHC2R3HU_cjs = require('./chunk-JHC2R3HU.cjs');
|
|
5
|
+
|
|
6
|
+
// tools/warp_grep/anthropic.ts
|
|
7
|
+
var INPUT_SCHEMA = {
|
|
8
|
+
type: "object",
|
|
9
|
+
properties: {
|
|
10
|
+
search_term: { type: "string", description: "Search problem statement that this subagent is supposed to research for" }
|
|
11
|
+
},
|
|
12
|
+
required: ["search_term"]
|
|
13
|
+
};
|
|
14
|
+
var warpGrepTool = {
|
|
15
|
+
name: chunkEJTL2BOZ_cjs.WARP_GREP_TOOL_NAME,
|
|
16
|
+
description: chunkEJTL2BOZ_cjs.WARP_GREP_DESCRIPTION,
|
|
17
|
+
input_schema: INPUT_SCHEMA
|
|
18
|
+
};
|
|
19
|
+
async function execute(input, config) {
|
|
20
|
+
return chunkJHC2R3HU_cjs.executeToolCall(input, config);
|
|
21
|
+
}
|
|
22
|
+
function createWarpGrepTool(config) {
|
|
23
|
+
const tool = {
|
|
24
|
+
name: config.name ?? chunkEJTL2BOZ_cjs.WARP_GREP_TOOL_NAME,
|
|
25
|
+
description: config.description ?? chunkEJTL2BOZ_cjs.WARP_GREP_DESCRIPTION,
|
|
26
|
+
input_schema: INPUT_SCHEMA
|
|
27
|
+
};
|
|
28
|
+
return Object.assign(tool, {
|
|
29
|
+
execute: async (input) => {
|
|
30
|
+
return chunkJHC2R3HU_cjs.executeToolCall(input, config);
|
|
31
|
+
},
|
|
32
|
+
formatResult: (result) => {
|
|
33
|
+
return chunkJHC2R3HU_cjs.formatResult(result);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function createGitHubSearchTool(config) {
|
|
38
|
+
const client = new chunkJHC2R3HU_cjs.WarpGrepClient(config);
|
|
39
|
+
const tool = {
|
|
40
|
+
name: chunkEJTL2BOZ_cjs.GITHUB_SEARCH_TOOL_NAME,
|
|
41
|
+
description: chunkEJTL2BOZ_cjs.GITHUB_SEARCH_DESCRIPTION,
|
|
42
|
+
input_schema: chunkEJTL2BOZ_cjs.GITHUB_SEARCH_INPUT_SCHEMA
|
|
43
|
+
};
|
|
44
|
+
return Object.assign(tool, {
|
|
45
|
+
execute: async (input) => {
|
|
46
|
+
const github = input.github_url || input.owner_repo;
|
|
47
|
+
if (!github) {
|
|
48
|
+
throw new Error("Please provide github search url or owner/repo id");
|
|
49
|
+
}
|
|
50
|
+
return client.searchGitHub({ searchTerm: input.search_term, github, branch: input.branch });
|
|
51
|
+
},
|
|
52
|
+
formatResult: (result) => {
|
|
53
|
+
return chunkJHC2R3HU_cjs.formatResult(result);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function createGitHubReadFileTool(config) {
|
|
58
|
+
const tool = {
|
|
59
|
+
name: chunkEJTL2BOZ_cjs.GITHUB_READ_FILE_TOOL_NAME,
|
|
60
|
+
description: chunkEJTL2BOZ_cjs.GITHUB_READ_FILE_DESCRIPTION,
|
|
61
|
+
input_schema: chunkEJTL2BOZ_cjs.GITHUB_READ_FILE_INPUT_SCHEMA
|
|
62
|
+
};
|
|
63
|
+
return Object.assign(tool, {
|
|
64
|
+
execute: async (input) => {
|
|
65
|
+
return chunkJHC2R3HU_cjs.executeGitHubReadFile(input, config);
|
|
66
|
+
},
|
|
67
|
+
formatResult: (result) => {
|
|
68
|
+
return chunkJHC2R3HU_cjs.formatGitHubReadFileResult(result);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
exports.createGitHubReadFileTool = createGitHubReadFileTool;
|
|
74
|
+
exports.createGitHubSearchTool = createGitHubSearchTool;
|
|
75
|
+
exports.createWarpGrepTool = createWarpGrepTool;
|
|
76
|
+
exports.execute = execute;
|
|
77
|
+
exports.warpGrepTool = warpGrepTool;
|