@danypops/jittor 0.16.2 → 0.17.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/README.md +38 -13
- package/docs/COMPACTION_EFFECTIVENESS.md +34 -0
- package/docs/CONTEXT_SNAPSHOTS.md +53 -0
- package/docs/MODEL_CATALOG.md +43 -0
- package/docs/OTLP_EXPORT.md +63 -0
- package/docs/PROVIDER_RESEARCH.md +1 -1
- package/docs/TOKEN_MEASUREMENT.md +53 -0
- package/docs/USAGE_BACKFILL.md +35 -0
- package/package.json +4 -3
- package/src/{providers/anthropic-contracts.ts → anthropic/rate-limits.ts} +1 -1
- package/src/{adapters/artificial-analysis-direct-source.ts → artificial-analysis/benchmark-source.ts} +3 -3
- package/src/cli-commands/backfill.ts +51 -0
- package/src/cli-commands/benchmarks.ts +4 -4
- package/src/cli-commands/catalog.ts +123 -0
- package/src/cli-commands/compaction.ts +1 -1
- package/src/cli-commands/context.ts +77 -4
- package/src/cli-commands/export.ts +30 -0
- package/src/cli-commands/metrics.ts +8 -2
- package/src/cli-commands/op.ts +1 -1
- package/src/cli-commands/route-args.ts +2 -2
- package/src/cli-commands/router.ts +2 -2
- package/src/cli-commands/support.ts +2 -2
- package/src/cli.ts +54 -21
- package/src/{providers/codex-contracts.ts → codex/contracts.ts} +1 -1
- package/src/codex/source.ts +53 -0
- package/src/{providers/codex.ts → codex/telemetry.ts} +2 -2
- package/src/constants.ts +18 -0
- package/src/daemon.ts +53 -23
- package/src/{providers/google-vertex-budget-contracts.ts → google-vertex/budget-contracts.ts} +3 -3
- package/src/{providers/google-vertex-budget.ts → google-vertex/budget-telemetry.ts} +6 -6
- package/src/{providers/google-vertex-contracts.ts → google-vertex/failures.ts} +1 -1
- package/src/google-vertex/source.ts +35 -0
- package/src/index.ts +135 -55
- package/src/{adapters/lmarena-hf-source.ts → lmarena/benchmark-source.ts} +3 -3
- package/src/observability/budget.ts +14 -0
- package/src/observability/context-delta.ts +309 -0
- package/src/{domain → observability}/context-hub.ts +19 -2
- package/src/observability/context-snapshot-history.ts +281 -0
- package/src/{domain → observability}/context-telemetry.ts +232 -4
- package/src/observability/model-identity.ts +42 -0
- package/src/{domain → observability}/model-observation.ts +26 -11
- package/src/{ports/metric-store.ts → observability/store.ts} +2 -2
- package/src/{ports → observability}/telemetry-source.ts +2 -2
- package/src/observability/token-measurement.ts +194 -0
- package/src/observability/usage-import.ts +122 -0
- package/src/openai/token-counter.ts +63 -0
- package/src/{adapters/openrouter-benchmark-source.ts → openrouter/benchmark-source.ts} +3 -3
- package/src/{providers/openrouter-contracts.ts → openrouter/contracts.ts} +1 -1
- package/src/{adapters/openrouter-design-arena-source.ts → openrouter/design-arena-source.ts} +4 -4
- package/src/openrouter/source.ts +20 -0
- package/src/{providers/openrouter.ts → openrouter/telemetry.ts} +2 -2
- package/src/{domain → optimization/model-selection}/benchmark.ts +9 -27
- package/src/optimization/model-selection/catalog-store.ts +97 -0
- package/src/optimization/model-selection/catalog.ts +478 -0
- package/src/{ports/benchmark-controller.ts → optimization/model-selection/controller.ts} +1 -1
- package/src/{adapters/metric-benchmark-store.ts → optimization/model-selection/observation-store.ts} +5 -5
- package/src/{domain/model-ranking-service.ts → optimization/model-selection/ranker.ts} +6 -12
- package/src/{domain/model-ranking.ts → optimization/model-selection/ranking.ts} +8 -2
- package/src/{ports/benchmark-source.ts → optimization/model-selection/source.ts} +1 -1
- package/src/{ports/benchmark-store.ts → optimization/model-selection/store.ts} +1 -1
- package/src/{domain/codex-recovery.ts → optimization/recovery/codex.ts} +1 -1
- package/src/{ports/router-controller.ts → optimization/routing/controller.ts} +1 -1
- package/src/{policy.ts → optimization/routing/policy.ts} +4 -14
- package/src/{router.ts → optimization/routing/router.ts} +4 -10
- package/src/otlp/exporter.ts +354 -0
- package/src/pi/session-usage-source.ts +203 -0
- package/src/{session-identity-service.ts → sessions/identity.ts} +2 -2
- package/src/{operations/session-scope.ts → sessions/router-authorization.ts} +1 -1
- package/src/{db.ts → sqlite/database.ts} +14 -1
- package/src/{adapters/sqlite-metric-store.ts → sqlite/metric-store.ts} +4 -4
- package/src/{adapters/sqlite-session-identity-store.ts → sqlite/session-store.ts} +1 -1
- package/src/sqlite/usage-import-store.ts +133 -0
- package/src/telemetry-export/exporter.ts +84 -0
- package/src/{operations → vehicle}/benchmark-operations.ts +3 -3
- package/src/vehicle/catalog-operations.ts +10 -0
- package/src/{client.ts → vehicle/client.ts} +1 -1
- package/src/{operations → vehicle}/context-operations.ts +13 -5
- package/src/vehicle/export-operations.ts +12 -0
- package/src/{operations/metrics-operations.ts → vehicle/metric-operations.ts} +4 -4
- package/src/{operations → vehicle}/model-ranking-operations.ts +3 -3
- package/src/{vehicle-registration.ts → vehicle/registration.ts} +14 -4
- package/src/{operations/router-operations.ts → vehicle/routing-operations.ts} +4 -4
- package/src/{service.ts → vehicle/service.ts} +108 -26
- package/src/{operations/session-identity-operations.ts → vehicle/session-operations.ts} +3 -3
- package/src/vehicle/usage-import-operations.ts +10 -0
- package/src/providers/telemetry-sources.ts +0 -108
- /package/src/{providers/google-adc-auth.ts → google-vertex/auth.ts} +0 -0
- /package/src/{domain → observability}/metric.ts +0 -0
- /package/src/{domain → observability}/task-cost.ts +0 -0
- /package/src/{domain → observability}/task-focus.ts +0 -0
- /package/src/{domain → observability}/usage.ts +0 -0
- /package/src/{config.ts → optimization/routing/config.ts} +0 -0
- /package/src/{ports/session-identity-store.ts → sessions/store.ts} +0 -0
- /package/src/{operations/types.ts → vehicle/operation-types.ts} +0 -0
package/src/daemon.ts
CHANGED
|
@@ -1,27 +1,37 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
1
2
|
import { type RunningDaemon, startDaemon as startDaemonKit } from "@danypops/vehicle-server/daemon";
|
|
2
|
-
import { ArtificialAnalysisDirectSource } from "./
|
|
3
|
-
import {
|
|
4
|
-
import { MetricBenchmarkStore } from "./adapters/metric-benchmark-store.ts";
|
|
5
|
-
import { OpenRouterBenchmarkSource } from "./adapters/openrouter-benchmark-source.ts";
|
|
6
|
-
import { OpenRouterDesignArenaSource } from "./adapters/openrouter-design-arena-source.ts";
|
|
7
|
-
import { SQLiteMetricStore } from "./adapters/sqlite-metric-store.ts";
|
|
8
|
-
import { SQLiteSessionIdentityStore } from "./adapters/sqlite-session-identity-store.ts";
|
|
9
|
-
import { DEFAULT_POLICY, UNCONFIGURED_ROUTE } from "./config.ts";
|
|
3
|
+
import { ArtificialAnalysisDirectSource } from "./artificial-analysis/benchmark-source.ts";
|
|
4
|
+
import { CodexTelemetrySource } from "./codex/source.ts";
|
|
10
5
|
import { MAINTENANCE_INTERVAL_MS, TELEMETRY_POLL_INTERVAL_MS } from "./constants.ts";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
6
|
+
import { createGoogleAdcTokenProvider } from "./google-vertex/auth.ts";
|
|
7
|
+
import { GOOGLE_PUBSUB_READONLY_SCOPE } from "./google-vertex/budget-telemetry.ts";
|
|
8
|
+
import type { GoogleVertexMetricSource } from "./google-vertex/failures.ts";
|
|
9
|
+
import { GoogleVertexBudgetTelemetrySource } from "./google-vertex/source.ts";
|
|
10
|
+
import { LmArenaHfSource } from "./lmarena/benchmark-source.ts";
|
|
14
11
|
import { logEvent, logger } from "./log.ts";
|
|
15
|
-
import type {
|
|
16
|
-
import
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
12
|
+
import type { TelemetrySource } from "./observability/telemetry-source.ts";
|
|
13
|
+
import { HistoricalUsageImporter } from "./observability/usage-import.ts";
|
|
14
|
+
import { OpenRouterBenchmarkSource } from "./openrouter/benchmark-source.ts";
|
|
15
|
+
import { OpenRouterDesignArenaSource } from "./openrouter/design-arena-source.ts";
|
|
16
|
+
import { OpenRouterTelemetrySource } from "./openrouter/source.ts";
|
|
17
|
+
import { BenchmarkCatalog } from "./optimization/model-selection/benchmark.ts";
|
|
18
|
+
import { ModelCatalog, type ModelCatalogSource, ModelsDevCatalogSource } from "./optimization/model-selection/catalog.ts";
|
|
19
|
+
import { MetricModelCatalogStore } from "./optimization/model-selection/catalog-store.ts";
|
|
20
|
+
import { MetricBenchmarkStore } from "./optimization/model-selection/observation-store.ts";
|
|
21
|
+
import { EvidenceModelRanker } from "./optimization/model-selection/ranker.ts";
|
|
22
|
+
import type { BenchmarkSource } from "./optimization/model-selection/source.ts";
|
|
23
|
+
import { DEFAULT_POLICY, UNCONFIGURED_ROUTE } from "./optimization/routing/config.ts";
|
|
24
|
+
import { JittorRouter } from "./optimization/routing/router.ts";
|
|
25
|
+
import { otlpExporterFromEnvironment } from "./otlp/exporter.ts";
|
|
26
|
+
import { PiSessionUsageSource } from "./pi/session-usage-source.ts";
|
|
27
|
+
import { SessionIdentity } from "./sessions/identity.ts";
|
|
28
|
+
import { openJittorDb } from "./sqlite/database.ts";
|
|
29
|
+
import { SQLiteMetricStore } from "./sqlite/metric-store.ts";
|
|
30
|
+
import { SQLiteSessionIdentityStore } from "./sqlite/session-store.ts";
|
|
31
|
+
import { SQLiteUsageImportStore } from "./sqlite/usage-import-store.ts";
|
|
24
32
|
import { ensureAuthToken, type JittorPaths, resolveJittorPaths } from "./state.ts";
|
|
33
|
+
import { DisabledObservationExporter, ExportingMetricStore } from "./telemetry-export/exporter.ts";
|
|
34
|
+
import { createApp, JittorService } from "./vehicle/service.ts";
|
|
25
35
|
|
|
26
36
|
export type { RunningDaemon } from "@danypops/vehicle-server/daemon";
|
|
27
37
|
|
|
@@ -47,6 +57,11 @@ function googleVertexMetricSource(value: string | undefined): GoogleVertexMetric
|
|
|
47
57
|
throw new Error("JITTOR_GOOGLE_VERTEX_BUDGET_SOURCE must be google-vertex or anthropic-vertex");
|
|
48
58
|
}
|
|
49
59
|
|
|
60
|
+
export function modelCatalogSourceFromEnvironment(env: Record<string, string | undefined> = process.env): ModelCatalogSource | undefined {
|
|
61
|
+
if (env.JITTOR_MODELS_DEV_CATALOG !== "1") return undefined;
|
|
62
|
+
return new ModelsDevCatalogSource({ sourceUrl: env.JITTOR_MODELS_DEV_CATALOG_URL });
|
|
63
|
+
}
|
|
64
|
+
|
|
50
65
|
export function telemetrySourcesFromEnvironment(env: Record<string, string | undefined> = process.env): TelemetrySource[] {
|
|
51
66
|
const sources: TelemetrySource[] = [];
|
|
52
67
|
const codexAuthFile = env.JITTOR_CODEX_AUTH_FILE;
|
|
@@ -80,13 +95,19 @@ export async function startDaemon(
|
|
|
80
95
|
): Promise<RunningDaemon> {
|
|
81
96
|
const token = ensureAuthToken(paths);
|
|
82
97
|
const db = openJittorDb(paths.database);
|
|
83
|
-
const
|
|
98
|
+
const localMetrics = new SQLiteMetricStore(db);
|
|
99
|
+
const exporter = otlpExporterFromEnvironment(env) ?? new DisabledObservationExporter();
|
|
100
|
+
const metrics = new ExportingMetricStore(localMetrics, exporter);
|
|
84
101
|
const sessionIdentity = new SessionIdentity(new SQLiteSessionIdentityStore(db));
|
|
85
102
|
const sources = telemetrySourcesFromEnvironment(env);
|
|
86
103
|
const benchmarkSources = benchmarkSourcesFromEnvironment(env);
|
|
87
104
|
const benchmarkStore = new MetricBenchmarkStore(metrics);
|
|
88
105
|
const benchmarks = new BenchmarkCatalog(benchmarkStore, benchmarkSources);
|
|
106
|
+
const catalogSource = modelCatalogSourceFromEnvironment(env);
|
|
107
|
+
const catalog = new ModelCatalog(new MetricModelCatalogStore(localMetrics), catalogSource);
|
|
89
108
|
const modelRanker = new EvidenceModelRanker(benchmarkStore, metrics);
|
|
109
|
+
const sessionsRoot = env.JITTOR_PI_SESSIONS_DIR ?? join(env.HOME ?? process.env.HOME ?? "", ".pi", "agent", "sessions");
|
|
110
|
+
const usageImporter = new HistoricalUsageImporter(new PiSessionUsageSource(sessionsRoot), new SQLiteUsageImportStore(db));
|
|
90
111
|
const router = new JittorRouter({
|
|
91
112
|
metrics,
|
|
92
113
|
sources,
|
|
@@ -94,7 +115,7 @@ export async function startDaemon(
|
|
|
94
115
|
routes: [],
|
|
95
116
|
currentRoute: UNCONFIGURED_ROUTE,
|
|
96
117
|
});
|
|
97
|
-
const service = new JittorService(metrics, router, benchmarks, modelRanker, sessionIdentity);
|
|
118
|
+
const service = new JittorService(metrics, router, benchmarks, modelRanker, sessionIdentity, undefined, catalog, usageImporter, exporter);
|
|
98
119
|
|
|
99
120
|
const daemon = await startDaemonKit({
|
|
100
121
|
daemonLabel: "Jittor",
|
|
@@ -116,6 +137,13 @@ export async function startDaemon(
|
|
|
116
137
|
await benchmarks.refresh().catch((error) => reportMaintenanceFailure("benchmark_refresh_failed", error));
|
|
117
138
|
},
|
|
118
139
|
},
|
|
140
|
+
{
|
|
141
|
+
name: "catalog-refresh",
|
|
142
|
+
intervalMs: MAINTENANCE_INTERVAL_MS,
|
|
143
|
+
run: async () => {
|
|
144
|
+
await catalog.refresh().catch((error) => reportMaintenanceFailure("catalog_refresh_failed", error));
|
|
145
|
+
},
|
|
146
|
+
},
|
|
119
147
|
{
|
|
120
148
|
name: "telemetry-poll",
|
|
121
149
|
intervalMs: TELEMETRY_POLL_INTERVAL_MS,
|
|
@@ -124,13 +152,15 @@ export async function startDaemon(
|
|
|
124
152
|
},
|
|
125
153
|
},
|
|
126
154
|
],
|
|
127
|
-
onShutdown: () => {
|
|
155
|
+
onShutdown: async () => {
|
|
156
|
+
await exporter.shutdown();
|
|
128
157
|
service.close();
|
|
129
158
|
},
|
|
130
159
|
});
|
|
131
160
|
|
|
132
161
|
if (sources.length > 0) router.poll().catch((error) => reportMaintenanceFailure("telemetry_poll_failed", error));
|
|
133
162
|
if (benchmarkSources.length > 0) benchmarks.refresh().catch((error) => reportMaintenanceFailure("benchmark_refresh_failed", error));
|
|
163
|
+
if (catalogSource) catalog.refresh().catch((error) => reportMaintenanceFailure("catalog_refresh_failed", error));
|
|
134
164
|
|
|
135
165
|
return daemon;
|
|
136
166
|
}
|
package/src/{providers/google-vertex-budget-contracts.ts → google-vertex/budget-contracts.ts}
RENAMED
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
GOOGLE_VERTEX_BUDGET_DISPLAY_NAME_MAX_CHARACTERS,
|
|
4
4
|
MILLISECONDS_PER_SECOND,
|
|
5
5
|
} from "../constants.ts";
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
8
|
-
import type { GoogleVertexMetricSource } from "./
|
|
6
|
+
import type { BudgetWindow } from "../observability/budget.ts";
|
|
7
|
+
import type { MetricObservation } from "../observability/metric.ts";
|
|
8
|
+
import type { GoogleVertexMetricSource } from "./failures.ts";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Cloud Billing's programmatic budget notification schema (Pub/Sub attributes + base64 JSON data
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { GOOGLE_VERTEX_BUDGET_MAX_MESSAGES_PER_PULL } from "../constants.ts";
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type { GoogleAdcTokenProvider } from "./
|
|
2
|
+
import type { BudgetWindow } from "../observability/budget.ts";
|
|
3
|
+
import type { MetricObservation } from "../observability/metric.ts";
|
|
4
|
+
import type { GoogleAdcTokenProvider } from "./auth.ts";
|
|
5
5
|
import {
|
|
6
6
|
type GoogleVertexBudgetNotification,
|
|
7
7
|
googleVertexBudgetMetrics,
|
|
8
8
|
googleVertexBudgetWindow,
|
|
9
9
|
parseGoogleVertexBudgetNotification,
|
|
10
|
-
} from "./
|
|
11
|
-
import type { GoogleVertexMetricSource } from "./
|
|
10
|
+
} from "./budget-contracts.ts";
|
|
11
|
+
import type { GoogleVertexMetricSource } from "./failures.ts";
|
|
12
12
|
|
|
13
13
|
export {
|
|
14
14
|
type GoogleVertexBudgetAmountType,
|
|
@@ -16,7 +16,7 @@ export {
|
|
|
16
16
|
googleVertexBudgetMetrics,
|
|
17
17
|
googleVertexBudgetWindow,
|
|
18
18
|
parseGoogleVertexBudgetNotification,
|
|
19
|
-
} from "./
|
|
19
|
+
} from "./budget-contracts.ts";
|
|
20
20
|
|
|
21
21
|
const PUBSUB_BASE_URL = "https://pubsub.googleapis.com/v1";
|
|
22
22
|
export const GOOGLE_PUBSUB_READONLY_SCOPE = "https://www.googleapis.com/auth/pubsub";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MILLISECONDS_PER_MINUTE, MILLISECONDS_PER_SECOND } from "../constants.ts";
|
|
2
|
-
import type { MetricObservation } from "../
|
|
2
|
+
import type { MetricObservation } from "../observability/metric.ts";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Google Vertex AI has no documented per-response rate-limit or remaining-quota header, and no
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { TelemetryBatch, TelemetrySource } from "../observability/telemetry-source.ts";
|
|
2
|
+
import type { GoogleAdcTokenProvider } from "./auth.ts";
|
|
3
|
+
import { GoogleVertexBudgetTelemetryAdapter, type GoogleVertexBudgetTransport } from "./budget-telemetry.ts";
|
|
4
|
+
import type { GoogleVertexMetricSource } from "./failures.ts";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Optional because project budget notification setup happens outside Jittor; its absence cannot
|
|
8
|
+
* block unrelated routes.
|
|
9
|
+
*/
|
|
10
|
+
export class GoogleVertexBudgetTelemetrySource implements TelemetrySource {
|
|
11
|
+
readonly id: string;
|
|
12
|
+
readonly provider: GoogleVertexMetricSource;
|
|
13
|
+
readonly required = false;
|
|
14
|
+
|
|
15
|
+
private readonly adapter: GoogleVertexBudgetTelemetryAdapter;
|
|
16
|
+
|
|
17
|
+
constructor(
|
|
18
|
+
subscription: string,
|
|
19
|
+
tokenProvider: GoogleAdcTokenProvider,
|
|
20
|
+
private readonly clock: () => number = Date.now,
|
|
21
|
+
transport: GoogleVertexBudgetTransport = fetch,
|
|
22
|
+
source: GoogleVertexMetricSource = "google-vertex",
|
|
23
|
+
) {
|
|
24
|
+
this.id = `google-vertex-budget:${source}`;
|
|
25
|
+
this.provider = source;
|
|
26
|
+
this.adapter = new GoogleVertexBudgetTelemetryAdapter(subscription, tokenProvider, transport, source);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async poll(): Promise<TelemetryBatch> {
|
|
30
|
+
const observedAt = this.clock();
|
|
31
|
+
const snapshot = await this.adapter.pull(observedAt);
|
|
32
|
+
if (!snapshot) return { observedAt, metrics: [], windows: [] };
|
|
33
|
+
return { observedAt, metrics: snapshot.metrics, windows: snapshot.window ? [snapshot.window] : [] };
|
|
34
|
+
}
|
|
35
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,19 +1,38 @@
|
|
|
1
1
|
export {
|
|
2
|
-
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
type AnthropicMetricSource,
|
|
3
|
+
type AnthropicRateLimitSnapshot,
|
|
4
|
+
type AnthropicRateLimitWindow,
|
|
5
|
+
hasAnthropicRateLimitHeaders,
|
|
6
|
+
parseAnthropicRateLimitHeaders,
|
|
7
|
+
} from "./anthropic/rate-limits.ts";
|
|
8
|
+
export { parseCodexRateLimitHeaders } from "./codex/telemetry.ts";
|
|
6
9
|
export * from "./constants.ts";
|
|
7
10
|
export {
|
|
8
|
-
|
|
9
|
-
type
|
|
10
|
-
type
|
|
11
|
-
type
|
|
12
|
-
type
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
classifyGoogleVertexFailure,
|
|
12
|
+
type GoogleVertexFailure,
|
|
13
|
+
type GoogleVertexFailureKind,
|
|
14
|
+
type GoogleVertexFailureMetadata,
|
|
15
|
+
type GoogleVertexMetricSource,
|
|
16
|
+
googleVertexFailureMetrics,
|
|
17
|
+
} from "./google-vertex/failures.ts";
|
|
18
|
+
export {
|
|
19
|
+
CONTEXT_SEGMENT_SOURCES,
|
|
20
|
+
CONTEXT_SEGMENT_STATES,
|
|
21
|
+
CONTEXT_SNAPSHOT_MAX_SEGMENTS,
|
|
22
|
+
type ContextDelta,
|
|
23
|
+
type ContextFingerprinter,
|
|
24
|
+
type ContextPrefixResetReason,
|
|
25
|
+
type ContextSegmentChange,
|
|
26
|
+
type ContextSegmentLifecycle,
|
|
27
|
+
type ContextSegmentSource,
|
|
28
|
+
type ContextSegmentState,
|
|
29
|
+
type ContextSnapshot,
|
|
30
|
+
type ContextSnapshotSegment,
|
|
31
|
+
type ContextSourceGrowth,
|
|
32
|
+
compareContextSnapshots,
|
|
33
|
+
HmacContextFingerprinter,
|
|
34
|
+
validateContextSnapshot,
|
|
35
|
+
} from "./observability/context-delta.ts";
|
|
17
36
|
export {
|
|
18
37
|
type ContextConfidenceTier,
|
|
19
38
|
type ContextContribution,
|
|
@@ -27,7 +46,11 @@ export {
|
|
|
27
46
|
toolLedgerSegment,
|
|
28
47
|
validateContextContribution,
|
|
29
48
|
validateContextSegment,
|
|
30
|
-
} from "./
|
|
49
|
+
} from "./observability/context-hub.ts";
|
|
50
|
+
export {
|
|
51
|
+
type ContextSnapshotHistory,
|
|
52
|
+
MetricContextSnapshotHistory,
|
|
53
|
+
} from "./observability/context-snapshot-history.ts";
|
|
31
54
|
export {
|
|
32
55
|
assessContextTelemetry,
|
|
33
56
|
type CompactionDurationEstimate,
|
|
@@ -38,7 +61,7 @@ export {
|
|
|
38
61
|
type PapyrusContextInjection,
|
|
39
62
|
papyrusContextMetric,
|
|
40
63
|
validatePapyrusContextInjection,
|
|
41
|
-
} from "./
|
|
64
|
+
} from "./observability/context-telemetry.ts";
|
|
42
65
|
export {
|
|
43
66
|
METRIC_UNITS,
|
|
44
67
|
type MetricObservation,
|
|
@@ -46,7 +69,7 @@ export {
|
|
|
46
69
|
type MetricUnit,
|
|
47
70
|
type StoredMetricObservation,
|
|
48
71
|
validateMetricObservation,
|
|
49
|
-
} from "./
|
|
72
|
+
} from "./observability/metric.ts";
|
|
50
73
|
export {
|
|
51
74
|
aggregateModelMetrics,
|
|
52
75
|
classifyTaskFromTools,
|
|
@@ -61,25 +84,29 @@ export {
|
|
|
61
84
|
TASK_DOMAINS,
|
|
62
85
|
TASK_TYPES,
|
|
63
86
|
validateModelRunObservation,
|
|
64
|
-
} from "./
|
|
65
|
-
export {
|
|
66
|
-
type ModelCandidate,
|
|
67
|
-
type ModelRankingInput,
|
|
68
|
-
type ModelRankingResult,
|
|
69
|
-
type RankedModel,
|
|
70
|
-
type RankingProvenance,
|
|
71
|
-
rankModelCandidates,
|
|
72
|
-
type ScopeAuthority,
|
|
73
|
-
type UtilityComponent,
|
|
74
|
-
type UtilityComponentName,
|
|
75
|
-
type UtilityWeights,
|
|
76
|
-
} from "./domain/model-ranking.ts";
|
|
87
|
+
} from "./observability/model-observation.ts";
|
|
88
|
+
export type { DistinctScopesFilter, MetricStore, UsageAggregateFilter } from "./observability/store.ts";
|
|
77
89
|
export {
|
|
78
90
|
applyTaskFocusEvent,
|
|
79
91
|
type TaskFocusEvent,
|
|
80
92
|
type TaskFocusStatus,
|
|
81
93
|
validateTaskFocusEvent,
|
|
82
|
-
} from "./
|
|
94
|
+
} from "./observability/task-focus.ts";
|
|
95
|
+
export {
|
|
96
|
+
countTextWithFallback,
|
|
97
|
+
type RequestTokenReconciliation,
|
|
98
|
+
reconcileRequestTokens,
|
|
99
|
+
StructuralTextTokenCounter,
|
|
100
|
+
type TextTokenCounter,
|
|
101
|
+
type TextTokenCountInput,
|
|
102
|
+
TOKEN_MEASUREMENT_PROVENANCES,
|
|
103
|
+
TOKEN_MEASUREMENT_SCOPES,
|
|
104
|
+
type TokenMeasurement,
|
|
105
|
+
type TokenMeasurementProvenance,
|
|
106
|
+
type TokenMeasurementScope,
|
|
107
|
+
validateRequestTokenReconciliation,
|
|
108
|
+
validateTokenMeasurement,
|
|
109
|
+
} from "./observability/token-measurement.ts";
|
|
83
110
|
export {
|
|
84
111
|
buildCostGraph,
|
|
85
112
|
buildUsageGraph,
|
|
@@ -100,7 +127,62 @@ export {
|
|
|
100
127
|
usageBucketIndex,
|
|
101
128
|
usagePeriod,
|
|
102
129
|
usagePeriodStart,
|
|
103
|
-
} from "./
|
|
130
|
+
} from "./observability/usage.ts";
|
|
131
|
+
export {
|
|
132
|
+
HistoricalUsageImporter,
|
|
133
|
+
type HistoricalUsageRecord,
|
|
134
|
+
type HistoricalUsageScan,
|
|
135
|
+
type HistoricalUsageSource,
|
|
136
|
+
type UsageImportController,
|
|
137
|
+
type UsageImportResult,
|
|
138
|
+
type UsageImportStatus,
|
|
139
|
+
type UsageImportStore,
|
|
140
|
+
} from "./observability/usage-import.ts";
|
|
141
|
+
export { loadOpenAiTextTokenCounter, OpenAiTextTokenCounter } from "./openai/token-counter.ts";
|
|
142
|
+
export {
|
|
143
|
+
ModelCatalog,
|
|
144
|
+
type ModelCatalogAuthority,
|
|
145
|
+
type ModelCatalogController,
|
|
146
|
+
type ModelCatalogEntry,
|
|
147
|
+
type ModelCatalogFieldAuthority,
|
|
148
|
+
type ModelCatalogPricing,
|
|
149
|
+
type ModelCatalogProvenance,
|
|
150
|
+
type ModelCatalogQuery,
|
|
151
|
+
type ModelCatalogQueryResult,
|
|
152
|
+
type ModelCatalogSource,
|
|
153
|
+
type ModelCatalogStatus,
|
|
154
|
+
ModelsDevCatalogSource,
|
|
155
|
+
translateModelsDevCatalog,
|
|
156
|
+
} from "./optimization/model-selection/catalog.ts";
|
|
157
|
+
export {
|
|
158
|
+
type ModelCandidate,
|
|
159
|
+
type ModelRankingInput,
|
|
160
|
+
type ModelRankingResult,
|
|
161
|
+
type RankedModel,
|
|
162
|
+
type RankingProvenance,
|
|
163
|
+
rankModelCandidates,
|
|
164
|
+
type ScopeAuthority,
|
|
165
|
+
type UtilityComponent,
|
|
166
|
+
type UtilityComponentName,
|
|
167
|
+
type UtilityWeights,
|
|
168
|
+
} from "./optimization/model-selection/ranking.ts";
|
|
169
|
+
export {
|
|
170
|
+
type CodexFailure,
|
|
171
|
+
type CodexFailureKind,
|
|
172
|
+
type CodexFailureMetadata,
|
|
173
|
+
type CodexRecoveryAttempt,
|
|
174
|
+
type CodexRecoveryOptions,
|
|
175
|
+
type CodexRecoveryPlan,
|
|
176
|
+
CodexRecoveryPolicy,
|
|
177
|
+
classifyCodexFailure,
|
|
178
|
+
} from "./optimization/recovery/codex.ts";
|
|
179
|
+
export type {
|
|
180
|
+
RouteOverride,
|
|
181
|
+
RouterController,
|
|
182
|
+
RouterStatus,
|
|
183
|
+
TelemetryPollResult,
|
|
184
|
+
TelemetrySourceStatus,
|
|
185
|
+
} from "./optimization/routing/controller.ts";
|
|
104
186
|
export {
|
|
105
187
|
type BudgetWindow,
|
|
106
188
|
evaluateRoutingPolicy,
|
|
@@ -112,31 +194,29 @@ export {
|
|
|
112
194
|
type PreviousDecision,
|
|
113
195
|
type Route,
|
|
114
196
|
type TelemetryFreshness,
|
|
115
|
-
} from "./policy.ts";
|
|
116
|
-
export type { DistinctScopesFilter, MetricStore, UsageAggregateFilter } from "./ports/metric-store.ts";
|
|
117
|
-
export type {
|
|
118
|
-
RouteOverride,
|
|
119
|
-
RouterController,
|
|
120
|
-
RouterStatus,
|
|
121
|
-
TelemetryPollResult,
|
|
122
|
-
TelemetrySourceStatus,
|
|
123
|
-
} from "./ports/router-controller.ts";
|
|
197
|
+
} from "./optimization/routing/policy.ts";
|
|
124
198
|
export {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
199
|
+
buildOtlpMetricsRequest,
|
|
200
|
+
mapObservationToOtlp,
|
|
201
|
+
OTLP_GENAI_SEMANTIC_CONVENTIONS,
|
|
202
|
+
type OtlpMetricPoint,
|
|
203
|
+
OtlpObservationExporter,
|
|
204
|
+
type OtlpObservationExporterOptions,
|
|
205
|
+
type OtlpTransport,
|
|
206
|
+
otlpExporterFromEnvironment,
|
|
207
|
+
} from "./otlp/exporter.ts";
|
|
208
|
+
export { PiSessionUsageSource, type PiSessionUsageSourceOptions } from "./pi/session-usage-source.ts";
|
|
132
209
|
export {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
type
|
|
136
|
-
type
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
210
|
+
DisabledObservationExporter,
|
|
211
|
+
ExportingMetricStore,
|
|
212
|
+
type ObservationExporter,
|
|
213
|
+
type ObservationExportStatus,
|
|
214
|
+
} from "./telemetry-export/exporter.ts";
|
|
215
|
+
export {
|
|
216
|
+
connectJittorClient,
|
|
217
|
+
type FetchTransport,
|
|
218
|
+
JittorClient,
|
|
219
|
+
} from "./vehicle/client.ts";
|
|
140
220
|
export {
|
|
141
221
|
createApp,
|
|
142
222
|
EXPECTED_OPERATION_NAMES,
|
|
@@ -147,5 +227,5 @@ export {
|
|
|
147
227
|
type OperationName,
|
|
148
228
|
type OperationOutputs,
|
|
149
229
|
UnknownOperationError,
|
|
150
|
-
} from "./service.ts";
|
|
230
|
+
} from "./vehicle/service.ts";
|
|
151
231
|
export { VERSION as jittorVersion } from "./version.ts";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { BENCHMARK_MAX_MODELS_PER_SOURCE, BENCHMARK_REFRESH_INTERVAL_MS, BENCHMARK_SOURCE_MAX_RESPONSE_BYTES } from "../constants.ts";
|
|
2
|
+
import { contractRecord } from "../openrouter/contracts.ts";
|
|
2
3
|
import {
|
|
3
4
|
type BenchmarkObservation,
|
|
4
5
|
type BenchmarkSourceSnapshot,
|
|
5
6
|
normalizeModelIdentity,
|
|
6
7
|
validateBenchmarkObservation,
|
|
7
|
-
} from "../
|
|
8
|
-
import type { BenchmarkSource } from "../
|
|
9
|
-
import { contractRecord } from "../providers/openrouter-contracts.ts";
|
|
8
|
+
} from "../optimization/model-selection/benchmark.ts";
|
|
9
|
+
import type { BenchmarkSource } from "../optimization/model-selection/source.ts";
|
|
10
10
|
|
|
11
11
|
const SOURCE_ID = "lmarena-hf";
|
|
12
12
|
const BASE_URL = "https://datasets-server.huggingface.co/rows";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type TelemetryFreshness = "fresh" | "stale" | "failed";
|
|
2
|
+
|
|
3
|
+
export interface BudgetWindow {
|
|
4
|
+
id: string;
|
|
5
|
+
source: string;
|
|
6
|
+
scope: string;
|
|
7
|
+
usedFraction: number;
|
|
8
|
+
windowSeconds: number;
|
|
9
|
+
resetsAt: number;
|
|
10
|
+
observedAt: number;
|
|
11
|
+
freshness: TelemetryFreshness;
|
|
12
|
+
confidence: number;
|
|
13
|
+
observedBurnPerSecond?: number;
|
|
14
|
+
}
|