pi-smart-router 0.21.0 → 1.0.0

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 (192) hide show
  1. package/.pi/extensions/smart-router/command-formatters.ts +9 -11
  2. package/.pi/extensions/smart-router/commands.ts +5 -2
  3. package/.pi/extensions/smart-router/dataset-export.ts +8 -7
  4. package/.pi/extensions/smart-router/delegate-stream.ts +8 -5
  5. package/.pi/extensions/smart-router/delegation-runtime.ts +8 -11
  6. package/.pi/extensions/smart-router/extension-setup.ts +9 -4
  7. package/.pi/extensions/smart-router/fleet-bootstrap.ts +19 -21
  8. package/.pi/extensions/smart-router/index.ts +5 -4
  9. package/.pi/extensions/smart-router/planning-delegate.ts +9 -8
  10. package/.pi/extensions/smart-router/pricing-lifecycle.ts +9 -4
  11. package/.pi/extensions/smart-router/route-and-delegate.ts +13 -12
  12. package/.pi/extensions/smart-router/routing-context.ts +4 -2
  13. package/.pi/extensions/smart-router/routing-outcomes.ts +6 -2
  14. package/.pi/extensions/smart-router/session-lifecycle.ts +5 -2
  15. package/.pi/extensions/smart-router/stream-delegation.ts +8 -2
  16. package/.pi/extensions/smart-router/types.ts +13 -16
  17. package/.pi/extensions/smart-router/utils.ts +5 -3
  18. package/README.md +63 -19
  19. package/config/benchmark-profiles.json +2 -2
  20. package/config/onnx-artifact-pins.json +18 -0
  21. package/config/operator-config.json.example +1 -0
  22. package/config/p-success-weights.json +12 -18
  23. package/config/routing-calibration.json +2806 -0
  24. package/dist/domain/matching/embedding-provider.d.ts +40 -3
  25. package/dist/domain/matching/embedding-provider.d.ts.map +1 -1
  26. package/dist/domain/matching/embedding-provider.js +159 -9
  27. package/dist/domain/matching/embedding-provider.js.map +1 -1
  28. package/dist/domain/pinning/session-pinner.js +1 -1
  29. package/dist/domain/pinning/session-pinner.js.map +1 -1
  30. package/dist/domain/pipeline/context-fit-stage.d.ts +14 -0
  31. package/dist/domain/pipeline/context-fit-stage.d.ts.map +1 -0
  32. package/dist/domain/pipeline/context-fit-stage.js +25 -0
  33. package/dist/domain/pipeline/context-fit-stage.js.map +1 -0
  34. package/dist/domain/pipeline/context-overflow-fallback-stage.d.ts +28 -0
  35. package/dist/domain/pipeline/context-overflow-fallback-stage.d.ts.map +1 -0
  36. package/dist/domain/pipeline/context-overflow-fallback-stage.js +77 -0
  37. package/dist/domain/pipeline/context-overflow-fallback-stage.js.map +1 -0
  38. package/dist/domain/pipeline/hardware-probe-stage.d.ts +12 -0
  39. package/dist/domain/pipeline/hardware-probe-stage.d.ts.map +1 -0
  40. package/dist/domain/pipeline/hardware-probe-stage.js +27 -0
  41. package/dist/domain/pipeline/hardware-probe-stage.js.map +1 -0
  42. package/dist/domain/pipeline/hydra-match-stage.d.ts +19 -0
  43. package/dist/domain/pipeline/hydra-match-stage.d.ts.map +1 -0
  44. package/dist/domain/pipeline/hydra-match-stage.js +178 -0
  45. package/dist/domain/pipeline/hydra-match-stage.js.map +1 -0
  46. package/dist/domain/pipeline/local-zero-stage.d.ts +23 -0
  47. package/dist/domain/pipeline/local-zero-stage.d.ts.map +1 -0
  48. package/dist/domain/pipeline/local-zero-stage.js +167 -0
  49. package/dist/domain/pipeline/local-zero-stage.js.map +1 -0
  50. package/dist/domain/pipeline/low-intensity-stage.d.ts +20 -0
  51. package/dist/domain/pipeline/low-intensity-stage.d.ts.map +1 -0
  52. package/dist/domain/pipeline/low-intensity-stage.js +221 -0
  53. package/dist/domain/pipeline/low-intensity-stage.js.map +1 -0
  54. package/dist/domain/pipeline/pipeline-stage.d.ts +116 -0
  55. package/dist/domain/pipeline/pipeline-stage.d.ts.map +1 -0
  56. package/dist/domain/pipeline/pipeline-stage.js +49 -0
  57. package/dist/domain/pipeline/pipeline-stage.js.map +1 -0
  58. package/dist/domain/pipeline/router-pipeline.d.ts +77 -185
  59. package/dist/domain/pipeline/router-pipeline.d.ts.map +1 -1
  60. package/dist/domain/pipeline/router-pipeline.js +160 -1232
  61. package/dist/domain/pipeline/router-pipeline.js.map +1 -1
  62. package/dist/domain/pipeline/safe-default-stage.d.ts +26 -0
  63. package/dist/domain/pipeline/safe-default-stage.d.ts.map +1 -0
  64. package/dist/domain/pipeline/safe-default-stage.js +75 -0
  65. package/dist/domain/pipeline/safe-default-stage.js.map +1 -0
  66. package/dist/domain/pipeline/session-pin-stage.d.ts +26 -0
  67. package/dist/domain/pipeline/session-pin-stage.d.ts.map +1 -0
  68. package/dist/domain/pipeline/session-pin-stage.js +195 -0
  69. package/dist/domain/pipeline/session-pin-stage.js.map +1 -0
  70. package/dist/domain/pipeline/stage-helpers.d.ts +58 -0
  71. package/dist/domain/pipeline/stage-helpers.d.ts.map +1 -0
  72. package/dist/domain/pipeline/stage-helpers.js +156 -0
  73. package/dist/domain/pipeline/stage-helpers.js.map +1 -0
  74. package/dist/domain/pipeline/triage-stage.d.ts +22 -0
  75. package/dist/domain/pipeline/triage-stage.d.ts.map +1 -0
  76. package/dist/domain/pipeline/triage-stage.js +83 -0
  77. package/dist/domain/pipeline/triage-stage.js.map +1 -0
  78. package/dist/domain/pipeline/turn-envelope-stage.d.ts +15 -0
  79. package/dist/domain/pipeline/turn-envelope-stage.d.ts.map +1 -0
  80. package/dist/domain/pipeline/turn-envelope-stage.js +201 -0
  81. package/dist/domain/pipeline/turn-envelope-stage.js.map +1 -0
  82. package/dist/domain/ports/hardware-probe-port.d.ts +100 -0
  83. package/dist/domain/ports/hardware-probe-port.d.ts.map +1 -0
  84. package/dist/domain/ports/hardware-probe-port.js +56 -0
  85. package/dist/domain/ports/hardware-probe-port.js.map +1 -0
  86. package/dist/domain/ports/local-runtime-port.d.ts +75 -0
  87. package/dist/domain/ports/local-runtime-port.d.ts.map +1 -0
  88. package/dist/domain/ports/local-runtime-port.js +115 -0
  89. package/dist/domain/ports/local-runtime-port.js.map +1 -0
  90. package/dist/domain/ports/telemetry-emitter-port.d.ts +121 -0
  91. package/dist/domain/ports/telemetry-emitter-port.d.ts.map +1 -0
  92. package/dist/domain/ports/telemetry-emitter-port.js +375 -0
  93. package/dist/domain/ports/telemetry-emitter-port.js.map +1 -0
  94. package/dist/domain/pricing/price-resolution.d.ts +38 -0
  95. package/dist/domain/pricing/price-resolution.d.ts.map +1 -0
  96. package/dist/domain/pricing/price-resolution.js +62 -0
  97. package/dist/domain/pricing/price-resolution.js.map +1 -0
  98. package/dist/domain/routing/expected-cost.js +1 -1
  99. package/dist/domain/routing/expected-cost.js.map +1 -1
  100. package/dist/domain/routing/p-success-classifier.d.ts +2 -2
  101. package/dist/domain/routing/p-success-classifier.d.ts.map +1 -1
  102. package/dist/domain/routing/p-success-classifier.js +20 -16
  103. package/dist/domain/routing/p-success-classifier.js.map +1 -1
  104. package/dist/index.d.ts +57 -6
  105. package/dist/index.d.ts.map +1 -1
  106. package/dist/index.js +57 -6
  107. package/dist/index.js.map +1 -1
  108. package/dist/infrastructure/gateway/gateway-dispatch.d.ts.map +1 -1
  109. package/dist/infrastructure/gateway/gateway-dispatch.js +12 -1
  110. package/dist/infrastructure/gateway/gateway-dispatch.js.map +1 -1
  111. package/dist/infrastructure/hardware/hardware-probe.d.ts +8 -21
  112. package/dist/infrastructure/hardware/hardware-probe.d.ts.map +1 -1
  113. package/dist/infrastructure/hardware/hardware-probe.js +7 -33
  114. package/dist/infrastructure/hardware/hardware-probe.js.map +1 -1
  115. package/dist/infrastructure/hardware/throughput-meter.d.ts +7 -47
  116. package/dist/infrastructure/hardware/throughput-meter.d.ts.map +1 -1
  117. package/dist/infrastructure/hardware/throughput-meter.js +5 -0
  118. package/dist/infrastructure/hardware/throughput-meter.js.map +1 -1
  119. package/dist/infrastructure/local/local-zero-tier.d.ts +14 -36
  120. package/dist/infrastructure/local/local-zero-tier.d.ts.map +1 -1
  121. package/dist/infrastructure/local/local-zero-tier.js +16 -79
  122. package/dist/infrastructure/local/local-zero-tier.js.map +1 -1
  123. package/dist/infrastructure/persistence/memory-store.d.ts.map +1 -1
  124. package/dist/infrastructure/persistence/memory-store.js +9 -3
  125. package/dist/infrastructure/persistence/memory-store.js.map +1 -1
  126. package/dist/infrastructure/persistence/sqlite-store.d.ts.map +1 -1
  127. package/dist/infrastructure/persistence/sqlite-store.js +12 -2
  128. package/dist/infrastructure/persistence/sqlite-store.js.map +1 -1
  129. package/dist/infrastructure/pricing/price-broker.d.ts +8 -27
  130. package/dist/infrastructure/pricing/price-broker.d.ts.map +1 -1
  131. package/dist/infrastructure/pricing/price-broker.js +7 -51
  132. package/dist/infrastructure/pricing/price-broker.js.map +1 -1
  133. package/dist/infrastructure/telemetry/pin-economics-telemetry.d.ts +62 -0
  134. package/dist/infrastructure/telemetry/pin-economics-telemetry.d.ts.map +1 -0
  135. package/dist/infrastructure/telemetry/pin-economics-telemetry.js +214 -0
  136. package/dist/infrastructure/telemetry/pin-economics-telemetry.js.map +1 -0
  137. package/dist/infrastructure/telemetry/planning-delegate-telemetry.d.ts +21 -0
  138. package/dist/infrastructure/telemetry/planning-delegate-telemetry.d.ts.map +1 -0
  139. package/dist/infrastructure/telemetry/planning-delegate-telemetry.js +67 -0
  140. package/dist/infrastructure/telemetry/planning-delegate-telemetry.js.map +1 -0
  141. package/dist/infrastructure/telemetry/routing-decision-log.d.ts +50 -0
  142. package/dist/infrastructure/telemetry/routing-decision-log.d.ts.map +1 -0
  143. package/dist/infrastructure/telemetry/routing-decision-log.js +163 -0
  144. package/dist/infrastructure/telemetry/routing-decision-log.js.map +1 -0
  145. package/dist/infrastructure/telemetry/routing-telemetry.d.ts +28 -211
  146. package/dist/infrastructure/telemetry/routing-telemetry.d.ts.map +1 -1
  147. package/dist/infrastructure/telemetry/routing-telemetry.js +32 -936
  148. package/dist/infrastructure/telemetry/routing-telemetry.js.map +1 -1
  149. package/dist/infrastructure/telemetry/telemetry-scalar-fields.d.ts +83 -0
  150. package/dist/infrastructure/telemetry/telemetry-scalar-fields.d.ts.map +1 -0
  151. package/dist/infrastructure/telemetry/telemetry-scalar-fields.js +184 -0
  152. package/dist/infrastructure/telemetry/telemetry-scalar-fields.js.map +1 -0
  153. package/package.json +11 -9
  154. package/skills/router-release-operator/SKILL.md +21 -9
  155. package/skills/router-release-operator/references/dependency-freshness.md +67 -0
  156. package/skills/router-release-operator/references/issue-intake-checklist.md +14 -0
  157. package/skills/router-release-operator/references/release-manifest-template.md +16 -0
  158. package/skills/router-release-operator/references/release-profiles.md +11 -5
  159. package/src/domain/matching/embedding-provider.ts +241 -7
  160. package/src/domain/pinning/session-pinner.ts +1 -1
  161. package/src/domain/pipeline/context-fit-stage.ts +32 -0
  162. package/src/domain/pipeline/context-overflow-fallback-stage.ts +112 -0
  163. package/src/domain/pipeline/hardware-probe-stage.ts +31 -0
  164. package/src/domain/pipeline/hydra-match-stage.ts +242 -0
  165. package/src/domain/pipeline/local-zero-stage.ts +228 -0
  166. package/src/domain/pipeline/low-intensity-stage.ts +312 -0
  167. package/src/domain/pipeline/pipeline-stage.ts +182 -0
  168. package/src/domain/pipeline/router-pipeline.ts +227 -1613
  169. package/src/domain/pipeline/safe-default-stage.ts +87 -0
  170. package/src/domain/pipeline/session-pin-stage.ts +259 -0
  171. package/src/domain/pipeline/stage-helpers.ts +230 -0
  172. package/src/domain/pipeline/triage-stage.ts +98 -0
  173. package/src/domain/pipeline/turn-envelope-stage.ts +300 -0
  174. package/src/domain/ports/hardware-probe-port.ts +158 -0
  175. package/src/domain/ports/local-runtime-port.ts +198 -0
  176. package/src/domain/ports/telemetry-emitter-port.ts +622 -0
  177. package/src/domain/pricing/price-resolution.ts +84 -0
  178. package/src/domain/routing/expected-cost.ts +1 -1
  179. package/src/domain/routing/p-success-classifier.ts +22 -18
  180. package/src/index.ts +188 -6
  181. package/src/infrastructure/gateway/gateway-dispatch.ts +12 -1
  182. package/src/infrastructure/hardware/hardware-probe.ts +26 -68
  183. package/src/infrastructure/hardware/throughput-meter.ts +19 -50
  184. package/src/infrastructure/local/local-zero-tier.ts +38 -136
  185. package/src/infrastructure/persistence/memory-store.ts +10 -2
  186. package/src/infrastructure/persistence/sqlite-store.ts +13 -2
  187. package/src/infrastructure/pricing/price-broker.ts +15 -72
  188. package/src/infrastructure/telemetry/pin-economics-telemetry.ts +353 -0
  189. package/src/infrastructure/telemetry/planning-delegate-telemetry.ts +101 -0
  190. package/src/infrastructure/telemetry/routing-decision-log.ts +262 -0
  191. package/src/infrastructure/telemetry/routing-telemetry.ts +134 -1443
  192. package/src/infrastructure/telemetry/telemetry-scalar-fields.ts +278 -0
