@vertesia/client 0.80.0-dev.20251121 → 0.80.1

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 (250) hide show
  1. package/README.md +110 -0
  2. package/package.json +13 -4
  3. package/src/InteractionsApi.ts +14 -1
  4. package/src/SkillsApi.ts +46 -0
  5. package/src/client.test.ts +3 -0
  6. package/src/client.ts +11 -7
  7. package/src/store/FilesApi.ts +93 -0
  8. package/src/store/ObjectsApi.ts +1 -0
  9. package/src/store/WorkersApi.ts +17 -0
  10. package/src/store/client.ts +2 -2
  11. package/src/store/index.ts +1 -0
  12. package/lib/cjs/AccountApi.js +0 -85
  13. package/lib/cjs/AccountApi.js.map +0 -1
  14. package/lib/cjs/AccountsApi.js +0 -16
  15. package/lib/cjs/AccountsApi.js.map +0 -1
  16. package/lib/cjs/AnalyticsApi.js +0 -13
  17. package/lib/cjs/AnalyticsApi.js.map +0 -1
  18. package/lib/cjs/ApiKeysApi.js +0 -63
  19. package/lib/cjs/ApiKeysApi.js.map +0 -1
  20. package/lib/cjs/AppsApi.js +0 -119
  21. package/lib/cjs/AppsApi.js.map +0 -1
  22. package/lib/cjs/CommandsApi.js +0 -19
  23. package/lib/cjs/CommandsApi.js.map +0 -1
  24. package/lib/cjs/EnvironmentsApi.js +0 -58
  25. package/lib/cjs/EnvironmentsApi.js.map +0 -1
  26. package/lib/cjs/GroupsApi.js +0 -78
  27. package/lib/cjs/GroupsApi.js.map +0 -1
  28. package/lib/cjs/IamApi.js +0 -53
  29. package/lib/cjs/IamApi.js.map +0 -1
  30. package/lib/cjs/InteractionBase.js +0 -44
  31. package/lib/cjs/InteractionBase.js.map +0 -1
  32. package/lib/cjs/InteractionCatalogApi.js +0 -64
  33. package/lib/cjs/InteractionCatalogApi.js.map +0 -1
  34. package/lib/cjs/InteractionOutput.js +0 -300
  35. package/lib/cjs/InteractionOutput.js.map +0 -1
  36. package/lib/cjs/InteractionResult.example.js +0 -57
  37. package/lib/cjs/InteractionResult.example.js.map +0 -1
  38. package/lib/cjs/InteractionsApi.js +0 -231
  39. package/lib/cjs/InteractionsApi.js.map +0 -1
  40. package/lib/cjs/ProjectsApi.js +0 -53
  41. package/lib/cjs/ProjectsApi.js.map +0 -1
  42. package/lib/cjs/PromptsApi.js +0 -133
  43. package/lib/cjs/PromptsApi.js.map +0 -1
  44. package/lib/cjs/RefsApi.js +0 -14
  45. package/lib/cjs/RefsApi.js.map +0 -1
  46. package/lib/cjs/RunsApi.js +0 -113
  47. package/lib/cjs/RunsApi.js.map +0 -1
  48. package/lib/cjs/StreamSource.js +0 -17
  49. package/lib/cjs/StreamSource.js.map +0 -1
  50. package/lib/cjs/TrainingApi.js +0 -54
  51. package/lib/cjs/TrainingApi.js.map +0 -1
  52. package/lib/cjs/UsersApi.js +0 -13
  53. package/lib/cjs/UsersApi.js.map +0 -1
  54. package/lib/cjs/client.js +0 -346
  55. package/lib/cjs/client.js.map +0 -1
  56. package/lib/cjs/execute.js +0 -158
  57. package/lib/cjs/execute.js.map +0 -1
  58. package/lib/cjs/index.js +0 -22
  59. package/lib/cjs/index.js.map +0 -1
  60. package/lib/cjs/nodejs/NodeStreamSource.js +0 -45
  61. package/lib/cjs/nodejs/NodeStreamSource.js.map +0 -1
  62. package/lib/cjs/nodejs/index.js +0 -18
  63. package/lib/cjs/nodejs/index.js.map +0 -1
  64. package/lib/cjs/package.json +0 -3
  65. package/lib/cjs/store/AgentsApi.js +0 -16
  66. package/lib/cjs/store/AgentsApi.js.map +0 -1
  67. package/lib/cjs/store/AnalyzeDocApi.js +0 -56
  68. package/lib/cjs/store/AnalyzeDocApi.js.map +0 -1
  69. package/lib/cjs/store/CollectionsApi.js +0 -131
  70. package/lib/cjs/store/CollectionsApi.js.map +0 -1
  71. package/lib/cjs/store/CommandsApi.js +0 -17
  72. package/lib/cjs/store/CommandsApi.js.map +0 -1
  73. package/lib/cjs/store/EmbeddingsApi.js +0 -29
  74. package/lib/cjs/store/EmbeddingsApi.js.map +0 -1
  75. package/lib/cjs/store/FilesApi.js +0 -148
  76. package/lib/cjs/store/FilesApi.js.map +0 -1
  77. package/lib/cjs/store/ObjectsApi.js +0 -282
  78. package/lib/cjs/store/ObjectsApi.js.map +0 -1
  79. package/lib/cjs/store/TypesApi.js +0 -57
  80. package/lib/cjs/store/TypesApi.js.map +0 -1
  81. package/lib/cjs/store/WorkflowsApi.js +0 -414
  82. package/lib/cjs/store/WorkflowsApi.js.map +0 -1
  83. package/lib/cjs/store/client.js +0 -71
  84. package/lib/cjs/store/client.js.map +0 -1
  85. package/lib/cjs/store/errors.js +0 -11
  86. package/lib/cjs/store/errors.js.map +0 -1
  87. package/lib/cjs/store/index.js +0 -22
  88. package/lib/cjs/store/index.js.map +0 -1
  89. package/lib/cjs/store/version.js +0 -6
  90. package/lib/cjs/store/version.js.map +0 -1
  91. package/lib/esm/AccountApi.js +0 -82
  92. package/lib/esm/AccountApi.js.map +0 -1
  93. package/lib/esm/AccountsApi.js +0 -13
  94. package/lib/esm/AccountsApi.js.map +0 -1
  95. package/lib/esm/AnalyticsApi.js +0 -10
  96. package/lib/esm/AnalyticsApi.js.map +0 -1
  97. package/lib/esm/ApiKeysApi.js +0 -59
  98. package/lib/esm/ApiKeysApi.js.map +0 -1
  99. package/lib/esm/AppsApi.js +0 -116
  100. package/lib/esm/AppsApi.js.map +0 -1
  101. package/lib/esm/CommandsApi.js +0 -16
  102. package/lib/esm/CommandsApi.js.map +0 -1
  103. package/lib/esm/EnvironmentsApi.js +0 -55
  104. package/lib/esm/EnvironmentsApi.js.map +0 -1
  105. package/lib/esm/GroupsApi.js +0 -74
  106. package/lib/esm/GroupsApi.js.map +0 -1
  107. package/lib/esm/IamApi.js +0 -47
  108. package/lib/esm/IamApi.js.map +0 -1
  109. package/lib/esm/InteractionBase.js +0 -40
  110. package/lib/esm/InteractionBase.js.map +0 -1
  111. package/lib/esm/InteractionCatalogApi.js +0 -60
  112. package/lib/esm/InteractionCatalogApi.js.map +0 -1
  113. package/lib/esm/InteractionOutput.js +0 -293
  114. package/lib/esm/InteractionOutput.js.map +0 -1
  115. package/lib/esm/InteractionResult.example.js +0 -55
  116. package/lib/esm/InteractionResult.example.js.map +0 -1
  117. package/lib/esm/InteractionsApi.js +0 -228
  118. package/lib/esm/InteractionsApi.js.map +0 -1
  119. package/lib/esm/ProjectsApi.js +0 -50
  120. package/lib/esm/ProjectsApi.js.map +0 -1
  121. package/lib/esm/PromptsApi.js +0 -130
  122. package/lib/esm/PromptsApi.js.map +0 -1
  123. package/lib/esm/RefsApi.js +0 -10
  124. package/lib/esm/RefsApi.js.map +0 -1
  125. package/lib/esm/RunsApi.js +0 -109
  126. package/lib/esm/RunsApi.js.map +0 -1
  127. package/lib/esm/StreamSource.js +0 -13
  128. package/lib/esm/StreamSource.js.map +0 -1
  129. package/lib/esm/TrainingApi.js +0 -51
  130. package/lib/esm/TrainingApi.js.map +0 -1
  131. package/lib/esm/UsersApi.js +0 -10
  132. package/lib/esm/UsersApi.js.map +0 -1
  133. package/lib/esm/client.js +0 -337
  134. package/lib/esm/client.js.map +0 -1
  135. package/lib/esm/execute.js +0 -118
  136. package/lib/esm/execute.js.map +0 -1
  137. package/lib/esm/index.js +0 -6
  138. package/lib/esm/index.js.map +0 -1
  139. package/lib/esm/nodejs/NodeStreamSource.js +0 -41
  140. package/lib/esm/nodejs/NodeStreamSource.js.map +0 -1
  141. package/lib/esm/nodejs/index.js +0 -2
  142. package/lib/esm/nodejs/index.js.map +0 -1
  143. package/lib/esm/store/AgentsApi.js +0 -12
  144. package/lib/esm/store/AgentsApi.js.map +0 -1
  145. package/lib/esm/store/AnalyzeDocApi.js +0 -52
  146. package/lib/esm/store/AnalyzeDocApi.js.map +0 -1
  147. package/lib/esm/store/CollectionsApi.js +0 -127
  148. package/lib/esm/store/CollectionsApi.js.map +0 -1
  149. package/lib/esm/store/CommandsApi.js +0 -13
  150. package/lib/esm/store/CommandsApi.js.map +0 -1
  151. package/lib/esm/store/EmbeddingsApi.js +0 -25
  152. package/lib/esm/store/EmbeddingsApi.js.map +0 -1
  153. package/lib/esm/store/FilesApi.js +0 -143
  154. package/lib/esm/store/FilesApi.js.map +0 -1
  155. package/lib/esm/store/ObjectsApi.js +0 -278
  156. package/lib/esm/store/ObjectsApi.js.map +0 -1
  157. package/lib/esm/store/TypesApi.js +0 -53
  158. package/lib/esm/store/TypesApi.js.map +0 -1
  159. package/lib/esm/store/WorkflowsApi.js +0 -408
  160. package/lib/esm/store/WorkflowsApi.js.map +0 -1
  161. package/lib/esm/store/client.js +0 -67
  162. package/lib/esm/store/client.js.map +0 -1
  163. package/lib/esm/store/errors.js +0 -7
  164. package/lib/esm/store/errors.js.map +0 -1
  165. package/lib/esm/store/index.js +0 -6
  166. package/lib/esm/store/index.js.map +0 -1
  167. package/lib/esm/store/version.js +0 -3
  168. package/lib/esm/store/version.js.map +0 -1
  169. package/lib/tsconfig.tsbuildinfo +0 -1
  170. package/lib/types/AccountApi.d.ts +0 -59
  171. package/lib/types/AccountApi.d.ts.map +0 -1
  172. package/lib/types/AccountsApi.d.ts +0 -7
  173. package/lib/types/AccountsApi.d.ts.map +0 -1
  174. package/lib/types/AnalyticsApi.d.ts +0 -6
  175. package/lib/types/AnalyticsApi.d.ts.map +0 -1
  176. package/lib/types/ApiKeysApi.d.ts +0 -42
  177. package/lib/types/ApiKeysApi.d.ts.map +0 -1
  178. package/lib/types/AppsApi.d.ts +0 -65
  179. package/lib/types/AppsApi.d.ts.map +0 -1
  180. package/lib/types/CommandsApi.d.ts +0 -10
  181. package/lib/types/CommandsApi.d.ts.map +0 -1
  182. package/lib/types/EnvironmentsApi.d.ts +0 -30
  183. package/lib/types/EnvironmentsApi.d.ts.map +0 -1
  184. package/lib/types/GroupsApi.d.ts +0 -65
  185. package/lib/types/GroupsApi.d.ts.map +0 -1
  186. package/lib/types/IamApi.d.ts +0 -41
  187. package/lib/types/IamApi.d.ts.map +0 -1
  188. package/lib/types/InteractionBase.d.ts +0 -22
  189. package/lib/types/InteractionBase.d.ts.map +0 -1
  190. package/lib/types/InteractionCatalogApi.d.ts +0 -36
  191. package/lib/types/InteractionCatalogApi.d.ts.map +0 -1
  192. package/lib/types/InteractionOutput.d.ts +0 -174
  193. package/lib/types/InteractionOutput.d.ts.map +0 -1
  194. package/lib/types/InteractionResult.example.d.ts +0 -6
  195. package/lib/types/InteractionResult.example.d.ts.map +0 -1
  196. package/lib/types/InteractionsApi.d.ts +0 -159
  197. package/lib/types/InteractionsApi.d.ts.map +0 -1
  198. package/lib/types/ProjectsApi.d.ts +0 -18
  199. package/lib/types/ProjectsApi.d.ts.map +0 -1
  200. package/lib/types/PromptsApi.d.ts +0 -106
  201. package/lib/types/PromptsApi.d.ts.map +0 -1
  202. package/lib/types/RefsApi.d.ts +0 -6
  203. package/lib/types/RefsApi.d.ts.map +0 -1
  204. package/lib/types/RunsApi.d.ts +0 -79
  205. package/lib/types/RunsApi.d.ts.map +0 -1
  206. package/lib/types/StreamSource.d.ts +0 -7
  207. package/lib/types/StreamSource.d.ts.map +0 -1
  208. package/lib/types/TrainingApi.d.ts +0 -27
  209. package/lib/types/TrainingApi.d.ts.map +0 -1
  210. package/lib/types/UsersApi.d.ts +0 -6
  211. package/lib/types/UsersApi.d.ts.map +0 -1
  212. package/lib/types/client.d.ts +0 -123
  213. package/lib/types/client.d.ts.map +0 -1
  214. package/lib/types/execute.d.ts +0 -37
  215. package/lib/types/execute.d.ts.map +0 -1
  216. package/lib/types/index.d.ts +0 -10
  217. package/lib/types/index.d.ts.map +0 -1
  218. package/lib/types/nodejs/NodeStreamSource.d.ts +0 -9
  219. package/lib/types/nodejs/NodeStreamSource.d.ts.map +0 -1
  220. package/lib/types/nodejs/index.d.ts +0 -1
  221. package/lib/types/nodejs/index.d.ts.map +0 -1
  222. package/lib/types/store/AgentsApi.d.ts +0 -6
  223. package/lib/types/store/AgentsApi.d.ts.map +0 -1
  224. package/lib/types/store/AnalyzeDocApi.d.ts +0 -17
  225. package/lib/types/store/AnalyzeDocApi.d.ts.map +0 -1
  226. package/lib/types/store/CollectionsApi.d.ts +0 -82
  227. package/lib/types/store/CollectionsApi.d.ts.map +0 -1
  228. package/lib/types/store/CommandsApi.d.ts +0 -10
  229. package/lib/types/store/CommandsApi.d.ts.map +0 -1
  230. package/lib/types/store/EmbeddingsApi.d.ts +0 -12
  231. package/lib/types/store/EmbeddingsApi.d.ts.map +0 -1
  232. package/lib/types/store/FilesApi.d.ts +0 -48
  233. package/lib/types/store/FilesApi.d.ts.map +0 -1
  234. package/lib/types/store/ObjectsApi.d.ts +0 -117
  235. package/lib/types/store/ObjectsApi.d.ts.map +0 -1
  236. package/lib/types/store/TypesApi.d.ts +0 -23
  237. package/lib/types/store/TypesApi.d.ts.map +0 -1
  238. package/lib/types/store/WorkflowsApi.d.ts +0 -62
  239. package/lib/types/store/WorkflowsApi.d.ts.map +0 -1
  240. package/lib/types/store/client.d.ts +0 -35
  241. package/lib/types/store/client.d.ts.map +0 -1
  242. package/lib/types/store/errors.d.ts +0 -4
  243. package/lib/types/store/errors.d.ts.map +0 -1
  244. package/lib/types/store/index.d.ts +0 -5
  245. package/lib/types/store/index.d.ts.map +0 -1
  246. package/lib/types/store/version.d.ts +0 -2
  247. package/lib/types/store/version.d.ts.map +0 -1
  248. package/lib/vertesia-client.js +0 -2
  249. package/lib/vertesia-client.js.map +0 -1
  250. package/src/store/AgentsApi.ts +0 -17
