@getmodus/sdk 0.9.0 → 0.11.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.cjs CHANGED
@@ -1,1383 +1,46 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+
19
4
 
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- APIConnectionError: () => APIConnectionError,
24
- AgentType: () => AgentType,
25
- AuthenticationError: () => AuthenticationError,
26
- ChatStream: () => ChatStream,
27
- ConflictError: () => ConflictError,
28
- InternalServerError: () => InternalServerError,
29
- Modus: () => Modus,
30
- ModusError: () => ModusError,
31
- NotFoundError: () => NotFoundError,
32
- OPERATIONS: () => OPERATIONS,
33
- Page: () => Page,
34
- PermissionDeniedError: () => PermissionDeniedError,
35
- RateLimitError: () => RateLimitError,
36
- RunCancelledError: () => RunCancelledError,
37
- StreamTimeoutError: () => StreamTimeoutError,
38
- UnprocessableError: () => UnprocessableError,
39
- ValidationError: () => ValidationError,
40
- WorkflowType: () => WorkflowType,
41
- conversationScopeId: () => conversationScopeId,
42
- conversationSkillId: () => conversationSkillId
43
- });
44
- module.exports = __toCommonJS(index_exports);
45
-
46
- // src/_generated/operations.ts
47
- var OPERATIONS = {
48
- "ConnectionsController_list": {
49
- method: "GET",
50
- path: "/api/v1/connections",
51
- service: "modus-api",
52
- serverUrl: "https://api.getmodus.com",
53
- pathParams: [],
54
- queryParams: ["pageToken", "pageSize", "type"],
55
- requestSchema: null,
56
- responseSchema: "ListConnectionsResponseDto"
57
- },
58
- "ConnectionsController_listSelections": {
59
- method: "GET",
60
- path: "/api/v1/connections/{connectionId}/selections",
61
- service: "modus-api",
62
- serverUrl: "https://api.getmodus.com",
63
- pathParams: ["connectionId"],
64
- queryParams: ["pageToken", "pageSize"],
65
- requestSchema: null,
66
- responseSchema: "ListConnectionSelectionsResponseDto"
67
- },
68
- "ContextCreatorsController_createLink": {
69
- method: "POST",
70
- path: "/api/v1/context/links",
71
- service: "modus-api",
72
- serverUrl: "https://api.getmodus.com",
73
- pathParams: [],
74
- queryParams: [],
75
- requestSchema: "CreateLinkDto",
76
- responseSchema: "CreatedContextItemResponseDto"
77
- },
78
- "ContextCreatorsController_createNote": {
79
- method: "POST",
80
- path: "/api/v1/context/notes",
81
- service: "modus-api",
82
- serverUrl: "https://api.getmodus.com",
83
- pathParams: [],
84
- queryParams: [],
85
- requestSchema: "CreateNoteDto",
86
- responseSchema: "CreatedContextItemResponseDto"
87
- },
88
- "ContextCreatorsController_createSavedQuery": {
89
- method: "POST",
90
- path: "/api/v1/context/saved-queries",
91
- service: "modus-api",
92
- serverUrl: "https://api.getmodus.com",
93
- pathParams: [],
94
- queryParams: [],
95
- requestSchema: "CreateSavedQueryDto",
96
- responseSchema: "CreatedContextItemResponseDto"
97
- },
98
- "ContextFilesController_finalize": {
99
- method: "POST",
100
- path: "/api/v1/context/files/{uploadId}/finalize",
101
- service: "modus-api",
102
- serverUrl: "https://api.getmodus.com",
103
- pathParams: ["uploadId"],
104
- queryParams: [],
105
- requestSchema: "FinalizeUploadDto",
106
- responseSchema: "FileUploadResourceDto"
107
- },
108
- "ContextFilesController_finalizeMany": {
109
- method: "POST",
110
- path: "/api/v1/context/files/finalize",
111
- service: "modus-api",
112
- serverUrl: "https://api.getmodus.com",
113
- pathParams: [],
114
- queryParams: [],
115
- requestSchema: "BulkFinalizeDto",
116
- responseSchema: "BulkFinalizeResponseDto"
117
- },
118
- "ContextFilesController_get": {
119
- method: "GET",
120
- path: "/api/v1/context/files/{uploadId}",
121
- service: "modus-api",
122
- serverUrl: "https://api.getmodus.com",
123
- pathParams: ["uploadId"],
124
- queryParams: [],
125
- requestSchema: null,
126
- responseSchema: "FileUploadResourceDto"
127
- },
128
- "ContextFilesController_list": {
129
- method: "GET",
130
- path: "/api/v1/context/files",
131
- service: "modus-api",
132
- serverUrl: "https://api.getmodus.com",
133
- pathParams: [],
134
- queryParams: ["pageToken", "pageSize"],
135
- requestSchema: null,
136
- responseSchema: "ListFilesResponseDto"
137
- },
138
- "ContextFilesController_uploadFromUrl": {
139
- method: "POST",
140
- path: "/api/v1/context/files/uploadFromUrl",
141
- service: "modus-api",
142
- serverUrl: "https://api.getmodus.com",
143
- pathParams: [],
144
- queryParams: [],
145
- requestSchema: "UploadFromUrlDto",
146
- responseSchema: "FileUploadResourceDto"
147
- },
148
- "ContextFilesController_uploadFromUrls": {
149
- method: "POST",
150
- path: "/api/v1/context/files/uploadFromUrls",
151
- service: "modus-api",
152
- serverUrl: "https://api.getmodus.com",
153
- pathParams: [],
154
- queryParams: [],
155
- requestSchema: "BulkUploadFromUrlsDto",
156
- responseSchema: "BulkUploadFromUrlsResponseDto"
157
- },
158
- "ContextFilesController_uploadUrl": {
159
- method: "POST",
160
- path: "/api/v1/context/files/uploadUrl",
161
- service: "modus-api",
162
- serverUrl: "https://api.getmodus.com",
163
- pathParams: [],
164
- queryParams: [],
165
- requestSchema: "UploadUrlDto",
166
- responseSchema: "UploadUrlResponseDto"
167
- },
168
- "ContextFilesController_uploadUrls": {
169
- method: "POST",
170
- path: "/api/v1/context/files/uploadUrls",
171
- service: "modus-api",
172
- serverUrl: "https://api.getmodus.com",
173
- pathParams: [],
174
- queryParams: [],
175
- requestSchema: "BulkUploadUrlsDto",
176
- responseSchema: "BulkUploadUrlsResponseDto"
177
- },
178
- "ContextItemsController_delete": {
179
- method: "DELETE",
180
- path: "/api/v1/context/items/{uid}",
181
- service: "modus-api",
182
- serverUrl: "https://api.getmodus.com",
183
- pathParams: ["uid"],
184
- queryParams: [],
185
- requestSchema: null,
186
- responseSchema: "DeleteContextItemResponseDto"
187
- },
188
- "ContextItemsController_get": {
189
- method: "GET",
190
- path: "/api/v1/context/items/{uid}",
191
- service: "modus-api",
192
- serverUrl: "https://api.getmodus.com",
193
- pathParams: ["uid"],
194
- queryParams: [],
195
- requestSchema: null,
196
- responseSchema: "ContextItemDto"
197
- },
198
- "ContextItemsController_list": {
199
- method: "GET",
200
- path: "/api/v1/context/items",
201
- service: "modus-api",
202
- serverUrl: "https://api.getmodus.com",
203
- pathParams: [],
204
- queryParams: ["pageToken", "pageSize", "contextTypes", "verificationStatuses", "searchQuery", "topics", "connectionIds", "parentUids", "ancestorUids"],
205
- requestSchema: null,
206
- responseSchema: "ListContextItemsResponseDto"
207
- },
208
- "ContextItemsController_listValues": {
209
- method: "GET",
210
- path: "/api/v1/context/items/{uid}/values",
211
- service: "modus-api",
212
- serverUrl: "https://api.getmodus.com",
213
- pathParams: ["uid"],
214
- queryParams: ["contextType", "contentKeyPath", "pageSize", "offset", "pageToken", "searchQuery", "dataPathPrefix"],
215
- requestSchema: null,
216
- responseSchema: "ListContextItemValuesResponseDto"
217
- },
218
- "ContextItemsController_lookup": {
219
- method: "POST",
220
- path: "/api/v1/context/items/lookup",
221
- service: "modus-api",
222
- serverUrl: "https://api.getmodus.com",
223
- pathParams: [],
224
- queryParams: [],
225
- requestSchema: "LookupContextItemDto",
226
- responseSchema: "LookupContextItemResponseDto"
227
- },
228
- "ContextItemsController_move": {
229
- method: "POST",
230
- path: "/api/v1/context/items/{uid}/move",
231
- service: "modus-api",
232
- serverUrl: "https://api.getmodus.com",
233
- pathParams: ["uid"],
234
- queryParams: [],
235
- requestSchema: "MoveContextItemDto",
236
- responseSchema: "MoveContextItemResponseDto"
237
- },
238
- "ContextItemsController_update": {
239
- method: "PATCH",
240
- path: "/api/v1/context/items/{uid}",
241
- service: "modus-api",
242
- serverUrl: "https://api.getmodus.com",
243
- pathParams: ["uid"],
244
- queryParams: ["updateMask"],
245
- requestSchema: "UpdateContextItemDto",
246
- responseSchema: null
247
- },
248
- "CustomContextItemsController_batchCreate": {
249
- method: "POST",
250
- path: "/api/v1/context/custom-items/batch",
251
- service: "modus-api",
252
- serverUrl: "https://api.getmodus.com",
253
- pathParams: [],
254
- queryParams: [],
255
- requestSchema: "BatchCreateCustomContextItemsDto",
256
- responseSchema: "BatchCreateCustomContextItemsResponseDto"
257
- },
258
- "CustomContextItemsController_create": {
259
- method: "POST",
260
- path: "/api/v1/context/custom-items",
261
- service: "modus-api",
262
- serverUrl: "https://api.getmodus.com",
263
- pathParams: [],
264
- queryParams: [],
265
- requestSchema: "CreateCustomContextItemDto",
266
- responseSchema: "CreatedCustomContextItemResponseDto"
267
- },
268
- "CustomContextItemsController_createRelations": {
269
- method: "POST",
270
- path: "/api/v1/context/custom-items/relations",
271
- service: "modus-api",
272
- serverUrl: "https://api.getmodus.com",
273
- pathParams: [],
274
- queryParams: [],
275
- requestSchema: "BatchCreateCustomContextItemRelationsDto",
276
- responseSchema: "BatchCreateCustomContextItemRelationsResponseDto"
277
- },
278
- "CustomContextItemsController_delete": {
279
- method: "DELETE",
280
- path: "/api/v1/context/custom-items/{uid}",
281
- service: "modus-api",
282
- serverUrl: "https://api.getmodus.com",
283
- pathParams: ["uid"],
284
- queryParams: [],
285
- requestSchema: null,
286
- responseSchema: "DeleteContextItemResponseDto"
287
- },
288
- "CustomContextItemsController_get": {
289
- method: "GET",
290
- path: "/api/v1/context/custom-items/{uid}",
291
- service: "modus-api",
292
- serverUrl: "https://api.getmodus.com",
293
- pathParams: ["uid"],
294
- queryParams: [],
295
- requestSchema: null,
296
- responseSchema: "ContextItemDto"
297
- },
298
- "CustomContextItemsController_list": {
299
- method: "GET",
300
- path: "/api/v1/context/custom-items",
301
- service: "modus-api",
302
- serverUrl: "https://api.getmodus.com",
303
- pathParams: [],
304
- queryParams: ["pageToken", "pageSize", "contextTypes", "verificationStatuses", "searchQuery", "topics"],
305
- requestSchema: null,
306
- responseSchema: "ListCustomContextItemsResponseDto"
307
- },
308
- "CustomContextItemsController_update": {
309
- method: "PATCH",
310
- path: "/api/v1/context/custom-items/{uid}",
311
- service: "modus-api",
312
- serverUrl: "https://api.getmodus.com",
313
- pathParams: ["uid"],
314
- queryParams: [],
315
- requestSchema: "UpdateCustomContextItemDto",
316
- responseSchema: null
317
- },
318
- "DashboardsController_acceptOwnership": {
319
- method: "POST",
320
- path: "/api/v1/context/dashboards/{dashboardId}/transfer-ownership/accept",
321
- service: "modus-api",
322
- serverUrl: "https://api.getmodus.com",
323
- pathParams: ["dashboardId"],
324
- queryParams: [],
325
- requestSchema: null,
326
- responseSchema: "DashboardDto"
327
- },
328
- "DashboardsController_cancelOwnership": {
329
- method: "DELETE",
330
- path: "/api/v1/context/dashboards/{dashboardId}/transfer-ownership",
331
- service: "modus-api",
332
- serverUrl: "https://api.getmodus.com",
333
- pathParams: ["dashboardId"],
334
- queryParams: [],
335
- requestSchema: null,
336
- responseSchema: "DashboardDto"
337
- },
338
- "DashboardsController_create": {
339
- method: "POST",
340
- path: "/api/v1/context/dashboards",
341
- service: "modus-api",
342
- serverUrl: "https://api.getmodus.com",
343
- pathParams: [],
344
- queryParams: [],
345
- requestSchema: "CreateDashboardDto",
346
- responseSchema: "DashboardDto"
347
- },
348
- "DashboardsController_createElement": {
349
- method: "POST",
350
- path: "/api/v1/context/dashboards/{dashboardId}/elements",
351
- service: "modus-api",
352
- serverUrl: "https://api.getmodus.com",
353
- pathParams: ["dashboardId"],
354
- queryParams: [],
355
- requestSchema: "CreateDashboardElementDto",
356
- responseSchema: "DashboardElementResponseDto"
357
- },
358
- "DashboardsController_delete": {
359
- method: "DELETE",
360
- path: "/api/v1/context/dashboards/{dashboardId}",
361
- service: "modus-api",
362
- serverUrl: "https://api.getmodus.com",
363
- pathParams: ["dashboardId"],
364
- queryParams: [],
365
- requestSchema: null,
366
- responseSchema: null
367
- },
368
- "DashboardsController_get": {
369
- method: "GET",
370
- path: "/api/v1/context/dashboards/{dashboardId}",
371
- service: "modus-api",
372
- serverUrl: "https://api.getmodus.com",
373
- pathParams: ["dashboardId"],
374
- queryParams: ["view"],
375
- requestSchema: null,
376
- responseSchema: "DashboardDto"
377
- },
378
- "DashboardsController_getElement": {
379
- method: "GET",
380
- path: "/api/v1/context/dashboards/{dashboardId}/elements/{elementId}",
381
- service: "modus-api",
382
- serverUrl: "https://api.getmodus.com",
383
- pathParams: ["dashboardId", "elementId"],
384
- queryParams: [],
385
- requestSchema: null,
386
- responseSchema: "DashboardElementResponseDto"
387
- },
388
- "DashboardsController_getVersion": {
389
- method: "GET",
390
- path: "/api/v1/context/dashboards/{dashboardId}/versions/{versionId}",
391
- service: "modus-api",
392
- serverUrl: "https://api.getmodus.com",
393
- pathParams: ["dashboardId", "versionId"],
394
- queryParams: [],
395
- requestSchema: null,
396
- responseSchema: "DashboardDto"
397
- },
398
- "DashboardsController_list": {
399
- method: "GET",
400
- path: "/api/v1/context/dashboards",
401
- service: "modus-api",
402
- serverUrl: "https://api.getmodus.com",
403
- pathParams: [],
404
- queryParams: ["view"],
405
- requestSchema: null,
406
- responseSchema: "ListDashboardsResponseDto"
407
- },
408
- "DashboardsController_listDraftSnapshots": {
409
- method: "GET",
410
- path: "/api/v1/context/dashboards/{dashboardId}/draft-snapshots",
411
- service: "modus-api",
412
- serverUrl: "https://api.getmodus.com",
413
- pathParams: ["dashboardId"],
414
- queryParams: [],
415
- requestSchema: null,
416
- responseSchema: "ListDashboardDraftSnapshotsResponseDto"
417
- },
418
- "DashboardsController_listElements": {
419
- method: "GET",
420
- path: "/api/v1/context/dashboards/{dashboardId}/elements",
421
- service: "modus-api",
422
- serverUrl: "https://api.getmodus.com",
423
- pathParams: ["dashboardId"],
424
- queryParams: [],
425
- requestSchema: null,
426
- responseSchema: "DashboardElementsListResponseDto"
427
- },
428
- "DashboardsController_listVersions": {
429
- method: "GET",
430
- path: "/api/v1/context/dashboards/{dashboardId}/versions",
431
- service: "modus-api",
432
- serverUrl: "https://api.getmodus.com",
433
- pathParams: ["dashboardId"],
434
- queryParams: [],
435
- requestSchema: null,
436
- responseSchema: "ListDashboardVersionsResponseDto"
437
- },
438
- "DashboardsController_publish": {
439
- method: "POST",
440
- path: "/api/v1/context/dashboards/{dashboardId}/publish",
441
- service: "modus-api",
442
- serverUrl: "https://api.getmodus.com",
443
- pathParams: ["dashboardId"],
444
- queryParams: [],
445
- requestSchema: "PublishDashboardDto",
446
- responseSchema: "PublishDashboardResponseDto"
447
- },
448
- "DashboardsController_restore": {
449
- method: "POST",
450
- path: "/api/v1/context/dashboards/{dashboardId}/versions/{versionId}/restore",
451
- service: "modus-api",
452
- serverUrl: "https://api.getmodus.com",
453
- pathParams: ["dashboardId", "versionId"],
454
- queryParams: [],
455
- requestSchema: null,
456
- responseSchema: "DashboardDto"
457
- },
458
- "DashboardsController_transferOwnership": {
459
- method: "POST",
460
- path: "/api/v1/context/dashboards/{dashboardId}/transfer-ownership",
461
- service: "modus-api",
462
- serverUrl: "https://api.getmodus.com",
463
- pathParams: ["dashboardId"],
464
- queryParams: [],
465
- requestSchema: "TransferDashboardOwnershipDto",
466
- responseSchema: "DashboardDto"
467
- },
468
- "DashboardsController_updateAccess": {
469
- method: "PATCH",
470
- path: "/api/v1/context/dashboards/{dashboardId}/access",
471
- service: "modus-api",
472
- serverUrl: "https://api.getmodus.com",
473
- pathParams: ["dashboardId"],
474
- queryParams: [],
475
- requestSchema: "UpdateDashboardAccessDto",
476
- responseSchema: "DashboardDto"
477
- },
478
- "DashboardsController_updateDraft": {
479
- method: "PATCH",
480
- path: "/api/v1/context/dashboards/{dashboardId}/draft",
481
- service: "modus-api",
482
- serverUrl: "https://api.getmodus.com",
483
- pathParams: ["dashboardId"],
484
- queryParams: [],
485
- requestSchema: "UpdateDashboardDraftDto",
486
- responseSchema: "DashboardDto"
487
- },
488
- "DashboardsController_updateElement": {
489
- method: "PATCH",
490
- path: "/api/v1/context/dashboards/{dashboardId}/elements/{elementId}",
491
- service: "modus-api",
492
- serverUrl: "https://api.getmodus.com",
493
- pathParams: ["dashboardId", "elementId"],
494
- queryParams: [],
495
- requestSchema: "UpdateDashboardElementDto",
496
- responseSchema: "DashboardDto"
497
- },
498
- "DashboardsController_updateLayout": {
499
- method: "PATCH",
500
- path: "/api/v1/context/dashboards/{dashboardId}/layout",
501
- service: "modus-api",
502
- serverUrl: "https://api.getmodus.com",
503
- pathParams: ["dashboardId"],
504
- queryParams: [],
505
- requestSchema: "UpdateDashboardLayoutDto",
506
- responseSchema: "DashboardDto"
507
- },
508
- "EvaluationsController_getConfig": {
509
- method: "GET",
510
- path: "/api/v1/scopes/{id}/evaluations/config",
511
- service: "modus-api",
512
- serverUrl: "https://api.getmodus.com",
513
- pathParams: ["id"],
514
- queryParams: [],
515
- requestSchema: null,
516
- responseSchema: "EvaluationConfigDto"
517
- },
518
- "EvaluationsController_getRun": {
519
- method: "GET",
520
- path: "/api/v1/scopes/{id}/evaluations/runs/{runId}",
521
- service: "modus-api",
522
- serverUrl: "https://api.getmodus.com",
523
- pathParams: ["id", "runId"],
524
- queryParams: [],
525
- requestSchema: null,
526
- responseSchema: "EvaluationRunWithResultsDto"
527
- },
528
- "EvaluationsController_listRuns": {
529
- method: "GET",
530
- path: "/api/v1/scopes/{id}/evaluations/runs",
531
- service: "modus-api",
532
- serverUrl: "https://api.getmodus.com",
533
- pathParams: ["id"],
534
- queryParams: ["pageSize", "pageToken"],
535
- requestSchema: null,
536
- responseSchema: "ListEvaluationRunsResponseDto"
537
- },
538
- "EvaluationsController_triggerRun": {
539
- method: "POST",
540
- path: "/api/v1/scopes/{id}/evaluations/runs",
541
- service: "modus-api",
542
- serverUrl: "https://api.getmodus.com",
543
- pathParams: ["id"],
544
- queryParams: [],
545
- requestSchema: null,
546
- responseSchema: "TriggerEvaluationRunResponseDto"
547
- },
548
- "EvaluationsController_updateConfig": {
549
- method: "PUT",
550
- path: "/api/v1/scopes/{id}/evaluations/config",
551
- service: "modus-api",
552
- serverUrl: "https://api.getmodus.com",
553
- pathParams: ["id"],
554
- queryParams: [],
555
- requestSchema: "UpdateEvaluationConfigDto",
556
- responseSchema: "EvaluationConfigDto"
557
- },
558
- "IngestedDataController_upload": {
559
- method: "POST",
560
- path: "/api/v1/ingested-data",
561
- service: "modus-api",
562
- serverUrl: "https://api.getmodus.com",
563
- pathParams: [],
564
- queryParams: [],
565
- requestSchema: "CreateIngestedDataDto",
566
- responseSchema: "CreatedIngestedDataResponseDto"
567
- },
568
- "MemberGroupsController_list": {
569
- method: "GET",
570
- path: "/api/v1/users/member-groups",
571
- service: "modus-api",
572
- serverUrl: "https://api.getmodus.com",
573
- pathParams: [],
574
- queryParams: [],
575
- requestSchema: null,
576
- responseSchema: "ListMemberGroupsResponseDto"
577
- },
578
- "ModusChatController_chat": {
579
- method: "POST",
580
- path: "/api/v1/modus/chat",
581
- service: "modus-api",
582
- serverUrl: "https://api.getmodus.com",
583
- pathParams: [],
584
- queryParams: [],
585
- requestSchema: "ModusChatRequestDto",
586
- responseSchema: "ModusChatResponseDto"
587
- },
588
- "ModusChatController_chatContinue": {
589
- method: "POST",
590
- path: "/api/v1/modus/conversations/{threadId}/chat",
591
- service: "modus-api",
592
- serverUrl: "https://api.getmodus.com",
593
- pathParams: ["threadId"],
594
- queryParams: [],
595
- requestSchema: "ModusChatRequestDto",
596
- responseSchema: "ModusChatResponseDto"
597
- },
598
- "ModusContextController_compose": {
599
- method: "POST",
600
- path: "/api/v1/modus/context",
601
- service: "modus-api",
602
- serverUrl: "https://api.getmodus.com",
603
- pathParams: [],
604
- queryParams: [],
605
- requestSchema: "ModusContextRequestDto",
606
- responseSchema: "ModusContextResponseDto"
607
- },
608
- "ModusConversationsController_get": {
609
- method: "GET",
610
- path: "/api/v1/modus/conversations/{threadId}",
611
- service: "modus-api",
612
- serverUrl: "https://api.getmodus.com",
613
- pathParams: ["threadId"],
614
- queryParams: [],
615
- requestSchema: null,
616
- responseSchema: "ConversationDto"
617
- },
618
- "ModusConversationsController_list": {
619
- method: "GET",
620
- path: "/api/v1/modus/conversations",
621
- service: "modus-api",
622
- serverUrl: "https://api.getmodus.com",
623
- pathParams: [],
624
- queryParams: ["pageToken", "page", "pageSize", "userId", "toolName", "source", "sourceRef", "timeframe", "includeTools", "kind"],
625
- requestSchema: null,
626
- responseSchema: "ListConversationsResponseDto"
627
- },
628
- "ModusRunsController_create": {
629
- method: "POST",
630
- path: "/agent/v1/modus/runs",
631
- service: "agent-service",
632
- serverUrl: "https://agent.getmodus.com",
633
- pathParams: [],
634
- queryParams: [],
635
- requestSchema: "ModusRunDto",
636
- responseSchema: null
637
- },
638
- "OrgMembersController_list": {
639
- method: "GET",
640
- path: "/api/v1/users/org-members",
641
- service: "modus-api",
642
- serverUrl: "https://api.getmodus.com",
643
- pathParams: [],
644
- queryParams: [],
645
- requestSchema: null,
646
- responseSchema: "ListOrgMembersResponseDto"
647
- },
648
- "ResumeRunsController_create": {
649
- method: "POST",
650
- path: "/agent/v1/runs/{runId}/resume",
651
- service: "agent-service",
652
- serverUrl: "https://agent.getmodus.com",
653
- pathParams: ["runId"],
654
- queryParams: [],
655
- requestSchema: "ResumeRunDto",
656
- responseSchema: null
657
- },
658
- "RunLifecycleController_active": {
659
- method: "GET",
660
- path: "/agent/v1/runs/active",
661
- service: "agent-service",
662
- serverUrl: "https://agent.getmodus.com",
663
- pathParams: [],
664
- queryParams: ["pageToken", "pageSize"],
665
- requestSchema: null,
666
- responseSchema: "ActiveRunsResponseDto"
667
- },
668
- "RunLifecycleController_activeBySession": {
669
- method: "POST",
670
- path: "/agent/v1/runs/active-by-session",
671
- service: "agent-service",
672
- serverUrl: "https://agent.getmodus.com",
673
- pathParams: [],
674
- queryParams: [],
675
- requestSchema: "ActiveRunsBySessionDto",
676
- responseSchema: "ActiveRunsBySessionResponseDto"
677
- },
678
- "RunLifecycleController_cancel": {
679
- method: "POST",
680
- path: "/agent/v1/runs/{runId}/cancel",
681
- service: "agent-service",
682
- serverUrl: "https://agent.getmodus.com",
683
- pathParams: ["runId"],
684
- queryParams: [],
685
- requestSchema: "CancelRunDto",
686
- responseSchema: null
687
- },
688
- "RunLifecycleController_editQueued": {
689
- method: "POST",
690
- path: "/agent/v1/runs/{runId}/queue-edit",
691
- service: "agent-service",
692
- serverUrl: "https://agent.getmodus.com",
693
- pathParams: ["runId"],
694
- queryParams: [],
695
- requestSchema: "EditQueuedRunDto",
696
- responseSchema: null
697
- },
698
- "RunLifecycleController_events": {
699
- method: "GET",
700
- path: "/agent/v1/runs/{runId}/events",
701
- service: "agent-service",
702
- serverUrl: "https://agent.getmodus.com",
703
- pathParams: ["runId"],
704
- queryParams: [],
705
- requestSchema: null,
706
- responseSchema: null
707
- },
708
- "RunLifecycleController_interrupt": {
709
- method: "POST",
710
- path: "/agent/v1/runs/{runId}/interrupt",
711
- service: "agent-service",
712
- serverUrl: "https://agent.getmodus.com",
713
- pathParams: ["runId"],
714
- queryParams: [],
715
- requestSchema: "InterruptRunDto",
716
- responseSchema: null
717
- },
718
- "RunLifecycleController_stream": {
719
- method: "GET",
720
- path: "/agent/v1/runs/{runId}/stream",
721
- service: "agent-service",
722
- serverUrl: "https://agent.getmodus.com",
723
- pathParams: ["runId"],
724
- queryParams: [],
725
- requestSchema: null,
726
- responseSchema: null
727
- },
728
- "ScopeChatController_chat": {
729
- method: "POST",
730
- path: "/api/v1/scopes/{id}/chat",
731
- service: "modus-api",
732
- serverUrl: "https://api.getmodus.com",
733
- pathParams: ["id"],
734
- queryParams: [],
735
- requestSchema: "SkillChatRequestDto",
736
- responseSchema: "SkillChatResponseDto"
737
- },
738
- "ScopeChatController_chatContinue": {
739
- method: "POST",
740
- path: "/api/v1/scopes/{id}/conversations/{threadId}/chat",
741
- service: "modus-api",
742
- serverUrl: "https://api.getmodus.com",
743
- pathParams: ["id", "threadId"],
744
- queryParams: [],
745
- requestSchema: "SkillChatRequestDto",
746
- responseSchema: "SkillChatResponseDto"
747
- },
748
- "ScopeContextController_compose": {
749
- method: "POST",
750
- path: "/api/v1/scopes/{id}/context",
751
- service: "modus-api",
752
- serverUrl: "https://api.getmodus.com",
753
- pathParams: ["id"],
754
- queryParams: [],
755
- requestSchema: "ComposeSkillContextRequestDto",
756
- responseSchema: "ComposeSkillContextResponseDto"
757
- },
758
- "ScopeConversationsController_get": {
759
- method: "GET",
760
- path: "/api/v1/scopes/{id}/conversations/{threadId}",
761
- service: "modus-api",
762
- serverUrl: "https://api.getmodus.com",
763
- pathParams: ["id", "threadId"],
764
- queryParams: ["messageLimit", "beforeMessageIndex"],
765
- requestSchema: null,
766
- responseSchema: "ConversationDto"
767
- },
768
- "ScopeConversationsController_list": {
769
- method: "GET",
770
- path: "/api/v1/scopes/{id}/conversations",
771
- service: "modus-api",
772
- serverUrl: "https://api.getmodus.com",
773
- pathParams: ["id"],
774
- queryParams: ["pageToken", "page", "pageSize", "userId", "toolName", "source", "sourceRef", "timeframe", "includeTools"],
775
- requestSchema: null,
776
- responseSchema: "ListConversationsResponseDto"
777
- },
778
- "ScopeInterfacesController_add": {
779
- method: "POST",
780
- path: "/api/v1/scopes/{id}/interfaces",
781
- service: "modus-api",
782
- serverUrl: "https://api.getmodus.com",
783
- pathParams: ["id"],
784
- queryParams: [],
785
- requestSchema: "AddScopeInterfaceDto",
786
- responseSchema: "ScopeInterfaceDto"
787
- },
788
- "ScopeInterfacesController_delete": {
789
- method: "DELETE",
790
- path: "/api/v1/scopes/{id}/interfaces/{interfaceId}",
791
- service: "modus-api",
792
- serverUrl: "https://api.getmodus.com",
793
- pathParams: ["id", "interfaceId"],
794
- queryParams: [],
795
- requestSchema: null,
796
- responseSchema: null
797
- },
798
- "ScopeInterfacesController_list": {
799
- method: "GET",
800
- path: "/api/v1/scopes/{id}/interfaces",
801
- service: "modus-api",
802
- serverUrl: "https://api.getmodus.com",
803
- pathParams: ["id"],
804
- queryParams: [],
805
- requestSchema: null,
806
- responseSchema: "ListScopeInterfacesResponseDto"
807
- },
808
- "ScopeInterfacesController_update": {
809
- method: "PATCH",
810
- path: "/api/v1/scopes/{id}/interfaces/{interfaceId}",
811
- service: "modus-api",
812
- serverUrl: "https://api.getmodus.com",
813
- pathParams: ["id", "interfaceId"],
814
- queryParams: ["updateMask"],
815
- requestSchema: "UpdateScopeInterfaceDto",
816
- responseSchema: "ScopeInterfaceDto"
817
- },
818
- "ScopeMemoriesController_delete": {
819
- method: "DELETE",
820
- path: "/api/v1/scopes/{id}/memories/{memoryId}",
821
- service: "modus-api",
822
- serverUrl: "https://api.getmodus.com",
823
- pathParams: ["id", "memoryId"],
824
- queryParams: [],
825
- requestSchema: null,
826
- responseSchema: null
827
- },
828
- "ScopeMemoriesController_list": {
829
- method: "GET",
830
- path: "/api/v1/scopes/{id}/memories",
831
- service: "modus-api",
832
- serverUrl: "https://api.getmodus.com",
833
- pathParams: ["id"],
834
- queryParams: ["pageToken", "pageSize", "userId", "limit"],
835
- requestSchema: null,
836
- responseSchema: "ListMemoriesResponseDto"
837
- },
838
- "ScopeMemoriesController_search": {
839
- method: "POST",
840
- path: "/api/v1/scopes/{id}/memories/search",
841
- service: "modus-api",
842
- serverUrl: "https://api.getmodus.com",
843
- pathParams: ["id"],
844
- queryParams: [],
845
- requestSchema: "SearchMemoriesRequestDto",
846
- responseSchema: "ListMemoriesResponseDto"
847
- },
848
- "ScopeMemoriesController_update": {
849
- method: "PATCH",
850
- path: "/api/v1/scopes/{id}/memories/{memoryId}",
851
- service: "modus-api",
852
- serverUrl: "https://api.getmodus.com",
853
- pathParams: ["id", "memoryId"],
854
- queryParams: ["updateMask"],
855
- requestSchema: "UpdateMemoryRequestDto",
856
- responseSchema: null
857
- },
858
- "ScopeRunsController_create": {
859
- method: "POST",
860
- path: "/agent/v1/scopes/{id}/runs",
861
- service: "agent-service",
862
- serverUrl: "https://agent.getmodus.com",
863
- pathParams: ["id"],
864
- queryParams: [],
865
- requestSchema: "SkillRunDto",
866
- responseSchema: null
867
- },
868
- "ScopeSupervisionController_get": {
869
- method: "GET",
870
- path: "/api/v1/scopes/{id}/supervision",
871
- service: "modus-api",
872
- serverUrl: "https://api.getmodus.com",
873
- pathParams: ["id"],
874
- queryParams: ["view"],
875
- requestSchema: null,
876
- responseSchema: "SupervisionDto"
877
- },
878
- "ScopeSupervisionController_set": {
879
- method: "PUT",
880
- path: "/api/v1/scopes/{id}/supervision",
881
- service: "modus-api",
882
- serverUrl: "https://api.getmodus.com",
883
- pathParams: ["id"],
884
- queryParams: [],
885
- requestSchema: "SetSupervisionRequestDto",
886
- responseSchema: "SupervisionDto"
887
- },
888
- "ScopeSupervisionController_setActive": {
889
- method: "PUT",
890
- path: "/api/v1/scopes/{id}/supervision/active",
891
- service: "modus-api",
892
- serverUrl: "https://api.getmodus.com",
893
- pathParams: ["id"],
894
- queryParams: [],
895
- requestSchema: "SetSupervisionRequestDto",
896
- responseSchema: "SupervisionDto"
897
- },
898
- "ScopesController_acceptOwnershipTransfer": {
899
- method: "POST",
900
- path: "/api/v1/scopes/{id}/transfer-ownership/accept",
901
- service: "modus-api",
902
- serverUrl: "https://api.getmodus.com",
903
- pathParams: ["id"],
904
- queryParams: [],
905
- requestSchema: null,
906
- responseSchema: "ScopeDto"
907
- },
908
- "ScopesController_cancelOwnershipTransfer": {
909
- method: "DELETE",
910
- path: "/api/v1/scopes/{id}/transfer-ownership",
911
- service: "modus-api",
912
- serverUrl: "https://api.getmodus.com",
913
- pathParams: ["id"],
914
- queryParams: [],
915
- requestSchema: null,
916
- responseSchema: "ScopeDto"
917
- },
918
- "ScopesController_create": {
919
- method: "POST",
920
- path: "/api/v1/scopes",
921
- service: "modus-api",
922
- serverUrl: "https://api.getmodus.com",
923
- pathParams: [],
924
- queryParams: [],
925
- requestSchema: "CreateSkillDto",
926
- responseSchema: "ScopeDto"
927
- },
928
- "ScopesController_delete": {
929
- method: "DELETE",
930
- path: "/api/v1/scopes/{id}",
931
- service: "modus-api",
932
- serverUrl: "https://api.getmodus.com",
933
- pathParams: ["id"],
934
- queryParams: [],
935
- requestSchema: null,
936
- responseSchema: null
937
- },
938
- "ScopesController_deploy": {
939
- method: "POST",
940
- path: "/api/v1/scopes/{id}/deploy",
941
- service: "modus-api",
942
- serverUrl: "https://api.getmodus.com",
943
- pathParams: ["id"],
944
- queryParams: [],
945
- requestSchema: "DeploySkillDto",
946
- responseSchema: "DeployResponseDto"
947
- },
948
- "ScopesController_get": {
949
- method: "GET",
950
- path: "/api/v1/scopes/{id}",
951
- service: "modus-api",
952
- serverUrl: "https://api.getmodus.com",
953
- pathParams: ["id"],
954
- queryParams: ["view"],
955
- requestSchema: null,
956
- responseSchema: "ScopeDto"
957
- },
958
- "ScopesController_getVariation": {
959
- method: "GET",
960
- path: "/api/v1/scopes/{id}/variations/{variationUid}",
961
- service: "modus-api",
962
- serverUrl: "https://api.getmodus.com",
963
- pathParams: ["id", "variationUid"],
964
- queryParams: [],
965
- requestSchema: null,
966
- responseSchema: "ScopeDto"
967
- },
968
- "ScopesController_list": {
969
- method: "GET",
970
- path: "/api/v1/scopes",
971
- service: "modus-api",
972
- serverUrl: "https://api.getmodus.com",
973
- pathParams: [],
974
- queryParams: ["pageToken", "pageSize", "view", "search", "managerId", "includeVariation"],
975
- requestSchema: null,
976
- responseSchema: "ListSkillsResponseDto"
977
- },
978
- "ScopesController_patchMcpConfig": {
979
- method: "PATCH",
980
- path: "/api/v1/scopes/{id}/mcp-config",
981
- service: "modus-api",
982
- serverUrl: "https://api.getmodus.com",
983
- pathParams: ["id"],
984
- queryParams: [],
985
- requestSchema: "PatchSkillMcpConfigDto",
986
- responseSchema: "PatchSkillMcpConfigResponseDto"
987
- },
988
- "ScopesController_requestOwnershipTransfer": {
989
- method: "POST",
990
- path: "/api/v1/scopes/{id}/transfer-ownership",
991
- service: "modus-api",
992
- serverUrl: "https://api.getmodus.com",
993
- pathParams: ["id"],
994
- queryParams: [],
995
- requestSchema: "TransferOwnershipDto",
996
- responseSchema: "ScopeDto"
997
- },
998
- "ScopesController_restore": {
999
- method: "POST",
1000
- path: "/api/v1/scopes/{id}/restore",
1001
- service: "modus-api",
1002
- serverUrl: "https://api.getmodus.com",
1003
- pathParams: ["id"],
1004
- queryParams: [],
1005
- requestSchema: null,
1006
- responseSchema: "ScopeDto"
1007
- },
1008
- "ScopesController_update": {
1009
- method: "PATCH",
1010
- path: "/api/v1/scopes/{id}",
1011
- service: "modus-api",
1012
- serverUrl: "https://api.getmodus.com",
1013
- pathParams: ["id"],
1014
- queryParams: ["updateMask"],
1015
- requestSchema: "UpdateSkillDto",
1016
- responseSchema: "ScopeDto"
1017
- },
1018
- "SuggestionsController_listApproved": {
1019
- method: "GET",
1020
- path: "/api/v1/suggestions/questions",
1021
- service: "modus-api",
1022
- serverUrl: "https://api.getmodus.com",
1023
- pathParams: [],
1024
- queryParams: ["pageToken", "pageSize", "scopeId", "scopeIds"],
1025
- requestSchema: null,
1026
- responseSchema: "ListSuggestionQuestionsResponseDto"
1027
- },
1028
- "SuggestionsController_recordEvent": {
1029
- method: "POST",
1030
- path: "/api/v1/suggestions/questions/{id}/events",
1031
- service: "modus-api",
1032
- serverUrl: "https://api.getmodus.com",
1033
- pathParams: ["id"],
1034
- queryParams: [],
1035
- requestSchema: "RecordSuggestionEventDto",
1036
- responseSchema: null
1037
- },
1038
- "ToolsController_list": {
1039
- method: "GET",
1040
- path: "/api/v1/tools",
1041
- service: "modus-api",
1042
- serverUrl: "https://api.getmodus.com",
1043
- pathParams: [],
1044
- queryParams: ["pageToken", "pageSize"],
1045
- requestSchema: null,
1046
- responseSchema: "ListToolsResponseDto"
1047
- },
1048
- "UsageController_list": {
1049
- method: "GET",
1050
- path: "/api/v1/usage",
1051
- service: "modus-api",
1052
- serverUrl: "https://api.getmodus.com",
1053
- pathParams: [],
1054
- queryParams: ["since", "until", "rollup", "model", "group_by", "skill_id", "agent_id", "user_id", "interface", "user_email"],
1055
- requestSchema: null,
1056
- responseSchema: "ListUsageResponseDto"
1057
- },
1058
- "UsageController_listUsers": {
1059
- method: "GET",
1060
- path: "/api/v1/usage/users",
1061
- service: "modus-api",
1062
- serverUrl: "https://api.getmodus.com",
1063
- pathParams: [],
1064
- queryParams: ["since", "until"],
1065
- requestSchema: null,
1066
- responseSchema: "ListUsageUsersResponseDto"
1067
- },
1068
- "WorkflowActionsController_cancel": {
1069
- method: "POST",
1070
- path: "/agent/v1/workflow-actions/{runId}/cancel",
1071
- service: "agent-service",
1072
- serverUrl: "https://agent.getmodus.com",
1073
- pathParams: ["runId"],
1074
- queryParams: [],
1075
- requestSchema: "CancelRunDto",
1076
- responseSchema: null
1077
- },
1078
- "WorkflowActionsController_execute": {
1079
- method: "POST",
1080
- path: "/agent/v1/workflow-actions",
1081
- service: "agent-service",
1082
- serverUrl: "https://agent.getmodus.com",
1083
- pathParams: [],
1084
- queryParams: [],
1085
- requestSchema: "WorkflowActionDto",
1086
- responseSchema: null
1087
- },
1088
- "WorkflowInterfacesController_add": {
1089
- method: "POST",
1090
- path: "/api/v1/workflows/{id}/interfaces",
1091
- service: "modus-api",
1092
- serverUrl: "https://api.getmodus.com",
1093
- pathParams: ["id"],
1094
- queryParams: [],
1095
- requestSchema: "AddAgentInterfaceDto",
1096
- responseSchema: "AgentInterfaceDto"
1097
- },
1098
- "WorkflowInterfacesController_delete": {
1099
- method: "DELETE",
1100
- path: "/api/v1/workflows/{id}/interfaces/{interfaceId}",
1101
- service: "modus-api",
1102
- serverUrl: "https://api.getmodus.com",
1103
- pathParams: ["id", "interfaceId"],
1104
- queryParams: [],
1105
- requestSchema: null,
1106
- responseSchema: null
1107
- },
1108
- "WorkflowInterfacesController_deleteAll": {
1109
- method: "DELETE",
1110
- path: "/api/v1/workflows/{id}/interfaces",
1111
- service: "modus-api",
1112
- serverUrl: "https://api.getmodus.com",
1113
- pathParams: ["id"],
1114
- queryParams: [],
1115
- requestSchema: null,
1116
- responseSchema: null
1117
- },
1118
- "WorkflowInterfacesController_list": {
1119
- method: "GET",
1120
- path: "/api/v1/workflows/{id}/interfaces",
1121
- service: "modus-api",
1122
- serverUrl: "https://api.getmodus.com",
1123
- pathParams: ["id"],
1124
- queryParams: [],
1125
- requestSchema: null,
1126
- responseSchema: "ListAgentInterfacesResponseDto"
1127
- },
1128
- "WorkflowInterfacesController_update": {
1129
- method: "PATCH",
1130
- path: "/api/v1/workflows/{id}/interfaces/{interfaceId}",
1131
- service: "modus-api",
1132
- serverUrl: "https://api.getmodus.com",
1133
- pathParams: ["id", "interfaceId"],
1134
- queryParams: ["updateMask"],
1135
- requestSchema: "UpdateAgentInterfaceDto",
1136
- responseSchema: "AgentInterfaceDto"
1137
- },
1138
- "WorkflowRunsController_create": {
1139
- method: "POST",
1140
- path: "/agent/v1/workflows/{id}/runs",
1141
- service: "agent-service",
1142
- serverUrl: "https://agent.getmodus.com",
1143
- pathParams: ["id"],
1144
- queryParams: [],
1145
- requestSchema: "AgentRunDto",
1146
- responseSchema: null
1147
- },
1148
- "WorkflowRunsController_get": {
1149
- method: "GET",
1150
- path: "/api/v1/workflows/{id}/runs/{runId}",
1151
- service: "modus-api",
1152
- serverUrl: "https://api.getmodus.com",
1153
- pathParams: ["id", "runId"],
1154
- queryParams: ["temporalRunId"],
1155
- requestSchema: null,
1156
- responseSchema: "GetAutomationRunResponseDto"
1157
- },
1158
- "WorkflowRunsController_list": {
1159
- method: "GET",
1160
- path: "/api/v1/workflows/{id}/runs",
1161
- service: "modus-api",
1162
- serverUrl: "https://api.getmodus.com",
1163
- pathParams: ["id"],
1164
- queryParams: ["status", "timeframe", "approvalScope", "search", "pageSize", "pageToken"],
1165
- requestSchema: null,
1166
- responseSchema: "ListAutomationRunsResponseDto"
1167
- },
1168
- "WorkflowsController_acceptOwnershipTransfer": {
1169
- method: "POST",
1170
- path: "/api/v1/workflows/{id}/transfer-ownership/accept",
1171
- service: "modus-api",
1172
- serverUrl: "https://api.getmodus.com",
1173
- pathParams: ["id"],
1174
- queryParams: [],
1175
- requestSchema: null,
1176
- responseSchema: "WorkflowDto"
1177
- },
1178
- "WorkflowsController_cancelOwnershipTransfer": {
1179
- method: "DELETE",
1180
- path: "/api/v1/workflows/{id}/transfer-ownership",
1181
- service: "modus-api",
1182
- serverUrl: "https://api.getmodus.com",
1183
- pathParams: ["id"],
1184
- queryParams: [],
1185
- requestSchema: null,
1186
- responseSchema: "WorkflowDto"
1187
- },
1188
- "WorkflowsController_create": {
1189
- method: "POST",
1190
- path: "/api/v1/workflows",
1191
- service: "modus-api",
1192
- serverUrl: "https://api.getmodus.com",
1193
- pathParams: [],
1194
- queryParams: [],
1195
- requestSchema: "CreateAgentDto",
1196
- responseSchema: "WorkflowDto"
1197
- },
1198
- "WorkflowsController_delete": {
1199
- method: "DELETE",
1200
- path: "/api/v1/workflows/{id}",
1201
- service: "modus-api",
1202
- serverUrl: "https://api.getmodus.com",
1203
- pathParams: ["id"],
1204
- queryParams: [],
1205
- requestSchema: null,
1206
- responseSchema: null
1207
- },
1208
- "WorkflowsController_deploy": {
1209
- method: "POST",
1210
- path: "/api/v1/workflows/{id}/deploy",
1211
- service: "modus-api",
1212
- serverUrl: "https://api.getmodus.com",
1213
- pathParams: ["id"],
1214
- queryParams: [],
1215
- requestSchema: "DeployAgentDto",
1216
- responseSchema: "AgentDeployResponseDto"
1217
- },
1218
- "WorkflowsController_get": {
1219
- method: "GET",
1220
- path: "/api/v1/workflows/{id}",
1221
- service: "modus-api",
1222
- serverUrl: "https://api.getmodus.com",
1223
- pathParams: ["id"],
1224
- queryParams: ["view"],
1225
- requestSchema: null,
1226
- responseSchema: "WorkflowDto"
1227
- },
1228
- "WorkflowsController_list": {
1229
- method: "GET",
1230
- path: "/api/v1/workflows",
1231
- service: "modus-api",
1232
- serverUrl: "https://api.getmodus.com",
1233
- pathParams: [],
1234
- queryParams: ["pageToken", "pageSize", "view", "type", "search", "includeVariation"],
1235
- requestSchema: null,
1236
- responseSchema: "ListAgentsResponseDto"
1237
- },
1238
- "WorkflowsController_requestOwnershipTransfer": {
1239
- method: "POST",
1240
- path: "/api/v1/workflows/{id}/transfer-ownership",
1241
- service: "modus-api",
1242
- serverUrl: "https://api.getmodus.com",
1243
- pathParams: ["id"],
1244
- queryParams: [],
1245
- requestSchema: "TransferOwnershipDto",
1246
- responseSchema: "WorkflowDto"
1247
- },
1248
- "WorkflowsController_restore": {
1249
- method: "POST",
1250
- path: "/api/v1/workflows/{id}/restore",
1251
- service: "modus-api",
1252
- serverUrl: "https://api.getmodus.com",
1253
- pathParams: ["id"],
1254
- queryParams: [],
1255
- requestSchema: null,
1256
- responseSchema: "WorkflowDto"
1257
- },
1258
- "WorkflowsController_toggle": {
1259
- method: "POST",
1260
- path: "/api/v1/workflows/{id}/toggle",
1261
- service: "modus-api",
1262
- serverUrl: "https://api.getmodus.com",
1263
- pathParams: ["id"],
1264
- queryParams: [],
1265
- requestSchema: "ToggleAgentDto",
1266
- responseSchema: "WorkflowDto"
1267
- },
1268
- "WorkflowsController_update": {
1269
- method: "PATCH",
1270
- path: "/api/v1/workflows/{id}",
1271
- service: "modus-api",
1272
- serverUrl: "https://api.getmodus.com",
1273
- pathParams: ["id"],
1274
- queryParams: ["updateMask"],
1275
- requestSchema: "UpdateAgentDto",
1276
- responseSchema: "WorkflowDto"
1277
- }
1278
- };
1279
5
 
