@skrr-ai/cli 0.1.179 → 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 (62) 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 +2 -0
  5. package/dist/commands/harnesses/evaluations/evidence.js +20 -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/platform-h9-turn.d.ts +13 -0
  9. package/dist/commands/harnesses/evaluations/platform-h9-turn.js +322 -0
  10. package/dist/commands/machines/hosted/identity-evaluations/issue.d.ts +12 -0
  11. package/dist/commands/machines/hosted/identity-evaluations/issue.js +40 -0
  12. package/dist/commands/machines/hosted/identity-evaluations/revoke.d.ts +11 -0
  13. package/dist/commands/machines/hosted/identity-evaluations/revoke.js +21 -0
  14. package/dist/commands/machines/hosted/identity-evaluations/show.d.ts +8 -0
  15. package/dist/commands/machines/hosted/identity-evaluations/show.js +20 -0
  16. package/dist/commands/machines/hosted/start.d.ts +1 -0
  17. package/dist/commands/machines/hosted/start.js +6 -0
  18. package/dist/lib/agentic-stream.d.ts +3 -0
  19. package/dist/lib/agentic-stream.js +63 -1
  20. package/dist/lib/copilot-fixed-probe-runner.d.ts +72 -0
  21. package/dist/lib/copilot-fixed-probe-runner.js +213 -0
  22. package/dist/lib/copilot-fixed-probe.d.ts +61 -0
  23. package/dist/lib/copilot-fixed-probe.js +223 -0
  24. package/dist/lib/first-party-harness-broker.d.ts +5 -0
  25. package/dist/lib/first-party-harness-broker.js +99 -0
  26. package/dist/lib/h9-platform-stream.d.ts +63 -0
  27. package/dist/lib/h9-platform-stream.js +317 -0
  28. package/dist/lib/h9-prior-stream.d.ts +44 -0
  29. package/dist/lib/h9-prior-stream.js +217 -0
  30. package/dist/lib/harness-evaluations.d.ts +85 -0
  31. package/dist/lib/harness-evaluations.js +8 -0
  32. package/dist/lib/hosted-identity-evaluations.d.ts +26 -0
  33. package/dist/lib/hosted-identity-evaluations.js +18 -0
  34. package/dist/lib/hosted-machines.d.ts +1 -0
  35. package/dist/lib/inference-overload-smoke-contract.d.ts +53 -0
  36. package/dist/lib/inference-overload-smoke-contract.js +192 -0
  37. package/dist/lib/inference-overload-smoke.d.ts +78 -0
  38. package/dist/lib/inference-overload-smoke.js +350 -0
  39. package/dist/lib/operator-probe-files.d.ts +6 -0
  40. package/dist/lib/operator-probe-files.js +68 -0
  41. package/dist/lib/platform-h9-plan.d.ts +47 -0
  42. package/dist/lib/platform-h9-plan.js +78 -0
  43. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/codex-model-catalog.json +150 -0
  44. package/dist/node_modules/@skrr-ai/data-provider/index.js +6 -6
  45. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/index.d.ts +3 -1
  46. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/index.js +23 -1
  47. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-haiku-none.d.ts +8 -0
  48. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-haiku-none.js +40 -0
  49. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-inference-broker.d.ts +2 -11
  50. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-inference-broker.js +31 -5
  51. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/overload-smoke.d.ts +56 -0
  52. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/overload-smoke.js +277 -0
  53. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/index.d.ts +3 -1
  54. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/index.js +3 -1
  55. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-haiku-none.d.ts +8 -0
  56. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-haiku-none.js +20 -0
  57. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-inference-broker.d.ts +2 -11
  58. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-inference-broker.js +28 -4
  59. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/overload-smoke.d.ts +56 -0
  60. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/overload-smoke.js +261 -0
  61. package/oclif.manifest.json +473 -1
  62. package/package.json +2 -2