@@ -1,23 +1,21 @@
1
1
  import {
2
2
  DEFAULT_HISTORY_LIMIT,
3
3
  MAX_HISTORY_LIMIT,
4
- } from '../../../src/infrastructure/telemetry/telemetry-limits.js';
4
+ aggregateSessionStatsFromFleet,
5
+ DEFAULT_TELEMETRY_CONTRIB_EXPORT_LIMIT,
6
+ parseExportTelemetryContribArgs,
7
+ } from '../../../src/index.js';
5
8
  import type {
6
9
  ModelProfile,
7
10
  PriceCatalog,
8
11
  RoutingDecision,
9
12
  RoutingTelemetry,
10
- } from '../../../src/domain/types/index.js';
11
- import {
12
- aggregateSessionStatsFromFleet,
13
- type SessionStatsSnapshot,
14
- } from '../../../src/infrastructure/telemetry/session-stats.js';
13
+ SessionStatsSnapshot,
14
+ PlacementPlanReport,
15
+ } from '../../../src/index.js';
16
+
15
17
  import { SMART_ROUTER_USAGE } from './commands.js';
16
- import {
17
- DEFAULT_TELEMETRY_CONTRIB_EXPORT_LIMIT,
18
- parseExportTelemetryContribArgs,
19
- } from '../../../src/cli/smart-router-cli.js';
20
- import type { PlacementPlanReport } from '../../../src/infrastructure/hardware/placement-plan.js';
18
+
21
19
  import {
22
20
  DEFAULT_DATASET_EXPORT_LIMIT,
23
21
  MAX_DATASET_EXPORT_LIMIT,
@@ -10,8 +10,11 @@ import {
10
10
  parseSmartRouterArgs,
11
11
  } from './command-formatters.js';
12
12
  import { exportDatasetToFile } from './dataset-export.js';
13
- import { exportTelemetryContrib } from '../../../src/cli/smart-router-cli.js';
14
- import { collectPlacementPlan } from '../../../src/infrastructure/hardware/placement-plan.js';
13
+ import {
14
+ exportTelemetryContrib,
15
+ collectPlacementPlan,
16
+ } from '../../../src/index.js';
17
+
15
18
  import { bindSharedModelRegistry, rebuildFleet } from './fleet-bootstrap.js';
16
19
  import { refreshPricingCatalog } from './pricing-lifecycle.js';
17
20
  import { FLEET_MODE_ENTRY_TYPE } from './session-lifecycle.js';
@@ -6,15 +6,16 @@ import { createHash } from 'node:crypto';
6
6
  import {
7
7
  attachOutcomeLabelsToExport,
8
8
  indexOutcomesByRequestId,
9
- } from '../../../src/domain/routing/p-success-classifier.js';
10
- import { DATASET_MAX_ENTRIES } from '../../../src/infrastructure/telemetry/dataset-limits.js';
11
- import {
9
+ DATASET_MAX_ENTRIES,
12
10
  DatasetRecorder,
13
11
  DATASET_ENABLED_NOTIFY_MESSAGE,
14
- } from '../../../src/infrastructure/telemetry/dataset-recorder.js';
15
- import { OutcomeRecorder } from '../../../src/infrastructure/telemetry/outcome-recorder.js';
16
- import type { RoutingDatasetRecord, RoutingOutcomeRecord } from '../../../src/domain/types/index.js';
17
- import type { StorePort } from '../../../src/domain/types/store-port.js';
12
+ OutcomeRecorder,
13
+ } from '../../../src/index.js';
14
+ import type {
15
+ RoutingDatasetRecord,
16
+ RoutingOutcomeRecord,
17
+ StorePort,
18
+ } from '../../../src/index.js';
18
19
 
