@oxecli/oxe 1.0.5 → 1.0.6

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/config.js CHANGED
@@ -166,11 +166,13 @@ export async function loadOrPrompt() {
166
166
  const validation = await validateOxeApiKey(api_key);
167
167
  if (validation.valid) {
168
168
  key_data = validation.key_data || {};
169
+ process.stdout.write("\n");
169
170
  process.stdout.write(markupToAnsi(`[green]✓ Oxe API Key verified[/green] [dim](${String(key_data["name"] ?? "Desktop")})[/dim]`) + "\n");
170
171
  process.env.OXE_API_KEY = api_key;
171
172
  break;
172
173
  }
173
174
  else {
175
+ process.stdout.write("\n");
174
176
  process.stdout.write(`\x1b[31mAuthentication Error:\x1b[0m ${validation.error}\n`);
175
177
  process.stdout.write("\n");
176
178
  api_key = "";
package/dist/engine.js CHANGED
@@ -76,7 +76,8 @@ export class InferenceEngine {
76
76
  this.client = new OpenAI({
77
77
  apiKey: config["api_key"],
78
78
  baseURL: config["base_url"],
79
- timeout: config["timeout"] ?? 120,
79
+ // OpenAI SDK `timeout` is in MILLISECONDS; config stores seconds.
80
+ timeout: (config["timeout"] ?? 120) * 1000,
80
81
  maxRetries: config["max_retries"] ?? 2,
81
82
  });
82
83
  this.temperature = config["temperature"] ?? null;
package/dist/ui.js CHANGED
@@ -357,23 +357,84 @@ export function renderBufferWithCursor(buffer, pasteSpans, prefix, label, cursor
357
357
  const w = terminalWidth();
358
358
  const borderW = Math.max(w - 4, 10);
359
359
  const [row, col] = cursorLineCol(buffer, cursor);
360
- // Build the inner content line(s) the whole prefix+text (or placeholder)
361
- // lives on a single row when the buffer is empty, matching the original.
362
- let content;
360
+ // Build the inner content: prefix, then the text with the `▏` block cursor
361
+ // always drawn at the cursor position (mirrors the original rich frame).
362
+ let display;
363
363
  if (!buffer) {
364
- content = `\x1b[1m${prefix}\x1b[0m \x1b[1m▏\x1b[0m\x1b[2m${PROMPT_PLACEHOLDER}\x1b[0m`;
364
+ display = `\x1b[1m▏\x1b[0m\x1b[2m${PROMPT_PLACEHOLDER}\x1b[0m`;
365
365
  }
366
366
  else {
367
367
  const segs = splitBlocks(buffer, pasteSpans);
368
- let display = "";
368
+ // Recompute each segment's buffer range [a, b) so we can locate the cursor.
369
+ const ranges = [];
370
+ {
371
+ let pos = 0;
372
+ const pts = new Set([0, buffer.length]);
373
+ for (const [s, e] of pasteSpans) {
374
+ pts.add(s);
375
+ pts.add(e);
376
+ }
377
+ const sorted = [...pts].sort((a, b) => a - b);
378
+ const isPaste = (a, b) => pasteSpans.some(([s, e]) => s <= a && b <= e);
379
+ const used = new Set();
380
+ for (const seg of segs) {
381
+ for (let i = 0; i < sorted.length - 1; i++) {
382
+ const a = sorted[i];
383
+ const b = sorted[i + 1];
384
+ if (a === b || used.has(a))
385
+ continue;
386
+ used.add(a);
387
+ ranges.push([a, b]);
388
+ break;
389
+ }
390
+ }
391
+ }
392
+ // Determine the target segment + inside offset (mirrors Python).
393
+ let target = -1;
394
+ let inside = 0;
395
+ if (cursor >= buffer.length) {
396
+ target = segs.length - 1;
397
+ inside = ranges.length ? ranges[ranges.length - 1][1] - ranges[ranges.length - 1][0] : 0;
398
+ }
399
+ else {
400
+ for (let i = 0; i < ranges.length; i++) {
401
+ const [a, b] = ranges[i];
402
+ if (a <= cursor && cursor <= b) {
403
+ target = i;
404
+ inside = cursor - a;
405
+ break;
406
+ }
407
+ }
408
+ if (target === -1) {
409
+ target = segs.length - 1;
410
+ inside = ranges.length ? ranges[ranges.length - 1][1] - ranges[ranges.length - 1][0] : 0;
411
+ }
412
+ }
413
+ display = "";
369
414
  for (let i = 0; i < segs.length; i++) {
370
415
  const [, kind, disp] = segs[i];
371
416
  if (i && !endsWithWs(segs[i - 1][2]))
372
417
  display += " ";
373
- display += kind === "collapsed" ? `\x1b[1m\x1b[36m${disp}\x1b[0m` : disp;
418
+ if (i === target) {
419
+ if (kind === "collapsed") {
420
+ display += `\x1b[1m\x1b[36m${disp}\x1b[0m`;
421
+ if (!endsWithWs(disp))
422
+ display += " ";
423
+ display += `\x1b[1m▏\x1b[0m`;
424
+ }
425
+ else {
426
+ const bold = i === target;
427
+ display += disp.slice(0, inside);
428
+ display += `\x1b[1m▏\x1b[0m`;
429
+ display += disp.slice(inside);
430
+ }
431
+ }
432
+ else {
433
+ display += kind === "collapsed" ? `\x1b[1m\x1b[36m${disp}\x1b[0m` : disp;
434
+ }
374
435
  }
375
- content = `\x1b[1m${prefix}\x1b[0m ${display}`;
376
436
  }
437
+ const content = `\x1b[1m${prefix}\x1b[0m ${display}`;
377
438
  const lines = content.split("\n");
378
439
  // Top border with the label embedded on the left.
379
440
  const topPad = Math.max(borderW - label.length - 2, 0);
@@ -387,10 +448,12 @@ export function renderBufferWithCursor(buffer, pasteSpans, prefix, label, cursor
387
448
  }
388
449
  const bottom = `\x1b[90m╰${"─".repeat(borderW)}╯\x1b[0m`;
389
450
  const frame = [top, ...body, bottom].join("\n");
390
- // Cursor placement: one row below the top border. Column includes the
391
- // "│ " left border (2) plus "prefix " (prefix.length + 1).
451
+ // Cursor placement: one row below the top border. Preceding columns are
452
+ // `│ ` (2) + prefix (prefix.length) + ` ` (1) = prefix.length+3, so the first
453
+ // display char (the `▏` block cursor) sits at column prefix.length+4 relative
454
+ // to line column `col`.
392
455
  const cursorRow = row + 1;
393
- const cursorCol = col + prefix.length + 3;
456
+ const cursorCol = col + prefix.length + 4;
394
457
  const totalRows = body.length + 2;
395
458
  return { frame, cursorRow, cursorCol, totalRows };
396
459
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxecli/oxe",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },