@rcrsr/rill-ext-gemini 0.11.0 → 0.16.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.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  // Generated by dts-bundle-generator v9.5.1
2
2
 
3
- import { ExtensionConfigSchema, ExtensionResult } from '@rcrsr/rill';
3
+ import { ExtensionConfigSchema, ExtensionManifest, ExtensionResult } from '@rcrsr/rill';
4
4
 
5
5
  /**
6
6
  * Base configuration for LLM extensions
@@ -73,8 +73,9 @@ export type GeminiExtensionConfig = LLMProviderConfig;
73
73
  * ```
74
74
  */
75
75
  export declare function createGeminiExtension(config: GeminiExtensionConfig): ExtensionResult;
76
- export declare const VERSION = "0.0.1";
76
+ export declare const VERSION: string;
77
77
  export declare const configSchema: ExtensionConfigSchema;
78
+ export declare const extensionManifest: ExtensionManifest;
78
79
 
79
80
  export {
80
81
  LLMProviderConfig as LLMExtensionConfig,
package/dist/index.js CHANGED
@@ -1,3 +1,6 @@
1
+ // src/index.ts
2
+ import { createRequire } from "module";
3
+
1
4
  // src/factory.ts
2
5
  import {
3
6
  GoogleGenAI,
@@ -8,7 +11,8 @@ import {
8
11
  emitExtensionEvent,
9
12
  createVector,
10
13
  isVector,
11
- isDict as isDict2
14
+ isDict as isDict2,
15
+ rillTypeToTypeValue
12
16
  } from "@rcrsr/rill";
13
17
 
14
18
  // ../../shared/ext-llm/dist/validation.js
@@ -124,7 +128,9 @@ function buildJsonSchemaFromStructuralType(type, params) {
124
128
  if (type.type === "closure") {
125
129
  const closureParams = type.params ?? [];
126
130
  for (let i = 0; i < closureParams.length; i++) {
127
- const [paramName, paramType] = closureParams[i];
131
+ const fieldDef = closureParams[i];
132
+ const paramName = fieldDef.name ?? `param${i}`;
133
+ const paramType = fieldDef.type;
128
134
  const rillParam = params?.[i];
129
135
  const property = buildPropertyFromStructuralType(paramType);
130
136
  const description = rillParam?.annotations["description"];
@@ -223,21 +229,20 @@ async function executeToolCall(toolName, toolInput, tools, context) {
223
229
  throw new RuntimeError4("RILL-R004", `Invalid tool input for ${toolName}: tool must be application, runtime, or script callable`);
224
230
  }
225
231
  try {
226
- let args;
227
- if ((callable.kind === "application" || callable.kind === "script") && callable.params && callable.params.length > 0) {
228
- const params = callable.params;
229
- const inputDict = toolInput;
230
- args = params.map((param) => {
231
- const value = inputDict[param.name];
232
- return value !== void 0 ? value : void 0;
233
- });
234
- } else {
235
- args = [toolInput];
236
- }
232
+ const inputDict = toolInput;
237
233
  if (callable.kind === "script") {
238
234
  if (!context) {
239
235
  throw new RuntimeError4("RILL-R004", `Invalid tool input for ${toolName}: script callable requires a runtime context`);
240
236
  }
237
+ let args;
238
+ if (callable.params && callable.params.length > 0) {
239
+ args = callable.params.map((param) => {
240
+ const value = inputDict[param.name];
241
+ return value !== void 0 ? value : void 0;
242
+ });
243
+ } else {
244
+ args = [inputDict];
245
+ }
241
246
  return await invokeCallable(callable, args, context);
242
247
  }
243
248
  const ctx = context ?? {
@@ -245,7 +250,7 @@ async function executeToolCall(toolName, toolInput, tools, context) {
245
250
  variables: /* @__PURE__ */ new Map(),
246
251
  pipeValue: null
247
252
  };
248
- const result = callable.fn(args, ctx);
253
+ const result = callable.fn(inputDict, ctx);
249
254
  return result instanceof Promise ? await result : result;
250
255
  } catch (error) {
251
256
  if (error instanceof RuntimeError4) {
@@ -338,18 +343,13 @@ async function executeToolLoop(messages, tools, maxErrors, callbacks, emitEvent,
338
343
  throw new RuntimeError4("RILL-R004", `tool_loop: tool "${name}" is not a callable`);
339
344
  }
340
345
  const callable = fnValue;
341
- let description;
342
- if (callable.kind === "script") {
343
- description = callable.annotations["description"] ?? "";
344
- } else {
345
- description = callable.description ?? "";
346
- }
346
+ const description = callable.annotations?.["description"] ?? "";
347
347
  let inputSchema;
348
348
  const params = callable.kind === "application" ? callable.params ?? [] : callable.kind === "script" ? callable.params : [];
349
349
  if (params.length > 0) {
350
350
  const closureType = {
351
351
  type: "closure",
352
- params: params.map((p2) => [p2.name, p2.type ?? { type: "any" }])
352
+ params: params.map((p2) => ({ name: p2.name, type: p2.type ?? { type: "any" } }))
353
353
  };
354
354
  const builtSchema = buildJsonSchemaFromStructuralType(closureType, [...params]);
355
355
  inputSchema = {
@@ -548,13 +548,15 @@ var p = {
548
548
  * @param name - Parameter name (must be a valid identifier)
549
549
  * @param desc - Optional description
550
550
  * @param def - Optional default value
551
- * @returns RillParam with type 'dict'
551
+ * @param fields - Optional structural field definitions (RillFieldDef with type and optional defaultValue)
552
+ * @returns RillParam with type 'dict' (with fields if provided)
552
553
  */
553
- dict(name, desc, def) {
554
+ dict(name, desc, def, fields) {
554
555
  validateParamName(name);
556
+ const type = fields !== void 0 ? { type: "dict", fields } : { type: "dict" };
555
557
  return {
556
558
  name,
557
- type: { type: "dict" },
559
+ type,
558
560
  defaultValue: def,
559
561
  annotations: buildAnnotations(desc)
560
562
  };
@@ -676,13 +678,16 @@ function createGeminiExtension(config) {
676
678
  message: {
677
679
  params: [
678
680
  p.str("text"),
679
- p.dict("options", void 0, {})
681
+ p.dict("options", void 0, {}, {
682
+ system: { type: { type: "string" }, defaultValue: "" },
683
+ max_tokens: { type: { type: "number" }, defaultValue: 0 }
684
+ })
680
685
  ],
681
686
  fn: async (args, ctx) => {
682
687
  const startTime = Date.now();
683
688
  try {
684
- const text = args[0];
685
- const options = args[1] ?? {};
689
+ const text = args["text"];
690
+ const options = args["options"] ?? {};
686
691
  if (text.trim().length === 0) {
687
692
  throw new RuntimeError6("RILL-R004", "prompt text cannot be empty");
688
693
  }
@@ -750,20 +755,33 @@ function createGeminiExtension(config) {
750
755
  throw rillError;
751
756
  }
752
757
  },
753
- description: "Send single message to Gemini API",
754
- returnType: { type: "dict" }
758
+ annotations: { description: "Send single message to Gemini API" },
759
+ returnType: rillTypeToTypeValue({
760
+ type: "dict",
761
+ fields: {
762
+ content: { type: { type: "string" } },
763
+ model: { type: { type: "string" } },
764
+ usage: { type: { type: "dict", fields: { input: { type: { type: "number" } }, output: { type: { type: "number" } } } } },
765
+ stop_reason: { type: { type: "string" } },
766
+ id: { type: { type: "string" } },
767
+ messages: { type: { type: "list", element: { type: "dict" } } }
768
+ }
769
+ })
755
770
  },
756
771
  // IR-5: gemini::messages
757
772
  messages: {
758
773
  params: [
759
- p.list("messages"),
760
- p.dict("options", void 0, {})
774
+ p.list("messages", { type: "dict", fields: { role: { type: { type: "string" } }, content: { type: { type: "string" } } } }),
775
+ p.dict("options", void 0, {}, {
776
+ system: { type: { type: "string" }, defaultValue: "" },
777
+ max_tokens: { type: { type: "number" }, defaultValue: 0 }
778
+ })
761
779
  ],
762
780
  fn: async (args, ctx) => {
763
781
  const startTime = Date.now();
764
782
  try {
765
- const messages = args[0];
766
- const options = args[1] ?? {};
783
+ const messages = args["messages"];
784
+ const options = args["options"] ?? {};
767
785
  if (messages.length === 0) {
768
786
  throw new RuntimeError6(
769
787
  "RILL-R004",
@@ -874,8 +892,18 @@ function createGeminiExtension(config) {
874
892
  throw rillError;
875
893
  }
876
894
  },
877
- description: "Send multi-turn conversation to Gemini API",
878
- returnType: { type: "dict" }
895
+ annotations: { description: "Send multi-turn conversation to Gemini API" },
896
+ returnType: rillTypeToTypeValue({
897
+ type: "dict",
898
+ fields: {
899
+ content: { type: { type: "string" } },
900
+ model: { type: { type: "string" } },
901
+ usage: { type: { type: "dict", fields: { input: { type: { type: "number" } }, output: { type: { type: "number" } } } } },
902
+ stop_reason: { type: { type: "string" } },
903
+ id: { type: { type: "string" } },
904
+ messages: { type: { type: "list", element: { type: "dict" } } }
905
+ }
906
+ })
879
907
  },
880
908
  // IR-6: gemini::embed
881
909
  embed: {
@@ -883,7 +911,7 @@ function createGeminiExtension(config) {
883
911
  fn: async (args, ctx) => {
884
912
  const startTime = Date.now();
885
913
  try {
886
- const text = args[0];
914
+ const text = args["text"];
887
915
  validateEmbedText(text);
888
916
  validateEmbedModel(factoryEmbedModel);
889
917
  const response = await client.models.embedContent({
@@ -920,8 +948,8 @@ function createGeminiExtension(config) {
920
948
  throw rillError;
921
949
  }
922
950
  },
923
- description: "Generate embedding vector for text",
924
- returnType: { type: "vector" }
951
+ annotations: { description: "Generate embedding vector for text" },
952
+ returnType: rillTypeToTypeValue({ type: "vector" })
925
953
  },
926
954
  // IR-7: gemini::embed_batch
927
955
  embed_batch: {
@@ -929,7 +957,7 @@ function createGeminiExtension(config) {
929
957
  fn: async (args, ctx) => {
930
958
  const startTime = Date.now();
931
959
  try {
932
- const texts = args[0];
960
+ const texts = args["texts"];
933
961
  if (texts.length === 0) {
934
962
  return [];
935
963
  }
@@ -981,20 +1009,27 @@ function createGeminiExtension(config) {
981
1009
  throw rillError;
982
1010
  }
983
1011
  },
984
- description: "Generate embedding vectors for multiple texts",
985
- returnType: { type: "list" }
1012
+ annotations: { description: "Generate embedding vectors for multiple texts" },
1013
+ returnType: rillTypeToTypeValue({ type: "list", element: { type: "vector" } })
986
1014
  },
987
1015
  // IR-8: gemini::tool_loop
988
1016
  tool_loop: {
989
1017
  params: [
990
1018
  p.str("prompt"),
991
- p.dict("options", void 0, {})
1019
+ p.dict("options", void 0, {}, {
1020
+ tools: { type: { type: "dict" } },
1021
+ system: { type: { type: "string" }, defaultValue: "" },
1022
+ max_tokens: { type: { type: "number" }, defaultValue: 0 },
1023
+ max_errors: { type: { type: "number" }, defaultValue: 3 },
1024
+ max_turns: { type: { type: "number" }, defaultValue: 10 },
1025
+ messages: { type: { type: "list", element: { type: "dict", fields: { role: { type: { type: "string" } }, content: { type: { type: "string" } } } } }, defaultValue: [] }
1026
+ })
992
1027
  ],
993
1028
  fn: async (args, ctx) => {
994
1029
  const startTime = Date.now();
995
1030
  try {
996
- const prompt = args[0];
997
- const options = args[1] ?? {};
1031
+ const prompt = args["prompt"];
1032
+ const options = args["options"] ?? {};
998
1033
  if (prompt.trim().length === 0) {
999
1034
  throw new RuntimeError6("RILL-R004", "prompt text cannot be empty");
1000
1035
  }
@@ -1186,20 +1221,35 @@ function createGeminiExtension(config) {
1186
1221
  throw rillError;
1187
1222
  }
1188
1223
  },
1189
- description: "Execute tool-use loop with Gemini API",
1190
- returnType: { type: "dict" }
1224
+ annotations: { description: "Execute tool-use loop with Gemini API" },
1225
+ returnType: rillTypeToTypeValue({
1226
+ type: "dict",
1227
+ fields: {
1228
+ content: { type: { type: "string" } },
1229
+ model: { type: { type: "string" } },
1230
+ usage: { type: { type: "dict", fields: { input: { type: { type: "number" } }, output: { type: { type: "number" } } } } },
1231
+ stop_reason: { type: { type: "string" } },
1232
+ turns: { type: { type: "number" } },
1233
+ messages: { type: { type: "list", element: { type: "dict" } } }
1234
+ }
1235
+ })
1191
1236
  },
1192
1237
  // IR-3: gemini::generate
1193
1238
  generate: {
1194
1239
  params: [
1195
1240
  p.str("prompt"),
1196
- p.dict("options")
1241
+ p.dict("options", void 0, {}, {
1242
+ schema: { type: { type: "dict" } },
1243
+ system: { type: { type: "string" }, defaultValue: "" },
1244
+ max_tokens: { type: { type: "number" }, defaultValue: 0 },
1245
+ messages: { type: { type: "list", element: { type: "dict", fields: { role: { type: { type: "string" } }, content: { type: { type: "string" } } } } }, defaultValue: [] }
1246
+ })
1197
1247
  ],
1198
1248
  fn: async (args, ctx) => {
1199
1249
  const startTime = Date.now();
1200
1250
  try {
1201
- const prompt = args[0];
1202
- const options = args[1] ?? {};
1251
+ const prompt = args["prompt"];
1252
+ const options = args["options"] ?? {};
1203
1253
  if (!("schema" in options) || options["schema"] === null || options["schema"] === void 0) {
1204
1254
  throw new RuntimeError6(
1205
1255
  "RILL-R004",
@@ -1310,8 +1360,18 @@ function createGeminiExtension(config) {
1310
1360
  throw rillError;
1311
1361
  }
1312
1362
  },
1313
- description: "Generate structured output from Gemini API",
1314
- returnType: { type: "dict" }
1363
+ annotations: { description: "Generate structured output from Gemini API" },
1364
+ returnType: rillTypeToTypeValue({
1365
+ type: "dict",
1366
+ fields: {
1367
+ data: { type: { type: "any" } },
1368
+ raw: { type: { type: "string" } },
1369
+ model: { type: { type: "string" } },
1370
+ usage: { type: { type: "dict", fields: { input: { type: { type: "number" } }, output: { type: { type: "number" } } } } },
1371
+ stop_reason: { type: { type: "string" } },
1372
+ id: { type: { type: "string" } }
1373
+ }
1374
+ })
1315
1375
  }
1316
1376
  };
1317
1377
  result.dispose = dispose;
@@ -1319,7 +1379,9 @@ function createGeminiExtension(config) {
1319
1379
  }
1320
1380
 
1321
1381
  // src/index.ts
1322
- var VERSION = "0.0.1";
1382
+ var _require = createRequire(import.meta.url);
1383
+ var _pkg = _require("../package.json");
1384
+ var VERSION = _pkg.version;
1323
1385
  var configSchema = {
1324
1386
  api_key: { type: "string", required: true, secret: true },
1325
1387
  model: { type: "string", required: true },
@@ -1331,8 +1393,14 @@ var configSchema = {
1331
1393
  system: { type: "string" },
1332
1394
  embed_model: { type: "string" }
1333
1395
  };
1396
+ var extensionManifest = {
1397
+ factory: createGeminiExtension,
1398
+ configSchema,
1399
+ version: VERSION
1400
+ };
1334
1401
  export {
1335
1402
  VERSION,
1336
1403
  configSchema,
1337
- createGeminiExtension
1404
+ createGeminiExtension,
1405
+ extensionManifest
1338
1406
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rcrsr/rill-ext-gemini",
3
- "version": "0.11.0",
3
+ "version": "0.16.0",
4
4
  "description": "rill extension for Google Gemini API integration",
5
5
  "license": "MIT",
6
6
  "author": "Andre Bremer",
@@ -17,10 +17,10 @@
17
17
  "scripting"
18
18
  ],
19
19
  "peerDependencies": {
20
- "@rcrsr/rill": "^0.11.0"
20
+ "@rcrsr/rill": "~0.16.0"
21
21
  },
22
22
  "devDependencies": {
23
- "@rcrsr/rill": "^0.11.0",
23
+ "@rcrsr/rill": "~0.16.0",
24
24
  "@types/node": "^25.3.0",
25
25
  "dts-bundle-generator": "^9.5.1",
26
26
  "tsup": "^8.5.1",