@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.
Files changed (66) 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/agent-model-check.d.ts +19 -0
  19. package/dist/lib/agent-model-check.js +10 -20
  20. package/dist/lib/agentic-stream.d.ts +3 -0
  21. package/dist/lib/agentic-stream.js +63 -1
  22. package/dist/lib/copilot-fixed-probe-runner.d.ts +72 -0
  23. package/dist/lib/copilot-fixed-probe-runner.js +213 -0
  24. package/dist/lib/copilot-fixed-probe.d.ts +61 -0
  25. package/dist/lib/copilot-fixed-probe.js +223 -0
  26. package/dist/lib/credential-resolver.d.ts +1 -0
  27. package/dist/lib/credential-resolver.js +5 -1
  28. package/dist/lib/first-party-harness-broker.d.ts +5 -10
  29. package/dist/lib/first-party-harness-broker.js +121 -50
  30. package/dist/lib/h9-platform-stream.d.ts +63 -0
  31. package/dist/lib/h9-platform-stream.js +317 -0
  32. package/dist/lib/h9-prior-stream.d.ts +44 -0
  33. package/dist/lib/h9-prior-stream.js +217 -0
  34. package/dist/lib/harness-evaluations.d.ts +85 -0
  35. package/dist/lib/harness-evaluations.js +8 -0
  36. package/dist/lib/hosted-identity-evaluations.d.ts +26 -0
  37. package/dist/lib/hosted-identity-evaluations.js +18 -0
  38. package/dist/lib/hosted-machines.d.ts +1 -0
  39. package/dist/lib/inference-overload-smoke-contract.d.ts +53 -0
  40. package/dist/lib/inference-overload-smoke-contract.js +192 -0
  41. package/dist/lib/inference-overload-smoke.d.ts +78 -0
  42. package/dist/lib/inference-overload-smoke.js +350 -0
  43. package/dist/lib/operator-probe-files.d.ts +6 -0
  44. package/dist/lib/operator-probe-files.js +68 -0
  45. package/dist/lib/platform-h9-plan.d.ts +47 -0
  46. package/dist/lib/platform-h9-plan.js +78 -0
  47. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/codex-model-catalog.json +150 -0
  48. package/dist/node_modules/@skrr-ai/data-provider/index.js +6 -6
  49. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/index.d.ts +3 -1
  50. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/index.js +23 -1
  51. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-haiku-none.d.ts +8 -0
  52. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-haiku-none.js +40 -0
  53. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-inference-broker.d.ts +2 -11
  54. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-inference-broker.js +31 -5
  55. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/overload-smoke.d.ts +56 -0
  56. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/overload-smoke.js +277 -0
  57. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/index.d.ts +3 -1
  58. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/index.js +3 -1
  59. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-haiku-none.d.ts +8 -0
  60. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-haiku-none.js +20 -0
  61. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-inference-broker.d.ts +2 -11
  62. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-inference-broker.js +28 -4
  63. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/overload-smoke.d.ts +56 -0
  64. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/overload-smoke.js +261 -0
  65. package/oclif.manifest.json +473 -1
  66. package/package.json +2 -2
@@ -36,9 +36,11 @@ __export(managed_inference_broker_exports, {
36
36
  managedInputEnvelopeValue: () => managedInputEnvelopeValue,
37
37
  noProxyEnvWithHosts: () => noProxyEnvWithHosts,
38
38
  parseManagedInputEnvelope: () => parseManagedInputEnvelope,
39
- startManagedInferenceBroker: () => startManagedInferenceBroker
39
+ startManagedInferenceBroker: () => startManagedInferenceBroker,
40
+ supportsOpenAIExplicitPromptCache: () => supportsOpenAIExplicitPromptCache
40
41
  });
41
42
  module.exports = __toCommonJS(managed_inference_broker_exports);
43
+ var import_managed_haiku_none = require("./managed-haiku-none.js");
42
44
  var import_node_crypto = require("node:crypto");
43
45
  var import_node_fs = require("node:fs");
44
46
  var import_node_path = require("node:path");
@@ -49,6 +51,18 @@ const WITH_INFERENCE_BROKER_HOST_RE = /[\s,]+$/;
49
51
  const BUILD_MANAGED_INFERENCE_RELAY_CREDENTIAL_RE = /\/$/;
50
52
  const START_MANAGED_INFERENCE_BROKER_RE = /\/+$/;
51
53
  const SUPPORTS_MANAGED_PROMPT_CACHING_RE = /^openai\//;
54
+ const CURRENT_OPENAI_CACHE_MODELS = /* @__PURE__ */ new Set([
55
+ "gpt-6-luna",
56
+ "gpt-6.1-terra",
57
+ "gpt-6.2-astra",
58
+ "gpt-6.2-sol"
59
+ ]);
60
+ function supportsOpenAIExplicitPromptCache(modelId) {
61
+ if (typeof modelId !== "string")
62
+ return false;
63
+ const model = modelId.trim().toLowerCase().replace(/^(?:openai\/|(?:(?:bedrock_mantle|bedrock|amazon-bedrock)\/)?openai\.)/, "");
64
+ return /(?:^|[/.])gpt-5\.6(?:-|$)/.test(model) || CURRENT_OPENAI_CACHE_MODELS.has(model);
65
+ }
52
66
  const MANAGED_STATUS_PATH = "/oversky/managed-status";
