@vertesia/client 1.6.0-dev.20260923.085325Z → 1.6.0-dev.20261008.064737Z

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 (120) hide show
  1. package/lib/AuditTrailApi.d.ts +3 -1
  2. package/lib/AuditTrailApi.d.ts.map +1 -1
  3. package/lib/AuditTrailApi.js +6 -0
  4. package/lib/AuditTrailApi.js.map +1 -1
  5. package/lib/EnvironmentsApi.d.ts +2 -1
  6. package/lib/EnvironmentsApi.d.ts.map +1 -1
  7. package/lib/EnvironmentsApi.js +3 -0
  8. package/lib/EnvironmentsApi.js.map +1 -1
  9. package/lib/InferenceProfilesApi.d.ts +14 -0
  10. package/lib/InferenceProfilesApi.d.ts.map +1 -0
  11. package/lib/InferenceProfilesApi.js +33 -0
  12. package/lib/InferenceProfilesApi.js.map +1 -0
  13. package/lib/InteractionBase.d.ts +2 -954
  14. package/lib/InteractionBase.d.ts.map +1 -1
  15. package/lib/InteractionConfigurationsApi.d.ts +9 -0
  16. package/lib/InteractionConfigurationsApi.d.ts.map +1 -0
  17. package/lib/InteractionConfigurationsApi.js +16 -0
  18. package/lib/InteractionConfigurationsApi.js.map +1 -0
  19. package/lib/InteractionsApi.d.ts +2 -7
  20. package/lib/InteractionsApi.d.ts.map +1 -1
  21. package/lib/InteractionsApi.js.map +1 -1
  22. package/lib/client.d.ts +6 -12
  23. package/lib/client.d.ts.map +1 -1
  24. package/lib/client.js +4 -3
  25. package/lib/client.js.map +1 -1
  26. package/lib/execute.d.ts.map +1 -1
  27. package/lib/execute.js +9 -2
  28. package/lib/execute.js.map +1 -1
  29. package/lib/index.d.ts +0 -2
  30. package/lib/index.d.ts.map +1 -1
  31. package/lib/index.js +0 -2
  32. package/lib/index.js.map +1 -1
  33. package/lib/managed-sse.d.ts.map +1 -1
  34. package/lib/managed-sse.js +2 -3
  35. package/lib/managed-sse.js.map +1 -1
  36. package/lib/store/AgentsApi.d.ts +6 -1
  37. package/lib/store/AgentsApi.d.ts.map +1 -1
  38. package/lib/store/AgentsApi.js +12 -4
  39. package/lib/store/AgentsApi.js.map +1 -1
  40. package/lib/store/ContentApi.d.ts +111 -0
  41. package/lib/store/ContentApi.d.ts.map +1 -0
  42. package/lib/store/ContentApi.js +83 -0
  43. package/lib/store/ContentApi.js.map +1 -0
  44. package/lib/store/DataApi.d.ts +1 -1
  45. package/lib/store/DataApi.js +1 -1
  46. package/lib/store/IndexingApi.d.ts +1 -1
  47. package/lib/store/IndexingApi.d.ts.map +1 -1
  48. package/lib/store/IndexingApi.js +2 -1
  49. package/lib/store/IndexingApi.js.map +1 -1
  50. package/lib/store/WorkflowsApi.d.ts.map +1 -1
  51. package/lib/store/WorkflowsApi.js +6 -1
  52. package/lib/store/WorkflowsApi.js.map +1 -1
  53. package/lib/store/client.d.ts +2 -0
  54. package/lib/store/client.d.ts.map +1 -1
  55. package/lib/store/client.js +2 -0
  56. package/lib/store/client.js.map +1 -1
  57. package/lib/store/index.d.ts +1 -0
  58. package/lib/store/index.d.ts.map +1 -1
  59. package/lib/store/index.js +1 -0
  60. package/lib/store/index.js.map +1 -1
  61. package/lib/store/signed-url.d.ts +13 -0
  62. package/lib/store/signed-url.d.ts.map +1 -1
  63. package/lib/store/signed-url.js +29 -1
  64. package/lib/store/signed-url.js.map +1 -1
  65. package/lib/vertesia-client.js +4 -4
  66. package/lib/vertesia-client.js.map +1 -1
  67. package/package.json +12 -11
  68. package/src/AuditTrailApi.ts +12 -0
  69. package/src/EnvironmentsApi.ts +6 -0
  70. package/src/InferenceProfilesApi.ts +47 -0
  71. package/src/InteractionConfigurationsApi.ts +20 -0
  72. package/src/InteractionsApi.ts +2 -9
  73. package/src/client.ts +4 -3
  74. package/src/execute.ts +15 -4
  75. package/src/index.ts +0 -2
  76. package/src/managed-sse.ts +2 -5
  77. package/src/store/AgentsApi.ts +14 -4
  78. package/src/store/ContentApi.ts +158 -0
  79. package/src/store/DataApi.ts +1 -1
  80. package/src/store/IndexingApi.ts +2 -0
  81. package/src/store/WorkflowsApi.ts +5 -1
  82. package/src/store/client.ts +2 -0
  83. package/src/store/index.ts +1 -0
  84. package/src/store/signed-url.ts +32 -1
  85. package/lib/InternalAccountsApi.d.ts +0 -7
  86. package/lib/InternalAccountsApi.d.ts.map +0 -1
  87. package/lib/InternalAccountsApi.js +0 -10
  88. package/lib/InternalAccountsApi.js.map +0 -1
  89. package/lib/InternalSecretsApi.d.ts +0 -18
  90. package/lib/InternalSecretsApi.d.ts.map +0 -1
  91. package/lib/InternalSecretsApi.js +0 -29
  92. package/lib/InternalSecretsApi.js.map +0 -1
  93. package/src/AccountApi.test.ts +0 -30
  94. package/src/AppsApi.test.ts +0 -132
  95. package/src/EnvironmentsApi.test.ts +0 -39
  96. package/src/InteractionOutput.test.ts +0 -338
  97. package/src/InternalAccountsApi.ts +0 -12
  98. package/src/InternalSecretsApi.ts +0 -63
  99. package/src/OAuthServerApi.test.ts +0 -56
  100. package/src/ProjectsApi.test.ts +0 -33
  101. package/src/RunsApi.test.ts +0 -24
  102. package/src/ViewsApi.test.ts +0 -38
  103. package/src/app-session.test.ts +0 -23
  104. package/src/bundle-isolation.test.ts +0 -37
  105. package/src/client.test.ts +0 -332
  106. package/src/execute.test.ts +0 -22
  107. package/src/store/AgentsApi.artifacts.test.ts +0 -119
  108. package/src/store/AgentsApi.history.test.ts +0 -29
  109. package/src/store/AgentsApi.stream.test.ts +0 -386
  110. package/src/store/DataApi.test.ts +0 -42
  111. package/src/store/EmbeddingsApi.test.ts +0 -31
  112. package/src/store/EventsApi.test.ts +0 -131
  113. package/src/store/FilesApi.test.ts +0 -118
  114. package/src/store/ObjectsApi.test.ts +0 -50
  115. package/src/store/ProcessApi.test.ts +0 -24
  116. package/src/store/ViewsApi.test.ts +0 -33
  117. package/src/store/signed-url.test.ts +0 -204
  118. package/src/store/stream-gap.test.ts +0 -230
  119. package/src/store/stream-termination.test.ts +0 -82
  120. package/src/store/uploadMimeType.test.ts +0 -22
