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