@skrr-ai/cli 0.1.175 → 0.1.177

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 (36) 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/cjs/inferenceBrokerHarnesses.d.ts +25 -0
  11. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/inferenceBrokerHarnesses.js +20 -6
  12. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarness.d.ts +7 -8
  13. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarness.js +11 -7
  14. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarnessUpdater.d.ts +29 -1
  15. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarnessUpdater.js +71 -4
  16. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/inferenceBrokerHarnesses.d.ts +25 -0
  17. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/inferenceBrokerHarnesses.js +31 -5
  18. package/dist/node_modules/@skrr-ai/data-provider/index.js +8038 -8034
  19. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/contract.d.ts +5 -0
  20. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/contract.js +6 -1
  21. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/index.d.ts +1 -1
  22. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/index.js +8 -0
  23. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/loopback-server.d.ts +4 -0
  24. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/loopback-server.js +4 -2
  25. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-inference-broker.d.ts +96 -0
  26. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-inference-broker.js +108 -9
  27. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/contract.d.ts +5 -0
  28. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/contract.js +5 -0
  29. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/index.d.ts +1 -1
  30. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/index.js +1 -1
  31. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/loopback-server.d.ts +4 -0
  32. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/loopback-server.js +1 -1
  33. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-inference-broker.d.ts +96 -0
  34. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-inference-broker.js +149 -11
  35. package/oclif.manifest.json +1 -1
  36. package/package.json +2 -2
@@ -7,7 +7,9 @@ export type { ReleaseKey } from './releaseManifest.js';
7
7
  export declare const PREVIOUS_SUFFIX = ".previous";
8
8
  export declare const PROVENANCE_SUFFIX = ".oversky-provenance.json";
9
9
  export declare const MAX_ARTIFACT_BYTES: number;
