@llmops/sdk 1.0.0-beta.5 → 1.0.0-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/agents.cjs +1 -1
  2. package/dist/agents.d.cts +1 -1
  3. package/dist/agents.d.mts +1 -1
  4. package/dist/agents.mjs +1 -1
  5. package/dist/d1-store-D664VLg0.d.cts +52 -0
  6. package/dist/d1-store-DBf99oU8.d.mts +52 -0
  7. package/dist/express.cjs +1 -1
  8. package/dist/express.d.cts +3 -3
  9. package/dist/express.d.mts +3 -3
  10. package/dist/express.mjs +1 -1
  11. package/dist/hono.d.cts +2 -2
  12. package/dist/hono.d.mts +2 -2
  13. package/dist/{index-DnWGper4.d.cts → index-BHO7MEJx.d.cts} +1 -1
  14. package/dist/{index-05byZKeu.d.mts → index-C0CDqR9v.d.mts} +1 -1
  15. package/dist/{index-Dvz-L2Hf.d.mts → index-DVkfeg2W.d.mts} +1 -1
  16. package/dist/{index-Beb26ZNG.d.cts → index-sjRozlIk.d.cts} +1 -1
  17. package/dist/index.cjs +6 -3
  18. package/dist/index.d.cts +5 -4
  19. package/dist/index.d.mts +5 -4
  20. package/dist/index.mjs +4 -3
  21. package/dist/interface-BrJMazBg.d.mts +240 -0
  22. package/dist/interface-DMuF7YgM.d.cts +240 -0
  23. package/dist/nextjs.d.cts +2 -2
  24. package/dist/nextjs.d.mts +2 -2
  25. package/dist/pg-store-sIMdF_Pc.mjs +13598 -0
  26. package/dist/pg-store-uawkO2hJ.cjs +13607 -0
  27. package/dist/store/d1.cjs +491 -0
  28. package/dist/store/d1.d.cts +12 -0
  29. package/dist/store/d1.d.mts +12 -0
  30. package/dist/store/d1.mjs +490 -0
  31. package/dist/store/pg.cjs +2 -7
  32. package/dist/store/pg.d.cts +2 -2
  33. package/dist/store/pg.d.mts +2 -2
  34. package/dist/store/pg.mjs +2 -2
  35. package/dist/types.d.cts +3 -2
  36. package/dist/types.d.mts +3 -2
  37. package/package.json +15 -5
  38. /package/dist/{agents-exporter-BZHCcFSd.d.mts → agents-exporter-Bn3NtzMO.d.mts} +0 -0
  39. /package/dist/{agents-exporter-BuTq2n2y.cjs → agents-exporter-CEbQkds8.cjs} +0 -0
  40. /package/dist/{agents-exporter-vcpgCF69.mjs → agents-exporter-CGxTzDeQ.mjs} +0 -0
  41. /package/dist/{agents-exporter-uzN3bkth.d.cts → agents-exporter-vuQine9v.d.cts} +0 -0
  42. /package/dist/{express-DMtc0d_Y.mjs → express-ClNV0OG9.mjs} +0 -0
  43. /package/dist/{express-B-wbCza5.cjs → express-D-Nfc61h.cjs} +0 -0
package/dist/agents.cjs CHANGED
@@ -1,3 +1,3 @@
1
- const require_agents_exporter = require('./agents-exporter-BuTq2n2y.cjs');
1
+ const require_agents_exporter = require('./agents-exporter-CEbQkds8.cjs');
2
2
 
3
3
  exports.createLLMOpsAgentsExporter = require_agents_exporter.createLLMOpsAgentsExporter;
package/dist/agents.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as AgentsTracingExporter, i as AgentsTrace, n as AgentsSpanData, o as LLMOpsAgentsExporterConfig, r as AgentsSpanError, s as createLLMOpsAgentsExporter, t as AgentsSpan } from "./agents-exporter-uzN3bkth.cjs";
1
+ import { a as AgentsTracingExporter, i as AgentsTrace, n as AgentsSpanData, o as LLMOpsAgentsExporterConfig, r as AgentsSpanError, s as createLLMOpsAgentsExporter, t as AgentsSpan } from "./agents-exporter-vuQine9v.cjs";
2
2
  export { AgentsSpan, AgentsSpanData, AgentsSpanError, AgentsTrace, AgentsTracingExporter, LLMOpsAgentsExporterConfig, createLLMOpsAgentsExporter };
