@skrr-ai/cli 0.1.179 → 0.1.181
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/code/index.js +5 -0
- package/dist/commands/diagnostics/inference-smoke.d.ts +13 -0
- package/dist/commands/diagnostics/inference-smoke.js +50 -0
- package/dist/commands/harnesses/evaluations/evidence.d.ts +2 -0
- package/dist/commands/harnesses/evaluations/evidence.js +20 -0
- package/dist/commands/harnesses/evaluations/fixed-tool.d.ts +10 -0
- package/dist/commands/harnesses/evaluations/fixed-tool.js +189 -0
- package/dist/commands/harnesses/evaluations/platform-h9-turn.d.ts +13 -0
- package/dist/commands/harnesses/evaluations/platform-h9-turn.js +322 -0
- package/dist/commands/machines/hosted/identity-evaluations/issue.d.ts +12 -0
- package/dist/commands/machines/hosted/identity-evaluations/issue.js +40 -0
- package/dist/commands/machines/hosted/identity-evaluations/revoke.d.ts +11 -0
- package/dist/commands/machines/hosted/identity-evaluations/revoke.js +21 -0
- package/dist/commands/machines/hosted/identity-evaluations/show.d.ts +8 -0
- package/dist/commands/machines/hosted/identity-evaluations/show.js +20 -0
- package/dist/commands/machines/hosted/start.d.ts +1 -0
- package/dist/commands/machines/hosted/start.js +6 -0
- package/dist/lib/agent-model-check.d.ts +19 -0
- package/dist/lib/agent-model-check.js +10 -20
- package/dist/lib/agentic-stream.d.ts +3 -0
- package/dist/lib/agentic-stream.js +63 -1
- package/dist/lib/copilot-fixed-probe-runner.d.ts +72 -0
- package/dist/lib/copilot-fixed-probe-runner.js +213 -0
- package/dist/lib/copilot-fixed-probe.d.ts +61 -0
- package/dist/lib/copilot-fixed-probe.js +223 -0
- package/dist/lib/credential-resolver.d.ts +1 -0
- package/dist/lib/credential-resolver.js +5 -1
- package/dist/lib/first-party-harness-broker.d.ts +5 -10
- package/dist/lib/first-party-harness-broker.js +121 -50
- package/dist/lib/h9-platform-stream.d.ts +63 -0
- package/dist/lib/h9-platform-stream.js +317 -0
- package/dist/lib/h9-prior-stream.d.ts +44 -0
- package/dist/lib/h9-prior-stream.js +217 -0
- package/dist/lib/harness-evaluations.d.ts +85 -0
- package/dist/lib/harness-evaluations.js +8 -0
- package/dist/lib/hosted-identity-evaluations.d.ts +26 -0
- package/dist/lib/hosted-identity-evaluations.js +18 -0
- package/dist/lib/hosted-machines.d.ts +1 -0
- package/dist/lib/inference-overload-smoke-contract.d.ts +53 -0
- package/dist/lib/inference-overload-smoke-contract.js +192 -0
- package/dist/lib/inference-overload-smoke.d.ts +78 -0
- package/dist/lib/inference-overload-smoke.js +350 -0
- package/dist/lib/operator-probe-files.d.ts +6 -0
- package/dist/lib/operator-probe-files.js +68 -0
- package/dist/lib/platform-h9-plan.d.ts +47 -0
- package/dist/lib/platform-h9-plan.js +78 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/codex-model-catalog.json +150 -0
- package/dist/node_modules/@skrr-ai/data-provider/index.js +6 -6
- package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/index.d.ts +3 -1
- package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/index.js +23 -1
- package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-haiku-none.d.ts +8 -0
- package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-haiku-none.js +40 -0
- package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-inference-broker.d.ts +2 -11
- package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-inference-broker.js +31 -5
- package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/overload-smoke.d.ts +56 -0
- package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/overload-smoke.js +277 -0
- package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/index.d.ts +3 -1
- package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/index.js +3 -1
- package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-haiku-none.d.ts +8 -0
- package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-haiku-none.js +20 -0
- package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-inference-broker.d.ts +2 -11
- package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-inference-broker.js +28 -4
- package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/overload-smoke.d.ts +56 -0
- package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/overload-smoke.js +261 -0
- package/oclif.manifest.json +473 -1
- package/package.json +2 -2
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sendSmokeNative = sendSmokeNative;
|
|
4
|
+
exports.runInferenceOverloadSmoke = runInferenceOverloadSmoke;
|
|
5
|
+
/**
|
|
6
|
+
* The sole client scheduler for the explicitly invoked OSK-24476 plumbing smoke.
|
|
7
|
+
* Normal acquisition/broker/renewal/release stay in acquireManagedSession. The server
|
|
8
|
+
* independently fences the one-use operation/native journal; this runner never retries.
|
|
9
|
+
*/
|
|
10
|
+
const node_crypto_1 = require("node:crypto");
|
|
11
|
+
const node_http_1 = require("node:http");
|
|
12
|
+
const node_stream_1 = require("node:stream");
|
|
13
|
+
const node_perf_hooks_1 = require("node:perf_hooks");
|
|
14
|
+
const promises_1 = require("node:timers/promises");
|
|
15
|
+
const inference_broker_1 = require("@skrr-ai/inference-broker");
|
|
16
|
+
const first_party_harness_broker_1 = require("./first-party-harness-broker");
|
|
17
|
+
const inference_overload_smoke_contract_1 = require("./inference-overload-smoke-contract");
|
|
18
|
+
function fail(code) {
|
|
19
|
+
throw new inference_overload_smoke_contract_1.InferenceSmokeError(code);
|
|
20
|
+
}
|
|
21
|
+
function safeCode(error) {
|
|
22
|
+
const code = error?.code;
|
|
23
|
+
return typeof code === 'string' && /^SMOKE_[A-Z0-9_]+$/.test(code)
|
|
24
|
+
? code
|
|
25
|
+
: 'SMOKE_RAIL_REFUSED_OR_UNKNOWN';
|
|
26
|
+
}
|
|
27
|
+
function partialObservation(value) {
|
|
28
|
+
if (!value || typeof value !== 'object')
|
|
29
|
+
return {};
|
|
30
|
+
const v = value, result = {};
|
|
31
|
+
for (const field of ['input', 'output', 'firstByteMs']) {
|
|
32
|
+
const n = v[field];
|
|
33
|
+
if (typeof n === 'number' &&
|
|
34
|
+
Number.isFinite(n) &&
|
|
35
|
+
n >= 0 &&
|
|
36
|
+
(field === 'firstByteMs' || (Number.isSafeInteger(n) && n <= (field === 'input' ? 1024 : 16))))
|
|
37
|
+
result[field] = n;
|
|
38
|
+
}
|
|
39
|
+
if (typeof v.responseId === 'string' && /^msg[-_A-Za-z0-9:.]{1,188}$/.test(v.responseId))
|
|
40
|
+
result.responseId = v.responseId;
|
|
41
|
+
if (typeof v.reportedModel === 'string' &&
|
|
42
|
+
/^(?:anthropic\/)?claude-haiku-4-5(?:-20251001)?$/.test(v.reportedModel))
|
|
43
|
+
result.reportedModel = v.reportedModel;
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
function p95(rows, field) {
|
|
47
|
+
const values = rows
|
|
48
|
+
.map((row) => row[field])
|
|
49
|
+
.filter((v) => typeof v === 'number' && Number.isFinite(v))
|
|
50
|
+
.sort((a, b) => a - b);
|
|
51
|
+
return values.length ? values[Math.ceil(values.length * 0.95) - 1] : null;
|
|
52
|
+
}
|
|
53
|
+
/** Only the existing Unix broker is addressed; its token is local to that socket. */
|
|
54
|
+
async function sendSmokeNative(handle, index, signal) {
|
|
55
|
+
let base;
|
|
56
|
+
try {
|
|
57
|
+
base = new URL(handle.env.ANTHROPIC_BASE_URL);
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return fail('SMOKE_BROKER_REQUIRED');
|
|
61
|
+
}
|
|
62
|
+
const token = handle.env.ANTHROPIC_AUTH_TOKEN;
|
|
63
|
+
if (base.protocol !== 'http:' ||
|
|
64
|
+
base.hostname !== inference_broker_1.INFERENCE_BROKER_HOST ||
|
|
65
|
+
base.username ||
|
|
66
|
+
base.password ||
|
|
67
|
+
!handle.socketPath ||
|
|
68
|
+
typeof token !== 'string' ||
|
|
69
|
+
!token ||
|
|
70
|
+
index < 0 ||
|
|
71
|
+
index >= inference_broker_1.OVERLOAD_SMOKE_PLAN.nativeCount)
|
|
72
|
+
return fail('SMOKE_BROKER_REQUIRED');
|
|
73
|
+
const payload = (0, inference_broker_1.overloadSmokeNativePayload)(index, handle.clientModelId ?? handle.model);
|
|
74
|
+
(0, inference_broker_1.boundedOverloadSmokeBody)(payload, (0, inference_broker_1.overloadSmokePrompt)(index));
|
|
75
|
+
const body = JSON.stringify(payload);
|
|
76
|
+
return new Promise((resolve, reject) => {
|
|
77
|
+
const request = (0, node_http_1.request)({
|
|
78
|
+
socketPath: handle.socketPath,
|
|
79
|
+
method: 'POST',
|
|
80
|
+
path: '/v1/messages',
|
|
81
|
+
signal,
|
|
82
|
+
headers: {
|
|
83
|
+
host: base.host,
|
|
84
|
+
authorization: `Bearer ${token}`,
|
|
85
|
+
'content-type': 'application/json',
|
|
86
|
+
'content-length': Buffer.byteLength(body),
|
|
87
|
+
'anthropic-version': '2023-06-01',
|
|
88
|
+
},
|
|
89
|
+
}, (response) => resolve({
|
|
90
|
+
status: response.statusCode ?? 0,
|
|
91
|
+
body: node_stream_1.Readable.toWeb(response),
|
|
92
|
+
}));
|
|
93
|
+
request.once('error', () => reject(new inference_overload_smoke_contract_1.InferenceSmokeError(signal.aborted ? 'SMOKE_ABORTED' : 'SMOKE_NATIVE_TRANSPORT_UNKNOWN')));
|
|
94
|
+
request.end(body);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
async function runInferenceOverloadSmoke(input, deps = {}) {
|
|
98
|
+
if (!input.agentRef?.trim())
|
|
99
|
+
fail('SMOKE_AGENT_REQUIRED');
|
|
100
|
+
if (input.sessionId !== undefined && !/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/.test(input.sessionId))
|
|
101
|
+
fail('SMOKE_SESSION_INVALID');
|
|
102
|
+
const plan = inference_broker_1.OVERLOAD_SMOKE_PLAN;
|
|
103
|
+
const now = deps.now ?? (() => node_perf_hooks_1.performance.now());
|
|
104
|
+
const wait = deps.wait ?? ((ms, signal) => (0, promises_1.setTimeout)(ms, undefined, { signal }));
|
|
105
|
+
const native = deps.native ?? sendSmokeNative;
|
|
106
|
+
const controller = new AbortController();
|
|
107
|
+
let handle = null, operationId = null, problem = null;
|
|
108
|
+
let started = now(), deadline = Infinity, nextNativeAt = started, timer = null;
|
|
109
|
+
let sends = 0, stopInvoked = false, receipt = null, readbackProblem = null;
|
|
110
|
+
let nativeCustomerQuoteMicros = null;
|
|
111
|
+
const rows = Array.from({ length: plan.total }, (_, index) => ({
|
|
112
|
+
index,
|
|
113
|
+
rail: index < plan.nativeCount ? 'native' : 'batch',
|
|
114
|
+
cohort: index < plan.baseline ? 'baseline' : 'mixed',
|
|
115
|
+
status: 'unsent',
|
|
116
|
+
}));
|
|
117
|
+
const abort = () => controller.abort(new inference_overload_smoke_contract_1.InferenceSmokeError('SMOKE_ABORTED'));
|
|
118
|
+
input.signal?.addEventListener('abort', abort, { once: true });
|
|
119
|
+
if (input.signal?.aborted)
|
|
120
|
+
abort();
|
|
121
|
+
function active() {
|
|
122
|
+
if (now() >= deadline && !controller.signal.aborted)
|
|
123
|
+
controller.abort(new inference_overload_smoke_contract_1.InferenceSmokeError('SMOKE_DEADLINE'));
|
|
124
|
+
if (controller.signal.aborted)
|
|
125
|
+
throw controller.signal.reason;
|
|
126
|
+
}
|
|
127
|
+
function stop(error) {
|
|
128
|
+
problem ??= safeCode(error);
|
|
129
|
+
if (!controller.signal.aborted)
|
|
130
|
+
controller.abort(new inference_overload_smoke_contract_1.InferenceSmokeError(problem));
|
|
131
|
+
}
|
|
132
|
+
async function send(index) {
|
|
133
|
+
const row = rows[index];
|
|
134
|
+
try {
|
|
135
|
+
active();
|
|
136
|
+
if (!handle || !operationId || row.status !== 'unsent' || sends >= plan.total)
|
|
137
|
+
fail('SMOKE_SEND_BOUND');
|
|
138
|
+
row.status = 'started';
|
|
139
|
+
sends += 1;
|
|
140
|
+
const at = now();
|
|
141
|
+
row.startedMs = at - started;
|
|
142
|
+
if (row.rail === 'native') {
|
|
143
|
+
const upstream = await native(handle, index, controller.signal);
|
|
144
|
+
try {
|
|
145
|
+
Object.assign(row, await (0, inference_broker_1.readOverloadSmokeNativeReceipt)(upstream, controller.signal, now, at));
|
|
146
|
+
}
|
|
147
|
+
finally {
|
|
148
|
+
await upstream.body.cancel().catch(() => { });
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
const result = await handle.overloadSmoke.batch(operationId, index - plan.nativeCount, controller.signal);
|
|
153
|
+
row.tokens = result.tokens;
|
|
154
|
+
row.authorizationId = result.authorizationId;
|
|
155
|
+
row.usageEventId = result.usageEventId;
|
|
156
|
+
row.canonicalCostMicros = result.canonicalCostMicros;
|
|
157
|
+
row.nativeOrdinalWaitMs = result.nativeOrdinalWaitMs;
|
|
158
|
+
}
|
|
159
|
+
row.status = 'completed';
|
|
160
|
+
}
|
|
161
|
+
catch (error) {
|
|
162
|
+
row.status = 'refused_or_unknown';
|
|
163
|
+
// The shared native parser's partial observation contains metadata only.
|
|
164
|
+
if (error && typeof error === 'object' && 'observed' in error)
|
|
165
|
+
row.observed = partialObservation(error.observed);
|
|
166
|
+
stop(error);
|
|
167
|
+
}
|
|
168
|
+
finally {
|
|
169
|
+
if (row.startedMs !== undefined) {
|
|
170
|
+
row.endedMs = now() - started;
|
|
171
|
+
row.totalMs = row.endedMs - row.startedMs;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
async function nativeRound(run) {
|
|
176
|
+
active();
|
|
177
|
+
if (now() < nextNativeAt)
|
|
178
|
+
await wait(nextNativeAt - now(), controller.signal);
|
|
179
|
+
active();
|
|
180
|
+
nextNativeAt = now() + plan.nativeSpacingMs;
|
|
181
|
+
await run();
|
|
182
|
+
}
|
|
183
|
+
try {
|
|
184
|
+
active();
|
|
185
|
+
const acquire = deps.acquire ?? ((options) => {
|
|
186
|
+
let pendingSessionId = input.sessionId;
|
|
187
|
+
return (0, first_party_harness_broker_1.acquireManagedSession)(options, {
|
|
188
|
+
newId() {
|
|
189
|
+
const id = pendingSessionId;
|
|
190
|
+
pendingSessionId = undefined;
|
|
191
|
+
return id ?? (0, node_crypto_1.randomUUID)();
|
|
192
|
+
},
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
handle = await acquire({
|
|
196
|
+
agentRef: input.agentRef,
|
|
197
|
+
model: plan.nativeModel,
|
|
198
|
+
reasoningEffort: 'none',
|
|
199
|
+
// This diagnostic emits only its closed metadata receipt; ordinary teardown/transport
|
|
200
|
+
// prose is not forwarded because it may contain request-derived diagnostics.
|
|
201
|
+
log: () => { },
|
|
202
|
+
onLeaseRenewalStopped: () => controller.abort(new inference_overload_smoke_contract_1.InferenceSmokeError('SMOKE_LEASE_ENDED')),
|
|
203
|
+
});
|
|
204
|
+
active();
|
|
205
|
+
if (!handle.overloadSmoke ||
|
|
206
|
+
(input.sessionId !== undefined && handle.sessionId !== input.sessionId) ||
|
|
207
|
+
handle.authorizedUsd !== 1 ||
|
|
208
|
+
![plan.alias, plan.nativeModel].includes(handle.model))
|
|
209
|
+
fail('SMOKE_NORMAL_ADMISSION_CHANGED');
|
|
210
|
+
started = now();
|
|
211
|
+
const beginStarted = started;
|
|
212
|
+
// Arm the fixed deadline before begin; admission/renewal can never reset it.
|
|
213
|
+
deadline = started + plan.durationMs;
|
|
214
|
+
timer = setTimeout(() => controller.abort(new inference_overload_smoke_contract_1.InferenceSmokeError('SMOKE_DEADLINE')), plan.durationMs);
|
|
215
|
+
const begin = await handle.overloadSmoke.begin(controller.signal);
|
|
216
|
+
operationId = begin.operationId;
|
|
217
|
+
nativeCustomerQuoteMicros = begin.nativeCustomerQuoteMicros;
|
|
218
|
+
// Use the earlier bound; a delayed begin response does not extend either clock.
|
|
219
|
+
deadline = Math.min(deadline, beginStarted + begin.remainingMs);
|
|
220
|
+
if (timer)
|
|
221
|
+
clearTimeout(timer);
|
|
222
|
+
timer = setTimeout(() => controller.abort(new inference_overload_smoke_contract_1.InferenceSmokeError('SMOKE_DEADLINE')), Math.max(0, deadline - now()));
|
|
223
|
+
nextNativeAt = now();
|
|
224
|
+
active();
|
|
225
|
+
for (let index = 0; index < plan.baseline; index += 1)
|
|
226
|
+
await nativeRound(() => send(index));
|
|
227
|
+
for (let round = 0; round < plan.mixedNative; round += 1) {
|
|
228
|
+
await nativeRound(() => Promise.allSettled([
|
|
229
|
+
send(plan.baseline + round),
|
|
230
|
+
(async () => {
|
|
231
|
+
await send(plan.nativeCount + round * 2);
|
|
232
|
+
active();
|
|
233
|
+
await send(plan.nativeCount + round * 2 + 1);
|
|
234
|
+
})(),
|
|
235
|
+
]));
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
catch (error) {
|
|
239
|
+
stop(error);
|
|
240
|
+
}
|
|
241
|
+
finally {
|
|
242
|
+
if (timer)
|
|
243
|
+
clearTimeout(timer);
|
|
244
|
+
input.signal?.removeEventListener('abort', abort);
|
|
245
|
+
if (handle) {
|
|
246
|
+
stopInvoked = true;
|
|
247
|
+
try {
|
|
248
|
+
await handle.stop(controller.signal.aborted ? 'cli_session_interrupted' : 'cli_session_ended');
|
|
249
|
+
}
|
|
250
|
+
catch {
|
|
251
|
+
problem ??= 'SMOKE_STOP_UNCONFIRMED';
|
|
252
|
+
}
|
|
253
|
+
if (operationId && handle.overloadSmoke) {
|
|
254
|
+
try {
|
|
255
|
+
receipt = await handle.overloadSmoke.receipt(operationId);
|
|
256
|
+
}
|
|
257
|
+
catch (error) {
|
|
258
|
+
readbackProblem = safeCode(error);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
const observedNativeUsage = rows.some((row) => row.rail === 'native' &&
|
|
264
|
+
((row.tokens?.input ?? 0) > 0 ||
|
|
265
|
+
(row.tokens?.output ?? 0) > 0 ||
|
|
266
|
+
Number(row.observed?.input ?? 0) > 0 ||
|
|
267
|
+
Number(row.observed?.output ?? 0) > 0));
|
|
268
|
+
const nativeFinancial = receipt?.native;
|
|
269
|
+
const nativeAuthorization = nativeFinancial?.authorization;
|
|
270
|
+
if (observedNativeUsage &&
|
|
271
|
+
nativeFinancial?.status === 'settled' &&
|
|
272
|
+
nativeFinancial.settledUsd === 0 &&
|
|
273
|
+
receipt?.reconciliationPending === false) {
|
|
274
|
+
readbackProblem = 'SMOKE_FINANCIAL_READBACK_INCONSISTENT';
|
|
275
|
+
problem ??= readbackProblem;
|
|
276
|
+
}
|
|
277
|
+
const nativeReconciled = nativeFinancial?.status === 'settled' &&
|
|
278
|
+
nativeFinancial.leaseStatus === 'revoked' &&
|
|
279
|
+
nativeFinancial.revokeStatus === 'revoked' &&
|
|
280
|
+
nativeFinancial.concurrencyReleased === true &&
|
|
281
|
+
nativeAuthorization &&
|
|
282
|
+
((nativeAuthorization.status === 'settled' &&
|
|
283
|
+
typeof nativeAuthorization.actualUsageUnits === 'number') ||
|
|
284
|
+
(!observedNativeUsage && nativeAuthorization.status === 'released'));
|
|
285
|
+
const utilityPending = receipt?.requests.some((row) => {
|
|
286
|
+
const authorization = row.authorization;
|
|
287
|
+
return row.status === 'completed'
|
|
288
|
+
? !authorization ||
|
|
289
|
+
authorization.status !== 'settled' ||
|
|
290
|
+
authorization.actualUsageUnits == null
|
|
291
|
+
: !!authorization && !['settled', 'released'].includes(authorization.status ?? '');
|
|
292
|
+
}) ?? true;
|
|
293
|
+
const reconciliationPending = !receipt ||
|
|
294
|
+
receipt.reconciliationPending ||
|
|
295
|
+
receipt.remoteWorkPending ||
|
|
296
|
+
receipt.authorizationCoverageUnknown ||
|
|
297
|
+
!nativeReconciled ||
|
|
298
|
+
utilityPending ||
|
|
299
|
+
readbackProblem !== null;
|
|
300
|
+
const complete = rows.filter((r) => r.status === 'completed');
|
|
301
|
+
const clientRequestOverlap = Array.from({ length: plan.mixedNative }, (_, round) => {
|
|
302
|
+
const nativeRow = rows[plan.baseline + round];
|
|
303
|
+
const batches = [rows[plan.nativeCount + round * 2], rows[plan.nativeCount + round * 2 + 1]];
|
|
304
|
+
const overlapMs = batches.reduce((sum, batch) => {
|
|
305
|
+
if (nativeRow.startedMs === undefined ||
|
|
306
|
+
nativeRow.endedMs === undefined ||
|
|
307
|
+
batch.startedMs === undefined ||
|
|
308
|
+
batch.endedMs === undefined)
|
|
309
|
+
return sum;
|
|
310
|
+
return (sum +
|
|
311
|
+
Math.max(0, Math.min(nativeRow.endedMs, batch.endedMs) -
|
|
312
|
+
Math.max(nativeRow.startedMs, batch.startedMs)));
|
|
313
|
+
}, 0);
|
|
314
|
+
return { round, overlapMs };
|
|
315
|
+
});
|
|
316
|
+
return {
|
|
317
|
+
kind: 'bounded-plumbing-smoke',
|
|
318
|
+
qualification: false,
|
|
319
|
+
providerComputeOverlap: null,
|
|
320
|
+
problem,
|
|
321
|
+
operationId,
|
|
322
|
+
sessionId: handle?.sessionId ?? null,
|
|
323
|
+
nativeReservationId: (0, inference_overload_smoke_contract_1.safeSmokeIdentifier)(handle?.reservationId),
|
|
324
|
+
requestedSends: 128,
|
|
325
|
+
sends,
|
|
326
|
+
completed: complete.length,
|
|
327
|
+
providerExposureCeilingUsd: sends * plan.providerExposurePerSendUsd,
|
|
328
|
+
nativeAuthorizedUsd: handle?.authorizedUsd ?? null,
|
|
329
|
+
nativeCustomerQuoteMicros,
|
|
330
|
+
requests: rows,
|
|
331
|
+
clientRequestOverlap,
|
|
332
|
+
latency: Object.fromEntries(['baseline', 'mixed'].map((cohort) => {
|
|
333
|
+
const selected = complete.filter((r) => r.rail === 'native' && r.cohort === cohort);
|
|
334
|
+
return [
|
|
335
|
+
cohort,
|
|
336
|
+
{
|
|
337
|
+
samples: selected.length,
|
|
338
|
+
p95FirstBodyByteMs: p95(selected, 'firstByteMs'),
|
|
339
|
+
p95TotalMs: p95(selected, 'totalMs'),
|
|
340
|
+
},
|
|
341
|
+
];
|
|
342
|
+
})),
|
|
343
|
+
cleanup: {
|
|
344
|
+
stopInvoked,
|
|
345
|
+
receipt,
|
|
346
|
+
reconciliationPending,
|
|
347
|
+
readbackProblem,
|
|
348
|
+
},
|
|
349
|
+
};
|
|
350
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sha = void 0;
|
|
4
|
+
exports.privatePlan = privatePlan;
|
|
5
|
+
exports.durable = durable;
|
|
6
|
+
const node_crypto_1 = require("node:crypto");
|
|
7
|
+
const node_fs_1 = require("node:fs");
|
|
8
|
+
const node_path_1 = require("node:path");
|
|
9
|
+
const sha = (raw) => (0, node_crypto_1.createHash)('sha256').update(raw).digest('hex');
|
|
10
|
+
exports.sha = sha;
|
|
11
|
+
function privatePlan(file) {
|
|
12
|
+
const absolute = (0, node_path_1.resolve)(file), parent = (0, node_fs_1.lstatSync)((0, node_path_1.dirname)(absolute));
|
|
13
|
+
const fd = (0, node_fs_1.openSync)(absolute, node_fs_1.constants.O_RDONLY | node_fs_1.constants.O_NOFOLLOW | node_fs_1.constants.O_NONBLOCK);
|
|
14
|
+
try {
|
|
15
|
+
const stat = (0, node_fs_1.fstatSync)(fd);
|
|
16
|
+
if (!stat.isFile() ||
|
|
17
|
+
stat.nlink !== 1 ||
|
|
18
|
+
stat.uid !== process.getuid?.() ||
|
|
19
|
+
stat.size > 65536 ||
|
|
20
|
+
stat.mode & 0o077 ||
|
|
21
|
+
!parent.isDirectory() ||
|
|
22
|
+
parent.isSymbolicLink() ||
|
|
23
|
+
parent.uid !== process.getuid?.() ||
|
|
24
|
+
parent.mode & 0o077)
|
|
25
|
+
throw new Error('PROBE_PRIVATE_PLAN_REQUIRED');
|
|
26
|
+
const raw = Buffer.alloc(65537);
|
|
27
|
+
let length = 0;
|
|
28
|
+
while (length < raw.length) {
|
|
29
|
+
const count = (0, node_fs_1.readSync)(fd, raw, length, raw.length - length, null);
|
|
30
|
+
if (!count)
|
|
31
|
+
break;
|
|
32
|
+
length += count;
|
|
33
|
+
}
|
|
34
|
+
const after = (0, node_fs_1.fstatSync)(fd);
|
|
35
|
+
if (length > 65536 ||
|
|
36
|
+
length !== stat.size ||
|
|
37
|
+
after.size !== stat.size ||
|
|
38
|
+
after.mtimeMs !== stat.mtimeMs)
|
|
39
|
+
throw new Error('PROBE_PLAN_CHANGED');
|
|
40
|
+
return { absolute, raw: raw.subarray(0, length) };
|
|
41
|
+
}
|
|
42
|
+
finally {
|
|
43
|
+
(0, node_fs_1.closeSync)(fd);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function syncParent(file) {
|
|
47
|
+
const fd = (0, node_fs_1.openSync)((0, node_path_1.dirname)(file), 'r');
|
|
48
|
+
try {
|
|
49
|
+
(0, node_fs_1.fsyncSync)(fd);
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
(0, node_fs_1.closeSync)(fd);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function durable(file, value, exclusive = false) {
|
|
56
|
+
const target = exclusive ? file : file + '.next';
|
|
57
|
+
const fd = (0, node_fs_1.openSync)(target, 'wx', 0o600);
|
|
58
|
+
try {
|
|
59
|
+
(0, node_fs_1.writeFileSync)(fd, JSON.stringify(value) + '\n');
|
|
60
|
+
(0, node_fs_1.fsyncSync)(fd);
|
|
61
|
+
}
|
|
62
|
+
finally {
|
|
63
|
+
(0, node_fs_1.closeSync)(fd);
|
|
64
|
+
}
|
|
65
|
+
if (!exclusive)
|
|
66
|
+
(0, node_fs_1.renameSync)(target, file);
|
|
67
|
+
syncParent(file);
|
|
68
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type H9Harness, type H9TurnLabel } from './h9-platform-stream';
|
|
2
|
+
export interface PlatformH9Plan {
|
|
3
|
+
schema: 'pi-platform-h9.v1' | 'copilot-platform-h9.v2';
|
|
4
|
+
operationId: string;
|
|
5
|
+
ownerUserId: string;
|
|
6
|
+
workspaceId?: string;
|
|
7
|
+
grantId: string;
|
|
8
|
+
agentId: string;
|
|
9
|
+
harnessId: string;
|
|
10
|
+
daemonId: string;
|
|
11
|
+
image: string;
|
|
12
|
+
origin: 'https://skrr.io' | 'https://skrr.ai';
|
|
13
|
+
version: '1.5.2' | '1.0.112';
|
|
14
|
+
model: 'claude-sonnet-5';
|
|
15
|
+
nonce: string;
|
|
16
|
+
expiresAt: string;
|
|
17
|
+
paidOperationApproved: boolean;
|
|
18
|
+
completionOnly?: true;
|
|
19
|
+
priorStream?: {
|
|
20
|
+
grantId: string;
|
|
21
|
+
machine: {
|
|
22
|
+
daemonId: string;
|
|
23
|
+
machineUuid: string;
|
|
24
|
+
machineProduct: string;
|
|
25
|
+
image: string;
|
|
26
|
+
};
|
|
27
|
+
capture: {
|
|
28
|
+
conversation: {
|
|
29
|
+
status: number;
|
|
30
|
+
data: unknown;
|
|
31
|
+
};
|
|
32
|
+
message: {
|
|
33
|
+
status: number;
|
|
34
|
+
data: unknown;
|
|
35
|
+
};
|
|
36
|
+
envelopes: {
|
|
37
|
+
status: number;
|
|
38
|
+
data: unknown;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export declare function platformH9Plan(value: unknown, now?: number): PlatformH9Plan;
|
|
44
|
+
export declare function platformH9Harness(plan: PlatformH9Plan): H9Harness;
|
|
45
|
+
/** Completion plans only collect missing evidence on a fresh grant. */
|
|
46
|
+
export declare function platformH9Labels(plan: PlatformH9Plan): readonly H9TurnLabel[];
|
|
47
|
+
export declare function platformH9RequestId(plan: PlatformH9Plan, label: H9TurnLabel): string;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.platformH9Plan = platformH9Plan;
|
|
4
|
+
exports.platformH9Harness = platformH9Harness;
|
|
5
|
+
exports.platformH9Labels = platformH9Labels;
|
|
6
|
+
exports.platformH9RequestId = platformH9RequestId;
|
|
7
|
+
const h9_platform_stream_1 = require("./h9-platform-stream");
|
|
8
|
+
const KEYS = [
|
|
9
|
+
'schema',
|
|
10
|
+
'operationId',
|
|
11
|
+
'ownerUserId',
|
|
12
|
+
'grantId',
|
|
13
|
+
'agentId',
|
|
14
|
+
'harnessId',
|
|
15
|
+
'daemonId',
|
|
16
|
+
'image',
|
|
17
|
+
'origin',
|
|
18
|
+
'version',
|
|
19
|
+
'model',
|
|
20
|
+
'nonce',
|
|
21
|
+
'expiresAt',
|
|
22
|
+
'paidOperationApproved',
|
|
23
|
+
];
|
|
24
|
+
const id = (value) => typeof value === 'string' && /^[A-Za-z0-9][A-Za-z0-9_.:@-]{0,239}$/.test(value);
|
|
25
|
+
const hex = (value) => typeof value === 'string' && /^[a-f0-9]{32}$/.test(value);
|
|
26
|
+
function platformH9Plan(value, now = Date.now()) {
|
|
27
|
+
const p = value;
|
|
28
|
+
if (!p ||
|
|
29
|
+
typeof p !== 'object' ||
|
|
30
|
+
Array.isArray(p) ||
|
|
31
|
+
JSON.stringify(Object.keys(p).sort()) !==
|
|
32
|
+
JSON.stringify([
|
|
33
|
+
...KEYS,
|
|
34
|
+
...(p.workspaceId === undefined ? [] : ['workspaceId']),
|
|
35
|
+
...(p.priorStream === undefined ? [] : ['priorStream']),
|
|
36
|
+
...(p.completionOnly === undefined ? [] : ['completionOnly']),
|
|
37
|
+
].sort()) ||
|
|
38
|
+
(p.workspaceId !== undefined && !id(p.workspaceId)) ||
|
|
39
|
+
(p.completionOnly !== undefined &&
|
|
40
|
+
(p.completionOnly !== true || p.priorStream !== undefined || !id(p.workspaceId))) ||
|
|
41
|
+
(p.priorStream !== undefined &&
|
|
42
|
+
(!id(p.priorStream?.grantId) ||
|
|
43
|
+
p.priorStream.grantId === p.grantId ||
|
|
44
|
+
!id(p.priorStream.machine?.daemonId) ||
|
|
45
|
+
!id(p.priorStream.machine.machineUuid) ||
|
|
46
|
+
p.priorStream.machine.image !== p.image ||
|
|
47
|
+
!['hosted-machine', 'dedicated-machine'].includes(p.priorStream.machine.machineProduct))) ||
|
|
48
|
+
!((p.schema === 'pi-platform-h9.v1' && p.version === '1.5.2') ||
|
|
49
|
+
(p.schema === 'copilot-platform-h9.v2' && p.version === '1.0.112')) ||
|
|
50
|
+
p.model !== 'claude-sonnet-5' ||
|
|
51
|
+
!['https://skrr.io', 'https://skrr.ai'].includes(p.origin) ||
|
|
52
|
+
![p.ownerUserId, p.grantId, p.agentId, p.harnessId, p.daemonId, p.image].every(id) ||
|
|
53
|
+
!hex(p.operationId) ||
|
|
54
|
+
!hex(p.nonce) ||
|
|
55
|
+
p.paidOperationApproved !== true ||
|
|
56
|
+
typeof p.expiresAt !== 'string' ||
|
|
57
|
+
!p.expiresAt.endsWith('Z') ||
|
|
58
|
+
!(Date.parse(p.expiresAt) > now && Date.parse(p.expiresAt) <= now + 15 * 60_000))
|
|
59
|
+
throw new Error('H9_EXACT_BOUNDED_PLAN_REQUIRED');
|
|
60
|
+
return Object.freeze({ ...p });
|
|
61
|
+
}
|
|
62
|
+
function platformH9Harness(plan) {
|
|
63
|
+
return plan.schema === 'pi-platform-h9.v1' ? 'pi' : 'copilot-sdk';
|
|
64
|
+
}
|
|
65
|
+
/** Completion plans only collect missing evidence on a fresh grant. */
|
|
66
|
+
function platformH9Labels(plan) {
|
|
67
|
+
if (plan.completionOnly) {
|
|
68
|
+
return platformH9Harness(plan) === 'pi'
|
|
69
|
+
? ['remember', 'interrupt', 'recall', 'cancel']
|
|
70
|
+
: ['cancel'];
|
|
71
|
+
}
|
|
72
|
+
return plan.priorStream ? h9_platform_stream_1.H9_TURN_LABELS.slice(1) : h9_platform_stream_1.H9_TURN_LABELS;
|
|
73
|
+
}
|
|
74
|
+
function platformH9RequestId(plan, label) {
|
|
75
|
+
if (!h9_platform_stream_1.H9_TURN_LABELS.includes(label))
|
|
76
|
+
throw new Error('H9_LABEL_INVALID');
|
|
77
|
+
return `h9-platform-${plan.operationId}:${label}`;
|
|
78
|
+
}
|