metergraph 0.5.0 → 0.6.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 CHANGED
@@ -5,14 +5,18 @@ provider-independent Vercel AI SDK language models on Node 18+, including AWS
5
5
  Lambda. Worker-style `waitUntil` hooks are present but are not part of the v1
6
6
  public-package qualification contract.
7
7
 
8
- `wrap()` initializes capture from the environment, so setup is one line per
9
- client; call `init(...)` before the first `wrap()` only to pass options in
10
- code.
8
+ Initialize Metergraph once, then wrap each provider client. `init()` reads the
9
+ token and other omitted options from the environment.
10
+
11
+ Initialization is process-wide. The first `init()` configuration remains
12
+ active; later explicit calls are ignored and produce one generic warning
13
+ without option names, token values, or other secrets.
11
14
 
12
15
  ```ts
13
- import { wrap, route, trace, modelFor, recordOutcome, setSession } from "metergraph";
16
+ import { init, wrap, route, trace, modelFor, recordOutcome, setSession } from "metergraph";
14
17
  import OpenAI from "openai";
15
18
 
19
+ init({ repository: "owner/repository" });
16
20
  // new Anthropic() and new GoogleGenAI({}) wrap the same way.
17
21
  const client = wrap(new OpenAI());
18
22
  setSession("ticket-123");
@@ -47,7 +51,7 @@ import * as mg from "metergraph";
47
51
 
48
52
  const model = wrapLanguageModel({
49
53
  model: openai("gpt-5.6-luna"),
50
- middleware: mg.vercelAISDKMiddleware(),
54
+ middleware: mg.vercelAISDKMiddleware({ repository: "owner/repository" }),
51
55
  });
52
56
 
53
57
  const result = await mg.trace("support-answer", () =>
@@ -65,6 +69,19 @@ for server-side pricing. Provider options, abort signals, and transport headers
65
69
  are never serialized. Calls outside `trace()` remain valid one-span traces;
66
70
  wrap a multi-call workflow in `trace()` to group its spans.
67
71
 
72
+ `vercelAISDKMiddleware()` initializes Metergraph itself, so the standard
73
+ integration needs only the middleware call. Pass any `init()` options there,
74
+ as shown above, or omit them when configuration comes from environment
75
+ variables. Applications that initialize Metergraph centrally may continue to
76
+ call `init()` first and then create the middleware without initialization
77
+ options.
78
+
79
+ Applications with several providers should use the [examples
80
+ chooser](../examples/README.md): apply MeterGraph once through the AI SDK
81
+ provider registry, or wrap the controlled exit of a custom factory the
82
+ application already has. The separate examples mark original application code
83
+ and every MeterGraph addition.
84
+
68
85
  | Vercel AI SDK | Metergraph middleware | Node.js |
69
86
  |---|---|---|
70
87
  | 5 | `vercelAISDKMiddleware({ aiSdkVersion: 5 })` | 18+ |
@@ -86,12 +103,22 @@ required and throws if missing so a caller error surfaces immediately
86
103
  instead of an `undefined` model reaching a provider call.
87
104
 
88
105
  Set `METERGRAPH_APP_TOKEN`; `METERGRAPH_INGEST_URL` is only needed to override
89
- the hosted HTTPS endpoint. SDK 0.4 automatically reads the GitHub `origin` on
90
- first initialization and creates `.metergraph/config.json` at the repository
91
- root if absent. Commit this non-secret file so production can use
92
- repository-aware ingest without Git metadata. Existing config is authoritative
93
- and never overwritten; when discovery or creation is unavailable, the SDK
94
- continues with protocol v1. SDK 0.4 captures the scrubbed provider request and a
106
+ the hosted HTTPS endpoint. Repository identity enables repository-level
107
+ attribution and [MeterGraph Bot](https://github.com/apps/metergraph). Choose any
108
+ one of these options; each is sufficient on its own:
109
+
110
+ - Pass `{ repository: "owner/repository" }` to `mg.init()`.
111
+ - Set `METERGRAPH_REPOSITORY=owner/repository` in the environment.
112
+ - Store the identity with the source code in `.metergraph/config.json`:
113
+
114
+ ```json
115
+ {"repository":"owner/repository"}
116
+ ```
117
+
118
+ Resolution order is the explicit option, environment variable, then
119
+ configuration file. The SDK treats the file as read-only. Without repository
120
+ identity, it warns once and continues capture without repository attribution.
121
+ Metergraph captures the scrubbed provider request and a
95
122
  normalized response envelope, including assistant content and tool calls, by
96
123
  default. Provider credentials and transport headers are removed. Request and
97
124
  response are each limited to 100 KiB of UTF-8 with an explicit truncation
@@ -173,11 +200,14 @@ Instrument this codebase's LLM API costs with the `metergraph` npm package
173
200
  then wrap every new OpenAI(), new Anthropic(), and new GoogleGenAI()
174
201
  construction in place, e.g. const client = mg.wrap(new OpenAI()) after
175
202
  import * as mg from "metergraph". wrap() returns the same client and
176
- initializes itself from the environment: METERGRAPH_APP_TOKEN is required
177
- (capture is silently off without it) and METERGRAPH_INGEST_URL is only for
178
- self-hosted servers. Add both to .env.example, and never commit a real token.
179
- SDK 0.4 captures scrubbed provider requests and normalized responses by
180
- default for the hosted dashboard; use METERGRAPH_CAPTURE_TEXT=0 or
203
+ initializes itself from the environment. Before wrapping, call
204
+ mg.init({ repository: "owner/repository" }) using the actual GitHub owner and
205
+ repository name. METERGRAPH_APP_TOKEN is required; the SDK warns and disables
206
+ capture when it is missing. METERGRAPH_INGEST_URL is only for self-hosted
207
+ servers. Document variable names with placeholders in .env.example, and put
208
+ real values only in deployment configuration. Metergraph captures scrubbed
209
+ provider requests and normalized responses by default for the hosted dashboard;
210
+ use METERGRAPH_CAPTURE_TEXT=0 or
181
211
  captureText: false around sensitive operations. Provider credentials and
182
212
  transport headers must never be captured. Capture is fail-open, so do not
183
213
  change call sites, arguments, or error handling; async and streaming work
@@ -1,3 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BatchFirstIneligibleError = void 0;
4
+ exports.runBatchFirst = runBatchFirst;
5
+ exports.batchFirst = batchFirst;
1
6
  /**
2
7
  * Explicit, opt-in batch-first execution: submit one request through a
3
8
  * provider's Batch API, wait a caller-selected deadline, and fall back to
@@ -14,7 +19,7 @@
14
19
  * arrives after the fallback already won is never returned, never
15
20
  * executed, and never mutates an already-resolved result.
16
21
  */
17
- import { createAnthropicBatchAdapter, createGoogleBatchAdapter, createOpenAIBatchAdapter, } from "./provider-batch.js";
22
+ const provider_batch_js_1 = require("./provider-batch.js");
18
23
  function realClock() {
19
24
  return {
20
25
  setTimeout: (handler, ms) => setTimeout(handler, ms),
@@ -25,8 +30,9 @@ function realClock() {
25
30
  * not eligible for batch-first execution — streaming, tools without
26
31
  * acknowledgement, a missing/false acceptDuplicateProviderExecution, or
27
32
  * an adapter-specific ineligibility. */
28
- export class BatchFirstIneligibleError extends Error {
33
+ class BatchFirstIneligibleError extends Error {
29
34
  }
35
+ exports.BatchFirstIneligibleError = BatchFirstIneligibleError;
30
36
  function hasTools(request) {
31
37
  return Array.isArray(request.tools) && request.tools.length > 0;
32
38
  }
@@ -53,7 +59,7 @@ const DEFAULT_POLL_INTERVAL_MS = 2_000;
53
59
  * fake-clock tests can drive it directly, and used internally by the
54
60
  * public, provider-explicit batchFirst() below.
55
61
  */
56
- export async function runBatchFirst(adapter, request, policy, testControls) {
62
+ async function runBatchFirst(adapter, request, policy, testControls) {
57
63
  validate(request, policy);
58
64
  const eligibility = adapter.eligibility(request);
59
65
  if (!eligibility.eligible) {
@@ -186,13 +192,13 @@ export async function runBatchFirst(adapter, request, policy, testControls) {
186
192
  }
187
193
  function resolveAdapter(client, provider) {
188
194
  if (provider === "openai") {
189
- return createOpenAIBatchAdapter(client);
195
+ return (0, provider_batch_js_1.createOpenAIBatchAdapter)(client);
190
196
  }
191
197
  if (provider === "anthropic") {
192
- return createAnthropicBatchAdapter(client);
198
+ return (0, provider_batch_js_1.createAnthropicBatchAdapter)(client);
193
199
  }
194
200
  if (provider === "google") {
195
- return createGoogleBatchAdapter(client);
201
+ return (0, provider_batch_js_1.createGoogleBatchAdapter)(client);
196
202
  }
197
203
  throw new BatchFirstIneligibleError(`batchFirst() has no adapter for provider "${provider}" yet`);
198
204
  }
@@ -201,7 +207,7 @@ function resolveAdapter(client, provider) {
201
207
  * the client instance — the caller states the provider, matching wrap()'s
202
208
  * own explicit-provider option.
203
209
  */
204
- export async function batchFirst(client, provider, request, policy) {
210
+ async function batchFirst(client, provider, request, policy) {
205
211
  const adapter = resolveAdapter(client, provider);
206
212
  return runBatchFirst(adapter, request, policy);
207
213
  }
package/dist/capture.js CHANGED
@@ -1,7 +1,11 @@
1
- import { randomBytes } from "node:crypto";
2
- import { contextSnapshot } from "./context.js";
3
- import { scrub, templateHash } from "./template.js";
4
- import { SDK_VERSION } from "./version.js";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CaptureRuntime = void 0;
4
+ exports.chunkText = chunkText;
5
+ const node_crypto_1 = require("node:crypto");
6
+ const context_js_1 = require("./context.js");
7
+ const template_js_1 = require("./template.js");
8
+ const version_js_1 = require("./version.js");
5
9
  function get(value, key) {
6
10
  return value && typeof value === "object" ? value[key] : undefined;
7
11
  }
@@ -94,7 +98,7 @@ function responseText(response) {
94
98
  }
95
99
  return undefined;
96
100
  }
97
- export function chunkText(chunk) {
101
+ function chunkText(chunk) {
98
102
  const delta = get(first(get(chunk, "choices")), "delta") ?? get(chunk, "delta");
99
103
  if (typeof delta === "string" && get(chunk, "type") === "text-delta")
100
104
  return delta;
@@ -126,7 +130,7 @@ function toolArgument(value) {
126
130
  return value;
127
131
  }
128
132
  }
129
- return scrub(value);
133
+ return (0, template_js_1.scrub)(value);
130
134
  }
131
135
  function toolEvents(request, response, streamChunks = []) {
132
136
  const calls = new Map();
@@ -297,7 +301,7 @@ function toolEvents(request, response, streamChunks = []) {
297
301
  arguments: input && typeof input === "object"
298
302
  && Object.keys(input).length === 0
299
303
  ? ""
300
- : JSON.stringify(scrub(input ?? {})),
304
+ : JSON.stringify((0, template_js_1.scrub)(input ?? {})),
301
305
  });
302
306
  }
303
307
  }
@@ -327,25 +331,25 @@ function responseContent(response, aggregate) {
327
331
  return aggregate;
328
332
  const direct = get(response, "output_text") ?? get(response, "text");
329
333
  if (direct !== undefined)
330
- return scrub(direct);
334
+ return (0, template_js_1.scrub)(direct);
331
335
  const message = get(first(get(response, "choices")), "message");
332
336
  const content = get(message, "content");
333
337
  if (content !== undefined)
334
- return scrub(content);
338
+ return (0, template_js_1.scrub)(content);
335
339
  const parsed = get(message, "parsed");
336
340
  if (parsed !== undefined)
337
- return scrub(parsed);
341
+ return (0, template_js_1.scrub)(parsed);
338
342
  const normalizedText = responseText(response);
339
343
  if (normalizedText !== undefined)
340
344
  return normalizedText;
341
345
  const blocks = get(response, "content");
342
346
  if (blocks !== undefined)
343
- return scrub(blocks);
347
+ return (0, template_js_1.scrub)(blocks);
344
348
  const output = get(response, "output");
345
349
  if (output !== undefined)
346
- return scrub(output);
350
+ return (0, template_js_1.scrub)(output);
347
351
  const candidates = get(response, "candidates");
348
- return candidates === undefined ? undefined : scrub(candidates);
352
+ return candidates === undefined ? undefined : (0, template_js_1.scrub)(candidates);
349
353
  }
350
354
  function responseEnvelope(response, aggregate, tools, error, status) {
351
355
  const responseMetadata = get(response, "response");
@@ -369,12 +373,9 @@ function responseEnvelope(response, aggregate, tools, error, status) {
369
373
  return Object.fromEntries(Object.entries(envelope).filter(([, value]) => value !== undefined));
370
374
  }
371
375
  const SDK_DIR = (() => {
372
- try {
373
- return new URL(".", import.meta.url).pathname;
374
- }
375
- catch {
376
- return "metergraph-sdk-dir-unavailable";
377
- }
376
+ const frame = new Error().stack?.split("\n")[1] ?? "";
377
+ const match = frame.match(/^\s*at\s+(?:.*?\s+\()?(.+?)[/\\][^/\\:]+:\d+:\d+\)?$/);
378
+ return match?.[1]?.replace(/^file:\/\//, "") ?? "metergraph-sdk-dir-unavailable";
378
379
  })();
379
380
  function frames(stack, appRoot, skip, repoRoot) {
380
381
  if (!stack)
@@ -405,14 +406,14 @@ function frames(stack, appRoot, skip, repoRoot) {
405
406
  }
406
407
  return result;
407
408
  }
408
- export class CaptureRuntime {
409
+ class CaptureRuntime {
409
410
  transport;
410
411
  options;
411
412
  constructor(transport, options) {
412
413
  this.transport = transport;
413
414
  this.options = options;
414
415
  }
415
- start(provider, endpoint, request, stack, context = contextSnapshot()) {
416
+ start(provider, endpoint, request, stack, context = (0, context_js_1.contextSnapshot)()) {
416
417
  return {
417
418
  provider,
418
419
  endpoint,
@@ -421,8 +422,8 @@ export class CaptureRuntime {
421
422
  started: performance.now(),
422
423
  ts: new Date().toISOString(),
423
424
  frames: frames(stack, this.options.appRoot, this.options.skipFrames, this.options.repoRoot),
424
- traceId: context.traceId ?? randomBytes(16).toString("hex"),
425
- spanId: randomBytes(8).toString("hex"),
425
+ traceId: context.traceId ?? (0, node_crypto_1.randomBytes)(16).toString("hex"),
426
+ spanId: (0, node_crypto_1.randomBytes)(8).toString("hex"),
426
427
  parentSpanId: context.parentSpanId,
427
428
  traceName: context.traceName ?? context.route ?? context.funcName
428
429
  ?? endpoint,
@@ -456,8 +457,8 @@ export class CaptureRuntime {
456
457
  }
457
458
  return { value: `${clipped}${marker}`, truncated: true };
458
459
  };
459
- const request = text(JSON.stringify(scrub(state.request)), "request");
460
- const fullTools = toolEvents(scrub(state.request), response, extra.responseChunks);
460
+ const request = text(JSON.stringify((0, template_js_1.scrub)(state.request)), "request");
461
+ const fullTools = toolEvents((0, template_js_1.scrub)(state.request), response, extra.responseChunks);
461
462
  const status = extra.status ?? (extra.error ? "error" : stopReason(response) ?? "success");
462
463
  const output = text(JSON.stringify(responseEnvelope(response, extra.responseText, fullTools, extra.error, status)), "response");
463
464
  let toolTruncated = false;
@@ -503,7 +504,7 @@ export class CaptureRuntime {
503
504
  span_id: state.spanId,
504
505
  parent_span_id: state.parentSpanId,
505
506
  trace_name: state.traceName,
506
- template_hash: templateHash(state.request),
507
+ template_hash: (0, template_js_1.templateHash)(state.request),
507
508
  unit_name: state.context.unitName,
508
509
  unit_count: state.context.unitCount,
509
510
  tool_calls: fullTools ? persistedTools : toolNames(state.request),
@@ -531,8 +532,9 @@ export class CaptureRuntime {
531
532
  error: Boolean(extra.error),
532
533
  error_type: extra.error instanceof Error ? extra.error.name : undefined,
533
534
  sdk: "js",
534
- sdk_version: SDK_VERSION,
535
+ sdk_version: version_js_1.SDK_VERSION,
535
536
  runtime: typeof process === "undefined" ? "edge" : `node-${process.versions.node}`,
536
537
  });
537
538
  }
538
539
  }
540
+ exports.CaptureRuntime = CaptureRuntime;
package/dist/config.js CHANGED
@@ -1,4 +1,8 @@
1
- import { FailureLogger } from "./failure-log.js";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConfigPoller = void 0;
4
+ exports.chooseModel = chooseModel;
5
+ const failure_log_js_1 = require("./failure-log.js");
2
6
  function bucket(value) {
3
7
  let hash = 0xcbf29ce484222325n;
4
8
  for (const byte of new TextEncoder().encode(value)) {
@@ -7,7 +11,7 @@ function bucket(value) {
7
11
  }
8
12
  return Number(hash) / 2 ** 64 * 100;
9
13
  }
10
- export function chooseModel(route, fallback, sessionKey, config) {
14
+ function chooseModel(route, fallback, sessionKey, config) {
11
15
  if (!config || config.enabled === false)
12
16
  return fallback;
13
17
  const incumbent = config.incumbent_model ?? fallback;
@@ -18,7 +22,7 @@ export function chooseModel(route, fallback, sessionKey, config) {
18
22
  const seed = `${route}:${config.version ?? ""}:${config.salt ?? ""}:${sessionKey}`;
19
23
  return bucket(seed) < percentage ? challenger : incumbent;
20
24
  }
21
- export class ConfigPoller {
25
+ class ConfigPoller {
22
26
  token;
23
27
  baseUrl;
24
28
  pollMs;
@@ -28,7 +32,7 @@ export class ConfigPoller {
28
32
  lastSuccess = 0;
29
33
  timer;
30
34
  stopped = false;
31
- failureLog = new FailureLogger();
35
+ failureLog = new failure_log_js_1.FailureLogger();
32
36
  /** Resolves once the constructor's initial poll attempt has completed (success or failure). Exposed primarily so tests can synchronize deterministically instead of guessing a delay; not required for normal use. */
33
37
  ready;
34
38
  constructor(token, baseUrl, pollMs = 30_000, hardTtlMs = 120_000) {
@@ -86,3 +90,4 @@ export class ConfigPoller {
86
90
  clearInterval(this.timer);
87
91
  }
88
92
  }
93
+ exports.ConfigPoller = ConfigPoller;
package/dist/context.js CHANGED
@@ -1,15 +1,23 @@
1
- import { AsyncLocalStorage } from "node:async_hooks";
2
- import { randomBytes } from "node:crypto";
3
- const storage = new AsyncLocalStorage();
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.contextSnapshot = contextSnapshot;
4
+ exports.runWithContext = runWithContext;
5
+ exports.route = route;
6
+ exports.trace = trace;
7
+ exports.setSession = setSession;
8
+ exports.setTags = setTags;
9
+ const node_async_hooks_1 = require("node:async_hooks");
10
+ const node_crypto_1 = require("node:crypto");
11
+ const storage = new node_async_hooks_1.AsyncLocalStorage();
4
12
  let ambient = { tags: {} };
5
- export function contextSnapshot() {
13
+ function contextSnapshot() {
6
14
  const value = storage.getStore() ?? ambient;
7
15
  return { ...value, tags: { ...value.tags } };
8
16
  }
9
- export function runWithContext(context, fn) {
17
+ function runWithContext(context, fn) {
10
18
  return storage.run(context, fn);
11
19
  }
12
- export async function route(name, fn, options = {}) {
20
+ async function route(name, fn, options = {}) {
13
21
  const parent = contextSnapshot();
14
22
  const child = {
15
23
  ...parent,
@@ -24,28 +32,28 @@ export async function route(name, fn, options = {}) {
24
32
  };
25
33
  return storage.run(child, fn);
26
34
  }
27
- export function trace(name, fn, options = {}) {
35
+ function trace(name, fn, options = {}) {
28
36
  const parent = contextSnapshot();
29
37
  const requested = options.traceId?.trim();
30
38
  const reuse = parent.traceId !== undefined
31
39
  && (requested === undefined || requested === parent.traceId);
32
40
  const child = {
33
41
  ...parent,
34
- traceId: reuse ? parent.traceId : requested || randomBytes(16).toString("hex"),
42
+ traceId: reuse ? parent.traceId : requested || (0, node_crypto_1.randomBytes)(16).toString("hex"),
35
43
  traceName: reuse ? parent.traceName : String(name),
36
44
  parentSpanId: options.parentSpanId ?? (reuse ? parent.parentSpanId : undefined),
37
45
  captureText: options.captureText ?? parent.captureText,
38
46
  };
39
47
  return storage.run(child, fn);
40
48
  }
41
- export function setSession(sessionId) {
49
+ function setSession(sessionId) {
42
50
  const store = storage.getStore();
43
51
  if (store)
44
52
  store.sessionId = sessionId;
45
53
  else
46
54
  ambient = { ...ambient, sessionId };
47
55
  }
48
- export function setTags(tags) {
56
+ function setTags(tags) {
49
57
  const normalized = Object.fromEntries(Object.entries(tags).map(([key, value]) => [key, String(value)]));
50
58
  const store = storage.getStore();
51
59
  if (store)
@@ -1,9 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FailureLogger = void 0;
1
4
  /**
2
5
  * Rate-limited failure logging. Logs the first occurrence of a failure kind
3
6
  * immediately, then suppresses repeats within a quiet window and reports how
4
7
  * many were suppressed on the next log line for that kind.
5
8
  */
6
- export class FailureLogger {
9
+ class FailureLogger {
7
10
  quietMs;
8
11
  clock;
9
12
  sink;
@@ -30,3 +33,4 @@ export class FailureLogger {
30
33
  this.lastLogged.set(kind, now);
31
34
  }
32
35
  }
36
+ exports.FailureLogger = FailureLogger;
package/dist/index.d.ts CHANGED
@@ -2,13 +2,14 @@ import { route, setSession, setTags, trace, type RouteOptions, type TraceOptions
2
2
  import { BatchFirstIneligibleError, batchFirst, type BatchFirstMetadata, type BatchFirstPolicy, type BatchFirstProvider, type BatchFirstRequest, type BatchFirstResult, type BatchFirstSource, type LateBatchInfo } from "./batch-first.js";
3
3
  import { track } from "./track.js";
4
4
  import { type TransportMode, type WaitUntil } from "./transport.js";
5
- import { type VercelAISDKMiddleware, type VercelAISDKMiddlewareOptions, type VercelAISDKMiddlewareSpecificationOptions, type VercelAISDKMiddlewareVersionOptions, type VercelAISDKSpecificationVersion } from "./vercel-ai.js";
5
+ import { type VercelAISDKMiddleware, type VercelAISDKMiddlewareOptions as VercelAISDKCompatibilityOptions, type VercelAISDKMiddlewareSpecificationOptions, type VercelAISDKMiddlewareVersionOptions, type VercelAISDKSpecificationVersion } from "./vercel-ai.js";
6
6
  export interface MetergraphOptions {
7
7
  token?: string;
8
8
  ingestUrl?: string;
9
9
  captureText?: boolean;
10
10
  redact?: (text: string, kind: "request" | "response") => string;
11
11
  appRoot?: string;
12
+ repository?: string;
12
13
  skipFrames?: string[];
13
14
  environment?: string;
14
15
  disabled?: boolean;
@@ -19,6 +20,7 @@ export interface MetergraphOptions {
19
20
  configPollMs?: number;
20
21
  configHardTtlMs?: number;
21
22
  }
23
+ export type VercelAISDKMiddlewareOptions<TVersion extends VercelAISDKSpecificationVersion = "v3"> = MetergraphOptions & VercelAISDKCompatibilityOptions<TVersion>;
22
24
  export interface ModelForOptions {
23
25
  default: string;
24
26
  sessionKey?: string;
@@ -55,12 +57,13 @@ export declare function wrap<T extends Record<PropertyKey, any>>(client: T, prov
55
57
  export declare const wrapClient: typeof wrap;
56
58
  /**
57
59
  * Capture Vercel AI SDK language-model calls through its middleware API.
58
- * The returned middleware has no runtime dependency on `ai`.
60
+ * Initializes Metergraph from these options when no runtime exists. The
61
+ * returned middleware has no runtime dependency on `ai`.
59
62
  */
60
- export declare function vercelAISDKMiddleware(options: VercelAISDKMiddlewareVersionOptions): VercelAISDKMiddleware<"v2">;
61
- export declare function vercelAISDKMiddleware<TVersion extends VercelAISDKSpecificationVersion = "v3">(options?: VercelAISDKMiddlewareSpecificationOptions<TVersion>): VercelAISDKMiddleware<TVersion>;
63
+ export declare function vercelAISDKMiddleware(options: MetergraphOptions & VercelAISDKMiddlewareVersionOptions): VercelAISDKMiddleware<"v2">;
64
+ export declare function vercelAISDKMiddleware<TVersion extends VercelAISDKSpecificationVersion = "v3">(options?: MetergraphOptions & VercelAISDKMiddlewareSpecificationOptions<TVersion>): VercelAISDKMiddleware<TVersion>;
62
65
  export { route, setSession, setTags, trace, track };
63
- export type { RouteOptions, TraceOptions, TransportMode, VercelAISDKMiddleware, VercelAISDKMiddlewareOptions, VercelAISDKSpecificationVersion, };
66
+ export type { RouteOptions, TraceOptions, TransportMode, VercelAISDKMiddleware, VercelAISDKSpecificationVersion, };
64
67
  /**
65
68
  * Explicit, opt-in batch-first execution over a provider's Batch API —
66
69
  * never enabled by wrap()/capture defaults or by an environment variable.