@skrr-ai/cli 0.1.178 → 0.1.180

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/dist/commands/code/index.js +5 -0
  2. package/dist/commands/diagnostics/inference-smoke.d.ts +13 -0
  3. package/dist/commands/diagnostics/inference-smoke.js +50 -0
  4. package/dist/commands/harnesses/evaluations/evidence.d.ts +22 -0
  5. package/dist/commands/harnesses/evaluations/evidence.js +92 -0
  6. package/dist/commands/harnesses/evaluations/fixed-tool.d.ts +10 -0
  7. package/dist/commands/harnesses/evaluations/fixed-tool.js +189 -0
  8. package/dist/commands/harnesses/evaluations/grant.d.ts +30 -0
  9. package/dist/commands/harnesses/evaluations/grant.js +109 -0
  10. package/dist/commands/harnesses/evaluations/list.d.ts +18 -0
  11. package/dist/commands/harnesses/evaluations/list.js +73 -0
  12. package/dist/commands/harnesses/evaluations/platform-h9-turn.d.ts +13 -0
  13. package/dist/commands/harnesses/evaluations/platform-h9-turn.js +322 -0
  14. package/dist/commands/harnesses/evaluations/revoke.d.ts +19 -0
  15. package/dist/commands/harnesses/evaluations/revoke.js +45 -0
  16. package/dist/commands/harnesses/evaluations/show.d.ts +14 -0
  17. package/dist/commands/harnesses/evaluations/show.js +46 -0
  18. package/dist/commands/harnesses/list.d.ts +1 -0
  19. package/dist/commands/harnesses/list.js +11 -2
  20. package/dist/commands/harnesses/show.js +5 -0
  21. package/dist/commands/machines/hosted/identity-evaluations/issue.d.ts +12 -0
  22. package/dist/commands/machines/hosted/identity-evaluations/issue.js +40 -0
  23. package/dist/commands/machines/hosted/identity-evaluations/revoke.d.ts +11 -0
  24. package/dist/commands/machines/hosted/identity-evaluations/revoke.js +21 -0
  25. package/dist/commands/machines/hosted/identity-evaluations/show.d.ts +8 -0
  26. package/dist/commands/machines/hosted/identity-evaluations/show.js +20 -0
  27. package/dist/commands/machines/hosted/start.d.ts +1 -0
  28. package/dist/commands/machines/hosted/start.js +6 -0
  29. package/dist/lib/agentic-stream.d.ts +3 -0
  30. package/dist/lib/agentic-stream.js +63 -1
  31. package/dist/lib/copilot-fixed-probe-runner.d.ts +72 -0
  32. package/dist/lib/copilot-fixed-probe-runner.js +213 -0
  33. package/dist/lib/copilot-fixed-probe.d.ts +61 -0
  34. package/dist/lib/copilot-fixed-probe.js +223 -0
  35. package/dist/lib/first-party-harness-broker.d.ts +5 -0
  36. package/dist/lib/first-party-harness-broker.js +99 -0
  37. package/dist/lib/h9-platform-stream.d.ts +63 -0
  38. package/dist/lib/h9-platform-stream.js +317 -0
  39. package/dist/lib/h9-prior-stream.d.ts +44 -0
  40. package/dist/lib/h9-prior-stream.js +217 -0
  41. package/dist/lib/harness-evaluations.d.ts +251 -0
  42. package/dist/lib/harness-evaluations.js +66 -0
  43. package/dist/lib/harness-labels.d.ts +10 -0
  44. package/dist/lib/harness-labels.js +23 -0
  45. package/dist/lib/hosted-identity-evaluations.d.ts +26 -0
  46. package/dist/lib/hosted-identity-evaluations.js +18 -0
  47. package/dist/lib/hosted-machines.d.ts +1 -0
  48. package/dist/lib/inference-overload-smoke-contract.d.ts +53 -0
  49. package/dist/lib/inference-overload-smoke-contract.js +192 -0
  50. package/dist/lib/inference-overload-smoke.d.ts +78 -0
  51. package/dist/lib/inference-overload-smoke.js +350 -0
  52. package/dist/lib/operator-probe-files.d.ts +6 -0
  53. package/dist/lib/operator-probe-files.js +68 -0
  54. package/dist/lib/platform-h9-plan.d.ts +47 -0
  55. package/dist/lib/platform-h9-plan.js +78 -0
  56. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/codex-model-catalog.json +150 -0
  57. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/inferenceBrokerHarnesses.d.ts +12 -2
  58. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/inferenceBrokerHarnesses.js +12 -5
  59. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/inferenceBrokerHarnesses.d.ts +12 -2
  60. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/inferenceBrokerHarnesses.js +21 -7
  61. package/dist/node_modules/@skrr-ai/data-provider/index.js +6 -6
  62. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/index.d.ts +3 -1
  63. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/index.js +23 -1
  64. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-haiku-none.d.ts +8 -0
  65. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-haiku-none.js +40 -0
  66. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-inference-broker.d.ts +11 -20
  67. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-inference-broker.js +88 -9
  68. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/overload-smoke.d.ts +56 -0
  69. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/overload-smoke.js +277 -0
  70. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/index.d.ts +3 -1
  71. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/index.js +3 -1
  72. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-haiku-none.d.ts +8 -0
  73. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-haiku-none.js +20 -0
  74. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-inference-broker.d.ts +11 -20
  75. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-inference-broker.js +105 -12
  76. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/overload-smoke.d.ts +56 -0
  77. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/overload-smoke.js +261 -0
  78. package/oclif.manifest.json +1391 -443
  79. package/package.json +5 -2
