@sickr/cli 0.9.13 → 0.9.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/run.js +37 -1
  2. package/package.json +1 -1
package/dist/run.js CHANGED
@@ -24,7 +24,7 @@ import { readFileSync, writeFileSync, appendFileSync, mkdirSync, existsSync, rea
24
24
  import { homedir } from 'node:os';
25
25
  import { join } from 'node:path';
26
26
  import { randomUUID } from 'node:crypto';
27
- import { execFileSync } from 'node:child_process';
27
+ import { execFileSync, spawn } from 'node:child_process';
28
28
  import { setTimeout as sleep } from 'node:timers/promises';
29
29
  import { readCredentials } from './auth.js';
30
30
  import { runsDir } from './recorder.js';
@@ -403,6 +403,40 @@ export function providerArgsFor(agent, existingArgs) {
403
403
  return ['run', model, ...existingArgs];
404
404
  return existingArgs;
405
405
  }
406
+ function ollamaHost() {
407
+ return process.env.OLLAMA_HOST || 'http://127.0.0.1:11434';
408
+ }
409
+ async function ollamaServerReady() {
410
+ try {
411
+ const res = await fetch(`${ollamaHost().replace(/\/$/, '')}/api/tags`, { signal: AbortSignal.timeout(1000) });
412
+ return res.ok;
413
+ }
414
+ catch {
415
+ return false;
416
+ }
417
+ }
418
+ export async function ensureOllamaServer(agentBin, opts = {}) {
419
+ if (await ollamaServerReady())
420
+ return;
421
+ const needsShell = process.platform === 'win32' && /\.(cmd|bat)$/i.test(agentBin);
422
+ const child = spawn(agentBin, ['serve'], {
423
+ cwd: process.cwd(),
424
+ env: process.env,
425
+ detached: true,
426
+ stdio: 'ignore',
427
+ windowsHide: true,
428
+ shell: needsShell,
429
+ });
430
+ child.unref();
431
+ const attempts = opts.attempts ?? 20;
432
+ const delayMs = opts.delayMs ?? 250;
433
+ for (let i = 0; i < attempts; i++) {
434
+ await sleep(delayMs);
435
+ if (await ollamaServerReady())
436
+ return;
437
+ }
438
+ throw new Error('Ollama server did not start. Try running `ollama serve` in another terminal, then retry `sickr run ollama`.');
439
+ }
406
440
  export async function startRun(opts) {
407
441
  const creds = readCredentials();
408
442
  if (!creds) {
@@ -424,6 +458,8 @@ export async function startRun(opts) {
424
458
  ensureRecordingHooks(opts.agent);
425
459
  const agentBin = resolveAgent(opts.agent);
426
460
  const provider = providerForAgent(opts.agent);
461
+ if (provider === 'ollama')
462
+ await ensureOllamaServer(agentBin);
427
463
  const agentLabel = provider ? PROVIDERS[provider].recordLabel : opts.agent;
428
464
  const runnerId = randomUUID();
429
465
  const runnerIdentity = { agent: agentLabel, runner: runnerId, sessions: new Set() };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sickr/cli",
3
- "version": "0.9.13",
3
+ "version": "0.9.14",
4
4
  "type": "module",
5
5
  "description": "npx @sickr/cli - replay, live look, and workflow orchestration for AI coding agents.",
6
6
  "bin": {