@@ -0,0 +1,217 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.capturedH9Stream = capturedH9Stream;
4
+ exports.bindH9PriorStreamSettlement = bindH9PriorStreamSettlement;
5
+ const node_util_1 = require("node:util");
6
+ const h9_platform_stream_1 = require("./h9-platform-stream");
7
+ const refuse = (reason) => {
8
+ throw new Error(`H9_PRIOR_STREAM_${reason}`);
9
+ };
10
+ /**
11
+ * The reviewer seals the historical owner reads before the former lease and
12
+ * conversation are cleaned up. Revalidate their exact scope and stream here.
13
+ */
14
+ function capturedH9Stream(plan, harness, machineProduct) {
15
+ const prior = plan.priorStream;
16
+ if (!prior)
17
+ return refuse('REQUIRED');
18
+ const machine = prior.machine;
19
+ const { conversation, message, envelopes } = prior.capture ?? {};
20
+ const convo = conversation?.data;
21
+ const holder = convo?.agenticSession;
22
+ const accepted = holder?.idempotencyResponse;
23
+ const page = envelopes?.data;
24
+ const rows = message?.data;
25
+ const response = Array.isArray(rows) && rows.length === 1 ? rows[0] : null;
26
+ if (!accepted ||
27
+ !response ||
28
+ !page ||
29
+ conversation?.status !== 200 ||
30
+ message?.status !== 200 ||
31
+ envelopes?.status !== 200 ||
32
+ machine?.image !== plan.image ||
33
+ machine.machineProduct !== machineProduct ||
34
+ !machine.machineUuid ||
35
+ convo?.user !== plan.ownerUserId ||
36
+ (convo?.workspaceId ?? null) !== (plan.workspaceId ?? null) ||
37
+ typeof convo?.agent_id !== 'string' ||
38
+ convo.agent_id !== response.model ||
39
+ convo.conversationId !== accepted.conversationId ||
40
+ holder.sessionId !== accepted.sessionId ||
41
+ holder.responseMessageId !== accepted.responseMessageId ||
42
+ holder.clientRequestId !== accepted.clientRequestId ||
43
+ !/^h9-platform-[a-f0-9]{32}:streaming$/.test(accepted.clientRequestId ?? '') ||
44
+ accepted.clientRequestId === `h9-platform-${plan.operationId}:streaming` ||
45
+ accepted.isNewConversation !== true ||
46
+ response.conversationId !== accepted.conversationId ||
47
+ response.messageId !== accepted.responseMessageId ||
48
+ response.metadata?.agentic?.sessionId !== accepted.sessionId ||
49
+ response.metadata.agentic.sessionOutcome?.status !== 'succeeded' ||
50
+ response.isCreatedByUser !== false ||
51
+ response.error !== false ||
52
+ response.unfinished !== false ||
53
+ typeof response.text !== 'string' ||
54
+ !response.text.trim())
55
+ return refuse('IDENTITY_OR_MESSAGE');
56
+ (0, h9_platform_stream_1.validateH9Acceptance)(accepted, {
57
+ agentId: convo.agent_id,
58
+ harness,
59
+ harnessId: accepted.runtime?.agentRuntime ?? '',
60
+ daemonId: machine.daemonId,
61
+ workspaceId: plan.workspaceId,
62
+ });
63
+ const records = page.envelopes;
64
+ if (page.sessionId !== accepted.sessionId ||
65
+ page.from !== 0 ||
66
+ page.gap !== false ||
67
+ page.hasMore !== false ||
68
+ !Array.isArray(records) ||
69
+ records.length > 500 ||
70
+ records.length !== page.nextSeq ||
71
+ records.some((record, i) => !record ||
72
+ record.__seq !== i + 1 ||
73
+ !['service', 'turn-start', 'text', 'turn-end', 'turn-finalized'].includes(record.ev?.t)))
74
+ return refuse('REPLAY_GAP_OR_UNEXPECTED_EVENT');
75
+ const begin = records.filter((record) => record.ev.t === 'turn-start');
76
+ const end = records.filter((record) => record.ev.t === 'turn-end');
77
+ const finalized = records.filter((record) => record.ev.t === 'turn-finalized');
78
+ const chunks = records.filter((record) => record.ev.t === 'text' && record.ev.thinking !== true);
79
+ if (begin.length !== 1 ||
80
+ end.length !== 1 ||
81
+ finalized.length !== 1 ||
82
+ end[0].ev.status !== 'completed' ||
83
+ finalized[0].ev.subtype !== 'success' ||
84
+ end[0].__seq >= finalized[0].__seq ||
85
+ !chunks.length ||
86
+ typeof begin[0].turn !== 'string' ||
87
+ !begin[0].turn ||
88
+ [...begin, ...chunks, ...end, ...finalized].some((record) => record.turn !== begin[0].turn ||
89
+ record.messageId !== accepted.responseMessageId ||
90
+ record.agentId !== convo.agent_id) ||
91
+ chunks.some((record) => record.__seq <= begin[0].__seq ||
92
+ record.__seq >= end[0].__seq ||
93
+ record.origin?.provider !== harness ||
94
+ typeof record.ev.text !== 'string' ||
95
+ !record.ev.text) ||
96
+ chunks
97
+ .map((record) => record.ev.text)
98
+ .join('')
99
+ .trim() !== response.text.trim())
100
+ return refuse('BEHAVIOR');
101
+ const firstByteMs = chunks[0].time - Date.parse(response.createdAt);
102
+ if (!Number.isFinite(firstByteMs) || firstByteMs < 0)
103
+ return refuse('TIMING');
104
+ return {
105
+ grantId: prior.grantId,
106
+ machine: {
107
+ daemonId: machine.daemonId,
108
+ machineUuid: machine.machineUuid,
109
+ machineProduct: machine.machineProduct,
110
+ image: machine.image,
111
+ },
112
+ harness,
113
+ version: plan.version,
114
+ model: plan.model,
115
+ sessionId: accepted.sessionId,
116
+ conversationId: accepted.conversationId,
117
+ responseMessageId: accepted.responseMessageId,
118
+ requestId: accepted.clientRequestId,
119
+ firstByteMs,
120
+ chunks: chunks.length,
121
+ };
122
+ }
123
+ function bindH9PriorStreamSettlement(plan, stream, readback, evidence, currentBinding) {
124
+ const { grant, financial } = readback;
125
+ const priorMachine = evidence.machine;
126
+ const admission = grant.admissions?.[0];
127
+ const ledger = financial.turns?.[0];
128
+ const customer = ledger?.customer;
129
+ const provider = ledger?.provider;
130
+ const row = evidence.turns?.find((turn) => turn.sessionId === stream.sessionId);
131
+ const reservation = row?.reservation;
132
+ if (grant.grantId !== stream.grantId ||
133
+ evidence.grant.grantId !== stream.grantId ||
134
+ grant.ownerUserId !== plan.ownerUserId ||
135
+ evidence.grant.ownerUserId !== plan.ownerUserId ||
136
+ grant.daemonId !== stream.machine.daemonId ||
137
+ grant.machineUuid !== stream.machine.machineUuid ||
138
+ priorMachine?.daemonId !== stream.machine.daemonId ||
139
+ priorMachine.machineUuid !== stream.machine.machineUuid ||
140
+ (priorMachine.image != null && priorMachine.image !== stream.machine.image) ||
141
+ (priorMachine.machineProduct != null &&
142
+ priorMachine.machineProduct !== stream.machine.machineProduct) ||
143
+ grant.harness !== stream.harness ||
144
+ grant.version !== plan.version ||
145
+ !(0, node_util_1.isDeepStrictEqual)(grant.models, [plan.model]) ||
146
+ !(0, node_util_1.isDeepStrictEqual)(grant.modelBindings, [currentBinding]) ||
147
+ !(0, node_util_1.isDeepStrictEqual)(evidence.grant.modelBindings, [currentBinding]) ||
148
+ financial.grantId !== stream.grantId ||
149
+ financial.workspaceId !== plan.workspaceId ||
150
+ financial.bindingDigest !== currentBinding.bindingDigest ||
151
+ financial.schemaVersion !== 1 ||
152
+ financial.state !== 'closed' ||
153
+ financial.outstandingReservations !== 0 ||
154
+ financial.providerAuthorizationUsd !== 1 ||
155
+ financial.customerQuoteUsageMicros !== 1_250_000 ||
156
+ !financial.priceBookVersion ||
157
+ evidence.gateway?.unavailable ||
158
+ admission?.sessionId !== stream.sessionId ||
159
+ ledger?.sessionId !== stream.sessionId ||
160
+ ledger.state !== 'closed' ||
161
+ ledger.closure !== 'provider_spend_reconciled' ||
162
+ customer?.status !== 'settled' ||
163
+ customer.priceBookVersion !== financial.priceBookVersion ||
164
+ customer.quoteUsageMicros !== financial.customerQuoteUsageMicros ||
165
+ [customer.settledUsageMicros, customer.settledBalanceMicros].some((amount) => !Number.isSafeInteger(amount) || amount < 0 || amount > customer.quoteUsageMicros) ||
166
+ !row ||
167
+ row.reservationId !== admission.reservationId ||
168
+ row.reservationId !== ledger.reservationId ||
169
+ row.requestedAlias !== plan.model ||
170
+ row.modelBindingDigest !== currentBinding.bindingDigest ||
171
+ !reservation ||
172
+ reservation.status !== 'settled' ||
173
+ reservation.finalizationReason !== 'provider_spend_reconciled' ||
174
+ reservation.provider !== stream.harness ||
175
+ reservation.upstreamProvider !== currentBinding.upstreamProvider ||
176
+ reservation.authorizedUsd !== financial.providerAuthorizationUsd ||
177
+ reservation.daemonId !== stream.machine.daemonId ||
178
+ reservation.harnessEvaluationGrantId !== stream.grantId ||
179
+ reservation.harnessVersion !== plan.version ||
180
+ reservation.harnessPlacement !== 'platform-machine' ||
181
+ reservation.managedAdmissionKind?.version !== 1 ||
182
+ reservation.managedAdmissionKind.kind !== 'evaluation' ||
183
+ !(0, node_util_1.isDeepStrictEqual)(reservation.harnessEvaluationModelBinding, currentBinding) ||
184
+ reservation.harnessEvaluationMintApproval?.bindingDigest !== currentBinding.bindingDigest ||
185
+ reservation.model !== currentBinding.policyModel ||
186
+ reservation.immutableGatewayModelAlias !== plan.model ||
187
+ !row.calls.length ||
188
+ provider?.leaseTerminal !== true ||
189
+ provider.authorizedUsd !== financial.providerAuthorizationUsd ||
190
+ row.calls.length !== provider.registeredRequests ||
191
+ row.calls.length !== provider.reconciledRequests ||
192
+ !Number.isFinite(provider.settledUsd) ||
193
+ provider.settledUsd < 0 ||
194
+ provider.settledUsd !== reservation.settledUsd)
195
+ return refuse('SETTLEMENT_OR_RUNTIME');
196
+ let providerSpend = 0;
197
+ for (const call of row.calls) {
198
+ const gateway = call.gateway;
199
+ if (!gateway ||
200
+ 'readError' in gateway ||
201
+ call.observation !== 'reconciled' ||
202
+ gateway.callId !== call.providerRequestId ||
203
+ gateway.callType !== 'anthropic_messages' ||
204
+ gateway.status !== 'success' ||
205
+ !Number.isFinite(gateway.endMs) ||
206
+ typeof gateway.spend !== 'number' ||
207
+ !Number.isFinite(gateway.spend) ||
208
+ gateway.spend < 0 ||
209
+ !gateway.model ||
210
+ !currentBinding.gatewayDeploymentModels.includes(gateway.model))
211
+ return refuse('GATEWAY');
212
+ providerSpend += gateway.spend;
213
+ }
214
+ if (Math.abs(providerSpend - provider.settledUsd) > 1e-9)
215
+ return refuse('PROVIDER_SPEND');
216
+ return { ...stream, reservationId: row.reservationId };
217
+ }
@@ -14,10 +14,33 @@
14
14
  * Paths are written INLINE at each call so `cli/src/__tests__/helpers/api-surface.ts` can read
