@veryfront/ext-llm-google 0.1.1285 → 0.1.1286-rc.25342

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.
@@ -1 +1 @@
1
- {"version":3,"file":"google-thought-signatures.d.ts","sourceRoot":"","sources":["../src/google-thought-signatures.ts"],"names":[],"mappings":"AAwBA,eAAO,MAAM,kCAAkC,QAAkB,CAAC;AAuQlE,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,MAAM,GAAG,SAAS,CASpB;AAED,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACrC,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3C,uBAAuB,CAAC,EAAE,SAAS,MAAM,EAAE,EAC3C,aAAa,CAAC,EAAE,MAAM,GACrB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CA+CrC;AAuGD,MAAM,MAAM,wBAAwB,GAAG;IACrC,KAAK,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IAC1C,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,wBAAgB,4BAA4B,CAC1C,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GACpD,wBAAwB,GAAG,SAAS,CAoCtC;AAED,wBAAgB,2BAA2B,CACzC,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GACpD,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,SAAS,CAEhD;AAED;;;GAGG;AACH,wBAAgB,+BAA+B,CAC7C,gBAAgB,EAAE,MAAM,CAAC,MAA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BAA+B,CAC7C,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzC,mBAAmB,EAAE,SAAS;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,GAC3D,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CA+ErC"}
@@ -124,6 +124,32 @@ function hasGoogleReplayTriggerProperty(part, key) {
124
124
  // descriptor-based snapshot rejects it without invoking caller code.
125
125
  return !Object.hasOwn(descriptor, "value") || descriptor.value !== undefined;
126
126
  }