@@ -29,22 +29,34 @@ __export(index_exports, {
29
29
  MANAGED_SESSION_ENV: () => import_managed_inference_broker.MANAGED_SESSION_ENV,
30
30
  MANAGED_STATUS_PATH: () => import_managed_inference_broker.MANAGED_STATUS_PATH,
31
31
  ModelProxyLoopbackServer: () => import_loopback_server.ModelProxyLoopbackServer,
32
+ OVERLOAD_SMOKE_PLAN: () => import_overload_smoke.OVERLOAD_SMOKE_PLAN,
33
+ boundedOverloadSmokeBody: () => import_overload_smoke.boundedOverloadSmokeBody,
34
+ boundedOverloadSmokeResponse: () => import_overload_smoke.boundedOverloadSmokeResponse,
32
35
  buildManagedInferenceRelayCredential: () => import_managed_inference_broker.buildManagedInferenceRelayCredential,
36
+ countAnthropicSmokeInputUnits: () => import_overload_smoke.countAnthropicSmokeInputUnits,
33
37
  inferenceBrokerNoProxyEnv: () => import_managed_inference_broker.inferenceBrokerNoProxyEnv,
34
38
  isManagedInferenceModelScope: () => import_managed_inference_broker.isManagedInferenceModelScope,
35
39
  managedInputEnvelopeValue: () => import_managed_inference_broker.managedInputEnvelopeValue,
36
40
  minimumCapabilityWindowMs: () => import_managed_inference_renewal.minimumCapabilityWindowMs,
37
41
  noProxyEnvWithHosts: () => import_managed_inference_broker.noProxyEnvWithHosts,
42
+ overloadSmokeError: () => import_overload_smoke.overloadSmokeError,
43
+ overloadSmokeNativePayload: () => import_overload_smoke.overloadSmokeNativePayload,
44
+ overloadSmokePrompt: () => import_overload_smoke.overloadSmokePrompt,
38
45
  parseManagedInputEnvelope: () => import_managed_inference_broker.parseManagedInputEnvelope,
46
+ projectManagedHaiku45None: () => import_managed_haiku_none.projectManagedHaiku45None,
47
+ readOverloadSmokeNativeReceipt: () => import_overload_smoke.readOverloadSmokeNativeReceipt,
39
48
  scheduleRenewalDelay: () => import_managed_inference_renewal.scheduleRenewalDelay,
40
49
  startManagedInferenceBroker: () => import_managed_inference_broker.startManagedInferenceBroker,
41
- startRenewalLoop: () => import_managed_inference_renewal.startRenewalLoop
50
+ startRenewalLoop: () => import_managed_inference_renewal.startRenewalLoop,
51
+ supportsOpenAIExplicitPromptCache: () => import_managed_inference_broker.supportsOpenAIExplicitPromptCache
42
52
  });
43
53
  module.exports = __toCommonJS(index_exports);
44
54
  var import_managed_inference_broker = require("./managed-inference-broker.js");
45
55
  var import_managed_inference_renewal = require("./managed-inference-renewal.js");
46
56
  var import_loopback_server = require("./loopback-server.js");
47
57
  __reExport(index_exports, require("./contract.js"), module.exports);
58
+ var import_overload_smoke = require("./overload-smoke.js");
59
+ var import_managed_haiku_none = require("./managed-haiku-none.js");
48
60
  // Annotate the CommonJS export names for ESM import in node:
