@skrr-ai/cli 0.1.178 → 0.1.180

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.
Files changed (79) hide show
  1. package/dist/commands/code/index.js +5 -0
  2. package/dist/commands/diagnostics/inference-smoke.d.ts +13 -0
  3. package/dist/commands/diagnostics/inference-smoke.js +50 -0
  4. package/dist/commands/harnesses/evaluations/evidence.d.ts +22 -0
  5. package/dist/commands/harnesses/evaluations/evidence.js +92 -0
  6. package/dist/commands/harnesses/evaluations/fixed-tool.d.ts +10 -0
  7. package/dist/commands/harnesses/evaluations/fixed-tool.js +189 -0
  8. package/dist/commands/harnesses/evaluations/grant.d.ts +30 -0
  9. package/dist/commands/harnesses/evaluations/grant.js +109 -0
  10. package/dist/commands/harnesses/evaluations/list.d.ts +18 -0
  11. package/dist/commands/harnesses/evaluations/list.js +73 -0
  12. package/dist/commands/harnesses/evaluations/platform-h9-turn.d.ts +13 -0
  13. package/dist/commands/harnesses/evaluations/platform-h9-turn.js +322 -0
  14. package/dist/commands/harnesses/evaluations/revoke.d.ts +19 -0
  15. package/dist/commands/harnesses/evaluations/revoke.js +45 -0
  16. package/dist/commands/harnesses/evaluations/show.d.ts +14 -0
  17. package/dist/commands/harnesses/evaluations/show.js +46 -0
  18. package/dist/commands/harnesses/list.d.ts +1 -0
  19. package/dist/commands/harnesses/list.js +11 -2
  20. package/dist/commands/harnesses/show.js +5 -0
  21. package/dist/commands/machines/hosted/identity-evaluations/issue.d.ts +12 -0
  22. package/dist/commands/machines/hosted/identity-evaluations/issue.js +40 -0
  23. package/dist/commands/machines/hosted/identity-evaluations/revoke.d.ts +11 -0
  24. package/dist/commands/machines/hosted/identity-evaluations/revoke.js +21 -0
  25. package/dist/commands/machines/hosted/identity-evaluations/show.d.ts +8 -0
  26. package/dist/commands/machines/hosted/identity-evaluations/show.js +20 -0
  27. package/dist/commands/machines/hosted/start.d.ts +1 -0
  28. package/dist/commands/machines/hosted/start.js +6 -0
  29. package/dist/lib/agentic-stream.d.ts +3 -0
  30. package/dist/lib/agentic-stream.js +63 -1
  31. package/dist/lib/copilot-fixed-probe-runner.d.ts +72 -0
  32. package/dist/lib/copilot-fixed-probe-runner.js +213 -0
  33. package/dist/lib/copilot-fixed-probe.d.ts +61 -0
  34. package/dist/lib/copilot-fixed-probe.js +223 -0
  35. package/dist/lib/first-party-harness-broker.d.ts +5 -0
  36. package/dist/lib/first-party-harness-broker.js +99 -0
  37. package/dist/lib/h9-platform-stream.d.ts +63 -0
  38. package/dist/lib/h9-platform-stream.js +317 -0
  39. package/dist/lib/h9-prior-stream.d.ts +44 -0
  40. package/dist/lib/h9-prior-stream.js +217 -0
  41. package/dist/lib/harness-evaluations.d.ts +251 -0
  42. package/dist/lib/harness-evaluations.js +66 -0
  43. package/dist/lib/harness-labels.d.ts +10 -0
  44. package/dist/lib/harness-labels.js +23 -0
  45. package/dist/lib/hosted-identity-evaluations.d.ts +26 -0
  46. package/dist/lib/hosted-identity-evaluations.js +18 -0
  47. package/dist/lib/hosted-machines.d.ts +1 -0
  48. package/dist/lib/inference-overload-smoke-contract.d.ts +53 -0
  49. package/dist/lib/inference-overload-smoke-contract.js +192 -0
  50. package/dist/lib/inference-overload-smoke.d.ts +78 -0
  51. package/dist/lib/inference-overload-smoke.js +350 -0
  52. package/dist/lib/operator-probe-files.d.ts +6 -0
  53. package/dist/lib/operator-probe-files.js +68 -0
  54. package/dist/lib/platform-h9-plan.d.ts +47 -0
  55. package/dist/lib/platform-h9-plan.js +78 -0
  56. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/codex-model-catalog.json +150 -0
  57. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/inferenceBrokerHarnesses.d.ts +12 -2
  58. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/inferenceBrokerHarnesses.js +12 -5
  59. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/inferenceBrokerHarnesses.d.ts +12 -2
  60. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/inferenceBrokerHarnesses.js +21 -7
  61. package/dist/node_modules/@skrr-ai/data-provider/index.js +6 -6
  62. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/index.d.ts +3 -1
  63. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/index.js +23 -1
  64. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-haiku-none.d.ts +8 -0
  65. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-haiku-none.js +40 -0
  66. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-inference-broker.d.ts +11 -20
  67. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-inference-broker.js +88 -9
  68. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/overload-smoke.d.ts +56 -0
  69. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/overload-smoke.js +277 -0
  70. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/index.d.ts +3 -1
  71. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/index.js +3 -1
  72. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-haiku-none.d.ts +8 -0
  73. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-haiku-none.js +20 -0
  74. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-inference-broker.d.ts +11 -20
  75. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-inference-broker.js +105 -12
  76. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/overload-smoke.d.ts +56 -0
  77. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/overload-smoke.js +261 -0
  78. package/oclif.manifest.json +1391 -443
  79. package/package.json +5 -2
