@morphllm/morphsdk 0.2.7 → 0.2.13
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-ZQEWQ7LJ.js → chunk-4F6DRRCR.js} +10 -10
- package/dist/chunk-4F6DRRCR.js.map +1 -0
- package/dist/{chunk-G4DJ6VSM.js → chunk-7NG7SI6M.js} +6 -2
- package/dist/{chunk-G4DJ6VSM.js.map → chunk-7NG7SI6M.js.map} +1 -1
- package/dist/{chunk-OI5YYE36.js → chunk-AKVAAKRB.js} +7 -60
- package/dist/chunk-AKVAAKRB.js.map +1 -0
- package/dist/{chunk-5COKN3XD.js → chunk-IUCGXKTX.js} +2 -2
- package/dist/{chunk-5COKN3XD.js.map → chunk-IUCGXKTX.js.map} +1 -1
- package/dist/{chunk-4UVEBIDK.js → chunk-OWXIAZUZ.js} +150 -6
- package/dist/chunk-OWXIAZUZ.js.map +1 -0
- package/dist/{chunk-YWS2GRQC.js → chunk-QFUHDWGY.js} +11 -2
- package/dist/{chunk-YWS2GRQC.js.map → chunk-QFUHDWGY.js.map} +1 -1
- package/dist/client.cjs +151 -64
- package/dist/client.cjs.map +1 -1
- package/dist/client.js +4 -4
- package/dist/index.cjs +151 -64
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -10
- package/dist/{tools/modelrouter → modelrouter}/core.cjs +7 -60
- package/dist/modelrouter/core.cjs.map +1 -0
- package/dist/modelrouter/core.js +13 -0
- package/dist/{tools/modelrouter → modelrouter}/index.cjs +7 -60
- package/dist/modelrouter/index.cjs.map +1 -0
- package/dist/modelrouter/index.js +13 -0
- package/dist/{tools/modelrouter → modelrouter}/types.cjs +1 -1
- package/dist/modelrouter/types.cjs.map +1 -0
- package/dist/tools/browser/anthropic.cjs +9 -3
- package/dist/tools/browser/anthropic.cjs.map +1 -1
- package/dist/tools/browser/anthropic.js +1 -1
- package/dist/tools/browser/core.cjs +145 -5
- package/dist/tools/browser/core.cjs.map +1 -1
- package/dist/tools/browser/core.js +1 -1
- package/dist/tools/browser/index.cjs +153 -5
- package/dist/tools/browser/index.cjs.map +1 -1
- package/dist/tools/browser/index.js +9 -1
- package/dist/tools/browser/openai.cjs +9 -3
- package/dist/tools/browser/openai.cjs.map +1 -1
- package/dist/tools/browser/openai.js +1 -1
- package/dist/tools/browser/types.cjs.map +1 -1
- package/dist/tools/browser/vercel.cjs +9 -3
- package/dist/tools/browser/vercel.cjs.map +1 -1
- package/dist/tools/browser/vercel.js +1 -1
- package/dist/tools/codebase_search/index.js +3 -3
- package/dist/tools/fastapply/anthropic.cjs +5 -1
- package/dist/tools/fastapply/anthropic.cjs.map +1 -1
- package/dist/tools/fastapply/anthropic.js +1 -1
- package/dist/tools/fastapply/index.cjs +16 -3
- package/dist/tools/fastapply/index.cjs.map +1 -1
- package/dist/tools/fastapply/index.js +5 -5
- package/dist/tools/fastapply/openai.cjs +10 -1
- package/dist/tools/fastapply/openai.cjs.map +1 -1
- package/dist/tools/fastapply/openai.js +1 -1
- package/dist/tools/fastapply/types.cjs.map +1 -1
- package/dist/tools/fastapply/vercel.cjs +1 -1
- package/dist/tools/fastapply/vercel.cjs.map +1 -1
- package/dist/tools/fastapply/vercel.js +1 -1
- package/dist/tools/index.cjs +16 -3
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.js +5 -5
- package/package.json +11 -8
- package/dist/chunk-4UVEBIDK.js.map +0 -1
- package/dist/chunk-OI5YYE36.js.map +0 -1
- package/dist/chunk-ZQEWQ7LJ.js.map +0 -1
- package/dist/tools/modelrouter/core.cjs.map +0 -1
- package/dist/tools/modelrouter/core.js +0 -13
- package/dist/tools/modelrouter/index.cjs.map +0 -1
- package/dist/tools/modelrouter/index.js +0 -13
- package/dist/tools/modelrouter/types.cjs.map +0 -1
- /package/dist/{tools/modelrouter → modelrouter}/core.js.map +0 -0
- /package/dist/{tools/modelrouter → modelrouter}/index.js.map +0 -0
- /package/dist/{tools/modelrouter → modelrouter}/types.js +0 -0
- /package/dist/{tools/modelrouter → modelrouter}/types.js.map +0 -0
package/dist/index.cjs
CHANGED
|
@@ -369,6 +369,82 @@ async function executeCodebaseSearch(input, config) {
|
|
|
369
369
|
}
|
|
370
370
|
}
|
|
371
371
|
|
|
372
|
+
// tools/browser/live.ts
|
|
373
|
+
var LIVE_PRESETS = {
|
|
374
|
+
/** Read-only monitoring (no interaction) */
|
|
375
|
+
readonly: { interactive: false },
|
|
376
|
+
/** Interactive control (human-in-the-loop) */
|
|
377
|
+
interactive: { interactive: true },
|
|
378
|
+
/** Watch-only without controls */
|
|
379
|
+
monitoring: { interactive: false, showControls: false }
|
|
380
|
+
};
|
|
381
|
+
function buildLiveUrl(debugUrl, options = {}) {
|
|
382
|
+
if (!debugUrl) {
|
|
383
|
+
throw new Error(
|
|
384
|
+
"debugUrl is required. Ensure your backend returns debugUrl in the task response. Contact support@morphllm.com if you need help."
|
|
385
|
+
);
|
|
386
|
+
}
|
|
387
|
+
const url = new URL(debugUrl);
|
|
388
|
+
if (options.interactive !== void 0) {
|
|
389
|
+
url.searchParams.set("interactive", String(options.interactive));
|
|
390
|
+
}
|
|
391
|
+
if (options.theme) {
|
|
392
|
+
url.searchParams.set("theme", options.theme);
|
|
393
|
+
}
|
|
394
|
+
if (options.showControls !== void 0) {
|
|
395
|
+
url.searchParams.set("showControls", String(options.showControls));
|
|
396
|
+
}
|
|
397
|
+
if (options.pageId) {
|
|
398
|
+
url.searchParams.set("pageId", options.pageId);
|
|
399
|
+
}
|
|
400
|
+
if (options.pageIndex) {
|
|
401
|
+
url.searchParams.set("pageIndex", options.pageIndex);
|
|
402
|
+
}
|
|
403
|
+
return url.toString();
|
|
404
|
+
}
|
|
405
|
+
function buildLiveIframe(debugUrl, options = {}) {
|
|
406
|
+
const {
|
|
407
|
+
width = "100%",
|
|
408
|
+
height = "600px",
|
|
409
|
+
style = "",
|
|
410
|
+
className = "",
|
|
411
|
+
...sessionOptions
|
|
412
|
+
} = options;
|
|
413
|
+
const src = buildLiveUrl(debugUrl, sessionOptions);
|
|
414
|
+
const widthStr = typeof width === "number" ? `${width}px` : width;
|
|
415
|
+
const heightStr = typeof height === "number" ? `${height}px` : height;
|
|
416
|
+
const baseStyle = `width: ${widthStr}; height: ${heightStr}; border: none;`;
|
|
417
|
+
const fullStyle = style ? `${baseStyle} ${style}` : baseStyle;
|
|
418
|
+
const attributes = [
|
|
419
|
+
`src="${src}"`,
|
|
420
|
+
`style="${fullStyle}"`
|
|
421
|
+
];
|
|
422
|
+
if (className) {
|
|
423
|
+
attributes.push(`class="${className}"`);
|
|
424
|
+
}
|
|
425
|
+
return `<iframe ${attributes.join(" ")}></iframe>`;
|
|
426
|
+
}
|
|
427
|
+
function buildEmbedCode(debugUrl, options = {}) {
|
|
428
|
+
const iframe = buildLiveIframe(debugUrl, options);
|
|
429
|
+
return `<!-- Embed Morph Live Session -->
|
|
430
|
+
${iframe}`;
|
|
431
|
+
}
|
|
432
|
+
function resolvePreset(optionsOrPreset) {
|
|
433
|
+
if (!optionsOrPreset) {
|
|
434
|
+
return {};
|
|
435
|
+
}
|
|
436
|
+
if (typeof optionsOrPreset === "string") {
|
|
437
|
+
const preset = LIVE_PRESETS[optionsOrPreset];
|
|
438
|
+
if (!preset) {
|
|
439
|
+
throw new Error(
|
|
440
|
+
`Unknown preset: ${optionsOrPreset}. Available presets: ${Object.keys(LIVE_PRESETS).join(", ")}`
|
|
441
|
+
);
|
|
442
|
+
}
|
|
443
|
+
return preset;
|
|
444
|
+
}
|
|
445
|
+
return optionsOrPreset;
|
|
446
|
+
}
|
|
447
|
+
|
|
372
448
|
// tools/browser/core.ts
|
|
373
449
|
var DEFAULT_CONFIG2 = {
|
|
374
450
|
apiUrl: process.env.MORPH_ENVIRONMENT === "DEV" ? "http://localhost:8000" : "https://browser.morphllm.com",
|
|
@@ -439,10 +515,16 @@ async function executeBrowserTask(input, config = {}) {
|
|
|
439
515
|
const timeout = config.timeout || DEFAULT_CONFIG2.timeout;
|
|
440
516
|
const debug = config.debug || false;
|
|
441
517
|
if (!input.task || input.task.trim().length === 0) {
|
|
442
|
-
return {
|
|
518
|
+
return {
|
|
519
|
+
success: false,
|
|
520
|
+
error: 'Task description is required. Example: "Go to example.com and click the login button"'
|
|
521
|
+
};
|
|
443
522
|
}
|
|
444
523
|
if (input.max_steps !== void 0 && (input.max_steps < 1 || input.max_steps > 50)) {
|
|
445
|
-
return {
|
|
524
|
+
return {
|
|
525
|
+
success: false,
|
|
526
|
+
error: "max_steps must be between 1 and 50. Use more steps for complex multi-page flows."
|
|
527
|
+
};
|
|
446
528
|
}
|
|
447
529
|
if (debug) {
|
|
448
530
|
console.log(`[Browser] Task: "${input.task.slice(0, 60)}..." url=${input.url || "none"} maxSteps=${input.max_steps ?? 10}`);
|
|
@@ -495,7 +577,7 @@ async function executeBrowserTask(input, config = {}) {
|
|
|
495
577
|
if (error.message.includes("ECONNREFUSED") || error.message.includes("fetch failed")) {
|
|
496
578
|
return {
|
|
497
579
|
success: false,
|
|
498
|
-
error: `Cannot connect to browser worker at ${apiUrl}. Ensure the service is running.`
|
|
580
|
+
error: `Cannot connect to browser worker at ${apiUrl}. Ensure the service is running and accessible. For local dev, set MORPH_ENVIRONMENT=DEV.`
|
|
499
581
|
};
|
|
500
582
|
}
|
|
501
583
|
return {
|
|
@@ -660,7 +742,7 @@ function wrapTaskResponse(result, config) {
|
|
|
660
742
|
if (!result.task_id) {
|
|
661
743
|
throw new Error("task_id is required to wrap response");
|
|
662
744
|
}
|
|
663
|
-
|
|
745
|
+
const wrapped = {
|
|
664
746
|
...result,
|
|
665
747
|
task_id: result.task_id,
|
|
666
748
|
liveUrl: generateLiveUrl(result.task_id, config),
|
|
@@ -668,13 +750,42 @@ function wrapTaskResponse(result, config) {
|
|
|
668
750
|
return pollTaskUntilComplete(result.task_id, config, pollConfig);
|
|
669
751
|
}
|
|
670
752
|
};
|
|
753
|
+
if (result.debugUrl) {
|
|
754
|
+
wrapped.getLiveUrl = (options) => {
|
|
755
|
+
return buildLiveUrl(result.debugUrl, options);
|
|
756
|
+
};
|
|
757
|
+
wrapped.getLiveIframe = (optionsOrPreset) => {
|
|
758
|
+
const options = resolvePreset(optionsOrPreset);
|
|
759
|
+
return buildLiveIframe(result.debugUrl, options);
|
|
760
|
+
};
|
|
761
|
+
wrapped.getEmbedCode = () => {
|
|
762
|
+
return buildEmbedCode(result.debugUrl);
|
|
763
|
+
};
|
|
764
|
+
} else {
|
|
765
|
+
wrapped.getLiveUrl = () => {
|
|
766
|
+
throw new Error(
|
|
767
|
+
"Live sessions not available. Your backend must return a debugUrl in the response. Contact support@morphllm.com if you need help."
|
|
768
|
+
);
|
|
769
|
+
};
|
|
770
|
+
wrapped.getLiveIframe = () => {
|
|
771
|
+
throw new Error(
|
|
772
|
+
"Live sessions not available. Your backend must return a debugUrl in the response. Contact support@morphllm.com if you need help."
|
|
773
|
+
);
|
|
774
|
+
};
|
|
775
|
+
wrapped.getEmbedCode = () => {
|
|
776
|
+
throw new Error(
|
|
777
|
+
"Live sessions not available. Your backend must return a debugUrl in the response. Contact support@morphllm.com if you need help."
|
|
778
|
+
);
|
|
779
|
+
};
|
|
780
|
+
}
|
|
781
|
+
return wrapped;
|
|
671
782
|
}
|
|
672
783
|
function wrapTaskResponseWithSchema(result, config, schema) {
|
|
673
784
|
if (!result.task_id) {
|
|
674
785
|
throw new Error("task_id is required to wrap response");
|
|
675
786
|
}
|
|
676
787
|
const parsed = result.output ? parseStructuredTaskOutput(result, schema) : { ...result, parsed: null };
|
|
677
|
-
|
|
788
|
+
const wrapped = {
|
|
678
789
|
...parsed,
|
|
679
790
|
task_id: result.task_id,
|
|
680
791
|
liveUrl: generateLiveUrl(result.task_id, config),
|
|
@@ -683,6 +794,35 @@ function wrapTaskResponseWithSchema(result, config, schema) {
|
|
|
683
794
|
return parseStructuredTaskOutput(finalResult, schema);
|
|
684
795
|
}
|
|
685
796
|
};
|
|
797
|
+
if (result.debugUrl) {
|
|
798
|
+
wrapped.getLiveUrl = (options) => {
|
|
799
|
+
return buildLiveUrl(result.debugUrl, options);
|
|
800
|
+
};
|
|
801
|
+
wrapped.getLiveIframe = (optionsOrPreset) => {
|
|
802
|
+
const options = resolvePreset(optionsOrPreset);
|
|
803
|
+
return buildLiveIframe(result.debugUrl, options);
|
|
804
|
+
};
|
|
805
|
+
wrapped.getEmbedCode = () => {
|
|
806
|
+
return buildEmbedCode(result.debugUrl);
|
|
807
|
+
};
|
|
808
|
+
} else {
|
|
809
|
+
wrapped.getLiveUrl = () => {
|
|
810
|
+
throw new Error(
|
|
811
|
+
"Live sessions not available. Your backend must return a debugUrl in the response. Contact support@morphllm.com if you need help enabling live sessions. "
|
|
812
|
+
);
|
|
813
|
+
};
|
|
814
|
+
wrapped.getLiveIframe = () => {
|
|
815
|
+
throw new Error(
|
|
816
|
+
"Live sessions not available. Your backend must return a debugUrl in the response. Contact support@morphllm.com if you need help enabling live sessions."
|
|
817
|
+
);
|
|
818
|
+
};
|
|
819
|
+
wrapped.getEmbedCode = () => {
|
|
820
|
+
throw new Error(
|
|
821
|
+
"Live sessions not available. Your backend must return a debugUrl in the response. Contact support@morphllm.com if you need help enabling live sessions."
|
|
822
|
+
);
|
|
823
|
+
};
|
|
824
|
+
}
|
|
825
|
+
return wrapped;
|
|
686
826
|
}
|
|
687
827
|
async function checkHealth(config = {}) {
|
|
688
828
|
const apiUrl = config.apiUrl || DEFAULT_CONFIG2.apiUrl;
|
|
@@ -1106,57 +1246,13 @@ var MorphGit = class {
|
|
|
1106
1246
|
var import_isomorphic_git2 = __toESM(require("isomorphic-git"), 1);
|
|
1107
1247
|
var import_node2 = __toESM(require("isomorphic-git/http/node"), 1);
|
|
1108
1248
|
|
|
1109
|
-
//
|
|
1249
|
+
// modelrouter/core.ts
|
|
1110
1250
|
var DEFAULT_CONFIG3 = {
|
|
1111
1251
|
apiUrl: "https://api.morphllm.com",
|
|
1112
|
-
timeout:
|
|
1113
|
-
//
|
|
1252
|
+
timeout: 5e3,
|
|
1253
|
+
// 5 seconds (responses typically <500ms)
|
|
1114
1254
|
debug: false
|
|
1115
1255
|
};
|
|
1116
|
-
var MODEL_MAPPINGS = {
|
|
1117
|
-
openai: {
|
|
1118
|
-
balanced: {
|
|
1119
|
-
easy: "gpt-5-mini",
|
|
1120
|
-
medium: "gpt-5-low",
|
|
1121
|
-
hard: "gpt-5-medium",
|
|
1122
|
-
"needs-info": "gpt-5-mini"
|
|
1123
|
-
},
|
|
1124
|
-
aggressive: {
|
|
1125
|
-
easy: "gpt-5-low",
|
|
1126
|
-
medium: "gpt-5-medium",
|
|
1127
|
-
hard: "gpt-5-high",
|
|
1128
|
-
"needs-info": "gpt-5-mini"
|
|
1129
|
-
}
|
|
1130
|
-
},
|
|
1131
|
-
anthropic: {
|
|
1132
|
-
balanced: {
|
|
1133
|
-
easy: "claude-4.5-haiku",
|
|
1134
|
-
medium: "claude-4.5-haiku",
|
|
1135
|
-
hard: "claude-4.5-sonnet",
|
|
1136
|
-
"needs-info": "claude-4.5-haiku"
|
|
1137
|
-
},
|
|
1138
|
-
aggressive: {
|
|
1139
|
-
easy: "claude-4.5-haiku",
|
|
1140
|
-
medium: "claude-4.5-sonnet",
|
|
1141
|
-
hard: "claude-4.5-sonnet",
|
|
1142
|
-
"needs-info": "claude-4.5-haiku"
|
|
1143
|
-
}
|
|
1144
|
-
},
|
|
1145
|
-
gemini: {
|
|
1146
|
-
balanced: {
|
|
1147
|
-
easy: "gemini-2.5-flash",
|
|
1148
|
-
medium: "gemini-2.5-flash",
|
|
1149
|
-
hard: "gemini-2.5-pro",
|
|
1150
|
-
"needs-info": "gemini-2.5-flash"
|
|
1151
|
-
},
|
|
1152
|
-
aggressive: {
|
|
1153
|
-
easy: "gemini-2.5-flash",
|
|
1154
|
-
medium: "gemini-2.5-pro",
|
|
1155
|
-
hard: "gemini-2.5-pro",
|
|
1156
|
-
"needs-info": "gemini-2.5-flash"
|
|
1157
|
-
}
|
|
1158
|
-
}
|
|
1159
|
-
};
|
|
1160
1256
|
var BaseRouter = class {
|
|
1161
1257
|
config;
|
|
1162
1258
|
provider;
|
|
@@ -1170,13 +1266,6 @@ var BaseRouter = class {
|
|
|
1170
1266
|
retryConfig: config.retryConfig
|
|
1171
1267
|
};
|
|
1172
1268
|
}
|
|
1173
|
-
/**
|
|
1174
|
-
* Map backend complexity classification to actual model name
|
|
1175
|
-
*/
|
|
1176
|
-
mapComplexityToModel(complexity, mode) {
|
|
1177
|
-
const mapping = MODEL_MAPPINGS[this.provider][mode];
|
|
1178
|
-
return mapping[complexity];
|
|
1179
|
-
}
|
|
1180
1269
|
/**
|
|
1181
1270
|
* Select the optimal model for a given input and mode
|
|
1182
1271
|
*/
|
|
@@ -1188,7 +1277,7 @@ var BaseRouter = class {
|
|
|
1188
1277
|
"Morph API key is required. Set MORPH_API_KEY environment variable or pass apiKey in config."
|
|
1189
1278
|
);
|
|
1190
1279
|
}
|
|
1191
|
-
const url = `${this.config.apiUrl}/router/${this.provider}`;
|
|
1280
|
+
const url = `${this.config.apiUrl}/v1/router/${this.provider}`;
|
|
1192
1281
|
const payload = {
|
|
1193
1282
|
input: input.input,
|
|
1194
1283
|
mode
|
|
@@ -1224,13 +1313,11 @@ var BaseRouter = class {
|
|
|
1224
1313
|
);
|
|
1225
1314
|
}
|
|
1226
1315
|
const apiResult = await response.json();
|
|
1227
|
-
const actualModel = this.mapComplexityToModel(apiResult.model, mode);
|
|
1228
1316
|
const result = {
|
|
1229
|
-
model:
|
|
1230
|
-
reasoning: apiResult.reasoning
|
|
1317
|
+
model: apiResult.model
|
|
1231
1318
|
};
|
|
1232
1319
|
if (this.config.debug) {
|
|
1233
|
-
console.log(`[ModelRouter]
|
|
1320
|
+
console.log(`[ModelRouter] Selected model: ${apiResult.model}, Confidence: ${apiResult.confidence?.toFixed(3)}`);
|
|
1234
1321
|
}
|
|
1235
1322
|
return result;
|
|
1236
1323
|
} catch (error) {
|