@skrr-ai/cli 0.1.93 → 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/agents/operating-plan.d.ts +11 -0
- package/dist/commands/agents/operating-plan.js +54 -0
- package/dist/commands/agents/roles/example.d.ts +11 -0
- package/dist/commands/agents/roles/example.js +30 -0
- package/dist/commands/{commitments/mode.d.ts → agents/roles/export.d.ts} +5 -5
- package/dist/commands/agents/roles/export.js +81 -0
- package/dist/commands/agents/roles/install.d.ts +12 -0
- package/dist/commands/agents/roles/install.js +48 -0
- package/dist/commands/agents/roles/list.d.ts +11 -0
- package/dist/commands/agents/roles/list.js +36 -0
- package/dist/commands/agents/roles/preview.d.ts +14 -0
- package/dist/commands/agents/roles/preview.js +49 -0
- package/dist/commands/agents/roles/withdraw.d.ts +13 -0
- package/dist/commands/agents/roles/withdraw.js +43 -0
- 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/commitments/{autonomy-requests → cadence-requests}/decide.d.ts +5 -7
- package/dist/commands/commitments/{autonomy-requests → cadence-requests}/decide.js +13 -15
- package/dist/commands/commitments/cost.d.ts +1 -1
- package/dist/commands/commitments/cost.js +1 -1
- package/dist/commands/commitments/create.d.ts +0 -7
- package/dist/commands/commitments/create.js +9 -98
- package/dist/commands/commitments/delivery.js +3 -21
- package/dist/commands/commitments/doctor.js +28 -27
- package/dist/commands/commitments/effective-policy.js +5 -36
- package/dist/commands/commitments/evaluations.d.ts +15 -0
- package/dist/commands/commitments/evaluations.js +54 -0
- package/dist/commands/commitments/pack/activate.d.ts +11 -0
- package/dist/commands/commitments/pack/activate.js +22 -0
- package/dist/commands/commitments/pack/bind.js +1 -1
- package/dist/commands/commitments/remediate.js +2 -5
- package/dist/commands/commitments/show.js +1 -1
- package/dist/commands/commitments/update.js +9 -9
- package/dist/commands/commitments/wake-capabilities.d.ts +1 -3
- package/dist/commands/commitments/wake-capabilities.js +5 -21
- 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/commitment-product.d.ts +0 -6
- package/dist/lib/commitment-product.js +1 -30
- package/dist/lib/commitments.d.ts +9 -53
- package/dist/lib/commitments.js +23 -146
- 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/northstars.js +1 -1
- 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/roles.d.ts +98 -0
- package/dist/lib/roles.js +45 -0
- 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/commitmentExecutionContract.d.ts +45 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/commitmentExecutionContract.js +550 -0
- 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/cjs/sessionPermissionAuthority.d.ts +7 -44
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/sessionPermissionAuthority.js +8 -47
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/commitmentExecutionContract.d.ts +45 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/commitmentExecutionContract.js +545 -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/dist/esm/sessionPermissionAuthority.d.ts +7 -44
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/sessionPermissionAuthority.js +8 -47
- package/dist/node_modules/@skrr-ai/auth-core/package.json +41 -1
- package/dist/node_modules/@skrr-ai/data-provider/index.js +7362 -7232
- package/dist/node_modules/@skrr-ai/data-provider/package.json +2 -2
- 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 +46381 -45478
- package/package.json +16 -11
- package/dist/commands/commitments/autonomy.d.ts +0 -30
- package/dist/commands/commitments/autonomy.js +0 -67
- package/dist/commands/commitments/mode.js +0 -58
- package/dist/commands/commitments/pack/promote.d.ts +0 -19
- package/dist/commands/commitments/pack/promote.js +0 -46
- package/dist/commands/commitments/pack/shadow.d.ts +0 -20
- package/dist/commands/commitments/pack/shadow.js +0 -42
|
@@ -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,33 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* execution contract governs the run's permissions, shared by the server and
|
|
4
|
-
* the daemon (OSK-11975 introduced it; it was implemented twice — the server
|
|
5
|
-
* read `kind !== 'commitment'`, the daemon read the `permissionSource` marker —
|
|
6
|
-
* which is exactly how a new contract kind or a new source value would drift
|
|
7
|
-
* them apart).
|
|
8
|
-
*
|
|
9
|
-
* The wire model:
|
|
10
|
-
*
|
|
11
|
-
* - The contract is closed (`hasOnlyKeys` on the daemon), so "whose
|
|
12
|
-
* permissions govern" can never ride INSIDE it. It is a top-level session
|
|
13
|
-
* field: `permissionSource`.
|
|
14
|
-
* - `'agent'` means the Agent's own configured permission mode, tool policy,
|
|
15
|
-
* Grants, session env, MCP servers and machine consent govern the run,
|
|
16
|
-
* exactly as for an unattended Task of the same Agent. Today only a
|
|
17
|
-
* `commitment` contract may carry it.
|
|
18
|
-
* - A `commitment` contract WITHOUT the marker (an older server mid-deploy)
|
|
19
|
-
* still governs permissions — the marker is the version signal, so its
|
|
20
|
-
* absence must keep the legacy fence, not silently lift it.
|
|
21
|
-
* - `task_delivery` contracts always govern, marker or not.
|
|
22
|
-
*
|
|
23
|
-
* Server vs daemon asymmetry, on purpose: the server STAMPS the marker
|
|
24
|
-
* (`permissionSourceForContract`), so on its own side the predicate reduces to
|
|
25
|
-
* "a commitment never governs" — `contractGovernsPermissions(c,
|
|
26
|
-
* permissionSourceForContract(c))` is exactly `kind !== 'commitment'`. The
|
|
27
|
-
* daemon reads the marker it received, because it cannot distinguish "new
|
|
28
|
-
* server, agent permissions" from "old server, contract fence" any other way.
|
|
29
|
-
* Both call the same function; only the input differs.
|
|
30
|
-
*/
|
|
1
|
+
/** Commitment context never overrides Agent permissions. Version 3 admission
|
|
2
|
+
* rejects old contracts; typed Task delivery is a separate frozen operation. */
|
|
31
3
|
/** The wire vocabulary for `permissionSource`. Top-level session field. */
|
|
32
4
|
export declare const SESSION_PERMISSION_SOURCES: readonly ["agent"];
|
|
33
5
|
export type SessionPermissionSource = (typeof SESSION_PERMISSION_SOURCES)[number];
|
|
@@ -37,7 +9,7 @@ export type SessionPermissionSource = (typeof SESSION_PERMISSION_SOURCES)[number
|
|
|
37
9
|
* a daemon without it (`COMMITMENT_AGENT_PERMISSIONS_RUNTIME_UNSUPPORTED`), so
|
|
38
10
|
* the marker never reaches a daemon that would ignore it.
|
|
39
11
|
*/
|
|
40
|
-
export declare const COMMITMENT_AGENT_PERMISSIONS_CAPABILITY = "
|
|
12
|
+
export declare const COMMITMENT_AGENT_PERMISSIONS_CAPABILITY = "commitment_execution_contract_v3";
|
|
41
13
|
/**
|
|
42
14
|
* The minimal contract shape this rule reads. The predicate only ever needs
|
|
43
15
|
* `kind` — keeping the input structural means this module never imports the
|
|
@@ -50,8 +22,7 @@ export type PermissionContractKind = {
|
|
|
50
22
|
} | null | undefined;
|
|
51
23
|
/**
|
|
52
24
|
* Untrusted wire input: anything but an exact vocabulary literal reads as
|
|
53
|
-
* absent.
|
|
54
|
-
* to "contract governs", the conservative answer.
|
|
25
|
+
* absent. An unknown marker carries no authority. Contract admission is validated separately.
|
|
55
26
|
*/
|
|
56
27
|
export declare function normalizeSessionPermissionSource(value: unknown): SessionPermissionSource | undefined;
|
|
57
28
|
/**
|
|
@@ -60,18 +31,10 @@ export declare function normalizeSessionPermissionSource(value: unknown): Sessio
|
|
|
60
31
|
* kind keeps its own authority and stamps nothing.
|
|
61
32
|
*/
|
|
62
33
|
export declare function permissionSourceForContract(contract: PermissionContractKind): SessionPermissionSource | undefined;
|
|
63
|
-
/**
|
|
64
|
-
*
|
|
65
|
-
* this rule lives.
|
|
66
|
-
*
|
|
67
|
-
* True for a non-commitment contract regardless of marker, and for a
|
|
68
|
-
* commitment whose server did not declare agent permissions. False for no
|
|
69
|
-
* contract at all, and for a commitment carrying `permissionSource: 'agent'`,
|
|
70
|
-
* which then follows the Agent's own permissions exactly as a Task does while
|
|
71
|
-
* the contract keeps its non-permission roles (normalized shape, ephemeral
|
|
72
|
-
* worktree, result validation, `GIT_OPTIONAL_LOCKS`, provider restriction).
|
|
34
|
+
/** Only typed Task delivery owns an effect-specific permission boundary.
|
|
35
|
+
* A Commitment is context for the Agent and cannot grant or restrict tools.
|
|
73
36
|
*/
|
|
74
|
-
export declare function contractGovernsPermissions(contract: PermissionContractKind,
|
|
37
|
+
export declare function contractGovernsPermissions(contract: PermissionContractKind, _permissionSource?: unknown): boolean;
|
|
75
38
|
/**
|
|
76
39
|
* The contract when it governs permissions, else `undefined` — for the sites
|
|
77
40
|
* that used `executionContract` as "is this run permission-fenced".
|
|
@@ -1,33 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* execution contract governs the run's permissions, shared by the server and
|
|
4
|
-
* the daemon (OSK-11975 introduced it; it was implemented twice — the server
|
|
5
|
-
* read `kind !== 'commitment'`, the daemon read the `permissionSource` marker —
|
|
6
|
-
* which is exactly how a new contract kind or a new source value would drift
|
|
7
|
-
* them apart).
|
|
8
|
-
*
|
|
9
|
-
* The wire model:
|
|
10
|
-
*
|
|
11
|
-
* - The contract is closed (`hasOnlyKeys` on the daemon), so "whose
|
|
12
|
-
* permissions govern" can never ride INSIDE it. It is a top-level session
|
|
13
|
-
* field: `permissionSource`.
|
|
14
|
-
* - `'agent'` means the Agent's own configured permission mode, tool policy,
|
|
15
|
-
* Grants, session env, MCP servers and machine consent govern the run,
|
|
16
|
-
* exactly as for an unattended Task of the same Agent. Today only a
|
|
17
|
-
* `commitment` contract may carry it.
|
|
18
|
-
* - A `commitment` contract WITHOUT the marker (an older server mid-deploy)
|
|
19
|
-
* still governs permissions — the marker is the version signal, so its
|
|
20
|
-
* absence must keep the legacy fence, not silently lift it.
|
|
21
|
-
* - `task_delivery` contracts always govern, marker or not.
|
|
22
|
-
*
|
|
23
|
-
* Server vs daemon asymmetry, on purpose: the server STAMPS the marker
|
|
24
|
-
* (`permissionSourceForContract`), so on its own side the predicate reduces to
|
|
25
|
-
* "a commitment never governs" — `contractGovernsPermissions(c,
|
|
26
|
-
* permissionSourceForContract(c))` is exactly `kind !== 'commitment'`. The
|
|
27
|
-
* daemon reads the marker it received, because it cannot distinguish "new
|
|
28
|
-
* server, agent permissions" from "old server, contract fence" any other way.
|
|
29
|
-
* Both call the same function; only the input differs.
|
|
30
|
-
*/
|
|
1
|
+
/** Commitment context never overrides Agent permissions. Version 3 admission
|
|
2
|
+
* rejects old contracts; typed Task delivery is a separate frozen operation. */
|
|
31
3
|
/** The wire vocabulary for `permissionSource`. Top-level session field. */
|
|
32
4
|
export const SESSION_PERMISSION_SOURCES = ['agent'];
|
|
33
5
|
/**
|
|
@@ -36,11 +8,10 @@ export const SESSION_PERMISSION_SOURCES = ['agent'];
|
|
|
36
8
|
* a daemon without it (`COMMITMENT_AGENT_PERMISSIONS_RUNTIME_UNSUPPORTED`), so
|
|
37
9
|
* the marker never reaches a daemon that would ignore it.
|
|
38
10
|
*/
|
|
39
|
-
export const COMMITMENT_AGENT_PERMISSIONS_CAPABILITY = '
|
|
11
|
+
export const COMMITMENT_AGENT_PERMISSIONS_CAPABILITY = 'commitment_execution_contract_v3';
|
|
40
12
|
/**
|
|
41
13
|
* Untrusted wire input: anything but an exact vocabulary literal reads as
|
|
42
|
-
* absent.
|
|
43
|
-
* to "contract governs", the conservative answer.
|
|
14
|
+
* absent. An unknown marker carries no authority. Contract admission is validated separately.
|
|
44
15
|
*/
|
|
45
16
|
export function normalizeSessionPermissionSource(value) {
|
|
46
17
|
return SESSION_PERMISSION_SOURCES.includes(value)
|
|
@@ -55,21 +26,11 @@ export function normalizeSessionPermissionSource(value) {
|
|
|
55
26
|
export function permissionSourceForContract(contract) {
|
|
56
27
|
return contract?.kind === 'commitment' ? 'agent' : undefined;
|
|
57
28
|
}
|
|
58
|
-
/**
|
|
59
|
-
*
|
|
60
|
-
* this rule lives.
|
|
61
|
-
*
|
|
62
|
-
* True for a non-commitment contract regardless of marker, and for a
|
|
63
|
-
* commitment whose server did not declare agent permissions. False for no
|
|
64
|
-
* contract at all, and for a commitment carrying `permissionSource: 'agent'`,
|
|
65
|
-
* which then follows the Agent's own permissions exactly as a Task does while
|
|
66
|
-
* the contract keeps its non-permission roles (normalized shape, ephemeral
|
|
67
|
-
* worktree, result validation, `GIT_OPTIONAL_LOCKS`, provider restriction).
|
|
29
|
+
/** Only typed Task delivery owns an effect-specific permission boundary.
|
|
30
|
+
* A Commitment is context for the Agent and cannot grant or restrict tools.
|
|
68
31
|
*/
|
|
69
|
-
export function contractGovernsPermissions(contract,
|
|
70
|
-
|
|
71
|
-
return false;
|
|
72
|
-
return !(contract.kind === 'commitment' && normalizeSessionPermissionSource(permissionSource) === 'agent');
|
|
32
|
+
export function contractGovernsPermissions(contract, _permissionSource) {
|
|
33
|
+
return Boolean(contract && contract.kind !== 'commitment');
|
|
73
34
|
}
|
|
74
35
|
/**
|
|
75
36
|
* The contract when it governs permissions, else `undefined` — for the sites
|