@morphllm/morphsdk 0.2.198 → 0.2.199
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -147
- package/dist/{chunk-CAFREMIT.js → chunk-5KQ2WRBU.js} +2 -2
- package/dist/{chunk-FUYX2MNM.js → chunk-7UU4NF4G.js} +4 -10
- package/dist/chunk-7UU4NF4G.js.map +1 -0
- package/dist/{chunk-XTFRHVCW.js → chunk-BLCCGRKT.js} +2 -2
- package/dist/{chunk-6XFL2NER.js → chunk-BTMMUG3E.js} +2 -2
- package/dist/{chunk-4JUIEYAH.js → chunk-CEXBKXWU.js} +3 -3
- package/dist/{chunk-FESO6TDQ.js → chunk-DP2PT36G.js} +2 -2
- package/dist/chunk-GKRPR5PZ.js +322 -0
- package/dist/chunk-GKRPR5PZ.js.map +1 -0
- package/dist/{chunk-ZQNTXHBQ.js → chunk-GTV27THY.js} +2 -2
- package/dist/{chunk-ZU5YYGBJ.js → chunk-JOC3ZI56.js} +3 -29
- package/dist/chunk-JOC3ZI56.js.map +1 -0
- package/dist/{chunk-WLMPQFER.js → chunk-K2JR2NFQ.js} +4 -4
- package/dist/{chunk-YQ2G5YLI.js → chunk-KXEPBLVD.js} +10 -10
- package/dist/{chunk-T6TXYTKH.js → chunk-MEZTHMB2.js} +4 -4
- package/dist/{chunk-ZGERT23F.js → chunk-O7LJEVZO.js} +2 -2
- package/dist/{chunk-LN7GNFET.js → chunk-OPNTDMHH.js} +4 -4
- package/dist/{chunk-QKNGVBE2.js → chunk-PKJ7ODTG.js} +3 -3
- package/dist/{chunk-4DNEBVGV.js → chunk-PW6K6OJL.js} +2 -2
- package/dist/{chunk-PV6EF6NG.js → chunk-Q3NH3NPD.js} +2 -2
- package/dist/{chunk-O5264GI4.js → chunk-RL3ZTXT3.js} +4 -4
- package/dist/{chunk-D2RFP6R2.js → chunk-ULHHMZRL.js} +3 -3
- package/dist/{chunk-PEFXG5M6.js → chunk-UT3NQLCF.js} +2 -2
- package/dist/{chunk-VBZ7BG47.js → chunk-VS5F2ORN.js} +3 -3
- package/dist/{chunk-YUH3MTP3.js → chunk-W37OFBSG.js} +2 -2
- package/dist/{chunk-SKN2L5CE.js → chunk-WDBYAXZ5.js} +2 -2
- package/dist/{chunk-XK3PQZW6.js → chunk-YSFEKIYQ.js} +2 -2
- package/dist/{chunk-3XS5P5XH.js → chunk-ZHB57ORD.js} +6 -6
- package/dist/client-CGW0Cevz.d.ts +402 -0
- package/dist/client.cjs +12 -1644
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +3 -7
- package/dist/client.js +27 -32
- package/dist/core/client.cjs +2 -34
- package/dist/core/client.cjs.map +1 -1
- package/dist/core/client.d.ts +0 -8
- package/dist/core/client.js +4 -4
- package/dist/core/error.cjs +2 -28
- package/dist/core/error.cjs.map +1 -1
- package/dist/core/error.js +3 -3
- package/dist/core/index.cjs +2 -34
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.js +4 -4
- package/dist/edge.cjs +2 -34
- package/dist/edge.cjs.map +1 -1
- package/dist/edge.js +7 -7
- package/dist/index.cjs +12 -1656
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -5
- package/dist/index.js +31 -49
- package/dist/modelrouter/core.cjs +2 -34
- package/dist/modelrouter/core.cjs.map +1 -1
- package/dist/modelrouter/core.js +5 -5
- package/dist/modelrouter/index.cjs +2 -34
- package/dist/modelrouter/index.cjs.map +1 -1
- package/dist/modelrouter/index.js +5 -5
- package/dist/subagents/anthropic.cjs +2 -34
- package/dist/subagents/anthropic.cjs.map +1 -1
- package/dist/subagents/anthropic.js +11 -11
- package/dist/subagents/vercel.cjs +2 -34
- package/dist/subagents/vercel.cjs.map +1 -1
- package/dist/subagents/vercel.js +11 -11
- package/dist/tools/codebase_search/anthropic.cjs +2 -34
- package/dist/tools/codebase_search/anthropic.cjs.map +1 -1
- package/dist/tools/codebase_search/anthropic.js +6 -6
- package/dist/tools/codebase_search/core.cjs +2 -34
- package/dist/tools/codebase_search/core.cjs.map +1 -1
- package/dist/tools/codebase_search/core.js +5 -5
- package/dist/tools/codebase_search/index.cjs +2 -34
- package/dist/tools/codebase_search/index.cjs.map +1 -1
- package/dist/tools/codebase_search/index.js +10 -10
- package/dist/tools/codebase_search/openai.cjs +2 -34
- package/dist/tools/codebase_search/openai.cjs.map +1 -1
- package/dist/tools/codebase_search/openai.js +6 -6
- package/dist/tools/codebase_search/vercel.cjs +2 -34
- package/dist/tools/codebase_search/vercel.cjs.map +1 -1
- package/dist/tools/codebase_search/vercel.js +6 -6
- package/dist/tools/compact/core.cjs +2 -34
- package/dist/tools/compact/core.cjs.map +1 -1
- package/dist/tools/compact/core.js +5 -5
- package/dist/tools/compact/index.cjs +2 -34
- package/dist/tools/compact/index.cjs.map +1 -1
- package/dist/tools/compact/index.js +6 -6
- package/dist/tools/fastapply/anthropic.cjs +2 -28
- package/dist/tools/fastapply/anthropic.cjs.map +1 -1
- package/dist/tools/fastapply/anthropic.js +7 -7
- package/dist/tools/fastapply/apply.cjs +2 -28
- package/dist/tools/fastapply/apply.cjs.map +1 -1
- package/dist/tools/fastapply/apply.js +2 -2
- package/dist/tools/fastapply/core.cjs +2 -34
- package/dist/tools/fastapply/core.cjs.map +1 -1
- package/dist/tools/fastapply/core.js +6 -6
- package/dist/tools/fastapply/index.cjs +2 -28
- package/dist/tools/fastapply/index.cjs.map +1 -1
- package/dist/tools/fastapply/index.js +11 -11
- package/dist/tools/fastapply/openai.cjs +2 -28
- package/dist/tools/fastapply/openai.cjs.map +1 -1
- package/dist/tools/fastapply/openai.js +7 -7
- package/dist/tools/fastapply/vercel.cjs +2 -28
- package/dist/tools/fastapply/vercel.cjs.map +1 -1
- package/dist/tools/fastapply/vercel.js +7 -7
- package/dist/tools/index.cjs +2 -28
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.js +11 -11
- package/dist/tools/utils/resilience.cjs +2 -28
- 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 +2 -28
- package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/runner.js +3 -3
- package/dist/tools/warp_grep/anthropic.cjs +2 -34
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
- package/dist/tools/warp_grep/anthropic.js +11 -11
- package/dist/tools/warp_grep/client.cjs +2 -34
- package/dist/tools/warp_grep/client.cjs.map +1 -1
- package/dist/tools/warp_grep/client.js +10 -10
- package/dist/tools/warp_grep/gemini.cjs +2 -34
- package/dist/tools/warp_grep/gemini.cjs.map +1 -1
- package/dist/tools/warp_grep/gemini.js +10 -10
- package/dist/tools/warp_grep/harness.js +9 -9
- package/dist/tools/warp_grep/index.cjs +2 -34
- package/dist/tools/warp_grep/index.cjs.map +1 -1
- package/dist/tools/warp_grep/index.js +16 -16
- package/dist/tools/warp_grep/openai.cjs +2 -34
- package/dist/tools/warp_grep/openai.cjs.map +1 -1
- package/dist/tools/warp_grep/openai.js +11 -11
- package/dist/tools/warp_grep/providers/local.js +2 -2
- package/dist/tools/warp_grep/vercel.cjs +2 -34
- package/dist/tools/warp_grep/vercel.cjs.map +1 -1
- package/dist/tools/warp_grep/vercel.js +11 -11
- package/dist/version.cjs +2 -28
- package/dist/version.cjs.map +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -28
- package/dist/anthropic-B6my2oBx.d.ts +0 -56
- package/dist/chunk-2AMEQAO2.js +0 -46
- package/dist/chunk-2AMEQAO2.js.map +0 -1
- package/dist/chunk-2HMEZZKK.js +0 -44
- package/dist/chunk-2HMEZZKK.js.map +0 -1
- package/dist/chunk-2VERUKO2.js +0 -177
- package/dist/chunk-2VERUKO2.js.map +0 -1
- package/dist/chunk-FUYX2MNM.js.map +0 -1
- package/dist/chunk-GJ42MYUU.js +0 -57
- package/dist/chunk-GJ42MYUU.js.map +0 -1
- package/dist/chunk-KQKLQHJF.js +0 -96
- package/dist/chunk-KQKLQHJF.js.map +0 -1
- package/dist/chunk-PIIXU2H3.js +0 -389
- package/dist/chunk-PIIXU2H3.js.map +0 -1
- package/dist/chunk-XH6KJJDI.js +0 -80
- package/dist/chunk-XH6KJJDI.js.map +0 -1
- package/dist/chunk-YD6TNDR4.js +0 -622
- package/dist/chunk-YD6TNDR4.js.map +0 -1
- package/dist/chunk-YHZJYCOU.js +0 -680
- package/dist/chunk-YHZJYCOU.js.map +0 -1
- package/dist/chunk-YTYCHRQ2.js +0 -106
- package/dist/chunk-YTYCHRQ2.js.map +0 -1
- package/dist/chunk-ZU5YYGBJ.js.map +0 -1
- package/dist/client-DCeydotn.d.ts +0 -1015
- package/dist/openai-BQMeDFef.d.ts +0 -81
- package/dist/tools/browser/anthropic.cjs +0 -645
- package/dist/tools/browser/anthropic.cjs.map +0 -1
- package/dist/tools/browser/anthropic.d.ts +0 -4
- package/dist/tools/browser/anthropic.js +0 -22
- package/dist/tools/browser/anthropic.js.map +0 -1
- package/dist/tools/browser/core.cjs +0 -1821
- package/dist/tools/browser/core.cjs.map +0 -1
- package/dist/tools/browser/core.d.ts +0 -245
- package/dist/tools/browser/core.js +0 -32
- package/dist/tools/browser/core.js.map +0 -1
- package/dist/tools/browser/errors.cjs +0 -208
- package/dist/tools/browser/errors.cjs.map +0 -1
- package/dist/tools/browser/errors.d.ts +0 -158
- package/dist/tools/browser/errors.js +0 -22
- package/dist/tools/browser/errors.js.map +0 -1
- package/dist/tools/browser/index.cjs +0 -2159
- package/dist/tools/browser/index.cjs.map +0 -1
- package/dist/tools/browser/index.d.ts +0 -134
- package/dist/tools/browser/index.js +0 -163
- package/dist/tools/browser/index.js.map +0 -1
- package/dist/tools/browser/live.cjs +0 -134
- package/dist/tools/browser/live.cjs.map +0 -1
- package/dist/tools/browser/live.d.ts +0 -75
- package/dist/tools/browser/live.js +0 -16
- package/dist/tools/browser/live.js.map +0 -1
- package/dist/tools/browser/openai.cjs +0 -661
- package/dist/tools/browser/openai.cjs.map +0 -1
- package/dist/tools/browser/openai.d.ts +0 -4
- package/dist/tools/browser/openai.js +0 -28
- package/dist/tools/browser/openai.js.map +0 -1
- package/dist/tools/browser/profiles/core.cjs +0 -932
- package/dist/tools/browser/profiles/core.cjs.map +0 -1
- package/dist/tools/browser/profiles/core.d.ts +0 -187
- package/dist/tools/browser/profiles/core.js +0 -30
- package/dist/tools/browser/profiles/core.js.map +0 -1
- package/dist/tools/browser/profiles/index.cjs +0 -932
- package/dist/tools/browser/profiles/index.cjs.map +0 -1
- package/dist/tools/browser/profiles/index.d.ts +0 -4
- package/dist/tools/browser/profiles/index.js +0 -30
- package/dist/tools/browser/profiles/index.js.map +0 -1
- package/dist/tools/browser/profiles/types.cjs +0 -74
- package/dist/tools/browser/profiles/types.cjs.map +0 -1
- package/dist/tools/browser/profiles/types.d.ts +0 -195
- package/dist/tools/browser/profiles/types.js +0 -16
- package/dist/tools/browser/profiles/types.js.map +0 -1
- package/dist/tools/browser/prompts.cjs +0 -69
- package/dist/tools/browser/prompts.cjs.map +0 -1
- package/dist/tools/browser/prompts.d.ts +0 -7
- package/dist/tools/browser/prompts.js +0 -10
- package/dist/tools/browser/prompts.js.map +0 -1
- package/dist/tools/browser/types.cjs +0 -19
- package/dist/tools/browser/types.cjs.map +0 -1
- package/dist/tools/browser/types.d.ts +0 -338
- package/dist/tools/browser/types.js +0 -1
- package/dist/tools/browser/types.js.map +0 -1
- package/dist/tools/browser/vercel.cjs +0 -622
- package/dist/tools/browser/vercel.cjs.map +0 -1
- package/dist/tools/browser/vercel.d.ts +0 -4
- package/dist/tools/browser/vercel.js +0 -22
- package/dist/tools/browser/vercel.js.map +0 -1
- package/dist/vercel-CVF27qFK.d.ts +0 -74
- /package/dist/{chunk-CAFREMIT.js.map → chunk-5KQ2WRBU.js.map} +0 -0
- /package/dist/{chunk-XTFRHVCW.js.map → chunk-BLCCGRKT.js.map} +0 -0
- /package/dist/{chunk-6XFL2NER.js.map → chunk-BTMMUG3E.js.map} +0 -0
- /package/dist/{chunk-4JUIEYAH.js.map → chunk-CEXBKXWU.js.map} +0 -0
- /package/dist/{chunk-FESO6TDQ.js.map → chunk-DP2PT36G.js.map} +0 -0
- /package/dist/{chunk-ZQNTXHBQ.js.map → chunk-GTV27THY.js.map} +0 -0
- /package/dist/{chunk-WLMPQFER.js.map → chunk-K2JR2NFQ.js.map} +0 -0
- /package/dist/{chunk-YQ2G5YLI.js.map → chunk-KXEPBLVD.js.map} +0 -0
- /package/dist/{chunk-T6TXYTKH.js.map → chunk-MEZTHMB2.js.map} +0 -0
- /package/dist/{chunk-ZGERT23F.js.map → chunk-O7LJEVZO.js.map} +0 -0
- /package/dist/{chunk-LN7GNFET.js.map → chunk-OPNTDMHH.js.map} +0 -0
- /package/dist/{chunk-QKNGVBE2.js.map → chunk-PKJ7ODTG.js.map} +0 -0
- /package/dist/{chunk-4DNEBVGV.js.map → chunk-PW6K6OJL.js.map} +0 -0
- /package/dist/{chunk-PV6EF6NG.js.map → chunk-Q3NH3NPD.js.map} +0 -0
- /package/dist/{chunk-O5264GI4.js.map → chunk-RL3ZTXT3.js.map} +0 -0
- /package/dist/{chunk-D2RFP6R2.js.map → chunk-ULHHMZRL.js.map} +0 -0
- /package/dist/{chunk-PEFXG5M6.js.map → chunk-UT3NQLCF.js.map} +0 -0
- /package/dist/{chunk-VBZ7BG47.js.map → chunk-VS5F2ORN.js.map} +0 -0
- /package/dist/{chunk-YUH3MTP3.js.map → chunk-W37OFBSG.js.map} +0 -0
- /package/dist/{chunk-SKN2L5CE.js.map → chunk-WDBYAXZ5.js.map} +0 -0
- /package/dist/{chunk-XK3PQZW6.js.map → chunk-YSFEKIYQ.js.map} +0 -0
- /package/dist/{chunk-3XS5P5XH.js.map → chunk-ZHB57ORD.js.map} +0 -0
|
@@ -1,661 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// tools/browser/openai.ts
|
|
31
|
-
var openai_exports = {};
|
|
32
|
-
__export(openai_exports, {
|
|
33
|
-
browserTool: () => browserTool,
|
|
34
|
-
createBrowserTool: () => createBrowserTool,
|
|
35
|
-
execute: () => execute,
|
|
36
|
-
formatResult: () => formatResult,
|
|
37
|
-
getSystemPrompt: () => getSystemPrompt
|
|
38
|
-
});
|
|
39
|
-
module.exports = __toCommonJS(openai_exports);
|
|
40
|
-
|
|
41
|
-
// package.json
|
|
42
|
-
var package_default = {
|
|
43
|
-
name: "@morphllm/morphsdk",
|
|
44
|
-
version: "0.2.198",
|
|
45
|
-
description: "TypeScript SDK and CLI for Morph Fast Apply integration",
|
|
46
|
-
type: "module",
|
|
47
|
-
main: "./dist/index.cjs",
|
|
48
|
-
module: "./dist/index.js",
|
|
49
|
-
types: "./dist/index.d.ts",
|
|
50
|
-
exports: {
|
|
51
|
-
".": {
|
|
52
|
-
types: "./dist/index.d.ts",
|
|
53
|
-
import: "./dist/index.js",
|
|
54
|
-
require: "./dist/index.cjs"
|
|
55
|
-
},
|
|
56
|
-
"./logger": {
|
|
57
|
-
types: "./dist/logger.d.ts",
|
|
58
|
-
import: "./dist/logger.js",
|
|
59
|
-
require: "./dist/logger.cjs"
|
|
60
|
-
},
|
|
61
|
-
"./edge": {
|
|
62
|
-
types: "./dist/edge.d.ts",
|
|
63
|
-
import: "./dist/edge.js",
|
|
64
|
-
require: "./dist/edge.cjs"
|
|
65
|
-
},
|
|
66
|
-
"./tools/warp-grep": {
|
|
67
|
-
types: "./dist/tools/warp_grep/index.d.ts",
|
|
68
|
-
import: "./dist/tools/warp_grep/index.js",
|
|
69
|
-
require: "./dist/tools/warp_grep/index.cjs"
|
|
70
|
-
},
|
|
71
|
-
"./tools/warp-grep/openai": {
|
|
72
|
-
types: "./dist/tools/warp_grep/openai.d.ts",
|
|
73
|
-
import: "./dist/tools/warp_grep/openai.js",
|
|
74
|
-
require: "./dist/tools/warp_grep/openai.cjs"
|
|
75
|
-
},
|
|
76
|
-
"./tools/warp-grep/anthropic": {
|
|
77
|
-
types: "./dist/tools/warp_grep/anthropic.d.ts",
|
|
78
|
-
import: "./dist/tools/warp_grep/anthropic.js",
|
|
79
|
-
require: "./dist/tools/warp_grep/anthropic.cjs"
|
|
80
|
-
},
|
|
81
|
-
"./tools/warp-grep/vercel": {
|
|
82
|
-
types: "./dist/tools/warp_grep/vercel.d.ts",
|
|
83
|
-
import: "./dist/tools/warp_grep/vercel.js",
|
|
84
|
-
require: "./dist/tools/warp_grep/vercel.cjs"
|
|
85
|
-
},
|
|
86
|
-
"./tools/warp-grep/client": {
|
|
87
|
-
types: "./dist/tools/warp_grep/client.d.ts",
|
|
88
|
-
import: "./dist/tools/warp_grep/client.js",
|
|
89
|
-
require: "./dist/tools/warp_grep/client.cjs"
|
|
90
|
-
},
|
|
91
|
-
"./tools/warp-grep/gemini": {
|
|
92
|
-
types: "./dist/tools/warp_grep/gemini.d.ts",
|
|
93
|
-
import: "./dist/tools/warp_grep/gemini.js",
|
|
94
|
-
require: "./dist/tools/warp_grep/gemini.cjs"
|
|
95
|
-
},
|
|
96
|
-
"./tools/warp-grep/harness": {
|
|
97
|
-
types: "./dist/tools/warp_grep/harness.d.ts",
|
|
98
|
-
import: "./dist/tools/warp_grep/harness.js",
|
|
99
|
-
require: "./dist/tools/warp_grep/harness.cjs"
|
|
100
|
-
},
|
|
101
|
-
"./tracing": {
|
|
102
|
-
types: "./dist/tracing/index.d.ts",
|
|
103
|
-
import: "./dist/tracing/index.js",
|
|
104
|
-
require: "./dist/tracing/index.cjs"
|
|
105
|
-
},
|
|
106
|
-
"./tracing/otel": {
|
|
107
|
-
types: "./dist/tracing/otel.d.ts",
|
|
108
|
-
import: "./dist/tracing/otel.js",
|
|
109
|
-
require: "./dist/tracing/otel.cjs"
|
|
110
|
-
},
|
|
111
|
-
"./tools/fastapply": {
|
|
112
|
-
types: "./dist/tools/fastapply/index.d.ts",
|
|
113
|
-
import: "./dist/tools/fastapply/index.js",
|
|
114
|
-
require: "./dist/tools/fastapply/index.cjs"
|
|
115
|
-
},
|
|
116
|
-
"./tools/fastapply/anthropic": {
|
|
117
|
-
types: "./dist/tools/fastapply/anthropic.d.ts",
|
|
118
|
-
import: "./dist/tools/fastapply/anthropic.js",
|
|
119
|
-
require: "./dist/tools/fastapply/anthropic.cjs"
|
|
120
|
-
},
|
|
121
|
-
"./tools/fastapply/openai": {
|
|
122
|
-
types: "./dist/tools/fastapply/openai.d.ts",
|
|
123
|
-
import: "./dist/tools/fastapply/openai.js",
|
|
124
|
-
require: "./dist/tools/fastapply/openai.cjs"
|
|
125
|
-
},
|
|
126
|
-
"./tools/fastapply/vercel": {
|
|
127
|
-
types: "./dist/tools/fastapply/vercel.d.ts",
|
|
128
|
-
import: "./dist/tools/fastapply/vercel.js",
|
|
129
|
-
require: "./dist/tools/fastapply/vercel.cjs"
|
|
130
|
-
},
|
|
131
|
-
"./tools/codebase-search": {
|
|
132
|
-
types: "./dist/tools/codebase_search/index.d.ts",
|
|
133
|
-
import: "./dist/tools/codebase_search/index.js",
|
|
134
|
-
require: "./dist/tools/codebase_search/index.cjs"
|
|
135
|
-
},
|
|
136
|
-
"./tools/codebase-search/anthropic": {
|
|
137
|
-
types: "./dist/tools/codebase_search/anthropic.d.ts",
|
|
138
|
-
import: "./dist/tools/codebase_search/anthropic.js",
|
|
139
|
-
require: "./dist/tools/codebase_search/anthropic.cjs"
|
|
140
|
-
},
|
|
141
|
-
"./tools/codebase-search/openai": {
|
|
142
|
-
types: "./dist/tools/codebase_search/openai.d.ts",
|
|
143
|
-
import: "./dist/tools/codebase_search/openai.js",
|
|
144
|
-
require: "./dist/tools/codebase_search/openai.cjs"
|
|
145
|
-
},
|
|
146
|
-
"./tools/codebase-search/vercel": {
|
|
147
|
-
types: "./dist/tools/codebase_search/vercel.d.ts",
|
|
148
|
-
import: "./dist/tools/codebase_search/vercel.js",
|
|
149
|
-
require: "./dist/tools/codebase_search/vercel.cjs"
|
|
150
|
-
},
|
|
151
|
-
"./tools/browser": {
|
|
152
|
-
types: "./dist/tools/browser/index.d.ts",
|
|
153
|
-
import: "./dist/tools/browser/index.js",
|
|
154
|
-
require: "./dist/tools/browser/index.cjs"
|
|
155
|
-
},
|
|
156
|
-
"./tools/browser/anthropic": {
|
|
157
|
-
types: "./dist/tools/browser/anthropic.d.ts",
|
|
158
|
-
import: "./dist/tools/browser/anthropic.js",
|
|
159
|
-
require: "./dist/tools/browser/anthropic.cjs"
|
|
160
|
-
},
|
|
161
|
-
"./tools/browser/openai": {
|
|
162
|
-
types: "./dist/tools/browser/openai.d.ts",
|
|
163
|
-
import: "./dist/tools/browser/openai.js",
|
|
164
|
-
require: "./dist/tools/browser/openai.cjs"
|
|
165
|
-
},
|
|
166
|
-
"./tools/browser/vercel": {
|
|
167
|
-
types: "./dist/tools/browser/vercel.d.ts",
|
|
168
|
-
import: "./dist/tools/browser/vercel.js",
|
|
169
|
-
require: "./dist/tools/browser/vercel.cjs"
|
|
170
|
-
},
|
|
171
|
-
"./tools/browser/profiles": {
|
|
172
|
-
types: "./dist/tools/browser/profiles/index.d.ts",
|
|
173
|
-
import: "./dist/tools/browser/profiles/index.js",
|
|
174
|
-
require: "./dist/tools/browser/profiles/index.cjs"
|
|
175
|
-
},
|
|
176
|
-
"./modelrouter": {
|
|
177
|
-
types: "./dist/modelrouter/index.d.ts",
|
|
178
|
-
import: "./dist/modelrouter/index.js",
|
|
179
|
-
require: "./dist/modelrouter/index.cjs"
|
|
180
|
-
},
|
|
181
|
-
"./tools/compact": {
|
|
182
|
-
types: "./dist/tools/compact/index.d.ts",
|
|
183
|
-
import: "./dist/tools/compact/index.js",
|
|
184
|
-
require: "./dist/tools/compact/index.cjs"
|
|
185
|
-
},
|
|
186
|
-
"./subagents": {
|
|
187
|
-
types: "./dist/subagents/index.d.ts",
|
|
188
|
-
import: "./dist/subagents/index.js",
|
|
189
|
-
require: "./dist/subagents/index.cjs"
|
|
190
|
-
},
|
|
191
|
-
"./subagents/vercel": {
|
|
192
|
-
types: "./dist/subagents/vercel.d.ts",
|
|
193
|
-
import: "./dist/subagents/vercel.js",
|
|
194
|
-
require: "./dist/subagents/vercel.cjs"
|
|
195
|
-
},
|
|
196
|
-
"./subagents/anthropic": {
|
|
197
|
-
types: "./dist/subagents/anthropic.d.ts",
|
|
198
|
-
import: "./dist/subagents/anthropic.js",
|
|
199
|
-
require: "./dist/subagents/anthropic.cjs"
|
|
200
|
-
},
|
|
201
|
-
"./ai-sdk": {
|
|
202
|
-
types: "./dist/ai-sdk/index.d.ts",
|
|
203
|
-
import: "./dist/ai-sdk/index.js",
|
|
204
|
-
require: "./dist/ai-sdk/index.cjs"
|
|
205
|
-
}
|
|
206
|
-
},
|
|
207
|
-
files: [
|
|
208
|
-
"dist/**/*.js",
|
|
209
|
-
"dist/**/*.cjs",
|
|
210
|
-
"dist/**/*.d.ts",
|
|
211
|
-
"dist/**/*.map",
|
|
212
|
-
"!dist/**/__tests__/**",
|
|
213
|
-
"!dist/**/*.test.*"
|
|
214
|
-
],
|
|
215
|
-
scripts: {
|
|
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 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 tracing/index.ts tracing/core.ts tracing/interaction.ts tracing/otel.ts tracing/types.ts --format esm,cjs --sourcemap --clean --dts --dts-resolve && tsup ai-sdk/index.ts --format esm,cjs --sourcemap --dts --no-clean --out-dir dist/ai-sdk",
|
|
217
|
-
prepare: "npm run build",
|
|
218
|
-
typecheck: "tsc --noEmit && tsc --noEmit -p ai-sdk/tsconfig.json",
|
|
219
|
-
lint: "eslint .",
|
|
220
|
-
test: "vitest run",
|
|
221
|
-
"test:watch": "vitest watch",
|
|
222
|
-
"test:anthropic": "vitest run anthropic",
|
|
223
|
-
"test:openai": "vitest run openai",
|
|
224
|
-
"test:vercel": "vitest run vercel",
|
|
225
|
-
"test:git": "vitest run git",
|
|
226
|
-
"test:browser": "vitest run browser",
|
|
227
|
-
"test:agent": "npx tsx tests/fullAgentTest.ts",
|
|
228
|
-
"test:integration": "npx tsx tests/fullIntegrationTest.ts",
|
|
229
|
-
"test:e2e": "vitest run --config vitest.e2e.config.ts",
|
|
230
|
-
"release:patch": "npm version patch && npm publish",
|
|
231
|
-
"release:minor": "npm version minor && npm publish",
|
|
232
|
-
"release:major": "npm version major && npm publish"
|
|
233
|
-
},
|
|
234
|
-
keywords: [
|
|
235
|
-
"morph",
|
|
236
|
-
"fast-apply",
|
|
237
|
-
"cli",
|
|
238
|
-
"sdk",
|
|
239
|
-
"edit-file"
|
|
240
|
-
],
|
|
241
|
-
engines: {
|
|
242
|
-
node: ">=18"
|
|
243
|
-
},
|
|
244
|
-
license: "MIT",
|
|
245
|
-
dependencies: {
|
|
246
|
-
"@opentelemetry/api": "^1.9.0",
|
|
247
|
-
"@opentelemetry/exporter-trace-otlp-http": "^0.203.0",
|
|
248
|
-
"@opentelemetry/sdk-trace-base": "^2.7.1",
|
|
249
|
-
"@traceloop/node-server-sdk": "^0.27.0",
|
|
250
|
-
"@vscode/ripgrep": "^1.17.0",
|
|
251
|
-
ai: ">=5.0.0",
|
|
252
|
-
diff: "^7.0.0",
|
|
253
|
-
openai: "^4.52.7",
|
|
254
|
-
zod: ">=3.23.0"
|
|
255
|
-
},
|
|
256
|
-
devDependencies: {
|
|
257
|
-
"@ai-sdk/anthropic": "^2.0.70",
|
|
258
|
-
"@ai-sdk/openai": "^2.0.35",
|
|
259
|
-
"@anthropic-ai/sdk": "^0.30.1",
|
|
260
|
-
"@google/generative-ai": "^0.24.1",
|
|
261
|
-
"@types/diff": "^7.0.2",
|
|
262
|
-
"@types/node": "^20.14.10",
|
|
263
|
-
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
264
|
-
"@typescript-eslint/parser": "^7.18.0",
|
|
265
|
-
dotenv: "^16.4.5",
|
|
266
|
-
eslint: "^8.57.0",
|
|
267
|
-
shx: "^0.3.4",
|
|
268
|
-
tsup: "^8.5.0",
|
|
269
|
-
tsx: "^4.16.2",
|
|
270
|
-
typescript: "^5.5.4",
|
|
271
|
-
vitest: "^2.1.6"
|
|
272
|
-
},
|
|
273
|
-
peerDependencies: {
|
|
274
|
-
"@ai-sdk/openai-compatible": ">=2.0.74 <4",
|
|
275
|
-
"@anthropic-ai/sdk": ">=0.25.0",
|
|
276
|
-
"@google/generative-ai": ">=0.21.0",
|
|
277
|
-
ai: ">=5.0.0",
|
|
278
|
-
zod: ">=3.23.0"
|
|
279
|
-
},
|
|
280
|
-
peerDependenciesMeta: {
|
|
281
|
-
"@anthropic-ai/sdk": {
|
|
282
|
-
optional: true
|
|
283
|
-
},
|
|
284
|
-
"@google/generative-ai": {
|
|
285
|
-
optional: true
|
|
286
|
-
},
|
|
287
|
-
ai: {
|
|
288
|
-
optional: true
|
|
289
|
-
},
|
|
290
|
-
zod: {
|
|
291
|
-
optional: true
|
|
292
|
-
}
|
|
293
|
-
},
|
|
294
|
-
publishConfig: {
|
|
295
|
-
access: "public"
|
|
296
|
-
}
|
|
297
|
-
};
|
|
298
|
-
|
|
299
|
-
// version.ts
|
|
300
|
-
var SDK_VERSION = package_default.version;
|
|
301
|
-
|
|
302
|
-
// tools/utils/resilience.ts
|
|
303
|
-
var DEFAULT_RETRY_CONFIG = {
|
|
304
|
-
maxRetries: 3,
|
|
305
|
-
initialDelay: 1e3,
|
|
306
|
-
maxDelay: 3e4,
|
|
307
|
-
backoffMultiplier: 2,
|
|
308
|
-
retryableErrors: ["ECONNREFUSED", "ETIMEDOUT", "ENOTFOUND"]
|
|
309
|
-
};
|
|
310
|
-
async function fetchWithRetry(url, options, retryConfig = {}) {
|
|
311
|
-
const {
|
|
312
|
-
maxRetries = DEFAULT_RETRY_CONFIG.maxRetries,
|
|
313
|
-
initialDelay = DEFAULT_RETRY_CONFIG.initialDelay,
|
|
314
|
-
maxDelay = DEFAULT_RETRY_CONFIG.maxDelay,
|
|
315
|
-
backoffMultiplier = DEFAULT_RETRY_CONFIG.backoffMultiplier,
|
|
316
|
-
retryableErrors = DEFAULT_RETRY_CONFIG.retryableErrors,
|
|
317
|
-
onRetry
|
|
318
|
-
} = retryConfig;
|
|
319
|
-
let lastError = null;
|
|
320
|
-
let delay = initialDelay;
|
|
321
|
-
options = { ...options, headers: { "X-Morph-SDK-Version": SDK_VERSION, ...options.headers } };
|
|
322
|
-
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
323
|
-
try {
|
|
324
|
-
const response = await fetch(url, options);
|
|
325
|
-
if (response.status === 429 || response.status === 503) {
|
|
326
|
-
if (attempt < maxRetries) {
|
|
327
|
-
const retryAfter = response.headers.get("Retry-After");
|
|
328
|
-
const waitTime = retryAfter ? parseInt(retryAfter) * 1e3 : Math.min(delay, maxDelay);
|
|
329
|
-
const error = new Error(`HTTP ${response.status}: Retrying after ${waitTime}ms`);
|
|
330
|
-
if (onRetry) {
|
|
331
|
-
onRetry(attempt + 1, error);
|
|
332
|
-
}
|
|
333
|
-
await sleep(waitTime);
|
|
334
|
-
delay *= backoffMultiplier;
|
|
335
|
-
continue;
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
return response;
|
|
339
|
-
} catch (error) {
|
|
340
|
-
lastError = error;
|
|
341
|
-
const isRetryable = retryableErrors.some(
|
|
342
|
-
(errType) => lastError?.message?.includes(errType)
|
|
343
|
-
);
|
|
344
|
-
if (!isRetryable || attempt === maxRetries) {
|
|
345
|
-
throw lastError;
|
|
346
|
-
}
|
|
347
|
-
const waitTime = Math.min(delay, maxDelay);
|
|
348
|
-
if (onRetry) {
|
|
349
|
-
onRetry(attempt + 1, lastError);
|
|
350
|
-
}
|
|
351
|
-
await sleep(waitTime);
|
|
352
|
-
delay *= backoffMultiplier;
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
throw lastError || new Error("Max retries exceeded");
|
|
356
|
-
}
|
|
357
|
-
async function withTimeout(promise, timeoutMs, errorMessage) {
|
|
358
|
-
let timeoutId;
|
|
359
|
-
const timeoutPromise = new Promise((_, reject) => {
|
|
360
|
-
timeoutId = setTimeout(() => {
|
|
361
|
-
reject(new Error(errorMessage || `Operation timed out after ${timeoutMs}ms`));
|
|
362
|
-
}, timeoutMs);
|
|
363
|
-
});
|
|
364
|
-
try {
|
|
365
|
-
const result = await Promise.race([promise, timeoutPromise]);
|
|
366
|
-
clearTimeout(timeoutId);
|
|
367
|
-
return result;
|
|
368
|
-
} catch (error) {
|
|
369
|
-
clearTimeout(timeoutId);
|
|
370
|
-
throw error;
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
function sleep(ms) {
|
|
374
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
// logger.ts
|
|
378
|
-
var MorphLogger = class {
|
|
379
|
-
enabled;
|
|
380
|
-
fileStream;
|
|
381
|
-
/** Resolves once the file stream is initialized (or immediately if no file logging). */
|
|
382
|
-
ready;
|
|
383
|
-
constructor() {
|
|
384
|
-
this.enabled = typeof process !== "undefined" && (process.env.MORPH_DEBUG === "1" || !!process.env.MORPH_LOG_FILE);
|
|
385
|
-
this.fileStream = null;
|
|
386
|
-
const f = typeof process !== "undefined" ? process.env.MORPH_LOG_FILE : void 0;
|
|
387
|
-
if (f) {
|
|
388
|
-
this.ready = import("fs").then((fs) => {
|
|
389
|
-
this.fileStream = fs.createWriteStream(f, { flags: "a" });
|
|
390
|
-
}).catch(() => {
|
|
391
|
-
});
|
|
392
|
-
} else {
|
|
393
|
-
this.ready = Promise.resolve();
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
debug(component, msg, data) {
|
|
397
|
-
this._log("debug", component, msg, data);
|
|
398
|
-
}
|
|
399
|
-
info(component, msg, data) {
|
|
400
|
-
this._log("info", component, msg, data);
|
|
401
|
-
}
|
|
402
|
-
warn(component, msg, data) {
|
|
403
|
-
this._log("warn", component, msg, data);
|
|
404
|
-
}
|
|
405
|
-
error(component, msg, data) {
|
|
406
|
-
this._log("error", component, msg, data);
|
|
407
|
-
}
|
|
408
|
-
enable() {
|
|
409
|
-
this.enabled = true;
|
|
410
|
-
}
|
|
411
|
-
get isEnabled() {
|
|
412
|
-
return this.enabled;
|
|
413
|
-
}
|
|
414
|
-
_log(level, component, msg, data) {
|
|
415
|
-
if (level !== "error" && !this.enabled) return;
|
|
416
|
-
const ts = (/* @__PURE__ */ new Date()).toISOString();
|
|
417
|
-
const prefix = `[${ts}] [${level.toUpperCase()}] [${component}]`;
|
|
418
|
-
console.error(data ? `${prefix} ${msg} ${JSON.stringify(data)}` : `${prefix} ${msg}`);
|
|
419
|
-
this.fileStream?.write(JSON.stringify({ ts, level, component, msg, ...data && { data } }) + "\n");
|
|
420
|
-
}
|
|
421
|
-
};
|
|
422
|
-
var logger = new MorphLogger();
|
|
423
|
-
|
|
424
|
-
// tools/browser/profiles/core.ts
|
|
425
|
-
var DEFAULT_API_URL = process.env.MORPH_ENVIRONMENT === "DEV" ? "http://localhost:8000" : "https://browser.morphllm.com";
|
|
426
|
-
|
|
427
|
-
// tools/browser/core.ts
|
|
428
|
-
var DEFAULT_CONFIG = {
|
|
429
|
-
apiUrl: process.env.MORPH_ENVIRONMENT === "DEV" ? "http://localhost:8000" : "https://browser.morphllm.com",
|
|
430
|
-
timeout: 1e6,
|
|
431
|
-
// 10 minutes for complex tasks
|
|
432
|
-
debug: false
|
|
433
|
-
};
|
|
434
|
-
async function executeBrowserTask(input, config = {}) {
|
|
435
|
-
const apiUrl = config.apiUrl || DEFAULT_CONFIG.apiUrl;
|
|
436
|
-
const timeout = config.timeout || DEFAULT_CONFIG.timeout;
|
|
437
|
-
const debug = config.debug || false;
|
|
438
|
-
if (!input.task || input.task.trim().length === 0) {
|
|
439
|
-
return {
|
|
440
|
-
success: false,
|
|
441
|
-
error: 'Task description is required. Example: "Go to example.com and click the login button"'
|
|
442
|
-
};
|
|
443
|
-
}
|
|
444
|
-
if (input.maxSteps !== void 0 && (input.maxSteps < 1 || input.maxSteps > 50)) {
|
|
445
|
-
return {
|
|
446
|
-
success: false,
|
|
447
|
-
error: "maxSteps must be between 1 and 50. Use more steps for complex multi-page flows."
|
|
448
|
-
};
|
|
449
|
-
}
|
|
450
|
-
logger.debug("Browser", "execute_start", { task: input.task.slice(0, 100), url: input.url, max_steps: input.maxSteps ?? 10, record_video: input.recordVideo ?? false });
|
|
451
|
-
const startTime = Date.now();
|
|
452
|
-
try {
|
|
453
|
-
const headers = { "Content-Type": "application/json" };
|
|
454
|
-
if (config.apiKey) headers["Authorization"] = `Bearer ${config.apiKey}`;
|
|
455
|
-
const fetchPromise = fetchWithRetry(
|
|
456
|
-
`${apiUrl}/browser-task`,
|
|
457
|
-
{
|
|
458
|
-
method: "POST",
|
|
459
|
-
headers,
|
|
460
|
-
body: JSON.stringify({
|
|
461
|
-
task: input.task,
|
|
462
|
-
url: input.url,
|
|
463
|
-
max_steps: input.maxSteps ?? 10,
|
|
464
|
-
model: input.model ?? "morph-computer-use-v0",
|
|
465
|
-
viewport_width: input.viewportWidth ?? 1280,
|
|
466
|
-
viewport_height: input.viewportHeight ?? 720,
|
|
467
|
-
external_id: input.externalId,
|
|
468
|
-
repo_id: input.repoId,
|
|
469
|
-
commit_id: input.commitId,
|
|
470
|
-
record_video: input.recordVideo ?? false,
|
|
471
|
-
video_width: input.videoWidth ?? input.viewportWidth ?? 1280,
|
|
472
|
-
video_height: input.videoHeight ?? input.viewportHeight ?? 720,
|
|
473
|
-
allow_resizing: input.allowResizing ?? false,
|
|
474
|
-
structured_output: input.structuredOutput,
|
|
475
|
-
auth: input.auth,
|
|
476
|
-
profile_id: input.profileId,
|
|
477
|
-
force_query_params: input.forceQueryParams
|
|
478
|
-
})
|
|
479
|
-
},
|
|
480
|
-
config.retryConfig
|
|
481
|
-
);
|
|
482
|
-
const response = await withTimeout(
|
|
483
|
-
fetchPromise,
|
|
484
|
-
timeout,
|
|
485
|
-
`Browser task timed out after ${timeout}ms. Consider increasing timeout or reducing maxSteps.`
|
|
486
|
-
);
|
|
487
|
-
if (!response.ok) {
|
|
488
|
-
const errorText = await response.text().catch(() => response.statusText);
|
|
489
|
-
logger.error("Browser", "execute_error", { status: response.status, error: errorText });
|
|
490
|
-
throw new Error(`HTTP ${response.status}: ${errorText}`);
|
|
491
|
-
}
|
|
492
|
-
const result = mapTaskResult(await response.json());
|
|
493
|
-
const elapsed = Date.now() - startTime;
|
|
494
|
-
logger.debug("Browser", "execute_complete", { success: result.success, latency_ms: elapsed, steps: result.stepsTaken ?? 0, recording_id: result.recordingId });
|
|
495
|
-
return result;
|
|
496
|
-
} catch (error) {
|
|
497
|
-
if (error instanceof Error) {
|
|
498
|
-
if (error.message.includes("ECONNREFUSED") || error.message.includes("fetch failed")) {
|
|
499
|
-
return {
|
|
500
|
-
success: false,
|
|
501
|
-
error: `Cannot connect to browser worker at ${apiUrl}. Ensure the service is running and accessible. For local dev, set MORPH_ENVIRONMENT=DEV.`
|
|
502
|
-
};
|
|
503
|
-
}
|
|
504
|
-
return {
|
|
505
|
-
success: false,
|
|
506
|
-
error: error.message
|
|
507
|
-
};
|
|
508
|
-
}
|
|
509
|
-
return {
|
|
510
|
-
success: false,
|
|
511
|
-
error: String(error)
|
|
512
|
-
};
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
function mapTaskResult(api) {
|
|
516
|
-
if (!api || typeof api !== "object") {
|
|
517
|
-
return api;
|
|
518
|
-
}
|
|
519
|
-
return {
|
|
520
|
-
success: api.success,
|
|
521
|
-
result: api.result,
|
|
522
|
-
error: api.error,
|
|
523
|
-
stepsTaken: api.steps_taken,
|
|
524
|
-
executionTimeMs: api.execution_time_ms,
|
|
525
|
-
urls: api.urls,
|
|
526
|
-
actionNames: api.action_names,
|
|
527
|
-
errors: api.errors,
|
|
528
|
-
modelActions: api.model_actions,
|
|
529
|
-
isDone: api.is_done,
|
|
530
|
-
actionHistory: api.action_history,
|
|
531
|
-
actionResults: api.action_results,
|
|
532
|
-
hasErrors: api.has_errors,
|
|
533
|
-
numberOfSteps: api.number_of_steps,
|
|
534
|
-
judgement: api.judgement,
|
|
535
|
-
isValidated: api.is_validated,
|
|
536
|
-
replayId: api.replay_id,
|
|
537
|
-
replayUrl: api.replay_url,
|
|
538
|
-
recordingId: api.recording_id,
|
|
539
|
-
recordingStatus: api.recording_status,
|
|
540
|
-
taskId: api.task_id,
|
|
541
|
-
status: api.status,
|
|
542
|
-
output: api.output,
|
|
543
|
-
debugUrl: api.debug_url
|
|
544
|
-
};
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
// tools/browser/prompts.ts
|
|
548
|
-
var BROWSER_TOOL_DESCRIPTION = `Test and verify your implemented code in a live browser. This tool executes natural language test instructions and returns a video recording plus detailed logs to help you debug issues.
|
|
549
|
-
|
|
550
|
-
## When to Use
|
|
551
|
-
Use this AFTER coding is complete to verify your implementation:
|
|
552
|
-
- You've finished writing/modifying code and need to verify it works
|
|
553
|
-
- You need to test user interactions end-to-end (clicks, forms, navigation)
|
|
554
|
-
- You want to catch runtime errors, console warnings, or network failures
|
|
555
|
-
- You need visual confirmation that UI elements render and behave correctly
|
|
556
|
-
|
|
557
|
-
## What You Get Back
|
|
558
|
-
The tool returns debugging artifacts to help you identify and fix issues:
|
|
559
|
-
- **Video recording**: Watch exactly what happened in the browser session
|
|
560
|
-
- **Console logs**: All console.log, warnings, and errors with timestamps
|
|
561
|
-
- **Network logs**: Failed requests, 404s, API errors with screenshots
|
|
562
|
-
- **Error screenshots**: Visual snapshots captured when errors occur
|
|
563
|
-
|
|
564
|
-
## How to Write Good Tests
|
|
565
|
-
Be specific about the user journey you're testing:
|
|
566
|
-
\u274C Bad: "Test the login feature"
|
|
567
|
-
\u2705 Good: "Navigate to /login, enter 'test@example.com' and 'password123', click the Login button, verify we reach the /dashboard page"
|
|
568
|
-
|
|
569
|
-
Include verification steps:
|
|
570
|
-
\u2705 "Click the Add Item button, verify the item appears in the list"
|
|
571
|
-
\u2705 "Submit the form, verify a success message is displayed"
|
|
572
|
-
|
|
573
|
-
## Iterating on Failures
|
|
574
|
-
1. Run the test and review the video + logs
|
|
575
|
-
2. Identify the specific issue (console error, failed request, wrong behavior)
|
|
576
|
-
3. Fix the code based on the evidence
|
|
577
|
-
4. Re-run the test to verify the fix
|
|
578
|
-
5. Repeat until test passes
|
|
579
|
-
|
|
580
|
-
## Requirements
|
|
581
|
-
- **URL**: Must be publicly accessible (use tunnels like ngrok, Cloudflare, or deploy to staging)
|
|
582
|
-
- **Timing**: Use this after implementation, not during coding
|
|
583
|
-
- **Complexity**: Set maxSteps higher (20-30) for multi-step user workflows`;
|
|
584
|
-
var BROWSER_SYSTEM_PROMPT = `You are an AI agent designed to automate browser tasks to accomplish the <user_request>. Respond with a valid JSON object in the format: {"thinking": "Reason step-by-step about your current state, history, and the user request to decide your next goal and action. Analyze the browser state and screenshot to confirm the outcome of your last action.", "evaluation_previous_goal": "A concise, one-sentence evaluation of your last action's outcome (e.g., Success, Failure, or Uncertain).", "memory": "1-3 sentences summarizing key information and progress so far. This helps you track progress across multiple steps (e.g., items collected, pages visited).", "next_goal": "A clear, one-sentence description of your immediate next objective.", "action": [{"action_name": {"parameter": "value"}}]}`;
|
|
585
|
-
|
|
586
|
-
// tools/browser/openai.ts
|
|
587
|
-
var browserTool = {
|
|
588
|
-
type: "function",
|
|
589
|
-
function: {
|
|
590
|
-
name: "browser_task",
|
|
591
|
-
description: BROWSER_TOOL_DESCRIPTION,
|
|
592
|
-
parameters: {
|
|
593
|
-
type: "object",
|
|
594
|
-
properties: {
|
|
595
|
-
task: {
|
|
596
|
-
type: "string",
|
|
597
|
-
description: 'Natural language description of what to do (e.g., "Test checkout flow for buying a pineapple")'
|
|
598
|
-
},
|
|
599
|
-
url: {
|
|
600
|
-
type: "string",
|
|
601
|
-
description: "Starting URL (e.g., https://3000-xyz.e2b.dev). Required if navigating to a specific page."
|
|
602
|
-
},
|
|
603
|
-
maxSteps: {
|
|
604
|
-
type: "number",
|
|
605
|
-
description: "Maximum number of browser actions to take (1-50). Default: 10. Use 15-30 for complex flows.",
|
|
606
|
-
default: 10
|
|
607
|
-
},
|
|
608
|
-
region: {
|
|
609
|
-
type: "string",
|
|
610
|
-
enum: ["sfo", "lon"],
|
|
611
|
-
description: "Browserless region: sfo (US West Coast) or lon (Europe). Default: sfo.",
|
|
612
|
-
default: "sfo"
|
|
613
|
-
}
|
|
614
|
-
},
|
|
615
|
-
required: ["task"]
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
};
|
|
619
|
-
async function execute(input, config) {
|
|
620
|
-
const parsedInput = typeof input === "string" ? JSON.parse(input) : input;
|
|
621
|
-
return executeBrowserTask(parsedInput, config);
|
|
622
|
-
}
|
|
623
|
-
function formatResult(result) {
|
|
624
|
-
if (result.success) {
|
|
625
|
-
const parts = [
|
|
626
|
-
"\u2705 Browser task completed successfully",
|
|
627
|
-
`Steps taken: ${result.stepsTaken ?? 0}`,
|
|
628
|
-
result.executionTimeMs ? `Execution time: ${result.executionTimeMs}ms` : null,
|
|
629
|
-
"",
|
|
630
|
-
"Result:",
|
|
631
|
-
result.result || "Task completed"
|
|
632
|
-
];
|
|
633
|
-
return parts.filter(Boolean).join("\n");
|
|
634
|
-
}
|
|
635
|
-
return `\u274C Browser task failed: ${result.error || "Unknown error"}`;
|
|
636
|
-
}
|
|
637
|
-
function getSystemPrompt() {
|
|
638
|
-
return BROWSER_SYSTEM_PROMPT;
|
|
639
|
-
}
|
|
640
|
-
function createBrowserTool(config) {
|
|
641
|
-
return Object.assign({}, browserTool, {
|
|
642
|
-
execute: async (input) => {
|
|
643
|
-
return execute(input, config);
|
|
644
|
-
},
|
|
645
|
-
formatResult: (result) => {
|
|
646
|
-
return formatResult(result);
|
|
647
|
-
},
|
|
648
|
-
getSystemPrompt: () => {
|
|
649
|
-
return getSystemPrompt();
|
|
650
|
-
}
|
|
651
|
-
});
|
|
652
|
-
}
|
|
653
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
654
|
-
0 && (module.exports = {
|
|
655
|
-
browserTool,
|
|
656
|
-
createBrowserTool,
|
|
657
|
-
execute,
|
|
658
|
-
formatResult,
|
|
659
|
-
getSystemPrompt
|
|
660
|
-
});
|
|
661
|
-
//# sourceMappingURL=openai.cjs.map
|