mtok-bridge 0.4.0 → 0.4.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/README.md +5 -2
- package/package.json +1 -1
- package/src/serve-core.mjs +7 -0
package/README.md
CHANGED
|
@@ -53,8 +53,11 @@ the verifier's payment timestamp, so a store migrating old claims can refuse amb
|
|
|
53
53
|
pre-cutover payments. Existing stores may ignore these additional arguments. The core still
|
|
54
54
|
verifies the payment before reading a completion, and known claims never run upstream again.
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
Set `replayOnly: true` when retiring a payment domain. The core still verifies the
|
|
57
|
+
payment before replaying a saved completion or returning its pending status. An
|
|
58
|
+
unrecorded payment returns 503 before fee evaluation, input counting, claiming or
|
|
59
|
+
inference. Quotes also return 503. Keep the legacy payment verifier and store
|
|
60
|
+
available for these retries; this mode never admits new paid work.
|
|
58
61
|
|
|
59
62
|
The new core requires `countInputTokens(safeRequest)`, returning a nonnegative safe integer
|
|
60
63
|
or a promise for one. The host must count its actual provider prompt, including its chat
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mtok-bridge",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Serve any model as an OpenAI-compatible API with a key. No payment, no market, runs anywhere node runs. The transport core behind mtok.market's seller relay.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/src/serve-core.mjs
CHANGED
|
@@ -223,6 +223,9 @@ export function createServeCore({
|
|
|
223
223
|
offerId, sellerAgentId, sellerWallet,
|
|
224
224
|
dripContractAddress, feeRecipient, feeBps,
|
|
225
225
|
screenPayer,
|
|
226
|
+
// A retired payment domain may honor verified receipts without admitting
|
|
227
|
+
// quotes or another inference attempt for an unrecorded payment.
|
|
228
|
+
replayOnly = false,
|
|
226
229
|
// The host counts its actual sanitized provider input. Missing or failed
|
|
227
230
|
// accounting refuses a fresh claim; saved completions do not need recounting.
|
|
228
231
|
countInputTokens,
|
|
@@ -235,6 +238,7 @@ export function createServeCore({
|
|
|
235
238
|
maxOutputTokens = DEFAULT_MAX_OUTPUT_TOKENS,
|
|
236
239
|
}) {
|
|
237
240
|
const quote = async (request) => {
|
|
241
|
+
if (replayOnly) return { status: 503, body: { error: 'redemption_unavailable', detail: 'this relay only replays saved completions' } };
|
|
238
242
|
const checked = validateRequest(request, model);
|
|
239
243
|
if (checked.error) return { status: 400, body: { error: 'bad_request', detail: checked.error } };
|
|
240
244
|
try {
|
|
@@ -353,6 +357,9 @@ export function createServeCore({
|
|
|
353
357
|
if (redemptionState === 'pending') {
|
|
354
358
|
return { status: 409, body: { error: 'draw_pending', detail: 'this paid draw was already claimed; refusing to run upstream again', _bookingId: bookingId } };
|
|
355
359
|
}
|
|
360
|
+
if (replayOnly) {
|
|
361
|
+
return { status: 503, body: { error: 'redemption_unavailable', detail: 'this payment has no saved completion; retry this same paid draw after reconciliation', _bookingId: bookingId } };
|
|
362
|
+
}
|
|
356
363
|
// Completed/pending claims already crossed the fee gate and cannot spend
|
|
357
364
|
// again. New claims use the policy at the verified payment time.
|
|
358
365
|
let currentFeeBps;
|