19
20
  const DEFAULT_DATASET_EXPORT_DIR = '.pi-smart-router/exports';
20
21
  const DEFAULT_DATASET_EXPORT_LIMIT = DATASET_MAX_ENTRIES;
@@ -9,13 +9,16 @@ import {
9
9
  streamSimple as compatDelegateStream,
10
10
  } from '@earendil-works/pi-ai/compat';
11
11
 
12
- import { parseAssistantMessageError } from '../../../src/infrastructure/delegation/provider-error.js';
13
- import { extractUsageActuals } from '../../../src/infrastructure/telemetry/routing-telemetry.js';
14
12
  import {
13
+ parseAssistantMessageError,
14
+ extractUsageActuals,
15
15
  resolveAdaptiveReasoning,
16
- type AdaptiveReasoningResult,
17
- type AdaptiveReasoningSignal,
18
- } from '../../../src/domain/delegation/adaptive-reasoning.js';
16
+ } from '../../../src/index.js';
17
+ import type {
18
+ AdaptiveReasoningResult,
19
+ AdaptiveReasoningSignal,
20
+ } from '../../../src/index.js';
21
+
19
22
  import {
20
23
  buildDelegationContext,
21
24
  forwardDelegatedEvent,
@@ -15,26 +15,23 @@ import type { ModelRegistry } from '@earendil-works/pi-coding-agent';
15
15
 
16
16
  import {
17
17
  applyConcisenessHint,
18
- type AdaptiveReasoningResult,
19
- } from '../../../src/domain/delegation/adaptive-reasoning.js';
20
- import {
21
18
  isGoogleDelegationTarget,
22
19
  normalizeDelegationContext,
23
20
  repairGeminiReplayContext,
24
- } from '../../../src/domain/delegation/delegation-context.js';
25
- import {
26
21
  computeOutputHeadroom,
27
- type OutputHeadroomConfig,
28
- } from '../../../src/domain/delegation/output-headroom.js';
29
- import type { ModelProfile } from '../../../src/domain/types/index.js';
30
- import {
31
22
  formatGeminiThoughtSignatureErrorMessage,
32
23
  formatProviderErrorMessage,
33
24
  isGeminiThoughtSignatureAssistantError,
34
25
  parseAssistantMessageError,
35
26
  sanitizeLengthStopMessage,
36
- type LengthStopHints,
37
- } from '../../../src/infrastructure/delegation/provider-error.js';
27
+ } from '../../../src/index.js';
28
+ import type {
29
+ AdaptiveReasoningResult,
30
+ OutputHeadroomConfig,
31
+ ModelProfile,
32
+ LengthStopHints,
33
+ } from '../../../src/index.js';
34
+
38
35
  import type { StreamDelegationDeps } from './types.js';
