@morphllm/morphsdk 0.2.199 → 0.2.201
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/dist/ai-sdk/index.cjs +0 -1
- package/dist/ai-sdk/index.js +0 -1
- package/dist/{chunk-HYRHI2UL.js → chunk-2PPYWRMZ.js} +0 -1
- package/dist/{chunk-IA5K2HTC.js → chunk-44OIEPIO.js} +1 -2
- package/dist/{chunk-FBRNUWEB.js → chunk-4OUGA3KS.js} +0 -1
- package/dist/{chunk-CEXBKXWU.js → chunk-5NSYDT36.js} +3 -4
- package/dist/{chunk-G2RSY56Q.js → chunk-6TZCVTW5.js} +0 -1
- package/dist/{chunk-F3NCFNUX.js → chunk-6WP7EA4F.js} +0 -1
- package/dist/{chunk-5KQ2WRBU.js → chunk-B376VMIH.js} +2 -3
- package/dist/{chunk-OPNTDMHH.js → chunk-BZXOAC2R.js} +6 -7
- package/dist/{chunk-YSFEKIYQ.js → chunk-DBNSOYQ3.js} +2 -3
- package/dist/{chunk-PW6K6OJL.js → chunk-EQAWWVKV.js} +1 -2
- package/dist/{chunk-ZZ25FZG2.js → chunk-ETBRAKVV.js} +0 -1
- package/dist/chunk-FBOZIVVQ.js +0 -0
- package/dist/{chunk-GKRPR5PZ.js → chunk-FVT4PU4I.js} +18 -70
- package/dist/{chunk-MRMBFJR2.js → chunk-HDP4QAZL.js} +0 -1
- package/dist/{chunk-TPP2UGQP.js → chunk-I26FQELI.js} +0 -1
- package/dist/{chunk-BTMMUG3E.js → chunk-ILY5N5NJ.js} +2 -3
- package/dist/{chunk-7UU4NF4G.js → chunk-JBAY3PRV.js} +4 -5
- package/dist/chunk-LDM7RNNN.js +0 -0
- package/dist/{chunk-ZHB57ORD.js → chunk-LISSWRUD.js} +8 -9
- package/dist/{chunk-CCJK3HTG.js → chunk-M34E2AMK.js} +0 -1
- package/dist/{chunk-WDBYAXZ5.js → chunk-M6AVXUM4.js} +2 -3
- package/dist/{chunk-QRXG5CAZ.js → chunk-MF56KEI4.js} +0 -1
- package/dist/{chunk-PZ5AY32C.js → chunk-MLKGABMK.js} +0 -1
- package/dist/{chunk-5TOJD2C5.js → chunk-NRG6QX3L.js} +0 -1
- package/dist/{chunk-GTV27THY.js → chunk-NWGRW4V7.js} +1 -2
- package/dist/{chunk-63VHBANJ.js → chunk-OPDWMD4Q.js} +0 -1
- package/dist/{chunk-O7LJEVZO.js → chunk-OVLUL5AC.js} +5 -6
- package/dist/{chunk-W37OFBSG.js → chunk-P2KW2O5R.js} +2 -3
- package/dist/{chunk-63WE2C5R.js → chunk-PA3UTI4A.js} +0 -1
- package/dist/{chunk-Q3NH3NPD.js → chunk-RJXAXR7Q.js} +5 -6
- package/dist/{chunk-A4D2CIIT.js → chunk-RYVW7RUM.js} +1 -2
- package/dist/{chunk-ULHHMZRL.js → chunk-RZOJ4GSY.js} +4 -5
- package/dist/{chunk-UT3NQLCF.js → chunk-SU7AAS3O.js} +2 -3
- package/dist/{chunk-DP2PT36G.js → chunk-TS3OJ4LA.js} +1 -2
- package/dist/{chunk-BLCCGRKT.js → chunk-TZC3EOZS.js} +5 -6
- package/dist/{chunk-Q6QCHAMD.js → chunk-UAPK3AIJ.js} +0 -1
- package/dist/{chunk-JOC3ZI56.js → chunk-UZCXOOZO.js} +2 -38
- package/dist/{chunk-PKJ7ODTG.js → chunk-VOXUA5ZH.js} +4 -5
- package/dist/{chunk-KXEPBLVD.js → chunk-WBTXEJOC.js} +12 -13
- package/dist/{chunk-YPKNMYD4.js → chunk-ZSHVXDA2.js} +0 -1
- package/dist/{client-CGW0Cevz.d.ts → client-BWhi-vSj.d.ts} +4 -65
- package/dist/client.cjs +45 -413
- package/dist/client.d.ts +2 -4
- package/dist/client.js +32 -38
- package/dist/core/client.cjs +2 -38
- package/dist/core/client.js +6 -7
- package/dist/core/error.cjs +2 -38
- package/dist/core/error.js +4 -5
- package/dist/core/index.cjs +2 -38
- package/dist/core/index.js +8 -9
- package/dist/core/resource.cjs +0 -1
- package/dist/core/resource.js +2 -3
- package/dist/edge.cjs +2 -38
- package/dist/edge.js +10 -11
- package/dist/index.cjs +48 -418
- package/dist/index.d.ts +2 -4
- package/dist/index.js +39 -48
- package/dist/modelrouter/core.cjs +2 -38
- package/dist/modelrouter/core.js +8 -9
- package/dist/modelrouter/index.cjs +2 -38
- package/dist/modelrouter/index.js +8 -9
- package/dist/modelrouter/types.cjs +0 -1
- package/dist/modelrouter/types.js +0 -1
- package/dist/subagents/anthropic.cjs +2 -38
- package/dist/subagents/anthropic.d.ts +1 -1
- package/dist/subagents/anthropic.js +19 -20
- package/dist/subagents/index.cjs +0 -1
- package/dist/subagents/index.d.ts +1 -1
- package/dist/subagents/index.js +2 -3
- package/dist/subagents/prompts.cjs +0 -1
- package/dist/subagents/prompts.d.ts +1 -1
- package/dist/subagents/prompts.js +2 -3
- package/dist/subagents/types.cjs +0 -1
- package/dist/subagents/types.d.ts +1 -1
- package/dist/subagents/types.js +0 -1
- package/dist/subagents/vercel.cjs +2 -38
- package/dist/subagents/vercel.d.ts +1 -1
- package/dist/subagents/vercel.js +19 -20
- package/dist/tools/compact/core.cjs +2 -38
- package/dist/tools/compact/core.js +8 -9
- package/dist/tools/compact/index.cjs +2 -38
- package/dist/tools/compact/index.js +9 -10
- package/dist/tools/compact/types.cjs +0 -1
- package/dist/tools/compact/types.js +0 -1
- package/dist/tools/fastapply/anthropic.cjs +2 -38
- package/dist/tools/fastapply/anthropic.js +11 -12
- package/dist/tools/fastapply/apply.cjs +2 -38
- package/dist/tools/fastapply/apply.js +4 -5
- package/dist/tools/fastapply/core.cjs +2 -38
- package/dist/tools/fastapply/core.js +9 -10
- package/dist/tools/fastapply/index.cjs +2 -38
- package/dist/tools/fastapply/index.js +17 -18
- package/dist/tools/fastapply/openai.cjs +2 -38
- package/dist/tools/fastapply/openai.js +11 -12
- package/dist/tools/fastapply/prompts.cjs +0 -1
- package/dist/tools/fastapply/prompts.js +2 -3
- package/dist/tools/fastapply/types.cjs +0 -1
- package/dist/tools/fastapply/types.js +0 -1
- package/dist/tools/fastapply/vercel.cjs +2 -38
- package/dist/tools/fastapply/vercel.js +11 -12
- package/dist/tools/index.cjs +2 -38
- package/dist/tools/index.js +17 -18
- package/dist/tools/utils/resilience.cjs +2 -38
- package/dist/tools/utils/resilience.js +3 -4
- package/dist/tools/warp_grep/agent/config.cjs +0 -1
- package/dist/tools/warp_grep/agent/config.js +2 -3
- package/dist/tools/warp_grep/agent/formatter.cjs +0 -1
- package/dist/tools/warp_grep/agent/formatter.js +2 -3
- package/dist/tools/warp_grep/agent/parser.cjs +0 -1
- package/dist/tools/warp_grep/agent/parser.js +2 -3
- package/dist/tools/warp_grep/agent/runner.cjs +2 -38
- package/dist/tools/warp_grep/agent/runner.js +7 -8
- package/dist/tools/warp_grep/agent/types.cjs +0 -1
- package/dist/tools/warp_grep/agent/types.js +0 -1
- package/dist/tools/warp_grep/anthropic.cjs +2 -38
- package/dist/tools/warp_grep/anthropic.d.ts +1 -1
- package/dist/tools/warp_grep/anthropic.js +19 -20
- package/dist/tools/warp_grep/client.cjs +2 -38
- package/dist/tools/warp_grep/client.d.ts +1 -1
- package/dist/tools/warp_grep/client.js +17 -18
- package/dist/tools/warp_grep/gemini.cjs +2 -38
- package/dist/tools/warp_grep/gemini.d.ts +1 -1
- package/dist/tools/warp_grep/gemini.js +18 -19
- package/dist/tools/warp_grep/harness.cjs +0 -1
- package/dist/tools/warp_grep/harness.js +14 -15
- package/dist/tools/warp_grep/index.cjs +2 -38
- package/dist/tools/warp_grep/index.d.ts +1 -1
- package/dist/tools/warp_grep/index.js +27 -28
- package/dist/tools/warp_grep/openai.cjs +2 -38
- package/dist/tools/warp_grep/openai.d.ts +1 -1
- package/dist/tools/warp_grep/openai.js +19 -20
- package/dist/tools/warp_grep/providers/code_storage_http.cjs +0 -1
- package/dist/tools/warp_grep/providers/code_storage_http.d.ts +1 -1
- package/dist/tools/warp_grep/providers/code_storage_http.js +2 -3
- package/dist/tools/warp_grep/providers/local.cjs +0 -1
- package/dist/tools/warp_grep/providers/local.js +6 -7
- package/dist/tools/warp_grep/providers/remote.cjs +0 -1
- package/dist/tools/warp_grep/providers/remote.d.ts +1 -1
- package/dist/tools/warp_grep/providers/remote.js +3 -4
- package/dist/tools/warp_grep/providers/types.cjs +0 -1
- package/dist/tools/warp_grep/providers/types.js +0 -1
- package/dist/tools/warp_grep/utils/files.cjs +0 -1
- package/dist/tools/warp_grep/utils/files.js +2 -3
- package/dist/tools/warp_grep/utils/github.cjs +0 -1
- package/dist/tools/warp_grep/utils/github.js +2 -3
- package/dist/tools/warp_grep/utils/paths.cjs +0 -1
- package/dist/tools/warp_grep/utils/paths.js +2 -3
- package/dist/tools/warp_grep/utils/ripgrep.cjs +0 -1
- package/dist/tools/warp_grep/utils/ripgrep.js +2 -3
- package/dist/tools/warp_grep/vercel.cjs +2 -38
- package/dist/tools/warp_grep/vercel.d.ts +1 -1
- package/dist/tools/warp_grep/vercel.js +19 -20
- package/dist/{types-qwD753FR.d.ts → types-DxZLPogx.d.ts} +1 -1
- package/dist/version.cjs +2 -38
- package/dist/version.js +2 -3
- package/package.json +2 -37
- package/dist/ai-sdk/index.cjs.map +0 -1
- package/dist/ai-sdk/index.js.map +0 -1
- package/dist/chunk-5KQ2WRBU.js.map +0 -1
- package/dist/chunk-5TOJD2C5.js.map +0 -1
- package/dist/chunk-63VHBANJ.js.map +0 -1
- package/dist/chunk-63WE2C5R.js.map +0 -1
- package/dist/chunk-7UU4NF4G.js.map +0 -1
- package/dist/chunk-A4D2CIIT.js.map +0 -1
- package/dist/chunk-BLCCGRKT.js.map +0 -1
- package/dist/chunk-BTMMUG3E.js.map +0 -1
- package/dist/chunk-CCJK3HTG.js.map +0 -1
- package/dist/chunk-CEXBKXWU.js.map +0 -1
- package/dist/chunk-DP2PT36G.js.map +0 -1
- package/dist/chunk-EMURAU6J.js +0 -148
- package/dist/chunk-EMURAU6J.js.map +0 -1
- package/dist/chunk-F3NCFNUX.js.map +0 -1
- package/dist/chunk-FBRNUWEB.js.map +0 -1
- package/dist/chunk-G2RSY56Q.js.map +0 -1
- package/dist/chunk-GKRPR5PZ.js.map +0 -1
- package/dist/chunk-GTV27THY.js.map +0 -1
- package/dist/chunk-HYRHI2UL.js.map +0 -1
- package/dist/chunk-IA5K2HTC.js.map +0 -1
- package/dist/chunk-IDMKQWQG.js +0 -214
- package/dist/chunk-IDMKQWQG.js.map +0 -1
- package/dist/chunk-JOC3ZI56.js.map +0 -1
- package/dist/chunk-K2JR2NFQ.js +0 -128
- package/dist/chunk-K2JR2NFQ.js.map +0 -1
- package/dist/chunk-KXEPBLVD.js.map +0 -1
- package/dist/chunk-MEZTHMB2.js +0 -83
- package/dist/chunk-MEZTHMB2.js.map +0 -1
- package/dist/chunk-MRMBFJR2.js.map +0 -1
- package/dist/chunk-O7LJEVZO.js.map +0 -1
- package/dist/chunk-OPNTDMHH.js.map +0 -1
- package/dist/chunk-PKJ7ODTG.js.map +0 -1
- package/dist/chunk-PW6K6OJL.js.map +0 -1
- package/dist/chunk-PZ5AY32C.js.map +0 -1
- package/dist/chunk-Q3NH3NPD.js.map +0 -1
- package/dist/chunk-Q6QCHAMD.js.map +0 -1
- package/dist/chunk-QRXG5CAZ.js.map +0 -1
- package/dist/chunk-RL3ZTXT3.js +0 -58
- package/dist/chunk-RL3ZTXT3.js.map +0 -1
- package/dist/chunk-TLXVGE4R.js +0 -42
- package/dist/chunk-TLXVGE4R.js.map +0 -1
- package/dist/chunk-TPP2UGQP.js.map +0 -1
- package/dist/chunk-ULHHMZRL.js.map +0 -1
- package/dist/chunk-UT3NQLCF.js.map +0 -1
- package/dist/chunk-VS5F2ORN.js +0 -97
- package/dist/chunk-VS5F2ORN.js.map +0 -1
- package/dist/chunk-VZ7BOH2K.js +0 -1
- package/dist/chunk-VZ7BOH2K.js.map +0 -1
- package/dist/chunk-W37OFBSG.js.map +0 -1
- package/dist/chunk-WDBYAXZ5.js.map +0 -1
- package/dist/chunk-X2K57BH6.js +0 -1
- package/dist/chunk-X2K57BH6.js.map +0 -1
- package/dist/chunk-YPKNMYD4.js.map +0 -1
- package/dist/chunk-YQMPVJ2L.js +0 -32
- package/dist/chunk-YQMPVJ2L.js.map +0 -1
- package/dist/chunk-YSFEKIYQ.js.map +0 -1
- package/dist/chunk-ZHB57ORD.js.map +0 -1
- package/dist/chunk-ZZ25FZG2.js.map +0 -1
- package/dist/client.cjs.map +0 -1
- package/dist/client.js.map +0 -1
- package/dist/core/client.cjs.map +0 -1
- package/dist/core/client.js.map +0 -1
- package/dist/core/error.cjs.map +0 -1
- package/dist/core/error.js.map +0 -1
- package/dist/core/index.cjs.map +0 -1
- package/dist/core/index.js.map +0 -1
- package/dist/core/resource.cjs.map +0 -1
- package/dist/core/resource.js.map +0 -1
- package/dist/edge.cjs.map +0 -1
- package/dist/edge.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/modelrouter/core.cjs.map +0 -1
- package/dist/modelrouter/core.js.map +0 -1
- package/dist/modelrouter/index.cjs.map +0 -1
- package/dist/modelrouter/index.js.map +0 -1
- package/dist/modelrouter/types.cjs.map +0 -1
- package/dist/modelrouter/types.js.map +0 -1
- package/dist/otel-CG0uqXjp.d.ts +0 -42
- package/dist/subagents/anthropic.cjs.map +0 -1
- package/dist/subagents/anthropic.js.map +0 -1
- package/dist/subagents/index.cjs.map +0 -1
- package/dist/subagents/index.js.map +0 -1
- package/dist/subagents/prompts.cjs.map +0 -1
- package/dist/subagents/prompts.js.map +0 -1
- package/dist/subagents/types.cjs.map +0 -1
- package/dist/subagents/types.js.map +0 -1
- package/dist/subagents/vercel.cjs.map +0 -1
- package/dist/subagents/vercel.js.map +0 -1
- package/dist/tools/codebase_search/anthropic.cjs +0 -664
- package/dist/tools/codebase_search/anthropic.cjs.map +0 -1
- package/dist/tools/codebase_search/anthropic.d.ts +0 -40
- package/dist/tools/codebase_search/anthropic.js +0 -16
- package/dist/tools/codebase_search/anthropic.js.map +0 -1
- package/dist/tools/codebase_search/core.cjs +0 -606
- package/dist/tools/codebase_search/core.cjs.map +0 -1
- package/dist/tools/codebase_search/core.d.ts +0 -51
- package/dist/tools/codebase_search/core.js +0 -16
- package/dist/tools/codebase_search/core.js.map +0 -1
- package/dist/tools/codebase_search/index.cjs +0 -789
- package/dist/tools/codebase_search/index.cjs.map +0 -1
- package/dist/tools/codebase_search/index.d.ts +0 -12
- package/dist/tools/codebase_search/index.js +0 -32
- package/dist/tools/codebase_search/index.js.map +0 -1
- package/dist/tools/codebase_search/openai.cjs +0 -713
- package/dist/tools/codebase_search/openai.cjs.map +0 -1
- package/dist/tools/codebase_search/openai.d.ts +0 -87
- package/dist/tools/codebase_search/openai.js +0 -26
- package/dist/tools/codebase_search/openai.js.map +0 -1
- package/dist/tools/codebase_search/prompts.cjs +0 -57
- package/dist/tools/codebase_search/prompts.cjs.map +0 -1
- package/dist/tools/codebase_search/prompts.d.ts +0 -7
- package/dist/tools/codebase_search/prompts.js +0 -10
- package/dist/tools/codebase_search/prompts.js.map +0 -1
- package/dist/tools/codebase_search/types.cjs +0 -19
- package/dist/tools/codebase_search/types.cjs.map +0 -1
- package/dist/tools/codebase_search/types.d.ts +0 -50
- package/dist/tools/codebase_search/types.js +0 -1
- package/dist/tools/codebase_search/types.js.map +0 -1
- package/dist/tools/codebase_search/vercel.cjs +0 -626
- package/dist/tools/codebase_search/vercel.cjs.map +0 -1
- package/dist/tools/codebase_search/vercel.d.ts +0 -65
- package/dist/tools/codebase_search/vercel.js +0 -20
- package/dist/tools/codebase_search/vercel.js.map +0 -1
- package/dist/tools/compact/core.cjs.map +0 -1
- package/dist/tools/compact/core.js.map +0 -1
- package/dist/tools/compact/index.cjs.map +0 -1
- package/dist/tools/compact/index.js.map +0 -1
- package/dist/tools/compact/types.cjs.map +0 -1
- package/dist/tools/compact/types.js.map +0 -1
- package/dist/tools/fastapply/anthropic.cjs.map +0 -1
- package/dist/tools/fastapply/anthropic.js.map +0 -1
- package/dist/tools/fastapply/apply.cjs.map +0 -1
- package/dist/tools/fastapply/apply.js.map +0 -1
- package/dist/tools/fastapply/core.cjs.map +0 -1
- package/dist/tools/fastapply/core.js.map +0 -1
- package/dist/tools/fastapply/index.cjs.map +0 -1
- package/dist/tools/fastapply/index.js.map +0 -1
- package/dist/tools/fastapply/openai.cjs.map +0 -1
- package/dist/tools/fastapply/openai.js.map +0 -1
- package/dist/tools/fastapply/prompts.cjs.map +0 -1
- package/dist/tools/fastapply/prompts.js.map +0 -1
- package/dist/tools/fastapply/types.cjs.map +0 -1
- package/dist/tools/fastapply/types.js.map +0 -1
- package/dist/tools/fastapply/vercel.cjs.map +0 -1
- package/dist/tools/fastapply/vercel.js.map +0 -1
- package/dist/tools/index.cjs.map +0 -1
- package/dist/tools/index.js.map +0 -1
- package/dist/tools/utils/resilience.cjs.map +0 -1
- package/dist/tools/utils/resilience.js.map +0 -1
- package/dist/tools/warp_grep/agent/config.cjs.map +0 -1
- package/dist/tools/warp_grep/agent/config.js.map +0 -1
- package/dist/tools/warp_grep/agent/formatter.cjs.map +0 -1
- package/dist/tools/warp_grep/agent/formatter.js.map +0 -1
- package/dist/tools/warp_grep/agent/parser.cjs.map +0 -1
- package/dist/tools/warp_grep/agent/parser.js.map +0 -1
- package/dist/tools/warp_grep/agent/runner.cjs.map +0 -1
- package/dist/tools/warp_grep/agent/runner.js.map +0 -1
- package/dist/tools/warp_grep/agent/types.cjs.map +0 -1
- package/dist/tools/warp_grep/agent/types.js.map +0 -1
- package/dist/tools/warp_grep/anthropic.cjs.map +0 -1
- package/dist/tools/warp_grep/anthropic.js.map +0 -1
- package/dist/tools/warp_grep/client.cjs.map +0 -1
- package/dist/tools/warp_grep/client.js.map +0 -1
- package/dist/tools/warp_grep/gemini.cjs.map +0 -1
- package/dist/tools/warp_grep/gemini.js.map +0 -1
- package/dist/tools/warp_grep/harness.cjs.map +0 -1
- package/dist/tools/warp_grep/harness.js.map +0 -1
- package/dist/tools/warp_grep/index.cjs.map +0 -1
- package/dist/tools/warp_grep/index.js.map +0 -1
- package/dist/tools/warp_grep/openai.cjs.map +0 -1
- package/dist/tools/warp_grep/openai.js.map +0 -1
- package/dist/tools/warp_grep/providers/code_storage_http.cjs.map +0 -1
- package/dist/tools/warp_grep/providers/code_storage_http.js.map +0 -1
- package/dist/tools/warp_grep/providers/local.cjs.map +0 -1
- package/dist/tools/warp_grep/providers/local.js.map +0 -1
- package/dist/tools/warp_grep/providers/remote.cjs.map +0 -1
- package/dist/tools/warp_grep/providers/remote.js.map +0 -1
- package/dist/tools/warp_grep/providers/types.cjs.map +0 -1
- package/dist/tools/warp_grep/providers/types.js.map +0 -1
- package/dist/tools/warp_grep/utils/files.cjs.map +0 -1
- package/dist/tools/warp_grep/utils/files.js.map +0 -1
- package/dist/tools/warp_grep/utils/github.cjs.map +0 -1
- package/dist/tools/warp_grep/utils/github.js.map +0 -1
- package/dist/tools/warp_grep/utils/paths.cjs.map +0 -1
- package/dist/tools/warp_grep/utils/paths.js.map +0 -1
- package/dist/tools/warp_grep/utils/ripgrep.cjs.map +0 -1
- package/dist/tools/warp_grep/utils/ripgrep.js.map +0 -1
- package/dist/tools/warp_grep/vercel.cjs.map +0 -1
- package/dist/tools/warp_grep/vercel.js.map +0 -1
- package/dist/tracing/core.cjs +0 -410
- package/dist/tracing/core.cjs.map +0 -1
- package/dist/tracing/core.d.ts +0 -58
- package/dist/tracing/core.js +0 -12
- package/dist/tracing/core.js.map +0 -1
- package/dist/tracing/index.cjs +0 -422
- package/dist/tracing/index.cjs.map +0 -1
- package/dist/tracing/index.d.ts +0 -5
- package/dist/tracing/index.js +0 -17
- package/dist/tracing/index.js.map +0 -1
- package/dist/tracing/interaction.cjs +0 -273
- package/dist/tracing/interaction.cjs.map +0 -1
- package/dist/tracing/interaction.d.ts +0 -41
- package/dist/tracing/interaction.js +0 -11
- package/dist/tracing/interaction.js.map +0 -1
- package/dist/tracing/otel.cjs +0 -56
- package/dist/tracing/otel.cjs.map +0 -1
- package/dist/tracing/otel.d.ts +0 -2
- package/dist/tracing/otel.js +0 -10
- package/dist/tracing/otel.js.map +0 -1
- package/dist/tracing/types.cjs +0 -19
- package/dist/tracing/types.cjs.map +0 -1
- package/dist/tracing/types.d.ts +0 -124
- package/dist/tracing/types.js +0 -1
- package/dist/tracing/types.js.map +0 -1
- package/dist/version.cjs.map +0 -1
- package/dist/version.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../tools/warp_grep/providers/local.ts"],"sourcesContent":["import fs from 'fs/promises';\nimport fssync from 'fs';\nimport path from 'path';\nimport { runRipgrep } from '../utils/ripgrep.js';\nimport { ensureWithinRepo, resolveUnderRepo, toRepoRelative, isSymlink, isTextualFile, fixPathRepetition } from '../utils/paths.js';\nimport type { WarpGrepProvider, GrepResult, ReadResult, GlobResult, ListDirectoryEntry } from './types.js';\nimport { readAllLines } from '../utils/files.js';\nimport { DEFAULT_EXCLUDES, AGENT_CONFIG } from '../agent/config.js';\n\n/**\n * Directories/files to always skip (exact name match)\n */\nconst SKIP_NAMES = new Set([\n // Version control\n '.git', '.svn', '.hg', '.bzr',\n // Dependencies\n 'node_modules', 'bower_components', '.pnpm', '.yarn',\n 'vendor', 'Pods', '.bundle',\n // Python\n '__pycache__', '.pytest_cache', '.mypy_cache', '.ruff_cache',\n '.venv', 'venv', '.tox', '.nox', '.eggs',\n // Build outputs\n 'dist', 'build', 'out', 'output', 'target', '_build',\n '.next', '.nuxt', '.output', '.vercel', '.netlify',\n // Cache\n '.cache', '.parcel-cache', '.turbo', '.nx', '.gradle',\n // IDE\n '.idea', '.vscode', '.vs',\n // Coverage\n 'coverage', '.coverage', 'htmlcov', '.nyc_output',\n // Temp\n 'tmp', 'temp', '.tmp', '.temp',\n // Lock files\n 'package-lock.json', 'yarn.lock', 'pnpm-lock.yaml', 'bun.lockb',\n 'Cargo.lock', 'Gemfile.lock', 'poetry.lock',\n]);\n\n/**\n * File extensions to skip\n */\n\nconst SKIP_EXTENSIONS = new Set([\n '.min.js', '.min.css', '.bundle.js',\n '.wasm', '.so', '.dll', '.pyc',\n '.map', '.js.map',\n]);\n\n/**\n * Check if a filename should be skipped\n */\nfunction shouldSkip(name: string, allowNames?: Set<string>): boolean {\n // Allow explicitly permitted names through\n if (allowNames?.has(name)) return false;\n\n // Skip exact name matches\n if (SKIP_NAMES.has(name)) return true;\n\n // Skip hidden files/directories (start with .)\n if (name.startsWith('.')) return true;\n\n // Skip files with certain extensions\n for (const ext of SKIP_EXTENSIONS) {\n if (name.endsWith(ext)) return true;\n }\n\n return false;\n}\n\nexport class LocalRipgrepProvider implements WarpGrepProvider {\n private readonly allowNames?: Set<string>;\n\n constructor(\n private readonly repoRoot: string,\n private readonly excludes: string[] = DEFAULT_EXCLUDES,\n options?: { allowNames?: string[] },\n ) {\n if (options?.allowNames?.length) {\n this.allowNames = new Set(options.allowNames);\n }\n }\n\n async grep(params: { pattern: string; path: string; glob?: string; context_lines?: number; case_sensitive?: boolean }): Promise<GrepResult> {\n let abs: string;\n try {\n abs = resolveUnderRepo(this.repoRoot, params.path);\n } catch (err) {\n return {\n lines: [],\n error: `[PATH ERROR] ${err instanceof Error ? err.message : String(err)}`,\n };\n }\n const stat = await fs.stat(abs).catch(() => null);\n if (!stat) return { lines: [] };\n const targetArg = abs === path.resolve(this.repoRoot) ? '.' : toRepoRelative(this.repoRoot, abs);\n const contextLines = params.context_lines !== undefined ? String(params.context_lines) : '1';\n const args = [\n '--no-config',\n '--no-heading',\n '--with-filename',\n '--line-number',\n '--color=never',\n '--trim',\n '--max-columns=400',\n '-C', contextLines,\n ...(params.case_sensitive === false ? ['--ignore-case'] : []),\n ...(params.glob ? ['--glob', params.glob] : []),\n ...this.excludes.filter(e => !this.allowNames?.has(e)).flatMap((e) => ['-g', `!${e}`]),\n params.pattern,\n targetArg || '.',\n ];\n const res = await runRipgrep(args, { cwd: this.repoRoot });\n \n // Gracefully handle ripgrep not being available\n if (res.exitCode === -1) {\n return {\n lines: [],\n error: `[RIPGREP NOT AVAILABLE] ripgrep (rg) is required but failed to execute. Please install it:\\n` +\n ` • macOS: brew install ripgrep\\n` +\n ` • Ubuntu/Debian: apt install ripgrep\\n` +\n ` • Windows: choco install ripgrep\\n` +\n ` • Or visit: https://github.com/BurntSushi/ripgrep#installation\\n` +\n `Exit code: ${res.exitCode}${res.stderr ? `\\nDetails: ${res.stderr}` : ''}`,\n };\n }\n \n // Handle other ripgrep errors gracefully\n if (res.exitCode !== 0 && res.exitCode !== 1) {\n return {\n lines: [],\n error: `[RIPGREP ERROR] grep failed with exit code ${res.exitCode}${res.stderr ? `: ${res.stderr}` : ''}`,\n };\n }\n \n const lines = (res.stdout || '')\n .trim()\n .split(/\\r?\\n/)\n .filter((l) => l.length > 0);\n if (lines.length > AGENT_CONFIG.MAX_OUTPUT_LINES) {\n const truncated = lines.slice(0, AGENT_CONFIG.MAX_OUTPUT_LINES);\n truncated.push(`... (output truncated at ${AGENT_CONFIG.MAX_OUTPUT_LINES} of ${lines.length} lines)`);\n return { lines: truncated };\n }\n \n return { lines };\n }\n\n async read(params: { path: string; start?: number; end?: number }): Promise<ReadResult> {\n let abs: string;\n try {\n abs = resolveUnderRepo(this.repoRoot, params.path);\n } catch (err) {\n return {\n lines: [],\n error: `[PATH ERROR] ${err instanceof Error ? err.message : String(err)}`,\n };\n }\n let stat = await fs.stat(abs).catch(() => null);\n\n // Handle duplicate path segments from model predictions\n if (!stat || !stat.isFile()) {\n const fixedPath = fixPathRepetition(abs);\n if (fixedPath) {\n const fixedStat = await fs.stat(fixedPath).catch(() => null);\n if (fixedStat?.isFile()) {\n abs = fixedPath;\n stat = fixedStat;\n }\n }\n }\n\n // Gracefully handle file not found / not a file\n if (!stat || !stat.isFile()) {\n return {\n lines: [],\n error: `[FILE NOT FOUND] You tried to read \"${params.path}\" but there is no file at this path. ` +\n `Double-check the path exists and is spelled correctly.`,\n };\n }\n \n // Gracefully handle symlinks\n if (isSymlink(abs)) {\n return {\n lines: [],\n error: `[SYMLINK] You tried to read \"${params.path}\" but this is a symlink. ` +\n `Try reading the actual file it points to instead.`,\n };\n }\n \n // Gracefully handle non-text or too-large files\n if (!isTextualFile(abs)) {\n return {\n lines: [],\n error: `[UNREADABLE FILE] You tried to read \"${params.path}\" but this file is either too large ` +\n `or not a text file, so it cannot be read. Try a different file.`,\n };\n }\n \n let lines: string[];\n try {\n lines = await readAllLines(abs);\n } catch (err) {\n return {\n lines: [],\n error: `[READ ERROR] Failed to read \"${params.path}\": ${err instanceof Error ? err.message : String(err)}`,\n };\n }\n const total = lines.length;\n const rawStart = params.start;\n const rawEnd = params.end;\n \n let s = 1;\n let e = total;\n \n const startValid = rawStart === undefined || (Number.isFinite(rawStart) && rawStart > 0);\n const endValid = rawEnd === undefined || (Number.isFinite(rawEnd) && rawEnd > 0);\n \n if (startValid && endValid) {\n s = rawStart ?? 1;\n e = Math.min(rawEnd ?? total, total);\n if ((s > total && total > 0) || (s > e)) {\n s = 1;\n e = total;\n }\n }\n const out: string[] = [];\n for (let i = s; i <= e; i += 1) {\n const content = lines[i - 1] ?? '';\n out.push(`${i}|${content}`);\n }\n if (out.length > AGENT_CONFIG.MAX_READ_LINES) {\n const truncated = out.slice(0, AGENT_CONFIG.MAX_READ_LINES);\n truncated.push(`... (output truncated at ${AGENT_CONFIG.MAX_READ_LINES} of ${out.length} lines)`);\n return { lines: truncated };\n }\n \n return { lines: out };\n }\n\n async listDirectory(params: { path: string; pattern?: string | null; maxResults?: number; maxDepth?: number }): Promise<ListDirectoryEntry[]> {\n let abs: string;\n try {\n abs = resolveUnderRepo(this.repoRoot, params.path);\n } catch {\n // Path outside repo - return empty (graceful failure)\n return [];\n }\n const stat = await fs.stat(abs).catch(() => null);\n if (!stat || !stat.isDirectory()) {\n return [];\n }\n const maxResults = params.maxResults ?? AGENT_CONFIG.MAX_OUTPUT_LINES;\n const maxDepth = params.maxDepth ?? AGENT_CONFIG.MAX_LIST_DEPTH;\n const regex = params.pattern ? new RegExp(params.pattern) : null;\n const repoRoot = this.repoRoot;\n const allowNames = this.allowNames;\n\n const results: ListDirectoryEntry[] = [];\n let timedOut = false;\n const startTime = Date.now();\n\n async function walk(dir: string, depth: number) {\n if (Date.now() - startTime > AGENT_CONFIG.LIST_TIMEOUT_MS) {\n timedOut = true;\n return;\n }\n if (depth > maxDepth || results.length >= maxResults) return;\n let entries: import('fs').Dirent[];\n try {\n entries = await fs.readdir(dir, { withFileTypes: true });\n } catch {\n return; // skip unreadable directories (ENOENT, EACCES, etc.)\n }\n for (const entry of entries) {\n if (timedOut || results.length >= maxResults) break;\n\n // Simple name-based filtering - skip junk dirs/files\n if (shouldSkip(entry.name, allowNames)) continue;\n \n // Apply user-provided pattern filter\n if (regex && !regex.test(entry.name)) continue;\n \n const full = path.join(dir, entry.name);\n const isDir = entry.isDirectory();\n \n results.push({\n name: entry.name,\n path: toRepoRelative(repoRoot, full),\n type: isDir ? 'dir' : 'file',\n depth,\n });\n if (isDir) {\n await walk(full, depth + 1);\n }\n }\n }\n await walk(abs, 0);\n return results;\n }\n\n async glob(params: { pattern: string; path?: string }): Promise<GlobResult> {\n let abs: string;\n try {\n abs = params.path ? resolveUnderRepo(this.repoRoot, params.path) : this.repoRoot;\n } catch (err) {\n return { files: [], searchDir: this.repoRoot, totalFound: 0, error: `[PATH ERROR] ${err instanceof Error ? err.message : String(err)}` };\n }\n const stat = await fs.stat(abs).catch(() => null);\n if (!stat || !stat.isDirectory()) {\n return { files: [], searchDir: abs, totalFound: 0, error: `[PATH ERROR] Directory not found: ${params.path || '.'}` };\n }\n\n const targetArg = abs === path.resolve(this.repoRoot) ? '.' : toRepoRelative(this.repoRoot, abs);\n const args = [\n '--no-config',\n '--files',\n '--color=never',\n '-g', params.pattern,\n ...this.excludes.filter(e => !this.allowNames?.has(e)).flatMap(e => ['-g', `!${e}`]),\n targetArg || '.',\n ];\n\n const res = await runRipgrep(args, { cwd: this.repoRoot });\n if (res.exitCode === -1) {\n return { files: [], searchDir: abs, totalFound: 0, error: `[RIPGREP NOT AVAILABLE] ripgrep (rg) is required for glob search.` };\n }\n if (res.exitCode !== 0 && res.exitCode !== 1) {\n return { files: [], searchDir: abs, totalFound: 0, error: `[GLOB ERROR] glob failed with exit code ${res.exitCode}${res.stderr ? `: ${res.stderr}` : ''}` };\n }\n\n // Convert to absolute paths\n const absRoot = path.resolve(this.repoRoot);\n const relFiles = (res.stdout || '').trim().split(/\\r?\\n/).filter(l => l.length > 0);\n const absFiles = relFiles.map(f => path.resolve(absRoot, f));\n\n // Sort by mtime descending (newest first), matching training format\n const withMtime: Array<{ file: string; mtime: number }> = [];\n for (const f of absFiles) {\n const s = await fs.stat(f).catch(() => null);\n withMtime.push({ file: f, mtime: s?.mtimeMs ?? 0 });\n }\n withMtime.sort((a, b) => b.mtime - a.mtime);\n\n const totalFound = withMtime.length;\n return { files: withMtime.slice(0, 100).map(f => f.file), searchDir: abs, totalFound };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ;AAEf,OAAO,UAAU;AAUjB,IAAM,aAAa,oBAAI,IAAI;AAAA;AAAA,EAEzB;AAAA,EAAQ;AAAA,EAAQ;AAAA,EAAO;AAAA;AAAA,EAEvB;AAAA,EAAgB;AAAA,EAAoB;AAAA,EAAS;AAAA,EAC7C;AAAA,EAAU;AAAA,EAAQ;AAAA;AAAA,EAElB;AAAA,EAAe;AAAA,EAAiB;AAAA,EAAe;AAAA,EAC/C;AAAA,EAAS;AAAA,EAAQ;AAAA,EAAQ;AAAA,EAAQ;AAAA;AAAA,EAEjC;AAAA,EAAQ;AAAA,EAAS;AAAA,EAAO;AAAA,EAAU;AAAA,EAAU;AAAA,EAC5C;AAAA,EAAS;AAAA,EAAS;AAAA,EAAW;AAAA,EAAW;AAAA;AAAA,EAExC;AAAA,EAAU;AAAA,EAAiB;AAAA,EAAU;AAAA,EAAO;AAAA;AAAA,EAE5C;AAAA,EAAS;AAAA,EAAW;AAAA;AAAA,EAEpB;AAAA,EAAY;AAAA,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AC;AAC3D,eAAW,KAAK,UAAU;AACxB,YAAM,IAAI,MAAM,GAAG,KAAK,CAAC,EAAE,MAAM,MAAM,IAAI;AAC3C,gBAAU,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,WAAW,EAAE,CAAC;AAAA,IACpD;AACA,cAAU,KAAK,CAAC,GAAG,MAAM,EAAE,QAAQ,EAAE,KAAK;AAE1C,UAAM,aAAa,UAAU;AAC7B,WAAO,EAAE,OAAO,UAAU,MAAM,GAAG,GAAG,EAAE,IAAI,OAAK,EAAE,IAAI,GAAG,WAAW,KAAK,WAAW;AAAA,EACvF;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../modelrouter/core.ts"],"sourcesContent":["/**\n * Core implementation for intelligent model routing.\n *\n * Routers are thin resources over the shared `MorphAPIClient` transport: they\n * POST to `/v1/router/<provider>` and map the response. Auth, retries, timeouts,\n * and the SDK-version header all live in the transport.\n */\nimport { MorphAPIClient } from '../core/client.js';\nimport { APIResource } from '../core/resource.js';\nimport { MorphError } from '../tools/utils/resilience.js';\nimport { logger } from '../logger.js';\nimport type {\n RouterConfig,\n RouterInput,\n RouterResult,\n RawRouterResult,\n ComplexityLevel,\n Provider,\n ClassifyInput,\n ClassifyResult,\n} from './types.js';\n\nconst DEFAULT_API_URL = 'https://api.morphllm.com';\nconst DEFAULT_TIMEOUT = 5000; // 5 seconds (responses typically <500ms)\n\nfunction resolveClient(clientOrConfig: MorphAPIClient | RouterConfig): MorphAPIClient {\n if (clientOrConfig instanceof MorphAPIClient) return clientOrConfig;\n return new MorphAPIClient({\n apiKey: clientOrConfig.apiKey,\n baseURL: clientOrConfig.apiUrl ?? DEFAULT_API_URL,\n timeout: clientOrConfig.timeout ?? DEFAULT_TIMEOUT,\n retryConfig: clientOrConfig.retryConfig,\n debug: clientOrConfig.debug,\n });\n}\n\nabstract class BaseRouter extends APIResource {\n protected provider: Provider;\n protected timeout: number;\n\n constructor(provider: Provider, clientOrConfig: MorphAPIClient | RouterConfig = {}) {\n super(resolveClient(clientOrConfig));\n this.provider = provider;\n const cfg = clientOrConfig instanceof MorphAPIClient ? {} : clientOrConfig;\n this.timeout = cfg.timeout ?? DEFAULT_TIMEOUT;\n }\n\n /** Throw the historical \"API key is required\" message when no key is resolvable. */\n protected requireApiKey(): void {\n if (!this._client.resolveApiKey()) {\n throw new Error(\n 'Morph API key is required. Set MORPH_API_KEY environment variable or pass apiKey in config.',\n );\n }\n }\n\n /** POST to the router and surface failures as `Router API error (<status>): ...`. */\n protected async route<T>(provider: string, input: RouterInput): Promise<T> {\n try {\n return await this._client.post<T>(`/v1/router/${provider}`, {\n body: { input: input.input, mode: input.mode || 'balanced' },\n timeout: this.timeout,\n });\n } catch (error) {\n if (error instanceof MorphError) {\n throw new Error(`Router API error (${error.statusCode}): ${error.message}`);\n }\n throw error;\n }\n }\n\n /**\n * Select the optimal model for a given input and mode\n */\n async selectModel(input: RouterInput): Promise<RouterResult> {\n this.requireApiKey();\n logger.debug('ModelRouter', 'request', { provider: this.provider, mode: input.mode || 'balanced' });\n const apiResult = await this.route<{ model: string; confidence?: number }>(this.provider, input);\n logger.debug('ModelRouter', 'selected', { provider: this.provider, model: apiResult.model });\n return { model: apiResult.model };\n }\n}\n\n/**\n * OpenAI model router for GPT-5 series\n *\n * @deprecated Prefer `MorphClient` (`new MorphClient({ apiKey }).routers.openai`). In edge\n * runtimes where `MorphClient` is unavailable, pass a shared transport:\n * `new OpenAIRouter(new MorphAPIClient({ apiKey }))`. Kept only for backwards compatibility.\n */\nexport class OpenAIRouter extends BaseRouter {\n constructor(clientOrConfig: MorphAPIClient | RouterConfig = {}) {\n super('openai', clientOrConfig);\n }\n\n /**\n * Select optimal GPT-5 model\n *\n * @param input - User input and mode\n * @returns Selected model name (gpt-5-mini | gpt-5-low | gpt-5-medium | gpt-5-high)\n */\n async selectModel(input: RouterInput): Promise<RouterResult> {\n return super.selectModel(input);\n }\n}\n\n/**\n * Anthropic model router for Claude 4.5 series\n *\n * @deprecated Prefer `MorphClient` (`new MorphClient({ apiKey }).routers.anthropic`). In edge\n * runtimes where `MorphClient` is unavailable, pass a shared transport:\n * `new AnthropicRouter(new MorphAPIClient({ apiKey }))`. Kept only for backwards compatibility.\n */\nexport class AnthropicRouter extends BaseRouter {\n constructor(clientOrConfig: MorphAPIClient | RouterConfig = {}) {\n super('anthropic', clientOrConfig);\n }\n\n /**\n * Select optimal Claude model\n *\n * @param input - User input and mode\n * @returns Selected model name (claude-4.5-haiku | claude-4.5-sonnet)\n */\n async selectModel(input: RouterInput): Promise<RouterResult> {\n return super.selectModel(input);\n }\n}\n\n/**\n * Google Gemini model router\n *\n * @deprecated Prefer `MorphClient` (`new MorphClient({ apiKey }).routers.gemini`). In edge\n * runtimes where `MorphClient` is unavailable, pass a shared transport:\n * `new GeminiRouter(new MorphAPIClient({ apiKey }))`. Kept only for backwards compatibility.\n */\nexport class GeminiRouter extends BaseRouter {\n constructor(clientOrConfig: MorphAPIClient | RouterConfig = {}) {\n super('gemini', clientOrConfig);\n }\n\n /**\n * Select optimal Gemini model\n *\n * @param input - User input and mode\n * @returns Selected model name (gemini-2.5-flash | gemini-2.5-pro)\n */\n async selectModel(input: RouterInput): Promise<RouterResult> {\n return super.selectModel(input);\n }\n}\n\n/**\n * Raw difficulty classification router (no provider-specific mapping)\n *\n * @deprecated Prefer `MorphClient` (`new MorphClient({ apiKey }).routers.raw`). In edge\n * runtimes where `MorphClient` is unavailable, pass a shared transport:\n * `new RawRouter(new MorphAPIClient({ apiKey }))`. Kept only for backwards compatibility.\n */\nexport class RawRouter extends BaseRouter {\n constructor(clientOrConfig: MorphAPIClient | RouterConfig = {}) {\n super('raw' as Provider, clientOrConfig);\n }\n\n /**\n * Get raw difficulty classification\n *\n * @param input - User input and mode\n * @returns Raw difficulty (easy | medium | hard | needs_info)\n */\n async classify(input: RouterInput): Promise<RawRouterResult> {\n this.requireApiKey();\n logger.debug('RawRouter', 'request', { mode: input.mode || 'balanced' });\n\n const apiResult = await this.route<{ model?: string; difficulty?: string; confidence?: number }>('raw', input);\n\n // Support both 'model' and 'difficulty' fields for compatibility.\n // Empty string from API means \"medium\" difficulty (API bug workaround).\n let difficulty: ComplexityLevel;\n if (apiResult.difficulty === '') {\n difficulty = 'medium';\n } else {\n difficulty = (apiResult.difficulty || apiResult.model) as ComplexityLevel;\n }\n\n logger.debug('RawRouter', 'classified', { difficulty });\n return { difficulty };\n }\n}\n\n/**\n * Classifier for `/v1/router/classify`.\n *\n * Returns the raw difficulty/ambiguity/domain signals without mapping them to a\n * model. The caller owns the policy — this is what `@morphllm/morphrouter` uses\n * so the routing matrix configured in the dashboard stays the source of truth.\n */\nexport class RouterClassifier extends APIResource {\n private timeout: number;\n\n constructor(clientOrConfig: MorphAPIClient | RouterConfig = {}) {\n super(resolveClient(clientOrConfig));\n const cfg = clientOrConfig instanceof MorphAPIClient ? {} : clientOrConfig;\n this.timeout = cfg.timeout ?? DEFAULT_TIMEOUT;\n }\n\n /** Classify an input across the requested axes (all three by default). */\n async classify(input: ClassifyInput): Promise<ClassifyResult> {\n if (!this._client.resolveApiKey()) {\n throw new Error(\n 'Morph API key is required. Set MORPH_API_KEY environment variable or pass apiKey in config.',\n );\n }\n logger.debug('RouterClassifier', 'request', { classes: input.classes ?? 'all' });\n try {\n const res = await this._client.post<{ classifications: ClassifyResult }>('/v1/router/classify', {\n body: { input: input.input, ...(input.classes ? { classes: input.classes } : {}) },\n timeout: this.timeout,\n });\n logger.debug('RouterClassifier', 'classified', {\n difficulty: res.classifications.difficulty?.label,\n ambiguity: res.classifications.ambiguity?.label,\n domain: res.classifications.domain?.label,\n });\n return res.classifications;\n } catch (error) {\n if (error instanceof MorphError) {\n throw new Error(`Router API error (${error.statusCode}): ${error.message}`);\n }\n throw error;\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAsBA,IAAM,kBAAkB;AACxB,IAAM,kBAAkB;AAExB,SAAS,cAAc,gBAA+D;AACpF,MAAI,0BAA0B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AAW;AAAA,EACtB;AACF;AASO,IAAM,mBAAN,cAA+B,YAAY;AAAA,EACxC;AAAA,EAER,YAAY,iBAAgD,CAAC,GAAG;AAC9D,UAAM,cAAc,cAAc,CAAC;AACnC,UAAM,MAAM,0BAA0B,iBAAiB,CAAC,IAAI;AAC5D,SAAK,UAAU,IAAI,WAAW;AAAA,EAChC;AAAA;AAAA,EAGA,MAAM,SAAS,OAA+C;AAC5D,QAAI,CAAC,KAAK,QAAQ,cAAc,GAAG;AACjC,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AACA,WAAO,MAAM,oBAAoB,WAAW,EAAE,SAAS,MAAM,WAAW,MAAM,CAAC;AAC/E,QAAI;AACF,YAAM,MAAM,MAAM,KAAK,QAAQ,KAA0C,uBAAuB;AAAA,QAC9F,MAAM,EAAE,OAAO,MAAM,OAAO,GAAI,MAAM,UAAU,EAAE,SAAS,MAAM,QAAQ,IAAI,CAAC,EAAG;AAAA,QACjF,SAAS,KAAK;AAAA,MAChB,CAAC;AACD,aAAO,MAAM,oBAAoB,cAAc;AAAA,QAC7C,YAAY,IAAI,gBAAgB,YAAY;AAAA,QAC5C,WAAW,IAAI,gBAAgB,WAAW;AAAA,QAC1C,QAAQ,IAAI,gBAAgB,QAAQ;AAAA,MACtC,CAAC;AACD,aAAO,IAAI;AAAA,IACb,SAAS,OAAO;AACd,UAAI,iBAAiB,YAAY;AAC/B,cAAM,IAAI,MAAM,qBAAqB,MAAM,UAAU,MAAM,MAAM,OAAO,EAAE;AAAA,MAC5E;AACA,YAAM;AAAA,IACR;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../core/error.ts"],"sourcesContent":["/**\n * Single error mapper for the SDK transport.\n *\n * Consolidates the per-tool error handling that used to live in every client\n * (compact, github, …) into one place, preserving the actionable\n * 401/429 messaging. Reuses the existing `MorphError` type so callers that\n * `instanceof MorphError` keep working.\n */\nimport { MorphError } from '../tools/utils/resilience.js';\n\ninterface ApiErrorBody {\n error?: { message?: string; code?: string; type?: string };\n message?: string;\n}\n\n/**\n * Turn a non-OK `Response` into a `MorphError`, extracting the API's error\n * message when present and marking 429/503 as retryable.\n */\nexport async function toMorphError(response: Response): Promise<MorphError> {\n let message = `Morph API request failed (${response.status})`;\n let code = 'api_error';\n\n try {\n const body = (await response.json()) as ApiErrorBody;\n message = body.error?.message ?? body.message ?? message;\n code = body.error?.code ?? body.error?.type ?? code;\n } catch {\n // Non-JSON body — keep the status-based default message.\n }\n\n if (response.status === 401) code = 'authentication_error';\n if (response.status === 429) code = 'rate_limit_exceeded';\n\n const retryable = response.status === 429 || response.status === 503;\n return new MorphError(message, code, response.status, retryable);\n}\n"],"mappings":";;;;;AAmBA,eAAsB,aAAa,UAAyC;AAC1E,MAAI,UAAU,6BAA6B,SAAS,MAAM;AAC1D,MAAI,OAAO;AAEX,MAAI;AACF,UAAM,OAAQ,MAAM,SAAS,KAAK;AAClC,cAAU,KAAK,OAAO,WAAW,KAAK,WAAW;AACjD,WAAO,KAAK,OAAO,QAAQ,KAAK,OAAO,QAAQ;AAAA,EACjD,QAAQ;AAAA,EAER;AAEA,MAAI,SAAS,WAAW,IAAK,QAAO;AACpC,MAAI,SAAS,WAAW,IAAK,QAAO;AAEpC,QAAM,YAAY,SAAS,WAAW,OAAO,SAAS,WAAW;AACjE,SAAO,IAAI,WAAW,SAAS,MAAM,SAAS,QAAQ,SAAS;AACjE;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../tools/fastapply/vercel.ts"],"sourcesContent":["/**\n * Vercel AI SDK adapter for edit_file tool\n */\n\nimport { tool } from 'ai';\nimport { z } from 'zod';\nimport { executeEditFile } from './core.js';\nimport { EDIT_FILE_TOOL_DESCRIPTION, EDIT_FILE_SYSTEM_PROMPT } from './prompts.js';\nimport type { EditFileConfig } from './types.js';\n\n/**\n * Vercel AI SDK tool for edit_file\n * \n * @example\n * ```ts\n * import { generateText } from 'ai';\n * import { anthropic } from '@ai-sdk/anthropic';\n * import { editFileTool } from 'morphsdk/tools/vercel';\n * \n * const result = await generateText({\n * model: anthropic('claude-sonnet-4-5-20250929'),\n * tools: { editFile: editFileTool },\n * prompt: \"Fix the bug in app.ts\"\n * });\n * ```\n */\nconst editFileSchema = z.object({\n target_filepath: z.string().describe('The path of the target file to modify'),\n instruction: z\n .string()\n .describe('A single sentence written in the first person describing what the agent is changing. Used to help disambiguate uncertainty in the edit.'),\n code_edit: z\n .string()\n .describe('Specify ONLY the precise lines of code that you wish to edit. Use `// ... existing code ...` for unchanged sections.'),\n});\n\nexport const editFileTool = tool({\n description: EDIT_FILE_TOOL_DESCRIPTION,\n inputSchema: editFileSchema,\n execute: async (params) => {\n const result = await executeEditFile({\n target_filepath: params.target_filepath,\n instruction: params.instruction,\n code_edit: params.code_edit,\n });\n \n if (!result.success) {\n throw new Error(`Failed to edit file: ${result.error}`);\n }\n \n return {\n success: true,\n filepath: result.filepath,\n changes: result.changes,\n udiff: result.udiff,\n };\n },\n});\n\n/**\n * Get the system prompt for edit_file usage\n * \n * Add this to your system message to guide the model on using edit_file properly.\n * \n * @example\n * ```ts\n * const result = await generateText({\n * model: anthropic('claude-sonnet-4-5-20250929'),\n * system: getSystemPrompt(),\n * tools: { editFile: editFileTool },\n * prompt: \"Fix bugs\"\n * });\n * ```\n */\nexport function getSystemPrompt(): string {\n return EDIT_FILE_SYSTEM_PROMPT;\n}\n\n/**\n * Create a custom edit_file tool with configuration\n * \n * @param config - Configuration options\n * @returns Vercel AI SDK tool with custom config\n * \n * @example\n * ```ts\n * const customEditTool = createEditFileTool({\n * baseDir: './src',\n * generateUdiff: true,\n * description: 'Custom tool description for your use case'\n * });\n * \n * const result = await generateText({\n * model: anthropic('claude-sonnet-4-5-20250929'),\n * tools: { editFile: customEditTool },\n * prompt: \"Fix bugs\"\n * });\n * ```\n */\nexport function createEditFileTool(config: EditFileConfig = {}) {\n const schema = z.object({\n target_filepath: z.string().describe('The path of the target file to modify'),\n instruction: z\n .string()\n .describe('A single sentence written in the first person describing what the agent is changing. Used to help disambiguate uncertainty in the edit.'),\n code_edit: z\n .string()\n .describe('Specify ONLY the precise lines of code that you wish to edit. Use `// ... existing code ...` for unchanged sections.'),\n });\n\n return tool({\n description: config.description || EDIT_FILE_TOOL_DESCRIPTION,\n inputSchema: schema,\n execute: async (params) => {\n const result = await executeEditFile(\n {\n target_filepath: params.target_filepath,\n instruction: params.instruction,\n code_edit: params.code_edit,\n },\n config\n );\n \n if (!result.success) {\n throw new Error(`Failed to edit file: ${result.error}`);\n }\n \n return {\n success: true,\n filepath: result.filepath,\n changes: result.changes,\n udiff: result.udiff,\n };\n },\n });\n}\n\n// Default export for convenience\nexport default editFileTool;\n\n"],"mappings":";;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,SAAS,YAAY;AACrB,SAAS,SAAS;AAqBlB,IAAM,iBAAiB,EAAE,OAAO;AAAA,EAC9B,iBAAiB,EAAE,OAAO,EAAE,SAAS,uCAAuC;AAAA,EAC5E,aAAa,EACV,OAAO,EACP,SAAS,yIAAyI;AAAA,EACrJ,WAAW,EACR,OAAO,EACP,SAAS,sHAAsH;AACpI,CAAC;AAEM,IAAM,eAAe,KAAK;AAAA,EAC/B,aAAa;AAAA,EACb,aAAa;AAAA,EACb,SAAS,OAAO,WAAW;AACzB,UAAM,SAAS,MAAM,gBAAgB;AAAA,MACnC,iBAAiB,OAAO;AAAA,MACxB,aAAa,OAAO;AAAA,MACpB,WAAW,OAAO;AAAA,IACpB,CAAC;AAED,QAAI,CAAC,OAAO,SAAS;AACnB,YAAM,IAAI,MAAM,wBAAwB,OAAO,KAAK,EAAE;AAAA,IACxD;AAEA,WAAO;AAAA,MACL,SAAS;AAAA,MACT,UAAU,OAAO;AAAA,MACjB,SAAS,OAAO;AAAA,MAChB,OAAO,OAAO;AAAA,IAChB;AAAA,EACF;AACF,CAAC;AAiBM,SAAS,kBAA0B;AACxC,SAAO;AACT;AAuBO,SAAS,mBAAmB,SAAyB,CAAC,GAAG;AAC9D,QAAM,SAAS,EAAE,OAAO;AAAA,IACtB,iBAAiB,EAAE,OAAO,EAAE,SAAS,uCAAuC;AAAA,IAC5E,aAAa,EACV,OAAO,EACP,SAAS,yIAAyI;AAAA,IACrJ,WAAW,EACR,OAAO,EACP,SAAS,sHAAsH;AAAA,EACpI,CAAC;AAED,SAAO,KAAK;AAAA,IACV,aAAa,OAAO,eAAe;AAAA,IACnC,aAAa;AAAA,IACb,SAAS,OAAO,WAAW;AACzB,YAAM,SAAS,MAAM;AAAA,QACnB;AAAA,UACE,iBAAiB,OAAO;AAAA,UACxB,aAAa,OAAO;AAAA,UACpB,WAAW,OAAO;AAAA,QACpB;AAAA,QACA;AAAA,MACF;AAEA,UAAI,CAAC,OAAO,SAAS;AACnB,cAAM,IAAI,MAAM,wBAAwB,OAAO,KAAK,EAAE;AAAA,MACxD;AAEA,aAAO;AAAA,QACL,SAAS;AAAA,QACT,UAAU,OAAO;AAAA,QACjB,SAAS,OAAO;AAAA,QAChB,OAAO,OAAO;AAAA,MAChB;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAGA,IAAO,iBAAQ;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../tools/warp_grep/prompts.ts"],"sourcesContent":["/**\n * Prompts and descriptions for codebase_search\n */\n\n/**\n * Default tool name for the warp grep tool\n */\nexport const WARP_GREP_TOOL_NAME = 'codebase_search';\n\n/**\n * Default tool description for the warp grep tool\n */\nexport const WARP_GREP_DESCRIPTION = \n 'Very fast code search exploration subagent (not a grep tool) that runs parallel grep and file read calls over multiple turns to locate relevant files and line ranges. ' +\n 'The search term should be a targeted natural-language query describing what you are trying to find or accomplish, e.g. ' +\n '\"Find where authentication requests are handled in the Express routes\" or \"How do callers of processOrder handle the error case?\". ' +\n 'Fill in extra context you can infer to make the query specific. Do not pass bare keywords or symbol names — use grep directly for exact symbol lookups. ' +\n 'Use this tool first when exploring unfamiliar code. The results may be partial — follow up with classical search tools or direct file reads if needed.'\n 'When a task requires exploration beyond a single known file, ALWAYS default to warpgrep codebase search before other search mechanisms.'\n\nexport const GITHUB_WARP_GREP_SEARCH_TOOL_NAME = 'github_codebase_search';\n\nexport const GITHUB_WARP_GREP_SEARCH_DESCRIPTION =\n 'Always use this when debugging errors in third-party dependencies to check for upstream fixes, open issues, or newer code pathsSearch tool for public GitHub repositories.' +\n 'Code search exploration subagent for public GitHub repositories (not your local workspace — use codebase_search for that). ' +\n 'Runs parallel grep and file read calls to locate relevant files and line ranges in external github repositories without cloning the repository. ' +\n 'Pass a targeted natural-language query, not bare keywords. Useful for understanding how a library works or investigating upstream bugs. ' +\n 'You must provide either github_url or owner_repo (at least one required). '\n\nexport const GITHUB_WARP_GREP_SEARCH_INPUT_SCHEMA = {\n type: 'object' as const,\n properties: {\n search_term: { type: 'string' as const, description: 'A targeted natural-language query describing what to find (e.g. \"How does auth work for SSO users?\"). Not a keyword or symbol name.' },\n github_url: { type: 'string' as const, description: 'GitHub repository URL to search (e.g. \"https://github.com/vercel/next.js\"). You must provide either github_url or owner_repo.' },\n owner_repo: { type: 'string' as const, description: 'Repository owner/repo shorthand (e.g. \"vercel/next.js\"). You must provide either github_url or owner_repo.' },\n branch: { type: 'string' as const, description: 'Branch to search (defaults to the repository default branch)' },\n },\n required: ['search_term'] as const,\n};\n\nexport const GITHUB_SEARCH_TOOL_NAME = GITHUB_WARP_GREP_SEARCH_TOOL_NAME;\nexport const GITHUB_SEARCH_DESCRIPTION = GITHUB_WARP_GREP_SEARCH_DESCRIPTION;\nexport const GITHUB_SEARCH_INPUT_SCHEMA = GITHUB_WARP_GREP_SEARCH_INPUT_SCHEMA;\n\nexport const GITHUB_READ_FILE_TOOL_NAME = 'readfile_github_search';\n\nexport const GITHUB_READ_FILE_DESCRIPTION =\n 'Read a single file (or a line range) from a public GitHub repository. ' +\n 'ONLY USE THIS WHEN YOU ALREADY KNOW THE EXACT FILE PATH YOU WANT TO READ, for example after finding it via github_codebase_search results. ' +\n 'Takes owner/repo shorthand and the file path within the repo. Optionally specify startLine and endLine (1-based) to read a specific range. ' +\n 'Returns the file content with line numbers.';\n\nexport const GITHUB_READ_FILE_INPUT_SCHEMA = {\n type: 'object' as const,\n properties: {\n github: { type: 'string' as const, description: 'owner/repo shorthand (e.g., \"vercel/next.js\")' },\n path: { type: 'string' as const, description: 'File path within the repository (e.g., \"src/server/index.ts\")' },\n startLine: { type: 'number' as const, description: 'Start line number (1-based). Omit to start from beginning.' },\n endLine: { type: 'number' as const, description: 'End line number (1-based, inclusive). Omit to read to the end.' },\n branch: { type: 'string' as const, description: 'Branch to read from (defaults to the repository default branch)' },\n },\n required: ['github', 'path'] as const,\n};\n"],"mappings":";AAOO,IAAM,sBAAsB;AAK5B,IAAM,wBACX;AAOK,IAAM,oCAAoC;AAE1C,IAAM,sCACX;AAMK,IAAM,uCAAuC;AAAA,EAClD,MAAM;AAAA,EACN,YAAY;AAAA,IACV,aAAa,EAAE,MAAM,UAAmB,aAAa,sIAAsI;AAAA,IAC3L,YAAY,EAAE,MAAM,UAAmB,aAAa,gIAAgI;AAAA,IACpL,YAAY,EAAE,MAAM,UAAmB,aAAa,6GAA6G;AAAA,IACjK,QAAQ,EAAE,MAAM,UAAmB,aAAa,+DAA+D;AAAA,EACjH;AAAA,EACA,UAAU,CAAC,aAAa;AAC1B;AAEO,IAAM,0BAA0B;AAChC,IAAM,4BAA4B;AAClC,IAAM,6BAA6B;AAEnC,IAAM,6BAA6B;AAEnC,IAAM,+BACX;AAKK,IAAM,gCAAgC;AAAA,EAC3C,MAAM;AAAA,EACN,YAAY;AAAA,IACV,QAAQ,EAAE,MAAM,UAAmB,aAAa,gDAAgD;AAAA,IAChG,MAAM,EAAE,MAAM,UAAmB,aAAa,gEAAgE;AAAA,IAC9G,WAAW,EAAE,MAAM,UAAmB,aAAa,6DAA6D;AAAA,IAChH,SAAS,EAAE,MAAM,UAAmB,aAAa,iEAAiE;AAAA,IAClH,QAAQ,EAAE,MAAM,UAAmB,aAAa,kEAAkE;AAAA,EACpH;AAAA,EACA,UAAU,CAAC,UAAU,MAAM;AAC7B;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../tools/warp_grep/agent/formatter.ts"],"sourcesContent":["export class ToolOutputFormatter {\n\tformat(\n\t\ttoolName: string,\n\t\t_args: Record<string, unknown> | null | undefined,\n\t\toutput: string,\n\t\toptions: { isError?: boolean } = {}\n\t): string {\n\t\tconst name = (toolName ?? \"\").trim();\n\t\tif (!name) {\n\t\t\treturn \"\";\n\t\t}\n\t\tconst payload = (output as any)?.toString?.()?.trim?.() ?? \"\";\n\t\tconst isError = Boolean(options.isError);\n\n\t\tif (!payload && !isError) {\n\t\t\treturn \"\";\n\t\t}\n\n\t\treturn `<tool_response>\\n${payload}\\n</tool_response>`;\n\t}\n}\n\nconst sharedFormatter = new ToolOutputFormatter();\n\nexport function formatAgentToolOutput(\n\ttoolName: string,\n\targs: Record<string, unknown> | null | undefined,\n\toutput: string,\n\toptions: { isError?: boolean } = {}\n): string {\n\treturn sharedFormatter.format(toolName, args, output, options);\n}\n"],"mappings":";AAAO,IAAM,sBAAN,MAA0B;AAAA,EAChC,OACC,UACA,OACA,QACA,UAAiC,CAAC,GACzB;AACT,UAAM,QAAQ,YAAY,IAAI,KAAK;AACnC,QAAI,CAAC,MAAM;AACV,aAAO;AAAA,IACR;AACA,UAAM,UAAW,QAAgB,WAAW,GAAG,OAAO,KAAK;AAC3D,UAAM,UAAU,QAAQ,QAAQ,OAAO;AAEvC,QAAI,CAAC,WAAW,CAAC,SAAS;AACzB,aAAO;AAAA,IACR;AAEA,WAAO;AAAA,EAAoB,OAAO;AAAA;AAAA,EACnC;AACD;AAEA,IAAM,kBAAkB,IAAI,oBAAoB;AAEzC,SAAS,sBACf,UACA,MACA,QACA,UAAiC,CAAC,GACzB;AACT,SAAO,gBAAgB,OAAO,UAAU,MAAM,QAAQ,OAAO;AAC9D;","names":[]}
|
package/dist/chunk-RL3ZTXT3.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CODEBASE_SEARCH_DESCRIPTION
|
|
3
|
-
} from "./chunk-YQMPVJ2L.js";
|
|
4
|
-
import {
|
|
5
|
-
executeCodebaseSearch
|
|
6
|
-
} from "./chunk-VS5F2ORN.js";
|
|
7
|
-
|
|
8
|
-
// tools/codebase_search/vercel.ts
|
|
9
|
-
import { tool } from "ai";
|
|
10
|
-
import { z } from "zod";
|
|
11
|
-
function createCodebaseSearchTool(config) {
|
|
12
|
-
const schema = z.object({
|
|
13
|
-
query: z.string().describe('A complete question about what you want to understand. Ask as if talking to a colleague: "How does X work?", "What happens when Y?", "Where is Z handled?"'),
|
|
14
|
-
target_directories: z.array(z.string()).describe("Prefix directory paths to limit search scope (single directory only, no glob patterns). Use [] to search entire repo."),
|
|
15
|
-
explanation: z.string().describe("One sentence explanation as to why this tool is being used, and how it contributes to the goal."),
|
|
16
|
-
limit: z.number().optional().describe("Max results to return (default: 10)")
|
|
17
|
-
});
|
|
18
|
-
return tool({
|
|
19
|
-
description: CODEBASE_SEARCH_DESCRIPTION,
|
|
20
|
-
inputSchema: schema,
|
|
21
|
-
execute: async (params) => {
|
|
22
|
-
const { query, target_directories, explanation, limit } = params;
|
|
23
|
-
const result = await executeCodebaseSearch(
|
|
24
|
-
{ query, target_directories, explanation, limit },
|
|
25
|
-
config
|
|
26
|
-
);
|
|
27
|
-
if (!result.success) {
|
|
28
|
-
return {
|
|
29
|
-
error: result.error,
|
|
30
|
-
results: []
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
return {
|
|
34
|
-
found: result.results.length,
|
|
35
|
-
searchTime: `${result.stats.searchTimeMs}ms`,
|
|
36
|
-
results: result.results.map((r) => ({
|
|
37
|
-
file: r.filepath,
|
|
38
|
-
symbol: r.symbolPath,
|
|
39
|
-
lines: `${r.startLine}-${r.endLine}`,
|
|
40
|
-
language: r.language,
|
|
41
|
-
relevance: `${(r.rerankScore * 100).toFixed(1)}%`,
|
|
42
|
-
code: r.content
|
|
43
|
-
}))
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
function getSystemPrompt() {
|
|
49
|
-
return CODEBASE_SEARCH_DESCRIPTION;
|
|
50
|
-
}
|
|
51
|
-
var vercel_default = { createCodebaseSearchTool, getSystemPrompt };
|
|
52
|
-
|
|
53
|
-
export {
|
|
54
|
-
createCodebaseSearchTool,
|
|
55
|
-
getSystemPrompt,
|
|
56
|
-
vercel_default
|
|
57
|
-
};
|
|
58
|
-
//# sourceMappingURL=chunk-RL3ZTXT3.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../tools/codebase_search/vercel.ts"],"sourcesContent":["/**\n * Vercel AI SDK adapter for codebase_search tool\n */\n\nimport { tool } from 'ai';\nimport { z } from 'zod';\nimport { executeCodebaseSearch } from './core.js';\nimport { CODEBASE_SEARCH_DESCRIPTION } from './prompts.js';\nimport type { CodebaseSearchConfig } from './types.js';\n\n/**\n * Create Vercel AI SDK codebase_search tool\n * \n * @param config - Configuration with repoId\n * @returns Vercel AI SDK tool definition (execution built-in)\n * \n * @example\n * ```ts\n * import { generateText } from 'ai';\n * import { anthropic } from '@ai-sdk/anthropic';\n * import { createCodebaseSearchTool } from 'morphsdk/tools/codebase-search/vercel';\n * \n * const tool = createCodebaseSearchTool({ repoId: 'my-project' });\n * \n * const result = await generateText({\n * model: anthropic('claude-3-5-sonnet-20241022'),\n * tools: { codebaseSearch: tool },\n * prompt: \"Find authentication code\",\n * maxSteps: 5\n * });\n * \n * // Vercel AI SDK automatically executes and handles results\n * console.log(result.text);\n * ```\n */\nexport function createCodebaseSearchTool(config: CodebaseSearchConfig) {\n const schema = z.object({\n query: z.string().describe('A complete question about what you want to understand. Ask as if talking to a colleague: \"How does X work?\", \"What happens when Y?\", \"Where is Z handled?\"'),\n target_directories: z.array(z.string()).describe('Prefix directory paths to limit search scope (single directory only, no glob patterns). Use [] to search entire repo.'),\n explanation: z.string().describe('One sentence explanation as to why this tool is being used, and how it contributes to the goal.'),\n limit: z.number().optional().describe('Max results to return (default: 10)'),\n });\n\n return tool({\n description: CODEBASE_SEARCH_DESCRIPTION,\n inputSchema: schema,\n execute: async (params) => {\n const { query, target_directories, explanation, limit } = params;\n const result = await executeCodebaseSearch(\n { query, target_directories, explanation, limit },\n config\n );\n\n if (!result.success) {\n return {\n error: result.error,\n results: [],\n };\n }\n\n // Format results for Vercel AI SDK\n return {\n found: result.results.length,\n searchTime: `${result.stats.searchTimeMs}ms`,\n results: result.results.map(r => ({\n file: r.filepath,\n symbol: r.symbolPath,\n lines: `${r.startLine}-${r.endLine}`,\n language: r.language,\n relevance: `${(r.rerankScore * 100).toFixed(1)}%`,\n code: r.content,\n })),\n };\n },\n });\n}\n\n/**\n * Get system prompt for Vercel AI SDK\n */\nexport function getSystemPrompt(): string {\n return CODEBASE_SEARCH_DESCRIPTION;\n}\n\n/**\n * Default export\n */\nexport default { createCodebaseSearchTool, getSystemPrompt };\n\n"],"mappings":";;;;;;;;AAIA,SAAS,YAAY;AACrB,SAAS,SAAS;AA8BX,SAAS,yBAAyB,QAA8B;AACrE,QAAM,SAAS,EAAE,OAAO;AAAA,IACtB,OAAO,EAAE,OAAO,EAAE,SAAS,4JAA4J;AAAA,IACvL,oBAAoB,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,uHAAuH;AAAA,IACxK,aAAa,EAAE,OAAO,EAAE,SAAS,iGAAiG;AAAA,IAClI,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,qCAAqC;AAAA,EAC7E,CAAC;AAED,SAAO,KAAK;AAAA,IACV,aAAa;AAAA,IACb,aAAa;AAAA,IACb,SAAS,OAAO,WAAW;AACzB,YAAM,EAAE,OAAO,oBAAoB,aAAa,MAAM,IAAI;AAC1D,YAAM,SAAS,MAAM;AAAA,QACnB,EAAE,OAAO,oBAAoB,aAAa,MAAM;AAAA,QAChD;AAAA,MACF;AAEA,UAAI,CAAC,OAAO,SAAS;AACnB,eAAO;AAAA,UACL,OAAO,OAAO;AAAA,UACd,SAAS,CAAC;AAAA,QACZ;AAAA,MACF;AAGA,aAAO;AAAA,QACL,OAAO,OAAO,QAAQ;AAAA,QACtB,YAAY,GAAG,OAAO,MAAM,YAAY;AAAA,QACxC,SAAS,OAAO,QAAQ,IAAI,QAAM;AAAA,UAChC,MAAM,EAAE;AAAA,UACR,QAAQ,EAAE;AAAA,UACV,OAAO,GAAG,EAAE,SAAS,IAAI,EAAE,OAAO;AAAA,UAClC,UAAU,EAAE;AAAA,UACZ,WAAW,IAAI,EAAE,cAAc,KAAK,QAAQ,CAAC,CAAC;AAAA,UAC9C,MAAM,EAAE;AAAA,QACV,EAAE;AAAA,MACJ;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAKO,SAAS,kBAA0B;AACxC,SAAO;AACT;AAKA,IAAO,iBAAQ,EAAE,0BAA0B,gBAAgB;","names":[]}
|
package/dist/chunk-TLXVGE4R.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__export
|
|
3
|
-
} from "./chunk-PZ5AY32C.js";
|
|
4
|
-
|
|
5
|
-
// tracing/otel.ts
|
|
6
|
-
var otel_exports = {};
|
|
7
|
-
__export(otel_exports, {
|
|
8
|
-
default: () => otel_default,
|
|
9
|
-
metadata: () => metadata
|
|
10
|
-
});
|
|
11
|
-
var RESERVED_KEYS = /* @__PURE__ */ new Set(["user_id", "convo_id", "event_id", "event_name"]);
|
|
12
|
-
function uuid() {
|
|
13
|
-
const c = globalThis.crypto;
|
|
14
|
-
if (c?.randomUUID) return c.randomUUID();
|
|
15
|
-
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (ch) => {
|
|
16
|
-
const r = Math.random() * 16 | 0;
|
|
17
|
-
const v = ch === "x" ? r : r & 3 | 8;
|
|
18
|
-
return v.toString(16);
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
function metadata(opts) {
|
|
22
|
-
const result = {
|
|
23
|
-
user_id: opts.userId,
|
|
24
|
-
event_id: opts.eventId ?? uuid()
|
|
25
|
-
};
|
|
26
|
-
if (opts.convoId) result.convo_id = opts.convoId;
|
|
27
|
-
if (opts.eventName) result.event_name = opts.eventName;
|
|
28
|
-
if (opts.properties) {
|
|
29
|
-
for (const [key, value] of Object.entries(opts.properties)) {
|
|
30
|
-
if (!RESERVED_KEYS.has(key)) result[key] = value;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return result;
|
|
34
|
-
}
|
|
35
|
-
var otel_default = { metadata };
|
|
36
|
-
|
|
37
|
-
export {
|
|
38
|
-
metadata,
|
|
39
|
-
otel_default,
|
|
40
|
-
otel_exports
|
|
41
|
-
};
|
|
42
|
-
//# sourceMappingURL=chunk-TLXVGE4R.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../tracing/otel.ts"],"sourcesContent":["/**\n * Morph Tracing — Vercel AI SDK helper.\n *\n * The Vercel AI SDK emits its own OpenTelemetry spans when you pass\n * `experimental_telemetry`. There is nothing to monkey-patch; instead you tag\n * each call with `metadata()` so Morph can attribute the resulting spans to a\n * user/conversation/event.\n *\n * @example\n * ```ts\n * import { generateText } from \"ai\";\n * import { metadata } from \"@morphllm/morphsdk/tracing/otel\";\n *\n * const res = await generateText({\n * model: openai(\"gpt-4o\"),\n * prompt: \"Hello!\",\n * experimental_telemetry: {\n * isEnabled: true,\n * metadata: metadata({ userId: \"user-123\", convoId: \"convo-456\" }),\n * },\n * });\n * ```\n */\nimport type { MetadataOptions } from './types.js';\n\n/**\n * Reserved metadata keys Morph owns. Custom `properties` can't overwrite these,\n * so attribution (user_id / convo_id / event_id) stays intact.\n *\n * The AI SDK stores metadata as `ai.telemetry.metadata.<key>`; Traceloop's span\n * processor copies them to `traceloop.association.properties.<key>`, which is\n * what ClickHouse views read. Use snake_case names (user_id, convo_id, …).\n */\nconst RESERVED_KEYS = new Set(['user_id', 'convo_id', 'event_id', 'event_name']);\n\nfunction uuid(): string {\n // Node 18+ and modern runtimes expose globalThis.crypto.randomUUID.\n const c = (globalThis as { crypto?: { randomUUID?: () => string } }).crypto;\n if (c?.randomUUID) return c.randomUUID();\n // Fallback: RFC4122-ish without crypto.\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (ch) => {\n const r = (Math.random() * 16) | 0;\n const v = ch === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n}\n\n/**\n * Build the metadata object for the Vercel AI SDK's\n * `experimental_telemetry.metadata`. The values are propagated to every span the\n * AI SDK creates for that call. Generate a fresh `eventId` per call for grouping.\n */\nexport function metadata(opts: MetadataOptions): Record<string, string> {\n const result: Record<string, string> = {\n user_id: opts.userId,\n event_id: opts.eventId ?? uuid(),\n };\n if (opts.convoId) result.convo_id = opts.convoId;\n if (opts.eventName) result.event_name = opts.eventName;\n if (opts.properties) {\n for (const [key, value] of Object.entries(opts.properties)) {\n if (!RESERVED_KEYS.has(key)) result[key] = value;\n }\n }\n return result;\n}\n\nexport default { metadata };\n"],"mappings":";;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiCA,IAAM,gBAAgB,oBAAI,IAAI,CAAC,WAAW,YAAY,YAAY,YAAY,CAAC;AAE/E,SAAS,OAAe;AAEtB,QAAM,IAAK,WAA0D;AACrE,MAAI,GAAG,WAAY,QAAO,EAAE,WAAW;AAEvC,SAAO,uCAAuC,QAAQ,SAAS,CAAC,OAAO;AACrE,UAAM,IAAK,KAAK,OAAO,IAAI,KAAM;AACjC,UAAM,IAAI,OAAO,MAAM,IAAK,IAAI,IAAO;AACvC,WAAO,EAAE,SAAS,EAAE;AAAA,EACtB,CAAC;AACH;AAOO,SAAS,SAAS,MAA+C;AACtE,QAAM,SAAiC;AAAA,IACrC,SAAS,KAAK;AAAA,IACd,UAAU,KAAK,WAAW,KAAK;AAAA,EACjC;AACA,MAAI,KAAK,QAAS,QAAO,WAAW,KAAK;AACzC,MAAI,KAAK,UAAW,QAAO,aAAa,KAAK;AAC7C,MAAI,KAAK,YAAY;AACnB,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,KAAK,UAAU,GAAG;AAC1D,UAAI,CAAC,cAAc,IAAI,GAAG,EAAG,QAAO,GAAG,IAAI;AAAA,IAC7C;AAAA,EACF;AACA,SAAO;AACT;AAEA,IAAO,eAAQ,EAAE,SAAS;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../tools/warp_grep/utils/ripgrep.ts"],"sourcesContent":["import { spawn } from 'child_process';\nimport { rgPath } from '@vscode/ripgrep';\n\nexport type ExecResult = { stdout: string; stderr: string; exitCode: number };\n\n// Cache the working ripgrep path to avoid repeated fallback checks\nlet resolvedRgPath: string | null = null;\nlet rgPathChecked = false;\n\nfunction spawnRg(rgBinary: string, args: string[], opts?: { cwd?: string; env?: NodeJS.ProcessEnv }): Promise<ExecResult> {\n return new Promise((resolve) => {\n const child = spawn(rgBinary, args, {\n cwd: opts?.cwd,\n env: { ...process.env, ...(opts?.env || {}) },\n stdio: ['ignore', 'pipe', 'pipe'],\n });\n let stdout = '';\n let stderr = '';\n child.stdout.on('data', (d) => (stdout += d.toString()));\n child.stderr.on('data', (d) => (stderr += d.toString()));\n child.on('close', (code) => {\n resolve({ stdout, stderr, exitCode: typeof code === 'number' ? code : -1 });\n });\n child.on('error', () => {\n resolve({ stdout: '', stderr: 'Failed to spawn ripgrep.', exitCode: -1 });\n });\n });\n}\n\n// Check if a result indicates a binary compatibility failure (not a normal rg error)\nfunction isBinaryFailure(result: ExecResult): boolean {\n // Spawn error\n if (result.exitCode === -1) return true;\n // jemalloc page size issue (common on ARM64 with non-standard page sizes)\n if (result.stderr.includes('jemalloc') || result.stderr.includes('Unsupported system page size')) return true;\n // SIGABRT (134 = 128 + 6)\n if (result.exitCode === 134) return true;\n return false;\n}\n\nexport async function runRipgrep(args: string[], opts?: { cwd?: string; env?: NodeJS.ProcessEnv }): Promise<ExecResult> {\n // If we've already determined the working path, use it\n if (rgPathChecked && resolvedRgPath) {\n return spawnRg(resolvedRgPath, args, opts);\n }\n\n // First attempt: bundled ripgrep\n if (!rgPathChecked) {\n const result = await spawnRg(rgPath, args, opts);\n \n if (!isBinaryFailure(result)) {\n // Bundled binary works, cache it\n resolvedRgPath = rgPath;\n rgPathChecked = true;\n return result;\n }\n\n // Bundled binary failed, try system rg\n const fallbackResult = await spawnRg('rg', args, opts);\n \n if (!isBinaryFailure(fallbackResult)) {\n // System rg works, cache it\n resolvedRgPath = 'rg';\n rgPathChecked = true;\n return fallbackResult;\n }\n\n // Neither works, mark as checked and return the original error\n rgPathChecked = true;\n return { \n stdout: '', \n stderr: 'Failed to spawn ripgrep. Neither bundled nor system rg is available.', \n exitCode: -1 \n };\n }\n\n // rgPathChecked is true but resolvedRgPath is null - no working rg found\n return { \n stdout: '', \n stderr: 'Failed to spawn ripgrep. Neither bundled nor system rg is available.', \n exitCode: -1 \n };\n}\n\n\n"],"mappings":";AAAA,SAAS,aAAa;AACtB,SAAS,cAAc;AAKvB,IAAI,iBAAgC;AACpC,IAAI,gBAAgB;AAEpB,SAAS,QAAQ,UAAkB,MAAgB,MAAuE;AACxH,SAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,UAAM,QAAQ,MAAM,UAAU,MAAM;AAAA,MAClC,KAAK,MAAM;AAAA,MACX,KAAK,EAAE,GAAG,QAAQ,KAAK,GAAI,MAAM,OAAO,CAAC,EAAG;AAAA,MAC5C,OAAO,CAAC,UAAU,QAAQ,MAAM;AAAA,IAClC,CAAC;AACD,QAAI,SAAS;AACb,QAAI,SAAS;AACb,UAAM,OAAO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
|
1
|
-
{"version":3,"sources":["../tools/fastapply/core.ts"],"sourcesContent":["/**\n * Core implementation of Morph Fast Apply\n *\n * This module provides file-based operations that require Node.js.\n * For edge-compatible code-in/code-out operations, use applyEdit from ./apply.ts\n */\n\nimport { join, resolve, relative } from 'path';\nimport type {\n EditFileInput,\n EditFileResult,\n EditFileConfig,\n} from './types.js';\nimport { logger } from '../../logger.js';\nimport { MorphAPIClient } from '../../core/client.js';\nimport { APIResource } from '../../core/resource.js';\nimport {\n FastApplyAnchorIntegrityError,\n FastApplyContextLengthError,\n} from './apply.js';\n\n// Re-export edge-compatible functions\nexport { applyEdit, generateUdiff, countChanges, callMorphAPI } from './apply.js';\nexport { FastApplyAnchorIntegrityError, FastApplyContextLengthError };\n\nconst DEFAULT_CONFIG: Required<Omit<EditFileConfig, 'morphApiKey' | 'systemPrompt' | 'retryConfig' | 'description' | 'large'>> = {\n morphApiUrl: 'https://api.morphllm.com',\n baseDir: process.cwd(),\n generateUdiff: true,\n autoWrite: true,\n timeout: 600000,\n anchorCompaction: true,\n anchorCompactionThreshold: 128 * 1024,\n debug: false,\n};\n\n/**\n * FastApply client for programmatic file editing\n * Note: This client requires Node.js for file operations\n *\n * @deprecated Prefer the unified `MorphClient` (`new MorphClient({ apiKey }).fastApply`).\n * Standalone clients remain only for backwards compatibility and may be removed in a future\n * major version — do not use them in new code.\n */\nexport class FastApplyClient extends APIResource {\n private config: EditFileConfig;\n\n constructor(clientOrConfig: MorphAPIClient | { apiKey?: string; debug?: boolean; timeout?: number; retryConfig?: any } = {}) {\n const isClient = clientOrConfig instanceof MorphAPIClient;\n super(\n isClient\n ? clientOrConfig\n : new MorphAPIClient({\n apiKey: clientOrConfig.apiKey,\n timeout: clientOrConfig.timeout ?? DEFAULT_CONFIG.timeout,\n retryConfig: clientOrConfig.retryConfig,\n debug: clientOrConfig.debug,\n }),\n );\n // FastApply talks to /v1/chat/completions through the `openai` package, but\n // sources its credentials and host from the shared transport.\n this.config = {\n morphApiKey: this._client.resolveApiKey(),\n morphApiUrl: this._client.baseURL,\n debug: this._client.debug,\n timeout: (isClient ? undefined : clientOrConfig.timeout) ?? DEFAULT_CONFIG.timeout,\n retryConfig: this._client.retryConfig,\n generateUdiff: DEFAULT_CONFIG.generateUdiff,\n autoWrite: DEFAULT_CONFIG.autoWrite,\n };\n }\n\n /**\n * Execute a file edit operation\n *\n * @param input - Edit parameters including filepath, instructions, and code_edit\n * @param overrides - Optional config overrides for this operation\n * @returns Edit result with success status and changes\n */\n async execute(input: EditFileInput, overrides?: Partial<EditFileConfig>): Promise<EditFileResult> {\n return executeEditFile(input, { ...this.config, ...overrides });\n }\n\n /**\n * Apply an edit to code directly without file I/O\n *\n * Useful for sandbox environments or when you manage your own file system.\n * Compatible with the earlier OpenAI client API contract.\n *\n * @param input - Code and edit parameters\n * @param overrides - Optional config overrides for this operation\n * @returns Result with merged code\n *\n * @example\n * ```typescript\n * const result = await client.applyEdit({\n * originalCode: 'function hello() { return \"world\"; }',\n * codeEdit: 'function hello() { return \"universe\"; }',\n * instructions: 'Change return value'\n * });\n * console.log(result.mergedCode);\n * ```\n */\n async applyEdit(input: import('./types.js').ApplyEditInput, overrides?: Partial<import('./types.js').ApplyEditConfig>): Promise<import('./types.js').ApplyEditResult> {\n const { applyEdit } = await import('./apply.js');\n return applyEdit(input, { ...this.config, ...overrides });\n }\n}\n\n/**\n * Execute a file edit using Morph Fast Apply\n * Note: This function requires Node.js for file I/O\n */\nexport async function executeEditFile(\n input: EditFileInput,\n config: EditFileConfig = {}\n): Promise<EditFileResult> {\n const baseDir = config.baseDir || DEFAULT_CONFIG.baseDir;\n const fullPath = resolve(join(baseDir, input.target_filepath));\n\n logger.debug('FastApply', 'execute_start', { target_filepath: input.target_filepath, baseDir, autoWrite: config.autoWrite !== false });\n\n // Security: ensure file is within baseDir\n const relativePath = relative(baseDir, fullPath);\n if (relativePath.startsWith('..') || fullPath === baseDir) {\n logger.warn('FastApply', 'security_check_failed', { target_filepath: input.target_filepath, relative: relativePath });\n return {\n success: false,\n filepath: input.target_filepath,\n changes: { linesAdded: 0, linesRemoved: 0, linesModified: 0 },\n error: `Invalid filepath: '${input.target_filepath}' is outside baseDir`,\n };\n }\n\n logger.debug('FastApply', 'security_check', { resolved: fullPath, relative: relativePath });\n\n try {\n // Dynamic import to avoid loading Node.js fs module at module evaluation time\n const { readFile, writeFile } = await import('fs/promises');\n const { callMorphAPI, generateUdiff, countChanges } = await import('./apply.js');\n\n // Handle both existing and non-existent files\n let originalCode = '';\n let fileExists = true;\n try {\n originalCode = await readFile(fullPath, 'utf-8');\n logger.debug('FastApply', 'file_read', { path: fullPath, exists: true, size_bytes: originalCode.length });\n } catch (error: any) {\n if (error.code !== 'ENOENT') {\n throw error; // Re-throw if it's not a \"file not found\" error\n }\n fileExists = false;\n logger.debug('FastApply', 'file_read', { path: fullPath, exists: false });\n }\n\n const instruction = input.instruction ?? input.instructions ?? '';\n logger.debug('FastApply', 'api_call', { instruction_len: instruction.length, code_edit_len: input.code_edit.length, original_len: originalCode.length });\n\n const { content: mergedCode, completionId } = await callMorphAPI(originalCode, input.code_edit, instruction, input.target_filepath, config);\n\n logger.debug('FastApply', 'api_response', { completion_id: completionId, merged_len: mergedCode.length });\n\n const udiff = config.generateUdiff !== false ? generateUdiff(originalCode, mergedCode, input.target_filepath) : undefined;\n\n if (config.autoWrite !== false) {\n await writeFile(fullPath, mergedCode, 'utf-8');\n logger.debug('FastApply', 'file_write', { path: fullPath, size_bytes: mergedCode.length });\n }\n\n const changes = countChanges(originalCode, mergedCode);\n logger.debug('FastApply', 'changes', { added: changes.linesAdded, removed: changes.linesRemoved, modified: changes.linesModified });\n\n return {\n success: true,\n filepath: input.target_filepath,\n udiff,\n changes,\n completionId,\n };\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';\n const structuredError = error instanceof FastApplyContextLengthError\n || error instanceof FastApplyAnchorIntegrityError\n ? error\n : undefined;\n logger.error('FastApply', 'execute_error', { error: errorMessage, target_filepath: input.target_filepath, stack: error instanceof Error ? error.stack : undefined });\n\n return {\n success: false,\n filepath: input.target_filepath,\n changes: { linesAdded: 0, linesRemoved: 0, linesModified: 0 },\n error: errorMessage,\n errorCode: structuredError?.code,\n completionId: structuredError?.completionId,\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAOA,SAAS,MAAM,SAAS,gBAAgB;AAkBxC,IAAM,iBAA2H;AAAA,EAC/H,aAAa;AAAA,EACb,SAAS,QAAQ,IAAI;AAAA,EACrB,eAAe;AAAA,EACf,WAAW;AAAA,EACX,SAAS;AAAA,EACT,kBAAkB;AAAA,EAClB,2BAA2B,MAAM;AAAA,EACjC,OAAO;AACT;AAUO,IAAM,kBAAN,cAA8B,YAAY;AAAA,EACvC;AAAA,EAER,YAAY,iBAA6G,CAAC,GAAG;AAC3H,UAAM,WAAW,0BAA0B;AAC3C;AAAA,MACE,WACI,iBACA,IAAI,eAAe;AAAA,QACjB,QAAQ,eAAe;AAAA,QACvB,SAAS,eAAe,WAAW,eAAe;AAAA,QAClD,aAAa,eAAe;AAAA,QAC5B,OAAO,eAAe;AAAA,MACxB,CAAC;AAAA,IACP;AAGA,SAAK,SAAS;AAAA,MACZ,aAAa,KAAK,QAAQ,cAAc;AAAA,MACxC,aAAa,KAAK,QAAQ;AAAA,MAC1B,OAAO,KAAK,QAAQ;AAAA,MACpB,UAAU,WAAW,SAAY,eAAe,YAAY,eAAe;AAAA,MAC3E,aAAa,KAAK,QAAQ;AAAA,MAC1B,eAAe,eAAe;AAAA,MAC9B,WAAW,eAAe;AAAA,IAC5B;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,QAAQ,OAAsB,WAA8D;AAChG,WAAO,gBAAgB,OAAO,EAAE,GAAG,KAAK,QAAQ,GAAG,UAAU,CAAC;AAAA,EAChE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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AAA,MAChB,SAAS,EAAE,YAAY,GAAG,cAAc,GAAG,eAAe,EAAE;AAAA,MAC5D,OAAO;AAAA,MACP,WAAW,iBAAiB;AAAA,MAC5B,cAAc,iBAAiB;AAAA,IACjC;AAAA,EACF;AACF;","names":["applyEdit","callMorphAPI","generateUdiff","countChanges"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../tools/warp_grep/vercel.ts"],"sourcesContent":["/**\n * Vercel AI SDK adapter for morph-warp-grep tool\n *\n * @example Using with your own Zod instance (recommended for avoiding version conflicts)\n * ```typescript\n * import { z } from 'zod'; // Your project's Zod\n * import { createWarpGrepTool } from '@morphllm/morphsdk/tools/warp-grep/vercel';\n *\n * const schema = z.object({\n * search_term: z.string().describe('Search problem statement'),\n * });\n *\n * const grepTool = createWarpGrepTool({\n * repoRoot: '.',\n * inputSchema: schema,\n * });\n * ```\n */\n\nimport { tool } from 'ai';\nimport { z } from 'zod';\nimport { jsonSchema } from 'ai';\nimport { executeToolCall, executeToolCallStreaming, formatResult, WarpGrepClient, executeGitHubReadFile, formatGitHubReadFileResult } from './client.js';\nimport { WARP_GREP_DESCRIPTION, GITHUB_SEARCH_DESCRIPTION, GITHUB_READ_FILE_DESCRIPTION } from './prompts.js';\nimport type { WarpGrepToolConfig, WarpGrepResult, GitHubSearchToolConfig, GitHubReadFileInput, GitHubReadFileResult, GitHubReadFileToolConfig } from './types.js';\nimport type { WarpGrepStep } from './agent/types.js';\n\n/**\n * Raw JSON Schema for warp grep input (no Zod dependency).\n * Use this with jsonSchema() from 'ai' if you have Zod version conflicts.\n *\n * @example\n * ```typescript\n * import { jsonSchema } from 'ai';\n * import { warpGrepJsonSchema, createWarpGrepToolWithSchema } from '@morphllm/morphsdk/tools/warp-grep/vercel';\n *\n * const grepTool = createWarpGrepToolWithSchema({\n * repoRoot: '.',\n * inputSchema: jsonSchema(warpGrepJsonSchema),\n * });\n * ```\n */\nexport const warpGrepJsonSchema = {\n type: 'object' as const,\n properties: {\n search_term: {\n type: 'string' as const,\n description: 'Search problem statement that this subagent is supposed to research for',\n },\n },\n required: ['search_term'] as const,\n additionalProperties: false as const,\n};\n\n/** Type for the model-facing warp grep tool input (snake_case to match JSON schema) */\nexport type WarpGrepToolInput = { search_term: string };\n\n/**\n * Extended config that accepts a custom inputSchema\n */\nexport interface WarpGrepVercelConfig extends WarpGrepToolConfig {\n /**\n * Custom Zod schema or AI SDK schema. Use this to provide your own Zod instance\n * to avoid version conflicts between your project and the SDK.\n *\n * @example Using your own Zod\n * ```typescript\n * import { z } from 'zod'; // Your Zod version\n *\n * const grepTool = createWarpGrepTool({\n * repoRoot: '.',\n * inputSchema: z.object({\n * search_term: z.string().describe('Search problem statement'),\n * }),\n * });\n * ```\n *\n * @example Using jsonSchema (no Zod needed)\n * ```typescript\n * import { jsonSchema } from 'ai';\n * import { warpGrepJsonSchema } from '@morphllm/morphsdk/tools/warp-grep/vercel';\n *\n * const grepTool = createWarpGrepTool({\n * repoRoot: '.',\n * inputSchema: jsonSchema(warpGrepJsonSchema),\n * });\n * ```\n */\n inputSchema?: Parameters<typeof tool>[0]['inputSchema'];\n}\n\n/**\n * Execute warp grep search\n *\n * @param input - Tool input with search_term\n * @param config - Configuration with repoRoot and optional provider\n * @returns Search results\n */\nexport async function execute(\n input: { search_term: string },\n config: WarpGrepToolConfig\n): Promise<WarpGrepResult> {\n return executeToolCall(input, config);\n}\n\n// Re-export formatResult for convenience\nexport { formatResult };\n\n/**\n * Create Vercel AI SDK warp grep tool\n *\n * @param config - Configuration options\n * @returns Vercel AI SDK tool\n *\n * @example Local usage (uses SDK's Zod)\n * ```typescript\n * import { generateText } from 'ai';\n * import { anthropic } from '@ai-sdk/anthropic';\n * import { createWarpGrepTool } from '@morphllm/morphsdk/tools/warp-grep/vercel';\n *\n * const grepTool = createWarpGrepTool({ repoRoot: '.' });\n *\n * const result = await generateText({\n * model: anthropic('claude-sonnet-4-5-20250929'),\n * tools: { grep: grepTool },\n * prompt: 'Find authentication middleware'\n * });\n * ```\n *\n * @example With your own Zod (avoids version conflicts)\n * ```typescript\n * import { z } from 'zod'; // Your project's Zod\n * import { createWarpGrepTool } from '@morphllm/morphsdk/tools/warp-grep/vercel';\n *\n * const grepTool = createWarpGrepTool({\n * repoRoot: '.',\n * inputSchema: z.object({\n * search_term: z.string().describe('Search problem statement'),\n * }),\n * });\n * ```\n *\n * @example Without Zod (using jsonSchema)\n * ```typescript\n * import { jsonSchema } from 'ai';\n * import { createWarpGrepTool, warpGrepJsonSchema } from '@morphllm/morphsdk/tools/warp-grep/vercel';\n *\n * const grepTool = createWarpGrepTool({\n * repoRoot: '.',\n * inputSchema: jsonSchema(warpGrepJsonSchema),\n * });\n * ```\n *\n * @example Remote sandbox (E2B, Modal, etc.)\n * ```typescript\n * const grepTool = createWarpGrepTool({\n * repoRoot: '/home/repo',\n * remoteCommands: {\n * grep: async (pattern, path) => (await sandbox.run(`rg '${pattern}' '${path}'`)).stdout,\n * read: async (path, start, end) => (await sandbox.run(`sed -n '${start},${end}p' '${path}'`)).stdout,\n * listDir: async (path, maxDepth) => (await sandbox.run(`find '${path}' -maxdepth ${maxDepth}`)).stdout,\n * },\n * });\n * ```\n */\nexport function createWarpGrepTool(config: WarpGrepVercelConfig) {\n // Use provided schema or fall back to SDK's Zod schema\n const schema = config.inputSchema ?? z.object({\n search_term: z.string().describe('Search problem statement that this subagent is supposed to research for'),\n });\n\n return tool({\n description: config.description ?? WARP_GREP_DESCRIPTION,\n inputSchema: schema,\n execute: async (params: WarpGrepToolInput) => {\n // Use streaming execution to collect intermediate steps\n const steps: WarpGrepStep[] = [];\n const generator = executeToolCallStreaming(params, config);\n\n let result: WarpGrepResult;\n for (;;) {\n const { value, done } = await generator.next();\n if (done) {\n result = value;\n break;\n }\n steps.push(value);\n }\n\n if (!result!.success) {\n throw new Error(`Failed to search codebase: ${result!.error}`);\n }\n\n // Flatten all intermediate tool calls across turns for progress display\n const allToolCalls = steps.flatMap(s => s.toolCalls);\n return {\n success: true,\n contexts: result!.contexts,\n summary: result!.summary,\n progress: allToolCalls.length > 0 ? { turn: steps.length, toolCalls: allToolCalls } : undefined,\n };\n },\n });\n}\n\n/**\n * Create a GitHub search tool for Vercel AI SDK\n *\n * @param config - Configuration options (morphApiKey, morphApiUrl, codeSearchUrl, timeout)\n * @returns Vercel AI SDK tool\n *\n * @example\n * ```typescript\n * import { generateText } from 'ai';\n * import { anthropic } from '@ai-sdk/anthropic';\n * import { createGitHubSearchTool } from '@morphllm/morphsdk/tools/warp-grep/vercel';\n *\n * const githubTool = createGitHubSearchTool({ morphApiKey: process.env.MORPH_API_KEY });\n *\n * const result = await generateText({\n * model: anthropic('claude-sonnet-4-5-20250929'),\n * tools: { githubSearch: githubTool },\n * prompt: 'How does auth work in vercel/next.js?'\n * });\n * ```\n */\nexport function createGitHubSearchTool(config: GitHubSearchToolConfig) {\n const client = new WarpGrepClient(config);\n\n return tool({\n description: GITHUB_SEARCH_DESCRIPTION,\n inputSchema: z.object({\n search_term: z.string().describe('Search problem statement that this subagent is supposed to research for'),\n github_url: z.string().optional().describe('GitHub repository URL to search (e.g. \"https://github.com/vercel/next.js\"). You must provide either github_url or owner_repo.'),\n owner_repo: z.string().optional().describe('Repository owner/repo shorthand (e.g. \"vercel/next.js\"). You must provide either github_url or owner_repo.'),\n branch: z.string().optional().describe('Branch to search (defaults to repo default branch)'),\n }),\n execute: async (params: { search_term: string; github_url?: string; owner_repo?: string; branch?: string }) => {\n const github = params.github_url || params.owner_repo;\n if (!github) {\n throw new Error('Please provide github search url or owner/repo id');\n }\n const result = await client.searchGitHub({ searchTerm: params.search_term, github, branch: params.branch });\n if (!result.success) {\n throw new Error(`GitHub search failed: ${result.error}`);\n }\n return {\n success: true,\n contexts: result.contexts,\n summary: result.summary,\n };\n },\n });\n}\n\n/**\n * Create a GitHub read file tool for Vercel AI SDK\n *\n * @param config - Optional configuration (timeout)\n * @returns Vercel AI SDK tool\n *\n * @example\n * ```typescript\n * import { generateText } from 'ai';\n * import { anthropic } from '@ai-sdk/anthropic';\n * import { createGitHubReadFileTool } from '@morphllm/morphsdk/tools/warp-grep/vercel';\n *\n * const readFileTool = createGitHubReadFileTool();\n *\n * const result = await generateText({\n * model: anthropic('claude-sonnet-4-5-20250929'),\n * tools: { readFile: readFileTool },\n * prompt: 'Read the package.json from vercel/next.js'\n * });\n * ```\n */\nexport function createGitHubReadFileTool(config?: GitHubReadFileToolConfig) {\n return tool({\n description: GITHUB_READ_FILE_DESCRIPTION,\n inputSchema: z.object({\n github: z.string().describe('owner/repo shorthand (e.g., \"vercel/next.js\")'),\n path: z.string().describe('File path within the repository'),\n startLine: z.number().optional().describe('Start line number (1-based)'),\n endLine: z.number().optional().describe('End line number (1-based, inclusive)'),\n branch: z.string().optional().describe('Branch to read from (defaults to repo default branch)'),\n }),\n execute: async (params: GitHubReadFileInput) => {\n const result = await executeGitHubReadFile(params, config);\n if (!result.success) {\n throw new Error(`GitHub read file failed: ${result.error}`);\n }\n return result;\n },\n });\n}\n\n// Default export for convenience\nexport default createWarpGrepTool;\n"],"mappings":";;;;;;;;;;;;;AAmBA,SAAS,YAAY;AACrB,SAAS,SAAS;AAsBX,IAAM,qBAAqB;AAAA,EAChC,MAAM;AAAA,EACN,YAAY;AAAA,IACV,aAAa;AAAA,MACX,MAAM;AAAA,MACN,aAAa;AAAA,IACf;AAAA,EACF;AAAA,EACA,UAAU,CAAC,aAAa;AAAA,EACxB,sBAAsB;AACxB;AA8CA,eAAsB,QACpB,OACA,QACyB;AACzB,SAAO,gBAAgB,OAAO,MAAM;AACtC;AA8DO,SAAS,mBAAmB,QAA8B;AAE/D,QAAM,SAAS,OAAO,eAAe,EAAE,OAAO;AAAA,IAC5C,aAAa,EAAE,OAAO,EAAE,SAAS,yEAAyE;AAAA,EAC5G,CAAC;AAED,SAAO,KAAK;AAAA,IACV,aAAa,OAAO,eAAe;AAAA,IACnC,aAAa;AAAA,IACb,SAAS,OAAO,WAA8B;AAE5C,YAAM,QAAwB,C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AAyB,OAAO,KAAK,EAAE;AAAA,MACzD;AACA,aAAO;AAAA,QACL,SAAS;AAAA,QACT,UAAU,OAAO;AAAA,QACjB,SAAS,OAAO;AAAA,MAClB;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAuBO,SAAS,yBAAyB,QAAmC;AAC1E,SAAO,KAAK;AAAA,IACV,aAAa;AAAA,IACb,aAAa,EAAE,OAAO;AAAA,MACpB,QAAQ,EAAE,OAAO,EAAE,SAAS,+CAA+C;AAAA,MAC3E,MAAM,EAAE,OAAO,EAAE,SAAS,iCAAiC;AAAA,MAC3D,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,6BAA6B;AAAA,MACvE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,sCAAsC;AAAA,MAC9E,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,uDAAuD;AAAA,IAChG,CAAC;AAAA,IACD,SAAS,OAAO,WAAgC;AAC9C,YAAM,SAAS,MAAM,sBAAsB,QAAQ,MAAM;AACzD,UAAI,CAAC,OAAO,SAAS;AACnB,cAAM,IAAI,MAAM,4BAA4B,OAAO,KAAK,EAAE;AAAA,MAC5D;AACA,aAAO;AAAA,IACT;AAAA,EACF,CAAC;AACH;AAGA,IAAO,iBAAQ;","names":[]}
|
package/dist/chunk-VS5F2ORN.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
MorphAPIClient
|
|
3
|
-
} from "./chunk-7UU4NF4G.js";
|
|
4
|
-
import {
|
|
5
|
-
logger
|
|
6
|
-
} from "./chunk-F3NCFNUX.js";
|
|
7
|
-
import {
|
|
8
|
-
MorphError
|
|
9
|
-
} from "./chunk-DP2PT36G.js";
|
|
10
|
-
import {
|
|
11
|
-
APIResource
|
|
12
|
-
} from "./chunk-5TOJD2C5.js";
|
|
13
|
-
|
|
14
|
-
// tools/codebase_search/core.ts
|
|
15
|
-
var DEFAULT_TIMEOUT = 3e4;
|
|
16
|
-
var emptyStats = { totalResults: 0, candidatesRetrieved: 0, searchTimeMs: 0 };
|
|
17
|
-
async function runSearch(client, input, repoId, timeout, baseURL) {
|
|
18
|
-
const startTime = Date.now();
|
|
19
|
-
logger.debug("CodebaseSearch", "request", { query: input.query.slice(0, 100), repo_id: repoId });
|
|
20
|
-
try {
|
|
21
|
-
const data = await client.post(
|
|
22
|
-
"/v1/codebase_search",
|
|
23
|
-
{
|
|
24
|
-
baseURL: baseURL ?? client.reposURL,
|
|
25
|
-
timeout,
|
|
26
|
-
body: {
|
|
27
|
-
query: input.query,
|
|
28
|
-
repoId,
|
|
29
|
-
targetDirectories: input.target_directories || [],
|
|
30
|
-
limit: input.limit || 10,
|
|
31
|
-
candidateLimit: 50
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
);
|
|
35
|
-
const elapsed = Date.now() - startTime;
|
|
36
|
-
logger.debug("CodebaseSearch", "response", { results_count: data.results?.length || 0, latency_ms: elapsed });
|
|
37
|
-
return {
|
|
38
|
-
success: true,
|
|
39
|
-
results: data.results || [],
|
|
40
|
-
stats: data.stats || { totalResults: 0, candidatesRetrieved: 0, searchTimeMs: elapsed }
|
|
41
|
-
};
|
|
42
|
-
} catch (error) {
|
|
43
|
-
const message = error instanceof MorphError && error.statusCode ? `Search failed (${error.statusCode}): ${error.message}` : error instanceof Error ? error.message : "Unknown error";
|
|
44
|
-
logger.error("CodebaseSearch", "error", { error: message, latency_ms: Date.now() - startTime });
|
|
45
|
-
return { success: false, results: [], stats: { ...emptyStats }, error: message };
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
var CodebaseSearchClient = class extends APIResource {
|
|
49
|
-
timeout;
|
|
50
|
-
constructor(clientOrConfig = {}) {
|
|
51
|
-
super(
|
|
52
|
-
clientOrConfig instanceof MorphAPIClient ? clientOrConfig : new MorphAPIClient({
|
|
53
|
-
apiKey: clientOrConfig.apiKey,
|
|
54
|
-
timeout: clientOrConfig.timeout ?? DEFAULT_TIMEOUT,
|
|
55
|
-
retryConfig: clientOrConfig.retryConfig,
|
|
56
|
-
debug: clientOrConfig.debug
|
|
57
|
-
})
|
|
58
|
-
);
|
|
59
|
-
this.timeout = (clientOrConfig instanceof MorphAPIClient ? void 0 : clientOrConfig.timeout) ?? DEFAULT_TIMEOUT;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Execute a semantic code search
|
|
63
|
-
*
|
|
64
|
-
* @param input - Search parameters including query, repoId, and target directories
|
|
65
|
-
* @param overrides - Optional config overrides for this operation
|
|
66
|
-
* @returns Search results with ranked code matches
|
|
67
|
-
*/
|
|
68
|
-
async search(input, overrides) {
|
|
69
|
-
return runSearch(
|
|
70
|
-
this._client,
|
|
71
|
-
{ query: input.query, target_directories: input.target_directories, explanation: input.explanation, limit: input.limit },
|
|
72
|
-
input.repoId,
|
|
73
|
-
overrides?.timeout ?? this.timeout,
|
|
74
|
-
overrides?.searchUrl
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
async function executeCodebaseSearch(input, config) {
|
|
79
|
-
const apiKey = config.apiKey || process.env.MORPH_API_KEY;
|
|
80
|
-
if (!apiKey) {
|
|
81
|
-
throw new Error("MORPH_API_KEY not found. Set environment variable or pass in config");
|
|
82
|
-
}
|
|
83
|
-
const client = new MorphAPIClient({
|
|
84
|
-
apiKey,
|
|
85
|
-
reposURL: config.searchUrl,
|
|
86
|
-
timeout: config.timeout ?? DEFAULT_TIMEOUT,
|
|
87
|
-
retryConfig: config.retryConfig,
|
|
88
|
-
debug: config.debug
|
|
89
|
-
});
|
|
90
|
-
return runSearch(client, input, config.repoId, config.timeout ?? DEFAULT_TIMEOUT, config.searchUrl);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export {
|
|
94
|
-
CodebaseSearchClient,
|
|
95
|
-
executeCodebaseSearch
|
|
96
|
-
};
|
|
97
|
-
//# sourceMappingURL=chunk-VS5F2ORN.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../tools/codebase_search/core.ts"],"sourcesContent":["/**\n * Core implementation for codebase search.\n * Calls the Morph rerank service for two-stage semantic search over the\n * code-storage host, through the shared `MorphAPIClient` transport.\n */\nimport { MorphAPIClient } from '../../core/client.js';\nimport { APIResource } from '../../core/resource.js';\nimport { MorphError } from '../utils/resilience.js';\nimport { logger } from '../../logger.js';\nimport type { CodebaseSearchConfig, CodebaseSearchInput, CodebaseSearchResult } from './types.js';\n\nconst DEFAULT_TIMEOUT = 30000;\n\nconst emptyStats = { totalResults: 0, candidatesRetrieved: 0, searchTimeMs: 0 };\n\n/**\n * Run a search against `/v1/codebase_search` on the repos host. HTTP failures\n * are returned in-band as `{ success: false, error }` (never thrown), matching\n * the long-standing contract callers rely on.\n */\nasync function runSearch(\n client: MorphAPIClient,\n input: CodebaseSearchInput,\n repoId: string,\n timeout: number,\n baseURL?: string,\n): Promise<CodebaseSearchResult> {\n const startTime = Date.now();\n logger.debug('CodebaseSearch', 'request', { query: input.query.slice(0, 100), repo_id: repoId });\n\n try {\n const data = await client.post<{ results?: unknown[]; stats?: CodebaseSearchResult['stats'] }>(\n '/v1/codebase_search',\n {\n baseURL: baseURL ?? client.reposURL,\n timeout,\n body: {\n query: input.query,\n repoId,\n targetDirectories: input.target_directories || [],\n limit: input.limit || 10,\n candidateLimit: 50,\n },\n },\n );\n\n const elapsed = Date.now() - startTime;\n logger.debug('CodebaseSearch', 'response', { results_count: data.results?.length || 0, latency_ms: elapsed });\n return {\n success: true,\n results: (data.results as CodebaseSearchResult['results']) || [],\n stats: data.stats || { totalResults: 0, candidatesRetrieved: 0, searchTimeMs: elapsed },\n };\n } catch (error) {\n const message =\n error instanceof MorphError && error.statusCode\n ? `Search failed (${error.statusCode}): ${error.message}`\n : error instanceof Error\n ? error.message\n : 'Unknown error';\n logger.error('CodebaseSearch', 'error', { error: message, latency_ms: Date.now() - startTime });\n return { success: false, results: [], stats: { ...emptyStats }, error: message };\n }\n}\n\n/**\n * CodebaseSearch client for programmatic semantic search\n *\n * @deprecated Prefer the unified `MorphClient` (`new MorphClient({ apiKey }).codebaseSearch`).\n * Standalone clients remain only for backwards compatibility and may be removed in a future\n * major version — do not use them in new code.\n */\nexport class CodebaseSearchClient extends APIResource {\n private readonly timeout: number;\n\n constructor(\n clientOrConfig: MorphAPIClient | { apiKey?: string; debug?: boolean; timeout?: number; retryConfig?: any } = {},\n ) {\n super(\n clientOrConfig instanceof MorphAPIClient\n ? clientOrConfig\n : new MorphAPIClient({\n apiKey: clientOrConfig.apiKey,\n timeout: clientOrConfig.timeout ?? DEFAULT_TIMEOUT,\n retryConfig: clientOrConfig.retryConfig,\n debug: clientOrConfig.debug,\n }),\n );\n this.timeout = (clientOrConfig instanceof MorphAPIClient ? undefined : clientOrConfig.timeout) ?? DEFAULT_TIMEOUT;\n }\n\n /**\n * Execute a semantic code search\n *\n * @param input - Search parameters including query, repoId, and target directories\n * @param overrides - Optional config overrides for this operation\n * @returns Search results with ranked code matches\n */\n async search(\n input: { query: string; repoId: string; target_directories?: string[]; explanation?: string; limit?: number },\n overrides?: { searchUrl?: string; timeout?: number },\n ): Promise<CodebaseSearchResult> {\n return runSearch(\n this._client,\n { query: input.query, target_directories: input.target_directories, explanation: input.explanation, limit: input.limit },\n input.repoId,\n overrides?.timeout ?? this.timeout,\n overrides?.searchUrl,\n );\n }\n}\n\n/**\n * Execute semantic code search (standalone — builds its own transport).\n * Throws on a missing API key; returns `{ success: false, error }` on HTTP failure.\n */\nexport async function executeCodebaseSearch(\n input: CodebaseSearchInput,\n config: CodebaseSearchConfig,\n): Promise<CodebaseSearchResult> {\n const apiKey = config.apiKey || process.env.MORPH_API_KEY;\n if (!apiKey) {\n throw new Error('MORPH_API_KEY not found. Set environment variable or pass in config');\n }\n\n const client = new MorphAPIClient({\n apiKey,\n reposURL: config.searchUrl,\n timeout: config.timeout ?? DEFAULT_TIMEOUT,\n retryConfig: config.retryConfig,\n debug: config.debug,\n });\n\n return runSearch(client, input, config.repo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version":3,"sources":["../tools/warp_grep/openai.ts"],"sourcesContent":["/**\n * OpenAI SDK adapter for morph-warp-grep tool\n */\n\nimport type { ChatCompletionTool } from 'openai/resources/chat/completions';\nimport { executeToolCall, formatResult, WarpGrepClient, executeGitHubReadFile, formatGitHubReadFileResult } from './client.js';\nimport { WARP_GREP_DESCRIPTION, WARP_GREP_TOOL_NAME, GITHUB_SEARCH_TOOL_NAME, GITHUB_SEARCH_DESCRIPTION, GITHUB_SEARCH_INPUT_SCHEMA, GITHUB_READ_FILE_TOOL_NAME, GITHUB_READ_FILE_DESCRIPTION, GITHUB_READ_FILE_INPUT_SCHEMA } from './prompts.js';\nimport type { WarpGrepToolConfig, WarpGrepResult, GitHubSearchToolConfig, GitHubReadFileInput, GitHubReadFileResult, GitHubReadFileToolConfig } from './types.js';\n\n/**\n * Input schema for the warp grep tool\n */\nconst TOOL_PARAMETERS = {\n type: 'object',\n properties: {\n search_term: { type: 'string', description: 'Search problem statement that this subagent is supposed to research for' },\n },\n required: ['search_term'],\n} as const;\n\n/**\n * OpenAI-native warp grep tool definition\n * \n * @example\n * ```typescript\n * import OpenAI from 'openai';\n * import { warpGrepTool, execute } from '@morphllm/morphsdk/tools/warp-grep/openai';\n * \n * const client = new OpenAI();\n * const response = await client.chat.completions.create({\n * model: 'gpt-4o',\n * tools: [warpGrepTool],\n * messages: [{ role: 'user', content: 'Find authentication middleware' }]\n * });\n * \n * // Execute the tool call\n * const result = await execute({ search_term: '...' }, { repoRoot: '.' });\n * ```\n */\nexport const warpGrepTool: ChatCompletionTool = {\n type: 'function',\n function: {\n name: WARP_GREP_TOOL_NAME,\n description: WARP_GREP_DESCRIPTION,\n parameters: TOOL_PARAMETERS,\n },\n};\n\n/**\n * Execute warp grep search\n * \n * @param input - Tool input with search_term\n * @param config - Configuration with repoRoot and optional provider\n * @returns Search results\n */\nexport async function execute(\n input: { search_term: string } | string,\n config: WarpGrepToolConfig\n): Promise<WarpGrepResult> {\n return executeToolCall(input, config);\n}\n\n// Re-export formatResult for convenience\nexport { formatResult };\n\n/**\n * Create a custom warp grep tool with configuration and methods\n * \n * @param config - Configuration options\n * @returns Tool definition with execute and formatResult methods\n * \n * @example Local usage\n * ```typescript\n * import OpenAI from 'openai';\n * import { createWarpGrepTool } from '@morphllm/morphsdk/tools/warp-grep/openai';\n * \n * const tool = createWarpGrepTool({ repoRoot: '.' });\n * \n * const client = new OpenAI();\n * const response = await client.chat.completions.create({\n * model: 'gpt-4o',\n * tools: [tool],\n * messages: [{ role: 'user', content: 'Find authentication middleware' }]\n * });\n * ```\n * \n * @example Remote sandbox (E2B, Modal, etc.)\n * ```typescript\n * const tool = createMorphWarpGrepTool({\n * repoRoot: '/home/repo',\n * remoteCommands: {\n * grep: async (pattern, path) => (await sandbox.run(`rg '${pattern}' '${path}'`)).stdout,\n * read: async (path, start, end) => (await sandbox.run(`sed -n '${start},${end}p' '${path}'`)).stdout,\n * listDir: async (path, maxDepth) => (await sandbox.run(`find '${path}' -maxdepth ${maxDepth}`)).stdout,\n * },\n * });\n * ```\n */\nexport function createWarpGrepTool(config: WarpGrepToolConfig) {\n const tool: ChatCompletionTool = {\n type: 'function',\n function: {\n name: config.name ?? WARP_GREP_TOOL_NAME,\n description: config.description ?? WARP_GREP_DESCRIPTION,\n parameters: TOOL_PARAMETERS,\n },\n };\n\n return Object.assign(tool, {\n execute: async (input: unknown): Promise<WarpGrepResult> => {\n return executeToolCall(input as { search_term: string } | string, config);\n },\n formatResult: (result: WarpGrepResult): string => {\n return formatResult(result);\n },\n });\n}\n\n/**\n * Create a GitHub search tool for OpenAI SDK\n *\n * @param config - Configuration options (morphApiKey, morphApiUrl, codeSearchUrl, timeout)\n * @returns OpenAI ChatCompletionTool with execute and formatResult methods\n *\n * @example\n * ```typescript\n * import OpenAI from 'openai';\n * import { createGitHubSearchTool } from '@morphllm/morphsdk/tools/warp-grep/openai';\n *\n * const tool = createGitHubSearchTool({ morphApiKey: process.env.MORPH_API_KEY });\n *\n * const response = await openai.chat.completions.create({\n * model: 'gpt-4o',\n * tools: [tool],\n * messages: [{ role: 'user', content: 'How does auth work in vercel/next.js?' }]\n * });\n *\n * // Execute\n * const result = await tool.execute({ search_term: 'auth middleware', github_url: 'https://github.com/vercel/next.js' });\n * console.log(tool.formatResult(result));\n * ```\n */\nexport function createGitHubSearchTool(config: GitHubSearchToolConfig) {\n const client = new WarpGrepClient(config);\n\n const tool: ChatCompletionTool = {\n type: 'function',\n function: {\n name: GITHUB_SEARCH_TOOL_NAME,\n description: GITHUB_SEARCH_DESCRIPTION,\n parameters: GITHUB_SEARCH_INPUT_SCHEMA,\n },\n };\n\n return Object.assign(tool, {\n execute: async (input: { search_term: string; github_url?: string; owner_repo?: string; branch?: string }): Promise<WarpGrepResult> => {\n const github = input.github_url || input.owner_repo;\n if (!github) {\n throw new Error('Please provide github search url or owner/repo id');\n }\n return client.searchGitHub({ searchTerm: input.search_term, github, branch: input.branch });\n },\n formatResult: (result: WarpGrepResult): string => {\n return formatResult(result);\n },\n });\n}\n\n/**\n * Create a GitHub read file tool for OpenAI SDK\n *\n * @param config - Optional configuration (timeout)\n * @returns OpenAI ChatCompletionTool with execute and formatResult methods\n *\n * @example\n * ```typescript\n * import OpenAI from 'openai';\n * import { createGitHubReadFileTool } from '@morphllm/morphsdk/tools/warp-grep/openai';\n *\n * const tool = createGitHubReadFileTool();\n *\n * const response = await openai.chat.completions.create({\n * model: 'gpt-4o',\n * tools: [tool],\n * messages: [{ role: 'user', content: 'Read the package.json from vercel/next.js' }]\n * });\n *\n * const result = await tool.execute({ github: 'vercel/next.js', path: 'package.json' });\n * console.log(tool.formatResult(result));\n * ```\n */\nexport function createGitHubReadFileTool(config?: GitHubReadFileToolConfig) {\n const tool: ChatCompletionTool = {\n type: 'function',\n function: {\n name: GITHUB_READ_FILE_TOOL_NAME,\n description: GITHUB_READ_FILE_DESCRIPTION,\n parameters: GITHUB_READ_FILE_INPUT_SCHEMA,\n },\n };\n\n return Object.assign(tool, {\n execute: async (input: GitHubReadFileInput): Promise<GitHubReadFileResult> => {\n return executeGitHubReadFile(input, config);\n },\n formatResult: (result: GitHubReadFileResult): string => {\n return formatGitHubReadFileResult(result);\n },\n });\n}\n\nexport default warpGrepTool;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAYA,IAAM,kBAAkB;AAAA,EACtB,MAAM;AAAA,EACN,YAAY;AAAA,IACV,aAAa,EAAE,MAAM,UAAU,aAAa,0EAA0E;AAAA,EACxH;AAAA,EACA,UAAU,CAAC,aAAa;AAC1B;AAqBO,IAAM,eAAmC;AAAA,EAC9C,MAAM;AAAA,EACN,UAAU;AAAA,IACR,MAAM;AAAA,IACN,aAAa;AAAA,IACb,YAAY;AAAA,EACd;AACF;AASA,eAAsB,QACpB,OACA,QACyB;AACzB,SAAO,gBAAgB,OAAO,MAAM;AACtC;AAsCO,SAAS,mBAAmB,QAA4B;AAC7D,QAAM,OAA2B;AAAA,IAC/B,MAAM;AAAA,IACN,UAAU;AAAA,MACR,MAAM,OAAO,QAAQ;AAAA,MACrB,aAAa,OAAO,eAAe;AAAA,MACnC,YAAY;AAAA,IACd;AAAA,EACF;AAEA,SAAO,OAAO,OAAO,MAAM;AAAA,IACzB,SAAS,OAAO,UAA4C;AAC1D,aAAO,gBAAgB,OAA2C,MAAM;AAAA,IAC1E;AAAA,IACA,cAAc,CAAC,WAAmC;AAChD,aAAO,aAAa,MAAM;AAAA,IAC5B;AAAA,EACF,CAAC;AACH;AA0BO,SAAS,uBAAuB,QAAgC;AACrE,QAAM,SAAS,IAAI,eAAe,MAAM;AAExC,QAAM,OAA2B;AAAA,IAC/B,MAAM;AAAA,IACN,UAAU;AAAA,MACR,MAAM;AAAA,MACN,aAAa;AAAA,MACb,YAAY;AAAA,IACd;AAAA,EACF;AAEA,SAAO,OAAO,OAAO,MAAM;AAAA,IACzB,SAAS,OAAO,UAAuH;AACrI,YAAM,SAAS,MAAM,cAAc,MAAM;AACzC,UAAI,CAAC,QAAQ;AACX,cAAM,IAAI,MAAM,mDAAmD;AAAA,MACrE;AACA,aAAO,OAAO,aAAa,EAAE,YAAY,MAAM,aAAa,QAAQ,QAAQ,MAAM,OAAO,CAAC;AAAA,IAC5F;AAAA,IACA,cAAc,CAAC,WAAmC;AAChD,aAAO,aAAa,MAAM;AAAA,IAC5B;AAAA,EACF,CAAC;AACH;AAyBO,SAAS,yBAAyB,QAAmC;AAC1E,QAAM,OAA2B;AAAA,IAC/B,MAAM;AAAA,IACN,UAAU;AAAA,MACR,MAAM;AAAA,MACN,aAAa;AAAA,MACb,YAAY;AAAA,IACd;AAAA,EACF;AAEA,SAAO,OAAO,OAAO,MAAM;AAAA,IACzB,SAAS,OAAO,UAA8D;AAC5E,aAAO,sBAAsB,OAAO,MAAM;AAAA,IAC5C;AAAA,IACA,cAAc,CAAC,WAAyC;AACtD,aAAO,2BAA2B,MAAM;AAAA,IAC1C;AAAA,EACF,CAAC;AACH;AAEA,IAAO,iBAAQ;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../subagents/vercel.ts"],"sourcesContent":["/**\n * Vercel AI SDK adapter for Explore subagent\n */\n\nimport { tool, generateText, stepCountIs } from 'ai';\nimport type { LanguageModel } from 'ai';\nimport { z } from 'zod';\nimport { WarpGrepClient } from '../tools/warp_grep/client.js';\nimport { formatResult } from '../tools/warp_grep/client.js';\nimport type { WarpGrepContext } from '../tools/warp_grep/types.js';\nimport { getSystemPrompt, CODEBASE_SEARCH_TOOL, SEND_MESSAGE_TOOL } from './prompts.js';\nimport type {\n ExploreSubagentConfig,\n ExploreResult,\n ExploreStep,\n ExploreSession,\n ExploreEvent,\n SubagentMessage,\n MessageHandler,\n StepHandler,\n} from './types.js';\n\n/** Config for Vercel AI SDK Explore subagent */\nexport interface VercelExploreConfig extends ExploreSubagentConfig {\n /** Vercel AI SDK model instance */\n model: LanguageModel;\n}\n\nconst DEFAULT_MAX_TURNS: Record<string, number> = {\n quick: 3,\n medium: 6,\n thorough: 12,\n};\n\nfunction getMaxTurns(config: ExploreSubagentConfig): number {\n return config.maxTurns ?? DEFAULT_MAX_TURNS[config.thoroughness ?? 'medium'] ?? 6;\n}\n\n/**\n * Create an Explore subagent using Vercel AI SDK\n */\nexport function createExploreSubagent(config: VercelExploreConfig) {\n if (!config.repoRoot) {\n throw new Error('repoRoot is required for Explore subagent');\n }\n\n const warpGrep = new WarpGrepClient({\n morphApiKey: config.morphApiKey,\n });\n\n const thoroughness = config.thoroughness ?? 'medium';\n const replyTimeout = config.replyTimeout ?? 30_000;\n\n /** Run the agent loop and collect results */\n async function runExplore(\n prompt: string,\n callbacks: {\n onStep?: StepHandler;\n onMessage?: MessageHandler;\n } = {},\n ): Promise<ExploreResult> {\n const startTime = Date.now();\n const allContexts: WarpGrepContext[] = [];\n let searchCount = 0;\n\n const timeoutMs = config.timeout;\n const timeoutPromise = timeoutMs\n ? new Promise<never>((_, reject) =>\n setTimeout(() => reject(new Error(`Exploration timed out after ${timeoutMs}ms`)), timeoutMs),\n )\n : null;\n\n const runPromise = (async (): Promise<ExploreResult> => {\n try {\n const codebaseSearchSchema = z.object({\n searchRequest: z.string().describe('Natural language description of what to search for'),\n });\n\n const sendMessageSchema = z.object({\n message: z.string().describe('The message to send to the orchestrator'),\n });\n\n const result = await generateText({\n model: config.model,\n system: getSystemPrompt(thoroughness),\n prompt,\n tools: {\n codebase_search: tool({\n description: CODEBASE_SEARCH_TOOL.description,\n inputSchema: codebaseSearchSchema,\n execute: async (params: z.infer<typeof codebaseSearchSchema>) => {\n searchCount++;\n const warpResult = await warpGrep.execute({\n searchTerm: params.searchRequest,\n repoRoot: config.repoRoot,\n excludes: config.excludes,\n includes: config.includes,\n });\n\n if (warpResult.contexts) {\n allContexts.push(...warpResult.contexts);\n }\n\n callbacks.onStep?.({\n step: searchCount,\n searchRequest: params.searchRequest,\n contextsFound: warpResult.contexts?.length ?? 0,\n isFinal: false,\n });\n\n return formatResult(warpResult);\n },\n }),\n send_message: tool({\n description: SEND_MESSAGE_TOOL.description,\n inputSchema: sendMessageSchema,\n execute: async (params: z.infer<typeof sendMessageSchema>) => {\n const subagentMsg: SubagentMessage = {\n from: 'explore',\n content: params.message,\n timestamp: Date.now(),\n };\n\n // Create a promise that waits for the host's reply\n const replyPromise = new Promise<string>((resolve) => {\n // Emit the message to the host via callback\n if (callbacks.onMessage) {\n callbacks.onMessage(subagentMsg, (replyText: string) => {\n resolve(replyText);\n });\n } else {\n // No handler registered, auto-resolve after timeout\n setTimeout(() => resolve(''), replyTimeout);\n }\n });\n\n // Wait for reply with timeout\n const reply = await Promise.race([\n replyPromise,\n new Promise<string>((resolve) =>\n setTimeout(() => resolve(''), replyTimeout),\n ),\n ]);\n\n if (reply) {\n return `Response from orchestrator: ${reply}`;\n }\n return 'No response. Continue with your best judgment.';\n },\n }),\n },\n stopWhen: stepCountIs(getMaxTurns(config)),\n });\n\n // Emit final step\n callbacks.onStep?.({\n step: searchCount,\n searchRequest: '',\n contextsFound: allContexts.length,\n isFinal: true,\n });\n\n // Deduplicate contexts by file path\n const uniqueContexts = deduplicateContexts(allContexts);\n\n return {\n success: true,\n summary: result.text || 'Exploration completed but no summary was generated.',\n contexts: uniqueContexts,\n searchCount,\n durationMs: Date.now() - startTime,\n };\n } catch (error) {\n return {\n success: false,\n summary: '',\n contexts: deduplicateContexts(allContexts),\n searchCount,\n durationMs: Date.now() - startTime,\n error: error instanceof Error ? error.message : String(error),\n };\n }\n })();\n\n if (timeoutPromise) {\n try {\n return await Promise.race([runPromise, timeoutPromise]);\n } catch (error) {\n return {\n success: false,\n summary: '',\n contexts: deduplicateContexts(allContexts),\n searchCount,\n durationMs: Date.now() - startTime,\n error: error instanceof Error ? error.message : String(error),\n };\n }\n }\n\n return runPromise;\n }\n\n const exploreToolSchema = z.object({\n searchRequest: z\n .string()\n .describe('What to explore in the codebase. Be specific about what you want to understand.'),\n });\n\n /** The Vercel AI tool for use in parent agents */\n const exploreTool = tool({\n description:\n 'Explore a codebase to answer questions about code structure, find implementations, trace call chains, and understand architecture. Returns a summary of findings. Use this for broad exploration rather than pinpoint keyword searches.',\n inputSchema: exploreToolSchema,\n execute: async (params: z.infer<typeof exploreToolSchema>) => {\n const result = await runExplore(params.searchRequest);\n return {\n success: result.success,\n summary: result.summary,\n searchCount: result.searchCount,\n error: result.error,\n };\n },\n });\n\n return {\n /** Vercel AI SDK tool for use as a tool in parent agents */\n tool: exploreTool,\n\n /** Run exploration with messaging support */\n run(prompt: string): ExploreSession {\n const messageHandlers: MessageHandler[] = [];\n const stepHandlers: StepHandler[] = [];\n\n // Start the run lazily (after handlers are attached)\n let resultPromise: Promise<ExploreResult> | null = null;\n\n const session: ExploreSession = {\n on(event: string, handler: any) {\n if (event === 'message') messageHandlers.push(handler);\n if (event === 'step') stepHandlers.push(handler);\n return session;\n },\n send(_text: string) {\n // Convenience method — pause-and-ask flow uses the reply callback\n },\n get result() {\n if (!resultPromise) {\n resultPromise = runExplore(prompt, {\n onStep: (step) => {\n for (const handler of stepHandlers) handler(step);\n },\n onMessage: (msg, reply) => {\n if (messageHandlers.length > 0) {\n for (const handler of messageHandlers) handler(msg, reply);\n } else {\n // No handlers, auto-reply\n reply('');\n }\n },\n });\n }\n return resultPromise;\n },\n };\n\n return session;\n },\n\n /** Stream exploration events as an async generator */\n async *stream(prompt: string): AsyncGenerator<ExploreEvent, ExploreResult, undefined> {\n const events: ExploreEvent[] = [];\n let resolveNext: (() => void) | null = null;\n let done = false;\n\n const resultPromise = runExplore(prompt, {\n onStep: (step) => {\n events.push({\n type: 'step',\n step: step.step,\n searchRequest: step.searchRequest,\n contextsFound: step.contextsFound,\n isFinal: step.isFinal,\n });\n resolveNext?.();\n },\n onMessage: (msg, reply) => {\n events.push({\n type: 'message',\n from: msg.from,\n content: msg.content,\n timestamp: msg.timestamp,\n });\n resolveNext?.();\n // Auto-reply in streaming mode\n reply('Continue with your best judgment.');\n },\n });\n\n // Yield events as they come in\n while (!done) {\n if (events.length > 0) {\n yield events.shift()!;\n } else {\n // Check if the result is already done\n const raceResult = await Promise.race([\n resultPromise.then((r) => ({ type: 'done' as const, result: r })),\n new Promise<{ type: 'event' }>((resolve) => {\n resolveNext = () => resolve({ type: 'event' });\n }),\n ]);\n\n if (raceResult.type === 'done') {\n // Drain remaining events\n while (events.length > 0) {\n yield events.shift()!;\n }\n done = true;\n return raceResult.result;\n }\n }\n }\n\n return await resultPromise;\n },\n };\n}\n\n/** Deduplicate contexts, keeping the latest version of each file */\nfunction deduplicateContexts(contexts: WarpGrepContext[]): WarpGrepContext[] {\n const map = new Map<string, WarpGrepContext>();\n for (const ctx of contexts) {\n const existing = map.get(ctx.file);\n if (!existing || ctx.content.length > existing.content.length) {\n map.set(ctx.file, ctx);\n }\n }\n return Array.from(map.values());\n}\n"],"mappings":";;;;;;;;;;;AAIA,SAAS,MAAM,cAAc,mBAAmB;AAEhD,SAAS,SAAS;AAsBlB,IAAM,oBAA4C;AAAA,EAChD,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,UAAU;AACZ;AAEA,SAAS,YAAY,QAAuC;AAC1D,SAAO,OAAO,YAAY,kBAAkB,OAAO,gBAAgB,QAAQ,KAAK;AAClF;AAKO,SAAS,sBAAsB,QAA6B;AACjE,MAAI,CAAC,OAAO,UAAU;AACpB,UAAM,IAAI,MAAM,2CAA2C;AAAA,EAC7D;AAEA,QAAM,WAAW,IAAI,eAAe;AAAA,IAClC,aAAa,OAAO;AAAA,EACtB,CAAC;AAED,QAAM,eAAe,OAAO,gBAAgB;AAC5C,QAAM,eAAe,OAAO,gBAAgB;AAG5C,iBAAe,WACb,QACA,YAGI,CAAC,GACmB;AACxB,UAAM,YAAY,KAAK,IAAI;AAC3B,UAAM,cAAiC,CAAC;AACxC,QAAI,cAAc;AAElB,UAAM,YAAY,OAAO;AACzB,UAAM,iBAAiB,YACnB,IAAI;AAAA,MAAe,CAAC,GAAG,WACrB,WAAW,MAAM,OAAO,IAAI,MAAM,+BAA+B,SAAS,IAAI,CAAC,GAAG,SAAS;AAAA,IAC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,IAAI;AACjC,QAAI,CAAC,YAAY,IAAI,QAAQ,SAAS,SAAS,QAAQ,QAAQ;AAC7D,UAAI,IAAI,IAAI,MAAM,GAAG;AAAA,IACvB;AAAA,EACF;AACA,SAAO,MAAM,KAAK,IAAI,OAAO,CAAC;AAChC;","names":[]}
|
package/dist/chunk-X2K57BH6.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=chunk-X2K57BH6.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../tools/warp_grep/utils/paths.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nexport function resolveUnderRepo(repoRoot: string, targetPath: string): string {\n const absRoot = path.resolve(repoRoot);\n const resolved = path.resolve(absRoot, targetPath);\n ensureWithinRepo(absRoot, resolved);\n return resolved;\n}\n\nexport function ensureWithinRepo(repoRoot: string, absTarget: string): void {\n const rel = path.relative(path.resolve(repoRoot), path.resolve(absTarget));\n if (rel.startsWith('..') || path.isAbsolute(rel)) {\n throw new Error(`Path outside repository root: ${absTarget}`);\n }\n}\n\nexport function toRepoRelative(repoRoot: string, absPath: string): string {\n return path.relative(path.resolve(repoRoot), path.resolve(absPath));\n}\n\nexport function isSymlink(p: string): boolean {\n try {\n const st = fs.lstatSync(p);\n return st.isSymbolicLink();\n } catch {\n return false;\n }\n}\n\n/**\n * Detects and removes consecutive duplicate path segments.\n *\n * When the model predicts a path that includes the repo directory name,\n * joining with repoRoot creates duplication:\n * repoRoot=\"/Users/dhruv/repo\" + predicted=\"repo/src/file.ts\"\n * → \"/Users/dhruv/repo/repo/src/file.ts\"\n *\n * This function detects such patterns and returns the corrected path,\n * or null if no duplication is found.\n */\nexport function fixPathRepetition(fullPath: string): string | null {\n const segments = fullPath.split(path.sep).filter(Boolean);\n if (segments.length < 2) return null;\n\n for (let len = Math.floor(segments.length / 2); len >= 1; len--) {\n for (let i = 0; i <= segments.length - 2 * len; i++) {\n const first = segments.slice(i, i + len);\n const second = segments.slice(i + len, i + 2 * len);\n\n if (first.every((seg, idx) => seg === second[idx])) {\n const fixed = [...segments.slice(0, i), ...segments.slice(i + len)];\n return path.sep + fixed.join(path.sep);\n }\n }\n }\n\n return null;\n}\n\nexport function isTextualFile(filePath: string, maxBytes = 2_000_000): boolean {\n try {\n const st = fs.statSync(filePath);\n if (!st.isFile()) return false;\n if (st.size > maxBytes) return false;\n const fd = fs.openSync(filePath, 'r');\n const buf = Buffer.alloc(512);\n const read = fs.readSync(fd, buf, 0, buf.length, 0);\n fs.closeSync(fd);\n for (let i = 0; i < read; i++) {\n const c = buf[i];\n if (c === 0) return false; // binary heuristic\n }\n return true;\n } catch {\n return false;\n }\n}\n\n\n"],"mappings":";AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AAEV,SAAS,iBAAiB,UAAkB,YAA4B;AAC7E,QAAM,UAAU,KAAK,QAAQ,QAAQ;AACrC,QAAM,WAAW,KAAK,QAAQ,SAAS,UAAU;AACjD,mBAAiB,SAAS,QAAQ;AAClC,SAAO;AACT;AAEO,SAAS,iBAAiB,UAAkB,WAAyB;AAC1E,QAAM,MAAM,KAAK,SAAS,KAAK,QAAQ,QAAQ,GAAG,KAAK,QAAQ,SAAS,CAAC;AACzE,MAAI,IAAI,WAAW,IAAI,KAAK,KAAK,WAAW,GAAG,GAAG;AAChD,UAAM,IAAI,MAAM,iCAAiC,SAAS,EAAE;AAAA,EAC9D;AACF;AAEO,SAAS,eAAe,UAAkB,SAAyB;AACxE,SAAO,KAAK,SAAS,KAAK,QAAQ,QAAQ,GAAG,KAAK,QAAQ,OAAO,CAAC;AACpE;AAEO,SAAS,UAAU,GAAoB;AAC5C,MAAI;AACF,UAAM,KAAK,GAAG,UAAU,CAAC;AACzB,WAAO,GAAG,eAAe;AAAA,EAC3B,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAaO,SAA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ts
|
|
2
|
-
var CODEBASE_SEARCH_DESCRIPTION = `Semantic search that finds code by meaning, not exact text.
|
|
3
|
-
|
|
4
|
-
Use this to explore unfamiliar codebases or ask "how/where/what" questions:
|
|
5
|
-
- "How does X work?" - Find implementation details
|
|
6
|
-
- "Where is Y handled?" - Locate specific functionality
|
|
7
|
-
- "What happens when Z?" - Understand flow
|
|
8
|
-
|
|
9
|
-
The tool uses two-stage retrieval (embedding similarity + reranking) to find the most semantically relevant code chunks.
|
|
10
|
-
|
|
11
|
-
Returns code chunks with file paths, line ranges, and full content ranked by relevance.`;
|
|
12
|
-
var CODEBASE_SEARCH_SYSTEM_PROMPT = `You have access to the codebase_search tool that performs semantic code search.
|
|
13
|
-
|
|
14
|
-
When searching:
|
|
15
|
-
- Use natural language queries describing what you're looking for
|
|
16
|
-
- Be specific about functionality, not variable names
|
|
17
|
-
- Use target_directories to narrow search if you know the area
|
|
18
|
-
- Results are ranked by relevance (rerank score is most important)
|
|
19
|
-
|
|
20
|
-
The tool returns:
|
|
21
|
-
- File paths with symbol names (e.g. "src/auth.ts::AuthService@L1-L17")
|
|
22
|
-
- Line ranges for precise navigation
|
|
23
|
-
- Full code content for each match
|
|
24
|
-
- Dual relevance scores: embedding similarity + rerank score
|
|
25
|
-
|
|
26
|
-
Use results to understand code or answer questions. The content is provided in full - avoid re-reading unless you need more context.`;
|
|
27
|
-
|
|
28
|
-
export {
|
|
29
|
-
CODEBASE_SEARCH_DESCRIPTION,
|
|
30
|
-
CODEBASE_SEARCH_SYSTEM_PROMPT
|
|
31
|
-
};
|
|
32
|
-
//# sourceMappingURL=chunk-YQMPVJ2L.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../tools/codebase_search/prompts.ts"],"sourcesContent":["/**\n * Tool descriptions and system prompts for codebase search\n */\n\nexport const CODEBASE_SEARCH_DESCRIPTION = `Semantic search that finds code by meaning, not exact text.\n\nUse this to explore unfamiliar codebases or ask \"how/where/what\" questions:\n- \"How does X work?\" - Find implementation details\n- \"Where is Y handled?\" - Locate specific functionality\n- \"What happens when Z?\" - Understand flow\n\nThe tool uses two-stage retrieval (embedding similarity + reranking) to find the most semantically relevant code chunks.\n\nReturns code chunks with file paths, line ranges, and full content ranked by relevance.`;\n\nexport const CODEBASE_SEARCH_SYSTEM_PROMPT = `You have access to the codebase_search tool that performs semantic code search.\n\nWhen searching:\n- Use natural language queries describing what you're looking for\n- Be specific about functionality, not variable names\n- Use target_directories to narrow search if you know the area\n- Results are ranked by relevance (rerank score is most important)\n\nThe tool returns:\n- File paths with symbol names (e.g. \"src/auth.ts::AuthService@L1-L17\")\n- Line ranges for precise navigation\n- Full code content for each match\n- Dual relevance scores: embedding similarity + rerank score\n\nUse results to understand code or answer questions. The content is provided in full - avoid re-reading unless you need more context.`;\n\n"],"mappings":";AAIO,IAAM,8BAA8B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWpC,IAAM,gCAAgC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../tools/warp_grep/anthropic.ts"],"sourcesContent":["/**\n * Anthropic SDK adapter for morph-warp-grep tool\n */\n\nimport type { Tool } from '@anthropic-ai/sdk/resources/messages';\nimport { executeToolCall, formatResult, WarpGrepClient, executeGitHubReadFile, formatGitHubReadFileResult } from './client.js';\nimport { WARP_GREP_DESCRIPTION, WARP_GREP_TOOL_NAME, GITHUB_SEARCH_TOOL_NAME, GITHUB_SEARCH_DESCRIPTION, GITHUB_SEARCH_INPUT_SCHEMA, GITHUB_READ_FILE_TOOL_NAME, GITHUB_READ_FILE_DESCRIPTION, GITHUB_READ_FILE_INPUT_SCHEMA } from './prompts.js';\nimport type { WarpGrepToolConfig, WarpGrepResult, GitHubSearchToolConfig, GitHubReadFileInput, GitHubReadFileResult, GitHubReadFileToolConfig } from './types.js';\n\n/**\n * Input schema for the warp grep tool\n */\nconst INPUT_SCHEMA = {\n type: 'object',\n properties: {\n search_term: { type: 'string', description: 'Search problem statement that this subagent is supposed to research for' },\n },\n required: ['search_term'],\n} as const;\n\n/**\n * Anthropic-native warp grep tool definition\n * \n * @example\n * ```typescript\n * import Anthropic from '@anthropic-ai/sdk';\n * import { warpGrepTool, execute } from '@morphllm/morphsdk/tools/warp-grep/anthropic';\n * \n * const client = new Anthropic();\n * const response = await client.messages.create({\n * model: 'claude-sonnet-4-5-20250929',\n * tools: [warpGrepTool],\n * messages: [{ role: 'user', content: 'Find authentication middleware' }]\n * });\n * \n * // Execute the tool call\n * const result = await execute({ search_term: '...' }, { repoRoot: '.' });\n * ```\n */\nexport const warpGrepTool: Tool = {\n name: WARP_GREP_TOOL_NAME,\n description: WARP_GREP_DESCRIPTION,\n input_schema: INPUT_SCHEMA,\n};\n\n/**\n * Execute warp grep search\n * \n * @param input - Tool input with search_term\n * @param config - Configuration with repoRoot and optional provider\n * @returns Search results\n */\nexport async function execute(\n input: { search_term: string } | string,\n config: WarpGrepToolConfig\n): Promise<WarpGrepResult> {\n return executeToolCall(input, config);\n}\n\n// Re-export formatResult for convenience\nexport { formatResult };\n\n/**\n * Create a custom warp grep tool with configuration and methods\n * \n * @param config - Configuration options\n * @returns Tool definition with execute and formatResult methods\n * \n * @example Local usage\n * ```typescript\n * import Anthropic from '@anthropic-ai/sdk';\n * import { createWarpGrepTool } from '@morphllm/morphsdk/tools/warp-grep/anthropic';\n * \n * const tool = createWarpGrepTool({ repoRoot: '.' });\n * \n * const client = new Anthropic();\n * const response = await client.messages.create({\n * model: 'claude-sonnet-4-5-20250929',\n * tools: [tool],\n * messages: [{ role: 'user', content: 'Find authentication middleware' }]\n * });\n * ```\n * \n * @example Remote sandbox (E2B, Modal, etc.)\n * ```typescript\n * const tool = createMorphWarpGrepTool({\n * repoRoot: '/home/repo',\n * remoteCommands: {\n * grep: async (pattern, path) => (await sandbox.run(`rg '${pattern}' '${path}'`)).stdout,\n * read: async (path, start, end) => (await sandbox.run(`sed -n '${start},${end}p' '${path}'`)).stdout,\n * listDir: async (path, maxDepth) => (await sandbox.run(`find '${path}' -maxdepth ${maxDepth}`)).stdout,\n * },\n * });\n * ```\n */\nexport function createWarpGrepTool(config: WarpGrepToolConfig) {\n const tool: Tool = {\n name: config.name ?? WARP_GREP_TOOL_NAME,\n description: config.description ?? WARP_GREP_DESCRIPTION,\n input_schema: INPUT_SCHEMA,\n };\n\n return Object.assign(tool, {\n execute: async (input: unknown): Promise<WarpGrepResult> => {\n return executeToolCall(input as { search_term: string } | string, config);\n },\n formatResult: (result: WarpGrepResult): string => {\n return formatResult(result);\n },\n });\n}\n\n/**\n * Create a GitHub search tool for Anthropic SDK\n *\n * @param config - Configuration options (morphApiKey, morphApiUrl, codeSearchUrl, timeout)\n * @returns Anthropic Tool with execute and formatResult methods\n *\n * @example\n * ```typescript\n * import Anthropic from '@anthropic-ai/sdk';\n * import { createGitHubSearchTool } from '@morphllm/morphsdk/tools/warp-grep/anthropic';\n *\n * const tool = createGitHubSearchTool({ morphApiKey: process.env.MORPH_API_KEY });\n *\n * const response = await client.messages.create({\n * model: 'claude-sonnet-4-5-20250929',\n * tools: [tool],\n * messages: [{ role: 'user', content: 'How does auth work in vercel/next.js?' }]\n * });\n *\n * // Execute\n * const result = await tool.execute({ search_term: 'auth middleware', github_url: 'https://github.com/vercel/next.js' });\n * console.log(tool.formatResult(result));\n * ```\n */\nexport function createGitHubSearchTool(config: GitHubSearchToolConfig) {\n const client = new WarpGrepClient(config);\n\n const tool: Tool = {\n name: GITHUB_SEARCH_TOOL_NAME,\n description: GITHUB_SEARCH_DESCRIPTION,\n input_schema: GITHUB_SEARCH_INPUT_SCHEMA,\n };\n\n return Object.assign(tool, {\n execute: async (input: { search_term: string; github_url?: string; owner_repo?: string; branch?: string }): Promise<WarpGrepResult> => {\n const github = input.github_url || input.owner_repo;\n if (!github) {\n throw new Error('Please provide github search url or owner/repo id');\n }\n return client.searchGitHub({ searchTerm: input.search_term, github, branch: input.branch });\n },\n formatResult: (result: WarpGrepResult): string => {\n return formatResult(result);\n },\n });\n}\n\n/**\n * Create a GitHub read file tool for Anthropic SDK\n *\n * @param config - Optional configuration (timeout)\n * @returns Anthropic Tool with execute and formatResult methods\n *\n * @example\n * ```typescript\n * import Anthropic from '@anthropic-ai/sdk';\n * import { createGitHubReadFileTool } from '@morphllm/morphsdk/tools/warp-grep/anthropic';\n *\n * const tool = createGitHubReadFileTool();\n *\n * const response = await client.messages.create({\n * model: 'claude-sonnet-4-5-20250929',\n * tools: [tool],\n * messages: [{ role: 'user', content: 'Read the package.json from vercel/next.js' }]\n * });\n *\n * const result = await tool.execute({ github: 'vercel/next.js', path: 'package.json' });\n * console.log(tool.formatResult(result));\n * ```\n */\nexport function createGitHubReadFileTool(config?: GitHubReadFileToolConfig) {\n const tool: Tool = {\n name: GITHUB_READ_FILE_TOOL_NAME,\n description: GITHUB_READ_FILE_DESCRIPTION,\n input_schema: GITHUB_READ_FILE_INPUT_SCHEMA,\n };\n\n return Object.assign(tool, {\n execute: async (input: GitHubReadFileInput): Promise<GitHubReadFileResult> => {\n return executeGitHubReadFile(input, config);\n },\n formatResult: (result: GitHubReadFileResult): string => {\n return formatGitHubReadFileResult(result);\n },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAYA,IAAM,eAAe;AAAA,EACnB,MAAM;AAAA,EACN,YAAY;AAAA,IACV,aAAa,EAAE,MAAM,UAAU,aAAa,0EAA0E;AAAA,EACxH;AAAA,EACA,UAAU,CAAC,aAAa;AAC1B;AAqBO,IAAM,eAAqB;AAAA,EAChC,MAAM;AAAA,EACN,aAAa;AAAA,EACb,cAAc;AAChB;AASA,eAAsB,QACpB,OACA,QACyB;AACzB,SAAO,gBAAgB,OAAO,MAAM;AACtC;AAsCO,SAAS,mBAAmB,QAA4B;AAC7D,QAAM,OAAa;AAAA,IACjB,MAAM,OAAO,QAAQ;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