@@ -0,0 +1,251 @@
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
+ /** Immutable server-issued identity. A reported alias is never parsed into a provider. */
18
+ export interface HarnessEvaluationModelBinding {
19
+ schemaVersion: 1;
20
+ requestedAlias: string;
21
+ policyModel: string;
22
+ upstreamProvider: string;
23
+ gatewayAlias: string;
24
+ family: string;
25
+ catalogVersion: string;
26
+ catalogInputsDigest: string;
27
+ routeCatalogInputsDigest: string;
28
+ gatewayDeploymentPoolVersion: string;
29
+ gatewayDeploymentModels: string[];
30
+ gatewayDeploymentRoutes: Array<{
31
+ model: string;
32
+ provider: string;
33
+ order: number;
34
+ }>;
35
+ policyVersionAtIssue: string;
36
+ bindingDigest: string;
37
+ }
38
+ export interface HarnessEvaluationAdmission {
39
+ reservationId: string;
40
+ sessionId: string;
41
+ model: string;
42
+ requestedAlias?: string | null;
43
+ modelBindingDigest?: string | null;
44
+ authorizedUsd: number;
45
+ at: string;
46
+ }
47
+ export interface HarnessEvaluationGrant {
48
+ grantId: string;
49
+ harness: string;
50
+ version: string;
51
+ models: string[];
52
+ modelBindings: HarnessEvaluationModelBinding[];
53
+ daemonId: string;
54
+ machineUuid: string | null;
55
+ ownerUserId: string | null;
56
+ state: 'active' | 'expired' | 'revoked';
57
+ active: boolean;
58
+ expiresAt: string | null;
59
+ maxSpendUsd: number;
60
+ admissions: HarnessEvaluationAdmission[];
61
+ grantReason: string;
62
+ grantedAt: string | null;
63
+ revokedAt: string | null;
64
+ revokedByUserId: string | null;
65
+ revokeReason: string | null;
66
+ }
67
+ export interface HarnessEvaluationGatewayRow {
68
+ callId: string | null;
69
+ callType?: string | null;
70
+ sessionId: string | null;
71
+ status: string | null;
72
+ model: string | null;
73
+ startMs: number | null;
74
+ endMs: number | null;
75
+ errorClass: string | null;
76
+ errorCode: string | null;
77
+ clientDisconnected: string | null;
78
+ spend: number | null;
79
+ completionTokens: number | null;
80
+ }
81
+ export interface HarnessEvaluationCall {
82
+ providerRequestId: string;
83
+ startedAt: string | null;
84
+ observation: string;
85
+ gateway?: HarnessEvaluationGatewayRow | {
86
+ readError: string;
87
+ } | null;
88
+ }
89
+ export interface HarnessEvaluationTurn {
90
+ reservationId: string;
91
+ sessionId: string;
92
+ model: string;
93
+ requestedAlias: string | null;
94
+ modelBindingDigest: string | null;
95
+ claimedAt: string | null;
96
+ authorizedUsd: number;
97
+ reservation: {
98
+ status: string;
99
+ provider: string;
100
+ model: string;
101
+ upstreamProvider: string | null;
102
+ immutableGatewayModelAlias: string | null;
103
+ harnessEvaluationModelBinding: HarnessEvaluationModelBinding | null;
104
+ harnessEvaluationGrantId: string | null;
105
+ managedAdmissionKind: {
106
+ version: 1;
107
+ kind: 'ordinary' | 'evaluation';
108
+ } | null;
109
+ harnessEvaluationMintApproval: {
110
+ bindingDigest: string;
111
+ gatewayAlias: string;
112
+ upstreamProvider: string;
113
+ gatewayDeploymentPoolVersion: string;
114
+ gatewayDeploymentModels: string[];
115
+ verifiedAt: string;
116
+ } | null;
117
+ harnessVersion: string | null;
118
+ harnessPlacement: string | null;
119
+ daemonId: string | null;
120
+ authorizedUsd: number;
121
+ settledUsd: number | null;
122
+ createdAt: string | null;
123
+ finalizedAt: string | null;
124
+ finalizationReason: string | null;
125
+ } | null;
126
+ calls: HarnessEvaluationCall[];
127
+ }
128
+ export interface HarnessEvaluationEvidence {
129
+ grant: HarnessEvaluationGrant;
130
+ machine: {
131
+ daemonId: string;
132
+ machineProduct: string | null;
133
+ machineUuid: string | null;
134
+ image: string | null;
135
+ unavailable?: string;
136
+ };
137
+ continuity?: {
138
+ conversationId: string;
139
+ platformSessionId: string | null;
140
+ nativeSessionId: string | null;
141
+ sdkSessionId: string | null;
142
+ harness: string | null;
143
+ grantSessionMatch: boolean;
144
+ receipt: {
145
+ platformSessionId: string;
146
+ nativeSessionId: string;
147
+ daemonId: string;
148
+ resumed: boolean;
149
+ recordedAt: string | null;
150
+ } | null;
151
+ };
152
+ turns: HarnessEvaluationTurn[];
153
+ gateway?: {
154
+ unavailable: string | null;
155
+ reads: number;
156
+ };
157
+ }
158
+ export interface HarnessEvaluationFinancialEvidence {
159
+ grant: HarnessEvaluationGrant;
160
+ financial: {
161
+ schemaVersion: 1;
162
+ state: 'closed' | 'pending' | 'refused';
163
+ reason: string;
164
+ grantId: string;
165
+ workspaceId?: string;
166
+ bindingDigest: string | null;
167
+ providerAuthorizationUsd: number | null;
168
+ customerQuoteUsageMicros: number | null;
169
+ priceBookVersion: string | null;
170
+ outstandingReservations: number | null;
171
+ totals: {
172
+ providerSettledUsd: number | null;
173
+ customerSettledUsageMicros: number | null;
174
+ customerSettledBalanceMicros: number | null;
175
+ };
176
+ turns: Array<{
177
+ reservationId: string;
178
+ sessionId: string;
179
+ state: string;
180
+ closure: string | null;
181
+ provider?: {
182
+ authorizedUsd: number;
183
+ settledUsd: number;
184
+ leaseTerminal: boolean;
185
+ registeredRequests: number;
186
+ reconciledRequests: number;
187
+ };
188
+ customer?: {
189
+ status: string;
190
+ quoteUsageMicros: number;
191
+ settledUsageMicros: number;
192
+ settledBalanceMicros: number;
193
+ priceBookVersion: string;
194
+ } | null;
195
+ }>;
196
+ };
197
+ }
198
+ /** Exact owner-scoped platform settlement read, with no model or gateway request. */
199
+ export declare function harnessEvaluationFinancialEvidence(grantId: string, workspaceId?: string): Promise<HarnessEvaluationFinancialEvidence>;
200
+ export interface GrantHarnessEvaluationInput {
201
+ harness: string;
202
+ version: string;
203
+ models: string[];
204
+ daemonId: string;
205
+ reason: string;
206
+ ttlMinutes?: number;
207
+ maxSpendUsd?: number;
208
+ }
209
+ /** Issue a grant for one of your own platform machines. */
210
+ export declare function grantHarnessEvaluation(input: GrantHarnessEvaluationInput): Promise<{
211
+ created: boolean;
212
+ grant: HarnessEvaluationGrant;
213
+ }>;
214
+ /** Your grants, newest first; expired and withdrawn ones with `includeEnded`. */
215
+ export declare function listHarnessEvaluations(opts?: {
216
+ harness?: string;
217
+ daemonId?: string;
218
+ includeEnded?: boolean;
219
+ limit?: number;
220
+ }): Promise<{
221
+ grants: HarnessEvaluationGrant[];
222
+ }>;
223
+ /** One of your grants, with every turn it admitted. */
224
+ export declare function showHarnessEvaluation(grantId: string): Promise<{
225
+ grant: HarnessEvaluationGrant;
226
+ }>;
227
+ /** Withdraw a grant. The row is kept as the record. */
228
+ export declare function revokeHarnessEvaluation(grantId: string, reason: string): Promise<{
229
+ revoked: boolean;
230
+ grant: HarnessEvaluationGrant;
231
+ }>;
232
+ /**
233
+ * What the platform recorded for each turn a grant admitted: its reservation and the relay's
234
+ * calls, and with `gateway` the gateway's own spend row for each call.
235
+ */
236
+ export declare function harnessEvaluationEvidence(grantId: string, opts?: {
237
+ gateway?: boolean;
238
+ conversationId?: string;
239
+ }): Promise<HarnessEvaluationEvidence>;
240
+ /** How a grant's state reads in a table: `active until <iso>`, `expired`, `revoked <iso>`. */
241
+ export declare function harnessEvaluationStateLabel(grant: HarnessEvaluationGrant): string;
242
+ /**
243
+ * Ask a connected daemon to detect its harnesses again and re-register, so a grant issued while it
244
+ * is connected is honoured now rather than at its next reconnect. The same request
245
+ * `skrr harnesses installers` recovery uses (`POST /api/daemons/:id/cli-installers/rescan`).
246
+ */
247
+ export declare function rescanDaemonHarnesses(daemonId: string): Promise<{
248
+ daemonId: string;
249
+ success?: boolean;
250
+ capabilities?: string[];
251
+ }>;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.harnessEvaluationFinancialEvidence = harnessEvaluationFinancialEvidence;
4
+ exports.grantHarnessEvaluation = grantHarnessEvaluation;
5
+ exports.listHarnessEvaluations = listHarnessEvaluations;
6
+ exports.showHarnessEvaluation = showHarnessEvaluation;
7
+ exports.revokeHarnessEvaluation = revokeHarnessEvaluation;
8
+ exports.harnessEvaluationEvidence = harnessEvaluationEvidence;
9
+ exports.harnessEvaluationStateLabel = harnessEvaluationStateLabel;
10
+ exports.rescanDaemonHarnesses = rescanDaemonHarnesses;
11
+ const api_fetch_1 = require("./api-fetch");
12
+ const triggers_1 = require("./triggers");
13
+ /** Exact owner-scoped platform settlement read, with no model or gateway request. */
14
+ function harnessEvaluationFinancialEvidence(grantId, workspaceId) {
15
+ return (0, api_fetch_1.apiFetch)((0, triggers_1.withQuery)(`/api/admin/harness-evaluations/${encodeURIComponent(grantId)}/evidence`, {
16
+ financial: 'true',
17
+ ...(workspaceId !== undefined ? { workspaceId } : {}),
18
+ }), { signal: AbortSignal.timeout(15_000), singleAttempt: true });
19
+ }
20
+ /** Issue a grant for one of your own platform machines. */
21
+ async function grantHarnessEvaluation(input) {
22
+ return (0, api_fetch_1.apiFetch)('/api/admin/harness-evaluations', { method: 'POST', body: input });
23
+ }
24
+ /** Your grants, newest first; expired and withdrawn ones with `includeEnded`. */
25
+ async function listHarnessEvaluations(opts = {}) {
26
+ return (0, api_fetch_1.apiFetch)((0, triggers_1.withQuery)('/api/admin/harness-evaluations', {
27
+ harness: opts.harness,
28
+ daemonId: opts.daemonId,
29
+ includeEnded: opts.includeEnded ? 'true' : undefined,
30
+ limit: opts.limit,
31
+ }));
32
+ }
33
+ /** One of your grants, with every turn it admitted. */
34
+ async function showHarnessEvaluation(grantId) {
35
+ return (0, api_fetch_1.apiFetch)(`/api/admin/harness-evaluations/${encodeURIComponent(grantId)}`);
36
+ }
37
+ /** Withdraw a grant. The row is kept as the record. */
38
+ async function revokeHarnessEvaluation(grantId, reason) {
39
+ return (0, api_fetch_1.apiFetch)(`/api/admin/harness-evaluations/${encodeURIComponent(grantId)}/revoke`, { method: 'POST', body: { reason } });
40
+ }
41
+ /**
42
+ * What the platform recorded for each turn a grant admitted: its reservation and the relay's
43
+ * calls, and with `gateway` the gateway's own spend row for each call.
44
+ */
45
+ async function harnessEvaluationEvidence(grantId, opts = {}) {
46
+ return (0, api_fetch_1.apiFetch)((0, triggers_1.withQuery)(`/api/admin/harness-evaluations/${encodeURIComponent(grantId)}/evidence`, {
47
+ gateway: opts.gateway ? 'true' : undefined,
48
+ conversationId: opts.conversationId,
49
+ }));
50
+ }
51
+ /** How a grant's state reads in a table: `active until <iso>`, `expired`, `revoked <iso>`. */
52
+ function harnessEvaluationStateLabel(grant) {
53
+ if (grant.state === 'active')
54
+ return `active until ${grant.expiresAt ?? '?'}`;
55
+ if (grant.state === 'revoked')
56
+ return `revoked ${grant.revokedAt ?? ''}`.trim();
57
+ return `expired ${grant.expiresAt ?? ''}`.trim();
58
+ }
59
+ /**
60
+ * Ask a connected daemon to detect its harnesses again and re-register, so a grant issued while it
61
+ * is connected is honoured now rather than at its next reconnect. The same request
62
+ * `skrr harnesses installers` recovery uses (`POST /api/daemons/:id/cli-installers/rescan`).
63
+ */
64
+ async function rescanDaemonHarnesses(daemonId) {
65
+ return (0, api_fetch_1.apiFetch)(`/api/daemons/${encodeURIComponent(daemonId)}/cli-installers/rescan`, { method: 'POST', body: {} });
66
+ }
@@ -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
  }
