@morphllm/morphsdk 0.2.8 → 0.2.14
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-G4DJ6VSM.js → chunk-7NG7SI6M.js} +6 -2
- package/dist/{chunk-G4DJ6VSM.js.map → chunk-7NG7SI6M.js.map} +1 -1
- package/dist/{chunk-BWI43OMO.js → chunk-C2TYLJRK.js} +10 -10
- 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 +145 -5
- package/dist/client.cjs.map +1 -1
- package/dist/client.js +4 -4
- package/dist/index.cjs +145 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -11
- 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 +7 -4
- package/dist/chunk-4UVEBIDK.js.map +0 -1
- /package/dist/{chunk-BWI43OMO.js.map → chunk-C2TYLJRK.js.map} +0 -0
package/dist/client.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
MorphClient
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-AKVAAKRB.js";
|
|
3
|
+
} from "./chunk-C2TYLJRK.js";
|
|
5
4
|
import "./chunk-VJK4PH5V.js";
|
|
5
|
+
import "./chunk-4V46N27D.js";
|
|
6
|
+
import "./chunk-OWXIAZUZ.js";
|
|
6
7
|
import "./chunk-74ZHKB54.js";
|
|
7
8
|
import "./chunk-5VQEQSJQ.js";
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-4UVEBIDK.js";
|
|
9
|
+
import "./chunk-AKVAAKRB.js";
|
|
10
10
|
import "./chunk-4VWJFZVS.js";
|
|
11
11
|
import "./chunk-PZ5AY32C.js";
|
|
12
12
|
export {
|
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;
|