39
36
 
40
37
  /** Stream options safe to forward to a delegated provider call. */
@@ -4,10 +4,15 @@ import {
4
4
  type ExtensionAPI,
5
5
  } from '@earendil-works/pi-coding-agent';
6
6
 
7
- import { resolveOperatorConfigFromEnv } from '../../../src/config/defaults.js';
8
- import { ExecutionLedger } from '../../../src/domain/delegation/execution-ledger.js';
9
- import type { SessionRoutingSnapshot } from '../../../src/infrastructure/telemetry/outcome-recorder.js';
10
- import { createRouterFromFleet, LifecycleHookState } from '../../../src/index.js';
7
+ import {
8
+ resolveOperatorConfigFromEnv,
9
+ ExecutionLedger,
10
+ createRouterFromFleet,
11
+ LifecycleHookState,
12
+ } from '../../../src/index.js';
13
+ import type {
14
+ SessionRoutingSnapshot,
15
+ } from '../../../src/index.js';
11
16
 
12
17
  import { registerSmartRouterCommand } from './commands.js';
13
18
  import {
@@ -2,39 +2,37 @@ import type { Api, Model } from '@earendil-works/pi-ai/compat';
2
2
  import {
3
3
  ModelRegistry,
4
4
  SettingsManager,
5
- type ExtensionAPI,
5
+ ExtensionAPI,
6
6
  } from '@earendil-works/pi-coding-agent';
7
7
 
8
- import { mapFleetFromRegistry } from '../../../src/config/pi-model-mapper.js';
9
8
  import {
9
+ mapFleetFromRegistry,
10
10
  DEFAULT_OPERATOR_CONFIG,
11
11
  resolveOperatorConfigFromEnv,
12
- } from '../../../src/config/defaults.js';
13
- import {
14
12
  HydraMatcher,
15
13
  createOnnxEmbeddingProvider,
16
- } from '../../../src/domain/matching/hydra-matcher.js';
17
- import { SessionPinner } from '../../../src/domain/pinning/session-pinner.js';
18
- import {
14
+ SessionPinner,
19
15
  collectPoolModelIds,
20
16
  resolveQuotaWindowEstimateConfigFromEnv,
21
17
  resolveQuotaWindowPosition,
22
- type QuotaWindowAdapter,
23
- type QuotaWindowEstimateConfig,
24
- } from '../../../src/domain/pricing/quota-window-feed.js';
25
- import type { ModelProfile, PriceCatalog } from '../../../src/domain/types/index.js';
26
- import type { QuotaWindowPosition } from '../../../src/domain/types/entities.js';
27
- import type { OperatorConfig } from '../../../src/domain/types/schemas.js';
28
- import type { StorePort } from '../../../src/domain/types/store-port.js';
29
- import { getDefaultSystemInfo } from '../../../src/infrastructure/hardware/hardware-probe.js';
30
- import { DEFAULT_LOCAL_CONFIG } from '../../../src/infrastructure/local/local-zero-tier.js';
31
- import { RoutingTelemetryEmitter } from '../../../src/infrastructure/telemetry/routing-telemetry.js';
32
- import { applyCatalogPricesToFleet } from '../../../src/infrastructure/pricing/price-broker.js';
33
- import {
18
+ getDefaultSystemInfo,
19
+ DEFAULT_LOCAL_CONFIG,
20
+ RoutingTelemetryEmitter,
21
+ applyCatalogPricesToFleet,
34
22
  createRouterFromFleet,
35
- type GatewayDispatchOptions,
36
- type PiExtensionHooks,
37
23
  } from '../../../src/index.js';
24
+ import type {
25
+ QuotaWindowAdapter,
26
+ QuotaWindowEstimateConfig,
27
+ ModelProfile,
28
+ PriceCatalog,
29
+ QuotaWindowPosition,
30
+ OperatorConfig,
31
+ StorePort,
32
+ GatewayDispatchOptions,
33
+ PiExtensionHooks,
34
+ } from '../../../src/index.js';
35
+
38
36
  import { resolveModelScope } from './pi-model-scope.js';
39
37
  import type { FleetMode, SmartRouterRuntime } from './types.js';
40
38
  import { resolveRateLimiter } from './utils.js';
@@ -6,8 +6,9 @@
6
6
  * hooks for routing state. Stream delegation routes each request through the
7
7
  * pipeline and forwards to the selected provider's built-in streaming API.
8
8
  *
9
- * Imports from ../../../src/** (not dist/) because the extension is loaded by pi
10
- * from source at dev time and is excluded from the npm dist artifact.
9
+ * Imports the package public facade (../../../src/index.js, not dist/) because
10
+ * the extension is loaded by pi from source at dev time and is excluded from
11
+ * the npm dist artifact. Deep src/** subpath imports are forbidden (SP-256/257).
11
12
  */
12
13
 
13
14
  import type { ExtensionAPI } from '@earendil-works/pi-coding-agent';
@@ -116,14 +117,14 @@ export { routeAndDelegate } from './route-and-delegate.js';
116
117
  export {
117
118
  formatGeminiThoughtSignatureErrorMessage,
118
119
  isGeminiThoughtSignatureAssistantError,
119
- } from '../../../src/infrastructure/delegation/provider-error.js';
120
+ } from '../../../src/index.js';
120
121
  export {
121
122
  GEMINI_TOOL_HISTORY_EXCLUDED,
122
123
  hasToolCallHistory,
123
124
  hasToolCallHistoryFromContext,
124
125
  isGoogleGeminiProfile,
125
126
  resolveEffectiveFleet,
126
- } from '../../../src/domain/routing/tool-history-guard.js';
127
+ } from '../../../src/index.js';
127
128
 
