@skrr-ai/cli 0.1.94 → 0.1.95
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/README.md +153 -165
- package/bin/run.js +32 -0
- package/bin/update-npm-runner.cjs +33 -0
- package/bin/update-session.cjs +194 -0
- package/bin/update-worker.cjs +208 -0
- package/dist/base-command.js +0 -15
- package/dist/commands/code/doctor.d.ts +1 -0
- package/dist/commands/code/doctor.js +6 -0
- package/dist/commands/code/index.js +4 -0
- package/dist/commands/code/install.d.ts +5 -62
- package/dist/commands/code/install.js +86 -279
- package/dist/commands/code/rollback.d.ts +8 -0
- package/dist/commands/code/rollback.js +20 -0
- package/dist/commands/code/update.d.ts +8 -37
- package/dist/commands/code/update.js +134 -213
- package/dist/commands/daemon/install.js +4 -0
- package/dist/commands/generate-recovery-code.d.ts +13 -1
- package/dist/commands/generate-recovery-code.js +146 -13
- package/dist/commands/instructions/guide.d.ts +20 -0
- package/dist/commands/instructions/guide.js +84 -0
- package/dist/commands/instructions/install.js +57 -33
- package/dist/commands/instructions/setup.d.ts +14 -0
- package/dist/commands/instructions/setup.js +72 -0
- package/dist/commands/integrations/execute.js +1 -1
- package/dist/commands/login.d.ts +5 -6
- package/dist/commands/login.js +27 -11
- package/dist/commands/logout.js +7 -7
- package/dist/commands/security/overview.d.ts +11 -0
- package/dist/commands/security/overview.js +158 -0
- package/dist/commands/spaces/claim.d.ts +12 -0
- package/dist/commands/spaces/claim.js +42 -0
- package/dist/commands/spaces/ownership.d.ts +12 -0
- package/dist/commands/spaces/ownership.js +46 -0
- package/dist/commands/tasks/cancel-cascade.js +1 -1
- package/dist/commands/tasks/create-tree.d.ts +5 -1
- package/dist/commands/tasks/create-tree.js +35 -7
- package/dist/commands/tasks/interrupt.js +2 -2
- package/dist/commands/tasks/pause-schedule.js +1 -1
- package/dist/commands/token/list.d.ts +3 -5
- package/dist/commands/token/list.js +99 -57
- package/dist/commands/update.d.ts +14 -0
- package/dist/commands/update.js +61 -0
- package/dist/generated/managed-instruction-guides.json +9 -0
- package/dist/hooks/init.d.ts +5 -0
- package/dist/hooks/init.js +27 -0
- package/dist/lib/commitments.d.ts +0 -8
- package/dist/lib/commitments.js +0 -52
- package/dist/lib/daemon-installer.d.ts +2 -0
- package/dist/lib/daemon-installer.js +100 -24
- package/dist/lib/first-party-harness-doctor.js +31 -1
- package/dist/lib/first-party-harness-remote-install.d.ts +71 -0
- package/dist/lib/first-party-harness-remote-install.js +310 -0
- package/dist/lib/first-party-harness-remote-update.d.ts +46 -0
- package/dist/lib/first-party-harness-remote-update.js +242 -0
- package/dist/lib/first-party-harness-startup-update.d.ts +26 -0
- package/dist/lib/first-party-harness-startup-update.js +166 -0
- package/dist/lib/first-party-harness-update.d.ts +46 -0
- package/dist/lib/first-party-harness-update.js +289 -0
- package/dist/lib/first-party-harness.js +7 -4
- package/dist/lib/managed-instruction-local.d.ts +12 -0
- package/dist/lib/managed-instruction-local.js +58 -0
- package/dist/lib/managed-instruction-setup.d.ts +35 -0
- package/dist/lib/managed-instruction-setup.js +306 -0
- package/dist/lib/memory-sync.d.ts +1 -0
- package/dist/lib/memory-sync.js +279 -68
- package/dist/lib/platform-update-local.d.ts +2 -0
- package/dist/lib/platform-update-local.js +113 -0
- package/dist/lib/platform-update.d.ts +39 -0
- package/dist/lib/platform-update.js +84 -0
- package/dist/lib/profile-machine-identity-guard.d.ts +2 -0
- package/dist/lib/profile-machine-identity-guard.js +13 -0
- package/dist/lib/prompt.d.ts +1 -0
- package/dist/lib/prompt.js +4 -3
- package/dist/lib/task-batch.d.ts +9 -0
- package/dist/lib/task-batch.js +94 -17
- package/dist/lib/task-instruction-offer.d.ts +1 -4
- package/dist/lib/task-instruction-offer.js +3 -129
- package/dist/lib/update-check.d.ts +61 -53
- package/dist/lib/update-check.js +453 -314
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarnessChannels.d.ts +3 -4
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarnessChannels.js +3 -4
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarnessReleaseKeys.d.ts +82 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarnessReleaseKeys.js +105 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarnessUpdater.d.ts +110 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarnessUpdater.js +945 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/harnessPermissionControls.d.ts +32 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/harnessPermissionControls.js +62 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/index.d.ts +2 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/index.js +4 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/machineUuid.js +35 -5
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/releasePolicy.d.ts +63 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/releasePolicy.js +169 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/releaseVersions.d.ts +2 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/releaseVersions.js +44 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarnessChannels.d.ts +3 -4
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarnessChannels.js +3 -4
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarnessReleaseKeys.d.ts +82 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarnessReleaseKeys.js +102 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarnessUpdater.d.ts +110 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarnessUpdater.js +923 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/harnessPermissionControls.d.ts +32 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/harnessPermissionControls.js +59 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/index.d.ts +2 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/index.js +2 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/machineUuid.js +35 -5
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/releasePolicy.d.ts +63 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/releasePolicy.js +163 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/releaseVersions.d.ts +2 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/releaseVersions.js +41 -0
- package/dist/node_modules/@skrr-ai/auth-core/package.json +31 -1
- package/dist/node_modules/@skrr-ai/data-provider/index.js +6584 -6567
- package/docs/v1/README.md +28 -0
- package/docs/v1/api.md +55 -0
- package/docs/v1/changelog.md +16 -0
- package/docs/v1/check-examples.mjs +178 -0
- package/docs/v1/examples/api-readonly.mjs +144 -0
- package/docs/v1/operations.md +87 -0
- package/docs/v1/quickstart.md +71 -0
- package/oclif.manifest.json +46007 -45462
- package/package.json +13 -11
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read-only capability wire for ordinary agent turns. This is NOT a session
|
|
3
|
+
* authorization request or an effective permission profile. In particular,
|
|
4
|
+
* an ACP approval callback is not a process sandbox, and access to a loopback
|
|
5
|
+
* inference broker is not a grant to make arbitrary outbound connections.
|
|
6
|
+
*
|
|
7
|
+
* Daemons advertise what their adapters implement; execution still validates
|
|
8
|
+
* the requested policy independently. Consumers never infer controls from a
|
|
9
|
+
* provider name, a missing report, or the unified permission-mode vocabulary.
|
|
10
|
+
*/
|
|
11
|
+
export interface HarnessPermissionControls {
|
|
12
|
+
version: 1;
|
|
13
|
+
plan: 'harness' | 'reported-actions' | 'unsupported' | 'unknown';
|
|
14
|
+
approval: 'harness' | 'reported-actions' | 'none' | 'unknown';
|
|
15
|
+
filesystem: 'harness-sandbox' | 'tool-path-guards' | 'reported-actions' | 'not-restricted-by-daemon' | 'unknown';
|
|
16
|
+
strictToolPolicy: {
|
|
17
|
+
modes: readonly ('none' | 'allowlist')[];
|
|
18
|
+
enforcement: 'harness' | 'negotiated' | 'unsupported' | 'unknown';
|
|
19
|
+
};
|
|
20
|
+
organizationToolDenylist: 'unsupported' | 'unknown';
|
|
21
|
+
networkEgress: 'not-restricted-by-daemon' | 'unknown';
|
|
22
|
+
}
|
|
23
|
+
export interface HarnessPermissionControlReport {
|
|
24
|
+
controls: HarnessPermissionControls | null;
|
|
25
|
+
source: 'daemon' | 'daemon_record' | 'unreported';
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Presence/registration metadata is untrusted input. Copy only the v1 enum
|
|
29
|
+
* vocabulary: unknown future claims and malformed profiles yield no report,
|
|
30
|
+
* rather than a green badge. Additive fields are stripped for compatibility.
|
|
31
|
+
*/
|
|
32
|
+
export declare function parseHarnessPermissionControls(value: unknown): HarnessPermissionControls | null;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const PLAN = ['harness', 'reported-actions', 'unsupported', 'unknown'];
|
|
2
|
+
const APPROVAL = ['harness', 'reported-actions', 'none', 'unknown'];
|
|
3
|
+
const FILESYSTEM = [
|
|
4
|
+
'harness-sandbox',
|
|
5
|
+
'tool-path-guards',
|
|
6
|
+
'reported-actions',
|
|
7
|
+
'not-restricted-by-daemon',
|
|
8
|
+
'unknown',
|
|
9
|
+
];
|
|
10
|
+
const TOOL_ENFORCEMENT = ['harness', 'negotiated', 'unsupported', 'unknown'];
|
|
11
|
+
/**
|
|
12
|
+
* Presence/registration metadata is untrusted input. Copy only the v1 enum
|
|
13
|
+
* vocabulary: unknown future claims and malformed profiles yield no report,
|
|
14
|
+
* rather than a green badge. Additive fields are stripped for compatibility.
|
|
15
|
+
*/
|
|
16
|
+
export function parseHarnessPermissionControls(value) {
|
|
17
|
+
try {
|
|
18
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
19
|
+
return null;
|
|
20
|
+
const row = value;
|
|
21
|
+
const { version, plan, approval, filesystem, organizationToolDenylist, networkEgress, strictToolPolicy, } = row;
|
|
22
|
+
const strict = strictToolPolicy;
|
|
23
|
+
if (!strict || typeof strict !== 'object' || Array.isArray(strict))
|
|
24
|
+
return null;
|
|
25
|
+
const strictModes = strict.modes;
|
|
26
|
+
const enforcement = strict.enforcement;
|
|
27
|
+
if (version !== 1 ||
|
|
28
|
+
!PLAN.includes(plan) ||
|
|
29
|
+
!APPROVAL.includes(approval) ||
|
|
30
|
+
!FILESYSTEM.includes(filesystem) ||
|
|
31
|
+
!['unsupported', 'unknown'].includes(organizationToolDenylist) ||
|
|
32
|
+
!['not-restricted-by-daemon', 'unknown'].includes(networkEgress) ||
|
|
33
|
+
!TOOL_ENFORCEMENT.includes(enforcement) ||
|
|
34
|
+
!Array.isArray(strictModes) ||
|
|
35
|
+
strictModes.length > 2 ||
|
|
36
|
+
!strictModes.every((mode) => mode === 'none' || mode === 'allowlist'))
|
|
37
|
+
return null;
|
|
38
|
+
const modes = [...new Set(strictModes)];
|
|
39
|
+
if (((enforcement === 'unsupported' || enforcement === 'unknown') && modes.length > 0) ||
|
|
40
|
+
((enforcement === 'harness' || enforcement === 'negotiated') && modes.length === 0))
|
|
41
|
+
return null;
|
|
42
|
+
return Object.freeze({
|
|
43
|
+
version: 1,
|
|
44
|
+
plan: plan,
|
|
45
|
+
approval: approval,
|
|
46
|
+
filesystem: filesystem,
|
|
47
|
+
strictToolPolicy: Object.freeze({
|
|
48
|
+
modes: Object.freeze(modes),
|
|
49
|
+
enforcement: enforcement,
|
|
50
|
+
}),
|
|
51
|
+
organizationToolDenylist: organizationToolDenylist,
|
|
52
|
+
networkEgress: networkEgress,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
// Malicious accessors/proxies must not break a read surface.
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -46,3 +46,5 @@ export { OVERSKY_RELEASE_PUBLIC_KEYS, type ReleaseKey } from './releaseKeys.js';
|
|
|
46
46
|
export { MAX_SIGS, TRUSTED_FEED_ORIGINS, buildArtifactMessage, buildManifestMessage, getDeltaFor, isTrustedArtifactOrigin, verifyArtifact, verifyManifest, type DaemonVersionManifest, type DeltaDescriptor, type ManifestSignature, type PlatformArtifact, type VerifyResult, } from './releaseManifest.js';
|
|
47
47
|
export { resolveConfigRoot, configRootPath, isConfigRootOverridden } from './configRoot.js';
|
|
48
48
|
export { PROFILES_SEGMENT, SUPERSEDED_MARKER_SUFFIX, SUPERSEDED_COPY_SUFFIX, profileStateDir, legacyProfileStateDir, resolveProfileStateDir, resolveProfileStateFile, profileStateFileLocations, profileStateFilePathsToClear, consolidateProfileState, type ResolvedProfileStateDir, type ConsolidationSpec, type ConsolidationStatus, type ConsolidationOutcome, } from './profileStateDir.js';
|
|
49
|
+
export * from './harnessPermissionControls.js';
|
|
50
|
+
export { compareReleaseVersions } from './releaseVersions.js';
|
|
@@ -182,3 +182,5 @@ export { resolveConfigRoot, configRootPath, isConfigRootOverridden } from './con
|
|
|
182
182
|
// the migration for a machine that ended up with two. Same lesson, one level
|
|
183
183
|
// down: two modules spelled the rule themselves and the two consumers disagreed.
|
|
184
184
|
export { PROFILES_SEGMENT, SUPERSEDED_MARKER_SUFFIX, SUPERSEDED_COPY_SUFFIX, profileStateDir, legacyProfileStateDir, resolveProfileStateDir, resolveProfileStateFile, profileStateFileLocations, profileStateFilePathsToClear, consolidateProfileState, } from './profileStateDir.js';
|
|
185
|
+
export * from './harnessPermissionControls.js';
|
|
186
|
+
export { compareReleaseVersions } from './releaseVersions.js';
|
|
@@ -198,11 +198,14 @@ export function setMachineUuidProfile(profile) {
|
|
|
198
198
|
export function getMachineUuidProfile() {
|
|
199
199
|
return activeMachineProfile;
|
|
200
200
|
}
|
|
201
|
-
function readPersistedChoice(file, hardware, profile) {
|
|
201
|
+
function readPersistedChoice(file, hardware, profile, requireProfile = false) {
|
|
202
202
|
try {
|
|
203
203
|
const parsed = JSON.parse(fs.readFileSync(file, 'utf-8'));
|
|
204
204
|
// A file from another machine (a restored backup, a synced home) is absent.
|
|
205
|
-
if (parsed?.version !== 1 ||
|
|
205
|
+
if (parsed?.version !== 1 ||
|
|
206
|
+
parsed.hardware !== hardware ||
|
|
207
|
+
(parsed.profile !== undefined && parsed.profile !== profile) ||
|
|
208
|
+
(requireProfile && parsed.profile !== profile))
|
|
206
209
|
return null;
|
|
207
210
|
// Only the two values this module can produce are accepted: a hand-edited or
|
|
208
211
|
// foreign string must never become an identity.
|
|
@@ -215,11 +218,18 @@ function readPersistedChoice(file, hardware, profile) {
|
|
|
215
218
|
return null;
|
|
216
219
|
}
|
|
217
220
|
}
|
|
218
|
-
function persistChoice(dir, file, hardware, machineUuid, reason) {
|
|
221
|
+
function persistChoice(dir, file, hardware, machineUuid, reason, profile) {
|
|
219
222
|
try {
|
|
220
223
|
fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
221
224
|
const tmp = `${file}.${process.pid}.${Date.now()}.tmp`;
|
|
222
|
-
const body = {
|
|
225
|
+
const body = {
|
|
226
|
+
version: 1,
|
|
227
|
+
hardware,
|
|
228
|
+
machineUuid,
|
|
229
|
+
profile,
|
|
230
|
+
reason,
|
|
231
|
+
decidedAt: new Date().toISOString(),
|
|
232
|
+
};
|
|
223
233
|
fs.writeFileSync(tmp, `${JSON.stringify(body)}\n`, { mode: 0o600 });
|
|
224
234
|
fs.renameSync(tmp, file);
|
|
225
235
|
}
|
|
@@ -228,6 +238,20 @@ function persistChoice(dir, file, hardware, machineUuid, reason) {
|
|
|
228
238
|
// next process decides again from the same evidence.
|
|
229
239
|
}
|
|
230
240
|
}
|
|
241
|
+
/** A nonsecret recovery copy survives product uninstall. Each profile has its
|
|
242
|
+
* own file, so concurrent profiles never overwrite a shared identity map. A
|
|
243
|
+
* copied home cannot adopt another machine's value: the hardware is verified
|
|
244
|
+
* and only this module's hardware/qualified values are admitted. */
|
|
245
|
+
function recoveryChoicePath(profile) {
|
|
246
|
+
const name = crypto.createHash('sha256').update(profile).digest('hex');
|
|
247
|
+
return path.join(os.homedir(), '.local', 'state', 'skrr', 'machine-identities', `${name}.json`);
|
|
248
|
+
}
|
|
249
|
+
function preserveRecoveryChoice(profile, hardware, machineUuid) {
|
|
250
|
+
const file = recoveryChoicePath(profile);
|
|
251
|
+
if (readPersistedChoice(file, hardware, profile, true) === machineUuid)
|
|
252
|
+
return;
|
|
253
|
+
persistChoice(path.dirname(file), file, hardware, machineUuid, 'restored_profile', profile);
|
|
254
|
+
}
|
|
231
255
|
/** The identity a NON-default profile registers under. Never throws. */
|
|
232
256
|
function resolveProfileMachineUuid(profile, hardware) {
|
|
233
257
|
const cacheKey = `${hardware}\u0000${profile}`;
|
|
@@ -237,6 +261,11 @@ function resolveProfileMachineUuid(profile, hardware) {
|
|
|
237
261
|
const dir = path.join(resolveConfigRoot(), 'profiles', profile);
|
|
238
262
|
const file = path.join(dir, MACHINE_IDENTITY_FILENAME);
|
|
239
263
|
let chosen = readPersistedChoice(file, hardware, profile);
|
|
264
|
+
if (!chosen) {
|
|
265
|
+
chosen = readPersistedChoice(recoveryChoicePath(profile), hardware, profile, true);
|
|
266
|
+
if (chosen)
|
|
267
|
+
persistChoice(dir, file, hardware, chosen, 'restored_profile', profile);
|
|
268
|
+
}
|
|
240
269
|
if (!chosen) {
|
|
241
270
|
const preExisting = PRE_EXISTING_PROFILE_EVIDENCE.some((name) => {
|
|
242
271
|
try {
|
|
@@ -247,8 +276,9 @@ function resolveProfileMachineUuid(profile, hardware) {
|
|
|
247
276
|
}
|
|
248
277
|
});
|
|
249
278
|
chosen = preExisting ? hardware : qualifyMachineUuid(hardware, profile);
|
|
250
|
-
persistChoice(dir, file, hardware, chosen, preExisting ? 'pre_existing_profile' : 'new_profile');
|
|
279
|
+
persistChoice(dir, file, hardware, chosen, preExisting ? 'pre_existing_profile' : 'new_profile', profile);
|
|
251
280
|
}
|
|
281
|
+
preserveRecoveryChoice(profile, hardware, chosen);
|
|
252
282
|
profileChoiceCache.set(cacheKey, chosen);
|
|
253
283
|
return chosen;
|
|
254
284
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { type ReleaseKey } from './releaseKeys.js';
|
|
2
|
+
export type ReleaseChannel = 'stable' | 'canary' | 'beta' | 'internal';
|
|
3
|
+
export interface ContractRange {
|
|
4
|
+
minimum: number;
|
|
5
|
+
maximum: number;
|
|
6
|
+
}
|
|
7
|
+
export interface ComponentReleasePolicy {
|
|
8
|
+
version: string;
|
|
9
|
+
minimumVersion?: string;
|
|
10
|
+
contracts?: Record<string, ContractRange>;
|
|
11
|
+
}
|
|
12
|
+
export interface ReleasePolicySignature {
|
|
13
|
+
keyId: string;
|
|
14
|
+
sig: string;
|
|
15
|
+
}
|
|
16
|
+
export interface SignedReleasePolicy {
|
|
17
|
+
schemaVersion: 1;
|
|
18
|
+
releaseId: string;
|
|
19
|
+
issuedAt: string;
|
|
20
|
+
expiresAt: string;
|
|
21
|
+
channel: ReleaseChannel;
|
|
22
|
+
/** Percentage in basis points (0–10000), avoiding floating-point policy. */
|
|
23
|
+
rolloutBasisPoints: number;
|
|
24
|
+
cohortSeed: string;
|
|
25
|
+
components: Record<string, ComponentReleasePolicy>;
|
|
26
|
+
keyId: string;
|
|
27
|
+
sig: string;
|
|
28
|
+
sigs?: ReleasePolicySignature[];
|
|
29
|
+
}
|
|
30
|
+
export type PolicyVerifyResult = {
|
|
31
|
+
ok: true;
|
|
32
|
+
} | {
|
|
33
|
+
ok: false;
|
|
34
|
+
reason: string;
|
|
35
|
+
} | {
|
|
36
|
+
disabled: true;
|
|
37
|
+
};
|
|
38
|
+
export interface ReleasePolicyAssessment {
|
|
39
|
+
valid: boolean;
|
|
40
|
+
eligible: boolean;
|
|
41
|
+
reason?: string;
|
|
42
|
+
}
|
|
43
|
+
/** Canonical, versioned signature message. Never sign JSON.stringify directly. */
|
|
44
|
+
export declare function buildReleasePolicyMessage(policy: Omit<SignedReleasePolicy, 'sig' | 'sigs'>): string;
|
|
45
|
+
export declare function verifyReleasePolicy(policy: SignedReleasePolicy, keys?: readonly ReleaseKey[]): PolicyVerifyResult;
|
|
46
|
+
export declare function isReleasePolicyCohortEligible(policy: SignedReleasePolicy, subject: string): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Verify expiry, daemon target binding, contract ranges, channel, and cohort.
|
|
49
|
+
* `autonomous=false` intentionally bypasses cohort gating: an operator who
|
|
50
|
+
* explicitly runs an update may recover a machine outside the staged cohort,
|
|
51
|
+
* but cannot bypass invalid signatures, an expired policy, or incompatibility.
|
|
52
|
+
*/
|
|
53
|
+
export declare function assessReleasePolicy(args: {
|
|
54
|
+
policy: SignedReleasePolicy;
|
|
55
|
+
targetDaemonVersion: string;
|
|
56
|
+
/** Defaults to daemon for backwards-compatible daemon policy assessment. */
|
|
57
|
+
targetComponent?: string;
|
|
58
|
+
channel: ReleaseChannel;
|
|
59
|
+
contracts: Record<string, number>;
|
|
60
|
+
cohortSubject: string;
|
|
61
|
+
autonomous: boolean;
|
|
62
|
+
now?: Date;
|
|
63
|
+
}): ReleasePolicyAssessment;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Signed multi-component release policy.
|
|
3
|
+
*
|
|
4
|
+
* The daemon artifact manifest authenticates a daemon binary. This envelope
|
|
5
|
+
* authenticates the *decision* to offer that binary to a cohort, and records
|
|
6
|
+
* the component contract that makes a CLI/daemon/desktop combination safe.
|
|
7
|
+
* It is separately signed so it can be added to a v1 artifact manifest without
|
|
8
|
+
* changing the legacy manifest signature bytes or blocking old daemons.
|
|
9
|
+
*/
|
|
10
|
+
import { createHash, createPublicKey, verify as verifyEd25519 } from 'node:crypto';
|
|
11
|
+
import { OVERSKY_RELEASE_PUBLIC_KEYS } from './releaseKeys.js';
|
|
12
|
+
const MAX_SIGS = 8;
|
|
13
|
+
function stableJson(value) {
|
|
14
|
+
if (value === null ||
|
|
15
|
+
typeof value === 'boolean' ||
|
|
16
|
+
typeof value === 'number' ||
|
|
17
|
+
typeof value === 'string') {
|
|
18
|
+
return JSON.stringify(value);
|
|
19
|
+
}
|
|
20
|
+
if (Array.isArray(value))
|
|
21
|
+
return `[${value.map(stableJson).join(',')}]`;
|
|
22
|
+
if (!value || typeof value !== 'object')
|
|
23
|
+
throw new Error('policy contains an unsupported value');
|
|
24
|
+
const record = value;
|
|
25
|
+
return `{${Object.keys(record)
|
|
26
|
+
.sort()
|
|
27
|
+
.map((key) => `${JSON.stringify(key)}:${stableJson(record[key])}`)
|
|
28
|
+
.join(',')}}`;
|
|
29
|
+
}
|
|
30
|
+
/** Canonical, versioned signature message. Never sign JSON.stringify directly. */
|
|
31
|
+
export function buildReleasePolicyMessage(policy) {
|
|
32
|
+
return ['oversky-release-policy', 'v1', stableJson(policy)].join('\n');
|
|
33
|
+
}
|
|
34
|
+
function verifyOne(message, signature, keys) {
|
|
35
|
+
if (keys.length === 0)
|
|
36
|
+
return { disabled: true };
|
|
37
|
+
if (!signature)
|
|
38
|
+
return { ok: false, reason: 'missing signature' };
|
|
39
|
+
const messageBytes = Buffer.from(message, 'utf8');
|
|
40
|
+
const signatureBytes = Buffer.from(signature, 'base64');
|
|
41
|
+
for (const keySpec of keys) {
|
|
42
|
+
try {
|
|
43
|
+
const key = createPublicKey({
|
|
44
|
+
key: Buffer.from(keySpec.publicKeySpkiB64, 'base64'),
|
|
45
|
+
format: 'der',
|
|
46
|
+
type: 'spki',
|
|
47
|
+
});
|
|
48
|
+
if (verifyEd25519(null, messageBytes, key, signatureBytes))
|
|
49
|
+
return { ok: true };
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
/* malformed signatures and keys are a verification failure */
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return { ok: false, reason: 'signature did not verify against any pinned key' };
|
|
56
|
+
}
|
|
57
|
+
function policyShapeIsValid(policy) {
|
|
58
|
+
if (!policy ||
|
|
59
|
+
typeof policy !== 'object' ||
|
|
60
|
+
policy.schemaVersion !== 1 ||
|
|
61
|
+
!/^[0-9A-Za-z._:-]+$/.test(policy.releaseId) ||
|
|
62
|
+
!['stable', 'canary', 'beta', 'internal'].includes(policy.channel) ||
|
|
63
|
+
!Number.isInteger(policy.rolloutBasisPoints) ||
|
|
64
|
+
policy.rolloutBasisPoints < 0 ||
|
|
65
|
+
policy.rolloutBasisPoints > 10_000 ||
|
|
66
|
+
typeof policy.cohortSeed !== 'string' ||
|
|
67
|
+
policy.cohortSeed.length < 8 ||
|
|
68
|
+
!policy.components ||
|
|
69
|
+
typeof policy.components !== 'object' ||
|
|
70
|
+
Array.isArray(policy.components)) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
const issued = Date.parse(policy.issuedAt);
|
|
74
|
+
const expires = Date.parse(policy.expiresAt);
|
|
75
|
+
if (!Number.isFinite(issued) || !Number.isFinite(expires) || expires <= issued)
|
|
76
|
+
return false;
|
|
77
|
+
return Object.values(policy.components).every((component) => component &&
|
|
78
|
+
typeof component === 'object' &&
|
|
79
|
+
!Array.isArray(component) &&
|
|
80
|
+
(!component.contracts ||
|
|
81
|
+
(typeof component.contracts === 'object' && !Array.isArray(component.contracts))) &&
|
|
82
|
+
typeof component.version === 'string' &&
|
|
83
|
+
component.version.length > 0 &&
|
|
84
|
+
Object.values(component.contracts ?? {}).every((range) => range &&
|
|
85
|
+
typeof range === 'object' &&
|
|
86
|
+
!Array.isArray(range) &&
|
|
87
|
+
Number.isInteger(range.minimum) &&
|
|
88
|
+
Number.isInteger(range.maximum) &&
|
|
89
|
+
range.minimum >= 0 &&
|
|
90
|
+
range.maximum >= range.minimum));
|
|
91
|
+
}
|
|
92
|
+
export function verifyReleasePolicy(policy, keys = OVERSKY_RELEASE_PUBLIC_KEYS) {
|
|
93
|
+
if (!policyShapeIsValid(policy))
|
|
94
|
+
return { ok: false, reason: 'invalid release-policy shape' };
|
|
95
|
+
const { sig, sigs, ...unsigned } = policy;
|
|
96
|
+
const message = buildReleasePolicyMessage(unsigned);
|
|
97
|
+
if (Array.isArray(sigs) && sigs.length > 0) {
|
|
98
|
+
if (keys.length === 0)
|
|
99
|
+
return { disabled: true };
|
|
100
|
+
for (const entry of sigs.slice(0, MAX_SIGS)) {
|
|
101
|
+
if (!entry || typeof entry.sig !== 'string')
|
|
102
|
+
continue;
|
|
103
|
+
const verdict = verifyOne(message, entry.sig, keys);
|
|
104
|
+
if ('ok' in verdict && verdict.ok)
|
|
105
|
+
return verdict;
|
|
106
|
+
}
|
|
107
|
+
return { ok: false, reason: 'no policy multi-signature verified against a pinned key' };
|
|
108
|
+
}
|
|
109
|
+
return verifyOne(message, sig, keys);
|
|
110
|
+
}
|
|
111
|
+
export function isReleasePolicyCohortEligible(policy, subject) {
|
|
112
|
+
if (!subject || policy.rolloutBasisPoints === 0)
|
|
113
|
+
return false;
|
|
114
|
+
if (policy.rolloutBasisPoints === 10_000)
|
|
115
|
+
return true;
|
|
116
|
+
const bucket = createHash('sha256')
|
|
117
|
+
.update(`${policy.releaseId}\n${policy.cohortSeed}\n${subject}`, 'utf8')
|
|
118
|
+
.digest()
|
|
119
|
+
.readUInt32BE(0) % 10_000;
|
|
120
|
+
return bucket < policy.rolloutBasisPoints;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Verify expiry, daemon target binding, contract ranges, channel, and cohort.
|
|
124
|
+
* `autonomous=false` intentionally bypasses cohort gating: an operator who
|
|
125
|
+
* explicitly runs an update may recover a machine outside the staged cohort,
|
|
126
|
+
* but cannot bypass invalid signatures, an expired policy, or incompatibility.
|
|
127
|
+
*/
|
|
128
|
+
export function assessReleasePolicy(args) {
|
|
129
|
+
const now = args.now ?? new Date();
|
|
130
|
+
if (Date.parse(args.policy.expiresAt) <= now.getTime()) {
|
|
131
|
+
return { valid: false, eligible: false, reason: `policy expired at ${args.policy.expiresAt}` };
|
|
132
|
+
}
|
|
133
|
+
if (args.policy.channel !== args.channel) {
|
|
134
|
+
return {
|
|
135
|
+
valid: false,
|
|
136
|
+
eligible: false,
|
|
137
|
+
reason: `policy channel ${args.policy.channel} does not match ${args.channel}`,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
const componentName = args.targetComponent ?? 'daemon';
|
|
141
|
+
const daemon = args.policy.components[componentName];
|
|
142
|
+
if (!daemon || daemon.version !== args.targetDaemonVersion) {
|
|
143
|
+
return {
|
|
144
|
+
valid: false,
|
|
145
|
+
eligible: false,
|
|
146
|
+
reason: `policy ${componentName} component does not bind the target artifact version`,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
for (const [name, range] of Object.entries(daemon.contracts ?? {})) {
|
|
150
|
+
const actual = args.contracts[name];
|
|
151
|
+
if (!Number.isInteger(actual) || actual < range.minimum || actual > range.maximum) {
|
|
152
|
+
return {
|
|
153
|
+
valid: false,
|
|
154
|
+
eligible: false,
|
|
155
|
+
reason: `local contract ${name}=${String(actual)} is outside policy range ${range.minimum}..${range.maximum}`,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
const eligible = !args.autonomous || isReleasePolicyCohortEligible(args.policy, args.cohortSubject);
|
|
160
|
+
return eligible
|
|
161
|
+
? { valid: true, eligible: true }
|
|
162
|
+
: { valid: true, eligible: false, reason: 'machine is outside rollout cohort' };
|
|
163
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** SemVer precedence shared by every local release consumer. Invalid inputs are never ordered. */
|
|
2
|
+
export function compareReleaseVersions(a, b) {
|
|
3
|
+
const parse = (value) => {
|
|
4
|
+
if (typeof value !== 'string')
|
|
5
|
+
return null;
|
|
6
|
+
const match = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/.exec(value.trim());
|
|
7
|
+
if (!match)
|
|
8
|
+
return null;
|
|
9
|
+
const prerelease = match[4]?.split('.') ?? [];
|
|
10
|
+
if (prerelease.some((part) => /^\d+$/.test(part) && part.length > 1 && part[0] === '0'))
|
|
11
|
+
return null;
|
|
12
|
+
return { core: match.slice(1, 4).map(BigInt), prerelease };
|
|
13
|
+
};
|
|
14
|
+
const left = parse(a);
|
|
15
|
+
const right = parse(b);
|
|
16
|
+
if (!left || !right)
|
|
17
|
+
return null;
|
|
18
|
+
for (let i = 0; i < 3; i++) {
|
|
19
|
+
if (left.core[i] !== right.core[i])
|
|
20
|
+
return left.core[i] < right.core[i] ? -1 : 1;
|
|
21
|
+
}
|
|
22
|
+
if (!left.prerelease.length || !right.prerelease.length) {
|
|
23
|
+
return left.prerelease.length === right.prerelease.length ? 0 : left.prerelease.length ? -1 : 1;
|
|
24
|
+
}
|
|
25
|
+
for (let i = 0; i < Math.max(left.prerelease.length, right.prerelease.length); i++) {
|
|
26
|
+
const l = left.prerelease[i];
|
|
27
|
+
const r = right.prerelease[i];
|
|
28
|
+
if (l === undefined || r === undefined)
|
|
29
|
+
return l === r ? 0 : l === undefined ? -1 : 1;
|
|
30
|
+
if (l === r)
|
|
31
|
+
continue;
|
|
32
|
+
const ln = /^\d+$/.test(l);
|
|
33
|
+
const rn = /^\d+$/.test(r);
|
|
34
|
+
if (ln && rn)
|
|
35
|
+
return BigInt(l) < BigInt(r) ? -1 : 1;
|
|
36
|
+
if (ln !== rn)
|
|
37
|
+
return ln ? -1 : 1;
|
|
38
|
+
return l < r ? -1 : 1;
|
|
39
|
+
}
|
|
40
|
+
return 0;
|
|
41
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skrr-ai/auth-core",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.20",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"types": "dist/esm/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -143,6 +143,36 @@
|
|
|
143
143
|
"types": "./dist/cjs/commitmentExecutionContract.d.ts",
|
|
144
144
|
"default": "./dist/cjs/commitmentExecutionContract.js"
|
|
145
145
|
}
|
|
146
|
+
},
|
|
147
|
+
"./harness-permission-controls": {
|
|
148
|
+
"import": {
|
|
149
|
+
"types": "./dist/esm/harnessPermissionControls.d.ts",
|
|
150
|
+
"default": "./dist/esm/harnessPermissionControls.js"
|
|
151
|
+
},
|
|
152
|
+
"require": {
|
|
153
|
+
"types": "./dist/cjs/harnessPermissionControls.d.ts",
|
|
154
|
+
"default": "./dist/cjs/harnessPermissionControls.js"
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
"./first-party-harness-updater": {
|
|
158
|
+
"import": {
|
|
159
|
+
"types": "./dist/esm/firstPartyHarnessUpdater.d.ts",
|
|
160
|
+
"default": "./dist/esm/firstPartyHarnessUpdater.js"
|
|
161
|
+
},
|
|
162
|
+
"require": {
|
|
163
|
+
"types": "./dist/cjs/firstPartyHarnessUpdater.d.ts",
|
|
164
|
+
"default": "./dist/cjs/firstPartyHarnessUpdater.js"
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
"./release-policy": {
|
|
168
|
+
"import": {
|
|
169
|
+
"types": "./dist/esm/releasePolicy.d.ts",
|
|
170
|
+
"default": "./dist/esm/releasePolicy.js"
|
|
171
|
+
},
|
|
172
|
+
"require": {
|
|
173
|
+
"types": "./dist/cjs/releasePolicy.d.ts",
|
|
174
|
+
"default": "./dist/cjs/releasePolicy.js"
|
|
175
|
+
}
|
|
146
176
|
}
|
|
147
177
|
},
|
|
148
178
|
"dependencies": {
|