@skrr-ai/cli 0.1.172 → 0.1.174

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.
@@ -2,9 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const config_1 = require("../lib/config");
4
4
  const update_check_1 = require("../lib/update-check");
5
+ const turn_context_1 = require("../lib/turn-context");
5
6
  /** All commands pass through this hook, including the local code/daemon
6
7
  * commands that intentionally do not use authenticated BaseCommand. */
7
8
  const hook = async function (options) {
9
+ // A resident harness engine's process: the current turn's session values
10
+ // come from the daemon, per call, before anything reads them. A no-op
11
+ // outside one. Refused means no credential is left in the environment and
12
+ // the command does not run (an `exit` makes oclif rethrow the hook's error).
13
+ const turnContext = await (0, turn_context_1.hydrateTurnContext)();
14
+ if (turnContext.kind === 'refused') {
15
+ this.error((0, turn_context_1.turnContextRefusalMessage)(turnContext), { exit: 75, code: turnContext.code });
16
+ }
8
17
  const argv = [
9
18
  ...(options.id ?? '').split(':').filter(Boolean),
10
19
  ...(options.argv ?? process.argv.slice(2)),
@@ -0,0 +1,20 @@
1
+ export declare const TURN_CONTEXT_FILE_ENV = "OVERSKY_TURN_CONTEXT_FILE";
2
+ export type TurnContextOutcome = {
3
+ kind: 'absent';
4
+ } | {
5
+ kind: 'hydrated';
6
+ names: string[];
7
+ } | {
8
+ kind: 'refused';
9
+ code: string;
10
+ message: string;
11
+ };
12
+ type Env = Record<string, string | undefined>;
13
+ /** Apply the current turn's environment to `env` (default `process.env`). */
14
+ export declare function hydrateTurnContext(env?: Env): Promise<TurnContextOutcome>;
15
+ /** The sentence a refused command prints. */
16
+ export declare function turnContextRefusalMessage(outcome: {
17
+ code: string;
18
+ message: string;
19
+ }): string;
20
+ export {};
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TURN_CONTEXT_FILE_ENV = void 0;
4
+ exports.hydrateTurnContext = hydrateTurnContext;
5
+ exports.turnContextRefusalMessage = turnContextRefusalMessage;
6
+ /**
7
+ * The turn context of a RESIDENT harness engine (OSK-24471).
8
+ *
9
+ * A daemon may keep a harness engine running between the turns of one
10
+ * conversation. Such an engine's environment then cannot carry anything that
11
+ * belongs to one turn: the session token and identity, and the delegated CLI
12
+ * capability, are served per turn by the daemon from a per-engine Unix socket
13
+ * instead, revoked when the turn ends. The engine's environment names that
14
+ * socket through one stable value, `OVERSKY_TURN_CONTEXT_FILE`: the path of a
15
+ * 0600 JSON file `{ socket, token }`.
16
+ *
17
+ * `hydrateTurnContext` runs in the `init` hook, before any command, and puts
18
+ * the current turn's values into `process.env`, so everything after it reads
19
+ * them exactly as it reads the values a per-turn engine is started with. With
20
+ * no `OVERSKY_TURN_CONTEXT_FILE` it does nothing at all.
21
+ *
22
+ * It fails closed. No active turn (the daemon answers `NO_ACTIVE_TURN`), an
23
+ * unreachable daemon or an unreadable reference leaves the process with no
24
+ * session credential and the autonomous marker set, so no command can fall
25
+ * back to anything ambient, and the hook then refuses to run the command.
26
+ *
27
+ * The wire is owned by the daemon (`daemon/src/resident-engine/turn-context-wire.ts`);
28
+ * this is a deliberate copy, because the CLI does not import the daemon.
29
+ */
30
+ const node_fs_1 = require("node:fs");
31
+ const node_http_1 = require("node:http");
32
+ exports.TURN_CONTEXT_FILE_ENV = 'OVERSKY_TURN_CONTEXT_FILE';
33
+ const TURN_CONTEXT_ENV_PATH = '/v1/turn/env';
34
+ const NO_ACTIVE_TURN = 'NO_ACTIVE_TURN';
35
+ const MAX_REFERENCE_BYTES = 4096;
36
+ const TIMEOUT_MS = 5_000;
37
+ /** Only the platform's own namespace may be set from the turn context, never PATH or NODE_OPTIONS. */
38
+ const HYDRATED_NAME = /^(OVERSKY|SKRR)_[A-Z0-9_]+$/;
39
+ /**
40
+ * What must be absent when hydration fails: every value a turn would have
41
+ * supplied, so that an engine's background process can never act on a value
42
+ * the daemon did not hand it for the current turn.
43
+ */
44
+ const TURN_CREDENTIAL_NAMES = [
45
+ 'OVERSKY_SESSION_TOKEN',
46
+ 'OVERSKY_SESSION_AUTH_TOKEN',
47
+ 'OVERSKY_SESSION_TOKEN_EXPIRES_AT',
48
+ 'OVERSKY_DELEGATED_CLI_CAPABILITY',
49
+ 'OVERSKY_DELEGATED_CLI_BROKER_URL',
50
+ 'OVERSKY_SESSION_ID',
51
+ 'OVERSKY_TOKEN',
52
+ 'SKRR_TOKEN',
53
+ ];
54
+ function readReference(path) {
55
+ const fd = (0, node_fs_1.openSync)(path, node_fs_1.constants.O_RDONLY | (node_fs_1.constants.O_NOFOLLOW ?? 0));
56
+ try {
57
+ const info = (0, node_fs_1.fstatSync)(fd);
58
+ if (!info.isFile() ||
59
+ info.nlink !== 1 ||
60
+ info.size > MAX_REFERENCE_BYTES ||
61
+ (process.platform !== 'win32' &&
62
+ ((info.mode & 0o077) !== 0 || info.uid !== process.getuid?.()))) {
63
+ throw new Error('the turn context reference is not private to this process');
64
+ }
65
+ const parsed = JSON.parse((0, node_fs_1.readFileSync)(fd, 'utf8'));
66
+ if (!parsed ||
67
+ typeof parsed.socket !== 'string' ||
68
+ !parsed.socket.startsWith('/') ||
69
+ typeof parsed.token !== 'string' ||
70
+ parsed.token.length < 32) {
71
+ throw new Error('the turn context reference is invalid');
72
+ }
73
+ return { socket: parsed.socket, token: parsed.token };
74
+ }
75
+ finally {
76
+ (0, node_fs_1.closeSync)(fd);
77
+ }
78
+ }
79
+ function getTurnEnv(reference) {
80
+ return new Promise((resolve, reject) => {
81
+ const req = (0, node_http_1.request)({
82
+ socketPath: reference.socket,
83
+ agent: false,
84
+ method: 'GET',
85
+ path: TURN_CONTEXT_ENV_PATH,
86
+ headers: { authorization: `Bearer ${reference.token}` },
87
+ timeout: TIMEOUT_MS,
88
+ }, (res) => {
89
+ const chunks = [];
90
+ res.on('data', (chunk) => chunks.push(chunk));
91
+ res.on('end', () => {
92
+ let body = null;
93
+ try {
94
+ body = JSON.parse(Buffer.concat(chunks).toString('utf8'));
95
+ }
96
+ catch {
97
+ body = null;
98
+ }
99
+ resolve({ status: res.statusCode ?? 0, body });
100
+ });
101
+ res.on('error', reject);
102
+ });
103
+ req.on('timeout', () => req.destroy(new Error('the turn context did not answer in time')));
104
+ req.on('error', reject);
105
+ req.end();
106
+ });
107
+ }
108
+ function refuse(env, code, message) {
109
+ for (const name of TURN_CREDENTIAL_NAMES) {
110
+ delete env[name];
111
+ delete env[name.replace(/^OVERSKY_/, 'SKRR_')];
112
+ }
113
+ env.OVERSKY_AUTONOMOUS_SESSION = '1';
114
+ return { kind: 'refused', code, message };
115
+ }
116
+ /** Apply the current turn's environment to `env` (default `process.env`). */
117
+ async function hydrateTurnContext(env = process.env) {
118
+ const path = env[exports.TURN_CONTEXT_FILE_ENV]?.trim();
119
+ if (!path)
120
+ return { kind: 'absent' };
121
+ let reference;
122
+ try {
123
+ reference = readReference(path);
124
+ }
125
+ catch (error) {
126
+ return refuse(env, 'TURN_CONTEXT_UNREADABLE', error.message);
127
+ }
128
+ let answer;
129
+ try {
130
+ answer = await getTurnEnv(reference);
131
+ }
132
+ catch (error) {
133
+ return refuse(env, 'TURN_CONTEXT_UNREACHABLE', `the daemon's turn context is unreachable (${error.message})`);
134
+ }
135
+ const body = answer.body;
136
+ if (answer.status !== 200 || !body || typeof body.env !== 'object' || body.env === null) {
137
+ const code = typeof body?.code === 'string' ? body.code : `HTTP_${answer.status}`;
138
+ return refuse(env, code === NO_ACTIVE_TURN ? 'TURN_CONTEXT_NO_ACTIVE_TURN' : 'TURN_CONTEXT_REFUSED', code === NO_ACTIVE_TURN
139
+ ? 'no turn is active on this agent engine; its credentials were revoked when its last turn ended'
140
+ : `the daemon refused the turn context (${code})`);
141
+ }
142
+ const names = [];
143
+ for (const [name, value] of Object.entries(body.env)) {
144
+ if (!HYDRATED_NAME.test(name) || name === exports.TURN_CONTEXT_FILE_ENV)
145
+ continue;
146
+ if (typeof value !== 'string')
147
+ continue;
148
+ env[name] = value;
149
+ names.push(name);
150
+ }
151
+ return { kind: 'hydrated', names: names.sort() };
152
+ }
153
+ /** The sentence a refused command prints. */
154
+ function turnContextRefusalMessage(outcome) {
155
+ return (`skrr will not run here: ${outcome.message}. This process belongs to an agent engine the ` +
156
+ 'skrr background service keeps between turns, and it reads its credentials from the turn ' +
157
+ `that is running now (${outcome.code}).`);
158
+ }
@@ -13,10 +13,14 @@
13
13
  * - The server (`api/server/services/ProviderCredentials/resolveProviderCredential.js`)
14
14
  * sends a credential only in a shape the harness's entry carries, and only
15
15
  * to a daemon that announces the entry (`announcedBy`) and the shape
16
- * (`SHAPE_ANNOUNCED_BY`), apart from a capability still pending
17
- * (`INFERENCE_BROKER_PENDING_CAPABILITIES`). A `byok-local` descriptor
18
- * carries no secret, so it is not gated: a daemon that cannot broker it
19
- * never injects it either.
16
+ * (`SHAPE_ANNOUNCED_BY`). A `byok-local` descriptor carries no secret, so
17
+ * it is not gated by a capability: a daemon that cannot broker it never
18
+ * injects it either. It is still checked against `carries`, and refused for
19
+ * a daemon on a platform-managed machine, whatever that daemon announces
20
+ * (OSK-24515).
21
+ * - The I1 process-tree test (`daemon/src/backends/i1-harness-environment.test.ts`)
22
+ * has a case for every entry here in every platform shape it carries, and
23
+ * fails when an entry or shape is added without one.
20
24
  *
21
25
  * A harness that is not listed is refused before spawn whenever its request
22
26
  * carries a credential, so the server sends it none. It runs on its own
@@ -57,8 +61,7 @@ export declare const HARNESS_CREDENTIAL_BROKER_CAPABILITY = "harness_credential_
57
61
  /**
58
62
  * Announced by a daemon whose broker route carries the first-party harness's
59
63
  * credentials and puts none into its environment (OSK-24515). An older daemon
60
- * put the grant into the harness's environment. Pending until contract
61
- * (`INFERENCE_BROKER_PENDING_CAPABILITIES`): such a daemon is still sent one.
64
+ * put the grant into the harness's environment, so it is sent none.
62
65
  */
63
66
  export declare const FIRST_PARTY_HARNESS_CREDENTIAL_BROKER_CAPABILITY = "first_party_harness_credential_broker_v1";
64
67
  /**
@@ -73,19 +76,16 @@ export declare const PI_CREDENTIAL_BROKER_CAPABILITY = "pi_credential_broker_v1"
73
76
  * Announced by a daemon whose broker redeems a managed lease with a session
74
77
  * token of its own, minted for `INFERENCE_RELAY_AUDIENCE` (OSK-24515). An older
75
78
  * daemon's broker forwarded the token the harness itself holds
76
- * (`OVERSKY_SESSION_TOKEN`), which the relay stops honouring at contract.
77
- * Pending until then (`INFERENCE_BROKER_PENDING_CAPABILITIES`): such a daemon
78
- * is still admitted a lease.
79
+ * (`OVERSKY_SESSION_TOKEN`), which the relay refuses, so it is admitted no
80
+ * lease.
79
81
  */
80
82
  export declare const MANAGED_INFERENCE_BROKER_TOKEN_CAPABILITY = "managed_inference_broker_token_v1";
81
83
  /**
82
84
  * The audience of the session token a broker redeems at the inference relay
83
85
  * (`/api/agentic/sessions/:id/inference/*`). A token minted with it is refused
84
- * everywhere else. Once the relay takes only this audience (the contract half
85
- * of OSK-24515), the token a harness holds for `skrr` and its tool callbacks is
86
- * refused there, so a harness that can read its own environment holds nothing
87
- * it can spend inference with (invariant I1). Until then the relay takes both
88
- * and logs `inference_relay_session_audience` for the older one.
86
+ * everywhere else, and the relay takes no other, so the token a harness holds
87
+ * for `skrr` and its tool callbacks is refused there: a harness that can read
88
+ * its own environment holds nothing it can spend inference with (invariant I1).
89
89
  */
90
90
  export declare const INFERENCE_RELAY_AUDIENCE = "inference";
91
91
  /** The audience of a session token minted without one: every route but the inference relay's. */
@@ -128,36 +128,22 @@ export declare function isPlatformMachineHarness(provider: unknown): boolean;
128
128
  */
129
129
  export declare function inferenceBrokerHarness(provider: unknown): InferenceBrokerHarness | null;
130
130
  /**
131
- * Capabilities a current daemon announces that the server does not REQUIRE
132
- * yet: the expand half of OSK-24515. Daemon and CLI releases ship from `main`
133
- * while the server ships from `beta` at promotion, so no release order makes
134
- * the clients arrive first, and a daemon already in the field (a platform
135
- * machine's image pins one) would otherwise lose a credential it uses today.
136
- * A daemon that lacks one is served exactly as before the capability existed,
137
- * and the server logs `inference_grant_legacy_daemon` (`inferenceBrokerPendingGaps`)
138
- * so the fleet's adoption can be counted.
139
- *
140
- * The contract change empties this list, after which `inferenceBrokerCarries`
141
- * requires every capability. Its merge criterion is in
142
- * `docs/architecture/managed-inference-execution-shapes-2026-08-12.md` §15.
131
+ * What a daemon announcing `announced` lacks to broker a credential of `shape`
132
+ * for `provider`: null when no daemon can (an unlisted harness, or a shape its
133
+ * entry does not carry), else the capabilities it does not announce, empty when
134
+ * it brokers it. Every capability listed here is one a current daemon
135
+ * announces, so a non-empty list is a daemon an update fixes, and the server
136
+ * words its refusal that way (OSK-24515). An absent or unreadable capability
137
+ * list announces nothing.
143
138
  */
144
- export declare const INFERENCE_BROKER_PENDING_CAPABILITIES: readonly string[];
139
+ export declare function inferenceBrokerMissingCapabilities(provider: unknown, shape: InferenceBrokerCredentialShape, announced: readonly unknown[] | null | undefined): string[] | null;
145
140
  /**
146
141
  * Whether a daemon announcing `announced` brokers a credential of `shape` for
147
- * `provider`. False for an unlisted harness, for a shape its entry does not
148
- * carry, and for a daemon that does not announce a required capability of the
149
- * entry or the shape. A pending capability is not required yet
150
- * (`INFERENCE_BROKER_PENDING_CAPABILITIES`). An absent or unreadable capability
151
- * list announces nothing.
142
+ * `provider`: false for an unlisted harness, for a shape its entry does not
143
+ * carry, and for a daemon that does not announce every capability of the entry
144
+ * and the shape (`inferenceBrokerMissingCapabilities`).
152
145
  */
153
146
  export declare function inferenceBrokerCarries(provider: unknown, shape: InferenceBrokerCredentialShape, announced: readonly unknown[] | null | undefined): boolean;
154
- /**
155
- * The pending capabilities a daemon announcing `announced` lacks for `shape` of
156
- * `provider`: the reasons contract will refuse what expand still serves. Empty
157
- * when the daemon announces them all, and when the harness or the shape is
158
- * never carried (refused already, so nothing changes at contract).
159
- */
160
- export declare function inferenceBrokerPendingGaps(provider: unknown, shape: InferenceBrokerCredentialShape, announced: readonly unknown[] | null | undefined): string[];
161
147
  /**
162
148
  * Every capability the server sends a credential by, for the daemon to announce
163
149
  * and the server's register guard to keep (`registerGuards.scopeAnnouncedCapabilities`).
@@ -23,7 +23,6 @@ __export(inferenceBrokerHarnesses_exports, {
23
23
  INFERENCE_BROKER_CAPABILITIES: () => INFERENCE_BROKER_CAPABILITIES,
24
24
  INFERENCE_BROKER_CREDENTIAL_SHAPES: () => INFERENCE_BROKER_CREDENTIAL_SHAPES,
25
25
  INFERENCE_BROKER_HARNESSES: () => INFERENCE_BROKER_HARNESSES,
26
- INFERENCE_BROKER_PENDING_CAPABILITIES: () => INFERENCE_BROKER_PENDING_CAPABILITIES,
27
26
  INFERENCE_RELAY_AUDIENCE: () => INFERENCE_RELAY_AUDIENCE,
28
27
  MANAGED_INFERENCE_BROKER_TOKEN_CAPABILITY: () => MANAGED_INFERENCE_BROKER_TOKEN_CAPABILITY,
29
28
  PI_CREDENTIAL_BROKER_CAPABILITY: () => PI_CREDENTIAL_BROKER_CAPABILITY,
@@ -31,7 +30,7 @@ __export(inferenceBrokerHarnesses_exports, {
31
30
  SESSION_TOKEN_AUDIENCE: () => SESSION_TOKEN_AUDIENCE,
32
31
  inferenceBrokerCarries: () => inferenceBrokerCarries,
33
32
  inferenceBrokerHarness: () => inferenceBrokerHarness,
34
- inferenceBrokerPendingGaps: () => inferenceBrokerPendingGaps,
33
+ inferenceBrokerMissingCapabilities: () => inferenceBrokerMissingCapabilities,
35
34
  isPlatformMachineHarness: () => isPlatformMachineHarness
36
35
  });
37
36
  module.exports = __toCommonJS(inferenceBrokerHarnesses_exports);
@@ -81,30 +80,21 @@ function inferenceBrokerHarness(provider) {
81
80
  const canonical = (0, import_firstPartyHarness.canonicalHarnessProvider)(provider);
82
81
  return INFERENCE_BROKER_HARNESSES.find((entry) => entry.provider === canonical) ?? null;
83
82
  }
84
- const INFERENCE_BROKER_PENDING_CAPABILITIES = Object.freeze([
85
- FIRST_PARTY_HARNESS_CREDENTIAL_BROKER_CAPABILITY,
86
- MANAGED_INFERENCE_BROKER_TOKEN_CAPABILITY
87
- ]);
88
83
  function announcedCapabilitiesFor(provider, shape) {
89
84
  const entry = inferenceBrokerHarness(provider);
90
85
  if (!entry || !entry.carries.includes(shape))
91
86
  return null;
92
87
  return [entry.announcedBy, SHAPE_ANNOUNCED_BY[shape]].filter((capability) => typeof capability === "string");
93
88
  }
94
- function announces(announced, capability) {
95
- return Array.isArray(announced) && announced.includes(capability);
96
- }
97
- function inferenceBrokerCarries(provider, shape, announced) {
89
+ function inferenceBrokerMissingCapabilities(provider, shape, announced) {
98
90
  const capabilities = announcedCapabilitiesFor(provider, shape);
99
91
  if (!capabilities)
100
- return false;
101
- return capabilities.filter((capability) => !INFERENCE_BROKER_PENDING_CAPABILITIES.includes(capability)).every((capability) => announces(announced, capability));
92
+ return null;
93
+ return capabilities.filter((capability) => !(Array.isArray(announced) && announced.includes(capability)));
102
94
  }
103
- function inferenceBrokerPendingGaps(provider, shape, announced) {
104
- const capabilities = announcedCapabilitiesFor(provider, shape);
105
- if (!capabilities)
106
- return [];
107
- return capabilities.filter((capability) => INFERENCE_BROKER_PENDING_CAPABILITIES.includes(capability) && !announces(announced, capability));
95
+ function inferenceBrokerCarries(provider, shape, announced) {
96
+ const missing = inferenceBrokerMissingCapabilities(provider, shape, announced);
97
+ return missing !== null && missing.length === 0;
108
98
  }
109
99
  const INFERENCE_BROKER_CAPABILITIES = Object.freeze([
110
100
  ...new Set([
@@ -119,7 +109,6 @@ const INFERENCE_BROKER_CAPABILITIES = Object.freeze([
119
109
  INFERENCE_BROKER_CAPABILITIES,
120
110
  INFERENCE_BROKER_CREDENTIAL_SHAPES,
121
111
  INFERENCE_BROKER_HARNESSES,
122
- INFERENCE_BROKER_PENDING_CAPABILITIES,
123
112
  INFERENCE_RELAY_AUDIENCE,
124
113
  MANAGED_INFERENCE_BROKER_TOKEN_CAPABILITY,
125
114
  PI_CREDENTIAL_BROKER_CAPABILITY,
@@ -127,6 +116,6 @@ const INFERENCE_BROKER_CAPABILITIES = Object.freeze([
127
116
  SESSION_TOKEN_AUDIENCE,
128
117
  inferenceBrokerCarries,
129
118
  inferenceBrokerHarness,
130
- inferenceBrokerPendingGaps,
119
+ inferenceBrokerMissingCapabilities,
131
120
  isPlatformMachineHarness
132
121
  });
@@ -13,10 +13,14 @@
13
13
  * - The server (`api/server/services/ProviderCredentials/resolveProviderCredential.js`)
14
14
  * sends a credential only in a shape the harness's entry carries, and only
15
15
  * to a daemon that announces the entry (`announcedBy`) and the shape
16
- * (`SHAPE_ANNOUNCED_BY`), apart from a capability still pending
17
- * (`INFERENCE_BROKER_PENDING_CAPABILITIES`). A `byok-local` descriptor
18
- * carries no secret, so it is not gated: a daemon that cannot broker it
19
- * never injects it either.
16
+ * (`SHAPE_ANNOUNCED_BY`). A `byok-local` descriptor carries no secret, so
17
+ * it is not gated by a capability: a daemon that cannot broker it never
18
+ * injects it either. It is still checked against `carries`, and refused for
19
+ * a daemon on a platform-managed machine, whatever that daemon announces
20
+ * (OSK-24515).
21
+ * - The I1 process-tree test (`daemon/src/backends/i1-harness-environment.test.ts`)
22
+ * has a case for every entry here in every platform shape it carries, and
23
+ * fails when an entry or shape is added without one.
20
24
  *
21
25
  * A harness that is not listed is refused before spawn whenever its request
22
26
  * carries a credential, so the server sends it none. It runs on its own
@@ -57,8 +61,7 @@ export declare const HARNESS_CREDENTIAL_BROKER_CAPABILITY = "harness_credential_
57
61
  /**
58
62
  * Announced by a daemon whose broker route carries the first-party harness's
59
63
  * credentials and puts none into its environment (OSK-24515). An older daemon
60
- * put the grant into the harness's environment. Pending until contract
61
- * (`INFERENCE_BROKER_PENDING_CAPABILITIES`): such a daemon is still sent one.
64
+ * put the grant into the harness's environment, so it is sent none.
62
65
  */
63
66
  export declare const FIRST_PARTY_HARNESS_CREDENTIAL_BROKER_CAPABILITY = "first_party_harness_credential_broker_v1";
64
67
  /**
@@ -73,19 +76,16 @@ export declare const PI_CREDENTIAL_BROKER_CAPABILITY = "pi_credential_broker_v1"
73
76
  * Announced by a daemon whose broker redeems a managed lease with a session
74
77
  * token of its own, minted for `INFERENCE_RELAY_AUDIENCE` (OSK-24515). An older
75
78
  * daemon's broker forwarded the token the harness itself holds
76
- * (`OVERSKY_SESSION_TOKEN`), which the relay stops honouring at contract.
77
- * Pending until then (`INFERENCE_BROKER_PENDING_CAPABILITIES`): such a daemon
78
- * is still admitted a lease.
79
+ * (`OVERSKY_SESSION_TOKEN`), which the relay refuses, so it is admitted no
80
+ * lease.
79
81
  */
80
82
  export declare const MANAGED_INFERENCE_BROKER_TOKEN_CAPABILITY = "managed_inference_broker_token_v1";
81
83
  /**
82
84
  * The audience of the session token a broker redeems at the inference relay
83
85
  * (`/api/agentic/sessions/:id/inference/*`). A token minted with it is refused
84
- * everywhere else. Once the relay takes only this audience (the contract half
85
- * of OSK-24515), the token a harness holds for `skrr` and its tool callbacks is
86
- * refused there, so a harness that can read its own environment holds nothing
87
- * it can spend inference with (invariant I1). Until then the relay takes both
88
- * and logs `inference_relay_session_audience` for the older one.
86
+ * everywhere else, and the relay takes no other, so the token a harness holds
87
+ * for `skrr` and its tool callbacks is refused there: a harness that can read
88
+ * its own environment holds nothing it can spend inference with (invariant I1).
89
89
  */
90
90
  export declare const INFERENCE_RELAY_AUDIENCE = "inference";
91
91
  /** The audience of a session token minted without one: every route but the inference relay's. */
@@ -128,36 +128,22 @@ export declare function isPlatformMachineHarness(provider: unknown): boolean;
128
128
  */
129
129
  export declare function inferenceBrokerHarness(provider: unknown): InferenceBrokerHarness | null;
130
130
  /**
131
- * Capabilities a current daemon announces that the server does not REQUIRE
132
- * yet: the expand half of OSK-24515. Daemon and CLI releases ship from `main`
133
- * while the server ships from `beta` at promotion, so no release order makes
134
- * the clients arrive first, and a daemon already in the field (a platform
135
- * machine's image pins one) would otherwise lose a credential it uses today.
136
- * A daemon that lacks one is served exactly as before the capability existed,
137
- * and the server logs `inference_grant_legacy_daemon` (`inferenceBrokerPendingGaps`)
138
- * so the fleet's adoption can be counted.
139
- *
140
- * The contract change empties this list, after which `inferenceBrokerCarries`
141
- * requires every capability. Its merge criterion is in
142
- * `docs/architecture/managed-inference-execution-shapes-2026-08-12.md` §15.
131
+ * What a daemon announcing `announced` lacks to broker a credential of `shape`
132
+ * for `provider`: null when no daemon can (an unlisted harness, or a shape its
133
+ * entry does not carry), else the capabilities it does not announce, empty when
134
+ * it brokers it. Every capability listed here is one a current daemon
135
+ * announces, so a non-empty list is a daemon an update fixes, and the server
136
+ * words its refusal that way (OSK-24515). An absent or unreadable capability
137
+ * list announces nothing.
143
138
  */
144
- export declare const INFERENCE_BROKER_PENDING_CAPABILITIES: readonly string[];
139
+ export declare function inferenceBrokerMissingCapabilities(provider: unknown, shape: InferenceBrokerCredentialShape, announced: readonly unknown[] | null | undefined): string[] | null;
145
140
  /**
146
141
  * Whether a daemon announcing `announced` brokers a credential of `shape` for
147
- * `provider`. False for an unlisted harness, for a shape its entry does not
148
- * carry, and for a daemon that does not announce a required capability of the
149
- * entry or the shape. A pending capability is not required yet
150
- * (`INFERENCE_BROKER_PENDING_CAPABILITIES`). An absent or unreadable capability
151
- * list announces nothing.
142
+ * `provider`: false for an unlisted harness, for a shape its entry does not
143
+ * carry, and for a daemon that does not announce every capability of the entry
144
+ * and the shape (`inferenceBrokerMissingCapabilities`).
152
145
  */
153
146
  export declare function inferenceBrokerCarries(provider: unknown, shape: InferenceBrokerCredentialShape, announced: readonly unknown[] | null | undefined): boolean;
154
- /**
155
- * The pending capabilities a daemon announcing `announced` lacks for `shape` of
156
- * `provider`: the reasons contract will refuse what expand still serves. Empty
157
- * when the daemon announces them all, and when the harness or the shape is
158
- * never carried (refused already, so nothing changes at contract).
159
- */
160
- export declare function inferenceBrokerPendingGaps(provider: unknown, shape: InferenceBrokerCredentialShape, announced: readonly unknown[] | null | undefined): string[];
161
147
  /**
162
148
  * Every capability the server sends a credential by, for the daemon to announce
163
149
  * and the server's register guard to keep (`registerGuards.scopeAnnouncedCapabilities`).
@@ -13,10 +13,14 @@
13
13
  * - The server (`api/server/services/ProviderCredentials/resolveProviderCredential.js`)
14
14
  * sends a credential only in a shape the harness's entry carries, and only
15
15
  * to a daemon that announces the entry (`announcedBy`) and the shape
16
- * (`SHAPE_ANNOUNCED_BY`), apart from a capability still pending
17
- * (`INFERENCE_BROKER_PENDING_CAPABILITIES`). A `byok-local` descriptor
18
- * carries no secret, so it is not gated: a daemon that cannot broker it
19
- * never injects it either.
16
+ * (`SHAPE_ANNOUNCED_BY`). A `byok-local` descriptor carries no secret, so
17
+ * it is not gated by a capability: a daemon that cannot broker it never
18
+ * injects it either. It is still checked against `carries`, and refused for
19
+ * a daemon on a platform-managed machine, whatever that daemon announces
20
+ * (OSK-24515).
21
+ * - The I1 process-tree test (`daemon/src/backends/i1-harness-environment.test.ts`)
22
+ * has a case for every entry here in every platform shape it carries, and
23
+ * fails when an entry or shape is added without one.
20
24
  *
21
25
  * A harness that is not listed is refused before spawn whenever its request
22
26
  * carries a credential, so the server sends it none. It runs on its own
@@ -47,8 +51,7 @@ export const HARNESS_CREDENTIAL_BROKER_CAPABILITY = 'harness_credential_broker_v
47
51
  /**
48
52
  * Announced by a daemon whose broker route carries the first-party harness's
49
53
  * credentials and puts none into its environment (OSK-24515). An older daemon
50
- * put the grant into the harness's environment. Pending until contract
51
- * (`INFERENCE_BROKER_PENDING_CAPABILITIES`): such a daemon is still sent one.
54
+ * put the grant into the harness's environment, so it is sent none.
52
55
  */
53
56
  export const FIRST_PARTY_HARNESS_CREDENTIAL_BROKER_CAPABILITY = 'first_party_harness_credential_broker_v1';
54
57
  /**
@@ -63,19 +66,16 @@ export const PI_CREDENTIAL_BROKER_CAPABILITY = 'pi_credential_broker_v1';
63
66
  * Announced by a daemon whose broker redeems a managed lease with a session
64
67
  * token of its own, minted for `INFERENCE_RELAY_AUDIENCE` (OSK-24515). An older
65
68
  * daemon's broker forwarded the token the harness itself holds
66
- * (`OVERSKY_SESSION_TOKEN`), which the relay stops honouring at contract.
67
- * Pending until then (`INFERENCE_BROKER_PENDING_CAPABILITIES`): such a daemon
68
- * is still admitted a lease.
69
+ * (`OVERSKY_SESSION_TOKEN`), which the relay refuses, so it is admitted no
70
+ * lease.
69
71
  */
70
72
  export const MANAGED_INFERENCE_BROKER_TOKEN_CAPABILITY = 'managed_inference_broker_token_v1';
71
73
  /**
72
74
  * The audience of the session token a broker redeems at the inference relay
73
75
  * (`/api/agentic/sessions/:id/inference/*`). A token minted with it is refused
74
- * everywhere else. Once the relay takes only this audience (the contract half
75
- * of OSK-24515), the token a harness holds for `skrr` and its tool callbacks is
76
- * refused there, so a harness that can read its own environment holds nothing
77
- * it can spend inference with (invariant I1). Until then the relay takes both
78
- * and logs `inference_relay_session_audience` for the older one.
76
+ * everywhere else, and the relay takes no other, so the token a harness holds
77
+ * for `skrr` and its tool callbacks is refused there: a harness that can read
78
+ * its own environment holds nothing it can spend inference with (invariant I1).
79
79
  */
80
80
  export const INFERENCE_RELAY_AUDIENCE = 'inference';
81
81
  /** The audience of a session token minted without one: every route but the inference relay's. */
@@ -134,24 +134,6 @@ export function inferenceBrokerHarness(provider) {
134
134
  const canonical = canonicalHarnessProvider(provider);
135
135
  return INFERENCE_BROKER_HARNESSES.find((entry) => entry.provider === canonical) ?? null;
136
136
  }
137
- /**
138
- * Capabilities a current daemon announces that the server does not REQUIRE
139
- * yet: the expand half of OSK-24515. Daemon and CLI releases ship from `main`
140
- * while the server ships from `beta` at promotion, so no release order makes
141
- * the clients arrive first, and a daemon already in the field (a platform
142
- * machine's image pins one) would otherwise lose a credential it uses today.
143
- * A daemon that lacks one is served exactly as before the capability existed,
144
- * and the server logs `inference_grant_legacy_daemon` (`inferenceBrokerPendingGaps`)
145
- * so the fleet's adoption can be counted.
146
- *
147
- * The contract change empties this list, after which `inferenceBrokerCarries`
148
- * requires every capability. Its merge criterion is in
149
- * `docs/architecture/managed-inference-execution-shapes-2026-08-12.md` §15.
150
- */
151
- export const INFERENCE_BROKER_PENDING_CAPABILITIES = Object.freeze([
152
- FIRST_PARTY_HARNESS_CREDENTIAL_BROKER_CAPABILITY,
153
- MANAGED_INFERENCE_BROKER_TOKEN_CAPABILITY,
154
- ]);
155
137
  /** Every capability a daemon announces when it brokers `shape` for `provider`, or null when it never can. */
156
138
  function announcedCapabilitiesFor(provider, shape) {
157
139
  const entry = inferenceBrokerHarness(provider);
@@ -159,37 +141,30 @@ function announcedCapabilitiesFor(provider, shape) {
159
141
  return null;
160
142
  return [entry.announcedBy, SHAPE_ANNOUNCED_BY[shape]].filter((capability) => typeof capability === 'string');
161
143
  }
162
- function announces(announced, capability) {
163
- return Array.isArray(announced) && announced.includes(capability);
164
- }
165
144
  /**
166
- * Whether a daemon announcing `announced` brokers a credential of `shape` for
167
- * `provider`. False for an unlisted harness, for a shape its entry does not
168
- * carry, and for a daemon that does not announce a required capability of the
169
- * entry or the shape. A pending capability is not required yet
170
- * (`INFERENCE_BROKER_PENDING_CAPABILITIES`). An absent or unreadable capability
145
+ * What a daemon announcing `announced` lacks to broker a credential of `shape`
146
+ * for `provider`: null when no daemon can (an unlisted harness, or a shape its
147
+ * entry does not carry), else the capabilities it does not announce, empty when
148
+ * it brokers it. Every capability listed here is one a current daemon
149
+ * announces, so a non-empty list is a daemon an update fixes, and the server
150
+ * words its refusal that way (OSK-24515). An absent or unreadable capability
171
151
  * list announces nothing.
172
152
  */
173
- export function inferenceBrokerCarries(provider, shape, announced) {
153
+ export function inferenceBrokerMissingCapabilities(provider, shape, announced) {
174
154
  const capabilities = announcedCapabilitiesFor(provider, shape);
175
155
  if (!capabilities)
176
- return false;
177
- return capabilities
178
- .filter((capability) => !INFERENCE_BROKER_PENDING_CAPABILITIES.includes(capability))
179
- .every((capability) => announces(announced, capability));
156
+ return null;
157
+ return capabilities.filter((capability) => !(Array.isArray(announced) && announced.includes(capability)));
180
158
  }
181
159
  /**
182
- * The pending capabilities a daemon announcing `announced` lacks for `shape` of
183
- * `provider`: the reasons contract will refuse what expand still serves. Empty
184
- * when the daemon announces them all, and when the harness or the shape is
185
- * never carried (refused already, so nothing changes at contract).
160
+ * Whether a daemon announcing `announced` brokers a credential of `shape` for
161
+ * `provider`: false for an unlisted harness, for a shape its entry does not
162
+ * carry, and for a daemon that does not announce every capability of the entry
163
+ * and the shape (`inferenceBrokerMissingCapabilities`).
186
164
  */
187
- export function inferenceBrokerPendingGaps(provider, shape, announced) {
188
- const capabilities = announcedCapabilitiesFor(provider, shape);
189
- if (!capabilities)
190
- return [];
191
- return capabilities.filter((capability) => INFERENCE_BROKER_PENDING_CAPABILITIES.includes(capability) &&
192
- !announces(announced, capability));
165
+ export function inferenceBrokerCarries(provider, shape, announced) {
166
+ const missing = inferenceBrokerMissingCapabilities(provider, shape, announced);
167
+ return missing !== null && missing.length === 0;
193
168
  }
194
169
  /**
195
170
  * Every capability the server sends a credential by, for the daemon to announce