@@ -0,0 +1,26 @@
1
+ export interface HostedIdentityEvaluation {
2
+ capabilityId: string;
3
+ ownerUserId: string;
4
+ startRequestId: string;
5
+ expectedIdentity: {
6
+ buildId: string;
7
+ publicationId: string;
8
+ manifestSha256: string;
9
+ };
10
+ expiresAt: string;
11
+ sessionId: string | null;
12
+ allocationStartedAt: string | null;
13
+ revokedAt: string | null;
14
+ }
15
+ type Result = {
16
+ capability: HostedIdentityEvaluation;
17
+ };
18
+ export declare function issueHostedIdentityEvaluation(input: {
19
+ startRequestId: string;
20
+ buildId: string;
21
+ ttlMinutes: number;
22
+ reason: string;
23
+ }): Promise<Result>;
24
+ export declare function readHostedIdentityEvaluation(id: string): Promise<Result>;
25
+ export declare function revokeHostedIdentityEvaluation(id: string, reason: string): Promise<Result>;
26
+ export {};
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.issueHostedIdentityEvaluation = issueHostedIdentityEvaluation;
4
+ exports.readHostedIdentityEvaluation = readHostedIdentityEvaluation;
5
+ exports.revokeHostedIdentityEvaluation = revokeHostedIdentityEvaluation;
6
+ const api_fetch_1 = require("./api-fetch");
7
+ function issueHostedIdentityEvaluation(input) {
8
+ return (0, api_fetch_1.apiFetch)('/api/admin/hosted-identity-evaluations', {
9
+ method: 'POST',
10
+ body: input,
11
+ });
12
+ }
13
+ function readHostedIdentityEvaluation(id) {
14
+ return (0, api_fetch_1.apiFetch)(`/api/admin/hosted-identity-evaluations/${encodeURIComponent(id)}`);
15
+ }
16
+ function revokeHostedIdentityEvaluation(id, reason) {
17
+ return (0, api_fetch_1.apiFetch)(`/api/admin/hosted-identity-evaluations/${encodeURIComponent(id)}/revoke`, { method: 'POST', body: { reason } });
18
+ }
@@ -136,6 +136,7 @@ export interface HostedMachineScope {
136
136
  workspaceId?: string;
137
137
  }
