@proteos/sdk 0.18.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 (94) hide show
  1. package/LICENSE +40 -0
  2. package/dist/chunk-7RGN4E22.cjs +1185 -0
  3. package/dist/chunk-7RGN4E22.cjs.map +1 -0
  4. package/dist/chunk-XJP5WCRZ.js +1125 -0
  5. package/dist/chunk-XJP5WCRZ.js.map +1 -0
  6. package/dist/index.cjs +2384 -0
  7. package/dist/index.cjs.map +1 -0
  8. package/dist/index.d.cts +5225 -0
  9. package/dist/index.d.ts +5225 -0
  10. package/dist/index.js +2146 -0
  11. package/dist/index.js.map +1 -0
  12. package/dist/meta/index.cjs +204 -0
  13. package/dist/meta/index.cjs.map +1 -0
  14. package/dist/meta/index.d.cts +2 -0
  15. package/dist/meta/index.d.ts +2 -0
  16. package/dist/meta/index.js +3 -0
  17. package/dist/meta/index.js.map +1 -0
  18. package/dist/types-BNsjfU8N.d.cts +3299 -0
  19. package/dist/types-BNsjfU8N.d.ts +3299 -0
  20. package/package.json +86 -0
  21. package/src/agent/agents.ts +53 -0
  22. package/src/agent/index.ts +134 -0
  23. package/src/agent/mcp-servers.ts +102 -0
  24. package/src/agent/prompts.ts +80 -0
  25. package/src/agent/session-types.ts +397 -0
  26. package/src/agent/sessions.ts +197 -0
  27. package/src/agent/skills.ts +89 -0
  28. package/src/agent/tools.ts +53 -0
  29. package/src/agent/types.ts +362 -0
  30. package/src/auth/index.ts +111 -0
  31. package/src/auth/me.ts +46 -0
  32. package/src/auth/organizations.ts +128 -0
  33. package/src/auth/platform-entities.ts +78 -0
  34. package/src/auth/roles.ts +213 -0
  35. package/src/auth/types.ts +294 -0
  36. package/src/auth/users.ts +226 -0
  37. package/src/client.ts +441 -0
  38. package/src/connector/index.ts +120 -0
  39. package/src/connector/types.ts +150 -0
  40. package/src/conversation/index.ts +297 -0
  41. package/src/conversation/types.ts +590 -0
  42. package/src/conversation/voice.ts +123 -0
  43. package/src/data/index.ts +53 -0
  44. package/src/data/queries.ts +66 -0
  45. package/src/data/records.ts +122 -0
  46. package/src/data/types.ts +89 -0
  47. package/src/errors.ts +148 -0
  48. package/src/events/index.ts +172 -0
  49. package/src/events/types.ts +77 -0
  50. package/src/functions/actions.ts +95 -0
  51. package/src/functions/index.ts +32 -0
  52. package/src/functions/types.ts +71 -0
  53. package/src/http/index.ts +2 -0
  54. package/src/http/query-params.ts +106 -0
  55. package/src/index.ts +598 -0
  56. package/src/iterator.ts +183 -0
  57. package/src/knowledge/graph.ts +35 -0
  58. package/src/knowledge/index.ts +104 -0
  59. package/src/knowledge/labels.ts +70 -0
  60. package/src/knowledge/links.ts +65 -0
  61. package/src/knowledge/nodes.ts +198 -0
  62. package/src/knowledge/record-links.ts +66 -0
  63. package/src/knowledge/types.ts +569 -0
  64. package/src/meta/apps.ts +107 -0
  65. package/src/meta/components.ts +124 -0
  66. package/src/meta/currency/index.ts +202 -0
  67. package/src/meta/entities.ts +193 -0
  68. package/src/meta/filters.ts +76 -0
  69. package/src/meta/index.ts +227 -0
  70. package/src/meta/layout/common-props.ts +93 -0
  71. package/src/meta/layout/control-registry.json +70 -0
  72. package/src/meta/layout/control-registry.ts +92 -0
  73. package/src/meta/layout/elements.ts +203 -0
  74. package/src/meta/layout/index.ts +41 -0
  75. package/src/meta/layout/page-layout.ts +35 -0
  76. package/src/meta/layout/size-value.ts +27 -0
  77. package/src/meta/list-views.ts +109 -0
  78. package/src/meta/lists.ts +104 -0
  79. package/src/meta/menu-configurations.ts +128 -0
  80. package/src/meta/modules.ts +159 -0
  81. package/src/meta/pages.ts +106 -0
  82. package/src/meta/types.ts +1115 -0
  83. package/src/meta/variables.ts +98 -0
  84. package/src/storage/files.ts +183 -0
  85. package/src/storage/index.ts +33 -0
  86. package/src/storage/types.ts +70 -0
  87. package/src/types/common.ts +143 -0
  88. package/src/types/index.ts +28 -0
  89. package/src/types/options.ts +95 -0
  90. package/src/workflow/executions.ts +99 -0
  91. package/src/workflow/index.ts +109 -0
  92. package/src/workflow/node-types.ts +50 -0
  93. package/src/workflow/types.ts +658 -0
  94. package/src/workflow/workflows.ts +152 -0
