@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/extract.js ADDED
@@ -0,0 +1,48 @@
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 extract_exports = {};
20
+ __export(extract_exports, {
21
+ extractJson: () => import_extract.extractJson,
22
+ parsePartialJson: () => import_extract.parsePartialJson
23
+ });
24
+ module.exports = __toCommonJS(extract_exports);
25
+ var import_extract = require("@genkit-ai/ai/extract");
26
+ /**
27
+ * @license
28
+ *
29
+ * Copyright 2024 Google LLC
30
+ *
31
+ * Licensed under the Apache License, Version 2.0 (the "License");
32
+ * you may not use this file except in compliance with the License.
33
+ * You may obtain a copy of the License at
34
+ *
35
+ * http://www.apache.org/licenses/LICENSE-2.0
36
+ *
37
+ * Unless required by applicable law or agreed to in writing, software
38
+ * distributed under the License is distributed on an "AS IS" BASIS,
39
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
40
+ * See the License for the specific language governing permissions and
41
+ * limitations under the License.
42
+ */
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
45
+ extractJson,
46
+ parsePartialJson
47
+ });
48
+ //# sourceMappingURL=extract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/extract.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 * Extraction utilities — helpers for extracting structured JSON from model\n * output, including partial JSON parsing for streaming.\n *\n * ```ts\n * import { extractJson, parsePartialJson } from 'genkit/extract';\n * ```\n *\n * @module extract\n */\n\nexport { extractJson, parsePartialJson } from '@genkit-ai/ai/extract';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6BA,qBAA8C;AA7B9C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;","names":[]}
@@ -0,0 +1,23 @@
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 { extractJson, parsePartialJson } from "@genkit-ai/ai/extract";
19
+ export {
20
+ extractJson,
21
+ parsePartialJson
22
+ };
23
+ //# sourceMappingURL=extract.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/extract.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 * Extraction utilities — helpers for extracting structured JSON from model\n * output, including partial JSON parsing for streaming.\n *\n * ```ts\n * import { extractJson, parsePartialJson } from 'genkit/extract';\n * ```\n *\n * @module extract\n */\n\nexport { extractJson, parsePartialJson } from '@genkit-ai/ai/extract';\n"],"mappings":"AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6BA,SAAS,aAAa,wBAAwB;","names":[]}
@@ -0,0 +1 @@
1
+ export { FormatArgument, Formatter } from '@genkit-ai/ai/formats';
@@ -0,0 +1 @@
1
+ export { FormatArgument, Formatter } from '@genkit-ai/ai/formats';
package/lib/formats.js ADDED
@@ -0,0 +1,34 @@
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 __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var formats_exports = {};
16
+ module.exports = __toCommonJS(formats_exports);
17
+ /**
18
+ * @license
19
+ *
20
+ * Copyright 2024 Google LLC
21
+ *
22
+ * Licensed under the Apache License, Version 2.0 (the "License");
23
+ * you may not use this file except in compliance with the License.
24
+ * You may obtain a copy of the License at
25
+ *
26
+ * http://www.apache.org/licenses/LICENSE-2.0
27
+ *
28
+ * Unless required by applicable law or agreed to in writing, software
29
+ * distributed under the License is distributed on an "AS IS" BASIS,
30
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31
+ * See the License for the specific language governing permissions and
32
+ * limitations under the License.
33
+ */
34
+ //# sourceMappingURL=formats.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/formats.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 * Output format types — `Formatter` and `FormatArgument` interfaces used when\n * defining custom output formats for model generation.\n *\n * ```ts\n * import type { Formatter, FormatArgument } from 'genkit/formats';\n * ```\n *\n * @module formats\n */\n\nexport type { FormatArgument, Formatter } from '@genkit-ai/ai/formats';\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;","names":[]}
@@ -0,0 +1,18 @@
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
+ //# sourceMappingURL=formats.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/formats.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 * Output format types — `Formatter` and `FormatArgument` interfaces used when\n * defining custom output formats for model generation.\n *\n * ```ts\n * import type { Formatter, FormatArgument } from 'genkit/formats';\n * ```\n *\n * @module formats\n */\n\nexport type { FormatArgument, Formatter } from '@genkit-ai/ai/formats';\n"],"mappings":"AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;","names":[]}
@@ -0,0 +1,183 @@
1
+ import { AgentFn, Agent, AgentConfig, InterruptConfig, ToolAction, GenerationCommonConfigSchema, GenerateOptions, GenerateResponseData, ResourceOptions, ResourceFn, ResourceAction } from '@genkit-ai/ai';
2
+ export { Agent, AgentFn, AgentStreamChunk, ClientTransform, PromptConfig, SessionRunner } from '@genkit-ai/ai';
3
+ import { SessionStore } from '@genkit-ai/ai/session';
4
+ export { SessionSnapshot, SessionSnapshotInput, SessionState, SessionStore, SessionStoreOptions, SnapshotMutator } from '@genkit-ai/ai/session';
5
+ export { FileSessionStore, InMemorySessionStore } from '@genkit-ai/ai/session-stores';
6
+ export { JsonPatch, JsonPatchOperation, applyPatch, diff } from '@genkit-ai/ai/json-patch';
7
+ import { z, Operation } from '@genkit-ai/core';
8
+ import { Formatter } from '@genkit-ai/ai/formats';
9
+ import { a as Genkit, G as GenkitOptions } from './index-BSkuxdwl.mjs';
10
+ import '@genkit-ai/ai/tool';
11
+ import '@genkit-ai/ai/embedder';
12
+ import '@genkit-ai/ai/evaluator';
13
+ import '@genkit-ai/ai/model';
14
+ import '@genkit-ai/ai/reranker';
15
+ import '@genkit-ai/ai/retriever';
16
+ import '@genkit-ai/core/registry';
17
+
18
+ /**
19
+ * Copyright 2025 Google LLC
20
+ *
21
+ * Licensed under the Apache License, Version 2.0 (the "License");
22
+ * you may not use this file except in compliance with the License.
23
+ * You may obtain a copy of the License at
24
+ *
25
+ * http://www.apache.org/licenses/LICENSE-2.0
26
+ *
27
+ * Unless required by applicable law or agreed to in writing, software
28
+ * distributed under the License is distributed on an "AS IS" BASIS,
29
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30
+ * See the License for the specific language governing permissions and
31
+ * limitations under the License.
32
+ */
33
+
34
+ /**
35
+ * WARNING: these APIs are considered unstable and subject to frequent breaking changes that may not honor semver.
36
+ *
37
+ * Initializes Genkit BETA APIs with a set of options.
38
+ *
39
+ * This will create a new Genkit registry, register the provided plugins, stores, and other configuration. This
40
+ * should be called before any flows are registered.
41
+ *
42
+ * @beta
43
+ */
44
+ declare function genkit(options: GenkitOptions): GenkitBeta;
45
+ /**
46
+ * Genkit BETA APIs.
47
+ *
48
+ * @beta
49
+ */
50
+ declare class GenkitBeta extends Genkit {
51
+ constructor(options?: GenkitOptions);
52
+ /**
53
+ * Defines and registers a custom agent with a custom handler function.
54
+ *
55
+ * @beta
56
+ */
57
+ defineCustomAgent<State = unknown>(config: {
58
+ name: string;
59
+ description?: string;
60
+ stateSchema?: z.ZodType<State>;
61
+ store?: SessionStore<State>;
62
+ }, fn: AgentFn<State>): Agent<State>;
63
+ /**
64
+ * Defines and registers an agent from an existing Prompt template.
65
+ *
66
+ * @beta
67
+ */
68
+ definePromptAgent<State = unknown, I extends z.ZodTypeAny = z.ZodTypeAny>(config: {
69
+ promptName: string;
70
+ /**
71
+ * Input values for the referenced prompt's input variables. Lets a single
72
+ * prompt be reused/customized across multiple agents.
73
+ */
74
+ promptInput?: z.infer<I>;
75
+ stateSchema?: z.ZodType<State>;
76
+ store?: SessionStore<State>;
77
+ }): Agent<State>;
78
+ /**
79
+ * Defines and registers an agent by creating a prompt and wiring it into a
80
+ * multi-turn agent in one step.
81
+ *
82
+ * This is a convenience shortcut that combines `definePrompt` and
83
+ * `definePromptAgent` into a single call.
84
+ *
85
+ * ```ts
86
+ * const myAgent = ai.defineAgent({
87
+ * name: 'myAgent',
88
+ * model: 'googleai/gemini-2.5-flash',
89
+ * system: 'Talk like a pirate.',
90
+ * tools: [weatherTool],
91
+ * store: new FileSessionStore('./.snapshots'),
92
+ * });
93
+ * ```
94
+ *
95
+ * @beta
96
+ */
97
+ defineAgent<State = unknown, I extends z.ZodTypeAny = z.ZodTypeAny>(config: AgentConfig<State, I>): Agent<State>;
98
+ /**
99
+ * Defines and registers a custom model output formatter.
100
+ *
101
+ * Here's an example of a custom JSON output formatter:
102
+ *
103
+ * ```ts
104
+ * import { extractJson } from 'genkit/extract';
105
+ *
106
+ * ai.defineFormat(
107
+ * { name: 'customJson' },
108
+ * (schema) => {
109
+ * let instructions: string | undefined;
110
+ * if (schema) {
111
+ * instructions = `Output should be in JSON format and conform to the following schema:
112
+ * \`\`\`
113
+ * ${JSON.stringify(schema)}
114
+ * \`\`\`
115
+ * `;
116
+ * }
117
+ * return {
118
+ * parseChunk: (chunk) => extractJson(chunk.accumulatedText),
119
+ * parseMessage: (message) => extractJson(message.text),
120
+ * instructions,
121
+ * };
122
+ * }
123
+ * );
124
+ *
125
+ * const { output } = await ai.generate({
126
+ * prompt: 'Invent a menu item for a pirate themed restaurant.',
127
+ * output: { format: 'customJson', schema: MenuItemSchema },
128
+ * });
129
+ * ```
130
+ *
131
+ * @beta
132
+ */
133
+ defineFormat(options: {
134
+ name: string;
135
+ } & Formatter['config'], handler: Formatter['handler']): {
136
+ config: Formatter['config'];
137
+ handler: Formatter['handler'];
138
+ };
139
+ /**
140
+ * Defines and registers an interrupt.
141
+ *
142
+ * Interrupts are special tools that halt model processing and return control back to the caller. Interrupts make it simpler to implement
143
+ * "human-in-the-loop" and out-of-band processing patterns that require waiting on external actions to complete.
144
+ *
145
+ * @beta
146
+ */
147
+ defineInterrupt<I extends z.ZodTypeAny, O extends z.ZodTypeAny>(config: InterruptConfig<I, O>): ToolAction<I, O>;
148
+ /**
149
+ * Starts a generate operation for long running generation models, typically for
150
+ * video and complex audio generation.
151
+ *
152
+ * See {@link GenerateOptions} for detailed information about available options.
153
+ *
154
+ * ```ts
155
+ * const operation = await ai.generateOperation({
156
+ * model: googleAI.model('veo-3.1-generate-preview'),
157
+ * prompt: 'A banana riding a bicycle.',
158
+ * });
159
+ * ```
160
+ *
161
+ * The status of the operation and final result can be obtained using {@link Genkit.checkOperation}.
162
+ */
163
+ generateOperation<O extends z.ZodTypeAny = z.ZodTypeAny, CustomOptions extends z.ZodTypeAny = typeof GenerationCommonConfigSchema>(opts: GenerateOptions<O, CustomOptions> | PromiseLike<GenerateOptions<O, CustomOptions>>): Promise<Operation<GenerateResponseData>>;
164
+ /**
165
+ * Defines a resource. Resources can then be accessed from a generate call.
166
+ *
167
+ * ```ts
168
+ * ai.defineResource({
169
+ * uri: 'my://resource/{param}',
170
+ * description: 'provides my resource',
171
+ * }, async ({param}) => {
172
+ * return [{ text: `resource ${param}` }]
173
+ * });
174
+ *
175
+ * await ai.generate({
176
+ * prompt: [{ resource: 'my://resource/value' }]
177
+ * })
178
+ * ```
179
+ */
180
+ defineResource(opts: ResourceOptions, fn: ResourceFn): ResourceAction;
181
+ }
182
+
183
+ export { GenkitBeta, GenkitOptions as GenkitBetaOptions, genkit };
@@ -0,0 +1,183 @@
1
+ import { AgentFn, Agent, AgentConfig, InterruptConfig, ToolAction, GenerationCommonConfigSchema, GenerateOptions, GenerateResponseData, ResourceOptions, ResourceFn, ResourceAction } from '@genkit-ai/ai';
2
+ export { Agent, AgentFn, AgentStreamChunk, ClientTransform, PromptConfig, SessionRunner } from '@genkit-ai/ai';
3
+ import { SessionStore } from '@genkit-ai/ai/session';
4
+ export { SessionSnapshot, SessionSnapshotInput, SessionState, SessionStore, SessionStoreOptions, SnapshotMutator } from '@genkit-ai/ai/session';
5
+ export { FileSessionStore, InMemorySessionStore } from '@genkit-ai/ai/session-stores';
6
+ export { JsonPatch, JsonPatchOperation, applyPatch, diff } from '@genkit-ai/ai/json-patch';
7
+ import { z, Operation } from '@genkit-ai/core';
8
+ import { Formatter } from '@genkit-ai/ai/formats';
9
+ import { a as Genkit, G as GenkitOptions } from './index-BSkuxdwl.js';
10
+ import '@genkit-ai/ai/tool';
11
+ import '@genkit-ai/ai/embedder';
12
+ import '@genkit-ai/ai/evaluator';
13
+ import '@genkit-ai/ai/model';
14
+ import '@genkit-ai/ai/reranker';
15
+ import '@genkit-ai/ai/retriever';
16
+ import '@genkit-ai/core/registry';
17
+
18
+ /**
19
+ * Copyright 2025 Google LLC
20
+ *
21
+ * Licensed under the Apache License, Version 2.0 (the "License");
22
+ * you may not use this file except in compliance with the License.
23
+ * You may obtain a copy of the License at
24
+ *
25
+ * http://www.apache.org/licenses/LICENSE-2.0
26
+ *
27
+ * Unless required by applicable law or agreed to in writing, software
28
+ * distributed under the License is distributed on an "AS IS" BASIS,
29
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30
+ * See the License for the specific language governing permissions and
31
+ * limitations under the License.
32
+ */
33
+
34
+ /**
35
+ * WARNING: these APIs are considered unstable and subject to frequent breaking changes that may not honor semver.
36
+ *
37
+ * Initializes Genkit BETA APIs with a set of options.
38
+ *
39
+ * This will create a new Genkit registry, register the provided plugins, stores, and other configuration. This
40
+ * should be called before any flows are registered.
41
+ *
42
+ * @beta
43
+ */
44
+ declare function genkit(options: GenkitOptions): GenkitBeta;
45
+ /**
46
+ * Genkit BETA APIs.
47
+ *
48
+ * @beta
49
+ */
50
+ declare class GenkitBeta extends Genkit {
51
+ constructor(options?: GenkitOptions);
52
+ /**
53
+ * Defines and registers a custom agent with a custom handler function.
54
+ *
55
+ * @beta
56
+ */
57
+ defineCustomAgent<State = unknown>(config: {
58
+ name: string;
59
+ description?: string;
60
+ stateSchema?: z.ZodType<State>;
61
+ store?: SessionStore<State>;
62
+ }, fn: AgentFn<State>): Agent<State>;
63
+ /**
64
+ * Defines and registers an agent from an existing Prompt template.
65
+ *
66
+ * @beta
67
+ */
68
+ definePromptAgent<State = unknown, I extends z.ZodTypeAny = z.ZodTypeAny>(config: {
69
+ promptName: string;
70
+ /**
71
+ * Input values for the referenced prompt's input variables. Lets a single
72
+ * prompt be reused/customized across multiple agents.
73
+ */
74
+ promptInput?: z.infer<I>;
75
+ stateSchema?: z.ZodType<State>;
76
+ store?: SessionStore<State>;
77
+ }): Agent<State>;
78
+ /**
79
+ * Defines and registers an agent by creating a prompt and wiring it into a
80
+ * multi-turn agent in one step.
81
+ *
82
+ * This is a convenience shortcut that combines `definePrompt` and
83
+ * `definePromptAgent` into a single call.
84
+ *
85
+ * ```ts
86
+ * const myAgent = ai.defineAgent({
87
+ * name: 'myAgent',
88
+ * model: 'googleai/gemini-2.5-flash',
89
+ * system: 'Talk like a pirate.',
90
+ * tools: [weatherTool],
91
+ * store: new FileSessionStore('./.snapshots'),
92
+ * });
93
+ * ```
94
+ *
95
+ * @beta
96
+ */
97
+ defineAgent<State = unknown, I extends z.ZodTypeAny = z.ZodTypeAny>(config: AgentConfig<State, I>): Agent<State>;
98
+ /**
99
+ * Defines and registers a custom model output formatter.
100
+ *
101
+ * Here's an example of a custom JSON output formatter:
102
+ *
103
+ * ```ts
104
+ * import { extractJson } from 'genkit/extract';
105
+ *
106
+ * ai.defineFormat(
107
+ * { name: 'customJson' },
108
+ * (schema) => {
109
+ * let instructions: string | undefined;
110
+ * if (schema) {
111
+ * instructions = `Output should be in JSON format and conform to the following schema:
112
+ * \`\`\`
113
+ * ${JSON.stringify(schema)}
114
+ * \`\`\`
115
+ * `;
116
+ * }
117
+ * return {
118
+ * parseChunk: (chunk) => extractJson(chunk.accumulatedText),
119
+ * parseMessage: (message) => extractJson(message.text),
120
+ * instructions,
121
+ * };
122
+ * }
123
+ * );
124
+ *
125
+ * const { output } = await ai.generate({
126
+ * prompt: 'Invent a menu item for a pirate themed restaurant.',
127
+ * output: { format: 'customJson', schema: MenuItemSchema },
128
+ * });
129
+ * ```
130
+ *
131
+ * @beta
132
+ */
133
+ defineFormat(options: {
134
+ name: string;
135
+ } & Formatter['config'], handler: Formatter['handler']): {
136
+ config: Formatter['config'];
137
+ handler: Formatter['handler'];
138
+ };
139
+ /**
140
+ * Defines and registers an interrupt.
141
+ *
142
+ * Interrupts are special tools that halt model processing and return control back to the caller. Interrupts make it simpler to implement
143
+ * "human-in-the-loop" and out-of-band processing patterns that require waiting on external actions to complete.
144
+ *
145
+ * @beta
146
+ */
147
+ defineInterrupt<I extends z.ZodTypeAny, O extends z.ZodTypeAny>(config: InterruptConfig<I, O>): ToolAction<I, O>;
148
+ /**
149
+ * Starts a generate operation for long running generation models, typically for
150
+ * video and complex audio generation.
151
+ *
152
+ * See {@link GenerateOptions} for detailed information about available options.
153
+ *
154
+ * ```ts
155
+ * const operation = await ai.generateOperation({
156
+ * model: googleAI.model('veo-3.1-generate-preview'),
157
+ * prompt: 'A banana riding a bicycle.',
158
+ * });
159
+ * ```
160
+ *
161
+ * The status of the operation and final result can be obtained using {@link Genkit.checkOperation}.
162
+ */
163
+ generateOperation<O extends z.ZodTypeAny = z.ZodTypeAny, CustomOptions extends z.ZodTypeAny = typeof GenerationCommonConfigSchema>(opts: GenerateOptions<O, CustomOptions> | PromiseLike<GenerateOptions<O, CustomOptions>>): Promise<Operation<GenerateResponseData>>;
164
+ /**
165
+ * Defines a resource. Resources can then be accessed from a generate call.
166
+ *
167
+ * ```ts
168
+ * ai.defineResource({
169
+ * uri: 'my://resource/{param}',
170
+ * description: 'provides my resource',
171
+ * }, async ({param}) => {
172
+ * return [{ text: `resource ${param}` }]
173
+ * });
174
+ *
175
+ * await ai.generate({
176
+ * prompt: [{ resource: 'my://resource/value' }]
177
+ * })
178
+ * ```
179
+ */
180
+ defineResource(opts: ResourceOptions, fn: ResourceFn): ResourceAction;
181
+ }
182
+
183
+ export { GenkitBeta, GenkitOptions as GenkitBetaOptions, genkit };