agentstack-sdk 0.5.1-rc2 → 0.5.2-rc2

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 (274) hide show
  1. package/dist/api.cjs +2 -0
  2. package/dist/api.cjs.map +1 -0
  3. package/dist/api.d.ts +5 -0
  4. package/dist/api.js +2 -0
  5. package/dist/api.js.map +1 -0
  6. package/dist/api.umd.js +2 -0
  7. package/dist/api.umd.js.map +1 -0
  8. package/dist/client/a2a/extensions/{ui/oauth.d.ts → auth/oauth/index.d.ts} +3 -6
  9. package/dist/client/a2a/extensions/auth/oauth/schemas.d.ts +32 -0
  10. package/dist/client/a2a/extensions/auth/oauth/types.d.ts +13 -0
  11. package/dist/client/a2a/extensions/auth/secrets/index.d.ts +10 -0
  12. package/dist/client/a2a/extensions/auth/secrets/schemas.d.ts +23 -0
  13. package/dist/client/a2a/extensions/auth/secrets/types.d.ts +10 -0
  14. package/dist/client/a2a/extensions/common/{form.d.ts → form/schemas.d.ts} +87 -45
  15. package/dist/client/a2a/extensions/common/form/types.d.ts +23 -0
  16. package/dist/client/a2a/extensions/index.d.ts +20 -0
  17. package/dist/client/a2a/extensions/interactions/approval/index.d.ts +9 -0
  18. package/dist/client/a2a/extensions/interactions/{approval.d.ts → approval/schemas.d.ts} +0 -8
  19. package/dist/client/a2a/extensions/interactions/approval/types.d.ts +10 -0
  20. package/dist/client/a2a/extensions/schemas.d.ts +18 -0
  21. package/dist/client/a2a/extensions/services/embedding/index.d.ts +9 -0
  22. package/dist/client/a2a/extensions/services/{embedding.d.ts → embedding/schemas.d.ts} +12 -8
  23. package/dist/client/a2a/extensions/services/embedding/types.d.ts +10 -0
  24. package/dist/client/a2a/extensions/services/form/index.d.ts +9 -0
  25. package/dist/client/a2a/extensions/services/{form.d.ts → form/schemas.d.ts} +2 -8
  26. package/dist/client/a2a/extensions/services/form/types.d.ts +8 -0
  27. package/dist/client/a2a/extensions/services/llm/index.d.ts +9 -0
  28. package/dist/client/a2a/extensions/services/{llm.d.ts → llm/schemas.d.ts} +12 -8
  29. package/dist/client/a2a/extensions/services/llm/types.d.ts +10 -0
  30. package/dist/client/a2a/extensions/services/mcp/index.d.ts +9 -0
  31. package/dist/client/a2a/extensions/services/mcp/schemas.d.ts +35 -0
  32. package/dist/client/a2a/extensions/services/mcp/types.d.ts +14 -0
  33. package/dist/client/a2a/extensions/services/{platform.d.ts → platform-api/index.d.ts} +1 -1
  34. package/dist/client/a2a/extensions/services/platform-api/schemas.d.ts +10 -0
  35. package/dist/client/a2a/extensions/services/platform-api/types.d.ts +7 -0
  36. package/dist/client/a2a/extensions/types.d.ts +14 -12
  37. package/dist/client/a2a/extensions/ui/agent-detail/index.d.ts +9 -0
  38. package/dist/client/a2a/extensions/ui/{agent-detail.d.ts → agent-detail/schemas.d.ts} +9 -17
  39. package/dist/client/a2a/extensions/ui/agent-detail/types.d.ts +13 -0
  40. package/dist/client/a2a/extensions/ui/canvas/index.d.ts +9 -0
  41. package/dist/client/a2a/extensions/ui/canvas/schemas.d.ts +11 -0
  42. package/dist/client/a2a/extensions/ui/canvas/types.d.ts +7 -0
  43. package/dist/client/a2a/extensions/ui/citation/index.d.ts +9 -0
  44. package/dist/client/a2a/extensions/ui/{citation.d.ts → citation/schemas.d.ts} +2 -8
  45. package/dist/client/a2a/extensions/ui/citation/types.d.ts +8 -0
  46. package/dist/client/a2a/extensions/ui/error/index.d.ts +9 -0
  47. package/dist/client/a2a/extensions/ui/{error.d.ts → error/schemas.d.ts} +12 -6
  48. package/dist/client/a2a/extensions/ui/error/types.d.ts +9 -0
  49. package/dist/client/a2a/extensions/ui/form-request/index.d.ts +9 -0
  50. package/dist/client/a2a/extensions/ui/settings/index.d.ts +9 -0
  51. package/dist/client/a2a/extensions/ui/{settings.d.ts → settings/schemas.d.ts} +46 -43
  52. package/dist/client/a2a/extensions/ui/settings/types.d.ts +18 -0
  53. package/dist/client/a2a/extensions/ui/trajectory/index.d.ts +9 -0
  54. package/dist/client/a2a/extensions/ui/trajectory/schemas.d.ts +10 -0
  55. package/dist/client/a2a/extensions/ui/trajectory/types.d.ts +7 -0
  56. package/dist/client/a2a/index.d.ts +6 -0
  57. package/dist/client/a2a/protocol/index.d.ts +6 -0
  58. package/dist/client/a2a/protocol/schemas.d.ts +988 -0
  59. package/dist/client/a2a/protocol/tests.d.ts +5 -0
  60. package/dist/client/a2a/protocol/types.d.ts +52 -0
  61. package/dist/client/a2a/protocol/utils.d.ts +6 -0
  62. package/dist/client/api/common/schemas.d.ts +30 -0
  63. package/dist/client/api/common/types.d.ts +18 -0
  64. package/dist/client/api/configuration/api.d.ts +22 -0
  65. package/dist/client/api/configuration/schemas.d.ts +31 -0
  66. package/dist/client/api/configuration/types.d.ts +11 -0
  67. package/dist/client/api/connectors/api.d.ts +78 -0
  68. package/dist/client/api/connectors/schemas.d.ts +114 -0
  69. package/dist/client/api/connectors/types.d.ts +28 -0
  70. package/dist/client/api/contexts/api.d.ts +133 -0
  71. package/dist/client/api/contexts/schemas.d.ts +359 -0
  72. package/dist/client/api/contexts/types.d.ts +34 -0
  73. package/dist/client/api/core/client.d.ts +1273 -0
  74. package/dist/client/api/core/errors/index.d.ts +6 -0
  75. package/dist/client/api/core/errors/types.d.ts +36 -0
  76. package/dist/client/api/core/errors/utils.d.ts +23 -0
  77. package/dist/client/api/core/index.d.ts +7 -0
  78. package/dist/client/api/core/schemas.d.ts +17 -0
  79. package/dist/client/api/core/types.d.ts +45 -0
  80. package/dist/client/api/core/utils.d.ts +23 -0
  81. package/dist/client/api/files/api.d.ts +32 -0
  82. package/dist/client/api/files/schemas.d.ts +61 -0
  83. package/dist/client/api/files/types.d.ts +19 -0
  84. package/dist/client/api/index.d.ts +7 -0
  85. package/dist/client/api/model-providers/api.d.ts +50 -0
  86. package/dist/client/api/model-providers/schemas.d.ts +80 -0
  87. package/dist/client/api/model-providers/types.d.ts +44 -0
  88. package/dist/client/api/provider-builds/api.d.ts +143 -0
  89. package/dist/client/api/provider-builds/schemas.d.ts +250 -0
  90. package/dist/client/api/provider-builds/types.d.ts +31 -0
  91. package/dist/client/api/providers/api.d.ts +847 -0
  92. package/dist/client/api/providers/schemas.d.ts +1335 -0
  93. package/dist/client/api/providers/types.d.ts +45 -0
  94. package/dist/client/api/schemas.d.ts +15 -0
  95. package/dist/client/api/types.d.ts +11 -97
  96. package/dist/client/api/user-feedback/api.d.ts +9 -0
  97. package/dist/client/api/user-feedback/schemas.d.ts +15 -0
  98. package/dist/client/api/user-feedback/types.d.ts +8 -0
  99. package/dist/client/api/users/api.d.ts +13 -0
  100. package/dist/client/api/users/schemas.d.ts +20 -0
  101. package/dist/client/api/users/types.d.ts +14 -0
  102. package/dist/client/api/variables/api.d.ts +12 -0
  103. package/dist/client/api/variables/schemas.d.ts +13 -0
  104. package/dist/client/api/variables/types.d.ts +10 -0
  105. package/dist/client/{a2a/extensions/utils.d.ts → core/extensions/extract.d.ts} +2 -5
  106. package/dist/client/core/extensions/fulfill.d.ts +8 -0
  107. package/dist/client/core/extensions/resolve-user-metadata.d.ts +6 -0
  108. package/dist/client/core/extensions/types.d.ts +67 -0
  109. package/dist/client/core/fulfillment-resolvers/build-llm-extension-fulfillment-resolver.d.ts +8 -0
  110. package/dist/client/{a2a/extensions → core}/handle-agent-card.d.ts +3 -24
  111. package/dist/client/core/handle-task-status-update.d.ts +7 -0
  112. package/dist/client/core/index.d.ts +13 -0
  113. package/dist/client/{a2a/extensions → core}/utils/build-message-builder.d.ts +2 -2
  114. package/dist/core.cjs +2 -0
  115. package/dist/core.cjs.map +1 -0
  116. package/dist/core.d.ts +5 -0
  117. package/dist/core.js +2 -0
  118. package/dist/core.js.map +1 -0
  119. package/dist/core.umd.js +2 -0
  120. package/dist/core.umd.js.map +1 -0
  121. package/dist/extensions.cjs +2 -0
  122. package/dist/extensions.cjs.map +1 -0
  123. package/dist/extensions.d.ts +5 -0
  124. package/dist/extensions.js +2 -0
  125. package/dist/extensions.js.map +1 -0
  126. package/dist/extensions.umd.js +2 -0
  127. package/dist/extensions.umd.js.map +1 -0
  128. package/dist/index.cjs +1 -1
  129. package/dist/index.cjs.map +1 -1
  130. package/dist/index.d.ts +3 -26
  131. package/dist/index.js +1 -1
  132. package/dist/index.js.map +1 -1
  133. package/dist/index.umd.js +1 -1
  134. package/dist/index.umd.js.map +1 -1
  135. package/package.json +36 -8
  136. package/src/api.ts +6 -0
  137. package/src/client/a2a/extensions/auth/oauth/index.ts +23 -0
  138. package/src/client/a2a/extensions/auth/oauth/schemas.ts +34 -0
  139. package/src/client/a2a/extensions/auth/oauth/types.ts +27 -0
  140. package/src/client/a2a/extensions/auth/secrets/index.ts +23 -0
  141. package/src/client/a2a/extensions/auth/secrets/schemas.ts +23 -0
  142. package/src/client/a2a/extensions/auth/secrets/types.ts +19 -0
  143. package/src/client/a2a/extensions/common/{form.ts → form/schemas.ts} +62 -73
  144. package/src/client/a2a/extensions/common/form/types.ts +48 -0
  145. package/src/client/a2a/extensions/index.ts +21 -0
  146. package/src/client/a2a/extensions/interactions/approval/index.ts +17 -0
  147. package/src/client/a2a/extensions/interactions/{approval.ts → approval/schemas.ts} +0 -13
  148. package/src/client/a2a/extensions/interactions/approval/types.ts +19 -0
  149. package/src/client/a2a/extensions/schemas.ts +19 -0
  150. package/src/client/a2a/extensions/services/embedding/index.ts +16 -0
  151. package/src/client/a2a/extensions/services/embedding/schemas.ts +26 -0
  152. package/src/client/a2a/extensions/services/embedding/types.ts +19 -0
  153. package/src/client/a2a/extensions/services/form/index.ts +16 -0
  154. package/src/client/a2a/extensions/services/form/schemas.ts +20 -0
  155. package/src/client/a2a/extensions/services/form/types.ts +12 -0
  156. package/src/client/a2a/extensions/services/llm/index.ts +16 -0
  157. package/src/client/a2a/extensions/services/llm/schemas.ts +26 -0
  158. package/src/client/a2a/extensions/services/llm/types.ts +14 -0
  159. package/src/client/a2a/extensions/services/mcp/index.ts +16 -0
  160. package/src/client/a2a/extensions/services/mcp/schemas.ts +32 -0
  161. package/src/client/a2a/extensions/services/mcp/types.ts +19 -0
  162. package/src/client/a2a/extensions/services/{platform.ts → platform-api/index.ts} +5 -9
  163. package/src/client/a2a/extensions/services/platform-api/schemas.ts +12 -0
  164. package/src/client/a2a/extensions/services/platform-api/types.ts +10 -0
  165. package/src/client/a2a/extensions/types.ts +14 -15
  166. package/src/client/a2a/extensions/ui/agent-detail/index.ts +17 -0
  167. package/src/client/a2a/extensions/ui/agent-detail/schemas.ts +36 -0
  168. package/src/client/a2a/extensions/ui/agent-detail/types.ts +19 -0
  169. package/src/client/a2a/extensions/ui/canvas/index.ts +17 -0
  170. package/src/client/a2a/extensions/ui/canvas/schemas.ts +13 -0
  171. package/src/client/a2a/extensions/ui/canvas/types.ts +10 -0
  172. package/src/client/a2a/extensions/ui/citation/index.ts +17 -0
  173. package/src/client/a2a/extensions/ui/citation/schemas.ts +18 -0
  174. package/src/client/a2a/extensions/ui/citation/types.ts +12 -0
  175. package/src/client/a2a/extensions/ui/error/index.ts +17 -0
  176. package/src/client/a2a/extensions/ui/error/schemas.ts +22 -0
  177. package/src/client/a2a/extensions/ui/error/types.ts +14 -0
  178. package/src/client/a2a/extensions/ui/{form-request.ts → form-request/index.ts} +5 -6
  179. package/src/client/a2a/extensions/ui/settings/index.ts +16 -0
  180. package/src/client/a2a/extensions/ui/settings/schemas.ts +65 -0
  181. package/src/client/a2a/extensions/ui/settings/types.ts +38 -0
  182. package/src/client/a2a/extensions/ui/{trajectory.ts → trajectory/index.ts} +4 -10
  183. package/src/client/a2a/extensions/ui/trajectory/schemas.ts +12 -0
  184. package/src/client/a2a/extensions/ui/trajectory/types.ts +10 -0
  185. package/src/client/a2a/index.ts +7 -0
  186. package/src/client/a2a/protocol/index.ts +7 -0
  187. package/src/client/a2a/protocol/schemas.ts +413 -0
  188. package/src/client/a2a/protocol/tests.ts +172 -0
  189. package/src/client/a2a/protocol/types.ts +127 -0
  190. package/src/client/a2a/protocol/utils.ts +39 -0
  191. package/src/client/api/common/schemas.ts +45 -0
  192. package/src/client/api/common/types.ts +34 -0
  193. package/src/client/api/configuration/api.ts +31 -0
  194. package/src/client/api/configuration/schemas.ts +25 -0
  195. package/src/client/api/configuration/types.ts +22 -0
  196. package/src/client/api/connectors/api.ts +86 -0
  197. package/src/client/api/connectors/schemas.ts +77 -0
  198. package/src/client/api/connectors/types.ts +57 -0
  199. package/src/client/api/contexts/api.ts +113 -0
  200. package/src/client/api/contexts/schemas.ts +156 -0
  201. package/src/client/api/contexts/types.ts +74 -0
  202. package/src/client/api/core/client.ts +155 -0
  203. package/src/client/api/core/errors/index.ts +7 -0
  204. package/src/client/api/core/errors/types.ts +45 -0
  205. package/src/client/api/core/errors/utils.ts +63 -0
  206. package/src/client/api/core/index.ts +8 -0
  207. package/src/client/api/core/schemas.ts +20 -0
  208. package/src/client/api/core/types.ts +57 -0
  209. package/src/client/api/core/utils.ts +100 -0
  210. package/src/client/api/files/api.ts +65 -0
  211. package/src/client/api/files/schemas.ts +56 -0
  212. package/src/client/api/files/types.ts +37 -0
  213. package/src/client/api/index.ts +8 -0
  214. package/src/client/api/model-providers/api.ts +67 -0
  215. package/src/client/api/model-providers/schemas.ts +68 -0
  216. package/src/client/api/model-providers/types.ts +66 -0
  217. package/src/client/api/provider-builds/api.ts +80 -0
  218. package/src/client/api/provider-builds/schemas.ts +98 -0
  219. package/src/client/api/provider-builds/types.ts +61 -0
  220. package/src/client/api/providers/api.ts +122 -0
  221. package/src/client/api/providers/schemas.ts +140 -0
  222. package/src/client/api/providers/types.ts +87 -0
  223. package/src/client/api/schemas.ts +16 -0
  224. package/src/client/api/types.ts +11 -130
  225. package/src/client/api/user-feedback/api.ts +23 -0
  226. package/src/client/api/user-feedback/schemas.ts +18 -0
  227. package/src/client/api/user-feedback/types.ts +11 -0
  228. package/src/client/api/users/api.ts +21 -0
  229. package/src/client/api/users/schemas.ts +21 -0
  230. package/src/client/api/users/types.ts +19 -0
  231. package/src/client/api/variables/api.ts +31 -0
  232. package/src/client/api/variables/schemas.ts +18 -0
  233. package/src/client/api/variables/types.ts +19 -0
  234. package/src/client/{a2a/extensions/utils.ts → core/extensions/extract.ts} +2 -21
  235. package/src/client/core/extensions/fulfill.ts +24 -0
  236. package/src/client/core/extensions/resolve-user-metadata.ts +25 -0
  237. package/src/client/core/extensions/types.ts +84 -0
  238. package/src/client/{a2a/extensions → core}/fulfillment-resolvers/build-llm-extension-fulfillment-resolver.ts +14 -10
  239. package/src/client/{a2a/extensions → core}/handle-agent-card.ts +14 -37
  240. package/src/client/core/handle-task-status-update.ts +60 -0
  241. package/src/client/core/index.ts +14 -0
  242. package/src/client/{a2a/extensions → core}/utils/build-message-builder.ts +2 -3
  243. package/src/core.ts +6 -0
  244. package/src/extensions.ts +6 -0
  245. package/src/index.ts +3 -30
  246. package/dist/client/a2a/extensions/fulfillment-resolvers/build-llm-extension-fulfillment-resolver.d.ts +0 -8
  247. package/dist/client/a2a/extensions/handle-task-status-update.d.ts +0 -32
  248. package/dist/client/a2a/extensions/resolve-user-metadata.d.ts +0 -11
  249. package/dist/client/a2a/extensions/services/mcp.d.ts +0 -46
  250. package/dist/client/a2a/extensions/services/oauth-provider.d.ts +0 -30
  251. package/dist/client/a2a/extensions/services/secrets.d.ts +0 -28
  252. package/dist/client/a2a/extensions/ui/canvas.d.ts +0 -16
  253. package/dist/client/a2a/extensions/ui/form-request.d.ts +0 -11
  254. package/dist/client/a2a/extensions/ui/trajectory.d.ts +0 -15
  255. package/dist/client/api/build-api-client.d.ts +0 -62
  256. package/dist/types.d.ts +0 -10
  257. package/src/client/a2a/extensions/handle-task-status-update.ts +0 -95
  258. package/src/client/a2a/extensions/resolve-user-metadata.ts +0 -30
  259. package/src/client/a2a/extensions/services/embedding.ts +0 -43
  260. package/src/client/a2a/extensions/services/form.ts +0 -31
  261. package/src/client/a2a/extensions/services/llm.ts +0 -39
  262. package/src/client/a2a/extensions/services/mcp.ts +0 -59
  263. package/src/client/a2a/extensions/services/oauth-provider.ts +0 -52
  264. package/src/client/a2a/extensions/services/secrets.ts +0 -46
  265. package/src/client/a2a/extensions/ui/agent-detail.ts +0 -46
  266. package/src/client/a2a/extensions/ui/canvas.ts +0 -24
  267. package/src/client/a2a/extensions/ui/citation.ts +0 -30
  268. package/src/client/a2a/extensions/ui/error.ts +0 -33
  269. package/src/client/a2a/extensions/ui/oauth.ts +0 -21
  270. package/src/client/a2a/extensions/ui/settings.ts +0 -84
  271. package/src/client/api/build-api-client.ts +0 -125
  272. package/src/types.ts +0 -9
  273. /package/dist/client/{a2a → core}/create-authenticated-fetch.d.ts +0 -0
  274. /package/src/client/{a2a → core}/create-authenticated-fetch.ts +0 -0
