@drawbridge/drawbridge-utils 0.0.60 → 0.0.61

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/ai.cjs CHANGED
@@ -157,7 +157,7 @@ var debit = async ({
157
157
 
158
158
  // lib/ai.js
159
159
  var google_client = new import_genai.GoogleGenAI({
160
- apiKey: process.env.GOOGLE_API_KEY
160
+ apiKey: process.env.GOOGLE_GEMINI_API_KEY
161
161
  });
162
162
  var googleCircuit = circuit({
163
163
  name: "google-ai",
@@ -303,13 +303,14 @@ var google = {
303
303
  text: async ({
304
304
  config = {},
305
305
  images = [],
306
+ parts = null,
306
307
  prompt = []
307
308
  }, {
308
309
  db,
309
310
  user
310
311
  }) => {
311
312
  const model = models.text;
312
- const contents = images.length ? { parts: [...images.map((image) => ({ inlineData: { data: image.data, mimeType: image.mimeType } })), { text: prompt.join("\n") }] } : prompt.join("\n");
313
+ const contents = parts ? { parts } : images.length ? { parts: [...images.map((image) => ({ inlineData: { data: image.data, mimeType: image.mimeType } })), { text: prompt.join("\n") }] } : prompt.join("\n");
313
314
  const response = await googleCircuit(() => google_client.models.generateContent({
314
315
  config: {
315
316
  ...config,
package/dist/ai.d.cts CHANGED
@@ -23,7 +23,7 @@ import '@drawbridge/drawbridge-telemetry';
23
23
 
24
24
 
25
25
  const google_client = new GoogleGenAI({
26
- apiKey : process.env.GOOGLE_API_KEY
26
+ apiKey : process.env.GOOGLE_GEMINI_API_KEY
27
27
  });
28
28
 
29
29
  const googleCircuit = circuit({
@@ -266,6 +266,7 @@ const google = {
266
266
  {
267
267
  config = {},
268
268
  images = [],
269
+ parts = null,
269
270
  prompt = []
270
271
  },
271
272
  {
@@ -276,12 +277,18 @@ const google = {
276
277
 
277
278
  const model = models.text;
278
279
 
279
- // When images are supplied (e.g. a page screenshot), send a multimodal
280
- // parts payload so the model can SEE them alongside the text prompt;
281
- // otherwise keep the plain-string contents for text-only calls.
282
- const contents = images.length
283
- ? { parts : [ ...images.map( ( image ) => ({ inlineData : { data : image.data, mimeType : image.mimeType } }) ), { text : prompt.join( '\n' ) } ] }
284
- : prompt.join( '\n' );
280
+ // Three contents shapes, in priority order:
281
+ // 1. `parts` a caller-built array of interleaved text/inlineData parts,
282
+ // used verbatim. For calls where ordering matters (e.g. the hero-pick
283
+ // interleaves "Image N:" labels with each thumbnail so the model can
284
+ // map an index to an image); images/prompt can't express that.
285
+ // 2. `images` — a screenshot etc. sent multimodally before the prompt.
286
+ // 3. plain joined string for text-only calls.
287
+ const contents = parts
288
+ ? { parts }
289
+ : images.length
290
+ ? { parts : [ ...images.map( ( image ) => ({ inlineData : { data : image.data, mimeType : image.mimeType } }) ), { text : prompt.join( '\n' ) } ] }
291
+ : prompt.join( '\n' );
285
292
 
286
293
  const response = await googleCircuit( () => google_client.models.generateContent({
287
294
  config : {
package/dist/ai.d.ts CHANGED
@@ -23,7 +23,7 @@ import '@drawbridge/drawbridge-telemetry';
23
23
 
24
24
 
25
25
  const google_client = new GoogleGenAI({
26
- apiKey : process.env.GOOGLE_API_KEY
26
+ apiKey : process.env.GOOGLE_GEMINI_API_KEY
27
27
  });
28
28
 
29
29
  const googleCircuit = circuit({
@@ -266,6 +266,7 @@ const google = {
266
266
  {
267
267
  config = {},
268
268
  images = [],
269
+ parts = null,
269
270
  prompt = []
270
271
  },
271
272
  {
@@ -276,12 +277,18 @@ const google = {
276
277
 
277
278
  const model = models.text;
278
279
 
279
- // When images are supplied (e.g. a page screenshot), send a multimodal
280
- // parts payload so the model can SEE them alongside the text prompt;
281
- // otherwise keep the plain-string contents for text-only calls.
282
- const contents = images.length
283
- ? { parts : [ ...images.map( ( image ) => ({ inlineData : { data : image.data, mimeType : image.mimeType } }) ), { text : prompt.join( '\n' ) } ] }
284
- : prompt.join( '\n' );
280
+ // Three contents shapes, in priority order:
281
+ // 1. `parts` a caller-built array of interleaved text/inlineData parts,
282
+ // used verbatim. For calls where ordering matters (e.g. the hero-pick
283
+ // interleaves "Image N:" labels with each thumbnail so the model can
284
+ // map an index to an image); images/prompt can't express that.
285
+ // 2. `images` — a screenshot etc. sent multimodally before the prompt.
286
+ // 3. plain joined string for text-only calls.
287
+ const contents = parts
288
+ ? { parts }
289
+ : images.length
290
+ ? { parts : [ ...images.map( ( image ) => ({ inlineData : { data : image.data, mimeType : image.mimeType } }) ), { text : prompt.join( '\n' ) } ] }
291
+ : prompt.join( '\n' );
285
292
 
286
293
  const response = await googleCircuit( () => google_client.models.generateContent({
287
294
  config : {
package/dist/ai.js CHANGED
@@ -127,7 +127,7 @@ var debit = async ({
127
127
 
128
128
  // lib/ai.js
129
129
  var google_client = new GoogleGenAI({
130
- apiKey: process.env.GOOGLE_API_KEY
130
+ apiKey: process.env.GOOGLE_GEMINI_API_KEY
131
131
  });
132
132
  var googleCircuit = circuit({
133
133
  name: "google-ai",
@@ -273,13 +273,14 @@ var google = {
273
273
  text: async ({
274
274
  config = {},
275
275
  images = [],
276
+ parts = null,
276
277
  prompt = []
277
278
  }, {
278
279
  db,
279
280
  user
280
281
  }) => {
281
282
  const model = models.text;
282
- const contents = images.length ? { parts: [...images.map((image) => ({ inlineData: { data: image.data, mimeType: image.mimeType } })), { text: prompt.join("\n") }] } : prompt.join("\n");
283
+ const contents = parts ? { parts } : images.length ? { parts: [...images.map((image) => ({ inlineData: { data: image.data, mimeType: image.mimeType } })), { text: prompt.join("\n") }] } : prompt.join("\n");
283
284
  const response = await googleCircuit(() => google_client.models.generateContent({
284
285
  config: {
285
286
  ...config,
package/package.json CHANGED
@@ -160,5 +160,5 @@
160
160
  "build": "tsup && npm publish"
161
161
  },
162
162
  "types": "dist/index.d.ts",
163
- "version": "0.0.60"
163
+ "version": "0.0.61"
164
164
  }