1280
- // src/_exceptions.ts
1281
- var ModusError = class extends Error {
1282
- constructor(message, options = {}) {
1283
- super(message);
1284
- this.name = "ModusError";
1285
- this.message = message;
1286
- this.statusCode = options.statusCode;
1287
- this.requestId = options.requestId;
1288
- this.responseHeaders = options.responseHeaders;
1289
- this.body = options.body;
1290
- this.code = options.code;
1291
- }
1292
- };
1293
- var APIConnectionError = class extends ModusError {
1294
- constructor(message) {
1295
- super(message);
1296
- this.name = "APIConnectionError";
1297
- }
1298
- };
1299
- var AuthenticationError = class extends ModusError {
1300
- constructor(message, options = {}) {
1301
- super(message, { ...options, statusCode: 401 });
1302
- this.name = "AuthenticationError";
1303
- }
1304
- };
1305
- var PermissionDeniedError = class extends ModusError {
1306
- constructor(message, options = {}) {
1307
- super(message, { ...options, statusCode: 403 });
1308
- this.name = "PermissionDeniedError";
1309
- }
1310
- };
1311
- var NotFoundError = class extends ModusError {
1312
- constructor(message, options = {}) {
1313
- super(message, { ...options, statusCode: 404 });
1314
- this.name = "NotFoundError";
1315
- }
1316
- };
1317
- var ConflictError = class extends ModusError {
1318
- constructor(message, options = {}) {
1319
- super(message, { ...options, statusCode: 409 });
1320
- this.name = "ConflictError";
1321
- }
1322
- };
1323
- var UnprocessableError = class extends ModusError {
1324
- constructor(message, options = {}) {
1325
- super(message, { ...options, statusCode: 422 });
1326
- this.name = "UnprocessableError";
1327
- this.errors = options.errors;
1328
- }
1329
- };
1330
- var RateLimitError = class extends ModusError {
1331
- constructor(message, options = {}) {
1332
- super(message, { ...options, statusCode: 429 });
1333
- this.name = "RateLimitError";
1334
- this.retryAfter = options.retryAfter;
1335
- }
1336
- };
1337
- var InternalServerError = class extends ModusError {
1338
- constructor(message, statusCode, options = {}) {
1339
- super(message, { ...options, statusCode });
1340
- this.name = "InternalServerError";
1341
- }
1342
- };
1343
- var RunCancelledError = class extends ModusError {
1344
- constructor(message = "Run was cancelled.") {
1345
- super(message);
1346
- this.name = "RunCancelledError";
1347
- }
1348
- };
1349
- var StreamTimeoutError = class extends ModusError {
1350
- constructor(message = "Stream timed out.") {
1351
- super(message);
1352
- this.name = "StreamTimeoutError";
1353
- }
1354
- };
1355
- var ValidationError = class extends ModusError {
1356
- constructor(message) {
1357
- super(message);
1358
- this.name = "ValidationError";
1359
- }
1360
- };
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+ var _chunk3MHHVC6Ccjs = require('./chunk-3MHHVC6C.cjs');
1361
35
 
