@mupt-ai/dari-gateway 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bun.d.ts +2 -0
- package/dist/bun.js +4 -0
- package/dist/context/eval_catalog.d.ts +3 -0
- package/dist/context/eval_catalog.js +7 -0
- package/dist/context/interaction_fingerprint.d.ts +27 -0
- package/dist/context/interaction_fingerprint.js +519 -0
- package/dist/context/interaction_fingerprint_format.d.ts +42 -0
- package/dist/context/interaction_fingerprint_format.js +113 -0
- package/dist/context/interaction_lease_depth.d.ts +2 -0
- package/dist/context/interaction_lease_depth.js +110 -0
- package/dist/context/lease_history.d.ts +7 -0
- package/dist/context/lease_history.js +158 -0
- package/dist/context/pricing.d.ts +4 -0
- package/dist/context/pricing.js +23 -0
- package/dist/context/provider_prompt_accounting.d.ts +14 -0
- package/dist/context/provider_prompt_accounting.js +187 -0
- package/dist/context/routing_context.d.ts +40 -0
- package/dist/context/routing_context.js +211 -0
- package/dist/http/auth.d.ts +2 -0
- package/dist/http/auth.js +35 -0
- package/dist/http/errors.d.ts +19 -0
- package/dist/http/errors.js +89 -0
- package/dist/http/handler.d.ts +12 -0
- package/dist/http/handler.js +81 -0
- package/dist/http/http2_server.d.ts +6 -0
- package/dist/http/http2_server.js +103 -0
- package/dist/http/serve.d.ts +20 -0
- package/dist/http/serve.js +78 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +8 -0
- package/dist/ingress/anthropic_messages.d.ts +3 -0
- package/dist/ingress/anthropic_messages.js +122 -0
- package/dist/ingress/anthropic_models.d.ts +1 -0
- package/dist/ingress/anthropic_models.js +23 -0
- package/dist/ingress/chat_completions.d.ts +2 -0
- package/dist/ingress/chat_completions.js +37 -0
- package/dist/ingress/claude_code/request_context.d.ts +2 -0
- package/dist/ingress/claude_code/request_context.js +31 -0
- package/dist/ingress/codex.d.ts +3 -0
- package/dist/ingress/codex.js +65 -0
- package/dist/ingress/codex_models.d.ts +2 -0
- package/dist/ingress/codex_models.js +89 -0
- package/dist/ingress/json.d.ts +1 -0
- package/dist/ingress/json.js +95 -0
- package/dist/ingress/models.d.ts +1 -0
- package/dist/ingress/models.js +53 -0
- package/dist/interaction/capabilities.d.ts +3 -0
- package/dist/interaction/capabilities.js +24 -0
- package/dist/interaction/image.d.ts +4 -0
- package/dist/interaction/image.js +13 -0
- package/dist/interaction/portable_reasoning_state.d.ts +4 -0
- package/dist/interaction/portable_reasoning_state.js +18 -0
- package/dist/interaction/provider_continuation_state.d.ts +6 -0
- package/dist/interaction/provider_continuation_state.js +27 -0
- package/dist/interaction/tool_identity.d.ts +10 -0
- package/dist/interaction/tool_identity.js +41 -0
- package/dist/interaction/types.d.ts +203 -0
- package/dist/interaction/types.js +5 -0
- package/dist/models/context_limits.d.ts +2 -0
- package/dist/models/context_limits.js +7 -0
- package/dist/models/execution_provider.d.ts +8 -0
- package/dist/models/execution_provider.js +13 -0
- package/dist/models/gateways.d.ts +11 -0
- package/dist/models/gateways.js +45 -0
- package/dist/models/ids.d.ts +1 -0
- package/dist/models/ids.js +15 -0
- package/dist/models/provider_defaults.d.ts +4 -0
- package/dist/models/provider_defaults.js +41 -0
- package/dist/models/runtime_overrides.d.ts +4 -0
- package/dist/models/runtime_overrides.js +209 -0
- package/dist/observability/errors.d.ts +8 -0
- package/dist/observability/errors.js +11 -0
- package/dist/platform/platform.d.ts +152 -0
- package/dist/platform/platform.js +11 -0
- package/dist/platform/routing_contract.d.ts +2 -0
- package/dist/platform/routing_contract.js +5 -0
- package/dist/protocol/input/anthropic_messages.d.ts +2 -0
- package/dist/protocol/input/anthropic_messages.js +494 -0
- package/dist/protocol/input/chat_completions.d.ts +4 -0
- package/dist/protocol/input/chat_completions.js +212 -0
- package/dist/protocol/input/chat_completions_validation.d.ts +2 -0
- package/dist/protocol/input/chat_completions_validation.js +257 -0
- package/dist/protocol/input/openai_responses.d.ts +2 -0
- package/dist/protocol/input/openai_responses.js +666 -0
- package/dist/protocol/input/router_model.d.ts +7 -0
- package/dist/protocol/input/router_model.js +43 -0
- package/dist/protocol/output/anthropic_messages.d.ts +10 -0
- package/dist/protocol/output/anthropic_messages.js +15 -0
- package/dist/protocol/output/anthropic_messages_output.d.ts +10 -0
- package/dist/protocol/output/anthropic_messages_output.js +124 -0
- package/dist/protocol/output/anthropic_messages_stream.d.ts +16 -0
- package/dist/protocol/output/anthropic_messages_stream.js +267 -0
- package/dist/protocol/output/chat_completions.d.ts +29 -0
- package/dist/protocol/output/chat_completions.js +406 -0
- package/dist/protocol/output/chat_reasoning_detail.d.ts +2 -0
- package/dist/protocol/output/chat_reasoning_detail.js +13 -0
- package/dist/protocol/output/delivered_stream_snapshot.d.ts +10 -0
- package/dist/protocol/output/delivered_stream_snapshot.js +31 -0
- package/dist/protocol/output/openai_responses.d.ts +10 -0
- package/dist/protocol/output/openai_responses.js +14 -0
- package/dist/protocol/output/openai_responses_output.d.ts +14 -0
- package/dist/protocol/output/openai_responses_output.js +125 -0
- package/dist/protocol/output/openai_responses_stream.d.ts +18 -0
- package/dist/protocol/output/openai_responses_stream.js +546 -0
- package/dist/protocol/output/sse_stream.d.ts +31 -0
- package/dist/protocol/output/sse_stream.js +67 -0
- package/dist/providers/anthropic_safeguards.d.ts +11 -0
- package/dist/providers/anthropic_safeguards.js +81 -0
- package/dist/providers/aws_assume_role.d.ts +17 -0
- package/dist/providers/aws_assume_role.js +107 -0
- package/dist/providers/cancel_estimate.d.ts +43 -0
- package/dist/providers/cancel_estimate.js +89 -0
- package/dist/providers/execution.d.ts +72 -0
- package/dist/providers/execution.js +491 -0
- package/dist/providers/model_capabilities.d.ts +11 -0
- package/dist/providers/model_capabilities.js +29 -0
- package/dist/providers/pi.d.ts +65 -0
- package/dist/providers/pi.js +319 -0
- package/dist/providers/pi_context.d.ts +7 -0
- package/dist/providers/pi_context.js +405 -0
- package/dist/providers/pi_options.d.ts +11 -0
- package/dist/providers/pi_options.js +398 -0
- package/dist/providers/pi_output.d.ts +2 -0
- package/dist/providers/pi_output.js +453 -0
- package/dist/providers/provider_attempt_runner.d.ts +55 -0
- package/dist/providers/provider_attempt_runner.js +90 -0
- package/dist/providers/provider_call.d.ts +77 -0
- package/dist/providers/provider_call.js +292 -0
- package/dist/providers/provider_reported_cost.d.ts +10 -0
- package/dist/providers/provider_reported_cost.js +123 -0
- package/dist/providers/reasoning.d.ts +12 -0
- package/dist/providers/reasoning.js +30 -0
- package/dist/providers/response_capture.d.ts +23 -0
- package/dist/providers/response_capture.js +47 -0
- package/dist/providers/stream_finalization.d.ts +46 -0
- package/dist/providers/stream_finalization.js +165 -0
- package/dist/providers/subscription_limits.d.ts +31 -0
- package/dist/providers/subscription_limits.js +163 -0
- package/dist/providers/subscription_usage.d.ts +10 -0
- package/dist/providers/subscription_usage.js +79 -0
- package/dist/runtime/claude_code/auxiliary_routing.d.ts +3 -0
- package/dist/runtime/claude_code/auxiliary_routing.js +60 -0
- package/dist/runtime/customer_disconnect.d.ts +20 -0
- package/dist/runtime/customer_disconnect.js +49 -0
- package/dist/runtime/explicit_model.d.ts +4 -0
- package/dist/runtime/explicit_model.js +53 -0
- package/dist/runtime/harness_identity/conversation.d.ts +33 -0
- package/dist/runtime/harness_identity/conversation.js +39 -0
- package/dist/runtime/harness_identity/extract.d.ts +8 -0
- package/dist/runtime/harness_identity/extract.js +214 -0
- package/dist/runtime/harness_identity/index.d.ts +2 -0
- package/dist/runtime/harness_identity/index.js +2 -0
- package/dist/runtime/prepare_routed_completion.d.ts +33 -0
- package/dist/runtime/prepare_routed_completion.js +167 -0
- package/dist/runtime/provider_stream_lifecycle.d.ts +31 -0
- package/dist/runtime/provider_stream_lifecycle.js +88 -0
- package/dist/runtime/provider_stream_outcome.d.ts +23 -0
- package/dist/runtime/provider_stream_outcome.js +55 -0
- package/dist/runtime/request_tags.d.ts +7 -0
- package/dist/runtime/request_tags.js +33 -0
- package/dist/runtime/routed_completion.d.ts +17 -0
- package/dist/runtime/routed_completion.js +80 -0
- package/dist/runtime/routed_protocol.d.ts +30 -0
- package/dist/runtime/routed_protocol.js +1 -0
- package/dist/runtime/routed_runtime.d.ts +40 -0
- package/dist/runtime/routed_runtime.js +535 -0
- package/dist/runtime/routing_lease.d.ts +26 -0
- package/dist/runtime/routing_lease.js +210 -0
- package/dist/runtime/runtime_reporter.d.ts +71 -0
- package/dist/runtime/runtime_reporter.js +35 -0
- package/dist/self_host/config.d.ts +46 -0
- package/dist/self_host/config.js +105 -0
- package/dist/self_host/main.d.ts +16 -0
- package/dist/self_host/main.js +95 -0
- package/dist/self_host/platform.d.ts +13 -0
- package/dist/self_host/platform.js +50 -0
- package/dist/self_host/prefix_store.d.ts +46 -0
- package/dist/self_host/prefix_store.js +261 -0
- package/dist/self_host/resolve.d.ts +28 -0
- package/dist/self_host/resolve.js +171 -0
- package/dist/self_host/subscriptions/access.d.ts +10 -0
- package/dist/self_host/subscriptions/access.js +37 -0
- package/dist/self_host/subscriptions/http.d.ts +15 -0
- package/dist/self_host/subscriptions/http.js +187 -0
- package/dist/self_host/subscriptions/index.d.ts +24 -0
- package/dist/self_host/subscriptions/index.js +24 -0
- package/dist/self_host/subscriptions/oauth.d.ts +55 -0
- package/dist/self_host/subscriptions/oauth.js +281 -0
- package/dist/self_host/subscriptions/store.d.ts +78 -0
- package/dist/self_host/subscriptions/store.js +235 -0
- package/dist/strategies/auto_routing_selector.d.ts +12 -0
- package/dist/strategies/auto_routing_selector.js +61 -0
- package/dist/strategies/eval_relevance.d.ts +17 -0
- package/dist/strategies/eval_relevance.js +32 -0
- package/dist/strategies/fallback_decision.d.ts +8 -0
- package/dist/strategies/fallback_decision.js +17 -0
- package/dist/strategies/priority_selector.d.ts +7 -0
- package/dist/strategies/priority_selector.js +37 -0
- package/dist/strategies/route_decision.d.ts +22 -0
- package/dist/strategies/route_decision.js +65 -0
- package/dist/strategies/routing.d.ts +74 -0
- package/dist/strategies/routing.js +280 -0
- package/dist/strategies/selector_projection.d.ts +15 -0
- package/dist/strategies/selector_projection.js +161 -0
- package/dist/telemetry/background.d.ts +7 -0
- package/dist/telemetry/background.js +33 -0
- package/dist/telemetry/benchmark_replay.d.ts +37 -0
- package/dist/telemetry/benchmark_replay.js +108 -0
- package/dist/telemetry/billing_finalization.d.ts +64 -0
- package/dist/telemetry/billing_finalization.js +96 -0
- package/dist/telemetry/ingest_values.d.ts +4 -0
- package/dist/telemetry/ingest_values.js +12 -0
- package/dist/telemetry/model_cost.d.ts +3 -0
- package/dist/telemetry/model_cost.js +15 -0
- package/dist/telemetry/prefix_state.d.ts +47 -0
- package/dist/telemetry/prefix_state.js +116 -0
- package/dist/telemetry/report.d.ts +88 -0
- package/dist/telemetry/report.js +621 -0
- package/dist/telemetry/requests/interaction_observability.d.ts +45 -0
- package/dist/telemetry/requests/interaction_observability.js +180 -0
- package/dist/telemetry/requests/retained_interaction_request.d.ts +8 -0
- package/dist/telemetry/requests/retained_interaction_request.js +10 -0
- package/dist/telemetry/scrub.d.ts +2 -0
- package/dist/telemetry/scrub.js +31 -0
- package/dist/telemetry/skills/claude/catalog.d.ts +6 -0
- package/dist/telemetry/skills/claude/catalog.js +99 -0
- package/dist/telemetry/skills/claude/file_reads.d.ts +4 -0
- package/dist/telemetry/skills/claude/file_reads.js +110 -0
- package/dist/telemetry/skills/claude/observations.d.ts +3 -0
- package/dist/telemetry/skills/claude/observations.js +366 -0
- package/dist/telemetry/skills/codex/catalog.d.ts +11 -0
- package/dist/telemetry/skills/codex/catalog.js +138 -0
- package/dist/telemetry/skills/codex/exec_file_reads.d.ts +9 -0
- package/dist/telemetry/skills/codex/exec_file_reads.js +36 -0
- package/dist/telemetry/skills/codex/explicit.d.ts +3 -0
- package/dist/telemetry/skills/codex/explicit.js +90 -0
- package/dist/telemetry/skills/codex/file_reads.d.ts +4 -0
- package/dist/telemetry/skills/codex/file_reads.js +37 -0
- package/dist/telemetry/skills/codex/identity.d.ts +2 -0
- package/dist/telemetry/skills/codex/identity.js +20 -0
- package/dist/telemetry/skills/observations.d.ts +21 -0
- package/dist/telemetry/skills/observations.js +41 -0
- package/dist/telemetry/skills/paths.d.ts +11 -0
- package/dist/telemetry/skills/paths.js +61 -0
- package/dist/telemetry/skills/pi.d.ts +6 -0
- package/dist/telemetry/skills/pi.js +223 -0
- package/dist/telemetry/skills/shell_file_reads.d.ts +7 -0
- package/dist/telemetry/skills/shell_file_reads.js +226 -0
- package/dist/telemetry/skills/shell_words.d.ts +13 -0
- package/dist/telemetry/skills/shell_words.js +189 -0
- package/dist/telemetry/tools/input.d.ts +2 -0
- package/dist/telemetry/tools/input.js +14 -0
- package/dist/telemetry/tools/observations.d.ts +29 -0
- package/dist/telemetry/tools/observations.js +247 -0
- package/dist/telemetry/usage.d.ts +57 -0
- package/dist/telemetry/usage.js +136 -0
- package/dist/types.d.ts +94 -0
- package/dist/types.js +1 -0
- package/package.json +21 -6
- package/src/bun.ts +2 -2
- package/src/context/eval_catalog.ts +1 -1
- package/src/context/interaction_fingerprint.ts +9 -9
- package/src/context/interaction_fingerprint_format.ts +1 -1
- package/src/context/interaction_lease_depth.ts +1 -1
- package/src/context/pricing.ts +1 -1
- package/src/context/provider_prompt_accounting.ts +5 -5
- package/src/context/routing_context.ts +16 -16
- package/src/http/auth.ts +1 -1
- package/src/http/handler.ts +8 -8
- package/src/http/serve.ts +3 -3
- package/src/index.ts +6 -6
- package/src/ingress/anthropic_messages.ts +12 -12
- package/src/ingress/anthropic_models.ts +1 -1
- package/src/ingress/chat_completions.ts +9 -9
- package/src/ingress/claude_code/request_context.ts +2 -2
- package/src/ingress/codex.ts +10 -10
- package/src/ingress/codex_models.ts +4 -4
- package/src/ingress/json.ts +1 -1
- package/src/ingress/models.ts +9 -9
- package/src/interaction/capabilities.ts +1 -1
- package/src/interaction/portable_reasoning_state.ts +1 -1
- package/src/interaction/provider_continuation_state.ts +1 -1
- package/src/interaction/tool_identity.ts +2 -2
- package/src/models/context_limits.ts +1 -1
- package/src/models/execution_provider.ts +1 -1
- package/src/models/ids.ts +1 -1
- package/src/models/provider_defaults.ts +1 -1
- package/src/models/runtime_overrides.ts +1 -1
- package/src/observability/errors.ts +2 -2
- package/src/platform/platform.ts +4 -4
- package/src/protocol/input/anthropic_messages.ts +7 -7
- package/src/protocol/input/chat_completions.ts +5 -5
- package/src/protocol/input/chat_completions_validation.ts +4 -4
- package/src/protocol/input/openai_responses.ts +6 -6
- package/src/protocol/output/anthropic_messages.ts +3 -3
- package/src/protocol/output/anthropic_messages_output.ts +6 -4
- package/src/protocol/output/anthropic_messages_stream.ts +7 -7
- package/src/protocol/output/chat_completions.ts +13 -13
- package/src/protocol/output/chat_reasoning_detail.ts +1 -1
- package/src/protocol/output/openai_responses.ts +3 -3
- package/src/protocol/output/openai_responses_output.ts +4 -2
- package/src/protocol/output/openai_responses_stream.ts +6 -6
- package/src/protocol/output/sse_stream.ts +3 -3
- package/src/providers/anthropic_safeguards.ts +2 -2
- package/src/providers/aws_assume_role.ts +2 -2
- package/src/providers/cancel_estimate.ts +1 -1
- package/src/providers/execution.ts +17 -17
- package/src/providers/pi.ts +14 -14
- package/src/providers/pi_context.ts +6 -6
- package/src/providers/pi_options.ts +10 -10
- package/src/providers/pi_output.ts +5 -5
- package/src/providers/provider_attempt_runner.ts +1 -1
- package/src/providers/provider_call.ts +14 -14
- package/src/providers/provider_reported_cost.ts +3 -3
- package/src/providers/reasoning.ts +2 -2
- package/src/providers/stream_finalization.ts +9 -9
- package/src/providers/subscription_limits.ts +3 -3
- package/src/runtime/claude_code/auxiliary_routing.ts +5 -5
- package/src/runtime/customer_disconnect.ts +1 -1
- package/src/runtime/explicit_model.ts +4 -4
- package/src/runtime/harness_identity/conversation.ts +1 -1
- package/src/runtime/harness_identity/extract.ts +3 -3
- package/src/runtime/harness_identity/index.ts +2 -2
- package/src/runtime/prepare_routed_completion.ts +13 -13
- package/src/runtime/provider_stream_lifecycle.ts +1 -1
- package/src/runtime/provider_stream_outcome.ts +2 -2
- package/src/runtime/request_tags.ts +2 -2
- package/src/runtime/routed_completion.ts +11 -11
- package/src/runtime/routed_protocol.ts +2 -2
- package/src/runtime/routed_runtime.ts +20 -19
- package/src/runtime/routing_lease.ts +7 -7
- package/src/runtime/runtime_reporter.ts +3 -3
- package/src/self_host/main.ts +12 -12
- package/src/self_host/platform.ts +5 -5
- package/src/self_host/prefix_store.ts +2 -2
- package/src/self_host/resolve.ts +6 -6
- package/src/self_host/subscriptions/access.ts +2 -2
- package/src/self_host/subscriptions/http.ts +2 -2
- package/src/self_host/subscriptions/index.ts +4 -4
- package/src/self_host/subscriptions/store.ts +1 -1
- package/src/strategies/auto_routing_selector.ts +2 -2
- package/src/strategies/eval_relevance.ts +3 -3
- package/src/strategies/priority_selector.ts +1 -1
- package/src/strategies/route_decision.ts +7 -7
- package/src/strategies/routing.ts +10 -10
- package/src/strategies/selector_projection.ts +2 -2
- package/src/telemetry/billing_finalization.ts +3 -3
- package/src/telemetry/model_cost.ts +1 -1
- package/src/telemetry/prefix_state.ts +4 -4
- package/src/telemetry/report.ts +21 -21
- package/src/telemetry/requests/interaction_observability.ts +1 -1
- package/src/telemetry/requests/retained_interaction_request.ts +1 -1
- package/src/telemetry/skills/claude/catalog.ts +1 -1
- package/src/telemetry/skills/claude/file_reads.ts +6 -6
- package/src/telemetry/skills/claude/observations.ts +3 -3
- package/src/telemetry/skills/codex/catalog.ts +3 -3
- package/src/telemetry/skills/codex/exec_file_reads.ts +4 -4
- package/src/telemetry/skills/codex/explicit.ts +3 -3
- package/src/telemetry/skills/codex/file_reads.ts +5 -5
- package/src/telemetry/skills/observations.ts +7 -7
- package/src/telemetry/skills/pi.ts +3 -3
- package/src/telemetry/skills/shell_file_reads.ts +2 -2
- package/src/telemetry/skills/shell_words.ts +1 -1
- package/src/telemetry/tools/input.ts +1 -1
- package/src/telemetry/tools/observations.ts +9 -9
- package/src/telemetry/usage.ts +5 -5
|
@@ -8,46 +8,46 @@ import {
|
|
|
8
8
|
type RoutingDecision,
|
|
9
9
|
} from "@mupt-ai/dari-router/policy-engine";
|
|
10
10
|
|
|
11
|
-
import { executionProviderForModel, keySourceForModel } from "../models/execution_provider";
|
|
12
|
-
import { HttpError } from "../http/errors";
|
|
13
|
-
import type { RequestTags } from "../platform/platform";
|
|
14
|
-
import type { InteractionRequest, ProviderIdentity } from "../interaction/types";
|
|
11
|
+
import { executionProviderForModel, keySourceForModel } from "../models/execution_provider.js";
|
|
12
|
+
import { HttpError } from "../http/errors.js";
|
|
13
|
+
import type { RequestTags } from "../platform/platform.js";
|
|
14
|
+
import type { InteractionRequest, ProviderIdentity } from "../interaction/types.js";
|
|
15
15
|
import {
|
|
16
16
|
CustomerDisconnectedError,
|
|
17
17
|
createProviderAttemptAbort,
|
|
18
18
|
type ProviderAttemptAbort,
|
|
19
|
-
} from "../runtime/customer_disconnect";
|
|
19
|
+
} from "../runtime/customer_disconnect.js";
|
|
20
20
|
import {
|
|
21
21
|
isProviderFailureMessage,
|
|
22
22
|
providerFailureFromCaught,
|
|
23
23
|
providerFailureFromEvent,
|
|
24
|
-
} from "../runtime/provider_stream_outcome";
|
|
25
|
-
import { providerAuthForSelectedModel } from "../strategies/routing";
|
|
26
|
-
import { scrubSecretValues } from "../telemetry/scrub";
|
|
24
|
+
} from "../runtime/provider_stream_outcome.js";
|
|
25
|
+
import { providerAuthForSelectedModel } from "../strategies/routing.js";
|
|
26
|
+
import { scrubSecretValues } from "../telemetry/scrub.js";
|
|
27
27
|
import {
|
|
28
28
|
usageContextFor,
|
|
29
29
|
type RoutingUsageContext,
|
|
30
|
-
} from "../telemetry/usage";
|
|
30
|
+
} from "../telemetry/usage.js";
|
|
31
31
|
import type {
|
|
32
32
|
ProviderAuth,
|
|
33
33
|
ProviderKeySource,
|
|
34
34
|
ResolvedRouter,
|
|
35
35
|
ResolvedRouterModelConfig,
|
|
36
|
-
} from "../types";
|
|
37
|
-
import { awsRoleCredentials } from "./aws_assume_role";
|
|
36
|
+
} from "../types.js";
|
|
37
|
+
import { awsRoleCredentials } from "./aws_assume_role.js";
|
|
38
38
|
import {
|
|
39
39
|
attachProviderResponseCapture,
|
|
40
40
|
createProviderResponseCapture,
|
|
41
41
|
type ProviderFetch,
|
|
42
42
|
type ProviderResponseCapture,
|
|
43
|
-
} from "./response_capture";
|
|
43
|
+
} from "./response_capture.js";
|
|
44
44
|
import {
|
|
45
45
|
completeInteractionModel,
|
|
46
46
|
streamInteractionModel,
|
|
47
47
|
type ProviderEndpoint,
|
|
48
48
|
type ProviderEventStream,
|
|
49
|
-
} from "./pi";
|
|
50
|
-
import { promptTokenEstimateFor, type PromptTokenEstimate } from "./cancel_estimate";
|
|
49
|
+
} from "./pi.js";
|
|
50
|
+
import { promptTokenEstimateFor, type PromptTokenEstimate } from "./cancel_estimate.js";
|
|
51
51
|
|
|
52
52
|
type ProviderCallConfig = {
|
|
53
53
|
model: string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { isRecord } from "@mupt-ai/dari-router/policy-engine";
|
|
2
2
|
|
|
3
|
-
import { gatewayFor } from "../models/gateways";
|
|
4
|
-
import { providerFailureFromCaught } from "../runtime/provider_stream_outcome";
|
|
5
|
-
import type { ProviderFetch } from "./response_capture";
|
|
3
|
+
import { gatewayFor } from "../models/gateways.js";
|
|
4
|
+
import { providerFailureFromCaught } from "../runtime/provider_stream_outcome.js";
|
|
5
|
+
import type { ProviderFetch } from "./response_capture.js";
|
|
6
6
|
|
|
7
7
|
// Gateways bill per call and say what they billed: OpenRouter as `usage.cost`
|
|
8
8
|
// on the final chunk, Vercel AI Gateway as `providerMetadata.gateway.cost`.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ReasoningEffort } from "@mupt-ai/dari-router/policy-engine";
|
|
2
|
-
import { HttpError } from "../http/errors";
|
|
3
|
-
import type { InteractionRequest } from "../interaction/types";
|
|
2
|
+
import { HttpError } from "../http/errors.js";
|
|
3
|
+
import type { InteractionRequest } from "../interaction/types.js";
|
|
4
4
|
|
|
5
5
|
type ReasoningRequest = Pick<InteractionRequest, "reasoning">;
|
|
6
6
|
|
|
@@ -3,32 +3,32 @@ import type {
|
|
|
3
3
|
RoutingDecision,
|
|
4
4
|
} from "@mupt-ai/dari-router/policy-engine";
|
|
5
5
|
|
|
6
|
-
import type { InteractionRequest, ProviderIdentity } from "../interaction/types";
|
|
6
|
+
import type { InteractionRequest, ProviderIdentity } from "../interaction/types.js";
|
|
7
7
|
import {
|
|
8
8
|
captureOperationalError,
|
|
9
9
|
type OperationalErrorCode,
|
|
10
|
-
} from "../observability/errors";
|
|
11
|
-
import type { ProviderStreamOutcome } from "../runtime/provider_stream_outcome";
|
|
12
|
-
import type { RoutedProtocol } from "../runtime/routed_protocol";
|
|
10
|
+
} from "../observability/errors.js";
|
|
11
|
+
import type { ProviderStreamOutcome } from "../runtime/provider_stream_outcome.js";
|
|
12
|
+
import type { RoutedProtocol } from "../runtime/routed_protocol.js";
|
|
13
13
|
import {
|
|
14
14
|
reportedExecution,
|
|
15
15
|
type FrozenProviderTerminal,
|
|
16
16
|
type ProviderAttemptRecord,
|
|
17
17
|
type ReportableProviderOutcome,
|
|
18
18
|
type RoutedRuntimeReporter,
|
|
19
|
-
} from "../runtime/runtime_reporter";
|
|
20
|
-
import type { ProviderKeySource } from "../types";
|
|
19
|
+
} from "../runtime/runtime_reporter.js";
|
|
20
|
+
import type { ProviderKeySource } from "../types.js";
|
|
21
21
|
import {
|
|
22
22
|
reportRoutingUsage,
|
|
23
23
|
type RoutingUsageContext,
|
|
24
|
-
} from "../telemetry/usage";
|
|
25
|
-
import { customerCanceledProviderMessage } from "../runtime/customer_disconnect";
|
|
24
|
+
} from "../telemetry/usage.js";
|
|
25
|
+
import { customerCanceledProviderMessage } from "../runtime/customer_disconnect.js";
|
|
26
26
|
import {
|
|
27
27
|
estimatedCancelUsage,
|
|
28
28
|
partialInteractionOutput,
|
|
29
29
|
type DeliveredOutput,
|
|
30
30
|
type PromptTokenEstimate,
|
|
31
|
-
} from "./cancel_estimate";
|
|
31
|
+
} from "./cancel_estimate.js";
|
|
32
32
|
|
|
33
33
|
// Structurally a subset of ProviderExecution. The narrowing is deliberate: it
|
|
34
34
|
// keeps apiKey and auth out of the finalizer.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { isRecord } from "@mupt-ai/dari-router/policy-engine";
|
|
2
2
|
|
|
3
|
-
import { providerFailureMessage } from "../runtime/provider_stream_outcome";
|
|
4
|
-
import type { ProviderKeySource } from "../types";
|
|
5
|
-
import type { CapturedProviderResponse } from "./response_capture";
|
|
3
|
+
import { providerFailureMessage } from "../runtime/provider_stream_outcome.js";
|
|
4
|
+
import type { ProviderKeySource } from "../types.js";
|
|
5
|
+
import type { CapturedProviderResponse } from "./response_capture.js";
|
|
6
6
|
|
|
7
7
|
export type SubscriptionOAuthProvider = "anthropic_claude_code" | "openai_codex";
|
|
8
8
|
|
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
type RoutingDecision,
|
|
5
5
|
} from "@mupt-ai/dari-router/policy-engine";
|
|
6
6
|
|
|
7
|
-
import type { RoutedDecision } from "../../strategies/route_decision";
|
|
8
|
-
import { isBackgroundRequest } from "../../interaction/types";
|
|
9
|
-
import { HttpError } from "../../http/errors";
|
|
10
|
-
import { assertCreditAvailableBeforeRouting } from "../../telemetry/usage";
|
|
11
|
-
import type { PreparedRoutedCompletion } from "../prepare_routed_completion";
|
|
7
|
+
import type { RoutedDecision } from "../../strategies/route_decision.js";
|
|
8
|
+
import { isBackgroundRequest } from "../../interaction/types.js";
|
|
9
|
+
import { HttpError } from "../../http/errors.js";
|
|
10
|
+
import { assertCreditAvailableBeforeRouting } from "../../telemetry/usage.js";
|
|
11
|
+
import type { PreparedRoutedCompletion } from "../prepare_routed_completion.js";
|
|
12
12
|
import { leaseFallbackDecision } from "../routing_lease.js";
|
|
13
13
|
|
|
14
14
|
// Explicit background classes bypass the selector and every lease path.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { RoutingCandidate, RoutingDecision } from "@mupt-ai/dari-router/policy-engine";
|
|
2
2
|
|
|
3
|
-
import { HttpError } from "../http/errors";
|
|
4
|
-
import { explicitModelId } from "../protocol/input/router_model";
|
|
5
|
-
import type { RoutedDecision } from "../strategies/route_decision";
|
|
6
|
-
import type { PreparedRoutedCompletion } from "./prepare_routed_completion";
|
|
3
|
+
import { HttpError } from "../http/errors.js";
|
|
4
|
+
import { explicitModelId } from "../protocol/input/router_model.js";
|
|
5
|
+
import type { RoutedDecision } from "../strategies/route_decision.js";
|
|
6
|
+
import type { PreparedRoutedCompletion } from "./prepare_routed_completion.js";
|
|
7
7
|
|
|
8
8
|
/* A request for `dari/model/<id>` is served by exactly that enabled model,
|
|
9
9
|
with no selector, lease, or fallback: the user chose it, like picking a
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { isRecord } from "@mupt-ai/dari-router/policy-engine";
|
|
2
2
|
|
|
3
|
-
import { HttpError } from "../../http/errors";
|
|
3
|
+
import { HttpError } from "../../http/errors.js";
|
|
4
4
|
import type {
|
|
5
5
|
AgentRequestClass,
|
|
6
6
|
AgentRequestContext,
|
|
7
7
|
InteractionRequestPurpose,
|
|
8
|
-
} from "../../interaction/types";
|
|
9
|
-
import type { HarnessConversationIdentity } from "./conversation";
|
|
8
|
+
} from "../../interaction/types.js";
|
|
9
|
+
import type { HarnessConversationIdentity } from "./conversation.js";
|
|
10
10
|
|
|
11
11
|
const MAX_ID_CHARS = 200;
|
|
12
12
|
|
|
@@ -3,7 +3,7 @@ export {
|
|
|
3
3
|
scopedHarnessSessionId,
|
|
4
4
|
type HarnessConversationIdentity,
|
|
5
5
|
type HarnessConversationScope,
|
|
6
|
-
} from "./conversation";
|
|
6
|
+
} from "./conversation.js";
|
|
7
7
|
export {
|
|
8
8
|
chatCompletionsConversationIdentity,
|
|
9
9
|
claudeCodeConversationIdentity,
|
|
@@ -11,4 +11,4 @@ export {
|
|
|
11
11
|
codexRequestPurpose,
|
|
12
12
|
codexRequestContext,
|
|
13
13
|
openCodeRequestContext,
|
|
14
|
-
} from "./extract";
|
|
14
|
+
} from "./extract.js";
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import type { CandidatePruningAudit } from "@mupt-ai/dari-router/policy-engine";
|
|
2
2
|
|
|
3
|
-
import { interactionConversationPrefix } from "../context/interaction_fingerprint";
|
|
3
|
+
import { interactionConversationPrefix } from "../context/interaction_fingerprint.js";
|
|
4
4
|
import {
|
|
5
5
|
buildRoutingContext,
|
|
6
6
|
derivePrefixLookupHashes,
|
|
7
7
|
type ImageCapabilityPrunedModel,
|
|
8
8
|
type RoutingContext,
|
|
9
|
-
} from "../context/routing_context";
|
|
10
|
-
import { isBackgroundRequest, type InteractionRequest } from "../interaction/types";
|
|
11
|
-
import { executionProviderForModel } from "../models/execution_provider";
|
|
12
|
-
import { gatewayPlatform, type RequestTags } from "../platform/platform";
|
|
13
|
-
import { resolveRouter } from "../strategies/routing";
|
|
14
|
-
import { RequestReporter, type ReportedCandidatePruning } from "../telemetry/report";
|
|
15
|
-
import { RoutingBillingFinalization } from "../telemetry/billing_finalization";
|
|
16
|
-
import type { ClientHarness, ProviderCredential, ResolvedRouter } from "../types";
|
|
17
|
-
import { requestTags } from "./request_tags";
|
|
18
|
-
import type { RoutedRuntimeReporter } from "./runtime_reporter";
|
|
19
|
-
import type { RoutedProtocol } from "./routed_protocol";
|
|
9
|
+
} from "../context/routing_context.js";
|
|
10
|
+
import { isBackgroundRequest, type InteractionRequest } from "../interaction/types.js";
|
|
11
|
+
import { executionProviderForModel } from "../models/execution_provider.js";
|
|
12
|
+
import { gatewayPlatform, type RequestTags } from "../platform/platform.js";
|
|
13
|
+
import { resolveRouter } from "../strategies/routing.js";
|
|
14
|
+
import { RequestReporter, type ReportedCandidatePruning } from "../telemetry/report.js";
|
|
15
|
+
import { RoutingBillingFinalization } from "../telemetry/billing_finalization.js";
|
|
16
|
+
import type { ClientHarness, ProviderCredential, ResolvedRouter } from "../types.js";
|
|
17
|
+
import { requestTags } from "./request_tags.js";
|
|
18
|
+
import type { RoutedRuntimeReporter } from "./runtime_reporter.js";
|
|
19
|
+
import type { RoutedProtocol } from "./routed_protocol.js";
|
|
20
20
|
import {
|
|
21
21
|
scopedHarnessConversationId,
|
|
22
22
|
scopedHarnessSessionId,
|
|
23
23
|
type HarnessConversationIdentity,
|
|
24
|
-
} from "./harness_identity";
|
|
24
|
+
} from "./harness_identity/index.js";
|
|
25
25
|
|
|
26
26
|
export type PreparedRoutedCompletion = {
|
|
27
27
|
requestId: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isRecord } from "@mupt-ai/dari-router/policy-engine";
|
|
2
|
-
import type { InteractionOutput } from "../interaction/types";
|
|
3
|
-
import { scrubSecrets } from "../telemetry/scrub";
|
|
2
|
+
import type { InteractionOutput } from "../interaction/types.js";
|
|
3
|
+
import { scrubSecrets } from "../telemetry/scrub.js";
|
|
4
4
|
|
|
5
5
|
export type ProviderStreamOutcome =
|
|
6
6
|
| {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { HttpError } from "../http/errors";
|
|
2
|
-
import type { RequestTags } from "../platform/platform";
|
|
1
|
+
import { HttpError } from "../http/errors.js";
|
|
2
|
+
import type { RequestTags } from "../platform/platform.js";
|
|
3
3
|
|
|
4
4
|
const TAGS_MAX_CHARS = 2048;
|
|
5
5
|
const TAGS_MAX_COUNT = 32;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
|
|
3
|
-
import { isBackgroundRequest, type InteractionRequest } from "../interaction/types";
|
|
4
|
-
import { explicitModelId } from "../protocol/input/router_model";
|
|
5
|
-
import { captureRequestError } from "../observability/errors";
|
|
6
|
-
import type { SelectorBackend } from "../strategies/routing";
|
|
7
|
-
import type { ClientHarness } from "../types";
|
|
8
|
-
import { assertAutoroutingAllowed, assertCreditAvailableBeforeRouting, routerSelectsModels } from "../telemetry/usage";
|
|
9
|
-
import type { HarnessConversationIdentity } from "./harness_identity";
|
|
10
|
-
import { CustomerDisconnectedError } from "./customer_disconnect";
|
|
11
|
-
import { prepareRoutedCompletion } from "./prepare_routed_completion";
|
|
12
|
-
import type { RoutedProtocol } from "./routed_protocol";
|
|
13
|
-
import { runPreparedRoutedCompletion } from "./routed_runtime";
|
|
3
|
+
import { isBackgroundRequest, type InteractionRequest } from "../interaction/types.js";
|
|
4
|
+
import { explicitModelId } from "../protocol/input/router_model.js";
|
|
5
|
+
import { captureRequestError } from "../observability/errors.js";
|
|
6
|
+
import type { SelectorBackend } from "../strategies/routing.js";
|
|
7
|
+
import type { ClientHarness } from "../types.js";
|
|
8
|
+
import { assertAutoroutingAllowed, assertCreditAvailableBeforeRouting, routerSelectsModels } from "../telemetry/usage.js";
|
|
9
|
+
import type { HarnessConversationIdentity } from "./harness_identity/index.js";
|
|
10
|
+
import { CustomerDisconnectedError } from "./customer_disconnect.js";
|
|
11
|
+
import { prepareRoutedCompletion } from "./prepare_routed_completion.js";
|
|
12
|
+
import type { RoutedProtocol } from "./routed_protocol.js";
|
|
13
|
+
import { runPreparedRoutedCompletion } from "./routed_runtime.js";
|
|
14
14
|
|
|
15
15
|
export async function handleRoutedCompletion(args: {
|
|
16
16
|
request: Request;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RoutingDecision } from "@mupt-ai/dari-router/policy-engine";
|
|
2
|
-
import type { InteractionOutput, InteractionRequest, ProviderIdentity } from "../interaction/types";
|
|
3
|
-
import type { ProviderStreamOutcome } from "./provider_stream_outcome";
|
|
2
|
+
import type { InteractionOutput, InteractionRequest, ProviderIdentity } from "../interaction/types.js";
|
|
3
|
+
import type { ProviderStreamOutcome } from "./provider_stream_outcome.js";
|
|
4
4
|
|
|
5
5
|
export type RoutedCompletionResponseArgs = {
|
|
6
6
|
id: string;
|
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
type RoutingDecision,
|
|
9
9
|
} from "@mupt-ai/dari-router/policy-engine";
|
|
10
10
|
|
|
11
|
-
import { buildRoutingContext } from "../context/routing_context";
|
|
12
|
-
import type { InteractionRequest } from "../interaction/types";
|
|
11
|
+
import { buildRoutingContext } from "../context/routing_context.js";
|
|
12
|
+
import type { InteractionRequest } from "../interaction/types.js";
|
|
13
13
|
import {
|
|
14
14
|
completeNonStreaming,
|
|
15
15
|
executeNonStreaming,
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
prepareStreamingExecution,
|
|
18
18
|
type CompletedNonStreamingExecution,
|
|
19
19
|
type ProviderChoice,
|
|
20
|
-
} from "../providers/execution";
|
|
20
|
+
} from "../providers/execution.js";
|
|
21
21
|
import {
|
|
22
22
|
prepareProviderExecution,
|
|
23
23
|
startProviderCompletion,
|
|
@@ -25,16 +25,16 @@ import {
|
|
|
25
25
|
type ProviderExecution,
|
|
26
26
|
type StartedCompletion,
|
|
27
27
|
type StartedStream,
|
|
28
|
-
} from "../providers/provider_call";
|
|
29
|
-
import type { SelectorBackend } from "../strategies/routing";
|
|
30
|
-
import { routeDecision, type RoutedDecision } from "../strategies/route_decision";
|
|
31
|
-
import { executionProviderForModel } from "../models/execution_provider";
|
|
32
|
-
import { trackBackgroundTelemetry } from "../telemetry/background";
|
|
33
|
-
import { estimateBenchmarkReplay } from "../telemetry/benchmark_replay";
|
|
34
|
-
import { buildCompletedPrefixHit } from "../telemetry/prefix_state";
|
|
35
|
-
import { scrubSecrets } from "../telemetry/scrub";
|
|
36
|
-
import type { ResolvedRouter } from "../types";
|
|
37
|
-
import type { PreparedRoutedCompletion } from "./prepare_routed_completion";
|
|
28
|
+
} from "../providers/provider_call.js";
|
|
29
|
+
import type { SelectorBackend } from "../strategies/routing.js";
|
|
30
|
+
import { routeDecision, type RoutedDecision } from "../strategies/route_decision.js";
|
|
31
|
+
import { executionProviderForModel } from "../models/execution_provider.js";
|
|
32
|
+
import { trackBackgroundTelemetry } from "../telemetry/background.js";
|
|
33
|
+
import { estimateBenchmarkReplay } from "../telemetry/benchmark_replay.js";
|
|
34
|
+
import { buildCompletedPrefixHit } from "../telemetry/prefix_state.js";
|
|
35
|
+
import { scrubSecrets } from "../telemetry/scrub.js";
|
|
36
|
+
import type { ResolvedRouter } from "../types.js";
|
|
37
|
+
import type { PreparedRoutedCompletion } from "./prepare_routed_completion.js";
|
|
38
38
|
import { auxiliaryDecision } from "./claude_code/auxiliary_routing.js";
|
|
39
39
|
import { explicitModelDecision, strictModelDecision } from "./explicit_model.js";
|
|
40
40
|
import {
|
|
@@ -47,12 +47,12 @@ import {
|
|
|
47
47
|
prefetchNextLease,
|
|
48
48
|
selectorNegotiatesLeases,
|
|
49
49
|
} from "./routing_lease.js";
|
|
50
|
-
import type { RoutedProtocol } from "./routed_protocol";
|
|
50
|
+
import type { RoutedProtocol } from "./routed_protocol.js";
|
|
51
51
|
import {
|
|
52
52
|
createExperimentRoutedRuntimeReporter,
|
|
53
53
|
type RoutedRuntimeReporter,
|
|
54
|
-
} from "./runtime_reporter";
|
|
55
|
-
import { HttpError } from "../http/errors";
|
|
54
|
+
} from "./runtime_reporter.js";
|
|
55
|
+
import { HttpError } from "../http/errors.js";
|
|
56
56
|
|
|
57
57
|
type SpeculativeExecution = {
|
|
58
58
|
decision: RoutingDecision;
|
|
@@ -113,12 +113,12 @@ export type {
|
|
|
113
113
|
SelectorAdapterArgs,
|
|
114
114
|
SelectorBackend,
|
|
115
115
|
SelectorRun,
|
|
116
|
-
} from "../strategies/routing";
|
|
116
|
+
} from "../strategies/routing.js";
|
|
117
117
|
export type {
|
|
118
118
|
ExperimentRoutedRuntimeReporter,
|
|
119
119
|
RoutedRuntimeReporter,
|
|
120
|
-
} from "./runtime_reporter";
|
|
121
|
-
export { createExperimentRoutedRuntimeReporter } from "./runtime_reporter";
|
|
120
|
+
} from "./runtime_reporter.js";
|
|
121
|
+
export { createExperimentRoutedRuntimeReporter } from "./runtime_reporter.js";
|
|
122
122
|
|
|
123
123
|
export async function runPreparedRoutedCompletion(args: {
|
|
124
124
|
prepared: PreparedRoutedCompletion;
|
|
@@ -709,6 +709,7 @@ const inProcessProtocol: RoutedProtocol = {
|
|
|
709
709
|
selected_model: args.routing.selectedModel,
|
|
710
710
|
reasoning_effort: args.routing.reasoningEffort,
|
|
711
711
|
reason: args.routing.reason,
|
|
712
|
+
request_id: args.id,
|
|
712
713
|
...(args.conversationId ? { conversation_id: args.conversationId } : {}),
|
|
713
714
|
},
|
|
714
715
|
}),
|
|
@@ -6,16 +6,16 @@ import {
|
|
|
6
6
|
type RoutingDecision,
|
|
7
7
|
} from "@mupt-ai/dari-router/policy-engine";
|
|
8
8
|
|
|
9
|
-
import { deriveFallbackDecision } from "../strategies/fallback_decision";
|
|
10
|
-
import { executionProviderForModel } from "../models/execution_provider";
|
|
11
|
-
import type { SelectorBackend } from "../strategies/routing";
|
|
9
|
+
import { deriveFallbackDecision } from "../strategies/fallback_decision.js";
|
|
10
|
+
import { executionProviderForModel } from "../models/execution_provider.js";
|
|
11
|
+
import type { SelectorBackend } from "../strategies/routing.js";
|
|
12
12
|
import {
|
|
13
13
|
routeDecision,
|
|
14
14
|
type RoutedDecision,
|
|
15
|
-
} from "../strategies/route_decision";
|
|
16
|
-
import { reportPendingLease } from "../telemetry/prefix_state";
|
|
17
|
-
import { scrubSecrets } from "../telemetry/scrub";
|
|
18
|
-
import type { PreparedRoutedCompletion } from "./prepare_routed_completion";
|
|
15
|
+
} from "../strategies/route_decision.js";
|
|
16
|
+
import { reportPendingLease } from "../telemetry/prefix_state.js";
|
|
17
|
+
import { scrubSecrets } from "../telemetry/scrub.js";
|
|
18
|
+
import type { PreparedRoutedCompletion } from "./prepare_routed_completion.js";
|
|
19
19
|
|
|
20
20
|
export type RoutingLeaseDecision = {
|
|
21
21
|
decision: RoutingDecision;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { RoutingDecision } from "@mupt-ai/dari-router/policy-engine";
|
|
2
|
-
import type { InteractionOutput } from "../interaction/types";
|
|
3
|
-
import type { SelectorRun } from "../strategies/routing";
|
|
4
|
-
import type { ProviderKeySource } from "../types";
|
|
2
|
+
import type { InteractionOutput } from "../interaction/types.js";
|
|
3
|
+
import type { SelectorRun } from "../strategies/routing.js";
|
|
4
|
+
import type { ProviderKeySource } from "../types.js";
|
|
5
5
|
|
|
6
6
|
export type ReportedProviderExecution = {
|
|
7
7
|
provider: string;
|
package/src/self_host/main.ts
CHANGED
|
@@ -3,18 +3,18 @@ import { chmodSync, existsSync } from "node:fs";
|
|
|
3
3
|
import { Database } from "bun:sqlite";
|
|
4
4
|
import { builtinModels } from "@mupt-ai/pi-ai/providers/all";
|
|
5
5
|
|
|
6
|
-
import { bearerToken } from "../http/auth";
|
|
7
|
-
import { errorResponse, HttpError } from "../http/errors";
|
|
8
|
-
import { createRequestHandler } from "../http/handler";
|
|
9
|
-
import { installShutdownHandlers, startServer } from "../http/serve";
|
|
10
|
-
import { createAutoRoutingSelectorBackend } from "../strategies/auto_routing_selector";
|
|
11
|
-
import { createPrioritySelectorBackend } from "../strategies/priority_selector";
|
|
12
|
-
import type { SelectorBackend } from "../strategies/routing";
|
|
13
|
-
import { loadGatewayConfig } from "./config";
|
|
14
|
-
import { createSelfHostedPlatform } from "./platform";
|
|
15
|
-
import { gatewayKeyIndex } from "./resolve";
|
|
16
|
-
import { PrefixStore } from "./prefix_store";
|
|
17
|
-
import { handleSubscriptionRequest, SubscriptionStore } from "./subscriptions";
|
|
6
|
+
import { bearerToken } from "../http/auth.js";
|
|
7
|
+
import { errorResponse, HttpError } from "../http/errors.js";
|
|
8
|
+
import { createRequestHandler } from "../http/handler.js";
|
|
9
|
+
import { installShutdownHandlers, startServer } from "../http/serve.js";
|
|
10
|
+
import { createAutoRoutingSelectorBackend } from "../strategies/auto_routing_selector.js";
|
|
11
|
+
import { createPrioritySelectorBackend } from "../strategies/priority_selector.js";
|
|
12
|
+
import type { SelectorBackend } from "../strategies/routing.js";
|
|
13
|
+
import { loadGatewayConfig } from "./config.js";
|
|
14
|
+
import { createSelfHostedPlatform } from "./platform.js";
|
|
15
|
+
import { gatewayKeyIndex } from "./resolve.js";
|
|
16
|
+
import { PrefixStore } from "./prefix_store.js";
|
|
17
|
+
import { handleSubscriptionRequest, SubscriptionStore } from "./subscriptions/index.js";
|
|
18
18
|
|
|
19
19
|
const SUBSCRIPTION_ROUTES = "/v1/organizations/current/credentials";
|
|
20
20
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { errorCode } from "../http/errors";
|
|
2
|
-
import type { GatewayPlatform } from "../platform/platform";
|
|
3
|
-
import type { PrefixStore } from "./prefix_store";
|
|
4
|
-
import { resolveSelfHostedRouter, type SelfHostedResolverDeps } from "./resolve";
|
|
5
|
-
import type { SubscriptionStore } from "./subscriptions";
|
|
1
|
+
import { errorCode } from "../http/errors.js";
|
|
2
|
+
import type { GatewayPlatform } from "../platform/platform.js";
|
|
3
|
+
import type { PrefixStore } from "./prefix_store.js";
|
|
4
|
+
import { resolveSelfHostedRouter, type SelfHostedResolverDeps } from "./resolve.js";
|
|
5
|
+
import type { SubscriptionStore } from "./subscriptions/index.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* The self-hosted platform: routers from the config file, subscriptions and
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
import type { Database } from "bun:sqlite";
|
|
15
15
|
import type { ReasoningEffort, RouterPrefixHit } from "@mupt-ai/dari-router/policy-engine";
|
|
16
16
|
|
|
17
|
-
import type { PendingLeaseWrite, PrefixStateWrite } from "../platform/platform";
|
|
18
|
-
import { ROUTING_PREFIX_HASHES_MAX_COUNT } from "../platform/routing_contract";
|
|
17
|
+
import type { PendingLeaseWrite, PrefixStateWrite } from "../platform/platform.js";
|
|
18
|
+
import { ROUTING_PREFIX_HASHES_MAX_COUNT } from "../platform/routing_contract.js";
|
|
19
19
|
|
|
20
20
|
// Resolve returns entries up to this age so a continuation after a pause still
|
|
21
21
|
// recovers its conversation id and previous decision; the runtime itself
|
package/src/self_host/resolve.ts
CHANGED
|
@@ -7,22 +7,22 @@ import {
|
|
|
7
7
|
type RouterModelPrice,
|
|
8
8
|
type RouterPrefixHit,
|
|
9
9
|
} from "@mupt-ai/dari-router/policy-engine";
|
|
10
|
-
import { HttpError } from "../http/errors";
|
|
11
|
-
import type { ResolveRouterRequest } from "../platform/platform";
|
|
12
|
-
import { registeredModelPrice } from "../providers/pi";
|
|
10
|
+
import { HttpError } from "../http/errors.js";
|
|
11
|
+
import type { ResolveRouterRequest } from "../platform/platform.js";
|
|
12
|
+
import { registeredModelPrice } from "../providers/pi.js";
|
|
13
13
|
import type {
|
|
14
14
|
ProviderKeySource,
|
|
15
15
|
ResolvedRouter,
|
|
16
16
|
ResolvedRouterModelConfig,
|
|
17
|
-
} from "../types";
|
|
18
|
-
import type { GatewayConfig, RouterConfig } from "./config";
|
|
17
|
+
} from "../types.js";
|
|
18
|
+
import type { GatewayConfig, RouterConfig } from "./config.js";
|
|
19
19
|
import {
|
|
20
20
|
freshAccessToken,
|
|
21
21
|
type OAuthFetch,
|
|
22
22
|
type SubscriptionCredential,
|
|
23
23
|
type SubscriptionProvider,
|
|
24
24
|
type SubscriptionStore,
|
|
25
|
-
} from "./subscriptions";
|
|
25
|
+
} from "./subscriptions/index.js";
|
|
26
26
|
|
|
27
27
|
// A self-hosted gateway is one tenant; these stand in for the hosted
|
|
28
28
|
// organization and the user a personal subscription belongs to.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { refreshOAuth, type OAuthFetch } from "./oauth";
|
|
2
|
-
import type { SubscriptionCredential, SubscriptionStore } from "./store";
|
|
1
|
+
import { refreshOAuth, type OAuthFetch } from "./oauth.js";
|
|
2
|
+
import type { SubscriptionCredential, SubscriptionStore } from "./store.js";
|
|
3
3
|
|
|
4
4
|
const REFRESH_MARGIN_MS = 5 * 60_000;
|
|
5
5
|
|
|
@@ -12,8 +12,8 @@ import {
|
|
|
12
12
|
startOAuth,
|
|
13
13
|
type OAuthFetch,
|
|
14
14
|
type SubscriptionProvider,
|
|
15
|
-
} from "./oauth";
|
|
16
|
-
import { isHeld, type SubscriptionCredential, type SubscriptionStore } from "./store";
|
|
15
|
+
} from "./oauth.js";
|
|
16
|
+
import { isHeld, type SubscriptionCredential, type SubscriptionStore } from "./store.js";
|
|
17
17
|
|
|
18
18
|
export type SubscriptionHttpDeps = {
|
|
19
19
|
store: SubscriptionStore;
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
* `store.markUnavailable` holds that subscription until its reset and says
|
|
19
19
|
* whether another one can serve the retry.
|
|
20
20
|
*/
|
|
21
|
-
export { freshAccessToken } from "./access";
|
|
22
|
-
export { handleSubscriptionRequest, type SubscriptionHttpDeps } from "./http";
|
|
21
|
+
export { freshAccessToken } from "./access.js";
|
|
22
|
+
export { handleSubscriptionRequest, type SubscriptionHttpDeps } from "./http.js";
|
|
23
23
|
export {
|
|
24
24
|
CODEX_APPROVAL_PENDING,
|
|
25
25
|
SUBSCRIPTION_PROVIDERS,
|
|
@@ -34,10 +34,10 @@ export {
|
|
|
34
34
|
type OAuthOptions,
|
|
35
35
|
type OAuthTokens,
|
|
36
36
|
type SubscriptionProvider,
|
|
37
|
-
} from "./oauth";
|
|
37
|
+
} from "./oauth.js";
|
|
38
38
|
export {
|
|
39
39
|
SubscriptionStore,
|
|
40
40
|
isHeld,
|
|
41
41
|
type PendingOAuthSession,
|
|
42
42
|
type SubscriptionCredential,
|
|
43
|
-
} from "./store";
|
|
43
|
+
} from "./store.js";
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
import type { Database } from "bun:sqlite";
|
|
14
14
|
import { randomBytes, randomUUID } from "node:crypto";
|
|
15
15
|
|
|
16
|
-
import type { OAuthTokens, SubscriptionProvider } from "./oauth";
|
|
16
|
+
import type { OAuthTokens, SubscriptionProvider } from "./oauth.js";
|
|
17
17
|
|
|
18
18
|
export type SubscriptionCredential = {
|
|
19
19
|
id: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { parseSelectorDecision } from "@mupt-ai/dari-router/policy-engine";
|
|
2
|
-
import { HttpError } from "../http/errors";
|
|
3
|
-
import type { SelectorBackend } from "./routing";
|
|
2
|
+
import { HttpError } from "../http/errors.js";
|
|
3
|
+
import type { SelectorBackend } from "./routing.js";
|
|
4
4
|
|
|
5
5
|
export const DARI_AUTO_ROUTING_ENDPOINT = "https://routing.dari.dev/v1/auto-router";
|
|
6
6
|
// Same selector identity and input budget as `createAutoRouter` in
|