@steve31415/baselib 3.74.0 → 3.75.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.
|
@@ -153,7 +153,19 @@ export const geminiProvider = {
|
|
|
153
153
|
}
|
|
154
154
|
const data = JSON.parse(responseText);
|
|
155
155
|
const latencyMs = Date.now() - startTime;
|
|
156
|
-
|
|
156
|
+
// The answer is every non-thought text part of the first candidate, in
|
|
157
|
+
// order — not just part 0. Gemini may split one answer over several
|
|
158
|
+
// parts: live on gemini-3.6-flash with audio at thinking level `low`
|
|
159
|
+
// (2026-11-28), part 0 held a stray reasoning fragment and part 1 the
|
|
160
|
+
// whole real transcript, so reading part 0 alone stored the fragment and
|
|
161
|
+
// dropped the transcript (Mirror row 3271ad65). Parts flagged
|
|
162
|
+
// `thought: true` are reasoning summaries, sent only when a request asks
|
|
163
|
+
// for them (`includeThoughts`, which this adapter never sets) and never
|
|
164
|
+
// part of the answer. Reasoning the model writes into an ordinary part is
|
|
165
|
+
// indistinguishable from the answer here: see "Audio input" in LLM.md.
|
|
166
|
+
const answerParts = (data.candidates?.[0]?.content?.parts ?? [])
|
|
167
|
+
.filter((part) => part.thought !== true && typeof part.text === 'string');
|
|
168
|
+
const text = answerParts.map((part) => part.text).join('');
|
|
157
169
|
// totalTokenCount = promptTokenCount (cached part included) + candidates
|
|
158
170
|
// + thoughts (verified live on 3.6 Flash, 2026-11-07). Google bills
|
|
159
171
|
// thoughts at the output rate and implicit-cache hits at a tenth of the
|
|
@@ -180,6 +192,8 @@ export const geminiProvider = {
|
|
|
180
192
|
status: response.status, latencyMs, tokensUsed, outputTokens, finishReason,
|
|
181
193
|
...(reasoningTokens !== undefined ? { reasoningTokens } : {}),
|
|
182
194
|
...(cacheReadTokens !== undefined ? { cacheReadTokens } : {}),
|
|
195
|
+
// A split answer is rare and has meant leaked reasoning (above).
|
|
196
|
+
...(answerParts.length > 1 ? { textParts: answerParts.length } : {}),
|
|
183
197
|
...(request.callSite ? { callSite: request.callSite } : {}),
|
|
184
198
|
});
|
|
185
199
|
return {
|
|
@@ -85,7 +85,9 @@ export interface SyncClientOptions<B, C extends EventBody, S extends EventBody,
|
|
|
85
85
|
fetchBootstrap(signal: AbortSignal): Promise<B>;
|
|
86
86
|
fetchCatchup(afterSeq: number, signal: AbortSignal): Promise<CatchupResult<S>>;
|
|
87
87
|
beaconUrl: string;
|
|
88
|
-
|
|
88
|
+
/** The app's own sync socket. Needed only without `hubUrl`: an app whose
|
|
89
|
+
* server no longer serves one omits it (since 3.75.0). */
|
|
90
|
+
socketUrl?(): string;
|
|
89
91
|
runtime: SyncBrowserRuntime;
|
|
90
92
|
authState: {
|
|
91
93
|
isBlocked(): boolean;
|
|
@@ -124,7 +126,8 @@ export interface SyncClientOptions<B, C extends EventBody, S extends EventBody,
|
|
|
124
126
|
* `wss://<hub>/api/ws?app=<app>` and carries hints only; mutations go over
|
|
125
127
|
* `postEvents` and catch-ups over `fetchCatchup`, against the app.
|
|
126
128
|
* Unset or empty: the same-origin socket (`socketUrl`), exactly as before.
|
|
127
|
-
* Requires `app` and `postEvents`.
|
|
129
|
+
* Requires `app` and `postEvents`. One of `hubUrl` and `socketUrl` must be
|
|
130
|
+
* set: the constructor throws otherwise. */
|
|
128
131
|
hubUrl?: string;
|
|
129
132
|
/** This app's name on the hub socket (hub mode). */
|
|
130
133
|
app?: string;
|
|
@@ -198,6 +201,8 @@ export declare class SyncClient<B, C extends EventBody, S extends EventBody, Sum
|
|
|
198
201
|
private visibleSinceMono;
|
|
199
202
|
private readonly counters;
|
|
200
203
|
private readonly hub;
|
|
204
|
+
/** Where the live socket goes: the hub's URL, or the app's own. */
|
|
205
|
+
private readonly socketUrl;
|
|
201
206
|
/** The live hub socket answered our `connect`. */
|
|
202
207
|
private hubAcked;
|
|
203
208
|
/** Counts acks: a catch-up establishes only if it began under the current one. */
|
|
@@ -386,7 +391,6 @@ export declare class SyncClient<B, C extends EventBody, S extends EventBody, Sum
|
|
|
386
391
|
private cancelResyncFailureRetry;
|
|
387
392
|
private sendConnect;
|
|
388
393
|
private connectMessage;
|
|
389
|
-
private socketUrl;
|
|
390
394
|
private sendRaw;
|
|
391
395
|
private trySend;
|
|
392
396
|
private flushViaBeacon;
|
|
@@ -169,6 +169,8 @@ export class SyncClient {
|
|
|
169
169
|
// fields above then hold the hub socket; the app's own reachability has
|
|
170
170
|
// its own ladder here, independent of the socket's.
|
|
171
171
|
hub;
|
|
172
|
+
/** Where the live socket goes: the hub's URL, or the app's own. */
|
|
173
|
+
socketUrl;
|
|
172
174
|
/** The live hub socket answered our `connect`. */
|
|
173
175
|
hubAcked = false;
|
|
174
176
|
/** Counts acks: a catch-up establishes only if it began under the current one. */
|
|
@@ -201,12 +203,18 @@ export class SyncClient {
|
|
|
201
203
|
constructor(options) {
|
|
202
204
|
this.options = options;
|
|
203
205
|
if (!options.hubUrl) {
|
|
206
|
+
const sameOrigin = options.socketUrl?.bind(options);
|
|
207
|
+
if (!sameOrigin)
|
|
208
|
+
throw new Error('sync needs hubUrl or socketUrl');
|
|
204
209
|
this.hub = null;
|
|
210
|
+
this.socketUrl = () => sameOrigin();
|
|
205
211
|
return;
|
|
206
212
|
}
|
|
207
213
|
if (!options.app || !options.postEvents)
|
|
208
214
|
throw new Error('sync hub mode needs app and postEvents');
|
|
209
|
-
|
|
215
|
+
const url = hubSocketUrl(options.hubUrl, options.app);
|
|
216
|
+
this.hub = { app: options.app, postEvents: options.postEvents };
|
|
217
|
+
this.socketUrl = () => url;
|
|
210
218
|
}
|
|
211
219
|
init() {
|
|
212
220
|
if (this.disposed)
|
|
@@ -1900,9 +1908,6 @@ export class SyncClient {
|
|
|
1900
1908
|
return { type: 'connect', clientGuid: this.options.clientGuid };
|
|
1901
1909
|
return { type: 'connect', clientGuid: this.options.clientGuid, lastSeq: this.options.store.currentSeq() };
|
|
1902
1910
|
}
|
|
1903
|
-
socketUrl() {
|
|
1904
|
-
return this.hub?.socketUrl ?? this.options.socketUrl();
|
|
1905
|
-
}
|
|
1906
1911
|
sendRaw(message) {
|
|
1907
1912
|
if (this.socket?.readyState !== SOCKET_OPEN)
|
|
1908
1913
|
return;
|
package/package.json
CHANGED