127
+ function isGooglePartIndex(partKey, partsLength) {
128
+ if (partKey === "length" || typeof partKey !== "string") {
129
+ return false;
130
+ }
131
+ const partIndex = Number(partKey);
132
+ if (!Number.isSafeInteger(partIndex) ||
133
+ partIndex < 0 ||
134
+ partIndex >= partsLength ||
135
+ String(partIndex) !== partKey) {
136
+ return false;
137
+ }
138
+ return true;
139
+ }
140
+ function readGoogleAssistantPartDescriptor(parts, partKey) {
141
+ let partDescriptor;
142
+ try {
143
+ partDescriptor = Object.getOwnPropertyDescriptor(parts, partKey);
144
+ }
145
+ catch {
146
+ throw new TypeError("Google assistant parts could not be inspected");
147
+ }
148
+ if (partDescriptor === undefined) {
149
+ throw new TypeError("Google assistant parts changed while being inspected");
150
+ }
151
+ return partDescriptor;
152
+ }
127
153
  function needsGoogleExactReplay(parts) {
128
154
  let lengthDescriptor;
129
155
  try {
@@ -147,26 +173,9 @@ function needsGoogleExactReplay(parts) {
147
173
  throw new TypeError("Google assistant parts could not be inspected");
148
174
  }
149
175
  for (const partKey of partKeys) {
150
- if (partKey === "length" || typeof partKey !== "string") {
176
+ if (!isGooglePartIndex(partKey, partsLength))
151
177
  continue;
152
- }
153
- const partIndex = Number(partKey);
154
- if (!Number.isSafeInteger(partIndex) ||
155
- partIndex < 0 ||
156
- partIndex >= partsLength ||
157
- String(partIndex) !== partKey) {
158
- continue;
159
- }
160
- let partDescriptor;
161
- try {
162
- partDescriptor = Object.getOwnPropertyDescriptor(parts, partKey);
163
- }
164
- catch {
165
- throw new TypeError("Google assistant parts could not be inspected");
166
- }
167
- if (partDescriptor === undefined) {
168
- throw new TypeError("Google assistant parts changed while being inspected");
169
- }
178
+ const partDescriptor = readGoogleAssistantPartDescriptor(parts, partKey);
170
179
  if (!Object.hasOwn(partDescriptor, "value")) {
171
180
  // Force the protected snapshot path, which rejects array accessors
172
181
  // without invoking them.
@@ -234,7 +243,7 @@ export function createGoogleProviderMetadata(parts, groundingMetadata, rawAssist
234
243
  return undefined;
235
244
  }
236
245
  let ownedParts;
237
- if (needsExactReplay) {
246
+ const snapshotReplayParts = () => {
238
247
  const partsSnapshot = snapshotGoogleProviderMetadata(parts);
239
248
  if (!Array.isArray(partsSnapshot)) {
240
249
  throw new TypeError("Google raw assistant parts must be an array");
@@ -245,8 +254,13 @@ export function createGoogleProviderMetadata(parts, groundingMetadata, rawAssist
245
254
  const ownedPartIndexes = rawAssistantPartIndexes === undefined
246
255
  ? undefined
247
256
  : validateGoogleRawAssistantPartIndexes(snapshotGoogleProviderMetadata(rawAssistantPartIndexes), partsSnapshot.length);
248
- ownedParts = validateGoogleRawAssistantParts(partsSnapshot, ownedPartIndexes, toolCallScope);
249
- rawAssistantPartIndexes = ownedPartIndexes;
257
+ const ownedParts = validateGoogleRawAssistantParts(partsSnapshot, ownedPartIndexes, toolCallScope);
258
+ return { parts: ownedParts, partIndexes: ownedPartIndexes };
259
+ };
260
+ if (needsExactReplay) {
261
+ const replayParts = snapshotReplayParts();
262
+ ownedParts = replayParts.parts;
263
+ rawAssistantPartIndexes = replayParts.partIndexes;
250
264
  }
251
265
  const metadata = snapshotGoogleProviderMetadata({
252
266
  [GOOGLE_METADATA_KEY]: {
@@ -276,19 +290,7 @@ function validateGoogleRawAssistantParts(rawParts, rawPartIndexes, toolCallScope
276
290
  let hasThoughtSignature = false;
277
291
  let hasCodeExecution = false;
278
292
  const toolCallRegistry = createGoogleToolCallCorrelationRegistry(toolCallScope);
279
- for (let partIndex = 0; partIndex < rawParts.length; partIndex += 1) {
280
- const rawPart = rawParts[partIndex];
281
- if (rawPart === undefined) {
282
- throw new TypeError("Google raw assistant parts must be dense");
283
- }
284
- const part = asSnapshotRecord(rawPart);
285
- if (!part) {
286
- throw new TypeError("Google raw assistant part must be an object");
287
- }
288
- const dataField = validateReplayableGooglePart(part);
289
- if (readGoogleThoughtSignature(part) !== undefined) {
290
- hasThoughtSignature = true;
291
- }
293
+ const validateToolPart = (dataField, part, partIndex) => {
292
294
  if (dataField === "functionCall") {
293
295
  const functionCall = readRecord(part.functionCall);
294
296
  const functionCallId = typeof functionCall?.id === "string" ? functionCall.id : undefined;
@@ -321,6 +323,21 @@ function validateGoogleRawAssistantParts(rawParts, rawPartIndexes, toolCallScope
321
323
  : "Google raw assistant code execution result id did not match executable code");
322
324
  }
323
325
  }
326
+ };
327
+ for (let partIndex = 0; partIndex < rawParts.length; partIndex += 1) {
328
+ const rawPart = rawParts[partIndex];
329
+ if (rawPart === undefined) {
330
+ throw new TypeError("Google raw assistant parts must be dense");
331
+ }
332
+ const part = asSnapshotRecord(rawPart);
333
+ if (!part) {
334
+ throw new TypeError("Google raw assistant part must be an object");
335
+ }
336
+ const dataField = validateReplayableGooglePart(part);
337
+ if (readGoogleThoughtSignature(part) !== undefined) {
338
+ hasThoughtSignature = true;
339
+ }
340
+ validateToolPart(dataField, part, partIndex);
324
341
  }
325
342
  if (!hasThoughtSignature && !hasCodeExecution) {
326
343
  throw new TypeError("Google raw assistant parts contained neither a thought signature nor code execution");
@@ -403,12 +420,7 @@ export function reconcileGoogleProviderMetadata(providerMetadata, suppressedTool
403
420
  const retainedPartIndexes = [];
404
421
  const registry = createGoogleToolCallCorrelationRegistry(toolCallScope);
405
422
  let retainedToolPart = false;
406
- for (let partIndex = 0; partIndex < rawAssistantParts.length; partIndex += 1) {
407
- const part = rawAssistantParts[partIndex];
408
- if (part === undefined) {
409
- throw new TypeError("Google raw assistant parts must be dense");
410
- }
411
- const dataField = readGooglePartDataField(part);
423
+ const resolveToolCallId = (part, partIndex, dataField) => {
412
424
  let toolCallId;
413
425
  if (dataField === "functionCall") {
414
426
  const functionCall = readRecord(part.functionCall);
@@ -423,6 +435,15 @@ export function reconcileGoogleProviderMetadata(providerMetadata, suppressedTool
423
435
  const result = readGoogleCodeExecutionResult(part.codeExecutionResult);
424
436
  toolCallId = registry.resolveCodeExecutionResult(result.providerId);
425
437
  }
438
+ return toolCallId;
439
+ };
440
+ for (let partIndex = 0; partIndex < rawAssistantParts.length; partIndex += 1) {
441
+ const part = rawAssistantParts[partIndex];
442
+ if (part === undefined) {
443
+ throw new TypeError("Google raw assistant parts must be dense");
444
+ }
445
+ const dataField = readGooglePartDataField(part);
446
+ const toolCallId = resolveToolCallId(part, partIndex, dataField);
426
447
  if (toolCallId !== undefined && suppressedIds.has(toolCallId)) {
427
448
  matchedSuppressedIds.add(toolCallId);
428
449
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veryfront/ext-llm-google",
3
- "version": "0.1.1285",
3
+ "version": "0.1.1286-rc.25342",
4
4
  "description": "Veryfront first-party extension package for ext-llm-google",
5
5
  "keywords": [
6
6
  "veryfront",
@@ -49,7 +49,7 @@
49
49
  "@deno/shim-crypto": "~0.3.1"
50
50
  },
51
51
  "peerDependencies": {
52
- "veryfront": "^0.1.1285"
52
+ "veryfront": "^0.1.1286-rc.25342"
53
53
  },
54
54
  "type": "module",
55
55
  "types": "./esm/index.d.ts",
@@ -59,5 +59,5 @@
59
59
  "NOTICE",
60
60
  "README.md"
61
61
  ],
62
- "gitHead": "2bac963100515224f14213021beb42e128b201ea"
62
+ "gitHead": "07f4ea751fe2a988164bd5c0db7b03d0349b3eba"
63
63
  }