@morphllm/morphsdk 0.2.171 → 0.2.173
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-SW527EQT.js → chunk-33ZRF6X3.js} +4 -4
- package/dist/{chunk-3BCKZKNK.js → chunk-3GNXTHHB.js} +2 -2
- package/dist/{chunk-IGQYZ2KH.js → chunk-3I4LCNWJ.js} +2 -2
- package/dist/{chunk-4324ZSCW.js → chunk-577P2AXE.js} +2 -2
- package/dist/{chunk-MZZMSL26.js → chunk-5RTWSAZ6.js} +2 -2
- package/dist/{chunk-JEDEBCZM.js → chunk-73DQQMGR.js} +8 -3
- package/dist/{chunk-JEDEBCZM.js.map → chunk-73DQQMGR.js.map} +1 -1
- package/dist/{chunk-3XRNC56L.js → chunk-7EUJ2AKS.js} +4 -4
- package/dist/{chunk-JLLIVBKY.js → chunk-ACWLQFYS.js} +30 -6
- package/dist/chunk-ACWLQFYS.js.map +1 -0
- package/dist/{chunk-IW4TYYG6.js → chunk-AZOSA7VT.js} +2 -2
- package/dist/{chunk-ZJQTTOHO.js → chunk-C3V5FHZI.js} +2 -2
- package/dist/{chunk-LL3EWDKD.js → chunk-CEZQSARX.js} +4 -4
- package/dist/{chunk-EFCDIESP.js → chunk-CV7SLK6R.js} +2 -2
- package/dist/{chunk-GLQWEINZ.js → chunk-EJ2CQO4V.js} +2 -2
- package/dist/{chunk-LE66XCOI.js → chunk-FN4ADWFQ.js} +27 -10
- package/dist/chunk-FN4ADWFQ.js.map +1 -0
- package/dist/{chunk-CMFY26F3.js → chunk-GESRH23M.js} +4 -4
- package/dist/{chunk-FQJCE2FX.js → chunk-I4FCFIBU.js} +29 -10
- package/dist/chunk-I4FCFIBU.js.map +1 -0
- package/dist/{chunk-JTUB5ZCT.js → chunk-JXJBF6CV.js} +2 -2
- package/dist/chunk-LKFZBBTD.js +12 -0
- package/dist/chunk-LKFZBBTD.js.map +1 -0
- package/dist/{chunk-2ALTBYMY.js → chunk-MQTMT4OR.js} +4 -4
- package/dist/{chunk-UK7TI7QY.js → chunk-NBKL7VWX.js} +101 -145
- package/dist/chunk-NBKL7VWX.js.map +1 -0
- package/dist/{chunk-C37YAYBK.js → chunk-QCFHQPHC.js} +2 -2
- package/dist/chunk-QE3SPHIM.js +120 -0
- package/dist/chunk-QE3SPHIM.js.map +1 -0
- package/dist/{chunk-TAS6S42A.js → chunk-QE6JHRVD.js} +2 -2
- package/dist/{chunk-Y6T4NA75.js → chunk-RXCHMNCY.js} +2 -2
- package/dist/{chunk-4MTZUTNH.js → chunk-S5R4H5HM.js} +23 -8
- package/dist/chunk-S5R4H5HM.js.map +1 -0
- package/dist/chunk-SM3OQZRS.js +142 -0
- package/dist/chunk-SM3OQZRS.js.map +1 -0
- package/dist/chunk-TS56XYWB.js +78 -0
- package/dist/chunk-TS56XYWB.js.map +1 -0
- package/dist/{chunk-5EUMJI3I.js → chunk-TW3XQET2.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-W6AGNJ5O.js +97 -0
- package/dist/chunk-W6AGNJ5O.js.map +1 -0
- package/dist/chunk-YGNPVOUO.js +158 -0
- package/dist/chunk-YGNPVOUO.js.map +1 -0
- package/dist/{chunk-2OAKX4SZ.js → chunk-Z3KRXUNG.js} +4 -4
- package/dist/chunk-ZFOR3LI4.js +24 -0
- package/dist/chunk-ZFOR3LI4.js.map +1 -0
- package/dist/{client-DsAAqupx.d.ts → client-Dh6yzCm4.d.ts} +14 -5
- package/dist/client.cjs +724 -523
- 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 +236 -173
- 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 +672 -465
- 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 +16 -2
- package/dist/tools/fastapply/anthropic.cjs.map +1 -1
- package/dist/tools/fastapply/anthropic.js +8 -4
- package/dist/tools/fastapply/apply.cjs +7 -2
- package/dist/tools/fastapply/apply.cjs.map +1 -1
- package/dist/tools/fastapply/apply.js +2 -2
- package/dist/tools/fastapply/core.cjs +242 -12
- 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 +16 -2
- 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 +16 -2
- package/dist/tools/fastapply/openai.cjs.map +1 -1
- package/dist/tools/fastapply/openai.js +8 -4
- package/dist/tools/fastapply/vercel.cjs +16 -2
- package/dist/tools/fastapply/vercel.cjs.map +1 -1
- package/dist/tools/fastapply/vercel.js +8 -4
- package/dist/tools/index.cjs +16 -2
- 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 +114 -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-4MTZUTNH.js.map +0 -1
- package/dist/chunk-FQJCE2FX.js.map +0 -1
- package/dist/chunk-H5WNI6R5.js +0 -102
- package/dist/chunk-H5WNI6R5.js.map +0 -1
- package/dist/chunk-JLLIVBKY.js.map +0 -1
- package/dist/chunk-KCFMXLZ7.js +0 -197
- package/dist/chunk-KCFMXLZ7.js.map +0 -1
- package/dist/chunk-LE66XCOI.js.map +0 -1
- package/dist/chunk-SCVWDNQP.js +0 -84
- package/dist/chunk-SCVWDNQP.js.map +0 -1
- package/dist/chunk-UK7TI7QY.js.map +0 -1
- /package/dist/{chunk-SW527EQT.js.map → chunk-33ZRF6X3.js.map} +0 -0
- /package/dist/{chunk-3BCKZKNK.js.map → chunk-3GNXTHHB.js.map} +0 -0
- /package/dist/{chunk-IGQYZ2KH.js.map → chunk-3I4LCNWJ.js.map} +0 -0
- /package/dist/{chunk-4324ZSCW.js.map → chunk-577P2AXE.js.map} +0 -0
- /package/dist/{chunk-MZZMSL26.js.map → chunk-5RTWSAZ6.js.map} +0 -0
- /package/dist/{chunk-3XRNC56L.js.map → chunk-7EUJ2AKS.js.map} +0 -0
- /package/dist/{chunk-IW4TYYG6.js.map → chunk-AZOSA7VT.js.map} +0 -0
- /package/dist/{chunk-ZJQTTOHO.js.map → chunk-C3V5FHZI.js.map} +0 -0
- /package/dist/{chunk-LL3EWDKD.js.map → chunk-CEZQSARX.js.map} +0 -0
- /package/dist/{chunk-EFCDIESP.js.map → chunk-CV7SLK6R.js.map} +0 -0
- /package/dist/{chunk-GLQWEINZ.js.map → chunk-EJ2CQO4V.js.map} +0 -0
- /package/dist/{chunk-CMFY26F3.js.map → chunk-GESRH23M.js.map} +0 -0
- /package/dist/{chunk-JTUB5ZCT.js.map → chunk-JXJBF6CV.js.map} +0 -0
- /package/dist/{chunk-2ALTBYMY.js.map → chunk-MQTMT4OR.js.map} +0 -0
- /package/dist/{chunk-C37YAYBK.js.map → chunk-QCFHQPHC.js.map} +0 -0
- /package/dist/{chunk-TAS6S42A.js.map → chunk-QE6JHRVD.js.map} +0 -0
- /package/dist/{chunk-Y6T4NA75.js.map → chunk-RXCHMNCY.js.map} +0 -0
- /package/dist/{chunk-5EUMJI3I.js.map → chunk-TW3XQET2.js.map} +0 -0
- /package/dist/{chunk-OPNTDMHH.js.map → chunk-VLZ6PNAD.js.map} +0 -0
- /package/dist/{chunk-2OAKX4SZ.js.map → chunk-Z3KRXUNG.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ProfilesClient
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-577P2AXE.js";
|
|
4
4
|
import {
|
|
5
5
|
buildEmbedCode,
|
|
6
6
|
buildLiveIframe,
|
|
@@ -8,12 +8,18 @@ import {
|
|
|
8
8
|
resolvePreset
|
|
9
9
|
} from "./chunk-YTYCHRQ2.js";
|
|
10
10
|
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} from "./chunk-JTUB5ZCT.js";
|
|
11
|
+
MorphAPIClient
|
|
12
|
+
} from "./chunk-QE3SPHIM.js";
|
|
14
13
|
import {
|
|
15
14
|
logger
|
|
16
15
|
} from "./chunk-F3NCFNUX.js";
|
|
16
|
+
import {
|
|
17
|
+
fetchWithRetry,
|
|
18
|
+
withTimeout
|
|
19
|
+
} from "./chunk-JXJBF6CV.js";
|
|
20
|
+
import {
|
|
21
|
+
APIResource
|
|
22
|
+
} from "./chunk-LKFZBBTD.js";
|
|
17
23
|
|
|
18
24
|
// tools/browser/core.ts
|
|
19
25
|
var DEFAULT_CONFIG = {
|
|
@@ -22,17 +28,30 @@ var DEFAULT_CONFIG = {
|
|
|
22
28
|
// 10 minutes for complex tasks
|
|
23
29
|
debug: false
|
|
24
30
|
};
|
|
25
|
-
var BrowserClient = class {
|
|
31
|
+
var BrowserClient = class extends APIResource {
|
|
26
32
|
config;
|
|
27
33
|
/**
|
|
28
34
|
* Profile management - create and manage browser profiles for storing login state.
|
|
29
35
|
*/
|
|
30
36
|
profiles;
|
|
31
|
-
constructor(
|
|
32
|
-
|
|
37
|
+
constructor(clientOrConfig = {}) {
|
|
38
|
+
const isClient = clientOrConfig instanceof MorphAPIClient;
|
|
39
|
+
super(
|
|
40
|
+
isClient ? clientOrConfig : new MorphAPIClient({
|
|
41
|
+
apiKey: clientOrConfig.apiKey,
|
|
42
|
+
browserURL: clientOrConfig.apiUrl,
|
|
43
|
+
timeout: clientOrConfig.timeout,
|
|
44
|
+
retryConfig: clientOrConfig.retryConfig,
|
|
45
|
+
debug: clientOrConfig.debug
|
|
46
|
+
})
|
|
47
|
+
);
|
|
48
|
+
this.config = isClient ? {
|
|
33
49
|
...DEFAULT_CONFIG,
|
|
34
|
-
|
|
35
|
-
|
|
50
|
+
apiUrl: clientOrConfig.browserURL,
|
|
51
|
+
apiKey: clientOrConfig.resolveApiKey(),
|
|
52
|
+
retryConfig: clientOrConfig.retryConfig,
|
|
53
|
+
debug: clientOrConfig.debug
|
|
54
|
+
} : { ...DEFAULT_CONFIG, ...clientOrConfig };
|
|
36
55
|
this.profiles = new ProfilesClient(this.config);
|
|
37
56
|
}
|
|
38
57
|
/**
|
|
@@ -600,4 +619,4 @@ export {
|
|
|
600
619
|
getWebp,
|
|
601
620
|
checkHealth
|
|
602
621
|
};
|
|
603
|
-
//# sourceMappingURL=chunk-
|
|
622
|
+
//# sourceMappingURL=chunk-I4FCFIBU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../tools/browser/core.ts"],"sourcesContent":["/**\n * Core implementation for browser automation tasks\n */\n\nimport { fetchWithRetry, withTimeout } from '../utils/resilience.js';\nimport { logger } from '../../logger.js';\nimport type {\n BrowserConfig,\n BrowserTaskInput,\n BrowserTaskInputWithSchema,\n BrowserTaskResult,\n BrowserTaskWithPromise,\n BrowserTaskWithPromiseAndSchema,\n RecordingStatus,\n RecordingWithMethods,\n ErrorsResponse,\n LiveSessionOptions,\n IframeOptions,\n WebpOptions,\n WebpResponse,\n} from './types.js';\nimport { buildLiveUrl, buildLiveIframe, buildEmbedCode, resolvePreset } from './live.js';\nimport { ProfilesClient } from './profiles/core.js';\nimport { MorphAPIClient } from '../../core/client.js';\nimport { APIResource } from '../../core/resource.js';\n\nconst DEFAULT_CONFIG = {\n apiUrl: process.env.MORPH_ENVIRONMENT === 'DEV' \n ? 'http://localhost:8000'\n : 'https://browser.morphllm.com',\n timeout: 1000000, // 10 minutes for complex tasks\n debug: false,\n};\n\n/**\n * BrowserClient class for easier usage with instance configuration\n *\n * @deprecated Prefer the unified `MorphClient` (`new MorphClient({ apiKey }).browser`).\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 BrowserClient extends APIResource {\n private config: BrowserConfig;\n\n /**\n * Profile management - create and manage browser profiles for storing login state.\n */\n public profiles: ProfilesClient;\n\n constructor(clientOrConfig: MorphAPIClient | BrowserConfig = {}) {\n const isClient = clientOrConfig instanceof MorphAPIClient;\n super(\n isClient\n ? clientOrConfig\n : new MorphAPIClient({\n apiKey: clientOrConfig.apiKey,\n browserURL: clientOrConfig.apiUrl,\n timeout: clientOrConfig.timeout,\n retryConfig: clientOrConfig.retryConfig,\n debug: clientOrConfig.debug,\n }),\n );\n // Browser is a distinct service: keep its own wire (raw fetch in the\n // module functions below) but source the host/key/retries from the shared\n // transport so configuration lives in one place.\n this.config = isClient\n ? {\n ...DEFAULT_CONFIG,\n apiUrl: clientOrConfig.browserURL,\n apiKey: clientOrConfig.resolveApiKey(),\n retryConfig: clientOrConfig.retryConfig,\n debug: clientOrConfig.debug,\n }\n : { ...DEFAULT_CONFIG, ...clientOrConfig };\n this.profiles = new ProfilesClient(this.config);\n }\n\n /**\n * Execute a browser automation task\n */\n async execute(input: BrowserTaskInput): Promise<BrowserTaskResult> {\n return executeBrowserTask(input, this.config);\n }\n\n async createTask(input: BrowserTaskInput): Promise<BrowserTaskWithPromise>;\n async createTask<T>(input: BrowserTaskInputWithSchema<T>): Promise<BrowserTaskWithPromiseAndSchema<T>>;\n async createTask<T>(\n input: BrowserTaskInput | BrowserTaskInputWithSchema<T>\n ): Promise<BrowserTaskWithPromise | BrowserTaskWithPromiseAndSchema<T>> {\n const apiUrl = this.config.apiUrl || DEFAULT_CONFIG.apiUrl;\n const debug = this.config.debug || false;\n \n const hasTask = typeof input.task === 'string' && input.task.trim().length > 0;\n const hasDiff = typeof (input as any).diff === 'string' && (input as any).diff.trim().length > 0;\n\n if (!hasTask && !hasDiff) {\n throw new Error('Browser task requires either \"task\" (natural language) or \"diff\" (PR-review planning)');\n }\n\n logger.debug('Browser', 'create_task', { task: (input.task ?? '').slice(0, 100), url: input.url, endpoint: `${apiUrl}/browser-task/async` });\n \n const headers: Record<string, string> = { 'Content-Type': 'application/json' };\n if (this.config.apiKey) headers['Authorization'] = `Bearer ${this.config.apiKey}`;\n \n // Call ASYNC endpoint for immediate return with live URL\n const response = await fetch(`${apiUrl}/browser-task/async`, {\n method: 'POST',\n headers,\n body: JSON.stringify({\n task: input.task,\n diff: input.diff,\n url: input.url,\n max_steps: input.maxSteps ?? 10,\n model: input.model ?? 'morph-computer-use-v0',\n viewport_width: input.viewportWidth ?? 1280,\n viewport_height: input.viewportHeight ?? 720,\n external_id: input.externalId,\n repo_id: input.repoId,\n repo_full_name: input.repoFullName,\n commit_id: input.commitId,\n record_video: input.recordVideo ?? false,\n video_width: input.videoWidth ?? input.viewportWidth ?? 1280,\n video_height: input.videoHeight ?? input.viewportHeight ?? 720,\n allow_resizing: input.allowResizing ?? false,\n structured_output: 'schema' in input ? stringifyStructuredOutput(input.schema) : undefined,\n auth: input.auth,\n profile_id: input.profileId,\n force_query_params: input.forceQueryParams,\n }),\n });\n\n if (!response.ok) {\n const errorText = await response.text().catch(() => response.statusText);\n logger.error('Browser', 'create_task_error', { status: response.status, error: errorText });\n throw new Error(`HTTP ${response.status}: ${errorText}`);\n }\n\n const result = mapTaskResult(await response.json());\n logger.debug('Browser', 'task_created', { recording_id: result.recordingId, task_id: result.taskId, debug_url: !!result.debugUrl });\n \n if ('schema' in input) {\n return wrapTaskResponseWithSchema(result, this.config, input.schema);\n } else {\n return wrapTaskResponse(result, this.config);\n }\n }\n\n /**\n * Execute task with recording and wait for video to be ready\n */\n async executeWithRecording(\n input: BrowserTaskInput & { recordVideo: true }\n ): Promise<BrowserTaskResult & { recording?: RecordingWithMethods }> {\n return executeWithRecording(input, this.config);\n }\n\n /**\n * Get recording status and URLs\n */\n async getRecording(recordingId: string): Promise<RecordingWithMethods> {\n return getRecording(recordingId, this.config);\n }\n\n /**\n * Wait for recording to complete with automatic polling\n */\n async waitForRecording(\n recordingId: string,\n options?: { timeout?: number; pollInterval?: number }\n ): Promise<RecordingWithMethods> {\n return waitForRecording(recordingId, this.config, options);\n }\n\n /**\n * Get errors from recording with screenshots\n */\n async getErrors(recordingId: string): Promise<ErrorsResponse> {\n return getErrors(recordingId, this.config);\n }\n\n /**\n * Get animated WebP preview of recording\n */\n async getWebp(\n recordingId: string,\n options?: WebpOptions\n ): Promise<WebpResponse> {\n return getWebp(recordingId, this.config, options);\n }\n\n /**\n * Check if browser worker service is healthy\n */\n async checkHealth(): Promise<{\n ok: boolean;\n google_configured: boolean;\n database_configured: boolean;\n s3_configured: boolean;\n error?: string;\n }> {\n return checkHealth(this.config);\n }\n}\n\n/**\n * Execute a natural language browser automation task\n * \n * Returns the full task result including rich agent history data (urls, errors, \n * action_history, judgement, etc.). When using this as an agent tool, use the\n * formatResult() functions from the SDK adapters to return a concise summary.\n * \n * @param input - Task parameters\n * @param config - Optional configuration (apiKey, apiUrl to override default)\n * @returns Task result with success status, findings, and comprehensive execution history\n * \n * @example\n * ```typescript\n * const result = await executeBrowserTask(\n * {\n * task: \"Test checkout flow for buying a pineapple\",\n * url: \"https://3000-abc.e2b.dev\",\n * maxSteps: 20,\n * repoId: \"my-project\",\n * commitId: \"uuid-here\"\n * },\n * {\n * apiKey: process.env.MORPH_API_KEY,\n * // apiUrl: 'http://localhost:8001' // Override for local testing\n * }\n * );\n * \n * if (result.success) {\n * console.log('Task completed:', result.result);\n * console.log('URLs visited:', result.urls);\n * console.log('Actions taken:', result.actionNames);\n * console.log('Has errors:', result.hasErrors);\n * console.log('Replay:', result.replayUrl);\n * }\n * ```\n */\nexport async function executeBrowserTask(\n input: BrowserTaskInput,\n config: BrowserConfig = {}\n): Promise<BrowserTaskResult> {\n const apiUrl = config.apiUrl || DEFAULT_CONFIG.apiUrl;\n const timeout = config.timeout || DEFAULT_CONFIG.timeout;\n const debug = config.debug || false;\n\n if (!input.task || input.task.trim().length === 0) {\n return { \n success: false, \n error: 'Task description is required. Example: \"Go to example.com and click the login button\"' \n };\n }\n\n if (input.maxSteps !== undefined && (input.maxSteps < 1 || input.maxSteps > 50)) {\n return { \n success: false, \n error: 'maxSteps must be between 1 and 50. Use more steps for complex multi-page flows.'\n };\n }\n\n logger.debug('Browser', 'execute_start', { task: input.task.slice(0, 100), url: input.url, max_steps: input.maxSteps ?? 10, record_video: input.recordVideo ?? false });\n\n const startTime = Date.now();\n\n try {\n const headers: Record<string, string> = { 'Content-Type': 'application/json' };\n if (config.apiKey) headers['Authorization'] = `Bearer ${config.apiKey}`;\n\n const fetchPromise = fetchWithRetry(\n `${apiUrl}/browser-task`,\n {\n method: 'POST',\n headers,\n body: JSON.stringify({\n task: input.task,\n url: input.url,\n max_steps: input.maxSteps ?? 10,\n model: input.model ?? 'morph-computer-use-v0',\n viewport_width: input.viewportWidth ?? 1280,\n viewport_height: input.viewportHeight ?? 720,\n external_id: input.externalId,\n repo_id: input.repoId,\n commit_id: input.commitId,\n record_video: input.recordVideo ?? false,\n video_width: input.videoWidth ?? input.viewportWidth ?? 1280,\n video_height: input.videoHeight ?? input.viewportHeight ?? 720,\n allow_resizing: input.allowResizing ?? false,\n structured_output: input.structuredOutput,\n auth: input.auth,\n profile_id: input.profileId,\n force_query_params: input.forceQueryParams,\n }),\n },\n config.retryConfig\n );\n\n const response = await withTimeout(\n fetchPromise,\n timeout,\n `Browser task timed out after ${timeout}ms. Consider increasing timeout or reducing maxSteps.`\n );\n\n if (!response.ok) {\n const errorText = await response.text().catch(() => response.statusText);\n logger.error('Browser', 'execute_error', { status: response.status, error: errorText });\n throw new Error(`HTTP ${response.status}: ${errorText}`);\n }\n\n const result: BrowserTaskResult = mapTaskResult(await response.json());\n const elapsed = Date.now() - startTime;\n logger.debug('Browser', 'execute_complete', { success: result.success, latency_ms: elapsed, steps: result.stepsTaken ?? 0, recording_id: result.recordingId });\n\n return result;\n\n } catch (error) {\n if (error instanceof Error) {\n // Handle network errors\n if (error.message.includes('ECONNREFUSED') || error.message.includes('fetch failed')) {\n return {\n success: false,\n error: `Cannot connect to browser worker at ${apiUrl}. Ensure the service is running and accessible. For local dev, set MORPH_ENVIRONMENT=DEV.`,\n };\n }\n\n return {\n success: false,\n error: error.message,\n };\n }\n\n return {\n success: false,\n error: String(error),\n };\n }\n}\n\n/**\n * Get recording status and video URL\n * \n * @param recordingId - Recording UUID from BrowserTaskResult\n * @param config - Configuration with apiKey\n * @returns Recording with convenience methods (.getWebp(), .getErrors())\n * \n * @example\n * ```typescript\n * const recording = await getRecording('uuid-here', { apiKey: 'key' });\n * \n * // Get animated WebP\n * const { webpUrl } = await recording.getWebp({ width: 780 });\n * \n * // Get errors with screenshots\n * const { errors } = await recording.getErrors();\n * ```\n */\nexport async function getRecording(\n recordingId: string,\n config: BrowserConfig = {}\n): Promise<RecordingWithMethods> {\n const apiUrl = config.apiUrl || DEFAULT_CONFIG.apiUrl;\n const debug = config.debug || false;\n\n if (!config.apiKey) {\n throw new Error('API key required for getRecording');\n }\n\n if (debug) console.log(`[Browser] getRecording: ${recordingId}`);\n\n const response = await fetch(`${apiUrl}/recordings/${recordingId}`, {\n method: 'GET',\n headers: { 'Authorization': `Bearer ${config.apiKey}` },\n });\n\n if (!response.ok) {\n const errorText = await response.text().catch(() => response.statusText);\n if (debug) console.error(`[Browser] getRecording error: ${response.status} - ${errorText}`);\n throw new Error(`HTTP ${response.status}: ${errorText}`);\n }\n\n const data: RecordingStatus = mapRecordingStatus(await response.json());\n if (debug) console.log(`[Browser] Recording status: ${data.status}`);\n\n // Return recording with convenience methods\n return {\n ...data,\n getWebp: (options?: WebpOptions) => getWebp(recordingId, config, options),\n getErrors: () => getErrors(recordingId, config),\n };\n}\n\n/**\n * Wait for recording to complete with automatic polling\n * \n * @param recordingId - Recording UUID\n * @param config - Configuration with apiKey\n * @param options - Polling options\n * @returns Recording status when completed or errored\n * \n * @example\n * ```typescript\n * const result = await executeBrowserTask({ task: '...', recordVideo: true }, config);\n * if (result.recordingId) {\n * const recording = await waitForRecording(result.recordingId, config, {\n * timeout: 60000, // 1 minute\n * pollInterval: 2000 // Check every 2 seconds\n * });\n * console.log('Video URL:', recording.videoUrl);\n * }\n * ```\n */\nexport async function waitForRecording(\n recordingId: string,\n config: BrowserConfig = {},\n options: { timeout?: number; pollInterval?: number } = {}\n): Promise<RecordingWithMethods> {\n const timeout = options.timeout ?? 60000; // Default 1 minute\n const pollInterval = options.pollInterval ?? 2000; // Default 2 seconds\n const startTime = Date.now();\n\n while (Date.now() - startTime < timeout) {\n const status = await getRecording(recordingId, config);\n \n if (status.status === 'COMPLETED' || status.status === 'ERROR') {\n return status;\n }\n\n // Wait before next poll\n await new Promise(resolve => setTimeout(resolve, pollInterval));\n }\n\n throw new Error(`Recording timeout after ${timeout}ms - status still pending`);\n}\n\n/**\n * Execute task with recording and wait for video to be ready\n * \n * @param input - Task parameters with recordVideo=true\n * @param config - Configuration with apiKey\n * @returns Task result with ready video URL\n * \n * @example\n * ```typescript\n * const result = await executeWithRecording(\n * {\n * task: \"Test checkout flow\",\n * url: \"https://example.com\",\n * recordVideo: true,\n * repoId: \"my-project\"\n * },\n * { apiKey: process.env.MORPH_API_KEY }\n * );\n * \n * console.log('Task result:', result.result);\n * console.log('Video URL:', result.recording?.videoUrl);\n * ```\n */\nexport async function executeWithRecording(\n input: BrowserTaskInput & { recordVideo: true },\n config: BrowserConfig = {}\n): Promise<BrowserTaskResult & { recording?: RecordingWithMethods }> {\n // Execute task with recording\n const taskResult = await executeBrowserTask(input, config);\n\n // If recording was created, wait for it to complete\n if (taskResult.recordingId) {\n try {\n const recording = await waitForRecording(\n taskResult.recordingId,\n config,\n { timeout: 60000, pollInterval: 2000 }\n );\n return {\n ...taskResult,\n recording,\n };\n } catch (error) {\n // Return task result even if recording fails\n // Still attach convenience methods for consistent API\n const errorRecording: RecordingWithMethods = {\n id: taskResult.recordingId,\n status: 'ERROR',\n error: error instanceof Error ? error.message : String(error),\n createdAt: new Date().toISOString(),\n getWebp: (options?: WebpOptions) => getWebp(taskResult.recordingId!, config, options),\n getErrors: () => getErrors(taskResult.recordingId!, config),\n };\n return {\n ...taskResult,\n recording: errorRecording,\n };\n }\n }\n\n return taskResult;\n}\n\n/**\n * Get errors from recording with screenshots\n * \n * Screenshots are captured in real-time (500ms after error occurs) during the browser session.\n * \n * @param recordingId - Recording UUID from BrowserTaskResult\n * @param config - Configuration with apiKey\n * @returns Errors with real-time screenshots\n * \n * @example\n * ```typescript\n * const { errors, totalErrors } = await getErrors('uuid-here', { apiKey: 'key' });\n * \n * console.log(`Found ${totalErrors} errors`);\n * \n * errors.forEach(err => {\n * console.log(`[${err.type}] ${err.message}`);\n * if (err.url) console.log(` URL: ${err.url}`);\n * if (err.screenshotUrl) console.log(` Screenshot: ${err.screenshotUrl}`);\n * \n * // Download screenshot\n * if (err.screenshotUrl) {\n * const response = await fetch(err.screenshotUrl);\n * const screenshot = await response.arrayBuffer();\n * // Save or process screenshot\n * }\n * });\n * ```\n */\nexport async function getErrors(\n recordingId: string,\n config: BrowserConfig = {}\n): Promise<ErrorsResponse> {\n const apiUrl = config.apiUrl || DEFAULT_CONFIG.apiUrl;\n const debug = config.debug || false;\n\n if (!config.apiKey) {\n throw new Error('API key required for getErrors');\n }\n\n if (debug) console.log(`[Browser] getErrors: ${recordingId}`);\n\n const response = await fetch(`${apiUrl}/recordings/${recordingId}/errors`, {\n method: 'GET',\n headers: { 'Authorization': `Bearer ${config.apiKey}` },\n });\n\n if (!response.ok) {\n const errorText = await response.text().catch(() => response.statusText);\n if (debug) console.error(`[Browser] getErrors error: ${response.status} - ${errorText}`);\n throw new Error(`HTTP ${response.status}: ${errorText}`);\n }\n\n const errors = mapErrorsResponse(await response.json());\n if (debug) console.log(`[Browser] Found ${errors.totalErrors} errors`);\n\n return errors;\n}\n\n/**\n * Helper to serialize Zod schema for API\n */\nfunction stringifyStructuredOutput(schema: any): string {\n try {\n return JSON.stringify({\n type: 'object',\n description: 'Zod schema definition (Zod v3)',\n zodDef: schema._def,\n });\n } catch (error) {\n console.warn('[Browser] Failed to serialize Zod schema:', error);\n return JSON.stringify({\n type: 'object',\n description: 'Schema serialization failed',\n });\n }\n}\n\n/**\n * Parse and validate structured task output\n */\nfunction parseStructuredTaskOutput<T>(\n result: BrowserTaskResult,\n schema: any\n): BrowserTaskResult & { parsed: T | null } {\n if (!result.output) {\n return { ...result, parsed: null };\n }\n\n try {\n const parsed = JSON.parse(result.output);\n const validated = schema.parse(parsed) as T;\n return { ...result, parsed: validated };\n } catch (error) {\n if (error instanceof SyntaxError) {\n return { ...result, parsed: null };\n }\n throw error;\n }\n}\n\nfunction mapTaskResult(api: any): BrowserTaskResult {\n if (!api || typeof api !== 'object') {\n return api as BrowserTaskResult;\n }\n\n return {\n success: api.success,\n result: api.result,\n error: api.error,\n stepsTaken: api.steps_taken,\n executionTimeMs: api.execution_time_ms,\n urls: api.urls,\n actionNames: api.action_names,\n errors: api.errors,\n modelActions: api.model_actions,\n isDone: api.is_done,\n actionHistory: api.action_history,\n actionResults: api.action_results,\n hasErrors: api.has_errors,\n numberOfSteps: api.number_of_steps,\n judgement: api.judgement,\n isValidated: api.is_validated,\n replayId: api.replay_id,\n replayUrl: api.replay_url,\n recordingId: api.recording_id,\n recordingStatus: api.recording_status,\n taskId: api.task_id,\n status: api.status,\n output: api.output,\n debugUrl: api.debug_url,\n };\n}\n\nfunction mapRecordingStatus(api: any): RecordingStatus {\n return {\n id: api.id,\n status: api.status,\n replayUrl: api.replay_url,\n networkUrl: api.network_url,\n consoleUrl: api.console_url,\n videoUrl: api.video_url,\n result: api.result,\n totalEvents: api.total_events,\n fileSize: api.file_size,\n duration: api.duration,\n error: api.error,\n createdAt: api.created_at,\n };\n}\n\nfunction mapBrowserError(api: any): ErrorsResponse['errors'][number] {\n return {\n type: api.type,\n message: api.message,\n url: api.url,\n timestamp: api.timestamp,\n screenshotUrl: api.screenshot_url,\n capturedAt: api.captured_at,\n status: api.status,\n };\n}\n\nfunction mapErrorsResponse(api: any): ErrorsResponse {\n return {\n recordingId: api.recording_id,\n totalErrors: api.total_errors,\n errors: Array.isArray(api.errors) ? api.errors.map(mapBrowserError) : [],\n };\n}\n\nfunction mapWebpResponse(api: any): WebpResponse {\n return {\n webpUrl: api.webp_url,\n cached: api.cached,\n width: api.width,\n fps: api.fps,\n maxDuration: api.max_duration,\n fileSize: api.file_size,\n maxSizeMb: api.max_size_mb,\n budgetMet: api.budget_met,\n qualityUsed: api.quality_used,\n attempts: api.attempts,\n };\n}\n\n/**\n * Get current task status\n */\nasync function getTaskStatus(\n taskId: string,\n config: BrowserConfig\n): Promise<BrowserTaskResult> {\n const apiUrl = config.apiUrl || DEFAULT_CONFIG.apiUrl;\n const debug = config.debug || false;\n\n if (debug) console.log(`[Browser] getTaskStatus: ${taskId}`);\n\n const headers: Record<string, string> = {};\n if (config.apiKey) headers['Authorization'] = `Bearer ${config.apiKey}`;\n\n const response = await fetch(`${apiUrl}/tasks/${taskId}`, {\n method: 'GET',\n headers,\n });\n\n if (!response.ok) {\n const errorText = await response.text().catch(() => response.statusText);\n if (debug) console.error(`[Browser] getTaskStatus error: ${response.status} - ${errorText}`);\n throw new Error(`HTTP ${response.status}: ${errorText}`);\n }\n\n const result: BrowserTaskResult = mapTaskResult(await response.json());\n if (debug) console.log(`[Browser] Task status: ${result.status}`);\n\n return result;\n}\n\n/**\n * Generate live URL for watching task execution in real-time\n */\nfunction generateLiveUrl(taskId: string, config: BrowserConfig): string {\n const apiUrl = config.apiUrl || DEFAULT_CONFIG.apiUrl;\n const baseUrl = apiUrl.replace('/api', '');\n return `${baseUrl}/tasks/${taskId}/live`;\n}\n\n/**\n * Poll task until completion\n */\nasync function pollTaskUntilComplete(\n taskId: string,\n config: BrowserConfig,\n pollConfig: { interval?: number; timeout?: number } = {}\n): Promise<BrowserTaskResult> {\n const interval = pollConfig.interval ?? 2000; // 2 seconds\n const timeout = pollConfig.timeout ?? 300000; // 5 minutes\n const startTime = Date.now();\n\n while (Date.now() - startTime < timeout) {\n const status = await getTaskStatus(taskId, config);\n \n if (status.status === 'completed' || status.status === 'failed') {\n return status;\n }\n\n await new Promise(resolve => setTimeout(resolve, interval));\n }\n\n throw new Error(`Task polling timeout after ${timeout}ms`);\n}\n\n/**\n * Wrap task response with convenience methods\n */\nfunction wrapTaskResponse(\n result: BrowserTaskResult,\n config: BrowserConfig\n): BrowserTaskWithPromise {\n const debugUrl = result.debugUrl ?? '';\n\n const wrapped: BrowserTaskWithPromise = {\n ...result,\n debugUrl,\n taskId: result.taskId || '',\n liveUrl: result.taskId\n ? generateLiveUrl(result.taskId, config)\n : debugUrl,\n complete: async (pollConfig?: { interval?: number; timeout?: number }) => {\n // If we have a taskId, poll task status endpoint\n if (result.taskId) {\n return pollTaskUntilComplete(result.taskId!, config, pollConfig);\n }\n // If we have a recordingId, poll recording status instead\n if (result.recordingId) {\n const recording = await waitForRecording(\n result.recordingId,\n config,\n pollConfig\n );\n // Return a result-like object (recording doesn't have full task result)\n return {\n ...result,\n recordingStatus: recording.status,\n } as BrowserTaskResult;\n }\n // No way to poll completion\n throw new Error('Cannot poll completion: no taskId or recordingId available');\n },\n // Add Steel live session helpers - either functional or error-throwing\n getLiveUrl: debugUrl\n ? (options?: LiveSessionOptions) => buildLiveUrl(debugUrl, options)\n : () => {\n throw new Error(\n 'Live sessions not available. Your backend must return a debugUrl in the response. Contact support@morphllm.com if you need help.'\n );\n },\n getLiveIframe: debugUrl\n ? (optionsOrPreset?: string | IframeOptions) => {\n const options = resolvePreset(optionsOrPreset);\n return buildLiveIframe(debugUrl, options);\n }\n : () => {\n throw new Error(\n 'Live sessions not available. Your backend must return a debugUrl in the response. Contact support@morphllm.com if you need help.'\n );\n },\n getEmbedCode: debugUrl\n ? () => buildEmbedCode(debugUrl)\n : () => {\n throw new Error(\n 'Live sessions not available. Your backend must return a debugUrl in the response. Contact support@morphllm.com if you need help.'\n );\n },\n };\n\n return wrapped;\n}\n\n/**\n * Wrap task response with schema validation\n */\nfunction wrapTaskResponseWithSchema<T>(\n result: BrowserTaskResult,\n config: BrowserConfig,\n schema: any\n): BrowserTaskWithPromiseAndSchema<T> {\n const debugUrl = result.debugUrl ?? '';\n const parsed = result.output\n ? parseStructuredTaskOutput<T>(result, schema)\n : { ...result, parsed: null };\n\n const wrapped: BrowserTaskWithPromiseAndSchema<T> = {\n ...parsed,\n debugUrl,\n taskId: result.taskId || '',\n liveUrl: result.taskId\n ? generateLiveUrl(result.taskId, config)\n : debugUrl,\n complete: async (pollConfig?: { interval?: number; timeout?: number }) => {\n // If we have a taskId, poll task status endpoint\n if (result.taskId) {\n const finalResult = await pollTaskUntilComplete(result.taskId!, config, pollConfig);\n return parseStructuredTaskOutput<T>(finalResult, schema);\n }\n // If we have a recordingId, poll recording status instead\n if (result.recordingId) {\n const recording = await waitForRecording(\n result.recordingId,\n config,\n pollConfig\n );\n // Return parsed result (recording doesn't have task output)\n return {\n ...parsed,\n recordingStatus: recording.status,\n };\n }\n // No way to poll completion\n throw new Error('Cannot poll completion: no taskId or recordingId available');\n },\n // Add Steel live session helpers - either functional or error-throwing\n getLiveUrl: debugUrl\n ? (options?: LiveSessionOptions) => buildLiveUrl(debugUrl, options)\n : () => {\n throw new Error(\n 'Live sessions not available. Your backend must return a debugUrl in the response. ' +\n 'Contact support@morphllm.com if you need help enabling live sessions. '\n );\n },\n getLiveIframe: debugUrl\n ? (optionsOrPreset?: string | IframeOptions) => {\n const options = resolvePreset(optionsOrPreset);\n return buildLiveIframe(debugUrl, options);\n }\n : () => {\n throw new Error(\n 'Live sessions not available. Your backend must return a debugUrl in the response. ' +\n 'Contact support@morphllm.com if you need help enabling live sessions.'\n );\n },\n getEmbedCode: debugUrl\n ? () => buildEmbedCode(debugUrl)\n : () => {\n throw new Error(\n 'Live sessions not available. Your backend must return a debugUrl in the response. ' +\n 'Contact support@morphllm.com if you need help enabling live sessions.'\n );\n },\n };\n\n return wrapped;\n}\n\n/**\n * Get animated WebP preview of recording\n * \n * Converts the native video recording to an animated WebP. Results are cached in S3.\n * \n * @param recordingId - Recording UUID from BrowserTaskResult\n * @param config - Configuration with apiKey\n * @param options - WebP generation options\n * @returns WebP URL and metadata\n * \n * @example\n * ```typescript\n * const webp = await getWebp('uuid-here', { apiKey: 'key' }, {\n * width: 780,\n * fps: 10,\n * quality: 65,\n * maxDuration: 15\n * });\n * console.log('WebP URL:', webp.webpUrl);\n * console.log('From cache:', webp.cached);\n * ```\n */\nexport async function getWebp(\n recordingId: string,\n config: BrowserConfig = {},\n options: WebpOptions = {}\n): Promise<WebpResponse> {\n const apiUrl = config.apiUrl || DEFAULT_CONFIG.apiUrl;\n const debug = config.debug || false;\n\n if (!config.apiKey) {\n throw new Error('API key required for getWebp');\n }\n\n // Build query params\n const params = new URLSearchParams();\n if (options.maxDuration !== undefined) params.set('max_duration', String(options.maxDuration));\n if (options.fps !== undefined) params.set('fps', String(options.fps));\n if (options.width !== undefined) params.set('width', String(options.width));\n if (options.quality !== undefined) params.set('quality', String(options.quality));\n if (options.maxSizeMb !== undefined) params.set('max_size_mb', String(options.maxSizeMb));\n\n const url = `${apiUrl}/recordings/${recordingId}/webp${params.toString() ? '?' + params.toString() : ''}`;\n \n if (debug) console.log(`[Browser] getWebp: ${url}`);\n\n const response = await fetch(url, {\n method: 'GET',\n headers: { 'Authorization': `Bearer ${config.apiKey}` },\n });\n\n if (!response.ok) {\n const errorText = await response.text().catch(() => response.statusText);\n if (debug) console.error(`[Browser] getWebp error: ${response.status} - ${errorText}`);\n throw new Error(`HTTP ${response.status}: ${errorText}`);\n }\n\n const result = mapWebpResponse(await response.json());\n if (debug) console.log(`[Browser] WebP ready: ${result.webpUrl} (cached: ${result.cached})`);\n\n return result;\n}\n\n/**\n * Check if browser worker service is healthy\n * \n * @param config - Optional configuration\n * @returns Health status\n */\nexport async function checkHealth(config: BrowserConfig = {}): Promise<{\n ok: boolean;\n google_configured: boolean;\n database_configured: boolean;\n s3_configured: boolean;\n error?: string;\n}> {\n const apiUrl = config.apiUrl || DEFAULT_CONFIG.apiUrl;\n\n try {\n const response = await fetch(`${apiUrl}/health`, {\n method: 'GET',\n headers: config.apiKey\n ? { 'Authorization': `Bearer ${config.apiKey}` }\n : {},\n });\n\n if (!response.ok) {\n throw new Error(`HTTP ${response.status}`);\n }\n\n const data = await response.json();\n return {\n ok: true,\n google_configured: data.google_configured ?? false,\n database_configured: data.database_configured ?? false,\n s3_configured: data.s3_configured ?? false,\n };\n } catch (error) {\n return {\n ok: false,\n google_configured: false,\n database_configured: false,\n s3_configured: false,\n error: error instanceof Error ? error.message : String(error),\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA0BA,IAAM,iBAAiB;AAAA,EACrB,QAAQ,QAAQ,IAAI,sBAAsB,QACtC,0BACA;AAAA,EACJ,SAAS;AAAA;AAAA,EACT,OAAO;AACT;AASO,IAAM,gBAAN,cAA4B,YAAY;AAAA,EACrC;AAAA;AAAA;AAAA;AAAA,EAKD;AAAA,EAEP,YAAY,iBAAiD,CAAC,GAAG;AAC/D,UAAM,WAAW,0BAA0B;AAC3C;AAAA,MACE,WACI,iBACA,IAAI,eAAe;AAAA,QACjB,QAAQ,eAAe;AAAA,QACvB,YAAY,eAAe;AAAA,QAC3B,SAAS,eAAe;AAAA,QACxB,aAAa,eAAe;AAAA,QAC5B,OAAO,eAAe;AAAA,MACxB,CAAC;AAAA,IACP;AAIA,SAAK,SAAS,WACV;AAA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
94
|
-
//# sourceMappingURL=chunk-
|
|
94
|
+
//# sourceMappingURL=chunk-JXJBF6CV.js.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":";AAUO,IAAe,cAAf,MAA2B;AAAA,EACtB;AAAA,EAEV,YAAY,QAAwB;AAClC,SAAK,UAAU;AAAA,EACjB;AACF;","names":[]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
executeCodebaseSearch
|
|
3
|
-
} from "./chunk-H5WNI6R5.js";
|
|
4
1
|
import {
|
|
5
2
|
CODEBASE_SEARCH_DESCRIPTION,
|
|
6
3
|
CODEBASE_SEARCH_SYSTEM_PROMPT
|
|
7
4
|
} from "./chunk-YQMPVJ2L.js";
|
|
5
|
+
import {
|
|
6
|
+
executeCodebaseSearch
|
|
7
|
+
} from "./chunk-W6AGNJ5O.js";
|
|
8
8
|
|
|
9
9
|
// tools/codebase_search/anthropic.ts
|
|
10
10
|
function createCodebaseSearchTool(config) {
|
|
@@ -80,4 +80,4 @@ function formatResult(result) {
|
|
|
80
80
|
export {
|
|
81
81
|
createCodebaseSearchTool
|
|
82
82
|
};
|
|
83
|
-
//# sourceMappingURL=chunk-
|
|
83
|
+
//# sourceMappingURL=chunk-MQTMT4OR.js.map
|
|
@@ -1,66 +1,75 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ReflexClient
|
|
3
|
+
} from "./chunk-YGNPVOUO.js";
|
|
4
|
+
import {
|
|
5
|
+
createGitHubSearchTool as createGitHubSearchTool2,
|
|
6
|
+
createWarpGrepTool as createWarpGrepTool2
|
|
7
|
+
} from "./chunk-AZOSA7VT.js";
|
|
1
8
|
import {
|
|
2
9
|
createGitHubSearchTool,
|
|
3
10
|
createWarpGrepTool
|
|
4
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-TW3XQET2.js";
|
|
5
12
|
import {
|
|
6
13
|
createGitHubSearchTool as createGitHubSearchTool3,
|
|
7
14
|
createWarpGrepTool as createWarpGrepTool3
|
|
8
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-QE6JHRVD.js";
|
|
9
16
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} from "./chunk-IW4TYYG6.js";
|
|
17
|
+
createCodebaseSearchTool
|
|
18
|
+
} from "./chunk-33ZRF6X3.js";
|
|
13
19
|
import {
|
|
14
20
|
createCodebaseSearchTool as createCodebaseSearchTool3
|
|
15
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-7EUJ2AKS.js";
|
|
16
22
|
import {
|
|
17
23
|
createCodebaseSearchTool as createCodebaseSearchTool2
|
|
18
|
-
} from "./chunk-
|
|
19
|
-
import {
|
|
20
|
-
createCodebaseSearchTool
|
|
21
|
-
} from "./chunk-SW527EQT.js";
|
|
24
|
+
} from "./chunk-MQTMT4OR.js";
|
|
22
25
|
import {
|
|
23
26
|
CodebaseSearchClient
|
|
24
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-W6AGNJ5O.js";
|
|
28
|
+
import {
|
|
29
|
+
createExploreSubagent as createExploreSubagent2
|
|
30
|
+
} from "./chunk-3I4LCNWJ.js";
|
|
31
|
+
import {
|
|
32
|
+
createEditFileTool as createEditFileTool2
|
|
33
|
+
} from "./chunk-CEZQSARX.js";
|
|
25
34
|
import {
|
|
26
35
|
createEditFileTool
|
|
27
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-GESRH23M.js";
|
|
28
37
|
import {
|
|
29
38
|
createEditFileTool as createEditFileTool3
|
|
30
|
-
} from "./chunk-
|
|
31
|
-
import {
|
|
32
|
-
createEditFileTool as createEditFileTool2
|
|
33
|
-
} from "./chunk-LL3EWDKD.js";
|
|
39
|
+
} from "./chunk-Z3KRXUNG.js";
|
|
34
40
|
import {
|
|
35
41
|
FastApplyClient
|
|
36
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-S5R4H5HM.js";
|
|
37
43
|
import {
|
|
38
44
|
BrowserClient
|
|
39
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-I4FCFIBU.js";
|
|
40
46
|
import {
|
|
41
|
-
|
|
42
|
-
} from "./chunk-
|
|
47
|
+
MorphGit
|
|
48
|
+
} from "./chunk-FN4ADWFQ.js";
|
|
43
49
|
import {
|
|
44
|
-
createExploreSubagent
|
|
45
|
-
} from "./chunk-
|
|
50
|
+
createExploreSubagent
|
|
51
|
+
} from "./chunk-5RTWSAZ6.js";
|
|
46
52
|
import {
|
|
47
53
|
WarpGrepClient
|
|
48
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-ACWLQFYS.js";
|
|
49
55
|
import {
|
|
50
56
|
AnthropicRouter,
|
|
51
57
|
GeminiRouter,
|
|
52
58
|
OpenAIRouter,
|
|
53
59
|
RawRouter
|
|
54
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-SM3OQZRS.js";
|
|
55
61
|
import {
|
|
56
62
|
CompactClient
|
|
57
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-TS56XYWB.js";
|
|
64
|
+
import {
|
|
65
|
+
MorphAPIClient
|
|
66
|
+
} from "./chunk-QE3SPHIM.js";
|
|
58
67
|
import {
|
|
59
68
|
logger
|
|
60
69
|
} from "./chunk-F3NCFNUX.js";
|
|
61
70
|
import {
|
|
62
|
-
|
|
63
|
-
} from "./chunk-
|
|
71
|
+
APIResource
|
|
72
|
+
} from "./chunk-LKFZBBTD.js";
|
|
64
73
|
|
|
65
74
|
// tools/github/types.ts
|
|
66
75
|
var GitHubError = class extends Error {
|
|
@@ -94,9 +103,7 @@ var PermissionError = class extends GitHubError {
|
|
|
94
103
|
// tools/github/core.ts
|
|
95
104
|
var DEFAULT_BASE_URL = "https://api.morphllm.com";
|
|
96
105
|
var DEFAULT_TIMEOUT = 3e4;
|
|
97
|
-
var GitHubClient = class {
|
|
98
|
-
apiKey;
|
|
99
|
-
baseUrl;
|
|
106
|
+
var GitHubClient = class extends APIResource {
|
|
100
107
|
timeout;
|
|
101
108
|
debug;
|
|
102
109
|
defaultInstallationId;
|
|
@@ -121,13 +128,21 @@ var GitHubClient = class {
|
|
|
121
128
|
getInstallUrl() {
|
|
122
129
|
return "https://github.com/apps/morph-subagents/installations/new";
|
|
123
130
|
}
|
|
124
|
-
constructor(
|
|
125
|
-
|
|
126
|
-
|
|
131
|
+
constructor(clientOrConfig = {}, options = {}) {
|
|
132
|
+
const isClient = clientOrConfig instanceof MorphAPIClient;
|
|
133
|
+
const config = isClient ? {} : clientOrConfig;
|
|
134
|
+
super(
|
|
135
|
+
isClient ? clientOrConfig : new MorphAPIClient({
|
|
136
|
+
apiKey: config.apiKey,
|
|
137
|
+
baseURL: config.baseUrl ?? DEFAULT_BASE_URL,
|
|
138
|
+
timeout: config.timeout ?? DEFAULT_TIMEOUT,
|
|
139
|
+
debug: config.debug
|
|
140
|
+
})
|
|
141
|
+
);
|
|
127
142
|
this.timeout = config.timeout || DEFAULT_TIMEOUT;
|
|
128
143
|
this.debug = config.debug || false;
|
|
129
|
-
this.defaultInstallationId = config.installationId;
|
|
130
|
-
if (!this.
|
|
144
|
+
this.defaultInstallationId = isClient ? options.installationId : config.installationId;
|
|
145
|
+
if (!this._client.resolveApiKey()) {
|
|
131
146
|
throw new Error("API key required. Set MORPH_API_KEY or pass apiKey in config.");
|
|
132
147
|
}
|
|
133
148
|
this.installations = {
|
|
@@ -171,59 +186,44 @@ var GitHubClient = class {
|
|
|
171
186
|
* Make an authenticated API request
|
|
172
187
|
*/
|
|
173
188
|
async request(method, path, body) {
|
|
174
|
-
const url = `${this.baseUrl}${path}`;
|
|
175
189
|
if (this.debug) {
|
|
176
190
|
console.log(`[GitHub SDK] ${method} ${path}`, body || "");
|
|
177
191
|
}
|
|
178
|
-
|
|
179
|
-
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
192
|
+
let response;
|
|
180
193
|
try {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
186
|
-
},
|
|
187
|
-
body: body ? JSON.stringify(body) : void 0,
|
|
188
|
-
signal: controller.signal
|
|
194
|
+
response = await this._client.request(method, path, {
|
|
195
|
+
body,
|
|
196
|
+
timeout: this.timeout,
|
|
197
|
+
raw: true
|
|
189
198
|
});
|
|
190
|
-
|
|
191
|
-
if (
|
|
192
|
-
|
|
193
|
-
const message = errorData.error || errorData.detail || errorData.message || response.statusText;
|
|
194
|
-
if (this.debug) {
|
|
195
|
-
console.error(`[GitHub SDK] Error ${response.status}:`, message);
|
|
196
|
-
}
|
|
197
|
-
if (response.status === 404) {
|
|
198
|
-
if (message.includes("installation")) {
|
|
199
|
-
throw new NoInstallationError(message);
|
|
200
|
-
}
|
|
201
|
-
throw new NotFoundError(message);
|
|
202
|
-
}
|
|
203
|
-
if (response.status === 403) {
|
|
204
|
-
throw new PermissionError(message);
|
|
205
|
-
}
|
|
206
|
-
throw new GitHubError(message, response.status, errorData.code);
|
|
199
|
+
} catch (error) {
|
|
200
|
+
if (error instanceof Error && /timed out/i.test(error.message)) {
|
|
201
|
+
throw new GitHubError("Request timeout", 408, "TIMEOUT");
|
|
207
202
|
}
|
|
208
|
-
|
|
203
|
+
throw new GitHubError(error instanceof Error ? error.message : "Unknown error", 500, "UNKNOWN");
|
|
204
|
+
}
|
|
205
|
+
if (!response.ok) {
|
|
206
|
+
const errorData = await response.json().catch(() => ({}));
|
|
207
|
+
const message = errorData.error || errorData.detail || errorData.message || response.statusText;
|
|
209
208
|
if (this.debug) {
|
|
210
|
-
console.
|
|
209
|
+
console.error(`[GitHub SDK] Error ${response.status}:`, message);
|
|
211
210
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
throw
|
|
211
|
+
if (response.status === 404) {
|
|
212
|
+
if (message.includes("installation")) {
|
|
213
|
+
throw new NoInstallationError(message);
|
|
214
|
+
}
|
|
215
|
+
throw new NotFoundError(message);
|
|
217
216
|
}
|
|
218
|
-
if (
|
|
219
|
-
throw new
|
|
217
|
+
if (response.status === 403) {
|
|
218
|
+
throw new PermissionError(message);
|
|
220
219
|
}
|
|
221
|
-
throw new GitHubError(
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
);
|
|
220
|
+
throw new GitHubError(message, response.status, errorData.code);
|
|
221
|
+
}
|
|
222
|
+
const data = await response.json();
|
|
223
|
+
if (this.debug) {
|
|
224
|
+
console.log(`[GitHub SDK] Response:`, JSON.stringify(data).slice(0, 200));
|
|
226
225
|
}
|
|
226
|
+
return data;
|
|
227
227
|
}
|
|
228
228
|
/**
|
|
229
229
|
* Get the installation ID to use for a request
|
|
@@ -602,7 +602,7 @@ var VercelToolFactory = class {
|
|
|
602
602
|
};
|
|
603
603
|
|
|
604
604
|
// client.ts
|
|
605
|
-
var MorphClient = class {
|
|
605
|
+
var MorphClient = class extends MorphAPIClient {
|
|
606
606
|
/** Client configuration */
|
|
607
607
|
config;
|
|
608
608
|
/** FastApply tool for editing files with AI-powered merge */
|
|
@@ -627,6 +627,8 @@ var MorphClient = class {
|
|
|
627
627
|
vercel;
|
|
628
628
|
/** Compact context with line ranges */
|
|
629
629
|
compact;
|
|
630
|
+
/** Reflex: train and serve small text classifiers */
|
|
631
|
+
reflex;
|
|
630
632
|
/**
|
|
631
633
|
* Create a new Morph SDK client
|
|
632
634
|
*
|
|
@@ -642,78 +644,32 @@ var MorphClient = class {
|
|
|
642
644
|
* ```
|
|
643
645
|
*/
|
|
644
646
|
constructor(config = {}) {
|
|
645
|
-
|
|
646
|
-
if (config.debug) {
|
|
647
|
-
logger.enable();
|
|
648
|
-
}
|
|
649
|
-
logger.debug("MorphClient", "initialized", { debug: !!config.debug, timeout: config.timeout });
|
|
650
|
-
this.fastApply = new FastApplyClient({
|
|
651
|
-
apiKey: config.apiKey,
|
|
652
|
-
debug: config.debug,
|
|
653
|
-
timeout: config.timeout,
|
|
654
|
-
retryConfig: config.retryConfig
|
|
655
|
-
});
|
|
656
|
-
this.codebaseSearch = new CodebaseSearchClient({
|
|
657
|
-
apiKey: config.apiKey,
|
|
658
|
-
debug: config.debug,
|
|
659
|
-
timeout: config.timeout,
|
|
660
|
-
retryConfig: config.retryConfig
|
|
661
|
-
});
|
|
662
|
-
this.warpGrep = new WarpGrepClient({
|
|
663
|
-
morphApiKey: config.apiKey,
|
|
664
|
-
debug: config.debug,
|
|
665
|
-
timeout: config.timeout,
|
|
666
|
-
retryConfig: config.retryConfig
|
|
667
|
-
});
|
|
668
|
-
this.browser = new BrowserClient({
|
|
669
|
-
apiKey: config.apiKey,
|
|
670
|
-
debug: config.debug,
|
|
671
|
-
timeout: config.timeout,
|
|
672
|
-
retryConfig: config.retryConfig
|
|
673
|
-
});
|
|
674
|
-
this.github = new GitHubClient({
|
|
647
|
+
super({
|
|
675
648
|
apiKey: config.apiKey,
|
|
676
|
-
debug: config.debug,
|
|
677
|
-
timeout: config.timeout,
|
|
678
|
-
installationId: config.github?.installationId
|
|
679
|
-
});
|
|
680
|
-
this.git = new MorphGit({
|
|
681
|
-
apiKey: config.apiKey,
|
|
682
|
-
retryConfig: config.retryConfig
|
|
683
|
-
});
|
|
684
|
-
this.routers = {
|
|
685
|
-
openai: new OpenAIRouter({
|
|
686
|
-
apiKey: config.apiKey,
|
|
687
|
-
debug: config.debug,
|
|
688
|
-
timeout: config.timeout,
|
|
689
|
-
retryConfig: config.retryConfig
|
|
690
|
-
}),
|
|
691
|
-
anthropic: new AnthropicRouter({
|
|
692
|
-
apiKey: config.apiKey,
|
|
693
|
-
debug: config.debug,
|
|
694
|
-
timeout: config.timeout,
|
|
695
|
-
retryConfig: config.retryConfig
|
|
696
|
-
}),
|
|
697
|
-
gemini: new GeminiRouter({
|
|
698
|
-
apiKey: config.apiKey,
|
|
699
|
-
debug: config.debug,
|
|
700
|
-
timeout: config.timeout,
|
|
701
|
-
retryConfig: config.retryConfig
|
|
702
|
-
}),
|
|
703
|
-
raw: new RawRouter({
|
|
704
|
-
apiKey: config.apiKey,
|
|
705
|
-
debug: config.debug,
|
|
706
|
-
timeout: config.timeout,
|
|
707
|
-
retryConfig: config.retryConfig
|
|
708
|
-
})
|
|
709
|
-
};
|
|
710
|
-
const compactClient = new CompactClient({
|
|
711
|
-
morphApiKey: config.apiKey,
|
|
712
649
|
timeout: config.timeout,
|
|
713
650
|
retryConfig: config.retryConfig,
|
|
714
651
|
debug: config.debug
|
|
715
652
|
});
|
|
653
|
+
if (!config.apiKey) {
|
|
654
|
+
throw new Error("Morph API key is required. Pass it as { apiKey } when constructing MorphClient.");
|
|
655
|
+
}
|
|
656
|
+
this.config = config;
|
|
657
|
+
logger.debug("MorphClient", "initialized", { debug: !!config.debug, timeout: config.timeout });
|
|
658
|
+
this.fastApply = new FastApplyClient(this);
|
|
659
|
+
this.codebaseSearch = new CodebaseSearchClient(this);
|
|
660
|
+
this.warpGrep = new WarpGrepClient(this);
|
|
661
|
+
this.browser = new BrowserClient(this);
|
|
662
|
+
this.github = new GitHubClient(this, { installationId: config.github?.installationId });
|
|
663
|
+
this.git = new MorphGit(this);
|
|
664
|
+
this.routers = {
|
|
665
|
+
openai: new OpenAIRouter(this),
|
|
666
|
+
anthropic: new AnthropicRouter(this),
|
|
667
|
+
gemini: new GeminiRouter(this),
|
|
668
|
+
raw: new RawRouter(this)
|
|
669
|
+
};
|
|
670
|
+
const compactClient = new CompactClient(this);
|
|
716
671
|
this.compact = compactClient.compact.bind(compactClient);
|
|
672
|
+
this.reflex = new ReflexClient(this);
|
|
717
673
|
this.openai = new OpenAIToolFactory(config);
|
|
718
674
|
this.anthropic = new AnthropicToolFactory(config);
|
|
719
675
|
this.vercel = new VercelToolFactory(config);
|
|
@@ -731,4 +687,4 @@ export {
|
|
|
731
687
|
VercelToolFactory,
|
|
732
688
|
MorphClient
|
|
733
689
|
};
|
|
734
|
-
//# sourceMappingURL=chunk-
|
|
690
|
+
//# sourceMappingURL=chunk-NBKL7VWX.js.map
|