@morphllm/morphsdk 0.2.38 → 0.2.40
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-AKVAAKRB.js → chunk-3NTGAUTJ.js} +73 -2
- package/dist/chunk-3NTGAUTJ.js.map +1 -0
- package/dist/{chunk-TBVDBQZ2.js → chunk-4WIBODS7.js} +61 -3
- package/dist/chunk-4WIBODS7.js.map +1 -0
- package/dist/{chunk-LN4CTQZG.js → chunk-7MCSSJJA.js} +2 -2
- package/dist/{chunk-DJSQUQGY.js → chunk-DIWNR3UP.js} +3 -3
- package/dist/{chunk-W5CHJ6OX.js → chunk-JSZQVUSE.js} +2 -2
- package/dist/{chunk-YSBSDU75.js → chunk-LUI7APXX.js} +2 -2
- package/dist/{chunk-EAA7D24N.js → chunk-N5654KQR.js} +13 -13
- package/dist/client.cjs +60 -2
- package/dist/client.cjs.map +1 -1
- package/dist/client.js +3 -3
- package/dist/git/client.cjs +60 -2
- package/dist/git/client.cjs.map +1 -1
- package/dist/git/client.js +1 -1
- package/dist/git/index.cjs +60 -2
- package/dist/git/index.cjs.map +1 -1
- package/dist/git/index.js +1 -1
- package/dist/git/types.cjs.map +1 -1
- package/dist/index.cjs +60 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -3
- package/dist/modelrouter/core.cjs +74 -2
- package/dist/modelrouter/core.cjs.map +1 -1
- package/dist/modelrouter/core.js +5 -3
- package/dist/modelrouter/index.cjs +74 -2
- package/dist/modelrouter/index.cjs.map +1 -1
- package/dist/modelrouter/index.js +5 -3
- package/dist/modelrouter/types.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/runner.js +5 -5
- package/dist/tools/warp_grep/anthropic.js +6 -6
- package/dist/tools/warp_grep/index.js +8 -8
- package/dist/tools/warp_grep/openai.js +6 -6
- package/dist/tools/warp_grep/vercel.js +6 -6
- package/package.json +1 -1
- package/dist/anthropic-DpEAqqZF.d.ts +0 -88
- package/dist/chunk-AKVAAKRB.js.map +0 -1
- package/dist/chunk-TBVDBQZ2.js.map +0 -1
- package/dist/client.d.ts +0 -114
- package/dist/git/client.d.ts +0 -261
- package/dist/git/config.d.ts +0 -11
- package/dist/git/index.d.ts +0 -5
- package/dist/git/types.d.ts +0 -102
- package/dist/index.d.ts +0 -14
- package/dist/modelrouter/core.d.ts +0 -56
- package/dist/modelrouter/index.d.ts +0 -2
- package/dist/modelrouter/types.d.ts +0 -35
- package/dist/openai-BkKsS30n.d.ts +0 -111
- package/dist/tools/browser/anthropic.d.ts +0 -51
- package/dist/tools/browser/core.d.ts +0 -203
- package/dist/tools/browser/index.d.ts +0 -72
- package/dist/tools/browser/openai.d.ts +0 -73
- package/dist/tools/browser/prompts.d.ts +0 -7
- package/dist/tools/browser/types.d.ts +0 -255
- package/dist/tools/browser/vercel.d.ts +0 -69
- package/dist/tools/codebase_search/anthropic.d.ts +0 -40
- package/dist/tools/codebase_search/core.d.ts +0 -40
- package/dist/tools/codebase_search/index.d.ts +0 -10
- package/dist/tools/codebase_search/openai.d.ts +0 -87
- package/dist/tools/codebase_search/prompts.d.ts +0 -7
- package/dist/tools/codebase_search/types.d.ts +0 -50
- package/dist/tools/codebase_search/vercel.d.ts +0 -65
- package/dist/tools/fastapply/anthropic.d.ts +0 -4
- package/dist/tools/fastapply/core.d.ts +0 -41
- package/dist/tools/fastapply/index.d.ts +0 -10
- package/dist/tools/fastapply/openai.d.ts +0 -4
- package/dist/tools/fastapply/prompts.d.ts +0 -7
- package/dist/tools/fastapply/types.d.ts +0 -77
- package/dist/tools/fastapply/vercel.d.ts +0 -4
- package/dist/tools/index.d.ts +0 -10
- package/dist/tools/utils/resilience.d.ts +0 -58
- package/dist/tools/warp_grep/agent/config.d.ts +0 -8
- package/dist/tools/warp_grep/agent/formatter.d.ts +0 -14
- package/dist/tools/warp_grep/agent/grep_helpers.d.ts +0 -16
- package/dist/tools/warp_grep/agent/parser.d.ts +0 -16
- package/dist/tools/warp_grep/agent/prompt.d.ts +0 -4
- package/dist/tools/warp_grep/agent/runner.d.ts +0 -10
- package/dist/tools/warp_grep/agent/types.d.ts +0 -44
- package/dist/tools/warp_grep/anthropic.d.ts +0 -14
- package/dist/tools/warp_grep/index.d.ts +0 -11
- package/dist/tools/warp_grep/openai.d.ts +0 -33
- package/dist/tools/warp_grep/providers/command.d.ts +0 -48
- package/dist/tools/warp_grep/providers/local.d.ts +0 -30
- package/dist/tools/warp_grep/providers/types.d.ts +0 -49
- package/dist/tools/warp_grep/tools/analyse.d.ts +0 -10
- package/dist/tools/warp_grep/tools/finish.d.ts +0 -10
- package/dist/tools/warp_grep/tools/grep.d.ts +0 -8
- package/dist/tools/warp_grep/tools/read.d.ts +0 -9
- package/dist/tools/warp_grep/utils/files.d.ts +0 -3
- package/dist/tools/warp_grep/utils/format.d.ts +0 -4
- package/dist/tools/warp_grep/utils/paths.d.ts +0 -7
- package/dist/tools/warp_grep/utils/ripgrep.d.ts +0 -11
- package/dist/tools/warp_grep/vercel.d.ts +0 -33
- package/dist/vercel-B1GZ_g9N.d.ts +0 -69
- /package/dist/{chunk-LN4CTQZG.js.map → chunk-7MCSSJJA.js.map} +0 -0
- /package/dist/{chunk-DJSQUQGY.js.map → chunk-DIWNR3UP.js.map} +0 -0
- /package/dist/{chunk-W5CHJ6OX.js.map → chunk-JSZQVUSE.js.map} +0 -0
- /package/dist/{chunk-YSBSDU75.js.map → chunk-LUI7APXX.js.map} +0 -0
- /package/dist/{chunk-EAA7D24N.js.map → chunk-N5654KQR.js.map} +0 -0
|
@@ -127,10 +127,81 @@ var GeminiRouter = class extends BaseRouter {
|
|
|
127
127
|
return super.selectModel(input);
|
|
128
128
|
}
|
|
129
129
|
};
|
|
130
|
+
var RawRouter = class extends BaseRouter {
|
|
131
|
+
constructor(config = {}) {
|
|
132
|
+
super("raw", config);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Get raw difficulty classification
|
|
136
|
+
*
|
|
137
|
+
* @param input - User input and mode
|
|
138
|
+
* @returns Raw difficulty (easy | medium | hard | needs-info)
|
|
139
|
+
*/
|
|
140
|
+
async classify(input) {
|
|
141
|
+
const mode = input.mode || "balanced";
|
|
142
|
+
const apiKey = this.config.apiKey || process.env.MORPH_API_KEY;
|
|
143
|
+
if (!apiKey) {
|
|
144
|
+
throw new Error(
|
|
145
|
+
"Morph API key is required. Set MORPH_API_KEY environment variable or pass apiKey in config."
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
const url = `${this.config.apiUrl}/v1/router/raw`;
|
|
149
|
+
const payload = {
|
|
150
|
+
input: input.input,
|
|
151
|
+
mode
|
|
152
|
+
};
|
|
153
|
+
if (this.config.debug) {
|
|
154
|
+
console.log(`[RawRouter] Requesting raw difficulty classification:`, {
|
|
155
|
+
mode,
|
|
156
|
+
inputLength: input.input.length
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
try {
|
|
160
|
+
const fetchPromise = fetchWithRetry(
|
|
161
|
+
url,
|
|
162
|
+
{
|
|
163
|
+
method: "POST",
|
|
164
|
+
headers: {
|
|
165
|
+
"Content-Type": "application/json",
|
|
166
|
+
Authorization: `Bearer ${apiKey}`
|
|
167
|
+
},
|
|
168
|
+
body: JSON.stringify(payload)
|
|
169
|
+
},
|
|
170
|
+
this.config.retryConfig
|
|
171
|
+
);
|
|
172
|
+
const response = await withTimeout(
|
|
173
|
+
fetchPromise,
|
|
174
|
+
this.config.timeout,
|
|
175
|
+
`Router API request timed out after ${this.config.timeout}ms`
|
|
176
|
+
);
|
|
177
|
+
if (!response.ok) {
|
|
178
|
+
const errorText = await response.text();
|
|
179
|
+
throw new Error(
|
|
180
|
+
`Router API error (${response.status}): ${errorText || response.statusText}`
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
const apiResult = await response.json();
|
|
184
|
+
const difficulty = apiResult.difficulty || apiResult.model;
|
|
185
|
+
const result = {
|
|
186
|
+
difficulty
|
|
187
|
+
};
|
|
188
|
+
if (this.config.debug) {
|
|
189
|
+
console.log(`[RawRouter] Classified as: ${difficulty}`);
|
|
190
|
+
}
|
|
191
|
+
return result;
|
|
192
|
+
} catch (error) {
|
|
193
|
+
if (this.config.debug) {
|
|
194
|
+
console.error(`[RawRouter] Error classifying:`, error);
|
|
195
|
+
}
|
|
196
|
+
throw error;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
};
|
|
130
200
|
|
|
131
201
|
export {
|
|
132
202
|
OpenAIRouter,
|
|
133
203
|
AnthropicRouter,
|
|
134
|
-
GeminiRouter
|
|
204
|
+
GeminiRouter,
|
|
205
|
+
RawRouter
|
|
135
206
|
};
|
|
136
|
-
//# sourceMappingURL=chunk-
|
|
207
|
+
//# sourceMappingURL=chunk-3NTGAUTJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../modelrouter/core.ts"],"sourcesContent":["/**\n * Core implementation for intelligent model routing\n */\n\nimport { fetchWithRetry, withTimeout } from '../tools/utils/resilience.js';\nimport type {\n RouterConfig,\n RouterInput,\n RouterResult,\n RawRouterResult,\n ComplexityLevel,\n RouterMode,\n Provider,\n} from './types.js';\n\nconst DEFAULT_CONFIG = {\n apiUrl: 'https://api.morphllm.com',\n timeout: 5000, // 5 seconds (responses typically <500ms)\n debug: false,\n};\n\nabstract class BaseRouter {\n protected config: Required<Omit<RouterConfig, 'apiKey' | 'retryConfig'>> & Pick<RouterConfig, 'apiKey' | 'retryConfig'>;\n protected provider: Provider;\n\n constructor(provider: Provider, config: RouterConfig = {}) {\n this.provider = provider;\n this.config = {\n apiKey: config.apiKey,\n apiUrl: config.apiUrl || DEFAULT_CONFIG.apiUrl,\n timeout: config.timeout || DEFAULT_CONFIG.timeout,\n debug: config.debug || DEFAULT_CONFIG.debug,\n retryConfig: config.retryConfig,\n };\n }\n\n /**\n * Select the optimal model for a given input and mode\n */\n async selectModel(input: RouterInput): Promise<RouterResult> {\n const mode = input.mode || 'balanced';\n const apiKey = this.config.apiKey || process.env.MORPH_API_KEY;\n\n if (!apiKey) {\n throw new Error(\n 'Morph API key is required. Set MORPH_API_KEY environment variable or pass apiKey in config.'\n );\n }\n\n const url = `${this.config.apiUrl}/v1/router/${this.provider}`;\n const payload = {\n input: input.input,\n mode,\n };\n\n if (this.config.debug) {\n console.log(`[ModelRouter] Requesting ${this.provider} model selection:`, {\n mode,\n inputLength: input.input.length,\n });\n }\n\n try {\n const fetchPromise = fetchWithRetry(\n url,\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${apiKey}`,\n },\n body: JSON.stringify(payload),\n },\n this.config.retryConfig\n );\n\n const response = await withTimeout(\n fetchPromise,\n this.config.timeout,\n `Router API request timed out after ${this.config.timeout}ms`\n );\n\n if (!response.ok) {\n const errorText = await response.text();\n throw new Error(\n `Router API error (${response.status}): ${errorText || response.statusText}`\n );\n }\n\n const apiResult: { model: string; confidence?: number } = await response.json();\n\n const result: RouterResult = {\n model: apiResult.model,\n };\n\n if (this.config.debug) {\n console.log(`[ModelRouter] Selected model: ${apiResult.model}, Confidence: ${apiResult.confidence?.toFixed(3)}`);\n }\n\n return result;\n } catch (error) {\n if (this.config.debug) {\n console.error(`[ModelRouter] Error selecting model:`, error);\n }\n throw error;\n }\n }\n}\n\n/**\n * OpenAI model router for GPT-5 series\n */\nexport class OpenAIRouter extends BaseRouter {\n constructor(config: RouterConfig = {}) {\n super('openai', config);\n }\n\n /**\n * Select optimal GPT-5 model\n * \n * @param input - User input and mode\n * @returns Selected model name (gpt-5-mini | gpt-5-low | gpt-5-medium | gpt-5-high)\n */\n async selectModel(input: RouterInput): Promise<RouterResult> {\n return super.selectModel(input);\n }\n}\n\n/**\n * Anthropic model router for Claude 4.5 series\n */\nexport class AnthropicRouter extends BaseRouter {\n constructor(config: RouterConfig = {}) {\n super('anthropic', config);\n }\n\n /**\n * Select optimal Claude model\n * \n * @param input - User input and mode\n * @returns Selected model name (claude-4.5-haiku | claude-4.5-sonnet)\n */\n async selectModel(input: RouterInput): Promise<RouterResult> {\n return super.selectModel(input);\n }\n}\n\n/**\n * Google Gemini model router\n */\nexport class GeminiRouter extends BaseRouter {\n constructor(config: RouterConfig = {}) {\n super('gemini', config);\n }\n\n /**\n * Select optimal Gemini model\n * \n * @param input - User input and mode\n * @returns Selected model name (gemini-2.5-flash | gemini-2.5-pro)\n */\n async selectModel(input: RouterInput): Promise<RouterResult> {\n return super.selectModel(input);\n }\n}\n\n/**\n * Raw difficulty classification router (no provider-specific mapping)\n */\nexport class RawRouter extends BaseRouter {\n constructor(config: RouterConfig = {}) {\n super('raw' as Provider, config);\n }\n\n /**\n * Get raw difficulty classification\n * \n * @param input - User input and mode\n * @returns Raw difficulty (easy | medium | hard | needs-info)\n */\n async classify(input: RouterInput): Promise<RawRouterResult> {\n const mode = input.mode || 'balanced';\n const apiKey = this.config.apiKey || process.env.MORPH_API_KEY;\n\n if (!apiKey) {\n throw new Error(\n 'Morph API key is required. Set MORPH_API_KEY environment variable or pass apiKey in config.'\n );\n }\n\n const url = `${this.config.apiUrl}/v1/router/raw`;\n const payload = {\n input: input.input,\n mode,\n };\n\n if (this.config.debug) {\n console.log(`[RawRouter] Requesting raw difficulty classification:`, {\n mode,\n inputLength: input.input.length,\n });\n }\n\n try {\n const fetchPromise = fetchWithRetry(\n url,\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${apiKey}`,\n },\n body: JSON.stringify(payload),\n },\n this.config.retryConfig\n );\n\n const response = await withTimeout(\n fetchPromise,\n this.config.timeout,\n `Router API request timed out after ${this.config.timeout}ms`\n );\n\n if (!response.ok) {\n const errorText = await response.text();\n throw new Error(\n `Router API error (${response.status}): ${errorText || response.statusText}`\n );\n }\n\n const apiResult: { model?: string; difficulty?: string; confidence?: number } = await response.json();\n\n // Support both 'model' and 'difficulty' fields for compatibility\n const difficulty = (apiResult.difficulty || apiResult.model) as ComplexityLevel;\n\n const result: RawRouterResult = {\n difficulty,\n };\n\n if (this.config.debug) {\n console.log(`[RawRouter] Classified as: ${difficulty}`);\n }\n\n return result;\n } catch (error) {\n if (this.config.debug) {\n console.error(`[RawRouter] Error classifying:`, error);\n }\n throw error;\n }\n }\n}\n"],"mappings":";;;;;;AAeA,IAAM,iBAAiB;AAAA,EACrB,QAAQ;AAAA,EACR,SAAS;AAAA;AAAA,EACT,OAAO;AACT;AAEA,IAAe,aAAf,MAA0B;AAAA,EACd;AAAA,EACA;AAAA,EAEV,YAAY,UAAoB,SAAuB,CAAC,GAAG;AACzD,SAAK,WAAW;AAChB,SAAK,SAAS;AAAA,MACZ,QAAQ,OAAO;AAAA,MACf,QAAQ,OAAO,UAAU,eAAe;AAAA,MACxC,SAAS,OAAO,WAAW,eAAe;AAAA,MAC1C,OAAO,OAAO,SAAS,eAAe;AAAA,MACtC,aAAa,OAAO;AAAA,IACtB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,YAAY,OAA2C;AAC3D,UAAM,OAAO,MAAM,QAAQ;AAC3B,UAAM,SAAS,KAAK,OAAO,UAAU,QAAQ,IAAI;AAEjD,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,UAAM,MAAM,GAAG,KAAK,OAAO,MAAM,cAAc,KAAK,QAAQ;AAC5D,UAAM,UAAU;AAAA,MACd,OAAO,MAAM;AAAA,MACb;AAAA,IACF;AAEA,QAAI,KAAK,OAAO,OAAO;AACrB,cAAQ,IAAI,4BAA4B,KAAK,QAAQ,qBAAqB;AAAA,QACxE;AAAA,QACA,aAAa,MAAM,MAAM;AAAA,MAC3B,CAAC;AAAA,IACH;AAEA,QAAI;AACF,YAAM,eAAe;AAAA,QACnB;AAAA,QACA;AAAA,UACE,QAAQ;AAAA,UACR,SAAS;AAAA,YACP,gBAAgB;AAAA,YAChB,eAAe,UAAU,MAAM;AAAA,UACjC;AAAA,UACA,MAAM,KAAK,UAAU,OAAO;AAAA,QAC9B;AAAA,QACA,KAAK,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AAc,UAAU;AAEtD,YAAM,SAA0B;AAAA,QAC9B;AAAA,MACF;AAEA,UAAI,KAAK,OAAO,OAAO;AACrB,gBAAQ,IAAI,8BAA8B,UAAU,EAAE;AAAA,MACxD;AAEA,aAAO;AAAA,IACT,SAAS,OAAO;AACd,UAAI,KAAK,OAAO,OAAO;AACrB,gBAAQ,MAAM,kCAAkC,KAAK;AAAA,MACvD;AACA,YAAM;AAAA,IACR;AAAA,EACF;AACF;","names":[]}
|
|
@@ -87,7 +87,6 @@ var MorphGit = class {
|
|
|
87
87
|
fs,
|
|
88
88
|
http,
|
|
89
89
|
dir,
|
|
90
|
-
corsProxy: this.proxyUrl,
|
|
91
90
|
url: `${this.proxyUrl}/v1/repos/${repoId}`,
|
|
92
91
|
ref: branch,
|
|
93
92
|
singleBranch,
|
|
@@ -107,12 +106,25 @@ var MorphGit = class {
|
|
|
107
106
|
* ```
|
|
108
107
|
*/
|
|
109
108
|
async push(options) {
|
|
110
|
-
const { dir, remote = "origin", branch } = options;
|
|
109
|
+
const { dir, remote = "origin", branch, waitForEmbeddings } = options;
|
|
111
110
|
if (!branch) {
|
|
112
111
|
throw new Error(
|
|
113
112
|
'branch is required for push operations. Specify the branch explicitly: { dir: "./my-project", branch: "main" }'
|
|
114
113
|
);
|
|
115
114
|
}
|
|
115
|
+
let commitHash;
|
|
116
|
+
let repoId;
|
|
117
|
+
if (waitForEmbeddings) {
|
|
118
|
+
commitHash = await git.resolveRef({ fs, dir, ref: "HEAD" });
|
|
119
|
+
const remotes = await git.listRemotes({ fs, dir });
|
|
120
|
+
const originRemote = remotes.find((r) => r.remote === remote);
|
|
121
|
+
if (originRemote) {
|
|
122
|
+
const match = originRemote.url.match(/\/repos\/([^\/]+)$/);
|
|
123
|
+
if (match) {
|
|
124
|
+
repoId = match[1];
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
116
128
|
await git.push({
|
|
117
129
|
fs,
|
|
118
130
|
http,
|
|
@@ -121,6 +133,9 @@ var MorphGit = class {
|
|
|
121
133
|
ref: branch,
|
|
122
134
|
onAuth: this.getAuthCallback()
|
|
123
135
|
});
|
|
136
|
+
if (waitForEmbeddings && repoId && commitHash) {
|
|
137
|
+
await this.waitForEmbeddings({ repoId, commitHash });
|
|
138
|
+
}
|
|
124
139
|
}
|
|
125
140
|
/**
|
|
126
141
|
* Pull changes from remote repository
|
|
@@ -153,6 +168,49 @@ var MorphGit = class {
|
|
|
153
168
|
}
|
|
154
169
|
});
|
|
155
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Wait for embeddings to complete after push.
|
|
173
|
+
* Polls status endpoint until embeddings are done.
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```ts
|
|
177
|
+
* await morphGit.push({ dir: './my-project', branch: 'main' });
|
|
178
|
+
* await morphGit.waitForEmbeddings({
|
|
179
|
+
* repoId: 'my-project',
|
|
180
|
+
* onProgress: (p) => console.log(`${p.filesProcessed}/${p.totalFiles}`)
|
|
181
|
+
* });
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
async waitForEmbeddings(options) {
|
|
185
|
+
const { repoId, commitHash, timeout = 12e4, onProgress } = options;
|
|
186
|
+
const startTime = Date.now();
|
|
187
|
+
const pollInterval = 1e3;
|
|
188
|
+
while (Date.now() - startTime < timeout) {
|
|
189
|
+
const statusUrl = `${this.proxyUrl}/v1/repos/${repoId}/embedding-status` + (commitHash ? `?commit_hash=${commitHash}` : "");
|
|
190
|
+
const response = await fetch(statusUrl, {
|
|
191
|
+
headers: { "Authorization": `Bearer ${this.apiKey}` }
|
|
192
|
+
});
|
|
193
|
+
if (response.status === 404) {
|
|
194
|
+
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
if (!response.ok) {
|
|
198
|
+
throw new Error(`Failed to get embedding status: ${response.status}`);
|
|
199
|
+
}
|
|
200
|
+
const status = await response.json();
|
|
201
|
+
if (onProgress && status.progress) {
|
|
202
|
+
onProgress(status.progress);
|
|
203
|
+
}
|
|
204
|
+
if (status.status === "completed") {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
if (status.status === "failed") {
|
|
208
|
+
throw new Error(`Embeddings failed: ${status.error || "Unknown error"}`);
|
|
209
|
+
}
|
|
210
|
+
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
211
|
+
}
|
|
212
|
+
throw new Error(`Embeddings timed out after ${timeout}ms`);
|
|
213
|
+
}
|
|
156
214
|
/**
|
|
157
215
|
* Stage a file for commit
|
|
158
216
|
*
|
|
@@ -456,4 +514,4 @@ var MorphGit = class {
|
|
|
456
514
|
export {
|
|
457
515
|
MorphGit
|
|
458
516
|
};
|
|
459
|
-
//# sourceMappingURL=chunk-
|
|
517
|
+
//# sourceMappingURL=chunk-4WIBODS7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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\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 CommitMetadata,\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 * });\n * ```\n */\n async push(options: PushOptions): Promise<void> {\n const { dir, remote = 'origin', branch, waitForEmbeddings } = 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 (for waitForEmbeddings)\n let commitHash: string | undefined;\n let repoId: string | undefined;\n \n if (waitForEmbeddings) {\n commitHash = await git.resolveRef({ fs, dir, ref: 'HEAD' });\n \n // Get repoId from git remote URL\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\n await git.push({\n fs,\n http,\n dir,\n remote,\n ref: branch,\n onAuth: this.getAuthCallback(),\n });\n \n // Wait for embeddings if requested\n if (waitForEmbeddings && repoId && commitHash) {\n await this.waitForEmbeddings({ repoId, commitHash });\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 * 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, 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 metadata as git note if provided\n if (chatHistory || recordingId) {\n const metadata: CommitMetadata = {\n chatHistory,\n recordingId\n };\n \n await git.addNote({\n fs,\n dir,\n ref: 'refs/notes/morph-metadata',\n oid: sha,\n note: JSON.stringify(metadata, 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 metadata (chat history, recording ID) attached to a commit\n * \n * @example\n * ```ts\n * const metadata = await morphGit.getCommitMetadata({\n * dir: './my-project',\n * commitSha: 'abc123...'\n * });\n * \n * if (metadata) {\n * console.log('Chat history:', metadata.chatHistory);\n * console.log('Recording ID:', metadata.recordingId);\n * }\n * ```\n */\n async getCommitMetadata(options: {\n dir: string;\n commitSha: string;\n }): Promise<CommitMetadata | 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 metadata = JSON.parse(new TextDecoder().decode(note));\n return metadata;\n } catch (err) {\n // No metadata found for this commit\n return null;\n }\n }\n}\n\n"],"mappings":";AAKA,OAAO,SAAS;AAChB,OAAO,UAAU;AACjB,OAAO,QAAQ;AAkBf,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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A,EAkBA,MAAM,kBAAkB,SAGW;AACjC,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,WAAW,KAAK,MAAM,IAAI,YAAY,EAAE,OAAO,IAAI,CAAC;AAC1D,aAAO;AAAA,IACT,SAAS,KAAK;AAEZ,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runWarpGrep
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-N5654KQR.js";
|
|
4
4
|
import {
|
|
5
5
|
LocalRipgrepProvider
|
|
6
6
|
} from "./chunk-UYBIKZPM.js";
|
|
@@ -53,4 +53,4 @@ function createMorphWarpGrepTool(config) {
|
|
|
53
53
|
export {
|
|
54
54
|
createMorphWarpGrepTool
|
|
55
55
|
};
|
|
56
|
-
//# sourceMappingURL=chunk-
|
|
56
|
+
//# sourceMappingURL=chunk-7MCSSJJA.js.map
|
|
@@ -9,12 +9,12 @@ import {
|
|
|
9
9
|
} from "./chunk-NCVWIW7L.js";
|
|
10
10
|
import {
|
|
11
11
|
MorphGit
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-4WIBODS7.js";
|
|
13
13
|
import {
|
|
14
14
|
AnthropicRouter,
|
|
15
15
|
GeminiRouter,
|
|
16
16
|
OpenAIRouter
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-3NTGAUTJ.js";
|
|
18
18
|
|
|
19
19
|
// client.ts
|
|
20
20
|
var MorphClient = class {
|
|
@@ -94,4 +94,4 @@ var MorphClient = class {
|
|
|
94
94
|
export {
|
|
95
95
|
MorphClient
|
|
96
96
|
};
|
|
97
|
-
//# sourceMappingURL=chunk-
|
|
97
|
+
//# sourceMappingURL=chunk-DIWNR3UP.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runWarpGrep
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-N5654KQR.js";
|
|
4
4
|
import {
|
|
5
5
|
LocalRipgrepProvider
|
|
6
6
|
} from "./chunk-UYBIKZPM.js";
|
|
@@ -50,4 +50,4 @@ function createMorphWarpGrepTool(config) {
|
|
|
50
50
|
export {
|
|
51
51
|
createMorphWarpGrepTool
|
|
52
52
|
};
|
|
53
|
-
//# sourceMappingURL=chunk-
|
|
53
|
+
//# sourceMappingURL=chunk-JSZQVUSE.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runWarpGrep
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-N5654KQR.js";
|
|
4
4
|
import {
|
|
5
5
|
LocalRipgrepProvider
|
|
6
6
|
} from "./chunk-UYBIKZPM.js";
|
|
@@ -41,4 +41,4 @@ function createMorphWarpGrepTool(config) {
|
|
|
41
41
|
export {
|
|
42
42
|
createMorphWarpGrepTool
|
|
43
43
|
};
|
|
44
|
-
//# sourceMappingURL=chunk-
|
|
44
|
+
//# sourceMappingURL=chunk-LUI7APXX.js.map
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
toolRead
|
|
3
|
-
} from "./chunk-Z2FBMSNE.js";
|
|
4
|
-
import {
|
|
5
|
-
getSystemPrompt
|
|
6
|
-
} from "./chunk-HKZB23U7.js";
|
|
7
|
-
import {
|
|
8
|
-
toolAnalyse
|
|
9
|
-
} from "./chunk-73RQWOQC.js";
|
|
10
|
-
import {
|
|
11
|
-
readFinishFiles
|
|
12
|
-
} from "./chunk-EK7OQPWD.js";
|
|
13
1
|
import {
|
|
14
2
|
AGENT_CONFIG,
|
|
15
3
|
DEFAULT_MODEL
|
|
@@ -25,6 +13,18 @@ import {
|
|
|
25
13
|
import {
|
|
26
14
|
LLMResponseParser
|
|
27
15
|
} from "./chunk-GTOXMAF2.js";
|
|
16
|
+
import {
|
|
17
|
+
getSystemPrompt
|
|
18
|
+
} from "./chunk-HKZB23U7.js";
|
|
19
|
+
import {
|
|
20
|
+
toolAnalyse
|
|
21
|
+
} from "./chunk-73RQWOQC.js";
|
|
22
|
+
import {
|
|
23
|
+
readFinishFiles
|
|
24
|
+
} from "./chunk-EK7OQPWD.js";
|
|
25
|
+
import {
|
|
26
|
+
toolRead
|
|
27
|
+
} from "./chunk-Z2FBMSNE.js";
|
|
28
28
|
import {
|
|
29
29
|
fetchWithRetry,
|
|
30
30
|
withTimeout
|
|
@@ -198,4 +198,4 @@ async function runWarpGrep(config) {
|
|
|
198
198
|
export {
|
|
199
199
|
runWarpGrep
|
|
200
200
|
};
|
|
201
|
-
//# sourceMappingURL=chunk-
|
|
201
|
+
//# sourceMappingURL=chunk-N5654KQR.js.map
|
package/dist/client.cjs
CHANGED
|
@@ -914,7 +914,6 @@ var MorphGit = class {
|
|
|
914
914
|
fs: import_fs.default,
|
|
915
915
|
http: import_node.default,
|
|
916
916
|
dir,
|
|
917
|
-
corsProxy: this.proxyUrl,
|
|
918
917
|
url: `${this.proxyUrl}/v1/repos/${repoId}`,
|
|
919
918
|
ref: branch,
|
|
920
919
|
singleBranch,
|
|
@@ -934,12 +933,25 @@ var MorphGit = class {
|
|
|
934
933
|
* ```
|
|
935
934
|
*/
|
|
936
935
|
async push(options) {
|
|
937
|
-
const { dir, remote = "origin", branch } = options;
|
|
936
|
+
const { dir, remote = "origin", branch, waitForEmbeddings } = options;
|
|
938
937
|
if (!branch) {
|
|
939
938
|
throw new Error(
|
|
940
939
|
'branch is required for push operations. Specify the branch explicitly: { dir: "./my-project", branch: "main" }'
|
|
941
940
|
);
|
|
942
941
|
}
|
|
942
|
+
let commitHash;
|
|
943
|
+
let repoId;
|
|
944
|
+
if (waitForEmbeddings) {
|
|
945
|
+
commitHash = await import_isomorphic_git.default.resolveRef({ fs: import_fs.default, dir, ref: "HEAD" });
|
|
946
|
+
const remotes = await import_isomorphic_git.default.listRemotes({ fs: import_fs.default, dir });
|
|
947
|
+
const originRemote = remotes.find((r) => r.remote === remote);
|
|
948
|
+
if (originRemote) {
|
|
949
|
+
const match = originRemote.url.match(/\/repos\/([^\/]+)$/);
|
|
950
|
+
if (match) {
|
|
951
|
+
repoId = match[1];
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
}
|
|
943
955
|
await import_isomorphic_git.default.push({
|
|
944
956
|
fs: import_fs.default,
|
|
945
957
|
http: import_node.default,
|
|
@@ -948,6 +960,9 @@ var MorphGit = class {
|
|
|
948
960
|
ref: branch,
|
|
949
961
|
onAuth: this.getAuthCallback()
|
|
950
962
|
});
|
|
963
|
+
if (waitForEmbeddings && repoId && commitHash) {
|
|
964
|
+
await this.waitForEmbeddings({ repoId, commitHash });
|
|
965
|
+
}
|
|
951
966
|
}
|
|
952
967
|
/**
|
|
953
968
|
* Pull changes from remote repository
|
|
@@ -980,6 +995,49 @@ var MorphGit = class {
|
|
|
980
995
|
}
|
|
981
996
|
});
|
|
982
997
|
}
|
|
998
|
+
/**
|
|
999
|
+
* Wait for embeddings to complete after push.
|
|
1000
|
+
* Polls status endpoint until embeddings are done.
|
|
1001
|
+
*
|
|
1002
|
+
* @example
|
|
1003
|
+
* ```ts
|
|
1004
|
+
* await morphGit.push({ dir: './my-project', branch: 'main' });
|
|
1005
|
+
* await morphGit.waitForEmbeddings({
|
|
1006
|
+
* repoId: 'my-project',
|
|
1007
|
+
* onProgress: (p) => console.log(`${p.filesProcessed}/${p.totalFiles}`)
|
|
1008
|
+
* });
|
|
1009
|
+
* ```
|
|
1010
|
+
*/
|
|
1011
|
+
async waitForEmbeddings(options) {
|
|
1012
|
+
const { repoId, commitHash, timeout = 12e4, onProgress } = options;
|
|
1013
|
+
const startTime = Date.now();
|
|
1014
|
+
const pollInterval = 1e3;
|
|
1015
|
+
while (Date.now() - startTime < timeout) {
|
|
1016
|
+
const statusUrl = `${this.proxyUrl}/v1/repos/${repoId}/embedding-status` + (commitHash ? `?commit_hash=${commitHash}` : "");
|
|
1017
|
+
const response = await fetch(statusUrl, {
|
|
1018
|
+
headers: { "Authorization": `Bearer ${this.apiKey}` }
|
|
1019
|
+
});
|
|
1020
|
+
if (response.status === 404) {
|
|
1021
|
+
await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
|
|
1022
|
+
continue;
|
|
1023
|
+
}
|
|
1024
|
+
if (!response.ok) {
|
|
1025
|
+
throw new Error(`Failed to get embedding status: ${response.status}`);
|
|
1026
|
+
}
|
|
1027
|
+
const status = await response.json();
|
|
1028
|
+
if (onProgress && status.progress) {
|
|
1029
|
+
onProgress(status.progress);
|
|
1030
|
+
}
|
|
1031
|
+
if (status.status === "completed") {
|
|
1032
|
+
return;
|
|
1033
|
+
}
|
|
1034
|
+
if (status.status === "failed") {
|
|
1035
|
+
throw new Error(`Embeddings failed: ${status.error || "Unknown error"}`);
|
|
1036
|
+
}
|
|
1037
|
+
await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
|
|
1038
|
+
}
|
|
1039
|
+
throw new Error(`Embeddings timed out after ${timeout}ms`);
|
|
1040
|
+
}
|
|
983
1041
|
/**
|
|
984
1042
|
* Stage a file for commit
|
|
985
1043
|
*
|