@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.
- package/dist/commands/harnesses/leases/show.js +8 -0
- package/dist/commands/harnesses/show.js +3 -0
- package/dist/lib/dedicated-wait.js +2 -0
- package/dist/lib/harness-engine-update.d.ts +5 -0
- package/dist/lib/harness-engine-update.js +82 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarness.d.ts +7 -8
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarness.js +11 -7
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarnessUpdater.d.ts +29 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarnessUpdater.js +57 -6
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarness.d.ts +7 -8
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarness.js +11 -7
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarnessUpdater.d.ts +29 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarnessUpdater.js +71 -4
- package/dist/node_modules/@skrr-ai/data-provider/index.js +8038 -8034
- package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/contract.d.ts +5 -0
- package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/contract.js +6 -1
- package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/index.d.ts +1 -1
- package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/index.js +8 -0
- package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/loopback-server.d.ts +4 -0
- package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/loopback-server.js +4 -2
- package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-inference-broker.d.ts +96 -0
- package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-inference-broker.js +108 -9
- package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/contract.d.ts +5 -0
- package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/contract.js +5 -0
- package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/index.d.ts +1 -1
- package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/index.js +1 -1
- package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/loopback-server.d.ts +4 -0
- package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/loopback-server.js +1 -1
- package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-inference-broker.d.ts +96 -0
- package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-inference-broker.js +149 -11
- package/oclif.manifest.json +1 -1
- package/package.json +2 -2
|
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
* words for separate intents.
|
|
11
11
|
*/
|
|
12
12
|
const core_1 = require("@oclif/core");
|
|
13
|
+
const data_provider_1 = require("@skrr-ai/data-provider");
|
|
13
14
|
const base_command_1 = require("../../../base-command");
|
|
14
15
|
const harnesses_1 = require("../../../lib/harnesses");
|
|
15
16
|
const balance_1 = require("../../../lib/balance");
|
|
@@ -61,6 +62,13 @@ class HarnessesLeasesShow extends base_command_1.BaseCommand {
|
|
|
61
62
|
line('ID:', lease.id);
|
|
62
63
|
line('Product:', lease.machineProductLabel ?? lease.machineProduct);
|
|
63
64
|
line('State:', lease.stateReason ? `${lease.state} (${lease.stateReason})` : lease.state);
|
|
65
|
+
// The reason in words, as `skrr machines dedicated show` prints it; the code stays on the row above,
|
|
66
|
+
// where support looks for it (OSK-13732, OSK-24426). A reason with no copy adds no row.
|
|
67
|
+
line('Why:', (0, data_provider_1.describeMachineStateReason)(typeof lease.stateReason === 'string' ? lease.stateReason : undefined, typeof lease.machineProduct === 'string' ? lease.machineProduct : undefined, {
|
|
68
|
+
workspaceVolumeMissing: typeof lease.workspaceVolumeMissing === 'boolean'
|
|
69
|
+
? lease.workspaceVolumeMissing
|
|
70
|
+
: undefined,
|
|
71
|
+
}));
|
|
64
72
|
line('Name:', lease.displayName);
|
|
65
73
|
line('Daemon:', nested(lease.daemon, 'version'));
|
|
66
74
|
const os = nested(lease.resources, 'os');
|
|
@@ -12,6 +12,7 @@ const harnesses_1 = require("../../lib/harnesses");
|
|
|
12
12
|
const harness_labels_1 = require("../../lib/harness-labels");
|
|
13
13
|
const cli_installers_1 = require("../../lib/cli-installers");
|
|
14
14
|
const api_fetch_1 = require("../../lib/api-fetch");
|
|
15
|
+
const harness_engine_update_1 = require("../../lib/harness-engine-update");
|
|
15
16
|
const data_provider_1 = require("@skrr-ai/data-provider");
|
|
16
17
|
const DESCRIBE_WRONG_HARNESS_REF_RE = /^daemon_/;
|
|
17
18
|
const DESCRIBE_WRONG_HARNESS_REF_RE_2 = /^(dedicated-runtime-|hosted-machine-|hosted-runtime-)/;
|
|
@@ -130,6 +131,8 @@ class HarnessesShow extends base_command_1.BaseCommand {
|
|
|
130
131
|
}
|
|
131
132
|
if (harness.daemonId)
|
|
132
133
|
this.log(` daemon ${harness.daemonId}`);
|
|
134
|
+
for (const line of (0, harness_engine_update_1.harnessEngineUpdateLines)(harness))
|
|
135
|
+
this.log(line);
|
|
133
136
|
for (const line of harnessPermissionLines(harness))
|
|
134
137
|
this.log(line);
|
|
135
138
|
if (verdict) {
|
|
@@ -26,6 +26,8 @@ function backupIsNewer(current, previous) {
|
|
|
26
26
|
const PLANNED_REPLACEMENT_PROGRESS = {
|
|
27
27
|
dedicated_runtime_image_update: 'replacing the machine',
|
|
28
28
|
dedicated_runtime_image_update_rolling_back: 'replacing the machine again',
|
|
29
|
+
// A start that moves the machine to its new network (OSK-24426); files are kept.
|
|
30
|
+
dedicated_runtime_network_move: 'moving the machine to a new network; files are kept',
|
|
29
31
|
};
|
|
30
32
|
/**
|
|
31
33
|
* The same two labels, keyed by the image move's OWN status.
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.harnessEngineUpdateLines = harnessEngineUpdateLines;
|
|
4
|
+
const auth_core_1 = require("@skrr-ai/auth-core");
|
|
5
|
+
const OWNER_LABELS = {
|
|
6
|
+
managed: 'the daemon keeps it on its channel',
|
|
7
|
+
pinned: 'held where it is by an explicit choice',
|
|
8
|
+
external: 'installed outside the managed store; its installer updates it',
|
|
9
|
+
desktop: 'bundled with the desktop app, which updates it',
|
|
10
|
+
image: "this machine's image decides it",
|
|
11
|
+
unsupported: 'no managed release for this platform',
|
|
12
|
+
};
|
|
13
|
+
const minute = (at) => (at ? `${at.slice(0, 16).replace('T', ' ')}Z` : '');
|
|
14
|
+
function gap(report) {
|
|
15
|
+
const behind = report.behind;
|
|
16
|
+
if (!behind?.unit)
|
|
17
|
+
return '';
|
|
18
|
+
const count = typeof behind.count === 'number' ? String(behind.count) : 'a';
|
|
19
|
+
const plural = typeof behind.count === 'number' && behind.count !== 1 ? 's' : '';
|
|
20
|
+
const since = behind.since ? ` since ${minute(behind.since)}` : '';
|
|
21
|
+
return ` (${count} ${behind.unit} release${plural} behind${since})`;
|
|
22
|
+
}
|
|
23
|
+
function headline(report) {
|
|
24
|
+
const installed = report.installedVersion ?? 'version unknown';
|
|
25
|
+
const offered = report.offeredVersion ?? 'a newer release';
|
|
26
|
+
const channel = report.channel ?? 'its channel';
|
|
27
|
+
const failed = (attempt) => attempt?.code ? ` [${attempt.code}]` : '';
|
|
28
|
+
switch (report.state) {
|
|
29
|
+
case 'up-to-date':
|
|
30
|
+
return `${installed}, current on ${channel}`;
|
|
31
|
+
case 'ahead':
|
|
32
|
+
return `${installed}, newer than ${channel} (${offered})`;
|
|
33
|
+
case 'behind':
|
|
34
|
+
return `${installed}, ${offered} available on ${channel}${gap(report)}`;
|
|
35
|
+
case 'installing':
|
|
36
|
+
return `${installed}, installing ${offered} from ${channel}`;
|
|
37
|
+
case 'check-failed':
|
|
38
|
+
return `${installed}; the last ${channel} check failed${failed(report.lastCheck)}`;
|
|
39
|
+
case 'install-failed':
|
|
40
|
+
return `${installed}; installing ${offered} failed${failed(report.lastInstall)}${gap(report)}`;
|
|
41
|
+
case 'not-installed':
|
|
42
|
+
return `not installed (${auth_core_1.FIRST_PARTY_HARNESS.command} install)`;
|
|
43
|
+
case 'unverified':
|
|
44
|
+
return `${installed}; its version cannot be verified`;
|
|
45
|
+
case 'unchecked':
|
|
46
|
+
return `${installed}; not checked against ${channel} yet`;
|
|
47
|
+
case 'disabled':
|
|
48
|
+
return `${installed}; not checked by the daemon`;
|
|
49
|
+
default:
|
|
50
|
+
return `${installed}; ${report.state}`;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/** The `engine` lines of `skrr harnesses show`, or none when the row carries no report. */
|
|
54
|
+
function harnessEngineUpdateLines(harness) {
|
|
55
|
+
if (!harness.provider || !(0, auth_core_1.isFirstPartyHarnessProvider)(harness.provider))
|
|
56
|
+
return [];
|
|
57
|
+
const report = harness.metadata?.engineUpdate;
|
|
58
|
+
if (!report || typeof report !== 'object' || !report.state)
|
|
59
|
+
return [];
|
|
60
|
+
const pad = ' ';
|
|
61
|
+
const owner = report.owner ?? 'unknown';
|
|
62
|
+
const pin = report.pin?.kind
|
|
63
|
+
? ` (${report.pin.kind}${report.pin.detail ? `: ${report.pin.detail}` : ''})`
|
|
64
|
+
: '';
|
|
65
|
+
const lines = [
|
|
66
|
+
` engine ${headline(report)}`,
|
|
67
|
+
`${pad}owner ${owner}${pin}: ${OWNER_LABELS[owner] ?? owner}; auto-update ${report.autoUpdate ?? 'unknown'}`,
|
|
68
|
+
];
|
|
69
|
+
if (report.forcedFloor) {
|
|
70
|
+
lines.push(report.belowForcedFloor
|
|
71
|
+
? `${pad}forced update to ${report.forcedFloor}: sessions are refused until it is installed`
|
|
72
|
+
: `${pad}forced update to ${report.forcedFloor}: satisfied`);
|
|
73
|
+
}
|
|
74
|
+
const install = report.lastInstall;
|
|
75
|
+
if (install?.at) {
|
|
76
|
+
lines.push(`${pad}last install ${install.ok ? 'ok' : `failed${install.code ? ` [${install.code}]` : ''}`}: ` +
|
|
77
|
+
`${install.fromVersion ?? 'none'} -> ${install.toVersion ?? '?'} at ${minute(install.at)}`);
|
|
78
|
+
}
|
|
79
|
+
if (report.updatedAt)
|
|
80
|
+
lines.push(`${pad}as the daemon reported it at ${minute(report.updatedAt)}`);
|
|
81
|
+
return lines;
|
|
82
|
+
}
|
|
@@ -263,6 +263,12 @@ export declare const FIRST_PARTY_HARNESS_ENV: Readonly<{
|
|
|
263
263
|
channel: FirstPartyHarnessEnvName;
|
|
264
264
|
/** Update-feed base URL override. */
|
|
265
265
|
updateFeedBase: FirstPartyHarnessEnvName;
|
|
266
|
+
/**
|
|
267
|
+
* The daemon's background update of the managed engine: unset or `on` checks
|
|
268
|
+
* and installs, `notify` checks and reports without installing, `off` (also
|
|
269
|
+
* `false`/`0`/`no`/`disabled`) does neither.
|
|
270
|
+
*/
|
|
271
|
+
autoUpdate: FirstPartyHarnessEnvName;
|
|
266
272
|
/** Path to a file of development release keys. */
|
|
267
273
|
devKeys: FirstPartyHarnessEnvName;
|
|
268
274
|
/** Engine version the desktop build bundles. */
|
|
@@ -313,13 +319,6 @@ declare const ENGINE_ENV_SUFFIXES: Readonly<{
|
|
|
313
319
|
allowUpstreamEgress: "ALLOW_UPSTREAM_EGRESS";
|
|
314
320
|
compatOpencode: "COMPAT_OPENCODE";
|
|
315
321
|
noCompatPrompts: "NO_COMPAT_PROMPTS";
|
|
316
|
-
/**
|
|
317
|
-
* Advisory input-token budget for a managed session, set by the daemon from
|
|
318
|
-
* the server-issued `requestEnvelope.maxInputTokens` so the engine's
|
|
319
|
-
* auto-compaction can trigger before the relay refuses the request. The
|
|
320
|
-
* engine must treat it as a hint: enforcement stays server-side.
|
|
321
|
-
*/
|
|
322
|
-
maxInputTokens: "MAX_INPUT_TOKENS";
|
|
323
322
|
/**
|
|
324
323
|
* The session id the engine stamps into processes it spawns — the one
|
|
325
324
|
* variable on this table the engine WRITES rather than reads, so a child
|
|
@@ -365,7 +364,7 @@ export declare const FIRST_PARTY_HARNESS_ENGINE: Readonly<{
|
|
|
365
364
|
* `readFirstPartyHarnessEngineEnv` to read one the way the engine does and
|
|
366
365
|
* `firstPartyHarnessEngineEnvEntries` to set one every engine build honours.
|
|
367
366
|
*/
|
|
368
|
-
env: Readonly<Record<"sessionId" | "appName" | "serverPassword" | "serverUsername" | "home" | "config" | "scriptName" | "allowUpstreamEgress" | "compatOpencode" | "noCompatPrompts"
|
|
367
|
+
env: Readonly<Record<"sessionId" | "appName" | "serverPassword" | "serverUsername" | "home" | "config" | "scriptName" | "allowUpstreamEgress" | "compatOpencode" | "noCompatPrompts", string>>;
|
|
369
368
|
}>;
|
|
370
369
|
/**
|
|
371
370
|
* Every name the engine reads for one purpose, current namespace first — the
|
|
@@ -212,6 +212,12 @@ const FIRST_PARTY_HARNESS_ENV = Object.freeze({
|
|
|
212
212
|
channel: envName("SKRR_FIRST_PARTY_HARNESS_CHANNEL"),
|
|
213
213
|
/** Update-feed base URL override. */
|
|
214
214
|
updateFeedBase: envName("SKRR_FIRST_PARTY_HARNESS_UPDATE_FEED_BASE"),
|
|
215
|
+
/**
|
|
216
|
+
* The daemon's background update of the managed engine: unset or `on` checks
|
|
217
|
+
* and installs, `notify` checks and reports without installing, `off` (also
|
|
218
|
+
* `false`/`0`/`no`/`disabled`) does neither.
|
|
219
|
+
*/
|
|
220
|
+
autoUpdate: envName("SKRR_FIRST_PARTY_HARNESS_AUTO_UPDATE"),
|
|
215
221
|
/** Path to a file of development release keys. */
|
|
216
222
|
devKeys: envName("SKRR_FIRST_PARTY_HARNESS_DEV_KEYS"),
|
|
217
223
|
/** Engine version the desktop build bundles. */
|
|
@@ -257,13 +263,11 @@ const ENGINE_ENV_SUFFIXES = Object.freeze({
|
|
|
257
263
|
allowUpstreamEgress: "ALLOW_UPSTREAM_EGRESS",
|
|
258
264
|
compatOpencode: "COMPAT_OPENCODE",
|
|
259
265
|
noCompatPrompts: "NO_COMPAT_PROMPTS",
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
*/
|
|
266
|
-
maxInputTokens: "MAX_INPUT_TOKENS",
|
|
266
|
+
// `maxInputTokens: 'MAX_INPUT_TOKENS'` (OSK-10309) is retired (OSK-24550):
|
|
267
|
+
// it was never produced for a brokered session, and a bare number compared
|
|
268
|
+
// with provider tokens is the wrong unit for the relay's cap. The lease's
|
|
269
|
+
// envelope reaches the engine from the broker, with its unit, as
|
|
270
|
+
// `MANAGED_INPUT_ENVELOPE_ENV` (`@skrr-ai/inference-broker`).
|
|
267
271
|
/**
|
|
268
272
|
* The session id the engine stamps into processes it spawns — the one
|
|
269
273
|
* variable on this table the engine WRITES rather than reads, so a child
|
|
@@ -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
|
}
|
|
@@ -45,6 +45,7 @@ __export(firstPartyHarnessUpdater_exports, {
|
|
|
45
45
|
installFirstPartyHarness: () => installFirstPartyHarness,
|
|
46
46
|
installedFirstPartyHarnessSize: () => installedFirstPartyHarnessSize,
|
|
47
47
|
isManagedFirstPartyHarnessReleasePath: () => isManagedFirstPartyHarnessReleasePath,
|
|
48
|
+
readFirstPartyHarnessPin: () => readFirstPartyHarnessPin,
|
|
48
49
|
readFirstPartyHarnessUpdateState: () => readFirstPartyHarnessUpdateState,
|
|
49
50
|
rollbackFirstPartyHarness: () => rollbackFirstPartyHarness
|
|
50
51
|
});
|
|
@@ -210,6 +211,7 @@ function paths(env) {
|
|
|
210
211
|
previous: import_node_path.default.join(home, "previous"),
|
|
211
212
|
state: import_node_path.default.join(home, "update-state.json"),
|
|
212
213
|
floor: import_node_path.default.join(home, "minimum-manifest.json"),
|
|
214
|
+
pin: import_node_path.default.join(home, "pin.json"),
|
|
213
215
|
lock: import_node_path.default.join(import_node_path.default.dirname(home), `.${import_firstPartyHarness.FIRST_PARTY_HARNESS.provider}-update`)
|
|
214
216
|
};
|
|
215
217
|
}
|
|
@@ -311,7 +313,38 @@ function readFirstPartyHarnessUpdateState(env = process.env) {
|
|
|
311
313
|
return null;
|
|
312
314
|
}
|
|
313
315
|
}
|
|
314
|
-
function
|
|
316
|
+
function readFirstPartyHarnessPin(options = {}) {
|
|
317
|
+
let pin;
|
|
318
|
+
try {
|
|
319
|
+
pin = JSON.parse((0, import_node_fs.readFileSync)(paths(options.env ?? process.env).pin, "utf8"));
|
|
320
|
+
} catch {
|
|
321
|
+
return null;
|
|
322
|
+
}
|
|
323
|
+
if (!pin || !["version", "rollback"].includes(pin.source) || typeof pin.version !== "string" || typeof pin.sha256 !== "string" || !Number.isFinite(pin.pinnedAt))
|
|
324
|
+
return null;
|
|
325
|
+
const installed = getVerifiedInstalledFirstPartyHarness(options);
|
|
326
|
+
return installed.verified && installed.version === pin.version && installed.provenance?.sha256 === pin.sha256.toLowerCase() ? pin : null;
|
|
327
|
+
}
|
|
328
|
+
function recordPin(env, keys, source) {
|
|
329
|
+
if (!source) {
|
|
330
|
+
(0, import_node_fs.rmSync)(paths(env).pin, { force: true });
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
const installed = getVerifiedInstalledFirstPartyHarness({ env, keys });
|
|
334
|
+
if (!installed.verified || !installed.version || !installed.provenance)
|
|
335
|
+
return;
|
|
336
|
+
atomicJson(paths(env).pin, {
|
|
337
|
+
source,
|
|
338
|
+
version: installed.version,
|
|
339
|
+
sha256: installed.provenance.sha256,
|
|
340
|
+
pinnedAt: Date.now()
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
function pinRefusal(env, keys) {
|
|
344
|
+
const pin = readFirstPartyHarnessPin({ env, keys });
|
|
345
|
+
return pin ? fail("pinned", `${import_firstPartyHarness.FIRST_PARTY_HARNESS.displayName} ${pin.version} was chosen explicitly (${pin.source}); an automatic update leaves it alone. Run \`skrr code update\` to follow the update channel again.`) : null;
|
|
346
|
+
}
|
|
347
|
+
function finishState(env, operation, attemptedAt, result, targetVersion, keys = import_firstPartyHarnessReleaseKeys.FIRST_PARTY_HARNESS_RELEASE_PUBLIC_KEYS, autonomous) {
|
|
315
348
|
atomicJson(paths(env).state, {
|
|
316
349
|
operation,
|
|
317
350
|
status: result.ok ? "succeeded" : "failed",
|
|
@@ -321,7 +354,8 @@ function finishState(env, operation, attemptedAt, result, targetVersion, keys =
|
|
|
321
354
|
installedVersion: result.version ?? getVerifiedInstalledFirstPartyHarness({ env, keys }).version ?? void 0,
|
|
322
355
|
code: result.code,
|
|
323
356
|
error: result.error,
|
|
324
|
-
changed: result.changed
|
|
357
|
+
changed: result.changed,
|
|
358
|
+
...autonomous ? { autonomous: true } : {}
|
|
325
359
|
});
|
|
326
360
|
}
|
|
327
361
|
function retainedManifest(env, keys) {
|
|
@@ -501,6 +535,11 @@ function activateLocked(options) {
|
|
|
501
535
|
return fail("minimum-version", `release ${record.version} is below the retained signed minimum ${floor}`);
|
|
502
536
|
if (options.manifest && (0, import_releaseVersions.compareReleaseVersions)(record.version, options.manifest.minimum) < 0)
|
|
503
537
|
return fail("minimum-version", "release is below its signed minimum");
|
|
538
|
+
if (options.respectPin) {
|
|
539
|
+
const pinned = pinRefusal(env, keys);
|
|
540
|
+
if (pinned)
|
|
541
|
+
return { ok: true, changed: false, binaryPath: binary, reason: pinned.error };
|
|
542
|
+
}
|
|
504
543
|
if (installed.exists && !installed.verified && options.preserveUnknownInstalled)
|
|
505
544
|
return {
|
|
506
545
|
ok: true,
|
|
@@ -575,7 +614,7 @@ function activateVerifiedFirstPartyHarnessArtifact(options) {
|
|
|
575
614
|
let release;
|
|
576
615
|
try {
|
|
577
616
|
release = import_proper_lockfile.default.lockSync(prepareLock(env), { realpath: false, stale: LOCK_STALE_MS });
|
|
578
|
-
const result = invalid ?? activateLocked(options);
|
|
617
|
+
const result = invalid ?? activateLocked({ ...options, respectPin: true });
|
|
579
618
|
finishState(env, "install", attemptedAt, result, options.provenance?.version, options.keys);
|
|
580
619
|
return result;
|
|
581
620
|
} catch (error) {
|
|
@@ -659,16 +698,20 @@ async function installFirstPartyHarness(options = {}) {
|
|
|
659
698
|
operation: "install",
|
|
660
699
|
status: "running",
|
|
661
700
|
attemptedAt,
|
|
662
|
-
targetVersion: options.version
|
|
701
|
+
targetVersion: options.version,
|
|
702
|
+
...options.autonomous ? { autonomous: true } : {}
|
|
663
703
|
});
|
|
664
704
|
result = await downloadAndActivate();
|
|
665
|
-
|
|
705
|
+
if (result.ok && !options.autonomous) {
|
|
706
|
+
recordPin(env, keys, options.version ? "version" : null);
|
|
707
|
+
}
|
|
708
|
+
finishState(env, "install", attemptedAt, result, result.version ?? options.version, keys, options.autonomous);
|
|
666
709
|
return result;
|
|
667
710
|
} catch (error) {
|
|
668
711
|
result = fail(error.code === "ELOCKED" ? "lock-busy" : "install-failed", describe(error));
|
|
669
712
|
if (release) {
|
|
670
713
|
try {
|
|
671
|
-
finishState(env, "install", attemptedAt, result, options.version, keys);
|
|
714
|
+
finishState(env, "install", attemptedAt, result, options.version, keys, options.autonomous);
|
|
672
715
|
} catch {
|
|
673
716
|
}
|
|
674
717
|
}
|
|
@@ -677,6 +720,11 @@ async function installFirstPartyHarness(options = {}) {
|
|
|
677
720
|
await release?.();
|
|
678
721
|
}
|
|
679
722
|
async function downloadAndActivate() {
|
|
723
|
+
if (options.autonomous && !options.version) {
|
|
724
|
+
const pinned = pinRefusal(env, keys);
|
|
725
|
+
if (pinned)
|
|
726
|
+
return pinned;
|
|
727
|
+
}
|
|
680
728
|
progress("Fetching signed release manifest\u2026");
|
|
681
729
|
const fetched = await fetchVerifiedManifest(options);
|
|
682
730
|
if (!fetched.ok)
|
|
@@ -773,6 +821,8 @@ function rollbackFirstPartyHarness(env = process.env, options = {}) {
|
|
|
773
821
|
try {
|
|
774
822
|
release = import_proper_lockfile.default.lockSync(prepareLock(env), { realpath: false, stale: LOCK_STALE_MS });
|
|
775
823
|
const result = performRollback();
|
|
824
|
+
if (result.ok)
|
|
825
|
+
recordPin(env, keys, "rollback");
|
|
776
826
|
finishState(env, "rollback", attemptedAt, result, result.version, keys);
|
|
777
827
|
return result;
|
|
778
828
|
} catch (error) {
|
|
@@ -839,6 +889,7 @@ function installedFirstPartyHarnessSize(env = process.env) {
|
|
|
839
889
|
installFirstPartyHarness,
|
|
840
890
|
installedFirstPartyHarnessSize,
|
|
841
891
|
isManagedFirstPartyHarnessReleasePath,
|
|
892
|
+
readFirstPartyHarnessPin,
|
|
842
893
|
readFirstPartyHarnessUpdateState,
|
|
843
894
|
rollbackFirstPartyHarness
|
|
844
895
|
});
|
|
@@ -263,6 +263,12 @@ export declare const FIRST_PARTY_HARNESS_ENV: Readonly<{
|
|
|
263
263
|
channel: FirstPartyHarnessEnvName;
|
|
264
264
|
/** Update-feed base URL override. */
|
|
265
265
|
updateFeedBase: FirstPartyHarnessEnvName;
|
|
266
|
+
/**
|
|
267
|
+
* The daemon's background update of the managed engine: unset or `on` checks
|
|
268
|
+
* and installs, `notify` checks and reports without installing, `off` (also
|
|
269
|
+
* `false`/`0`/`no`/`disabled`) does neither.
|
|
270
|
+
*/
|
|
271
|
+
autoUpdate: FirstPartyHarnessEnvName;
|
|
266
272
|
/** Path to a file of development release keys. */
|
|
267
273
|
devKeys: FirstPartyHarnessEnvName;
|
|
268
274
|
/** Engine version the desktop build bundles. */
|
|
@@ -313,13 +319,6 @@ declare const ENGINE_ENV_SUFFIXES: Readonly<{
|
|
|
313
319
|
allowUpstreamEgress: "ALLOW_UPSTREAM_EGRESS";
|
|
314
320
|
compatOpencode: "COMPAT_OPENCODE";
|
|
315
321
|
noCompatPrompts: "NO_COMPAT_PROMPTS";
|
|
316
|
-
/**
|
|
317
|
-
* Advisory input-token budget for a managed session, set by the daemon from
|
|
318
|
-
* the server-issued `requestEnvelope.maxInputTokens` so the engine's
|
|
319
|
-
* auto-compaction can trigger before the relay refuses the request. The
|
|
320
|
-
* engine must treat it as a hint: enforcement stays server-side.
|
|
321
|
-
*/
|
|
322
|
-
maxInputTokens: "MAX_INPUT_TOKENS";
|
|
323
322
|
/**
|
|
324
323
|
* The session id the engine stamps into processes it spawns — the one
|
|
325
324
|
* variable on this table the engine WRITES rather than reads, so a child
|
|
@@ -365,7 +364,7 @@ export declare const FIRST_PARTY_HARNESS_ENGINE: Readonly<{
|
|
|
365
364
|
* `readFirstPartyHarnessEngineEnv` to read one the way the engine does and
|
|
366
365
|
* `firstPartyHarnessEngineEnvEntries` to set one every engine build honours.
|
|
367
366
|
*/
|
|
368
|
-
env: Readonly<Record<"sessionId" | "appName" | "serverPassword" | "serverUsername" | "home" | "config" | "scriptName" | "allowUpstreamEgress" | "compatOpencode" | "noCompatPrompts"
|
|
367
|
+
env: Readonly<Record<"sessionId" | "appName" | "serverPassword" | "serverUsername" | "home" | "config" | "scriptName" | "allowUpstreamEgress" | "compatOpencode" | "noCompatPrompts", string>>;
|
|
369
368
|
}>;
|
|
370
369
|
/**
|
|
371
370
|
* Every name the engine reads for one purpose, current namespace first — the
|
|
@@ -352,6 +352,12 @@ export const FIRST_PARTY_HARNESS_ENV = Object.freeze({
|
|
|
352
352
|
channel: envName('SKRR_FIRST_PARTY_HARNESS_CHANNEL'),
|
|
353
353
|
/** Update-feed base URL override. */
|
|
354
354
|
updateFeedBase: envName('SKRR_FIRST_PARTY_HARNESS_UPDATE_FEED_BASE'),
|
|
355
|
+
/**
|
|
356
|
+
* The daemon's background update of the managed engine: unset or `on` checks
|
|
357
|
+
* and installs, `notify` checks and reports without installing, `off` (also
|
|
358
|
+
* `false`/`0`/`no`/`disabled`) does neither.
|
|
359
|
+
*/
|
|
360
|
+
autoUpdate: envName('SKRR_FIRST_PARTY_HARNESS_AUTO_UPDATE'),
|
|
355
361
|
/** Path to a file of development release keys. */
|
|
356
362
|
devKeys: envName('SKRR_FIRST_PARTY_HARNESS_DEV_KEYS'),
|
|
357
363
|
/** Engine version the desktop build bundles. */
|
|
@@ -416,13 +422,11 @@ const ENGINE_ENV_SUFFIXES = Object.freeze({
|
|
|
416
422
|
allowUpstreamEgress: 'ALLOW_UPSTREAM_EGRESS',
|
|
417
423
|
compatOpencode: 'COMPAT_OPENCODE',
|
|
418
424
|
noCompatPrompts: 'NO_COMPAT_PROMPTS',
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
*/
|
|
425
|
-
maxInputTokens: 'MAX_INPUT_TOKENS',
|
|
425
|
+
// `maxInputTokens: 'MAX_INPUT_TOKENS'` (OSK-10309) is retired (OSK-24550):
|
|
426
|
+
// it was never produced for a brokered session, and a bare number compared
|
|
427
|
+
// with provider tokens is the wrong unit for the relay's cap. The lease's
|
|
428
|
+
// envelope reaches the engine from the broker, with its unit, as
|
|
429
|
+
// `MANAGED_INPUT_ENVELOPE_ENV` (`@skrr-ai/inference-broker`).
|
|
426
430
|
/**
|
|
427
431
|
* The session id the engine stamps into processes it spawns — the one
|
|
428
432
|
* variable on this table the engine WRITES rather than reads, so a child
|
|
@@ -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
|
}
|