138
138
  export interface StartHostedMachineInput extends HostedMachineScope {
139
+ identityEvaluationId?: string;
139
140
  agentId?: string;
140
141
  conversationId?: string;
141
142
  environmentId?: string;
@@ -0,0 +1,53 @@
1
+ /** Closed metadata contract for the explicitly invoked bounded inference diagnostic. */
2
+ export type SmokeTokens = {
3
+ input: number;
4
+ output: number;
5
+ };
6
+ export type SmokeAuthorization = {
7
+ status: string;
8
+ quoteUsageUnits?: number;
9
+ actualUsageUnits?: number | null;
10
+ };
11
+ export type SmokeBegin = {
12
+ operationId: string;
13
+ remainingMs: number;
14
+ planVersion: 1;
15
+ nativeAuthorizedUsd: 1;
16
+ nativeCustomerQuoteMicros: 1250000;
17
+ };
18
+ export type SmokeBatch = {
19
+ index: number;
20
+ status: 'completed';
21
+ tokens: SmokeTokens;
22
+ authorizationId: string;
23
+ usageEventId: string;
24
+ canonicalCostMicros: number;
25
+ authorization: SmokeAuthorization;
26
+ nativeOrdinalWaitMs: number;
27
+ };
28
+ export type SmokeReceipt = {
29
+ operationId: string;
30
+ state: string;
31
+ nextBatchIndex: number;
32
+ nativeObservationCount: number;
33
+ requests: Array<Record<string, unknown>>;
34
+ native: Record<string, unknown> | null;
35
+ reconciliationPending: boolean;
36
+ remoteWorkPending: boolean;
37
+ authorizationCoverageUnknown: boolean;
38
+ qualification: false;
39
+ };
40
+ export interface ManagedSmokeOperations {
41
+ begin(signal?: AbortSignal): Promise<SmokeBegin>;
42
+ batch(operationId: string, index: number, signal?: AbortSignal): Promise<SmokeBatch>;
43
+ receipt(operationId: string, signal?: AbortSignal): Promise<SmokeReceipt>;
44
+ }
45
+ export declare class InferenceSmokeError extends Error {
46
+ readonly code: string;
47
+ constructor(code: string);
48
+ }
49
+ export declare function safeSmokeIdentifier(value: unknown): string | null;
50
+ export declare function projectSmokeBegin(value: unknown): SmokeBegin;
51
+ export declare function projectSmokeBatch(value: unknown, index: number): SmokeBatch;
52
+ /** Select metadata explicitly; raw response/error bodies and capabilities never reach a manifest. */
53
+ export declare function projectSmokeReceipt(value: unknown, operationId: string): SmokeReceipt;
@@ -0,0 +1,192 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InferenceSmokeError = void 0;
4
+ exports.safeSmokeIdentifier = safeSmokeIdentifier;
5
+ exports.projectSmokeBegin = projectSmokeBegin;
6
+ exports.projectSmokeBatch = projectSmokeBatch;
7
+ exports.projectSmokeReceipt = projectSmokeReceipt;
8
+ class InferenceSmokeError extends Error {
9
+ code;
10
+ constructor(code) {
11
+ const safe = /^SMOKE_[A-Z0-9_]{1,90}$/.test(code) ? code : 'SMOKE_OPERATION_FAILED';
12
+ super(safe);
13
+ this.name = 'InferenceSmokeError';
14
+ this.code = safe;
15
+ }
16
+ }
17
+ exports.InferenceSmokeError = InferenceSmokeError;
18
+ const STATUS = new Set([
19
+ 'active',
20
+ 'prepared',
21
+ 'running',
22
+ 'completed',
23
+ 'failed',
24
+ 'cancelled',
25
+ 'expired',
26
+ 'unsent',
27
+ 'unused',
28
+ 'claimed',
29
+ 'awaiting_native',
30
+ 'authorizing',
31
+ 'dispatching',
32
+ 'refused_or_unknown',
33
+ 'settled',
34
+ 'exception',
35
+ 'released',
36
+ 'issued',
37
+ 'unissued',
38
+ 'issuing',
39
+ 'revoked',
40
+ 'revoking',
41
+ ]);
42
+ function object(value) {
43
+ if (!value || typeof value !== 'object' || Array.isArray(value))
44
+ throw new InferenceSmokeError('SMOKE_METADATA_INVALID');
45
+ return value;
46
+ }
47
+ function number(value, integer = false) {
48
+ if (typeof value !== 'number' ||
49
+ !Number.isFinite(value) ||
50
+ value < 0 ||
51
+ (integer && !Number.isSafeInteger(value)))
52
+ throw new InferenceSmokeError('SMOKE_METADATA_INVALID');
53
+ return value;
54
+ }
55
+ function safeSmokeIdentifier(value) {
56
+ return typeof value === 'string' &&
57
+ /^[A-Za-z0-9_.:-]{1,192}$/.test(value) &&
58
+ !/^(?:agst_|sk-|Bearer)/i.test(value)
59
+ ? value
60
+ : null;
61
+ }
62
+ function id(value) {
63
+ const safe = safeSmokeIdentifier(value);
64
+ if (!safe)
65
+ throw new InferenceSmokeError('SMOKE_METADATA_INVALID');
66
+ return safe;
67
+ }
68
+ function status(value) {
69
+ if (typeof value !== 'string' || !STATUS.has(value))
70
+ throw new InferenceSmokeError('SMOKE_METADATA_INVALID');
71
+ return value;
72
+ }
73
+ function tokens(value) {
74
+ const v = object(value);
75
+ const input = number(v.input, true), output = number(v.output, true);
76
+ if (input > 1024 || output > 16)
77
+ throw new InferenceSmokeError('SMOKE_USAGE_UNKNOWN');
78
+ return { input, output };
79
+ }
80
+ function authorization(value) {
81
+ const v = object(value);
82
+ return {
83
+ status: status(v.status),
84
+ ...(v.quoteUsageUnits === undefined
85
+ ? {}
86
+ : { quoteUsageUnits: number(v.quoteUsageUnits, true) }),
87
+ ...(v.actualUsageUnits === undefined
88
+ ? {}
89
+ : {
90
+ actualUsageUnits: v.actualUsageUnits === null ? null : number(v.actualUsageUnits, true),
91
+ }),
92
+ };
93
+ }
94
+ function projectSmokeBegin(value) {
95
+ const v = object(value);
96
+ if (v.planVersion !== 1 || v.nativeAuthorizedUsd !== 1 || v.nativeCustomerQuoteMicros !== 1250000)
97
+ throw new InferenceSmokeError('SMOKE_NORMAL_ADMISSION_CHANGED');
98
+ const remainingMs = number(v.remainingMs, true);
99
+ if (remainingMs <= 0 || remainingMs > 180000)
100
+ throw new InferenceSmokeError('SMOKE_DEADLINE');
101
+ return {
102
+ operationId: id(v.operationId),
103
+ remainingMs,
104
+ planVersion: 1,
105
+ nativeAuthorizedUsd: 1,
106
+ nativeCustomerQuoteMicros: 1250000,
107
+ };
108
+ }
109
+ function projectSmokeBatch(value, index) {
110
+ const v = object(value);
111
+ if (v.index !== index || v.status !== 'completed')
112
+ throw new InferenceSmokeError('SMOKE_BATCH_INCOMPLETE');
113
+ const a = authorization(v.authorization);
114
+ if (a.status !== 'settled' || a.quoteUsageUnits === undefined || a.actualUsageUnits == null)
115
+ throw new InferenceSmokeError('SMOKE_UTILITY_SETTLEMENT_PENDING');
116
+ return {
117
+ index,
118
+ status: 'completed',
119
+ tokens: tokens(v.tokens),
120
+ authorizationId: id(v.authorizationId),
121
+ usageEventId: id(v.usageEventId),
122
+ canonicalCostMicros: number(v.canonicalCostMicros, true),
123
+ authorization: a,
124
+ nativeOrdinalWaitMs: number(v.nativeOrdinalWaitMs),
125
+ };
126
+ }
127
+ /** Select metadata explicitly; raw response/error bodies and capabilities never reach a manifest. */
128
+ function projectSmokeReceipt(value, operationId) {
129
+ const v = object(value);
130
+ if (v.operationId !== operationId ||
131
+ v.qualification !== false ||
132
+ typeof v.reconciliationPending !== 'boolean' ||
133
+ !Array.isArray(v.requests) ||
134
+ v.requests.length !== 64)
135
+ throw new InferenceSmokeError('SMOKE_METADATA_INVALID');
136
+ const requests = v.requests.map((entry, index) => {
137
+ const row = object(entry);
138
+ if (row.index !== index)
139
+ throw new InferenceSmokeError('SMOKE_METADATA_INVALID');
140
+ return {
141
+ index,
142
+ status: status(row.status),
143
+ ...(row.authorizationId == null ? {} : { authorizationId: id(row.authorizationId) }),
144
+ ...(row.usageEventId == null ? {} : { usageEventId: id(row.usageEventId) }),
145
+ ...(row.tokens == null ? {} : { tokens: tokens(row.tokens) }),
146
+ ...(row.canonicalCostMicros == null
147
+ ? {}
148
+ : { canonicalCostMicros: number(row.canonicalCostMicros, true) }),
149
+ ...(row.authorization == null ? {} : { authorization: authorization(row.authorization) }),
150
+ ...(row.nativeOrdinalWaitMs == null
151
+ ? {}
152
+ : { nativeOrdinalWaitMs: number(row.nativeOrdinalWaitMs) }),
153
+ };
154
+ });
155
+ let native = null;
156
+ if (v.native != null) {
157
+ const n = object(v.native);
158
+ native = {};
159
+ for (const key of ['status', 'leaseStatus', 'revokeStatus'])
160
+ if (n[key] != null)
161
+ native[key] = status(n[key]);
162
+ for (const key of [
163
+ 'settledUsd',
164
+ 'spentUsd',
165
+ 'authorizedUsd',
166
+ 'customerQuoteMicros',
167
+ 'spendObservationCount',
168
+ ])
169
+ if (n[key] != null)
170
+ native[key] = number(n[key], key.endsWith('Micros') || key === 'spendObservationCount');
171
+ if (typeof n.concurrencyReleased === 'boolean')
172
+ native.concurrencyReleased = n.concurrencyReleased;
173
+ if (n.customerAuthorizationId != null)
174
+ native.customerAuthorizationId = id(n.customerAuthorizationId);
175
+ native.authorization = n.authorization == null ? null : authorization(n.authorization);
176
+ }
177
+ if (number(v.nextBatchIndex, true) > 64 || number(v.nativeObservationCount, true) > 64)
178
+ throw new InferenceSmokeError('SMOKE_METADATA_INVALID');
179
+ return {
180
+ operationId,
181
+ state: status(v.state),
182
+ nextBatchIndex: number(v.nextBatchIndex, true),
183
+ nativeObservationCount: number(v.nativeObservationCount, true),
184
+ requests,
185
+ native,
186
+ reconciliationPending: v.reconciliationPending,
187
+ remoteWorkPending: v.remoteWorkPending === true ||
188
+ requests.some((row) => ['claimed', 'awaiting_native', 'authorizing', 'dispatching'].includes(row.status)),
189
+ authorizationCoverageUnknown: v.authorizationCoverageUnknown !== false,
190
+ qualification: false,
191
+ };
192
+ }