@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/beta.js ADDED
@@ -0,0 +1,88 @@
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 beta_exports = {};
21
+ __export(beta_exports, {
22
+ AgentError: () => import_agent.AgentError,
23
+ AgentInitSchema: () => import_ai.AgentInitSchema,
24
+ AgentInputSchema: () => import_ai.AgentInputSchema,
25
+ AgentOutputSchema: () => import_ai.AgentOutputSchema,
26
+ AgentStreamChunkSchema: () => import_ai.AgentStreamChunkSchema,
27
+ AsyncTaskQueue: () => import_async.AsyncTaskQueue,
28
+ FileSessionStore: () => import_genkit_beta.FileSessionStore,
29
+ GenkitBeta: () => import_genkit_beta.GenkitBeta,
30
+ InMemorySessionStore: () => import_genkit_beta.InMemorySessionStore,
31
+ InMemoryStreamManager: () => import_core.InMemoryStreamManager,
32
+ Session: () => import_session.Session,
33
+ SessionRunner: () => import_genkit_beta.SessionRunner,
34
+ StreamNotFoundError: () => import_core.StreamNotFoundError,
35
+ applyPatch: () => import_genkit_beta.applyPatch,
36
+ diff: () => import_genkit_beta.diff,
37
+ genkit: () => import_genkit_beta.genkit,
38
+ lazy: () => import_async.lazy,
39
+ remoteAgent: () => import_agent.remoteAgent
40
+ });
41
+ module.exports = __toCommonJS(beta_exports);
42
+ var import_ai = require("@genkit-ai/ai");
43
+ var import_session = require("@genkit-ai/ai/session");
44
+ var import_agent = require("./client/agent.js");
45
+ var import_core = require("@genkit-ai/core");
46
+ var import_async = require("@genkit-ai/core/async");
47
+ __reExport(beta_exports, require("./common.js"), module.exports);
48
+ var import_genkit_beta = require("./genkit-beta.js");
49
+ /**
50
+ * @license
51
+ *
52
+ * Copyright 2025 Google LLC
53
+ *
54
+ * Licensed under the Apache License, Version 2.0 (the "License");
55
+ * you may not use this file except in compliance with the License.
56
+ * You may obtain a copy of the License at
57
+ *
58
+ * http://www.apache.org/licenses/LICENSE-2.0
59
+ *
60
+ * Unless required by applicable law or agreed to in writing, software
61
+ * distributed under the License is distributed on an "AS IS" BASIS,
62
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
63
+ * See the License for the specific language governing permissions and
64
+ * limitations under the License.
65
+ */
66
+ // Annotate the CommonJS export names for ESM import in node:
67
+ 0 && (module.exports = {
68
+ AgentError,
69
+ AgentInitSchema,
70
+ AgentInputSchema,
71
+ AgentOutputSchema,
72
+ AgentStreamChunkSchema,
73
+ AsyncTaskQueue,
74
+ FileSessionStore,
75
+ GenkitBeta,
76
+ InMemorySessionStore,
77
+ InMemoryStreamManager,
78
+ Session,
79
+ SessionRunner,
80
+ StreamNotFoundError,
81
+ applyPatch,
82
+ diff,
83
+ genkit,
84
+ lazy,
85
+ remoteAgent,
86
+ ...require("./common.js")
87
+ });
88
+ //# sourceMappingURL=beta.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/beta.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 * Beta features including interrupts, stream managers, and the experimental\n * {@link GenkitBeta} class.\n *\n * ```ts\n * import { genkit } from 'genkit/beta';\n * ```\n *\n * @module beta\n */\n\nexport {\n AgentInitSchema,\n AgentInputSchema,\n AgentOutputSchema,\n AgentStreamChunkSchema,\n type AgentInit,\n type AgentInput,\n type AgentOutput,\n} from '@genkit-ai/ai';\nexport { Session, type Artifact } from '@genkit-ai/ai/session';\nexport {\n AgentError,\n remoteAgent,\n type AgentAPI,\n type AgentChat,\n type AgentChunk,\n type AgentInterrupt,\n type AgentResponse,\n type AgentTurn,\n type DetachedTask,\n type RemoteAgentOptions,\n} from './client/agent.js';\n\nexport type { AgentFinishReason } from './client/types.js';\n\nexport {\n InMemoryStreamManager,\n StreamNotFoundError,\n type ActionStreamInput,\n type ActionStreamSubscriber,\n type StreamManager,\n} from '@genkit-ai/core';\nexport { AsyncTaskQueue, lazy } from '@genkit-ai/core/async';\nexport * from './common.js';\nexport {\n FileSessionStore,\n GenkitBeta,\n InMemorySessionStore,\n SessionRunner,\n applyPatch,\n diff,\n genkit,\n type Agent,\n type AgentFn,\n type AgentStreamChunk,\n type ClientTransform,\n type GenkitBetaOptions,\n type JsonPatch,\n type JsonPatchOperation,\n type SessionSnapshot,\n type SessionSnapshotInput,\n type SessionState,\n type SessionStore,\n type SessionStoreOptions,\n type SnapshotMutator,\n} from './genkit-beta.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6BA,gBAQO;AACP,qBAAuC;AACvC,mBAWO;AAIP,kBAMO;AACP,mBAAqC;AACrC,yBAAc,wBA9Dd;AA+DA,yBAqBO;AApFP;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;","names":[]}
package/lib/beta.mjs ADDED
@@ -0,0 +1,64 @@
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
+ import {
19
+ AgentInitSchema,
20
+ AgentInputSchema,
21
+ AgentOutputSchema,
22
+ AgentStreamChunkSchema
23
+ } from "@genkit-ai/ai";
24
+ import { Session } from "@genkit-ai/ai/session";
25
+ import {
26
+ AgentError,
27
+ remoteAgent
28
+ } from "./client/agent.mjs";
29
+ import {
30
+ InMemoryStreamManager,
31
+ StreamNotFoundError
32
+ } from "@genkit-ai/core";
33
+ import { AsyncTaskQueue, lazy } from "@genkit-ai/core/async";
34
+ export * from "./common.mjs";
35
+ import {
36
+ FileSessionStore,
37
+ GenkitBeta,
38
+ InMemorySessionStore,
39
+ SessionRunner,
40
+ applyPatch,
41
+ diff,
42
+ genkit
43
+ } from "./genkit-beta.mjs";
44
+ export {
45
+ AgentError,
46
+ AgentInitSchema,
47
+ AgentInputSchema,
48
+ AgentOutputSchema,
49
+ AgentStreamChunkSchema,
50
+ AsyncTaskQueue,
51
+ FileSessionStore,
52
+ GenkitBeta,
53
+ InMemorySessionStore,
54
+ InMemoryStreamManager,
55
+ Session,
56
+ SessionRunner,
57
+ StreamNotFoundError,
58
+ applyPatch,
59
+ diff,
60
+ genkit,
61
+ lazy,
62
+ remoteAgent
63
+ };
64
+ //# sourceMappingURL=beta.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/beta.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 * Beta features including interrupts, stream managers, and the experimental\n * {@link GenkitBeta} class.\n *\n * ```ts\n * import { genkit } from 'genkit/beta';\n * ```\n *\n * @module beta\n */\n\nexport {\n AgentInitSchema,\n AgentInputSchema,\n AgentOutputSchema,\n AgentStreamChunkSchema,\n type AgentInit,\n type AgentInput,\n type AgentOutput,\n} from '@genkit-ai/ai';\nexport { Session, type Artifact } from '@genkit-ai/ai/session';\nexport {\n AgentError,\n remoteAgent,\n type AgentAPI,\n type AgentChat,\n type AgentChunk,\n type AgentInterrupt,\n type AgentResponse,\n type AgentTurn,\n type DetachedTask,\n type RemoteAgentOptions,\n} from './client/agent.mjs';\n\nexport type { AgentFinishReason } from './client/types.mjs';\n\nexport {\n InMemoryStreamManager,\n StreamNotFoundError,\n type ActionStreamInput,\n type ActionStreamSubscriber,\n type StreamManager,\n} from '@genkit-ai/core';\nexport { AsyncTaskQueue, lazy } from '@genkit-ai/core/async';\nexport * from './common.mjs';\nexport {\n FileSessionStore,\n GenkitBeta,\n InMemorySessionStore,\n SessionRunner,\n applyPatch,\n diff,\n genkit,\n type Agent,\n type AgentFn,\n type AgentStreamChunk,\n type ClientTransform,\n type GenkitBetaOptions,\n type JsonPatch,\n type JsonPatchOperation,\n type SessionSnapshot,\n type SessionSnapshotInput,\n type SessionState,\n type SessionStore,\n type SessionStoreOptions,\n type SnapshotMutator,\n} from './genkit-beta.mjs';\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,OAIK;AACP,SAAS,eAA8B;AACvC;AAAA,EACE;AAAA,EACA;AAAA,OASK;AAIP;AAAA,EACE;AAAA,EACA;AAAA,OAIK;AACP,SAAS,gBAAgB,YAAY;AACrC,cAAc;AACd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAcK;","names":[]}
@@ -0,0 +1,52 @@
1
+ import { AgentAPI } from '@genkit-ai/ai/agent-core';
2
+ export { AgentAPI, AgentChat, AgentChunk, AgentError, AgentInterrupt, AgentResponse, AgentTurn, DetachedTask } from '@genkit-ai/ai/agent-core';
3
+ export { JsonPatch, applyPatch } from '@genkit-ai/ai/json-patch';
4
+
5
+ /**
6
+ * Copyright 2026 Google LLC
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ *
12
+ * http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software
15
+ * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * See the License for the specific language governing permissions and
18
+ * limitations under the License.
19
+ */
20
+
21
+ /**
22
+ * Options for {@link remoteAgent}.
23
+ */
24
+ interface RemoteAgentOptions {
25
+ /** Required. The agent endpoint. */
26
+ url: string;
27
+ /** Optional. Defaults to `${url}/getSnapshot`. */
28
+ getSnapshotUrl?: string;
29
+ /** Optional. Defaults to `${url}/abort`. */
30
+ abortUrl?: string;
31
+ /** Optional. Static headers, or a function called per request. */
32
+ headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>);
33
+ /** Optional. Declares server- vs client-managed state; inferred otherwise. */
34
+ stateManagement?: 'server' | 'client';
35
+ }
36
+ /**
37
+ * Creates a typed client for talking to a Genkit agent over HTTP.
38
+ *
39
+ * ```ts
40
+ * import { remoteAgent } from 'genkit/beta/client';
41
+ *
42
+ * const agent = remoteAgent<WeatherState>({
43
+ * url: '/api/weatherAgent',
44
+ * });
45
+ * const chat = agent.chat();
46
+ * const res = await chat.send('Weather in Tokyo?').response;
47
+ * console.log(res.text);
48
+ * ```
49
+ */
50
+ declare function remoteAgent<State = unknown>(options: RemoteAgentOptions): AgentAPI<State>;
51
+
52
+ export { type RemoteAgentOptions, remoteAgent };
@@ -0,0 +1,52 @@
1
+ import { AgentAPI } from '@genkit-ai/ai/agent-core';
2
+ export { AgentAPI, AgentChat, AgentChunk, AgentError, AgentInterrupt, AgentResponse, AgentTurn, DetachedTask } from '@genkit-ai/ai/agent-core';
3
+ export { JsonPatch, applyPatch } from '@genkit-ai/ai/json-patch';
4
+
5
+ /**
6
+ * Copyright 2026 Google LLC
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ *
12
+ * http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software
15
+ * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * See the License for the specific language governing permissions and
18
+ * limitations under the License.
19
+ */
20
+
21
+ /**
22
+ * Options for {@link remoteAgent}.
23
+ */
24
+ interface RemoteAgentOptions {
25
+ /** Required. The agent endpoint. */
26
+ url: string;
27
+ /** Optional. Defaults to `${url}/getSnapshot`. */
28
+ getSnapshotUrl?: string;
29
+ /** Optional. Defaults to `${url}/abort`. */
30
+ abortUrl?: string;
31
+ /** Optional. Static headers, or a function called per request. */
32
+ headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>);
33
+ /** Optional. Declares server- vs client-managed state; inferred otherwise. */
34
+ stateManagement?: 'server' | 'client';
35
+ }
36
+ /**
37
+ * Creates a typed client for talking to a Genkit agent over HTTP.
38
+ *
39
+ * ```ts
40
+ * import { remoteAgent } from 'genkit/beta/client';
41
+ *
42
+ * const agent = remoteAgent<WeatherState>({
43
+ * url: '/api/weatherAgent',
44
+ * });
45
+ * const chat = agent.chat();
46
+ * const res = await chat.send('Weather in Tokyo?').response;
47
+ * console.log(res.text);
48
+ * ```
49
+ */
50
+ declare function remoteAgent<State = unknown>(options: RemoteAgentOptions): AgentAPI<State>;
51
+
52
+ export { type RemoteAgentOptions, remoteAgent };
@@ -0,0 +1,90 @@
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 agent_exports = {};
20
+ __export(agent_exports, {
21
+ AgentError: () => import_agent_core2.AgentError,
22
+ applyPatch: () => import_json_patch.applyPatch,
23
+ remoteAgent: () => remoteAgent
24
+ });
25
+ module.exports = __toCommonJS(agent_exports);
26
+ var import_agent_core = require("@genkit-ai/ai/agent-core");
27
+ var import_client = require("./client.js");
28
+ var import_agent_core2 = require("@genkit-ai/ai/agent-core");
29
+ var import_json_patch = require("@genkit-ai/ai/json-patch");
30
+ function remoteAgent(options) {
31
+ const { url } = options;
32
+ const getSnapshotUrl = options.getSnapshotUrl ?? `${url}/getSnapshot`;
33
+ const abortUrl = options.abortUrl ?? `${url}/abort`;
34
+ const resolveHeaders = async () => {
35
+ if (!options.headers) return void 0;
36
+ if (typeof options.headers === "function") {
37
+ return options.headers();
38
+ }
39
+ return options.headers;
40
+ };
41
+ const transport = {
42
+ stateManagement: options.stateManagement,
43
+ runTurn(input, init, opts) {
44
+ const started = (async () => {
45
+ const headers = await resolveHeaders();
46
+ return (0, import_client.streamFlow)({
47
+ url,
48
+ input,
49
+ init,
50
+ headers,
51
+ abortSignal: opts.abortSignal
52
+ });
53
+ })();
54
+ const output = (async () => {
55
+ const { output: output2 } = await started;
56
+ return output2;
57
+ })();
58
+ const stream = (async function* () {
59
+ const { stream: rawStream } = await started;
60
+ yield* rawStream;
61
+ })();
62
+ return { stream, output };
63
+ },
64
+ async getSnapshot(lookup) {
65
+ const headers = await resolveHeaders();
66
+ return (0, import_client.runFlow)({
67
+ url: getSnapshotUrl,
68
+ input: lookup,
69
+ headers
70
+ });
71
+ },
72
+ async abort(snapshotId) {
73
+ const headers = await resolveHeaders();
74
+ const result = await (0, import_client.runFlow)({
75
+ url: abortUrl,
76
+ input: { snapshotId },
77
+ headers
78
+ });
79
+ return result?.status;
80
+ }
81
+ };
82
+ return (0, import_agent_core.createAgentAPI)(transport);
83
+ }
84
+ // Annotate the CommonJS export names for ESM import in node:
85
+ 0 && (module.exports = {
86
+ AgentError,
87
+ applyPatch,
88
+ remoteAgent
89
+ });
90
+ //# sourceMappingURL=agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/client/agent.ts"],"sourcesContent":["/**\n * Copyright 2026 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\nimport {\n createAgentAPI,\n type AgentAPI,\n type AgentTransport,\n type SnapshotLookup,\n} from '@genkit-ai/ai/agent-core';\n\nimport type {\n AgentInit,\n AgentInput,\n AgentOutput,\n AgentStreamChunk,\n} from '@genkit-ai/ai';\nimport type { SessionSnapshot } from '@genkit-ai/ai/session';\nimport { runFlow, streamFlow } from './client.js';\n\n// Re-export the transport-agnostic agent-client surface so existing imports\n// from `genkit/beta/client` keep working.\nexport {\n AgentError,\n type AgentAPI,\n type AgentChat,\n type AgentChunk,\n type AgentInterrupt,\n type AgentResponse,\n type AgentTurn,\n type DetachedTask,\n} from '@genkit-ai/ai/agent-core';\n\n// Re-export the JSON Patch helper so apps can apply a chunk's `customPatch` to\n// their own locally tracked copy of the agent's custom state.\nexport { applyPatch, type JsonPatch } from '@genkit-ai/ai/json-patch';\n\n/**\n * Options for {@link remoteAgent}.\n */\nexport interface RemoteAgentOptions {\n /** Required. The agent endpoint. */\n url: string;\n /** Optional. Defaults to `${url}/getSnapshot`. */\n getSnapshotUrl?: string;\n /** Optional. Defaults to `${url}/abort`. */\n abortUrl?: string;\n /** Optional. Static headers, or a function called per request. */\n headers?:\n | Record<string, string>\n | (() => Record<string, string> | Promise<Record<string, string>>);\n /** Optional. Declares server- vs client-managed state; inferred otherwise. */\n stateManagement?: 'server' | 'client';\n}\n\n// ---------------------------------------------------------------------------\n// remoteAgent factory\n// ---------------------------------------------------------------------------\n\n/**\n * Creates a typed client for talking to a Genkit agent over HTTP.\n *\n * ```ts\n * import { remoteAgent } from 'genkit/beta/client';\n *\n * const agent = remoteAgent<WeatherState>({\n * url: '/api/weatherAgent',\n * });\n * const chat = agent.chat();\n * const res = await chat.send('Weather in Tokyo?').response;\n * console.log(res.text);\n * ```\n */\nexport function remoteAgent<State = unknown>(\n options: RemoteAgentOptions\n): AgentAPI<State> {\n const { url } = options;\n const getSnapshotUrl = options.getSnapshotUrl ?? `${url}/getSnapshot`;\n const abortUrl = options.abortUrl ?? `${url}/abort`;\n\n const resolveHeaders = async (): Promise<\n Record<string, string> | undefined\n > => {\n if (!options.headers) return undefined;\n if (typeof options.headers === 'function') {\n return options.headers();\n }\n return options.headers;\n };\n\n const transport: AgentTransport = {\n stateManagement: options.stateManagement,\n\n runTurn(\n input: AgentInput,\n init: AgentInit,\n opts: { abortSignal: AbortSignal }\n ) {\n // Kick off the request lazily so headers can be resolved asynchronously.\n const started = (async () => {\n const headers = await resolveHeaders();\n return streamFlow<AgentOutput, AgentStreamChunk, AgentInit>({\n url,\n input,\n init,\n headers,\n abortSignal: opts.abortSignal,\n });\n })();\n\n const output = (async () => {\n const { output } = await started;\n return output;\n })();\n\n const stream = (async function* (): AsyncIterable<AgentStreamChunk> {\n const { stream: rawStream } = await started;\n yield* rawStream;\n })();\n\n return { stream, output };\n },\n\n async getSnapshot(lookup: SnapshotLookup) {\n const headers = await resolveHeaders();\n return runFlow<SessionSnapshot<State> | undefined>({\n url: getSnapshotUrl,\n input: lookup,\n headers,\n });\n },\n\n async abort(snapshotId: string) {\n const headers = await resolveHeaders();\n const result = await runFlow<{\n snapshotId: string;\n status?: SessionSnapshot['status'];\n }>({\n url: abortUrl,\n input: { snapshotId },\n headers,\n });\n return result?.status;\n },\n };\n\n return createAgentAPI<State>(transport);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,wBAKO;AASP,oBAAoC;AAIpC,IAAAA,qBASO;AAIP,wBAA2C;AAsCpC,SAAS,YACd,SACiB;AACjB,QAAM,EAAE,IAAI,IAAI;AAChB,QAAM,iBAAiB,QAAQ,kBAAkB,GAAG,GAAG;AACvD,QAAM,WAAW,QAAQ,YAAY,GAAG,GAAG;AAE3C,QAAM,iBAAiB,YAElB;AACH,QAAI,CAAC,QAAQ,QAAS,QAAO;AAC7B,QAAI,OAAO,QAAQ,YAAY,YAAY;AACzC,aAAO,QAAQ,QAAQ;AAAA,IACzB;AACA,WAAO,QAAQ;AAAA,EACjB;AAEA,QAAM,YAA4B;AAAA,IAChC,iBAAiB,QAAQ;AAAA,IAEzB,QACE,OACA,MACA,MACA;AAEA,YAAM,WAAW,YAAY;AAC3B,cAAM,UAAU,MAAM,eAAe;AACrC,mBAAO,0BAAqD;AAAA,UAC1D;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA,aAAa,KAAK;AAAA,QACpB,CAAC;AAAA,MACH,GAAG;AAEH,YAAM,UAAU,YAAY;AAC1B,cAAM,EAAE,QAAAC,QAAO,IAAI,MAAM;AACzB,eAAOA;AAAA,MACT,GAAG;AAEH,YAAM,UAAU,mBAAoD;AAClE,cAAM,EAAE,QAAQ,UAAU,IAAI,MAAM;AACpC,eAAO;AAAA,MACT,GAAG;AAEH,aAAO,EAAE,QAAQ,OAAO;AAAA,IAC1B;AAAA,IAEA,MAAM,YAAY,QAAwB;AACxC,YAAM,UAAU,MAAM,eAAe;AACrC,iBAAO,uBAA4C;AAAA,QACjD,KAAK;AAAA,QACL,OAAO;AAAA,QACP;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IAEA,MAAM,MAAM,YAAoB;AAC9B,YAAM,UAAU,MAAM,eAAe;AACrC,YAAM,SAAS,UAAM,uBAGlB;AAAA,QACD,KAAK;AAAA,QACL,OAAO,EAAE,WAAW;AAAA,QACpB;AAAA,MACF,CAAC;AACD,aAAO,QAAQ;AAAA,IACjB;AAAA,EACF;AAEA,aAAO,kCAAsB,SAAS;AACxC;","names":["import_agent_core","output"]}
@@ -0,0 +1,68 @@
1
+ import {
2
+ createAgentAPI
3
+ } from "@genkit-ai/ai/agent-core";
4
+ import { runFlow, streamFlow } from "./client.mjs";
5
+ import {
6
+ AgentError
7
+ } from "@genkit-ai/ai/agent-core";
8
+ import { applyPatch } from "@genkit-ai/ai/json-patch";
9
+ function remoteAgent(options) {
10
+ const { url } = options;
11
+ const getSnapshotUrl = options.getSnapshotUrl ?? `${url}/getSnapshot`;
12
+ const abortUrl = options.abortUrl ?? `${url}/abort`;
13
+ const resolveHeaders = async () => {
14
+ if (!options.headers) return void 0;
15
+ if (typeof options.headers === "function") {
16
+ return options.headers();
17
+ }
18
+ return options.headers;
19
+ };
20
+ const transport = {
21
+ stateManagement: options.stateManagement,
22
+ runTurn(input, init, opts) {
23
+ const started = (async () => {
24
+ const headers = await resolveHeaders();
25
+ return streamFlow({
26
+ url,
27
+ input,
28
+ init,
29
+ headers,
30
+ abortSignal: opts.abortSignal
31
+ });
32
+ })();
33
+ const output = (async () => {
34
+ const { output: output2 } = await started;
35
+ return output2;
36
+ })();
37
+ const stream = (async function* () {
38
+ const { stream: rawStream } = await started;
39
+ yield* rawStream;
40
+ })();
41
+ return { stream, output };
42
+ },
43
+ async getSnapshot(lookup) {
44
+ const headers = await resolveHeaders();
45
+ return runFlow({
46
+ url: getSnapshotUrl,
47
+ input: lookup,
48
+ headers
49
+ });
50
+ },
51
+ async abort(snapshotId) {
52
+ const headers = await resolveHeaders();
53
+ const result = await runFlow({
54
+ url: abortUrl,
55
+ input: { snapshotId },
56
+ headers
57
+ });
58
+ return result?.status;
59
+ }
60
+ };
61
+ return createAgentAPI(transport);
62
+ }
63
+ export {
64
+ AgentError,
65
+ applyPatch,
66
+ remoteAgent
67
+ };
68
+ //# sourceMappingURL=agent.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/client/agent.ts"],"sourcesContent":["/**\n * Copyright 2026 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\nimport {\n createAgentAPI,\n type AgentAPI,\n type AgentTransport,\n type SnapshotLookup,\n} from '@genkit-ai/ai/agent-core';\n\nimport type {\n AgentInit,\n AgentInput,\n AgentOutput,\n AgentStreamChunk,\n} from '@genkit-ai/ai';\nimport type { SessionSnapshot } from '@genkit-ai/ai/session';\nimport { runFlow, streamFlow } from './client.mjs';\n\n// Re-export the transport-agnostic agent-client surface so existing imports\n// from `genkit/beta/client` keep working.\nexport {\n AgentError,\n type AgentAPI,\n type AgentChat,\n type AgentChunk,\n type AgentInterrupt,\n type AgentResponse,\n type AgentTurn,\n type DetachedTask,\n} from '@genkit-ai/ai/agent-core';\n\n// Re-export the JSON Patch helper so apps can apply a chunk's `customPatch` to\n// their own locally tracked copy of the agent's custom state.\nexport { applyPatch, type JsonPatch } from '@genkit-ai/ai/json-patch';\n\n/**\n * Options for {@link remoteAgent}.\n */\nexport interface RemoteAgentOptions {\n /** Required. The agent endpoint. */\n url: string;\n /** Optional. Defaults to `${url}/getSnapshot`. */\n getSnapshotUrl?: string;\n /** Optional. Defaults to `${url}/abort`. */\n abortUrl?: string;\n /** Optional. Static headers, or a function called per request. */\n headers?:\n | Record<string, string>\n | (() => Record<string, string> | Promise<Record<string, string>>);\n /** Optional. Declares server- vs client-managed state; inferred otherwise. */\n stateManagement?: 'server' | 'client';\n}\n\n// ---------------------------------------------------------------------------\n// remoteAgent factory\n// ---------------------------------------------------------------------------\n\n/**\n * Creates a typed client for talking to a Genkit agent over HTTP.\n *\n * ```ts\n * import { remoteAgent } from 'genkit/beta/client';\n *\n * const agent = remoteAgent<WeatherState>({\n * url: '/api/weatherAgent',\n * });\n * const chat = agent.chat();\n * const res = await chat.send('Weather in Tokyo?').response;\n * console.log(res.text);\n * ```\n */\nexport function remoteAgent<State = unknown>(\n options: RemoteAgentOptions\n): AgentAPI<State> {\n const { url } = options;\n const getSnapshotUrl = options.getSnapshotUrl ?? `${url}/getSnapshot`;\n const abortUrl = options.abortUrl ?? `${url}/abort`;\n\n const resolveHeaders = async (): Promise<\n Record<string, string> | undefined\n > => {\n if (!options.headers) return undefined;\n if (typeof options.headers === 'function') {\n return options.headers();\n }\n return options.headers;\n };\n\n const transport: AgentTransport = {\n stateManagement: options.stateManagement,\n\n runTurn(\n input: AgentInput,\n init: AgentInit,\n opts: { abortSignal: AbortSignal }\n ) {\n // Kick off the request lazily so headers can be resolved asynchronously.\n const started = (async () => {\n const headers = await resolveHeaders();\n return streamFlow<AgentOutput, AgentStreamChunk, AgentInit>({\n url,\n input,\n init,\n headers,\n abortSignal: opts.abortSignal,\n });\n })();\n\n const output = (async () => {\n const { output } = await started;\n return output;\n })();\n\n const stream = (async function* (): AsyncIterable<AgentStreamChunk> {\n const { stream: rawStream } = await started;\n yield* rawStream;\n })();\n\n return { stream, output };\n },\n\n async getSnapshot(lookup: SnapshotLookup) {\n const headers = await resolveHeaders();\n return runFlow<SessionSnapshot<State> | undefined>({\n url: getSnapshotUrl,\n input: lookup,\n headers,\n });\n },\n\n async abort(snapshotId: string) {\n const headers = await resolveHeaders();\n const result = await runFlow<{\n snapshotId: string;\n status?: SessionSnapshot['status'];\n }>({\n url: abortUrl,\n input: { snapshotId },\n headers,\n });\n return result?.status;\n },\n };\n\n return createAgentAPI<State>(transport);\n}\n"],"mappings":"AAgBA;AAAA,EACE;AAAA,OAIK;AASP,SAAS,SAAS,kBAAkB;AAIpC;AAAA,EACE;AAAA,OAQK;AAIP,SAAS,kBAAkC;AAsCpC,SAAS,YACd,SACiB;AACjB,QAAM,EAAE,IAAI,IAAI;AAChB,QAAM,iBAAiB,QAAQ,kBAAkB,GAAG,GAAG;AACvD,QAAM,WAAW,QAAQ,YAAY,GAAG,GAAG;AAE3C,QAAM,iBAAiB,YAElB;AACH,QAAI,CAAC,QAAQ,QAAS,QAAO;AAC7B,QAAI,OAAO,QAAQ,YAAY,YAAY;AACzC,aAAO,QAAQ,QAAQ;AAAA,IACzB;AACA,WAAO,QAAQ;AAAA,EACjB;AAEA,QAAM,YAA4B;AAAA,IAChC,iBAAiB,QAAQ;AAAA,IAEzB,QACE,OACA,MACA,MACA;AAEA,YAAM,WAAW,YAAY;AAC3B,cAAM,UAAU,MAAM,eAAe;AACrC,eAAO,WAAqD;AAAA,UAC1D;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA,aAAa,KAAK;AAAA,QACpB,CAAC;AAAA,MACH,GAAG;AAEH,YAAM,UAAU,YAAY;AAC1B,cAAM,EAAE,QAAAA,QAAO,IAAI,MAAM;AACzB,eAAOA;AAAA,MACT,GAAG;AAEH,YAAM,UAAU,mBAAoD;AAClE,cAAM,EAAE,QAAQ,UAAU,IAAI,MAAM;AACpC,eAAO;AAAA,MACT,GAAG;AAEH,aAAO,EAAE,QAAQ,OAAO;AAAA,IAC1B;AAAA,IAEA,MAAM,YAAY,QAAwB;AACxC,YAAM,UAAU,MAAM,eAAe;AACrC,aAAO,QAA4C;AAAA,QACjD,KAAK;AAAA,QACL,OAAO;AAAA,QACP;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IAEA,MAAM,MAAM,YAAoB;AAC9B,YAAM,UAAU,MAAM,eAAe;AACrC,YAAM,SAAS,MAAM,QAGlB;AAAA,QACD,KAAK;AAAA,QACL,OAAO,EAAE,WAAW;AAAA,QACpB;AAAA,MACF,CAAC;AACD,aAAO,QAAQ;AAAA,IACjB;AAAA,EACF;AAEA,SAAO,eAAsB,SAAS;AACxC;","names":["output"]}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Copyright 2024 Google LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * Invoke and stream response from a deployed flow.
18
+ *
19
+ * For example:
20
+ *
21
+ * ```js
22
+ * import { streamFlow } from 'genkit/beta/client';
23
+ *
24
+ * const response = streamFlow({
25
+ * url: 'https://my-flow-deployed-url',
26
+ * input: 'foo',
27
+ * });
28
+ * for await (const chunk of response.stream) {
29
+ * console.log(chunk);
30
+ * }
31
+ * console.log(await response.output);
32
+ * ```
33
+ */
34
+ declare function streamFlow<O = any, S = any, Init = any>({ url, input, init, streamId, headers, abortSignal, }: {
35
+ /** URL of the deployed flow. */
36
+ url: string;
37
+ /** Flow input. */
38
+ input?: any;
39
+ /** Initialization data for the action. */
40
+ init?: Init;
41
+ /** Stream ID to connect to. */
42
+ streamId?: string;
43
+ /** A map of HTTP headers to be added to the HTTP call. */
44
+ headers?: Record<string, string>;
45
+ /** Abort signal to abort the request. */
46
+ abortSignal?: AbortSignal;
47
+ }): {
48
+ readonly output: Promise<O>;
49
+ readonly stream: AsyncIterable<S>;
50
+ readonly streamId: Promise<string | null>;
51
+ };
52
+ /**
53
+ * Invoke a deployed flow over HTTP(s).
54
+ *
55
+ * For example:
56
+ *
57
+ * ```js
58
+ * import { runFlow } from 'genkit/beta/client';
59
+ *
60
+ * const response = await runFlow({
61
+ * url: 'https://my-flow-deployed-url',
62
+ * input: 'foo',
63
+ * });
64
+ * console.log(await response);
65
+ * ```
66
+ */
67
+ declare function runFlow<O = any, Init = any>({ url, input, init, headers, abortSignal, }: {
68
+ /** URL of the deployed flow. */
69
+ url: string;
70
+ /** Flow input. */
71
+ input?: any;
72
+ /** Initialization data for the action. */
73
+ init?: Init;
74
+ /** A map of HTTP headers to be added to the HTTP call. */
75
+ headers?: Record<string, string>;
76
+ /** Abort signal to abort the request. */
77
+ abortSignal?: AbortSignal;
78
+ }): Promise<O>;
79
+
80
+ export { runFlow, streamFlow };
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Copyright 2024 Google LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * Invoke and stream response from a deployed flow.
18
+ *
19
+ * For example:
20
+ *
21
+ * ```js
22
+ * import { streamFlow } from 'genkit/beta/client';
23
+ *
24
+ * const response = streamFlow({
25
+ * url: 'https://my-flow-deployed-url',
26
+ * input: 'foo',
27
+ * });
28
+ * for await (const chunk of response.stream) {
29
+ * console.log(chunk);
30
+ * }
31
+ * console.log(await response.output);
32
+ * ```
33
+ */
34
+ declare function streamFlow<O = any, S = any, Init = any>({ url, input, init, streamId, headers, abortSignal, }: {
35
+ /** URL of the deployed flow. */
36
+ url: string;
37
+ /** Flow input. */
38
+ input?: any;
39
+ /** Initialization data for the action. */
40
+ init?: Init;
41
+ /** Stream ID to connect to. */
42
+ streamId?: string;
43
+ /** A map of HTTP headers to be added to the HTTP call. */
44
+ headers?: Record<string, string>;
45
+ /** Abort signal to abort the request. */
46
+ abortSignal?: AbortSignal;
47
+ }): {
48
+ readonly output: Promise<O>;
49
+ readonly stream: AsyncIterable<S>;
50
+ readonly streamId: Promise<string | null>;
51
+ };
52
+ /**
53
+ * Invoke a deployed flow over HTTP(s).
54
+ *
55
+ * For example:
56
+ *
57
+ * ```js
58
+ * import { runFlow } from 'genkit/beta/client';
59
+ *
60
+ * const response = await runFlow({
61
+ * url: 'https://my-flow-deployed-url',
62
+ * input: 'foo',
63
+ * });
64
+ * console.log(await response);
65
+ * ```
66
+ */
67
+ declare function runFlow<O = any, Init = any>({ url, input, init, headers, abortSignal, }: {
68
+ /** URL of the deployed flow. */
69
+ url: string;
70
+ /** Flow input. */
71
+ input?: any;
72
+ /** Initialization data for the action. */
73
+ init?: Init;
74
+ /** A map of HTTP headers to be added to the HTTP call. */
75
+ headers?: Record<string, string>;
76
+ /** Abort signal to abort the request. */
77
+ abortSignal?: AbortSignal;
78
+ }): Promise<O>;
79
+
80
+ export { runFlow, streamFlow };