@@ -1,230 +0,0 @@
1
- import { type AgentMessage, AgentMessageType } from '@vertesia/common';
2
- import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
3
- import { VertesiaClient } from '../client.js';
4
-
5
- class FakeEventSource {
6
- static readonly CONNECTING = 0;
7
- static readonly OPEN = 1;
8
- static readonly CLOSED = 2;
9
-
10
- static urls: string[] = [];
11
-
12
- readonly url: string;
13
- readonly withCredentials = false;
14
- readyState = FakeEventSource.CONNECTING;
15
- onopen: ((event: Event) => void) | null = null;
16
- onmessage: ((event: MessageEvent) => void) | null = null;
17
- onerror: ((event: Event) => void) | null = null;
18
-
19
- constructor(url: string) {
20
- this.url = url;
21
- FakeEventSource.urls.push(url);
22
- }
23
-
24
- close() {
25
- this.readyState = FakeEventSource.CLOSED;
26
- }
27
-
28
- addEventListener() {}
29
-
30
- removeEventListener() {}
31
-
32
- dispatchEvent() {
33
- return true;
34
- }
35
- }
36
-
37
- function createClient(): VertesiaClient {
38
- const client = new VertesiaClient({
39
- serverUrl: 'https://studio.example.test',
40
- storeUrl: 'https://store.example.test',
41
- });
42
- client.withAuthCallback(async () => 'Bearer test-token');
43
- return client;
44
- }
45
-
46
- function message(timestamp: number): AgentMessage {
47
- return {
48
- type: AgentMessageType.THOUGHT,
49
- timestamp,
50
- workflow_run_id: 'run-1',
51
- message: 'historical',
52
- workstream_id: 'main',
53
- };
54
- }
55
-
56
- function mockApiGet<T extends object>(api: T, response: unknown) {
57
- return vi
58
- .spyOn(api as unknown as { get: (path: string, options?: unknown) => Promise<unknown> }, 'get')
59
- .mockResolvedValue(response);
60
- }
61
-
62
- describe('streamMessages GET-to-SSE handoff', () => {
63
- beforeEach(() => {
64
- FakeEventSource.urls = [];
65
- vi.stubGlobal('EventSource', FakeEventSource);
66
- });
67
-
68
- afterEach(() => {
69
- vi.unstubAllGlobals();
70
- vi.restoreAllMocks();
71
- });
72
-
73
- it('uses a positive SSE since cursor for an agent run with empty initial history', async () => {
74
- const client = createClient();
75
- vi.spyOn(client.agents, 'retrieveMessages').mockResolvedValue([]);
76
- const abort = new AbortController();
77
-
78
- const stream = client.agents.streamMessages('agent-run-1', undefined, undefined, abort.signal);
79
-
80
- await vi.waitFor(() => expect(FakeEventSource.urls).toHaveLength(1));
81
-
82
- const streamUrl = new URL(FakeEventSource.urls[0]);
83
- expect(streamUrl.searchParams.get('skipHistory')).toBe('true');
84
- expect(Number(streamUrl.searchParams.get('since'))).toBeGreaterThan(0);
85
-
86
- abort.abort();
87
- await stream;
88
- });
89
-
90
- it('keeps the latest historical timestamp as the SSE since cursor for an agent run', async () => {
91
- const client = createClient();
92
- vi.spyOn(client.agents, 'retrieveMessages').mockResolvedValue([message(1_234)]);
93
- const abort = new AbortController();
94
-
95
- const stream = client.agents.streamMessages('agent-run-1', undefined, undefined, abort.signal);
96
-
97
- await vi.waitFor(() => expect(FakeEventSource.urls).toHaveLength(1));
98
-
99
- const streamUrl = new URL(FakeEventSource.urls[0]);
100
- expect(streamUrl.searchParams.get('since')).toBe('1234');
101
-
102
- abort.abort();
103
- await stream;
104
- });
105
-
106
- it('delivers full agent history before closing on a terminal historical message', async () => {
107
- const client = createClient();
108
- const complete = {
109
- ...message(1_000),
110
- type: AgentMessageType.COMPLETE,
111
- message: 'previous turn complete',
112
- };
113
- const latest = {
114
- ...message(2_000),
115
- message: 'newer historical message',
116
- };
117
- vi.spyOn(client.agents, 'retrieveMessages').mockResolvedValue([complete, latest]);
118
- const delivered: AgentMessage[] = [];
119
- const abort = new AbortController();
120
-
121
- const stream = client.agents.streamMessages(
122
- 'agent-run-1',
123
- (msg) => {
124
- delivered.push(msg);
125
- },
126
- undefined,
127
- abort.signal,
128
- );
129
-
130
- await vi.waitFor(() => expect(FakeEventSource.urls).toHaveLength(1));
131
-
132
- expect(delivered.map((msg) => msg.message)).toEqual(['previous turn complete', 'newer historical message']);
133
- expect(new URL(FakeEventSource.urls[0]).searchParams.get('since')).toBe('2000');
134
-
135
- abort.abort();
136
- await stream;
137
- });
138
-
139
- it('normalizes legacy agent history messages before returning them to the UI', async () => {
140
- const client = createClient();
141
- mockApiGet(client.agents, {
142
- messages: [
143
- {
144
- type: 8,
145
- timestamp: 1_000,
146
- workflow_run_id: 'legacy-run',
147
- message: 'What are the news headlines in France today?',
148
- workstream_id: 'main',
149
- details: { event_class: 'user_content' },
150
- },
151
- {
152
- type: 7,
153
- timestamp: 2_000,
154
- workflow_run_id: 'legacy-run',
155
- message: 'Here are the headlines.',
156
- workstream_id: 'main',
157
- details: { streamed: true },
158
- },
159
- ],
160
- });
161
-
162
- const messages = await client.agents.retrieveMessages('agent-run-1');
163
-
164
- expect(messages).toEqual([
165
- expect.objectContaining({
166
- type: AgentMessageType.QUESTION,
167
- timestamp: 1_000,
168
- workflow_run_id: 'agent-run-1',
169
- message: 'What are the news headlines in France today?',
170
- details: { event_class: 'user_content' },
171
- }),
172
- expect.objectContaining({
173
- type: AgentMessageType.ANSWER,
174
- timestamp: 2_000,
175
- workflow_run_id: 'agent-run-1',
176
- message: 'Here are the headlines.',
177
- details: { streamed: true },
178
- }),
179
- ]);
180
- });
181
-
182
- it('normalizes legacy workflow history messages before returning them to the UI', async () => {
183
- const client = createClient();
184
- mockApiGet(client.workflows, {
185
- messages: [
186
- {
187
- type: 'answer',
188
- timestamp: 3_000,
189
- workflow_run_id: 'legacy-run',
190
- message: 'Workflow answer',
191
- workstream_id: 'main',
192
- },
193
- ],
194
- });
195
-
196
- const messages = await client.workflows.retrieveMessages('workflow-1', 'workflow-run-1');
197
-
198
- expect(messages).toEqual([
199
- expect.objectContaining({
200
- type: AgentMessageType.ANSWER,
201
- timestamp: 3_000,
202
- workflow_run_id: 'workflow-run-1',
203
- message: 'Workflow answer',
204
- }),
205
- ]);
206
- });
207
-
208
- it('uses a positive SSE since cursor for a workflow run with empty initial history', async () => {
209
- const client = createClient();
210
- vi.spyOn(client.workflows, 'retrieveMessages').mockResolvedValue([]);
211
- const abort = new AbortController();
212
-
213
- const stream = client.workflows.streamMessages(
214
- 'workflow-1',
215
- 'workflow-run-1',
216
- undefined,
217
- undefined,
218
- abort.signal,
219
- );
220
-
221
- await vi.waitFor(() => expect(FakeEventSource.urls).toHaveLength(1));
222
-
223
- const streamUrl = new URL(FakeEventSource.urls[0]);
224
- expect(streamUrl.searchParams.get('skipHistory')).toBe('true');
225
- expect(Number(streamUrl.searchParams.get('since'))).toBeGreaterThan(0);
226
-
227
- abort.abort();
228
- await stream;
229
- });
230
- });
@@ -1,82 +0,0 @@
1
- import { type AgentMessage, AgentMessageType, type CompactMessage } from '@vertesia/common';
2
- import { describe, expect, it } from 'vitest';
3
- import { shouldCloseAgentRunStream, shouldCloseCompactRunStream } from './stream-termination.js';
4
-
5
- describe('stream termination', () => {
6
- const rootRunId = 'root-run';
7
-
8
- it('closes agent streams on the root run completion', () => {
9
- const message: AgentMessage = {
10
- type: AgentMessageType.COMPLETE,
11
- timestamp: Date.now(),
12
- workflow_run_id: rootRunId,
13
- message: 'root complete',
14
- workstream_id: 'main',
15
- details: {
16
- process_run_id: rootRunId,
17
- },
18
- };
19
-
20
- expect(shouldCloseAgentRunStream(message, rootRunId)).toBe(true);
21
- });
22
-
23
- it('keeps agent streams open for child process completion on main', () => {
24
- const message: AgentMessage = {
25
- type: AgentMessageType.COMPLETE,
26
- timestamp: Date.now(),
27
- workflow_run_id: rootRunId,
28
- message: 'child complete',
29
- workstream_id: 'main',
30
- details: {
31
- process_run_id: 'child-run',
32
- },
33
- };
34
-
35
- expect(shouldCloseAgentRunStream(message, rootRunId)).toBe(false);
36
- });
37
-
38
- it('keeps compact streams open for child process completion on main', () => {
39
- const message: CompactMessage = {
40
- t: AgentMessageType.COMPLETE,
41
- m: 'child complete',
42
- d: {
43
- process_run_id: 'child-run',
44
- },
45
- };
46
-
47
- expect(shouldCloseCompactRunStream(message, rootRunId)).toBe(false);
48
- });
49
-
50
- it('still closes streams for main completion without process metadata', () => {
51
- const message: CompactMessage = {
52
- t: AgentMessageType.COMPLETE,
53
- m: 'conversation complete',
54
- };
55
-
56
- expect(shouldCloseCompactRunStream(message, rootRunId)).toBe(true);
57
- });
58
-
59
- it('keeps interactive root streams open when the conversation becomes idle', () => {
60
- const message: AgentMessage = {
61
- type: AgentMessageType.IDLE,
62
- timestamp: Date.now(),
63
- workflow_run_id: rootRunId,
64
- message: 'Waiting for your command...',
65
- workstream_id: 'main',
66
- };
67
-
68
- expect(shouldCloseAgentRunStream(message, rootRunId)).toBe(false);
69
- expect(shouldCloseAgentRunStream(message, rootRunId, true)).toBe(true);
70
- });
71
-
72
- it('keeps compact streams open when a child workstream becomes idle', () => {
73
- const message: CompactMessage = {
74
- t: AgentMessageType.IDLE,
75
- m: 'Child waiting',
76
- w: 'implementation',
77
- };
78
-
79
- expect(shouldCloseCompactRunStream(message, rootRunId)).toBe(false);
80
- expect(shouldCloseCompactRunStream(message, rootRunId, true)).toBe(false);
81
- });
82
- });
@@ -1,22 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { getUploadMimeTypeHint, resolveUploadMimeType } from './uploadMimeType.js';
3
-
4
- describe('upload MIME type resolution', () => {
5
- it('keeps a specific browser-provided content type', () => {
6
- expect(getUploadMimeTypeHint('text/plain')).toBe('text/plain');
7
- expect(resolveUploadMimeType('text/plain', 'text/markdown')).toBe('text/plain');
8
- });
9
-
10
- it('uses filename inference when the browser reports generic binary content', () => {
11
- expect(getUploadMimeTypeHint('application/octet-stream')).toBeUndefined();
12
- expect(resolveUploadMimeType('application/octet-stream', 'text/markdown')).toBe('text/markdown');
13
- });
14
-
15
- it('uses filename inference when the browser omits the content type', () => {
16
- expect(resolveUploadMimeType('', 'text/markdown')).toBe('text/markdown');
17
- });
18
-
19
- it('retains octet-stream when no more specific type can be inferred', () => {
20
- expect(resolveUploadMimeType('application/octet-stream', undefined)).toBe('application/octet-stream');
21
- });
22
- });