@skrr-ai/cli 0.1.178 → 0.1.179
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/evaluations/evidence.d.ts +20 -0
- package/dist/commands/harnesses/evaluations/evidence.js +72 -0
- package/dist/commands/harnesses/evaluations/grant.d.ts +30 -0
- package/dist/commands/harnesses/evaluations/grant.js +109 -0
- package/dist/commands/harnesses/evaluations/list.d.ts +18 -0
- package/dist/commands/harnesses/evaluations/list.js +73 -0
- package/dist/commands/harnesses/evaluations/revoke.d.ts +19 -0
- package/dist/commands/harnesses/evaluations/revoke.js +45 -0
- package/dist/commands/harnesses/evaluations/show.d.ts +14 -0
- package/dist/commands/harnesses/evaluations/show.js +46 -0
- package/dist/commands/harnesses/list.d.ts +1 -0
- package/dist/commands/harnesses/list.js +11 -2
- package/dist/commands/harnesses/show.js +5 -0
- package/dist/lib/harness-evaluations.d.ts +166 -0
- package/dist/lib/harness-evaluations.js +58 -0
- package/dist/lib/harness-labels.d.ts +10 -0
- package/dist/lib/harness-labels.js +23 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/inferenceBrokerHarnesses.d.ts +12 -2
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/inferenceBrokerHarnesses.js +12 -5
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/inferenceBrokerHarnesses.d.ts +12 -2
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/inferenceBrokerHarnesses.js +21 -7
- package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-inference-broker.d.ts +9 -9
- package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-inference-broker.js +58 -5
- package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-inference-broker.d.ts +9 -9
- package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-inference-broker.js +78 -9
- package/oclif.manifest.json +477 -1
- package/package.json +5 -2
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Harness evaluations on platform machines (OSK-24597): `/api/admin/harness-evaluations`.
|
|
3
|
+
*
|
|
4
|
+
* A harness the registry marks `evaluating` at platform-machine (pi, copilot-sdk) is never offered
|
|
5
|
+
* on a Hosted Machine or a Dedicated Runtime, so its H9 admission there can never be measured. A
|
|
6
|
+
* grant lets ONE such harness, at ONE exact image version, run ONE to four catalog models on ONE
|
|
7
|
+
* of your own platform machines, for your own turns, for at most six hours and a capped spend,
|
|
8
|
+
* through the same daemon, broker, relay and gateway lease an admitted harness uses. The machine's
|
|
9
|
+
* harness list shows the row as evaluating, by whom and until when.
|
|
10
|
+
*
|
|
11
|
+
* Platform admins only, signed in as a person (`skrr login`). A personal access token is refused
|
|
12
|
+
* for every `/api/admin` path, and a daemon credential for this one.
|
|
13
|
+
*
|
|
14
|
+
* Paths are written INLINE at each call so `cli/src/__tests__/helpers/api-surface.ts` can read
|
|
15
|
+
* them; queries ride in `withQuery` for the same reason.
|
|
16
|
+
*/
|
|
17
|
+
export interface HarnessEvaluationAdmission {
|
|
18
|
+
reservationId: string;
|
|
19
|
+
sessionId: string;
|
|
20
|
+
model: string;
|
|
21
|
+
authorizedUsd: number;
|
|
22
|
+
at: string;
|
|
23
|
+
}
|
|
24
|
+
export interface HarnessEvaluationGrant {
|
|
25
|
+
grantId: string;
|
|
26
|
+
harness: string;
|
|
27
|
+
version: string;
|
|
28
|
+
models: string[];
|
|
29
|
+
daemonId: string;
|
|
30
|
+
machineUuid: string | null;
|
|
31
|
+
ownerUserId: string | null;
|
|
32
|
+
state: 'active' | 'expired' | 'revoked';
|
|
33
|
+
active: boolean;
|
|
34
|
+
expiresAt: string | null;
|
|
35
|
+
maxSpendUsd: number;
|
|
36
|
+
admissions: HarnessEvaluationAdmission[];
|
|
37
|
+
grantReason: string;
|
|
38
|
+
grantedAt: string | null;
|
|
39
|
+
revokedAt: string | null;
|
|
40
|
+
revokedByUserId: string | null;
|
|
41
|
+
revokeReason: string | null;
|
|
42
|
+
}
|
|
43
|
+
export interface HarnessEvaluationGatewayRow {
|
|
44
|
+
callId: string | null;
|
|
45
|
+
sessionId: string | null;
|
|
46
|
+
status: string | null;
|
|
47
|
+
model: string | null;
|
|
48
|
+
startMs: number | null;
|
|
49
|
+
endMs: number | null;
|
|
50
|
+
errorClass: string | null;
|
|
51
|
+
errorCode: string | null;
|
|
52
|
+
clientDisconnected: string | null;
|
|
53
|
+
spend: number | null;
|
|
54
|
+
completionTokens: number | null;
|
|
55
|
+
}
|
|
56
|
+
export interface HarnessEvaluationCall {
|
|
57
|
+
providerRequestId: string;
|
|
58
|
+
startedAt: string | null;
|
|
59
|
+
observation: string;
|
|
60
|
+
gateway?: HarnessEvaluationGatewayRow | {
|
|
61
|
+
readError: string;
|
|
62
|
+
} | null;
|
|
63
|
+
}
|
|
64
|
+
export interface HarnessEvaluationTurn {
|
|
65
|
+
reservationId: string;
|
|
66
|
+
sessionId: string;
|
|
67
|
+
model: string;
|
|
68
|
+
claimedAt: string | null;
|
|
69
|
+
authorizedUsd: number;
|
|
70
|
+
reservation: {
|
|
71
|
+
status: string;
|
|
72
|
+
provider: string;
|
|
73
|
+
model: string;
|
|
74
|
+
harnessVersion: string | null;
|
|
75
|
+
harnessPlacement: string | null;
|
|
76
|
+
daemonId: string | null;
|
|
77
|
+
authorizedUsd: number;
|
|
78
|
+
settledUsd: number | null;
|
|
79
|
+
createdAt: string | null;
|
|
80
|
+
finalizedAt: string | null;
|
|
81
|
+
finalizationReason: string | null;
|
|
82
|
+
} | null;
|
|
83
|
+
calls: HarnessEvaluationCall[];
|
|
84
|
+
}
|
|
85
|
+
export interface HarnessEvaluationEvidence {
|
|
86
|
+
grant: HarnessEvaluationGrant;
|
|
87
|
+
machine: {
|
|
88
|
+
daemonId: string;
|
|
89
|
+
machineProduct: string | null;
|
|
90
|
+
machineUuid: string | null;
|
|
91
|
+
image: string | null;
|
|
92
|
+
unavailable?: string;
|
|
93
|
+
};
|
|
94
|
+
continuity?: {
|
|
95
|
+
conversationId: string;
|
|
96
|
+
platformSessionId: string | null;
|
|
97
|
+
nativeSessionId: string | null;
|
|
98
|
+
sdkSessionId: string | null;
|
|
99
|
+
harness: string | null;
|
|
100
|
+
grantSessionMatch: boolean;
|
|
101
|
+
receipt: {
|
|
102
|
+
platformSessionId: string;
|
|
103
|
+
nativeSessionId: string;
|
|
104
|
+
daemonId: string;
|
|
105
|
+
resumed: boolean;
|
|
106
|
+
recordedAt: string | null;
|
|
107
|
+
} | null;
|
|
108
|
+
};
|
|
109
|
+
turns: HarnessEvaluationTurn[];
|
|
110
|
+
gateway?: {
|
|
111
|
+
unavailable: string | null;
|
|
112
|
+
reads: number;
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
export interface GrantHarnessEvaluationInput {
|
|
116
|
+
harness: string;
|
|
117
|
+
version: string;
|
|
118
|
+
models: string[];
|
|
119
|
+
daemonId: string;
|
|
120
|
+
reason: string;
|
|
121
|
+
ttlMinutes?: number;
|
|
122
|
+
maxSpendUsd?: number;
|
|
123
|
+
}
|
|
124
|
+
/** Issue a grant for one of your own platform machines. */
|
|
125
|
+
export declare function grantHarnessEvaluation(input: GrantHarnessEvaluationInput): Promise<{
|
|
126
|
+
created: boolean;
|
|
127
|
+
grant: HarnessEvaluationGrant;
|
|
128
|
+
}>;
|
|
129
|
+
/** Your grants, newest first; expired and withdrawn ones with `includeEnded`. */
|
|
130
|
+
export declare function listHarnessEvaluations(opts?: {
|
|
131
|
+
harness?: string;
|
|
132
|
+
daemonId?: string;
|
|
133
|
+
includeEnded?: boolean;
|
|
134
|
+
limit?: number;
|
|
135
|
+
}): Promise<{
|
|
136
|
+
grants: HarnessEvaluationGrant[];
|
|
137
|
+
}>;
|
|
138
|
+
/** One of your grants, with every turn it admitted. */
|
|
139
|
+
export declare function showHarnessEvaluation(grantId: string): Promise<{
|
|
140
|
+
grant: HarnessEvaluationGrant;
|
|
141
|
+
}>;
|
|
142
|
+
/** Withdraw a grant. The row is kept as the record. */
|
|
143
|
+
export declare function revokeHarnessEvaluation(grantId: string, reason: string): Promise<{
|
|
144
|
+
revoked: boolean;
|
|
145
|
+
grant: HarnessEvaluationGrant;
|
|
146
|
+
}>;
|
|
147
|
+
/**
|
|
148
|
+
* What the platform recorded for each turn a grant admitted: its reservation and the relay's
|
|
149
|
+
* calls, and with `gateway` the gateway's own spend row for each call.
|
|
150
|
+
*/
|
|
151
|
+
export declare function harnessEvaluationEvidence(grantId: string, opts?: {
|
|
152
|
+
gateway?: boolean;
|
|
153
|
+
conversationId?: string;
|
|
154
|
+
}): Promise<HarnessEvaluationEvidence>;
|
|
155
|
+
/** How a grant's state reads in a table: `active until <iso>`, `expired`, `revoked <iso>`. */
|
|
156
|
+
export declare function harnessEvaluationStateLabel(grant: HarnessEvaluationGrant): string;
|
|
157
|
+
/**
|
|
158
|
+
* Ask a connected daemon to detect its harnesses again and re-register, so a grant issued while it
|
|
159
|
+
* is connected is honoured now rather than at its next reconnect. The same request
|
|
160
|
+
* `skrr harnesses installers` recovery uses (`POST /api/daemons/:id/cli-installers/rescan`).
|
|
161
|
+
*/
|
|
162
|
+
export declare function rescanDaemonHarnesses(daemonId: string): Promise<{
|
|
163
|
+
daemonId: string;
|
|
164
|
+
success?: boolean;
|
|
165
|
+
capabilities?: string[];
|
|
166
|
+
}>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.grantHarnessEvaluation = grantHarnessEvaluation;
|
|
4
|
+
exports.listHarnessEvaluations = listHarnessEvaluations;
|
|
5
|
+
exports.showHarnessEvaluation = showHarnessEvaluation;
|
|
6
|
+
exports.revokeHarnessEvaluation = revokeHarnessEvaluation;
|
|
7
|
+
exports.harnessEvaluationEvidence = harnessEvaluationEvidence;
|
|
8
|
+
exports.harnessEvaluationStateLabel = harnessEvaluationStateLabel;
|
|
9
|
+
exports.rescanDaemonHarnesses = rescanDaemonHarnesses;
|
|
10
|
+
const api_fetch_1 = require("./api-fetch");
|
|
11
|
+
const triggers_1 = require("./triggers");
|
|
12
|
+
/** Issue a grant for one of your own platform machines. */
|
|
13
|
+
async function grantHarnessEvaluation(input) {
|
|
14
|
+
return (0, api_fetch_1.apiFetch)('/api/admin/harness-evaluations', { method: 'POST', body: input });
|
|
15
|
+
}
|
|
16
|
+
/** Your grants, newest first; expired and withdrawn ones with `includeEnded`. */
|
|
17
|
+
async function listHarnessEvaluations(opts = {}) {
|
|
18
|
+
return (0, api_fetch_1.apiFetch)((0, triggers_1.withQuery)('/api/admin/harness-evaluations', {
|
|
19
|
+
harness: opts.harness,
|
|
20
|
+
daemonId: opts.daemonId,
|
|
21
|
+
includeEnded: opts.includeEnded ? 'true' : undefined,
|
|
22
|
+
limit: opts.limit,
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
/** One of your grants, with every turn it admitted. */
|
|
26
|
+
async function showHarnessEvaluation(grantId) {
|
|
27
|
+
return (0, api_fetch_1.apiFetch)(`/api/admin/harness-evaluations/${encodeURIComponent(grantId)}`);
|
|
28
|
+
}
|
|
29
|
+
/** Withdraw a grant. The row is kept as the record. */
|
|
30
|
+
async function revokeHarnessEvaluation(grantId, reason) {
|
|
31
|
+
return (0, api_fetch_1.apiFetch)(`/api/admin/harness-evaluations/${encodeURIComponent(grantId)}/revoke`, { method: 'POST', body: { reason } });
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* What the platform recorded for each turn a grant admitted: its reservation and the relay's
|
|
35
|
+
* calls, and with `gateway` the gateway's own spend row for each call.
|
|
36
|
+
*/
|
|
37
|
+
async function harnessEvaluationEvidence(grantId, opts = {}) {
|
|
38
|
+
return (0, api_fetch_1.apiFetch)((0, triggers_1.withQuery)(`/api/admin/harness-evaluations/${encodeURIComponent(grantId)}/evidence`, {
|
|
39
|
+
gateway: opts.gateway ? 'true' : undefined,
|
|
40
|
+
conversationId: opts.conversationId,
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
/** How a grant's state reads in a table: `active until <iso>`, `expired`, `revoked <iso>`. */
|
|
44
|
+
function harnessEvaluationStateLabel(grant) {
|
|
45
|
+
if (grant.state === 'active')
|
|
46
|
+
return `active until ${grant.expiresAt ?? '?'}`;
|
|
47
|
+
if (grant.state === 'revoked')
|
|
48
|
+
return `revoked ${grant.revokedAt ?? ''}`.trim();
|
|
49
|
+
return `expired ${grant.expiresAt ?? ''}`.trim();
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Ask a connected daemon to detect its harnesses again and re-register, so a grant issued while it
|
|
53
|
+
* is connected is honoured now rather than at its next reconnect. The same request
|
|
54
|
+
* `skrr harnesses installers` recovery uses (`POST /api/daemons/:id/cli-installers/rescan`).
|
|
55
|
+
*/
|
|
56
|
+
async function rescanDaemonHarnesses(daemonId) {
|
|
57
|
+
return (0, api_fetch_1.apiFetch)(`/api/daemons/${encodeURIComponent(daemonId)}/cli-installers/rescan`, { method: 'POST', body: {} });
|
|
58
|
+
}
|
|
@@ -23,6 +23,16 @@ export declare function harnessStatusLabel(row: {
|
|
|
23
23
|
presenceStatus?: string | null;
|
|
24
24
|
superseded?: boolean | null;
|
|
25
25
|
}): string;
|
|
26
|
+
/**
|
|
27
|
+
* What a row offered under a harness evaluation grant says (OSK-24597): the server writes
|
|
28
|
+
* `metadata.evaluation` when a platform operator's grant let a harness that is still evaluating
|
|
29
|
+
* on platform machines register on one of their own. Null for every other row. A grant whose end
|
|
30
|
+
* has passed reads `evaluation ended`, because the row keeps the metadata until its daemon next
|
|
31
|
+
* registers, and the turn would already be refused.
|
|
32
|
+
*/
|
|
33
|
+
export declare function harnessEvaluationLabel(row: {
|
|
34
|
+
metadata?: Record<string, unknown> | null;
|
|
35
|
+
}, nowMs?: number): string | null;
|
|
26
36
|
export declare function isNoCodingAgentProvider(provider: string | null | undefined): boolean;
|
|
27
37
|
export declare function harnessProviderLabel(provider: string | null | undefined): string;
|
|
28
38
|
/**
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
exports.NO_CODING_AGENT_PROVIDER_LABEL = void 0;
|
|
22
22
|
exports.harnessStatusLabel = harnessStatusLabel;
|
|
23
|
+
exports.harnessEvaluationLabel = harnessEvaluationLabel;
|
|
23
24
|
exports.isNoCodingAgentProvider = isNoCodingAgentProvider;
|
|
24
25
|
exports.harnessProviderLabel = harnessProviderLabel;
|
|
25
26
|
exports.isAliasCoveringSharedName = isAliasCoveringSharedName;
|
|
@@ -36,6 +37,28 @@ function harnessStatusLabel(row) {
|
|
|
36
37
|
return 'unconfirmed';
|
|
37
38
|
return typeof row.status === 'string' && row.status.length > 0 ? row.status : 'unknown';
|
|
38
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* What a row offered under a harness evaluation grant says (OSK-24597): the server writes
|
|
42
|
+
* `metadata.evaluation` when a platform operator's grant let a harness that is still evaluating
|
|
43
|
+
* on platform machines register on one of their own. Null for every other row. A grant whose end
|
|
44
|
+
* has passed reads `evaluation ended`, because the row keeps the metadata until its daemon next
|
|
45
|
+
* registers, and the turn would already be refused.
|
|
46
|
+
*/
|
|
47
|
+
function harnessEvaluationLabel(row, nowMs = Date.now()) {
|
|
48
|
+
const evaluation = row.metadata?.evaluation;
|
|
49
|
+
if (!evaluation || typeof evaluation !== 'object' || typeof evaluation.grantId !== 'string') {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
const expiresMs = typeof evaluation.expiresAt === 'string' ? Date.parse(evaluation.expiresAt) : Number.NaN;
|
|
53
|
+
if (!Number.isFinite(expiresMs) || expiresMs <= nowMs) {
|
|
54
|
+
return `evaluation ended (${evaluation.grantId})`;
|
|
55
|
+
}
|
|
56
|
+
const by = typeof evaluation.grantedByUserId === 'string' ? evaluation.grantedByUserId : 'unknown';
|
|
57
|
+
const models = Array.isArray(evaluation.models)
|
|
58
|
+
? evaluation.models.filter((m) => typeof m === 'string').join(', ')
|
|
59
|
+
: '';
|
|
60
|
+
return `evaluating until ${new Date(expiresMs).toISOString()}, granted by ${by}${models ? ` for ${models}` : ''} (${evaluation.grantId})`;
|
|
61
|
+
}
|
|
39
62
|
function isNoCodingAgentProvider(provider) {
|
|
40
63
|
return typeof provider === 'string' && (0, data_provider_1.isManagedProductFallbackProvider)(provider);
|
|
41
64
|
}
|
|
@@ -41,8 +41,9 @@
|
|
|
41
41
|
* offering it: its image bakes it at a pinned version, the daemon announces its
|
|
42
42
|
* session capability once that runtime resolves, and the server still refuses
|
|
43
43
|
* it there until its registry placement is `available` (the GitHub Copilot SDK,
|
|
44
|
-
* OSK-24469, whose platform-machine
|
|
45
|
-
* what lets admission need no new image; it grants nothing by
|
|
44
|
+
* OSK-24469, and pi, OSK-24597, whose platform-machine admissions wait on H9).
|
|
45
|
+
* Announcing it is what lets admission need no new image; it grants nothing by
|
|
46
|
+
* itself.
|
|
46
47
|
*
|
|
47
48
|
* Pure: no `node:` imports and nothing read at module load.
|
|
48
49
|
*/
|
|
@@ -87,6 +88,15 @@ export declare const PI_CREDENTIAL_BROKER_CAPABILITY = "pi_credential_broker_v1"
|
|
|
87
88
|
* lease.
|
|
88
89
|
*/
|
|
89
90
|
export declare const MANAGED_INFERENCE_BROKER_TOKEN_CAPABILITY = "managed_inference_broker_token_v1";
|
|
91
|
+
/**
|
|
92
|
+
* Announced by a daemon whose broker carries a Claude lease that ALLOWS prompt
|
|
93
|
+
* caching, under the reviewed `cache_control` contract (OSK-24595). An older
|
|
94
|
+
* daemon's broker refuses such a lease outright, so admission issues it the
|
|
95
|
+
* same envelope with caching off (`promptCacheEnvelopeForRuntime` in
|
|
96
|
+
* `api/server/services/ProviderCredentials/managedPromptCacheAuthority.js`).
|
|
97
|
+
* Grants nothing: whether a model may cache is the policy's.
|
|
98
|
+
*/
|
|
99
|
+
export declare const MANAGED_CLAUDE_PROMPT_CACHE_CAPABILITY = "managed_claude_prompt_cache_v1";
|
|
90
100
|
/**
|
|
91
101
|
* The audience of the session token a broker redeems at the inference relay
|
|
92
102
|
* (`/api/agentic/sessions/:id/inference/*`). A token minted with it is refused
|
|
@@ -24,6 +24,7 @@ __export(inferenceBrokerHarnesses_exports, {
|
|
|
24
24
|
INFERENCE_BROKER_CREDENTIAL_SHAPES: () => INFERENCE_BROKER_CREDENTIAL_SHAPES,
|
|
25
25
|
INFERENCE_BROKER_HARNESSES: () => INFERENCE_BROKER_HARNESSES,
|
|
26
26
|
INFERENCE_RELAY_AUDIENCE: () => INFERENCE_RELAY_AUDIENCE,
|
|
27
|
+
MANAGED_CLAUDE_PROMPT_CACHE_CAPABILITY: () => MANAGED_CLAUDE_PROMPT_CACHE_CAPABILITY,
|
|
27
28
|
MANAGED_INFERENCE_BROKER_TOKEN_CAPABILITY: () => MANAGED_INFERENCE_BROKER_TOKEN_CAPABILITY,
|
|
28
29
|
PI_CREDENTIAL_BROKER_CAPABILITY: () => PI_CREDENTIAL_BROKER_CAPABILITY,
|
|
29
30
|
PLATFORM_MACHINE_EVALUATION_HARNESS_PROVIDERS: () => PLATFORM_MACHINE_EVALUATION_HARNESS_PROVIDERS,
|
|
@@ -42,6 +43,7 @@ const HARNESS_CREDENTIAL_BROKER_CAPABILITY = "harness_credential_broker_v1";
|
|
|
42
43
|
const FIRST_PARTY_HARNESS_CREDENTIAL_BROKER_CAPABILITY = "first_party_harness_credential_broker_v1";
|
|
43
44
|
const PI_CREDENTIAL_BROKER_CAPABILITY = "pi_credential_broker_v1";
|
|
44
45
|
const MANAGED_INFERENCE_BROKER_TOKEN_CAPABILITY = "managed_inference_broker_token_v1";
|
|
46
|
+
const MANAGED_CLAUDE_PROMPT_CACHE_CAPABILITY = "managed_claude_prompt_cache_v1";
|
|
45
47
|
const INFERENCE_RELAY_AUDIENCE = "inference";
|
|
46
48
|
const SESSION_TOKEN_AUDIENCE = "session";
|
|
47
49
|
const SHAPE_ANNOUNCED_BY = Object.freeze({ "managed-lease": MANAGED_INFERENCE_BROKER_TOKEN_CAPABILITY });
|
|
@@ -72,11 +74,15 @@ const INFERENCE_BROKER_HARNESSES = Object.freeze([
|
|
|
72
74
|
platformMachineEvaluation: true
|
|
73
75
|
}),
|
|
74
76
|
// pi takes platform credits only as a managed lease, through the daemon's
|
|
75
|
-
// loopback broker (OSK-24468).
|
|
76
|
-
//
|
|
77
|
-
//
|
|
78
|
-
//
|
|
79
|
-
|
|
77
|
+
// loopback broker (OSK-24468). Every platform machine image bakes it at its
|
|
78
|
+
// pin from a committed lockfile (`guest-harness-pins.json` `pi`), so a platform
|
|
79
|
+
// machine announces it for measurement (H9, OSK-24597), while its placement
|
|
80
|
+
// there is still `evaluating` (`packages/llm/harnesses/pi.yaml`) and the
|
|
81
|
+
// server refuses it: a baked binary is not an admission.
|
|
82
|
+
harness("pi", ["managed-lease"], PI_CREDENTIAL_BROKER_CAPABILITY, {
|
|
83
|
+
platformMachine: false,
|
|
84
|
+
platformMachineEvaluation: true
|
|
85
|
+
})
|
|
80
86
|
]);
|
|
81
87
|
const PLATFORM_MACHINE_HARNESS_PROVIDERS = Object.freeze(INFERENCE_BROKER_HARNESSES.filter((entry) => entry.platformMachine).map((entry) => entry.provider));
|
|
82
88
|
function isPlatformMachineHarness(provider) {
|
|
@@ -122,6 +128,7 @@ const INFERENCE_BROKER_CAPABILITIES = Object.freeze([
|
|
|
122
128
|
INFERENCE_BROKER_CREDENTIAL_SHAPES,
|
|
123
129
|
INFERENCE_BROKER_HARNESSES,
|
|
124
130
|
INFERENCE_RELAY_AUDIENCE,
|
|
131
|
+
MANAGED_CLAUDE_PROMPT_CACHE_CAPABILITY,
|
|
125
132
|
MANAGED_INFERENCE_BROKER_TOKEN_CAPABILITY,
|
|
126
133
|
PI_CREDENTIAL_BROKER_CAPABILITY,
|
|
127
134
|
PLATFORM_MACHINE_EVALUATION_HARNESS_PROVIDERS,
|
|
@@ -41,8 +41,9 @@
|
|
|
41
41
|
* offering it: its image bakes it at a pinned version, the daemon announces its
|
|
42
42
|
* session capability once that runtime resolves, and the server still refuses
|
|
43
43
|
* it there until its registry placement is `available` (the GitHub Copilot SDK,
|
|
44
|
-
* OSK-24469, whose platform-machine
|
|
45
|
-
* what lets admission need no new image; it grants nothing by
|
|
44
|
+
* OSK-24469, and pi, OSK-24597, whose platform-machine admissions wait on H9).
|
|
45
|
+
* Announcing it is what lets admission need no new image; it grants nothing by
|
|
46
|
+
* itself.
|
|
46
47
|
*
|
|
47
48
|
* Pure: no `node:` imports and nothing read at module load.
|
|
48
49
|
*/
|
|
@@ -87,6 +88,15 @@ export declare const PI_CREDENTIAL_BROKER_CAPABILITY = "pi_credential_broker_v1"
|
|
|
87
88
|
* lease.
|
|
88
89
|
*/
|
|
89
90
|
export declare const MANAGED_INFERENCE_BROKER_TOKEN_CAPABILITY = "managed_inference_broker_token_v1";
|
|
91
|
+
/**
|
|
92
|
+
* Announced by a daemon whose broker carries a Claude lease that ALLOWS prompt
|
|
93
|
+
* caching, under the reviewed `cache_control` contract (OSK-24595). An older
|
|
94
|
+
* daemon's broker refuses such a lease outright, so admission issues it the
|
|
95
|
+
* same envelope with caching off (`promptCacheEnvelopeForRuntime` in
|
|
96
|
+
* `api/server/services/ProviderCredentials/managedPromptCacheAuthority.js`).
|
|
97
|
+
* Grants nothing: whether a model may cache is the policy's.
|
|
98
|
+
*/
|
|
99
|
+
export declare const MANAGED_CLAUDE_PROMPT_CACHE_CAPABILITY = "managed_claude_prompt_cache_v1";
|
|
90
100
|
/**
|
|
91
101
|
* The audience of the session token a broker redeems at the inference relay
|
|
92
102
|
* (`/api/agentic/sessions/:id/inference/*`). A token minted with it is refused
|
|
@@ -41,8 +41,9 @@
|
|
|
41
41
|
* offering it: its image bakes it at a pinned version, the daemon announces its
|
|
42
42
|
* session capability once that runtime resolves, and the server still refuses
|
|
43
43
|
* it there until its registry placement is `available` (the GitHub Copilot SDK,
|
|
44
|
-
* OSK-24469, whose platform-machine
|
|
45
|
-
* what lets admission need no new image; it grants nothing by
|
|
44
|
+
* OSK-24469, and pi, OSK-24597, whose platform-machine admissions wait on H9).
|
|
45
|
+
* Announcing it is what lets admission need no new image; it grants nothing by
|
|
46
|
+
* itself.
|
|
46
47
|
*
|
|
47
48
|
* Pure: no `node:` imports and nothing read at module load.
|
|
48
49
|
*/
|
|
@@ -77,6 +78,15 @@ export const PI_CREDENTIAL_BROKER_CAPABILITY = 'pi_credential_broker_v1';
|
|
|
77
78
|
* lease.
|
|
78
79
|
*/
|
|
79
80
|
export const MANAGED_INFERENCE_BROKER_TOKEN_CAPABILITY = 'managed_inference_broker_token_v1';
|
|
81
|
+
/**
|
|
82
|
+
* Announced by a daemon whose broker carries a Claude lease that ALLOWS prompt
|
|
83
|
+
* caching, under the reviewed `cache_control` contract (OSK-24595). An older
|
|
84
|
+
* daemon's broker refuses such a lease outright, so admission issues it the
|
|
85
|
+
* same envelope with caching off (`promptCacheEnvelopeForRuntime` in
|
|
86
|
+
* `api/server/services/ProviderCredentials/managedPromptCacheAuthority.js`).
|
|
87
|
+
* Grants nothing: whether a model may cache is the policy's.
|
|
88
|
+
*/
|
|
89
|
+
export const MANAGED_CLAUDE_PROMPT_CACHE_CAPABILITY = 'managed_claude_prompt_cache_v1';
|
|
80
90
|
/**
|
|
81
91
|
* The audience of the session token a broker redeems at the inference relay
|
|
82
92
|
* (`/api/agentic/sessions/:id/inference/*`). A token minted with it is refused
|
|
@@ -116,11 +126,15 @@ export const INFERENCE_BROKER_HARNESSES = Object.freeze([
|
|
|
116
126
|
platformMachineEvaluation: true,
|
|
117
127
|
}),
|
|
118
128
|
// pi takes platform credits only as a managed lease, through the daemon's
|
|
119
|
-
// loopback broker (OSK-24468).
|
|
120
|
-
//
|
|
121
|
-
//
|
|
122
|
-
//
|
|
123
|
-
|
|
129
|
+
// loopback broker (OSK-24468). Every platform machine image bakes it at its
|
|
130
|
+
// pin from a committed lockfile (`guest-harness-pins.json` `pi`), so a platform
|
|
131
|
+
// machine announces it for measurement (H9, OSK-24597), while its placement
|
|
132
|
+
// there is still `evaluating` (`packages/llm/harnesses/pi.yaml`) and the
|
|
133
|
+
// server refuses it: a baked binary is not an admission.
|
|
134
|
+
harness('pi', ['managed-lease'], PI_CREDENTIAL_BROKER_CAPABILITY, {
|
|
135
|
+
platformMachine: false,
|
|
136
|
+
platformMachineEvaluation: true,
|
|
137
|
+
}),
|
|
124
138
|
]);
|
|
125
139
|
/**
|
|
126
140
|
* The canonical providers a platform-managed machine offers, in registry order:
|
|
@@ -171,15 +171,15 @@ export interface ManagedInferenceBrokerOptions {
|
|
|
171
171
|
*/
|
|
172
172
|
transport?: ManagedInferenceBrokerTransport;
|
|
173
173
|
/**
|
|
174
|
-
* What
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
174
|
+
* What the broker does with an Anthropic-dialect `cache_control` marker the
|
|
175
|
+
* lease does not admit. `refuse` (the default) fails the request. `strip`
|
|
176
|
+
* forwards it within the lease instead, for a harness that always sends the
|
|
177
|
+
* markers and cannot be told not to (Claude Code, OSK-24457): under a lease
|
|
178
|
+
* that does NOT allow caching every marker is removed; under a Claude lease
|
|
179
|
+
* that does (OSK-24595) a `ttl` other than `5m` is removed (a 1-hour write is
|
|
180
|
+
* 2x input and no reservation prices it), and a request still outside the
|
|
181
|
+
* contract after that is forwarded uncached. Stripping can only lower what a
|
|
182
|
+
* request costs. Every other prompt-cache field is still refused.
|
|
183
183
|
*/
|
|
184
184
|
promptCacheControl?: 'refuse' | 'strip';
|
|
185
185
|
}
|
|
@@ -810,25 +810,78 @@ function isPlainObject(value) {
|
|
|
810
810
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
811
811
|
}
|
|
812
812
|
const MAX_OPENAI_CACHE_BREAKPOINTS = 50;
|
|
813
|
-
|
|
813
|
+
const CLAUDE_PROMPT_CACHE_TTL = "5m";
|
|
814
|
+
const CLAUDE_MAX_CACHE_BREAKPOINTS = 4;
|
|
815
|
+
const CLAUDE_PROMPT_CACHE_UPSTREAMS = ["anthropic", "bedrock"];
|
|
816
|
+
function managedPromptCacheContract(modelScope) {
|
|
814
817
|
const model = nonEmpty(modelScope.wireModel)?.replace(SUPPORTS_MANAGED_PROMPT_CACHING_RE, "").toLowerCase();
|
|
815
|
-
|
|
818
|
+
if (modelScope.upstreamProvider === "openai" && model?.startsWith("gpt-5.6"))
|
|
819
|
+
return "openai";
|
|
820
|
+
if (CLAUDE_PROMPT_CACHE_UPSTREAMS.includes(modelScope.upstreamProvider) && model?.includes("claude")) {
|
|
821
|
+
return "claude";
|
|
822
|
+
}
|
|
823
|
+
return null;
|
|
824
|
+
}
|
|
825
|
+
function supportsManagedPromptCaching(modelScope) {
|
|
826
|
+
return managedPromptCacheContract(modelScope) !== null;
|
|
827
|
+
}
|
|
828
|
+
function claudeCacheControlViolation(payload) {
|
|
829
|
+
const controls = objectKeyValues(payload, "cache_control");
|
|
830
|
+
if (controls.length > CLAUDE_MAX_CACHE_BREAKPOINTS) {
|
|
831
|
+
return `at most ${CLAUDE_MAX_CACHE_BREAKPOINTS} cache_control breakpoints are allowed`;
|
|
832
|
+
}
|
|
833
|
+
for (const control of controls) {
|
|
834
|
+
if (!isPlainObject(control))
|
|
835
|
+
return "cache_control must be an object";
|
|
836
|
+
if (Object.keys(control).some((key) => key !== "type" && key !== "ttl")) {
|
|
837
|
+
return "cache_control accepts only type and ttl";
|
|
838
|
+
}
|
|
839
|
+
if (control.type !== "ephemeral")
|
|
840
|
+
return "cache_control type must be ephemeral";
|
|
841
|
+
if (control.ttl != null && control.ttl !== CLAUDE_PROMPT_CACHE_TTL) {
|
|
842
|
+
return `cache_control ttl must be ${CLAUDE_PROMPT_CACHE_TTL}`;
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
return null;
|
|
846
|
+
}
|
|
847
|
+
function normalizeClaudeCacheTtl(payload) {
|
|
848
|
+
for (const control of objectKeyValues(payload, "cache_control")) {
|
|
849
|
+
if (isPlainObject(control) && control.ttl != null && control.ttl !== CLAUDE_PROMPT_CACHE_TTL) {
|
|
850
|
+
delete control.ttl;
|
|
851
|
+
}
|
|
852
|
+
}
|
|
816
853
|
}
|
|
817
854
|
function enforcePromptCacheEnvelope(payload, envelope, modelScope, promptCacheControl = "refuse") {
|
|
818
855
|
const model = nonEmpty(modelScope.wireModel)?.replace(SUPPORTS_MANAGED_PROMPT_CACHING_RE, "").toLowerCase();
|
|
819
856
|
const claudeCacheControlFamily = ["anthropic", "openrouter", "bedrock"].includes(modelScope.upstreamProvider) && model?.includes("claude");
|
|
820
857
|
if (claudeCacheControlFamily) {
|
|
858
|
+
const openAICacheFields = containsObjectKey(payload, "prompt_cache_breakpoint") || payload.prompt_cache_key != null || payload.prompt_cache_options != null || payload.prompt_cache_retention != null;
|
|
821
859
|
if (envelope.allowPromptCaching) {
|
|
822
|
-
|
|
860
|
+
if (managedPromptCacheContract(modelScope) !== "claude") {
|
|
861
|
+
rejectManagedRequest("managed inference broker has no prompt cache policy for the leased model");
|
|
862
|
+
}
|
|
863
|
+
if (openAICacheFields) {
|
|
864
|
+
rejectManagedRequest("managed inference broker denied a prompt cache field Claude caching does not use");
|
|
865
|
+
}
|
|
866
|
+
if (promptCacheControl === "strip") {
|
|
867
|
+
normalizeClaudeCacheTtl(payload);
|
|
868
|
+
if (claudeCacheControlViolation(payload))
|
|
869
|
+
deleteObjectKey(payload, "cache_control");
|
|
870
|
+
}
|
|
871
|
+
const violation = claudeCacheControlViolation(payload);
|
|
872
|
+
if (violation) {
|
|
873
|
+
rejectManagedRequest(`managed inference broker denied prompt caching: ${violation}`);
|
|
874
|
+
}
|
|
875
|
+
return;
|
|
823
876
|
}
|
|
824
877
|
if (promptCacheControl === "strip")
|
|
825
878
|
deleteObjectKey(payload, "cache_control");
|
|
826
|
-
if (containsObjectKey(payload, "cache_control") ||
|
|
879
|
+
if (containsObjectKey(payload, "cache_control") || openAICacheFields) {
|
|
827
880
|
rejectManagedRequest("managed inference broker denied prompt caching outside the lease envelope");
|
|
828
881
|
}
|
|
829
882
|
return;
|
|
830
883
|
}
|
|
831
|
-
if (
|
|
884
|
+
if (managedPromptCacheContract(modelScope) !== "openai") {
|
|
832
885
|
rejectManagedRequest("managed inference broker has no prompt cache policy for the leased model");
|
|
833
886
|
}
|
|
834
887
|
const breakpoints = objectKeyValues(payload, "prompt_cache_breakpoint");
|
|
@@ -171,15 +171,15 @@ export interface ManagedInferenceBrokerOptions {
|
|
|
171
171
|
*/
|
|
172
172
|
transport?: ManagedInferenceBrokerTransport;
|
|
173
173
|
/**
|
|
174
|
-
* What
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
174
|
+
* What the broker does with an Anthropic-dialect `cache_control` marker the
|
|
175
|
+
* lease does not admit. `refuse` (the default) fails the request. `strip`
|
|
176
|
+
* forwards it within the lease instead, for a harness that always sends the
|
|
177
|
+
* markers and cannot be told not to (Claude Code, OSK-24457): under a lease
|
|
178
|
+
* that does NOT allow caching every marker is removed; under a Claude lease
|
|
179
|
+
* that does (OSK-24595) a `ttl` other than `5m` is removed (a 1-hour write is
|
|
180
|
+
* 2x input and no reservation prices it), and a request still outside the
|
|
181
|
+
* contract after that is forwarded uncached. Stripping can only lower what a
|
|
182
|
+
* request costs. Every other prompt-cache field is still refused.
|
|
183
183
|
*/
|
|
184
184
|
promptCacheControl?: 'refuse' | 'strip';
|
|
185
185
|
}
|