@skrr-ai/cli 0.1.173 → 0.1.175
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/harnesses/rollouts/grant.d.ts +6 -4
- package/dist/commands/harnesses/rollouts/grant.js +28 -8
- package/dist/commands/harnesses/rollouts/list.d.ts +10 -4
- package/dist/commands/harnesses/rollouts/list.js +22 -8
- package/dist/commands/harnesses/rollouts/revoke.d.ts +4 -2
- package/dist/commands/harnesses/rollouts/revoke.js +24 -5
- package/dist/commands/harnesses/usage.d.ts +19 -1
- package/dist/commands/harnesses/usage.js +33 -8
- package/dist/hooks/init.js +9 -0
- package/dist/lib/balance.d.ts +17 -0
- package/dist/lib/balance.js +48 -5
- package/dist/lib/provider-rollouts.d.ts +26 -5
- package/dist/lib/provider-rollouts.js +22 -0
- package/dist/lib/turn-context.d.ts +20 -0
- package/dist/lib/turn-context.js +158 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/inferenceBrokerHarnesses.d.ts +25 -39
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/inferenceBrokerHarnesses.js +8 -19
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/inferenceBrokerHarnesses.d.ts +25 -39
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/inferenceBrokerHarnesses.js +30 -55
- package/dist/node_modules/@skrr-ai/data-provider/index.js +11164 -11130
- package/oclif.manifest.json +38 -10
- package/package.json +2 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.listProviderRollouts = listProviderRollouts;
|
|
4
|
+
exports.providerRolloutSubjectFromFlags = providerRolloutSubjectFromFlags;
|
|
4
5
|
exports.grantProviderRollout = grantProviderRollout;
|
|
5
6
|
exports.revokeProviderRollout = revokeProviderRollout;
|
|
6
7
|
const api_fetch_1 = require("./api-fetch");
|
|
@@ -8,11 +9,32 @@ const triggers_1 = require("./triggers");
|
|
|
8
9
|
async function listProviderRollouts(opts = {}) {
|
|
9
10
|
return (0, api_fetch_1.apiFetch)((0, triggers_1.withQuery)('/api/admin/provider-rollouts', {
|
|
10
11
|
provider: opts.provider,
|
|
12
|
+
subjectType: opts.subjectType,
|
|
11
13
|
subjectId: opts.subjectId,
|
|
12
14
|
includeRevoked: opts.includeRevoked ? 'true' : undefined,
|
|
13
15
|
limit: opts.limit,
|
|
14
16
|
}));
|
|
15
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* The subject a `grant` / `revoke` / `list` invocation names, from its flags.
|
|
20
|
+
* `--for-workspace`, not `--workspace`: the global `--workspace` flag scopes the
|
|
21
|
+
* REQUEST (`X-Workspace-Id`), and reusing the name would make one flag mean two
|
|
22
|
+
* things. Exactly one of the two is required; the commands declare that with
|
|
23
|
+
* oclif's `exactlyOne`, and this repeats it so a caller cannot build a subject
|
|
24
|
+
* that names both or neither.
|
|
25
|
+
*/
|
|
26
|
+
function providerRolloutSubjectFromFlags(flags) {
|
|
27
|
+
const user = flags.user?.trim();
|
|
28
|
+
const workspace = flags['for-workspace']?.trim();
|
|
29
|
+
if (user && workspace) {
|
|
30
|
+
throw new Error('Name one subject: --user <id|me> or --for-workspace <workspace-id>, not both.');
|
|
31
|
+
}
|
|
32
|
+
if (user)
|
|
33
|
+
return { type: 'user', id: user };
|
|
34
|
+
if (workspace)
|
|
35
|
+
return { type: 'workspace', id: workspace };
|
|
36
|
+
throw new Error('Name a subject: --user <id|me> or --for-workspace <workspace-id>.');
|
|
37
|
+
}
|
|
16
38
|
/** Release `provider` to one subject. Idempotent: an active grant comes back as is. */
|
|
17
39
|
async function grantProviderRollout(provider, subject, reason) {
|
|
18
40
|
return (0, api_fetch_1.apiFetch)(`/api/admin/provider-rollouts/${encodeURIComponent(provider)}/subjects/${encodeURIComponent(subject.type)}/${encodeURIComponent(subject.id)}`, { method: 'PUT', body: { reason } });
|
|
@@ -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`)
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
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
|
|
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
|
|
77
|
-
*
|
|
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
|
|
85
|
-
*
|
|
86
|
-
*
|
|
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
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
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
|
|
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
|
|
148
|
-
* carry, and for a daemon that does not announce
|
|
149
|
-
*
|
|
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
|
-
|
|
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
|
|
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
|
|
101
|
-
return capabilities.filter((capability) => !
|
|
92
|
+
return null;
|
|
93
|
+
return capabilities.filter((capability) => !(Array.isArray(announced) && announced.includes(capability)));
|
|
102
94
|
}
|
|
103
|
-
function
|
|
104
|
-
const
|
|
105
|
-
|
|
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
|
-
|
|
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`)
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
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
|
|
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
|
|
77
|
-
*
|
|
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
|
|
85
|
-
*
|
|
86
|
-
*
|
|
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
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
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
|
|
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
|
|
148
|
-
* carry, and for a daemon that does not announce
|
|
149
|
-
*
|
|
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`)
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
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
|
|
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
|
|
67
|
-
*
|
|
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
|
|
75
|
-
*
|
|
76
|
-
*
|
|
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
|
-
*
|
|
167
|
-
* `provider
|
|
168
|
-
* carry,
|
|
169
|
-
*
|
|
170
|
-
*
|
|
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
|
|
153
|
+
export function inferenceBrokerMissingCapabilities(provider, shape, announced) {
|
|
174
154
|
const capabilities = announcedCapabilitiesFor(provider, shape);
|
|
175
155
|
if (!capabilities)
|
|
176
|
-
return
|
|
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
|
-
*
|
|
183
|
-
* `provider`:
|
|
184
|
-
*
|
|
185
|
-
*
|
|
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
|
|
188
|
-
const
|
|
189
|
-
|
|
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
|