@harrym1707/sdk 0.0.0-stage → 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/LICENSE +98 -0
- package/README.md +48 -2
- package/bin/mesh-demo.mjs +105 -0
- package/bin/mesh-proxy.mjs +39 -0
- package/bin/mesh-quote.mjs +45 -0
- package/bin/mesh-report.mjs +47 -0
- package/index.cjs +6306 -0
- package/index.js +6204 -0
- package/package.json +39 -4
- package/types/blind-features.d.ts +28 -0
- package/types/cache-volatility-guard.d.ts +31 -0
- package/types/core/account-store.d.ts +7 -0
- package/types/core/accounts.d.ts +134 -0
- package/types/core/billing-worker.d.ts +113 -0
- package/types/core/budget.d.ts +216 -0
- package/types/core/cache-simulator.d.ts +271 -0
- package/types/core/confidence.d.ts +36 -0
- package/types/core/cost.d.ts +16 -0
- package/types/core/evaluator.d.ts +16 -0
- package/types/core/gateway.d.ts +75 -0
- package/types/core/geo-visibility.d.ts +25 -0
- package/types/core/github-oauth.d.ts +41 -0
- package/types/core/helicone.d.ts +6 -0
- package/types/core/index.d.ts +36 -0
- package/types/core/langfuse.d.ts +7 -0
- package/types/core/ledger-store.d.ts +62 -0
- package/types/core/litellm.d.ts +15 -0
- package/types/core/local-tier.d.ts +82 -0
- package/types/core/model-prices.d.ts +25 -0
- package/types/core/output-diagnostics.d.ts +39 -0
- package/types/core/price-catalogue.d.ts +168 -0
- package/types/core/provider-usage.d.ts +84 -0
- package/types/core/quote-report.d.ts +54 -0
- package/types/core/replay.d.ts +2 -0
- package/types/core/router.d.ts +9 -0
- package/types/core/routing.d.ts +282 -0
- package/types/core/savings-ledger.d.ts +349 -0
- package/types/core/savings-model.d.ts +132 -0
- package/types/core/stripe-billing.d.ts +67 -0
- package/types/core/stripe-client.d.ts +117 -0
- package/types/core/stripe-sink.d.ts +77 -0
- package/types/core/theo-coverage.d.ts +49 -0
- package/types/core/token-reduction.d.ts +219 -0
- package/types/core/tool-schema.d.ts +64 -0
- package/types/core/traffic.d.ts +182 -0
- package/types/core/triage.d.ts +70 -0
- package/types/core/types.d.ts +149 -0
- package/types/core/workflow-sessions.d.ts +50 -0
- package/types/cta.d.ts +60 -0
- package/types/evaluation-capture.d.ts +11 -0
- package/types/exact-cache.d.ts +20 -0
- package/types/graders.d.ts +53 -0
- package/types/index.d.ts +31 -0
- package/types/ledger-mirror.d.ts +38 -0
- package/types/openai.d.ts +23 -0
- package/types/proxy.d.ts +104 -0
- package/types/reduce-request.d.ts +272 -0
- package/types/replay-gate.d.ts +120 -0
- package/types/report.d.ts +33 -0
- package/types/routing.d.ts +11 -0
- package/types/savings-ledger.d.ts +22 -0
- package/types/savings-snapshot.d.ts +11 -0
- package/types/semantic-compaction.d.ts +84 -0
- package/types/telemetry.d.ts +6 -0
- package/types/theo-agent-store.d.ts +27 -0
- package/types/theo-agent.d.ts +247 -0
- package/types/theo-gate.d.ts +75 -0
- package/types/theo-policy.d.ts +219 -0
- package/types/types.d.ts +287 -0
- package/types/wrap.d.ts +60 -0
package/types/types.d.ts
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import type { LedgerGateVerdict } from "../../core/dist/src/savings-ledger.js";
|
|
2
|
+
import type { PriceCatalogue } from "../../core/dist/src/price-catalogue.js";
|
|
3
|
+
import type { MeshReductionSummary, MeshTokenReductionConfig } from "./reduce-request.js";
|
|
4
|
+
export type MeshTelemetryConfig = {
|
|
5
|
+
/**
|
|
6
|
+
* Where to POST usage metadata. Unset (the default) means telemetry is OFF
|
|
7
|
+
* and nothing is ever sent anywhere. There is no mode that sends content:
|
|
8
|
+
* events carry usage numbers and lever names, never prompts, and provider
|
|
9
|
+
* error text is masked before send.
|
|
10
|
+
*/
|
|
11
|
+
endpoint?: string;
|
|
12
|
+
};
|
|
13
|
+
export type MeshRequestEvent = {
|
|
14
|
+
/** What reduction removed from this request, when reduction is configured. */
|
|
15
|
+
reduction?: MeshReductionSummary;
|
|
16
|
+
requestId: string;
|
|
17
|
+
applicationId: string;
|
|
18
|
+
provider: string;
|
|
19
|
+
model: string;
|
|
20
|
+
requestedModel?: string;
|
|
21
|
+
taskClass?: string;
|
|
22
|
+
workflow?: string;
|
|
23
|
+
difficulty?: "low" | "medium" | "high";
|
|
24
|
+
riskLevel?: "low" | "medium" | "high";
|
|
25
|
+
contextProfileId?: string;
|
|
26
|
+
contextProfileVersion?: string;
|
|
27
|
+
routePolicyId?: string;
|
|
28
|
+
routeReason?: string;
|
|
29
|
+
estimatedCostSavingsPercent?: number;
|
|
30
|
+
modelsAttempted?: string[];
|
|
31
|
+
fallbackUsed?: boolean;
|
|
32
|
+
fallbackReason?: "quality_rejected" | "quality_check_error" | "candidate_error" | "context_transform_unavailable" | "context_transform_error" | "context_profile_mismatch";
|
|
33
|
+
qualityCheckPassed?: boolean;
|
|
34
|
+
cacheHit?: boolean;
|
|
35
|
+
tokensAvoided?: number;
|
|
36
|
+
costAvoidedUsd?: number;
|
|
37
|
+
inputTokens?: number;
|
|
38
|
+
outputTokens?: number;
|
|
39
|
+
uncachedInputTokens?: number;
|
|
40
|
+
cachedInputTokens?: number;
|
|
41
|
+
cacheWriteInputTokens?: number;
|
|
42
|
+
/** Output-waste metering: re-emission of request context in the completion (tokens only, never billed). */
|
|
43
|
+
outputDiagnostics?: {
|
|
44
|
+
inspectedOutputTokens: number;
|
|
45
|
+
reEmittedOutputTokens: number;
|
|
46
|
+
reEmittedCodeTokens: number;
|
|
47
|
+
};
|
|
48
|
+
/** This request was byte-identical to an earlier one from the same app. */
|
|
49
|
+
duplicateOfRequestId?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Provider-reported TTL split of the cache writes (Anthropic
|
|
52
|
+
* usage.cache_creation). Present as a PAIR only when the provider reported
|
|
53
|
+
* the split; absent means unknown, and billing uses MESH's stamped TTL when
|
|
54
|
+
* available (otherwise the 1h premium, dispute-safe), never assumes 5m.
|
|
55
|
+
*/
|
|
56
|
+
cacheWrite5mInputTokens?: number;
|
|
57
|
+
cacheWrite1hInputTokens?: number;
|
|
58
|
+
costUsd?: number;
|
|
59
|
+
/**
|
|
60
|
+
* service_tier as reported on the final RESPONSE, never the requested one: a
|
|
61
|
+
* flex request that 429s and falls back to standard bills standard and earns
|
|
62
|
+
* zero tier savings. Absent when the provider reports none.
|
|
63
|
+
*/
|
|
64
|
+
responseServiceTier?: string;
|
|
65
|
+
/** Response service_tier per attempt, aligned with modelsAttempted; null where unreported. */
|
|
66
|
+
attemptServiceTiers?: Array<string | null>;
|
|
67
|
+
latencyMs: number;
|
|
68
|
+
status: "succeeded" | "failed";
|
|
69
|
+
error?: string;
|
|
70
|
+
timestamp: string;
|
|
71
|
+
};
|
|
72
|
+
export type MeshRoutingEvidence = {
|
|
73
|
+
baselineModel: string;
|
|
74
|
+
candidateModel: string;
|
|
75
|
+
eligibleForReview: boolean;
|
|
76
|
+
sampleSize: number;
|
|
77
|
+
candidateAccuracyLower95: number;
|
|
78
|
+
accuracyDrop: number;
|
|
79
|
+
baselineCostUsd: number;
|
|
80
|
+
candidateCostUsd: number;
|
|
81
|
+
};
|
|
82
|
+
export type MeshRoutingCandidate = {
|
|
83
|
+
model: string;
|
|
84
|
+
/** Share of requests assigned to this candidate, from 0 to 1. */
|
|
85
|
+
trafficShare: number;
|
|
86
|
+
/** Explicit human approval after reviewing the offline replay report. */
|
|
87
|
+
approved: boolean;
|
|
88
|
+
evidence: MeshRoutingEvidence;
|
|
89
|
+
/** Optional lower output-token cap for this candidate. The baseline request is unchanged on fallback. */
|
|
90
|
+
maxOutputTokens?: number;
|
|
91
|
+
/** Versioned deterministic context-reduction transform evaluated in replay. */
|
|
92
|
+
contextProfileId?: string;
|
|
93
|
+
};
|
|
94
|
+
export type MeshRoutingPolicy = {
|
|
95
|
+
id: string;
|
|
96
|
+
taskClass: string;
|
|
97
|
+
workflow?: string;
|
|
98
|
+
difficulty?: "low" | "medium" | "high";
|
|
99
|
+
riskLevel?: "low" | "medium" | "high";
|
|
100
|
+
baselineModel: string;
|
|
101
|
+
minimumSamples: number;
|
|
102
|
+
minimumCandidateAccuracyLower95: number;
|
|
103
|
+
maximumAccuracyDrop: number;
|
|
104
|
+
candidates: MeshRoutingCandidate[];
|
|
105
|
+
};
|
|
106
|
+
export type MeshRoutingConfig = {
|
|
107
|
+
policies: MeshRoutingPolicy[];
|
|
108
|
+
/** Return a stable, non-sensitive key such as tenant/user or job ID. */
|
|
109
|
+
getRequestKey: (request: unknown) => string | undefined;
|
|
110
|
+
};
|
|
111
|
+
export type MeshExactCacheConfig = {
|
|
112
|
+
/** Maximum completed responses retained in this client process. */
|
|
113
|
+
maxEntries: number;
|
|
114
|
+
/** Cache entry lifetime in milliseconds. */
|
|
115
|
+
ttlMs: number;
|
|
116
|
+
/** Return an isolation scope such as tenant ID; returning undefined disables caching for that request. */
|
|
117
|
+
getScopeKey: (request: unknown) => string | undefined;
|
|
118
|
+
};
|
|
119
|
+
export type MeshEvaluationCaptureAttempt = {
|
|
120
|
+
model: string;
|
|
121
|
+
contextProfileId?: string;
|
|
122
|
+
maxOutputTokens?: number;
|
|
123
|
+
request: unknown;
|
|
124
|
+
response?: unknown;
|
|
125
|
+
error?: string;
|
|
126
|
+
inputTokens?: number;
|
|
127
|
+
outputTokens?: number;
|
|
128
|
+
costUsd?: number;
|
|
129
|
+
score?: number;
|
|
130
|
+
};
|
|
131
|
+
/** Content-bearing local evaluation record. Enable only with an explicit redactor. */
|
|
132
|
+
export type MeshEvaluationCaptureRecord = {
|
|
133
|
+
schemaVersion: 1;
|
|
134
|
+
id: string;
|
|
135
|
+
caseId: string;
|
|
136
|
+
/** Optional stable, non-sensitive group ID used to keep related prompts in one split. */
|
|
137
|
+
groupId?: string;
|
|
138
|
+
applicationId: string;
|
|
139
|
+
requestedModel: string;
|
|
140
|
+
finalModel: string;
|
|
141
|
+
taskClass?: string;
|
|
142
|
+
workflow?: string;
|
|
143
|
+
difficulty?: "low" | "medium" | "high";
|
|
144
|
+
riskLevel?: "low" | "medium" | "high";
|
|
145
|
+
request: unknown;
|
|
146
|
+
expected?: unknown;
|
|
147
|
+
attempts: MeshEvaluationCaptureAttempt[];
|
|
148
|
+
cacheHit?: boolean;
|
|
149
|
+
routeReason?: string;
|
|
150
|
+
status: "succeeded" | "failed";
|
|
151
|
+
timestamp: string;
|
|
152
|
+
};
|
|
153
|
+
export type MeshEvaluationCaptureConfig = {
|
|
154
|
+
/** Stable ID across deliberate replays of the same application test case. */
|
|
155
|
+
getCaseId?: (request: unknown) => string | undefined;
|
|
156
|
+
/** Optional stable group key, ideally a one-way hash of the normalized input. */
|
|
157
|
+
getGroupId?: (request: unknown) => string | undefined;
|
|
158
|
+
/** Optional trusted answer/label from a test fixture or application outcome. */
|
|
159
|
+
getExpected?: (request: unknown) => unknown;
|
|
160
|
+
/** Task-specific scorer returning a normalized value in [0, 1]. */
|
|
161
|
+
score?: (expected: unknown, response: unknown, meta: {
|
|
162
|
+
model: string;
|
|
163
|
+
workflow?: string;
|
|
164
|
+
taskClass?: string;
|
|
165
|
+
}) => number;
|
|
166
|
+
/** Required privacy boundary: return a sanitized copy, or undefined to discard the record. */
|
|
167
|
+
redact: (record: MeshEvaluationCaptureRecord) => MeshEvaluationCaptureRecord | undefined;
|
|
168
|
+
/** Write sanitized records locally or to an explicitly chosen sink. */
|
|
169
|
+
write: (record: MeshEvaluationCaptureRecord) => void | Promise<void>;
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* Opt-in savings ledger: an append-only, hash-chained JSONL spool of billable
|
|
173
|
+
* events, one per request, written synchronously from the event path. Off by
|
|
174
|
+
* default; every write is wrapped so a full disk or bad path can never throw
|
|
175
|
+
* into the request path. The spool is the billing source of truth a customer
|
|
176
|
+
* recomputes themselves with `recomputeInvoice`.
|
|
177
|
+
*/
|
|
178
|
+
/**
|
|
179
|
+
* Mirror appended ledger records to a Mesh metering API. When present, each
|
|
180
|
+
* record is pushed fire-and-forget (with retry) to `${apiUrl}/v1/ledger/events`
|
|
181
|
+
* AFTER the local append, authenticated by the Mesh account key. The push never
|
|
182
|
+
* blocks or throws into the request path, and the local spool is always kept so
|
|
183
|
+
* the customer can still recompute every figure themselves.
|
|
184
|
+
*
|
|
185
|
+
* The account key is NOT the provider API key — it only identifies the Mesh
|
|
186
|
+
* account. The provider key never reaches the Mesh API.
|
|
187
|
+
*/
|
|
188
|
+
export type MeshLedgerMirrorConfig = {
|
|
189
|
+
/** Mesh API base URL, e.g. https://www.mesh-technology.com. */
|
|
190
|
+
apiUrl: string;
|
|
191
|
+
/** Mesh account key (mesh_sk_…). */
|
|
192
|
+
accountKey: string;
|
|
193
|
+
/** Injectable fetch for tests; defaults to the global fetch. */
|
|
194
|
+
fetch?: typeof fetch;
|
|
195
|
+
/** Retry attempts per flush before the batch waits for the next append. Default 3. */
|
|
196
|
+
maxRetries?: number;
|
|
197
|
+
/** Max unconfirmed records buffered before the mirror quietly stops (local spool is unaffected). Default 5000. */
|
|
198
|
+
maxPending?: number;
|
|
199
|
+
};
|
|
200
|
+
export type MeshSavingsLedgerConfig = {
|
|
201
|
+
/** Append-only JSONL file; parent directories are created on first write. */
|
|
202
|
+
path: string;
|
|
203
|
+
/** Optional mirror of each appended record to the Mesh metering API. */
|
|
204
|
+
mirror?: MeshLedgerMirrorConfig;
|
|
205
|
+
/** Provider key used to resolve rates in the catalogue. Default "openai". */
|
|
206
|
+
provider?: string;
|
|
207
|
+
/** Rates to pin event pricing against. Default: the published catalogue. */
|
|
208
|
+
catalogue?: PriceCatalogue;
|
|
209
|
+
/**
|
|
210
|
+
* Replay-gate verdict reference per lossy lever id. A lossy lever's savings
|
|
211
|
+
* bill only when its verdict here is "approved"; unknown lossy levers are
|
|
212
|
+
* recorded and never billed.
|
|
213
|
+
*/
|
|
214
|
+
gateVerdicts?: Record<string, LedgerGateVerdict>;
|
|
215
|
+
/** Optional task correlation so a failed task's turns are excluded from the invoice. */
|
|
216
|
+
getCorrelation?: (event: MeshRequestEvent) => {
|
|
217
|
+
taskId?: string;
|
|
218
|
+
turnIndex?: number;
|
|
219
|
+
} | undefined;
|
|
220
|
+
/**
|
|
221
|
+
* Optional measured counterfactual cost (standard tier, no levers) in USD for
|
|
222
|
+
* this request, from a replay/counterfactual measurement path. Stored on the
|
|
223
|
+
* event; the measured token-reduction delta bills only when it is present.
|
|
224
|
+
*/
|
|
225
|
+
getBaselineUsd?: (event: MeshRequestEvent) => number | undefined;
|
|
226
|
+
};
|
|
227
|
+
export type MeshRequestContext = {
|
|
228
|
+
taskClass?: string;
|
|
229
|
+
workflow?: string;
|
|
230
|
+
difficulty?: "low" | "medium" | "high";
|
|
231
|
+
riskLevel?: "low" | "medium" | "high";
|
|
232
|
+
};
|
|
233
|
+
/** A deterministic, versioned context transformation that can be replayed before rollout. */
|
|
234
|
+
export type MeshContextProfile = {
|
|
235
|
+
id: string;
|
|
236
|
+
version: string;
|
|
237
|
+
/** Optional guard; every supplied field must exactly match the request's trusted context. */
|
|
238
|
+
match?: Partial<Pick<MeshRequestContext, "taskClass" | "workflow" | "difficulty" | "riskLevel">>;
|
|
239
|
+
/** Transform synchronously to avoid adding another model call to the inference path. */
|
|
240
|
+
transform: (request: unknown, context: MeshRequestContext) => unknown;
|
|
241
|
+
};
|
|
242
|
+
export type MeshOptions = {
|
|
243
|
+
applicationId: string;
|
|
244
|
+
pricing?: {
|
|
245
|
+
inputPerMillion: number;
|
|
246
|
+
cachedInputPerMillion?: number;
|
|
247
|
+
cacheWriteInputPerMillion?: number;
|
|
248
|
+
/** 1h-TTL cache writes bill at their own premium (Anthropic: 2x base input). */
|
|
249
|
+
cacheWrite1hInputPerMillion?: number;
|
|
250
|
+
outputPerMillion: number;
|
|
251
|
+
};
|
|
252
|
+
pricingByModel?: Record<string, {
|
|
253
|
+
inputPerMillion: number;
|
|
254
|
+
cachedInputPerMillion?: number;
|
|
255
|
+
cacheWriteInputPerMillion?: number;
|
|
256
|
+
/** 1h-TTL cache writes bill at their own premium (Anthropic: 2x base input). */
|
|
257
|
+
cacheWrite1hInputPerMillion?: number;
|
|
258
|
+
outputPerMillion: number;
|
|
259
|
+
}>;
|
|
260
|
+
telemetry?: MeshTelemetryConfig;
|
|
261
|
+
classify?: (request: unknown) => string | undefined;
|
|
262
|
+
getContext?: (request: unknown) => MeshRequestContext;
|
|
263
|
+
/**
|
|
264
|
+
* Token reduction applied to every request, independent of routing. Omit to
|
|
265
|
+
* leave requests untouched.
|
|
266
|
+
*/
|
|
267
|
+
tokenReduction?: MeshTokenReductionConfig;
|
|
268
|
+
contextProfiles?: readonly MeshContextProfile[];
|
|
269
|
+
/** @deprecated Use versioned contextProfiles for replayable context transformations. */
|
|
270
|
+
contextTransforms?: Record<string, (request: unknown, context: MeshRequestContext) => unknown>;
|
|
271
|
+
routing?: MeshRoutingConfig;
|
|
272
|
+
/** Return false or throw to retry a routed candidate request on the baseline model. */
|
|
273
|
+
qualityCheck?: (input: {
|
|
274
|
+
request: unknown;
|
|
275
|
+
response: unknown;
|
|
276
|
+
taskClass?: string;
|
|
277
|
+
context?: MeshRequestContext;
|
|
278
|
+
candidateModel: string;
|
|
279
|
+
}) => boolean | Promise<boolean>;
|
|
280
|
+
/** Opt-in, in-memory exact response cache. Tool/conversation/streaming requests are bypassed. */
|
|
281
|
+
exactCache?: MeshExactCacheConfig;
|
|
282
|
+
/** Off by default. Captures request/response content only when explicitly configured. */
|
|
283
|
+
evaluationCapture?: MeshEvaluationCaptureConfig;
|
|
284
|
+
/** Off by default. Appends hash-chained billable events to a local JSONL spool. */
|
|
285
|
+
ledger?: MeshSavingsLedgerConfig;
|
|
286
|
+
onEvent?: (event: MeshRequestEvent) => void;
|
|
287
|
+
};
|
package/types/wrap.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { MeshTokenReductionConfig } from "./reduce-request.js";
|
|
2
|
+
/**
|
|
3
|
+
* wrapMesh — the one-line drop-in for an existing provider client.
|
|
4
|
+
*
|
|
5
|
+
* import OpenAI from "openai";
|
|
6
|
+
* import { wrapMesh } from "@harrym1707/sdk";
|
|
7
|
+
* const openai = wrapMesh(new OpenAI()); // <- the only change
|
|
8
|
+
* // ...use `openai` exactly as before...
|
|
9
|
+
* console.log(openai.mesh.savings()); // { requests, savedUsd, ... }
|
|
10
|
+
*
|
|
11
|
+
* This is `withMesh` with sane, zero-config defaults for someone who just wants
|
|
12
|
+
* their AI app to spend less without learning the proxy, the ledger, or any
|
|
13
|
+
* options object. The client's response shapes are preserved, its own key is
|
|
14
|
+
* used, prompts never leave the machine, and reduction is LOSSLESS-ONLY by
|
|
15
|
+
* default — so there is no quality risk to switching one import.
|
|
16
|
+
*
|
|
17
|
+
* The savings number is the real measured one: every request appends a
|
|
18
|
+
* hash-chained ledger event priced from provider-reported usage, and
|
|
19
|
+
* `mesh.savings()` recomputes the invoice from that spool — the same audit a
|
|
20
|
+
* customer runs. It is never MESH's own token estimate.
|
|
21
|
+
*/
|
|
22
|
+
export type WrapMeshOptions = {
|
|
23
|
+
/** Names this app on the ledger + invoice. Default "app". */
|
|
24
|
+
app?: string;
|
|
25
|
+
/** Where the hash-chained savings ledger is written. Default ./.mesh/<app>.jsonl */
|
|
26
|
+
ledgerPath?: string;
|
|
27
|
+
/** Catalogue provider key for pricing. Auto-detected from the client; override if needed. */
|
|
28
|
+
provider?: string;
|
|
29
|
+
/** Override reduction. Default: lossless-only (safe, no quality gate needed). */
|
|
30
|
+
tokenReduction?: MeshTokenReductionConfig;
|
|
31
|
+
/** Opt into the Anthropic prompt-cache stamp on multi-turn traffic ("5m" | "1h"). */
|
|
32
|
+
cacheTtl?: "5m" | "1h";
|
|
33
|
+
/**
|
|
34
|
+
* Mirror ledger events to a Mesh account. Set both to push each metered
|
|
35
|
+
* event to `${meshApiUrl}/v1/ledger/events`, authenticated by the Mesh
|
|
36
|
+
* account key from signup. Reads MESH_API_URL / MESH_ACCOUNT_KEY from the
|
|
37
|
+
* environment when omitted. The provider key is never sent to Mesh.
|
|
38
|
+
*/
|
|
39
|
+
meshApiUrl?: string;
|
|
40
|
+
meshAccountKey?: string;
|
|
41
|
+
};
|
|
42
|
+
export type MeshSavingsSummary = {
|
|
43
|
+
/** Requests metered through MESH for this app. */
|
|
44
|
+
requests: number;
|
|
45
|
+
/** Net verified savings in USD (never MESH's token estimate; from provider usage). */
|
|
46
|
+
savedUsd: number;
|
|
47
|
+
/** MESH's fee at 1% of verified savings. */
|
|
48
|
+
feeUsd: number;
|
|
49
|
+
verdict: "charge" | "do_not_charge";
|
|
50
|
+
ledgerPath: string;
|
|
51
|
+
};
|
|
52
|
+
export type MeshHandle = {
|
|
53
|
+
/** Recompute the measured savings from the ledger spool. */
|
|
54
|
+
savings(): MeshSavingsSummary;
|
|
55
|
+
/** The ledger spool path, for `recomputeInvoice` / `mesh-report`. */
|
|
56
|
+
ledgerPath: string;
|
|
57
|
+
};
|
|
58
|
+
export declare function wrapMesh<T extends object>(client: T, options?: WrapMeshOptions): T & {
|
|
59
|
+
mesh: MeshHandle;
|
|
60
|
+
};
|