@morphllm/morphsdk 0.2.170 → 0.2.172
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-IY7DESC3.js → chunk-2SNAXTUJ.js} +4 -4
- package/dist/chunk-453ZV2AX.js +120 -0
- package/dist/chunk-453ZV2AX.js.map +1 -0
- package/dist/chunk-53ZJMCWU.js +142 -0
- package/dist/chunk-53ZJMCWU.js.map +1 -0
- package/dist/{chunk-5KFQBI4J.js → chunk-5DA6SZQJ.js} +2 -2
- package/dist/chunk-66OHYI24.js +78 -0
- package/dist/chunk-66OHYI24.js.map +1 -0
- package/dist/chunk-6X6QMRQG.js +158 -0
- package/dist/chunk-6X6QMRQG.js.map +1 -0
- package/dist/{chunk-76XER44U.js → chunk-7PVVPLRL.js} +2 -2
- package/dist/{chunk-BCPZAPWY.js → chunk-AE7M2I52.js} +2 -2
- package/dist/{chunk-LNXIVRPY.js → chunk-CQF76HJC.js} +30 -6
- package/dist/chunk-CQF76HJC.js.map +1 -0
- package/dist/{chunk-OJQYBWHR.js → chunk-ESXCQBMU.js} +2 -2
- package/dist/{chunk-LAGN62H5.js → chunk-FOIDGIY4.js} +29 -10
- package/dist/chunk-FOIDGIY4.js.map +1 -0
- package/dist/{chunk-KUPSW5QN.js → chunk-GJZXDRH5.js} +8 -3
- package/dist/{chunk-KUPSW5QN.js.map → chunk-GJZXDRH5.js.map} +1 -1
- package/dist/{chunk-5IR3YE77.js → chunk-IJ33I7P5.js} +4 -4
- package/dist/{chunk-E5QWXVTF.js → chunk-IN2U7AAI.js} +99 -143
- package/dist/chunk-IN2U7AAI.js.map +1 -0
- package/dist/{chunk-LE66XCOI.js → chunk-JWZ5DLAS.js} +27 -10
- package/dist/chunk-JWZ5DLAS.js.map +1 -0
- package/dist/chunk-LKFZBBTD.js +12 -0
- package/dist/chunk-LKFZBBTD.js.map +1 -0
- package/dist/{chunk-6LPWEZ6H.js → chunk-MO6S2LRD.js} +2 -2
- package/dist/{chunk-S4IEM5EG.js → chunk-NI7PWQ3B.js} +4 -4
- package/dist/{chunk-GLQWEINZ.js → chunk-QAXXE4AD.js} +2 -2
- package/dist/{chunk-YG2I377B.js → chunk-QFE5523Q.js} +18 -3
- package/dist/chunk-QFE5523Q.js.map +1 -0
- package/dist/{chunk-G4FPDEUP.js → chunk-QQXNZIVK.js} +4 -4
- package/dist/{chunk-A3ZUWLYX.js → chunk-QZ3V2BP7.js} +2 -2
- package/dist/chunk-QZR7SJ5N.js +24 -0
- package/dist/chunk-QZR7SJ5N.js.map +1 -0
- package/dist/{chunk-SYD6BRQX.js → chunk-SJVLAGUL.js} +4 -4
- package/dist/{chunk-JMEQ6FLB.js → chunk-U4J3BVAQ.js} +4 -4
- package/dist/{chunk-QAWYDWDW.js → chunk-U4MRSZQQ.js} +2 -2
- package/dist/{chunk-WU3D46MH.js → chunk-UADW6FYD.js} +2 -2
- package/dist/{chunk-K7NY5SVR.js → chunk-VBARKJWL.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-GUGHUAJU.js → chunk-XJDXV5VX.js} +2 -2
- package/dist/{chunk-GPNUS3H2.js → chunk-XYTYIAMQ.js} +2 -2
- package/dist/{chunk-MKBVWPU7.js → chunk-Z4GJVN52.js} +23 -8
- package/dist/chunk-Z4GJVN52.js.map +1 -0
- package/dist/chunk-ZLSNL6M2.js +97 -0
- package/dist/chunk-ZLSNL6M2.js.map +1 -0
- package/dist/{client-DsAAqupx.d.ts → client-Dh6yzCm4.d.ts} +14 -5
- package/dist/client.cjs +741 -525
- 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 +252 -174
- 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 +688 -466
- 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 +32 -3
- package/dist/tools/fastapply/anthropic.cjs.map +1 -1
- package/dist/tools/fastapply/anthropic.js +8 -4
- package/dist/tools/fastapply/apply.cjs +23 -3
- package/dist/tools/fastapply/apply.cjs.map +1 -1
- package/dist/tools/fastapply/apply.js +2 -2
- package/dist/tools/fastapply/core.cjs +258 -13
- 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 +32 -3
- 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 +32 -3
- package/dist/tools/fastapply/openai.cjs.map +1 -1
- package/dist/tools/fastapply/openai.js +8 -4
- package/dist/tools/fastapply/vercel.cjs +32 -3
- package/dist/tools/fastapply/vercel.cjs.map +1 -1
- package/dist/tools/fastapply/vercel.js +8 -4
- package/dist/tools/index.cjs +32 -3
- 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 +113 -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-E5QWXVTF.js.map +0 -1
- package/dist/chunk-INBZD4EX.js +0 -197
- package/dist/chunk-INBZD4EX.js.map +0 -1
- package/dist/chunk-LAGN62H5.js.map +0 -1
- package/dist/chunk-LE66XCOI.js.map +0 -1
- package/dist/chunk-LNXIVRPY.js.map +0 -1
- package/dist/chunk-MKBVWPU7.js.map +0 -1
- package/dist/chunk-SCVWDNQP.js +0 -84
- package/dist/chunk-SCVWDNQP.js.map +0 -1
- package/dist/chunk-VE7J6VYX.js +0 -102
- package/dist/chunk-VE7J6VYX.js.map +0 -1
- package/dist/chunk-YG2I377B.js.map +0 -1
- /package/dist/{chunk-IY7DESC3.js.map → chunk-2SNAXTUJ.js.map} +0 -0
- /package/dist/{chunk-5KFQBI4J.js.map → chunk-5DA6SZQJ.js.map} +0 -0
- /package/dist/{chunk-76XER44U.js.map → chunk-7PVVPLRL.js.map} +0 -0
- /package/dist/{chunk-BCPZAPWY.js.map → chunk-AE7M2I52.js.map} +0 -0
- /package/dist/{chunk-OJQYBWHR.js.map → chunk-ESXCQBMU.js.map} +0 -0
- /package/dist/{chunk-5IR3YE77.js.map → chunk-IJ33I7P5.js.map} +0 -0
- /package/dist/{chunk-6LPWEZ6H.js.map → chunk-MO6S2LRD.js.map} +0 -0
- /package/dist/{chunk-S4IEM5EG.js.map → chunk-NI7PWQ3B.js.map} +0 -0
- /package/dist/{chunk-GLQWEINZ.js.map → chunk-QAXXE4AD.js.map} +0 -0
- /package/dist/{chunk-G4FPDEUP.js.map → chunk-QQXNZIVK.js.map} +0 -0
- /package/dist/{chunk-A3ZUWLYX.js.map → chunk-QZ3V2BP7.js.map} +0 -0
- /package/dist/{chunk-SYD6BRQX.js.map → chunk-SJVLAGUL.js.map} +0 -0
- /package/dist/{chunk-JMEQ6FLB.js.map → chunk-U4J3BVAQ.js.map} +0 -0
- /package/dist/{chunk-QAWYDWDW.js.map → chunk-U4MRSZQQ.js.map} +0 -0
- /package/dist/{chunk-WU3D46MH.js.map → chunk-UADW6FYD.js.map} +0 -0
- /package/dist/{chunk-K7NY5SVR.js.map → chunk-VBARKJWL.js.map} +0 -0
- /package/dist/{chunk-OPNTDMHH.js.map → chunk-VLZ6PNAD.js.map} +0 -0
- /package/dist/{chunk-GUGHUAJU.js.map → chunk-XJDXV5VX.js.map} +0 -0
- /package/dist/{chunk-GPNUS3H2.js.map → chunk-XYTYIAMQ.js.map} +0 -0
|
@@ -1 +0,0 @@
|
|
|
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';\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 */\nexport class BrowserClient {\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(config: BrowserConfig = {}) {\n this.config = {\n ...DEFAULT_CONFIG,\n ...config,\n };\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":";;;;;;;;;;;;;;;;;;AAwBA,IAAM,iBAAiB;AAAA,EACrB,QAAQ,QAAQ,IAAI,sBAAsB,QACtC,0BACA;AAAA,EACJ,SAAS;AAAA;AAAA,EACT,OAAO;AACT;AAKO,IAAM,gBAAN,MAAoB;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA,EAKD;AAAA,EAEP,YAAY,SAAwB,CAAC,GAAG;AACtC,SAAK,SAAS;AAAA,MACZ,GAAG;AAAA,MACH,GAAG;AAAA,IACL;AACA,SAAK,WAAW,IAAI,eAAe,KAAK,MAAM;AAAA,EAChD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,QAAQ,OAAqD;AACjE,WAAO,mBAAmB,OAAO,KAAK,MAAM;AAAA,EAC9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AAM,MAAM,GAAG,MAAM,WAAW;AAAA,MAC/C,QAAQ;AAAA,MACR,SAAS,OAAO,SACZ,EAAE,iBAAiB,UAAU,OAAO,MAAM,GAAG,IAC7C,CAAC;AAAA,IACP,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AAChB,YAAM,IAAI,MAAM,QAAQ,SAAS,MAAM,EAAE;AAAA,IAC3C;AAEA,UAAM,OAAO,MAAM,SAAS,KAAK;AACjC,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,mBAAmB,KAAK,qBAAqB;AAAA,MAC7C,qBAAqB,KAAK,uBAAuB;AAAA,MACjD,eAAe,KAAK,iBAAiB;AAAA,IACvC;AAAA,EACF,SAAS,OAAO;AACd,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,mBAAmB;AAAA,MACnB,qBAAqB;AAAA,MACrB,eAAe;AAAA,MACf,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAAA,IAC9D;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../git/client.ts"],"sourcesContent":["/**\n * Morph Git Client - Simple, high-level Git operations\n * Built on isomorphic-git with explicit configuration\n */\n\n\nimport git from 'isomorphic-git';\nimport http from 'isomorphic-git/http/node';\nimport fs from 'fs';\nimport type {\n CloneOptions,\n PushOptions,\n PullOptions,\n AddOptions,\n CommitOptions,\n StatusOptions,\n LogOptions,\n CheckoutOptions,\n BranchOptions,\n DiffOptions,\n CommitObject,\n StatusResult,\n MorphGitConfig,\n MorphNotesSchema,\n WaitForEmbeddingsOptions,\n EmbeddingProgress,\n} from './types.js';\n\nconst DEFAULT_PROXY_URL = 'https://repos.morphllm.com';\n\n/**\n * MorphGit - Git operations for AI agents with Morph backend\n * \n * @example\n * ```typescript\n * import { MorphGit } from 'morphsdk/git';\n * \n * const morphGit = new MorphGit({\n * apiKey: process.env.MORPH_API_KEY!,\n * proxyUrl: 'https://repos.morphllm.com' // Optional\n * });\n * \n * await morphGit.init({ repoId: 'my-project', dir: './my-project' });\n * await morphGit.push({ dir: './my-project' });\n * ```\n */\nexport class MorphGit {\n private readonly apiKey: string;\n private readonly proxyUrl: string;\n\n constructor(config: MorphGitConfig) {\n // Validate API key\n if (!config.apiKey) {\n throw new Error('API key is required. Get one at https://morphllm.com/dashboard');\n }\n \n if (!config.apiKey.startsWith('sk-') && !config.apiKey.startsWith('morph-')) {\n throw new Error('Invalid API key format. Expected: sk-... or morph-...');\n }\n \n this.apiKey = config.apiKey;\n this.proxyUrl = config.proxyUrl || DEFAULT_PROXY_URL;\n }\n \n /**\n * Get auth callback for isomorphic-git operations\n * @private\n */\n private getAuthCallback() {\n return () => ({\n username: 'morph',\n password: this.apiKey,\n });\n }\n\n /**\n * Initialize a new repository\n * Creates the repo in the database and in the git provider\n * \n * @example\n * ```ts\n * await morphGit.init({\n * repoId: 'my-project',\n * dir: './my-project',\n * defaultBranch: 'main'\n * });\n * ```\n */\n async init(options: {\n repoId: string;\n dir: string;\n defaultBranch?: string;\n }): Promise<void> {\n const { repoId, dir, defaultBranch = 'main' } = options;\n\n // Call backend API to create repository\n const response = await fetch(`${this.proxyUrl}/v1/repos`, {\n method: 'POST',\n headers: {\n 'Authorization': `Bearer ${this.apiKey}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n repoId,\n name: repoId,\n defaultBranch,\n }),\n });\n\n if (!response.ok) {\n const error = await response.text();\n throw new Error(`Failed to create repository: ${error}`);\n }\n\n // Initialize local git repository (industry standard: no clone needed)\n await git.init({\n fs,\n dir,\n defaultBranch,\n });\n\n // Add remote pointing to Morph git-proxy\n await git.addRemote({\n fs,\n dir,\n remote: 'origin',\n url: `${this.proxyUrl}/v1/repos/${repoId}`,\n });\n\n console.log(`✓ Repository '${repoId}' initialized`);\n }\n\n /**\n * Clone a repository from Morph repos\n * \n * @example\n * ```ts\n * await morphGit.clone({\n * repoId: 'my-project',\n * dir: './my-project'\n * });\n * ```\n */\n async clone(options: CloneOptions): Promise<void> {\n const { repoId, dir, branch = 'main', depth, singleBranch = true } = options;\n\n await git.clone({\n fs,\n http,\n dir,\n url: `${this.proxyUrl}/v1/repos/${repoId}`,\n ref: branch,\n singleBranch,\n depth,\n onAuth: this.getAuthCallback(),\n });\n }\n\n /**\n * Push changes to remote repository\n * \n * @example\n * ```ts\n * await morphGit.push({ \n * dir: './my-project',\n * branch: 'main', // Required: explicit branch name\n * index: true // Optional: generate embeddings for semantic search\n * });\n * ```\n */\n async push(options: PushOptions): Promise<void> {\n const { dir, remote = 'origin', branch, waitForEmbeddings, index = false } = options;\n\n if (!branch) {\n throw new Error(\n 'branch is required for push operations. ' +\n 'Specify the branch explicitly: { dir: \"./my-project\", branch: \"main\" }'\n );\n }\n\n // Get commit hash and repoId before pushing\n const commitHash = await git.resolveRef({ fs, dir, ref: 'HEAD' });\n \n // Get repoId from git remote URL\n let repoId: string | undefined;\n const remotes = await git.listRemotes({ fs, dir });\n const originRemote = remotes.find(r => r.remote === remote);\n if (originRemote) {\n // Extract repoId from URL: https://repos.morphllm.com/v1/repos/{repoId}\n const match = originRemote.url.match(/\\/repos\\/([^\\/]+)$/);\n if (match) {\n repoId = match[1];\n }\n }\n\n await git.push({\n fs,\n http,\n dir,\n remote,\n ref: branch,\n onAuth: this.getAuthCallback(),\n });\n \n // Configure commit after successful push (set index flag)\n if (repoId && commitHash) {\n await this.configureCommit({ repoId, commitHash, branch, index });\n }\n \n // Wait for embeddings if requested (and indexing is enabled)\n if (waitForEmbeddings && repoId && commitHash && index) {\n await this.waitForEmbeddings({ repoId, commitHash });\n }\n }\n\n /**\n * Configure commit settings on the backend after push.\n * Sets the index flag to control embedding generation.\n * @private\n */\n private async configureCommit(options: {\n repoId: string;\n commitHash: string;\n branch: string;\n index: boolean;\n }): Promise<void> {\n const { repoId, commitHash, branch, index } = options;\n \n const response = await fetch(\n `${this.proxyUrl}/v1/repos/${repoId}/commits/${commitHash}/config`,\n {\n method: 'POST',\n headers: {\n 'Authorization': `Bearer ${this.apiKey}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({ index, branch }),\n }\n );\n\n if (!response.ok) {\n // Non-fatal: log warning but don't throw\n console.warn(`Failed to configure commit: ${response.status}`);\n }\n }\n\n /**\n * Pull changes from remote repository\n * \n * @example\n * ```ts\n * await morphGit.pull({ \n * dir: './my-project',\n * branch: 'main' // Required: explicit branch name\n * });\n * ```\n */\n async pull(options: PullOptions): Promise<void> {\n const { dir, remote = 'origin', branch } = options;\n\n if (!branch) {\n throw new Error(\n 'branch is required for pull operations. ' +\n 'Specify the branch explicitly: { dir: \"./my-project\", branch: \"main\" }'\n );\n }\n\n await git.pull({\n fs,\n http,\n dir,\n remote,\n ref: branch,\n onAuth: this.getAuthCallback(),\n author: {\n name: 'Morph Agent',\n email: 'agent@morph.com',\n },\n });\n }\n\n /**\n * Wait for embeddings to complete after push.\n * Polls status endpoint until embeddings are done.\n * \n * @example\n * ```ts\n * await morphGit.push({ dir: './my-project', branch: 'main' });\n * await morphGit.waitForEmbeddings({\n * repoId: 'my-project',\n * onProgress: (p) => console.log(`${p.filesProcessed}/${p.totalFiles}`)\n * });\n * ```\n */\n async waitForEmbeddings(options: WaitForEmbeddingsOptions): Promise<void> {\n const { repoId, commitHash, timeout = 120000, onProgress } = options;\n const startTime = Date.now();\n const pollInterval = 1000; // Poll every 1s\n \n while (Date.now() - startTime < timeout) {\n const statusUrl = `${this.proxyUrl}/v1/repos/${repoId}/embedding-status` +\n (commitHash ? `?commit_hash=${commitHash}` : '');\n \n const response = await fetch(statusUrl, {\n headers: { 'Authorization': `Bearer ${this.apiKey}` }\n });\n \n if (response.status === 404) {\n // No job found yet - might still be creating\n await new Promise(resolve => setTimeout(resolve, pollInterval));\n continue;\n }\n \n if (!response.ok) {\n throw new Error(`Failed to get embedding status: ${response.status}`);\n }\n \n const status = await response.json();\n \n if (onProgress && status.progress) {\n onProgress(status.progress);\n }\n \n if (status.status === 'completed') {\n return; // Done!\n }\n \n if (status.status === 'failed') {\n throw new Error(`Embeddings failed: ${status.error || 'Unknown error'}`);\n }\n \n // Still processing (queued or processing), wait and poll again\n await new Promise(resolve => setTimeout(resolve, pollInterval));\n }\n \n throw new Error(`Embeddings timed out after ${timeout}ms`);\n }\n\n /**\n * Stage a file for commit\n * \n * @example\n * ```ts\n * await morphGit.add({\n * dir: './my-project',\n * filepath: 'src/app.ts'\n * });\n * ```\n */\n async add(options: AddOptions): Promise<void> {\n const { dir, filepath } = options;\n\n await git.add({\n fs,\n dir,\n filepath,\n });\n }\n\n /**\n * Remove a file from staging\n * \n * @example\n * ```ts\n * await morphGit.remove({\n * dir: './my-project',\n * filepath: 'src/old-file.ts'\n * });\n * ```\n */\n async remove(options: AddOptions): Promise<void> {\n const { dir, filepath } = options;\n\n await git.remove({\n fs,\n dir,\n filepath,\n });\n }\n\n /**\n * Commit staged changes\n * \n * @example\n * ```ts\n * await morphGit.commit({\n * dir: './my-project',\n * message: 'Add new feature',\n * author: {\n * name: 'AI Agent',\n * email: 'ai@example.com'\n * },\n * metadata: { issueId: 'PROJ-123', source: 'agent' },\n * chatHistory: [\n * { role: 'user', content: 'Please add a new feature' },\n * { role: 'assistant', content: 'I will add that feature' }\n * ],\n * recordingId: 'rec_123'\n * });\n * ```\n */\n async commit(options: CommitOptions): Promise<string> {\n const { dir, message, author, metadata, chatHistory, recordingId } = options;\n\n // Provide default author if not specified\n const commitAuthor = author || {\n name: 'Morph SDK',\n email: 'sdk@morphllm.com'\n };\n\n const sha = await git.commit({\n fs,\n dir,\n message,\n author: commitAuthor,\n });\n\n // Store notes if any note fields are provided\n if (metadata || chatHistory || recordingId) {\n const notes: MorphNotesSchema = {\n metadata,\n chatHistory,\n recordingId,\n _version: 1\n };\n \n await git.addNote({\n fs,\n dir,\n ref: 'refs/notes/morph-metadata',\n oid: sha,\n note: JSON.stringify(notes, null, 2),\n author: commitAuthor\n });\n }\n\n return sha;\n }\n\n /**\n * Get status of a file\n * \n * @example\n * ```ts\n * const status = await morphGit.status({\n * dir: './my-project',\n * filepath: 'src/app.ts'\n * });\n * console.log(status); // 'modified', '*added', etc.\n * ```\n */\n async status(options: StatusOptions): Promise<string> {\n const { dir, filepath } = options;\n\n if (!filepath) {\n throw new Error('filepath is required for status check');\n }\n\n const status = await git.status({\n fs,\n dir,\n filepath,\n });\n\n return status;\n }\n\n /**\n * Get commit history\n * \n * @example\n * ```ts\n * const commits = await morphGit.log({\n * dir: './my-project',\n * depth: 10\n * });\n * ```\n */\n async log(options: LogOptions): Promise<CommitObject[]> {\n const { dir, depth, ref } = options;\n\n const commits = await git.log({\n fs,\n dir,\n depth,\n ref,\n });\n\n return commits as CommitObject[];\n }\n\n /**\n * Checkout a branch or commit\n * \n * @example\n * ```ts\n * await morphGit.checkout({\n * dir: './my-project',\n * ref: 'feature-branch'\n * });\n * ```\n */\n async checkout(options: CheckoutOptions): Promise<void> {\n const { dir, ref } = options;\n\n await git.checkout({\n fs,\n dir,\n ref,\n });\n }\n\n /**\n * Create a new branch\n * \n * @example\n * ```ts\n * await morphGit.branch({\n * dir: './my-project',\n * name: 'feature-branch',\n * checkout: true\n * });\n * ```\n */\n async branch(options: BranchOptions): Promise<void> {\n const { dir, name, checkout = false } = options;\n\n await git.branch({\n fs,\n dir,\n ref: name,\n checkout,\n });\n }\n\n /**\n * List all branches\n * \n * @example\n * ```ts\n * const branches = await morphGit.listBranches({\n * dir: './my-project'\n * });\n * ```\n */\n async listBranches(options: { dir: string }): Promise<string[]> {\n const { dir } = options;\n\n const branches = await git.listBranches({\n fs,\n dir,\n });\n\n return branches;\n }\n\n /**\n * Get the current branch name\n * \n * @example\n * ```ts\n * const branch = await morphGit.currentBranch({\n * dir: './my-project'\n * });\n * ```\n */\n async currentBranch(options: { dir: string }): Promise<string | undefined> {\n const { dir } = options;\n\n const branch = await git.currentBranch({\n fs,\n dir,\n });\n\n return branch || undefined;\n }\n\n /**\n * Get list of changed files (similar to git diff --name-only)\n * \n * @example\n * ```ts\n * const changes = await morphGit.statusMatrix({\n * dir: './my-project'\n * });\n * ```\n */\n async statusMatrix(options: { dir: string }): Promise<StatusResult[]> {\n const { dir } = options;\n\n const matrix = await git.statusMatrix({\n fs,\n dir,\n });\n\n return matrix.map(([filepath, HEADStatus, workdirStatus, stageStatus]) => {\n let status: StatusResult['status'] = 'unmodified';\n\n // Determine status based on statusMatrix values\n if (HEADStatus === 1 && workdirStatus === 2 && stageStatus === 2) {\n status = 'modified';\n } else if (HEADStatus === 1 && workdirStatus === 2 && stageStatus === 1) {\n status = '*modified';\n } else if (HEADStatus === 0 && workdirStatus === 2 && stageStatus === 2) {\n status = 'added';\n } else if (HEADStatus === 0 && workdirStatus === 2 && stageStatus === 0) {\n status = '*added';\n } else if (HEADStatus === 1 && workdirStatus === 0 && stageStatus === 0) {\n status = 'deleted';\n } else if (HEADStatus === 1 && workdirStatus === 0 && stageStatus === 1) {\n status = '*deleted';\n } else if (HEADStatus === 1 && workdirStatus === 1 && stageStatus === 1) {\n status = 'unmodified';\n } else if (HEADStatus === 0 && workdirStatus === 0 && stageStatus === 0) {\n status = 'absent';\n }\n\n return {\n filepath,\n status,\n };\n });\n }\n\n /**\n * Get the current commit hash\n * \n * @example\n * ```ts\n * const hash = await morphGit.resolveRef({\n * dir: './my-project',\n * ref: 'HEAD'\n * });\n * ```\n */\n async resolveRef(options: { dir: string; ref: string }): Promise<string> {\n const { dir, ref } = options;\n\n const oid = await git.resolveRef({\n fs,\n dir,\n ref,\n });\n\n return oid;\n }\n\n /**\n * Get notes (metadata, chat history, recording ID) attached to a commit\n * \n * @example\n * ```ts\n * const notes = await morphGit.getCommitMetadata({\n * dir: './my-project',\n * commitSha: 'abc123...'\n * });\n * \n * if (notes) {\n * console.log('Metadata:', notes.metadata);\n * console.log('Chat history:', notes.chatHistory);\n * console.log('Recording ID:', notes.recordingId);\n * }\n * ```\n */\n async getCommitMetadata(options: {\n dir: string;\n commitSha: string;\n }): Promise<MorphNotesSchema | null> {\n try {\n const note = await git.readNote({\n fs,\n dir: options.dir,\n ref: 'refs/notes/morph-metadata',\n oid: options.commitSha\n });\n \n const notes: MorphNotesSchema = JSON.parse(new TextDecoder().decode(note));\n return notes;\n } catch (err) {\n // No notes found for this commit\n return null;\n }\n }\n}\n\n"],"mappings":";AAMA,OAAO,SAAS;AAChB,OAAO,UAAU;AACjB,OAAO,QAAQ;AAoBf,IAAM,oBAAoB;AAkBnB,IAAM,WAAN,MAAe;AAAA,EACH;AAAA,EACA;AAAA,EAEjB,YAAY,QAAwB;AAElC,QAAI,CAAC,OAAO,QAAQ;AAClB,YAAM,IAAI,MAAM,gEAAgE;AAAA,IAClF;AAEA,QAAI,CAAC,OAAO,OAAO,WAAW,KAAK,KAAK,CAAC,OAAO,OAAO,WAAW,QAAQ,GAAG;AAC3E,YAAM,IAAI,MAAM,uDAAuD;AAAA,IACzE;AAEA,SAAK,SAAS,OAAO;AACrB,SAAK,WAAW,OAAO,YAAY;AAAA,EACrC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMQ,kBAAkB;AACxB,WAAO,OAAO;AAAA,MACZ,UAAU;AAAA,MACV,UAAU,KAAK;AAAA,IACjB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAeA,MAAM,KAAK,SAIO;AAChB,UAAM,EAAE,QAAQ,KAAK,gBAAgB,OAAO,IAAI;AAGhD,UAAM,WAAW,MAAM,MAAM,GAAG,KAAK,QAAQ,aAAa;AAAA,MACxD,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,iBAAiB,UAAU,KAAK,MAAM;AAAA,QACtC,gBAAgB;AAAA,MAClB;AAAA,MACA,MAAM,KAAK,UAAU;AAAA,QACnB;AAAA,QACA,MAAM;AAAA,QACN;AAAA,MACF,CAAC;AAAA,IACH,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AAChB,YAAM,QAAQ,MAAM,SAAS,KAAK;AAClC,YAAM,IAAI,MAAM,gCAAg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AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmBA,MAAM,kBAAkB,SAGa;AACnC,QAAI;AACF,YAAM,OAAO,MAAM,IAAI,SAAS;AAAA,QAC9B;AAAA,QACA,KAAK,QAAQ;AAAA,QACb,KAAK;AAAA,QACL,KAAK,QAAQ;AAAA,MACf,CAAC;AAED,YAAM,QAA0B,KAAK,MAAM,IAAI,YAAY,EAAE,OAAO,IAAI,CAAC;AACzE,aAAO;AAAA,IACT,SAAS,KAAK;AAEZ,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../tools/warp_grep/client.ts"],"sourcesContent":["/**\n * WarpGrep client for programmatic code search\n */\n\nimport { runWarpGrep, runWarpGrepStreaming } from './agent/runner.js';\nimport { logger } from '../../logger.js';\nimport { RemoteCommandsProvider } from './providers/remote.js';\nimport type { WarpGrepProvider } from './providers/types.js';\nimport type { AgentRunResult, WarpGrepStep } from './agent/types.js';\nimport type {\n WarpGrepClientConfig,\n WarpGrepInput,\n WarpGrepResult,\n WarpGrepContext,\n WarpGrepToolConfig,\n GitHubSearchInput,\n GitHubReadFileInput,\n GitHubReadFileResult,\n RemoteCommands,\n} from './types.js';\nimport { createCodeStorageHttpCommands } from './providers/code_storage_http.js';\nimport { parseGitHubUrl } from './utils/github.js';\nimport { compactFileContexts } from '../compact/utils.js';\n\nconst DEFAULT_CODE_SEARCH_URL = 'https://morphllm.com';\n\n/**\n * Lazy-load LocalRipgrepProvider to avoid importing Node.js-specific\n * modules (child_process, fs) in edge environments like Cloudflare Workers.\n * Only loads when actually needed (i.e., when no remoteCommands or provider is specified).\n */\nasync function getLocalProvider(repoRoot: string, excludes?: string[], allowNames?: string[]): Promise<WarpGrepProvider> {\n const { LocalRipgrepProvider } = await import('./providers/local.js');\n const opts = allowNames?.length ? { allowNames } : undefined;\n return new LocalRipgrepProvider(repoRoot, excludes, opts);\n}\n\n/**\n * WarpGrep client for programmatic code search\n * \n * @example\n * ```typescript\n * import { WarpGrepClient } from '@morphllm/morphsdk';\n * \n * const client = new WarpGrepClient({ morphApiKey: process.env.MORPH_API_KEY });\n * \n * // Simple usage - defaults to LocalRipgrepProvider\n * const result = await client.execute({\n * searchTerm: 'Find authentication middleware',\n * repoRoot: '.'\n * });\n *\n * // With custom excludes\n * const result = await client.execute({\n * searchTerm: 'Find database models',\n * repoRoot: '.',\n * excludes: ['node_modules', '.git', 'dist']\n * });\n * ```\n */\nexport class WarpGrepClient {\n private config: WarpGrepClientConfig;\n\n constructor(config: WarpGrepClientConfig = {}) {\n this.config = { ...config };\n }\n\n /**\n * Execute a code search\n *\n * @param input - Search parameters including searchTerm, repoRoot, and optional provider\n * @returns Search results with relevant code contexts, or an AsyncGenerator if streamSteps is true\n *\n * @example\n * ```typescript\n * // Standard execution\n * const result = await client.execute({\n * searchTerm: 'Find authentication middleware',\n * repoRoot: '.'\n * });\n *\n * if (result.success) {\n * for (const ctx of result.contexts) {\n * console.log(`File: ${ctx.file}`);\n * console.log(ctx.content);\n * }\n * }\n *\n * // Streaming execution\n * const stream = client.execute({\n * searchTerm: 'Find auth middleware',\n * repoRoot: '.',\n * streamSteps: true\n * });\n *\n * for await (const step of stream) {\n * console.log(`Turn ${step.turn}:`, step.toolCalls);\n * }\n * ```\n */\n execute(input: WarpGrepInput & { streamSteps: true }): AsyncGenerator<WarpGrepStep, WarpGrepResult, undefined>;\n execute(input: WarpGrepInput & { streamSteps?: false | undefined }): Promise<WarpGrepResult>;\n execute(input: WarpGrepInput): Promise<WarpGrepResult> | AsyncGenerator<WarpGrepStep, WarpGrepResult, undefined> {\n const toolConfig: WarpGrepToolConfig = {\n repoRoot: input.repoRoot,\n remoteCommands: input.remoteCommands,\n provider: input.provider,\n excludes: input.excludes,\n includes: input.includes,\n debug: input.debug ?? this.config.debug,\n morphApiKey: this.config.morphApiKey,\n morphApiUrl: this.config.morphApiUrl,\n retryConfig: this.config.retryConfig,\n timeout: this.config.timeout,\n search_type: input.search_type,\n };\n\n if (input.streamSteps) {\n return executeToolCallStreaming({ search_term: input.searchTerm }, toolConfig);\n }\n return executeToolCall({ search_term: input.searchTerm }, toolConfig);\n }\n\n /**\n * Search a public GitHub repository\n *\n * @example\n * ```typescript\n * // Simple usage\n * const result = await client.searchGitHub({\n * searchTerm: 'Find authentication middleware',\n * github: 'vercel/next.js',\n * });\n *\n * // With streaming\n * const stream = client.searchGitHub({\n * searchTerm: 'Find auth middleware',\n * github: 'https://github.com/vercel/next.js',\n * streamSteps: true,\n * });\n * for await (const step of stream) {\n * console.log(`Turn ${step.turn}:`, step.toolCalls);\n * }\n * ```\n */\n searchGitHub(input: GitHubSearchInput & { streamSteps: true }): AsyncGenerator<WarpGrepStep, WarpGrepResult, undefined>;\n searchGitHub(input: GitHubSearchInput & { streamSteps?: false | undefined }): Promise<WarpGrepResult>;\n searchGitHub(input: GitHubSearchInput): Promise<WarpGrepResult> | AsyncGenerator<WarpGrepStep, WarpGrepResult, undefined> {\n if (input.streamSteps) {\n return this._searchGitHubStreaming(input);\n }\n return this._searchGitHubAsync(input);\n }\n\n /**\n * Read a single file from a public GitHub repository\n *\n * @example\n * ```typescript\n * const result = await client.readGitHubFile({\n * github: 'vercel/next.js',\n * path: 'src/server/app-render/index.tsx',\n * startLine: 1,\n * endLine: 50,\n * });\n * if (result.success) console.log(result.content);\n * ```\n */\n async readGitHubFile(input: GitHubReadFileInput): Promise<GitHubReadFileResult> {\n return executeGitHubReadFile(input, { timeout: this.config.timeout });\n }\n\n private async _resolveGitHubRepo(input: GitHubSearchInput): Promise<{ repo: string; remoteCommands: RemoteCommands }> {\n const { owner, repo } = parseGitHubUrl(input.github);\n const baseUrl = this.config.codeSearchUrl || DEFAULT_CODE_SEARCH_URL;\n logger.debug('WarpGrep', 'github_resolve', { owner_repo: `${owner}/${repo}`, branch: input.branch });\n\n const resolveStart = Date.now();\n const importRes = await fetch(`${baseUrl}/api/code-search/get-or-create?url=${encodeURIComponent(`${owner}/${repo}`)}`);\n if (!importRes.ok) {\n const text = await importRes.text().catch(() => importRes.statusText);\n logger.error('WarpGrep', 'github_resolve_failed', { owner_repo: `${owner}/${repo}`, status: importRes.status, error: text });\n throw new Error(`Failed to import repo ${owner}/${repo}: ${text}`);\n }\n const { repoId, defaultBranch } = await importRes.json();\n logger.debug('WarpGrep', 'github_repo_fetched', { repo_id: repoId, default_branch: defaultBranch, latency_ms: Date.now() - resolveStart });\n\n return {\n repo,\n remoteCommands: createCodeStorageHttpCommands({ baseUrl, repoId, branch: input.branch || defaultBranch }),\n };\n }\n\n private async _searchGitHubAsync(input: GitHubSearchInput): Promise<WarpGrepResult> {\n try {\n const { remoteCommands } = await this._resolveGitHubRepo(input);\n return this.execute({\n searchTerm: input.searchTerm,\n repoRoot: '.',\n remoteCommands,\n });\n } catch (error) {\n return { success: false, error: error instanceof Error ? error.message : String(error) };\n }\n }\n\n private async *_searchGitHubStreaming(input: GitHubSearchInput): AsyncGenerator<WarpGrepStep, WarpGrepResult, undefined> {\n let remoteCommands: RemoteCommands;\n try {\n ({ remoteCommands } = await this._resolveGitHubRepo(input));\n } catch (error) {\n return { success: false, error: error instanceof Error ? error.message : String(error) };\n }\n\n const generator = this.execute({\n searchTerm: input.searchTerm,\n repoRoot: '.',\n remoteCommands,\n streamSteps: true,\n });\n\n let result: WarpGrepResult;\n for (;;) {\n const { value, done } = await generator.next();\n if (done) {\n result = value;\n break;\n }\n yield value;\n }\n return result;\n }\n}\n\n/**\n * Execute a warp grep search directly\n *\n * @param input - Search parameters\n * @param config - Optional client configuration\n * @returns Search results, or an AsyncGenerator if streamSteps is true\n *\n * @example\n * ```typescript\n * import { executeWarpGrep } from '@morphllm/morphsdk/tools/warp-grep';\n *\n * const result = await executeWarpGrep({\n * searchTerm: 'Find authentication middleware',\n * repoRoot: '.'\n * });\n *\n * // Streaming\n * const stream = executeWarpGrep({\n * searchTerm: 'Find auth',\n * repoRoot: '.',\n * streamSteps: true\n * });\n * for await (const step of stream) {\n * console.log(step.turn, step.toolCalls);\n * }\n * ```\n */\nexport function executeWarpGrep(\n input: WarpGrepInput & { streamSteps: true },\n config?: WarpGrepClientConfig\n): AsyncGenerator<WarpGrepStep, WarpGrepResult, undefined>;\nexport function executeWarpGrep(\n input: WarpGrepInput & { streamSteps?: false | undefined },\n config?: WarpGrepClientConfig\n): Promise<WarpGrepResult>;\nexport function executeWarpGrep(\n input: WarpGrepInput,\n config?: WarpGrepClientConfig\n): Promise<WarpGrepResult> | AsyncGenerator<WarpGrepStep, WarpGrepResult, undefined> {\n const client = new WarpGrepClient(config);\n if (input.streamSteps) {\n return client.execute({ ...input, streamSteps: true });\n }\n return client.execute({ ...input, streamSteps: false });\n}\n\nexport async function executeToolCall(\n input: { search_term: string } | string,\n config: WarpGrepToolConfig\n): Promise<WarpGrepResult> {\n const parsed = typeof input === 'string' ? JSON.parse(input) : input;\n\n // Priority: remoteCommands > provider > LocalRipgrepProvider (lazy-loaded for edge compatibility)\n const allowNames = config.search_type === 'node_modules' ? ['node_modules'] : undefined;\n const provider = config.remoteCommands\n ? new RemoteCommandsProvider(config.repoRoot, config.remoteCommands)\n : config.provider ?? await getLocalProvider(config.repoRoot, config.excludes, allowNames);\n\n const result = await runWarpGrep({\n searchTerm: parsed.search_term,\n repoRoot: config.repoRoot,\n provider,\n excludes: config.excludes,\n includes: config.includes,\n debug: config.debug ?? false,\n morphApiKey: config.morphApiKey,\n morphApiUrl: config.morphApiUrl,\n retryConfig: config.retryConfig,\n timeout: config.timeout,\n search_type: config.search_type,\n });\n\n return processAgentResult(result, parsed.search_term, config.morphApiKey, config.morphApiUrl);\n}\n\n/**\n * Helper to process AgentRunResult into WarpGrepResult\n */\nasync function processAgentResult(\n result: AgentRunResult,\n searchTerm: string,\n apiKey?: string,\n apiUrl?: string\n): Promise<WarpGrepResult> {\n const finish = result.finish;\n if (result.terminationReason !== 'completed' || !finish?.metadata) {\n const errorDetails = result.errors?.map(e => e.message).join('; ') || 'unknown reason';\n console.error(`[warp_grep] processAgentResult failed. Reason: ${result.terminationReason}. Errors: ${errorDetails}. Turns: ${result.timings?.turns?.length ?? 0}`);\n return { success: false, error: `Search did not complete: ${errorDetails}` };\n }\n\n const contexts: WarpGrepContext[] = (finish.resolved ?? []).map(r => ({\n file: r.path,\n content: r.content,\n lines: r.ranges,\n }));\n\n try {\n const compactable = contexts.map(c => ({ path: c.file, content: c.content }));\n const compacted = await compactFileContexts(compactable, searchTerm, apiKey, apiUrl);\n for (let i = 0; i < contexts.length; i++) {\n contexts[i].content = compacted[i].content;\n }\n } catch (error) {\n console.error(`[warp_grep] Failed to compact result contexts:`, error);\n }\n\n return { success: true, contexts, summary: finish.payload };\n}\n\n/**\n * Streaming version of executeToolCall that yields WarpGrepStep for each turn.\n */\nexport async function* executeToolCallStreaming(\n input: { search_term: string } | string,\n config: WarpGrepToolConfig\n): AsyncGenerator<WarpGrepStep, WarpGrepResult, undefined> {\n const parsed = typeof input === 'string' ? JSON.parse(input) : input;\n\n // Priority: remoteCommands > provider > LocalRipgrepProvider (lazy-loaded for edge compatibility)\n const allowNames = config.search_type === 'node_modules' ? ['node_modules'] : undefined;\n const provider = config.remoteCommands\n ? new RemoteCommandsProvider(config.repoRoot, config.remoteCommands)\n : config.provider ?? await getLocalProvider(config.repoRoot, config.excludes, allowNames);\n\n const generator = runWarpGrepStreaming({\n searchTerm: parsed.search_term,\n repoRoot: config.repoRoot,\n provider,\n excludes: config.excludes,\n includes: config.includes,\n debug: config.debug ?? false,\n morphApiKey: config.morphApiKey,\n morphApiUrl: config.morphApiUrl,\n retryConfig: config.retryConfig,\n timeout: config.timeout,\n search_type: config.search_type,\n });\n\n // Forward all yielded steps\n let agentResult: AgentRunResult;\n for (;;) {\n const { value, done } = await generator.next();\n if (done) {\n agentResult = value;\n break;\n }\n yield value;\n }\n\n return processAgentResult(agentResult, parsed.search_term, config.morphApiKey, config.morphApiUrl);\n}\n\n/**\n * Fetch raw file content from a public GitHub repository.\n * Tries the given branch first, then falls back to main/master/develop.\n */\nasync function fetchRawGitHubFile(\n owner: string,\n repo: string,\n filePath: string,\n branch?: string,\n timeout?: number,\n): Promise<{ content: string; branch: string }> {\n const branches = branch ? [branch] : ['HEAD'];\n const fallbacks = ['main', 'master', 'develop'];\n\n const fetchWithTimeout = (url: string) =>\n timeout ? fetch(url, { signal: AbortSignal.timeout(timeout) }) : fetch(url);\n\n for (const b of branches) {\n const url = `https://raw.githubusercontent.com/${owner}/${repo}/${b}/${filePath}`;\n const res = await fetchWithTimeout(url);\n if (res.ok) return { content: await res.text(), branch: b };\n }\n\n for (const fb of fallbacks) {\n if (branch && fb === branch) continue;\n const url = `https://raw.githubusercontent.com/${owner}/${repo}/${fb}/${filePath}`;\n const res = await fetchWithTimeout(url);\n if (res.ok) return { content: await res.text(), branch: fb };\n }\n\n throw new Error(`File not found: ${owner}/${repo}/${filePath}`);\n}\n\n/**\n * Read a single file (or line range) from a public GitHub repository\n */\nexport async function executeGitHubReadFile(\n input: GitHubReadFileInput,\n config?: { timeout?: number },\n): Promise<GitHubReadFileResult> {\n try {\n const { owner, repo } = parseGitHubUrl(input.github);\n const { content: raw, branch } = await fetchRawGitHubFile(\n owner, repo, input.path, input.branch, config?.timeout,\n );\n\n const allLines = raw.split('\\n');\n const totalLines = allLines.length;\n const start = Math.max(1, input.startLine ?? 1);\n const end = Math.min(totalLines, input.endLine ?? totalLines);\n\n const selected = allLines.slice(start - 1, end);\n const padWidth = String(end).length;\n const numbered = selected\n .map((line, i) => `${String(start + i).padStart(padWidth)}|${line}`)\n .join('\\n');\n\n return {\n success: true,\n content: numbered,\n path: input.path,\n github: `${owner}/${repo}`,\n branch,\n lineRange: [start, end],\n totalLines,\n };\n } catch (error) {\n return {\n success: false,\n error: error instanceof Error ? error.message : String(error),\n };\n }\n}\n\n/**\n * Format a GitHub read file result for display or tool responses\n */\nexport function formatGitHubReadFileResult(result: GitHubReadFileResult): string {\n if (!result.success) {\n return `Failed to read file: ${result.error}`;\n }\n\n const rangeStr = result.lineRange\n ? ` (lines ${result.lineRange[0]}-${result.lineRange[1]} of ${result.totalLines})`\n : '';\n\n return `File: ${result.github}/${result.path}${rangeStr}\\n\\n${result.content}`;\n}\n\n/**\n * Format warp grep results for display or tool responses\n * \n * @param result - The search result\n * @returns Formatted string representation\n */\nexport function formatResult(result: WarpGrepResult): string {\n if (!result.success) {\n return `Search failed: ${result.error}`;\n }\n\n if (!result.contexts || result.contexts.length === 0) {\n return 'No relevant code found. Try rephrasing your search term.';\n }\n\n const parts: string[] = [];\n parts.push(`Morph Fast Context subagent performed search on repository:\\n`);\n parts.push('Relevant context found:');\n\n for (const ctx of result.contexts) {\n const rangeStr = !ctx.lines || ctx.lines === '*'\n ? '*'\n : ctx.lines.map(([s, e]) => `${s}-${e}`).join(',');\n parts.push(`- ${ctx.file}:${rangeStr}`);\n }\n\n parts.push('\\nHere is the content of files:\\n');\n\n for (const ctx of result.contexts) {\n const rangeStr = !ctx.lines || ctx.lines === '*'\n ? ''\n : ` lines=\"${ctx.lines.map(([s, e]) => `${s}-${e}`).join(',')}\"`;\n parts.push(`<file path=\"${ctx.file}\"${rangeStr}>`);\n parts.push(ctx.content);\n parts.push('</file>\\n');\n }\n\n return parts.join('\\n');\n}\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAwBA,IAAM,0BAA0B;AAOhC,eAAe,iBAAiB,UAAkB,UAAqB,YAAkD;AACvH,QAAM,EAAE,qBAAqB,IAAI,MAAM,OAAO,sCAAsB;AACpE,QAAM,OAAO,YAAY,SAAS,EAAE,WAAW,IAAI;AACnD,SAAO,IAAI,qBAAqB,UAAU,UAAU,IAAI;AAC1D;AAyBO,IAAM,iBAAN,MAAqB;AAAA,EAClB;AAAA,EAER,YAAY,SAA+B,CAAC,GAAG;AAC7C,SAAK,SAAS,EAAE,GAAG,OAAO;AAAA,EAC5B;AAAA,EAqCA,QAAQ,OAAyG;AAC/G,UAAM,a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EA,MAAI,CAAC,OAAO,YAAY,OAAO,SAAS,WAAW,GAAG;AACpD,WAAO;AAAA,EACT;AAEA,QAAM,QAAkB,CAAC;AACzB,QAAM,KAAK;AAAA,CAA+D;AAC1E,QAAM,KAAK,yBAAyB;AAEpC,aAAW,OAAO,OAAO,UAAU;AACjC,UAAM,WAAW,CAAC,IAAI,SAAS,IAAI,UAAU,MACzC,MACA,IAAI,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,GAAG;AACnD,UAAM,KAAK,KAAK,IAAI,IAAI,IAAI,QAAQ,EAAE;AAAA,EACxC;AAEA,QAAM,KAAK,mCAAmC;AAE9C,aAAW,OAAO,OAAO,UAAU;AACjC,UAAM,WAAW,CAAC,IAAI,SAAS,IAAI,UAAU,MACzC,KACA,WAAW,IAAI,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,GAAG,CAAC;AAC/D,UAAM,KAAK,eAAe,IAAI,IAAI,IAAI,QAAQ,GAAG;AACjD,UAAM,KAAK,IAAI,OAAO;AACtB,UAAM,KAAK,WAAW;AAAA,EACxB;AAEA,SAAO,MAAM,KAAK,IAAI;AACxB;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../tools/fastapply/core.ts"],"sourcesContent":["/**\n * Core implementation of Morph Fast Apply\n *\n * This module provides file-based operations that require Node.js.\n * For edge-compatible code-in/code-out operations, use applyEdit from ./apply.ts\n */\n\nimport { join, resolve, relative } from 'path';\nimport type {\n EditFileInput,\n EditFileResult,\n EditFileConfig,\n} from './types.js';\nimport { logger } from '../../logger.js';\n\n// Re-export edge-compatible functions\nexport { applyEdit, generateUdiff, countChanges, callMorphAPI } from './apply.js';\n\nconst DEFAULT_CONFIG: Required<Omit<EditFileConfig, 'morphApiKey' | 'systemPrompt' | 'retryConfig' | 'description' | 'large'>> = {\n morphApiUrl: 'https://api.morphllm.com',\n baseDir: process.cwd(),\n generateUdiff: true,\n autoWrite: true,\n timeout: 90000,\n debug: false,\n};\n\n/**\n * FastApply client for programmatic file editing\n * Note: This client requires Node.js for file operations\n */\nexport class FastApplyClient {\n private config: EditFileConfig;\n\n constructor(config: { apiKey?: string; debug?: boolean; timeout?: number; retryConfig?: any } = {}) {\n this.config = {\n morphApiKey: config.apiKey,\n morphApiUrl: DEFAULT_CONFIG.morphApiUrl,\n debug: config.debug,\n timeout: config.timeout || DEFAULT_CONFIG.timeout,\n retryConfig: config.retryConfig,\n generateUdiff: DEFAULT_CONFIG.generateUdiff,\n autoWrite: DEFAULT_CONFIG.autoWrite,\n };\n }\n\n /**\n * Execute a file edit operation\n *\n * @param input - Edit parameters including filepath, instructions, and code_edit\n * @param overrides - Optional config overrides for this operation\n * @returns Edit result with success status and changes\n */\n async execute(input: EditFileInput, overrides?: Partial<EditFileConfig>): Promise<EditFileResult> {\n return executeEditFile(input, { ...this.config, ...overrides });\n }\n\n /**\n * Apply an edit to code directly without file I/O\n *\n * Useful for sandbox environments or when you manage your own file system.\n * Compatible with the earlier OpenAI client API contract.\n *\n * @param input - Code and edit parameters\n * @param overrides - Optional config overrides for this operation\n * @returns Result with merged code\n *\n * @example\n * ```typescript\n * const result = await client.applyEdit({\n * originalCode: 'function hello() { return \"world\"; }',\n * codeEdit: 'function hello() { return \"universe\"; }',\n * instructions: 'Change return value'\n * });\n * console.log(result.mergedCode);\n * ```\n */\n async applyEdit(input: import('./types.js').ApplyEditInput, overrides?: Partial<import('./types.js').ApplyEditConfig>): Promise<import('./types.js').ApplyEditResult> {\n const { applyEdit } = await import('./apply.js');\n return applyEdit(input, { ...this.config, ...overrides });\n }\n}\n\n/**\n * Execute a file edit using Morph Fast Apply\n * Note: This function requires Node.js for file I/O\n */\nexport async function executeEditFile(\n input: EditFileInput,\n config: EditFileConfig = {}\n): Promise<EditFileResult> {\n const baseDir = config.baseDir || DEFAULT_CONFIG.baseDir;\n const fullPath = resolve(join(baseDir, input.target_filepath));\n\n logger.debug('FastApply', 'execute_start', { target_filepath: input.target_filepath, baseDir, autoWrite: config.autoWrite !== false });\n\n // Security: ensure file is within baseDir\n const relativePath = relative(baseDir, fullPath);\n if (relativePath.startsWith('..') || fullPath === baseDir) {\n logger.warn('FastApply', 'security_check_failed', { target_filepath: input.target_filepath, relative: relativePath });\n return {\n success: false,\n filepath: input.target_filepath,\n changes: { linesAdded: 0, linesRemoved: 0, linesModified: 0 },\n error: `Invalid filepath: '${input.target_filepath}' is outside baseDir`,\n };\n }\n\n logger.debug('FastApply', 'security_check', { resolved: fullPath, relative: relativePath });\n\n try {\n // Dynamic import to avoid loading Node.js fs module at module evaluation time\n const { readFile, writeFile } = await import('fs/promises');\n const { callMorphAPI, generateUdiff, countChanges } = await import('./apply.js');\n\n // Handle both existing and non-existent files\n let originalCode = '';\n let fileExists = true;\n try {\n originalCode = await readFile(fullPath, 'utf-8');\n logger.debug('FastApply', 'file_read', { path: fullPath, exists: true, size_bytes: originalCode.length });\n } catch (error: any) {\n if (error.code !== 'ENOENT') {\n throw error; // Re-throw if it's not a \"file not found\" error\n }\n fileExists = false;\n logger.debug('FastApply', 'file_read', { path: fullPath, exists: false });\n }\n\n const instruction = input.instruction ?? input.instructions ?? '';\n logger.debug('FastApply', 'api_call', { instruction_len: instruction.length, code_edit_len: input.code_edit.length, original_len: originalCode.length });\n\n const { content: mergedCode, completionId } = await callMorphAPI(originalCode, input.code_edit, instruction, input.target_filepath, config);\n\n logger.debug('FastApply', 'api_response', { completion_id: completionId, merged_len: mergedCode.length });\n\n const udiff = config.generateUdiff !== false ? generateUdiff(originalCode, mergedCode, input.target_filepath) : undefined;\n\n if (config.autoWrite !== false) {\n await writeFile(fullPath, mergedCode, 'utf-8');\n logger.debug('FastApply', 'file_write', { path: fullPath, size_bytes: mergedCode.length });\n }\n\n const changes = countChanges(originalCode, mergedCode);\n logger.debug('FastApply', 'changes', { added: changes.linesAdded, removed: changes.linesRemoved, modified: changes.linesModified });\n\n return {\n success: true,\n filepath: input.target_filepath,\n udiff,\n changes,\n completionId,\n };\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';\n logger.error('FastApply', 'execute_error', { error: errorMessage, target_filepath: input.target_filepath, stack: error instanceof Error ? error.stack : undefined });\n\n return {\n success: false,\n filepath: input.target_filepath,\n changes: { linesAdded: 0, linesRemoved: 0, linesModified: 0 },\n error: errorMessage,\n };\n }\n}\n"],"mappings":";;;;;AAOA,SAAS,MAAM,SAAS,gBAAgB;AAWxC,IAAM,iBAA2H;AAAA,EAC/H,aAAa;AAAA,EACb,SAAS,QAAQ,IAAI;AAAA,EACrB,eAAe;AAAA,EACf,WAAW;AAAA,EACX,SAAS;AAAA,EACT,OAAO;AACT;AAMO,IAAM,kBAAN,MAAsB;AAAA,EACnB;AAAA,EAER,YAAY,SAAoF,CAAC,GAAG;AAClG,SAAK,SAAS;AAAA,MACZ,aAAa,OAAO;AAAA,MACpB,aAAa,eAAe;AAAA,MAC5B,OAAO,OAAO;AAAA,MACd,SAAS,OAAO,WAAW,eAAe;AAAA,MAC1C,aAAa,OAAO;AAAA,MACpB,eAAe,eAAe;AAAA,MAC9B,WAAW,eAAe;AAAA,IAC5B;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,QAAQ,OAAsB,WAA8D;AAChG,WAAO,gBAAgB,OAAO,EAAE,GAAG,KAAK,QAAQ,GAAG,UAAU,CAAC;AAAA,EAChE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAsBA,MAAM,UAAU,OAA4C,WAA0G;AACpK,UAAM,EAAE,WAAAA,WAAU,IAAI,MAAM,OAAO,4BAAY;AAC/C,WAAOA,WAAU,OAAO,EAAE,GAAG,KAAK,QAAQ,GAAG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= "https://api.morphllm.com";
|
|
3
|
-
var DEFAULT_TIMEOUT = 12e4;
|
|
4
|
-
var CompactClient = class {
|
|
5
|
-
config;
|
|
6
|
-
constructor(config = {}) {
|
|
7
|
-
this.config = {
|
|
8
|
-
...config,
|
|
9
|
-
morphApiUrl: config.morphApiUrl ?? DEFAULT_API_URL,
|
|
10
|
-
timeout: config.timeout ?? DEFAULT_TIMEOUT
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Compact messages or text via /v1/compact.
|
|
15
|
-
* Returns per-message `compacted_line_ranges` showing which lines were removed.
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```typescript
|
|
19
|
-
* const client = new CompactClient({ morphApiKey: 'sk-...' });
|
|
20
|
-
* const result = await client.compact({
|
|
21
|
-
* input: codeFile,
|
|
22
|
-
* query: "authentication",
|
|
23
|
-
* compressionRatio: 0.5,
|
|
24
|
-
* });
|
|
25
|
-
* console.log(result.output);
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
async compact(input) {
|
|
29
|
-
const apiKey = this.config.morphApiKey || (typeof process !== "undefined" ? process.env?.MORPH_API_KEY : void 0);
|
|
30
|
-
const debug = this.config.debug || false;
|
|
31
|
-
if (!apiKey) {
|
|
32
|
-
throw new Error(
|
|
33
|
-
"Morph API key not found. Set MORPH_API_KEY environment variable or pass morphApiKey in config."
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
const url = `${this.config.morphApiUrl}/v1/compact`;
|
|
37
|
-
if (debug) {
|
|
38
|
-
console.log(`[Compact] Calling ${url}`);
|
|
39
|
-
}
|
|
40
|
-
const body = {
|
|
41
|
-
compression_ratio: input.compressionRatio ?? 0.5,
|
|
42
|
-
preserve_recent: input.preserveRecent ?? 2,
|
|
43
|
-
model: input.model ?? "morph-compactor",
|
|
44
|
-
include_line_ranges: input.includeLineRanges ?? true,
|
|
45
|
-
include_markers: input.includeMarkers ?? true
|
|
46
|
-
};
|
|
47
|
-
if (input.query !== void 0) {
|
|
48
|
-
body.query = input.query;
|
|
49
|
-
}
|
|
50
|
-
if (input.messages) {
|
|
51
|
-
body.messages = input.messages;
|
|
52
|
-
} else if (typeof input.input === "string") {
|
|
53
|
-
body.input = input.input;
|
|
54
|
-
} else if (Array.isArray(input.input)) {
|
|
55
|
-
body.messages = input.input;
|
|
56
|
-
} else {
|
|
57
|
-
throw new Error("Either 'input' or 'messages' must be provided");
|
|
58
|
-
}
|
|
59
|
-
const startTime = Date.now();
|
|
60
|
-
const response = await fetch(url, {
|
|
61
|
-
method: "POST",
|
|
62
|
-
headers: {
|
|
63
|
-
"Authorization": `Bearer ${apiKey}`,
|
|
64
|
-
"Content-Type": "application/json"
|
|
65
|
-
},
|
|
66
|
-
body: JSON.stringify(body),
|
|
67
|
-
signal: AbortSignal.timeout(this.config.timeout)
|
|
68
|
-
});
|
|
69
|
-
if (!response.ok) {
|
|
70
|
-
const text = await response.text();
|
|
71
|
-
throw new Error(`Compact API error ${response.status}: ${text}`);
|
|
72
|
-
}
|
|
73
|
-
const data = await response.json();
|
|
74
|
-
if (debug) {
|
|
75
|
-
console.log(`[Compact] compact() done in ${Date.now() - startTime}ms`);
|
|
76
|
-
}
|
|
77
|
-
return data;
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export {
|
|
82
|
-
CompactClient
|
|
83
|
-
};
|
|
84
|
-
//# sourceMappingURL=chunk-SCVWDNQP.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../tools/compact/core.ts"],"sourcesContent":["/**\n * CompactClient — calls the Morph /v1/compact endpoint.\n *\n * Returns per-message compacted_line_ranges showing which lines were removed.\n */\n\nimport type { CompactConfig, CompactInput, CompactResult } from './types.js';\n\nconst DEFAULT_API_URL = 'https://api.morphllm.com';\nconst DEFAULT_TIMEOUT = 120000;\n\nexport class CompactClient {\n private config: Required<Pick<CompactConfig, 'morphApiUrl' | 'timeout'>> & CompactConfig;\n\n constructor(config: CompactConfig = {}) {\n this.config = {\n ...config,\n morphApiUrl: config.morphApiUrl ?? DEFAULT_API_URL,\n timeout: config.timeout ?? DEFAULT_TIMEOUT,\n };\n }\n\n /**\n * Compact messages or text via /v1/compact.\n * Returns per-message `compacted_line_ranges` showing which lines were removed.\n *\n * @example\n * ```typescript\n * const client = new CompactClient({ morphApiKey: 'sk-...' });\n * const result = await client.compact({\n * input: codeFile,\n * query: \"authentication\",\n * compressionRatio: 0.5,\n * });\n * console.log(result.output);\n * ```\n */\n async compact(input: CompactInput): Promise<CompactResult> {\n const apiKey = this.config.morphApiKey || (typeof process !== 'undefined' ? process.env?.MORPH_API_KEY : undefined);\n const debug = this.config.debug || false;\n\n if (!apiKey) {\n throw new Error(\n 'Morph API key not found. Set MORPH_API_KEY environment variable or pass morphApiKey in config.'\n );\n }\n\n const url = `${this.config.morphApiUrl}/v1/compact`;\n\n if (debug) {\n console.log(`[Compact] Calling ${url}`);\n }\n\n // Build request body with snake_case keys\n const body: Record<string, unknown> = {\n compression_ratio: input.compressionRatio ?? 0.5,\n preserve_recent: input.preserveRecent ?? 2,\n model: input.model ?? 'morph-compactor',\n include_line_ranges: input.includeLineRanges ?? true,\n include_markers: input.includeMarkers ?? true,\n };\n\n if (input.query !== undefined) {\n body.query = input.query;\n }\n\n // Normalize input: string → { input }, array → { messages }, messages field → { messages }\n if (input.messages) {\n body.messages = input.messages;\n } else if (typeof input.input === 'string') {\n body.input = input.input;\n } else if (Array.isArray(input.input)) {\n body.messages = input.input;\n } else {\n throw new Error(\"Either 'input' or 'messages' must be provided\");\n }\n\n const startTime = Date.now();\n\n const response = await fetch(url, {\n method: 'POST',\n headers: {\n 'Authorization': `Bearer ${apiKey}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(body),\n signal: AbortSignal.timeout(this.config.timeout),\n });\n\n if (!response.ok) {\n const text = await response.text();\n throw new Error(`Compact API error ${response.status}: ${text}`);\n }\n\n const data = await response.json() as Compact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L,YAAM,IAAI,MAAM,+CAA+C;AAAA,IACjE;AAEA,UAAM,YAAY,KAAK,IAAI;AAE3B,UAAM,WAAW,MAAM,MAAM,KAAK;AAAA,MAChC,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,iBAAiB,UAAU,MAAM;AAAA,QACjC,gBAAgB;AAAA,MAClB;AAAA,MACA,MAAM,KAAK,UAAU,IAAI;AAAA,MACzB,QAAQ,YAAY,QAAQ,KAAK,OAAO,OAAO;AAAA,IACjD,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AAChB,YAAM,OAAO,MAAM,SAAS,KAAK;AACjC,YAAM,IAAI,MAAM,qBAAqB,SAAS,MAAM,KAAK,IAAI,EAAE;AAAA,IACjE;AAEA,UAAM,OAAO,MAAM,SAAS,KAAK;AAEjC,QAAI,OAAO;AACT,cAAQ,IAAI,+BAA+B,KAAK,IAAI,IAAI,SAAS,IAAI;AAAA,IACvE;AAEA,WAAO;AAAA,EACT;AACF;","names":[]}
|
package/dist/chunk-VE7J6VYX.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
fetchWithRetry,
|
|
3
|
-
withTimeout
|
|
4
|
-
} from "./chunk-GPNUS3H2.js";
|
|
5
|
-
import {
|
|
6
|
-
logger
|
|
7
|
-
} from "./chunk-F3NCFNUX.js";
|
|
8
|
-
|
|
9
|
-
// tools/codebase_search/core.ts
|
|
10
|
-
var CodebaseSearchClient = class {
|
|
11
|
-
config;
|
|
12
|
-
constructor(config = {}) {
|
|
13
|
-
this.config = {
|
|
14
|
-
apiKey: config.apiKey,
|
|
15
|
-
searchUrl: process.env.MORPH_SEARCH_URL || "https://repos.morphllm.com",
|
|
16
|
-
debug: config.debug,
|
|
17
|
-
timeout: config.timeout || 3e4,
|
|
18
|
-
retryConfig: config.retryConfig
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Execute a semantic code search
|
|
23
|
-
*
|
|
24
|
-
* @param input - Search parameters including query, repoId, and target directories
|
|
25
|
-
* @param overrides - Optional config overrides for this operation
|
|
26
|
-
* @returns Search results with ranked code matches
|
|
27
|
-
*/
|
|
28
|
-
async search(input, overrides) {
|
|
29
|
-
return executeCodebaseSearch(
|
|
30
|
-
{
|
|
31
|
-
query: input.query,
|
|
32
|
-
target_directories: input.target_directories,
|
|
33
|
-
explanation: input.explanation,
|
|
34
|
-
limit: input.limit
|
|
35
|
-
},
|
|
36
|
-
{ ...this.config, repoId: input.repoId, ...overrides }
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
async function executeCodebaseSearch(input, config) {
|
|
41
|
-
const apiKey = config.apiKey || process.env.MORPH_API_KEY;
|
|
42
|
-
if (!apiKey) {
|
|
43
|
-
throw new Error("MORPH_API_KEY not found. Set environment variable or pass in config");
|
|
44
|
-
}
|
|
45
|
-
const searchUrl = config.searchUrl || process.env.MORPH_SEARCH_URL || "https://repos.morphllm.com";
|
|
46
|
-
const timeout = config.timeout || 3e4;
|
|
47
|
-
logger.debug("CodebaseSearch", "request", { query: input.query.slice(0, 100), repo_id: config.repoId, url: `${searchUrl}/v1/codebase_search` });
|
|
48
|
-
const startTime = Date.now();
|
|
49
|
-
try {
|
|
50
|
-
const fetchPromise = fetchWithRetry(
|
|
51
|
-
`${searchUrl}/v1/codebase_search`,
|
|
52
|
-
{
|
|
53
|
-
method: "POST",
|
|
54
|
-
headers: {
|
|
55
|
-
"Content-Type": "application/json",
|
|
56
|
-
"Authorization": `Bearer ${apiKey}`
|
|
57
|
-
},
|
|
58
|
-
body: JSON.stringify({
|
|
59
|
-
query: input.query,
|
|
60
|
-
repoId: config.repoId,
|
|
61
|
-
targetDirectories: input.target_directories || [],
|
|
62
|
-
limit: input.limit || 10,
|
|
63
|
-
candidateLimit: 50
|
|
64
|
-
})
|
|
65
|
-
},
|
|
66
|
-
config.retryConfig
|
|
67
|
-
);
|
|
68
|
-
const response = await withTimeout(fetchPromise, timeout, `Codebase search timed out after ${timeout}ms`);
|
|
69
|
-
if (!response.ok) {
|
|
70
|
-
const errorText = await response.text();
|
|
71
|
-
logger.error("CodebaseSearch", "response_error", { status: response.status, error: errorText, latency_ms: Date.now() - startTime });
|
|
72
|
-
return {
|
|
73
|
-
success: false,
|
|
74
|
-
results: [],
|
|
75
|
-
stats: { totalResults: 0, candidatesRetrieved: 0, searchTimeMs: 0 },
|
|
76
|
-
error: `Search failed (${response.status}): ${errorText}`
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
const data = await response.json();
|
|
80
|
-
const elapsed = Date.now() - startTime;
|
|
81
|
-
logger.debug("CodebaseSearch", "response", { results_count: data.results?.length || 0, latency_ms: elapsed });
|
|
82
|
-
return {
|
|
83
|
-
success: true,
|
|
84
|
-
results: data.results || [],
|
|
85
|
-
stats: data.stats || { totalResults: 0, candidatesRetrieved: 0, searchTimeMs: elapsed }
|
|
86
|
-
};
|
|
87
|
-
} catch (error) {
|
|
88
|
-
logger.error("CodebaseSearch", "exception", { error: error instanceof Error ? error.message : String(error), latency_ms: Date.now() - startTime });
|
|
89
|
-
return {
|
|
90
|
-
success: false,
|
|
91
|
-
results: [],
|
|
92
|
-
stats: { totalResults: 0, candidatesRetrieved: 0, searchTimeMs: 0 },
|
|
93
|
-
error: error instanceof Error ? error.message : "Unknown error"
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export {
|
|
99
|
-
CodebaseSearchClient,
|
|
100
|
-
executeCodebaseSearch
|
|
101
|
-
};
|
|
102
|
-
//# sourceMappingURL=chunk-VE7J6VYX.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../tools/codebase_search/core.ts"],"sourcesContent":["/**\n * Core implementation for codebase search\n * Calls Morph rerank service for two-stage semantic search\n */\n\nimport { fetchWithRetry, withTimeout } from '../utils/resilience.js';\nimport { logger } from '../../logger.js';\nimport type { CodebaseSearchConfig, CodebaseSearchInput, CodebaseSearchResult } from './types.js';\n\n/**\n * CodebaseSearch client for programmatic semantic search\n */\nexport class CodebaseSearchClient {\n private config: { \n apiKey?: string; \n searchUrl?: string; \n debug?: boolean; \n timeout?: number; \n retryConfig?: any;\n };\n\n constructor(config: { apiKey?: string; debug?: boolean; timeout?: number; retryConfig?: any } = {}) {\n this.config = {\n apiKey: config.apiKey,\n searchUrl: process.env.MORPH_SEARCH_URL || 'https://repos.morphllm.com',\n debug: config.debug,\n timeout: config.timeout || 30000,\n retryConfig: config.retryConfig,\n };\n }\n\n /**\n * Execute a semantic code search\n * \n * @param input - Search parameters including query, repoId, and target directories\n * @param overrides - Optional config overrides for this operation\n * @returns Search results with ranked code matches\n */\n async search(\n input: { query: string; repoId: string; target_directories?: string[]; explanation?: string; limit?: number },\n overrides?: any\n ): Promise<CodebaseSearchResult> {\n return executeCodebaseSearch(\n {\n query: input.query,\n target_directories: input.target_directories,\n explanation: input.explanation,\n limit: input.limit,\n },\n { ...this.config, repoId: input.repoId, ...overrides }\n );\n }\n}\n\n/**\n * Execute semantic code search\n */\nexport async function executeCodebaseSearch(\n input: CodebaseSearchInput,\n config: CodebaseSearchConfig\n): Promise<CodebaseSearchResult> {\n const apiKey = config.apiKey || process.env.MORPH_API_KEY;\n if (!apiKey) {\n throw new Error('MORPH_API_KEY not found. Set environment variable or pass in config');\n }\n\n const searchUrl = config.searchUrl || process.env.MORPH_SEARCH_URL || 'https://repos.morphllm.com';\n const timeout = config.timeout || 30000;\n\n logger.debug('CodebaseSearch', 'request', { query: input.query.slice(0, 100), repo_id: config.repoId, url: `${searchUrl}/v1/codebase_search` });\n\n const startTime = Date.now();\n\n try {\n const fetchPromise = fetchWithRetry(\n `${searchUrl}/v1/codebase_search`,\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${apiKey}`,\n },\n body: JSON.stringify({\n query: input.query,\n repoId: config.repoId,\n targetDirectories: input.target_directories || [],\n limit: input.limit || 10,\n candidateLimit: 50,\n }),\n },\n config.retryConfig\n );\n\n const response = await withTimeout(fetchPromise, timeout, `Codebase search timed out after ${timeout}ms`);\n\n if (!response.ok) {\n const errorText = await response.text();\n logger.error('CodebaseSearch', 'response_error', { status: response.status, error: errorText, latency_ms: Date.now() - startTime });\n return {\n success: false,\n results: [],\n stats: { totalResults: 0, candidatesRetrieved: 0, searchTimeMs: 0 },\n error: `Search failed (${response.status}): ${errorText}`,\n };\n }\n\n const data = await response.json();\n const elapsed = Date.now() - startTime;\n logger.debug('CodebaseSearch', 'response', { results_count: data.results?.length || 0, latency_ms: elapsed });\n\n return {\n success: true,\n results: data.results || [],\n stats: data.stats || { totalResults: 0, candidatesRetrieved: 0, searchTimeMs: elapsed },\n };\n\n } catch (error) {\n logger.error('CodebaseSearch', 'exception', { error: error instanceof Error ? error.message : String(error), latency_ms: Date.now() - startTime });\n return {\n success: false,\n results: [],\n stats: { totalResults: 0, candidatesRetrieved: 0, searchTimeMs: 0 },\n error: error instanceof Error ? error.message : 'Unknown error',\n };\n }\n}\n\n"],"mappings":";;;;;;;;;AAYO,IAAM,uBAAN,MAA2B;AAAA,EACxB;AAAA,EAQR,YAAY,SAAoF,CAAC,GAAG;AAClG,SAAK,SAAS;AAAA,MACZ,QAAQ,OAAO;AAAA,MACf,WAAW,QAAQ,IAAI,oBAAoB;AAAA,MAC3C,OAAO,OAAO;AAAA,MACd,SAAS,OAAO,WAAW;AAAA,MAC3B,aAAa,OAAO;AAAA,IACtB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,OACJ,OACA,WAC+B;AAC/B,WAAO;AAAA,MACL;AAAA,QACE,OAAO,MAAM;AAAA,QACb,oBAAoB,MAAM;AAAA,QAC1B,aAAa,MAAM;AAAA,QACnB,OAAO,MAAM;AAAA,MACf;AAAA,MACA,EAAE,GAAG,KAAK,QAAQ,QAAQ,MAAM,QAAQ,GAAG,UAAU;AAAA,IACvD;AAAA,EACF;AACF;AAK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KAAK;AACjC,UAAM,UAAU,KAAK,IAAI,IAAI;AAC7B,WAAO,MAAM,kBAAkB,YAAY,EAAE,eAAe,KAAK,SAAS,UAAU,GAAG,YAAY,QAAQ,CAAC;AAE5G,WAAO;AAAA,MACL,SAAS;AAAA,MACT,SAAS,KAAK,WAAW,CAAC;AAAA,MAC1B,OAAO,KAAK,SAAS,EAAE,cAAc,GAAG,qBAAqB,GAAG,cAAc,QAAQ;AAAA,IACxF;AAAA,EAEF,SAAS,OAAO;AACd,WAAO,MAAM,kBAAkB,aAAa,EAAE,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAAG,YAAY,KAAK,IAAI,IAAI,UAAU,CAAC;AACjJ,WAAO;AAAA,MACL,SAAS;AAAA,MACT,SAAS,CAAC;AAAA,MACV,OAAO,EAAE,cAAc,GAAG,qBAAqB,GAAG,cAAc,EAAE;AAAA,MAClE,OAAO,iBAAiB,QAAQ,MAAM,UAAU;AAAA,IAClD;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../tools/fastapply/apply.ts"],"sourcesContent":["/**\n * Edge-compatible code application API\n *\n * This module works on:\n * - Node.js\n * - Cloudflare Workers\n * - Vercel Edge Functions\n * - Deno Deploy\n * - Browser environments\n *\n * For file-based operations, use executeEditFile from core.ts\n */\n\nimport { createTwoFilesPatch } from 'diff';\nimport OpenAI from 'openai';\nimport { SDK_VERSION } from '../../version.js';\nimport { logger } from '../../logger.js';\nimport type {\n EditChanges,\n ApplyEditInput,\n ApplyEditResult,\n ApplyEditConfig,\n} from './types.js';\n\nconst DEFAULT_API_URL = 'https://api.morphllm.com';\nconst DEFAULT_TIMEOUT = 90000;\n\n/**\n * Generate a unified diff between two strings\n */\nexport function generateUdiff(\n original: string,\n modified: string,\n filepath: string\n): string {\n return createTwoFilesPatch(\n filepath,\n filepath,\n original,\n modified,\n 'Original',\n 'Modified'\n );\n}\n\n/**\n * Count changes from a unified diff\n */\nexport function countChanges(original: string, modified: string): EditChanges {\n const diff = generateUdiff(original, modified, 'file');\n const lines = diff.split('\\n');\n\n let linesAdded = 0;\n let linesRemoved = 0;\n\n for (const line of lines) {\n if (line.startsWith('+') && !line.startsWith('+++')) {\n linesAdded++;\n } else if (line.startsWith('-') && !line.startsWith('---')) {\n linesRemoved++;\n }\n }\n\n const linesModified = Math.min(linesAdded, linesRemoved);\n\n return {\n linesAdded: linesAdded - linesModified,\n linesRemoved: linesRemoved - linesModified,\n linesModified,\n };\n}\n\n/**\n * Call Morph Apply API to merge code edits\n * Uses OpenAI SDK for reliable connection handling, retries, and timeouts\n */\nexport async function callMorphAPI(\n originalCode: string,\n codeEdit: string,\n instructions: string,\n filepath: string,\n config: ApplyEditConfig\n): Promise<{ content: string; completionId?: string }> {\n const apiKey = config.morphApiKey || (typeof process !== 'undefined' ? process.env?.MORPH_API_KEY : undefined);\n const apiUrl = config.morphApiUrl || DEFAULT_API_URL;\n const useLarge = config.large ?? (typeof process !== 'undefined' ? process.env?.MORPH_LARGE_APPLY !== 'false' : true);\n const model = useLarge ? 'morph-v3-large' : 'morph-v3-fast';\n const timeout = config.timeout || DEFAULT_TIMEOUT;\n const debug = config.debug || false;\n\n if (!apiKey) {\n throw new Error(\n 'Morph API key not found. Set MORPH_API_KEY environment variable or pass morphApiKey in config.'\n );\n }\n\n // Format message with XML tags as per Morph Fast Apply spec\n const message = `<instruction>${instructions}</instruction>\\n<code>${originalCode}</code>\\n<update>${codeEdit}</update>`;\n\n logger.debug('FastApply', 'http_request', {\n url: `${apiUrl}/v1/chat/completions`,\n model,\n filepath,\n instruction_len: instructions.length,\n original_len: originalCode.length,\n code_edit_len: codeEdit.length,\n });\n\n const startTime = Date.now();\n\n const client = new OpenAI({\n apiKey,\n baseURL: `${apiUrl}/v1`,\n timeout,\n maxRetries: config.retryConfig?.maxRetries ?? 3,\n defaultHeaders: { 'X-Morph-SDK-Version': SDK_VERSION },\n });\n\n try {\n const completion = await client.chat.completions.create({\n model,\n messages: [{ role: 'user', content: message }],\n });\n\n const content = completion.choices[0]?.message?.content;\n if (!content) {\n throw new Error('Morph API returned empty response');\n }\n\n const elapsed = Date.now() - startTime;\n logger.debug('FastApply', 'http_response', { status: 200, completion_id: completion.id, content_len: content.length, latency_ms: elapsed });\n\n return { content, completionId: completion.id };\n } catch (error: any) {\n const elapsed = Date.now() - startTime;\n logger.error('FastApply', 'http_error', {\n status: error?.status || error?.response?.status,\n error: error?.message,\n latency_ms: elapsed,\n });\n throw error;\n }\n}\n\n/**\n * Apply an edit to code directly without file I/O\n *\n * This is the edge-compatible code-in/code-out API that accepts code content directly\n * and returns the merged result without reading or writing any files.\n *\n * Works on Cloudflare Workers, Vercel Edge Functions, Deno, and browsers.\n *\n * @param input - Code and edit parameters\n * @param config - Optional configuration\n * @returns Result with merged code\n *\n * @example\n * ```typescript\n * import { applyEdit } from '@morphllm/morphsdk';\n *\n * const result = await applyEdit({\n * originalCode: fs.readFileSync('file.ts', 'utf-8'),\n * codeEdit: '// ... existing code ...\\nconst newVar = 42;\\n// ... existing code ...',\n * instructions: 'Add a new variable',\n * // filepath is accepted but does nothing\n * });\n *\n * if (result.success) {\n * fs.writeFileSync('file.ts', result.mergedCode);\n * }\n * ```\n */\nexport async function applyEdit(\n input: ApplyEditInput,\n config: ApplyEditConfig = {}\n): Promise<ApplyEditResult> {\n const filepath = input.filepath || 'file';\n\n try {\n logger.debug('FastApply', 'apply_edit_start', { original_len: input.originalCode.length, code_edit_len: input.codeEdit.length });\n\n const instruction = input.instruction ?? input.instructions ?? '';\n const { content: mergedCode, completionId } = await callMorphAPI(\n input.originalCode,\n input.codeEdit,\n instruction,\n filepath,\n config\n );\n\n const udiff = config.generateUdiff !== false\n ? generateUdiff(input.originalCode, mergedCode, filepath)\n : undefined;\n\n const changes = countChanges(input.originalCode, mergedCode);\n\n return {\n success: true,\n mergedCode,\n udiff,\n changes,\n completionId,\n };\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';\n logger.error('FastApply', 'apply_edit_error', { error: errorMessage });\n\n return {\n success: false,\n changes: { linesAdded: 0, linesRemoved: 0, linesModified: 0 },\n error: errorMessage,\n };\n }\n}\n"],"mappings":";;;;;;;;AAaA,SAAS,2BAA2B;AACpC,OAAO,YAAY;AAUnB,IAAM,kBAAkB;AACxB,IAAM,kBAAkB;AAKjB,SAAS,cACd,UACA,UACA,UACQ;AACR,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAKO,SAAS,aAAa,UAAkB,UAA+B;AAC5E,QAAM,OAAO,cAAc,UAAU,UAAU,MAAM;AACrD,QAAM,QAAQ,KAAK,MAAM,IAAI;AAE7B,MAAI,aAAa;AACjB,MAAI,eAAe;AAEnB,aAAW,QAAQ,OAAO;AACxB,QAAI,KAAK,WAAW,GAAG,KAAK,CAAC,KAAK,WAAW,KAAK,GAAG;AACnD;AAAA,IACF,WAAW,KAAK,WAAW,GAAG,KAAK,CAAC,KAAK,WAAW,KAAK,GAAG;AAC1D;AAAA,IACF;AAAA,EACF;AAEA,QAAM,gBAAgB,KAAK,IAAI,YAAY,YAAY;AAEvD,SAAO;AAAA,IACL,YAAY,aAAa;AAAA,IACzB,cAAc,eAAe;AAAA,IAC7B;AAAA,EACF;AACF;AAMA,eAAsB,aACpB,cACA,UACA,cACA,UACA,QACqD;AACrD,QAAM,SAAS,OAAO,gBAAgB,OAAO,YAAY,cAAc,QAAQ,KAAK,gBAAgB;AACpG,QAAM,SAAS,OAAO,eAAe;AACrC,QAAM,WAAW,OAAO,UAAU,OAAO,YAAY,cAAc,QAAQ,KAAK,sBAAsB,UAAU;AAChH,QAAM,QAAQ,WAAW,mBAAmB;AAC5C,QAAM,UAAU,OAAO,WAAW;AAClC,QAAM,QAAQ,OAAO,SAAS;AAE9B,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;A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AO,MAAM,aAAa,oBAAoB,EAAE,cAAc,MAAM,aAAa,QAAQ,eAAe,MAAM,SAAS,OAAO,CAAC;AAE/H,UAAM,cAAc,MAAM,eAAe,MAAM,gBAAgB;AAC/D,UAAM,EAAE,SAAS,YAAY,aAAa,IAAI,MAAM;AAAA,MAClD,MAAM;AAAA,MACN,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAEA,UAAM,QAAQ,OAAO,kBAAkB,QACnC,cAAc,MAAM,cAAc,YAAY,QAAQ,IACtD;AAEJ,UAAM,UAAU,aAAa,MAAM,cAAc,UAAU;AAE3D,WAAO;AAAA,MACL,SAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF,SAAS,OAAO;AACd,UAAM,eAAe,iBAAiB,QAAQ,MAAM,UAAU;AAC9D,WAAO,MAAM,aAAa,oBAAoB,EAAE,OAAO,aAAa,CAAC;AAErE,WAAO;AAAA,MACL,SAAS;AAAA,MACT,SAAS,EAAE,YAAY,GAAG,cAAc,GAAG,eAAe,EAAE;AAAA,MAC5D,OAAO;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|