@dvmkit/sdk 0.14.1 → 0.15.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/dist/{chunk-ITRSITFP.js → chunk-2I6NXIPG.js} +1 -1
- package/dist/{chunk-TKJBUFYY.js → chunk-33J3NQDZ.js} +1 -1
- package/dist/{chunk-7KQLPVV7.js → chunk-7NZRJPEP.js} +1 -1
- package/dist/{chunk-Z4FOPROB.js → chunk-BAHZK334.js} +2 -0
- package/dist/{chunk-D4FFS3IS.js → chunk-CRH6BMMG.js} +1 -1
- package/dist/{chunk-LDKV4UHI.js → chunk-CVT5LTAK.js} +1 -1
- package/dist/{chunk-EP7OVWI5.js → chunk-FOXGN4KQ.js} +1 -1
- package/dist/{chunk-VWIMQ5H5.js → chunk-G47UY3BK.js} +1 -1
- package/dist/{chunk-JLT2YIBS.js → chunk-GB2N4NG5.js} +2 -2
- package/dist/{chunk-E7ZBCT5U.js → chunk-I2H2XYQV.js} +1 -1
- package/dist/{chunk-3YFFZLW7.js → chunk-IUODXRQN.js} +2 -2
- package/dist/{chunk-566CFXGU.js → chunk-IVW5UMD3.js} +1 -1
- package/dist/{chunk-AFV77S4C.js → chunk-KVKJ7R5V.js} +81 -2
- package/dist/{chunk-A2YESDQM.js → chunk-LM6E4YHQ.js} +2 -2
- package/dist/{chunk-5JSPTVIK.js → chunk-LZFZGY7L.js} +1 -1
- package/dist/{chunk-FFRTAQUW.js → chunk-P5KQKLWL.js} +1 -1
- package/dist/{chunk-KJZVTWMX.js → chunk-PKLNMMKF.js} +52 -15
- package/dist/{chunk-M4NFYEEY.js → chunk-QRYGBKCR.js} +1 -1
- package/dist/{chunk-HNXMWHLU.js → chunk-R7FH7SHX.js} +1 -1
- package/dist/{chunk-NS2OMIU7.js → chunk-RQK7OFJO.js} +1 -1
- package/dist/{chunk-TWKQFIOW.js → chunk-YMMCRQ2H.js} +84 -14
- package/dist/{chunk-JFH34P3M.js → chunk-ZJRGORJ3.js} +359 -169
- package/dist/{chunk-HULU2UVM.js → chunk-ZO2ZAPG3.js} +1 -1
- package/dist/{content-retention-BcHNpP2F.d.ts → content-retention-BASsjgKw.d.ts} +1 -1
- package/dist/{credit-ledger-D3UUR2GW.js → credit-ledger-EZDZYLSK.js} +3 -3
- package/dist/{credit-menu-C-kmf61K.d.ts → credit-menu-B239nIY5.d.ts} +23 -9
- package/dist/{fx-hFlF4Cn8.d.ts → fx-BmvWGISH.d.ts} +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.js +12 -5
- package/dist/internal/caller.d.ts +11 -7
- package/dist/internal/caller.js +7 -7
- package/dist/internal/server.d.ts +7 -7
- package/dist/internal/server.js +21 -21
- package/dist/{job-store-DVCATwhU.d.ts → job-store-CA7u1nHV.d.ts} +22 -4
- package/dist/{lightning-backend-DXNVlVs9.d.ts → lightning-backend-BOcopzXk.d.ts} +1 -1
- package/dist/{memory-credit-ledger-SCXQO4HZ.js → memory-credit-ledger-REZGHPJP.js} +4 -4
- package/dist/{mpp-setup-JU3MT7QX.js → mpp-setup-RG5JDMIO.js} +3 -3
- package/dist/{payout-reporter-NXWQVKXW.js → payout-reporter-DDQ7FGRC.js} +2 -2
- package/dist/{postgres-consumed-credential-store-WXJLM6J7.js → postgres-consumed-credential-store-I4WTNVQZ.js} +1 -1
- package/dist/{postgres-job-store-ZVMAN6L2.js → postgres-job-store-IXTNWT4K.js} +3 -3
- package/dist/{postgres-replay-store-QJ4FG6AR.js → postgres-replay-store-3F5FCUXN.js} +2 -2
- package/dist/{pricing-KCLENT2C.js → pricing-HLYEGPXD.js} +3 -3
- package/dist/{revenue-reporter-HD4GMXGD.js → revenue-reporter-RIEHBKRA.js} +2 -2
- package/dist/server/index.d.ts +15 -12
- package/dist/server/index.js +28 -28
- package/dist/{step-cache-CoORQQ_Y.d.ts → step-cache-BCRHimiY.d.ts} +48 -9
- package/dist/{tempo-charge-store-7LTUAQHQ.js → tempo-charge-store-B5SYDCBK.js} +2 -2
- package/dist/{tempo-session-store-LYAIDR2B.js → tempo-session-store-FHW7N22I.js} +3 -3
- package/dist/testing/index.d.ts +7 -4
- package/dist/testing/index.js +7 -7
- package/dist/{usd-CeXGiyTC.d.ts → usd-B8_WMfHT.d.ts} +1 -1
- package/dist/{x402-RUJ4LUKF.js → x402-AY6P5KV4.js} +3 -3
- package/package.json +1 -1
|
@@ -203,6 +203,7 @@ var diagnostic_catalogue_v1_default = {
|
|
|
203
203
|
"job_heartbeat_failed",
|
|
204
204
|
"job_id",
|
|
205
205
|
"job_message_append_failed",
|
|
206
|
+
"step_persist_failed",
|
|
206
207
|
"job_messages_listen_connect_failed",
|
|
207
208
|
"job_messages_listen_lost",
|
|
208
209
|
"job_retention_alert_failed",
|
|
@@ -368,6 +369,7 @@ var diagnostic_catalogue_v1_default = {
|
|
|
368
369
|
"spans_retention_failed",
|
|
369
370
|
"stale_job_cancelled",
|
|
370
371
|
"stale_job_failed",
|
|
372
|
+
"stale_job_local_live_skipped",
|
|
371
373
|
"stale_job_sweep_clock_skew",
|
|
372
374
|
"stale_job_sweep_failed",
|
|
373
375
|
"stripe.create_checkout_session",
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
loggers
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-R7FH7SHX.js";
|
|
4
4
|
import {
|
|
5
5
|
diagnosticConsole
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-BAHZK334.js";
|
|
7
7
|
|
|
8
8
|
// src/sdk/server/mpp-setup.ts
|
|
9
9
|
import { createHash, randomUUID } from "crypto";
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
createX402FacilitatorAuthHeaders,
|
|
3
3
|
settleWithFacilitator,
|
|
4
4
|
verifyWithFacilitator
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-I2H2XYQV.js";
|
|
6
6
|
import {
|
|
7
7
|
buildPaymentRequirements,
|
|
8
8
|
decodePayment,
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
} from "./chunk-66HGCPBU.js";
|
|
16
16
|
import {
|
|
17
17
|
diagnosticConsole
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-BAHZK334.js";
|
|
19
19
|
|
|
20
20
|
// src/lib/x402/verify.ts
|
|
21
21
|
async function verifyX402Payment(paymentHeader, config, requiredUsdcMicro, resource, btcUsdRate, exactVersions = { v1: true, v2: true }) {
|
|
@@ -26,6 +26,7 @@ function toJobRecord(job) {
|
|
|
26
26
|
awaitingInputAtMs: job.awaitingInputAtMs,
|
|
27
27
|
messages: job.messages,
|
|
28
28
|
seq: job.seq,
|
|
29
|
+
upfrontPayment: job.upfrontPayment,
|
|
29
30
|
paidMsats: job.paidMsats,
|
|
30
31
|
paymentMint: job.paymentMint,
|
|
31
32
|
paymentRail: job.paymentRail,
|
|
@@ -77,6 +78,7 @@ function fromJobRecord(record) {
|
|
|
77
78
|
awaitingInputAtMs: record.awaitingInputAtMs,
|
|
78
79
|
messages: [...record.messages],
|
|
79
80
|
seq: record.seq,
|
|
81
|
+
upfrontPayment: record.upfrontPayment,
|
|
80
82
|
paidMsats: record.paidMsats,
|
|
81
83
|
paymentMint: record.paymentMint,
|
|
82
84
|
paymentRail: record.paymentRail,
|
|
@@ -138,6 +140,9 @@ function providerMessage(job, type, content) {
|
|
|
138
140
|
job.replayProviderSkip--;
|
|
139
141
|
return;
|
|
140
142
|
}
|
|
143
|
+
if (type === "prompt" || type === "payment-request") {
|
|
144
|
+
content = { ...content, expires_at_ms: Date.now() + (job.idleTimeoutMs ?? 36e5) };
|
|
145
|
+
}
|
|
141
146
|
const msg = localMessage(job, "provider", type, content);
|
|
142
147
|
if (type === "payment-request") {
|
|
143
148
|
const paymentRequest = content;
|
|
@@ -160,7 +165,51 @@ function providerMessage(job, type, content) {
|
|
|
160
165
|
}
|
|
161
166
|
job.messageAppender?.(msg, type === "prompt" ? { awaitingInput: job.status === "awaiting-input" } : void 0);
|
|
162
167
|
}
|
|
168
|
+
var historyHolds = /* @__PURE__ */ new WeakMap();
|
|
169
|
+
var heldNotifications = /* @__PURE__ */ new WeakMap();
|
|
170
|
+
function holdJobHistory(job, seq) {
|
|
171
|
+
let holds = historyHolds.get(job);
|
|
172
|
+
if (!holds) {
|
|
173
|
+
holds = /* @__PURE__ */ new Set();
|
|
174
|
+
historyHolds.set(job, holds);
|
|
175
|
+
}
|
|
176
|
+
holds.add(seq);
|
|
177
|
+
}
|
|
178
|
+
function visibleJobMessages(job) {
|
|
179
|
+
const holds = historyHolds.get(job);
|
|
180
|
+
if (!holds?.size) return job.messages;
|
|
181
|
+
const boundary = Math.min(...holds);
|
|
182
|
+
return job.messages.filter((message) => message.seq < boundary);
|
|
183
|
+
}
|
|
184
|
+
function releaseJobHistory(job, seq, accepted) {
|
|
185
|
+
const holds = historyHolds.get(job);
|
|
186
|
+
const wasPending = holds?.delete(seq);
|
|
187
|
+
if (accepted && wasPending) {
|
|
188
|
+
const next = job.messages.findIndex((existing) => existing.seq > accepted.seq);
|
|
189
|
+
job.messages.splice(next < 0 ? job.messages.length : next, 0, accepted);
|
|
190
|
+
const queued = heldNotifications.get(job) ?? [];
|
|
191
|
+
queued.push(accepted);
|
|
192
|
+
heldNotifications.set(job, queued);
|
|
193
|
+
}
|
|
194
|
+
flushJobHistory(job);
|
|
195
|
+
}
|
|
196
|
+
function flushJobHistory(job) {
|
|
197
|
+
const holds = historyHolds.get(job);
|
|
198
|
+
const boundary = holds?.size ? Math.min(...holds) : Infinity;
|
|
199
|
+
const queued = heldNotifications.get(job) ?? [];
|
|
200
|
+
queued.sort((a, b) => a.seq - b.seq);
|
|
201
|
+
heldNotifications.set(job, queued.filter((message) => message.seq >= boundary));
|
|
202
|
+
for (const message of queued) {
|
|
203
|
+
if (message.seq < boundary) {
|
|
204
|
+
for (const listener of job.listeners) listener(message);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
163
208
|
function localMessage(job, from, type, content) {
|
|
209
|
+
if (type === "cancel" || type === "complete") {
|
|
210
|
+
historyHolds.get(job)?.clear();
|
|
211
|
+
flushJobHistory(job);
|
|
212
|
+
}
|
|
164
213
|
job.seq++;
|
|
165
214
|
const msg = {
|
|
166
215
|
seq: job.seq,
|
|
@@ -170,8 +219,13 @@ function localMessage(job, from, type, content) {
|
|
|
170
219
|
content
|
|
171
220
|
};
|
|
172
221
|
job.messages.push(msg);
|
|
173
|
-
|
|
174
|
-
|
|
222
|
+
const holds = historyHolds.get(job);
|
|
223
|
+
if (holds?.size && msg.seq >= Math.min(...holds)) {
|
|
224
|
+
const queued = heldNotifications.get(job) ?? [];
|
|
225
|
+
queued.push(msg);
|
|
226
|
+
heldNotifications.set(job, queued);
|
|
227
|
+
} else {
|
|
228
|
+
for (const listener of job.listeners) listener(msg);
|
|
175
229
|
}
|
|
176
230
|
return msg;
|
|
177
231
|
}
|
|
@@ -181,6 +235,26 @@ function isTerminal(status) {
|
|
|
181
235
|
function isYieldMessage(msg) {
|
|
182
236
|
return msg.type === "prompt" || msg.type === "payment-request" || msg.type === "working" || msg.type === "complete" || msg.type === "cancel";
|
|
183
237
|
}
|
|
238
|
+
function callerDeadline(job, legacyTimeoutMs) {
|
|
239
|
+
if (isTerminal(job.status)) return void 0;
|
|
240
|
+
const prompts = /* @__PURE__ */ new Map();
|
|
241
|
+
let payment;
|
|
242
|
+
for (const message of job.messages) {
|
|
243
|
+
if (message.from === "provider" && message.type === "prompt") prompts.set(message.content.id, message);
|
|
244
|
+
if (message.from === "provider" && message.type === "payment-request") payment = message;
|
|
245
|
+
if (message.from === "requester" && message.type === "response") prompts.delete(message.content.prompt_id);
|
|
246
|
+
}
|
|
247
|
+
const asks = [...prompts.values(), ...payment && (job.pendingPaymentMsats ?? 0) > 0 ? [payment] : []];
|
|
248
|
+
const deadlines = asks.map((ask) => ask.content.expires_at_ms).filter((stamp) => Number.isSafeInteger(stamp));
|
|
249
|
+
if (deadlines.length > 0) return Math.min(...deadlines);
|
|
250
|
+
if (job.status === "awaiting-input" && legacyTimeoutMs !== void 0 && (asks.length > 0 || job.messages.length === 0)) {
|
|
251
|
+
return (job.awaitingInputAtMs ?? job.lastActivityAt) + legacyTimeoutMs;
|
|
252
|
+
}
|
|
253
|
+
return void 0;
|
|
254
|
+
}
|
|
255
|
+
function hasCallerDeadline(messages) {
|
|
256
|
+
return messages.some((message) => message.from === "provider" && (message.type === "prompt" || message.type === "payment-request") && Number.isSafeInteger(message.content.expires_at_ms));
|
|
257
|
+
}
|
|
184
258
|
|
|
185
259
|
// src/sdk/server/content-retention.ts
|
|
186
260
|
import { randomUUID } from "crypto";
|
|
@@ -247,9 +321,14 @@ export {
|
|
|
247
321
|
abortJob,
|
|
248
322
|
JobCancelledError,
|
|
249
323
|
providerMessage,
|
|
324
|
+
holdJobHistory,
|
|
325
|
+
visibleJobMessages,
|
|
326
|
+
releaseJobHistory,
|
|
250
327
|
localMessage,
|
|
251
328
|
isTerminal,
|
|
252
329
|
isYieldMessage,
|
|
330
|
+
callerDeadline,
|
|
331
|
+
hasCallerDeadline,
|
|
253
332
|
ContentHoldError,
|
|
254
333
|
isContentHoldStore,
|
|
255
334
|
contentMetadata,
|
|
@@ -10,13 +10,13 @@ import {
|
|
|
10
10
|
} from "./chunk-5UC7TOQC.js";
|
|
11
11
|
import {
|
|
12
12
|
applyRetryToPool
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-FOXGN4KQ.js";
|
|
14
14
|
import {
|
|
15
15
|
x402NetworkByCaip2
|
|
16
16
|
} from "./chunk-BPYMEMQX.js";
|
|
17
17
|
import {
|
|
18
18
|
diagnosticConsole
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-BAHZK334.js";
|
|
20
20
|
|
|
21
21
|
// src/sdk/server/credit-ledger.ts
|
|
22
22
|
import { randomUUID } from "crypto";
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ContentHoldError,
|
|
3
3
|
applyContentHoldMutation,
|
|
4
|
+
callerDeadline,
|
|
5
|
+
hasCallerDeadline,
|
|
4
6
|
isTerminal
|
|
5
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-KVKJ7R5V.js";
|
|
6
8
|
import {
|
|
7
9
|
redactUrl
|
|
8
10
|
} from "./chunk-FUJ36YDV.js";
|
|
9
11
|
import {
|
|
10
12
|
loggers
|
|
11
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-R7FH7SHX.js";
|
|
12
14
|
|
|
13
15
|
// src/sdk/server/job-store.ts
|
|
14
16
|
function accumulateAskedTopUp(prior, ask) {
|
|
@@ -114,7 +116,10 @@ var MemoryJobStore = class {
|
|
|
114
116
|
return Promise.resolve();
|
|
115
117
|
}
|
|
116
118
|
const snapshot = structuredClone(record);
|
|
117
|
-
if (existing)
|
|
119
|
+
if (existing) {
|
|
120
|
+
snapshot.createdAt = existing.createdAt;
|
|
121
|
+
snapshot.upfrontPayment = structuredClone(existing.upfrontPayment);
|
|
122
|
+
}
|
|
118
123
|
if (existing && isTerminal(existing.status)) snapshot.lastActivityAt = existing.lastActivityAt;
|
|
119
124
|
if (existing?.receipt) snapshot.receipt = existing.receipt;
|
|
120
125
|
snapshot.timingKnown = existing ? existing.timingKnown ?? false : record.timingKnown ?? true;
|
|
@@ -123,6 +128,7 @@ var MemoryJobStore = class {
|
|
|
123
128
|
const cur = this.nextSeq.get(record.id) ?? 1;
|
|
124
129
|
this.nextSeq.set(record.id, Math.max(cur, record.seq + 1));
|
|
125
130
|
if (isTerminal(record.status)) {
|
|
131
|
+
this.notify(record.id);
|
|
126
132
|
this.messages.delete(record.id);
|
|
127
133
|
}
|
|
128
134
|
return Promise.resolve();
|
|
@@ -234,7 +240,7 @@ var MemoryJobStore = class {
|
|
|
234
240
|
}
|
|
235
241
|
if (!isTerminal(record.status)) record.lastActivityAt = Date.now();
|
|
236
242
|
if (seq > record.seq) record.seq = seq;
|
|
237
|
-
this.notify(jobId
|
|
243
|
+
this.notify(jobId);
|
|
238
244
|
return Promise.resolve(seq);
|
|
239
245
|
}
|
|
240
246
|
recordInbound(jobId, message) {
|
|
@@ -295,7 +301,7 @@ var MemoryJobStore = class {
|
|
|
295
301
|
}
|
|
296
302
|
}
|
|
297
303
|
if (!isTerminal(record.status)) record.lastActivityAt = Date.now();
|
|
298
|
-
this.notify(jobId
|
|
304
|
+
this.notify(jobId);
|
|
299
305
|
return Promise.resolve({
|
|
300
306
|
counters: snapshotCounters(record),
|
|
301
307
|
alreadyVerified: false,
|
|
@@ -316,6 +322,7 @@ var MemoryJobStore = class {
|
|
|
316
322
|
const stored = this.messagesFor(jobId).find((m) => m.message.seq === seq);
|
|
317
323
|
if (stored?.status === "pending-verification") {
|
|
318
324
|
stored.status = "failed-verify";
|
|
325
|
+
this.notify(jobId);
|
|
319
326
|
}
|
|
320
327
|
return Promise.resolve();
|
|
321
328
|
}
|
|
@@ -406,11 +413,8 @@ var MemoryJobStore = class {
|
|
|
406
413
|
if (subSet.size === 0) this.notifySubscribers.delete(jobId);
|
|
407
414
|
});
|
|
408
415
|
}
|
|
409
|
-
getMessages(jobId, afterSeq) {
|
|
410
|
-
|
|
411
|
-
return Promise.resolve(
|
|
412
|
-
stored.filter((m) => m.status === "verified" && m.message.seq > afterSeq).map((m) => m.message)
|
|
413
|
-
);
|
|
416
|
+
getMessages(jobId, afterSeq, options) {
|
|
417
|
+
return Promise.resolve(this.visibleMessages(jobId, afterSeq, options?.includeHeld));
|
|
414
418
|
}
|
|
415
419
|
initStreaming() {
|
|
416
420
|
return Promise.resolve();
|
|
@@ -431,6 +435,15 @@ var MemoryJobStore = class {
|
|
|
431
435
|
if (!record) return Promise.resolve(false);
|
|
432
436
|
const eligible = (record.status === "processing" || record.status === "working" || record.status === "awaiting-input") && (expectedActivityBefore === null || record.lastActivityAt <= expectedActivityBefore);
|
|
433
437
|
if (!eligible) return Promise.resolve(false);
|
|
438
|
+
let terminalMessages = record.messages;
|
|
439
|
+
if (expectedActivityBefore !== null) {
|
|
440
|
+
const messages = this.messagesFor(jobId).filter((entry) => entry.status === "verified").map((entry) => entry.message);
|
|
441
|
+
const history = messages.length ? messages : record.messages;
|
|
442
|
+
terminalMessages = history;
|
|
443
|
+
const deadline = callerDeadline({ ...record, messages: history });
|
|
444
|
+
const awaiting = deadline !== void 0 || record.status === "awaiting-input" && !hasCallerDeadline(history);
|
|
445
|
+
if (terminalStatus === "cancelled" !== awaiting || deadline !== void 0 && Date.now() < deadline) return Promise.resolve(false);
|
|
446
|
+
}
|
|
434
447
|
const seq = this.allocateSeq(jobId);
|
|
435
448
|
const cancelMsg = {
|
|
436
449
|
seq,
|
|
@@ -440,14 +453,14 @@ var MemoryJobStore = class {
|
|
|
440
453
|
content: { reason }
|
|
441
454
|
};
|
|
442
455
|
this.messagesFor(jobId).push({ message: cancelMsg, status: "verified" });
|
|
443
|
-
record.endedBy = expectedActivityBefore === null ||
|
|
456
|
+
record.endedBy = expectedActivityBefore === null || terminalStatus === "cancelled" ? "caller" : "provider";
|
|
444
457
|
applyTiming(record, structuredClone(record), Date.now(), terminalStatus);
|
|
445
458
|
record.status = terminalStatus;
|
|
446
459
|
record.summary = record.summary ?? reason;
|
|
447
|
-
record.messages = [...
|
|
460
|
+
record.messages = [...terminalMessages, cancelMsg];
|
|
448
461
|
record.seq = seq;
|
|
449
462
|
record.lastActivityAt = Date.now();
|
|
450
|
-
this.notify(jobId
|
|
463
|
+
this.notify(jobId);
|
|
451
464
|
this.messages.delete(jobId);
|
|
452
465
|
return Promise.resolve(true);
|
|
453
466
|
}
|
|
@@ -464,11 +477,35 @@ var MemoryJobStore = class {
|
|
|
464
477
|
}
|
|
465
478
|
return list;
|
|
466
479
|
}
|
|
467
|
-
|
|
480
|
+
visibleMessages(jobId, afterSeq, includeHeld = false) {
|
|
481
|
+
const stored = this.messagesFor(jobId);
|
|
482
|
+
const record = this.data.get(jobId);
|
|
483
|
+
const terminal = record && isTerminal(record.status);
|
|
484
|
+
const terminalMessage = stored.some((entry) => entry.status === "verified" && entry.message.from === "provider" && (entry.message.type === "complete" || entry.message.type === "cancel"));
|
|
485
|
+
let boundary = Infinity;
|
|
486
|
+
if (!includeHeld && !terminal && !terminalMessage) {
|
|
487
|
+
for (const entry of stored) {
|
|
488
|
+
if (entry.status === "pending-verification" && entry.message.type === "payment") {
|
|
489
|
+
boundary = Math.min(boundary, entry.message.seq);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
const messages = /* @__PURE__ */ new Map();
|
|
494
|
+
if (terminal) {
|
|
495
|
+
for (const message of record.messages) if (message.seq > afterSeq) messages.set(message.seq, message);
|
|
496
|
+
}
|
|
497
|
+
for (const entry of stored) {
|
|
498
|
+
if (entry.status === "verified" && entry.message.seq > afterSeq && entry.message.seq < boundary) {
|
|
499
|
+
messages.set(entry.message.seq, entry.message);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
return [...messages.values()].sort((a, b) => a.seq - b.seq);
|
|
503
|
+
}
|
|
504
|
+
notify(jobId) {
|
|
468
505
|
const subs = this.messageSubscribers.get(jobId);
|
|
469
506
|
if (subs) {
|
|
470
507
|
for (const sub of subs) {
|
|
471
|
-
|
|
508
|
+
for (const message of this.visibleMessages(jobId, sub.afterSeq)) {
|
|
472
509
|
sub.afterSeq = message.seq;
|
|
473
510
|
sub.cb(message);
|
|
474
511
|
}
|