package/dist/agents.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as AgentsTracingExporter, i as AgentsTrace, n as AgentsSpanData, o as LLMOpsAgentsExporterConfig, r as AgentsSpanError, s as createLLMOpsAgentsExporter, t as AgentsSpan } from "./agents-exporter-BZHCcFSd.mjs";
1
+ import { a as AgentsTracingExporter, i as AgentsTrace, n as AgentsSpanData, o as LLMOpsAgentsExporterConfig, r as AgentsSpanError, s as createLLMOpsAgentsExporter, t as AgentsSpan } from "./agents-exporter-Bn3NtzMO.mjs";
2
2
  export { AgentsSpan, AgentsSpanData, AgentsSpanError, AgentsTrace, AgentsTracingExporter, LLMOpsAgentsExporterConfig, createLLMOpsAgentsExporter };
package/dist/agents.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { t as createLLMOpsAgentsExporter } from "./agents-exporter-vcpgCF69.mjs";
1
+ import { t as createLLMOpsAgentsExporter } from "./agents-exporter-CGxTzDeQ.mjs";
2
2
 
3
3
  export { createLLMOpsAgentsExporter };
@@ -0,0 +1,52 @@
1
+ import { t as TelemetryStore } from "./interface-DMuF7YgM.cjs";
2
+
3
+ //#region src/store/d1/types.d.ts
4
+
5
+ /**
6
+ * Minimal D1Database type interface.
7
+ * Avoids depending on @cloudflare/workers-types (10MB+).
8
+ * Users pass their actual D1 binding which satisfies this structurally.
9
+ */
10
+ interface D1Database {
11
+ prepare(query: string): D1PreparedStatement;
12
+ batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
13
+ }
14
+ interface D1PreparedStatement {
15
+ bind(...values: unknown[]): D1PreparedStatement;
16
+ first<T = unknown>(colName?: string): Promise<T | null>;
17
+ all<T = unknown>(): Promise<D1Result<T>>;
18
+ run(): Promise<D1Result>;
19
+ }
20
+ interface D1Result<T = unknown> {
21
+ results: T[];
22
+ success: boolean;
23
+ meta: {
24
+ changes: number;
25
+ duration: number;
26
+ last_row_id: number;
27
+ };
28
+ }
29
+ //#endregion
30
+ //#region src/store/d1/d1-store.d.ts
31
+ type D1Store = TelemetryStore & {
32
+ _db: D1Database;
33
+ };
34
+ /**
35
+ * Create a Cloudflare D1-backed telemetry store.
36
+ *
37
+ * Usage:
38
+ * ```ts
39
+ * import { d1Store } from '@llmops/sdk/store/d1'
40
+ *
41
+ * export default {
42
+ * async fetch(request, env) {
43
+ * const ops = llmops({
44
+ * telemetry: d1Store(env.DB),
45
+ * })
46
+ * }
47
+ * }
48
+ * ```
49
+ */
50
+ declare function createD1Store(db: D1Database): D1Store;
51
+ //#endregion
52
+ export { createD1Store as n, D1Database as r, D1Store as t };
@@ -0,0 +1,52 @@
1
+ import { t as TelemetryStore } from "./interface-BrJMazBg.mjs";
2
+
3
+ //#region src/store/d1/types.d.ts
4
+
5
+ /**
6
+ * Minimal D1Database type interface.
7
+ * Avoids depending on @cloudflare/workers-types (10MB+).
8
+ * Users pass their actual D1 binding which satisfies this structurally.
9
+ */
10
+ interface D1Database {
11
+ prepare(query: string): D1PreparedStatement;
12
+ batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
13
+ }
14
+ interface D1PreparedStatement {
15
+ bind(...values: unknown[]): D1PreparedStatement;
16
+ first<T = unknown>(colName?: string): Promise<T | null>;
17
+ all<T = unknown>(): Promise<D1Result<T>>;
18
+ run(): Promise<D1Result>;
19
+ }
20
+ interface D1Result<T = unknown> {
21
+ results: T[];
22
+ success: boolean;
23
+ meta: {
24
+ changes: number;
25
+ duration: number;
26
+ last_row_id: number;
27
+ };
28
+ }
29
+ //#endregion
30
+ //#region src/store/d1/d1-store.d.ts
31
+ type D1Store = TelemetryStore & {
32
+ _db: D1Database;
33
+ };
34
+ /**
35
+ * Create a Cloudflare D1-backed telemetry store.
36
+ *
37
+ * Usage:
38
+ * ```ts
39
+ * import { d1Store } from '@llmops/sdk/store/d1'
40
+ *
41
+ * export default {
42
+ * async fetch(request, env) {
43
+ * const ops = llmops({
44
+ * telemetry: d1Store(env.DB),
45
+ * })
46
+ * }
47
+ * }
48
+ * ```
49
+ */
50
+ declare function createD1Store(db: D1Database): D1Store;
51
+ //#endregion
52
+ export { createD1Store as n, D1Database as r, D1Store as t };
package/dist/express.cjs CHANGED
@@ -1,3 +1,3 @@
1
- const require_express = require('./express-B-wbCza5.cjs');
1
+ const require_express = require('./express-D-Nfc61h.cjs');
2
2
 