49
61
  0 && (module.exports = {
50
62
  CREDENTIAL_UNAVAILABLE_STATUS,
@@ -57,15 +69,25 @@ __reExport(index_exports, require("./contract.js"), module.exports);
57
69
  MANAGED_SESSION_ENV,
58
70
  MANAGED_STATUS_PATH,
59
71
  ModelProxyLoopbackServer,
72
+ OVERLOAD_SMOKE_PLAN,
73
+ boundedOverloadSmokeBody,
74
+ boundedOverloadSmokeResponse,
60
75
  buildManagedInferenceRelayCredential,
76
+ countAnthropicSmokeInputUnits,
61
77
  inferenceBrokerNoProxyEnv,
62
78
  isManagedInferenceModelScope,
63
79
  managedInputEnvelopeValue,
64
80
  minimumCapabilityWindowMs,
65
81
  noProxyEnvWithHosts,
82
+ overloadSmokeError,
83
+ overloadSmokeNativePayload,
84
+ overloadSmokePrompt,
66
85
  parseManagedInputEnvelope,
86
+ projectManagedHaiku45None,
87
+ readOverloadSmokeNativeReceipt,
67
88
  scheduleRenewalDelay,
68
89
  startManagedInferenceBroker,
69
90
  startRenewalLoop,
91
+ supportsOpenAIExplicitPromptCache,
70
92
  ...require("./contract.js")
71
93
  });
@@ -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,40 @@
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 managed_haiku_none_exports = {};
20
+ __export(managed_haiku_none_exports, {
21
+ projectManagedHaiku45None: () => projectManagedHaiku45None
22
+ });
23
+ module.exports = __toCommonJS(managed_haiku_none_exports);
24
+ function projectManagedHaiku45None(payload, options) {
25
+ if (options.upstreamProvider !== "anthropic" || options.effort !== "none" || !["claude-haiku-4-5", "anthropic/claude-haiku-4-5"].includes(options.model))
26
+ return false;
27
+ const thinking = payload.thinking;
28
+ if (thinking != null && (!thinking || typeof thinking !== "object" || Array.isArray(thinking) || Object.keys(thinking).length !== 1 || thinking.type !== "disabled"))
29
+ throw new Error("managed Haiku NONE conflicts with thinking");
30
+ const output = payload.output_config;
31
+ if (output != null && (!output || typeof output !== "object" || Array.isArray(output) || Object.keys(output).some((key) => key !== "effort") || output.effort != null && output.effort !== "none"))
32
+ throw new Error("managed Haiku NONE conflicts with output config");
33
+ delete payload.output_config;
34
+ payload.thinking = { type: "disabled" };
35
+ return true;
36
+ }
37
+ // Annotate the CommonJS export names for ESM import in node:
38
+ 0 && (module.exports = {
39
+ projectManagedHaiku45None
40
+ });
@@ -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;
@@ -171,15 +162,15 @@ export interface ManagedInferenceBrokerOptions {
171
162
  */
172
163
  transport?: ManagedInferenceBrokerTransport;
173
164
  /**
174
- * What a managed lease that does NOT allow prompt caching does with an
175
- * Anthropic-dialect `cache_control` marker. `refuse` (the default) fails the
176
- * request. `strip` removes the markers and forwards the request uncached,
177
- * for a harness that always sends them and cannot be told not to (Claude
178
- * Code, OSK-24457). Stripping can only lower what a request costs: a cache
179
- * write is billed above an ordinary input token, an uncached read is not.
180
- * Every other prompt-cache field is still refused, and a lease that ALLOWS
181
- * caching for a Claude-family model is still refused (there is no policy for
182
- * it yet), whichever value is set.
165
+ * What the broker does with an Anthropic-dialect `cache_control` marker the
166
+ * lease does not admit. `refuse` (the default) fails the request. `strip`
167
+ * forwards it within the lease instead, for a harness that always sends the
168
+ * markers and cannot be told not to (Claude Code, OSK-24457): under a lease
169
+ * that does NOT allow caching every marker is removed; under a Claude lease
170
+ * that does (OSK-24595) a `ttl` other than `5m` is removed (a 1-hour write is
171
+ * 2x input and no reservation prices it), and a request still outside the
172
+ * contract after that is forwarded uncached. Stripping can only lower what a
173
+ * request costs. Every other prompt-cache field is still refused.
183
174
  */
184
175
  promptCacheControl?: 'refuse' | 'strip';
185
176
  }
@@ -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;
@@ -810,25 +835,78 @@ function isPlainObject(value) {
810
835
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
811
836
  }
812
837
  const MAX_OPENAI_CACHE_BREAKPOINTS = 50;
