@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/client.cjs
CHANGED
|
@@ -362,6 +362,82 @@ async function executeCodebaseSearch(input, config) {
|
|
|
362
362
|
}
|
|
363
363
|
}
|
|
364
364
|
|
|
365
|
+
// tools/browser/live.ts
|
|
366
|
+
var LIVE_PRESETS = {
|
|
367
|
+
/** Read-only monitoring (no interaction) */
|
|
368
|
+
readonly: { interactive: false },
|
|
369
|
+
/** Interactive control (human-in-the-loop) */
|
|
370
|
+
interactive: { interactive: true },
|
|
371
|
+
/** Watch-only without controls */
|
|
372
|
+
monitoring: { interactive: false, showControls: false }
|
|
373
|
+
};
|
|
374
|
+
function buildLiveUrl(debugUrl, options = {}) {
|
|
375
|
+
if (!debugUrl) {
|
|
376
|
+
throw new Error(
|
|
377
|
+
"debugUrl is required. Ensure your backend returns debugUrl in the task response. Contact support@morphllm.com if you need help."
|
|
378
|
+
);
|
|
379
|
+
}
|
|
380
|
+
const url = new URL(debugUrl);
|
|
381
|
+
if (options.interactive !== void 0) {
|
|
382
|
+
url.searchParams.set("interactive", String(options.interactive));
|
|
383
|
+
}
|
|
384
|
+
if (options.theme) {
|
|
385
|
+
url.searchParams.set("theme", options.theme);
|
|
386
|
+
}
|
|
387
|
+
if (options.showControls !== void 0) {
|
|
388
|
+
url.searchParams.set("showControls", String(options.showControls));
|
|
389
|
+
}
|
|
390
|
+
if (options.pageId) {
|
|
391
|
+
url.searchParams.set("pageId", options.pageId);
|
|
392
|
+
}
|
|
393
|
+
if (options.pageIndex) {
|
|
394
|
+
url.searchParams.set("pageIndex", options.pageIndex);
|
|
395
|
+
}
|
|
396
|
+
return url.toString();
|
|
397
|
+
}
|
|
398
|
+
function buildLiveIframe(debugUrl, options = {}) {
|
|
399
|
+
const {
|
|
400
|
+
width = "100%",
|
|
401
|
+
height = "600px",
|
|
402
|
+
style = "",
|
|
403
|
+
className = "",
|
|
404
|
+
...sessionOptions
|
|
405
|
+
} = options;
|
|
406
|
+
const src = buildLiveUrl(debugUrl, sessionOptions);
|
|
407
|
+
const widthStr = typeof width === "number" ? `${width}px` : width;
|
|
408
|
+
const heightStr = typeof height === "number" ? `${height}px` : height;
|
|
409
|
+
const baseStyle = `width: ${widthStr}; height: ${heightStr}; border: none;`;
|
|
410
|
+
const fullStyle = style ? `${baseStyle} ${style}` : baseStyle;
|
|
411
|
+
const attributes = [
|
|
412
|
+
`src="${src}"`,
|
|
413
|
+
`style="${fullStyle}"`
|
|
414
|
+
];
|
|
415
|
+
if (className) {
|
|
416
|
+
attributes.push(`class="${className}"`);
|
|
417
|
+
}
|
|
418
|
+
return `<iframe ${attributes.join(" ")}></iframe>`;
|
|
419
|
+
}
|
|
420
|
+
function buildEmbedCode(debugUrl, options = {}) {
|
|
421
|
+
const iframe = buildLiveIframe(debugUrl, options);
|
|
422
|
+
return `<!-- Embed Morph Live Session -->
|
|
423
|
+
${iframe}`;
|
|
424
|
+
}
|
|
425
|
+
function resolvePreset(optionsOrPreset) {
|
|
426
|
+
if (!optionsOrPreset) {
|
|
427
|
+
return {};
|
|
428
|
+
}
|
|
429
|
+
if (typeof optionsOrPreset === "string") {
|
|
430
|
+
const preset = LIVE_PRESETS[optionsOrPreset];
|
|
431
|
+
if (!preset) {
|
|
432
|
+
throw new Error(
|
|
433
|
+
`Unknown preset: ${optionsOrPreset}. Available presets: ${Object.keys(LIVE_PRESETS).join(", ")}`
|
|
434
|
+
);
|
|
435
|
+
}
|
|
436
|
+
return preset;
|
|
437
|
+
}
|
|
438
|
+
return optionsOrPreset;
|
|
439
|
+
}
|
|
440
|
+
|
|
365
441
|
// tools/browser/core.ts
|
|
366
442
|
var DEFAULT_CONFIG2 = {
|
|
367
443
|
apiUrl: process.env.MORPH_ENVIRONMENT === "DEV" ? "http://localhost:8000" : "https://browser.morphllm.com",
|
|
@@ -432,10 +508,16 @@ async function executeBrowserTask(input, config = {}) {
|
|
|
432
508
|
const timeout = config.timeout || DEFAULT_CONFIG2.timeout;
|
|
433
509
|
const debug = config.debug || false;
|
|
434
510
|
if (!input.task || input.task.trim().length === 0) {
|
|
435
|
-
return {
|
|
511
|
+
return {
|
|
512
|
+
success: false,
|
|
513
|
+
error: 'Task description is required. Example: "Go to example.com and click the login button"'
|
|
514
|
+
};
|
|
436
515
|
}
|
|
437
516
|
if (input.max_steps !== void 0 && (input.max_steps < 1 || input.max_steps > 50)) {
|
|
438
|
-
return {
|
|
517
|
+
return {
|
|
518
|
+
success: false,
|
|
519
|
+
error: "max_steps must be between 1 and 50. Use more steps for complex multi-page flows."
|
|
520
|
+
};
|
|
439
521
|
}
|
|
440
522
|
if (debug) {
|
|
441
523
|
console.log(`[Browser] Task: "${input.task.slice(0, 60)}..." url=${input.url || "none"} maxSteps=${input.max_steps ?? 10}`);
|
|
@@ -488,7 +570,7 @@ async function executeBrowserTask(input, config = {}) {
|
|
|
488
570
|
if (error.message.includes("ECONNREFUSED") || error.message.includes("fetch failed")) {
|
|
489
571
|
return {
|
|
490
572
|
success: false,
|
|
491
|
-
error: `Cannot connect to browser worker at ${apiUrl}. Ensure the service is running.`
|
|
573
|
+
error: `Cannot connect to browser worker at ${apiUrl}. Ensure the service is running and accessible. For local dev, set MORPH_ENVIRONMENT=DEV.`
|
|
492
574
|
};
|
|
493
575
|
}
|
|
494
576
|
return {
|
|
@@ -653,7 +735,7 @@ function wrapTaskResponse(result, config) {
|
|
|
653
735
|
if (!result.task_id) {
|
|
654
736
|
throw new Error("task_id is required to wrap response");
|
|
655
737
|
}
|
|
656
|
-
|
|
738
|
+
const wrapped = {
|
|
657
739
|
...result,
|
|
658
740
|
task_id: result.task_id,
|
|
659
741
|
liveUrl: generateLiveUrl(result.task_id, config),
|
|
@@ -661,13 +743,42 @@ function wrapTaskResponse(result, config) {
|
|
|
661
743
|
return pollTaskUntilComplete(result.task_id, config, pollConfig);
|
|
662
744
|
}
|
|
663
745
|
};
|
|
746
|
+
if (result.debugUrl) {
|
|
747
|
+
wrapped.getLiveUrl = (options) => {
|
|
748
|
+
return buildLiveUrl(result.debugUrl, options);
|
|
749
|
+
};
|
|
750
|
+
wrapped.getLiveIframe = (optionsOrPreset) => {
|
|
751
|
+
const options = resolvePreset(optionsOrPreset);
|
|
752
|
+
return buildLiveIframe(result.debugUrl, options);
|
|
753
|
+
};
|
|
754
|
+
wrapped.getEmbedCode = () => {
|
|
755
|
+
return buildEmbedCode(result.debugUrl);
|
|
756
|
+
};
|
|
757
|
+
} else {
|
|
758
|
+
wrapped.getLiveUrl = () => {
|
|
759
|
+
throw new Error(
|
|
760
|
+
"Live sessions not available. Your backend must return a debugUrl in the response. Contact support@morphllm.com if you need help."
|
|
761
|
+
);
|
|
762
|
+
};
|
|
763
|
+
wrapped.getLiveIframe = () => {
|
|
764
|
+
throw new Error(
|
|
765
|
+
"Live sessions not available. Your backend must return a debugUrl in the response. Contact support@morphllm.com if you need help."
|
|
766
|
+
);
|
|
767
|
+
};
|
|
768
|
+
wrapped.getEmbedCode = () => {
|
|
769
|
+
throw new Error(
|
|
770
|
+
"Live sessions not available. Your backend must return a debugUrl in the response. Contact support@morphllm.com if you need help."
|
|
771
|
+
);
|
|
772
|
+
};
|
|
773
|
+
}
|
|
774
|
+
return wrapped;
|
|
664
775
|
}
|
|
665
776
|
function wrapTaskResponseWithSchema(result, config, schema) {
|
|
666
777
|
if (!result.task_id) {
|
|
667
778
|
throw new Error("task_id is required to wrap response");
|
|
668
779
|
}
|
|
669
780
|
const parsed = result.output ? parseStructuredTaskOutput(result, schema) : { ...result, parsed: null };
|
|
670
|
-
|
|
781
|
+
const wrapped = {
|
|
671
782
|
...parsed,
|
|
672
783
|
task_id: result.task_id,
|
|
673
784
|
liveUrl: generateLiveUrl(result.task_id, config),
|
|
@@ -676,6 +787,35 @@ function wrapTaskResponseWithSchema(result, config, schema) {
|
|
|
676
787
|
return parseStructuredTaskOutput(finalResult, schema);
|
|
677
788
|
}
|
|
678
789
|
};
|
|
790
|
+
if (result.debugUrl) {
|
|
791
|
+
wrapped.getLiveUrl = (options) => {
|
|
792
|
+
return buildLiveUrl(result.debugUrl, options);
|
|
793
|
+
};
|
|
794
|
+
wrapped.getLiveIframe = (optionsOrPreset) => {
|
|
795
|
+
const options = resolvePreset(optionsOrPreset);
|
|
796
|
+
return buildLiveIframe(result.debugUrl, options);
|
|
797
|
+
};
|
|
798
|
+
wrapped.getEmbedCode = () => {
|
|
799
|
+
return buildEmbedCode(result.debugUrl);
|
|
800
|
+
};
|
|
801
|
+
} else {
|
|
802
|
+
wrapped.getLiveUrl = () => {
|
|
803
|
+
throw new Error(
|
|
804
|
+
"Live sessions not available. Your backend must return a debugUrl in the response. Contact support@morphllm.com if you need help enabling live sessions. "
|
|
805
|
+
);
|
|
806
|
+
};
|
|
807
|
+
wrapped.getLiveIframe = () => {
|
|
808
|
+
throw new Error(
|
|
809
|
+
"Live sessions not available. Your backend must return a debugUrl in the response. Contact support@morphllm.com if you need help enabling live sessions."
|
|
810
|
+
);
|
|
811
|
+
};
|
|
812
|
+
wrapped.getEmbedCode = () => {
|
|
813
|
+
throw new Error(
|
|
814
|
+
"Live sessions not available. Your backend must return a debugUrl in the response. Contact support@morphllm.com if you need help enabling live sessions."
|
|
815
|
+
);
|
|
816
|
+
};
|
|
817
|
+
}
|
|
818
|
+
return wrapped;
|
|
679
819
|
}
|
|
680
820
|
async function checkHealth(config = {}) {
|
|
681
821
|
const apiUrl = config.apiUrl || DEFAULT_CONFIG2.apiUrl;
|
|
@@ -1099,57 +1239,13 @@ var MorphGit = class {
|
|
|
1099
1239
|
var import_isomorphic_git2 = __toESM(require("isomorphic-git"), 1);
|
|
1100
1240
|
var import_node2 = __toESM(require("isomorphic-git/http/node"), 1);
|
|
1101
1241
|
|
|
1102
|
-
//
|
|
1242
|
+
// modelrouter/core.ts
|
|
1103
1243
|
var DEFAULT_CONFIG3 = {
|
|
1104
1244
|
apiUrl: "https://api.morphllm.com",
|
|
1105
|
-
timeout:
|
|
1106
|
-
//
|
|
1245
|
+
timeout: 5e3,
|
|
1246
|
+
// 5 seconds (responses typically <500ms)
|
|
1107
1247
|
debug: false
|
|
1108
1248
|
};
|
|
1109
|
-
var MODEL_MAPPINGS = {
|
|
1110
|
-
openai: {
|
|
1111
|
-
balanced: {
|
|
1112
|
-
easy: "gpt-5-mini",
|
|
1113
|
-
medium: "gpt-5-low",
|
|
1114
|
-
hard: "gpt-5-medium",
|
|
1115
|
-
"needs-info": "gpt-5-mini"
|
|
1116
|
-
},
|
|
1117
|
-
aggressive: {
|
|
1118
|
-
easy: "gpt-5-low",
|
|
1119
|
-
medium: "gpt-5-medium",
|
|
1120
|
-
hard: "gpt-5-high",
|
|
1121
|
-
"needs-info": "gpt-5-mini"
|
|
1122
|
-
}
|
|
1123
|
-
},
|
|
1124
|
-
anthropic: {
|
|
1125
|
-
balanced: {
|
|
1126
|
-
easy: "claude-4.5-haiku",
|
|
1127
|
-
medium: "claude-4.5-haiku",
|
|
1128
|
-
hard: "claude-4.5-sonnet",
|
|
1129
|
-
"needs-info": "claude-4.5-haiku"
|
|
1130
|
-
},
|
|
1131
|
-
aggressive: {
|
|
1132
|
-
easy: "claude-4.5-haiku",
|
|
1133
|
-
medium: "claude-4.5-sonnet",
|
|
1134
|
-
hard: "claude-4.5-sonnet",
|
|
1135
|
-
"needs-info": "claude-4.5-haiku"
|
|
1136
|
-
}
|
|
1137
|
-
},
|
|
1138
|
-
gemini: {
|
|
1139
|
-
balanced: {
|
|
1140
|
-
easy: "gemini-2.5-flash",
|
|
1141
|
-
medium: "gemini-2.5-flash",
|
|
1142
|
-
hard: "gemini-2.5-pro",
|
|
1143
|
-
"needs-info": "gemini-2.5-flash"
|
|
1144
|
-
},
|
|
1145
|
-
aggressive: {
|
|
1146
|
-
easy: "gemini-2.5-flash",
|
|
1147
|
-
medium: "gemini-2.5-pro",
|
|
1148
|
-
hard: "gemini-2.5-pro",
|
|
1149
|
-
"needs-info": "gemini-2.5-flash"
|
|
1150
|
-
}
|
|
1151
|
-
}
|
|
1152
|
-
};
|
|
1153
1249
|
var BaseRouter = class {
|
|
1154
1250
|
config;
|
|
1155
1251
|
provider;
|
|
@@ -1163,13 +1259,6 @@ var BaseRouter = class {
|
|
|
1163
1259
|
retryConfig: config.retryConfig
|
|
1164
1260
|
};
|
|
1165
1261
|
}
|
|
1166
|
-
/**
|
|
1167
|
-
* Map backend complexity classification to actual model name
|
|
1168
|
-
*/
|
|
1169
|
-
mapComplexityToModel(complexity, mode) {
|
|
1170
|
-
const mapping = MODEL_MAPPINGS[this.provider][mode];
|
|
1171
|
-
return mapping[complexity];
|
|
1172
|
-
}
|
|
1173
1262
|
/**
|
|
1174
1263
|
* Select the optimal model for a given input and mode
|
|
1175
1264
|
*/
|
|
@@ -1181,7 +1270,7 @@ var BaseRouter = class {
|
|
|
1181
1270
|
"Morph API key is required. Set MORPH_API_KEY environment variable or pass apiKey in config."
|
|
1182
1271
|
);
|
|
1183
1272
|
}
|
|
1184
|
-
const url = `${this.config.apiUrl}/router/${this.provider}`;
|
|
1273
|
+
const url = `${this.config.apiUrl}/v1/router/${this.provider}`;
|
|
1185
1274
|
const payload = {
|
|
1186
1275
|
input: input.input,
|
|
1187
1276
|
mode
|
|
@@ -1217,13 +1306,11 @@ var BaseRouter = class {
|
|
|
1217
1306
|
);
|
|
1218
1307
|
}
|
|
1219
1308
|
const apiResult = await response.json();
|
|
1220
|
-
const actualModel = this.mapComplexityToModel(apiResult.model, mode);
|
|
1221
1309
|
const result = {
|
|
1222
|
-
model:
|
|
1223
|
-
reasoning: apiResult.reasoning
|
|
1310
|
+
model: apiResult.model
|
|
1224
1311
|
};
|
|
1225
1312
|
if (this.config.debug) {
|
|
1226
|
-
console.log(`[ModelRouter]
|
|
1313
|
+
console.log(`[ModelRouter] Selected model: ${apiResult.model}, Confidence: ${apiResult.confidence?.toFixed(3)}`);
|
|
1227
1314
|
}
|
|
1228
1315
|
return result;
|
|
1229
1316
|
} catch (error) {
|