3
3
  exports.createLLMOpsMiddleware = require_express.createLLMOpsMiddleware;
@@ -1,4 +1,4 @@
1
- import "./agents-exporter-uzN3bkth.cjs";
2
- import "./index-Beb26ZNG.cjs";
3
- import { t as createLLMOpsMiddleware } from "./index-DnWGper4.cjs";
1
+ import "./agents-exporter-vuQine9v.cjs";
2
+ import "./index-sjRozlIk.cjs";
3
+ import { t as createLLMOpsMiddleware } from "./index-BHO7MEJx.cjs";
4
4
  export { createLLMOpsMiddleware };
@@ -1,4 +1,4 @@
1
- import "./agents-exporter-BZHCcFSd.mjs";
2
- import "./index-05byZKeu.mjs";
3
- import { t as createLLMOpsMiddleware } from "./index-Dvz-L2Hf.mjs";
1
+ import "./agents-exporter-Bn3NtzMO.mjs";
2
+ import "./index-C0CDqR9v.mjs";
3
+ import { t as createLLMOpsMiddleware } from "./index-DVkfeg2W.mjs";
4
4
  export { createLLMOpsMiddleware };
package/dist/express.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { t as createLLMOpsMiddleware } from "./express-DMtc0d_Y.mjs";
1
+ import { t as createLLMOpsMiddleware } from "./express-ClNV0OG9.mjs";
2
2
 
3
3
  export { createLLMOpsMiddleware };
package/dist/hono.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import "./agents-exporter-uzN3bkth.cjs";
2
- import { t as LLMOpsClient } from "./index-Beb26ZNG.cjs";
1
+ import "./agents-exporter-vuQine9v.cjs";
2
+ import { t as LLMOpsClient } from "./index-sjRozlIk.cjs";
3
3
  import { MiddlewareHandler } from "hono";
4
4
 
5
5
  //#region src/lib/hono/index.d.ts
package/dist/hono.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import "./agents-exporter-BZHCcFSd.mjs";
2
- import { t as LLMOpsClient } from "./index-05byZKeu.mjs";
1
+ import "./agents-exporter-Bn3NtzMO.mjs";
2
+ import { t as LLMOpsClient } from "./index-C0CDqR9v.mjs";
3
3
  import { MiddlewareHandler } from "hono";
4
4
 
5
5
  //#region src/lib/hono/index.d.ts
@@ -1,4 +1,4 @@
1
- import { t as LLMOpsClient } from "./index-Beb26ZNG.cjs";
1
+ import { t as LLMOpsClient } from "./index-sjRozlIk.cjs";
2
2
  import { NextFunction, Request, Response } from "express";
3
3
 
4
4
  //#region src/lib/express/index.d.ts