53
67
  const INFERENCE_BROKER_ORIGIN = "http://oversky-inference-broker.invalid";
54
68
  const INFERENCE_BROKER_HOST = new URL(INFERENCE_BROKER_ORIGIN).hostname;
@@ -745,10 +759,21 @@ function enforceRequestEnvelope(payload, path, envelope, modelScope, promptCache
745
759
  effort: effectiveEffort
746
760
  };
747
761
  } else if (path.endsWith("/messages")) {
748
- if (!["low", "medium", "high", "max"].includes(effectiveEffort)) {
762
+ let noThinking = false;
763
+ try {
764
+ noThinking = (0, import_managed_haiku_none.projectManagedHaiku45None)(payload, {
765
+ model: modelScope.harnessModelId,
766
+ upstreamProvider: modelScope.upstreamProvider,
767
+ effort: effectiveEffort
768
+ });
769
+ } catch {
770
+ rejectManagedRequest("managed Haiku NONE conflicts with thinking or output config");
771
+ }
772
+ if (!noThinking && !["low", "medium", "high", "max"].includes(effectiveEffort)) {
749
773
  rejectManagedRequest("managed inference broker denied reasoning effort unsupported by the Anthropic dialect");
750
774
  }
751
- payload.output_config = { ...anthropicOutputConfig ?? {}, effort: effectiveEffort };
775
+ if (!noThinking)
776
+ payload.output_config = { ...anthropicOutputConfig ?? {}, effort: effectiveEffort };
752
777
  } else if (modelScope.upstreamProvider === "openrouter") {
753
778
  const openRouterReasoning = reasoning && typeof reasoning === "object" && !Array.isArray(reasoning) ? { ...reasoning } : {};
754
779
  delete openRouterReasoning.max_tokens;
@@ -815,7 +840,7 @@ const CLAUDE_MAX_CACHE_BREAKPOINTS = 4;
815
840
  const CLAUDE_PROMPT_CACHE_UPSTREAMS = ["anthropic", "bedrock"];
816
841
  function managedPromptCacheContract(modelScope) {
817
842
  const model = nonEmpty(modelScope.wireModel)?.replace(SUPPORTS_MANAGED_PROMPT_CACHING_RE, "").toLowerCase();
818
- if (modelScope.upstreamProvider === "openai" && model?.startsWith("gpt-5.6"))
843
+ if (modelScope.upstreamProvider === "openai" && supportsOpenAIExplicitPromptCache(modelScope.wireModel))
819
844
  return "openai";
820
845
  if (CLAUDE_PROMPT_CACHE_UPSTREAMS.includes(modelScope.upstreamProvider) && model?.includes("claude")) {
821
846
  return "claude";
@@ -1002,5 +1027,6 @@ async function* responseBody(response, maxBytes, onComplete = () => {
1002
1027
  managedInputEnvelopeValue,
1003
1028
  noProxyEnvWithHosts,
1004
1029
  parseManagedInputEnvelope,
1005
- startManagedInferenceBroker
1030
+ startManagedInferenceBroker,
1031
+ supportsOpenAIExplicitPromptCache
1006
1032
  });
@@ -0,0 +1,56 @@
1
+ /** Fixed synthetic inference smoke contract. No caller-configurable workload or authority. */
2
+ export declare const OVERLOAD_SMOKE_PLAN: Readonly<{
3
+ version: 1;
4
+ total: 128;
5
+ baseline: 32;
6
+ mixedNative: 32;
7
+ nativeCount: 64;
8
+ batch: 64;
9
+ durationMs: 180000;
10
+ nativeSpacingMs: 2100;
11
+ maxOutputTokens: 16;
12
+ maxInputUnits: 1024;
13
+ maxResponseBytes: 65536;
14
+ nativeOrdinalWaitMs: 10000;
15
+ nativeOrdinalPollMs: 250;
16
+ alias: "claude-haiku-4-5";
17
+ nativeModel: "anthropic/claude-haiku-4-5";
18
+ purpose: "utility.diagnostics.overload";
19
+ feature: "inference-overload-smoke";
20
+ providerExposurePerSendUsd: 0.0023184;
21
+ }>;
22
+ export declare function overloadSmokeError(code: string): Error & {
23
+ code: string;
24
+ };
25
+ /** utf8_bytes_json_v1 input bound, not provider token usage. API parity controls hold this
26
+ * equal to the existing authoritative native accounting strategy for these fixed JSON bodies. */
27
+ export declare function countAnthropicSmokeInputUnits(body: unknown): number;
28
+ export declare function overloadSmokePrompt(index: number): string;
29
+ export declare function overloadSmokeNativePayload(index: number, modelSelector?: string): {
30
+ model: string;
31
+ max_tokens: 16;
32
+ stream: boolean;
33
+ messages: {
34
+ role: string;
35
+ content: string;
36
+ }[];
37
+ };
38
+ export declare function boundedOverloadSmokeBody(body: any, expectedPrompt: string): number;
39
+ type NativeReceiptUpstream = {
40
+ status: number;
41
+ body: {
42
+ getReader(): Pick<ReadableStreamDefaultReader<Uint8Array>, 'read' | 'cancel'>;
43
+ } | null;
44
+ };
45
+ /** Consume the real native Messages stream; retain metadata only, never generated text. */
46
+ export declare function readOverloadSmokeNativeReceipt(upstream: NativeReceiptUpstream, signal: AbortSignal, now: () => number, started: number): Promise<{
47
+ tokens: {
48
+ input: number;
49
+ output: number;
50
+ };
51
+ responseId: never;
52
+ reportedModel: null;
53
+ firstByteMs: number | null;
54
+ }>;
55
+ export declare function boundedOverloadSmokeResponse(response: Response, signal: AbortSignal): Promise<Response>;
56
+ export {};
@@ -0,0 +1,277 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var overload_smoke_exports = {};
20
+ __export(overload_smoke_exports, {
21
+ OVERLOAD_SMOKE_PLAN: () => OVERLOAD_SMOKE_PLAN,
22
+ boundedOverloadSmokeBody: () => boundedOverloadSmokeBody,
23
+ boundedOverloadSmokeResponse: () => boundedOverloadSmokeResponse,
24
+ countAnthropicSmokeInputUnits: () => countAnthropicSmokeInputUnits,
25
+ overloadSmokeError: () => overloadSmokeError,
26
+ overloadSmokeNativePayload: () => overloadSmokeNativePayload,
27
+ overloadSmokePrompt: () => overloadSmokePrompt,
28
+ readOverloadSmokeNativeReceipt: () => readOverloadSmokeNativeReceipt
29
+ });
30
+ module.exports = __toCommonJS(overload_smoke_exports);
31
+ const OVERLOAD_SMOKE_PLAN = Object.freeze({
32
+ version: 1,
33
+ total: 128,
34
+ baseline: 32,
35
+ mixedNative: 32,
36
+ nativeCount: 64,
37
+ batch: 64,
38
+ durationMs: 18e4,
39
+ nativeSpacingMs: 2100,
40
+ maxOutputTokens: 16,
41
+ maxInputUnits: 1024,
42
+ maxResponseBytes: 65536,
43
+ nativeOrdinalWaitMs: 1e4,
44
+ nativeOrdinalPollMs: 250,
45
+ alias: "claude-haiku-4-5",
46
+ nativeModel: "anthropic/claude-haiku-4-5",
47
+ purpose: "utility.diagnostics.overload",
48
+ feature: "inference-overload-smoke",
49
+ providerExposurePerSendUsd: 23184e-7
50
+ });
51
+ const LIMITS = OVERLOAD_SMOKE_PLAN;
52
+ const ALIAS = OVERLOAD_SMOKE_PLAN.alias;
53
+ function overloadSmokeError(code) {
54
+ return Object.assign(new Error(code), { code });
55
+ }
56
+ const refusal = overloadSmokeError;
57
+ function countAnthropicSmokeInputUnits(body) {
58
+ let serialized;
59
+ try {
60
+ serialized = JSON.stringify(body);
61
+ } catch {
62
+ throw refusal("SMOKE_WIRE_CHANGED");
63
+ }
64
+ if (!serialized)
65
+ throw refusal("SMOKE_WIRE_CHANGED");
66
+ let containers = 0;
67
+ const pending = [body];
68
+ while (pending.length) {
69
+ const value = pending.pop();
70
+ if (Array.isArray(value)) {
71
+ containers += 1 + value.length;
72
+ pending.push(...value);
73
+ } else if (value && typeof value === "object") {
74
+ containers += 1;
75
+ pending.push(...Object.values(value));
76
+ }
77
+ }
78
+ return Buffer.byteLength(serialized, "utf8") + 256 + containers * 4;
79
+ }
80
+ function integer(value) {
81
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
82
+ }
83
+ function overloadSmokePrompt(index) {
84
+ if (!Number.isSafeInteger(index) || index < 0 || index >= 128)
85
+ throw refusal("SMOKE_INDEX_INVALID");
86
+ return `Reply only OK. OSK24476 synthetic probe ${String(index).padStart(3, "0")}.`;
87
+ }
88
+ function overloadSmokeNativePayload(index, modelSelector = ALIAS) {
89
+ if (!Number.isSafeInteger(index) || index < 0 || index >= 64)
90
+ throw refusal("SMOKE_INDEX_INVALID");
91
+ return {
92
+ model: modelSelector,
93
+ max_tokens: LIMITS.maxOutputTokens,
94
+ stream: true,
95
+ messages: [{ role: "user", content: overloadSmokePrompt(index) }]
96
+ };
97
+ }
98
+ function boundedOverloadSmokeBody(body, expectedPrompt) {
99
+ const allowed = /* @__PURE__ */ new Set([
100
+ "model",
101
+ "max_tokens",
102
+ "messages",
103
+ "stream",
104
+ "temperature",
105
+ "top_p",
106
+ "top_k",
107
+ "stop_sequences",
108
+ "thinking"
109
+ ]);
110
+ if (!body || Object.keys(body).some((key) => !allowed.has(key)) || ![ALIAS, OVERLOAD_SMOKE_PLAN.nativeModel].includes(body.model) || body.max_tokens !== LIMITS.maxOutputTokens || body.messages?.length !== 1 || body.messages[0].role !== "user" || body.tools != null || body.system != null || body.output_config != null || body.thinking != null && (body.thinking.type !== "disabled" || Object.keys(body.thinking).length !== 1))
111
+ throw refusal("SMOKE_WIRE_CHANGED");
112
+ const content = body.messages[0].content;
113
+ const text = typeof content === "string" ? content : Array.isArray(content) && content.length === 1 && content[0].type === "text" && Object.keys(content[0]).every((key) => ["type", "text"].includes(key)) ? content[0].text : null;
114
+ if (text !== expectedPrompt)
115
+ throw refusal("SMOKE_WIRE_CHANGED");
116
+ const units = countAnthropicSmokeInputUnits(body);
117
+ if (units > LIMITS.maxInputUnits)
118
+ throw refusal("SMOKE_INPUT_BOUND");
119
+ return units;
120
+ }
121
+ function checkedUsage(usage) {
122
+ const input = usage?.input_tokens ?? usage?.inputTokens ?? usage?.input;
123
+ const output = usage?.output_tokens ?? usage?.outputTokens ?? usage?.output;
124
+ if (!integer(input) || !integer(output) || input > LIMITS.maxInputUnits || output > LIMITS.maxOutputTokens || usage.cache_creation_input_tokens || usage.cache_read_input_tokens)
125
+ throw refusal("SMOKE_USAGE_UNKNOWN");
126
+ return { input, output };
127
+ }
128
+ async function readOverloadSmokeNativeReceipt(upstream, signal, now, started) {
129
+ if (upstream.status !== 200)
130
+ throw refusal(`SMOKE_NATIVE_HTTP_${upstream.status}`);
131
+ const reader = upstream.body?.getReader();
132
+ if (!reader)
133
+ throw refusal("SMOKE_NATIVE_STREAM_MISSING");
134
+ let buffer = "";
135
+ let bytes = 0;
136
+ let firstByteMs = null;
137
+ let stopped = false;
138
+ let stopReason = null;
139
+ let input = null;
140
+ let output = null;
141
+ let responseId = null;
142
+ let reportedModel = null;
143
+ const decoder = new TextDecoder();
144
+ const consume = (frame) => {
145
+ const data = frame.split(/\r?\n/).filter((line) => line.startsWith("data:")).map((line) => line.slice(5).trim()).join("\n");
146
+ if (!data)
147
+ return;
148
+ let event;
149
+ try {
150
+ event = JSON.parse(data);
151
+ } catch {
152
+ throw refusal("SMOKE_NATIVE_STREAM_INVALID");
153
+ }
154
+ if (event.type === "message_start") {
155
+ if (input !== null)
156
+ throw refusal("SMOKE_NATIVE_MULTIPLE_RESPONSES");
157
+ const usage = checkedUsage({
158
+ ...event.message?.usage,
159
+ output_tokens: event.message?.usage?.output_tokens ?? 0
160
+ });
161
+ input = usage.input;
162
+ output = usage.output;
163
+ responseId = typeof event.message?.id === "string" && /^msg[-_A-Za-z0-9:.]{1,188}$/.test(event.message.id) ? event.message.id : null;
164
+ reportedModel = typeof event.message?.model === "string" && /^(?:anthropic\/)?claude-haiku-4-5(?:-20251001)?$/.test(event.message.model) ? event.message.model : null;
165
+ }
166
+ if (event.type === "message_delta") {
167
+ if (!integer(event.usage?.output_tokens))
168
+ throw refusal("SMOKE_USAGE_UNKNOWN");
169
+ output = event.usage.output_tokens;
170
+ stopReason = event.delta?.stop_reason;
171
+ }
172
+ if (event.type === "message_stop")
173
+ stopped = true;
174
+ if (event.type === "error" || event.type === "content_block_start" && event.content_block?.type === "tool_use")
175
+ throw refusal("SMOKE_NATIVE_UNEXPECTED_WORK");
176
+ };
177
+ const onAbort = () => {
178
+ void reader.cancel().catch(() => {
179
+ });
180
+ };
181
+ signal.addEventListener("abort", onAbort, { once: true });
182
+ try {
183
+ while (true) {
184
+ if (signal.aborted)
185
+ throw signal.reason || refusal("SMOKE_ABORTED");
186
+ const chunk = await reader.read();
187
+ if (chunk.done)
188
+ break;
189
+ if (chunk.value.byteLength === 0)
190
+ continue;
191
+ if (firstByteMs === null)
192
+ firstByteMs = now() - started;
193
+ bytes += chunk.value.byteLength;
194
+ if (bytes > LIMITS.maxResponseBytes)
195
+ throw refusal("SMOKE_RESPONSE_BOUND");
196
+ buffer += decoder.decode(chunk.value, { stream: true });
197
+ let match;
198
+ while (match = /\r?\n\r?\n/.exec(buffer)) {
199
+ consume(buffer.slice(0, match.index));
200
+ buffer = buffer.slice(match.index + match[0].length);
201
+ }
202
+ }
203
+ if (signal.aborted)
204
+ throw signal.reason || refusal("SMOKE_ABORTED");
205
+ if (buffer.trim())
206
+ consume(buffer);
207
+ if (!stopped || !["end_turn", "max_tokens"].includes(stopReason || "") || !responseId || !/^msg[-_A-Za-z0-9:.]{1,188}$/.test(responseId) || !/^(?:anthropic\/)?claude-haiku-4-5(?:-20251001)?$/.test(reportedModel || ""))
208
+ throw refusal("SMOKE_NATIVE_INCOMPLETE");
209
+ return {
210
+ tokens: checkedUsage({ input_tokens: input, output_tokens: output }),
211
+ responseId,
212
+ reportedModel,
213
+ firstByteMs
214
+ };
215
+ } catch (error) {
216
+ const failure = error instanceof Error ? error : refusal("SMOKE_NATIVE_STREAM_INVALID");
217
+ Object.assign(failure, { observed: {
218
+ input: integer(input) ? input : null,
219
+ output: integer(output) ? output : null,
220
+ responseId,
221
+ reportedModel,
222
+ firstByteMs
223
+ } });
224
+ throw failure;
225
+ } finally {
226
+ signal.removeEventListener("abort", onAbort);
227
+ await reader.cancel().catch(() => {
228
+ });
229
+ }
230
+ }
231
+ async function boundedOverloadSmokeResponse(response, signal) {
232
+ const reader = response.body?.getReader();
233
+ if (!reader)
234
+ throw refusal("SMOKE_RESPONSE_MISSING");
235
+ const chunks = [];
236
+ let size = 0;
237
+ const abort = () => {
238
+ void reader.cancel().catch(() => {
239
+ });
240
+ };
241
+ signal.addEventListener("abort", abort, { once: true });
242
+ try {
243
+ while (true) {
244
+ if (signal.aborted)
245
+ throw signal.reason || refusal("SMOKE_ABORTED");
246
+ const { value, done } = await reader.read();
247
+ if (done)
248
+ break;
249
+ size += value.byteLength;
250
+ if (size > LIMITS.maxResponseBytes)
251
+ throw refusal("SMOKE_RESPONSE_BOUND");
252
+ chunks.push(Buffer.from(value));
253
+ }
254
+ if (signal.aborted)
255
+ throw signal.reason || refusal("SMOKE_ABORTED");
256
+ return new Response(new Uint8Array(Buffer.concat(chunks)), {
257
+ status: response.status,
258
+ statusText: response.statusText,
259
+ headers: response.headers
260
+ });
261
+ } finally {
262
+ signal.removeEventListener("abort", abort);
263
+ await reader.cancel().catch(() => {
264
+ });
265
+ }
266
+ }
267
+ // Annotate the CommonJS export names for ESM import in node:
268
+ 0 && (module.exports = {
269
+ OVERLOAD_SMOKE_PLAN,
270
+ boundedOverloadSmokeBody,
271
+ boundedOverloadSmokeResponse,
272
+ countAnthropicSmokeInputUnits,
273
+ overloadSmokeError,
274
+ overloadSmokeNativePayload,
275
+ overloadSmokePrompt,
276
+ readOverloadSmokeNativeReceipt
277
+ });
@@ -51,7 +51,9 @@
51
51
  * ESM and CJS are both emitted because the daemon is ESM and the CLI is CJS, and
52
52
  * this package exists precisely so both can host the broker.
53
53
  */
54
- export { INFERENCE_BROKER_ORIGIN, INFERENCE_BROKER_SOCKET_ENV, MANAGED_SESSION_ENV, MANAGED_PROMPT_CACHING_ENV, MANAGED_INPUT_ENVELOPE_ENV, managedInputEnvelopeValue, parseManagedInputEnvelope, MANAGED_STATUS_PATH, INFERENCE_BROKER_HOST, inferenceBrokerNoProxyEnv, LOOPBACK_BROKER_NO_PROXY_HOSTS, noProxyEnvWithHosts, type ManagedSessionStatus, buildManagedInferenceRelayCredential, startManagedInferenceBroker, isManagedInferenceModelScope, type GatewayCredential, type ManagedCapabilityRefresh, type ManagedCapabilityRefreshResult, type ManagedInferenceBrokerOptions, type ManagedInferenceBrokerSession, type ManagedInferenceBrokerTransport, type ManagedInferenceEndpoint, type ManagedInferenceLoopbackSession, type ManagedInferenceInputTokenAccounting, type ManagedInputEnvelope, type ManagedInferenceModelScope, type ManagedInferenceRequestEnvelope, type ManagedReasoningPolicy, CREDENTIAL_UNAVAILABLE_STATUS, type ManagedInferenceLocalRefusal, type ManagedInferenceUpstreamTransport, } from './managed-inference-broker.js';
54
+ export { INFERENCE_BROKER_ORIGIN, INFERENCE_BROKER_SOCKET_ENV, MANAGED_SESSION_ENV, MANAGED_PROMPT_CACHING_ENV, MANAGED_INPUT_ENVELOPE_ENV, managedInputEnvelopeValue, parseManagedInputEnvelope, MANAGED_STATUS_PATH, INFERENCE_BROKER_HOST, inferenceBrokerNoProxyEnv, LOOPBACK_BROKER_NO_PROXY_HOSTS, noProxyEnvWithHosts, type ManagedSessionStatus, buildManagedInferenceRelayCredential, startManagedInferenceBroker, isManagedInferenceModelScope, supportsOpenAIExplicitPromptCache, type GatewayCredential, type ManagedCapabilityRefresh, type ManagedCapabilityRefreshResult, type ManagedInferenceBrokerOptions, type ManagedInferenceBrokerSession, type ManagedInferenceBrokerTransport, type ManagedInferenceEndpoint, type ManagedInferenceLoopbackSession, type ManagedInferenceInputTokenAccounting, type ManagedInputEnvelope, type ManagedInferenceModelScope, type ManagedInferenceRequestEnvelope, type ManagedReasoningPolicy, CREDENTIAL_UNAVAILABLE_STATUS, type ManagedInferenceLocalRefusal, type ManagedInferenceUpstreamTransport, } from './managed-inference-broker.js';
55
55
  export { minimumCapabilityWindowMs, scheduleRenewalDelay, startRenewalLoop, type CapabilityRefreshOutcome, type RenewalLoop, type RenewalLoopOptions, type RenewalOutcome, type RenewalStopReason, } from './managed-inference-renewal.js';
56
56
  export { ModelProxyLoopbackServer, type ModelProxyForwarder } from './loopback-server.js';
57
57
  export * from './contract.js';
58
+ export { OVERLOAD_SMOKE_PLAN, overloadSmokePrompt, overloadSmokeNativePayload, boundedOverloadSmokeBody, readOverloadSmokeNativeReceipt, boundedOverloadSmokeResponse, overloadSmokeError, countAnthropicSmokeInputUnits } from './overload-smoke.js';
59
+ export { projectManagedHaiku45None } from './managed-haiku-none.js';
@@ -51,10 +51,12 @@
51
51
  * ESM and CJS are both emitted because the daemon is ESM and the CLI is CJS, and
52
52
  * this package exists precisely so both can host the broker.
53
53
  */
54
- export { INFERENCE_BROKER_ORIGIN, INFERENCE_BROKER_SOCKET_ENV, MANAGED_SESSION_ENV, MANAGED_PROMPT_CACHING_ENV, MANAGED_INPUT_ENVELOPE_ENV, managedInputEnvelopeValue, parseManagedInputEnvelope, MANAGED_STATUS_PATH, INFERENCE_BROKER_HOST, inferenceBrokerNoProxyEnv, LOOPBACK_BROKER_NO_PROXY_HOSTS, noProxyEnvWithHosts, buildManagedInferenceRelayCredential, startManagedInferenceBroker, isManagedInferenceModelScope, CREDENTIAL_UNAVAILABLE_STATUS, } from './managed-inference-broker.js';
54
+ export { INFERENCE_BROKER_ORIGIN, INFERENCE_BROKER_SOCKET_ENV, MANAGED_SESSION_ENV, MANAGED_PROMPT_CACHING_ENV, MANAGED_INPUT_ENVELOPE_ENV, managedInputEnvelopeValue, parseManagedInputEnvelope, MANAGED_STATUS_PATH, INFERENCE_BROKER_HOST, inferenceBrokerNoProxyEnv, LOOPBACK_BROKER_NO_PROXY_HOSTS, noProxyEnvWithHosts, buildManagedInferenceRelayCredential, startManagedInferenceBroker, isManagedInferenceModelScope, supportsOpenAIExplicitPromptCache, CREDENTIAL_UNAVAILABLE_STATUS, } from './managed-inference-broker.js';
55
55
  export { minimumCapabilityWindowMs, scheduleRenewalDelay, startRenewalLoop, } from './managed-inference-renewal.js';
56
56
  export { ModelProxyLoopbackServer } from './loopback-server.js';
57
57
  // Re-exported in full because `daemon/src/model-proxy/contract.ts` becomes a
58
58
  // pure re-export of this module: 23 daemon files import that path today, and
59
59
  // keeping it a re-export means none of them change.
60
60
  export * from './contract.js';
61
+ export { OVERLOAD_SMOKE_PLAN, overloadSmokePrompt, overloadSmokeNativePayload, boundedOverloadSmokeBody, readOverloadSmokeNativeReceipt, boundedOverloadSmokeResponse, overloadSmokeError, countAnthropicSmokeInputUnits } from './overload-smoke.js';
62
+ export { projectManagedHaiku45None } from './managed-haiku-none.js';
@@ -0,0 +1,8 @@
1
+ /** Native Haiku4.5 accepts thinking.disabled, not a named output_config effort. Project
2
+ * the already-admitted NONE in that exact dialect; never change the immutable lease.
3
+ * All other models/providers/efforts retain their existing transport behavior. */
4
+ export declare function projectManagedHaiku45None(payload: Record<string, unknown>, options: {
5
+ model: string;
6
+ upstreamProvider: string;
7
+ effort: string;
8
+ }): boolean;
@@ -0,0 +1,20 @@
1
+ /** Native Haiku4.5 accepts thinking.disabled, not a named output_config effort. Project
2
+ * the already-admitted NONE in that exact dialect; never change the immutable lease.
3
+ * All other models/providers/efforts retain their existing transport behavior. */
4
+ export function projectManagedHaiku45None(payload, options) {
5
+ if (options.upstreamProvider !== 'anthropic' || options.effort !== 'none' ||
6
+ !['claude-haiku-4-5', 'anthropic/claude-haiku-4-5'].includes(options.model))
7
+ return false;
8
+ const thinking = payload.thinking;
9
+ if (thinking != null && (!thinking || typeof thinking !== 'object' || Array.isArray(thinking) ||
10
+ Object.keys(thinking).length !== 1 || thinking.type !== 'disabled'))
11
+ throw new Error('managed Haiku NONE conflicts with thinking');
12
+ const output = payload.output_config;
13
+ if (output != null && (!output || typeof output !== 'object' || Array.isArray(output) ||
14
+ Object.keys(output).some(key => key !== 'effort') ||
15
+ (output.effort != null && output.effort !== 'none')))
16
+ throw new Error('managed Haiku NONE conflicts with output config');
17
+ delete payload.output_config;
18
+ payload.thinking = { type: 'disabled' };
19
+ return true;
20
+ }
@@ -1,16 +1,7 @@
1
- /**
2
- * First-party managed-inference broker for skrr Code.
3
- *
4
- * A LiteLLM virtual key is still a bearer capability. Delivering it through
5
- * an ACP child's environment would make it available to the harness, its
6
- * descendants, crash dumps, and the default wrapper's serialized request.
7
- * For the first-party runtime the server retains that key behind an
8
- * authenticated public relay. The daemon exposes a per-session Unix loopback
9
- * endpoint, and the child receives only a random secret usable against that
10
- * endpoint while it is alive.
11
- */
12
1
  import { MODEL_PROXY_ERROR } from './contract.js';
13
2
  import { type CapabilityRefreshOutcome, type RenewalOutcome, type RenewalStopReason } from './managed-inference-renewal.js';
3
+ /** Reviewed OpenAI models that accept explicit-only caching. */
4
+ export declare function supportsOpenAIExplicitPromptCache(modelId: unknown): boolean;
14
5
  type FetchLike = (url: string, init: RequestInit) => Promise<Response>;
15
6
  export interface GatewayCredential {
16
7
  baseUrl?: string;
@@ -1,3 +1,4 @@
1
+ import { projectManagedHaiku45None } from './managed-haiku-none.js';
1
2
  /**
2
3
  * First-party managed-inference broker for skrr Code.
3
4
  *
@@ -19,6 +20,20 @@ const WITH_INFERENCE_BROKER_HOST_RE = /[\s,]+$/;
19
20
  const BUILD_MANAGED_INFERENCE_RELAY_CREDENTIAL_RE = /\/$/;
20
21
  const START_MANAGED_INFERENCE_BROKER_RE = /\/+$/;
21
22
  const SUPPORTS_MANAGED_PROMPT_CACHING_RE = /^openai\//;
23
+ const CURRENT_OPENAI_CACHE_MODELS = new Set([
24
+ 'gpt-6-luna',
25
+ 'gpt-6.1-terra',
26
+ 'gpt-6.2-astra',
27
+ 'gpt-6.2-sol',
28
+ ]);
29
+ /** Reviewed OpenAI models that accept explicit-only caching. */
30
+ export function supportsOpenAIExplicitPromptCache(modelId) {
31
+ if (typeof modelId !== 'string')
32
+ return false;
33
+ const model = modelId.trim().toLowerCase()
34
+ .replace(/^(?:openai\/|(?:(?:bedrock_mantle|bedrock|amazon-bedrock)\/)?openai\.)/, '');
35
+ return /(?:^|[/.])gpt-5\.6(?:-|$)/.test(model) || CURRENT_OPENAI_CACHE_MODELS.has(model);
36
+ }
22
37
  // A synthetic origin is required by URL-oriented provider SDKs. skrr Code pairs
23
38
  // it with OVERSKY_INFERENCE_BROKER_SOCKET and Bun's `fetch({ unix })`; it is
24
39
  // never resolved through DNS or connected over TCP.
@@ -1113,10 +1128,19 @@ function enforceRequestEnvelope(payload, path, envelope, modelScope, promptCache
1113
1128
  };
1114
1129
  }
1115
1130
  else if (path.endsWith('/messages')) {
1116
- if (!['low', 'medium', 'high', 'max'].includes(effectiveEffort)) {
1131
+ let noThinking = false;
1132
+ try {
1133
+ noThinking = projectManagedHaiku45None(payload, { model: modelScope.harnessModelId,
1134
+ upstreamProvider: modelScope.upstreamProvider, effort: effectiveEffort });
1135
+ }
1136
+ catch {
1137
+ rejectManagedRequest('managed Haiku NONE conflicts with thinking or output config');
1138
+ }
1139
+ if (!noThinking && !['low', 'medium', 'high', 'max'].includes(effectiveEffort)) {
1117
1140
  rejectManagedRequest('managed inference broker denied reasoning effort unsupported by the Anthropic dialect');
1118
1141
  }
1119
- payload.output_config = { ...(anthropicOutputConfig ?? {}), effort: effectiveEffort };
1142
+ if (!noThinking)
1143
+ payload.output_config = { ...(anthropicOutputConfig ?? {}), effort: effectiveEffort };
1120
1144
  }
1121
1145
  else if (modelScope.upstreamProvider === 'openrouter') {
1122
1146
  // OpenRouter accepts either reasoning.effort or reasoning.max_tokens,
@@ -1208,7 +1232,7 @@ function managedPromptCacheContract(modelScope) {
1208
1232
  const model = nonEmpty(modelScope.wireModel)
1209
1233
  ?.replace(SUPPORTS_MANAGED_PROMPT_CACHING_RE, '')
1210
1234
  .toLowerCase();
1211
- if (modelScope.upstreamProvider === 'openai' && model?.startsWith('gpt-5.6'))
1235
+ if (modelScope.upstreamProvider === 'openai' && supportsOpenAIExplicitPromptCache(modelScope.wireModel))
1212
1236
  return 'openai';
1213
1237
  if (CLAUDE_PROMPT_CACHE_UPSTREAMS.includes(modelScope.upstreamProvider) &&
1214
1238
  model?.includes('claude')) {
@@ -1248,7 +1272,7 @@ function normalizeClaudeCacheTtl(payload) {
1248
1272
  }
1249
1273
  }
1250
1274
  /**
1251
- * OpenAI GPT-5.6 caching is implicit by default; removing the SDK's routing
1275
+ * OpenAI caching is implicit by default on models with this contract; removing the SDK's routing
1252
1276
  * key does not disable it. A disabled lease is normalized to the provider's
1253
1277
  * explicit/no-breakpoint contract before the request reaches the public relay.
1254
1278
  * The authenticated API repeats this enforcement for direct capability calls.
@@ -0,0 +1,56 @@
1
+ /** Fixed synthetic inference smoke contract. No caller-configurable workload or authority. */
2
+ export declare const OVERLOAD_SMOKE_PLAN: Readonly<{
3
+ version: 1;
4
+ total: 128;
5
+ baseline: 32;
6
+ mixedNative: 32;
7
+ nativeCount: 64;
8
+ batch: 64;
9
+ durationMs: 180000;
10
+ nativeSpacingMs: 2100;
11
+ maxOutputTokens: 16;
12
+ maxInputUnits: 1024;
13
+ maxResponseBytes: 65536;
14
+ nativeOrdinalWaitMs: 10000;
15
+ nativeOrdinalPollMs: 250;
16
+ alias: "claude-haiku-4-5";
17
+ nativeModel: "anthropic/claude-haiku-4-5";
18
+ purpose: "utility.diagnostics.overload";
19
+ feature: "inference-overload-smoke";
20
+ providerExposurePerSendUsd: 0.0023184;
21
+ }>;
22
+ export declare function overloadSmokeError(code: string): Error & {
23
+ code: string;
24
+ };
25
+ /** utf8_bytes_json_v1 input bound, not provider token usage. API parity controls hold this
26
+ * equal to the existing authoritative native accounting strategy for these fixed JSON bodies. */
27
+ export declare function countAnthropicSmokeInputUnits(body: unknown): number;
28
+ export declare function overloadSmokePrompt(index: number): string;
29
+ export declare function overloadSmokeNativePayload(index: number, modelSelector?: string): {
30
+ model: string;
31
+ max_tokens: 16;
32
+ stream: boolean;
33
+ messages: {
34
+ role: string;
35
+ content: string;
36
+ }[];
37
+ };
38
+ export declare function boundedOverloadSmokeBody(body: any, expectedPrompt: string): number;
39
+ type NativeReceiptUpstream = {
40
+ status: number;
41
+ body: {
42
+ getReader(): Pick<ReadableStreamDefaultReader<Uint8Array>, 'read' | 'cancel'>;
43
+ } | null;
44
+ };
45
+ /** Consume the real native Messages stream; retain metadata only, never generated text. */
46
+ export declare function readOverloadSmokeNativeReceipt(upstream: NativeReceiptUpstream, signal: AbortSignal, now: () => number, started: number): Promise<{
47
+ tokens: {
48
+ input: number;
49
+ output: number;
50
+ };
51
+ responseId: never;
52
+ reportedModel: null;
53
+ firstByteMs: number | null;
54
+ }>;
55
+ export declare function boundedOverloadSmokeResponse(response: Response, signal: AbortSignal): Promise<Response>;
56
+ export {};