@skrr-ai/cli 0.1.175 → 0.1.176

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 (32) hide show
  1. package/dist/commands/harnesses/leases/show.js +8 -0
  2. package/dist/commands/harnesses/show.js +3 -0
  3. package/dist/lib/dedicated-wait.js +2 -0
  4. package/dist/lib/harness-engine-update.d.ts +5 -0
  5. package/dist/lib/harness-engine-update.js +82 -0
  6. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarness.d.ts +7 -8
  7. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarness.js +11 -7
  8. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarnessUpdater.d.ts +29 -1
  9. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarnessUpdater.js +57 -6
  10. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarness.d.ts +7 -8
  11. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarness.js +11 -7
  12. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarnessUpdater.d.ts +29 -1
  13. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarnessUpdater.js +71 -4
  14. package/dist/node_modules/@skrr-ai/data-provider/index.js +8038 -8034
  15. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/contract.d.ts +5 -0
  16. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/contract.js +6 -1
  17. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/index.d.ts +1 -1
  18. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/index.js +8 -0
  19. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/loopback-server.d.ts +4 -0
  20. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/loopback-server.js +4 -2
  21. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-inference-broker.d.ts +96 -0
  22. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-inference-broker.js +108 -9
  23. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/contract.d.ts +5 -0
  24. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/contract.js +5 -0
  25. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/index.d.ts +1 -1
  26. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/index.js +1 -1
  27. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/loopback-server.d.ts +4 -0
  28. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/loopback-server.js +1 -1
  29. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-inference-broker.d.ts +96 -0
  30. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-inference-broker.js +149 -11
  31. package/oclif.manifest.json +1 -1
  32. package/package.json +2 -2
@@ -231,6 +231,7 @@ function paths(env) {
231
231
  previous: path.join(home, 'previous'),
232
232
  state: path.join(home, 'update-state.json'),
233
233
  floor: path.join(home, 'minimum-manifest.json'),
234
+ pin: path.join(home, 'pin.json'),
234
235
  lock: path.join(path.dirname(home), `.${FIRST_PARTY_HARNESS.provider}-update`),
235
236
  };
236
237
  }
@@ -355,7 +356,51 @@ export function readFirstPartyHarnessUpdateState(env = process.env) {
355
356
  return null;
356
357
  }
357
358
  }
