modulex-js 0.1.0 → 1.0.0

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.
package/dist/index.mjs CHANGED
@@ -24,6 +24,12 @@ var ModulexError = class extends Error {
24
24
  this.body = body;
25
25
  this.headers = headers;
26
26
  this.name = "ModulexError";
27
+ const env = extractErrorEnvelope(body);
28
+ if (env) {
29
+ if (typeof env.code === "string") this.code = env.code;
30
+ if (typeof env.reason === "string") this.reason = env.reason;
31
+ if (typeof env.layer === "string") this.layer = env.layer;
32
+ }
27
33
  }
28
34
  };
29
35
  var BadRequestError = class extends ModulexError {
@@ -66,10 +72,18 @@ var RateLimitError = class extends ModulexError {
66
72
  constructor(message, body, headers) {
67
73
  super(message, 429, body, headers);
68
74
  this.name = "RateLimitError";
69
- const retryHeader = headers?.get("retry-after");
70
- this.retryAfter = retryHeader ? Number(retryHeader) : void 0;
75
+ this.retryAfter = parseNumericHeader(headers, "retry-after");
76
+ this.limit = parseNumericHeader(headers, "x-ratelimit-limit");
77
+ this.remaining = parseNumericHeader(headers, "x-ratelimit-remaining");
78
+ this.reset = parseNumericHeader(headers, "x-ratelimit-reset");
71
79
  }
72
80
  };
81
+ function parseNumericHeader(headers, name) {
82
+ const raw = headers?.get(name);
83
+ if (raw == null) return void 0;
84
+ const n = Number(raw);
85
+ return Number.isNaN(n) ? void 0 : n;
86
+ }
73
87
  var InternalError = class extends ModulexError {
74
88
  constructor(message, body, headers) {
75
89
  super(message, 500, body, headers);
@@ -127,18 +141,43 @@ function createErrorFromStatus(status, body, headers) {
127
141
  return new ModulexError(message, status, body, headers);
128
142
  }
129
143
  }
144
+ function extractErrorEnvelope(body) {
145
+ if (!body || typeof body !== "object") return void 0;
146
+ const b = body;
147
+ const detail = b.detail;
148
+ if (detail && typeof detail === "object" && !Array.isArray(detail)) {
149
+ return detail;
150
+ }
151
+ if (typeof b.code === "string" || typeof b.reason === "string") {
152
+ return b;
153
+ }
154
+ return void 0;
155
+ }
130
156
  function extractErrorMessage(body, status) {
131
- if (body && typeof body === "object" && "detail" in body) {
132
- const detail = body.detail;
157
+ if (body && typeof body === "object") {
158
+ const b = body;
159
+ const detail = b.detail;
133
160
  if (typeof detail === "string") return detail;
134
161
  if (Array.isArray(detail)) {
135
162
  return detail.map((d) => `${d.loc?.join(".")}: ${d.msg}`).join("; ");
136
163
  }
164
+ const env = extractErrorEnvelope(body);
165
+ if (env) {
166
+ const reason = env.reason ?? env.message;
167
+ const code = env.code;
168
+ if (typeof reason === "string" && typeof code === "string") return `${reason} (${code})`;
169
+ if (typeof reason === "string") return reason;
170
+ if (typeof code === "string") return code;
171
+ }
172
+ if (typeof b.message === "string") return b.message;
137
173
  }
138
174
  return `HTTP ${status} error`;
139
175
  }
140
176
 
141
177
  // src/streaming.ts
178
+ function resolveEventType(event, data) {
179
+ return typeof data.type === "string" && data.type ? data.type : event;
180
+ }
142
181
  async function* parseSSEStream(response, signal) {
143
182
  const body = response.body;
144
183
  if (!body) {
@@ -171,8 +210,10 @@ async function* parseSSEStream(response, signal) {
171
210
  } catch {
172
211
  parsedData = { raw: dataStr };
173
212
  }
213
+ const ev = currentEvent || "message";
174
214
  yield {
175
- event: currentEvent || "message",
215
+ event: ev,
216
+ type: resolveEventType(ev, parsedData),
176
217
  data: parsedData,
177
218
  id: currentId,
178
219
  retry: currentRetry
@@ -224,8 +265,10 @@ async function* parseSSEStream(response, signal) {
224
265
  } catch {
225
266
  parsedData = { raw: dataStr };
226
267
  }
268
+ const ev = currentEvent || "message";
227
269
  yield {
228
- event: currentEvent || "message",
270
+ event: ev,
271
+ type: resolveEventType(ev, parsedData),
229
272
  data: parsedData,
230
273
  id: currentId,
231
274
  retry: currentRetry
@@ -566,7 +609,8 @@ var Auth = class extends BaseResource {
566
609
  /**
567
610
  * POST /auth/invitations/{id}/accept
568
611
  *
569
- * Accepts a pending organization invitation.
612
+ * Accepts a pending organization invitation. On success the response
613
+ * includes the joined organization and the granted role.
570
614
  */
571
615
  async acceptInvitation(invitationId, options) {
572
616
  return this._post(
@@ -660,7 +704,9 @@ var Organizations = class extends BaseResource {
660
704
  /**
661
705
  * POST /organizations/invite
662
706
  *
663
- * Sends an invitation email to add a user to the current organization.
707
+ * Sends an invitation email to add a user to the current organization. The
708
+ * invited user joins as `admin`; the org `member` role was retired, so the
709
+ * backend rejects `role: 'member'` with HTTP 422.
664
710
  */
665
711
  async invite(params, options) {
666
712
  return this._post("/organizations/invite", params, options);
@@ -692,7 +738,9 @@ var Organizations = class extends BaseResource {
692
738
  /**
693
739
  * PUT /organizations/{orgId}/users/{userId}/role
694
740
  *
695
- * Updates a member's role within an organization.
741
+ * Updates a member's role within an organization. Only `'admin'` is accepted —
742
+ * the org `member` role was retired, so the backend rejects `role: 'member'`
743
+ * with HTTP 422.
696
744
  */
697
745
  async updateRole(organizationId, userId, params, options) {
698
746
  return this._put(
@@ -713,6 +761,67 @@ var Organizations = class extends BaseResource {
713
761
  options
714
762
  );
715
763
  }
764
+ /**
765
+ * POST /organizations/invite/preview
766
+ *
767
+ * Previews the prorated cost of adding one seat to the current organization,
768
+ * for displaying to the user before confirming an invite. The organization is
769
+ * resolved from the `X-Organization-ID` header, so no request body is sent.
770
+ *
771
+ * Returns a discriminated union on `preview_available`: when `false`, the
772
+ * organization has no active paid subscription (a `reason` is provided); when
773
+ * `true`, full prorated pricing detail is returned.
774
+ *
775
+ * @remarks Admin-only: requires organization admin (or owner) permission.
776
+ */
777
+ async invitePreview(options) {
778
+ return this._post("/organizations/invite/preview", void 0, options);
779
+ }
780
+ /**
781
+ * GET /organizations/settings
782
+ *
783
+ * Returns the per-organization preference settings (model visibility and the
784
+ * default composer LLM) for the current organization. The organization is
785
+ * resolved from the `X-Organization-ID` header.
786
+ *
787
+ * @remarks Available to any organization member.
788
+ */
789
+ async getSettings(options) {
790
+ return this._get("/organizations/settings", options);
791
+ }
792
+ /**
793
+ * PUT /organizations/settings/llm-model-visibility
794
+ *
795
+ * Sets which models are visible in the dropdown for a single integration.
796
+ * Send the FULL desired visible list; an empty `models` array resets that
797
+ * integration's visibility to the catalog default. The organization is
798
+ * resolved from the `X-Organization-ID` header.
799
+ *
800
+ * @remarks Admin-only: requires organization admin (or owner) permission.
801
+ */
802
+ async setModelVisibility(params, options) {
803
+ return this._put(
804
+ "/organizations/settings/llm-model-visibility",
805
+ params,
806
+ options
807
+ );
808
+ }
809
+ /**
810
+ * PUT /organizations/settings/composer-llm
811
+ *
812
+ * Persists the organization's default composer LLM. Composer requests that
813
+ * omit an explicit LLM fall back to this value. The organization is resolved
814
+ * from the `X-Organization-ID` header.
815
+ *
816
+ * @remarks Admin-only: requires organization admin (or owner) permission.
817
+ */
818
+ async setComposerLlm(params, options) {
819
+ return this._put(
820
+ "/organizations/settings/composer-llm",
821
+ params,
822
+ options
823
+ );
824
+ }
716
825
  };
717
826
 
718
827
  // src/resources/workflows.ts
@@ -720,7 +829,13 @@ var Workflows = class extends BaseResource {
720
829
  /**
721
830
  * POST /workflows
722
831
  *
723
- * Creates a new workflow with the given schema.
832
+ * Creates a new workflow with the given schema. Returns HTTP 201.
833
+ * Requires organization admin/owner role.
834
+ *
835
+ * `params.visibility` is passed through unchanged with no client-side default;
836
+ * omit it to let the backend default to `"organization"`. `"private"` is no
837
+ * longer creator-only — it behaves like `"organization"` (any org admin/owner
838
+ * can view/run/resume).
724
839
  */
725
840
  async create(params, options) {
726
841
  return this._post("/workflows", params, options);
@@ -777,6 +892,7 @@ var Workflows = class extends BaseResource {
777
892
  * PUT /workflows/{workflowId}
778
893
  *
779
894
  * Updates an existing workflow. Only provided fields are changed.
895
+ * Requires organization admin/owner role.
780
896
  */
781
897
  async update(workflowId, params, options) {
782
898
  return this._put(`/workflows/${workflowId}`, params, options);
@@ -784,7 +900,9 @@ var Workflows = class extends BaseResource {
784
900
  /**
785
901
  * DELETE /workflows/{workflowId}
786
902
  *
787
- * Soft-deletes a workflow.
903
+ * Permanently (hard) deletes a workflow. This is IRREVERSIBLE — the workflow
904
+ * row and its schema are removed from the database, not soft-deleted.
905
+ * Requires organization admin/owner role.
788
906
  */
789
907
  async delete(workflowId, options) {
790
908
  return this._delete(
@@ -810,6 +928,19 @@ var Workflows = class extends BaseResource {
810
928
  }
811
929
  });
812
930
  }
931
+ /**
932
+ * GET /workflows/{workflowId}/changes — SSE stream
933
+ *
934
+ * Opens a Server-Sent Events stream of real-time collaboration changes for a
935
+ * workflow (canvas/composer sync). This is a data-only stream: each yielded
936
+ * value is a {@link WorkflowChangeEvent} discriminated on its `type` field
937
+ * (`connected`, `workflow_updated`, `user_joined`, `user_left`).
938
+ */
939
+ async *listenChanges(workflowId, options) {
940
+ for await (const frame of this.streamSSE(`/workflows/${workflowId}/changes`, options)) {
941
+ yield frame.data;
942
+ }
943
+ }
813
944
  };
814
945
 
815
946
  // src/resources/executions.ts
@@ -817,9 +948,14 @@ var Executions = class extends BaseResource {
817
948
  /**
818
949
  * POST /workflows/run
819
950
  *
820
- * Initiates a workflow run. Supports four modes: existing workflow, ad-hoc
821
- * workflow, direct LLM call, and system workflow. Returns immediately with
822
- * run metadata; stream events via `listen()`.
951
+ * Initiates a workflow run. Supports two modes: a saved workflow (`workflowId`,
952
+ * which requires an active deployment the backend returns 400 otherwise) or
953
+ * an inline ad-hoc definition (`workflow`). Returns immediately with run
954
+ * metadata (`status` is `"running"` for streaming runs); stream events via
955
+ * `listen()`.
956
+ *
957
+ * The legacy direct-LLM mode was removed; an `llm_config`-only request now
958
+ * returns HTTP 410 — use `client.assistant.chat()` instead.
823
959
  */
824
960
  async run(params, options) {
825
961
  return this._post("/workflows/run", params, options);
@@ -829,6 +965,10 @@ var Executions = class extends BaseResource {
829
965
  *
830
966
  * Returns the persisted state snapshot of a workflow thread at its latest
831
967
  * checkpoint.
968
+ *
969
+ * Throws `NotFoundError` on HTTP 404 — the thread does not exist OR is not
970
+ * owned by your organization. Ownership failures return an identical 404 (not
971
+ * 403) by design, so there is no existence leak.
832
972
  */
833
973
  async getState(threadId, options) {
834
974
  return this._get(`/workflows/state/${threadId}`, options);
@@ -837,6 +977,11 @@ var Executions = class extends BaseResource {
837
977
  * POST /workflows/resume/{threadId}
838
978
  *
839
979
  * Resumes a workflow that is waiting at an interrupt node.
980
+ *
981
+ * Guard responses: 400 (missing `resumeValue` or `runId`); 404 — a
982
+ * `NotFoundError` — when there is no checkpoint for the thread OR the
983
+ * run/thread is not owned by your organization. Ownership failures return an
984
+ * identical 404 (not 403) by design, so there is no existence leak.
840
985
  */
841
986
  async resume(params, options) {
842
987
  const { threadId, ...rest } = params;
@@ -849,7 +994,13 @@ var Executions = class extends BaseResource {
849
994
  /**
850
995
  * POST /workflows/cancel/{runId}
851
996
  *
852
- * Requests cancellation of an in-progress workflow run.
997
+ * Requests cancellation of an in-progress workflow run. On success the
998
+ * response `status` is `"cancellation_requested"`.
999
+ *
1000
+ * Guard responses: 404 — a `NotFoundError` — when the run is unknown OR is not
1001
+ * owned by your organization (ownership failures return an identical 404, not
1002
+ * 403, by design, so there is no existence leak); 400 (the run is not in a
1003
+ * `running`/`interrupted` state).
853
1004
  */
854
1005
  async cancel(runId, params, options) {
855
1006
  return this._post(
@@ -861,14 +1012,53 @@ var Executions = class extends BaseResource {
861
1012
  /**
862
1013
  * GET /workflows/listen/{runId} — SSE stream
863
1014
  *
864
- * Opens a Server-Sent Events stream for real-time execution events of
865
- * an in-progress workflow run. Yields typed `WorkflowSSEEvent` values.
1015
+ * Opens a Server-Sent Events stream for real-time execution events of an
1016
+ * in-progress workflow run. This is a data-only stream: each yielded value is
1017
+ * a {@link WorkflowSSEEvent} discriminated on its `type` field (`metadata`,
1018
+ * `node_started`, `node_update`, `interrupt`, `resumed`, `done`, `cancelled`,
1019
+ * `error`). The stream ends after a `done` or `error` event.
1020
+ *
1021
+ * A 404 on connect throws `NotFoundError` before any event is yielded — the
1022
+ * run does not exist OR is not owned by your organization (ownership failures
1023
+ * return an identical 404, not 403). The stream does NOT auto-reconnect on a
1024
+ * 404.
866
1025
  */
867
- listen(runId, options) {
868
- return this.streamSSE(
869
- `/workflows/listen/${runId}`,
870
- options
871
- );
1026
+ async *listen(runId, options) {
1027
+ for await (const frame of this.streamSSE(`/workflows/listen/${runId}`, options)) {
1028
+ yield frame.data;
1029
+ }
1030
+ }
1031
+ };
1032
+
1033
+ // src/resources/workflow-runs.ts
1034
+ var WorkflowRuns = class extends BaseResource {
1035
+ /**
1036
+ * GET /workflow-runs
1037
+ *
1038
+ * Lists workflow runs for the organization, newest first. Pass `workflowId`
1039
+ * for per-workflow history. Pagination is via `has_more` (no total count).
1040
+ */
1041
+ async list(params, options) {
1042
+ return this._get("/workflow-runs", {
1043
+ ...options,
1044
+ params: {
1045
+ ...params,
1046
+ ...options?.params
1047
+ }
1048
+ });
1049
+ }
1050
+ /**
1051
+ * GET /workflow-runs/{runPk}
1052
+ *
1053
+ * Returns the full durable run record (including input/output snapshots).
1054
+ *
1055
+ * NOTE: `runPk` is the run table primary key (the `id` field of a
1056
+ * {@link WorkflowRunListItem} / {@link WorkflowRunDetail}), NOT the string
1057
+ * `run_id` used by `executions.listen()` / `executions.cancel()`. Passing a
1058
+ * `run_id` here returns 404.
1059
+ */
1060
+ async get(runPk, options) {
1061
+ return this._get(`/workflow-runs/${runPk}`, options);
872
1062
  }
873
1063
  };
874
1064
 
@@ -1038,7 +1228,8 @@ var Credentials = class extends BaseResource {
1038
1228
  /**
1039
1229
  * GET /credentials/{credentialId}
1040
1230
  *
1041
- * Returns a single credential record.
1231
+ * Returns a single credential record, including ownership and (optionally
1232
+ * masked) auth detail fields not present on the list endpoint.
1042
1233
  */
1043
1234
  async get(credentialId, params, options) {
1044
1235
  return this._get(`/credentials/${credentialId}`, {
@@ -1053,6 +1244,8 @@ var Credentials = class extends BaseResource {
1053
1244
  * POST /credentials
1054
1245
  *
1055
1246
  * Creates a new credential. The auth data is encrypted at rest.
1247
+ *
1248
+ * @remarks Requires admin/owner role on the organization.
1056
1249
  */
1057
1250
  async create(params, options) {
1058
1251
  return this._post("/credentials", params, options);
@@ -1114,6 +1307,8 @@ var Credentials = class extends BaseResource {
1114
1307
  * GET /credentials/{credentialId}/usage
1115
1308
  *
1116
1309
  * Returns usage statistics for a credential.
1310
+ *
1311
+ * @remarks Requires admin/owner role on the organization.
1117
1312
  */
1118
1313
  async usage(credentialId, params, options) {
1119
1314
  return this._get(`/credentials/${credentialId}/usage`, {
@@ -1128,7 +1323,9 @@ var Credentials = class extends BaseResource {
1128
1323
  /**
1129
1324
  * GET /credentials/{credentialId}/audit
1130
1325
  *
1131
- * Returns the audit log for a credential.
1326
+ * Returns the audit log for a credential as an array of entries.
1327
+ *
1328
+ * @remarks Requires admin/owner role on the organization.
1132
1329
  */
1133
1330
  async audit(credentialId, params, options) {
1134
1331
  return this._get(`/credentials/${credentialId}/audit`, {
@@ -1143,7 +1340,10 @@ var Credentials = class extends BaseResource {
1143
1340
  /**
1144
1341
  * POST /credentials/bulk-modulex-keys/stream — SSE
1145
1342
  *
1146
- * Streams bulk ModuleX managed key provisioning events.
1343
+ * Streams bulk ModuleX managed key provisioning events. Each event's
1344
+ * `data` field can be parsed as a {@link ModulexKeyBulkEventData}.
1345
+ *
1346
+ * @remarks Requires admin/owner role on the organization.
1147
1347
  */
1148
1348
  bulkModulexKeys(options) {
1149
1349
  return this.streamSSEPost("/credentials/bulk-modulex-keys/stream", void 0, options);
@@ -1154,7 +1354,11 @@ var Credentials = class extends BaseResource {
1154
1354
  * Creates a credential for a Model Context Protocol (MCP) server.
1155
1355
  */
1156
1356
  async mcpServer(params, options) {
1157
- return this._post("/credentials/mcp-server", params, options);
1357
+ return this._post(
1358
+ "/credentials/mcp-server",
1359
+ params,
1360
+ options
1361
+ );
1158
1362
  }
1159
1363
  /**
1160
1364
  * POST /credentials/{credentialId}/refresh-discovery
@@ -1179,6 +1383,37 @@ var Credentials = class extends BaseResource {
1179
1383
  options
1180
1384
  );
1181
1385
  }
1386
+ /**
1387
+ * POST /credentials/oauth2/initiate
1388
+ *
1389
+ * Initiates an OAuth2 authorization flow for an integration and returns the
1390
+ * authorization URL the user should be redirected to, along with a `state`
1391
+ * token correlating the flow.
1392
+ *
1393
+ * @remarks Requires admin/owner role on the organization.
1394
+ */
1395
+ async initiateOAuth2(params, options) {
1396
+ return this._post(
1397
+ "/credentials/oauth2/initiate",
1398
+ params,
1399
+ options
1400
+ );
1401
+ }
1402
+ /**
1403
+ * POST /credentials/{credentialId}/oauth2/refresh
1404
+ *
1405
+ * Manually refreshes the access token of an existing OAuth2 credential and
1406
+ * returns the updated credential record.
1407
+ *
1408
+ * @remarks Requires admin/owner role on the organization.
1409
+ */
1410
+ async refreshOAuth2(credentialId, options) {
1411
+ return this._post(
1412
+ `/credentials/${credentialId}/oauth2/refresh`,
1413
+ void 0,
1414
+ options
1415
+ );
1416
+ }
1182
1417
  };
1183
1418
 
1184
1419
  // src/resources/integrations.ts
@@ -1222,7 +1457,7 @@ var Integrations = class extends BaseResource {
1222
1457
  */
1223
1458
  async tool(integrationName, options) {
1224
1459
  return this._get(
1225
- `/integrations/tools/${integrationName}`,
1460
+ `/integrations/tools/${encodeURIComponent(integrationName)}`,
1226
1461
  options
1227
1462
  );
1228
1463
  }
@@ -1244,7 +1479,7 @@ var Integrations = class extends BaseResource {
1244
1479
  */
1245
1480
  async llmProvider(providerName, options) {
1246
1481
  return this._get(
1247
- `/integrations/llm-providers/${providerName}`,
1482
+ `/integrations/llm-providers/${encodeURIComponent(providerName)}`,
1248
1483
  options
1249
1484
  );
1250
1485
  }
@@ -1266,7 +1501,7 @@ var Integrations = class extends BaseResource {
1266
1501
  */
1267
1502
  async knowledgeProvider(providerName, options) {
1268
1503
  return this._get(
1269
- `/integrations/knowledge-providers/${providerName}`,
1504
+ `/integrations/knowledge-providers/${encodeURIComponent(providerName)}`,
1270
1505
  options
1271
1506
  );
1272
1507
  }
@@ -1277,7 +1512,7 @@ var Integrations = class extends BaseResource {
1277
1512
  */
1278
1513
  async get(integrationName, options) {
1279
1514
  return this._get(
1280
- `/integrations/${integrationName}`,
1515
+ `/integrations/${encodeURIComponent(integrationName)}`,
1281
1516
  options
1282
1517
  );
1283
1518
  }
@@ -1289,6 +1524,9 @@ var Knowledge = class extends BaseResource {
1289
1524
  * GET /knowledge-bases
1290
1525
  *
1291
1526
  * Lists knowledge bases for the current organization.
1527
+ *
1528
+ * The backend returns a bare JSON array (no pagination envelope); the
1529
+ * `limit`/`offset`/`status` query params control which records are returned.
1292
1530
  */
1293
1531
  async list(params, options) {
1294
1532
  return this._get("/knowledge-bases", {
@@ -1305,6 +1543,8 @@ var Knowledge = class extends BaseResource {
1305
1543
  * POST /knowledge-bases
1306
1544
  *
1307
1545
  * Creates a new knowledge base.
1546
+ *
1547
+ * Requires an organization admin or owner role; non-admin keys receive 403.
1308
1548
  */
1309
1549
  async create(params, options) {
1310
1550
  return this._post("/knowledge-bases", params, options);
@@ -1332,6 +1572,8 @@ var Knowledge = class extends BaseResource {
1332
1572
  * PUT /knowledge-bases/{kbId}
1333
1573
  *
1334
1574
  * Updates a knowledge base's name, description, or configuration.
1575
+ *
1576
+ * Requires an organization admin or owner role; non-admin keys receive 403.
1335
1577
  */
1336
1578
  async update(knowledgeBaseId, params, options) {
1337
1579
  return this._put(
@@ -1345,6 +1587,8 @@ var Knowledge = class extends BaseResource {
1345
1587
  *
1346
1588
  * Deletes a knowledge base. Pass `deleteFiles: true` to also remove
1347
1589
  * the underlying stored files.
1590
+ *
1591
+ * Requires an organization admin or owner role; non-admin keys receive 403.
1348
1592
  */
1349
1593
  async delete(knowledgeBaseId, params, options) {
1350
1594
  return this._delete(
@@ -1363,6 +1607,9 @@ var Knowledge = class extends BaseResource {
1363
1607
  * POST /knowledge-bases/{kbId}/archive
1364
1608
  *
1365
1609
  * Archives a knowledge base, pausing ingestion without deleting data.
1610
+ * Returns the updated knowledge base record.
1611
+ *
1612
+ * Requires an organization admin or owner role; non-admin keys receive 403.
1366
1613
  */
1367
1614
  async archive(knowledgeBaseId, options) {
1368
1615
  return this._post(
@@ -1375,6 +1622,9 @@ var Knowledge = class extends BaseResource {
1375
1622
  * GET /knowledge-bases/{kbId}/documents
1376
1623
  *
1377
1624
  * Returns documents within a knowledge base.
1625
+ *
1626
+ * The backend returns a bare JSON array; the `limit`/`offset`/`status`
1627
+ * query params control which records are returned.
1378
1628
  */
1379
1629
  async documents(knowledgeBaseId, params, options) {
1380
1630
  return this._get(
@@ -1395,6 +1645,8 @@ var Knowledge = class extends BaseResource {
1395
1645
  *
1396
1646
  * Uploads a document file to a knowledge base for ingestion.
1397
1647
  * Builds a `FormData` with the file and optional metadata JSON.
1648
+ *
1649
+ * Requires an organization admin or owner role; non-admin keys receive 403.
1398
1650
  */
1399
1651
  async uploadDocument(knowledgeBaseId, params, options) {
1400
1652
  const formData = new FormData();
@@ -1422,7 +1674,8 @@ var Knowledge = class extends BaseResource {
1422
1674
  /**
1423
1675
  * GET /knowledge-bases/{kbId}/documents/{docId}/status
1424
1676
  *
1425
- * Returns the processing status and progress of a document.
1677
+ * Returns the processing status of a document. Some fields are conditional
1678
+ * on the document's `status` value.
1426
1679
  */
1427
1680
  async documentStatus(knowledgeBaseId, documentId, options) {
1428
1681
  return this._get(
@@ -1435,6 +1688,8 @@ var Knowledge = class extends BaseResource {
1435
1688
  *
1436
1689
  * Deletes a document and its chunks from the knowledge base.
1437
1690
  * Pass `deleteFile: true` to also remove the source file from storage.
1691
+ *
1692
+ * Requires an organization admin or owner role; non-admin keys receive 403.
1438
1693
  */
1439
1694
  async deleteDocument(knowledgeBaseId, documentId, params, options) {
1440
1695
  return this._delete(
@@ -1452,7 +1707,9 @@ var Knowledge = class extends BaseResource {
1452
1707
  /**
1453
1708
  * POST /knowledge-bases/{kbId}/documents/{docId}/retry
1454
1709
  *
1455
- * Retries ingestion of a failed document.
1710
+ * Retries ingestion of a failed document. Returns the updated document record.
1711
+ *
1712
+ * Requires an organization admin or owner role; non-admin keys receive 403.
1456
1713
  */
1457
1714
  async retryDocument(knowledgeBaseId, documentId, options) {
1458
1715
  return this._post(
@@ -1596,6 +1853,7 @@ var Schedules = class extends BaseResource {
1596
1853
  * POST /schedules/{scheduleId}/pause
1597
1854
  *
1598
1855
  * Pauses a schedule, preventing future runs until resumed.
1856
+ * Returns the updated schedule.
1599
1857
  */
1600
1858
  async pause(scheduleId, options) {
1601
1859
  return this._post(
@@ -1607,7 +1865,7 @@ var Schedules = class extends BaseResource {
1607
1865
  /**
1608
1866
  * POST /schedules/{scheduleId}/resume
1609
1867
  *
1610
- * Resumes a paused schedule.
1868
+ * Resumes a paused schedule. Returns the updated schedule.
1611
1869
  */
1612
1870
  async resume(scheduleId, options) {
1613
1871
  return this._post(
@@ -1674,204 +1932,293 @@ var Schedules = class extends BaseResource {
1674
1932
  }
1675
1933
  };
1676
1934
 
1677
- // src/resources/templates.ts
1678
- var Templates = class extends BaseResource {
1935
+ // src/resources/composer.ts
1936
+ var Composer = class extends BaseResource {
1679
1937
  /**
1680
- * GET /templates
1938
+ * POST /composer/chat
1681
1939
  *
1682
- * Returns the public template library.
1940
+ * Starts a new Composer chat or sends a message to an existing session.
1941
+ * Returns a run ID that can be used to listen to the SSE stream.
1942
+ *
1943
+ * Errors: 409 if the chat has a pending HITL question (answer it via
1944
+ * `resume()` first); 402/403/429 for billing/limit gates.
1683
1945
  */
1684
- async list(options) {
1685
- return this._get("/templates", options);
1946
+ async chat(params, options) {
1947
+ return this._post("/composer/chat", params, options);
1686
1948
  }
1687
1949
  /**
1688
- * GET /templates/{templateId}
1950
+ * GET /composer/chats
1689
1951
  *
1690
- * Returns a single template including its full workflow schema.
1952
+ * Lists the current user's Composer chats, newest first, with cursor
1953
+ * pagination (`next_cursor` is an ISO `updated_at` timestamp).
1691
1954
  */
1692
- async get(templateId, options) {
1693
- return this._get(`/templates/${templateId}`, options);
1955
+ async list(params, options) {
1956
+ return this._get("/composer/chats", {
1957
+ ...options,
1958
+ params: {
1959
+ ...options?.params,
1960
+ limit: params?.limit,
1961
+ cursor: params?.cursor
1962
+ }
1963
+ });
1694
1964
  }
1695
1965
  /**
1696
- * GET /templates/me
1966
+ * GET /composer/chat/{composerChatId}
1697
1967
  *
1698
- * Returns templates created by the authenticated user.
1968
+ * Returns a Composer chat session with its messages, touched workflows, and
1969
+ * any open HITL question (`pending_user_input_request`).
1699
1970
  */
1700
- async mine(options) {
1701
- return this._get("/templates/me", options);
1971
+ async get(composerChatId, options) {
1972
+ return this._get(
1973
+ `/composer/chat/${composerChatId}`,
1974
+ options
1975
+ );
1702
1976
  }
1703
1977
  /**
1704
- * POST /templates
1978
+ * GET /composer/chat/{composerChatId}/listen/{runId} — SSE
1979
+ *
1980
+ * Opens a Server-Sent Events stream for real-time Composer output. This is a
1981
+ * data-only stream: each yielded value is a {@link ComposerSSEEvent}
1982
+ * discriminated on `type`. A `user_input_request` frame signals a HITL pause —
1983
+ * answer it with `resume()`.
1705
1984
  *
1706
- * Publishes a workflow as a new template.
1985
+ * A 404 on connect throws `NotFoundError` before any event is yielded — the
1986
+ * chat/run does not exist OR is not owned by your organization (ownership
1987
+ * failures return an identical 404, not 403). The stream does NOT
1988
+ * auto-reconnect on a 404.
1707
1989
  */
1708
- async create(params, options) {
1709
- return this._post("/templates", params, options);
1990
+ async *listen(composerChatId, runId, options) {
1991
+ for await (const frame of this.streamSSE(
1992
+ `/composer/chat/${composerChatId}/listen/${runId}`,
1993
+ options
1994
+ )) {
1995
+ yield frame.data;
1996
+ }
1710
1997
  }
1711
1998
  /**
1712
- * POST /templates/{templateId}/like
1999
+ * POST /composer/chat/{composerChatId}/resume
2000
+ *
2001
+ * Answers an open HITL question and resumes the paused run. Returns a NEW
2002
+ * `run_id` to listen on.
1713
2003
  *
1714
- * Toggles the authenticated user's like on a template.
2004
+ * Errors: 404 (a `NotFoundError`) when the chat does not exist OR is not owned
2005
+ * by your organization (ownership failures return an identical 404, not 403);
2006
+ * 410 if the `requestId` is not pending or already consumed; 403 if the caller
2007
+ * is not the user who triggered the question. The `llm` config is required in
2008
+ * production (the backend returns 400 if omitted).
1715
2009
  */
1716
- async like(templateId, options) {
2010
+ async resume(composerChatId, params, options) {
1717
2011
  return this._post(
1718
- `/templates/${templateId}/like`,
1719
- void 0,
2012
+ `/composer/chat/${composerChatId}/resume`,
2013
+ params,
1720
2014
  options
1721
2015
  );
1722
2016
  }
1723
2017
  /**
1724
- * POST /templates/{templateId}/use
2018
+ * PATCH /composer/chat/{composerChatId}/focus
1725
2019
  *
1726
- * Imports a template as a new workflow in the current organization.
2020
+ * Sets (or clears, with `workflowId: null`) the chat's focused workflow.
1727
2021
  */
1728
- async use(templateId, options) {
1729
- return this._post(
1730
- `/templates/${templateId}/use`,
1731
- void 0,
2022
+ async focus(composerChatId, params, options) {
2023
+ return this._patch(
2024
+ `/composer/chat/${composerChatId}/focus`,
2025
+ params,
1732
2026
  options
1733
2027
  );
1734
2028
  }
1735
2029
  /**
1736
- * POST /templates/{templateId}/update-request
2030
+ * POST /composer/chat/{composerChatId}/save
1737
2031
  *
1738
- * Submits an update request for a published template.
2032
+ * Saves the Composer's pending workflow changes. Without `workflowId` it
2033
+ * targets the chat's focused workflow (400 if there is none). Returns a
2034
+ * `workflow_sync` payload for refreshing the canvas.
1739
2035
  */
1740
- async updateRequest(templateId, params, options) {
2036
+ async save(composerChatId, params, options) {
1741
2037
  return this._post(
1742
- `/templates/${templateId}/update-request`,
2038
+ `/composer/chat/${composerChatId}/save`,
1743
2039
  params,
1744
2040
  options
1745
2041
  );
1746
2042
  }
1747
2043
  /**
1748
- * POST /templates/creators
2044
+ * POST /composer/chat/{composerChatId}/revert
1749
2045
  *
1750
- * Creates or updates the authenticated user's template creator profile.
2046
+ * Reverts pending changes to the last snapshot. Without `workflowId` it
2047
+ * targets the focused workflow (400 if there is none, or if no snapshot
2048
+ * exists). Returns a `workflow_sync` payload.
1751
2049
  */
1752
- async createCreator(params, options) {
1753
- return this._post("/templates/creators", params, options);
2050
+ async revert(composerChatId, params, options) {
2051
+ return this._post(
2052
+ `/composer/chat/${composerChatId}/revert`,
2053
+ params,
2054
+ options
2055
+ );
1754
2056
  }
1755
2057
  /**
1756
- * GET /templates/creators/me
2058
+ * DELETE /composer/chat/{composerChatId}
1757
2059
  *
1758
- * Returns the authenticated user's template creator profile.
2060
+ * Deletes a Composer chat session. Pass `permanent: true` for a hard delete
2061
+ * (default is a soft delete). `permanent` is sent as a query parameter.
1759
2062
  */
1760
- async getCreator(options) {
1761
- return this._get("/templates/creators/me", options);
2063
+ async delete(composerChatId, params, options) {
2064
+ return this._delete(
2065
+ `/composer/chat/${composerChatId}`,
2066
+ void 0,
2067
+ {
2068
+ ...options,
2069
+ params: { ...options?.params, permanent: params?.permanent }
2070
+ }
2071
+ );
1762
2072
  }
1763
- };
1764
-
1765
- // src/resources/composer.ts
1766
- var Composer = class extends BaseResource {
1767
2073
  /**
1768
- * POST /composer/chat
2074
+ * GET /composer/chat/{composerChatId}/status
1769
2075
  *
1770
- * Starts a new Composer chat or sends a message to an existing session.
1771
- * Returns a run ID that can be used to listen to the SSE stream.
2076
+ * Returns the real-time status of a Composer chat session, including HITL
2077
+ * pause state (`awaiting_input` / `pending_request_id`).
1772
2078
  */
1773
- async chat(params, options) {
1774
- return this._post("/composer/chat", params, options);
2079
+ async status(composerChatId, options) {
2080
+ return this._get(
2081
+ `/composer/chat/${composerChatId}/status`,
2082
+ options
2083
+ );
1775
2084
  }
1776
2085
  /**
1777
- * GET /composer/chat/{composerChatId}
2086
+ * POST /composer/chat/{composerChatId}/cancel
1778
2087
  *
1779
- * Returns a Composer chat session with its messages and workflow snapshot status.
2088
+ * Cancels the in-progress run for a Composer chat session.
2089
+ *
2090
+ * Throws `NotFoundError` on HTTP 404 — the chat does not exist OR is not owned
2091
+ * by your organization (ownership failures return an identical 404, not 403,
2092
+ * so there is no existence leak).
1780
2093
  */
1781
- async get(composerChatId, options) {
1782
- return this._get(
1783
- `/composer/chat/${composerChatId}`,
2094
+ async cancel(composerChatId, options) {
2095
+ return this._post(
2096
+ `/composer/chat/${composerChatId}/cancel`,
2097
+ void 0,
1784
2098
  options
1785
2099
  );
1786
2100
  }
2101
+ };
2102
+
2103
+ // src/resources/assistant.ts
2104
+ var Assistant = class extends BaseResource {
1787
2105
  /**
1788
- * GET /composer/chat/{composerChatId}/listen/{runId} — SSE
2106
+ * POST /assistant/chat
2107
+ *
2108
+ * Starts a new Assistant chat or sends a message to an existing one. Returns
2109
+ * a run ID to listen on.
1789
2110
  *
1790
- * Opens a Server-Sent Events stream for real-time Composer output during a run.
2111
+ * Errors: 409 if the chat has a pending HITL question or a run is already in
2112
+ * progress (answer via `resume()` / `cancel()` first); 402/403/429 at the
2113
+ * billing gate.
1791
2114
  */
1792
- listen(composerChatId, runId, options) {
1793
- return this.streamSSE(
1794
- `/composer/chat/${composerChatId}/listen/${runId}`,
1795
- options
1796
- );
2115
+ async chat(params, options) {
2116
+ return this._post("/assistant/chat", params, options);
1797
2117
  }
1798
2118
  /**
1799
- * POST /composer/chat/{composerChatId}/save
2119
+ * GET /assistant/chats
1800
2120
  *
1801
- * Saves the Composer's current workflow changes to the associated workflow.
2121
+ * Lists the current user's Assistant chats, newest first, with cursor
2122
+ * pagination (`next_cursor` is an ISO `updated_at` timestamp).
1802
2123
  */
1803
- async save(composerChatId, options) {
1804
- return this._post(
1805
- `/composer/chat/${composerChatId}/save`,
1806
- void 0,
1807
- options
1808
- );
2124
+ async list(params, options) {
2125
+ return this._get("/assistant/chats", {
2126
+ ...options,
2127
+ params: {
2128
+ ...options?.params,
2129
+ limit: params?.limit,
2130
+ cursor: params?.cursor
2131
+ }
2132
+ });
1809
2133
  }
1810
2134
  /**
1811
- * POST /composer/chat/{composerChatId}/revert
2135
+ * GET /assistant/chat/{chatId}
1812
2136
  *
1813
- * Reverts the Composer's pending changes, restoring the last saved state.
2137
+ * Returns an Assistant chat with its messages and any open HITL question
2138
+ * (`pending_user_input_request`).
1814
2139
  */
1815
- async revert(composerChatId, options) {
1816
- return this._post(
1817
- `/composer/chat/${composerChatId}/revert`,
1818
- void 0,
1819
- options
1820
- );
2140
+ async get(chatId, options) {
2141
+ return this._get(`/assistant/chat/${chatId}`, options);
1821
2142
  }
1822
2143
  /**
1823
- * GET /composer/chat/workflow/{workflowId}/history
2144
+ * GET /assistant/chat/{chatId}/listen/{runId} — SSE
2145
+ *
2146
+ * Opens a Server-Sent Events stream for real-time Assistant output. This is a
2147
+ * data-only stream: each yielded value is an {@link AssistantSSEEvent}
2148
+ * discriminated on `type`. A `user_input_request` frame signals a HITL pause —
2149
+ * answer it with `resume()`.
1824
2150
  *
1825
- * Returns the Composer chat history associated with a workflow.
2151
+ * A 404 on connect throws `NotFoundError` before any event is yielded — the
2152
+ * chat/run does not exist OR is not owned by your organization (ownership
2153
+ * failures return an identical 404, not 403). The stream does NOT
2154
+ * auto-reconnect on a 404.
1826
2155
  */
1827
- async history(workflowId, params, options) {
1828
- return this._get(
1829
- `/composer/chat/workflow/${workflowId}/history`,
1830
- {
1831
- ...options,
1832
- params: {
1833
- ...options?.params,
1834
- limit: params?.limit
1835
- }
1836
- }
1837
- );
2156
+ async *listen(chatId, runId, options) {
2157
+ for await (const frame of this.streamSSE(
2158
+ `/assistant/chat/${chatId}/listen/${runId}`,
2159
+ options
2160
+ )) {
2161
+ yield frame.data;
2162
+ }
1838
2163
  }
1839
2164
  /**
1840
- * DELETE /composer/chat/{composerChatId}
2165
+ * POST /assistant/chat/{chatId}/resume
2166
+ *
2167
+ * Answers an open HITL question and resumes the paused run. Returns a NEW
2168
+ * `run_id` to listen on.
1841
2169
  *
1842
- * Deletes a Composer chat session. Pass `permanent: true` to also delete
1843
- * the associated workflow.
2170
+ * Errors: 404 (a `NotFoundError`) when the chat is not found OR is not owned by
2171
+ * your organization (ownership failures return an identical 404, not 403); 410
2172
+ * if the question was already answered or cancelled; 403 if the caller is not
2173
+ * the user who triggered it. `llm` is required (400 if omitted).
1844
2174
  */
1845
- async delete(composerChatId, params, options) {
1846
- return this._delete(
1847
- `/composer/chat/${composerChatId}`,
2175
+ async resume(chatId, params, options) {
2176
+ return this._post(
2177
+ `/assistant/chat/${chatId}/resume`,
1848
2178
  params,
1849
2179
  options
1850
2180
  );
1851
2181
  }
1852
2182
  /**
1853
- * GET /composer/chat/{composerChatId}/status
2183
+ * GET /assistant/chat/{chatId}/status
1854
2184
  *
1855
- * Returns the real-time status of a Composer chat session.
2185
+ * Returns real-time status including HITL pause state (`awaiting_input` /
2186
+ * `pending_request_id`).
1856
2187
  */
1857
- async status(composerChatId, options) {
1858
- return this._get(
1859
- `/composer/chat/${composerChatId}/status`,
1860
- options
1861
- );
2188
+ async status(chatId, options) {
2189
+ return this._get(`/assistant/chat/${chatId}/status`, options);
1862
2190
  }
1863
2191
  /**
1864
- * POST /composer/chat/{composerChatId}/cancel
2192
+ * POST /assistant/chat/{chatId}/cancel
1865
2193
  *
1866
- * Cancels the in-progress run for a Composer chat session.
2194
+ * Cancels the in-progress run and clears any pending HITL question. The
2195
+ * returned `run_id` is the run that was cancelled. Errors: 404 (a
2196
+ * `NotFoundError`) when the chat is not found OR is not owned by your
2197
+ * organization (ownership failures return an identical 404, not 403); 400 if
2198
+ * there is no active execution.
1867
2199
  */
1868
- async cancel(composerChatId, options) {
2200
+ async cancel(chatId, options) {
1869
2201
  return this._post(
1870
- `/composer/chat/${composerChatId}/cancel`,
2202
+ `/assistant/chat/${chatId}/cancel`,
1871
2203
  void 0,
1872
2204
  options
1873
2205
  );
1874
2206
  }
2207
+ /**
2208
+ * DELETE /assistant/chat/{chatId}
2209
+ *
2210
+ * Deletes an Assistant chat. Pass `permanent: true` for a hard delete
2211
+ * (default is a soft delete).
2212
+ */
2213
+ async delete(chatId, params, options) {
2214
+ return this._delete(`/assistant/chat/${chatId}`, void 0, {
2215
+ ...options,
2216
+ params: {
2217
+ ...options?.params,
2218
+ permanent: params?.permanent
2219
+ }
2220
+ });
2221
+ }
1875
2222
  };
1876
2223
 
1877
2224
  // src/resources/dashboard.ts
@@ -1963,54 +2310,6 @@ var Dashboard = class extends BaseResource {
1963
2310
  }
1964
2311
  };
1965
2312
 
1966
- // src/resources/subscriptions.ts
1967
- var Subscriptions = class extends BaseResource {
1968
- /**
1969
- * GET /subscriptions/organization-plans
1970
- *
1971
- * Returns the list of available organization subscription plans.
1972
- */
1973
- async organizationPlans(options) {
1974
- return this._get(
1975
- "/subscriptions/organization-plans",
1976
- options
1977
- );
1978
- }
1979
- /**
1980
- * GET /subscriptions/organization-billing
1981
- *
1982
- * Returns the current organization's billing status and active subscription.
1983
- */
1984
- async billing(options) {
1985
- return this._get("/subscriptions/organization-billing", options);
1986
- }
1987
- /**
1988
- * POST /subscriptions/checkout-link
1989
- *
1990
- * Creates a Stripe Checkout session and returns the redirect URL.
1991
- */
1992
- async checkoutLink(params, options) {
1993
- return this._post(
1994
- "/subscriptions/checkout-link",
1995
- params,
1996
- options
1997
- );
1998
- }
1999
- /**
2000
- * POST /subscriptions/customer-portal
2001
- *
2002
- * Creates a Stripe Customer Portal session and returns the redirect URL
2003
- * for the user to manage their billing.
2004
- */
2005
- async customerPortal(options) {
2006
- return this._post(
2007
- "/subscriptions/customer-portal",
2008
- void 0,
2009
- options
2010
- );
2011
- }
2012
- };
2013
-
2014
2313
  // src/resources/notifications.ts
2015
2314
  var Notifications = class extends BaseResource {
2016
2315
  /**
@@ -2025,6 +2324,14 @@ var Notifications = class extends BaseResource {
2025
2324
  * POST /notifications/organization
2026
2325
  *
2027
2326
  * Creates a new notification for the organization or a specific user.
2327
+ *
2328
+ * Requires an organization context: an `X-Organization-ID` header is sent
2329
+ * automatically from the client's configured `organizationId` or from
2330
+ * `options.organizationId`. If neither is set, no header is sent and the
2331
+ * backend responds with HTTP 400 ("X-Organization-ID header is required").
2332
+ *
2333
+ * @returns The created notification wrapped in a `{ success, notification }`
2334
+ * envelope.
2028
2335
  */
2029
2336
  async create(params, options) {
2030
2337
  return this._post(
@@ -2037,44 +2344,10 @@ var Notifications = class extends BaseResource {
2037
2344
 
2038
2345
  // src/resources/system.ts
2039
2346
  var System = class extends BaseResource {
2040
- /**
2041
- * GET /system/health
2042
- *
2043
- * Returns the service health status, name, and version.
2044
- */
2045
- async health(options) {
2046
- return this._get(
2047
- "/system/health",
2048
- options
2049
- );
2050
- }
2051
- /**
2052
- * GET /system/metrics
2053
- *
2054
- * Returns Prometheus-format metrics as plain text.
2055
- * This endpoint bypasses the JSON-parsing logic of `BaseResource.get()` and
2056
- * reads the raw response body as a string.
2057
- */
2058
- async metrics(options) {
2059
- const orgId = options?.organizationId ?? this._config.organizationId;
2060
- const url = `${this._config.baseUrl}/system/metrics`;
2061
- const headers = {
2062
- "Authorization": `Bearer ${this._config.apiKey}`
2063
- };
2064
- if (orgId) {
2065
- headers["X-Organization-ID"] = orgId;
2066
- }
2067
- const response = await this._config.fetch(url, {
2068
- method: "GET",
2069
- headers,
2070
- signal: options?.signal
2071
- });
2072
- return response.text();
2073
- }
2074
2347
  /**
2075
2348
  * GET /system/timezones
2076
2349
  *
2077
- * Returns the list of supported IANA timezone identifiers.
2350
+ * Returns popular timezone groups plus the full list of IANA identifiers.
2078
2351
  */
2079
2352
  async timezones(options) {
2080
2353
  return this._get("/system/timezones", options);
@@ -2082,7 +2355,8 @@ var System = class extends BaseResource {
2082
2355
  /**
2083
2356
  * GET /system/timezones/search
2084
2357
  *
2085
- * Searches supported IANA timezone identifiers by query string.
2358
+ * Searches supported IANA timezones by query string. `query` must be at least
2359
+ * 2 characters (the backend returns 422 otherwise). Returns at most 20 results.
2086
2360
  */
2087
2361
  async searchTimezones(query, options) {
2088
2362
  return this._get("/system/timezones/search", {
@@ -2113,10 +2387,14 @@ var Modulex = class {
2113
2387
  get workflows() {
2114
2388
  return this._workflows ?? (this._workflows = new Workflows(this._config));
2115
2389
  }
2116
- /** Workflow execution endpoints (run, resume, cancel, listen). */
2390
+ /** Workflow execution-control endpoints (run, resume, cancel, listen). */
2117
2391
  get executions() {
2118
2392
  return this._executions ?? (this._executions = new Executions(this._config));
2119
2393
  }
2394
+ /** Durable workflow run-history endpoints (list, get persisted runs). */
2395
+ get workflowRuns() {
2396
+ return this._workflowRuns ?? (this._workflowRuns = new WorkflowRuns(this._config));
2397
+ }
2120
2398
  /** Workflow deployment endpoints. */
2121
2399
  get deployments() {
2122
2400
  return this._deployments ?? (this._deployments = new Deployments(this._config));
@@ -2141,22 +2419,18 @@ var Modulex = class {
2141
2419
  get schedules() {
2142
2420
  return this._schedules ?? (this._schedules = new Schedules(this._config));
2143
2421
  }
2144
- /** Template endpoints. */
2145
- get templates() {
2146
- return this._templates ?? (this._templates = new Templates(this._config));
2147
- }
2148
2422
  /** Composer (AI workflow builder) endpoints. */
2149
2423
  get composer() {
2150
2424
  return this._composer ?? (this._composer = new Composer(this._config));
2151
2425
  }
2426
+ /** Assistant (HITL chat agent) endpoints. */
2427
+ get assistant() {
2428
+ return this._assistant ?? (this._assistant = new Assistant(this._config));
2429
+ }
2152
2430
  /** Dashboard and analytics endpoints. */
2153
2431
  get dashboard() {
2154
2432
  return this._dashboard ?? (this._dashboard = new Dashboard(this._config));
2155
2433
  }
2156
- /** Subscription and billing endpoints. */
2157
- get subscriptions() {
2158
- return this._subscriptions ?? (this._subscriptions = new Subscriptions(this._config));
2159
- }
2160
2434
  /** Notification endpoints. */
2161
2435
  get notifications() {
2162
2436
  return this._notifications ?? (this._notifications = new Notifications(this._config));