vim-todo-ai-bridge 1.0.0 → 1.0.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/server.js +8 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vim-todo-ai-bridge",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Local omp RPC bridge for vim-todo-list",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",
package/server.js CHANGED
@@ -18,6 +18,8 @@ function readOmpArgs() {
18
18
  }
19
19
 
20
20
  const OMP_BIN = process.env.OMP_BIN || 'omp';
21
+ const OMP_DEFAULT_MODEL_IDS = ['claude-haiku-5-5', 'claude-haiku-4-5'];
22
+ let completeSeq = 0;
21
23
  const OMP_ARGS = readOmpArgs();
22
24
  const OMP_PROVIDER_IDS = {
23
25
  openai: 'openai',
@@ -206,7 +208,7 @@ class OmpRpcClient {
206
208
  String(candidate.id) === requestedValue ||
207
209
  modelSelector(modelProviderId(candidate), candidate) === requestedValue
208
210
  )
209
- : matches[0];
211
+ : OMP_DEFAULT_MODEL_IDS.map((id) => matches.find((c) => String(c.id) === id)).find(Boolean) || matches[0];
210
212
  if (!model) {
211
213
  throw new Error(
212
214
  requestedValue
@@ -234,7 +236,9 @@ class OmpRpcClient {
234
236
  }
235
237
 
236
238
  async complete(provider, requestedModel, prompt) {
239
+ const seq = ++completeSeq;
237
240
  const run = this.requestQueue.catch(() => undefined).then(async () => {
241
+ if (seq !== completeSeq) throw new Error('superseded by a newer completion request');
238
242
  const model = await this.resolveModel(provider, requestedModel);
239
243
  await this.request('new_session');
240
244
  await this.request('set_model', {
@@ -338,6 +342,9 @@ async function complete(body) {
338
342
  documentBlock,
339
343
  ].filter(Boolean).join('\n\n');
340
344
  const result = await omp.complete(provider, body.model, prompt);
345
+ if (!String(result.text || '').trim()) {
346
+ throw new Error(`model ${result.model} returned no text; choose another model in Settings`);
347
+ }
341
348
  return {
342
349
  provider,
343
350
  model: result.model,