128
129
  export default async function smartRouterExtension(pi: ExtensionAPI): Promise<void> {
129
130
  const cwd = process.cwd();
@@ -22,21 +22,22 @@ import {
22
22
  type TextContent,
23
23
  } from '@earendil-works/pi-ai/compat';
24
24
 
25
- import type {
26
- CompressedContextSpec,
27
- PlanningDelegateObservability,
28
- RoutingDecision,
29
- } from '../../../src/domain/types/index.js';
30
- import { resolveAdaptiveReasoning } from '../../../src/domain/delegation/adaptive-reasoning.js';
31
- import { DEFAULT_PLANNING_DELEGATE_CONFIG } from '../../../src/domain/types/schemas.js';
32
25
  import {
26
+ resolveAdaptiveReasoning,
27
+ DEFAULT_PLANNING_DELEGATE_CONFIG,
33
28
  createPlanningDelegateObservability,
34
29
  enrichRoutingDecisionWithPlanningDelegate,
35
30
  PLANNING_DELEGATE,
36
31
  PLANNING_DELEGATE_TIMEOUT,
37
32
  PLANNING_DELEGATE_UNAVAILABLE,
38
33
  PLANNING_DIRECT_FRONTIER,
39
- } from '../../../src/infrastructure/telemetry/routing-telemetry.js';
34
+ } from '../../../src/index.js';
35
+ import type {
36
+ CompressedContextSpec,
37
+ PlanningDelegateObservability,
38
+ RoutingDecision,
39
+ } from '../../../src/index.js';
40
+
40
41
  import { collectDelegatedStream } from './delegate-stream.js';