@@ -1,4 +1,4 @@
1
- import { a as AgentsTracingExporter } from "./agents-exporter-BZHCcFSd.mjs";
1
+ import { a as AgentsTracingExporter } from "./agents-exporter-Bn3NtzMO.mjs";
2
2
  import { LLMOpsConfig, ValidatedLLMOpsConfig } from "@llmops/core";
3
3
 
4
4
  //#region src/telemetry/langchain-client.d.ts
@@ -1,4 +1,4 @@
1
- import { t as LLMOpsClient } from "./index-05byZKeu.mjs";
1
+ import { t as LLMOpsClient } from "./index-C0CDqR9v.mjs";
2
2
  import { NextFunction, Request, Response } from "express";
3
3
 
4
4
  //#region src/lib/express/index.d.ts
@@ -1,4 +1,4 @@
1
- import { a as AgentsTracingExporter } from "./agents-exporter-uzN3bkth.cjs";
1
+ import { a as AgentsTracingExporter } from "./agents-exporter-vuQine9v.cjs";
2
2
  import { LLMOpsConfig, ValidatedLLMOpsConfig } from "@llmops/core";
3
3
 
4
4
  //#region src/telemetry/langchain-client.d.ts
package/dist/index.cjs CHANGED
@@ -1,5 +1,6 @@
1
- const require_express = require('./express-B-wbCza5.cjs');
2
- const require_agents_exporter = require('./agents-exporter-BuTq2n2y.cjs');
1
+ const require_pg_store = require('./pg-store-uawkO2hJ.cjs');
2
+ const require_express = require('./express-D-Nfc61h.cjs');
3
+ const require_agents_exporter = require('./agents-exporter-CEbQkds8.cjs');
3
4
  let __llmops_core = require("@llmops/core");
4
5
  let __llmops_app = require("@llmops/app");
5
6
 
@@ -229,8 +230,10 @@ function createLLMOpsSpanExporter(config) {
229
230
  }
230
231
 
231
232
  //#endregion
233
+ exports.COST_SUMMARY_GROUP_BY = require_pg_store.COST_SUMMARY_GROUP_BY;
232
234
  exports.createLLMOpsAgentsExporter = require_agents_exporter.createLLMOpsAgentsExporter;
233
235
  exports.createLLMOpsLangChainClient = createLLMOpsLangChainClient;
234
236
  exports.createLLMOpsMiddleware = require_express.createLLMOpsMiddleware;
235
237
  exports.createLLMOpsSpanExporter = createLLMOpsSpanExporter;
236
- exports.llmops = createLLMOps;
238
+ exports.llmops = createLLMOps;
239
+ exports.pgStore = require_pg_store.createPgStore;
package/dist/index.d.cts CHANGED
@@ -1,6 +1,7 @@
1
- import { a as AgentsTracingExporter, o as LLMOpsAgentsExporterConfig, s as createLLMOpsAgentsExporter } from "./agents-exporter-uzN3bkth.cjs";
2
- import { a as LLMOpsLangChainClientConfig, i as createLLMOps, n as ProviderOptions, o as LangChainTracingClient, r as TraceContext, s as createLLMOpsLangChainClient, t as LLMOpsClient } from "./index-Beb26ZNG.cjs";
3
- import { t as createLLMOpsMiddleware } from "./index-DnWGper4.cjs";
1
+ import { a as AgentsTracingExporter, o as LLMOpsAgentsExporterConfig, s as createLLMOpsAgentsExporter } from "./agents-exporter-vuQine9v.cjs";
2
+ import { a as LLMOpsLangChainClientConfig, i as createLLMOps, n as ProviderOptions, o as LangChainTracingClient, r as TraceContext, s as createLLMOpsLangChainClient, t as LLMOpsClient } from "./index-sjRozlIk.cjs";
3
+ import { t as createLLMOpsMiddleware } from "./index-BHO7MEJx.cjs";
4
+ import { a as PgStore, c as TraceUpsert, i as LLMRequestInsert, l as createPgStore, n as COST_SUMMARY_GROUP_BY, o as SpanEventInsert, r as CostSummaryGroupBy, s as SpanInsert, t as TelemetryStore } from "./interface-DMuF7YgM.cjs";
4
5
 
