@dvmkit/sdk 0.3.1-rc.10 → 0.3.3-rc.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-2D75MNNG.js → chunk-2SD2W2BG.js} +8 -5
- package/dist/{chunk-XZ7LW4S5.js → chunk-4J32DTLT.js} +20 -16
- package/dist/{chunk-XMDQOXHO.js → chunk-4UZN2GP5.js} +4 -1
- package/dist/{chunk-YO56VCTQ.js → chunk-6DOGTAHA.js} +190 -75
- package/dist/{chunk-VA7GT6C6.js → chunk-7X6UDVCQ.js} +56 -53
- package/dist/{chunk-4A2RAKCW.js → chunk-BYCEKO65.js} +7 -3
- package/dist/{chunk-MMCE7XSR.js → chunk-C2AGARLM.js} +1 -13
- package/dist/{chunk-H2MEFVH6.js → chunk-CE7XEHYC.js} +7 -4
- package/dist/{chunk-D7YQYLLM.js → chunk-EAMZZ2B4.js} +1 -1
- package/dist/chunk-ETXDTUJO.js +1438 -0
- package/dist/{chunk-FDKRXOZO.js → chunk-FI4CST2D.js} +57 -49
- package/dist/{chunk-HHTL3ZFT.js → chunk-JDFLRNAZ.js} +16 -13
- package/dist/{chunk-U5VNEALI.js → chunk-M4QDXD2A.js} +1 -1
- package/dist/{chunk-GAIPXGM3.js → chunk-O3QDFPKM.js} +1 -1
- package/dist/{chunk-MD3H3BF7.js → chunk-O5AT6S5T.js} +1 -1
- package/dist/{chunk-C3MTFLC6.js → chunk-P6QON7ER.js} +14 -12
- package/dist/{chunk-CC3UY6OS.js → chunk-UZC4A4DM.js} +379 -374
- package/dist/{chunk-QX52F6IB.js → chunk-VAMSJRJT.js} +7 -4
- package/dist/{chunk-AJNFXR7J.js → chunk-VHNPVGSA.js} +4 -1
- package/dist/{chunk-N5B66UOS.js → chunk-YHN3WMMF.js} +4 -1
- package/dist/{chunk-O6D72KYA.js → chunk-YRDA7EWN.js} +1 -1
- package/dist/{chunk-VIVXB4CD.js → chunk-YYQG4R7T.js} +1 -1
- package/dist/{chunk-FPOLJRBF.js → chunk-Z3EHBW2G.js} +2 -2
- package/dist/{credit-ledger-MHA652TV.js → credit-ledger-A35WH2TI.js} +3 -2
- package/dist/index.js +4 -3
- package/dist/internal/caller.d.ts +32 -3
- package/dist/internal/caller.js +22 -12
- package/dist/internal/index.js +1 -1
- package/dist/internal/server.js +16 -15
- package/dist/memory-credit-ledger-2LBZVMKJ.js +10 -0
- package/dist/{mpp-setup-MPP3ST5X.js → mpp-setup-7CGBKNUP.js} +2 -1
- package/dist/{payout-reporter-KEMUXEUO.js → payout-reporter-ZMOA37GN.js} +2 -1
- package/dist/{postgres-consumed-credential-store-6N2V5MJN.js → postgres-consumed-credential-store-CUQJKRSL.js} +4 -1
- package/dist/{postgres-job-store-VE2JRUEC.js → postgres-job-store-MSD2HZOI.js} +2 -1
- package/dist/{postgres-replay-store-ZF4JNZOW.js → postgres-replay-store-ARZSQ45X.js} +2 -1
- package/dist/{pricing-MU5GNUJZ.js → pricing-XT2IAPNE.js} +2 -1
- package/dist/{revenue-reporter-O75BGYFK.js → revenue-reporter-EKJOGQYR.js} +2 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +112 -112
- package/dist/{tempo-charge-store-SDTUNTKA.js → tempo-charge-store-4WX7FPOV.js} +2 -1
- package/dist/{tempo-lifecycle-G5SB4HFC.js → tempo-lifecycle-TJ62A7UX.js} +3 -3
- package/dist/{tempo-session-store-WF3VZXNF.js → tempo-session-store-LCSDHB7G.js} +3 -2
- package/dist/{tempo-wallet-ZFNUDFVO.js → tempo-wallet-RCGBBAJH.js} +1 -1
- package/dist/testing/index.js +4 -3
- package/dist/{x402-CI6PSHNO.js → x402-S47Q77UE.js} +2 -2
- package/package.json +1 -1
- package/dist/memory-credit-ledger-BYBATRN3.js +0 -9
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
callerLoggers
|
|
3
3
|
} from "./chunk-66HGCPBU.js";
|
|
4
|
+
import {
|
|
5
|
+
diagnosticConsole,
|
|
6
|
+
projectSpanRow
|
|
7
|
+
} from "./chunk-ETXDTUJO.js";
|
|
4
8
|
|
|
5
9
|
// src/lib/x402/env.ts
|
|
6
10
|
import { isAddress } from "viem";
|
|
@@ -136,6 +140,9 @@ var SpanWriter = class {
|
|
|
136
140
|
backoffTimer = null;
|
|
137
141
|
/** Enqueue a span row. Non-blocking — truncates oversize JSONB and appends to buffer. */
|
|
138
142
|
enqueue(row) {
|
|
143
|
+
const projected = projectSpanRow(row);
|
|
144
|
+
if (!projected.ok) return;
|
|
145
|
+
row = projected.row;
|
|
139
146
|
const originalBytes = JSON.stringify({
|
|
140
147
|
attributes: row.attributes,
|
|
141
148
|
dimensions: row.dimensions
|
|
@@ -146,14 +153,12 @@ var SpanWriter = class {
|
|
|
146
153
|
if (this.buffer.length >= MAX_BUFFERED_SPANS) {
|
|
147
154
|
this.dropCount++;
|
|
148
155
|
if (this.dropCount === 1 || this.dropCount % 1e3 === 0) {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
})
|
|
156
|
-
);
|
|
156
|
+
diagnosticConsole.error({
|
|
157
|
+
event: "span_buffer_drop",
|
|
158
|
+
reason: "buffer_full",
|
|
159
|
+
total_dropped: this.dropCount,
|
|
160
|
+
buffer_size: this.buffer.length
|
|
161
|
+
});
|
|
157
162
|
}
|
|
158
163
|
return;
|
|
159
164
|
}
|
|
@@ -182,24 +187,26 @@ var SpanWriter = class {
|
|
|
182
187
|
if (this.flushing) return;
|
|
183
188
|
if (this.buffer.length === 0) return;
|
|
184
189
|
this.flushing = true;
|
|
185
|
-
const
|
|
190
|
+
const queuedBatch = this.buffer;
|
|
186
191
|
this.buffer = [];
|
|
187
192
|
try {
|
|
193
|
+
const batch = queuedBatch.flatMap((row) => {
|
|
194
|
+
const projected = projectSpanRow(row);
|
|
195
|
+
return projected.ok ? [projected.row] : [];
|
|
196
|
+
});
|
|
188
197
|
await this.transport.send(batch);
|
|
189
198
|
this.consecutiveFailures = 0;
|
|
190
|
-
} catch (
|
|
199
|
+
} catch (_err) {
|
|
191
200
|
this.consecutiveFailures++;
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
})
|
|
199
|
-
);
|
|
201
|
+
diagnosticConsole.error({
|
|
202
|
+
event: "span_flush_failed",
|
|
203
|
+
error: void 0,
|
|
204
|
+
batch_size: queuedBatch.length,
|
|
205
|
+
consecutive_failures: this.consecutiveFailures
|
|
206
|
+
});
|
|
200
207
|
const room = MAX_BUFFERED_SPANS - this.buffer.length;
|
|
201
208
|
if (room > 0) {
|
|
202
|
-
this.buffer.unshift(...
|
|
209
|
+
this.buffer.unshift(...queuedBatch.slice(0, room));
|
|
203
210
|
}
|
|
204
211
|
if (this.consecutiveFailures > 1) {
|
|
205
212
|
const exponent = Math.min(this.consecutiveFailures - 1, MAX_BACKOFF_EXPONENT);
|
|
@@ -252,43 +259,36 @@ var SpanWriter = class {
|
|
|
252
259
|
}).length;
|
|
253
260
|
let mode;
|
|
254
261
|
if (afterStringPass <= MAX_ROW_JSONB_BYTES) {
|
|
255
|
-
row =
|
|
262
|
+
row.attributes = truncatedAttrs;
|
|
256
263
|
mode = "string_pass";
|
|
257
264
|
} else {
|
|
258
265
|
const dimSize = JSON.stringify(row.dimensions).length;
|
|
259
266
|
if (dimSize > MAX_ROW_JSONB_BYTES) {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
})
|
|
267
|
-
);
|
|
267
|
+
diagnosticConsole.error({
|
|
268
|
+
event: "span_dimension_oversized",
|
|
269
|
+
name: row.name,
|
|
270
|
+
dataset: row.dataset,
|
|
271
|
+
dimension_bytes: dimSize
|
|
272
|
+
});
|
|
268
273
|
}
|
|
269
|
-
row = {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
original_bytes: originalBytes,
|
|
274
|
-
original_keys: Object.keys(row.attributes).sort()
|
|
275
|
-
}
|
|
274
|
+
row.attributes = {
|
|
275
|
+
_truncated: true,
|
|
276
|
+
original_bytes: originalBytes,
|
|
277
|
+
original_keys: Object.keys(row.attributes).sort()
|
|
276
278
|
};
|
|
277
279
|
mode = "wholesale_fallback";
|
|
278
280
|
}
|
|
279
281
|
this.truncatedSpanCount++;
|
|
280
282
|
if (this.truncatedSpanCount === 1 || this.truncatedSpanCount % 100 === 0) {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
})
|
|
291
|
-
);
|
|
283
|
+
diagnosticConsole.error({
|
|
284
|
+
event: "span_truncated",
|
|
285
|
+
name: row.name,
|
|
286
|
+
dataset: row.dataset,
|
|
287
|
+
original_bytes: originalBytes,
|
|
288
|
+
after_string_pass_bytes: afterStringPass,
|
|
289
|
+
mode,
|
|
290
|
+
total_truncated: this.truncatedSpanCount
|
|
291
|
+
});
|
|
292
292
|
}
|
|
293
293
|
return row;
|
|
294
294
|
}
|
|
@@ -318,7 +318,10 @@ async function insertSpanBatch(pool, rows) {
|
|
|
318
318
|
const values = [];
|
|
319
319
|
const placeholders = [];
|
|
320
320
|
let idx = 1;
|
|
321
|
-
for (const
|
|
321
|
+
for (const candidate of rows) {
|
|
322
|
+
const projected = projectSpanRow(candidate);
|
|
323
|
+
if (!projected.ok) continue;
|
|
324
|
+
const row = projected.row;
|
|
322
325
|
const rowPlaceholders = [];
|
|
323
326
|
for (const col of SPAN_COLUMNS) {
|
|
324
327
|
let val = row[col] ?? null;
|
|
@@ -336,6 +339,7 @@ async function insertSpanBatch(pool, rows) {
|
|
|
336
339
|
}
|
|
337
340
|
placeholders.push(`(${rowPlaceholders.join(", ")})`);
|
|
338
341
|
}
|
|
342
|
+
if (placeholders.length === 0) return;
|
|
339
343
|
await pool.query(
|
|
340
344
|
`INSERT INTO observability.spans (${SPAN_COLUMNS.join(", ")})
|
|
341
345
|
VALUES ${placeholders.join(",\n")}
|
|
@@ -364,14 +368,18 @@ var HttpTransport = class {
|
|
|
364
368
|
platformUrl;
|
|
365
369
|
serviceToken;
|
|
366
370
|
async send(rows) {
|
|
367
|
-
|
|
371
|
+
const safeRows = rows.flatMap((row) => {
|
|
372
|
+
const projected = projectSpanRow(row);
|
|
373
|
+
return projected.ok ? [projected.row] : [];
|
|
374
|
+
});
|
|
375
|
+
if (safeRows.length === 0) return;
|
|
368
376
|
const resp = await fetch(`${this.platformUrl.replace(/\/$/, "")}/_internal/spans`, {
|
|
369
377
|
method: "POST",
|
|
370
378
|
headers: {
|
|
371
379
|
"Content-Type": "application/json",
|
|
372
380
|
Authorization: `Bearer ${this.serviceToken}`
|
|
373
381
|
},
|
|
374
|
-
body: JSON.stringify({ spans:
|
|
382
|
+
body: JSON.stringify({ spans: safeRows })
|
|
375
383
|
});
|
|
376
384
|
if (!resp.ok) {
|
|
377
385
|
const text = await resp.text().catch(() => "");
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
withSdkInitLock
|
|
3
3
|
} from "./chunk-COYKJRMM.js";
|
|
4
|
+
import {
|
|
5
|
+
diagnosticConsole
|
|
6
|
+
} from "./chunk-ETXDTUJO.js";
|
|
4
7
|
|
|
5
8
|
// src/sdk/server/postgres-job-store.ts
|
|
6
9
|
import { createHash } from "crypto";
|
|
@@ -594,12 +597,12 @@ var PostgresJobStore = class {
|
|
|
594
597
|
]
|
|
595
598
|
);
|
|
596
599
|
if (rowCount === 0) {
|
|
597
|
-
|
|
598
|
-
|
|
600
|
+
diagnosticConsole.warn(
|
|
601
|
+
{
|
|
599
602
|
level: "job_save_rejected_terminal",
|
|
600
603
|
jobId: record.id,
|
|
601
604
|
attemptedStatus: record.status
|
|
602
|
-
}
|
|
605
|
+
}
|
|
603
606
|
);
|
|
604
607
|
return;
|
|
605
608
|
}
|
|
@@ -1150,21 +1153,21 @@ var PostgresJobStore = class {
|
|
|
1150
1153
|
onNotification: (payload) => {
|
|
1151
1154
|
this.dispatch(payload);
|
|
1152
1155
|
},
|
|
1153
|
-
onLost: (
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
+
onLost: (_err) => {
|
|
1157
|
+
diagnosticConsole.warn(
|
|
1158
|
+
{
|
|
1156
1159
|
level: "job_messages_listen_lost",
|
|
1157
|
-
error:
|
|
1158
|
-
}
|
|
1160
|
+
error: void 0
|
|
1161
|
+
}
|
|
1159
1162
|
);
|
|
1160
1163
|
},
|
|
1161
|
-
onReconnectFailed: (attempt,
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
+
onReconnectFailed: (attempt, _err) => {
|
|
1165
|
+
diagnosticConsole.warn(
|
|
1166
|
+
{
|
|
1164
1167
|
level: "job_messages_listen_connect_failed",
|
|
1165
1168
|
attempt,
|
|
1166
|
-
error:
|
|
1167
|
-
}
|
|
1169
|
+
error: void 0
|
|
1170
|
+
}
|
|
1168
1171
|
);
|
|
1169
1172
|
}
|
|
1170
1173
|
});
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
diagnosticConsole
|
|
3
|
+
} from "./chunk-ETXDTUJO.js";
|
|
4
|
+
|
|
1
5
|
// src/lib/pg-retry.ts
|
|
2
6
|
import { AsyncLocalStorage } from "async_hooks";
|
|
3
7
|
var postgresRecovery = new AsyncLocalStorage();
|
|
@@ -19,9 +23,7 @@ async function withInitRetry(fn, label, delays = [1e3, 4e3, 15e3]) {
|
|
|
19
23
|
} catch (err) {
|
|
20
24
|
if (!isTransportError(err) || attempt >= delays.length) throw err;
|
|
21
25
|
const wait = delays[attempt];
|
|
22
|
-
|
|
23
|
-
`[${label}] DB init attempt ${attempt + 1} failed (${err.message}), retrying in ${wait / 1e3}s`
|
|
24
|
-
);
|
|
26
|
+
diagnosticConsole.warn();
|
|
25
27
|
await new Promise((resolve) => setTimeout(resolve, wait));
|
|
26
28
|
}
|
|
27
29
|
}
|
|
@@ -39,8 +41,8 @@ function applyRetryToPool(pool, label = "pg-pool") {
|
|
|
39
41
|
if (patchedPools.has(pool)) return;
|
|
40
42
|
patchedPools.add(pool);
|
|
41
43
|
pool.options.application_name = formatPostgresApplicationName(label);
|
|
42
|
-
pool.on("error", (
|
|
43
|
-
|
|
44
|
+
pool.on("error", (_err) => {
|
|
45
|
+
diagnosticConsole.error();
|
|
44
46
|
});
|
|
45
47
|
const p = pool;
|
|
46
48
|
const origQuery = p.query.bind(pool);
|
|
@@ -119,8 +121,8 @@ function hostPoolSize(pool) {
|
|
|
119
121
|
return typeof configured === "number" && Number.isSafeInteger(configured) && configured > 0 ? configured : 10;
|
|
120
122
|
}
|
|
121
123
|
function logTransportRecovery(args) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
+
diagnosticConsole.warn(
|
|
125
|
+
{
|
|
124
126
|
level: "postgres_transport_recovery",
|
|
125
127
|
label: args.label,
|
|
126
128
|
route: args.context?.route,
|
|
@@ -129,20 +131,20 @@ function logTransportRecovery(args) {
|
|
|
129
131
|
attempts: args.attempts,
|
|
130
132
|
elapsed_ms: args.elapsedMs,
|
|
131
133
|
outcome: args.outcome,
|
|
132
|
-
error:
|
|
133
|
-
}
|
|
134
|
+
error: void 0
|
|
135
|
+
}
|
|
134
136
|
);
|
|
135
137
|
}
|
|
136
138
|
function asError(error) {
|
|
137
139
|
return error instanceof Error ? error : new Error(String(error));
|
|
138
140
|
}
|
|
139
|
-
function guardCheckedOutClient(client,
|
|
141
|
+
function guardCheckedOutClient(client, _label) {
|
|
140
142
|
if (client === null || typeof client !== "object") return;
|
|
141
143
|
const emitter = client;
|
|
142
144
|
if (typeof emitter.on !== "function" || guardedClients.has(client)) return;
|
|
143
145
|
guardedClients.add(client);
|
|
144
|
-
emitter.on("error", (
|
|
145
|
-
|
|
146
|
+
emitter.on("error", (_err) => {
|
|
147
|
+
diagnosticConsole.error();
|
|
146
148
|
});
|
|
147
149
|
}
|
|
148
150
|
function truncateUtf8(value, maxBytes) {
|