41
42
  import { findFleetProfile, resolveRegistryModel } from './delegation-runtime.js';
42
43
  import type { StreamDelegationDeps } from './types.js';
@@ -1,7 +1,12 @@
1
- import { DEFAULT_OPERATOR_CONFIG } from '../../../src/config/defaults.js';
2
- import type { PriceCatalog } from '../../../src/domain/types/index.js';
3
- import { fetchLitellmPriceCatalog } from '../../../src/infrastructure/pricing/litellm-fetch.js';
4
- import { checkStaleness } from '../../../src/infrastructure/pricing/pricing-monitor.js';
1
+ import {
2
+ DEFAULT_OPERATOR_CONFIG,
3
+ fetchLitellmPriceCatalog,
4
+ checkStaleness,
5
+ } from '../../../src/index.js';
6
+ import type {
7
+ PriceCatalog,
8
+ } from '../../../src/index.js';
9
+
5
10
  import type { SmartRouterRuntime } from './types.js';
6
11
 
7
12
  export async function refreshPricingCatalog(
@@ -7,27 +7,28 @@ import type {
7
7
  SimpleStreamOptions,
8
8
  } from '@earendil-works/pi-ai/compat';
9
9
 
10
- import { safeCloudDefault } from '../../../src/domain/pipeline/safe-default.js';
11
- import { computeOutputHeadroom } from '../../../src/domain/delegation/output-headroom.js';
12
- import { resolvePeakPricingAdjustment } from '../../../src/domain/pricing/peak-pricing.js';
13
10
  import {
11
+ safeCloudDefault,
12
+ computeOutputHeadroom,
13
+ resolvePeakPricingAdjustment,
14
14
  CONTEXT_OVERFLOW_NO_FIT,
15
15
  resolveContextOverflowFallback,
16
- } from '../../../src/domain/routing/context-fit.js';
17
- import {
18
16
  assertRoutableFleetAfterGeminiToolHistoryGuard,
19
17
  GEMINI_TOOL_HISTORY_EXCLUDED,
20
18
  isGoogleGeminiProfile,
21
19
  resolveEffectiveFleet,
22
- } from '../../../src/domain/routing/tool-history-guard.js';
23
- import type { ModelProfile, RoutingDecision, RoutingRequest } from '../../../src/domain/types/index.js';
24
- import type { GeminiToolHistoryGuardResult } from '../../../src/domain/routing/tool-history-guard.js';
25
- import {
26
20
  isGeminiThoughtSignatureAssistantError,
27
21
  parseAssistantMessageError,
28
- } from '../../../src/infrastructure/delegation/provider-error.js';
29
- import { GEMINI_REPLAY_INCOMPATIBLE } from '../../../src/infra/gemini-provider.js';
30
- import { shouldFailoverOnProviderError } from '../../../src/infrastructure/gateway/gateway-dispatch.js';
22
+ GEMINI_REPLAY_INCOMPATIBLE,
23
+ shouldFailoverOnProviderError,
24
+ } from '../../../src/index.js';
25
+ import type {
26
+ ModelProfile,
27
+ RoutingDecision,
28
+ RoutingRequest,
29
+ GeminiToolHistoryGuardResult,
30
+ } from '../../../src/index.js';
31
+
31
32
  import {
32
33
  commitPipedTerminal,
33
34
  delegateWithOutcome,
@@ -7,12 +7,14 @@ import {
7
7
  type TextContent,
8
8
  } from '@earendil-works/pi-ai/compat';
9
9
 
10
+ import {
11
+ LifecycleHookState,
12
+ } from '../../../src/index.js';
10
13
  import type {
11
14
  Message as RoutingMessage,
12
15
  RoutingRequest,
13
16
  TurnType,
14
- } from '../../../src/domain/types/index.js';
15
- import { LifecycleHookState } from '../../../src/index.js';
17
+ } from '../../../src/index.js';
16
18
 
