@dvmkit/sdk 0.20.0 → 0.21.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.
|
@@ -18479,6 +18479,16 @@ function waitForInlineResult(store, jobId, localJob, seconds, signal) {
|
|
|
18479
18479
|
notify();
|
|
18480
18480
|
});
|
|
18481
18481
|
}
|
|
18482
|
+
var INLINE_RESULT_MESSAGES_MAX_BYTES = 1048576;
|
|
18483
|
+
async function inlineResultMessages(store, job) {
|
|
18484
|
+
if (job.status !== "completed" || job.redactedAt !== void 0 || !job.messages.some((message) => message.type === "artifact")) return void 0;
|
|
18485
|
+
let messages = job.messages.filter((message) => message.seq > 0);
|
|
18486
|
+
if (isStreamableJobStore(store)) {
|
|
18487
|
+
const durable = await store.getMessages(job.id, 0, { includeHeld: true });
|
|
18488
|
+
if (durable.length > 0) messages = durable;
|
|
18489
|
+
}
|
|
18490
|
+
return Buffer.byteLength(JSON.stringify(messages), "utf8") <= INLINE_RESULT_MESSAGES_MAX_BYTES ? messages : void 0;
|
|
18491
|
+
}
|
|
18482
18492
|
|
|
18483
18493
|
// src/sdk/server/job-read-response.ts
|
|
18484
18494
|
async function withJobReadAvailability(read) {
|
|
@@ -24691,7 +24701,8 @@ var DVMServer = class {
|
|
|
24691
24701
|
return snapshot;
|
|
24692
24702
|
}
|
|
24693
24703
|
async submitResponse(c, job, jobToken) {
|
|
24694
|
-
|
|
24704
|
+
const inlineResult = job.paymentRail === "cashu" && job.paymentTxHash?.startsWith(DERIVED_REQUEST_ID_PREFIX) && !job.requesterPubkey && c.req.header("X-Cashu") && !c.req.header("X-Cashu-Request-Id");
|
|
24705
|
+
if (inlineResult) {
|
|
24695
24706
|
await waitForInlineResult(
|
|
24696
24707
|
this.jobManager.store,
|
|
24697
24708
|
job.id,
|
|
@@ -24701,7 +24712,10 @@ var DVMServer = class {
|
|
|
24701
24712
|
);
|
|
24702
24713
|
}
|
|
24703
24714
|
const snapshot = await this.readJobSnapshot(job, !("listeners" in job));
|
|
24704
|
-
|
|
24715
|
+
const messages = inlineResult ? await inlineResultMessages(this.jobManager.store, snapshot) : void 0;
|
|
24716
|
+
const fields = await this.contentFields(snapshot);
|
|
24717
|
+
if (messages && fields.content_available !== false) fields.messages = messages;
|
|
24718
|
+
return buildSubmitResponse(c, snapshot, jobToken, fields);
|
|
24705
24719
|
}
|
|
24706
24720
|
async contentFields(job) {
|
|
24707
24721
|
const store = this.jobManager.store;
|
package/dist/internal/server.js
CHANGED
package/dist/server/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dvmkit/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "SDK for building Digital Vending Machines: pay-per-use HTTPS services AI agents can find, pay, and call with no account or API key",
|
|
5
5
|
"author": "DVM Technologies Ltd",
|
|
6
6
|
"keywords": [
|