813
- function supportsManagedPromptCaching(modelScope) {
838
+ const CLAUDE_PROMPT_CACHE_TTL = "5m";
839
+ const CLAUDE_MAX_CACHE_BREAKPOINTS = 4;
840
+ const CLAUDE_PROMPT_CACHE_UPSTREAMS = ["anthropic", "bedrock"];
841
+ function managedPromptCacheContract(modelScope) {
814
842
  const model = nonEmpty(modelScope.wireModel)?.replace(SUPPORTS_MANAGED_PROMPT_CACHING_RE, "").toLowerCase();
815
- return modelScope.upstreamProvider === "openai" && Boolean(model?.startsWith("gpt-5.6"));
843
+ if (modelScope.upstreamProvider === "openai" && supportsOpenAIExplicitPromptCache(modelScope.wireModel))
844
+ return "openai";
845
+ if (CLAUDE_PROMPT_CACHE_UPSTREAMS.includes(modelScope.upstreamProvider) && model?.includes("claude")) {
846
+ return "claude";
847
+ }
848
+ return null;
849
+ }
850
+ function supportsManagedPromptCaching(modelScope) {
851
+ return managedPromptCacheContract(modelScope) !== null;
852
+ }
853
+ function claudeCacheControlViolation(payload) {
854
+ const controls = objectKeyValues(payload, "cache_control");
855
+ if (controls.length > CLAUDE_MAX_CACHE_BREAKPOINTS) {
856
+ return `at most ${CLAUDE_MAX_CACHE_BREAKPOINTS} cache_control breakpoints are allowed`;
857
+ }
858
+ for (const control of controls) {
859
+ if (!isPlainObject(control))
860
+ return "cache_control must be an object";
861
+ if (Object.keys(control).some((key) => key !== "type" && key !== "ttl")) {
862
+ return "cache_control accepts only type and ttl";
863
+ }
864
+ if (control.type !== "ephemeral")
865
+ return "cache_control type must be ephemeral";
866
+ if (control.ttl != null && control.ttl !== CLAUDE_PROMPT_CACHE_TTL) {
867
+ return `cache_control ttl must be ${CLAUDE_PROMPT_CACHE_TTL}`;
868
+ }
869
+ }
870
+ return null;
871
+ }
872
+ function normalizeClaudeCacheTtl(payload) {
873
+ for (const control of objectKeyValues(payload, "cache_control")) {
874
+ if (isPlainObject(control) && control.ttl != null && control.ttl !== CLAUDE_PROMPT_CACHE_TTL) {
875
+ delete control.ttl;
876
+ }
877
+ }
816
878
  }
817
879
  function enforcePromptCacheEnvelope(payload, envelope, modelScope, promptCacheControl = "refuse") {
818
880
  const model = nonEmpty(modelScope.wireModel)?.replace(SUPPORTS_MANAGED_PROMPT_CACHING_RE, "").toLowerCase();
819
881
  const claudeCacheControlFamily = ["anthropic", "openrouter", "bedrock"].includes(modelScope.upstreamProvider) && model?.includes("claude");
820
882
  if (claudeCacheControlFamily) {
883
+ const openAICacheFields = containsObjectKey(payload, "prompt_cache_breakpoint") || payload.prompt_cache_key != null || payload.prompt_cache_options != null || payload.prompt_cache_retention != null;
821
884
  if (envelope.allowPromptCaching) {
822
- rejectManagedRequest("managed inference broker has no prompt cache policy for the leased model");
885
+ if (managedPromptCacheContract(modelScope) !== "claude") {
886
+ rejectManagedRequest("managed inference broker has no prompt cache policy for the leased model");
887
+ }
888
+ if (openAICacheFields) {
889
+ rejectManagedRequest("managed inference broker denied a prompt cache field Claude caching does not use");
890
+ }
891
+ if (promptCacheControl === "strip") {
892
+ normalizeClaudeCacheTtl(payload);
893
+ if (claudeCacheControlViolation(payload))
894
+ deleteObjectKey(payload, "cache_control");
895
+ }
896
+ const violation = claudeCacheControlViolation(payload);
897
+ if (violation) {
898
+ rejectManagedRequest(`managed inference broker denied prompt caching: ${violation}`);
899
+ }
900
+ return;
823
901
  }
824
902
  if (promptCacheControl === "strip")
825
903
  deleteObjectKey(payload, "cache_control");
826
- if (containsObjectKey(payload, "cache_control") || containsObjectKey(payload, "prompt_cache_breakpoint") || payload.prompt_cache_key != null || payload.prompt_cache_options != null || payload.prompt_cache_retention != null) {
904
+ if (containsObjectKey(payload, "cache_control") || openAICacheFields) {
827
905
  rejectManagedRequest("managed inference broker denied prompt caching outside the lease envelope");
828
906
  }
829
907
  return;
830
908
  }
831
- if (!supportsManagedPromptCaching(modelScope)) {
909
+ if (managedPromptCacheContract(modelScope) !== "openai") {
832
910
  rejectManagedRequest("managed inference broker has no prompt cache policy for the leased model");
833
911
  }
834
912
  const breakpoints = objectKeyValues(payload, "prompt_cache_breakpoint");
@@ -949,5 +1027,6 @@ async function* responseBody(response, maxBytes, onComplete = () => {
949
1027
  managedInputEnvelopeValue,
950
1028
  noProxyEnvWithHosts,
951
1029
  parseManagedInputEnvelope,
952
- startManagedInferenceBroker
1030
+ startManagedInferenceBroker,
1031
+ supportsOpenAIExplicitPromptCache
953
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';