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.
- package/.pi/extensions/smart-router/command-formatters.ts +9 -11
- package/.pi/extensions/smart-router/commands.ts +5 -2
- package/.pi/extensions/smart-router/dataset-export.ts +8 -7
- package/.pi/extensions/smart-router/delegate-stream.ts +8 -5
- package/.pi/extensions/smart-router/delegation-runtime.ts +8 -11
- package/.pi/extensions/smart-router/extension-setup.ts +9 -4
- package/.pi/extensions/smart-router/fleet-bootstrap.ts +19 -21
- package/.pi/extensions/smart-router/index.ts +5 -4
- package/.pi/extensions/smart-router/planning-delegate.ts +9 -8
- package/.pi/extensions/smart-router/pricing-lifecycle.ts +9 -4
- package/.pi/extensions/smart-router/route-and-delegate.ts +13 -12
- package/.pi/extensions/smart-router/routing-context.ts +4 -2
- package/.pi/extensions/smart-router/routing-outcomes.ts +6 -2
- package/.pi/extensions/smart-router/session-lifecycle.ts +5 -2
- package/.pi/extensions/smart-router/stream-delegation.ts +8 -2
- package/.pi/extensions/smart-router/types.ts +13 -16
- package/.pi/extensions/smart-router/utils.ts +5 -3
- package/README.md +63 -19
- package/config/benchmark-profiles.json +2 -2
- package/config/onnx-artifact-pins.json +18 -0
- package/config/operator-config.json.example +1 -0
- package/config/p-success-weights.json +12 -18
- package/config/routing-calibration.json +2806 -0
- package/dist/domain/matching/embedding-provider.d.ts +40 -3
- package/dist/domain/matching/embedding-provider.d.ts.map +1 -1
- package/dist/domain/matching/embedding-provider.js +159 -9
- package/dist/domain/matching/embedding-provider.js.map +1 -1
- package/dist/domain/pinning/session-pinner.js +1 -1
- package/dist/domain/pinning/session-pinner.js.map +1 -1
- package/dist/domain/pipeline/context-fit-stage.d.ts +14 -0
- package/dist/domain/pipeline/context-fit-stage.d.ts.map +1 -0
- package/dist/domain/pipeline/context-fit-stage.js +25 -0
- package/dist/domain/pipeline/context-fit-stage.js.map +1 -0
- package/dist/domain/pipeline/context-overflow-fallback-stage.d.ts +28 -0
- package/dist/domain/pipeline/context-overflow-fallback-stage.d.ts.map +1 -0
- package/dist/domain/pipeline/context-overflow-fallback-stage.js +77 -0
- package/dist/domain/pipeline/context-overflow-fallback-stage.js.map +1 -0
- package/dist/domain/pipeline/hardware-probe-stage.d.ts +12 -0
- package/dist/domain/pipeline/hardware-probe-stage.d.ts.map +1 -0
- package/dist/domain/pipeline/hardware-probe-stage.js +27 -0
- package/dist/domain/pipeline/hardware-probe-stage.js.map +1 -0
- package/dist/domain/pipeline/hydra-match-stage.d.ts +19 -0
- package/dist/domain/pipeline/hydra-match-stage.d.ts.map +1 -0
- package/dist/domain/pipeline/hydra-match-stage.js +178 -0
- package/dist/domain/pipeline/hydra-match-stage.js.map +1 -0
- package/dist/domain/pipeline/local-zero-stage.d.ts +23 -0
- package/dist/domain/pipeline/local-zero-stage.d.ts.map +1 -0
- package/dist/domain/pipeline/local-zero-stage.js +167 -0
- package/dist/domain/pipeline/local-zero-stage.js.map +1 -0
- package/dist/domain/pipeline/low-intensity-stage.d.ts +20 -0
- package/dist/domain/pipeline/low-intensity-stage.d.ts.map +1 -0
- package/dist/domain/pipeline/low-intensity-stage.js +221 -0
- package/dist/domain/pipeline/low-intensity-stage.js.map +1 -0
- package/dist/domain/pipeline/pipeline-stage.d.ts +116 -0
- package/dist/domain/pipeline/pipeline-stage.d.ts.map +1 -0
- package/dist/domain/pipeline/pipeline-stage.js +49 -0
- package/dist/domain/pipeline/pipeline-stage.js.map +1 -0
- package/dist/domain/pipeline/router-pipeline.d.ts +77 -185
- package/dist/domain/pipeline/router-pipeline.d.ts.map +1 -1
- package/dist/domain/pipeline/router-pipeline.js +160 -1232
- package/dist/domain/pipeline/router-pipeline.js.map +1 -1
- package/dist/domain/pipeline/safe-default-stage.d.ts +26 -0
- package/dist/domain/pipeline/safe-default-stage.d.ts.map +1 -0
- package/dist/domain/pipeline/safe-default-stage.js +75 -0
- package/dist/domain/pipeline/safe-default-stage.js.map +1 -0
- package/dist/domain/pipeline/session-pin-stage.d.ts +26 -0
- package/dist/domain/pipeline/session-pin-stage.d.ts.map +1 -0
- package/dist/domain/pipeline/session-pin-stage.js +195 -0
- package/dist/domain/pipeline/session-pin-stage.js.map +1 -0
- package/dist/domain/pipeline/stage-helpers.d.ts +58 -0
- package/dist/domain/pipeline/stage-helpers.d.ts.map +1 -0
- package/dist/domain/pipeline/stage-helpers.js +156 -0
- package/dist/domain/pipeline/stage-helpers.js.map +1 -0
- package/dist/domain/pipeline/triage-stage.d.ts +22 -0
- package/dist/domain/pipeline/triage-stage.d.ts.map +1 -0
- package/dist/domain/pipeline/triage-stage.js +83 -0
- package/dist/domain/pipeline/triage-stage.js.map +1 -0
- package/dist/domain/pipeline/turn-envelope-stage.d.ts +15 -0
- package/dist/domain/pipeline/turn-envelope-stage.d.ts.map +1 -0
- package/dist/domain/pipeline/turn-envelope-stage.js +201 -0
- package/dist/domain/pipeline/turn-envelope-stage.js.map +1 -0
- package/dist/domain/ports/hardware-probe-port.d.ts +100 -0
- package/dist/domain/ports/hardware-probe-port.d.ts.map +1 -0
- package/dist/domain/ports/hardware-probe-port.js +56 -0
- package/dist/domain/ports/hardware-probe-port.js.map +1 -0
- package/dist/domain/ports/local-runtime-port.d.ts +75 -0
- package/dist/domain/ports/local-runtime-port.d.ts.map +1 -0
- package/dist/domain/ports/local-runtime-port.js +115 -0
- package/dist/domain/ports/local-runtime-port.js.map +1 -0
- package/dist/domain/ports/telemetry-emitter-port.d.ts +121 -0
- package/dist/domain/ports/telemetry-emitter-port.d.ts.map +1 -0
- package/dist/domain/ports/telemetry-emitter-port.js +375 -0
- package/dist/domain/ports/telemetry-emitter-port.js.map +1 -0
- package/dist/domain/pricing/price-resolution.d.ts +38 -0
- package/dist/domain/pricing/price-resolution.d.ts.map +1 -0
- package/dist/domain/pricing/price-resolution.js +62 -0
- package/dist/domain/pricing/price-resolution.js.map +1 -0
- package/dist/domain/routing/expected-cost.js +1 -1
- package/dist/domain/routing/expected-cost.js.map +1 -1
- package/dist/domain/routing/p-success-classifier.d.ts +2 -2
- package/dist/domain/routing/p-success-classifier.d.ts.map +1 -1
- package/dist/domain/routing/p-success-classifier.js +20 -16
- package/dist/domain/routing/p-success-classifier.js.map +1 -1
- package/dist/index.d.ts +57 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +57 -6
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/gateway/gateway-dispatch.d.ts.map +1 -1
- package/dist/infrastructure/gateway/gateway-dispatch.js +12 -1
- package/dist/infrastructure/gateway/gateway-dispatch.js.map +1 -1
- package/dist/infrastructure/hardware/hardware-probe.d.ts +8 -21
- package/dist/infrastructure/hardware/hardware-probe.d.ts.map +1 -1
- package/dist/infrastructure/hardware/hardware-probe.js +7 -33
- package/dist/infrastructure/hardware/hardware-probe.js.map +1 -1
- package/dist/infrastructure/hardware/throughput-meter.d.ts +7 -47
- package/dist/infrastructure/hardware/throughput-meter.d.ts.map +1 -1
- package/dist/infrastructure/hardware/throughput-meter.js +5 -0
- package/dist/infrastructure/hardware/throughput-meter.js.map +1 -1
- package/dist/infrastructure/local/local-zero-tier.d.ts +14 -36
- package/dist/infrastructure/local/local-zero-tier.d.ts.map +1 -1
- package/dist/infrastructure/local/local-zero-tier.js +16 -79
- package/dist/infrastructure/local/local-zero-tier.js.map +1 -1
- package/dist/infrastructure/persistence/memory-store.d.ts.map +1 -1
- package/dist/infrastructure/persistence/memory-store.js +9 -3
- package/dist/infrastructure/persistence/memory-store.js.map +1 -1
- package/dist/infrastructure/persistence/sqlite-store.d.ts.map +1 -1
- package/dist/infrastructure/persistence/sqlite-store.js +12 -2
- package/dist/infrastructure/persistence/sqlite-store.js.map +1 -1
- package/dist/infrastructure/pricing/price-broker.d.ts +8 -27
- package/dist/infrastructure/pricing/price-broker.d.ts.map +1 -1
- package/dist/infrastructure/pricing/price-broker.js +7 -51
- package/dist/infrastructure/pricing/price-broker.js.map +1 -1
- package/dist/infrastructure/telemetry/pin-economics-telemetry.d.ts +62 -0
- package/dist/infrastructure/telemetry/pin-economics-telemetry.d.ts.map +1 -0
- package/dist/infrastructure/telemetry/pin-economics-telemetry.js +214 -0
- package/dist/infrastructure/telemetry/pin-economics-telemetry.js.map +1 -0
- package/dist/infrastructure/telemetry/planning-delegate-telemetry.d.ts +21 -0
- package/dist/infrastructure/telemetry/planning-delegate-telemetry.d.ts.map +1 -0
- package/dist/infrastructure/telemetry/planning-delegate-telemetry.js +67 -0
- package/dist/infrastructure/telemetry/planning-delegate-telemetry.js.map +1 -0
- package/dist/infrastructure/telemetry/routing-decision-log.d.ts +50 -0
- package/dist/infrastructure/telemetry/routing-decision-log.d.ts.map +1 -0
- package/dist/infrastructure/telemetry/routing-decision-log.js +163 -0
- package/dist/infrastructure/telemetry/routing-decision-log.js.map +1 -0
- package/dist/infrastructure/telemetry/routing-telemetry.d.ts +28 -211
- package/dist/infrastructure/telemetry/routing-telemetry.d.ts.map +1 -1
- package/dist/infrastructure/telemetry/routing-telemetry.js +32 -936
- package/dist/infrastructure/telemetry/routing-telemetry.js.map +1 -1
- package/dist/infrastructure/telemetry/telemetry-scalar-fields.d.ts +83 -0
- package/dist/infrastructure/telemetry/telemetry-scalar-fields.d.ts.map +1 -0
- package/dist/infrastructure/telemetry/telemetry-scalar-fields.js +184 -0
- package/dist/infrastructure/telemetry/telemetry-scalar-fields.js.map +1 -0
- package/package.json +11 -9
- package/skills/router-release-operator/SKILL.md +21 -9
- package/skills/router-release-operator/references/dependency-freshness.md +67 -0
- package/skills/router-release-operator/references/issue-intake-checklist.md +14 -0
- package/skills/router-release-operator/references/release-manifest-template.md +16 -0
- package/skills/router-release-operator/references/release-profiles.md +11 -5
- package/src/domain/matching/embedding-provider.ts +241 -7
- package/src/domain/pinning/session-pinner.ts +1 -1
- package/src/domain/pipeline/context-fit-stage.ts +32 -0
- package/src/domain/pipeline/context-overflow-fallback-stage.ts +112 -0
- package/src/domain/pipeline/hardware-probe-stage.ts +31 -0
- package/src/domain/pipeline/hydra-match-stage.ts +242 -0
- package/src/domain/pipeline/local-zero-stage.ts +228 -0
- package/src/domain/pipeline/low-intensity-stage.ts +312 -0
- package/src/domain/pipeline/pipeline-stage.ts +182 -0
- package/src/domain/pipeline/router-pipeline.ts +227 -1613
- package/src/domain/pipeline/safe-default-stage.ts +87 -0
- package/src/domain/pipeline/session-pin-stage.ts +259 -0
- package/src/domain/pipeline/stage-helpers.ts +230 -0
- package/src/domain/pipeline/triage-stage.ts +98 -0
- package/src/domain/pipeline/turn-envelope-stage.ts +300 -0
- package/src/domain/ports/hardware-probe-port.ts +158 -0
- package/src/domain/ports/local-runtime-port.ts +198 -0
- package/src/domain/ports/telemetry-emitter-port.ts +622 -0
- package/src/domain/pricing/price-resolution.ts +84 -0
- package/src/domain/routing/expected-cost.ts +1 -1
- package/src/domain/routing/p-success-classifier.ts +22 -18
- package/src/index.ts +188 -6
- package/src/infrastructure/gateway/gateway-dispatch.ts +12 -1
- package/src/infrastructure/hardware/hardware-probe.ts +26 -68
- package/src/infrastructure/hardware/throughput-meter.ts +19 -50
- package/src/infrastructure/local/local-zero-tier.ts +38 -136
- package/src/infrastructure/persistence/memory-store.ts +10 -2
- package/src/infrastructure/persistence/sqlite-store.ts +13 -2
- package/src/infrastructure/pricing/price-broker.ts +15 -72
- package/src/infrastructure/telemetry/pin-economics-telemetry.ts +353 -0
- package/src/infrastructure/telemetry/planning-delegate-telemetry.ts +101 -0
- package/src/infrastructure/telemetry/routing-decision-log.ts +262 -0
- package/src/infrastructure/telemetry/routing-telemetry.ts +134 -1443
- 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
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
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 {
|
|
14
|
-
|
|
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
|
-
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
import type {
|
|
17
|
-
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
37
|
-
|
|
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 {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
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
|
-
|
|
17
|
-
import { SessionPinner } from '../../../src/domain/pinning/session-pinner.js';
|
|
18
|
-
import {
|
|
14
|
+
SessionPinner,
|
|
19
15
|
collectPoolModelIds,
|
|
20
16
|
resolveQuotaWindowEstimateConfigFromEnv,
|
|
21
17
|
resolveQuotaWindowPosition,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
|
10
|
-
* from source at dev time and is excluded from
|
|
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/
|
|
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/
|
|
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/
|
|
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 {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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/
|
|
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 {
|
|
2
|
-
|
|
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 {
|
|
4
|
-
|
|
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
|
|
11
|
-
|
|
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
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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/
|
|
8
|
-
import type {
|
|
9
|
-
|
|
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;
|