@@ -1,293 +0,0 @@
1
- /**
2
- * Symbol used to mark InteractionOutputArray instances.
3
- * This allows us to detect if a CompletionResult[] has already been wrapped.
4
- */
5
- export const IS_INTERACTION_OUTPUT = Symbol('InteractionOutput');
6
- export function enhanceInteractionExecutionResult(r) {
7
- r.result = InteractionOutput.from(r.result);
8
- return r;
9
- }
10
- export function enhanceExecutionRun(r) {
11
- r.result = InteractionOutput.from(r.result);
12
- return r;
13
- }
14
- /**
15
- * A convenient wrapper around CompletionResult[] that provides ergonomic accessors
16
- * for different result types (text, JSON/objects, images) from interaction executions.
17
- *
18
- * Use the static from() method to create a proxied array that acts as both
19
- * an array and has these convenience methods.
20
- *
21
- * @template T - The expected type of JSON/object results. Defaults to any.
22
- *
23
- * @example
24
- * ```typescript
25
- * // Recommended: Using the static from() method
26
- * const output = InteractionOutput.from<MyResponse>(run.result);
27
- * output[0]; // CompletionResult (array access)
28
- * output.length; // number (array property)
29
- * const obj = output.object(); // MyResponse (custom method)
30
- * const text = output.text(); // string (custom getter)
31
- *
32
- * // Alternative: Using the class directly (less common)
33
- * const output = new InteractionOutput<MyResponse>(run.result);
34
- * const obj = output.object(); // Returns MyResponse
35
- * const objs = output.objects(); // Returns MyResponse[]
36
- *
37
- * // Override type for specific objects
38
- * interface OtherType { title: string; }
39
- * ```
40
- */
41
- export class InteractionOutput {
42
- results;
43
- /**
44
- * The raw completion results array.
45
- * Access this when you need to work with the underlying CompletionResult[] directly.
46
- */
47
- constructor(results) {
48
- this.results = results;
49
- }
50
- /**
51
- * Create an interaction output that acts as both an array and has convenience methods.
52
- * This is the recommended way to work with interaction execution results.
53
- *
54
- * @template T - The expected type of JSON/object results. Defaults to any.
55
- * @param results - The raw CompletionResult array from an interaction execution
56
- * @returns A proxied array with convenience methods
57
- *
58
- * @example
59
- * ```typescript
60
- * interface MyResponse { name: string; age: number; }
61
- * const output = InteractionOutput.from<MyResponse>(run.result);
62
- *
63
- * // Array access
64
- * output[0]; // CompletionResult
65
- * output.length; // number
66
- *
67
- * // Convenience methods
68
- * const obj = output.object(); // MyResponse
69
- * const text = output.text(); // string
70
- * ```
71
- */
72
- static from(results) {
73
- if (!results) {
74
- return createInteractionOutput([]);
75
- }
76
- // Check if already wrapped using the symbol marker
77
- if (results[IS_INTERACTION_OUTPUT]) {
78
- return results;
79
- }
80
- if (Array.isArray(results)) {
81
- return createInteractionOutput(results);
82
- }
83
- else if (typeof results === 'object') {
84
- return createInteractionOutput([{ type: 'json', value: results }]);
85
- }
86
- else {
87
- return createInteractionOutput([{ type: 'text', value: String(results) }]);
88
- }
89
- }
90
- static isInteractionOutputArray(obj) {
91
- return obj && obj[IS_INTERACTION_OUTPUT] === true;
92
- }
93
- get isEmpty() {
94
- return this.results.length === 0;
95
- }
96
- hasObject() {
97
- return this.results.some(r => r.type === 'json');
98
- }
99
- hasText() {
100
- return this.results.some(r => r.type === 'text');
101
- }
102
- hasImage() {
103
- return this.results.some(r => r.type === 'image');
104
- }
105
- /**
106
- * Get the concatenated text from all text results.
107
- * Returns an empty string if no text results exist.
108
- */
109
- text(delimiter = '\n') {
110
- return this.results
111
- .filter(r => r.type === 'text')
112
- .map(r => r.value)
113
- .join(delimiter);
114
- }
115
- /**
116
- * Get an array of all text values from text results.
117
- */
118
- texts() {
119
- return this.results
120
- .filter(r => r.type === 'text')
121
- .map(r => r.value);
122
- }
123
- /**
124
- * Get the first JSON result as a parsed object.
125
- * If no JSON result exists, attempts to parse the concatenated text as JSON.
126
- * @returns The first JSON result typed as T (the class generic type)
127
- * @throws Error if no JSON result found and text cannot be parsed as JSON
128
- */
129
- object() {
130
- const jsonResult = this.results.find(r => r.type === 'json');
131
- if (jsonResult) {
132
- return jsonResult.value;
133
- }
134
- // Fallback: try to parse the other text parts as JSON
135
- return parseCompletionResultAsJson(this.results);
136
- }
137
- /**
138
- * Get all JSON results as parsed objects.
139
- * @returns An array of all JSON results typed as T[] (the class generic type)
140
- */
141
- objects() {
142
- return this.results
143
- .filter(r => r.type === 'json')
144
- .map(r => r.value);
145
- }
146
- /**
147
- * Get a specific JSON result by index as a parsed object.
148
- * @template U - The type of the object at this index. Defaults to T (the class generic).
149
- * @param index - The zero-based index of the JSON result
150
- * @returns The JSON result at the specified index typed as U
151
- * @throws Error if the index is out of bounds
152
- */
153
- objectAt(index) {
154
- let i = 0;
155
- for (const result of this.results) {
156
- if (result.type === 'json') {
157
- if (i === index) {
158
- return result.value;
159
- }
160
- i++;
161
- }
162
- }
163
- throw new Error(`Object at index ${index} not found`);
164
- }
165
- /**
166
- * Get the first image result (base64 data URL or URL).
167
- * @throws Error if no image result exists
168
- */
169
- image() {
170
- const imageResult = this.results.find(r => r.type === 'image');
171
- if (!imageResult) {
172
- throw new Error('No image result found');
173
- }
174
- return imageResult.value;
175
- }
176
- /**
177
- * Get an array of all image values (base64 data URLs or URLs).
178
- */
179
- images() {
180
- return this.results
181
- .filter(r => r.type === 'image')
182
- .map(r => r.value);
183
- }
184
- /**
185
- * Convert all results to a string representation.
186
- * Text and image results are used as-is, JSON results are stringified with the specified indent.
187
- * All parts are joined using the specified separator.
188
- *
189
- * @param separator - The separator to use between parts (default: '\n')
190
- * @param indent - The indentation to use for JSON.stringify (default: 0 = no formatting)
191
- * @returns A string representation of all results
192
- *
193
- * @example
194
- * ```typescript
195
- * const output = InteractionOutput.from(results);
196
- * output.stringify(); // Each part on a new line, compact JSON
197
- * output.stringify('\n\n', 2); // Double newlines between parts, formatted JSON
198
- * output.stringify(' '); // Space-separated, compact JSON
199
- * ```
200
- */
201
- stringify(separator = '\n', indent = 2) {
202
- return this.results
203
- .map(r => {
204
- switch (r.type) {
205
- case 'json':
206
- return JSON.stringify(r.value, null, indent);
207
- default:
208
- return String(r.value);
209
- }
210
- })
211
- .join(separator);
212
- }
213
- /**
214
- * Convert to string representation (concatenated text).
215
- * Useful for template literals or string coercion.
216
- */
217
- toString() {
218
- return this.text();
219
- }
220
- /**
221
- * Convert to JSON representation.
222
- * Attempts to return the first JSON object, falls back to concatenated text.
223
- */
224
- toJSON() {
225
- return this.results;
226
- }
227
- }
228
- /**
229
- * Creates a proxied array that acts as both a CompletionResult[] and has InteractionOutput convenience methods.
230
- * Note: It's recommended to use InteractionOutput.from() instead of calling this function directly.
231
- *
232
- * @template T - The expected type of JSON/object results. Defaults to any.
233
- * @param results - The raw CompletionResult array from the interaction execution
234
- * @returns A proxy that behaves as both an array and has convenience methods
235
- *
236
- * @example
237
- * ```typescript
238
- * interface MyResponse { name: string; age: number; }
239
- * const output = createInteractionOutput<MyResponse>(run.result);
240
- *
241
- * // Array access
242
- * output[0]; // CompletionResult
243
- * output.length; // number
244
- * output.map(r => r.type) // string[]
245
- *
246
- * // Convenience methods
247
- * const obj = output.object(); // MyResponse
248
- * const text = output.text(); // string
249
- * const img = output.image(); // string
250
- * ```
251
- */
252
- export function createInteractionOutput(results) {
253
- const wrapper = new InteractionOutput(results);
254
- return new Proxy(results, {
255
- get(target, prop, receiver) {
256
- // Return the marker symbol to identify wrapped arrays
257
- if (prop === IS_INTERACTION_OUTPUT) {
258
- return true;
259
- }
260
- // Check if the wrapper has this property/method
261
- if (prop in wrapper) {
262
- const value = wrapper[prop];
263
- // If it's a function, bind it to the wrapper so 'this' works correctly
264
- if (typeof value === 'function') {
265
- return value.bind(wrapper);
266
- }
267
- // For getters and regular properties, just return the value
268
- return value;
269
- }
270
- // Otherwise delegate to the array
271
- return Reflect.get(target, prop, receiver);
272
- }
273
- });
274
- }
275
- function parseCompletionResultAsJson(data) {
276
- let lastError;
277
- for (const part of data) {
278
- if (part.type === "text") {
279
- const text = part.value.trim();
280
- try {
281
- return JSON.parse(text);
282
- }
283
- catch (error) {
284
- lastError = error;
285
- }
286
- }
287
- }
288
- if (!lastError) {
289
- lastError = new Error("No JSON result found and no text available to parse");
290
- }
291
- throw lastError;
292
- }
293
- //# sourceMappingURL=InteractionOutput.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"InteractionOutput.js","sourceRoot":"","sources":["../../src/InteractionOutput.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC;AAEjE,MAAM,UAAU,iCAAiC,CAA+B,CAAsC;IACjH,CAAS,CAAC,MAAM,GAAG,iBAAiB,CAAC,IAAI,CAAU,CAAC,CAAC,MAAM,CAAC,CAAC;IAC9D,OAAO,CAAyD,CAAC;AACrE,CAAC;AAED,MAAM,UAAU,mBAAmB,CAA+B,CAAwB;IACrF,CAAS,CAAC,MAAM,GAAG,iBAAiB,CAAC,IAAI,CAAU,CAAC,CAAC,MA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I,EAAE,CAAC;QACtB,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YACvB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;YAC/B,IAAI,CAAC;gBACD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC5B,CAAC;YAAC,OAAO,KAAU,EAAE,CAAC;gBAClB,SAAS,GAAG,KAAK,CAAC;YACtB,CAAC;QACL,CAAC;IACL,CAAC;IACD,IAAI,CAAC,SAAS,EAAE,CAAC;QACb,SAAS,GAAG,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACjF,CAAC;IACD,MAAM,SAAS,CAAC;AACpB,CAAC"}
@@ -1,55 +0,0 @@
1
- /**
2
- * Example usage of InteractionOutput
3
- * This file demonstrates the Proxy-based approach where the result acts as both
4
- * an array and has convenience methods.
5
- */
6
- import { InteractionOutput } from './InteractionOutput.js';
7
- // Sample data
8
- const sampleResults = [
9
- { type: 'text', value: 'Hello, ' },
10
- { type: 'text', value: 'World!' },
11
- { type: 'json', value: { name: 'Alice', age: 30 } },
12
- { type: 'json', value: { title: 'Engineer', level: 'Senior' } },
13
- { type: 'image', value: 'data:image/png;base64,iVBORw0K...' }
14
- ];
15
- // Example 1: Using InteractionOutput.from() (Proxy approach - RECOMMENDED)
16
- console.log('=== Example 1: Proxy Approach ===');
17
- const output = InteractionOutput.from(sampleResults);
18
- // Works as an array
19
- console.log('Array length:', output.length); // 5
20
- console.log('First item:', output[0]); // { type: 'text', value: 'Hello, ' }
21
- console.log('Types:', output.map(r => r.type)); // ['text', 'text', 'json', 'json', 'image']
22
- // Has convenience methods
23
- console.log('All text:', output.text); // 'Hello, World!'
24
- console.log('First object:', output.object()); // { name: 'Alice', age: 30 } (typed as Person)
25
- console.log('All objects:', output.objects()); // [{ name: 'Alice', age: 30 }, { title: 'Engineer', level: 'Senior' }]
26
- console.log('First image:', output.image); // 'data:image/png;base64,iVBORw0K...'
27
- console.log('Second object:', output.objectAt(1)); // { title: 'Engineer', level: 'Senior' } (typed as Job)
28
- // Example 2: Using InteractionOutput class directly
29
- console.log('\n=== Example 2: Class Approach ===');
30
- const wrapper = new InteractionOutput(sampleResults);
31
- // Access through wrapper properties (no array access)
32
- console.log('All text:', wrapper.text);
33
- console.log('Raw results:', wrapper.results); // Original array
34
- console.log('First object:', wrapper.object());
35
- // Example 3: Type safety demonstration
36
- console.log('\n=== Example 3: Type Safety ===');
37
- const contractResults = [
38
- { type: 'json', value: { title: 'Sales Agreement', parties: ['Alice', 'Bob'] } }
39
- ];
40
- const contractOutput = InteractionOutput.from(contractResults);
41
- const contract = contractOutput.object(); // TypeScript knows this is Contract
42
- console.log('Contract title:', contract.title);
43
- console.log('Parties:', contract.parties.join(', '));
44
- // Example 4: Mixed content
45
- console.log('\n=== Example 4: Mixed Content ===');
46
- const mixedResults = [
47
- { type: 'text', value: 'Analysis complete. Results: ' },
48
- { type: 'json', value: { score: 0.95, confidence: 'high' } },
49
- { type: 'text', value: '\nThank you!' }
50
- ];
51
- const mixed = InteractionOutput.from(mixedResults);
52
- console.log('Full text:', mixed.text); // 'Analysis complete. Results: \nThank you!'
53
- console.log('Analysis:', mixed.object()); // { score: 0.95, confidence: 'high' }
54
- console.log('Text parts:', mixed.texts); // ['Analysis complete. Results: ', '\nThank you!']
55
- //# sourceMappingURL=InteractionResult.example.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"InteractionResult.example.js","sourceRoot":"","sources":["../../src/InteractionResult.example.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,cAAc;AACd,MAAM,aAAa,GAAuB;IACtC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE;IAClC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE;IACjC,EAAE,IAAI,EAAE,MAAM,EAAE,KAA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AAE,cAAc,EAAE;CAC1C,CAAC;AAEF,MAAM,KAAK,GAAG,iBAAiB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;AACnD,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAiB,6CAA6C;AACpG,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAc,sCAAsC;AAC7F,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAe,mDAAmD"}
@@ -1,228 +0,0 @@
1
- import { ApiTopic, ServerError } from "@vertesia/api-fetch-client";
2
- import { checkRateLimit, executeInteraction, executeInteractionAsync, executeInteractionByName } from "./execute.js";
3
- import { InteractionCatalogApi } from "./InteractionCatalogApi.js";
4
- import { enhanceExecutionRun, enhanceInteractionExecutionResult } from "./InteractionOutput.js";
5
- export default class InteractionsApi extends ApiTopic {
6
- catalog;
7
- constructor(parent) {
8
- super(parent, "/api/v1/interactions");
9
- this.catalog = new InteractionCatalogApi(parent);
10
- }
11
- /**
12
- * Get the list of all interactions in the current project
13
- * @returns InteractionRef[]
14
- **/
15
- list(payload = {}) {
16
- const query = payload.query || {};
17
- return this.get("/", {
18
- query: {
19
- ...query
20
- }
21
- });
22
- }
23
- /**
24
- * Find interactions given a mongo match query.
25
- * You can also specify if prompts schemas are included in the result
26
- */
27
- listEndpoints(payload) {
28
- return this.post("/endpoints", {
29
- payload
30
- });
31
- }
32
- /**
33
- * List all interaction versions in the project having the given endpoint name.
34
- * This is useful to list orphaned versions
35
- * @param name
36
- */
37
- listVersionsByName(name) {
38
- return this.get(`/versions/${name}`);
39
- }
40
- /**
41
- * Get the list of all interactions facets
42
- * @param payload query payload to filter facet search
43
- * @returns ComputeInteractionFacetsResponse[]
44
- **/
45
- computeFacets(query) {
46
- return this.post("/facets", {
47
- payload: query
48
- });
49
- }
50
- /**
51
- * List interaction names in the current project
52
- * @returns
53
- */
54
- listNames() {
55
- return this.get('/names');
56
- }
57
- /**
58
- * Get the list of all interactions in the current project. Schemas will be returned too.
59
- * @returns InteractionRefWithSchema[]
60
- **/
61
- export(payload) {
62
- return this.post('/export', { payload });
63
- }
64
- /**
65
- * Create a new interaction
66
- * @param payload InteractionCreatePayload
67
- * @returns Interaction
68
- * @throws ApiError
69
- * @throws 400 if payload is invalid
70
- * @throws 500 if interaction creation fails
71
- **/
72
- create(payload) {
73
- return this.post('/', {
74
- payload
75
- });
76
- }
77
- /**
78
- * Retrieve an existing interaction definition
79
- * @param id of the interaction to retrieve
80
- * @returns Interaction
81
- **/
82
- retrieve(id) {
83
- return this.get(`/${id}`);
84
- }
85
- /**
86
- * Update an existing interaction definition
87
- * @param id of the interaction to update
88
- * @param payload InteractionUpdatePayload
89
- * @returns Interaction
90
- * @throws ApiError
91
- * @throws 400 if payload is invalid
92
- * @throws 500 if interaction update fails
93
- * @throws 404 if interaction not found
94
- **/
95
- update(id, payload) {
96
- return this.put(`/${id}`, {
97
- payload
98
- });
99
- }
100
- /**
101
- * Execute an interaction and return a promise which will be resolved with the executed run when
102
- * the run completes or fails.
103
- * If the onChunk callback is passed then the streaming of the result is enabled.
104
- * The onChunk callback with be called with the next chunk of the result as soon as it is available.
105
- * When all chunks are received the function will return the resolved promise
106
- * @param id of the interaction to execute
107
- * @param payload InteractionExecutionPayload
108
- * @param onChunk callback to be called when the next chunk of the response is available
109
- * @returns Promise<ExecutionRun>
110
- * @throws ApiError
111
- * @throws 404 if interaction not found
112
- * @throws 400 if payload is invalid
113
- * @throws 500 if interaction execution fails
114
- * @throws 500 if interaction execution times out
115
- **/
116
- async execute(id, payload = {}, onChunk) {
117
- const r = await executeInteraction(this.client, id, payload, onChunk).catch(err => {
118
- if (err instanceof ServerError && err.payload?.id) {
119
- throw err.updateDetails({ run_id: err.payload.id });
120
- }
121
- else {
122
- throw err;
123
- }
124
- });
125
- return enhanceInteractionExecutionResult(r);
126
- }
127
- /**
128
- * Same as execute but uses the interaction name selector instead of the id.
129
- *
130
- * A name selector is the interaction endpoint name suffixed with an optional tag or version which is starting with a `@` character.
131
- * The special `draft` tag is used to select the draft version of the interaction. If no tag or version is specified then the latest version is selected.
132
- * Examples of selectors:
133
- * - `ReviewContract` - select the latest version of the ReviewContract interaction
134
- * - `ReviewContract@1` - select the version 1 of the ReviewContract interaction
135
- * - `ReviewContract@draft` - select the draft version of the ReviewContract interaction
136
- * - `ReviewContract@fixed` - select the ReviewContract interaction which is tagged with 'fixed' tag.
137
- * @param nameWithTag
138
- * @param payload
139
- * @param onChunk
140
- * @returns
141
- */
142
- async executeByName(nameWithTag, payload = {}, onChunk) {
143
- const r = await executeInteractionByName(this.client, nameWithTag, payload, onChunk).catch(err => {
144
- if (err instanceof ServerError && err.payload?.id) {
145
- throw err.updateDetails({ run_id: err.payload.id });
146
- }
147
- else {
148
- throw err;
149
- }
150
- });
151
- return enhanceInteractionExecutionResult(r);
152
- }
153
- /**
154
- * Execute an interaction in an workflow
155
- * @param payload
156
- * @returns
157
- */
158
- executeAsync(payload) {
159
- return executeInteractionAsync(this.client, payload);
160
- }
161
- publish(id, payload) {
162
- return this.post(`/${id}/publish`, {
163
- payload
164
- });
165
- }
166
- fork(id, payload) {
167
- return this.post(`/${id}/fork`, {
168
- payload
169
- });
170
- }
171
- /**
172
- * Generate Composable definition of an interaction
173
- **/
174
- generateInteraction(id, payload) {
175
- return this.post(`${id}/generate-interaction`, {
176
- payload
177
- });
178
- }
179
- /**
180
- * Generate Test Data for an interaction
181
- **/
182
- generateTestData(id, payload) {
183
- return this.post(`${id}/generate-test-data`, {
184
- payload
185
- });
186
- }
187
- /**
188
- * Suggest Improvement for a prompt
189
- * @deprecated use suggestPromptImprovements instead
190
- */
191
- async suggestImprovements(id, payload) {
192
- const r = await this.post(`${id}/suggest-prompt-improvements`, {
193
- payload
194
- });
195
- return enhanceExecutionRun(r);
196
- }
197
- async suggestPromptImprovements(payload) {
198
- const r = await this.post(`/improve`, {
199
- payload
200
- });
201
- return enhanceInteractionExecutionResult(r);
202
- }
203
- /**
204
- * List the versions of the interaction. Returns an empty array if no versions are found
205
- * @param id
206
- * @returns the versions list or an empty array if no versions are found
207
- */
208
- listVersions(id) {
209
- return this.get(`/${id}/versions`);
210
- }
211
- /**
212
- * List the forks of the interaction. Returns an empty array if no forks are found
213
- * @param id
214
- * @returns the versions list or an empty array if no forks are found
215
- */
216
- listForks(id) {
217
- return this.get(`/${id}/forks`);
218
- }
219
- /**
220
- * Request a time slot to execute an interaction with a given environment / model
221
- * @param payload RateLimitRequestPayload
222
- * @returns RateLimitRequestResponse with delay_ms
223
- */
224
- requestSlot(payload) {
225
- return checkRateLimit(this.client, payload);
226
- }
227
- }
228
- //# sourceMappingURL=InteractionsApi.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"InteractionsApi.js","sourceRoot":"","sources":["../../src/InteractionsApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAc,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAW/E,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AACrH,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAA4D,mBAAmB,EAAE,iCAAiC,EAAE,MAAM,wBAAwB,CAAC;AAY1J,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,QAAQ;IACjD,OAAO,CAAwB;IAE/B,YAAY,MAAkB;QAC1B,KAAK,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;QACtC,IAAI,CAAC,OAAO,GAAG,IAAI,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACrD,CAAC;IAED;;;QAGI;IACJ,IAAI,CAAC,UAAoC,EAAE;QACvC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,EAA4B,CAAC;QAE5D,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,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C;CAEJ"}
@@ -1,50 +0,0 @@
1
- import { ApiTopic } from "@vertesia/api-fetch-client";
2
- export default class ProjectsApi extends ApiTopic {
3
- constructor(parent) {
4
- super(parent, "/api/v1/projects");
5
- }
6
- list(account) {
7
- return this.get('/', { query: { account } });
8
- }
9
- retrieve(projectId) {
10
- return this.get(`/${projectId}`);
11
- }
12
- create(payload) {
13
- return this.post('/', {
14
- payload
15
- });
16
- }
17
- update(projectId, payload) {
18
- return this.put(`/${projectId}`, {
19
- payload
20
- });
21
- }
22
- updateConfiguration(projectId, payload) {
23
- return this.put(`/${projectId}/configuration`, {
24
- payload
25
- });
26
- }
27
- integrations = new IntegrationsConfigurationApi(this);
28
- }
29
- class IntegrationsConfigurationApi extends ApiTopic {
30
- constructor(parent) {
31
- super(parent, "/");
32
- }
33
- list(projectId) {
34
- return this.get(`/${projectId}/integrations`).then(res => res.integrations);
35
- }
36
- retrieve(projectId, integrationId) {
37
- return this.get(`/${projectId}/integrations/${integrationId}`).catch(err => {
38
- if (err.status === 404) {
39
- return undefined;
40
- }
41
- throw err;
42
- });
43
- }
44
- update(projectId, integrationId, payload) {
45
- return this.put(`/${projectId}/integrations/${integrationId}`, {
46
- payload
47
- });
48
- }
49
- }
50
- //# sourceMappingURL=ProjectsApi.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ProjectsApi.js","sourceRoot":"","sources":["../../src/ProjectsApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAc,MAAM,4BAA4B,CAAC;AAGlE,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,QAAQ;IAC7C,YAAY,MAAkB;QAC1B,KAAK,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IACtC,CAAC;IAED,IAAI,CAAC,OAAkB;QACnB,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;IACjD,CAAC;IAED,QAAQ,CAAC,SA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