1362
36
  // src/_agent_run_request.ts
1363
- var import_node_crypto = require("crypto");
37
+ var _crypto = require('crypto');
1364
38
  function resolveAgentRunSessionId(sessionId) {
1365
39
  if (typeof sessionId === "string" && sessionId.trim()) return sessionId.trim();
1366
- return (0, import_node_crypto.randomUUID)();
40
+ return _crypto.randomUUID.call(void 0, );
1367
41
  }
1368
42
 
1369
43
  // src/_streaming.ts
1370
- var SILENTLY_IGNORED = /* @__PURE__ */ new Set([
1371
- "heartbeat",
1372
- "ws_chunk",
1373
- "unknown",
1374
- "tool_start",
1375
- "tool_end",
1376
- "tool_chunk",
1377
- "agent_thinking",
1378
- "warning",
1379
- "selected_final_content"
1380
- ]);
1381
44
  function parseLine(line) {
1382
45
  if (!line.startsWith("data:")) return void 0;
1383
46
  const raw = line.slice(5).trimStart();
@@ -1387,7 +50,7 @@ function parseLine(line) {
1387
50
  if (data && typeof data === "object" && !Array.isArray(data)) {
1388
51
  return data;
1389
52
  }
1390
- } catch {
53
+ } catch (e) {
1391
54
  return void 0;
1392
55
  }
1393
56
  return void 0;
@@ -1395,30 +58,61 @@ function parseLine(line) {
1395
58
  function isAsyncIterable(value) {
1396
59
  return Symbol.asyncIterator in Object(value);
1397
60
  }
1398
- function* parseData(data) {
61
+ var NODE_TERMINAL_TYPES = /* @__PURE__ */ new Set(["done", "error", "cancelled", "stream_timeout"]);
62
+ function* parseData(data, id) {
1399
63
  const eventType = typeof data.type === "string" ? data.type : "unknown";
1400
- if (eventType === "token") {
64
+ const withId = id === void 0 ? {} : { id };
65
+ if (eventType === "node_content") {
66
+ const inner = data.event;
67
+ if (inner && typeof inner === "object" && !Array.isArray(inner)) {
68
+ const frame = inner;
69
+ if (!NODE_TERMINAL_TYPES.has(frame.type)) yield* parseData(frame, id);
70
+ }
71
+ } else if (eventType === "token") {
1401
72
  const event = {
1402
73
  type: "token",
1403
- content: typeof data.content === "string" ? data.content : ""
74
+ content: typeof data.content === "string" ? data.content : "",
75
+ ...typeof data.subAgent === "string" ? { subAgent: data.subAgent } : {},
76
+ ...withId
1404
77
  };
1405
78
  yield event;
1406
- } else if (eventType === "done") {
79
+ } else if (eventType === "done" || eventType === "workflow_done") {
80
+ const content = eventType === "done" ? data.content : data.finalOutput;
1407
81
  const event = {
1408
82
  type: "done",
1409
83
  runId: typeof data.runId === "string" ? data.runId : "",
1410
- threadId: typeof data.threadId === "string" ? data.threadId : ""
84
+ threadId: typeof data.threadId === "string" ? data.threadId : "",
85
+ ...typeof content === "string" ? { content } : {},
86
+ ...withId
1411
87
  };
1412
88
  yield event;
1413
- } else if (eventType === "error") {
1414
- const msg = data.error ?? data.message ?? data.content ?? "Unknown run error";
1415
- const event = { type: "error", message: String(msg) };
89
+ } else if (eventType === "approval_required") {
90
+ const event = { type: "approval_required" };
91
+ for (const key of ["toolId", "toolName", "title", "description", "nodeId", "prompt"]) {
92
+ const value = data[key];
93
+ if (typeof value === "string") event[key] = value;
94
+ }
95
+ const { args, options } = data;
96
+ if (args && typeof args === "object" && !Array.isArray(args)) event.args = args;
97
+ if (Array.isArray(options)) event.options = options;
98
+ yield { ...event, ...withId };
99
+ } else if (eventType === "workflow_cancelled") {
100
+ const event = { type: "cancelled", ...withId };
101
+ yield event;
102
+ } else if (eventType === "error" || eventType === "workflow_error") {
103
+ const msg = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(data.error, () => ( data.message)), () => ( data.content)), () => ( "Unknown run error"));
104
+ const event = {
105
+ type: "error",
106
+ message: String(msg),
107
+ ...typeof data.requestId === "string" ? { requestId: data.requestId } : {},
108
+ ...withId
109
+ };
1416
110
  yield event;
1417
111
  } else if (eventType === "cancelled") {
1418
- const event = { type: "cancelled" };
112
+ const event = { type: "cancelled", ...withId };
1419
113
  yield event;
1420
114
  } else if (eventType === "stream_timeout") {
1421
- const event = { type: "stream_timeout" };
115
+ const event = { type: "stream_timeout", ...withId };
1422
116
  yield event;
1423
117
  } else if (eventType === "assistant_content_reset") {
1424
118
  if (typeof data.content !== "string") return;
@@ -1427,416 +121,231 @@ function* parseData(data) {
1427
121
  content: data.content,
1428
122
  ...typeof data.visibleContent === "string" ? { visibleContent: data.visibleContent } : {},
1429
123
  attempt: typeof data.attempt === "number" ? data.attempt : 1,
1430
- reason: "provider_stream_failed"
124
+ reason: "provider_stream_failed",
125
+ ...data.subAgent && typeof data.subAgent === "object" && !Array.isArray(data.subAgent) ? { subAgent: data.subAgent } : {},
126
+ ...withId
1431
127
  };
1432
128
  yield event;
1433
- } else if (!SILENTLY_IGNORED.has(eventType)) {
1434
- return;
1435
129
  }
1436
130
  }
1437
- function* parseSyncSseLines(lines) {
1438
- for (const line of lines) {
131
+ function sseLineParser() {
132
+ let lastId;
133
+ return function* (line) {
134
+ if (line.startsWith("id:")) {
135
+ lastId = line.slice(3).trim() || void 0;
136
+ return;
137
+ }
1439
138
  const data = parseLine(line);
1440
- if (data !== void 0) yield* parseData(data);
1441
- }
139
+ if (data !== void 0) yield* parseData(data, lastId);
140
+ };
141
+ }
142
+ function* parseSyncSseLines(lines) {
143
+ const parse = sseLineParser();
144
+ for (const line of lines) yield* parse(line);
1442
145
  }
1443
146
  async function* parseAsyncSseLines(lines) {
1444
- for await (const line of lines) {
1445
- const data = parseLine(line);
1446
- if (data !== void 0) yield* parseData(data);
1447
- }
147
+ const parse = sseLineParser();
148
+ for await (const line of lines) yield* parse(line);
1448
149
  }
1449
150
  function parseSseStream(lines) {
1450
151
  return isAsyncIterable(lines) ? parseAsyncSseLines(lines) : parseSyncSseLines(lines);
1451
152
  }
1452
153
 
1453
- // src/_generated/write-body-keys.ts
1454
- var WRITE_BODY_ALLOWED_KEYS = {
1455
- ContextCreatorsController_createLink: ["url", "title", "isCrawl", "pageLimit"],
1456
- ContextCreatorsController_createNote: ["title", "content"],
1457
- ContextCreatorsController_createSavedQuery: ["name", "connectionId", "query", "description", "path"],
1458
- ContextFilesController_finalize: ["fileName", "folderPath"],
1459
- ContextFilesController_finalizeMany: ["uploads"],
1460
- ContextFilesController_uploadFromUrl: ["url", "fileName", "folderPath"],
1461
- ContextFilesController_uploadFromUrls: ["urls"],
1462
- ContextFilesController_uploadUrl: ["fileName", "contentType", "fileSize"],
1463
- ContextFilesController_uploadUrls: ["files"],
1464
- ContextItemsController_lookup: ["contextType", "dataPath", "contentProjection"],
1465
- ContextItemsController_move: ["destinationFolderUid"],
1466
- ContextItemsController_update: ["contextType", "content", "description", "userFeedback", "topics"],
1467
- CustomContextItemsController_batchCreate: ["items"],
1468
- CustomContextItemsController_create: ["kind", "sourceId", "sourceName", "collectionId", "collectionName", "externalId", "fieldName", "name", "entityType", "description", "content", "url", "attributes", "dataType", "value", "samples", "raw", "topics", "idempotencyKey", "access"],
1469
- CustomContextItemsController_createRelations: ["relations"],
1470
- CustomContextItemsController_update: ["name", "entityType", "description", "content", "url", "attributes", "dataType", "value", "samples", "raw", "topics"],
1471
- DashboardsController_create: ["title", "description", "definition", "access"],
1472
- DashboardsController_createElement: ["expectedRevision", "kind", "title", "layout"],
1473
- DashboardsController_publish: ["expectedRevision"],
1474
- DashboardsController_transferOwnership: ["newOwnerUserId"],
1475
- DashboardsController_updateAccess: ["visibility", "groupPermissions", "sharedWith"],
1476
- DashboardsController_updateDraft: ["expectedRevision", "title", "description", "definition"],
1477
- DashboardsController_updateElement: ["expectedRevision", "patch"],
1478
- DashboardsController_updateLayout: ["expectedRevision", "elements"],
1479
- EvaluationsController_updateConfig: ["enabled", "cadence", "judgeModel", "judgeGuidance", "notifications"],
1480
- IngestedDataController_upload: ["integration_type", "request", "response"],
1481
- ModusChatController_chat: ["message", "model"],
1482
- ModusContextController_compose: ["message", "limit"],
1483
- ModusRunsController_create: ["message", "sessionId", "organizationId", "version", "fileThreadId", "config", "attachments", "userContext", "source", "runId", "subordinateSkillIds"],
1484
- ResumeRunsController_create: ["message", "sessionId", "organizationId", "version", "fileThreadId", "config", "attachments", "userContext", "source", "runId", "decision"],
1485
- RunLifecycleController_activeBySession: ["sessionIds"],
1486
- RunLifecycleController_cancel: [],
1487
- RunLifecycleController_editQueued: [],
1488
- RunLifecycleController_interrupt: [],
1489
- ScopeChatController_chat: ["message", "model"],
1490
- ScopeContextController_compose: ["message", "limit"],
1491
- ScopeInterfacesController_add: ["type", "name", "config"],
1492
- ScopeInterfacesController_update: ["name", "config"],
1493
- ScopeMemoriesController_search: ["query", "userId", "limit"],
1494
- ScopeMemoriesController_update: ["memory", "metadata"],
1495
- ScopeRunsController_create: ["message", "sessionId", "organizationId", "version", "fileThreadId", "config", "attachments", "userContext", "source", "runId", "subordinateSkillIds"],
1496
- ScopesController_acceptOwnershipTransfer: [],
1497
- ScopesController_create: ["name", "description", "expectedOutput", "instructions", "toolset", "model", "connectionSet", "contextSelections", "includeOwnLearnings", "interfaces", "accessConfig"],
1498
- ScopesController_deploy: [],
1499
- ScopesController_patchMcpConfig: ["config"],
1500
- ScopesController_requestOwnershipTransfer: ["newOwnerUserId"],
1501
- ScopesController_restore: [],
1502
- ScopesController_update: ["name", "description", "expectedOutput", "instructions", "toolset", "model", "connectionSet", "contextSelections", "interfaces", "accessConfig", "managerId", "evaluations", "supervisionSubordinateDescriptions"],
1503
- ScopeSupervisionController_set: ["subordinateAgentIds"],
1504
- ScopeSupervisionController_setActive: ["subordinateAgentIds"],
1505
- SuggestionsController_recordEvent: ["eventType", "source", "skillId", "threadId", "metadata"],
1506
- WorkflowActionsController_cancel: [],
1507
- WorkflowActionsController_execute: ["organizationId", "sessionId", "fileThreadId", "workflowAction", "previousOutputs", "userTimezone", "runId", "automationId", "source"],
1508
- WorkflowInterfacesController_add: ["type", "name", "config"],
1509
- WorkflowInterfacesController_update: ["name", "config"],
1510
- WorkflowRunsController_create: ["message", "sessionId", "organizationId", "version", "fileThreadId", "config", "attachments", "userContext", "source", "runId"],
1511
- WorkflowsController_acceptOwnershipTransfer: [],
1512
- WorkflowsController_create: ["name", "type", "description", "trigger", "agentSelection", "workflowStructure", "accessConfig"],
1513
- WorkflowsController_deploy: [],
1514
- WorkflowsController_requestOwnershipTransfer: ["newOwnerUserId"],
1515
- WorkflowsController_restore: [],
1516
- WorkflowsController_toggle: ["active"],
1517
- WorkflowsController_update: ["name", "type", "description", "trigger", "agentSelection", "workflowStructure", "accessConfig"]
1518
- };
1519
-
1520
- // src/_validation.ts
1521
- var DEFAULT_MAX_PAGE_SIZE = 200;
1522
- function validatePageSize(pageSize, maxPageSize) {
1523
- if (!Number.isInteger(pageSize) || pageSize < 1) {
1524
- throw new Error(`page_size must be a positive int, got ${pageSize}`);
1525
- }
1526
- if (maxPageSize !== void 0 && pageSize > maxPageSize) {
1527
- throw new Error(`page_size must be <= ${maxPageSize}, got ${pageSize}`);
1528
- }
1529
- }
1530
- function validateId(resourceId, name = "id") {
1531
- if (typeof resourceId === "string" && !resourceId.trim()) {
1532
- throw new Error(`${name} must be a non-empty string or int`);
1533
- }
1534
- }
1535
- var ALLOWED_CHAT_MODELS = /* @__PURE__ */ new Set([
1536
- "claude-sonnet-5",
1537
- "claude-sonnet-5.5",
1538
- "claude-sonnet-4.6",
1539
- "claude-opus-4.8",
1540
- "claude-opus-5.5",
1541
- "gpt-5.2",
1542
- "gpt-5.5",
1543
- "gpt-5-mini",
1544
- "gpt-5.6-luna",
1545
- "gpt-6-luna",
1546
- "gpt-oss-120b",
1547
- "gpt-oss-20b",
1548
- "qwen3-235b-a22b-2507",
1549
- "qwen3-coder",
1550
- "qwen3-32b",
1551
- "deepseek-chat-v3.1",
1552
- "deepseek-v4-pro",
1553
- "deepseek-v4-flash-latest",
1554
- "minimax-m2.7",
1555
- "llama-4-maverick",
1556
- "llama-4-scout",
1557
- "llama-3.3-70b-instruct",
1558
- "gemini-3.1-pro-preview",
1559
- "gemini-3-flash-preview",
1560
- "grok-4.3-fast",
1561
- "grok-4.3",
1562
- "grok-4.7",
1563
- "kimi-k3"
1564
- ]);
1565
- function validateChatModel(model) {
1566
- if (!ALLOWED_CHAT_MODELS.has(model)) {
1567
- const supported = [...ALLOWED_CHAT_MODELS].sort().join(", ");
1568
- throw new Error(`Unsupported model ${JSON.stringify(model)}. Choose one of: ${supported}.`);
1569
- }
1570
- }
1571
- function assertWriteBodyKeys(operationId, body) {
1572
- const allowed = WRITE_BODY_ALLOWED_KEYS[operationId];
1573
- if (allowed === void 0) return;
1574
- if (body === void 0 || body === null) return;
1575
- if (typeof body !== "object" || Array.isArray(body)) {
1576
- throw new ValidationError(`Request body must be a plain object for ${operationId}`);
1577
- }
1578
- const allowedSet = new Set(allowed);
1579
- const extra = Object.keys(body).filter((k) => !allowedSet.has(k));
1580
- if (extra.length > 0) {
1581
- throw new ValidationError(
1582
- `${operationId}: disallowed request body field(s): ${extra.sort().join(", ")}`
1583
- );
1584
- }
1585
- }
1586
-
1587
154
  // src/_chat.ts
1588
155
  function effectiveThreadId(threadId) {
1589
- if (threadId === void 0) return void 0;
1590
- if (!threadId.trim()) return void 0;
156
+ if (threadId === void 0 || !threadId.trim()) return void 0;
1591
157
  return threadId;
1592
158
  }
1593
- function resolveSessionId(threadId) {
1594
- return resolveAgentRunSessionId(effectiveThreadId(threadId));
1595
- }
1596
- function chatPath(resource, resourceId, options) {
1597
- const safeId = encodeURIComponent(String(resourceId));
1598
- const tid = effectiveThreadId(options.threadId);
1599
- if (tid !== void 0) {
1600
- const safeTid = encodeURIComponent(tid);
1601
- return `/api/v1/${resource}/${safeId}/conversations/${safeTid}/chat`;
1602
- }
1603
- return `/api/v1/${resource}/${safeId}/chat`;
1604
- }
1605
- function modusChatPath(options) {
1606
- const tid = effectiveThreadId(options.threadId);
1607
- if (tid !== void 0) {
1608
- validateId(tid, "thread_id");
1609
- return `/api/v1/modus/conversations/${encodeURIComponent(tid)}/chat`;
1610
- }
1611
- return `/api/v1/modus/chat`;
1612
- }
1613
- function agentHostRunsPath(resource, resourceId) {
1614
- if (resource === "modus") return "/agent/v1/modus/runs";
1615
- const safeId = encodeURIComponent(String(resourceId));
1616
- return `/agent/v1/${resource}/${safeId}/runs`;
1617
- }
1618
- function chatBody(message, model) {
1619
- return { message, model };
1620
- }
1621
- function agentRunsBody(message, model, options) {
1622
- const body = {
1623
- message,
1624
- config: { model },
1625
- sessionId: options.sessionId
1626
- };
1627
- if (options.organizationId !== void 0) {
1628
- body.organizationId = options.organizationId;
1629
- }
1630
- if (options.version !== void 0) {
1631
- body.version = options.version;
1632
- }
1633
- return body;
159
+ function runsPath(target) {
160
+ if (target.kind === "modus") return "/agent/v1/modus/runs";
161
+ return `/agent/v1/${target.kind}/${encodeURIComponent(String(target.id))}/runs`;
1634
162
  }
1635
163
  function raiseForEvent(event) {
1636
- if (event.type === "error") throw new ModusError(event.message);
1637
- if (event.type === "cancelled") throw new RunCancelledError();
1638
- if (event.type === "stream_timeout") throw new StreamTimeoutError();
164
+ if (event.type === "error") throw new (0, _chunk3MHHVC6Ccjs.ModusError)(event.message, { requestId: event.requestId });
165
+ if (event.type === "cancelled") throw new (0, _chunk3MHHVC6Ccjs.RunCancelledError)();
166
+ if (event.type === "stream_timeout") throw new (0, _chunk3MHHVC6Ccjs.StreamTimeoutError)();
1639
167
  return event;
1640
168
  }
1641
- var ChatStream = class {
1642
- constructor(http, path, body, baseUrl) {
169
+ var ChatSession = class _ChatSession {
170
+ /**
171
+ * @internal A session built with `failure` never sends; every read rejects
172
+ * with it, as the promise `chat()` used to return did.
173
+ */
174
+ constructor(http, request, failure) {
1643
175
  this.http = http;
1644
- this.path = path;
1645
- this.body = body;
1646
- this.baseUrl = baseUrl;
1647
- this.textParts = [];
176
+ this.request = request;
177
+ this.received = [];
178
+ this.finished = false;
179
+ if (failure !== void 0) {
180
+ this.failure = failure;
181
+ this.finished = true;
182
+ }
1648
183
  }
1649
184
  /**
1650
- * Async iterable of assistant text token chunks as they arrive.
185
+ * The assistant's reply as text chunks, as they arrive. Sub-agent output is
186
+ * left out.
1651
187
  *
1652
- * @returns An async generator yielding partial text strings.
1653
- * @throws {ModusError} When the stream emits an error event.
188
+ * @throws {ModusError} When the run reports an error.
1654
189
  * @throws {RunCancelledError} When the run is cancelled.
1655
- * @throws {StreamTimeoutError} When the stream times out.
190
+ * @throws {StreamTimeoutError} When the run times out.
1656
191
  */
1657
192
  async *textStream() {
1658
- for await (const event of this.events(false)) {
1659
- if (event.type === "token") yield event.content;
193
+ const lastReset = this.received.findLastIndex(
194
+ (event) => event.type === "assistant_content_reset" && event.subAgent === void 0
195
+ );
196
+ let index = 0;
197
+ for await (const event of this.replay(false)) {
198
+ const at = index++;
199
+ if (at < lastReset) continue;
200
+ if (at === lastReset && event.type === "assistant_content_reset") {
201
+ if (event.content) yield event.content;
202
+ } else if (event.type === "token" && event.subAgent === void 0) {
203
+ yield event.content;
204
+ }
1660
205
  }
1661
206
  }
1662
207
  /**
1663
- * Async iterable of structured run events (tokens, tool calls, done, and so on).
208
+ * Every run event (tokens, approvals, `done`, …) as it arrives.
1664
209
  *
1665
- * @returns An async generator yielding {@link RunEvent} objects.
1666
- * @throws {ModusError} When the stream emits an error event.
210
+ * @throws {ModusError} When the run reports an error.
1667
211
  * @throws {RunCancelledError} When the run is cancelled.
1668
- * @throws {StreamTimeoutError} When the stream times out.
212
+ * @throws {StreamTimeoutError} When the run times out.
1669
213
  */
1670
- async *eventStream() {
1671
- yield* this.events(true);
1672
- }
1673
- async *events(supportsReset) {
1674
- const body = supportsReset ? { ...this.body, streamProtocolVersion: 2 } : this.body;
1675
- for await (const line of this.http.streamPost(this.path, body, {
1676
- baseUrl: this.baseUrl
1677
- })) {
1678
- for (const event of parseSseStream([line])) {
1679
- const normalized = raiseForEvent(event);
1680
- if (normalized.type === "token") this.textParts.push(normalized.content);
1681
- if (normalized.type === "assistant_content_reset") {
1682
- this.textParts.length = 0;
1683
- this.textParts.push(normalized.content);
1684
- }
1685
- if (normalized.type === "done") {
1686
- this.final = {
1687
- content: this.textParts.join(""),
1688
- threadId: normalized.threadId,
1689
- runId: normalized.runId
1690
- };
1691
- yield normalized;
1692
- return;
1693
- }
1694
- yield normalized;
1695
- }
1696
- }
214
+ eventStream() {
215
+ return this.replay(true);
1697
216
  }
1698
217
  /**
1699
- * Final chat result after the stream completes.
218
+ * Waits for the run to finish and returns its final answer. `approval` is
219
+ * set when the run stopped for a decision; continue with {@link resume}.
1700
220
  *
1701
- * Call only after fully consuming {@link ChatStream.textStream} or
1702
- * {@link ChatStream.eventStream}.
1703
- *
1704
- * @returns The assembled assistant reply, thread id, and run id.
1705
- * @throws {ModusError} When called before the stream finishes with a done event.
221
+ * @throws {ModusError} When the run reports an error or ends without finishing.
1706
222
  */
1707
- getFinalResult() {
1708
- if (this.final === void 0) {
1709
- throw new ModusError(
1710
- "Stream ended without a done event; call getFinalResult() only after consuming textStream() or eventStream()."
1711
- );
223
+ async result() {
224
+ for await (const _event of this.replay(true)) {
1712
225
  }
226
+ if (this.final === void 0) throw new (0, _chunk3MHHVC6Ccjs.ModusError)("Chat stream ended without a done event");
1713
227
  return this.final;
1714
228
  }
1715
- };
1716
- async function chatBuffered(http, resource, resourceId, message, options) {
1717
- validateId(resourceId, `${resource}_id`);
1718
- validateChatModel(options.model);
1719
- const path = chatPath(resource, resourceId, {
1720
- threadId: options.threadId
1721
- });
1722
- const data = await http.post(path, chatBody(message, options.model));
1723
- return data;
1724
- }
1725
- function chatStreamSession(http, config, resource, resourceId, message, options) {
1726
- validateId(resourceId, `${resource}_id`);
1727
- validateChatModel(options.model);
1728
- const path = agentHostRunsPath(resource, resourceId);
1729
- return new ChatStream(
1730
- http,
1731
- path,
1732
- agentRunsBody(message, options.model, {
1733
- sessionId: resolveSessionId(options.threadId),
1734
- organizationId: config.organizationId,
1735
- version: options.version
1736
- }),
1737
- config.agentHost
1738
- );
1739
- }
1740
- async function modusChatBuffered(http, message, options) {
1741
- validateChatModel(options.model);
1742
- const path = modusChatPath({ threadId: options.threadId });
1743
- const data = await http.post(path, chatBody(message, options.model));
1744
- return data;
1745
- }
1746
- function modusChatStreamSession(http, config, message, options) {
1747
- validateChatModel(options.model);
1748
- return new ChatStream(
1749
- http,
1750
- agentHostRunsPath("modus"),
1751
- agentRunsBody(message, options.model, {
1752
- sessionId: resolveSessionId(options.threadId),
1753
- organizationId: config.organizationId
1754
- }),
1755
- config.agentHost
1756
- );
1757
- }
1758
-
1759
- // src/_pagination.ts
1760
- var Page = class {
1761
- constructor(items, nextPageToken, fetchPage) {
1762
- this.items = items;
1763
- this.nextPageToken = normalizePageToken(nextPageToken);
1764
- this.fetchPage = fetchPage;
229
+ /** Resolve with the final {@link ChatResult}, so the session can be awaited. */
230
+ then(onfulfilled, onrejected) {
231
+ return this.result().then(onfulfilled, onrejected);
1765
232
  }
1766
- /**
1767
- * Whether another page of results is available.
1768
- *
1769
- * @returns `true` when {@link Page.nextPageToken} is set.
1770
- */
1771
- hasNextPage() {
1772
- return this.nextPageToken !== void 0;
233
+ /** Handle a failed run, as on the promise `chat()` used to return. */
234
+ catch(onrejected) {
235
+ return this.result().catch(onrejected);
236
+ }
237
+ /** Run `onfinally` once the run settles, as on the promise `chat()` used to return. */
238
+ finally(onfinally) {
239
+ return this.result().finally(onfinally);
1773
240
  }
1774
241
  /**
1775
- * Fetch the next page using {@link Page.nextPageToken}.
242
+ * Approve or deny the action this run stopped for, continuing the same
243
+ * conversation.
244
+ *
245
+ * @param input.decision - `approve` or `deny`.
246
+ * @returns A new session for the continued run.
247
+ * @throws {ModusError} When called before the run has finished.
1776
248
  *
1777
- * @returns The following page of results.
1778
- * @throws {Error} When there is no next page. Check {@link Page.hasNextPage} first.
249
+ * @example
250
+ * ```ts
251
+ * const chat = client.modus.chat('Fix the typo in accounts', { model: 'claude-sonnet-5.5' })
252
+ * const first = await chat
253
+ * if (first.approval) {
254
+ * const done = await chat.resume({ decision: 'approve' })
255
+ * }
256
+ * ```
1779
257
  */
1780
- async getNextPage() {
1781
- if (this.nextPageToken === void 0) {
1782
- throw new Error(
1783
- "No next page available. Check hasNextPage() before calling getNextPage()."
1784
- );
258
+ resume(input) {
259
+ if (this.final === void 0) {
260
+ throw new (0, _chunk3MHHVC6Ccjs.ModusError)("resume() needs a finished run: await the chat first");
1785
261
  }
1786
- return this.fetchPage(this.nextPageToken);
262
+ const { runId, threadId } = this.final;
263
+ _chunk3MHHVC6Ccjs.validateId.call(void 0, runId, "run_id");
264
+ return new _ChatSession(this.http, {
265
+ path: `/agent/v1/runs/${encodeURIComponent(runId)}/resume`,
266
+ body: { sessionId: threadId, decision: input.decision },
267
+ sessionId: threadId,
268
+ baseUrl: this.request.baseUrl
269
+ });
1787
270
  }
1788
271
  /**
1789
- * Async-iterate over all items across every page, fetching additional pages as needed.
1790
- *
1791
- * @returns An async generator yielding every item in the result set.
1792
- * @throws {ModusError} When a follow-up page request fails.
272
+ * Stop reading the run and release its connection. Call it when you stop
273
+ * iterating before the run ends; a session that reached `done` has already
274
+ * let go. The run itself keeps going on the server.
1793
275
  */
1794
- async *autoPagingIter() {
1795
- for (const item of this.items) yield item;
1796
- let nextPageToken = this.nextPageToken;
1797
- while (nextPageToken !== void 0) {
1798
- const page = await this.fetchPage(nextPageToken);
1799
- for (const item of page.items) yield item;
1800
- nextPageToken = page.nextPageToken;
276
+ async close() {
277
+ this.finished = true;
278
+ await _optionalChain([this, 'access', _ => _.live, 'optionalAccess', _2 => _2.return, 'call', _3 => _3(void 0)]);
279
+ }
280
+ // ponytail: one consumer at a time; concurrent iterators would race on `live`.
281
+ async *replay(resetAware) {
282
+ let index = 0;
283
+ while (true) {
284
+ if (index < this.received.length) {
285
+ yield this.received[index++];
286
+ continue;
287
+ }
288
+ if (this.failure !== void 0) throw this.failure;
289
+ if (this.finished) return;
290
+ _nullishCoalesce(this.live, () => ( (this.live = this.open(resetAware))));
291
+ try {
292
+ const next = await this.live.next();
293
+ if (next.done) {
294
+ this.finished = true;
295
+ } else {
296
+ this.received.push(next.value);
297
+ if (next.value.type === "done") await this.close();
298
+ }
299
+ } catch (error) {
300
+ this.failure = error;
301
+ throw error;
302
+ }
1801
303
  }
1802
304
  }
1803
- /** Iterate over the current page's items only. */
1804
- [Symbol.iterator]() {
1805
- return this.items[Symbol.iterator]();
305
+ async *open(resetAware) {
306
+ const request = this.request;
307
+ const body = resetAware ? { ...request.body, streamProtocolVersion: 2 } : request.body;
308
+ const lines = this.http.streamPost(request.path, body, { baseUrl: request.baseUrl });
309
+ for await (const event of parseSseStream(lines)) {
310
+ raiseForEvent(event);
311
+ if (event.type === "approval_required") this.approval = event;
312
+ if (event.type === "done") {
313
+ this.final = {
314
+ content: _nullishCoalesce(event.content, () => ( "")),
315
+ threadId: event.threadId || this.request.sessionId,
316
+ runId: event.runId,
317
+ ...this.approval !== void 0 ? { approval: this.approval } : {}
318
+ };
319
+ yield event;
320
+ return;
321
+ }
322
+ yield event;
323
+ }
1806
324
  }
1807
325
  };
1808
- function normalizePageToken(token) {
1809
- if (token === void 0 || token === null || !String(token).trim()) return void 0;
1810
- return token;
1811
- }
1812
- function aipListParams(pageSize, pageToken, extra = {}) {
1813
- const params = { pageSize, ...extra };
1814
- const token = normalizePageToken(pageToken);
1815
- if (token !== void 0) params.pageToken = token;
1816
- return params;
1817
- }
1818
- function nextPageTokenFromResponse(data) {
1819
- return normalizePageToken(
1820
- typeof data.nextPageToken === "string" ? data.nextPageToken : void 0
1821
- );
1822
- }
1823
- function requireItemsList(data, itemsKey) {
1824
- const value = data[itemsKey];
1825
- if (!Array.isArray(value)) {
1826
- throw new ModusError(
1827
- `Unexpected list response shape: ${itemsKey} must be a list, got ${typeof value}. This is likely a backend error.`
1828
- );
326
+ function startChat(http, config, target, message, options) {
327
+ try {
328
+ return new ChatSession(http, chatRequest(config, target, message, options));
329
+ } catch (error) {
330
+ return new ChatSession(http, void 0, error);
1829
331
  }
1830
- return value;
1831
332
  }
1832
- function buildAipPage(data, itemsKey, mapItem, fetchPage) {
1833
- if (typeof data !== "object" || data === null || !(itemsKey in data)) {
1834
- throw new ModusError(
1835
- `Unexpected list response shape: missing ${itemsKey}. Got: ${typeof data}. This is likely a backend error.`
1836
- );
1837
- }
1838
- const items = requireItemsList(data, itemsKey).map(mapItem);
1839
- return new Page(items, nextPageTokenFromResponse(data), fetchPage);
333
+ function chatRequest(config, target, message, options) {
334
+ if (target.kind !== "modus") _chunk3MHHVC6Ccjs.validateId.call(void 0, target.id, `${target.kind.slice(0, -1)}_id`);
335
+ _chunk3MHHVC6Ccjs.validateChatModel.call(void 0, options.model);
336
+ const baseUrl = _chunk3MHHVC6Ccjs.requireAgentHost.call(void 0, config);
337
+ const sessionId = resolveAgentRunSessionId(effectiveThreadId(options.threadId));
338
+ return {
339
+ path: runsPath(target),
340
+ body: {
341
+ message,
342
+ config: { model: options.model },
343
+ sessionId,
344
+ ...config.organizationId !== void 0 ? { organizationId: config.organizationId } : {}
345
+ },
346
+ sessionId,
347
+ baseUrl
348
+ };
1840
349
  }
1841
350
 
1842
351
  // src/types/workflows.ts
@@ -1854,490 +363,6 @@ function conversationSkillId(item) {
1854
363
  return item.scopeId;
1855
364
  }
1856
365
 
1857
- // src/_auth.ts
1858
- var ENV_API_KEY = "MODUS_API_KEY";
1859
- var ENV_BASE_URL = "MODUS_BASE_URL";
1860
- var ENV_AGENT_HOST = "MODUS_AGENT_HOST";
1861
- var ENV_ORGANIZATION_ID = "MODUS_ORGANIZATION_ID";
1862
- var ENV_TIMEOUT = "MODUS_TIMEOUT";
1863
- var ENV_MAX_RETRIES = "MODUS_MAX_RETRIES";
1864
- var KEY_PREFIX = "modus_";
1865
- function resolveApiKey(apiKey) {
1866
- const key = apiKey ?? process.env[ENV_API_KEY];
1867
- if (!key) {
1868
- throw new AuthenticationError(
1869
- `No API key provided. Pass apiKey or set the ${ENV_API_KEY} environment variable. Create a token at app.getmodus.com \u2192 Settings \u2192 API Tokens.`
1870
- );
1871
- }
1872
- if (!key.startsWith(KEY_PREFIX)) {
1873
- throw new AuthenticationError(
1874
- `Invalid API key format. Modus API keys start with '${KEY_PREFIX}'. Create a token at app.getmodus.com \u2192 Settings \u2192 API Tokens.`
1875
- );
1876
- }
1877
- return key;
1878
- }
1879
- function resolveBaseUrl(baseUrl) {
1880
- return baseUrl ?? process.env[ENV_BASE_URL] ?? void 0;
1881
- }
1882
- function resolveAgentHost(agentHost) {
1883
- return agentHost ?? process.env[ENV_AGENT_HOST] ?? void 0;
1884
- }
1885
- function isModusApiHostname(hostname) {
1886
- return hostname === "api.getmodus.com" || /^api\.[a-z0-9-]+\.getmodus\.com$/i.test(hostname);
1887
- }
1888
- function deriveAgentHostFromBaseUrl(baseUrl) {
1889
- try {
1890
- const url = new URL(baseUrl);
1891
- if (!isModusApiHostname(url.hostname)) return void 0;
1892
- url.hostname = `agent.${url.hostname.slice("api.".length)}`;
1893
- return url.origin;
1894
- } catch {
1895
- return void 0;
1896
- }
1897
- }
1898
- function resolveOrganizationId(organizationId) {
1899
- const raw = organizationId ?? process.env[ENV_ORGANIZATION_ID];
1900
- if (raw === void 0) return void 0;
1901
- const stripped = raw.trim();
1902
- return stripped || void 0;
1903
- }
1904
- function resolveTimeoutMs(explicitMs) {
1905
- if (explicitMs !== void 0) return explicitMs;
1906
- const raw = process.env[ENV_TIMEOUT];
1907
- if (raw === void 0) return void 0;
1908
- const seconds = Number(raw);
1909
- return Number.isFinite(seconds) ? seconds * 1e3 : void 0;
1910
- }
1911
- function resolveMaxRetries(explicit) {
1912
- if (explicit !== void 0) {
1913
- if (explicit < 0) throw new Error(`max_retries must be >= 0, got ${explicit}`);
1914
- return explicit;
1915
- }
1916
- const raw = process.env[ENV_MAX_RETRIES];
1917
- if (raw === void 0) return void 0;
1918
- const value = Number.parseInt(raw, 10);
1919
- return Number.isFinite(value) && value >= 0 ? value : void 0;
1920
- }
1921
- function authHeaders(apiKey) {
1922
- return { Authorization: `Bearer ${apiKey}` };
1923
- }
1924
-
1925
- // src/_config.ts
1926
- var DEFAULT_BASE_URL = "https://api.getmodus.com";
1927
- var DEFAULT_AGENT_HOST = "https://agent.getmodus.com";
1928
- var DEFAULT_TIMEOUT_MS = 3e5;
1929
- var DEFAULT_MAX_RETRIES = 2;
1930
- function normalizeBaseUrl(baseUrl) {
1931
- return baseUrl.replace(/\/$/, "");
1932
- }
1933
- function normalizeBaseUrls(baseUrls) {
1934
- return Object.fromEntries(
1935
- Object.entries(baseUrls ?? {}).map(([service, baseUrl]) => [
1936
- service,
1937
- normalizeBaseUrl(baseUrl)
1938
- ])
1939
- );
1940
- }
1941
- function createModusConfig(options = {}) {
1942
- const maxRetries = resolveMaxRetries(options.maxRetries) ?? DEFAULT_MAX_RETRIES;
1943
- if (!Number.isInteger(maxRetries) || maxRetries < 0) {
1944
- throw new Error(`max_retries must be a non-negative int, got ${maxRetries}`);
1945
- }
1946
- const baseUrl = normalizeBaseUrl(resolveBaseUrl(options.baseUrl) ?? DEFAULT_BASE_URL);
1947
- const baseUrlOverrides = normalizeBaseUrls(options.baseUrls);
1948
- const agentHost = normalizeBaseUrl(
1949
- baseUrlOverrides["agent-service"] ?? resolveAgentHost(options.agentHost) ?? deriveAgentHostFromBaseUrl(baseUrl) ?? DEFAULT_AGENT_HOST
1950
- );
1951
- const organizationId = resolveOrganizationId(options.organizationId);
1952
- return Object.freeze({
1953
- apiKey: resolveApiKey(options.apiKey),
1954
- baseUrl,
1955
- agentHost,
1956
- ...organizationId !== void 0 ? { organizationId } : {},
1957
- baseUrls: Object.freeze({
1958
- "modus-api": baseUrl,
1959
- "agent-service": agentHost,
1960
- ...baseUrlOverrides
1961
- }),
1962
- timeoutMs: resolveTimeoutMs(options.timeoutMs) ?? DEFAULT_TIMEOUT_MS,
1963
- maxRetries,
1964
- defaultHeaders: Object.freeze({ ...options.defaultHeaders }),
1965
- fetch: options.fetch ?? globalThis.fetch.bind(globalThis)
1966
- });
1967
- }
1968
- function resolveServiceBaseUrl(config, service, generatedBaseUrl) {
1969
- if (service === "agent-service") {
1970
- return config.baseUrls["agent-service"] ?? config.agentHost ?? generatedBaseUrl ?? config.baseUrl;
1971
- }
1972
- return config.baseUrls[service] ?? generatedBaseUrl ?? config.baseUrl;
1973
- }
1974
- function formatConfigForLog(config) {
1975
- const masked = config.apiKey.length > 10 ? `${config.apiKey.slice(0, 10)}***` : "***";
1976
- return `ModusConfig(apiKey=${JSON.stringify(masked)}, baseUrl=${JSON.stringify(config.baseUrl)}, timeoutMs=${config.timeoutMs}, maxRetries=${config.maxRetries})`;
1977
- }
1978
-
1979
- // src/_http.ts
1980
- var USER_AGENT = `modus-typescript/${"0.9.0"} (node/${process.version}; ${process.platform})`;
1981
- function buildUrl(baseUrl, path, params) {
1982
- const url = new URL(path.startsWith("/") ? path : `/${path}`, baseUrl);
1983
- if (params) {
1984
- for (const [key, value] of Object.entries(params)) {
1985
- if (value === void 0 || value === null) continue;
1986
- if (Array.isArray(value)) {
1987
- for (const item of value) url.searchParams.append(key, String(item));
1988
- } else {
1989
- url.searchParams.set(key, String(value));
1990
- }
1991
- }
1992
- }
1993
- return url.toString();
1994
- }
1995
- function mergeHeaders(...layers) {
1996
- const merged = /* @__PURE__ */ new Map();
1997
- for (const layer of layers) {
1998
- for (const [name, value] of Object.entries(layer ?? {})) {
1999
- merged.set(name.toLowerCase(), [name, value]);
2000
- }
2001
- }
2002
- return Object.fromEntries(merged.values());
2003
- }
2004
- function headersToRecord(headers) {
2005
- const out = {};
2006
- headers.forEach((value, key) => {
2007
- out[key] = value;
2008
- });
2009
- return out;
2010
- }
2011
- function messageFromBody(raw, statusCode) {
2012
- if (!raw) return `HTTP ${statusCode}`;
2013
- try {
2014
- const body = JSON.parse(raw);
2015
- if (body && typeof body === "object") {
2016
- const record = body;
2017
- const envelope = record.error;
2018
- if (envelope && typeof envelope === "object") {
2019
- const msg2 = envelope.message;
2020
- if (typeof msg2 === "string" && msg2) return msg2;
2021
- }
2022
- const msg = record.message ?? record.error;
2023
- if (Array.isArray(msg)) return msg.map(String).join("; ");
2024
- if (typeof msg === "string" && msg) return msg;
2025
- }
2026
- } catch {
2027
- }
2028
- return raw;
2029
- }
2030
- function errorCodeFromBody(raw) {
2031
- try {
2032
- const body = JSON.parse(raw);
2033
- return typeof body.error?.code === "string" ? body.error.code : void 0;
2034
- } catch {
2035
- return void 0;
2036
- }
2037
- }
2038
- function raiseForStatus(response, body) {
2039
- if (response.ok) return;
2040
- const message = messageFromBody(body, response.status);
2041
- const requestId = response.headers.get("x-request-id") ?? response.headers.get("X-Request-ID") ?? void 0;
2042
- const headers = headersToRecord(response.headers);
2043
- const code = errorCodeFromBody(body);
2044
- const base = { requestId, responseHeaders: headers, body, code };
2045
- switch (response.status) {
2046
- case 401:
2047
- throw new AuthenticationError(message, base);
2048
- case 403:
2049
- throw new PermissionDeniedError(message, base);
2050
- case 404:
2051
- throw new NotFoundError(message, base);
2052
- case 409:
2053
- throw new ConflictError(message, base);
2054
- case 422: {
2055
- let errors;
2056
- try {
2057
- errors = JSON.parse(body);
2058
- } catch {
2059
- errors = void 0;
2060
- }
2061
- throw new UnprocessableError(message, { ...base, errors });
2062
- }
2063
- case 429: {
2064
- const retryHeader = response.headers.get("retry-after") ?? "";
2065
- const retryAfter = /^\d+$/.test(retryHeader) ? Number.parseInt(retryHeader, 10) : void 0;
2066
- throw new RateLimitError(message, { ...base, retryAfter });
2067
- }
2068
- default:
2069
- if (response.status >= 500) {
2070
- throw new InternalServerError(message, response.status, base);
2071
- }
2072
- throw new ModusError(message, { ...base, statusCode: response.status });
2073
- }
2074
- }
2075
- function wrapNetworkError(error, baseUrl) {
2076
- const detail = error instanceof Error ? error.message : String(error);
2077
- return new APIConnectionError(
2078
- `Network error communicating with Modus API at ${JSON.stringify(baseUrl)}: ${detail}. Check connectivity and that baseUrl is correct.`
2079
- );
2080
- }
2081
- async function readBody(response) {
2082
- return response.text();
2083
- }
2084
- async function readBodyPreview(response, maxChars = 200) {
2085
- if (!response.body) return "";
2086
- const reader = response.body.getReader();
2087
- const decoder = new TextDecoder();
2088
- let out = "";
2089
- try {
2090
- while (out.length < maxChars) {
2091
- const { done, value } = await reader.read();
2092
- if (done) break;
2093
- out += decoder.decode(value, { stream: true });
2094
- if (out.length >= maxChars) {
2095
- out = out.slice(0, maxChars);
2096
- break;
2097
- }
2098
- }
2099
- } finally {
2100
- await reader.cancel().catch(() => void 0);
2101
- }
2102
- return out;
2103
- }
2104
- var HttpClient = class {
2105
- constructor(config) {
2106
- this.config = config;
2107
- }
2108
- defaultHeaders() {
2109
- return mergeHeaders(
2110
- {
2111
- Accept: "application/json",
2112
- "Content-Type": "application/json",
2113
- "User-Agent": USER_AGENT,
2114
- "X-Modus-Client": "sdk"
2115
- },
2116
- this.config.defaultHeaders
2117
- );
2118
- }
2119
- async request(method, path, options = {}) {
2120
- const baseUrl = options.baseUrl ?? this.config.baseUrl;
2121
- const url = buildUrl(baseUrl, path, options.params);
2122
- try {
2123
- const response = await this.config.fetch(url, {
2124
- method,
2125
- headers: mergeHeaders(this.defaultHeaders(), options.headers, authHeaders(this.config.apiKey)),
2126
- body: options.json !== void 0 ? JSON.stringify(options.json) : void 0,
2127
- signal: AbortSignal.timeout(this.config.timeoutMs)
2128
- });
2129
- const body = await readBody(response);
2130
- raiseForStatus(response, body);
2131
- if (response.status === 204 || !body) return null;
2132
- return JSON.parse(body);
2133
- } catch (error) {
2134
- if (error instanceof ModusError) throw error;
2135
- if (error instanceof DOMException && error.name === "AbortError") {
2136
- throw wrapNetworkError(new Error("Request timed out"), baseUrl);
2137
- }
2138
- throw wrapNetworkError(error, baseUrl);
2139
- }
2140
- }
2141
- get(path, params, options = {}) {
2142
- return this.request("GET", path, { params, ...options });
2143
- }
2144
- post(path, json, options = {}) {
2145
- return this.request("POST", path, { json, ...options });
2146
- }
2147
- put(path, json, options = {}) {
2148
- return this.request("PUT", path, { json, ...options });
2149
- }
2150
- patch(path, json, params, options = {}) {
2151
- return this.request("PATCH", path, { json, params, ...options });
2152
- }
2153
- delete(path, options = {}) {
2154
- return this.request("DELETE", path, options);
2155
- }
2156
- async *stream(method, path, options = {}) {
2157
- const baseUrl = options.baseUrl ?? this.config.baseUrl;
2158
- const url = buildUrl(baseUrl, path, options.params);
2159
- try {
2160
- const response = await this.config.fetch(url, {
2161
- method,
2162
- // Agent-service negotiates SSE vs JSON polling on Accept; JSON-only
2163
- // Accept returns {"runId","status":"pending"} instead of token SSE.
2164
- headers: mergeHeaders(
2165
- this.defaultHeaders(),
2166
- options.headers,
2167
- { Accept: "text/event-stream" },
2168
- authHeaders(this.config.apiKey)
2169
- ),
2170
- body: options.json !== void 0 ? JSON.stringify(options.json) : void 0,
2171
- signal: AbortSignal.timeout(this.config.timeoutMs)
2172
- });
2173
- if (!response.ok) {
2174
- const body = await readBody(response);
2175
- raiseForStatus(response, body);
2176
- return;
2177
- }
2178
- const contentType = response.headers.get("content-type") ?? "";
2179
- if (!contentType.toLowerCase().includes("text/event-stream")) {
2180
- const preview = await readBodyPreview(response);
2181
- throw new ModusError(
2182
- `Unexpected stream response: expected Content-Type text/event-stream, got ${JSON.stringify(contentType) || "(missing)"}. Body preview: ${preview}`,
2183
- { statusCode: response.status, body: preview }
2184
- );
2185
- }
2186
- if (!response.body) return;
2187
- const reader = response.body.getReader();
2188
- const decoder = new TextDecoder();
2189
- let buffer = "";
2190
- while (true) {
2191
- const { done, value } = await reader.read();
2192
- if (done) break;
2193
- buffer += decoder.decode(value, { stream: true });
2194
- const lines = buffer.split("\n");
2195
- buffer = lines.pop() ?? "";
2196
- for (const line of lines) {
2197
- if (line.trim()) yield line;
2198
- }
2199
- }
2200
- if (buffer.trim()) yield buffer;
2201
- } catch (error) {
2202
- if (error instanceof ModusError) throw error;
2203
- if (error instanceof DOMException && error.name === "AbortError") {
2204
- throw wrapNetworkError(new Error("Request timed out"), baseUrl);
2205
- }
2206
- throw wrapNetworkError(error, baseUrl);
2207
- }
2208
- }
2209
- streamGet(path, params, options = {}) {
2210
- return this.stream("GET", path, { params, ...options });
2211
- }
2212
- streamPost(path, json, options = {}) {
2213
- return this.stream("POST", path, { json, ...options });
2214
- }
2215
- };
2216
-
2217
- // src/_client-base.ts
2218
- var ModusClientBase = class {
2219
- constructor(options = {}) {
2220
- this._config = createModusConfig(options);
2221
- this._http = new HttpClient(this._config);
2222
- }
2223
- get config() {
2224
- return this._config;
2225
- }
2226
- /** @internal */
2227
- get http() {
2228
- return this._http;
2229
- }
2230
- toString() {
2231
- return formatConfigForLog(this._config);
2232
- }
2233
- };
2234
-
2235
- // src/_openapi-invoke.ts
2236
- function getOperation(operationId) {
2237
- if (!(operationId in OPERATIONS)) {
2238
- throw new Error(
2239
- `Unknown API operation ${JSON.stringify(operationId)}. Upgrade @getmodus/sdk or report a version mismatch.`
2240
- );
2241
- }
2242
- return OPERATIONS[operationId];
2243
- }
2244
- function formatPath(template, pathParams) {
2245
- return template.split("/").map((segment) => {
2246
- if (!segment.startsWith("{") || !segment.endsWith("}")) return segment;
2247
- const key = segment.slice(1, -1);
2248
- if (!(key in pathParams)) {
2249
- throw new Error(`Missing path parameter ${JSON.stringify(key)} for ${JSON.stringify(template)}`);
2250
- }
2251
- return encodeURIComponent(String(pathParams[key]));
2252
- }).join("/");
2253
- }
2254
- function operationBaseUrl(http, operation) {
2255
- return resolveServiceBaseUrl(http.config, operation.service, operation.serverUrl);
2256
- }
2257
- function formatOperationPath(operationId, pathParams = {}) {
2258
- return formatPath(getOperation(operationId).path, pathParams);
2259
- }
2260
- async function invokeOperation(http, operationId, options = {}) {
2261
- const op = getOperation(operationId);
2262
- const path = formatPath(op.path, options.pathParams ?? {});
2263
- const params = options.query;
2264
- const requestOptions = {
2265
- baseUrl: operationBaseUrl(http, op),
2266
- headers: options.headers
2267
- };
2268
- switch (op.method) {
2269
- case "GET":
2270
- return http.get(path, params, requestOptions);
2271
- case "POST":
2272
- return http.post(path, options.jsonBody, requestOptions);
2273
- case "PUT":
2274
- return http.put(path, options.jsonBody, requestOptions);
2275
- case "PATCH":
2276
- return http.patch(path, options.jsonBody, params, requestOptions);
2277
- case "DELETE":
2278
- return http.delete(path, requestOptions);
2279
- default:
2280
- throw new Error(`Unsupported HTTP method ${JSON.stringify(op.method)}`);
2281
- }
2282
- }
2283
-
2284
- // src/_retry.ts
2285
- var DEPLOY_NOT_FOUND_BACKOFF_MS = 500;
2286
- var MAX_DEPLOY_NOT_FOUND_RETRIES = 1;
2287
- var RETRYABLE = [RateLimitError, InternalServerError, APIConnectionError];
2288
- function isRetryable(error) {
2289
- return RETRYABLE.some((Cls) => error instanceof Cls);
2290
- }
2291
- function backoffSeconds(attempt, error) {
2292
- if (error instanceof RateLimitError && error.retryAfter !== void 0) {
2293
- return Math.max(0, error.retryAfter);
2294
- }
2295
- if (attempt === 0) return 0;
2296
- return Math.max(0.5, 2 ** (attempt - 1) + (Math.random() * 0.6 - 0.3));
2297
- }
2298
- function sleep(ms) {
2299
- return new Promise((resolve) => setTimeout(resolve, ms));
2300
- }
2301
- async function withRetry(fn, maxRetries, options = {}) {
2302
- let deployNotFoundRetries = 0;
2303
- let attempt = 0;
2304
- while (true) {
2305
- try {
2306
- return await fn();
2307
- } catch (error) {
2308
- if (options.retryNotFoundOnDeploy && error instanceof NotFoundError && deployNotFoundRetries < MAX_DEPLOY_NOT_FOUND_RETRIES) {
2309
- deployNotFoundRetries++;
2310
- await sleep(DEPLOY_NOT_FOUND_BACKOFF_MS);
2311
- continue;
2312
- }
2313
- if (!isRetryable(error) || attempt >= maxRetries) throw error;
2314
- await sleep(backoffSeconds(attempt, error) * 1e3);
2315
- attempt++;
2316
- }
2317
- }
2318
- }
2319
-
2320
- // src/_request.ts
2321
- async function invokeWithRetry(config, http, operationId, options = {}) {
2322
- if (options.jsonBody !== void 0) {
2323
- assertWriteBodyKeys(operationId, options.jsonBody);
2324
- }
2325
- return withRetry(() => invokeOperation(http, operationId, options), config.maxRetries, {
2326
- retryNotFoundOnDeploy: operationId.endsWith("_deploy")
2327
- });
2328
- }
2329
- function omitUndefined(obj) {
2330
- return Object.fromEntries(
2331
- Object.entries(obj).filter((entry) => entry[1] !== void 0)
2332
- );
2333
- }
2334
- function asRecord(data) {
2335
- if (typeof data === "object" && data !== null && !Array.isArray(data)) {
2336
- return data;
2337
- }
2338
- throw new Error(`Expected object response, got ${typeof data}`);
2339
- }
2340
-
2341
366
  // src/_generated/resources/consumption/workflows.ts
2342
367
  var WorkflowsResourceBase = class {
2343
368
  /** @internal */
@@ -2358,8 +383,9 @@ var WorkflowsResourceBase = class {
2358
383
  * for the first page.
2359
384
  * @param options.search - Case-insensitive substring filter on workflow name.
2360
385
  * @param options.type - Filter by workflow type.
2361
- * @param options.view - Variation view. `active` reads deployed; `draft` reads the latest builder
2362
- * snapshot.
386
+ * @param options.view - Variation view. `active` reads the deployed version. `draft` reads the
387
+ * latest builder snapshot. `published` reads only a published workflow of type workflow that
388
+ * you can use; tasks are excluded.
2363
389
  * @param options.includeVariation - Include the requested variation payload (`trigger`,
2364
390
  * `workflowStructure`, `agentSelection`) on list rows.
2365
391
  * @returns A page of workflows.
@@ -2372,8 +398,8 @@ var WorkflowsResourceBase = class {
2372
398
  * ```
2373
399
  */
2374
400
  list(options = {}) {
2375
- const pageSize = options.pageSize ?? 25;
2376
- validatePageSize(pageSize);
401
+ const pageSize = _nullishCoalesce(options.pageSize, () => ( 25));
402
+ _chunk3MHHVC6Ccjs.validatePageSize.call(void 0, pageSize);
2377
403
  return this.listPage(pageSize, options.pageToken, options.search, options.type, options.view, options.includeVariation);
2378
404
  }
2379
405
  async listPage(pageSize, pageToken, search, type, view, includeVariation) {
@@ -2382,12 +408,12 @@ var WorkflowsResourceBase = class {
2382
408
  if (type !== void 0) extra.type = type;
2383
409
  if (view !== void 0) extra.view = view;
2384
410
  if (includeVariation !== void 0) extra.includeVariation = includeVariation;
2385
- const data = asRecord(
2386
- await invokeWithRetry(this.config, this.http, "WorkflowsController_list", {
2387
- query: aipListParams(pageSize, pageToken, extra)
411
+ const data = _chunk3MHHVC6Ccjs.asRecord.call(void 0,
412
+ await _chunk3MHHVC6Ccjs.invokeWithRetry.call(void 0, this.config, this.http, "WorkflowsController_list", {
413
+ query: _chunk3MHHVC6Ccjs.aipListParams.call(void 0, pageSize, pageToken, extra)
2388
414
  })
2389
415
  );
2390
- return buildAipPage(
416
+ return _chunk3MHHVC6Ccjs.buildAipPage.call(void 0,
2391
417
  data,
2392
418
  "workflows",
2393
419
  (raw) => raw,
@@ -2397,11 +423,11 @@ var WorkflowsResourceBase = class {
2397
423
  };
2398
424
 
2399
425
  // src/resources/workflows/runs.ts
2400
- var import_node_crypto2 = require("crypto");
426
+
2401
427
  var RUNS_MAX_PAGE_SIZE = 100;
2402
428
  function runsListParams(pageSize, pageToken, status, timeframe, approvalScope, search) {
2403
429
  const params = { pageSize };
2404
- const token = normalizePageToken(pageToken);
430
+ const token = _chunk3MHHVC6Ccjs.normalizePageToken.call(void 0, pageToken);
2405
431
  if (token !== void 0) params.pageToken = token;
2406
432
  if (status !== void 0) params.status = status;
2407
433
  if (timeframe !== void 0) params.timeframe = timeframe;
@@ -2411,7 +437,7 @@ function runsListParams(pageSize, pageToken, status, timeframe, approvalScope, s
2411
437
  }
2412
438
  function activeRunsParams(pageSize, pageToken) {
2413
439
  const params = { pageSize };
2414
- const token = normalizePageToken(pageToken);
440
+ const token = _chunk3MHHVC6Ccjs.normalizePageToken.call(void 0, pageToken);
2415
441
  if (token !== void 0) params.pageToken = token;
2416
442
  return params;
2417
443
  }
@@ -2419,37 +445,42 @@ function parseRun(raw) {
2419
445
  return raw;
2420
446
  }
2421
447
  function parseActiveRunsArray(raw) {
2422
- const data = asRecord(raw);
448
+ const data = _chunk3MHHVC6Ccjs.asRecord.call(void 0, raw);
2423
449
  const runs = data.runs;
2424
450
  if (!Array.isArray(runs)) {
2425
- throw new ModusError(
451
+ throw new (0, _chunk3MHHVC6Ccjs.ModusError)(
2426
452
  `Unexpected active runs response shape: runs must be a list, got ${typeof runs}.`
2427
453
  );
2428
454
  }
2429
455
  return runs;
2430
456
  }
2431
457
  function parseActiveRunsPage(raw, fetchPage) {
2432
- const data = asRecord(raw);
458
+ const data = _chunk3MHHVC6Ccjs.asRecord.call(void 0, raw);
2433
459
  const runs = data.runs;
2434
460
  if (!Array.isArray(runs)) {
2435
- throw new ModusError(
461
+ throw new (0, _chunk3MHHVC6Ccjs.ModusError)(
2436
462
  `Unexpected active runs response shape: runs must be a list, got ${typeof runs}.`
2437
463
  );
2438
464
  }
2439
- return new Page(
465
+ return new (0, _chunk3MHHVC6Ccjs.Page)(
2440
466
  runs,
2441
- normalizePageToken(
467
+ _chunk3MHHVC6Ccjs.normalizePageToken.call(void 0,
2442
468
  typeof data.nextPageToken === "string" ? data.nextPageToken : void 0
2443
469
  ),
2444
470
  fetchPage
2445
471
  );
2446
472
  }
2447
473
  function randomRunId() {
2448
- return (0, import_node_crypto2.randomUUID)();
474
+ return _crypto.randomUUID.call(void 0, );
2449
475
  }
2450
476
  function sessionIdFromBody(body) {
2451
477
  return resolveAgentRunSessionId(body.sessionId);
2452
478
  }
479
+ function requireSessionId(sessionId) {
480
+ if (!_optionalChain([sessionId, 'optionalAccess', _4 => _4.trim, 'call', _5 => _5()])) {
481
+ throw new (0, _chunk3MHHVC6Ccjs.ValidationError)("sessionId must be the run's conversation id (a non-empty string)");
482
+ }
483
+ }
2453
484
  function makeAgentRunStream(runId, events) {
2454
485
  return {
2455
486
  runId,
@@ -2468,7 +499,7 @@ var WorkflowRunsResource = class {
2468
499
  /**
2469
500
  * List runs for a workflow.
2470
501
  *
2471
- * @param workflowId - Workflow id or slug.
502
+ * @param workflowId - Numeric workflow id.
2472
503
  * @param options.pageSize - Maximum items per page (default 25, max 100).
2473
504
  * @param options.pageToken - Opaque token from a previous page.
2474
505
  * @param options.status - Filter by run status.
@@ -2487,14 +518,14 @@ var WorkflowRunsResource = class {
2487
518
  * ```
2488
519
  */
2489
520
  list(workflowId, options = {}) {
2490
- validateId(workflowId, "workflow_id");
2491
- const pageSize = options.pageSize ?? 25;
2492
- validatePageSize(pageSize, RUNS_MAX_PAGE_SIZE);
521
+ _chunk3MHHVC6Ccjs.validateId.call(void 0, workflowId, "workflow_id");
522
+ const pageSize = _nullishCoalesce(options.pageSize, () => ( 25));
523
+ _chunk3MHHVC6Ccjs.validatePageSize.call(void 0, pageSize, RUNS_MAX_PAGE_SIZE);
2493
524
  return this.listPage(workflowId, pageSize, options.pageToken, options);
2494
525
  }
2495
526
  async listPage(workflowId, pageSize, pageToken, filters) {
2496
- const data = asRecord(
2497
- await invokeWithRetry(this.config, this.http, "WorkflowRunsController_list", {
527
+ const data = _chunk3MHHVC6Ccjs.asRecord.call(void 0,
528
+ await _chunk3MHHVC6Ccjs.invokeWithRetry.call(void 0, this.config, this.http, "WorkflowRunsController_list", {
2498
529
  pathParams: { id: workflowId },
2499
530
  query: runsListParams(
2500
531
  pageSize,
@@ -2508,13 +539,13 @@ var WorkflowRunsResource = class {
2508
539
  );
2509
540
  const runs = data.runs;
2510
541
  if (!Array.isArray(runs)) {
2511
- throw new ModusError(
542
+ throw new (0, _chunk3MHHVC6Ccjs.ModusError)(
2512
543
  `Unexpected list response shape: runs must be a list, got ${typeof runs}.`
2513
544
  );
2514
545
  }
2515
- return new Page(
546
+ return new (0, _chunk3MHHVC6Ccjs.Page)(
2516
547
  runs,
2517
- normalizePageToken(
548
+ _chunk3MHHVC6Ccjs.normalizePageToken.call(void 0,
2518
549
  typeof data.nextPageToken === "string" ? data.nextPageToken : void 0
2519
550
  ),
2520
551
  (token) => this.listPage(workflowId, pageSize, token, filters)
@@ -2523,7 +554,7 @@ var WorkflowRunsResource = class {
2523
554
  /**
2524
555
  * Retrieve a workflow run by id.
2525
556
  *
2526
- * @param workflowId - Workflow id or slug the run belongs to.
557
+ * @param workflowId - Numeric workflow id the run belongs to.
2527
558
  * @param runId - Run id (the list row's `workflowId` field, not the composite `id`).
2528
559
  * @param options.temporalRunId - Optional internal execution id when disambiguating retries.
2529
560
  * @returns Run details including status and output.
@@ -2536,10 +567,10 @@ var WorkflowRunsResource = class {
2536
567
  * ```
2537
568
  */
2538
569
  async get(workflowId, runId, options = {}) {
2539
- validateId(workflowId, "workflow_id");
2540
- if (!runId.trim()) throw new Error("run_id must be a non-empty string");
570
+ _chunk3MHHVC6Ccjs.validateId.call(void 0, workflowId, "workflow_id");
571
+ if (!runId.trim()) throw new (0, _chunk3MHHVC6Ccjs.ValidationError)("run_id must be a non-empty string");
2541
572
  const query = options.temporalRunId !== void 0 ? { temporalRunId: options.temporalRunId } : void 0;
2542
- const data = await invokeWithRetry(this.config, this.http, "WorkflowRunsController_get", {
573
+ const data = await _chunk3MHHVC6Ccjs.invokeWithRetry.call(void 0, this.config, this.http, "WorkflowRunsController_get", {
2543
574
  pathParams: { id: workflowId, runId },
2544
575
  query
2545
576
  });
@@ -2548,7 +579,7 @@ var WorkflowRunsResource = class {
2548
579
  /**
2549
580
  * Start a workflow run and stream run events.
2550
581
  *
2551
- * @param workflowId - Workflow id or slug to run.
582
+ * @param workflowId - Numeric workflow id to run.
2552
583
  * @param body - Run body (`message`, optional `sessionId`, optional `version` as `published` or `draft`).
2553
584
  * @param options.idempotencyKey - Client-supplied idempotency key; defaults to `body.runId` or a new uuid.
2554
585
  * @returns A stream of run events (tokens, completion, errors, and related signals).
@@ -2566,7 +597,7 @@ var WorkflowRunsResource = class {
2566
597
  * ```
2567
598
  */
2568
599
  create(workflowId, body, options = {}) {
2569
- validateId(workflowId, "workflow_id");
600
+ _chunk3MHHVC6Ccjs.validateId.call(void 0, workflowId, "workflow_id");
2570
601
  return this.createRun("WorkflowRunsController_create", body, { id: workflowId }, options);
2571
602
  }
2572
603
  /**
@@ -2591,7 +622,7 @@ var WorkflowRunsResource = class {
2591
622
  * ```
2592
623
  */
2593
624
  createScope(scopeId, body, options = {}) {
2594
- validateId(scopeId, "scope_id");
625
+ _chunk3MHHVC6Ccjs.validateId.call(void 0, scopeId, "scope_id");
2595
626
  return this.createRun("ScopeRunsController_create", body, { id: scopeId }, options);
2596
627
  }
2597
628
  /**
@@ -2616,18 +647,21 @@ var WorkflowRunsResource = class {
2616
647
  return this.createRun("ModusRunsController_create", body, {}, options);
2617
648
  }
2618
649
  /**
2619
- * Resume an interrupted run and stream run events.
650
+ * Resume a run paused at an approval or connect interrupt, and stream the continuation's events.
2620
651
  *
2621
- * @param runId - Run id to resume.
2622
- * @param body - Resume body (`message`, `sessionId`, and `decision`: `approve` / `deny` / `connected` / `cancelled`).
652
+ * The decision is the whole turn: send no `message` (a non-empty one is rejected).
653
+ *
654
+ * @param runId - Id of the interrupted run.
655
+ * @param body - `sessionId` (the run's conversation id, required) and `decision`
656
+ * (`approve` / `deny` / `connected` / `cancelled`); optional `approvalTarget`.
2623
657
  * @param options.idempotencyKey - Client-supplied idempotency key; defaults to `body.runId` or a new uuid.
2624
658
  * @returns A stream of run events.
659
+ * @throws {ValidationError} When `sessionId` is blank, before any request is sent.
2625
660
  *
2626
661
  * @example
2627
662
  * ```ts
2628
663
  * const stream = client.workflows.runs.resume(runId, {
2629
664
  * decision: 'approve',
2630
- * message: 'Looks good — continue.',
2631
665
  * sessionId,
2632
666
  * })
2633
667
  * for await (const event of stream) {
@@ -2636,7 +670,8 @@ var WorkflowRunsResource = class {
2636
670
  * ```
2637
671
  */
2638
672
  resume(runId, body, options = {}) {
2639
- validateId(runId, "run_id");
673
+ _chunk3MHHVC6Ccjs.validateId.call(void 0, runId, "run_id");
674
+ requireSessionId(body.sessionId);
2640
675
  return this.createRun("ResumeRunsController_create", body, { runId }, options);
2641
676
  }
2642
677
  /**
@@ -2650,46 +685,86 @@ var WorkflowRunsResource = class {
2650
685
  * ```
2651
686
  */
2652
687
  async cancel(runId) {
2653
- validateId(runId, "run_id");
2654
- await invokeWithRetry(this.config, this.http, "RunLifecycleController_cancel", {
688
+ _chunk3MHHVC6Ccjs.validateId.call(void 0, runId, "run_id");
689
+ await _chunk3MHHVC6Ccjs.invokeWithRetry.call(void 0, this.config, this.http, "RunLifecycleController_cancel", {
2655
690
  pathParams: { runId },
2656
691
  jsonBody: {}
2657
692
  });
2658
693
  }
2659
694
  /**
2660
- * Fetch stored run events for a run.
695
+ * Poll a run's buffered events once (the JSON transport, not SSE).
2661
696
  *
2662
697
  * @param runId - Run id.
2663
- * @returns Run event history for replay or inspection.
698
+ * @returns The poll response: `events` (each with its stream `id` and `type`), `cursor`,
699
+ * `status` and `done`.
2664
700
  */
2665
701
  async events(runId) {
2666
- validateId(runId, "run_id");
2667
- return invokeWithRetry(this.config, this.http, "RunLifecycleController_events", {
702
+ _chunk3MHHVC6Ccjs.validateId.call(void 0, runId, "run_id");
703
+ return await _chunk3MHHVC6Ccjs.invokeWithRetry.call(void 0, this.config, this.http, "RunLifecycleController_events", {
2668
704
  pathParams: { runId }
2669
705
  });
2670
706
  }
2671
707
  /**
2672
- * Request a graceful stop for a running execution.
708
+ * Supersede a run's current turn with a follow-up turn.
709
+ *
710
+ * The run is cancelled and `nextRun` starts as a new run on the same conversation.
711
+ * On a run that has already finished nothing is cancelled, and `nextRun` simply
712
+ * starts a follow-up turn. `nextRun.runId` is pinned (a new uuid when you do not
713
+ * set one), so a retried request returns the same run instead of starting another.
2673
714
  *
2674
715
  * @param runId - Run id to interrupt.
716
+ * @param nextRun - The follow-up turn: `message` and `sessionId` (the run's conversation id).
717
+ * @param options.lastSeenEventId - Id of the last event you rendered, so the cancelled
718
+ * turn's saved output stops there.
719
+ * @returns The new run (`runId`, `status`); follow it with {@link stream}.
720
+ * @throws {ValidationError} When `nextRun.sessionId` is blank, before any request is sent.
721
+ *
722
+ * @example
723
+ * ```ts
724
+ * const { runId: nextRunId } = await client.workflows.runs.interrupt(runId, {
725
+ * message: 'Only count EMEA.',
726
+ * sessionId,
727
+ * })
728
+ * for await (const event of client.workflows.runs.stream(nextRunId)) {
729
+ * if (event.type === 'token') process.stdout.write(event.content)
730
+ * }
731
+ * ```
2675
732
  */
2676
- async interrupt(runId) {
2677
- validateId(runId, "run_id");
2678
- await invokeWithRetry(this.config, this.http, "RunLifecycleController_interrupt", {
733
+ async interrupt(runId, nextRun, options = {}) {
734
+ _chunk3MHHVC6Ccjs.validateId.call(void 0, runId, "run_id");
735
+ requireSessionId(nextRun.sessionId);
736
+ const jsonBody = {
737
+ nextRun: { ...nextRun, runId: _optionalChain([nextRun, 'access', _6 => _6.runId, 'optionalAccess', _7 => _7.trim, 'call', _8 => _8()]) || randomRunId() },
738
+ ...options.lastSeenEventId ? { lastSeenEventId: options.lastSeenEventId } : {}
739
+ };
740
+ return await _chunk3MHHVC6Ccjs.invokeWithRetry.call(void 0, this.config, this.http, "RunLifecycleController_interrupt", {
2679
741
  pathParams: { runId },
2680
- jsonBody: {}
742
+ jsonBody
2681
743
  });
2682
744
  }
2683
745
  /**
2684
- * Move a queued run back into an editable state before it starts.
746
+ * Replace the turn of a run that is still queued (not yet started).
2685
747
  *
2686
748
  * @param runId - Queued run id.
749
+ * @param nextRun - The replacement turn: `message` and `sessionId` (the run's conversation id).
750
+ * @returns The edited run (`runId`, `status`).
751
+ * @throws {ValidationError} When `nextRun.sessionId` is blank, before any request is sent.
752
+ * @throws {ConflictError} When the run has already started.
753
+ *
754
+ * @example
755
+ * ```ts
756
+ * await client.workflows.runs.editQueued(queuedRunId, {
757
+ * message: 'Summarize last week instead.',
758
+ * sessionId,
759
+ * })
760
+ * ```
2687
761
  */
2688
- async editQueued(runId) {
2689
- validateId(runId, "run_id");
2690
- await invokeWithRetry(this.config, this.http, "RunLifecycleController_editQueued", {
762
+ async editQueued(runId, nextRun) {
763
+ _chunk3MHHVC6Ccjs.validateId.call(void 0, runId, "run_id");
764
+ requireSessionId(nextRun.sessionId);
765
+ return await _chunk3MHHVC6Ccjs.invokeWithRetry.call(void 0, this.config, this.http, "RunLifecycleController_editQueued", {
2691
766
  pathParams: { runId },
2692
- jsonBody: {}
767
+ jsonBody: { nextRun }
2693
768
  });
2694
769
  }
2695
770
  /**
@@ -2700,13 +775,13 @@ var WorkflowRunsResource = class {
2700
775
  * @returns A page of active runs with session and status metadata.
2701
776
  */
2702
777
  active(options = {}) {
2703
- const pageSize = options.pageSize ?? 50;
2704
- validatePageSize(pageSize, RUNS_MAX_PAGE_SIZE);
778
+ const pageSize = _nullishCoalesce(options.pageSize, () => ( 50));
779
+ _chunk3MHHVC6Ccjs.validatePageSize.call(void 0, pageSize, RUNS_MAX_PAGE_SIZE);
2705
780
  return this.activePage(pageSize, options.pageToken);
2706
781
  }
2707
782
  async activePage(pageSize, pageToken) {
2708
783
  return parseActiveRunsPage(
2709
- await invokeWithRetry(this.config, this.http, "RunLifecycleController_active", {
784
+ await _chunk3MHHVC6Ccjs.invokeWithRetry.call(void 0, this.config, this.http, "RunLifecycleController_active", {
2710
785
  query: activeRunsParams(pageSize, pageToken)
2711
786
  }),
2712
787
  (token) => this.activePage(pageSize, token)
@@ -2717,55 +792,57 @@ var WorkflowRunsResource = class {
2717
792
  *
2718
793
  * @param sessionIds - Up to 100 session ids.
2719
794
  * @returns Active runs matching any of the given sessions.
2720
- * @throws {Error} When more than 100 session ids are provided.
795
+ * @throws {ValidationError} When more than 100 session ids are provided.
2721
796
  */
2722
797
  async activeBySession(sessionIds) {
2723
798
  const uniqueSessionIds = [...new Set(sessionIds.map((id) => id.trim()).filter(Boolean))];
2724
799
  if (uniqueSessionIds.length > 100) {
2725
- throw new Error("sessionIds must contain at most 100 ids");
800
+ throw new (0, _chunk3MHHVC6Ccjs.ValidationError)("sessionIds must contain at most 100 ids");
2726
801
  }
2727
802
  return parseActiveRunsArray(
2728
- await invokeWithRetry(this.config, this.http, "RunLifecycleController_activeBySession", {
803
+ await _chunk3MHHVC6Ccjs.invokeWithRetry.call(void 0, this.config, this.http, "RunLifecycleController_activeBySession", {
2729
804
  jsonBody: { sessionIds: uniqueSessionIds }
2730
805
  })
2731
806
  );
2732
807
  }
2733
808
  /**
2734
- * Reconnect to an in-progress run and stream run events.
809
+ * Reconnect to a run and stream its events.
2735
810
  *
2736
811
  * @param runId - Run id to follow.
2737
- * @param options.lastEventId - Resume after this event id when catching up.
2738
- * @returns A stream of run events from the current execution point.
812
+ * @param options.lastEventId - The `id` of the last event you handled; the stream resumes
813
+ * after it. Omit to replay the run from its first event.
814
+ * @returns A stream of run events.
2739
815
  *
2740
816
  * @example
2741
817
  * ```ts
2742
- * const stream = client.workflows.runs.stream(runId, { lastEventId: checkpoint })
2743
- * for await (const event of stream) {
818
+ * let lastEventId: string | undefined
819
+ * for await (const event of client.workflows.runs.stream(runId, { lastEventId })) {
2744
820
  * if (event.type === 'token') process.stdout.write(event.content)
821
+ * lastEventId = event.id // after handling it: reconnect with it if the connection drops
2745
822
  * }
2746
823
  * ```
2747
824
  */
2748
825
  stream(runId, options = {}) {
2749
- validateId(runId, "run_id");
2750
- const op = getOperation("RunLifecycleController_stream");
2751
- const path = formatOperationPath("RunLifecycleController_stream", { runId });
826
+ _chunk3MHHVC6Ccjs.validateId.call(void 0, runId, "run_id");
827
+ const op = _chunk3MHHVC6Ccjs.getOperation.call(void 0, "RunLifecycleController_stream");
828
+ const path = _chunk3MHHVC6Ccjs.formatOperationPath.call(void 0, "RunLifecycleController_stream", { runId });
2752
829
  const lines = this.http.streamGet(path, void 0, {
2753
- baseUrl: operationBaseUrl(this.http, op),
830
+ baseUrl: _chunk3MHHVC6Ccjs.operationBaseUrl.call(void 0, this.http, op),
2754
831
  headers: options.lastEventId ? { "Last-Event-ID": options.lastEventId } : void 0
2755
832
  });
2756
833
  return makeAgentRunStream(runId, this.parseEvents(lines));
2757
834
  }
2758
835
  createRun(operationId, body, pathParams, options) {
2759
- const runId = options.idempotencyKey?.trim() || body.runId?.trim() || randomRunId();
836
+ const runId = _optionalChain([options, 'access', _9 => _9.idempotencyKey, 'optionalAccess', _10 => _10.trim, 'call', _11 => _11()]) || _optionalChain([body, 'access', _12 => _12.runId, 'optionalAccess', _13 => _13.trim, 'call', _14 => _14()]) || randomRunId();
2760
837
  const sessionId = sessionIdFromBody(body);
2761
- const op = getOperation(operationId);
2762
- const path = formatOperationPath(operationId, pathParams);
838
+ const op = _chunk3MHHVC6Ccjs.getOperation.call(void 0, operationId);
839
+ const path = _chunk3MHHVC6Ccjs.formatOperationPath.call(void 0, operationId, pathParams);
2763
840
  const lines = this.http.streamPost(path, {
2764
841
  ...body,
2765
842
  sessionId,
2766
843
  streamProtocolVersion: 2
2767
844
  }, {
2768
- baseUrl: operationBaseUrl(this.http, op),
845
+ baseUrl: _chunk3MHHVC6Ccjs.operationBaseUrl.call(void 0, this.http, op),
2769
846
  headers: { "Idempotency-Key": runId }
2770
847
  });
2771
848
  return makeAgentRunStream(runId, this.parseEvents(lines));
@@ -2776,9 +853,9 @@ var WorkflowRunsResource = class {
2776
853
  };
2777
854
 
2778
855
  // src/resources/workflows/workflow-actions.ts
2779
- var import_node_crypto3 = require("crypto");
856
+
2780
857
  function randomRunId2() {
2781
- return (0, import_node_crypto3.randomUUID)();
858
+ return _crypto.randomUUID.call(void 0, );
2782
859
  }
2783
860
  var AgentWorkflowActionsResource = class {
2784
861
  /** @internal */
@@ -2794,11 +871,11 @@ var AgentWorkflowActionsResource = class {
2794
871
  * @returns A stream of run events for the action execution.
2795
872
  */
2796
873
  execute(body, options = {}) {
2797
- const runId = options.idempotencyKey?.trim() || body.runId?.trim() || randomRunId2();
2798
- const op = getOperation("WorkflowActionsController_execute");
2799
- const path = formatOperationPath("WorkflowActionsController_execute");
874
+ const runId = _optionalChain([options, 'access', _15 => _15.idempotencyKey, 'optionalAccess', _16 => _16.trim, 'call', _17 => _17()]) || _optionalChain([body, 'access', _18 => _18.runId, 'optionalAccess', _19 => _19.trim, 'call', _20 => _20()]) || randomRunId2();
875
+ const op = _chunk3MHHVC6Ccjs.getOperation.call(void 0, "WorkflowActionsController_execute");
876
+ const path = _chunk3MHHVC6Ccjs.formatOperationPath.call(void 0, "WorkflowActionsController_execute");
2800
877
  const lines = this.http.streamPost(path, body, {
2801
- baseUrl: operationBaseUrl(this.http, op),
878
+ baseUrl: _chunk3MHHVC6Ccjs.operationBaseUrl.call(void 0, this.http, op),
2802
879
  headers: { "Idempotency-Key": runId }
2803
880
  });
2804
881
  return makeAgentRunStream(runId, this.parseEvents(lines));
@@ -2809,8 +886,8 @@ var AgentWorkflowActionsResource = class {
2809
886
  * @param runId - Action run id to cancel.
2810
887
  */
2811
888
  async cancel(runId) {
2812
- validateId(runId, "run_id");
2813
- await invokeWithRetry(this.config, this.http, "WorkflowActionsController_cancel", {
889
+ _chunk3MHHVC6Ccjs.validateId.call(void 0, runId, "run_id");
890
+ await _chunk3MHHVC6Ccjs.invokeWithRetry.call(void 0, this.config, this.http, "WorkflowActionsController_cancel", {
2814
891
  pathParams: { runId },
2815
892
  jsonBody: {}
2816
893
  });
@@ -2832,33 +909,57 @@ var WorkflowsResource = class extends WorkflowsResourceBase {
2832
909
  this.workflowActions = new AgentWorkflowActionsResource(http, config);
2833
910
  }
2834
911
  /**
2835
- * Retrieve a workflow by ID or slug.
912
+ * Retrieve a workflow by its numeric id.
2836
913
  *
2837
- * @param workflowId - Numeric id or slug.
914
+ * @param workflowId - Numeric workflow id.
2838
915
  * @param options.view - Which saved version to return (`active` or `draft`).
2839
916
  * @param options.includeVariation - Include variation metadata when supported.
2840
917
  * @returns The workflow (`id`, `name`, `status`, …).
2841
- * @throws {NotFoundError} When no workflow matches the id or slug.
918
+ * @throws {NotFoundError} When no workflow has this id.
2842
919
  *
2843
920
  * @example
2844
921
  * ```ts
2845
- * const wf = await client.workflows.get('weekly-digest')
922
+ * const [first] = (await client.workflows.list()).items
923
+ * const wf = await client.workflows.get(first.id)
2846
924
  * console.log(wf.name, wf.status)
2847
925
  * ```
2848
926
  */
2849
927
  async get(workflowId, options = {}) {
2850
- validateId(workflowId, "workflow_id");
928
+ _chunk3MHHVC6Ccjs.validateId.call(void 0, workflowId, "workflow_id");
2851
929
  const query = {};
2852
930
  if (options.view !== void 0) query.view = options.view;
2853
931
  if (options.includeVariation !== void 0) {
2854
932
  query.includeVariation = options.includeVariation;
2855
933
  }
2856
- const data = await invokeWithRetry(this.config, this.http, "WorkflowsController_get", {
934
+ const data = await _chunk3MHHVC6Ccjs.invokeWithRetry.call(void 0, this.config, this.http, "WorkflowsController_get", {
2857
935
  pathParams: { id: workflowId },
2858
936
  query: Object.keys(query).length > 0 ? query : void 0
2859
937
  });
2860
938
  return parseWorkflow(data);
2861
939
  }
940
+ /**
941
+ * Chat with a published workflow. Node output streams live from the agent
942
+ * host: iterate `textStream()` for tokens, or `await` the result for the
943
+ * workflow's final output.
944
+ *
945
+ * @param workflowId - Numeric workflow id.
946
+ * @param message - User message text.
947
+ * @param options.model - Required model id (e.g. `"claude-sonnet-5.5"`).
948
+ * @param options.threadId - Continue an existing conversation; omit to start new.
949
+ * @returns A chat session — iterate it or `await` it for `content`, `threadId`, `runId`.
950
+ * @throws {ModusError} When no agent host is known for a custom `baseUrl`.
951
+ *
952
+ * @example
953
+ * ```ts
954
+ * const { content } = await client.workflows.chat(workflowId, 'Run this week\'s digest', {
955
+ * model: 'claude-sonnet-5.5',
956
+ * })
957
+ * console.log(content)
958
+ * ```
959
+ */
960
+ chat(workflowId, message, options) {
961
+ return startChat(this.http, this.config, { kind: "workflows", id: workflowId }, message, options);
962
+ }
2862
963
  };
2863
964
 
2864
965
  // src/_generated/resources/consumption/connections.ts
@@ -2884,19 +985,19 @@ var ConnectionsResourceBase = class {
2884
985
  * @returns A page of connections.
2885
986
  */
2886
987
  list(options = {}) {
2887
- const pageSize = options.pageSize ?? 25;
2888
- validatePageSize(pageSize);
988
+ const pageSize = _nullishCoalesce(options.pageSize, () => ( 25));
989
+ _chunk3MHHVC6Ccjs.validatePageSize.call(void 0, pageSize);
2889
990
  return this.listPage(pageSize, options.pageToken, options.type);
2890
991
  }
2891
992
  async listPage(pageSize, pageToken, type) {
2892
993
  const extra = {};
2893
994
  if (type !== void 0) extra.type = type;
2894
- const data = asRecord(
2895
- await invokeWithRetry(this.config, this.http, "ConnectionsController_list", {
2896
- query: aipListParams(pageSize, pageToken, extra)
995
+ const data = _chunk3MHHVC6Ccjs.asRecord.call(void 0,
996
+ await _chunk3MHHVC6Ccjs.invokeWithRetry.call(void 0, this.config, this.http, "ConnectionsController_list", {
997
+ query: _chunk3MHHVC6Ccjs.aipListParams.call(void 0, pageSize, pageToken, extra)
2897
998
  })
2898
999
  );
2899
- return buildAipPage(
1000
+ return _chunk3MHHVC6Ccjs.buildAipPage.call(void 0,
2900
1001
  data,
2901
1002
  "connections",
2902
1003
  (raw) => raw,
@@ -2918,13 +1019,13 @@ var ConnectionsResource = class extends ConnectionsResourceBase {
2918
1019
  * @returns The matching connection, or `undefined` if none is found.
2919
1020
  */
2920
1021
  async find(options) {
2921
- const pageSize = options.pageSize ?? 25;
2922
- validatePageSize(pageSize);
1022
+ const pageSize = _nullishCoalesce(options.pageSize, () => ( 25));
1023
+ _chunk3MHHVC6Ccjs.validatePageSize.call(void 0, pageSize);
2923
1024
  const target = options.name.trim().toLowerCase();
2924
1025
  let token;
2925
1026
  do {
2926
1027
  const page = await this.listPage(pageSize, token, options.type);
2927
- const match = page.items.find((c) => c.name?.toLowerCase() === target);
1028
+ const match = page.items.find((c) => _optionalChain([c, 'access', _21 => _21.name, 'optionalAccess', _22 => _22.toLowerCase, 'call', _23 => _23()]) === target);
2928
1029
  if (match) return match;
2929
1030
  if (!page.hasNextPage()) break;
2930
1031
  token = page.nextPageToken;
@@ -2944,19 +1045,19 @@ var ConnectionsResource = class extends ConnectionsResourceBase {
2944
1045
  * }
2945
1046
  */
2946
1047
  listSelections(connectionId, options = {}) {
2947
- validateId(connectionId, "connection_id");
2948
- const pageSize = options.pageSize ?? 25;
2949
- validatePageSize(pageSize);
1048
+ _chunk3MHHVC6Ccjs.validateId.call(void 0, connectionId, "connection_id");
1049
+ const pageSize = _nullishCoalesce(options.pageSize, () => ( 25));
1050
+ _chunk3MHHVC6Ccjs.validatePageSize.call(void 0, pageSize);
2950
1051
  return this.listSelectionsPage(connectionId, pageSize, options.pageToken);
2951
1052
  }
2952
1053
  async listSelectionsPage(connectionId, pageSize, pageToken) {
2953
- const data = asRecord(
2954
- await invokeWithRetry(this.config, this.http, "ConnectionsController_listSelections", {
1054
+ const data = _chunk3MHHVC6Ccjs.asRecord.call(void 0,
1055
+ await _chunk3MHHVC6Ccjs.invokeWithRetry.call(void 0, this.config, this.http, "ConnectionsController_listSelections", {
2955
1056
  pathParams: { connectionId },
2956
- query: aipListParams(pageSize, pageToken)
1057
+ query: _chunk3MHHVC6Ccjs.aipListParams.call(void 0, pageSize, pageToken)
2957
1058
  })
2958
1059
  );
2959
- return buildAipPage(
1060
+ return _chunk3MHHVC6Ccjs.buildAipPage.call(void 0,
2960
1061
  data,
2961
1062
  "selections",
2962
1063
  (raw) => raw,
@@ -2979,224 +1080,37 @@ var ConnectionsResource = class extends ConnectionsResourceBase {
2979
1080
  }
2980
1081
  };
2981
1082
 
2982
- // src/resources/context/custom-items.ts
2983
- function parseContextItem(raw) {
2984
- return raw;
2985
- }
2986
- function parseCreatedCustomContextItem(raw) {
2987
- const data = asRecord(raw);
2988
- const contextItemId = data.contextItemId;
2989
- if (typeof contextItemId !== "string" || !contextItemId) {
2990
- throw new ValidationError(
2991
- "Custom context create response missing non-empty string contextItemId"
2992
- );
2993
- }
2994
- return {
2995
- ...data,
2996
- contextItemId,
2997
- uid: contextItemId
2998
- };
2999
- }
3000
- function parseDeletion(raw) {
3001
- return raw;
3002
- }
3003
- var CustomContextItemsResource = class {
1083
+ // src/_generated/resources/consumption/context/items.ts
1084
+ var ContextItemsResourceBase = class {
3004
1085
  /** @internal */
3005
1086
  constructor(http, config) {
3006
1087
  this.http = http;
3007
1088
  this.config = config;
3008
1089
  }
3009
1090
  /**
3010
- * List custom context items.
3011
- *
3012
- * @param options.pageSize - Maximum items per page (default 25).
3013
- * @param options.pageToken - Opaque token from a previous page.
3014
- * @param options.searchQuery - Word search: returns rows that contain every word of the query, case-insensitive.
3015
- * @param options.topics - Filter to items tagged with any of these topics.
3016
- * @returns A page of custom context items.
3017
- * @example
3018
- * ```ts
3019
- * const client = new Modus()
3020
- * const page = await client.context.customItems.list({ pageSize: 25 })
3021
- * for (const item of page.items) console.log(item.uid, item.contextType)
3022
- * ```
3023
- */
3024
- list(options = {}) {
3025
- const pageSize = options.pageSize ?? 25;
3026
- validatePageSize(pageSize);
3027
- return this.listPage(pageSize, options.pageToken, options);
3028
- }
3029
- async listPage(pageSize, pageToken, options) {
3030
- const data = asRecord(
3031
- await invokeWithRetry(this.config, this.http, "CustomContextItemsController_list", {
3032
- query: aipListParams(pageSize, pageToken, {
3033
- searchQuery: options.searchQuery,
3034
- topics: options.topics
3035
- })
3036
- })
3037
- );
3038
- return buildAipPage(
3039
- data,
3040
- "contextItems",
3041
- parseContextItem,
3042
- (token) => this.listPage(pageSize, token, options)
3043
- );
3044
- }
3045
- /**
3046
- * Retrieve a custom context item by uid.
3047
- *
3048
- * @param uid - Item uid.
3049
- * @returns The custom context item.
3050
- * @throws {NotFoundError} When no item matches the uid.
3051
- * @example
3052
- * ```ts
3053
- * const client = new Modus()
3054
- * const item = await client.context.customItems.get('PLACEHOLDER_UID')
3055
- * ```
3056
- */
3057
- async get(uid) {
3058
- return parseContextItem(
3059
- await invokeWithRetry(this.config, this.http, "CustomContextItemsController_get", {
3060
- pathParams: { uid }
3061
- })
3062
- );
3063
- }
3064
- /**
3065
- * Create a custom context item.
3066
- *
3067
- * @param input.kind - Item kind (`source`, `collection`, `entity`, `field`, or `entity_samples`).
3068
- * @param input.sourceId - Source identifier for the item hierarchy.
3069
- * @param input.name - Display name when applicable.
3070
- * @param input.content - Item payload.
3071
- * @param input.idempotencyKey - Optional idempotency key for safe retries.
3072
- * @returns Created item ids and hierarchy metadata.
3073
- *
3074
- * @example
3075
- * ```ts
3076
- * const client = new Modus()
3077
- * // Create the source and collection first, or use batchCreate as shown below.
3078
- * const created = await client.context.customItems.create({
3079
- * kind: 'entity',
3080
- * sourceId: 'billing-db',
3081
- * collectionId: 'contracts',
3082
- * externalId: 'contract-123',
3083
- * name: 'Q3 churn notes',
3084
- * content: { summary: 'Key findings…' },
3085
- * })
3086
- * console.log(created.uid, created.dataPath)
3087
- * ```
3088
- */
3089
- async create(input) {
3090
- return parseCreatedCustomContextItem(
3091
- await invokeWithRetry(this.config, this.http, "CustomContextItemsController_create", {
3092
- jsonBody: omitUndefined(input)
3093
- })
3094
- );
3095
- }
3096
- /**
3097
- * Create multiple custom context items in one request.
1091
+ * Query context items with SQL.
3098
1092
  *
3099
- * @param inputs - Items to create (same fields as {@link CustomContextItemsResource.create}).
3100
- * @returns Created item metadata for each input.
1093
+ * Runs one read-only SQL statement over the `context_items` table and returns its rows. The query
1094
+ * sees only the items you can read. A query that is not read-only or not valid returns 400; one
1095
+ * that runs past 20 s returns 422.
3101
1096
  *
3102
- * @example
3103
- * ```ts
3104
- * const client = new Modus()
3105
- * const created = await client.context.customItems.batchCreate([
3106
- * { kind: 'source', sourceId: 'billing-db', name: 'Billing database' },
3107
- * {
3108
- * kind: 'collection',
3109
- * sourceId: 'billing-db',
3110
- * collectionId: 'contracts',
3111
- * name: 'Contracts',
3112
- * },
3113
- * {
3114
- * kind: 'entity',
3115
- * sourceId: 'billing-db',
3116
- * collectionId: 'contracts',
3117
- * externalId: 'contract-123',
3118
- * name: 'Acme renewal',
3119
- * },
3120
- * ])
3121
- * console.log(created.map((item) => item.dataPath))
3122
- * ```
3123
- */
3124
- async batchCreate(inputs) {
3125
- const data = asRecord(
3126
- await invokeWithRetry(this.config, this.http, "CustomContextItemsController_batchCreate", {
3127
- jsonBody: {
3128
- items: inputs.map((input) => omitUndefined(input))
3129
- }
3130
- })
3131
- );
3132
- const items = data.contextItems;
3133
- return Array.isArray(items) ? items.map(parseCreatedCustomContextItem) : [];
3134
- }
3135
- /**
3136
- * Create or update typed relations between context items.
1097
+ * **Requires:** `context:read`
3137
1098
  *
3138
- * @param relations - Relations with source and target item uids, a snake_case type, and optional content.
3139
- * @returns Number of relations created or updated.
3140
- * @example
3141
- * ```ts
3142
- * const client = new Modus()
3143
- * await client.context.customItems.createRelations([{
3144
- * fromUid: 'SOURCE_UID',
3145
- * toUid: 'TARGET_UID',
3146
- * relationType: 'depends_on',
3147
- * }])
3148
- * ```
3149
- */
3150
- async createRelations(relations) {
3151
- const data = asRecord(
3152
- await invokeWithRetry(
3153
- this.config,
3154
- this.http,
3155
- "CustomContextItemsController_createRelations",
3156
- { jsonBody: { relations } }
3157
- )
3158
- );
3159
- return data.upsertedCount;
3160
- }
3161
- /**
3162
- * Update a custom context item.
1099
+ * @param query - Request body; see `ContextItemsQuery`.
3163
1100
  *
3164
- * @param uid - Item uid.
3165
- * @param input - Fields to change (kind and hierarchy ids cannot be changed).
3166
- * @returns The updated item uid.
3167
1101
  * @example
3168
1102
  * ```ts
3169
- * const client = new Modus()
3170
- * await client.context.customItems.update('PLACEHOLDER_UID', {
3171
- * description: 'Updated summary',
1103
+ * const result = await modus.context.items.query({
1104
+ * sql: 'SELECT context_type, count(*) AS items FROM context_items GROUP BY context_type',
3172
1105
  * })
1106
+ * result.rows
3173
1107
  * ```
3174
1108
  */
3175
- async update(uid, input) {
3176
- return asRecord(
3177
- await invokeWithRetry(this.config, this.http, "CustomContextItemsController_update", {
3178
- pathParams: { uid },
3179
- jsonBody: omitUndefined(input)
3180
- })
3181
- );
3182
- }
3183
- /**
3184
- * Delete a custom context item.
3185
- *
3186
- * @param uid - Item uid.
3187
- * @returns Deletion confirmation with uid and context type.
3188
- * @example
3189
- * ```ts
3190
- * const client = new Modus()
3191
- * const result = await client.context.customItems.delete('PLACEHOLDER_UID')
3192
- * ```
3193
- */
3194
- async delete(uid) {
3195
- return parseDeletion(
3196
- await invokeWithRetry(this.config, this.http, "CustomContextItemsController_delete", {
3197
- pathParams: { uid }
3198
- })
3199
- );
1109
+ async query(query) {
1110
+ const data = await _chunk3MHHVC6Ccjs.invokeWithRetry.call(void 0, this.config, this.http, "ContextItemsQueryController_query", {
1111
+ jsonBody: _chunk3MHHVC6Ccjs.omitUndefined.call(void 0, query)
1112
+ });
1113
+ return data;
3200
1114
  }
3201
1115
  };
3202
1116
 
@@ -3213,9 +1127,9 @@ function contextListParams(pageSize, pageToken, filters = {}) {
3213
1127
  if (filters.connectionIds !== void 0) {
3214
1128
  extra.connectionIds = filters.connectionIds.length === 0 ? "" : [...filters.connectionIds];
3215
1129
  }
3216
- return aipListParams(pageSize, pageToken, extra);
1130
+ return _chunk3MHHVC6Ccjs.aipListParams.call(void 0, pageSize, pageToken, extra);
3217
1131
  }
3218
- function parseContextItem2(raw) {
1132
+ function parseContextItem(raw) {
3219
1133
  return raw;
3220
1134
  }
3221
1135
  function parseContextValueRow(raw) {
@@ -3226,12 +1140,7 @@ function parseLookupResponse(raw) {
3226
1140
  if (item === null || item === void 0) return void 0;
3227
1141
  return item;
3228
1142
  }
3229
- var ContextItemsResource = class {
3230
- /** @internal */
3231
- constructor(http, config) {
3232
- this.http = http;
3233
- this.config = config;
3234
- }
1143
+ var ContextItemsResource = class extends ContextItemsResourceBase {
3235
1144
  /**
3236
1145
  * List knowledge-base items.
3237
1146
  *
@@ -3279,8 +1188,8 @@ var ContextItemsResource = class {
3279
1188
  * ```
3280
1189
  */
3281
1190
  list(options = {}) {
3282
- const pageSize = options.pageSize ?? 25;
3283
- validatePageSize(pageSize);
1191
+ const pageSize = _nullishCoalesce(options.pageSize, () => ( 25));
1192
+ _chunk3MHHVC6Ccjs.validatePageSize.call(void 0, pageSize);
3284
1193
  return this.listPage(pageSize, options.pageToken, {
3285
1194
  contextType: options.contextType,
3286
1195
  parentUids: options.parentUids,
@@ -3289,15 +1198,15 @@ var ContextItemsResource = class {
3289
1198
  });
3290
1199
  }
3291
1200
  async listPage(pageSize, pageToken, filters) {
3292
- const data = asRecord(
3293
- await invokeWithRetry(this.config, this.http, "ContextItemsController_list", {
1201
+ const data = _chunk3MHHVC6Ccjs.asRecord.call(void 0,
1202
+ await _chunk3MHHVC6Ccjs.invokeWithRetry.call(void 0, this.config, this.http, "ContextItemsController_list", {
3294
1203
  query: contextListParams(pageSize, pageToken, filters)
3295
1204
  })
3296
1205
  );
3297
- return buildAipPage(
1206
+ return _chunk3MHHVC6Ccjs.buildAipPage.call(void 0,
3298
1207
  data,
3299
1208
  "contextItems",
3300
- parseContextItem2,
1209
+ parseContextItem,
3301
1210
  (token) => this.listPage(pageSize, token, filters)
3302
1211
  );
3303
1212
  }
@@ -3315,10 +1224,10 @@ var ContextItemsResource = class {
3315
1224
  * ```
3316
1225
  */
3317
1226
  async get(uid) {
3318
- const data = await invokeWithRetry(this.config, this.http, "ContextItemsController_get", {
1227
+ const data = await _chunk3MHHVC6Ccjs.invokeWithRetry.call(void 0, this.config, this.http, "ContextItemsController_get", {
3319
1228
  pathParams: { uid }
3320
1229
  });
3321
- return parseContextItem2(data);
1230
+ return parseContextItem(data);
3322
1231
  }
3323
1232
  /**
3324
1233
  * Look up a knowledge-base item by type and data path.
@@ -3334,36 +1243,41 @@ var ContextItemsResource = class {
3334
1243
  * contextType: 'note',
3335
1244
  * dataPath: ['finance', 'arr-definition'],
3336
1245
  * })
3337
- * if (found) console.log(found.uid, found.description ?? found.uid)
1246
+ * if (found) console.log(found.uid, found.content)
3338
1247
  * ```
3339
1248
  */
3340
1249
  async lookup(options) {
3341
- const body = omitUndefined({
1250
+ const body = _chunk3MHHVC6Ccjs.omitUndefined.call(void 0, {
3342
1251
  contextType: options.contextType,
3343
1252
  dataPath: options.dataPath,
3344
1253
  contentProjection: options.contentProjection
3345
1254
  });
3346
1255
  try {
3347
- const raw = asRecord(
3348
- await invokeWithRetry(this.config, this.http, "ContextItemsController_lookup", {
1256
+ const raw = _chunk3MHHVC6Ccjs.asRecord.call(void 0,
1257
+ await _chunk3MHHVC6Ccjs.invokeWithRetry.call(void 0, this.config, this.http, "ContextItemsController_lookup", {
3349
1258
  jsonBody: body
3350
1259
  })
3351
1260
  );
3352
1261
  return parseLookupResponse(raw);
3353
1262
  } catch (error) {
3354
- if (error instanceof NotFoundError) return void 0;
1263
+ if (error instanceof _chunk3MHHVC6Ccjs.NotFoundError) return void 0;
3355
1264
  throw error;
3356
1265
  }
3357
1266
  }
3358
1267
  /**
3359
- * List values stored under a content key on a context item.
1268
+ * Page through the elements of an array field inside one context item's content.
1269
+ *
1270
+ * Each row is `{ index, value }`: the element's position in the array and the
1271
+ * element itself. A field that is not an array reads as one element; a missing
1272
+ * field as none. Rejects with a not-found error when the item does not exist,
1273
+ * you cannot read it, or its context type is not `contextType`.
3360
1274
  *
3361
1275
  * @param uid - Item uid.
3362
1276
  * @param contextType - Context type of the item.
3363
- * @param contentKeyPath - Dot path to the value field inside item content (e.g. `"enumValues"`).
3364
- * @param options.pageSize - Maximum items per page (default 25).
3365
- * @param options.pageToken - Opaque token from a previous page.
3366
- * @returns A page of value rows.
1277
+ * @param contentKeyPath - Dot path to the array inside item content (e.g. `"enumValues"`).
1278
+ * @param options.pageSize - Maximum elements per page (default 25).
1279
+ * @param options.pageToken - Opaque token from a previous page of the same item.
1280
+ * @returns A page of `{ index, value }` rows.
3367
1281
  *
3368
1282
  * @example
3369
1283
  * ```ts
@@ -3374,22 +1288,22 @@ var ContextItemsResource = class {
3374
1288
  * 'enumValues',
3375
1289
  * { pageSize: 25 },
3376
1290
  * )
3377
- * for (const row of page.items) console.log(row)
1291
+ * for (const row of page.items) console.log(row.index, row.value)
3378
1292
  * ```
3379
1293
  */
3380
1294
  listValues(uid, contextType, contentKeyPath, options = {}) {
3381
- const pageSize = options.pageSize ?? 25;
3382
- validatePageSize(pageSize, DEFAULT_MAX_PAGE_SIZE);
1295
+ const pageSize = _nullishCoalesce(options.pageSize, () => ( 25));
1296
+ _chunk3MHHVC6Ccjs.validatePageSize.call(void 0, pageSize, _chunk3MHHVC6Ccjs.DEFAULT_MAX_PAGE_SIZE);
3383
1297
  return this.listValuesPage(uid, contextType, contentKeyPath, pageSize, options.pageToken);
3384
1298
  }
3385
1299
  /**
3386
- * List values for a context item already loaded via {@link ContextItemsResource.list} or {@link ContextItemsResource.get}.
1300
+ * Page through an array field of a context item already loaded via {@link ContextItemsResource.list} or {@link ContextItemsResource.get}.
3387
1301
  *
3388
1302
  * @param item - Context item (uses `item.uid` and `item.contextType`).
3389
- * @param contentKeyPath - Dot path to the value field inside item content.
3390
- * @param options.pageSize - Maximum items per page (default 25).
3391
- * @param options.pageToken - Opaque token from a previous page.
3392
- * @returns A page of value rows.
1303
+ * @param contentKeyPath - Dot path to the array inside item content.
1304
+ * @param options.pageSize - Maximum elements per page (default 25).
1305
+ * @param options.pageToken - Opaque token from a previous page of the same item.
1306
+ * @returns A page of `{ index, value }` rows.
3393
1307
  *
3394
1308
  * @example
3395
1309
  * ```ts
@@ -3403,16 +1317,16 @@ var ContextItemsResource = class {
3403
1317
  return this.listValues(item.uid, item.contextType, contentKeyPath, options);
3404
1318
  }
3405
1319
  async listValuesPage(uid, contextType, contentKeyPath, pageSize, pageToken) {
3406
- const data = asRecord(
3407
- await invokeWithRetry(this.config, this.http, "ContextItemsController_listValues", {
1320
+ const data = _chunk3MHHVC6Ccjs.asRecord.call(void 0,
1321
+ await _chunk3MHHVC6Ccjs.invokeWithRetry.call(void 0, this.config, this.http, "ContextItemsController_listValues", {
3408
1322
  pathParams: { uid },
3409
- query: aipListParams(pageSize, pageToken, {
1323
+ query: _chunk3MHHVC6Ccjs.aipListParams.call(void 0, pageSize, pageToken, {
3410
1324
  contextType,
3411
1325
  contentKeyPath
3412
1326
  })
3413
1327
  })
3414
1328
  );
3415
- return buildAipPage(
1329
+ return _chunk3MHHVC6Ccjs.buildAipPage.call(void 0,
3416
1330
  data,
3417
1331
  "values",
3418
1332
  parseContextValueRow,
@@ -3426,7 +1340,7 @@ var ContextResource = class {
3426
1340
  /** @internal */
3427
1341
  constructor(http, config) {
3428
1342
  this.items = new ContextItemsResource(http, config);
3429
- this.customItems = new CustomContextItemsResource(http, config);
1343
+ this.customItems = new (0, _chunk3MHHVC6Ccjs.CustomContextItemsResource)(http, config);
3430
1344
  }
3431
1345
  };
3432
1346
 
@@ -3461,7 +1375,7 @@ var IngestedDataResource = class {
3461
1375
  * ```
3462
1376
  */
3463
1377
  async upload(options) {
3464
- const data = await invokeWithRetry(this.config, this.http, "IngestedDataController_upload", {
1378
+ const data = await _chunk3MHHVC6Ccjs.invokeWithRetry.call(void 0, this.config, this.http, "IngestedDataController_upload", {
3465
1379
  jsonBody: {
3466
1380
  integration_type: options.integrationType,
3467
1381
  request: options.request,
@@ -3489,8 +1403,8 @@ var ModusConversationsResourceBase = class {
3489
1403
  * @param threadId - Thread id from a conversation list or chat response.
3490
1404
  */
3491
1405
  async get(threadId) {
3492
- validateId(threadId, "thread_id");
3493
- const data = await invokeWithRetry(this.config, this.http, "ModusConversationsController_get", {
1406
+ _chunk3MHHVC6Ccjs.validateId.call(void 0, threadId, "thread_id");
1407
+ const data = await _chunk3MHHVC6Ccjs.invokeWithRetry.call(void 0, this.config, this.http, "ModusConversationsController_get", {
3494
1408
  pathParams: { threadId }
3495
1409
  });
3496
1410
  return data;
@@ -3501,7 +1415,7 @@ var ModusConversationsResourceBase = class {
3501
1415
  var ALLOWED_KINDS = /* @__PURE__ */ new Set(["all", "modus", "scopes"]);
3502
1416
  function listParams(pageSize, pageToken, kind, source, sourceRef) {
3503
1417
  if (kind !== void 0 && !ALLOWED_KINDS.has(kind)) {
3504
- throw new Error(
1418
+ throw new (0, _chunk3MHHVC6Ccjs.ValidationError)(
3505
1419
  `kind must be one of ${[...ALLOWED_KINDS].sort().join(", ")}, got ${JSON.stringify(kind)}`
3506
1420
  );
3507
1421
  }
@@ -3509,7 +1423,7 @@ function listParams(pageSize, pageToken, kind, source, sourceRef) {
3509
1423
  if (kind !== void 0) extra.kind = kind;
3510
1424
  if (source !== void 0) extra.source = source;
3511
1425
  if (sourceRef !== void 0) extra.sourceRef = sourceRef;
3512
- return aipListParams(pageSize, pageToken, extra);
1426
+ return _chunk3MHHVC6Ccjs.aipListParams.call(void 0, pageSize, pageToken, extra);
3513
1427
  }
3514
1428
  function parseListItem(raw) {
3515
1429
  return raw;
@@ -3535,17 +1449,17 @@ var ModusConversationsResource = class extends ModusConversationsResourceBase {
3535
1449
  * @returns Page of conversation list items.
3536
1450
  */
3537
1451
  list(options = {}) {
3538
- const pageSize = options.pageSize ?? 25;
3539
- validatePageSize(pageSize);
1452
+ const pageSize = _nullishCoalesce(options.pageSize, () => ( 25));
1453
+ _chunk3MHHVC6Ccjs.validatePageSize.call(void 0, pageSize);
3540
1454
  return this.listPage(pageSize, options.pageToken, options.kind, options.source, options.sourceRef);
3541
1455
  }
3542
1456
  async listPage(pageSize, pageToken, kind, source, sourceRef) {
3543
- const data = asRecord(
3544
- await invokeWithRetry(this.config, this.http, "ModusConversationsController_list", {
1457
+ const data = _chunk3MHHVC6Ccjs.asRecord.call(void 0,
1458
+ await _chunk3MHHVC6Ccjs.invokeWithRetry.call(void 0, this.config, this.http, "ModusConversationsController_list", {
3545
1459
  query: listParams(pageSize, pageToken, kind, source, sourceRef)
3546
1460
  })
3547
1461
  );
3548
- return buildAipPage(
1462
+ return _chunk3MHHVC6Ccjs.buildAipPage.call(void 0,
3549
1463
  data,
3550
1464
  "conversations",
3551
1465
  parseListItem,
@@ -3564,6 +1478,9 @@ var ModusResource = class {
3564
1478
  /**
3565
1479
  * Compose full-environment context for an intent without running chat.
3566
1480
  *
1481
+ * Runs on the agent host, like `chat`, so a compose may take up to 90 seconds; keep `timeoutMs`
1482
+ * above that. A compose still running at 90 seconds fails with `UPSTREAM_TIMEOUT` (504).
1483
+ *
3567
1484
  * @param message - Natural-language intent used to select context.
3568
1485
  * @param options.limit - Maximum context items to return. Omit to return all selected items.
3569
1486
  * @returns Composition metadata (counts / session id). Use `chat` for a reply.
@@ -3575,57 +1492,37 @@ var ModusResource = class {
3575
1492
  * ```
3576
1493
  */
3577
1494
  async getContext(message, options = {}) {
3578
- const data = await invokeWithRetry(this.config, this.http, "ModusContextController_compose", {
3579
- jsonBody: omitUndefined({ message, limit: options.limit })
1495
+ const data = await _chunk3MHHVC6Ccjs.invokeWithRetry.call(void 0, this.config, this.http, "ModusContextComposeController_compose", {
1496
+ jsonBody: _chunk3MHHVC6Ccjs.omitUndefined.call(void 0, { message, limit: options.limit })
3580
1497
  });
3581
1498
  return data;
3582
1499
  }
3583
1500
  /**
3584
- * Send a message to Modus and wait for the complete reply.
1501
+ * Chat with Modus, the org-wide assistant. The reply streams live from the
1502
+ * agent host: iterate `textStream()` for tokens, or `await` the result for
1503
+ * the final answer. Pass the returned `threadId` back to continue.
3585
1504
  *
3586
1505
  * @param message - User message text.
3587
- * @param options.model - Required model id (e.g. `"claude-sonnet-5"`).
1506
+ * @param options.model - Required model id (e.g. `"claude-sonnet-5.5"`).
3588
1507
  * @param options.threadId - Continue an existing conversation; omit to start new.
3589
- * @returns Chat result: `content`, `threadId` (for follow-ups), `runId`.
1508
+ * @returns A chat session — iterate it or `await` it for `content`, `threadId`, `runId`.
1509
+ * @throws {ModusError} When no agent host is known for a custom `baseUrl`.
3590
1510
  *
3591
1511
  * @example
3592
1512
  * ```ts
3593
1513
  * const result = await client.modus.chat('What tables describe revenue?', {
3594
- * model: 'claude-sonnet-5',
1514
+ * model: 'claude-sonnet-5.5',
3595
1515
  * })
3596
- * console.log(result.content, result.threadId)
3597
- * const follow = await client.modus.chat('Break that down by region.', {
3598
- * model: 'claude-sonnet-5',
1516
+ * console.log(result.content)
1517
+ * const follow = client.modus.chat('Break that down by region.', {
1518
+ * model: 'claude-sonnet-5.5',
3599
1519
  * threadId: result.threadId,
3600
1520
  * })
1521
+ * for await (const token of follow.textStream()) process.stdout.write(token)
3601
1522
  * ```
3602
1523
  */
3603
1524
  chat(message, options) {
3604
- return modusChatBuffered(this.http, message, options);
3605
- }
3606
- /**
3607
- * Stream a Modus reply token by token (SSE).
3608
- *
3609
- * The request starts when you consume `textStream()` or `eventStream()`.
3610
- *
3611
- * @param message - User message text.
3612
- * @param options.model - Required model id (e.g. `"claude-sonnet-5"`).
3613
- * @param options.threadId - Continue an existing conversation; omit to start new.
3614
- * @returns Chat stream — iterate `textStream()` for tokens.
3615
- *
3616
- * @example
3617
- * ```ts
3618
- * const stream = client.modus.chatStream('Summarize ARR in three bullets.', {
3619
- * model: 'claude-sonnet-5',
3620
- * })
3621
- * for await (const token of stream.textStream()) {
3622
- * process.stdout.write(token)
3623
- * }
3624
- * console.log(stream.getFinalResult().threadId)
3625
- * ```
3626
- */
3627
- chatStream(message, options) {
3628
- return modusChatStreamSession(this.http, this.config, message, options);
1525
+ return startChat(this.http, this.config, { kind: "modus" }, message, options);
3629
1526
  }
3630
1527
  };
3631
1528
 
@@ -3648,8 +1545,9 @@ var ScopesResourceBase = class {
3648
1545
  * @param options.pageToken - Opaque page token from a previous response's `nextPageToken`. Omit
3649
1546
  * for the first page.
3650
1547
  * @param options.search - Case-insensitive substring filter on scope name.
3651
- * @param options.view - Variation view. `active` reads deployed; `draft` reads the latest builder
3652
- * snapshot.
1548
+ * @param options.view - Variation view. `active` reads the deployed version, or the latest draft
1549
+ * when nothing is published. `draft` reads the latest builder snapshot. `published` reads only
1550
+ * the published version, and only scopes you can use.
3653
1551
  * @param options.managerId - Return only scopes supervised by this manager scope id.
3654
1552
  * @returns A page of scopes.
3655
1553
  *
@@ -3661,8 +1559,8 @@ var ScopesResourceBase = class {
3661
1559
  * ```
3662
1560
  */
3663
1561
  list(options = {}) {
3664
- const pageSize = options.pageSize ?? 25;
3665
- validatePageSize(pageSize);
1562
+ const pageSize = _nullishCoalesce(options.pageSize, () => ( 25));
1563
+ _chunk3MHHVC6Ccjs.validatePageSize.call(void 0, pageSize);
3666
1564
  return this.listPage(pageSize, options.pageToken, options.search, options.view, options.managerId);
3667
1565
  }
3668
1566
  async listPage(pageSize, pageToken, search, view, managerId) {
@@ -3670,12 +1568,12 @@ var ScopesResourceBase = class {
3670
1568
  if (search !== void 0) extra.search = search;
3671
1569
  if (view !== void 0) extra.view = view;
3672
1570
  if (managerId !== void 0) extra.managerId = managerId;
3673
- const data = asRecord(
3674
- await invokeWithRetry(this.config, this.http, "ScopesController_list", {
3675
- query: aipListParams(pageSize, pageToken, extra)
1571
+ const data = _chunk3MHHVC6Ccjs.asRecord.call(void 0,
1572
+ await _chunk3MHHVC6Ccjs.invokeWithRetry.call(void 0, this.config, this.http, "ScopesController_list", {
1573
+ query: _chunk3MHHVC6Ccjs.aipListParams.call(void 0, pageSize, pageToken, extra)
3676
1574
  })
3677
1575
  );
3678
- return buildAipPage(
1576
+ return _chunk3MHHVC6Ccjs.buildAipPage.call(void 0,
3679
1577
  data,
3680
1578
  "scopes",
3681
1579
  (raw) => raw,
@@ -3685,23 +1583,26 @@ var ScopesResourceBase = class {
3685
1583
  /**
3686
1584
  * Get a scope.
3687
1585
  *
3688
- * Returns a scope. `view=active` (default) returns the deployed version; `view=draft` returns the
3689
- * latest unpublished edits. Returns 404 if you cannot access the scope.
1586
+ * Returns a scope. `view=active` (default) is the deployed version, or the latest draft when
1587
+ * nothing is published. `view=draft` is the latest edits. `view=published` is only the published
1588
+ * version, and only if you can use the scope. Returns 404 if you cannot access it.
3690
1589
  *
3691
1590
  * **Requires:** `scopes:read`
3692
1591
  *
3693
1592
  * @param scopeId - Numeric scope id.
3694
- * @param options.view - Which variation snapshot to read. Defaults to `active`.
1593
+ * @param options.view - Which version to read. Defaults to `active`. `published` is only the
1594
+ * published version, and only if you can use the scope.
3695
1595
  *
3696
1596
  * @example
3697
1597
  * ```ts
3698
- * const scope = await client.scopes.get('revenue-analysis')
1598
+ * const [first] = (await client.scopes.list()).items
1599
+ * const scope = await client.scopes.get(first.id)
3699
1600
  * console.log(scope.name, scope.status)
3700
1601
  * ```
3701
1602
  */
3702
1603
  async get(scopeId, options = {}) {
3703
- validateId(scopeId, "scope_id");
3704
- const data = await invokeWithRetry(this.config, this.http, "ScopesController_get", {
1604
+ _chunk3MHHVC6Ccjs.validateId.call(void 0, scopeId, "scope_id");
1605
+ const data = await _chunk3MHHVC6Ccjs.invokeWithRetry.call(void 0, this.config, this.http, "ScopesController_get", {
3705
1606
  pathParams: { id: scopeId },
3706
1607
  query: { view: options.view }
3707
1608
  });
@@ -3709,110 +1610,12 @@ var ScopesResourceBase = class {
3709
1610
  }
3710
1611
  };
3711
1612
 
3712
- // src/_generated/resources/consumption/scopes/conversations.ts
3713
- var ScopesConversationsResourceBase = class {
3714
- /** @internal */
3715
- constructor(http, config, scopeId) {
3716
- this.http = http;
3717
- this.config = config;
3718
- this.scopeId = scopeId;
3719
- }
3720
- /**
3721
- * List scope conversations.
3722
- *
3723
- * Returns a page of conversation summaries (most recently updated first) for a scope. Use `id=0`
3724
- * for your cross-scope recent history. Pass `nextPageToken` as `pageToken` to fetch the next
3725
- * page.
3726
- *
3727
- * **Requires:** `scopes:read`
3728
- *
3729
- * @param options.pageSize - Items per page. Defaults to 25.
3730
- * @param options.pageToken - Opaque page token from a previous response's `nextPageToken`. Omit
3731
- * for the first page.
3732
- * @param options.source - Return only conversations started from this UI surface.
3733
- * @param options.sourceRef - Narrow `source` to one instance of that surface — for
3734
- * `dashboard_copilot` or `dashboard_assistant`, a dashboard id (both scope conversation history
3735
- * per dashboard). Requires `source`; sent alone it is a 422.
3736
- * @returns A page of conversations.
3737
- *
3738
- * @example
3739
- * ```ts
3740
- * for await (const row of (
3741
- * await client.scopes.conversations(scopeId).list({ pageSize: 10 })
3742
- * ).autoPagingIter()) {
3743
- * console.log(row.threadId, row.firstMessage, row.messageCount)
3744
- * }
3745
- * ```
3746
- */
3747
- list(options = {}) {
3748
- const pageSize = options.pageSize ?? 25;
3749
- validatePageSize(pageSize);
3750
- return this.listPage(pageSize, options.pageToken, options.source, options.sourceRef);
3751
- }
3752
- async listPage(pageSize, pageToken, source, sourceRef) {
3753
- validateId(this.scopeId, "scope_id");
3754
- const extra = {};
3755
- if (source !== void 0) extra.source = source;
3756
- if (sourceRef !== void 0) extra.sourceRef = sourceRef;
3757
- const data = asRecord(
3758
- await invokeWithRetry(this.config, this.http, "ScopeConversationsController_list", {
3759
- pathParams: { id: this.scopeId },
3760
- query: aipListParams(pageSize, pageToken, extra)
3761
- })
3762
- );
3763
- return buildAipPage(
3764
- data,
3765
- "conversations",
3766
- (raw) => raw,
3767
- (token) => this.listPage(pageSize, token, source, sourceRef)
3768
- );
3769
- }
3770
- };
3771
-
3772
- // src/resources/scopes/conversations.ts
3773
- function parseConversation(raw) {
3774
- return raw;
3775
- }
3776
- var ScopeConversationsResource = class extends ScopesConversationsResourceBase {
3777
- /**
3778
- * Retrieve a thread with full message history.
3779
- *
3780
- * @param threadId - Conversation thread id.
3781
- * @param options.messageLimit - Maximum messages to return (1–100).
3782
- * @param options.beforeMessageIndex - Return messages before this index (requires messageLimit).
3783
- * @returns Conversation with `messages` (`type`, `content`).
3784
- *
3785
- * @example
3786
- * ```ts
3787
- * const thread = await client.scopes.conversations(scopeId).get(row.threadId)
3788
- * for (const msg of thread.messages) {
3789
- * console.log(msg.type, String(msg.content).slice(0, 80))
3790
- * }
3791
- * ```
3792
- */
3793
- async get(threadId, options = {}) {
3794
- validateId(this.scopeId, "scope_id");
3795
- validateId(threadId, "thread_id");
3796
- if (options.beforeMessageIndex !== void 0 && options.messageLimit === void 0) {
3797
- throw new Error("beforeMessageIndex requires messageLimit");
3798
- }
3799
- const data = await invokeWithRetry(this.config, this.http, "ScopeConversationsController_get", {
3800
- pathParams: { id: this.scopeId, threadId },
3801
- query: {
3802
- messageLimit: options.messageLimit,
3803
- beforeMessageIndex: options.beforeMessageIndex
3804
- }
3805
- });
3806
- return parseConversation(data);
3807
- }
3808
- };
3809
-
3810
1613
  // src/resources/scopes.ts
3811
1614
  var ScopesResource = class extends ScopesResourceBase {
3812
1615
  /**
3813
1616
  * Return the conversations sub-resource scoped to `scopeId`.
3814
1617
  *
3815
- * @param scopeId - Scope numeric id or slug.
1618
+ * @param scopeId - Numeric scope id.
3816
1619
  * @returns Conversations resource for the scope.
3817
1620
  *
3818
1621
  * @example
@@ -3825,15 +1628,17 @@ var ScopesResource = class extends ScopesResourceBase {
3825
1628
  * ```
3826
1629
  */
3827
1630
  conversations(scopeId) {
3828
- return new ScopeConversationsResource(this.http, this.config, scopeId);
1631
+ return new (0, _chunk3MHHVC6Ccjs.ScopeConversationsResource)(this.http, this.config, scopeId);
3829
1632
  }
3830
1633
  /**
3831
1634
  * Compose context this scope would use for an intent, without running chat.
3832
1635
  *
3833
1636
  * Large bodies are bounded inline previews. This REST method does not expose file references
3834
- * or a full-content fetch operation.
1637
+ * or a full-content fetch operation. Runs on the agent host, like `chat`, so a compose may take
1638
+ * up to 90 seconds; keep `timeoutMs` above that. A compose still running at 90 seconds fails
1639
+ * with `UPSTREAM_TIMEOUT` (504).
3835
1640
  *
3836
- * @param scopeId - Scope numeric id or slug.
1641
+ * @param scopeId - Numeric scope id.
3837
1642
  * @param message - Natural-language intent used to select context.
3838
1643
  * @param options.limit - Maximum context items to return. Omit to return all selected items.
3839
1644
  * @returns Composed context text plus selection counts, item UIDs, and correlation session id.
@@ -3847,64 +1652,41 @@ var ScopesResource = class extends ScopesResourceBase {
3847
1652
  * ```
3848
1653
  */
3849
1654
  async getContext(scopeId, message, options = {}) {
3850
- validateId(scopeId, "scope_id");
3851
- const data = await invokeWithRetry(this.config, this.http, "ScopeContextController_compose", {
1655
+ _chunk3MHHVC6Ccjs.validateId.call(void 0, scopeId, "scope_id");
1656
+ const data = await _chunk3MHHVC6Ccjs.invokeWithRetry.call(void 0, this.config, this.http, "ScopeContextComposeController_compose", {
3852
1657
  pathParams: { id: scopeId },
3853
- jsonBody: omitUndefined({ message, limit: options.limit })
1658
+ jsonBody: _chunk3MHHVC6Ccjs.omitUndefined.call(void 0, { message, limit: options.limit })
3854
1659
  });
3855
1660
  return data;
3856
1661
  }
3857
1662
  /**
3858
- * Send a message to a published scope and wait for the complete reply.
1663
+ * Chat with a published scope. The reply streams live from the agent host:
1664
+ * iterate `textStream()` for tokens, or `await` the result for the final
1665
+ * answer. Pass the returned `threadId` back to continue the conversation.
3859
1666
  *
3860
1667
  * For the org-wide assistant use `client.modus.chat` instead.
3861
1668
  *
3862
- * @param scopeId - Scope numeric id or slug (must be active for chat).
1669
+ * @param scopeId - Numeric scope id (must be active for chat).
3863
1670
  * @param message - User message text.
3864
- * @param options.model - Required model id (e.g. `"claude-sonnet-5"`).
1671
+ * @param options.model - Required model id (e.g. `"claude-sonnet-5.5"`).
3865
1672
  * @param options.threadId - Continue an existing conversation; omit to start new.
3866
- * @returns Chat result: `content`, `threadId`, `runId`.
1673
+ * @returns A chat session — iterate it or `await` it for `content`, `threadId`, `runId`.
1674
+ * @throws {ModusError} When no agent host is known for a custom `baseUrl`.
3867
1675
  *
3868
1676
  * @example
3869
1677
  * ```ts
3870
- * const result = await client.scopes.chat(scopeId, 'What is our ARR trend?', {
3871
- * model: 'claude-sonnet-5',
3872
- * })
3873
- * console.log(result.content, result.threadId)
1678
+ * const chat = client.scopes.chat(scopeId, 'What is our ARR trend?', { model: 'claude-sonnet-5.5' })
1679
+ * for await (const token of chat.textStream()) process.stdout.write(token)
1680
+ * const { threadId } = await chat
3874
1681
  * const follow = await client.scopes.chat(scopeId, 'Break that down by segment.', {
3875
- * model: 'claude-sonnet-5',
3876
- * threadId: result.threadId,
1682
+ * model: 'claude-sonnet-5.5',
1683
+ * threadId,
3877
1684
  * })
1685
+ * console.log(follow.content)
3878
1686
  * ```
3879
1687
  */
3880
1688
  chat(scopeId, message, options) {
3881
- return chatBuffered(this.http, "scopes", scopeId, message, options);
3882
- }
3883
- /**
3884
- * Stream a scope reply token by token (SSE).
3885
- *
3886
- * The request starts when you consume `textStream()` or `eventStream()`.
3887
- *
3888
- * @param scopeId - Scope numeric id or slug.
3889
- * @param message - User message text.
3890
- * @param options.model - Required model id (e.g. `"claude-sonnet-5"`).
3891
- * @param options.threadId - Continue an existing conversation; omit to start new.
3892
- * @param options.version - `"published"` or `"draft"`.
3893
- * @returns Chat stream — iterate `textStream()` for tokens.
3894
- *
3895
- * @example
3896
- * ```ts
3897
- * const stream = client.scopes.chatStream(scopeId, 'Summarize in three bullets.', {
3898
- * model: 'claude-sonnet-5',
3899
- * })
3900
- * for await (const token of stream.textStream()) {
3901
- * process.stdout.write(token)
3902
- * }
3903
- * console.log(stream.getFinalResult().threadId)
3904
- * ```
3905
- */
3906
- chatStream(scopeId, message, options) {
3907
- return chatStreamSession(this.http, this.config, "scopes", scopeId, message, options);
1689
+ return startChat(this.http, this.config, { kind: "scopes", id: scopeId }, message, options);
3908
1690
  }
3909
1691
  };
3910
1692
 
@@ -3919,7 +1701,7 @@ function suggestionListParams(options) {
3919
1701
  pageSize: options.pageSize,
3920
1702
  pageToken: options.pageToken,
3921
1703
  scopeId: options.scopeId,
3922
- scopeIds: options.scopeIds?.join(",")
1704
+ scopeIds: _optionalChain([options, 'access', _24 => _24.scopeIds, 'optionalAccess', _25 => _25.join, 'call', _26 => _26(",")])
3923
1705
  };
3924
1706
  }
3925
1707
  var SuggestionsResource = class {
@@ -3934,21 +1716,24 @@ var SuggestionsResource = class {
3934
1716
  * @param options.pageSize - Maximum items per page (default 5, max 12).
3935
1717
  * @param options.pageToken - Opaque token from a previous page.
3936
1718
  * @param options.scopeId - Filter to a single scope.
3937
- * @param options.scopeIds - Filter to one or more scopes.
1719
+ * @param options.scopeIds - Filter to one or more scopes. An empty list throws; omit it for every scope.
3938
1720
  * @returns A page of suggested questions.
3939
1721
  */
3940
1722
  list(options = {}) {
3941
- const pageSize = options.pageSize ?? DEFAULT_SUGGESTIONS_PAGE_SIZE;
3942
- validatePageSize(pageSize, MAX_SUGGESTIONS_PAGE_SIZE);
1723
+ const pageSize = _nullishCoalesce(options.pageSize, () => ( DEFAULT_SUGGESTIONS_PAGE_SIZE));
1724
+ _chunk3MHHVC6Ccjs.validatePageSize.call(void 0, pageSize, MAX_SUGGESTIONS_PAGE_SIZE);
1725
+ if (_optionalChain([options, 'access', _27 => _27.scopeIds, 'optionalAccess', _28 => _28.length]) === 0) {
1726
+ throw new (0, _chunk3MHHVC6Ccjs.ValidationError)("scopeIds requires at least one id; omit it to list suggestions for every scope");
1727
+ }
3943
1728
  return this.listPage(pageSize, options.pageToken, options.scopeId, options.scopeIds);
3944
1729
  }
3945
1730
  async listPage(pageSize, pageToken, scopeId, scopeIds) {
3946
- const data = asRecord(
3947
- await invokeWithRetry(this.config, this.http, "SuggestionsController_listApproved", {
1731
+ const data = _chunk3MHHVC6Ccjs.asRecord.call(void 0,
1732
+ await _chunk3MHHVC6Ccjs.invokeWithRetry.call(void 0, this.config, this.http, "SuggestionsController_listApproved", {
3948
1733
  query: suggestionListParams({ pageSize, pageToken, scopeId, scopeIds })
3949
1734
  })
3950
1735
  );
3951
- return buildAipPage(
1736
+ return _chunk3MHHVC6Ccjs.buildAipPage.call(void 0,
3952
1737
  data,
3953
1738
  "suggestions",
3954
1739
  parseSuggestion,
@@ -3962,8 +1747,8 @@ var SuggestionsResource = class {
3962
1747
  * @param event - Event details, including `eventType` (`shown`, `clicked`, `dismissed`, or `submitted`).
3963
1748
  */
3964
1749
  async recordEvent(id, event) {
3965
- validateId(id, "id");
3966
- await invokeWithRetry(this.config, this.http, "SuggestionsController_recordEvent", {
1750
+ _chunk3MHHVC6Ccjs.validateId.call(void 0, id, "id");
1751
+ await _chunk3MHHVC6Ccjs.invokeWithRetry.call(void 0, this.config, this.http, "SuggestionsController_recordEvent", {
3967
1752
  pathParams: { id },
3968
1753
  jsonBody: event
3969
1754
  });
@@ -3971,7 +1756,7 @@ var SuggestionsResource = class {
3971
1756
  };
3972
1757
 
3973
1758
  // src/index.ts
3974
- var Modus = class extends ModusClientBase {
1759
+ var Modus = class extends _chunk3MHHVC6Ccjs.ModusClientBase {
3975
1760
  constructor(options = {}) {
3976
1761
  super(options);
3977
1762
  this.scopes = new ScopesResource(this.http, this.config);
@@ -3983,27 +1768,27 @@ var Modus = class extends ModusClientBase {
3983
1768
  this.ingestedData = new IngestedDataResource(this.http, this.config);
3984
1769
  }
3985
1770
  };
3986
- // Annotate the CommonJS export names for ESM import in node:
3987
- 0 && (module.exports = {
3988
- APIConnectionError,
3989
- AgentType,
3990
- AuthenticationError,
3991
- ChatStream,
3992
- ConflictError,
3993
- InternalServerError,
3994
- Modus,
3995
- ModusError,
3996
- NotFoundError,
3997
- OPERATIONS,
3998
- Page,
3999
- PermissionDeniedError,
4000
- RateLimitError,
4001
- RunCancelledError,
4002
- StreamTimeoutError,
4003
- UnprocessableError,
4004
- ValidationError,
4005
- WorkflowType,
4006
- conversationScopeId,
4007
- conversationSkillId
4008
- });
1771
+
1772
+
1773
+
1774
+
1775
+
1776
+
1777
+
1778
+
1779
+
1780
+
1781
+
1782
+
1783
+
1784
+
1785
+
1786
+
1787
+
1788
+
1789
+
1790
+
1791
+
1792
+
1793
+ exports.APIConnectionError = _chunk3MHHVC6Ccjs.APIConnectionError; exports.AgentType = AgentType; exports.AuthenticationError = _chunk3MHHVC6Ccjs.AuthenticationError; exports.BadRequestError = _chunk3MHHVC6Ccjs.BadRequestError; exports.ChatSession = ChatSession; exports.ConflictError = _chunk3MHHVC6Ccjs.ConflictError; exports.InternalServerError = _chunk3MHHVC6Ccjs.InternalServerError; exports.Modus = Modus; exports.ModusError = _chunk3MHHVC6Ccjs.ModusError; exports.NotFoundError = _chunk3MHHVC6Ccjs.NotFoundError; exports.OPERATIONS = _chunk3MHHVC6Ccjs.OPERATIONS; exports.Page = _chunk3MHHVC6Ccjs.Page; exports.PermissionDeniedError = _chunk3MHHVC6Ccjs.PermissionDeniedError; exports.RateLimitError = _chunk3MHHVC6Ccjs.RateLimitError; exports.RunCancelledError = _chunk3MHHVC6Ccjs.RunCancelledError; exports.StreamTimeoutError = _chunk3MHHVC6Ccjs.StreamTimeoutError; exports.UnprocessableError = _chunk3MHHVC6Ccjs.UnprocessableError; exports.ValidationError = _chunk3MHHVC6Ccjs.ValidationError; exports.WorkflowType = WorkflowType; exports.conversationScopeId = conversationScopeId; exports.conversationSkillId = conversationSkillId;
4009
1794
  //# sourceMappingURL=index.cjs.map