@morphllm/morphsdk 0.2.170 → 0.2.172
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/{chunk-IY7DESC3.js → chunk-2SNAXTUJ.js} +4 -4
- package/dist/chunk-453ZV2AX.js +120 -0
- package/dist/chunk-453ZV2AX.js.map +1 -0
- package/dist/chunk-53ZJMCWU.js +142 -0
- package/dist/chunk-53ZJMCWU.js.map +1 -0
- package/dist/{chunk-5KFQBI4J.js → chunk-5DA6SZQJ.js} +2 -2
- package/dist/chunk-66OHYI24.js +78 -0
- package/dist/chunk-66OHYI24.js.map +1 -0
- package/dist/chunk-6X6QMRQG.js +158 -0
- package/dist/chunk-6X6QMRQG.js.map +1 -0
- package/dist/{chunk-76XER44U.js → chunk-7PVVPLRL.js} +2 -2
- package/dist/{chunk-BCPZAPWY.js → chunk-AE7M2I52.js} +2 -2
- package/dist/{chunk-LNXIVRPY.js → chunk-CQF76HJC.js} +30 -6
- package/dist/chunk-CQF76HJC.js.map +1 -0
- package/dist/{chunk-OJQYBWHR.js → chunk-ESXCQBMU.js} +2 -2
- package/dist/{chunk-LAGN62H5.js → chunk-FOIDGIY4.js} +29 -10
- package/dist/chunk-FOIDGIY4.js.map +1 -0
- package/dist/{chunk-KUPSW5QN.js → chunk-GJZXDRH5.js} +8 -3
- package/dist/{chunk-KUPSW5QN.js.map → chunk-GJZXDRH5.js.map} +1 -1
- package/dist/{chunk-5IR3YE77.js → chunk-IJ33I7P5.js} +4 -4
- package/dist/{chunk-E5QWXVTF.js → chunk-IN2U7AAI.js} +99 -143
- package/dist/chunk-IN2U7AAI.js.map +1 -0
- package/dist/{chunk-LE66XCOI.js → chunk-JWZ5DLAS.js} +27 -10
- package/dist/chunk-JWZ5DLAS.js.map +1 -0
- package/dist/chunk-LKFZBBTD.js +12 -0
- package/dist/chunk-LKFZBBTD.js.map +1 -0
- package/dist/{chunk-6LPWEZ6H.js → chunk-MO6S2LRD.js} +2 -2
- package/dist/{chunk-S4IEM5EG.js → chunk-NI7PWQ3B.js} +4 -4
- package/dist/{chunk-GLQWEINZ.js → chunk-QAXXE4AD.js} +2 -2
- package/dist/{chunk-YG2I377B.js → chunk-QFE5523Q.js} +18 -3
- package/dist/chunk-QFE5523Q.js.map +1 -0
- package/dist/{chunk-G4FPDEUP.js → chunk-QQXNZIVK.js} +4 -4
- package/dist/{chunk-A3ZUWLYX.js → chunk-QZ3V2BP7.js} +2 -2
- package/dist/chunk-QZR7SJ5N.js +24 -0
- package/dist/chunk-QZR7SJ5N.js.map +1 -0
- package/dist/{chunk-SYD6BRQX.js → chunk-SJVLAGUL.js} +4 -4
- package/dist/{chunk-JMEQ6FLB.js → chunk-U4J3BVAQ.js} +4 -4
- package/dist/{chunk-QAWYDWDW.js → chunk-U4MRSZQQ.js} +2 -2
- package/dist/{chunk-WU3D46MH.js → chunk-UADW6FYD.js} +2 -2
- package/dist/{chunk-K7NY5SVR.js → chunk-VBARKJWL.js} +2 -2
- package/dist/{chunk-OPNTDMHH.js → chunk-VLZ6PNAD.js} +4 -4
- package/dist/chunk-VZ7BOH2K.js +1 -0
- package/dist/chunk-VZ7BOH2K.js.map +1 -0
- package/dist/{chunk-GUGHUAJU.js → chunk-XJDXV5VX.js} +2 -2
- package/dist/{chunk-GPNUS3H2.js → chunk-XYTYIAMQ.js} +2 -2
- package/dist/{chunk-MKBVWPU7.js → chunk-Z4GJVN52.js} +23 -8
- package/dist/chunk-Z4GJVN52.js.map +1 -0
- package/dist/chunk-ZLSNL6M2.js +97 -0
- package/dist/chunk-ZLSNL6M2.js.map +1 -0
- package/dist/{client-DsAAqupx.d.ts → client-Dh6yzCm4.d.ts} +14 -5
- package/dist/client.cjs +741 -525
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +5 -1
- package/dist/client.js +31 -27
- package/dist/core/client.cjs +540 -0
- package/dist/core/client.cjs.map +1 -0
- package/dist/core/client.d.ts +79 -0
- package/dist/core/client.js +12 -0
- package/dist/core/client.js.map +1 -0
- package/dist/core/error.cjs +309 -0
- package/dist/core/error.cjs.map +1 -0
- package/dist/core/error.d.ts +18 -0
- package/dist/core/error.js +10 -0
- package/dist/core/error.js.map +1 -0
- package/dist/core/index.cjs +552 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.js +20 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/resource.cjs +36 -0
- package/dist/core/resource.cjs.map +1 -0
- package/dist/core/resource.d.ts +18 -0
- package/dist/core/resource.js +8 -0
- package/dist/core/resource.js.map +1 -0
- package/dist/edge.cjs +252 -174
- package/dist/edge.cjs.map +1 -1
- package/dist/edge.d.ts +2 -0
- package/dist/edge.js +8 -5
- package/dist/git/client.cjs +529 -9
- package/dist/git/client.cjs.map +1 -1
- package/dist/git/client.d.ts +8 -2
- package/dist/git/client.js +7 -1
- package/dist/git/index.cjs +529 -9
- package/dist/git/index.cjs.map +1 -1
- package/dist/git/index.d.ts +2 -0
- package/dist/git/index.js +7 -1
- package/dist/index.cjs +688 -466
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.js +49 -33
- package/dist/modelrouter/core.cjs +204 -125
- package/dist/modelrouter/core.cjs.map +1 -1
- package/dist/modelrouter/core.d.ts +36 -9
- package/dist/modelrouter/core.js +6 -3
- package/dist/modelrouter/index.cjs +204 -125
- package/dist/modelrouter/index.cjs.map +1 -1
- package/dist/modelrouter/index.d.ts +3 -0
- package/dist/modelrouter/index.js +6 -3
- package/dist/subagents/anthropic.cjs +268 -52
- package/dist/subagents/anthropic.cjs.map +1 -1
- package/dist/subagents/anthropic.js +10 -6
- package/dist/subagents/vercel.cjs +268 -52
- package/dist/subagents/vercel.cjs.map +1 -1
- package/dist/subagents/vercel.js +10 -6
- package/dist/tools/browser/anthropic.cjs +7 -2
- package/dist/tools/browser/anthropic.cjs.map +1 -1
- package/dist/tools/browser/anthropic.js +9 -6
- package/dist/tools/browser/core.cjs +162 -10
- package/dist/tools/browser/core.cjs.map +1 -1
- package/dist/tools/browser/core.d.ts +8 -2
- package/dist/tools/browser/core.js +8 -5
- package/dist/tools/browser/index.cjs +163 -11
- package/dist/tools/browser/index.cjs.map +1 -1
- package/dist/tools/browser/index.d.ts +2 -0
- package/dist/tools/browser/index.js +18 -15
- package/dist/tools/browser/index.js.map +1 -1
- package/dist/tools/browser/openai.cjs +7 -2
- package/dist/tools/browser/openai.cjs.map +1 -1
- package/dist/tools/browser/openai.js +9 -6
- package/dist/tools/browser/profiles/core.cjs +7 -2
- package/dist/tools/browser/profiles/core.cjs.map +1 -1
- package/dist/tools/browser/profiles/core.js +3 -3
- package/dist/tools/browser/profiles/index.cjs +7 -2
- package/dist/tools/browser/profiles/index.cjs.map +1 -1
- package/dist/tools/browser/profiles/index.js +3 -3
- package/dist/tools/browser/vercel.cjs +7 -2
- package/dist/tools/browser/vercel.cjs.map +1 -1
- package/dist/tools/browser/vercel.js +9 -6
- package/dist/tools/codebase_search/anthropic.cjs +162 -41
- package/dist/tools/codebase_search/anthropic.cjs.map +1 -1
- package/dist/tools/codebase_search/anthropic.js +7 -4
- package/dist/tools/codebase_search/core.cjs +195 -66
- package/dist/tools/codebase_search/core.cjs.map +1 -1
- package/dist/tools/codebase_search/core.d.ts +18 -7
- package/dist/tools/codebase_search/core.js +6 -3
- package/dist/tools/codebase_search/index.cjs +162 -41
- package/dist/tools/codebase_search/index.cjs.map +1 -1
- package/dist/tools/codebase_search/index.d.ts +2 -0
- package/dist/tools/codebase_search/index.js +13 -10
- package/dist/tools/codebase_search/openai.cjs +162 -41
- package/dist/tools/codebase_search/openai.cjs.map +1 -1
- package/dist/tools/codebase_search/openai.js +7 -4
- package/dist/tools/codebase_search/vercel.cjs +162 -41
- package/dist/tools/codebase_search/vercel.cjs.map +1 -1
- package/dist/tools/codebase_search/vercel.js +7 -4
- package/dist/tools/compact/core.cjs +551 -47
- package/dist/tools/compact/core.cjs.map +1 -1
- package/dist/tools/compact/core.d.ts +16 -3
- package/dist/tools/compact/core.js +7 -1
- package/dist/tools/compact/index.cjs +549 -47
- package/dist/tools/compact/index.cjs.map +1 -1
- package/dist/tools/compact/index.d.ts +2 -0
- package/dist/tools/compact/index.js +8 -2
- package/dist/tools/fastapply/anthropic.cjs +32 -3
- package/dist/tools/fastapply/anthropic.cjs.map +1 -1
- package/dist/tools/fastapply/anthropic.js +8 -4
- package/dist/tools/fastapply/apply.cjs +23 -3
- package/dist/tools/fastapply/apply.cjs.map +1 -1
- package/dist/tools/fastapply/apply.js +2 -2
- package/dist/tools/fastapply/core.cjs +258 -13
- package/dist/tools/fastapply/core.cjs.map +1 -1
- package/dist/tools/fastapply/core.d.ts +8 -2
- package/dist/tools/fastapply/core.js +7 -3
- package/dist/tools/fastapply/index.cjs +32 -3
- package/dist/tools/fastapply/index.cjs.map +1 -1
- package/dist/tools/fastapply/index.d.ts +2 -0
- package/dist/tools/fastapply/index.js +13 -9
- package/dist/tools/fastapply/openai.cjs +32 -3
- package/dist/tools/fastapply/openai.cjs.map +1 -1
- package/dist/tools/fastapply/openai.js +8 -4
- package/dist/tools/fastapply/vercel.cjs +32 -3
- package/dist/tools/fastapply/vercel.cjs.map +1 -1
- package/dist/tools/fastapply/vercel.js +8 -4
- package/dist/tools/index.cjs +32 -3
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.js +13 -9
- package/dist/tools/reflex/core.cjs +693 -0
- package/dist/tools/reflex/core.cjs.map +1 -0
- package/dist/tools/reflex/core.d.ts +53 -0
- package/dist/tools/reflex/core.js +16 -0
- package/dist/tools/reflex/core.js.map +1 -0
- package/dist/tools/reflex/index.cjs +693 -0
- package/dist/tools/reflex/index.cjs.map +1 -0
- package/dist/tools/reflex/index.d.ts +5 -0
- package/dist/tools/reflex/index.js +16 -0
- package/dist/tools/reflex/index.js.map +1 -0
- package/dist/tools/reflex/types.cjs +19 -0
- package/dist/tools/reflex/types.cjs.map +1 -0
- package/dist/tools/reflex/types.d.ts +113 -0
- package/dist/tools/reflex/types.js +1 -0
- package/dist/tools/reflex/types.js.map +1 -0
- package/dist/tools/utils/resilience.cjs +7 -2
- package/dist/tools/utils/resilience.cjs.map +1 -1
- package/dist/tools/utils/resilience.js +2 -2
- package/dist/tools/warp_grep/agent/runner.cjs +7 -2
- package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/runner.js +2 -2
- package/dist/tools/warp_grep/anthropic.cjs +268 -52
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
- package/dist/tools/warp_grep/anthropic.d.ts +2 -0
- package/dist/tools/warp_grep/anthropic.js +10 -6
- package/dist/tools/warp_grep/client.cjs +268 -52
- package/dist/tools/warp_grep/client.cjs.map +1 -1
- package/dist/tools/warp_grep/client.d.ts +8 -2
- package/dist/tools/warp_grep/client.js +9 -5
- package/dist/tools/warp_grep/gemini.cjs +268 -52
- package/dist/tools/warp_grep/gemini.cjs.map +1 -1
- package/dist/tools/warp_grep/gemini.d.ts +2 -0
- package/dist/tools/warp_grep/gemini.js +9 -5
- package/dist/tools/warp_grep/gemini.js.map +1 -1
- package/dist/tools/warp_grep/harness.js +5 -5
- package/dist/tools/warp_grep/index.cjs +268 -52
- package/dist/tools/warp_grep/index.cjs.map +1 -1
- package/dist/tools/warp_grep/index.d.ts +2 -0
- package/dist/tools/warp_grep/index.js +12 -8
- package/dist/tools/warp_grep/openai.cjs +268 -52
- package/dist/tools/warp_grep/openai.cjs.map +1 -1
- package/dist/tools/warp_grep/openai.d.ts +2 -0
- package/dist/tools/warp_grep/openai.js +10 -6
- package/dist/tools/warp_grep/providers/local.js +2 -2
- package/dist/tools/warp_grep/vercel.cjs +268 -52
- package/dist/tools/warp_grep/vercel.cjs.map +1 -1
- package/dist/tools/warp_grep/vercel.d.ts +2 -0
- package/dist/tools/warp_grep/vercel.js +10 -6
- package/dist/version.cjs +7 -2
- package/dist/version.cjs.map +1 -1
- package/dist/version.js +1 -1
- package/package.json +7 -2
- package/dist/chunk-E5QWXVTF.js.map +0 -1
- package/dist/chunk-INBZD4EX.js +0 -197
- package/dist/chunk-INBZD4EX.js.map +0 -1
- package/dist/chunk-LAGN62H5.js.map +0 -1
- package/dist/chunk-LE66XCOI.js.map +0 -1
- package/dist/chunk-LNXIVRPY.js.map +0 -1
- package/dist/chunk-MKBVWPU7.js.map +0 -1
- package/dist/chunk-SCVWDNQP.js +0 -84
- package/dist/chunk-SCVWDNQP.js.map +0 -1
- package/dist/chunk-VE7J6VYX.js +0 -102
- package/dist/chunk-VE7J6VYX.js.map +0 -1
- package/dist/chunk-YG2I377B.js.map +0 -1
- /package/dist/{chunk-IY7DESC3.js.map → chunk-2SNAXTUJ.js.map} +0 -0
- /package/dist/{chunk-5KFQBI4J.js.map → chunk-5DA6SZQJ.js.map} +0 -0
- /package/dist/{chunk-76XER44U.js.map → chunk-7PVVPLRL.js.map} +0 -0
- /package/dist/{chunk-BCPZAPWY.js.map → chunk-AE7M2I52.js.map} +0 -0
- /package/dist/{chunk-OJQYBWHR.js.map → chunk-ESXCQBMU.js.map} +0 -0
- /package/dist/{chunk-5IR3YE77.js.map → chunk-IJ33I7P5.js.map} +0 -0
- /package/dist/{chunk-6LPWEZ6H.js.map → chunk-MO6S2LRD.js.map} +0 -0
- /package/dist/{chunk-S4IEM5EG.js.map → chunk-NI7PWQ3B.js.map} +0 -0
- /package/dist/{chunk-GLQWEINZ.js.map → chunk-QAXXE4AD.js.map} +0 -0
- /package/dist/{chunk-G4FPDEUP.js.map → chunk-QQXNZIVK.js.map} +0 -0
- /package/dist/{chunk-A3ZUWLYX.js.map → chunk-QZ3V2BP7.js.map} +0 -0
- /package/dist/{chunk-SYD6BRQX.js.map → chunk-SJVLAGUL.js.map} +0 -0
- /package/dist/{chunk-JMEQ6FLB.js.map → chunk-U4J3BVAQ.js.map} +0 -0
- /package/dist/{chunk-QAWYDWDW.js.map → chunk-U4MRSZQQ.js.map} +0 -0
- /package/dist/{chunk-WU3D46MH.js.map → chunk-UADW6FYD.js.map} +0 -0
- /package/dist/{chunk-K7NY5SVR.js.map → chunk-VBARKJWL.js.map} +0 -0
- /package/dist/{chunk-OPNTDMHH.js.map → chunk-VLZ6PNAD.js.map} +0 -0
- /package/dist/{chunk-GUGHUAJU.js.map → chunk-XJDXV5VX.js.map} +0 -0
- /package/dist/{chunk-GPNUS3H2.js.map → chunk-XYTYIAMQ.js.map} +0 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import "../chunk-VZ7BOH2K.js";
|
|
2
|
+
import {
|
|
3
|
+
MorphAPIClient
|
|
4
|
+
} from "../chunk-453ZV2AX.js";
|
|
5
|
+
import "../chunk-F3NCFNUX.js";
|
|
6
|
+
import {
|
|
7
|
+
toMorphError
|
|
8
|
+
} from "../chunk-QZR7SJ5N.js";
|
|
9
|
+
import "../chunk-XYTYIAMQ.js";
|
|
10
|
+
import "../chunk-GJZXDRH5.js";
|
|
11
|
+
import {
|
|
12
|
+
APIResource
|
|
13
|
+
} from "../chunk-LKFZBBTD.js";
|
|
14
|
+
import "../chunk-PZ5AY32C.js";
|
|
15
|
+
export {
|
|
16
|
+
APIResource,
|
|
17
|
+
MorphAPIClient,
|
|
18
|
+
toMorphError
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// core/resource.ts
|
|
21
|
+
var resource_exports = {};
|
|
22
|
+
__export(resource_exports, {
|
|
23
|
+
APIResource: () => APIResource
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(resource_exports);
|
|
26
|
+
var APIResource = class {
|
|
27
|
+
_client;
|
|
28
|
+
constructor(client) {
|
|
29
|
+
this._client = client;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
+
0 && (module.exports = {
|
|
34
|
+
APIResource
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=resource.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../core/resource.ts"],"sourcesContent":["/**\n * Base class for every API resource (FastApply, Compact, Reflex, …).\n *\n * Mirrors the OpenAI SDK's `APIResource`: a resource holds nothing but a\n * reference to the transport (`MorphAPIClient`) and delegates all HTTP to it.\n * Sub-resources receive the same client by reference, so configuration and the\n * fetch/retry/auth machinery live in exactly one place.\n */\nimport type { MorphAPIClient } from './client.js';\n\nexport abstract class APIResource {\n protected _client: MorphAPIClient;\n\n constructor(client: MorphAPIClient) {\n this._client = client;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAUO,IAAe,cAAf,MAA2B;AAAA,EACtB;AAAA,EAEV,YAAY,QAAwB;AAClC,SAAK,UAAU;AAAA,EACjB;AACF;","names":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { MorphAPIClient } from './client.js';
|
|
2
|
+
import '../tools/utils/resilience.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Base class for every API resource (FastApply, Compact, Reflex, …).
|
|
6
|
+
*
|
|
7
|
+
* Mirrors the OpenAI SDK's `APIResource`: a resource holds nothing but a
|
|
8
|
+
* reference to the transport (`MorphAPIClient`) and delegates all HTTP to it.
|
|
9
|
+
* Sub-resources receive the same client by reference, so configuration and the
|
|
10
|
+
* fetch/retry/auth machinery live in exactly one place.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
declare abstract class APIResource {
|
|
14
|
+
protected _client: MorphAPIClient;
|
|
15
|
+
constructor(client: MorphAPIClient);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { APIResource };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/edge.cjs
CHANGED
|
@@ -46,7 +46,7 @@ module.exports = __toCommonJS(edge_exports);
|
|
|
46
46
|
// package.json
|
|
47
47
|
var package_default = {
|
|
48
48
|
name: "@morphllm/morphsdk",
|
|
49
|
-
version: "0.2.
|
|
49
|
+
version: "0.2.172",
|
|
50
50
|
description: "TypeScript SDK and CLI for Morph Fast Apply integration",
|
|
51
51
|
type: "module",
|
|
52
52
|
main: "./dist/index.cjs",
|
|
@@ -183,6 +183,11 @@ var package_default = {
|
|
|
183
183
|
import: "./dist/tools/compact/index.js",
|
|
184
184
|
require: "./dist/tools/compact/index.cjs"
|
|
185
185
|
},
|
|
186
|
+
"./tools/reflex": {
|
|
187
|
+
types: "./dist/tools/reflex/index.d.ts",
|
|
188
|
+
import: "./dist/tools/reflex/index.js",
|
|
189
|
+
require: "./dist/tools/reflex/index.cjs"
|
|
190
|
+
},
|
|
186
191
|
"./subagents": {
|
|
187
192
|
types: "./dist/subagents/index.d.ts",
|
|
188
193
|
import: "./dist/subagents/index.js",
|
|
@@ -208,7 +213,7 @@ var package_default = {
|
|
|
208
213
|
"!dist/**/*.test.*"
|
|
209
214
|
],
|
|
210
215
|
scripts: {
|
|
211
|
-
build: "tsup version.ts index.ts edge.ts client.ts tools/index.ts tools/fastapply/index.ts tools/fastapply/core.ts tools/fastapply/apply.ts tools/fastapply/types.ts tools/fastapply/prompts.ts tools/fastapply/anthropic.ts tools/fastapply/openai.ts tools/fastapply/vercel.ts tools/codebase_search/index.ts tools/codebase_search/core.ts tools/codebase_search/types.ts tools/codebase_search/prompts.ts tools/codebase_search/anthropic.ts tools/codebase_search/openai.ts tools/codebase_search/vercel.ts tools/warp_grep/index.ts tools/warp_grep/client.ts tools/warp_grep/openai.ts tools/warp_grep/anthropic.ts tools/warp_grep/vercel.ts tools/warp_grep/gemini.ts tools/warp_grep/harness.ts tools/warp_grep/agent/config.ts tools/warp_grep/agent/parser.ts tools/warp_grep/agent/runner.ts tools/warp_grep/agent/types.ts tools/warp_grep/agent/formatter.ts tools/warp_grep/providers/types.ts tools/warp_grep/providers/local.ts tools/warp_grep/providers/remote.ts tools/warp_grep/providers/code_storage_http.ts tools/warp_grep/tools/grep.ts tools/warp_grep/tools/analyse.ts tools/warp_grep/tools/read.ts tools/warp_grep/tools/finish.ts tools/warp_grep/utils/paths.ts tools/warp_grep/utils/github.ts tools/warp_grep/utils/ripgrep.ts tools/warp_grep/utils/format.ts tools/warp_grep/utils/files.ts git/index.ts git/client.ts git/config.ts git/types.ts tools/browser/index.ts tools/browser/core.ts tools/browser/types.ts tools/browser/prompts.ts tools/browser/anthropic.ts tools/browser/openai.ts tools/browser/vercel.ts tools/browser/live.ts tools/browser/errors.ts tools/browser/profiles/index.ts tools/browser/profiles/core.ts tools/browser/profiles/types.ts modelrouter/index.ts modelrouter/core.ts modelrouter/types.ts tools/compact/index.ts tools/compact/core.ts tools/compact/types.ts tools/utils/resilience.ts subagents/index.ts subagents/types.ts subagents/prompts.ts subagents/vercel.ts subagents/anthropic.ts --format esm,cjs --sourcemap --clean --dts --dts-resolve",
|
|
216
|
+
build: "tsup version.ts index.ts edge.ts client.ts core/index.ts core/client.ts core/resource.ts core/error.ts tools/index.ts tools/fastapply/index.ts tools/fastapply/core.ts tools/fastapply/apply.ts tools/fastapply/types.ts tools/fastapply/prompts.ts tools/fastapply/anthropic.ts tools/fastapply/openai.ts tools/fastapply/vercel.ts tools/codebase_search/index.ts tools/codebase_search/core.ts tools/codebase_search/types.ts tools/codebase_search/prompts.ts tools/codebase_search/anthropic.ts tools/codebase_search/openai.ts tools/codebase_search/vercel.ts tools/warp_grep/index.ts tools/warp_grep/client.ts tools/warp_grep/openai.ts tools/warp_grep/anthropic.ts tools/warp_grep/vercel.ts tools/warp_grep/gemini.ts tools/warp_grep/harness.ts tools/warp_grep/agent/config.ts tools/warp_grep/agent/parser.ts tools/warp_grep/agent/runner.ts tools/warp_grep/agent/types.ts tools/warp_grep/agent/formatter.ts tools/warp_grep/providers/types.ts tools/warp_grep/providers/local.ts tools/warp_grep/providers/remote.ts tools/warp_grep/providers/code_storage_http.ts tools/warp_grep/tools/grep.ts tools/warp_grep/tools/analyse.ts tools/warp_grep/tools/read.ts tools/warp_grep/tools/finish.ts tools/warp_grep/utils/paths.ts tools/warp_grep/utils/github.ts tools/warp_grep/utils/ripgrep.ts tools/warp_grep/utils/format.ts tools/warp_grep/utils/files.ts git/index.ts git/client.ts git/config.ts git/types.ts tools/browser/index.ts tools/browser/core.ts tools/browser/types.ts tools/browser/prompts.ts tools/browser/anthropic.ts tools/browser/openai.ts tools/browser/vercel.ts tools/browser/live.ts tools/browser/errors.ts tools/browser/profiles/index.ts tools/browser/profiles/core.ts tools/browser/profiles/types.ts modelrouter/index.ts modelrouter/core.ts modelrouter/types.ts tools/compact/index.ts tools/compact/core.ts tools/compact/types.ts tools/reflex/index.ts tools/reflex/core.ts tools/reflex/types.ts tools/utils/resilience.ts subagents/index.ts subagents/types.ts subagents/prompts.ts subagents/vercel.ts subagents/anthropic.ts --format esm,cjs --sourcemap --clean --dts --dts-resolve",
|
|
212
217
|
prepare: "npm run build",
|
|
213
218
|
typecheck: "tsc --noEmit",
|
|
214
219
|
lint: "eslint .",
|
|
@@ -418,11 +423,26 @@ async function callMorphAPI(originalCode, codeEdit, instructions, filepath, conf
|
|
|
418
423
|
return { content, completionId: completion.id };
|
|
419
424
|
} catch (error) {
|
|
420
425
|
const elapsed = Date.now() - startTime;
|
|
426
|
+
const status = error?.status || error?.response?.status;
|
|
421
427
|
logger.error("FastApply", "http_error", {
|
|
422
|
-
status
|
|
428
|
+
status,
|
|
423
429
|
error: error?.message,
|
|
424
430
|
latency_ms: elapsed
|
|
425
431
|
});
|
|
432
|
+
if (status === 401) {
|
|
433
|
+
const err = new Error(
|
|
434
|
+
"Authentication failed: Your Morph API key is invalid or has been revoked. Please visit https://morphllm.com to get a valid API key, then update your MCP configuration."
|
|
435
|
+
);
|
|
436
|
+
err.status = 401;
|
|
437
|
+
throw err;
|
|
438
|
+
}
|
|
439
|
+
if (status === 429) {
|
|
440
|
+
const err = new Error(
|
|
441
|
+
"Rate limited: You've exceeded your Morph API usage limits. Please visit https://morphllm.com to check your plan and purchase additional credits."
|
|
442
|
+
);
|
|
443
|
+
err.status = 429;
|
|
444
|
+
throw err;
|
|
445
|
+
}
|
|
426
446
|
throw error;
|
|
427
447
|
}
|
|
428
448
|
}
|
|
@@ -532,87 +552,203 @@ async function withTimeout(promise, timeoutMs, errorMessage) {
|
|
|
532
552
|
function sleep(ms) {
|
|
533
553
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
534
554
|
}
|
|
555
|
+
var MorphError = class extends Error {
|
|
556
|
+
constructor(message, code, statusCode, retryable = false) {
|
|
557
|
+
super(message);
|
|
558
|
+
this.code = code;
|
|
559
|
+
this.statusCode = statusCode;
|
|
560
|
+
this.retryable = retryable;
|
|
561
|
+
this.name = "MorphError";
|
|
562
|
+
}
|
|
563
|
+
};
|
|
564
|
+
|
|
565
|
+
// core/error.ts
|
|
566
|
+
async function toMorphError(response) {
|
|
567
|
+
let message = `Morph API request failed (${response.status})`;
|
|
568
|
+
let code = "api_error";
|
|
569
|
+
try {
|
|
570
|
+
const body = await response.json();
|
|
571
|
+
message = body.error?.message ?? body.message ?? message;
|
|
572
|
+
code = body.error?.code ?? body.error?.type ?? code;
|
|
573
|
+
} catch {
|
|
574
|
+
}
|
|
575
|
+
if (response.status === 401) code = "authentication_error";
|
|
576
|
+
if (response.status === 429) code = "rate_limit_exceeded";
|
|
577
|
+
const retryable = response.status === 429 || response.status === 503;
|
|
578
|
+
return new MorphError(message, code, response.status, retryable);
|
|
579
|
+
}
|
|
535
580
|
|
|
536
|
-
//
|
|
537
|
-
var
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
581
|
+
// core/client.ts
|
|
582
|
+
var DEFAULT_BASE_URL = "https://api.morphllm.com";
|
|
583
|
+
var DEFAULT_REPOS_URL = "https://repos.morphllm.com";
|
|
584
|
+
var DEFAULT_BROWSER_URL = "https://browser.morphllm.com";
|
|
585
|
+
var DEFAULT_TIMEOUT2 = 6e4;
|
|
586
|
+
var env = (name) => typeof process !== "undefined" ? process.env?.[name] : void 0;
|
|
587
|
+
var stripTrailingSlash = (url) => url.replace(/\/+$/, "");
|
|
588
|
+
var MorphAPIClient = class {
|
|
589
|
+
/** Explicit key as provided; resolved against env at request time. */
|
|
590
|
+
apiKey;
|
|
591
|
+
baseURL;
|
|
592
|
+
reposURL;
|
|
593
|
+
browserURL;
|
|
594
|
+
/** Explicit default timeout (ms), if set. The request default is applied lazily so
|
|
595
|
+
* resources can read an undefined value and supply their own fallback. */
|
|
596
|
+
timeout;
|
|
597
|
+
retryConfig;
|
|
598
|
+
debug;
|
|
599
|
+
constructor(options = {}) {
|
|
600
|
+
this.apiKey = options.apiKey;
|
|
601
|
+
this.baseURL = stripTrailingSlash(options.baseURL ?? DEFAULT_BASE_URL);
|
|
602
|
+
this.reposURL = stripTrailingSlash(options.reposURL ?? env("MORPH_SEARCH_URL") ?? DEFAULT_REPOS_URL);
|
|
603
|
+
this.browserURL = stripTrailingSlash(
|
|
604
|
+
options.browserURL ?? (env("MORPH_ENVIRONMENT") === "DEV" ? "http://localhost:8000" : DEFAULT_BROWSER_URL)
|
|
605
|
+
);
|
|
606
|
+
this.timeout = options.timeout;
|
|
607
|
+
this.retryConfig = options.retryConfig;
|
|
608
|
+
this.debug = options.debug ?? false;
|
|
609
|
+
if (this.debug) logger.enable();
|
|
610
|
+
}
|
|
611
|
+
/** The key actually used for requests: explicit, else `MORPH_API_KEY`. */
|
|
612
|
+
resolveApiKey() {
|
|
613
|
+
return this.apiKey ?? env("MORPH_API_KEY");
|
|
614
|
+
}
|
|
615
|
+
/** Headers shared with tools that bring their own HTTP client (FastApply/WarpGrep via the `openai` package). */
|
|
616
|
+
defaultHeaders() {
|
|
617
|
+
return { "X-Morph-SDK-Version": SDK_VERSION };
|
|
618
|
+
}
|
|
619
|
+
buildURL(path, baseURL) {
|
|
620
|
+
if (/^https?:\/\//i.test(path)) return path;
|
|
621
|
+
const base = stripTrailingSlash(baseURL ?? this.baseURL);
|
|
622
|
+
return `${base}${path.startsWith("/") ? "" : "/"}${path}`;
|
|
623
|
+
}
|
|
624
|
+
buildHeaders(apiKey, extra) {
|
|
625
|
+
return {
|
|
626
|
+
"Content-Type": "application/json",
|
|
627
|
+
"X-Morph-SDK-Version": SDK_VERSION,
|
|
628
|
+
Authorization: `Bearer ${apiKey}`,
|
|
629
|
+
...extra
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
applyQuery(url, query) {
|
|
633
|
+
if (!query) return url;
|
|
634
|
+
const params = new URLSearchParams();
|
|
635
|
+
for (const [key, value] of Object.entries(query)) {
|
|
636
|
+
if (value !== void 0 && value !== null) params.set(key, String(value));
|
|
637
|
+
}
|
|
638
|
+
const qs = params.toString();
|
|
639
|
+
return qs ? `${url}${url.includes("?") ? "&" : "?"}${qs}` : url;
|
|
640
|
+
}
|
|
641
|
+
async request(method, path, opts = {}) {
|
|
642
|
+
const apiKey = this.resolveApiKey();
|
|
643
|
+
if (!apiKey) {
|
|
644
|
+
throw new MorphError(
|
|
645
|
+
"Morph API key not found. Set the MORPH_API_KEY environment variable or pass apiKey in config.",
|
|
646
|
+
"missing_api_key",
|
|
647
|
+
401
|
|
648
|
+
);
|
|
649
|
+
}
|
|
650
|
+
const url = this.applyQuery(this.buildURL(path, opts.baseURL), opts.query);
|
|
651
|
+
const timeout = opts.timeout ?? this.timeout ?? DEFAULT_TIMEOUT2;
|
|
652
|
+
const init = {
|
|
653
|
+
method,
|
|
654
|
+
headers: this.buildHeaders(apiKey, opts.headers),
|
|
655
|
+
...opts.body !== void 0 ? { body: JSON.stringify(opts.body) } : {},
|
|
656
|
+
...opts.signal ? { signal: opts.signal } : {}
|
|
657
|
+
};
|
|
658
|
+
logger.debug("MorphAPIClient", "request", { method, url });
|
|
659
|
+
const response = await withTimeout(
|
|
660
|
+
fetchWithRetry(url, init, this.retryConfig ?? {}),
|
|
661
|
+
timeout,
|
|
662
|
+
`Morph request to ${url} timed out after ${timeout}ms`
|
|
663
|
+
);
|
|
664
|
+
if (opts.raw) return response;
|
|
665
|
+
if (!response.ok) throw await toMorphError(response);
|
|
666
|
+
if (opts.stream) return response;
|
|
667
|
+
if (response.status === 204) return void 0;
|
|
668
|
+
const text = await response.text();
|
|
669
|
+
return text ? JSON.parse(text) : void 0;
|
|
670
|
+
}
|
|
671
|
+
get(path, opts) {
|
|
672
|
+
return this.request("GET", path, opts);
|
|
673
|
+
}
|
|
674
|
+
post(path, opts) {
|
|
675
|
+
return this.request("POST", path, opts);
|
|
676
|
+
}
|
|
677
|
+
delete(path, opts) {
|
|
678
|
+
return this.request("DELETE", path, opts);
|
|
679
|
+
}
|
|
542
680
|
};
|
|
543
|
-
|
|
544
|
-
|
|
681
|
+
|
|
682
|
+
// core/resource.ts
|
|
683
|
+
var APIResource = class {
|
|
684
|
+
_client;
|
|
685
|
+
constructor(client) {
|
|
686
|
+
this._client = client;
|
|
687
|
+
}
|
|
688
|
+
};
|
|
689
|
+
|
|
690
|
+
// modelrouter/core.ts
|
|
691
|
+
var DEFAULT_API_URL2 = "https://api.morphllm.com";
|
|
692
|
+
var DEFAULT_TIMEOUT3 = 5e3;
|
|
693
|
+
function resolveClient(clientOrConfig) {
|
|
694
|
+
if (clientOrConfig instanceof MorphAPIClient) return clientOrConfig;
|
|
695
|
+
return new MorphAPIClient({
|
|
696
|
+
apiKey: clientOrConfig.apiKey,
|
|
697
|
+
baseURL: clientOrConfig.apiUrl ?? DEFAULT_API_URL2,
|
|
698
|
+
timeout: clientOrConfig.timeout ?? DEFAULT_TIMEOUT3,
|
|
699
|
+
retryConfig: clientOrConfig.retryConfig,
|
|
700
|
+
debug: clientOrConfig.debug
|
|
701
|
+
});
|
|
702
|
+
}
|
|
703
|
+
var BaseRouter = class extends APIResource {
|
|
545
704
|
provider;
|
|
546
|
-
|
|
705
|
+
timeout;
|
|
706
|
+
constructor(provider, clientOrConfig = {}) {
|
|
707
|
+
super(resolveClient(clientOrConfig));
|
|
547
708
|
this.provider = provider;
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
apiUrl: config.apiUrl || DEFAULT_CONFIG.apiUrl,
|
|
551
|
-
timeout: config.timeout || DEFAULT_CONFIG.timeout,
|
|
552
|
-
debug: config.debug || DEFAULT_CONFIG.debug,
|
|
553
|
-
retryConfig: config.retryConfig
|
|
554
|
-
};
|
|
709
|
+
const cfg = clientOrConfig instanceof MorphAPIClient ? {} : clientOrConfig;
|
|
710
|
+
this.timeout = cfg.timeout ?? DEFAULT_TIMEOUT3;
|
|
555
711
|
}
|
|
556
|
-
/**
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
async selectModel(input) {
|
|
560
|
-
const mode = input.mode || "balanced";
|
|
561
|
-
const apiKey = this.config.apiKey || (typeof process !== "undefined" ? process.env?.MORPH_API_KEY : void 0);
|
|
562
|
-
if (!apiKey) {
|
|
712
|
+
/** Throw the historical "API key is required" message when no key is resolvable. */
|
|
713
|
+
requireApiKey() {
|
|
714
|
+
if (!this._client.resolveApiKey()) {
|
|
563
715
|
throw new Error(
|
|
564
716
|
"Morph API key is required. Set MORPH_API_KEY environment variable or pass apiKey in config."
|
|
565
717
|
);
|
|
566
718
|
}
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
mode
|
|
571
|
-
};
|
|
572
|
-
logger.debug("ModelRouter", "request", { provider: this.provider, mode, input_len: input.input.length, url });
|
|
719
|
+
}
|
|
720
|
+
/** POST to the router and surface failures as `Router API error (<status>): ...`. */
|
|
721
|
+
async route(provider, input) {
|
|
573
722
|
try {
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
headers: {
|
|
579
|
-
"Content-Type": "application/json",
|
|
580
|
-
Authorization: `Bearer ${apiKey}`
|
|
581
|
-
},
|
|
582
|
-
body: JSON.stringify(payload)
|
|
583
|
-
},
|
|
584
|
-
this.config.retryConfig
|
|
585
|
-
);
|
|
586
|
-
const response = await withTimeout(
|
|
587
|
-
fetchPromise,
|
|
588
|
-
this.config.timeout,
|
|
589
|
-
`Router API request timed out after ${this.config.timeout}ms`
|
|
590
|
-
);
|
|
591
|
-
if (!response.ok) {
|
|
592
|
-
const errorText = await response.text();
|
|
593
|
-
throw new Error(
|
|
594
|
-
`Router API error (${response.status}): ${errorText || response.statusText}`
|
|
595
|
-
);
|
|
596
|
-
}
|
|
597
|
-
const apiResult = await response.json();
|
|
598
|
-
const result = {
|
|
599
|
-
model: apiResult.model
|
|
600
|
-
};
|
|
601
|
-
logger.debug("ModelRouter", "selected", { provider: this.provider, model: apiResult.model, confidence: apiResult.confidence });
|
|
602
|
-
return result;
|
|
723
|
+
return await this._client.post(`/v1/router/${provider}`, {
|
|
724
|
+
body: { input: input.input, mode: input.mode || "balanced" },
|
|
725
|
+
timeout: this.timeout
|
|
726
|
+
});
|
|
603
727
|
} catch (error) {
|
|
604
|
-
|
|
728
|
+
if (error instanceof MorphError) {
|
|
729
|
+
throw new Error(`Router API error (${error.statusCode}): ${error.message}`);
|
|
730
|
+
}
|
|
605
731
|
throw error;
|
|
606
732
|
}
|
|
607
733
|
}
|
|
734
|
+
/**
|
|
735
|
+
* Select the optimal model for a given input and mode
|
|
736
|
+
*/
|
|
737
|
+
async selectModel(input) {
|
|
738
|
+
this.requireApiKey();
|
|
739
|
+
logger.debug("ModelRouter", "request", { provider: this.provider, mode: input.mode || "balanced" });
|
|
740
|
+
const apiResult = await this.route(this.provider, input);
|
|
741
|
+
logger.debug("ModelRouter", "selected", { provider: this.provider, model: apiResult.model });
|
|
742
|
+
return { model: apiResult.model };
|
|
743
|
+
}
|
|
608
744
|
};
|
|
609
745
|
var OpenAIRouter = class extends BaseRouter {
|
|
610
|
-
constructor(
|
|
611
|
-
super("openai",
|
|
746
|
+
constructor(clientOrConfig = {}) {
|
|
747
|
+
super("openai", clientOrConfig);
|
|
612
748
|
}
|
|
613
749
|
/**
|
|
614
750
|
* Select optimal GPT-5 model
|
|
615
|
-
*
|
|
751
|
+
*
|
|
616
752
|
* @param input - User input and mode
|
|
617
753
|
* @returns Selected model name (gpt-5-mini | gpt-5-low | gpt-5-medium | gpt-5-high)
|
|
618
754
|
*/
|
|
@@ -621,12 +757,12 @@ var OpenAIRouter = class extends BaseRouter {
|
|
|
621
757
|
}
|
|
622
758
|
};
|
|
623
759
|
var AnthropicRouter = class extends BaseRouter {
|
|
624
|
-
constructor(
|
|
625
|
-
super("anthropic",
|
|
760
|
+
constructor(clientOrConfig = {}) {
|
|
761
|
+
super("anthropic", clientOrConfig);
|
|
626
762
|
}
|
|
627
763
|
/**
|
|
628
764
|
* Select optimal Claude model
|
|
629
|
-
*
|
|
765
|
+
*
|
|
630
766
|
* @param input - User input and mode
|
|
631
767
|
* @returns Selected model name (claude-4.5-haiku | claude-4.5-sonnet)
|
|
632
768
|
*/
|
|
@@ -635,12 +771,12 @@ var AnthropicRouter = class extends BaseRouter {
|
|
|
635
771
|
}
|
|
636
772
|
};
|
|
637
773
|
var GeminiRouter = class extends BaseRouter {
|
|
638
|
-
constructor(
|
|
639
|
-
super("gemini",
|
|
774
|
+
constructor(clientOrConfig = {}) {
|
|
775
|
+
super("gemini", clientOrConfig);
|
|
640
776
|
}
|
|
641
777
|
/**
|
|
642
778
|
* Select optimal Gemini model
|
|
643
|
-
*
|
|
779
|
+
*
|
|
644
780
|
* @param input - User input and mode
|
|
645
781
|
* @returns Selected model name (gemini-2.5-flash | gemini-2.5-pro)
|
|
646
782
|
*/
|
|
@@ -649,82 +785,53 @@ var GeminiRouter = class extends BaseRouter {
|
|
|
649
785
|
}
|
|
650
786
|
};
|
|
651
787
|
var RawRouter = class extends BaseRouter {
|
|
652
|
-
constructor(
|
|
653
|
-
super("raw",
|
|
788
|
+
constructor(clientOrConfig = {}) {
|
|
789
|
+
super("raw", clientOrConfig);
|
|
654
790
|
}
|
|
655
791
|
/**
|
|
656
792
|
* Get raw difficulty classification
|
|
657
|
-
*
|
|
793
|
+
*
|
|
658
794
|
* @param input - User input and mode
|
|
659
795
|
* @returns Raw difficulty (easy | medium | hard | needs_info)
|
|
660
796
|
*/
|
|
661
797
|
async classify(input) {
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
const payload = {
|
|
671
|
-
input: input.input,
|
|
672
|
-
mode
|
|
673
|
-
};
|
|
674
|
-
logger.debug("RawRouter", "request", { mode, input_len: input.input.length, url });
|
|
675
|
-
try {
|
|
676
|
-
const fetchPromise = fetchWithRetry(
|
|
677
|
-
url,
|
|
678
|
-
{
|
|
679
|
-
method: "POST",
|
|
680
|
-
headers: {
|
|
681
|
-
"Content-Type": "application/json",
|
|
682
|
-
Authorization: `Bearer ${apiKey}`
|
|
683
|
-
},
|
|
684
|
-
body: JSON.stringify(payload)
|
|
685
|
-
},
|
|
686
|
-
this.config.retryConfig
|
|
687
|
-
);
|
|
688
|
-
const response = await withTimeout(
|
|
689
|
-
fetchPromise,
|
|
690
|
-
this.config.timeout,
|
|
691
|
-
`Router API request timed out after ${this.config.timeout}ms`
|
|
692
|
-
);
|
|
693
|
-
if (!response.ok) {
|
|
694
|
-
const errorText = await response.text();
|
|
695
|
-
throw new Error(
|
|
696
|
-
`Router API error (${response.status}): ${errorText || response.statusText}`
|
|
697
|
-
);
|
|
698
|
-
}
|
|
699
|
-
const apiResult = await response.json();
|
|
700
|
-
let difficulty;
|
|
701
|
-
if (apiResult.difficulty === "") {
|
|
702
|
-
difficulty = "medium";
|
|
703
|
-
} else {
|
|
704
|
-
difficulty = apiResult.difficulty || apiResult.model;
|
|
705
|
-
}
|
|
706
|
-
const result = {
|
|
707
|
-
difficulty
|
|
708
|
-
};
|
|
709
|
-
logger.debug("RawRouter", "classified", { difficulty });
|
|
710
|
-
return result;
|
|
711
|
-
} catch (error) {
|
|
712
|
-
logger.error("RawRouter", "error", { error: error instanceof Error ? error.message : String(error) });
|
|
713
|
-
throw error;
|
|
798
|
+
this.requireApiKey();
|
|
799
|
+
logger.debug("RawRouter", "request", { mode: input.mode || "balanced" });
|
|
800
|
+
const apiResult = await this.route("raw", input);
|
|
801
|
+
let difficulty;
|
|
802
|
+
if (apiResult.difficulty === "") {
|
|
803
|
+
difficulty = "medium";
|
|
804
|
+
} else {
|
|
805
|
+
difficulty = apiResult.difficulty || apiResult.model;
|
|
714
806
|
}
|
|
807
|
+
logger.debug("RawRouter", "classified", { difficulty });
|
|
808
|
+
return { difficulty };
|
|
715
809
|
}
|
|
716
810
|
};
|
|
717
811
|
|
|
718
812
|
// tools/compact/core.ts
|
|
719
|
-
var
|
|
720
|
-
var
|
|
721
|
-
|
|
813
|
+
var DEFAULT_API_URL3 = "https://api.morphllm.com";
|
|
814
|
+
var DEFAULT_TIMEOUT4 = 12e4;
|
|
815
|
+
function resolveClient2(clientOrConfig) {
|
|
816
|
+
if (clientOrConfig instanceof MorphAPIClient) return clientOrConfig;
|
|
817
|
+
return new MorphAPIClient({
|
|
818
|
+
apiKey: clientOrConfig.morphApiKey,
|
|
819
|
+
baseURL: clientOrConfig.morphApiUrl ?? DEFAULT_API_URL3,
|
|
820
|
+
timeout: clientOrConfig.timeout ?? DEFAULT_TIMEOUT4,
|
|
821
|
+
retryConfig: clientOrConfig.retryConfig,
|
|
822
|
+
debug: clientOrConfig.debug
|
|
823
|
+
});
|
|
824
|
+
}
|
|
825
|
+
var CompactClient = class extends APIResource {
|
|
826
|
+
/** Resolved URL/timeout, exposed for backwards-compatible introspection. */
|
|
722
827
|
config;
|
|
723
|
-
constructor(
|
|
828
|
+
constructor(clientOrConfig = {}) {
|
|
829
|
+
super(resolveClient2(clientOrConfig));
|
|
830
|
+
const cfg = clientOrConfig instanceof MorphAPIClient ? {} : clientOrConfig;
|
|
724
831
|
this.config = {
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
832
|
+
morphApiUrl: this._client.baseURL,
|
|
833
|
+
timeout: cfg.timeout ?? DEFAULT_TIMEOUT4,
|
|
834
|
+
debug: cfg.debug ?? false
|
|
728
835
|
};
|
|
729
836
|
}
|
|
730
837
|
/**
|
|
@@ -743,17 +850,6 @@ var CompactClient = class {
|
|
|
743
850
|
* ```
|
|
744
851
|
*/
|
|
745
852
|
async compact(input) {
|
|
746
|
-
const apiKey = this.config.morphApiKey || (typeof process !== "undefined" ? process.env?.MORPH_API_KEY : void 0);
|
|
747
|
-
const debug = this.config.debug || false;
|
|
748
|
-
if (!apiKey) {
|
|
749
|
-
throw new Error(
|
|
750
|
-
"Morph API key not found. Set MORPH_API_KEY environment variable or pass morphApiKey in config."
|
|
751
|
-
);
|
|
752
|
-
}
|
|
753
|
-
const url = `${this.config.morphApiUrl}/v1/compact`;
|
|
754
|
-
if (debug) {
|
|
755
|
-
console.log(`[Compact] Calling ${url}`);
|
|
756
|
-
}
|
|
757
853
|
const body = {
|
|
758
854
|
compression_ratio: input.compressionRatio ?? 0.5,
|
|
759
855
|
preserve_recent: input.preserveRecent ?? 2,
|
|
@@ -761,37 +857,19 @@ var CompactClient = class {
|
|
|
761
857
|
include_line_ranges: input.includeLineRanges ?? true,
|
|
762
858
|
include_markers: input.includeMarkers ?? true
|
|
763
859
|
};
|
|
764
|
-
if (input.query !== void 0)
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
if (input.
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
}
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
const startTime = Date.now();
|
|
777
|
-
const response = await fetch(url, {
|
|
778
|
-
method: "POST",
|
|
779
|
-
headers: {
|
|
780
|
-
"Authorization": `Bearer ${apiKey}`,
|
|
781
|
-
"Content-Type": "application/json"
|
|
782
|
-
},
|
|
783
|
-
body: JSON.stringify(body),
|
|
784
|
-
signal: AbortSignal.timeout(this.config.timeout)
|
|
785
|
-
});
|
|
786
|
-
if (!response.ok) {
|
|
787
|
-
const text = await response.text();
|
|
788
|
-
throw new Error(`Compact API error ${response.status}: ${text}`);
|
|
789
|
-
}
|
|
790
|
-
const data = await response.json();
|
|
791
|
-
if (debug) {
|
|
792
|
-
console.log(`[Compact] compact() done in ${Date.now() - startTime}ms`);
|
|
860
|
+
if (input.query !== void 0) body.query = input.query;
|
|
861
|
+
if (input.messages) body.messages = input.messages;
|
|
862
|
+
else if (typeof input.input === "string") body.input = input.input;
|
|
863
|
+
else if (Array.isArray(input.input)) body.messages = input.input;
|
|
864
|
+
else throw new Error("Either 'input' or 'messages' must be provided");
|
|
865
|
+
try {
|
|
866
|
+
return await this._client.post("/v1/compact", { body, timeout: this.config.timeout });
|
|
867
|
+
} catch (err) {
|
|
868
|
+
if (err instanceof MorphError) {
|
|
869
|
+
throw new Error(`Compact API error ${err.statusCode}: ${err.message}`);
|
|
870
|
+
}
|
|
871
|
+
throw err;
|
|
793
872
|
}
|
|
794
|
-
return data;
|
|
795
873
|
}
|
|
796
874
|
};
|
|
797
875
|
// Annotate the CommonJS export names for ESM import in node:
|