@@ -0,0 +1,156 @@
1
+ /**
2
+ * Copyright 2025 © BeeAI a Series of LF Projects, LLC
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ import z from 'zod';
7
+
8
+ import { artifactSchema, messageSchema } from '../../a2a/protocol/schemas';
9
+ import { paginatedResponseSchema, paginationQuerySchema } from '../core/schemas';
10
+ import { ContextHistoryKind } from './types';
11
+
12
+ export const contextSchema = z.object({
13
+ id: z.string(),
14
+ created_at: z.string(),
15
+ updated_at: z.string(),
16
+ last_active_at: z.string(),
17
+ created_by: z.string(),
18
+ provider_id: z.string().nullable(),
19
+ metadata: z.record(z.string(), z.unknown()).nullable(),
20
+ });
21
+
22
+ export const listContextsRequestSchema = z.object({
23
+ query: paginationQuerySchema
24
+ .extend({
25
+ provider_id: z.string().nullish(),
26
+ include_empty: z.boolean().optional(),
27
+ })
28
+ .optional(),
29
+ });
30
+
31
+ export const listContextsResponseSchema = paginatedResponseSchema.extend({
32
+ items: z.array(contextSchema),
33
+ });
34
+
35
+ export const createContextRequestSchema = z.object({
36
+ provider_id: z.string().nullish(),
37
+ metadata: z.record(z.string(), z.string()).nullish(),
38
+ });
39
+
40
+ export const createContextResponseSchema = contextSchema;
41
+
42
+ export const readContextRequestSchema = z.object({
43
+ context_id: z.string(),
44
+ });
45
+
46
+ export const readContextResponseSchema = contextSchema;
47
+
48
+ export const updateContextRequestSchema = z.object({
49
+ context_id: z.string(),
50
+ metadata: z.record(z.string(), z.string()).nullish(),
51
+ });
52
+
53
+ export const updateContextResponseSchema = contextSchema;
54
+
55
+ export const deleteContextRequestSchema = z.object({
56
+ context_id: z.string(),
57
+ });
58
+
59
+ export const deleteContextResponseSchema = z.null();
60
+
61
+ export const contextHistoryKind = z.enum(ContextHistoryKind);
62
+
63
+ export const contextHistorySchema = z.object({
64
+ id: z.string(),
65
+ context_id: z.string(),
66
+ created_at: z.string(),
67
+ kind: contextHistoryKind,
68
+ data: z.union([artifactSchema, messageSchema]),
69
+ });
70
+
71
+ export const listContextHistoryRequestSchema = z.object({
72
+ context_id: z.string(),
73
+ query: paginationQuerySchema.optional(),
74
+ });
75
+
76
+ export const listContextHistoryResponseSchema = paginatedResponseSchema.extend({
77
+ items: z.array(contextHistorySchema),
78
+ });
79
+
80
+ export const createContextHistoryRequestSchema = z.object({
81
+ context_id: z.string(),
82
+ data: z.union([artifactSchema, messageSchema]),
83
+ });
84
+
85
+ export const createContextHistoryResponseSchema = z.null();
86
+
87
+ export const patchContextMetadataRequestSchema = z.object({
88
+ context_id: z.string(),
89
+ metadata: z.record(z.string(), z.union([z.string(), z.null()])),
90
+ });
91
+
92
+ export const patchContextMetadataResponseSchema = contextSchema;
93
+
94
+ export const contextTokenSchema = z.object({
95
+ token: z.string(),
96
+ expires_at: z.string().nullable(),
97
+ });
98
+
99
+ export const resourceIdPermissionSchema = z.object({
100
+ id: z.string(),
101
+ });
102
+
103
+ export const contextPermissionsGrantSchema = z.object({
104
+ files: z.array(z.literal(['read', 'write', 'extract', '*'])).optional(),
105
+ vector_stores: z.array(z.literal(['read', 'write', '*'])).optional(),
106
+ context_data: z.array(z.literal(['read', 'write', '*'])).optional(),
107
+ });
108
+
109
+ export const globalPermissionsGrantSchema = contextPermissionsGrantSchema
110
+ .extend({
111
+ feedback: z.array(z.literal('write')).optional(),
112
+
113
+ llm: z.array(z.union([z.literal('*'), resourceIdPermissionSchema])).optional(),
114
+ embeddings: z.array(z.union([z.literal('*'), resourceIdPermissionSchema])).optional(),
115
+ model_providers: z.array(z.literal(['read', 'write', '*'])).optional(),
116
+
117
+ a2a_proxy: z.array(z.union([z.literal('*'), z.string()])).optional(),
118
+
119
+ providers: z.array(z.literal(['read', 'write', '*'])).optional(),
120
+ provider_variables: z.array(z.literal(['read', 'write', '*'])).optional(),
121
+
122
+ contexts: z.array(z.literal(['read', 'write', '*'])).optional(),
123
+
124
+ connectors: z.array(z.literal(['read', 'write', 'proxy', '*'])).optional(),
125
+ })
126
+ .superRefine((val, ctx) => {
127
+ if (!val.a2a_proxy) return;
128
+
129
+ if (val.a2a_proxy.length === 0) {
130
+ ctx.addIssue({
131
+ code: z.ZodIssueCode.custom,
132
+ message: 'a2a_proxy cannot be empty array',
133
+ path: ['a2a_proxy'],
134
+ });
135
+ return;
136
+ }
137
+
138
+ const hasWildcard = val.a2a_proxy.includes('*');
139
+ const hasOthers = val.a2a_proxy.some((v) => v !== '*');
140
+
141
+ if (hasWildcard && hasOthers) {
142
+ ctx.addIssue({
143
+ code: z.ZodIssueCode.custom,
144
+ message: "a2a_proxy cannot mix '*' with specific providers",
145
+ path: ['a2a_proxy'],
146
+ });
147
+ }
148
+ });
149
+
150
+ export const createContextTokenRequestSchema = z.object({
151
+ context_id: z.string(),
152
+ grant_context_permissions: contextPermissionsGrantSchema.optional(),
153
+ grant_global_permissions: globalPermissionsGrantSchema.optional(),
154
+ });
155
+
156
+ export const createContextTokenResponseSchema = contextTokenSchema;
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Copyright 2025 © BeeAI a Series of LF Projects, LLC
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ import type z from 'zod';
7
+
8
+ import type {
9
+ contextHistorySchema,
10
+ contextPermissionsGrantSchema,
11
+ contextSchema,
12
+ contextTokenSchema,
13
+ createContextHistoryRequestSchema,
14
+ createContextHistoryResponseSchema,
15
+ createContextRequestSchema,
16
+ createContextResponseSchema,
17
+ createContextTokenRequestSchema,
18
+ createContextTokenResponseSchema,
19
+ deleteContextRequestSchema,
20
+ deleteContextResponseSchema,
21
+ globalPermissionsGrantSchema,
22
+ listContextHistoryRequestSchema,
23
+ listContextHistoryResponseSchema,
24
+ listContextsRequestSchema,
25
+ listContextsResponseSchema,
26
+ patchContextMetadataRequestSchema,
27
+ patchContextMetadataResponseSchema,
28
+ readContextRequestSchema,
29
+ readContextResponseSchema,
30
+ resourceIdPermissionSchema,
31
+ updateContextRequestSchema,
32
+ updateContextResponseSchema,
33
+ } from './schemas';
34
+
35
+ export type Context = z.infer<typeof contextSchema>;
36
+
37
+ export type ListContextsRequest = z.infer<typeof listContextsRequestSchema>;
38
+ export type ListContextsResponse = z.infer<typeof listContextsResponseSchema>;
39
+
40
+ export type CreateContextRequest = z.infer<typeof createContextRequestSchema>;
41
+ export type CreateContextResponse = z.infer<typeof createContextResponseSchema>;
42
+
43
+ export type ReadContextRequest = z.infer<typeof readContextRequestSchema>;
44
+ export type ReadContextResponse = z.infer<typeof readContextResponseSchema>;
45
+
46
+ export type UpdateContextRequest = z.infer<typeof updateContextRequestSchema>;
47
+ export type UpdateContextResponse = z.infer<typeof updateContextResponseSchema>;
48
+
49
+ export type DeleteContextRequest = z.infer<typeof deleteContextRequestSchema>;
50
+ export type DeleteContextResponse = z.infer<typeof deleteContextResponseSchema>;
51
+
52
+ export enum ContextHistoryKind {
53
+ Artifact = 'artifact',
54
+ Message = 'message',
55
+ }
56
+ export type ContextHistory = z.infer<typeof contextHistorySchema>;
57
+
58
+ export type ListContextHistoryRequest = z.infer<typeof listContextHistoryRequestSchema>;
59
+ export type ListContextHistoryResponse = z.infer<typeof listContextHistoryResponseSchema>;
60
+
61
+ export type CreateContextHistoryRequest = z.infer<typeof createContextHistoryRequestSchema>;
62
+ export type CreateContextHistoryResponse = z.infer<typeof createContextHistoryResponseSchema>;
63
+
64
+ export type PatchContextMetadataRequest = z.infer<typeof patchContextMetadataRequestSchema>;
65
+ export type PatchContextMetadataResponse = z.infer<typeof patchContextMetadataResponseSchema>;
66
+
67
+ export type ContextToken = z.infer<typeof contextTokenSchema>;
68
+
69
+ export type ResourceIdPermission = z.infer<typeof resourceIdPermissionSchema>;
70
+ export type ContextPermissionsGrant = z.infer<typeof contextPermissionsGrantSchema>;
71
+ export type GlobalPermissionsGrant = z.infer<typeof globalPermissionsGrantSchema>;
72
+
73
+ export type CreateContextTokenRequest = z.infer<typeof createContextTokenRequestSchema>;
74
+ export type CreateContextTokenResponse = z.infer<typeof createContextTokenResponseSchema>;
@@ -0,0 +1,155 @@
1
+ /**
2
+ * Copyright 2025 © BeeAI a Series of LF Projects, LLC
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ import type z from 'zod';
7
+
8
+ import { createConfigurationApi } from '../configuration/api';
9
+ import { createConnectorsApi } from '../connectors/api';
10
+ import { createContextsApi } from '../contexts/api';
11
+ import { createFilesApi } from '../files/api';
12
+ import { createModelProvidersApi } from '../model-providers/api';
13
+ import { createProviderBuildsApi } from '../provider-builds/api';
14
+ import { createProvidersApi } from '../providers/api';
15
+ import { createUserFeedbackApi } from '../user-feedback/api';
16
+ import { createUsersApi } from '../users/api';
17
+ import { createVariablesApi } from '../variables/api';
18
+ import type { HttpError, NetworkError, ParseError, ValidationError } from './errors';
19
+ import { ApiErrorException, ApiErrorType } from './errors';
20
+ import type { ApiFailure, ApiRequest, ApiResult, CallApi } from './types';
21
+ import { buildRequestInit, buildRequestUrl, parseBodyText, safeReadText } from './utils';
22
+
23
+ function createCallApi({ baseUrl, fetch: fetchFn }: { baseUrl: string; fetch: typeof globalThis.fetch }): CallApi {
24
+ return async function callApi({ method, path, schema, query, body, parseAsStream }) {
25
+ const requestUrl = buildRequestUrl({ baseUrl, path, query });
26
+ const requestInit = buildRequestInit({ method, body });
27
+
28
+ const request: ApiRequest = {
29
+ method,
30
+ url: requestUrl,
31
+ };
32
+
33
+ try {
34
+ const rawResponse = await fetchFn(requestUrl, requestInit);
35
+ const bodyText = parseAsStream ? rawResponse.body : await safeReadText(rawResponse);
36
+
37
+ const { ok, status, statusText, headers } = rawResponse;
38
+ const response = { status, statusText, bodyText };
39
+
40
+ if (!ok) {
41
+ return {
42
+ ok: false,
43
+ error: {
44
+ type: ApiErrorType.Http,
45
+ message: 'API Http Error',
46
+ request,
47
+ response,
48
+ } satisfies HttpError,
49
+ } satisfies ApiFailure;
50
+ }
51
+
52
+ const { data: parsedBody, error: parseError } = parseBodyText(bodyText, headers);
53
+
54
+ if (parseError) {
55
+ return {
56
+ ok: false,
57
+ error: {
58
+ type: ApiErrorType.Parse,
59
+ message: 'API Parse Error',
60
+ request,
61
+ response,
62
+ details: parseError,
63
+ } satisfies ParseError,
64
+ } satisfies ApiFailure;
65
+ }
66
+
67
+ const { data: result, success, error } = schema.safeParse(parsedBody);
68
+
69
+ if (!success) {
70
+ return {
71
+ ok: false,
72
+ error: {
73
+ type: ApiErrorType.Validation,
74
+ message: 'API Validation Error',
75
+ request,
76
+ response,
77
+ details: error,
78
+ } satisfies ValidationError,
79
+ } satisfies ApiFailure;
80
+ }
81
+
82
+ return {
83
+ ok: true,
84
+ data: result,
85
+ response,
86
+ };
87
+ } catch (details) {
88
+ return {
89
+ ok: false,
90
+ error: {
91
+ type: ApiErrorType.Network,
92
+ message: 'API Network Error',
93
+ request,
94
+ details,
95
+ } satisfies NetworkError,
96
+ } satisfies ApiFailure;
97
+ }
98
+ };
99
+ }
100
+
101
+ export const buildApiClient = (
102
+ {
103
+ baseUrl,
104
+ fetch: fetchFn,
105
+ }: {
106
+ baseUrl: string;
107
+ fetch?: typeof globalThis.fetch;
108
+ } = { baseUrl: '' },
109
+ ) => {
110
+ const maybeFetch = fetchFn ?? (typeof globalThis.fetch !== 'undefined' ? globalThis.fetch : undefined);
111
+
112
+ if (!maybeFetch) {
113
+ throw new Error(
114
+ 'fetch is not available. In Node.js < 18 or environments without global fetch, provide a fetch implementation via the fetch option.',
115
+ );
116
+ }
117
+
118
+ const callApi = createCallApi({ baseUrl, fetch: maybeFetch });
119
+
120
+ const configurationApi = createConfigurationApi(callApi);
121
+ const connectorsApi = createConnectorsApi(callApi);
122
+ const contextsApi = createContextsApi(callApi);
123
+ const filesApi = createFilesApi(callApi);
124
+ const modelProvidersApi = createModelProvidersApi(callApi);
125
+ const providerBuildsApi = createProviderBuildsApi(callApi);
126
+ const providersApi = createProvidersApi(callApi);
127
+ const userFeedbackApi = createUserFeedbackApi(callApi);
128
+ const usersApi = createUsersApi(callApi);
129
+ const variablesApi = createVariablesApi(callApi);
130
+
131
+ return {
132
+ ...configurationApi,
133
+ ...connectorsApi,
134
+ ...contextsApi,
135
+ ...filesApi,
136
+ ...modelProvidersApi,
137
+ ...providerBuildsApi,
138
+ ...providersApi,
139
+ ...userFeedbackApi,
140
+ ...usersApi,
141
+ ...variablesApi,
142
+ };
143
+ };
144
+
145
+ export function unwrapResult<T>(result: ApiResult<T>): T;
146
+ export function unwrapResult<T, Out extends T>(result: ApiResult<T>, schema: z.ZodType<Out>): Out;
147
+ export function unwrapResult<T, Out extends T>(result: ApiResult<T>, schema?: z.ZodType<Out>): T | Out {
148
+ if (result.ok) {
149
+ const { data } = result;
150
+
151
+ return schema ? schema.parse(data) : data;
152
+ }
153
+
154
+ throw new ApiErrorException(result.error);
155
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Copyright 2025 © BeeAI a Series of LF Projects, LLC
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ export * from './types';
7
+ export * from './utils';
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Copyright 2025 © BeeAI a Series of LF Projects, LLC
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ import type { ZodError } from 'zod';
7
+
8
+ import type { ApiRequest, ApiResponse } from '../types';
9
+
10
+ export enum ApiErrorType {
11
+ Http = 'http',
12
+ Network = 'network',
13
+ Parse = 'parse',
14
+ Unknown = 'unknown',
15
+ Validation = 'validation',
16
+ }
17
+
18
+ export interface ApiErrorBase {
19
+ message: string;
20
+ request: ApiRequest;
21
+ }
22
+
23
+ export interface HttpError extends ApiErrorBase {
24
+ type: ApiErrorType.Http;
25
+ response: ApiResponse;
26
+ }
27
+
28
+ export interface NetworkError extends ApiErrorBase {
29
+ type: ApiErrorType.Network;
30
+ details: unknown;
31
+ }
32
+
33
+ export interface ParseError extends ApiErrorBase {
34
+ type: ApiErrorType.Parse;
35
+ response: ApiResponse;
36
+ details: Error;
37
+ }
38
+
39
+ export interface ValidationError extends ApiErrorBase {
40
+ type: ApiErrorType.Validation;
41
+ response: ApiResponse;
42
+ details: ZodError;
43
+ }
44
+
45
+ export type ApiError = HttpError | NetworkError | ParseError | ValidationError;
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Copyright 2025 © BeeAI a Series of LF Projects, LLC
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ import type { HttpError, NetworkError, ParseError, ValidationError } from './types';
7
+ import { type ApiError, ApiErrorType } from './types';
8
+
9
+ export class ApiErrorException extends Error {
10
+ apiError: ApiError;
11
+
12
+ constructor(apiError: ApiError) {
13
+ super(apiError.message);
14
+
15
+ this.apiError = apiError;
16
+ }
17
+ }
18
+
19
+ export function isApiError(error: unknown): error is ApiErrorException {
20
+ return error instanceof ApiErrorException;
21
+ }
22
+
23
+ export function isHttpError(error: unknown, status?: number): error is ApiErrorException & { apiError: HttpError } {
24
+ if (!isApiError(error)) {
25
+ return false;
26
+ }
27
+
28
+ const { apiError } = error;
29
+
30
+ if (apiError.type !== ApiErrorType.Http) {
31
+ return false;
32
+ }
33
+
34
+ if (typeof status === 'number') {
35
+ return apiError.response.status === status;
36
+ }
37
+
38
+ return true;
39
+ }
40
+
41
+ export function isNetworkError(error: unknown): error is ApiErrorException & { apiError: NetworkError } {
42
+ if (!isApiError(error)) {
43
+ return false;
44
+ }
45
+
46
+ return error.apiError.type === ApiErrorType.Network;
47
+ }
48
+
49
+ export function isParseError(error: unknown): error is ApiErrorException & { apiError: ParseError } {
50
+ if (!isApiError(error)) {
51
+ return false;
52
+ }
53
+
54
+ return error.apiError.type === ApiErrorType.Parse;
55
+ }
56
+
57
+ export function isValidationError(error: unknown): error is ApiErrorException & { apiError: ValidationError } {
58
+ if (!isApiError(error)) {
59
+ return false;
60
+ }
61
+
62
+ return error.apiError.type === ApiErrorType.Validation;
63
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Copyright 2025 © BeeAI a Series of LF Projects, LLC
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ export * from './client';
7
+ export * from './errors';
8
+ export * from './types';
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright 2025 © BeeAI a Series of LF Projects, LLC
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ import z from 'zod';
7
+
8
+ export const paginationQuerySchema = z.object({
9
+ limit: z.number().optional(),
10
+ order: z.string().optional(),
11
+ order_by: z.string().optional(),
12
+ page_token: z.string().nullish(),
13
+ });
14
+
15
+ export const paginatedResponseSchema = z.object({
16
+ items: z.array(z.unknown()),
17
+ total_count: z.number(),
18
+ has_more: z.boolean(),
19
+ next_page_token: z.string().nullable(),
20
+ });
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Copyright 2025 © BeeAI a Series of LF Projects, LLC
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ import type z from 'zod';
7
+
8
+ import type { buildApiClient } from './client';
9
+ import type { ApiError } from './errors';
10
+
11
+ export enum ApiMethod {
12
+ Get = 'GET',
13
+ Post = 'POST',
14
+ Put = 'PUT',
15
+ Delete = 'DELETE',
16
+ Patch = 'PATCH',
17
+ }
18
+
19
+ export type ApiQueryParams = Record<string, unknown>;
20
+ export type ApiRequestBody = Record<string, unknown> | FormData;
21
+
22
+ export interface ApiParams<T> {
23
+ method: ApiMethod;
24
+ path: string;
25
+ schema: z.ZodSchema<T>;
26
+ query?: ApiQueryParams;
27
+ body?: ApiRequestBody;
28
+ parseAsStream?: boolean;
29
+ }
30
+
31
+ export interface ApiRequest {
32
+ method: ApiMethod;
33
+ url: string;
34
+ }
35
+
36
+ export interface ApiResponse {
37
+ status: number;
38
+ statusText: string;
39
+ bodyText: ReadableStream<Uint8Array> | string | null;
40
+ }
41
+
42
+ export interface ApiSuccess<T> {
43
+ ok: true;
44
+ data: T;
45
+ response: ApiResponse;
46
+ }
47
+
48
+ export interface ApiFailure {
49
+ ok: false;
50
+ error: ApiError;
51
+ }
52
+
53
+ export type ApiResult<T> = ApiSuccess<T> | ApiFailure;
54
+
55
+ export type CallApi = <T>(params: ApiParams<T>) => Promise<ApiResult<T>>;
56
+
57
+ export type AgentStackClient = ReturnType<typeof buildApiClient>;
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Copyright 2025 © BeeAI a Series of LF Projects, LLC
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ import type { ApiMethod, ApiQueryParams, ApiRequestBody } from './types';
7
+
8
+ export function buildRequestUrl({ baseUrl, path, query }: { baseUrl: string; path: string; query?: ApiQueryParams }) {
9
+ const url = `${baseUrl.replace(/\/+$/, '')}${path}`;
10
+
11
+ if (query) {
12
+ const searchParams = new URLSearchParams();
13
+
14
+ Object.entries(query).forEach(([key, value]) => {
15
+ if (value != null) {
16
+ searchParams.append(key, String(value));
17
+ }
18
+ });
19
+
20
+ const queryString = searchParams.toString();
21
+
22
+ if (queryString) {
23
+ return `${url}?${queryString}`;
24
+ }
25
+ }
26
+
27
+ return url;
28
+ }
29
+
30
+ export function buildRequestInit({ method, body }: { method: ApiMethod; body?: ApiRequestBody }) {
31
+ const headers = new Headers();
32
+
33
+ let requestBody: FormData | string | undefined;
34
+
35
+ if (body) {
36
+ if (body instanceof FormData) {
37
+ requestBody = body;
38
+ } else {
39
+ headers.set('Content-Type', 'application/json');
40
+
41
+ requestBody = JSON.stringify(body);
42
+ }
43
+ }
44
+
45
+ return {
46
+ method,
47
+ headers,
48
+ body: requestBody,
49
+ };
50
+ }
51
+
52
+ export async function safeReadText(response: Response) {
53
+ try {
54
+ return await response.text();
55
+ } catch {
56
+ return null;
57
+ }
58
+ }
59
+
60
+ export function parseBodyText(
61
+ bodyText: ReadableStream<Uint8Array> | string | null,
62
+ headers: Headers,
63
+ ): {
64
+ data: unknown;
65
+ error?: Error;
66
+ } {
67
+ const isStreamResponse = bodyText instanceof ReadableStream;
68
+
69
+ if (isStreamResponse) {
70
+ return {
71
+ data: bodyText,
72
+ };
73
+ }
74
+
75
+ if (bodyText == null || bodyText.trim() === '') {
76
+ return {
77
+ data: null,
78
+ };
79
+ }
80
+
81
+ const contentType = headers.get('content-type') ?? '';
82
+ const isJsonResponse = contentType.includes('application/json');
83
+
84
+ if (isJsonResponse) {
85
+ try {
86
+ return {
87
+ data: JSON.parse(bodyText),
88
+ };
89
+ } catch (error) {
90
+ return {
91
+ data: null,
92
+ error: error instanceof Error ? error : new Error('Failed to parse body text.'),
93
+ };
94
+ }
95
+ }
96
+
97
+ return {
98
+ data: bodyText,
99
+ };
100
+ }