@wopr-network/platform-core 1.75.0 → 1.75.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.
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { Credit } from "@wopr-network/platform-core/credits";
|
|
9
9
|
import { logger } from "../config/logger.js";
|
|
10
10
|
import { withMargin } from "../monetization/adapters/types.js";
|
|
11
|
+
import { debitCredits } from "./credit-gate.js";
|
|
11
12
|
import { DEFAULT_TOKEN_RATES, resolveTokenRates } from "./rate-lookup.js";
|
|
12
13
|
/**
|
|
13
14
|
* Proxy an SSE stream from upstream, metering after completion.
|
|
@@ -93,6 +94,8 @@ export function proxySSEStream(upstreamResponse, opts) {
|
|
|
93
94
|
provider,
|
|
94
95
|
timestamp: Date.now(),
|
|
95
96
|
});
|
|
97
|
+
// Debit credits (fire-and-forget, same as non-streaming path)
|
|
98
|
+
debitCredits(deps, tenant.id, accumulatedCost, deps.defaultMargin, capability, provider);
|
|
96
99
|
logger.info("Gateway proxy: SSE stream completed", {
|
|
97
100
|
tenant: tenant.id,
|
|
98
101
|
capability,
|
package/package.json
CHANGED
package/src/gateway/streaming.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import { Credit } from "@wopr-network/platform-core/credits";
|
|
10
10
|
import { logger } from "../config/logger.js";
|
|
11
11
|
import { withMargin } from "../monetization/adapters/types.js";
|
|
12
|
+
import { debitCredits } from "./credit-gate.js";
|
|
12
13
|
import type { ProxyDeps } from "./proxy.js";
|
|
13
14
|
import type { SellRateLookupFn } from "./rate-lookup.js";
|
|
14
15
|
import { DEFAULT_TOKEN_RATES, resolveTokenRates } from "./rate-lookup.js";
|
|
@@ -120,6 +121,9 @@ export function proxySSEStream(
|
|
|
120
121
|
timestamp: Date.now(),
|
|
121
122
|
});
|
|
122
123
|
|
|
124
|
+
// Debit credits (fire-and-forget, same as non-streaming path)
|
|
125
|
+
debitCredits(deps, tenant.id, accumulatedCost, deps.defaultMargin, capability, provider);
|
|
126
|
+
|
|
123
127
|
logger.info("Gateway proxy: SSE stream completed", {
|
|
124
128
|
tenant: tenant.id,
|
|
125
129
|
capability,
|