17
19
  const TOKEN_ESTIMATE_KEYS = [
18
20
  'estimatedInputTokens',
@@ -1,5 +1,9 @@
1
- import type { RoutingDecision, RoutingRequest } from '../../../src/domain/types/index.js';
2
- import type { SessionRoutingSnapshot } from '../../../src/infrastructure/telemetry/outcome-recorder.js';
1
+ import type {
2
+ RoutingDecision,
3
+ RoutingRequest,
4
+ SessionRoutingSnapshot,
5
+ } from '../../../src/index.js';
6
+
3
7
  import type { StreamDelegationDeps } from './types.js';
4
8
 
5
9
  export function capturePreRouteOutcomes(
@@ -1,7 +1,10 @@
1
1
  import type { ExtensionAPI, ExtensionContext } from '@earendil-works/pi-coding-agent';
2
2
 
3
- import { evictInMemorySessionState } from '../../../src/api/session-eviction.js';
4
- import { SessionPinner } from '../../../src/domain/pinning/session-pinner.js';
3
+ import {
4
+ evictInMemorySessionState,
5
+ SessionPinner,
6
+ } from '../../../src/index.js';
7
+
5
8
  import {
6
9
  bindSharedModelRegistry,
7
10
  ensureFleetFresh,
@@ -7,8 +7,14 @@ import {
7
7
  createAssistantMessageEventStream,
8
8
  } from '@earendil-works/pi-ai/compat';
9
9
 
10
- import type { RoutingDecision, RoutingFeatureSidecar } from '../../../src/domain/types/index.js';
11
- import { resolvePeakPricingAdjustment } from '../../../src/domain/pricing/peak-pricing.js';
10
+ import {
11
+ resolvePeakPricingAdjustment,
12
+ } from '../../../src/index.js';
13
+ import type {
14
+ RoutingDecision,
15
+ RoutingFeatureSidecar,
16
+ } from '../../../src/index.js';
17
+
12
18
  import { createErrorMessage } from './delegation-runtime.js';
13
19
  import { routeAndDelegate } from './route-and-delegate.js';
14
20
  import type { StreamDelegationDeps } from './types.js';
@@ -7,10 +7,15 @@ import type {
7
7
  } from '@earendil-works/pi-ai/compat';
8
8
  import type { ModelRegistry } from '@earendil-works/pi-coding-agent';
9
9
 
10
- import type { HydraMatcher } from '../../../src/domain/matching/hydra-matcher.js';
11
- import { ExecutionLedger } from '../../../src/domain/delegation/execution-ledger.js';
12
- import { SessionPinner } from '../../../src/domain/pinning/session-pinner.js';
10
+ import {
11
+ ExecutionLedger,
12
+ SessionPinner,
13
+ DatasetRecorder,
14
+ OutcomeRecorder,
15
+ LifecycleHookState,
16
+ } from '../../../src/index.js';
13
17
  import type {
18
+ HydraMatcher,
14
19
  AdaptiveReasoningConfig,
15
20
  ModelProfile,
16
21
  PlanningDelegateConfig,
@@ -18,21 +23,13 @@ import type {
18
23
  RoutingDecision,
19
24
  RoutingReasoningTelemetry,
20
25
  RoutingUsageActuals,
21
- } from '../../../src/domain/types/index.js';
22
- import type { PlanningDelegateSpawnFn } from './planning-delegate.js';
23
- import type { StorePort } from '../../../src/domain/types/store-port.js';
24
- import {
25
- DatasetRecorder,
26
- } from '../../../src/infrastructure/telemetry/dataset-recorder.js';
27
- import {
28
- OutcomeRecorder,
29
- type SessionRoutingSnapshot,
30
- } from '../../../src/infrastructure/telemetry/outcome-recorder.js';
31
- import {
32
- LifecycleHookState,
33
- type RouterHandle,
26
+ StorePort,
27
+ SessionRoutingSnapshot,
28
+ RouterHandle,
34
29
  } from '../../../src/index.js';
35
30
 
31
+ import type { PlanningDelegateSpawnFn } from './planning-delegate.js';
32
+
36
33
  export type FleetMode = 'scoped' | 'all';
37
34
 
38
35
  export type SmartRouterCommand =
@@ -4,9 +4,11 @@ import {
4
4
  createResilientStore,
5
5
  SqliteStore,
6
6
  SqliteStoreError,
7
- } from '../../../src/infrastructure/persistence/sqlite-store.js';
8
- import type { StorePort } from '../../../src/domain/types/store-port.js';
9
- import type { RateLimitPort } from '../../../src/infrastructure/gateway/gateway-dispatch.js';
7
+ } from '../../../src/index.js';
8
+ import type {
9
+ StorePort,
10
+ RateLimitPort,
11
+ } from '../../../src/index.js';
10
12
 
11
13
  export const DEFAULT_ROUTER_STATE_DB_PATH = '.pi-smart-router/state.db';
12
14
  export const DEFAULT_RATE_LIMIT_MAX_TOKENS = 60;