package/dist/index.js ADDED
@@ -0,0 +1,2146 @@
1
+ import { AuditFieldsSchema, AttributeSchema, UserRefSchema, PageIterator } from './chunk-XJP5WCRZ.js';
2
+ export { AppSchema, AttributeSchema, AuditFieldsSchema, ColumnSchema, ComponentSchema, CurrencyAttributeMetaSchema, DEFAULT_PAGE_SIZE, DONE, EntitySchema, EntityWithSchemaSchema, FileRefSchema, FilterElementSchema, FilterGroupSchema, ListSchema, ListViewSchema, MenuConfigurationSchema, MenuItemSchema, MenuItemType, MetaClient, ModuleSchema, OnDeleteActionSchema, PLATFORM_ATTRIBUTE_NAMES, PLATFORM_USER_ID, PageActionSchema, PageIterator, PageLayoutSchema, PageSchema, RelationAttributeMetaSchema, ResponseMetaSchema, SortConfigSchema, UserRefSchema, VariableSchema, allCurrencyCodes, createIterator, createListResultSchema, currencyLabel, currencySymbol, currencySymbolSide, formatAmount, formatMoney, isPlatformAttributeName, localeNumberSeparators, parseAmount, parseCurrencyMeta, parseFileMeta, parseRelationMeta, platformAttributes } from './chunk-XJP5WCRZ.js';
3
+ import { z } from 'zod';
4
+ import { fetchEventSource } from '@microsoft/fetch-event-source';
5
+
6
+ // src/agent/agents.ts
7
+ var AGENTS_BASE_PATH = "/agents/v1/agents";
8
+ var AgentServiceImpl = class {
9
+ constructor(client) {
10
+ this.client = client;
11
+ }
12
+ client;
13
+ list(options = {}) {
14
+ return new PageIterator((opts) => this.listPage(opts), options);
15
+ }
16
+ async listPage(options = {}) {
17
+ return this.client.requestWithQuery("GET", AGENTS_BASE_PATH, options);
18
+ }
19
+ async get(key) {
20
+ return this.client.request("GET", `${AGENTS_BASE_PATH}/${key}`);
21
+ }
22
+ async create(request) {
23
+ return this.client.request("POST", AGENTS_BASE_PATH, request);
24
+ }
25
+ async update(key, request) {
26
+ return this.client.request("PATCH", `${AGENTS_BASE_PATH}/${key}`, request);
27
+ }
28
+ async delete(key) {
29
+ await this.client.request("DELETE", `${AGENTS_BASE_PATH}/${key}`);
30
+ }
31
+ };
32
+
33
+ // src/agent/mcp-servers.ts
34
+ var MCP_SERVERS_BASE_PATH = "/agents/v1/mcp-servers";
35
+ var McpServerServiceImpl = class {
36
+ constructor(client) {
37
+ this.client = client;
38
+ }
39
+ client;
40
+ list(options = {}) {
41
+ return new PageIterator((opts) => this.listPage(opts), options);
42
+ }
43
+ async listPage(options = {}) {
44
+ return this.client.requestWithQuery(
45
+ "GET",
46
+ MCP_SERVERS_BASE_PATH,
47
+ options
48
+ );
49
+ }
50
+ async get(key) {
51
+ return this.client.request("GET", `${MCP_SERVERS_BASE_PATH}/${key}`);
52
+ }
53
+ async create(request) {
54
+ return this.client.request("POST", MCP_SERVERS_BASE_PATH, request);
55
+ }
56
+ async update(key, request) {
57
+ return this.client.request("PATCH", `${MCP_SERVERS_BASE_PATH}/${key}`, request);
58
+ }
59
+ async delete(key) {
60
+ await this.client.request("DELETE", `${MCP_SERVERS_BASE_PATH}/${key}`);
61
+ }
62
+ async listTools(key) {
63
+ const response = await this.client.request(
64
+ "GET",
65
+ `${MCP_SERVERS_BASE_PATH}/${key}/tools`
66
+ );
67
+ return response.data;
68
+ }
69
+ async getConnectionStatus(key) {
70
+ const response = await this.client.request(
71
+ "GET",
72
+ `${MCP_SERVERS_BASE_PATH}/${key}/connection`
73
+ );
74
+ return response.data;
75
+ }
76
+ async startOAuth(key) {
77
+ return this.client.request(
78
+ "POST",
79
+ `${MCP_SERVERS_BASE_PATH}/${key}/oauth/connect`
80
+ );
81
+ }
82
+ async disconnectOAuth(key) {
83
+ await this.client.request("DELETE", `${MCP_SERVERS_BASE_PATH}/${key}/oauth/connect`);
84
+ }
85
+ };
86
+
87
+ // src/agent/prompts.ts
88
+ var PROMPTS_BASE_PATH = "/agents/v1/prompts";
89
+ var PromptServiceImpl = class {
90
+ constructor(client) {
91
+ this.client = client;
92
+ }
93
+ client;
94
+ list(options = {}) {
95
+ return new PageIterator((opts) => this.listPage(opts), options);
96
+ }
97
+ async listPage(options = {}) {
98
+ return this.client.requestWithQuery("GET", PROMPTS_BASE_PATH, options);
99
+ }
100
+ async get(key) {
101
+ return this.client.request("GET", `${PROMPTS_BASE_PATH}/${key}`);
102
+ }
103
+ async create(request) {
104
+ return this.client.request("POST", PROMPTS_BASE_PATH, request);
105
+ }
106
+ async update(key, request) {
107
+ return this.client.request("PATCH", `${PROMPTS_BASE_PATH}/${key}`, request);
108
+ }
109
+ async delete(key) {
110
+ await this.client.request("DELETE", `${PROMPTS_BASE_PATH}/${key}`);
111
+ }
112
+ async listVersions(key) {
113
+ const response = await this.client.request(
114
+ "GET",
115
+ `${PROMPTS_BASE_PATH}/${key}/versions`
116
+ );
117
+ return response.data;
118
+ }
119
+ async getVersion(key, number) {
120
+ return this.client.request(
121
+ "GET",
122
+ `${PROMPTS_BASE_PATH}/${key}/versions/${number}`
123
+ );
124
+ }
125
+ };
126
+
127
+ // src/agent/sessions.ts
128
+ var SESSIONS_BASE_PATH = "/agents/v1/sessions";
129
+ var SessionServiceImpl = class {
130
+ constructor(client) {
131
+ this.client = client;
132
+ }
133
+ client;
134
+ list(options = {}) {
135
+ return new PageIterator((opts) => this.listPage(opts), options);
136
+ }
137
+ async listPage(options = {}) {
138
+ return this.client.requestWithQuery("GET", SESSIONS_BASE_PATH, options);
139
+ }
140
+ async get(id) {
141
+ return this.client.request("GET", `${SESSIONS_BASE_PATH}/${id}`);
142
+ }
143
+ async create(request) {
144
+ return this.client.request("POST", SESSIONS_BASE_PATH, request);
145
+ }
146
+ async events(id, options = {}) {
147
+ const { types, ...rest } = options;
148
+ const query = {
149
+ ...rest,
150
+ ...types && types.length > 0 ? { types: types.join(",") } : {}
151
+ };
152
+ const response = await this.client.requestWithQuery(
153
+ "GET",
154
+ `${SESSIONS_BASE_PATH}/${id}/events`,
155
+ query
156
+ );
157
+ return response.data ?? [];
158
+ }
159
+ async appendEvent(id, request) {
160
+ return this.client.request("POST", `${SESSIONS_BASE_PATH}/${id}/events`, request);
161
+ }
162
+ async turns(id) {
163
+ const response = await this.client.request(
164
+ "GET",
165
+ `${SESSIONS_BASE_PATH}/${id}/turns`
166
+ );
167
+ return response.data ?? [];
168
+ }
169
+ async *stream(id, options = {}) {
170
+ const query = options.afterSeq ? `?after_seq=${options.afterSeq}` : "";
171
+ const path = `${SESSIONS_BASE_PATH}/${id}/events/stream${query}`;
172
+ const streamOptions = options.signal ? { signal: options.signal } : {};
173
+ for await (const frame of this.client.streamEvents(path, streamOptions)) {
174
+ const event = parseEvent(frame.data);
175
+ if (event) yield event;
176
+ }
177
+ }
178
+ async sendMessage(id, text, turnId) {
179
+ return this.sendUserMessage(id, { text, ...turnId ? { turnId } : {} });
180
+ }
181
+ async sendUserMessage(id, input) {
182
+ const content = [];
183
+ const text = input.text?.trim();
184
+ if (text) content.push({ type: "text", text });
185
+ for (const file of input.files ?? []) {
186
+ content.push({ type: "file", ...file });
187
+ }
188
+ return this.appendEvent(id, {
189
+ type: "user.message",
190
+ ...input.turnId ? { turn_id: input.turnId } : {},
191
+ payload: { content }
192
+ });
193
+ }
194
+ async interrupt(id) {
195
+ return this.appendEvent(id, { type: "user.interrupt" });
196
+ }
197
+ async submitToolResult(id, input) {
198
+ return this.appendEvent(id, {
199
+ type: "user.tool_result",
200
+ payload: {
201
+ tool_use_id: input.toolUseId,
202
+ result: input.result,
203
+ outcome: input.outcome ?? "success"
204
+ }
205
+ });
206
+ }
207
+ };
208
+ function parseEvent(data) {
209
+ if (!data) return null;
210
+ try {
211
+ return JSON.parse(data);
212
+ } catch {
213
+ return null;
214
+ }
215
+ }
216
+
217
+ // src/agent/skills.ts
218
+ var SKILLS_BASE_PATH = "/agents/v1/skills";
219
+ var SkillServiceImpl = class {
220
+ constructor(client) {
221
+ this.client = client;
222
+ }
223
+ client;
224
+ list(options = {}) {
225
+ return new PageIterator((opts) => this.listPage(opts), options);
226
+ }
227
+ async listPage(options = {}) {
228
+ return this.client.requestWithQuery("GET", SKILLS_BASE_PATH, options);
229
+ }
230
+ async get(key) {
231
+ return this.client.request("GET", `${SKILLS_BASE_PATH}/${key}`);
232
+ }
233
+ async deploy(bundle, options) {
234
+ const formData = new FormData();
235
+ const filename = bundle instanceof File ? bundle.name : "skill.tar.gz";
236
+ formData.append("bundle", bundle, filename);
237
+ if (options?.displayName) {
238
+ formData.append("display_name", options.displayName);
239
+ }
240
+ if (options?.moduleSlug) {
241
+ formData.append("module_slug", options.moduleSlug);
242
+ }
243
+ return this.client.requestMultipart("POST", `${SKILLS_BASE_PATH}/deploy`, formData);
244
+ }
245
+ async delete(key) {
246
+ await this.client.request("DELETE", `${SKILLS_BASE_PATH}/${key}`);
247
+ }
248
+ async listVersions(key) {
249
+ const response = await this.client.request(
250
+ "GET",
251
+ `${SKILLS_BASE_PATH}/${key}/versions`
252
+ );
253
+ return response.data;
254
+ }
255
+ async getVersion(key, number) {
256
+ return this.client.request("GET", `${SKILLS_BASE_PATH}/${key}/versions/${number}`);
257
+ }
258
+ };
259
+
260
+ // src/agent/tools.ts
261
+ var TOOLS_BASE_PATH = "/agents/v1/tools";
262
+ var ToolServiceImpl = class {
263
+ constructor(client) {
264
+ this.client = client;
265
+ }
266
+ client;
267
+ list(options = {}) {
268
+ return new PageIterator((opts) => this.listPage(opts), options);
269
+ }
270
+ async listPage(options = {}) {
271
+ return this.client.requestWithQuery("GET", TOOLS_BASE_PATH, options);
272
+ }
273
+ async get(key) {
274
+ return this.client.request("GET", `${TOOLS_BASE_PATH}/${key}`);
275
+ }
276
+ async create(request) {
277
+ return this.client.request("POST", TOOLS_BASE_PATH, request);
278
+ }
279
+ async update(key, request) {
280
+ return this.client.request("PATCH", `${TOOLS_BASE_PATH}/${key}`, request);
281
+ }
282
+ async delete(key) {
283
+ await this.client.request("DELETE", `${TOOLS_BASE_PATH}/${key}`);
284
+ }
285
+ };
286
+
287
+ // src/agent/index.ts
288
+ var AgentClient = class {
289
+ /** Service for managing agents. */
290
+ agents;
291
+ /** Service for managing prompts (versioned). */
292
+ prompts;
293
+ /** Service for managing skills (versioned bundles). */
294
+ skills;
295
+ /** Service for managing tools. */
296
+ tools;
297
+ /** Service for managing MCP server registrations. */
298
+ mcpServers;
299
+ /** Service for managing chat sessions (conversations + event log + stream). */
300
+ sessions;
301
+ /**
302
+ * Creates a new AgentClient instance.
303
+ *
304
+ * @param client - The base ProteosClient to use for API requests
305
+ */
306
+ constructor(client) {
307
+ this.agents = new AgentServiceImpl(client);
308
+ this.prompts = new PromptServiceImpl(client);
309
+ this.skills = new SkillServiceImpl(client);
310
+ this.tools = new ToolServiceImpl(client);
311
+ this.mcpServers = new McpServerServiceImpl(client);
312
+ this.sessions = new SessionServiceImpl(client);
313
+ }
314
+ };
315
+
316
+ // src/auth/me.ts
317
+ var ME_BASE_PATH = "/accounts/v1/me";
318
+ var MeServiceImpl = class {
319
+ constructor(client) {
320
+ this.client = client;
321
+ }
322
+ client;
323
+ async get() {
324
+ return this.client.request("GET", ME_BASE_PATH);
325
+ }
326
+ async organizations() {
327
+ const response = await this.client.request(
328
+ "GET",
329
+ `${ME_BASE_PATH}/organizations`
330
+ );
331
+ return response.data;
332
+ }
333
+ };
334
+
335
+ // src/auth/organizations.ts
336
+ var ORGANIZATIONS_BASE_PATH = "/accounts/v1/organizations";
337
+ var OrganizationServiceImpl = class {
338
+ constructor(client) {
339
+ this.client = client;
340
+ }
341
+ client;
342
+ list(options = {}) {
343
+ return new PageIterator((opts) => this.listPage(opts), options);
344
+ }
345
+ async listPage(options = {}) {
346
+ return this.client.requestWithQuery(
347
+ "GET",
348
+ ORGANIZATIONS_BASE_PATH,
349
+ options
350
+ );
351
+ }
352
+ async get(id) {
353
+ return this.client.request("GET", `${ORGANIZATIONS_BASE_PATH}/${id}`);
354
+ }
355
+ async create(request) {
356
+ return this.client.request("POST", ORGANIZATIONS_BASE_PATH, request);
357
+ }
358
+ async update(id, request) {
359
+ return this.client.request("PATCH", `${ORGANIZATIONS_BASE_PATH}/${id}`, request);
360
+ }
361
+ async delete(id) {
362
+ await this.client.request("DELETE", `${ORGANIZATIONS_BASE_PATH}/${id}`);
363
+ }
364
+ };
365
+
366
+ // src/auth/roles.ts
367
+ var ROLES_BASE_PATH = "/accounts/v1/roles";
368
+ var RoleServiceImpl = class {
369
+ constructor(client) {
370
+ this.client = client;
371
+ }
372
+ client;
373
+ list(options = {}) {
374
+ return new PageIterator((opts) => this.listPage(opts), options);
375
+ }
376
+ async listPage(options = {}) {
377
+ return this.client.requestWithQuery("GET", ROLES_BASE_PATH, options);
378
+ }
379
+ async get(slug) {
380
+ return this.client.request("GET", `${ROLES_BASE_PATH}/${slug}`);
381
+ }
382
+ async create(request) {
383
+ return this.client.request("POST", ROLES_BASE_PATH, request);
384
+ }
385
+ async upsert(slug, request) {
386
+ return this.client.request("PUT", `${ROLES_BASE_PATH}/${slug}`, { ...request, slug });
387
+ }
388
+ async update(slug, request) {
389
+ return this.client.request("PATCH", `${ROLES_BASE_PATH}/${slug}`, request);
390
+ }
391
+ async delete(slug) {
392
+ await this.client.request("DELETE", `${ROLES_BASE_PATH}/${slug}`);
393
+ }
394
+ getPermissions(roleSlug, options = {}) {
395
+ return new PageIterator((opts) => this.fetchPermissionsPage(roleSlug, opts), options);
396
+ }
397
+ async assignPermission(roleSlug, request) {
398
+ return this.client.request(
399
+ "POST",
400
+ `${ROLES_BASE_PATH}/${roleSlug}/permissions`,
401
+ request
402
+ );
403
+ }
404
+ async removePermission(roleSlug, permissionId) {
405
+ await this.client.request(
406
+ "DELETE",
407
+ `${ROLES_BASE_PATH}/${roleSlug}/permissions/${permissionId}`
408
+ );
409
+ }
410
+ async fetchPermissionsPage(roleSlug, options) {
411
+ return this.client.requestWithQuery(
412
+ "GET",
413
+ `${ROLES_BASE_PATH}/${roleSlug}/permissions`,
414
+ options
415
+ );
416
+ }
417
+ };
418
+
419
+ // src/auth/users.ts
420
+ var USERS_BASE_PATH = "/accounts/v1/users";
421
+ var UserServiceImpl = class {
422
+ constructor(client) {
423
+ this.client = client;
424
+ }
425
+ client;
426
+ list(options = {}) {
427
+ return new PageIterator((opts) => this.listPage(opts), options);
428
+ }
429
+ async listPage(options = {}) {
430
+ return this.client.requestWithQuery("GET", USERS_BASE_PATH, options);
431
+ }
432
+ async get(id) {
433
+ return this.client.request("GET", `${USERS_BASE_PATH}/${id}`);
434
+ }
435
+ async create(request) {
436
+ return this.client.request("POST", USERS_BASE_PATH, request);
437
+ }
438
+ async update(id, request) {
439
+ return this.client.request("PATCH", `${USERS_BASE_PATH}/${id}`, request);
440
+ }
441
+ getRoles(userId, options = {}) {
442
+ return new PageIterator((opts) => this.fetchRolesPage(userId, opts), options);
443
+ }
444
+ async assignRole(userId, request) {
445
+ return this.client.request(
446
+ "POST",
447
+ `${USERS_BASE_PATH}/${userId}/roles`,
448
+ request
449
+ );
450
+ }
451
+ async unassignRole(userId, roleSlug) {
452
+ await this.client.request("DELETE", `${USERS_BASE_PATH}/${userId}/roles/${roleSlug}`);
453
+ }
454
+ async listApiKeys(userId) {
455
+ const response = await this.client.request(
456
+ "GET",
457
+ `${USERS_BASE_PATH}/${userId}/api-keys`
458
+ );
459
+ return response.data;
460
+ }
461
+ async createApiKey(userId, request) {
462
+ return this.client.request(
463
+ "POST",
464
+ `${USERS_BASE_PATH}/${userId}/api-keys`,
465
+ request
466
+ );
467
+ }
468
+ async deleteApiKey(userId, keyId) {
469
+ await this.client.request("DELETE", `${USERS_BASE_PATH}/${userId}/api-keys/${keyId}`);
470
+ }
471
+ async fetchRolesPage(userId, options) {
472
+ return this.client.requestWithQuery(
473
+ "GET",
474
+ `${USERS_BASE_PATH}/${userId}/roles`,
475
+ options
476
+ );
477
+ }
478
+ };
479
+
480
+ // src/auth/platform-entities.ts
481
+ var PLATFORM_ENTITIES = [
482
+ // Access (account-service)
483
+ { slug: "organizations", name: "Organizations" },
484
+ { slug: "users", name: "Users" },
485
+ { slug: "roles", name: "Roles" },
486
+ { slug: "user-role-assignments", name: "User Role Assignments" },
487
+ { slug: "role-entity-permissions", name: "Role Entity Permissions" },
488
+ // Schema / content (metadata-service)
489
+ { slug: "entities", name: "Entities" },
490
+ { slug: "pages", name: "Pages" },
491
+ { slug: "menu-configurations", name: "Menu Configurations" },
492
+ { slug: "apps", name: "Apps" },
493
+ { slug: "components", name: "Components" },
494
+ { slug: "lists", name: "Lists" },
495
+ { slug: "list-views", name: "List Views" },
496
+ // System (metadata-service)
497
+ { slug: "modules", name: "Modules" },
498
+ { slug: "variables", name: "Variables" },
499
+ { slug: "deployments", name: "Deployments" },
500
+ // Storage (storage-service)
501
+ { slug: "files", name: "Files" },
502
+ // Automation (function-service)
503
+ { slug: "hooks", name: "Hooks" },
504
+ { slug: "actions", name: "Actions" },
505
+ // Knowledge (knowledge-service)
506
+ { slug: "knowledge-nodes", name: "Knowledge Nodes" },
507
+ { slug: "knowledge-links", name: "Knowledge Links" },
508
+ { slug: "knowledge-labels", name: "Knowledge Labels" },
509
+ // Agent suite (agent-service)
510
+ { slug: "agents", name: "Agents" },
511
+ { slug: "prompts", name: "Prompts" },
512
+ { slug: "skills", name: "Skills" },
513
+ { slug: "tools", name: "Tools" },
514
+ { slug: "mcp-servers", name: "MCP Servers" },
515
+ { slug: "agent-sessions", name: "Agent Sessions" },
516
+ // Messaging bus (event-service)
517
+ { slug: "topics", name: "Topics" },
518
+ { slug: "events", name: "Events" },
519
+ // Conversations (conversation-service). NOTE: `connections` is enforced by
520
+ // BOTH conversation-service and connector-service (2026-07 decision) — same
521
+ // concept in both; conversation connections migrate onto connector-service
522
+ // later.
523
+ { slug: "connections", name: "Connections" },
524
+ { slug: "conversations", name: "Conversations" },
525
+ { slug: "messages", name: "Messages" },
526
+ { slug: "agent-listeners", name: "Agent Listeners" },
527
+ { slug: "transcriptions", name: "Transcriptions" },
528
+ // Connectors (connector-service). `connections` above is shared; this is the
529
+ // manifest catalog.
530
+ { slug: "connectors", name: "Connectors" }
531
+ ];
532
+ var PLATFORM_ENTITY_SLUGS = PLATFORM_ENTITIES.map(
533
+ (entity) => entity.slug
534
+ );
535
+ function isPlatformEntity(slug) {
536
+ return PLATFORM_ENTITY_SLUGS.includes(slug);
537
+ }
538
+ var RoleEntityPermissionSchema = AuditFieldsSchema.extend({
539
+ id: z.string(),
540
+ role_slug: z.string(),
541
+ entity_slug: z.string(),
542
+ permission: z.enum(["read", "write", "delete"])
543
+ });
544
+ var UserRoleAssignmentSchema = AuditFieldsSchema.extend({
545
+ id: z.string(),
546
+ user_id: z.string(),
547
+ role_slug: z.string(),
548
+ org_id: z.string()
549
+ });
550
+ var UserSchema = AuditFieldsSchema.extend({
551
+ id: z.string(),
552
+ email: z.string(),
553
+ given_name: z.string(),
554
+ family_name: z.string(),
555
+ external_id: z.string(),
556
+ default_org_id: z.string()
557
+ });
558
+ AuditFieldsSchema.extend({
559
+ id: z.string(),
560
+ user_id: z.string(),
561
+ org_id: z.string(),
562
+ name: z.string(),
563
+ token_prefix: z.string(),
564
+ token_suffix: z.string(),
565
+ expires_at: z.string().nullable(),
566
+ last_used_at: z.string().nullable()
567
+ });
568
+ var RoleSchema = AuditFieldsSchema.extend({
569
+ slug: z.string(),
570
+ name: z.string(),
571
+ org_id: z.string(),
572
+ description: z.string()
573
+ });
574
+ var OrganizationSchema = AuditFieldsSchema.extend({
575
+ id: z.string(),
576
+ name: z.string(),
577
+ description: z.string()
578
+ });
579
+
580
+ // src/auth/index.ts
581
+ var AccountClient = class {
582
+ /**
583
+ * Service for caller-scoped queries ("who am I", my organizations).
584
+ */
585
+ me;
586
+ /**
587
+ * Service for managing users and their role assignments.
588
+ */
589
+ users;
590
+ /**
591
+ * Service for managing roles and their entity permissions.
592
+ */
593
+ roles;
594
+ /**
595
+ * Service for managing organizations.
596
+ */
597
+ organizations;
598
+ /**
599
+ * Creates a new AccountClient instance.
600
+ *
601
+ * @param client - The base ProteosClient to use for API requests
602
+ */
603
+ constructor(client) {
604
+ this.me = new MeServiceImpl(client);
605
+ this.users = new UserServiceImpl(client);
606
+ this.roles = new RoleServiceImpl(client);
607
+ this.organizations = new OrganizationServiceImpl(client);
608
+ }
609
+ };
610
+
611
+ // src/errors.ts
612
+ var ErrorCode = {
613
+ NOT_FOUND: "not_found",
614
+ UNAUTHORIZED: "unauthorized",
615
+ FORBIDDEN: "forbidden",
616
+ BAD_REQUEST: "bad_request",
617
+ CONFLICT: "conflict",
618
+ INTERNAL_SERVER_ERROR: "internal_server_error",
619
+ INVALID_PAYLOAD: "invalid_payload",
620
+ INVALID_PERSONA: "invalid_persona"
621
+ };
622
+ var ProteosError = class extends Error {
623
+ /** HTTP status code of the response */
624
+ httpStatus;
625
+ /** API error code (e.g., 'not_found', 'unauthorized') */
626
+ code;
627
+ constructor(message, httpStatus, code) {
628
+ super(message);
629
+ this.name = "ProteosError";
630
+ this.httpStatus = httpStatus;
631
+ this.code = code;
632
+ const v8Capture = Error.captureStackTrace;
633
+ if (v8Capture) v8Capture(this, this.constructor);
634
+ }
635
+ /**
636
+ * Returns a formatted string representation of the error.
637
+ */
638
+ toString() {
639
+ return `${this.code}: ${this.message} (HTTP ${this.httpStatus})`;
640
+ }
641
+ };
642
+ function isProteosError(error) {
643
+ return error instanceof ProteosError;
644
+ }
645
+ function isNotFound(error) {
646
+ return isProteosError(error) && error.httpStatus === 404;
647
+ }
648
+ function isUnauthorized(error) {
649
+ return isProteosError(error) && error.httpStatus === 401;
650
+ }
651
+ function isForbidden(error) {
652
+ return isProteosError(error) && error.httpStatus === 403;
653
+ }
654
+ function isBadRequest(error) {
655
+ return isProteosError(error) && error.httpStatus === 400;
656
+ }
657
+ function isConflict(error) {
658
+ return isProteosError(error) && error.httpStatus === 409;
659
+ }
660
+ function getDefaultErrorCode(httpStatus) {
661
+ switch (httpStatus) {
662
+ case 400:
663
+ return ErrorCode.BAD_REQUEST;
664
+ case 401:
665
+ return ErrorCode.UNAUTHORIZED;
666
+ case 403:
667
+ return ErrorCode.FORBIDDEN;
668
+ case 404:
669
+ return ErrorCode.NOT_FOUND;
670
+ case 409:
671
+ return ErrorCode.CONFLICT;
672
+ default:
673
+ return ErrorCode.INTERNAL_SERVER_ERROR;
674
+ }
675
+ }
676
+ async function parseErrorResponse(response) {
677
+ const httpStatus = response.status;
678
+ let code = getDefaultErrorCode(httpStatus);
679
+ let message = "Unknown error";
680
+ try {
681
+ const body = await response.text();
682
+ try {
683
+ const json = JSON.parse(body);
684
+ if (json.code) {
685
+ code = json.code;
686
+ }
687
+ if (json.message) {
688
+ message = json.message;
689
+ } else {
690
+ message = body || `HTTP ${httpStatus}`;
691
+ }
692
+ } catch {
693
+ message = body.trim() || `HTTP ${httpStatus}`;
694
+ }
695
+ } catch {
696
+ message = `HTTP ${httpStatus}`;
697
+ }
698
+ return new ProteosError(message, httpStatus, code);
699
+ }
700
+
701
+ // src/http/query-params.ts
702
+ function toQueryParams(obj) {
703
+ const params = new URLSearchParams();
704
+ if (!obj) {
705
+ return params;
706
+ }
707
+ for (const [key, value] of Object.entries(obj)) {
708
+ appendQueryParam(params, key, value);
709
+ }
710
+ return params;
711
+ }
712
+ function appendQueryParam(params, key, value) {
713
+ if (value === null || value === void 0) {
714
+ return;
715
+ }
716
+ if (Array.isArray(value)) {
717
+ for (const item of value) {
718
+ if (item !== null && item !== void 0) {
719
+ params.append(key, String(item));
720
+ }
721
+ }
722
+ return;
723
+ }
724
+ if (typeof value === "object") {
725
+ return;
726
+ }
727
+ params.set(key, String(value));
728
+ }
729
+ function toQueryString(params) {
730
+ const str = params.toString();
731
+ return str;
732
+ }
733
+ function buildUrl(baseUrl, path, query) {
734
+ const url = new URL(path, baseUrl);
735
+ if (query) {
736
+ const params = toQueryParams(query);
737
+ params.forEach((value, key) => {
738
+ url.searchParams.append(key, value);
739
+ });
740
+ }
741
+ return url.toString();
742
+ }
743
+
744
+ // src/types/options.ts
745
+ var DEFAULT_OPTIONS = {
746
+ timeout: 3e4,
747
+ headers: {}
748
+ };
749
+ function resolveOptions(options) {
750
+ return {
751
+ baseUrl: options.baseUrl.replace(/\/$/, ""),
752
+ // Remove trailing slash
753
+ ...options.token !== void 0 ? { token: options.token } : {},
754
+ ...options.tokenProvider !== void 0 ? { tokenProvider: options.tokenProvider } : {},
755
+ timeout: options.timeout ?? DEFAULT_OPTIONS.timeout,
756
+ fetch: (options.fetch ?? globalThis.fetch).bind(globalThis),
757
+ headers: { ...DEFAULT_OPTIONS.headers, ...options.headers }
758
+ };
759
+ }
760
+
761
+ // src/client.ts
762
+ function isAbortError(error) {
763
+ return error instanceof DOMException && error.name === "AbortError";
764
+ }
765
+ var ProteosClient = class {
766
+ options;
767
+ /**
768
+ * Creates a new ProteosClient instance.
769
+ *
770
+ * @param options - Client configuration options
771
+ *
772
+ * @example
773
+ * ```ts
774
+ * // With static token
775
+ * const client = new ProteosClient({
776
+ * baseUrl: 'https://api.proteos.ai',
777
+ * token: 'your-api-token',
778
+ * });
779
+ *
780
+ * // With dynamic token provider
781
+ * const client = new ProteosClient({
782
+ * baseUrl: 'https://api.proteos.ai',
783
+ * tokenProvider: async () => {
784
+ * return await authService.getAccessToken();
785
+ * },
786
+ * });
787
+ * ```
788
+ */
789
+ constructor(options) {
790
+ this.options = resolveOptions(options);
791
+ }
792
+ /**
793
+ * Returns the base URL configured for this client.
794
+ */
795
+ get baseUrl() {
796
+ return this.options.baseUrl;
797
+ }
798
+ /**
799
+ * Gets the current authentication token.
800
+ * Calls tokenProvider if available, otherwise returns static token.
801
+ */
802
+ async getToken() {
803
+ if (this.options.tokenProvider) {
804
+ return await this.options.tokenProvider();
805
+ }
806
+ return this.options.token;
807
+ }
808
+ /**
809
+ * Builds the headers for a request.
810
+ */
811
+ async buildHeaders(requestOptions) {
812
+ const headers = new Headers({
813
+ "Content-Type": "application/json",
814
+ Accept: "application/json",
815
+ ...this.options.headers,
816
+ ...requestOptions?.headers
817
+ });
818
+ const token = await this.getToken();
819
+ if (token) {
820
+ headers.set("Authorization", `Bearer ${token}`);
821
+ }
822
+ return headers;
823
+ }
824
+ /**
825
+ * Creates an AbortSignal with timeout.
826
+ */
827
+ createTimeoutSignal(requestOptions) {
828
+ const timeout = requestOptions?.timeout ?? this.options.timeout;
829
+ if (requestOptions?.signal) {
830
+ const controller = new AbortController();
831
+ requestOptions.signal.addEventListener("abort", () => {
832
+ controller.abort(requestOptions.signal?.reason);
833
+ });
834
+ const timeoutId = setTimeout(() => {
835
+ controller.abort(new Error(`Request timeout after ${timeout}ms`));
836
+ }, timeout);
837
+ controller.signal.addEventListener("abort", () => {
838
+ clearTimeout(timeoutId);
839
+ });
840
+ return controller.signal;
841
+ }
842
+ return AbortSignal.timeout(timeout);
843
+ }
844
+ /**
845
+ * Performs an HTTP request and decodes the JSON response.
846
+ *
847
+ * @param method - HTTP method (GET, POST, PATCH, DELETE, etc.)
848
+ * @param path - Request path (appended to baseUrl)
849
+ * @param body - Request body (will be JSON-serialized)
850
+ * @param requestOptions - Optional request configuration
851
+ * @returns Decoded response body
852
+ * @throws {ProteosError} If the response status is >= 400
853
+ */
854
+ async request(method, path, body, requestOptions) {
855
+ return this.requestWithQuery(method, path, void 0, body, requestOptions);
856
+ }
857
+ /**
858
+ * Performs an HTTP request with query parameters.
859
+ *
860
+ * @param method - HTTP method
861
+ * @param path - Request path
862
+ * @param query - Query parameters object
863
+ * @param body - Request body
864
+ * @param requestOptions - Optional request configuration
865
+ * @returns Decoded response body
866
+ * @throws {ProteosError} If the response status is >= 400
867
+ */
868
+ async requestWithQuery(method, path, query, body, requestOptions) {
869
+ let url = `${this.options.baseUrl}${path}`;
870
+ if (query) {
871
+ const params = toQueryParams(query);
872
+ const queryString = params.toString();
873
+ if (queryString) {
874
+ url += `?${queryString}`;
875
+ }
876
+ }
877
+ const headers = await this.buildHeaders(requestOptions);
878
+ const signal = this.createTimeoutSignal(requestOptions);
879
+ const response = await this.options.fetch(url, {
880
+ method,
881
+ headers,
882
+ body: body !== void 0 ? JSON.stringify(body) : null,
883
+ signal
884
+ });
885
+ if (response.status >= 400) {
886
+ throw await parseErrorResponse(response);
887
+ }
888
+ if (response.status === 204) {
889
+ return void 0;
890
+ }
891
+ const text = await response.text();
892
+ if (!text) {
893
+ return void 0;
894
+ }
895
+ try {
896
+ return JSON.parse(text);
897
+ } catch {
898
+ throw new ProteosError(
899
+ `Failed to parse response as JSON: ${text.slice(0, 100)}`,
900
+ response.status,
901
+ "parse_error"
902
+ );
903
+ }
904
+ }
905
+ /**
906
+ * Performs a multipart form request (for file uploads).
907
+ *
908
+ * @param method - HTTP method
909
+ * @param path - Request path
910
+ * @param formData - FormData instance with files and fields
911
+ * @param requestOptions - Optional request configuration
912
+ * @returns Decoded response body
913
+ * @throws {ProteosError} If the response status is >= 400
914
+ */
915
+ async requestMultipart(method, path, formData, requestOptions) {
916
+ const url = `${this.options.baseUrl}${path}`;
917
+ const headers = new Headers({
918
+ Accept: "application/json",
919
+ ...this.options.headers,
920
+ ...requestOptions?.headers
921
+ });
922
+ const token = await this.getToken();
923
+ if (token) {
924
+ headers.set("Authorization", `Bearer ${token}`);
925
+ }
926
+ const signal = this.createTimeoutSignal(requestOptions);
927
+ const response = await this.options.fetch(url, {
928
+ method,
929
+ headers,
930
+ body: formData,
931
+ signal
932
+ });
933
+ if (response.status >= 400) {
934
+ throw await parseErrorResponse(response);
935
+ }
936
+ if (response.status === 204) {
937
+ return void 0;
938
+ }
939
+ return await response.json();
940
+ }
941
+ /**
942
+ * Performs an HTTP request and returns the raw response.
943
+ * Used for downloading files or streaming responses.
944
+ *
945
+ * @param method - HTTP method
946
+ * @param path - Request path
947
+ * @param body - Request body
948
+ * @param requestOptions - Optional request configuration
949
+ * @returns Object with response body stream and full Response object
950
+ * @throws {ProteosError} If the response status is >= 400
951
+ */
952
+ async requestRaw(method, path, body, requestOptions) {
953
+ const url = `${this.options.baseUrl}${path}`;
954
+ const headers = await this.buildHeaders(requestOptions);
955
+ const signal = this.createTimeoutSignal(requestOptions);
956
+ const response = await this.options.fetch(url, {
957
+ method,
958
+ headers,
959
+ body: body !== void 0 ? JSON.stringify(body) : null,
960
+ signal
961
+ });
962
+ if (response.status >= 400) {
963
+ throw await parseErrorResponse(response);
964
+ }
965
+ return {
966
+ body: response.body,
967
+ response
968
+ };
969
+ }
970
+ /**
971
+ * Opens a Server-Sent-Events stream and yields each frame as it arrives.
972
+ *
973
+ * Built on `@microsoft/fetch-event-source` (not the browser-native
974
+ * `EventSource`, which can't set an `Authorization` header) so the bearer token
975
+ * is attached like any other request. The library tracks `Last-Event-ID` and
976
+ * reconnects with exponential backoff on transient errors; a 4xx is fatal and
977
+ * rejects. The stream runs until the caller's `AbortSignal` fires.
978
+ *
979
+ * The token is resolved once at stream start; teardown is the caller's signal.
980
+ *
981
+ * @param path - Request path (appended to baseUrl)
982
+ * @param requestOptions - Optional request configuration (signal)
983
+ * @returns Async generator of parsed {@link SseFrame}s
984
+ * @throws {ProteosError} On a non-retryable (4xx) response
985
+ */
986
+ async *streamEvents(path, requestOptions) {
987
+ const url = `${this.options.baseUrl}${path}`;
988
+ const headers = { ...this.options.headers };
989
+ const token = await this.getToken();
990
+ if (token) {
991
+ headers.Authorization = `Bearer ${token}`;
992
+ }
993
+ const queue = [];
994
+ let wake = null;
995
+ let finished = false;
996
+ let failure;
997
+ const notify = () => {
998
+ wake?.();
999
+ wake = null;
1000
+ };
1001
+ const push = (frame) => {
1002
+ queue.push(frame);
1003
+ notify();
1004
+ };
1005
+ const finish = (error) => {
1006
+ if (error !== void 0) failure = error;
1007
+ finished = true;
1008
+ notify();
1009
+ };
1010
+ const controller = new AbortController();
1011
+ const onExternalAbort = () => controller.abort();
1012
+ if (requestOptions?.signal) {
1013
+ if (requestOptions.signal.aborted) controller.abort();
1014
+ else requestOptions.signal.addEventListener("abort", onExternalAbort, { once: true });
1015
+ }
1016
+ const streaming = fetchEventSource(url, {
1017
+ method: "GET",
1018
+ headers,
1019
+ signal: controller.signal,
1020
+ fetch: this.options.fetch,
1021
+ // Keep streaming when the tab is backgrounded (default would disconnect).
1022
+ openWhenHidden: true,
1023
+ onopen: async (response) => {
1024
+ if (response.status >= 400) {
1025
+ throw await parseErrorResponse(response);
1026
+ }
1027
+ },
1028
+ onmessage: (message) => {
1029
+ push({
1030
+ id: message.id || void 0,
1031
+ event: message.event || void 0,
1032
+ data: message.data
1033
+ });
1034
+ },
1035
+ onerror: (error) => {
1036
+ if (isAbortError(error)) throw error;
1037
+ if (error instanceof ProteosError && error.httpStatus >= 400 && error.httpStatus < 500) {
1038
+ throw error;
1039
+ }
1040
+ return 2e3;
1041
+ }
1042
+ }).then(() => finish()).catch((error) => finish(error));
1043
+ try {
1044
+ while (true) {
1045
+ if (queue.length > 0) {
1046
+ yield queue.shift();
1047
+ continue;
1048
+ }
1049
+ if (finished) break;
1050
+ await new Promise((resolve) => {
1051
+ wake = resolve;
1052
+ });
1053
+ }
1054
+ if (failure !== void 0 && !isAbortError(failure)) throw failure;
1055
+ } finally {
1056
+ controller.abort();
1057
+ requestOptions?.signal?.removeEventListener("abort", onExternalAbort);
1058
+ await streaming.catch(() => {
1059
+ });
1060
+ }
1061
+ }
1062
+ /**
1063
+ * Opens an authenticated WebSocket to a service path and resolves once it is
1064
+ * open.
1065
+ *
1066
+ * The browser-native `WebSocket` can't set an `Authorization` header, so the
1067
+ * access token is passed via the `bearer` subprotocol (`["bearer", token]`),
1068
+ * which the gateway lifts back into the auth header — the same token resolved
1069
+ * for every other request. The `http(s)` base URL is rewritten to `ws(s)`.
1070
+ *
1071
+ * @param path - Request path (appended to baseUrl), including any query string
1072
+ * @returns The open WebSocket
1073
+ */
1074
+ async openWebSocket(path) {
1075
+ const wsBaseUrl = this.options.baseUrl.replace(/^http/, "ws");
1076
+ const url = `${wsBaseUrl}${path}`;
1077
+ const token = await this.getToken();
1078
+ const socket = token ? new WebSocket(url, ["bearer", token]) : new WebSocket(url);
1079
+ await new Promise((resolve, reject) => {
1080
+ socket.onopen = () => resolve();
1081
+ socket.onerror = () => reject(new ProteosError("WebSocket connection failed", 0, "ws_error"));
1082
+ });
1083
+ socket.onopen = null;
1084
+ socket.onerror = null;
1085
+ return socket;
1086
+ }
1087
+ };
1088
+
1089
+ // src/conversation/voice.ts
1090
+ var VOICE_BASE_PATH = "/conversations/v1/voice";
1091
+ var VoiceServiceImpl = class {
1092
+ constructor(client) {
1093
+ this.client = client;
1094
+ }
1095
+ client;
1096
+ async transcribeStream(options) {
1097
+ const query = buildQuery(options);
1098
+ const socket = await this.client.openWebSocket(`${VOICE_BASE_PATH}/transcribe/stream${query}`);
1099
+ socket.binaryType = "arraybuffer";
1100
+ socket.onmessage = (event) => {
1101
+ if (typeof event.data !== "string") return;
1102
+ try {
1103
+ options.onResult(JSON.parse(event.data));
1104
+ } catch {
1105
+ }
1106
+ };
1107
+ if (options.onError) socket.onerror = options.onError;
1108
+ socket.onclose = () => options.onClose?.();
1109
+ const isOpen = () => socket.readyState === WebSocket.OPEN;
1110
+ return {
1111
+ sendAudio: (chunk) => {
1112
+ if (isOpen()) socket.send(chunk);
1113
+ },
1114
+ finalize: () => {
1115
+ if (isOpen()) socket.send(JSON.stringify({ type: "finalize" }));
1116
+ },
1117
+ close: () => socket.close()
1118
+ };
1119
+ }
1120
+ };
1121
+ function buildQuery(options) {
1122
+ const params = new URLSearchParams();
1123
+ if (options.language) params.set("language", options.language);
1124
+ if (options.interimResults !== void 0)
1125
+ params.set("interim_results", String(options.interimResults));
1126
+ if (options.punctuate !== void 0) params.set("punctuate", String(options.punctuate));
1127
+ if (options.smartFormat !== void 0) params.set("smart_format", String(options.smartFormat));
1128
+ if (options.encoding) params.set("encoding", options.encoding);
1129
+ if (options.sampleRate !== void 0) params.set("sample_rate", String(options.sampleRate));
1130
+ const queryString = params.toString();
1131
+ return queryString ? `?${queryString}` : "";
1132
+ }
1133
+
1134
+ // src/conversation/index.ts
1135
+ var CONVERSATION_BASE_PATH = "/conversations/v1";
1136
+ var ConversationClient = class {
1137
+ connections;
1138
+ conversations;
1139
+ messages;
1140
+ agentListeners;
1141
+ transcriptions;
1142
+ /** Realtime speech-to-text (dictation) — moved here from agent-service. */
1143
+ voice;
1144
+ constructor(client) {
1145
+ this.connections = new ConnectionServiceImpl(client);
1146
+ this.conversations = new ConversationServiceImpl(client);
1147
+ this.messages = new MessageServiceImpl(client);
1148
+ this.agentListeners = new AgentListenerServiceImpl(client);
1149
+ this.transcriptions = new TranscriptionServiceImpl(client);
1150
+ this.voice = new VoiceServiceImpl(client);
1151
+ }
1152
+ };
1153
+ var ConnectionServiceImpl = class {
1154
+ constructor(client) {
1155
+ this.client = client;
1156
+ }
1157
+ client;
1158
+ list(query = {}) {
1159
+ return this.client.requestWithQuery("GET", `${CONVERSATION_BASE_PATH}/connections`, query);
1160
+ }
1161
+ get(id) {
1162
+ return this.client.request("GET", `${CONVERSATION_BASE_PATH}/connections/${encodeURIComponent(id)}`);
1163
+ }
1164
+ create(request) {
1165
+ return this.client.request("POST", `${CONVERSATION_BASE_PATH}/connections`, request);
1166
+ }
1167
+ update(id, request) {
1168
+ return this.client.request("PATCH", `${CONVERSATION_BASE_PATH}/connections/${encodeURIComponent(id)}`, request);
1169
+ }
1170
+ async delete(id) {
1171
+ await this.client.request("DELETE", `${CONVERSATION_BASE_PATH}/connections/${encodeURIComponent(id)}`);
1172
+ }
1173
+ install(id) {
1174
+ return this.client.request("POST", `${CONVERSATION_BASE_PATH}/connections/${encodeURIComponent(id)}/install`);
1175
+ }
1176
+ listParticipants(connectionId, query = {}) {
1177
+ return this.client.requestWithQuery(
1178
+ "GET",
1179
+ `${CONVERSATION_BASE_PATH}/connections/${encodeURIComponent(connectionId)}/participants`,
1180
+ query
1181
+ );
1182
+ }
1183
+ listRooms(connectionId, query = {}) {
1184
+ return this.client.requestWithQuery(
1185
+ "GET",
1186
+ `${CONVERSATION_BASE_PATH}/connections/${encodeURIComponent(connectionId)}/rooms`,
1187
+ query
1188
+ );
1189
+ }
1190
+ };
1191
+ var ConversationServiceImpl = class {
1192
+ constructor(client) {
1193
+ this.client = client;
1194
+ }
1195
+ client;
1196
+ list(query = {}) {
1197
+ return this.client.requestWithQuery("GET", `${CONVERSATION_BASE_PATH}/conversations`, query);
1198
+ }
1199
+ get(id) {
1200
+ return this.client.request("GET", `${CONVERSATION_BASE_PATH}/conversations/${encodeURIComponent(id)}`);
1201
+ }
1202
+ end(id) {
1203
+ return this.client.request("POST", `${CONVERSATION_BASE_PATH}/conversations/${encodeURIComponent(id)}/end`);
1204
+ }
1205
+ markRead(id) {
1206
+ return this.client.request("POST", `${CONVERSATION_BASE_PATH}/conversations/${encodeURIComponent(id)}/read`);
1207
+ }
1208
+ markUnread(id) {
1209
+ return this.client.request("DELETE", `${CONVERSATION_BASE_PATH}/conversations/${encodeURIComponent(id)}/read`);
1210
+ }
1211
+ unreadCounts() {
1212
+ return this.client.request("GET", `${CONVERSATION_BASE_PATH}/conversations/unread-counts`);
1213
+ }
1214
+ };
1215
+ var MessageServiceImpl = class {
1216
+ constructor(client) {
1217
+ this.client = client;
1218
+ }
1219
+ client;
1220
+ listByConversation(conversationId, query = {}) {
1221
+ return this.client.requestWithQuery(
1222
+ "GET",
1223
+ `${CONVERSATION_BASE_PATH}/conversations/${encodeURIComponent(conversationId)}/messages`,
1224
+ query
1225
+ );
1226
+ }
1227
+ send(request) {
1228
+ return this.client.request("POST", `${CONVERSATION_BASE_PATH}/messages/send`, request);
1229
+ }
1230
+ async getReactions(messageId) {
1231
+ const response = await this.client.request(
1232
+ "GET",
1233
+ `${CONVERSATION_BASE_PATH}/messages/${encodeURIComponent(messageId)}/reactions`
1234
+ );
1235
+ return response.data;
1236
+ }
1237
+ async addReaction(messageId, emoji) {
1238
+ const response = await this.client.request(
1239
+ "POST",
1240
+ `${CONVERSATION_BASE_PATH}/messages/${encodeURIComponent(messageId)}/reactions`,
1241
+ { emoji }
1242
+ );
1243
+ return response.data;
1244
+ }
1245
+ async removeReaction(messageId, emoji) {
1246
+ const response = await this.client.request(
1247
+ "DELETE",
1248
+ `${CONVERSATION_BASE_PATH}/messages/${encodeURIComponent(messageId)}/reactions/${encodeURIComponent(emoji)}`
1249
+ );
1250
+ return response.data;
1251
+ }
1252
+ };
1253
+ var AgentListenerServiceImpl = class {
1254
+ constructor(client) {
1255
+ this.client = client;
1256
+ }
1257
+ client;
1258
+ list(query = {}) {
1259
+ return this.client.requestWithQuery("GET", `${CONVERSATION_BASE_PATH}/agent-listeners`, query);
1260
+ }
1261
+ get(id) {
1262
+ return this.client.request("GET", `${CONVERSATION_BASE_PATH}/agent-listeners/${encodeURIComponent(id)}`);
1263
+ }
1264
+ create(request) {
1265
+ return this.client.request("POST", `${CONVERSATION_BASE_PATH}/agent-listeners`, request);
1266
+ }
1267
+ update(id, request) {
1268
+ return this.client.request("PATCH", `${CONVERSATION_BASE_PATH}/agent-listeners/${encodeURIComponent(id)}`, request);
1269
+ }
1270
+ async delete(id) {
1271
+ await this.client.request("DELETE", `${CONVERSATION_BASE_PATH}/agent-listeners/${encodeURIComponent(id)}`);
1272
+ }
1273
+ };
1274
+ var TranscriptionServiceImpl = class {
1275
+ constructor(client) {
1276
+ this.client = client;
1277
+ }
1278
+ client;
1279
+ createFromFile(request) {
1280
+ return this.client.request("POST", `${CONVERSATION_BASE_PATH}/transcriptions`, request);
1281
+ }
1282
+ list(query = {}) {
1283
+ return this.client.requestWithQuery("GET", `${CONVERSATION_BASE_PATH}/transcriptions`, query);
1284
+ }
1285
+ get(id) {
1286
+ return this.client.request("GET", `${CONVERSATION_BASE_PATH}/transcriptions/${encodeURIComponent(id)}`);
1287
+ }
1288
+ materialize(id, request = {}) {
1289
+ return this.client.request(
1290
+ "POST",
1291
+ `${CONVERSATION_BASE_PATH}/transcriptions/${encodeURIComponent(id)}/materialize`,
1292
+ request
1293
+ );
1294
+ }
1295
+ };
1296
+
1297
+ // src/connector/index.ts
1298
+ var CONNECTOR_BASE_PATH = "/connectors/v1";
1299
+ var ConnectorClient = class {
1300
+ connectors;
1301
+ connections;
1302
+ constructor(client) {
1303
+ this.connectors = new ConnectorCatalogServiceImpl(client);
1304
+ this.connections = new ConnectorConnectionServiceImpl(client);
1305
+ }
1306
+ };
1307
+ var ConnectorCatalogServiceImpl = class {
1308
+ constructor(client) {
1309
+ this.client = client;
1310
+ }
1311
+ client;
1312
+ list(query = {}) {
1313
+ return this.client.requestWithQuery("GET", `${CONNECTOR_BASE_PATH}/connectors`, query);
1314
+ }
1315
+ get(key) {
1316
+ return this.client.request("GET", `${CONNECTOR_BASE_PATH}/connectors/${encodeURIComponent(key)}`);
1317
+ }
1318
+ async listMethods(key) {
1319
+ const connector = await this.get(key);
1320
+ return connector.methods ?? [];
1321
+ }
1322
+ };
1323
+ var ConnectorConnectionServiceImpl = class {
1324
+ constructor(client) {
1325
+ this.client = client;
1326
+ }
1327
+ client;
1328
+ list(query = {}) {
1329
+ return this.client.requestWithQuery("GET", `${CONNECTOR_BASE_PATH}/connections`, query);
1330
+ }
1331
+ get(id) {
1332
+ return this.client.request("GET", `${CONNECTOR_BASE_PATH}/connections/${encodeURIComponent(id)}`);
1333
+ }
1334
+ create(request) {
1335
+ return this.client.request("POST", `${CONNECTOR_BASE_PATH}/connections`, request);
1336
+ }
1337
+ update(id, request) {
1338
+ return this.client.request("PATCH", `${CONNECTOR_BASE_PATH}/connections/${encodeURIComponent(id)}`, request);
1339
+ }
1340
+ async delete(id) {
1341
+ await this.client.request("DELETE", `${CONNECTOR_BASE_PATH}/connections/${encodeURIComponent(id)}`);
1342
+ }
1343
+ install(id) {
1344
+ return this.client.request("POST", `${CONNECTOR_BASE_PATH}/connections/${encodeURIComponent(id)}/install`);
1345
+ }
1346
+ token(id) {
1347
+ return this.client.request("POST", `${CONNECTOR_BASE_PATH}/connections/${encodeURIComponent(id)}/token`);
1348
+ }
1349
+ async invokeMethod(id, method, params = {}) {
1350
+ const response = await this.client.request(
1351
+ "POST",
1352
+ `${CONNECTOR_BASE_PATH}/connections/${encodeURIComponent(id)}/methods/${encodeURIComponent(method)}/invoke`,
1353
+ params
1354
+ );
1355
+ return response.result;
1356
+ }
1357
+ };
1358
+
1359
+ // src/data/queries.ts
1360
+ var QUERY_BASE_PATH = "/data/v1/query";
1361
+ var QueryServiceImpl = class {
1362
+ constructor(client) {
1363
+ this.client = client;
1364
+ }
1365
+ client;
1366
+ async execute(sql) {
1367
+ return this.client.request("POST", `${QUERY_BASE_PATH}/execute`, { sql });
1368
+ }
1369
+ async validate(sql) {
1370
+ return this.client.request("POST", `${QUERY_BASE_PATH}/validate`, {
1371
+ sql
1372
+ });
1373
+ }
1374
+ };
1375
+
1376
+ // src/data/records.ts
1377
+ var RECORDS_BASE_PATH = "/data/v1/records";
1378
+ var BATCH_RECORDS_BASE_PATH = "/data/v1/batch/records";
1379
+ var RecordServiceImpl = class {
1380
+ constructor(client) {
1381
+ this.client = client;
1382
+ }
1383
+ client;
1384
+ list(entitySlug, options = {}) {
1385
+ return new PageIterator((opts) => this.listPage(entitySlug, opts), options);
1386
+ }
1387
+ async listPage(entitySlug, options = {}) {
1388
+ return this.client.requestWithQuery(
1389
+ "GET",
1390
+ `${RECORDS_BASE_PATH}/${entitySlug}`,
1391
+ options
1392
+ );
1393
+ }
1394
+ async get(entitySlug, id) {
1395
+ return this.client.request("GET", `${RECORDS_BASE_PATH}/${entitySlug}/${id}`);
1396
+ }
1397
+ async create(entitySlug, data) {
1398
+ return this.client.request("POST", `${RECORDS_BASE_PATH}/${entitySlug}`, data);
1399
+ }
1400
+ async update(entitySlug, id, data) {
1401
+ return this.client.request(
1402
+ "PATCH",
1403
+ `${RECORDS_BASE_PATH}/${entitySlug}/${id}`,
1404
+ data
1405
+ );
1406
+ }
1407
+ async delete(entitySlug, id) {
1408
+ await this.client.request("DELETE", `${RECORDS_BASE_PATH}/${entitySlug}/${id}`);
1409
+ }
1410
+ async batchUpsert(entitySlug, transactions) {
1411
+ return this.client.request(
1412
+ "POST",
1413
+ `${BATCH_RECORDS_BASE_PATH}/${entitySlug}/upsert`,
1414
+ transactions
1415
+ );
1416
+ }
1417
+ };
1418
+ var BatchUpsertTransactionSchema = z.object({
1419
+ transaction_id: z.string(),
1420
+ data: z.record(z.unknown())
1421
+ });
1422
+ var BatchTransactionErrorSchema = z.object({
1423
+ code: z.string(),
1424
+ message: z.string()
1425
+ });
1426
+ var BatchUpsertTransactionResultSchema = z.object({
1427
+ transaction_id: z.string(),
1428
+ status: z.enum(["success", "error"]),
1429
+ record: z.record(z.unknown()).optional(),
1430
+ error: BatchTransactionErrorSchema.optional()
1431
+ });
1432
+ var BatchUpsertRecordsResponseSchema = z.object({
1433
+ results: z.array(BatchUpsertTransactionResultSchema)
1434
+ });
1435
+
1436
+ // src/data/index.ts
1437
+ var DataClient = class {
1438
+ records;
1439
+ queries;
1440
+ constructor(client) {
1441
+ this.records = new RecordServiceImpl(client);
1442
+ this.queries = new QueryServiceImpl(client);
1443
+ }
1444
+ };
1445
+
1446
+ // src/events/index.ts
1447
+ var EVENTS_BASE_PATH = "/events/v1";
1448
+ var TAIL_TIMEOUT_MS = 24 * 60 * 60 * 1e3;
1449
+ var EventsClient = class {
1450
+ topics;
1451
+ constructor(client) {
1452
+ this.topics = new TopicServiceImpl(client);
1453
+ }
1454
+ };
1455
+ var TopicServiceImpl = class {
1456
+ constructor(client) {
1457
+ this.client = client;
1458
+ }
1459
+ client;
1460
+ async list() {
1461
+ const response = await this.client.request(
1462
+ "GET",
1463
+ `${EVENTS_BASE_PATH}/topics`
1464
+ );
1465
+ return response.data ?? [];
1466
+ }
1467
+ async events(topic, options = {}) {
1468
+ const response = await this.client.requestWithQuery(
1469
+ "GET",
1470
+ `${EVENTS_BASE_PATH}/topics/${encodeURIComponent(topic)}/events`,
1471
+ options
1472
+ );
1473
+ return response.data ?? [];
1474
+ }
1475
+ async *tail(topic, options = {}) {
1476
+ const path = `${EVENTS_BASE_PATH}/topics/${encodeURIComponent(topic)}/events?follow=true`;
1477
+ let body;
1478
+ try {
1479
+ ;
1480
+ ({ body } = await this.client.requestRaw("GET", path, void 0, {
1481
+ timeout: TAIL_TIMEOUT_MS,
1482
+ ...options.signal ? { signal: options.signal } : {},
1483
+ headers: { Accept: "application/x-ndjson" }
1484
+ }));
1485
+ } catch (error) {
1486
+ if (isAbort(error)) return;
1487
+ throw error;
1488
+ }
1489
+ if (!body) return;
1490
+ const reader = body.getReader();
1491
+ const decoder = new TextDecoder();
1492
+ let buffer = "";
1493
+ try {
1494
+ while (true) {
1495
+ const { done, value } = await reader.read();
1496
+ if (done) break;
1497
+ buffer += decoder.decode(value, { stream: true });
1498
+ let newlineIndex = buffer.indexOf("\n");
1499
+ while (newlineIndex !== -1) {
1500
+ const line = buffer.slice(0, newlineIndex).trim();
1501
+ buffer = buffer.slice(newlineIndex + 1);
1502
+ const event = parseLine(line);
1503
+ if (event) yield event;
1504
+ newlineIndex = buffer.indexOf("\n");
1505
+ }
1506
+ }
1507
+ const remainder = parseLine(buffer.trim());
1508
+ if (remainder) yield remainder;
1509
+ } catch (error) {
1510
+ if (!isAbort(error)) throw error;
1511
+ } finally {
1512
+ reader.releaseLock();
1513
+ void body.cancel().catch(() => {
1514
+ });
1515
+ }
1516
+ }
1517
+ async publish(topic, request) {
1518
+ return this.client.request(
1519
+ "POST",
1520
+ `${EVENTS_BASE_PATH}/topics/${encodeURIComponent(topic)}/events`,
1521
+ request
1522
+ );
1523
+ }
1524
+ async redrive(topic) {
1525
+ return this.client.request(
1526
+ "POST",
1527
+ `${EVENTS_BASE_PATH}/topics/${encodeURIComponent(topic)}/redrive`
1528
+ );
1529
+ }
1530
+ async purge(topic) {
1531
+ await this.client.request(
1532
+ "POST",
1533
+ `${EVENTS_BASE_PATH}/topics/${encodeURIComponent(topic)}/purge`
1534
+ );
1535
+ }
1536
+ };
1537
+ function isAbort(error) {
1538
+ return error instanceof DOMException && error.name === "AbortError";
1539
+ }
1540
+ function parseLine(line) {
1541
+ if (!line) return null;
1542
+ try {
1543
+ return JSON.parse(line);
1544
+ } catch {
1545
+ return null;
1546
+ }
1547
+ }
1548
+
1549
+ // src/functions/actions.ts
1550
+ var ACTIONS_BASE_PATH = "/functions/v1/actions";
1551
+ var ActionServiceImpl = class {
1552
+ constructor(client) {
1553
+ this.client = client;
1554
+ }
1555
+ client;
1556
+ list(options = {}) {
1557
+ return new PageIterator((opts) => this.listPage(opts), options);
1558
+ }
1559
+ async listPage(options = {}) {
1560
+ return this.client.requestWithQuery("GET", ACTIONS_BASE_PATH, options);
1561
+ }
1562
+ async get(slug) {
1563
+ return this.client.request("GET", `${ACTIONS_BASE_PATH}/${slug}`);
1564
+ }
1565
+ async invokeGlobal(slug, params) {
1566
+ const response = await this.client.request(
1567
+ "POST",
1568
+ `${ACTIONS_BASE_PATH}/${slug}/invoke`,
1569
+ params
1570
+ );
1571
+ return response.result;
1572
+ }
1573
+ async invokeEntity(entitySlug, recordId, slug, params) {
1574
+ const response = await this.client.request(
1575
+ "POST",
1576
+ `/functions/v1/entities/${entitySlug}/records/${recordId}/actions/${slug}/invoke`,
1577
+ params
1578
+ );
1579
+ return response.result;
1580
+ }
1581
+ };
1582
+ var ActionScopeSchema = z.enum(["entity", "global"]);
1583
+ var ActionSchema = AuditFieldsSchema.extend({
1584
+ slug: z.string(),
1585
+ org_id: z.string(),
1586
+ module_slug: z.string(),
1587
+ scope: ActionScopeSchema,
1588
+ entity: z.string().optional(),
1589
+ name: z.string(),
1590
+ is_active: z.boolean(),
1591
+ file_id: z.string(),
1592
+ params: z.array(AttributeSchema),
1593
+ returns: z.array(AttributeSchema)
1594
+ });
1595
+
1596
+ // src/functions/index.ts
1597
+ var FunctionsClient = class {
1598
+ actions;
1599
+ constructor(client) {
1600
+ this.actions = new ActionServiceImpl(client);
1601
+ }
1602
+ };
1603
+
1604
+ // src/knowledge/graph.ts
1605
+ var GRAPH_BASE_PATH = "/knowledge/v1/graph";
1606
+ var GraphServiceImpl = class {
1607
+ constructor(client) {
1608
+ this.client = client;
1609
+ }
1610
+ client;
1611
+ async get(options = {}) {
1612
+ const query = {};
1613
+ if (options.label_ids && options.label_ids.length > 0) {
1614
+ query.label_ids = options.label_ids.join(",");
1615
+ }
1616
+ return this.client.requestWithQuery("GET", GRAPH_BASE_PATH, query);
1617
+ }
1618
+ };
1619
+
1620
+ // src/knowledge/labels.ts
1621
+ var LABELS_BASE_PATH = "/knowledge/v1/labels";
1622
+ var LabelServiceImpl = class {
1623
+ constructor(client) {
1624
+ this.client = client;
1625
+ }
1626
+ client;
1627
+ list(options = {}) {
1628
+ return new PageIterator((opts) => this.listPage(opts), options);
1629
+ }
1630
+ async listPage(options = {}) {
1631
+ return this.client.requestWithQuery(
1632
+ "GET",
1633
+ LABELS_BASE_PATH,
1634
+ options
1635
+ );
1636
+ }
1637
+ async get(id) {
1638
+ return this.client.request("GET", `${LABELS_BASE_PATH}/${id}`);
1639
+ }
1640
+ async create(request) {
1641
+ return this.client.request("POST", LABELS_BASE_PATH, request);
1642
+ }
1643
+ async update(id, request) {
1644
+ return this.client.request("PATCH", `${LABELS_BASE_PATH}/${id}`, request);
1645
+ }
1646
+ async delete(id) {
1647
+ await this.client.request("DELETE", `${LABELS_BASE_PATH}/${id}`);
1648
+ }
1649
+ };
1650
+
1651
+ // src/knowledge/links.ts
1652
+ var LINKS_BASE_PATH = "/knowledge/v1/links";
1653
+ var LinkServiceImpl = class {
1654
+ constructor(client) {
1655
+ this.client = client;
1656
+ }
1657
+ client;
1658
+ list(options = {}) {
1659
+ return new PageIterator((opts) => this.listPage(opts), options);
1660
+ }
1661
+ async listPage(options = {}) {
1662
+ return this.client.requestWithQuery("GET", LINKS_BASE_PATH, options);
1663
+ }
1664
+ async get(id) {
1665
+ return this.client.request("GET", `${LINKS_BASE_PATH}/${id}`);
1666
+ }
1667
+ async create(request) {
1668
+ return this.client.request("POST", LINKS_BASE_PATH, request);
1669
+ }
1670
+ async update(id, request) {
1671
+ return this.client.request("PATCH", `${LINKS_BASE_PATH}/${id}`, request);
1672
+ }
1673
+ async delete(id) {
1674
+ await this.client.request("DELETE", `${LINKS_BASE_PATH}/${id}`);
1675
+ }
1676
+ };
1677
+
1678
+ // src/knowledge/nodes.ts
1679
+ var NODES_BASE_PATH = "/knowledge/v1/nodes";
1680
+ var NodeServiceImpl = class {
1681
+ constructor(client) {
1682
+ this.client = client;
1683
+ }
1684
+ client;
1685
+ list(options = {}) {
1686
+ return new PageIterator((opts) => this.listPage(opts), options);
1687
+ }
1688
+ async listPage(options = {}) {
1689
+ const { label_ids, ...rest } = options;
1690
+ const query = { ...rest };
1691
+ if (label_ids && label_ids.length > 0) {
1692
+ query.label_ids = label_ids.join(",");
1693
+ }
1694
+ return this.client.requestWithQuery(
1695
+ "GET",
1696
+ NODES_BASE_PATH,
1697
+ query
1698
+ );
1699
+ }
1700
+ async get(id) {
1701
+ return this.client.request("GET", `${NODES_BASE_PATH}/${id}`);
1702
+ }
1703
+ async create(request) {
1704
+ return this.client.request("POST", NODES_BASE_PATH, request);
1705
+ }
1706
+ async update(id, request) {
1707
+ return this.client.request("PATCH", `${NODES_BASE_PATH}/${id}`, request);
1708
+ }
1709
+ async delete(id) {
1710
+ await this.client.request("DELETE", `${NODES_BASE_PATH}/${id}`);
1711
+ }
1712
+ async search(request) {
1713
+ return this.client.request(
1714
+ "POST",
1715
+ `${NODES_BASE_PATH}/actions/search`,
1716
+ request
1717
+ );
1718
+ }
1719
+ async neighbors(id, options = {}) {
1720
+ return this.client.requestWithQuery(
1721
+ "GET",
1722
+ `${NODES_BASE_PATH}/${id}/neighbors`,
1723
+ options
1724
+ );
1725
+ }
1726
+ async getContent(id) {
1727
+ return this.client.request("GET", `${NODES_BASE_PATH}/${id}/content`);
1728
+ }
1729
+ async writeContent(id, content) {
1730
+ return this.client.request("PUT", `${NODES_BASE_PATH}/${id}/content`, {
1731
+ content
1732
+ });
1733
+ }
1734
+ async editContent(id, request) {
1735
+ return this.client.request(
1736
+ "POST",
1737
+ `${NODES_BASE_PATH}/${id}/content/actions/edit`,
1738
+ request
1739
+ );
1740
+ }
1741
+ async getOutline(request) {
1742
+ return this.client.request(
1743
+ "POST",
1744
+ `${NODES_BASE_PATH}/content/actions/outline`,
1745
+ request
1746
+ );
1747
+ }
1748
+ async searchContent(request) {
1749
+ return this.client.request(
1750
+ "POST",
1751
+ `${NODES_BASE_PATH}/content/actions/search`,
1752
+ request
1753
+ );
1754
+ }
1755
+ async listLabels(id) {
1756
+ const result = await this.client.request(
1757
+ "GET",
1758
+ `${NODES_BASE_PATH}/${id}/labels`
1759
+ );
1760
+ return result.data;
1761
+ }
1762
+ async attachLabel(id, labelId) {
1763
+ return this.client.request("POST", `${NODES_BASE_PATH}/${id}/labels`, {
1764
+ label_id: labelId
1765
+ });
1766
+ }
1767
+ async detachLabel(id, labelId) {
1768
+ await this.client.request("DELETE", `${NODES_BASE_PATH}/${id}/labels/${labelId}`);
1769
+ }
1770
+ };
1771
+
1772
+ // src/knowledge/record-links.ts
1773
+ var RECORD_LINKS_BASE_PATH = "/knowledge/v1/record-links";
1774
+ var RecordLinkServiceImpl = class {
1775
+ constructor(client) {
1776
+ this.client = client;
1777
+ }
1778
+ client;
1779
+ list(options = {}) {
1780
+ return new PageIterator((opts) => this.listPage(opts), options);
1781
+ }
1782
+ async listPage(options = {}) {
1783
+ return this.client.requestWithQuery(
1784
+ "GET",
1785
+ RECORD_LINKS_BASE_PATH,
1786
+ options
1787
+ );
1788
+ }
1789
+ async get(id) {
1790
+ return this.client.request("GET", `${RECORD_LINKS_BASE_PATH}/${id}`);
1791
+ }
1792
+ async create(request) {
1793
+ return this.client.request("POST", RECORD_LINKS_BASE_PATH, request);
1794
+ }
1795
+ async delete(id) {
1796
+ await this.client.request("DELETE", `${RECORD_LINKS_BASE_PATH}/${id}`);
1797
+ }
1798
+ };
1799
+ var KnowledgeNodeMetadataSchema = z.object({
1800
+ id: z.string(),
1801
+ org_id: z.string(),
1802
+ title: z.string(),
1803
+ type: z.enum(["markdown", "file", "url"]),
1804
+ status: z.enum(["draft", "published", "archived"]),
1805
+ embedding_model: z.string().nullish(),
1806
+ embedded_at: z.string().nullish(),
1807
+ file_id: z.string().nullish(),
1808
+ url: z.string().nullish(),
1809
+ summary: z.string().nullish(),
1810
+ valid_from: z.string().nullish(),
1811
+ valid_until: z.string().nullish()
1812
+ }).merge(AuditFieldsSchema);
1813
+ var KnowledgeNodeSchema = KnowledgeNodeMetadataSchema.extend({
1814
+ content: z.string()
1815
+ });
1816
+ var KnowledgeNodeSearchResultSchema = KnowledgeNodeMetadataSchema.extend({
1817
+ score: z.number()
1818
+ });
1819
+ var KnowledgeLinkSchema = z.object({
1820
+ id: z.string(),
1821
+ org_id: z.string(),
1822
+ from_id: z.string(),
1823
+ to_id: z.string(),
1824
+ type: z.enum([
1825
+ "references",
1826
+ "relates_to",
1827
+ "depends_on",
1828
+ "part_of",
1829
+ "derived_from",
1830
+ "contradicts",
1831
+ "supports",
1832
+ "duplicates",
1833
+ "superseded_by"
1834
+ ]),
1835
+ description: z.string().nullish()
1836
+ }).merge(AuditFieldsSchema);
1837
+ var KnowledgeRecordLinkSchema = z.object({
1838
+ id: z.string(),
1839
+ org_id: z.string(),
1840
+ node_id: z.string(),
1841
+ entity_slug: z.string(),
1842
+ record_id: z.string(),
1843
+ created_at: z.string(),
1844
+ created_by: UserRefSchema
1845
+ });
1846
+ var KnowledgeLabelSchema = z.object({
1847
+ id: z.string(),
1848
+ org_id: z.string(),
1849
+ name: z.string(),
1850
+ slug: z.string(),
1851
+ description: z.string().nullish(),
1852
+ color: z.string().nullish(),
1853
+ icon: z.string().nullish()
1854
+ }).merge(AuditFieldsSchema);
1855
+ var KnowledgeNodeLabelSchema = z.object({
1856
+ org_id: z.string(),
1857
+ node_id: z.string(),
1858
+ label_id: z.string(),
1859
+ created_at: z.string(),
1860
+ created_by: UserRefSchema
1861
+ });
1862
+ var NodeNeighborhoodSchema = z.object({
1863
+ nodes: z.array(
1864
+ z.object({
1865
+ id: z.string(),
1866
+ title: z.string(),
1867
+ type: z.enum(["markdown", "file", "url"]),
1868
+ status: z.enum(["draft", "published", "archived"]),
1869
+ distance: z.number()
1870
+ })
1871
+ ),
1872
+ edges: z.array(
1873
+ z.object({
1874
+ id: z.string(),
1875
+ from_id: z.string(),
1876
+ to_id: z.string(),
1877
+ type: z.string()
1878
+ })
1879
+ )
1880
+ });
1881
+
1882
+ // src/knowledge/index.ts
1883
+ var KnowledgeClient = class {
1884
+ nodes;
1885
+ links;
1886
+ /** Node→record edges (links to data-service records): `knowledge.recordLinks`. */
1887
+ recordLinks;
1888
+ labels;
1889
+ /** Whole-org graph bulk read (radiant graph view): `knowledge.graph.get()`. */
1890
+ graph;
1891
+ constructor(client) {
1892
+ this.nodes = new NodeServiceImpl(client);
1893
+ this.links = new LinkServiceImpl(client);
1894
+ this.recordLinks = new RecordLinkServiceImpl(client);
1895
+ this.labels = new LabelServiceImpl(client);
1896
+ this.graph = new GraphServiceImpl(client);
1897
+ }
1898
+ };
1899
+
1900
+ // src/storage/files.ts
1901
+ var FILES_BASE_PATH = "/storage/v1/files";
1902
+ var FileServiceImpl = class {
1903
+ constructor(client) {
1904
+ this.client = client;
1905
+ }
1906
+ client;
1907
+ async upload(file, options) {
1908
+ const metadata = {
1909
+ name: options?.name ?? file.name,
1910
+ content_type: options?.contentType ?? file.type ?? "application/octet-stream"
1911
+ };
1912
+ const formData = new FormData();
1913
+ formData.append("metadata", new Blob([JSON.stringify(metadata)], { type: "application/json" }));
1914
+ formData.append("file", file, metadata.name);
1915
+ const response = await this.client.requestMultipart(
1916
+ "POST",
1917
+ FILES_BASE_PATH,
1918
+ formData
1919
+ );
1920
+ return response.data;
1921
+ }
1922
+ async create(metadata) {
1923
+ const formData = new FormData();
1924
+ formData.append(
1925
+ "metadata",
1926
+ new Blob(
1927
+ [
1928
+ JSON.stringify({
1929
+ name: metadata.name,
1930
+ content_type: metadata.content_type ?? "application/octet-stream"
1931
+ })
1932
+ ],
1933
+ { type: "application/json" }
1934
+ )
1935
+ );
1936
+ const response = await this.client.requestMultipart(
1937
+ "POST",
1938
+ FILES_BASE_PATH,
1939
+ formData
1940
+ );
1941
+ return response.data;
1942
+ }
1943
+ async createUploadUrl(id) {
1944
+ const response = await this.client.request(
1945
+ "POST",
1946
+ `${FILES_BASE_PATH}/${id}/generate-upload-url`
1947
+ );
1948
+ return response.data;
1949
+ }
1950
+ async parse(id, options) {
1951
+ const response = await this.client.request(
1952
+ "POST",
1953
+ `${FILES_BASE_PATH}/${id}/parse`,
1954
+ options ?? {}
1955
+ );
1956
+ return response.data;
1957
+ }
1958
+ async getContent(id) {
1959
+ const response = await this.client.request(
1960
+ "GET",
1961
+ `${FILES_BASE_PATH}/${id}/content`
1962
+ );
1963
+ return response.data;
1964
+ }
1965
+ async get(id) {
1966
+ const response = await this.client.request(
1967
+ "GET",
1968
+ `${FILES_BASE_PATH}/${id}`
1969
+ );
1970
+ return response.data;
1971
+ }
1972
+ async createDownloadUrl(id, options) {
1973
+ const body = options?.allowsMultiUse !== void 0 ? { allows_multi_use: options.allowsMultiUse } : void 0;
1974
+ const response = await this.client.request(
1975
+ "POST",
1976
+ `${FILES_BASE_PATH}/${id}/generate-download-url`,
1977
+ body
1978
+ );
1979
+ return response.data;
1980
+ }
1981
+ async download(id) {
1982
+ const { response } = await this.client.requestRaw("GET", `${FILES_BASE_PATH}/${id}/download`);
1983
+ return await response.blob();
1984
+ }
1985
+ };
1986
+
1987
+ // src/storage/index.ts
1988
+ var StorageClient = class {
1989
+ files;
1990
+ constructor(client) {
1991
+ this.files = new FileServiceImpl(client);
1992
+ }
1993
+ };
1994
+
1995
+ // src/workflow/executions.ts
1996
+ var EXECUTIONS_BASE_PATH = "/workflows/v1/executions";
1997
+ var WORKFLOWS_BASE_PATH = "/workflows/v1/workflows";
1998
+ var ExecutionServiceImpl = class {
1999
+ constructor(client) {
2000
+ this.client = client;
2001
+ }
2002
+ client;
2003
+ list(options = {}) {
2004
+ return new PageIterator((opts) => this.listPage(opts), options);
2005
+ }
2006
+ async listPage(options = {}) {
2007
+ return this.client.requestWithQuery(
2008
+ "GET",
2009
+ EXECUTIONS_BASE_PATH,
2010
+ options
2011
+ );
2012
+ }
2013
+ async get(id) {
2014
+ return this.client.request("GET", `${EXECUTIONS_BASE_PATH}/${id}`);
2015
+ }
2016
+ async getDetail(id) {
2017
+ return this.client.request(
2018
+ "GET",
2019
+ `${EXECUTIONS_BASE_PATH}/${id}/detail`
2020
+ );
2021
+ }
2022
+ async getNodeItems(executionId, nodeId, runIndex, options = {}) {
2023
+ return this.client.requestWithQuery(
2024
+ "GET",
2025
+ `${EXECUTIONS_BASE_PATH}/${executionId}/nodes/${nodeId}/runs/${runIndex}/items`,
2026
+ options
2027
+ );
2028
+ }
2029
+ async listForWorkflow(key, options = {}) {
2030
+ return this.client.requestWithQuery(
2031
+ "GET",
2032
+ `${WORKFLOWS_BASE_PATH}/${key}/executions`,
2033
+ options
2034
+ );
2035
+ }
2036
+ };
2037
+
2038
+ // src/workflow/node-types.ts
2039
+ var NODE_TYPES_BASE_PATH = "/workflows/v1/node-types";
2040
+ var NodeTypeServiceImpl = class {
2041
+ constructor(client) {
2042
+ this.client = client;
2043
+ }
2044
+ client;
2045
+ async list() {
2046
+ const response = await this.client.request("GET", NODE_TYPES_BASE_PATH);
2047
+ return response.data;
2048
+ }
2049
+ async invokeMethod(type, method, request = {}) {
2050
+ const path = `${NODE_TYPES_BASE_PATH}/${encodeURIComponent(type)}/methods/${encodeURIComponent(method)}`;
2051
+ return this.client.request("POST", path, request);
2052
+ }
2053
+ };
2054
+
2055
+ // src/workflow/workflows.ts
2056
+ var WORKFLOWS_BASE_PATH2 = "/workflows/v1/workflows";
2057
+ var WorkflowServiceImpl = class {
2058
+ constructor(client) {
2059
+ this.client = client;
2060
+ }
2061
+ client;
2062
+ list(options = {}) {
2063
+ return new PageIterator((opts) => this.listPage(opts), options);
2064
+ }
2065
+ async listPage(options = {}) {
2066
+ return this.client.requestWithQuery("GET", WORKFLOWS_BASE_PATH2, options);
2067
+ }
2068
+ async get(key) {
2069
+ return this.client.request("GET", `${WORKFLOWS_BASE_PATH2}/${key}`);
2070
+ }
2071
+ async create(request) {
2072
+ return this.client.request("POST", WORKFLOWS_BASE_PATH2, request);
2073
+ }
2074
+ async update(key, request) {
2075
+ return this.client.request("PATCH", `${WORKFLOWS_BASE_PATH2}/${key}`, request);
2076
+ }
2077
+ async delete(key) {
2078
+ await this.client.request("DELETE", `${WORKFLOWS_BASE_PATH2}/${key}`);
2079
+ }
2080
+ async run(key, request = {}) {
2081
+ return this.client.request(
2082
+ "POST",
2083
+ `${WORKFLOWS_BASE_PATH2}/${key}/run`,
2084
+ request
2085
+ );
2086
+ }
2087
+ async testNode(key, nodeId, request) {
2088
+ return this.client.request(
2089
+ "POST",
2090
+ `${WORKFLOWS_BASE_PATH2}/${key}/nodes/${nodeId}/test`,
2091
+ request
2092
+ );
2093
+ }
2094
+ async pause(key) {
2095
+ return this.client.request("POST", `${WORKFLOWS_BASE_PATH2}/${key}/pause`, {});
2096
+ }
2097
+ async unpause(key) {
2098
+ return this.client.request("POST", `${WORKFLOWS_BASE_PATH2}/${key}/unpause`, {});
2099
+ }
2100
+ listVersions(key, options = {}) {
2101
+ return new PageIterator((opts) => this.listVersionsPage(key, opts), options);
2102
+ }
2103
+ async listVersionsPage(key, options = {}) {
2104
+ return this.client.requestWithQuery(
2105
+ "GET",
2106
+ `${WORKFLOWS_BASE_PATH2}/${key}/versions`,
2107
+ options
2108
+ );
2109
+ }
2110
+ async getVersion(key, version) {
2111
+ return this.client.request(
2112
+ "GET",
2113
+ `${WORKFLOWS_BASE_PATH2}/${key}/versions/${version}`
2114
+ );
2115
+ }
2116
+ async restoreVersion(key, version) {
2117
+ return this.client.request(
2118
+ "POST",
2119
+ `${WORKFLOWS_BASE_PATH2}/${key}/versions/${version}/restore`,
2120
+ {}
2121
+ );
2122
+ }
2123
+ };
2124
+
2125
+ // src/workflow/types.ts
2126
+ var DEFAULT_PORT = "main";
2127
+ var ERROR_PORT = "error";
2128
+
2129
+ // src/workflow/index.ts
2130
+ var WorkflowClient = class {
2131
+ /** Service for managing workflow definitions. */
2132
+ workflows;
2133
+ /** Service for reading workflow executions. */
2134
+ executions;
2135
+ /** Service for the node-type catalog + dynamic node methods. */
2136
+ nodeTypes;
2137
+ constructor(client) {
2138
+ this.workflows = new WorkflowServiceImpl(client);
2139
+ this.executions = new ExecutionServiceImpl(client);
2140
+ this.nodeTypes = new NodeTypeServiceImpl(client);
2141
+ }
2142
+ };
2143
+
2144
+ export { AccountClient, ActionSchema, ActionScopeSchema, AgentClient, BatchTransactionErrorSchema, BatchUpsertRecordsResponseSchema, BatchUpsertTransactionResultSchema, BatchUpsertTransactionSchema, ConnectorClient, ConversationClient, DEFAULT_OPTIONS, DEFAULT_PORT, DataClient, ERROR_PORT, ErrorCode, EventsClient, FunctionsClient, KnowledgeClient, KnowledgeLabelSchema, KnowledgeLinkSchema, KnowledgeNodeLabelSchema, KnowledgeNodeMetadataSchema, KnowledgeNodeSchema, KnowledgeNodeSearchResultSchema, KnowledgeRecordLinkSchema, NodeNeighborhoodSchema, OrganizationSchema, PLATFORM_ENTITIES, PLATFORM_ENTITY_SLUGS, ProteosClient, ProteosError, RoleEntityPermissionSchema, RoleSchema, StorageClient, UserRoleAssignmentSchema, UserSchema, WorkflowClient, buildUrl, getDefaultErrorCode, isBadRequest, isConflict, isForbidden, isNotFound, isPlatformEntity, isProteosError, isUnauthorized, parseErrorResponse, resolveOptions, toQueryParams, toQueryString };
2145
+ //# sourceMappingURL=index.js.map
2146
+ //# sourceMappingURL=index.js.map