358
- function finishState(env, operation, attemptedAt, result, targetVersion, keys = FIRST_PARTY_HARNESS_RELEASE_PUBLIC_KEYS) {
359
+ /** The explicit release choice in effect, or null when there is none or it no longer describes `current`. */
360
+ export function readFirstPartyHarnessPin(options = {}) {
361
+ let pin;
362
+ try {
363
+ pin = JSON.parse(readFileSync(paths(options.env ?? process.env).pin, 'utf8'));
364
+ }
365
+ catch {
366
+ return null;
367
+ }
368
+ if (!pin ||
369
+ !['version', 'rollback'].includes(pin.source) ||
370
+ typeof pin.version !== 'string' ||
371
+ typeof pin.sha256 !== 'string' ||
372
+ !Number.isFinite(pin.pinnedAt))
373
+ return null;
374
+ const installed = getVerifiedInstalledFirstPartyHarness(options);
375
+ return installed.verified &&
376
+ installed.version === pin.version &&
377
+ installed.provenance?.sha256 === pin.sha256.toLowerCase()
378
+ ? pin
379
+ : null;
380
+ }
381
+ function recordPin(env, keys, source) {
382
+ if (!source) {
383
+ rmSync(paths(env).pin, { force: true });
384
+ return;
385
+ }
386
+ const installed = getVerifiedInstalledFirstPartyHarness({ env, keys });
387
+ if (!installed.verified || !installed.version || !installed.provenance)
388
+ return;
389
+ atomicJson(paths(env).pin, {
390
+ source,
391
+ version: installed.version,
392
+ sha256: installed.provenance.sha256,
393
+ pinnedAt: Date.now(),
394
+ });
395
+ }
396
+ function pinRefusal(env, keys) {
397
+ const pin = readFirstPartyHarnessPin({ env, keys });
398
+ return pin
399
+ ? fail('pinned', `${FIRST_PARTY_HARNESS.displayName} ${pin.version} was chosen explicitly (${pin.source}); ` +
400
+ 'an automatic update leaves it alone. Run `skrr code update` to follow the update channel again.')
401
+ : null;
402
+ }
403
+ function finishState(env, operation, attemptedAt, result, targetVersion, keys = FIRST_PARTY_HARNESS_RELEASE_PUBLIC_KEYS, autonomous) {
359
404
  atomicJson(paths(env).state, {
360
405
  operation,
361
406
  status: result.ok ? 'succeeded' : 'failed',
@@ -366,6 +411,7 @@ function finishState(env, operation, attemptedAt, result, targetVersion, keys =
366
411
  code: result.code,
367
412
  error: result.error,
368
413
  changed: result.changed,
414
+ ...(autonomous ? { autonomous: true } : {}),
369
415
  });
370
416
  }
371
417
  function retainedManifest(env, keys) {
@@ -571,6 +617,11 @@ function activateLocked(options) {
571
617
  return fail('minimum-version', `release ${record.version} is below the retained signed minimum ${floor}`);
572
618
  if (options.manifest && compareReleaseVersions(record.version, options.manifest.minimum) < 0)
573
619
  return fail('minimum-version', 'release is below its signed minimum');
620
+ if (options.respectPin) {
621
+ const pinned = pinRefusal(env, keys);
622
+ if (pinned)
623
+ return { ok: true, changed: false, binaryPath: binary, reason: pinned.error };
624
+ }
574
625
  if (installed.exists && !installed.verified && options.preserveUnknownInstalled)
575
626
  return {
576
627
  ok: true,
@@ -649,7 +700,9 @@ export function activateVerifiedFirstPartyHarnessArtifact(options) {
649
700
  let release;
650
701
  try {
651
702
  release = lockfile.lockSync(prepareLock(env), { realpath: false, stale: LOCK_STALE_MS });
652
- const result = invalid ?? activateLocked(options);
703
+ // Seeding a bundled engine is an install nobody asked for, like the
704
+ // daemon's background update: it never replaces an explicit choice.
705
+ const result = invalid ?? activateLocked({ ...options, respectPin: true });
653
706
  finishState(env, 'install', attemptedAt, result, options.provenance?.version, options.keys);
654
707
  return result;
655
708
  }
@@ -743,16 +796,22 @@ export async function installFirstPartyHarness(options = {}) {
743
796
  status: 'running',
744
797
  attemptedAt,
745
798
  targetVersion: options.version,
799
+ ...(options.autonomous ? { autonomous: true } : {}),
746
800
  });
747
801
  result = await downloadAndActivate();
748
- finishState(env, 'install', attemptedAt, result, result.version ?? options.version, keys);
802
+ if (result.ok && !options.autonomous) {
803
+ // A named version is an explicit choice background updaters must keep;
804
+ // a channel install someone asked for means "follow the channel again".
805
+ recordPin(env, keys, options.version ? 'version' : null);
806
+ }
807
+ finishState(env, 'install', attemptedAt, result, result.version ?? options.version, keys, options.autonomous);
749
808
  return result;
750
809
  }
751
810
  catch (error) {
752
811
  result = fail(error.code === 'ELOCKED' ? 'lock-busy' : 'install-failed', describe(error));
753
812
  if (release) {
754
813
  try {
755
- finishState(env, 'install', attemptedAt, result, options.version, keys);
814
+ finishState(env, 'install', attemptedAt, result, options.version, keys, options.autonomous);
756
815
  }
757
816
  catch {
758
817
  /* preserve original error */
@@ -764,6 +823,11 @@ export async function installFirstPartyHarness(options = {}) {
764
823
  await release?.();
765
824
  }
766
825
  async function downloadAndActivate() {
826
+ if (options.autonomous && !options.version) {
827
+ const pinned = pinRefusal(env, keys);
828
+ if (pinned)
829
+ return pinned;
830
+ }
767
831
  progress('Fetching signed release manifest…');
768
832
  const fetched = await fetchVerifiedManifest(options);
769
833
  if (!fetched.ok)
@@ -865,6 +929,9 @@ export function rollbackFirstPartyHarness(env = process.env, options = {}) {
865
929
  try {
866
930
  release = lockfile.lockSync(prepareLock(env), { realpath: false, stale: LOCK_STALE_MS });
867
931
  const result = performRollback();
932
+ // Rolling back is choosing an older release on purpose: keep it chosen.
933
+ if (result.ok)
934
+ recordPin(env, keys, 'rollback');
868
935
  finishState(env, 'rollback', attemptedAt, result, result.version, keys);
869
936
  return result;
870
937
  }