@ohos-ports/genkit 1.42.0-beta.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.
Files changed (202) hide show
  1. package/LICENSE +203 -0
  2. package/README.md +434 -0
  3. package/lib/beta.d.mts +18 -0
  4. package/lib/beta.d.ts +18 -0
  5. package/lib/beta.js +88 -0
  6. package/lib/beta.js.map +1 -0
  7. package/lib/beta.mjs +64 -0
  8. package/lib/beta.mjs.map +1 -0
  9. package/lib/client/agent.d.mts +52 -0
  10. package/lib/client/agent.d.ts +52 -0
  11. package/lib/client/agent.js +90 -0
  12. package/lib/client/agent.js.map +1 -0
  13. package/lib/client/agent.mjs +68 -0
  14. package/lib/client/agent.mjs.map +1 -0
  15. package/lib/client/client.d.mts +80 -0
  16. package/lib/client/client.d.ts +80 -0
  17. package/lib/client/client.js +164 -0
  18. package/lib/client/client.js.map +1 -0
  19. package/lib/client/client.mjs +139 -0
  20. package/lib/client/client.mjs.map +1 -0
  21. package/lib/client/index.d.mts +6 -0
  22. package/lib/client/index.d.ts +6 -0
  23. package/lib/client/index.js +55 -0
  24. package/lib/client/index.js.map +1 -0
  25. package/lib/client/index.mjs +31 -0
  26. package/lib/client/index.mjs.map +1 -0
  27. package/lib/client/types.d.mts +17 -0
  28. package/lib/client/types.d.ts +17 -0
  29. package/lib/client/types.js +17 -0
  30. package/lib/client/types.js.map +1 -0
  31. package/lib/client/types.mjs +1 -0
  32. package/lib/client/types.mjs.map +1 -0
  33. package/lib/common.d.mts +3 -0
  34. package/lib/common.d.ts +3 -0
  35. package/lib/common.js +151 -0
  36. package/lib/common.js.map +1 -0
  37. package/lib/common.mjs +128 -0
  38. package/lib/common.mjs.map +1 -0
  39. package/lib/context.d.mts +1 -0
  40. package/lib/context.d.ts +1 -0
  41. package/lib/context.js +50 -0
  42. package/lib/context.js.map +1 -0
  43. package/lib/context.mjs +28 -0
  44. package/lib/context.mjs.map +1 -0
  45. package/lib/embedder.d.mts +1 -0
  46. package/lib/embedder.d.ts +1 -0
  47. package/lib/embedder.js +48 -0
  48. package/lib/embedder.js.map +1 -0
  49. package/lib/embedder.mjs +26 -0
  50. package/lib/embedder.mjs.map +1 -0
  51. package/lib/evaluator.d.mts +1 -0
  52. package/lib/evaluator.d.ts +1 -0
  53. package/lib/evaluator.js +60 -0
  54. package/lib/evaluator.js.map +1 -0
  55. package/lib/evaluator.mjs +38 -0
  56. package/lib/evaluator.mjs.map +1 -0
  57. package/lib/extract.d.mts +1 -0
  58. package/lib/extract.d.ts +1 -0
  59. package/lib/extract.js +48 -0
  60. package/lib/extract.js.map +1 -0
  61. package/lib/extract.mjs +23 -0
  62. package/lib/extract.mjs.map +1 -0
  63. package/lib/formats.d.mts +1 -0
  64. package/lib/formats.d.ts +1 -0
  65. package/lib/formats.js +34 -0
  66. package/lib/formats.js.map +1 -0
  67. package/lib/formats.mjs +18 -0
  68. package/lib/formats.mjs.map +1 -0
  69. package/lib/genkit-beta.d.mts +183 -0
  70. package/lib/genkit-beta.d.ts +183 -0
  71. package/lib/genkit-beta.js +178 -0
  72. package/lib/genkit-beta.js.map +1 -0
  73. package/lib/genkit-beta.mjs +159 -0
  74. package/lib/genkit-beta.mjs.map +1 -0
  75. package/lib/genkit.d.mts +10 -0
  76. package/lib/genkit.d.ts +10 -0
  77. package/lib/genkit.js +471 -0
  78. package/lib/genkit.js.map +1 -0
  79. package/lib/genkit.mjs +489 -0
  80. package/lib/genkit.mjs.map +1 -0
  81. package/lib/index-BSkuxdwl.d.mts +311 -0
  82. package/lib/index-BSkuxdwl.d.ts +311 -0
  83. package/lib/index.d.mts +10 -0
  84. package/lib/index.d.ts +10 -0
  85. package/lib/index.js +51 -0
  86. package/lib/index.js.map +1 -0
  87. package/lib/index.mjs +24 -0
  88. package/lib/index.mjs.map +1 -0
  89. package/lib/logging.d.mts +1 -0
  90. package/lib/logging.d.ts +1 -0
  91. package/lib/logging.js +46 -0
  92. package/lib/logging.js.map +1 -0
  93. package/lib/logging.mjs +22 -0
  94. package/lib/logging.mjs.map +1 -0
  95. package/lib/middleware.d.mts +1 -0
  96. package/lib/middleware.d.ts +1 -0
  97. package/lib/middleware.js +56 -0
  98. package/lib/middleware.js.map +1 -0
  99. package/lib/middleware.mjs +34 -0
  100. package/lib/middleware.mjs.map +1 -0
  101. package/lib/model.d.mts +1 -0
  102. package/lib/model.d.ts +1 -0
  103. package/lib/model.js +92 -0
  104. package/lib/model.js.map +1 -0
  105. package/lib/model.mjs +70 -0
  106. package/lib/model.mjs.map +1 -0
  107. package/lib/plugin.d.mts +10 -0
  108. package/lib/plugin.d.ts +10 -0
  109. package/lib/plugin.js +143 -0
  110. package/lib/plugin.js.map +1 -0
  111. package/lib/plugin.mjs +113 -0
  112. package/lib/plugin.mjs.map +1 -0
  113. package/lib/registry.d.mts +1 -0
  114. package/lib/registry.d.ts +1 -0
  115. package/lib/registry.js +46 -0
  116. package/lib/registry.js.map +1 -0
  117. package/lib/registry.mjs +24 -0
  118. package/lib/registry.mjs.map +1 -0
  119. package/lib/reranker.d.mts +1 -0
  120. package/lib/reranker.d.ts +1 -0
  121. package/lib/reranker.js +54 -0
  122. package/lib/reranker.js.map +1 -0
  123. package/lib/reranker.mjs +32 -0
  124. package/lib/reranker.mjs.map +1 -0
  125. package/lib/retriever.d.mts +1 -0
  126. package/lib/retriever.d.ts +1 -0
  127. package/lib/retriever.js +58 -0
  128. package/lib/retriever.js.map +1 -0
  129. package/lib/retriever.mjs +36 -0
  130. package/lib/retriever.mjs.map +1 -0
  131. package/lib/schema.d.mts +1 -0
  132. package/lib/schema.d.ts +1 -0
  133. package/lib/schema.js +54 -0
  134. package/lib/schema.js.map +1 -0
  135. package/lib/schema.mjs +32 -0
  136. package/lib/schema.mjs.map +1 -0
  137. package/lib/testing.d.mts +1 -0
  138. package/lib/testing.d.ts +1 -0
  139. package/lib/testing.js +50 -0
  140. package/lib/testing.js.map +1 -0
  141. package/lib/testing.mjs +28 -0
  142. package/lib/testing.mjs.map +1 -0
  143. package/lib/tool.d.mts +1 -0
  144. package/lib/tool.d.ts +1 -0
  145. package/lib/tool.js +54 -0
  146. package/lib/tool.js.map +1 -0
  147. package/lib/tool.mjs +32 -0
  148. package/lib/tool.mjs.map +1 -0
  149. package/lib/tracing.d.mts +1 -0
  150. package/lib/tracing.d.ts +1 -0
  151. package/lib/tracing.js +82 -0
  152. package/lib/tracing.js.map +1 -0
  153. package/lib/tracing.mjs +60 -0
  154. package/lib/tracing.mjs.map +1 -0
  155. package/package.json +233 -0
  156. package/src/beta.ts +85 -0
  157. package/src/client/agent.ts +160 -0
  158. package/src/client/client.ts +237 -0
  159. package/src/client/index.ts +72 -0
  160. package/src/client/types.ts +41 -0
  161. package/src/common.ts +175 -0
  162. package/src/context.ts +37 -0
  163. package/src/embedder.ts +41 -0
  164. package/src/evaluator.ts +50 -0
  165. package/src/extract.ts +30 -0
  166. package/src/formats.ts +30 -0
  167. package/src/genkit-beta.ts +275 -0
  168. package/src/genkit.ts +818 -0
  169. package/src/index.ts +29 -0
  170. package/src/logging.ts +30 -0
  171. package/src/middleware.ts +38 -0
  172. package/src/model.ts +87 -0
  173. package/src/plugin.ts +172 -0
  174. package/src/registry.ts +36 -0
  175. package/src/reranker.ts +42 -0
  176. package/src/retriever.ts +55 -0
  177. package/src/schema.ts +40 -0
  178. package/src/testing.ts +47 -0
  179. package/src/tool.ts +40 -0
  180. package/src/tracing.ts +55 -0
  181. package/tests/agent_client_test.ts +497 -0
  182. package/tests/embed_test.ts +142 -0
  183. package/tests/evaluate_test.ts +52 -0
  184. package/tests/flow_test.ts +94 -0
  185. package/tests/formats_test.ts +168 -0
  186. package/tests/generate_test.ts +1631 -0
  187. package/tests/genkit_test.ts +33 -0
  188. package/tests/helpers.ts +176 -0
  189. package/tests/mock-model_test.ts +490 -0
  190. package/tests/plugins_test.ts +259 -0
  191. package/tests/prompts/badSchemaRef.prompt +9 -0
  192. package/tests/prompts/chat_preamble.prompt +5 -0
  193. package/tests/prompts/kitchensink.prompt +25 -0
  194. package/tests/prompts/output.prompt +11 -0
  195. package/tests/prompts/schemaRef.prompt +9 -0
  196. package/tests/prompts/sub/test.prompt +5 -0
  197. package/tests/prompts/test.prompt +5 -0
  198. package/tests/prompts/test.variant.prompt +8 -0
  199. package/tests/prompts/toolPrompt.prompt +6 -0
  200. package/tests/prompts_test.ts +1442 -0
  201. package/tests/session_test.ts +17 -0
  202. package/typedoc.json +22 -0
