@eduardo191labs/opencode-free-pi 0.3.14 → 0.3.15
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/ads/impression.js +6 -2
- package/package.json +1 -1
- package/src/ads/impression.ts +6 -2
package/dist/ads/impression.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** Fetches an ad for a turn and records its impression. */
|
|
2
2
|
import { AD_CONTEXT_HEADER, AD_IMPRESSION_LIMIT, AD_IMPRESSION_TIMEOUT_MS, AD_REQUEST_TIMEOUT_MS, } from "../constants.js";
|
|
3
|
+
import { wireSessionID } from "../session/wire.js";
|
|
3
4
|
import { trimMap } from "../utils/async.js";
|
|
4
5
|
import { adClientHeaders } from "../utils/device.js";
|
|
5
6
|
import { readJson } from "../utils/json.js";
|
|
@@ -55,9 +56,12 @@ export function postAdImpression(deps, token, sessionId, ad) {
|
|
|
55
56
|
}
|
|
56
57
|
export async function fetchAdAndPostImpression(deps, token, sessionId, turn) {
|
|
57
58
|
try {
|
|
59
|
+
// The ad must ride on the same wire id as the model request; the server
|
|
60
|
+
// ties the impression to that session (the CLI sends one id for both).
|
|
61
|
+
const wireID = wireSessionID(deps, sessionId);
|
|
58
62
|
const headers = {
|
|
59
63
|
authorization: `Bearer ${token}`,
|
|
60
|
-
"x-session-id":
|
|
64
|
+
"x-session-id": wireID,
|
|
61
65
|
"x-client-version": deps.state.latestClientVersion,
|
|
62
66
|
"x-turn-id": turn.turnId,
|
|
63
67
|
"x-ad-trigger": "user_message",
|
|
@@ -73,7 +77,7 @@ export async function fetchAdAndPostImpression(deps, token, sessionId, turn) {
|
|
|
73
77
|
const ad = await readJson(response);
|
|
74
78
|
if (!ad)
|
|
75
79
|
return;
|
|
76
|
-
await postAdImpression(deps, token,
|
|
80
|
+
await postAdImpression(deps, token, wireID, ad);
|
|
77
81
|
}
|
|
78
82
|
catch { }
|
|
79
83
|
}
|
package/package.json
CHANGED
package/src/ads/impression.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
AD_REQUEST_TIMEOUT_MS,
|
|
8
8
|
} from "../constants.js";
|
|
9
9
|
import type { Deps } from "../deps.js";
|
|
10
|
+
import { wireSessionID } from "../session/wire.js";
|
|
10
11
|
import type { AdTurn } from "../types.js";
|
|
11
12
|
import { trimMap } from "../utils/async.js";
|
|
12
13
|
import { adClientHeaders } from "../utils/device.js";
|
|
@@ -73,9 +74,12 @@ export async function fetchAdAndPostImpression(
|
|
|
73
74
|
turn: AdTurn,
|
|
74
75
|
): Promise<void> {
|
|
75
76
|
try {
|
|
77
|
+
// The ad must ride on the same wire id as the model request; the server
|
|
78
|
+
// ties the impression to that session (the CLI sends one id for both).
|
|
79
|
+
const wireID = wireSessionID(deps, sessionId);
|
|
76
80
|
const headers: Record<string, string> = {
|
|
77
81
|
authorization: `Bearer ${token}`,
|
|
78
|
-
"x-session-id":
|
|
82
|
+
"x-session-id": wireID,
|
|
79
83
|
"x-client-version": deps.state.latestClientVersion,
|
|
80
84
|
"x-turn-id": turn.turnId,
|
|
81
85
|
"x-ad-trigger": "user_message",
|
|
@@ -89,7 +93,7 @@ export async function fetchAdAndPostImpression(
|
|
|
89
93
|
if (!response?.ok || response.status === 204) return;
|
|
90
94
|
const ad = await readJson(response);
|
|
91
95
|
if (!ad) return;
|
|
92
|
-
await postAdImpression(deps, token,
|
|
96
|
+
await postAdImpression(deps, token, wireID, ad);
|
|
93
97
|
} catch {}
|
|
94
98
|
}
|
|
95
99
|
|