5
6
  //#region src/telemetry/exporter.d.ts
6
7
 
@@ -92,4 +93,4 @@ interface LLMOpsExporterConfig {
92
93
  */
93
94
  declare function createLLMOpsSpanExporter(config: LLMOpsExporterConfig): SpanExporter;
94
95
  //#endregion
95
- export { type AgentsTracingExporter, type LLMOpsAgentsExporterConfig, type LLMOpsClient, type LLMOpsExporterConfig, type LLMOpsLangChainClientConfig, type LangChainTracingClient, type ProviderOptions, type SpanExporter, type TraceContext, createLLMOpsAgentsExporter, createLLMOpsLangChainClient, createLLMOpsMiddleware, createLLMOpsSpanExporter, createLLMOps as llmops };
96
+ export { type AgentsTracingExporter, COST_SUMMARY_GROUP_BY, type CostSummaryGroupBy, type LLMOpsAgentsExporterConfig, type LLMOpsClient, type LLMOpsExporterConfig, type LLMOpsLangChainClientConfig, type LLMRequestInsert, type LangChainTracingClient, type PgStore, type ProviderOptions, type SpanEventInsert, type SpanExporter, type SpanInsert, type TelemetryStore, type TraceContext, type TraceUpsert, createLLMOpsAgentsExporter, createLLMOpsLangChainClient, createLLMOpsMiddleware, createLLMOpsSpanExporter, createLLMOps as llmops, createPgStore as pgStore };
package/dist/index.d.mts CHANGED
@@ -1,6 +1,7 @@
1
- import { a as AgentsTracingExporter, o as LLMOpsAgentsExporterConfig, s as createLLMOpsAgentsExporter } from "./agents-exporter-BZHCcFSd.mjs";
2
- import { a as LLMOpsLangChainClientConfig, i as createLLMOps, n as ProviderOptions, o as LangChainTracingClient, r as TraceContext, s as createLLMOpsLangChainClient, t as LLMOpsClient } from "./index-05byZKeu.mjs";
3
- import { t as createLLMOpsMiddleware } from "./index-Dvz-L2Hf.mjs";
1
+ import { a as AgentsTracingExporter, o as LLMOpsAgentsExporterConfig, s as createLLMOpsAgentsExporter } from "./agents-exporter-Bn3NtzMO.mjs";
2
+ import { a as LLMOpsLangChainClientConfig, i as createLLMOps, n as ProviderOptions, o as LangChainTracingClient, r as TraceContext, s as createLLMOpsLangChainClient, t as LLMOpsClient } from "./index-C0CDqR9v.mjs";
3
+ import { t as createLLMOpsMiddleware } from "./index-DVkfeg2W.mjs";
4
+ import { a as PgStore, c as TraceUpsert, i as LLMRequestInsert, l as createPgStore, n as COST_SUMMARY_GROUP_BY, o as SpanEventInsert, r as CostSummaryGroupBy, s as SpanInsert, t as TelemetryStore } from "./interface-BrJMazBg.mjs";
4
5
 
5
6
  //#region src/telemetry/exporter.d.ts
6
7
 
@@ -92,4 +93,4 @@ interface LLMOpsExporterConfig {
92
93
  */
93
94
  declare function createLLMOpsSpanExporter(config: LLMOpsExporterConfig): SpanExporter;
94
95
  //#endregion
95
- export { type AgentsTracingExporter, type LLMOpsAgentsExporterConfig, type LLMOpsClient, type LLMOpsExporterConfig, type LLMOpsLangChainClientConfig, type LangChainTracingClient, type ProviderOptions, type SpanExporter, type TraceContext, createLLMOpsAgentsExporter, createLLMOpsLangChainClient, createLLMOpsMiddleware, createLLMOpsSpanExporter, createLLMOps as llmops };
96
+ export { type AgentsTracingExporter, COST_SUMMARY_GROUP_BY, type CostSummaryGroupBy, type LLMOpsAgentsExporterConfig, type LLMOpsClient, type LLMOpsExporterConfig, type LLMOpsLangChainClientConfig, type LLMRequestInsert, type LangChainTracingClient, type PgStore, type ProviderOptions, type SpanEventInsert, type SpanExporter, type SpanInsert, type TelemetryStore, type TraceContext, type TraceUpsert, createLLMOpsAgentsExporter, createLLMOpsLangChainClient, createLLMOpsMiddleware, createLLMOpsSpanExporter, createLLMOps as llmops, createPgStore as pgStore };
package/dist/index.mjs CHANGED
@@ -1,5 +1,6 @@
1
- import { t as createLLMOpsMiddleware } from "./express-DMtc0d_Y.mjs";
2
- import { t as createLLMOpsAgentsExporter } from "./agents-exporter-vcpgCF69.mjs";
1
+ import { n as createPgStore, t as COST_SUMMARY_GROUP_BY } from "./pg-store-sIMdF_Pc.mjs";
2
+ import { t as createLLMOpsMiddleware } from "./express-ClNV0OG9.mjs";
3
+ import { t as createLLMOpsAgentsExporter } from "./agents-exporter-CGxTzDeQ.mjs";
3
4
  import { LLMOPS_INTERNAL_HEADER, LLMOPS_SPAN_NAME_HEADER, LLMOPS_TRACE_ID_HEADER, LLMOPS_TRACE_NAME_HEADER } from "@llmops/core";
4
5
  import { createApp } from "@llmops/app";
5
6
 
@@ -229,4 +230,4 @@ function createLLMOpsSpanExporter(config) {
229
230
  }
230
231
 
231
232
  //#endregion
232
- export { createLLMOpsAgentsExporter, createLLMOpsLangChainClient, createLLMOpsMiddleware, createLLMOpsSpanExporter, createLLMOps as llmops };
233
+ export { COST_SUMMARY_GROUP_BY, createLLMOpsAgentsExporter, createLLMOpsLangChainClient, createLLMOpsMiddleware, createLLMOpsSpanExporter, createLLMOps as llmops, createPgStore as pgStore };
@@ -0,0 +1,240 @@
1
+ import z from "zod";
2
+
3
+ //#region src/telemetry/pg-store.d.ts
4
+ declare const insertLLMRequestSchema: z.ZodObject<{
5
+ requestId: z.ZodString;
6
+ configId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
7
+ variantId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
8
+ environmentId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
9
+ providerConfigId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
10
+ provider: z.ZodString;
11
+ model: z.ZodString;
12
+ promptTokens: z.ZodDefault<z.ZodNumber>;
13
+ completionTokens: z.ZodDefault<z.ZodNumber>;
14
+ totalTokens: z.ZodDefault<z.ZodNumber>;
15
+ cachedTokens: z.ZodDefault<z.ZodNumber>;
16
+ cacheCreationTokens: z.ZodDefault<z.ZodNumber>;
17
+ cost: z.ZodDefault<z.ZodNumber>;
18
+ cacheSavings: z.ZodDefault<z.ZodNumber>;
19
+ inputCost: z.ZodDefault<z.ZodNumber>;
20
+ outputCost: z.ZodDefault<z.ZodNumber>;
21
+ endpoint: z.ZodString;
22
+ statusCode: z.ZodNumber;
23
+ latencyMs: z.ZodDefault<z.ZodNumber>;
24
+ isStreaming: z.ZodDefault<z.ZodBoolean>;
25
+ userId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
26
+ tags: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
27
+ guardrailResults: z.ZodOptional<z.ZodNullable<z.ZodObject<{
28
+ results: z.ZodArray<z.ZodObject<{
29
+ checkId: z.ZodString;
30
+ functionId: z.ZodString;
31
+ hookType: z.ZodEnum<{
32
+ beforeRequestHook: "beforeRequestHook";
33
+ afterRequestHook: "afterRequestHook";
34
+ }>;
35
+ verdict: z.ZodBoolean;
36
+ latencyMs: z.ZodNumber;
37
+ }, z.core.$strip>>;
38
+ action: z.ZodEnum<{
39
+ allowed: "allowed";
40
+ blocked: "blocked";
41
+ logged: "logged";
42
+ }>;
43
+ totalLatencyMs: z.ZodNumber;
44
+ }, z.core.$strip>>>;
45
+ traceId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
46
+ spanId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
47
+ parentSpanId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
48
+ sessionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
49
+ }, z.core.$strip>;
50
+ type LLMRequestInsert = z.infer<typeof insertLLMRequestSchema>;
51
+ declare const COST_SUMMARY_GROUP_BY: readonly ["day", "hour", "model", "provider", "endpoint", "tags"];
52
+ type CostSummaryGroupBy = (typeof COST_SUMMARY_GROUP_BY)[number];
53
+ declare const upsertTraceSchema: z.ZodObject<{
54
+ traceId: z.ZodString;
55
+ name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
56
+ sessionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
57
+ userId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
58
+ status: z.ZodDefault<z.ZodEnum<{
59
+ error: "error";
60
+ unset: "unset";
61
+ ok: "ok";
62
+ }>>;
63
+ startTime: z.ZodDate;
64
+ endTime: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
65
+ durationMs: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
66
+ spanCount: z.ZodDefault<z.ZodNumber>;
67
+ totalInputTokens: z.ZodDefault<z.ZodNumber>;
68
+ totalOutputTokens: z.ZodDefault<z.ZodNumber>;
69
+ totalTokens: z.ZodDefault<z.ZodNumber>;
70
+ totalCost: z.ZodDefault<z.ZodNumber>;
71
+ tags: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
72
+ metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
73
+ }, z.core.$strip>;
74
+ type TraceUpsert = z.infer<typeof upsertTraceSchema>;
75
+ declare const insertSpanSchema: z.ZodObject<{
76
+ traceId: z.ZodString;
77
+ spanId: z.ZodString;
78
+ parentSpanId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
79
+ name: z.ZodString;
80
+ kind: z.ZodDefault<z.ZodNumber>;
81
+ status: z.ZodDefault<z.ZodNumber>;
82
+ statusMessage: z.ZodOptional<z.ZodNullable<z.ZodString>>;
83
+ startTime: z.ZodDate;
84
+ endTime: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
85
+ durationMs: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
86
+ provider: z.ZodOptional<z.ZodNullable<z.ZodString>>;
87
+ model: z.ZodOptional<z.ZodNullable<z.ZodString>>;
88
+ promptTokens: z.ZodDefault<z.ZodNumber>;
89
+ completionTokens: z.ZodDefault<z.ZodNumber>;
90
+ totalTokens: z.ZodDefault<z.ZodNumber>;
91
+ cost: z.ZodDefault<z.ZodNumber>;
92
+ configId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
93
+ variantId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
94
+ environmentId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
95
+ providerConfigId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
96
+ requestId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
97
+ source: z.ZodDefault<z.ZodEnum<{
98
+ gateway: "gateway";
99
+ otlp: "otlp";
100
+ langsmith: "langsmith";
101
+ }>>;
102
+ input: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
103
+ output: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
104
+ attributes: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
105
+ }, z.core.$strip>;
106
+ type SpanInsert = z.infer<typeof insertSpanSchema>;
107
+ declare const insertSpanEventSchema: z.ZodObject<{
108
+ traceId: z.ZodString;
109
+ spanId: z.ZodString;
110
+ name: z.ZodString;
111
+ timestamp: z.ZodDate;
112
+ attributes: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
113
+ }, z.core.$strip>;
114
+ type SpanEventInsert = z.infer<typeof insertSpanEventSchema>;
115
+ type PgStore = TelemetryStore & {
116
+ _pool: unknown;
117
+ _schema: string;
118
+ };
119
+ /**
120
+ * Create a PostgreSQL-backed telemetry store.
121
+ *
122
+ * Usage:
123
+ * ```ts
124
+ * import { llmops } from '@llmops/sdk'
125
+ * import { pgStore } from '@llmops/sdk/store/pg'
126
+ *
127
+ * const ops = llmops({
128
+ * telemetry: pgStore(process.env.DATABASE_URL),
129
+ * })
130
+ * ```
131
+ */
132
+ declare function createPgStore(connectionString: string, options?: {
133
+ schema?: string;
134
+ }): PgStore;
135
+ //#endregion
136
+ //#region src/telemetry/interface.d.ts
137
+ /**
138
+ * TelemetryStore provides read + write access to telemetry data.
139
+ * Implemented by pgStore, d1Store, and future store backends.
140
+ */
141
+ interface TelemetryStore {
142
+ batchInsertRequests(requests: LLMRequestInsert[]): Promise<{
143
+ count: number;
144
+ }>;
145
+ insertRequest(request: LLMRequestInsert): Promise<unknown>;
146
+ listRequests(params?: {
147
+ limit?: number;
148
+ offset?: number;
149
+ configId?: string;
150
+ variantId?: string;
151
+ environmentId?: string;
152
+ providerConfigId?: string;
153
+ provider?: string;
154
+ model?: string;
155
+ startDate?: Date;
156
+ endDate?: Date;
157
+ tags?: Record<string, string[]>;
158
+ }): Promise<{
159
+ data: unknown[];
160
+ total: number;
161
+ limit: number;
162
+ offset: number;
163
+ }>;
164
+ getRequestByRequestId(requestId: string): Promise<unknown | undefined>;
165
+ getTotalCost(params: {
166
+ startDate: Date;
167
+ endDate: Date;
168
+ configId?: string;
169
+ variantId?: string;
170
+ environmentId?: string;
171
+ tags?: Record<string, string[]>;
172
+ }): Promise<unknown>;
173
+ getCostByModel(params: {
174
+ startDate: Date;
175
+ endDate: Date;
176
+ }): Promise<unknown[]>;
177
+ getCostByProvider(params: {
178
+ startDate: Date;
179
+ endDate: Date;
180
+ }): Promise<unknown[]>;
181
+ getDailyCosts(params: {
182
+ startDate: Date;
183
+ endDate: Date;
184
+ }): Promise<unknown[]>;
185
+ getCostSummary(params: {
186
+ startDate: Date;
187
+ endDate: Date;
188
+ configId?: string;
189
+ variantId?: string;
190
+ environmentId?: string;
191
+ groupBy?: CostSummaryGroupBy;
192
+ tags?: Record<string, string[]>;
193
+ tagKeys?: string[];
194
+ }): Promise<unknown[]>;
195
+ getRequestStats(params: {
196
+ startDate: Date;
197
+ endDate: Date;
198
+ configId?: string;
199
+ variantId?: string;
200
+ environmentId?: string;
201
+ tags?: Record<string, string[]>;
202
+ }): Promise<unknown>;
203
+ getDistinctTags(): Promise<unknown[]>;
204
+ upsertTrace(data: TraceUpsert): Promise<void>;
205
+ batchInsertSpans(spans: SpanInsert[]): Promise<{
206
+ count: number;
207
+ }>;
208
+ batchInsertSpanEvents(events: SpanEventInsert[]): Promise<{
209
+ count: number;
210
+ }>;
211
+ listTraces(params?: {
212
+ limit?: number;
213
+ offset?: number;
214
+ sessionId?: string;
215
+ userId?: string;
216
+ status?: string;
217
+ name?: string;
218
+ startDate?: Date;
219
+ endDate?: Date;
220
+ tags?: Record<string, string[]>;
221
+ }): Promise<{
222
+ data: unknown[];
223
+ total: number;
224
+ limit: number;
225
+ offset: number;
226
+ }>;
227
+ getTraceWithSpans(traceId: string): Promise<{
228
+ trace: unknown;
229
+ spans: unknown[];
230
+ events: unknown[];
231
+ } | undefined>;
232
+ getTraceStats(params: {
233
+ startDate: Date;
234
+ endDate: Date;
235
+ sessionId?: string;
236
+ userId?: string;
237
+ }): Promise<unknown>;
238
+ }
239
+ //#endregion
240
+ export { PgStore as a, TraceUpsert as c, LLMRequestInsert as i, createPgStore as l, COST_SUMMARY_GROUP_BY as n, SpanEventInsert as o, CostSummaryGroupBy as r, SpanInsert as s, TelemetryStore as t };