package/lib/index.js ADDED
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var index_exports = {};
21
+ __export(index_exports, {
22
+ Genkit: () => import_genkit.Genkit,
23
+ genkit: () => import_genkit.genkit
24
+ });
25
+ module.exports = __toCommonJS(index_exports);
26
+ __reExport(index_exports, require("./common.js"), module.exports);
27
+ var import_genkit = require("./genkit.js");
28
+ /**
29
+ * @license
30
+ *
31
+ * Copyright 2025 Google LLC
32
+ *
33
+ * Licensed under the Apache License, Version 2.0 (the "License");
34
+ * you may not use this file except in compliance with the License.
35
+ * You may obtain a copy of the License at
36
+ *
37
+ * http://www.apache.org/licenses/LICENSE-2.0
38
+ *
39
+ * Unless required by applicable law or agreed to in writing, software
40
+ * distributed under the License is distributed on an "AS IS" BASIS,
41
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
42
+ * See the License for the specific language governing permissions and
43
+ * limitations under the License.
44
+ */
45
+ // Annotate the CommonJS export names for ESM import in node:
46
+ 0 && (module.exports = {
47
+ Genkit,
48
+ genkit,
49
+ ...require("./common.js")
50
+ });
51
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Main genkit import.\n *\n * ```ts\n * import { genkit } from 'genkit';\n * ```\n *\n * @module /\n */\nexport * from './common.js';\nexport { Genkit, genkit, type GenkitOptions } from './genkit.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA2BA,0BAAc,wBA3Bd;AA4BA,oBAAmD;AA5BnD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;","names":[]}
package/lib/index.mjs ADDED
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @license
3
+ *
4
+ * Copyright 2025 Google LLC
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ export * from "./common.mjs";
19
+ import { Genkit, genkit } from "./genkit.mjs";
20
+ export {
21
+ Genkit,
22
+ genkit
23
+ };
24
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Main genkit import.\n *\n * ```ts\n * import { genkit } from 'genkit';\n * ```\n *\n * @module /\n */\nexport * from './common.mjs';\nexport { Genkit, genkit, type GenkitOptions } from './genkit.mjs';\n"],"mappings":"AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA2BA,cAAc;AACd,SAAS,QAAQ,cAAkC;","names":[]}
@@ -0,0 +1 @@
1
+ export { logger } from '@genkit-ai/core/logging';
@@ -0,0 +1 @@
1
+ export { logger } from '@genkit-ai/core/logging';
package/lib/logging.js ADDED
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var logging_exports = {};
20
+ __export(logging_exports, {
21
+ logger: () => import_logging.logger
22
+ });
23
+ module.exports = __toCommonJS(logging_exports);
24
+ var import_logging = require("@genkit-ai/core/logging");
25
+ /**
26
+ * @license
27
+ *
28
+ * Copyright 2024 Google LLC
29
+ *
30
+ * Licensed under the Apache License, Version 2.0 (the "License");
31
+ * you may not use this file except in compliance with the License.
32
+ * You may obtain a copy of the License at
33
+ *
34
+ * http://www.apache.org/licenses/LICENSE-2.0
35
+ *
36
+ * Unless required by applicable law or agreed to in writing, software
37
+ * distributed under the License is distributed on an "AS IS" BASIS,
38
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
39
+ * See the License for the specific language governing permissions and
40
+ * limitations under the License.
41
+ */
42
+ // Annotate the CommonJS export names for ESM import in node:
43
+ 0 && (module.exports = {
44
+ logger
45
+ });
46
+ //# sourceMappingURL=logging.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/logging.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Logging utilities — the Genkit {@link logger} singleton for structured log\n * output.\n *\n * ```ts\n * import { logger } from 'genkit/logging';\n * ```\n *\n * @module logging\n */\n\nexport { logger } from '@genkit-ai/core/logging';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA6BA,qBAAuB;AA7BvB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;","names":[]}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @license
3
+ *
4
+ * Copyright 2024 Google LLC
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ import { logger } from "@genkit-ai/core/logging";
19
+ export {
20
+ logger
21
+ };
22
+ //# sourceMappingURL=logging.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/logging.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Logging utilities — the Genkit {@link logger} singleton for structured log\n * output.\n *\n * ```ts\n * import { logger } from 'genkit/logging';\n * ```\n *\n * @module logging\n */\n\nexport { logger } from '@genkit-ai/core/logging';\n"],"mappings":"AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6BA,SAAS,cAAc;","names":[]}
@@ -0,0 +1 @@
1
+ export { AugmentWithContextOptions, augmentWithContext, downloadRequestMedia, fallback, retry, simulateSystemPrompt, validateSupport } from '@genkit-ai/ai/model/middleware';
@@ -0,0 +1 @@
1
+ export { AugmentWithContextOptions, augmentWithContext, downloadRequestMedia, fallback, retry, simulateSystemPrompt, validateSupport } from '@genkit-ai/ai/model/middleware';
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var middleware_exports = {};
20
+ __export(middleware_exports, {
21
+ augmentWithContext: () => import_middleware.augmentWithContext,
22
+ downloadRequestMedia: () => import_middleware.downloadRequestMedia,
23
+ fallback: () => import_middleware.fallback,
24
+ retry: () => import_middleware.retry,
25
+ simulateSystemPrompt: () => import_middleware.simulateSystemPrompt,
26
+ validateSupport: () => import_middleware.validateSupport
27
+ });
28
+ module.exports = __toCommonJS(middleware_exports);
29
+ var import_middleware = require("@genkit-ai/ai/model/middleware");
30
+ /**
31
+ * @license
32
+ *
33
+ * Copyright 2024 Google LLC
34
+ *
35
+ * Licensed under the Apache License, Version 2.0 (the "License");
36
+ * you may not use this file except in compliance with the License.
37
+ * You may obtain a copy of the License at
38
+ *
39
+ * http://www.apache.org/licenses/LICENSE-2.0
40
+ *
41
+ * Unless required by applicable law or agreed to in writing, software
42
+ * distributed under the License is distributed on an "AS IS" BASIS,
43
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
44
+ * See the License for the specific language governing permissions and
45
+ * limitations under the License.
46
+ */
47
+ // Annotate the CommonJS export names for ESM import in node:
48
+ 0 && (module.exports = {
49
+ augmentWithContext,
50
+ downloadRequestMedia,
51
+ fallback,
52
+ retry,
53
+ simulateSystemPrompt,
54
+ validateSupport
55
+ });
56
+ //# sourceMappingURL=middleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/middleware.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Built-in model middleware — `retry`, `fallback`, `augmentWithContext`,\n * `validateSupport`, and other middleware for enhancing model requests.\n *\n * ```ts\n * import { retry, fallback } from 'genkit/model/middleware';\n * ```\n *\n * @module model/middleware\n */\n\nexport {\n augmentWithContext,\n downloadRequestMedia,\n fallback,\n retry,\n simulateSystemPrompt,\n validateSupport,\n type AugmentWithContextOptions,\n} from '@genkit-ai/ai/model/middleware';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6BA,wBAQO;AArCP;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;","names":[]}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @license
3
+ *
4
+ * Copyright 2024 Google LLC
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ import {
19
+ augmentWithContext,
20
+ downloadRequestMedia,
21
+ fallback,
22
+ retry,
23
+ simulateSystemPrompt,
24
+ validateSupport
25
+ } from "@genkit-ai/ai/model/middleware";
26
+ export {
27
+ augmentWithContext,
28
+ downloadRequestMedia,
29
+ fallback,
30
+ retry,
31
+ simulateSystemPrompt,
32
+ validateSupport
33
+ };
34
+ //# sourceMappingURL=middleware.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/middleware.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Built-in model middleware — `retry`, `fallback`, `augmentWithContext`,\n * `validateSupport`, and other middleware for enhancing model requests.\n *\n * ```ts\n * import { retry, fallback } from 'genkit/model/middleware';\n * ```\n *\n * @module model/middleware\n */\n\nexport {\n augmentWithContext,\n downloadRequestMedia,\n fallback,\n retry,\n simulateSystemPrompt,\n validateSupport,\n type AugmentWithContextOptions,\n} from '@genkit-ai/ai/model/middleware';\n"],"mappings":"AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6BA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;","names":[]}
@@ -0,0 +1 @@
1
+ export { BackgroundModelAction, CandidateData, CandidateError, CandidateErrorSchema, CandidateSchema, CustomPart, CustomPartSchema, DataPart, DataPartSchema, DefineBackgroundModelOptions, DefineModelOptions, GenerateRequest, GenerateRequestData, GenerateRequestSchema, GenerateResponseChunkData, GenerateResponseChunkSchema, GenerateResponseData, GenerateResponseSchema, GenerationCommonConfig, GenerationCommonConfigDescriptions, GenerationCommonConfigSchema, GenerationUsage, GenerationUsageSchema, MediaPart, MediaPartSchema, MessageData, MessageSchema, ModelAction, ModelArgument, ModelInfo, ModelInfoSchema, ModelMiddleware, ModelMiddlewareArgument, ModelMiddlewareWithOptions, ModelReference, ModelRequest, ModelRequestSchema, ModelResponseChunkData, ModelResponseData, ModelResponseSchema, OutputConfig, Part, PartSchema, Role, RoleSchema, TextPart, TextPartSchema, ToolDefinition, ToolDefinitionSchema, ToolRequestPart, ToolRequestPartSchema, ToolResponsePart, ToolResponsePartSchema, getBasicUsageStats, modelRef, simulateConstrainedGeneration } from '@genkit-ai/ai/model';
package/lib/model.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { BackgroundModelAction, CandidateData, CandidateError, CandidateErrorSchema, CandidateSchema, CustomPart, CustomPartSchema, DataPart, DataPartSchema, DefineBackgroundModelOptions, DefineModelOptions, GenerateRequest, GenerateRequestData, GenerateRequestSchema, GenerateResponseChunkData, GenerateResponseChunkSchema, GenerateResponseData, GenerateResponseSchema, GenerationCommonConfig, GenerationCommonConfigDescriptions, GenerationCommonConfigSchema, GenerationUsage, GenerationUsageSchema, MediaPart, MediaPartSchema, MessageData, MessageSchema, ModelAction, ModelArgument, ModelInfo, ModelInfoSchema, ModelMiddleware, ModelMiddlewareArgument, ModelMiddlewareWithOptions, ModelReference, ModelRequest, ModelRequestSchema, ModelResponseChunkData, ModelResponseData, ModelResponseSchema, OutputConfig, Part, PartSchema, Role, RoleSchema, TextPart, TextPartSchema, ToolDefinition, ToolDefinitionSchema, ToolRequestPart, ToolRequestPartSchema, ToolResponsePart, ToolResponsePartSchema, getBasicUsageStats, modelRef, simulateConstrainedGeneration } from '@genkit-ai/ai/model';
package/lib/model.js ADDED
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var model_exports = {};
20
+ __export(model_exports, {
21
+ CandidateErrorSchema: () => import_model.CandidateErrorSchema,
22
+ CandidateSchema: () => import_model.CandidateSchema,
23
+ CustomPartSchema: () => import_model.CustomPartSchema,
24
+ DataPartSchema: () => import_model.DataPartSchema,
25
+ GenerateRequestSchema: () => import_model.GenerateRequestSchema,
26
+ GenerateResponseChunkSchema: () => import_model.GenerateResponseChunkSchema,
27
+ GenerateResponseSchema: () => import_model.GenerateResponseSchema,
28
+ GenerationCommonConfigDescriptions: () => import_model.GenerationCommonConfigDescriptions,
29
+ GenerationCommonConfigSchema: () => import_model.GenerationCommonConfigSchema,
30
+ GenerationUsageSchema: () => import_model.GenerationUsageSchema,
31
+ MediaPartSchema: () => import_model.MediaPartSchema,
32
+ MessageSchema: () => import_model.MessageSchema,
33
+ ModelInfoSchema: () => import_model.ModelInfoSchema,
34
+ ModelRequestSchema: () => import_model.ModelRequestSchema,
35
+ ModelResponseSchema: () => import_model.ModelResponseSchema,
36
+ PartSchema: () => import_model.PartSchema,
37
+ RoleSchema: () => import_model.RoleSchema,
38
+ TextPartSchema: () => import_model.TextPartSchema,
39
+ ToolDefinitionSchema: () => import_model.ToolDefinitionSchema,
40
+ ToolRequestPartSchema: () => import_model.ToolRequestPartSchema,
41
+ ToolResponsePartSchema: () => import_model.ToolResponsePartSchema,
42
+ getBasicUsageStats: () => import_model.getBasicUsageStats,
43
+ modelRef: () => import_model.modelRef,
44
+ simulateConstrainedGeneration: () => import_model.simulateConstrainedGeneration
45
+ });
46
+ module.exports = __toCommonJS(model_exports);
47
+ var import_model = require("@genkit-ai/ai/model");
48
+ /**
49
+ * @license
50
+ *
51
+ * Copyright 2024 Google LLC
52
+ *
53
+ * Licensed under the Apache License, Version 2.0 (the "License");
54
+ * you may not use this file except in compliance with the License.
55
+ * You may obtain a copy of the License at
56
+ *
57
+ * http://www.apache.org/licenses/LICENSE-2.0
58
+ *
59
+ * Unless required by applicable law or agreed to in writing, software
60
+ * distributed under the License is distributed on an "AS IS" BASIS,
61
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
62
+ * See the License for the specific language governing permissions and
63
+ * limitations under the License.
64
+ */
65
+ // Annotate the CommonJS export names for ESM import in node:
66
+ 0 && (module.exports = {
67
+ CandidateErrorSchema,
68
+ CandidateSchema,
69
+ CustomPartSchema,
70
+ DataPartSchema,
71
+ GenerateRequestSchema,
72
+ GenerateResponseChunkSchema,
73
+ GenerateResponseSchema,
74
+ GenerationCommonConfigDescriptions,
75
+ GenerationCommonConfigSchema,
76
+ GenerationUsageSchema,
77
+ MediaPartSchema,
78
+ MessageSchema,
79
+ ModelInfoSchema,
80
+ ModelRequestSchema,
81
+ ModelResponseSchema,
82
+ PartSchema,
83
+ RoleSchema,
84
+ TextPartSchema,
85
+ ToolDefinitionSchema,
86
+ ToolRequestPartSchema,
87
+ ToolResponsePartSchema,
88
+ getBasicUsageStats,
89
+ modelRef,
90
+ simulateConstrainedGeneration
91
+ });
92
+ //# sourceMappingURL=model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/model.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Model types and helpers — request/response schemas, message and part types,\n * model references, and middleware interfaces for building model plugins.\n *\n * ```ts\n * import { modelRef, type ModelAction, type MessageData } from 'genkit/model';\n * ```\n *\n * @module model\n */\n\nexport {\n CandidateErrorSchema,\n CandidateSchema,\n CustomPartSchema,\n DataPartSchema,\n GenerateRequestSchema,\n GenerateResponseChunkSchema,\n GenerateResponseSchema,\n GenerationCommonConfigDescriptions,\n GenerationCommonConfigSchema,\n GenerationUsageSchema,\n MediaPartSchema,\n MessageSchema,\n ModelInfoSchema,\n ModelRequestSchema,\n ModelResponseSchema,\n PartSchema,\n RoleSchema,\n TextPartSchema,\n ToolDefinitionSchema,\n ToolRequestPartSchema,\n ToolResponsePartSchema,\n getBasicUsageStats,\n modelRef,\n simulateConstrainedGeneration,\n type BackgroundModelAction,\n type CandidateData,\n type CandidateError,\n type CustomPart,\n type DataPart,\n type DefineBackgroundModelOptions,\n type DefineModelOptions,\n type GenerateRequest,\n type GenerateRequestData,\n type GenerateResponseChunkData,\n type GenerateResponseData,\n type GenerationCommonConfig,\n type GenerationUsage,\n type MediaPart,\n type MessageData,\n type ModelAction,\n type ModelArgument,\n type ModelInfo,\n type ModelMiddleware,\n type ModelMiddlewareArgument,\n type ModelMiddlewareWithOptions,\n type ModelReference,\n type ModelRequest,\n type ModelResponseChunkData,\n type ModelResponseData,\n type OutputConfig,\n type Part,\n type Role,\n type TextPart,\n type ToolDefinition,\n type ToolRequestPart,\n type ToolResponsePart,\n} from '@genkit-ai/ai/model';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6BA,mBAyDO;AAtFP;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;","names":[]}
package/lib/model.mjs ADDED
@@ -0,0 +1,70 @@
1
+ /**
2
+ * @license
3
+ *
4
+ * Copyright 2024 Google LLC
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ import {
19
+ CandidateErrorSchema,
20
+ CandidateSchema,
21
+ CustomPartSchema,
22
+ DataPartSchema,
23
+ GenerateRequestSchema,
24
+ GenerateResponseChunkSchema,
25
+ GenerateResponseSchema,
26
+ GenerationCommonConfigDescriptions,
27
+ GenerationCommonConfigSchema,
28
+ GenerationUsageSchema,
29
+ MediaPartSchema,
30
+ MessageSchema,
31
+ ModelInfoSchema,
32
+ ModelRequestSchema,
33
+ ModelResponseSchema,
34
+ PartSchema,
35
+ RoleSchema,
36
+ TextPartSchema,
37
+ ToolDefinitionSchema,
38
+ ToolRequestPartSchema,
39
+ ToolResponsePartSchema,
40
+ getBasicUsageStats,
41
+ modelRef,
42
+ simulateConstrainedGeneration
43
+ } from "@genkit-ai/ai/model";
44
+ export {
45
+ CandidateErrorSchema,
46
+ CandidateSchema,
47
+ CustomPartSchema,
48
+ DataPartSchema,
49
+ GenerateRequestSchema,
50
+ GenerateResponseChunkSchema,
51
+ GenerateResponseSchema,
52
+ GenerationCommonConfigDescriptions,
53
+ GenerationCommonConfigSchema,
54
+ GenerationUsageSchema,
55
+ MediaPartSchema,
56
+ MessageSchema,
57
+ ModelInfoSchema,
58
+ ModelRequestSchema,
59
+ ModelResponseSchema,
60
+ PartSchema,
61
+ RoleSchema,
62
+ TextPartSchema,
63
+ ToolDefinitionSchema,
64
+ ToolRequestPartSchema,
65
+ ToolResponsePartSchema,
66
+ getBasicUsageStats,
67
+ modelRef,
68
+ simulateConstrainedGeneration
69
+ };
70
+ //# sourceMappingURL=model.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/model.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Model types and helpers — request/response schemas, message and part types,\n * model references, and middleware interfaces for building model plugins.\n *\n * ```ts\n * import { modelRef, type ModelAction, type MessageData } from 'genkit/model';\n * ```\n *\n * @module model\n */\n\nexport {\n CandidateErrorSchema,\n CandidateSchema,\n CustomPartSchema,\n DataPartSchema,\n GenerateRequestSchema,\n GenerateResponseChunkSchema,\n GenerateResponseSchema,\n GenerationCommonConfigDescriptions,\n GenerationCommonConfigSchema,\n GenerationUsageSchema,\n MediaPartSchema,\n MessageSchema,\n ModelInfoSchema,\n ModelRequestSchema,\n ModelResponseSchema,\n PartSchema,\n RoleSchema,\n TextPartSchema,\n ToolDefinitionSchema,\n ToolRequestPartSchema,\n ToolResponsePartSchema,\n getBasicUsageStats,\n modelRef,\n simulateConstrainedGeneration,\n type BackgroundModelAction,\n type CandidateData,\n type CandidateError,\n type CustomPart,\n type DataPart,\n type DefineBackgroundModelOptions,\n type DefineModelOptions,\n type GenerateRequest,\n type GenerateRequestData,\n type GenerateResponseChunkData,\n type GenerateResponseData,\n type GenerationCommonConfig,\n type GenerationUsage,\n type MediaPart,\n type MessageData,\n type ModelAction,\n type ModelArgument,\n type ModelInfo,\n type ModelMiddleware,\n type ModelMiddlewareArgument,\n type ModelMiddlewareWithOptions,\n type ModelReference,\n type ModelRequest,\n type ModelResponseChunkData,\n type ModelResponseData,\n type OutputConfig,\n type Part,\n type Role,\n type TextPart,\n type ToolDefinition,\n type ToolRequestPart,\n type ToolResponsePart,\n} from '@genkit-ai/ai/model';\n"],"mappings":"AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6BA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAiCK;","names":[]}
@@ -0,0 +1,10 @@
1
+ export { GenerateMiddleware, GenkitPluginV2 } from '@genkit-ai/ai';
2
+ export { backgroundModel, model, modelActionMetadata } from '@genkit-ai/ai/model';
3
+ export { ResolvableAction } from '@genkit-ai/core';
4
+ export { b as GenkitPlugin, c as GenkitPluginV2Instance, P as PluginActionResolver, d as PluginInit, e as PluginProvider, g as genkitPlugin, f as genkitPluginV2, i as isPluginV2 } from './index-BSkuxdwl.mjs';
5
+ import '@genkit-ai/core/registry';
6
+ export { embedder, embedderActionMetadata } from '@genkit-ai/ai/embedder';
7
+ export { evaluator } from '@genkit-ai/ai/evaluator';
8
+ export { reranker } from '@genkit-ai/ai/reranker';
9
+ export { indexer, retriever } from '@genkit-ai/ai/retriever';
10
+ import '@genkit-ai/ai/tool';
@@ -0,0 +1,10 @@
1
+ export { GenerateMiddleware, GenkitPluginV2 } from '@genkit-ai/ai';
2
+ export { backgroundModel, model, modelActionMetadata } from '@genkit-ai/ai/model';
3
+ export { ResolvableAction } from '@genkit-ai/core';
4
+ export { b as GenkitPlugin, c as GenkitPluginV2Instance, P as PluginActionResolver, d as PluginInit, e as PluginProvider, g as genkitPlugin, f as genkitPluginV2, i as isPluginV2 } from './index-BSkuxdwl.js';
5
+ import '@genkit-ai/core/registry';
6
+ export { embedder, embedderActionMetadata } from '@genkit-ai/ai/embedder';
7
+ export { evaluator } from '@genkit-ai/ai/evaluator';
8
+ export { reranker } from '@genkit-ai/ai/reranker';
9
+ export { indexer, retriever } from '@genkit-ai/ai/retriever';
10
+ import '@genkit-ai/ai/tool';
package/lib/plugin.js ADDED
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var plugin_exports = {};
20
+ __export(plugin_exports, {
21
+ GenkitPluginV2Instance: () => GenkitPluginV2Instance,
22
+ backgroundModel: () => import_model2.backgroundModel,
23
+ embedder: () => import_embedder.embedder,
24
+ embedderActionMetadata: () => import_embedder.embedderActionMetadata,
25
+ evaluator: () => import_evaluator.evaluator,
26
+ genkitPlugin: () => genkitPlugin,
27
+ genkitPluginV2: () => genkitPluginV2,
28
+ indexer: () => import_retriever.indexer,
29
+ isPluginV2: () => isPluginV2,
30
+ model: () => import_model2.model,
31
+ modelActionMetadata: () => import_model2.modelActionMetadata,
32
+ reranker: () => import_reranker.reranker,
33
+ retriever: () => import_retriever.retriever
34
+ });
35
+ module.exports = __toCommonJS(plugin_exports);
36
+ var import_core = require("@genkit-ai/core");
37
+ var import_embedder = require("@genkit-ai/ai/embedder");
38
+ var import_evaluator = require("@genkit-ai/ai/evaluator");
39
+ var import_model2 = require("@genkit-ai/ai/model");
40
+ var import_reranker = require("@genkit-ai/ai/reranker");
41
+ var import_retriever = require("@genkit-ai/ai/retriever");
42
+ /**
43
+ * @license
44
+ *
45
+ * Copyright 2024 Google LLC
46
+ *
47
+ * Licensed under the Apache License, Version 2.0 (the "License");
48
+ * you may not use this file except in compliance with the License.
49
+ * You may obtain a copy of the License at
50
+ *
51
+ * http://www.apache.org/licenses/LICENSE-2.0
52
+ *
53
+ * Unless required by applicable law or agreed to in writing, software
54
+ * distributed under the License is distributed on an "AS IS" BASIS,
55
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
56
+ * See the License for the specific language governing permissions and
57
+ * limitations under the License.
58
+ */
59
+ function genkitPlugin(pluginName, initFn, resolveFn, listActionsFn) {
60
+ return (genkit) => ({
61
+ name: pluginName,
62
+ initializer: async () => {
63
+ await initFn(genkit);
64
+ },
65
+ resolver: async (action, target) => {
66
+ if (resolveFn) {
67
+ return await resolveFn(genkit, action, target);
68
+ }
69
+ },
70
+ listActions: async () => {
71
+ if (listActionsFn) {
72
+ return await listActionsFn();
73
+ }
74
+ return [];
75
+ }
76
+ });
77
+ }
78
+ class GenkitPluginV2Instance {
79
+ version = "v2";
80
+ name;
81
+ plugin;
82
+ constructor(plugin) {
83
+ this.name = plugin.name;
84
+ this.plugin = plugin;
85
+ }
86
+ init() {
87
+ if (!this.plugin.init) {
88
+ return [];
89
+ }
90
+ return this.plugin.init();
91
+ }
92
+ list() {
93
+ if (!this.plugin.list) {
94
+ return [];
95
+ }
96
+ return this.plugin.list();
97
+ }
98
+ middleware() {
99
+ if (!this.plugin.middleware) {
100
+ return [];
101
+ }
102
+ return this.plugin.middleware();
103
+ }
104
+ resolve(actionType, name) {
105
+ if (!this.plugin.resolve) {
106
+ return void 0;
107
+ }
108
+ return this.plugin.resolve(actionType, name);
109
+ }
110
+ async model(name) {
111
+ const model2 = await this.resolve("model", name);
112
+ if (!model2) {
113
+ throw new import_core.GenkitError({
114
+ message: `Failed to resolve model ${name} for plugin ${this.name}`,
115
+ status: "NOT_FOUND"
116
+ });
117
+ }
118
+ return model2;
119
+ }
120
+ }
121
+ function genkitPluginV2(options) {
122
+ return new GenkitPluginV2Instance(options);
123
+ }
124
+ function isPluginV2(plugin) {
125
+ return plugin.version === "v2";
126
+ }
127
+ // Annotate the CommonJS export names for ESM import in node:
128
+ 0 && (module.exports = {
129
+ GenkitPluginV2Instance,
130
+ backgroundModel,
131
+ embedder,
132
+ embedderActionMetadata,
133
+ evaluator,
134
+ genkitPlugin,
135
+ genkitPluginV2,
136
+ indexer,
137
+ isPluginV2,
138
+ model,
139
+ modelActionMetadata,
140
+ reranker,
141
+ retriever
142
+ });
143
+ //# sourceMappingURL=plugin.js.map