15
15
  * them; queries ride in `withQuery` for the same reason.
16
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
+ }
17
38
  export interface HarnessEvaluationAdmission {
18
39
  reservationId: string;
19
40
  sessionId: string;
20
41
  model: string;
42
+ requestedAlias?: string | null;
43
+ modelBindingDigest?: string | null;
21
44
  authorizedUsd: number;
22
45
  at: string;
23
46
  }
@@ -26,6 +49,7 @@ export interface HarnessEvaluationGrant {
26
49
  harness: string;
27
50
  version: string;
28
51
  models: string[];
52
+ modelBindings: HarnessEvaluationModelBinding[];
29
53
  daemonId: string;
30
54
  machineUuid: string | null;
31
55
  ownerUserId: string | null;
@@ -42,6 +66,7 @@ export interface HarnessEvaluationGrant {
42
66
  }
43
67
  export interface HarnessEvaluationGatewayRow {
44
68
  callId: string | null;
69
+ callType?: string | null;
45
70
  sessionId: string | null;
46
71
  status: string | null;
47
72
  model: string | null;
@@ -65,12 +90,30 @@ export interface HarnessEvaluationTurn {
65
90
  reservationId: string;
66
91
  sessionId: string;
67
92
  model: string;
93
+ requestedAlias: string | null;
94
+ modelBindingDigest: string | null;
68
95
  claimedAt: string | null;
69
96
  authorizedUsd: number;
70
97
  reservation: {
71
98
  status: string;
72
99
  provider: string;
73
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;
74
117
  harnessVersion: string | null;
75
118
  harnessPlacement: string | null;
76
119
  daemonId: string | null;
@@ -112,6 +155,48 @@ export interface HarnessEvaluationEvidence {
112
155
  reads: number;
113
156
  };
114
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>;
115
200
  export interface GrantHarnessEvaluationInput {
116
201
  harness: string;
117
202
  version: string;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.harnessEvaluationFinancialEvidence = harnessEvaluationFinancialEvidence;
3
4
  exports.grantHarnessEvaluation = grantHarnessEvaluation;
4
5
  exports.listHarnessEvaluations = listHarnessEvaluations;
5
6
  exports.showHarnessEvaluation = showHarnessEvaluation;
@@ -9,6 +10,13 @@ exports.harnessEvaluationStateLabel = harnessEvaluationStateLabel;
9
10
  exports.rescanDaemonHarnesses = rescanDaemonHarnesses;
10
11
  const api_fetch_1 = require("./api-fetch");
11
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
+ }
12
20
  /** Issue a grant for one of your own platform machines. */
13
21
  async function grantHarnessEvaluation(input) {
14
22
  return (0, api_fetch_1.apiFetch)('/api/admin/harness-evaluations', { method: 'POST', body: input });
@@ -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
+ }