10
- export type InstallFailureCode = 'unsupported-platform' | 'feed-unreachable' | 'manifest-malformed' | 'manifest-unverified' | 'artifact-missing' | 'artifact-unverified' | 'download-failed' | 'hash-mismatch' | 'too-large' | 'install-failed' | 'no-pinned-keys' | 'downgrade-refused' | 'version-invalid' | 'lock-busy' | 'minimum-version' | 'policy-rejected';
10
+ export type InstallFailureCode = 'unsupported-platform' | 'feed-unreachable' | 'manifest-malformed' | 'manifest-unverified' | 'artifact-missing' | 'artifact-unverified' | 'download-failed' | 'hash-mismatch' | 'too-large' | 'install-failed' | 'no-pinned-keys' | 'downgrade-refused' | 'version-invalid' | 'lock-busy' | 'minimum-version' | 'policy-rejected'
11
+ /** An autonomous install found an explicitly chosen release active and left it alone. */
12
+ | 'pinned';
11
13
  export interface InstallResult {
12
14
  ok: boolean;
13
15
  version?: string;
@@ -30,6 +32,12 @@ export interface InstallOptions {
30
32
  allowDowngrade?: boolean;
31
33
  signal?: AbortSignal;
32
34
  manifestTimeoutMs?: number;
35
+ /**
36
+ * True only for an install no person asked for (the daemon's background
37
+ * updater). It honours signed rollout cohorts, and it never replaces a
38
+ * release someone chose explicitly (`readFirstPartyHarnessPin`): checked
39
+ * under the install lock, so a pin made while the updater was deciding wins.
40
+ */
33
41
  autonomous?: boolean;
34
42
  cohortSubject?: string;
35
43
  contracts?: Record<string, number>;
@@ -54,6 +62,22 @@ export interface FirstPartyHarnessUpdateState {
54
62
  code?: InstallFailureCode;
55
63
  error?: string;
56
64
  changed?: boolean;
65
+ /** Set when the attempt was an autonomous (background) install, so "who changed my engine" has an answer. */
66
+ autonomous?: boolean;
67
+ }
68
+ /**
69
+ * A release a person chose explicitly: an install of a named version
70
+ * (`skrr code update --version`) or a rollback. Background installers leave it
71
+ * alone. It is in effect only while `current` is still that exact release
72
+ * (version AND digest), so a later explicit move by any writer makes it inert
73
+ * rather than leaving a stale pin that blocks the next one; an explicit channel
74
+ * install (no version, not autonomous) removes it.
75
+ */
76
+ export interface FirstPartyHarnessPin {
77
+ source: 'version' | 'rollback';
78
+ version: string;
79
+ sha256: string;
80
+ pinnedAt: number;
57
81
  }
58
82
  type InstallFailure = InstallResult & {
59
83
  ok: false;
@@ -75,6 +99,8 @@ export declare function getVerifiedInstalledFirstPartyHarness(options?: Pick<Ins
75
99
  provenance: HarnessProvenanceRecord | null;
76
100
  };
77
101
  export declare function readFirstPartyHarnessUpdateState(env?: NodeJS.ProcessEnv): FirstPartyHarnessUpdateState | null;
102
+ /** The explicit release choice in effect, or null when there is none or it no longer describes `current`. */
103
+ export declare function readFirstPartyHarnessPin(options?: Pick<InstallOptions, 'env' | 'keys' | 'platform' | 'arch'>): FirstPartyHarnessPin | null;
78
104
  export interface ActivateFirstPartyHarnessOptions {
79
105
  binary: Buffer;
80
106
  provenance: HarnessProvenanceRecord;
@@ -86,6 +112,8 @@ export interface ActivateFirstPartyHarnessOptions {
86
112
  onProgress?: (message: string) => void;
87
113
  preserveUnknownInstalled?: boolean;
88
114
  preserveExternalLink?: boolean;
115
+ /** Leave an explicitly chosen release (`readFirstPartyHarnessPin`) active, reporting why. */
116
+ respectPin?: boolean;
89
117
  /** Optional already verified signed manifest; retained as minimum-floor evidence. */
90
118
  manifest?: DaemonVersionManifest;
91
119
  }
@@ -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
  }
@@ -37,6 +37,13 @@
37
37
  * `platform-machine: available`) is held to the same set by
38
38
  * `api/server/services/Harness/__tests__/harnessSelection.spec.js`.
39
39
  *
40
+ * `platformMachineEvaluation` marks a harness such a machine ANNOUNCES without
41
+ * offering it: its image bakes it at a pinned version, the daemon announces its
42
+ * session capability once that runtime resolves, and the server still refuses
43
+ * it there until its registry placement is `available` (the GitHub Copilot SDK,
44
+ * OSK-24469, whose platform-machine admission waits on H9). Announcing it is
45
+ * what lets admission need no new image; it grants nothing by itself.
46
+ *
40
47
  * Pure: no `node:` imports and nothing read at module load.
41
48
  */
42
49
  /**
@@ -107,6 +114,13 @@ export interface InferenceBrokerHarness {
107
114
  * setuid wrapper, and it reaches its model only through this broker.
108
115
  */
109
116
  readonly platformMachine: boolean;
117
+ /**
118
+ * Whether a platform-managed machine announces this harness while its placement
119
+ * there is still evaluated: baked into the image, announced when its runtime
120
+ * resolves, and refused by the server's selection until the registry admits it.
121
+ * Never true beside `platformMachine`.
122
+ */
123
+ readonly platformMachineEvaluation: boolean;
110
124
  }
111
125
  export declare const INFERENCE_BROKER_HARNESSES: readonly InferenceBrokerHarness[];
112
126
  /**
@@ -121,6 +135,17 @@ export declare const PLATFORM_MACHINE_HARNESS_PROVIDERS: readonly string[];
121
135
  * `inferenceBrokerHarness`; false for anything unlisted or unreadable.
122
136
  */
123
137
  export declare function isPlatformMachineHarness(provider: unknown): boolean;
138
+ /**
139
+ * The canonical providers a platform-managed machine announces while their
140
+ * placement there is evaluated (`platformMachineEvaluation`): baked, announced
141
+ * when present, and admitted by nothing until the registry says `available`.
142
+ */
143
+ export declare const PLATFORM_MACHINE_EVALUATION_HARNESS_PROVIDERS: readonly string[];
144
+ /**
145
+ * Whether a platform-managed machine announces this harness for evaluation
146
+ * without offering it. False for the offered three and for anything unlisted.
147
+ */
148
+ export declare function isPlatformMachineEvaluationHarness(provider: unknown): boolean;
124
149
  /**
125
150
  * The listed harness for a provider name, or null. The first-party harness is
126
151
  * matched in every accepted spelling and never in a former one, which no entry
@@ -37,6 +37,13 @@
37
37
  * `platform-machine: available`) is held to the same set by
38
38
  * `api/server/services/Harness/__tests__/harnessSelection.spec.js`.
39
39
  *
40
+ * `platformMachineEvaluation` marks a harness such a machine ANNOUNCES without
41
+ * offering it: its image bakes it at a pinned version, the daemon announces its
42
+ * session capability once that runtime resolves, and the server still refuses
43
+ * it there until its registry placement is `available` (the GitHub Copilot SDK,
44
+ * OSK-24469, whose platform-machine admission waits on H9). Announcing it is
45
+ * what lets admission need no new image; it grants nothing by itself.
46
+ *
40
47
  * Pure: no `node:` imports and nothing read at module load.
41
48
  */
42
49
  import { FIRST_PARTY_HARNESS_PROVIDER, canonicalHarnessProvider } from './firstPartyHarness.js';
@@ -82,12 +89,13 @@ export const INFERENCE_RELAY_AUDIENCE = 'inference';
82
89
  export const SESSION_TOKEN_AUDIENCE = 'session';
83
90
  /** The capability a daemon announces when it can carry a shape at all, beyond its harness's entry. */
84
91
  const SHAPE_ANNOUNCED_BY = Object.freeze({ 'managed-lease': MANAGED_INFERENCE_BROKER_TOKEN_CAPABILITY });
85
- function harness(provider, carries, announcedBy, { platformMachine }) {
92
+ function harness(provider, carries, announcedBy, { platformMachine, platformMachineEvaluation = false, }) {
86
93
  return Object.freeze({
87
94
  provider,
88
95
  carries: Object.freeze([...carries]),
89
96
  announcedBy,
90
97
  platformMachine,
98
+ platformMachineEvaluation: platformMachineEvaluation && !platformMachine,
91
99
  });
92
100
  }
93
101
  export const INFERENCE_BROKER_HARNESSES = Object.freeze([
@@ -98,10 +106,15 @@ export const INFERENCE_BROKER_HARNESSES = Object.freeze([
98
106
  harness('codex', ['managed-lease', 'gateway'], HARNESS_CREDENTIAL_BROKER_CAPABILITY, {
99
107
  platformMachine: true,
100
108
  }),
101
- // The Copilot SDK broker takes platform credits only as a managed lease. No
102
- // platform machine image bakes its runtime; its placement there is still
103
- // being evaluated (`packages/llm/harnesses/copilot-sdk.yaml`).
104
- harness('copilot-sdk', ['managed-lease'], null, { platformMachine: false }),
109
+ // The Copilot SDK broker takes platform credits only as a managed lease. The
110
+ // platform machine image bakes its runtime at the SDK's pin
111
+ // (`guest-harness-pins.json` `copilot-sdk`), so a platform machine announces it
112
+ // for measurement (H9), while its placement there is still `evaluating`
113
+ // (`packages/llm/harnesses/copilot-sdk.yaml`) and the server refuses it.
114
+ harness('copilot-sdk', ['managed-lease'], null, {
115
+ platformMachine: false,
116
+ platformMachineEvaluation: true,
117
+ }),
105
118
  // pi takes platform credits only as a managed lease, through the daemon's
106
119
  // loopback broker (OSK-24468). Not yet offered on a platform machine: the
107
120
  // image bakes it at its pin (`guest-harness-pins.json`), but its registry
@@ -123,6 +136,19 @@ export const PLATFORM_MACHINE_HARNESS_PROVIDERS = Object.freeze(INFERENCE_BROKER
123
136
  export function isPlatformMachineHarness(provider) {
124
137
  return inferenceBrokerHarness(provider)?.platformMachine === true;
125
138
  }
139
+ /**
140
+ * The canonical providers a platform-managed machine announces while their
141
+ * placement there is evaluated (`platformMachineEvaluation`): baked, announced
142
+ * when present, and admitted by nothing until the registry says `available`.
143
+ */
144
+ export const PLATFORM_MACHINE_EVALUATION_HARNESS_PROVIDERS = Object.freeze(INFERENCE_BROKER_HARNESSES.filter((entry) => entry.platformMachineEvaluation).map((entry) => entry.provider));
145
+ /**
146
+ * Whether a platform-managed machine announces this harness for evaluation
147
+ * without offering it. False for the offered three and for anything unlisted.
148
+ */
149
+ export function isPlatformMachineEvaluationHarness(provider) {
150
+ return inferenceBrokerHarness(provider)?.platformMachineEvaluation === true;
151
+ }
126
152
  /**
127
153
  * The listed harness for a provider name, or null. The first-party harness is
128
154
  * matched in every accepted spelling and never in a former one, which no entry