@getmodus/sdk 0.3.0 → 0.4.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.js CHANGED
@@ -29,7 +29,7 @@ import {
29
29
  validateChatModel,
30
30
  validateId,
31
31
  validatePageSize
32
- } from "./chunk-D3NU2M6B.js";
32
+ } from "./chunk-I56O44TR.js";
33
33
 
34
34
  // src/_agent_run_request.ts
35
35
  import { randomUUID } from "crypto";
@@ -184,11 +184,27 @@ var ChatStream = class {
184
184
  this.baseUrl = baseUrl;
185
185
  this.textParts = [];
186
186
  }
187
+ /**
188
+ * Async iterable of assistant text token chunks as they arrive.
189
+ *
190
+ * @returns An async generator yielding partial text strings.
191
+ * @throws {ModusError} When the stream emits an error event.
192
+ * @throws {RunCancelledError} When the run is cancelled.
193
+ * @throws {StreamTimeoutError} When the stream times out.
194
+ */
187
195
  async *textStream() {
188
196
  for await (const event of this.events(false)) {
189
197
  if (event.type === "token") yield event.content;
190
198
  }
191
199
  }
200
+ /**
201
+ * Async iterable of structured run events (tokens, tool calls, done, and so on).
202
+ *
203
+ * @returns An async generator yielding {@link RunEvent} objects.
204
+ * @throws {ModusError} When the stream emits an error event.
205
+ * @throws {RunCancelledError} When the run is cancelled.
206
+ * @throws {StreamTimeoutError} When the stream times out.
207
+ */
192
208
  async *eventStream() {
193
209
  yield* this.events(true);
194
210
  }
@@ -217,6 +233,15 @@ var ChatStream = class {
217
233
  }
218
234
  }
219
235
  }
236
+ /**
237
+ * Final chat result after the stream completes.
238
+ *
239
+ * Call only after fully consuming {@link ChatStream.textStream} or
240
+ * {@link ChatStream.eventStream}.
241
+ *
242
+ * @returns The assembled assistant reply, thread id, and run id.
243
+ * @throws {ModusError} When called before the stream finishes with a done event.
244
+ */
220
245
  getFinalResult() {
221
246
  if (this.final === void 0) {
222
247
  throw new ModusError(
@@ -348,10 +373,23 @@ function makeAgentRunStream(runId, events) {
348
373
  };
349
374
  }
350
375
  var WorkflowRunsResource = class {
376
+ /** @internal */
351
377
  constructor(http, config) {
352
378
  this.http = http;
353
379
  this.config = config;
354
380
  }
381
+ /**
382
+ * List runs for a workflow.
383
+ *
384
+ * @param workflowId - Workflow id or slug.
385
+ * @param options.pageSize - Maximum items per page (default 25, max 100).
386
+ * @param options.pageToken - Opaque token from a previous page.
387
+ * @param options.status - Filter by run status.
388
+ * @param options.timeframe - Filter by recency (`last_hour`, `last_day`, or `last_week`).
389
+ * @param options.approvalScope - Filter approval-related runs (`mine` or `all`).
390
+ * @param options.search - Free-text search filter.
391
+ * @returns A page of run summaries.
392
+ */
355
393
  list(workflowId, options = {}) {
356
394
  validateId(workflowId, "workflow_id");
357
395
  const pageSize = options.pageSize ?? 25;
@@ -386,6 +424,15 @@ var WorkflowRunsResource = class {
386
424
  (token) => this.listPage(workflowId, pageSize, token, filters)
387
425
  );
388
426
  }
427
+ /**
428
+ * Retrieve a workflow run by id.
429
+ *
430
+ * @param workflowId - Workflow id or slug the run belongs to.
431
+ * @param runId - Run id.
432
+ * @param options.temporalRunId - Optional internal execution id when disambiguating retries.
433
+ * @returns Run details including status and output.
434
+ * @throws {NotFoundError} When the run does not exist.
435
+ */
389
436
  async get(workflowId, runId, options = {}) {
390
437
  validateId(workflowId, "workflow_id");
391
438
  if (!runId.trim()) throw new Error("run_id must be a non-empty string");
@@ -396,21 +443,69 @@ var WorkflowRunsResource = class {
396
443
  });
397
444
  return parseRun(data);
398
445
  }
446
+ /**
447
+ * Start a workflow run and stream run events.
448
+ *
449
+ * @param workflowId - Workflow id or slug to run.
450
+ * @param body - Run body (`message`, optional `sessionId`, optional `version` as `published` or `draft`).
451
+ * @param options.idempotencyKey - Client-supplied idempotency key; defaults to `body.runId` or a new uuid.
452
+ * @returns A stream of run events (tokens, completion, errors, and related signals).
453
+ *
454
+ * @example
455
+ * ```ts
456
+ * const stream = client.workflows.runs.create(workflowId, {
457
+ * message: 'Summarize yesterday\'s sales',
458
+ * sessionId: 'conv-abc',
459
+ * })
460
+ * for await (const event of stream) {
461
+ * if (event.type === 'token') process.stdout.write(event.content)
462
+ * if (event.type === 'done') break
463
+ * }
464
+ * ```
465
+ */
399
466
  create(workflowId, body, options = {}) {
400
467
  validateId(workflowId, "workflow_id");
401
468
  return this.createRun("WorkflowRunsController_create", body, { id: workflowId }, options);
402
469
  }
470
+ /**
471
+ * Start a scope run and stream run events.
472
+ *
473
+ * @param scopeId - Scope id to run.
474
+ * @param body - Run body (`message`, optional `sessionId`, optional `version` as `published` or `draft`).
475
+ * @param options.idempotencyKey - Client-supplied idempotency key; defaults to `body.runId` or a new uuid.
476
+ * @returns A stream of run events.
477
+ */
403
478
  createScope(scopeId, body, options = {}) {
404
479
  validateId(scopeId, "scope_id");
405
480
  return this.createRun("ScopeRunsController_create", body, { id: scopeId }, options);
406
481
  }
482
+ /**
483
+ * Start a Modus assistant run and stream run events.
484
+ *
485
+ * @param body - Run body (`message`, optional `sessionId`, optional `subordinateSkillIds` to narrow context).
486
+ * @param options.idempotencyKey - Client-supplied idempotency key; defaults to `body.runId` or a new uuid.
487
+ * @returns A stream of run events.
488
+ */
407
489
  createModus(body, options = {}) {
408
490
  return this.createRun("ModusRunsController_create", body, {}, options);
409
491
  }
492
+ /**
493
+ * Resume an interrupted run and stream run events.
494
+ *
495
+ * @param runId - Run id to resume.
496
+ * @param body - Resume body (`message`, `sessionId`, and `decision`: `approve` / `deny` / `connected` / `cancelled`).
497
+ * @param options.idempotencyKey - Client-supplied idempotency key; defaults to `body.runId` or a new uuid.
498
+ * @returns A stream of run events.
499
+ */
410
500
  resume(runId, body, options = {}) {
411
501
  validateId(runId, "run_id");
412
502
  return this.createRun("ResumeRunsController_create", body, { runId }, options);
413
503
  }
504
+ /**
505
+ * Cancel a run that is still in progress.
506
+ *
507
+ * @param runId - Run id to cancel.
508
+ */
414
509
  async cancel(runId) {
415
510
  validateId(runId, "run_id");
416
511
  await invokeWithRetry(this.config, this.http, "RunLifecycleController_cancel", {
@@ -418,12 +513,23 @@ var WorkflowRunsResource = class {
418
513
  jsonBody: {}
419
514
  });
420
515
  }
516
+ /**
517
+ * Fetch stored run events for a run.
518
+ *
519
+ * @param runId - Run id.
520
+ * @returns Run event history for replay or inspection.
521
+ */
421
522
  async events(runId) {
422
523
  validateId(runId, "run_id");
423
524
  return invokeWithRetry(this.config, this.http, "RunLifecycleController_events", {
424
525
  pathParams: { runId }
425
526
  });
426
527
  }
528
+ /**
529
+ * Request a graceful stop for a running execution.
530
+ *
531
+ * @param runId - Run id to interrupt.
532
+ */
427
533
  async interrupt(runId) {
428
534
  validateId(runId, "run_id");
429
535
  await invokeWithRetry(this.config, this.http, "RunLifecycleController_interrupt", {
@@ -431,6 +537,11 @@ var WorkflowRunsResource = class {
431
537
  jsonBody: {}
432
538
  });
433
539
  }
540
+ /**
541
+ * Move a queued run back into an editable state before it starts.
542
+ *
543
+ * @param runId - Queued run id.
544
+ */
434
545
  async editQueued(runId) {
435
546
  validateId(runId, "run_id");
436
547
  await invokeWithRetry(this.config, this.http, "RunLifecycleController_editQueued", {
@@ -438,6 +549,13 @@ var WorkflowRunsResource = class {
438
549
  jsonBody: {}
439
550
  });
440
551
  }
552
+ /**
553
+ * List active conversation runs across the organization.
554
+ *
555
+ * @param options.pageSize - Maximum items per page (default 50, max 100).
556
+ * @param options.pageToken - Opaque token from a previous page.
557
+ * @returns A page of active runs with session and status metadata.
558
+ */
441
559
  active(options = {}) {
442
560
  const pageSize = options.pageSize ?? 50;
443
561
  validatePageSize(pageSize, RUNS_MAX_PAGE_SIZE);
@@ -451,6 +569,13 @@ var WorkflowRunsResource = class {
451
569
  (token) => this.activePage(pageSize, token)
452
570
  );
453
571
  }
572
+ /**
573
+ * Look up active runs for specific conversation sessions.
574
+ *
575
+ * @param sessionIds - Up to 100 session ids.
576
+ * @returns Active runs matching any of the given sessions.
577
+ * @throws {Error} When more than 100 session ids are provided.
578
+ */
454
579
  async activeBySession(sessionIds) {
455
580
  const uniqueSessionIds = [...new Set(sessionIds.map((id) => id.trim()).filter(Boolean))];
456
581
  if (uniqueSessionIds.length > 100) {
@@ -462,6 +587,21 @@ var WorkflowRunsResource = class {
462
587
  })
463
588
  );
464
589
  }
590
+ /**
591
+ * Reconnect to an in-progress run and stream run events.
592
+ *
593
+ * @param runId - Run id to follow.
594
+ * @param options.lastEventId - Resume after this event id when catching up.
595
+ * @returns A stream of run events from the current execution point.
596
+ *
597
+ * @example
598
+ * ```ts
599
+ * const stream = client.workflows.runs.stream(runId, { lastEventId: checkpoint })
600
+ * for await (const event of stream) {
601
+ * if (event.type === 'token') process.stdout.write(event.content)
602
+ * }
603
+ * ```
604
+ */
465
605
  stream(runId, options = {}) {
466
606
  validateId(runId, "run_id");
467
607
  const op = getOperation("RunLifecycleController_stream");
@@ -498,10 +638,18 @@ function randomRunId2() {
498
638
  return randomUUID3();
499
639
  }
500
640
  var AgentWorkflowActionsResource = class {
641
+ /** @internal */
501
642
  constructor(http, config) {
502
643
  this.http = http;
503
644
  this.config = config;
504
645
  }
646
+ /**
647
+ * Execute a workflow action and stream run events.
648
+ *
649
+ * @param body - Action body (`organizationId`, `sessionId`, `workflowAction`, optional `previousOutputs`).
650
+ * @param options.idempotencyKey - Client-supplied idempotency key; defaults to `body.runId` or a new uuid.
651
+ * @returns A stream of run events for the action execution.
652
+ */
505
653
  execute(body, options = {}) {
506
654
  const runId = options.idempotencyKey?.trim() || body.runId?.trim() || randomRunId2();
507
655
  const op = getOperation("WorkflowActionsController_execute");
@@ -512,6 +660,11 @@ var AgentWorkflowActionsResource = class {
512
660
  });
513
661
  return makeAgentRunStream(runId, this.parseEvents(lines));
514
662
  }
663
+ /**
664
+ * Cancel a workflow action run.
665
+ *
666
+ * @param runId - Action run id to cancel.
667
+ */
515
668
  async cancel(runId) {
516
669
  validateId(runId, "run_id");
517
670
  await invokeWithRetry(this.config, this.http, "WorkflowActionsController_cancel", {
@@ -537,12 +690,24 @@ function parseWorkflow(raw) {
537
690
  return raw;
538
691
  }
539
692
  var WorkflowsResource = class {
693
+ /** @internal */
540
694
  constructor(http, config) {
541
695
  this.http = http;
542
696
  this.config = config;
543
697
  this.runs = new WorkflowRunsResource(http, config);
544
698
  this.workflowActions = new AgentWorkflowActionsResource(http, config);
545
699
  }
700
+ /**
701
+ * List workflows.
702
+ *
703
+ * @param options.pageSize - Maximum items per page (default 25).
704
+ * @param options.pageToken - Opaque token from a previous page.
705
+ * @param options.search - Free-text search filter.
706
+ * @param options.type - Workflow kind: `"task"` or `"workflow"`.
707
+ * @param options.view - Which saved version to return (`active` or `draft`).
708
+ * @param options.includeVariation - Include variation metadata when supported.
709
+ * @returns A page of workflows.
710
+ */
546
711
  list(options = {}) {
547
712
  const pageSize = options.pageSize ?? 25;
548
713
  validatePageSize(pageSize);
@@ -575,6 +740,15 @@ var WorkflowsResource = class {
575
740
  (token) => this.listPage(pageSize, token, search, type, view, includeVariation)
576
741
  );
577
742
  }
743
+ /**
744
+ * Retrieve a workflow by ID or slug.
745
+ *
746
+ * @param workflowId - Numeric id or slug.
747
+ * @param options.view - Which saved version to return (`active` or `draft`).
748
+ * @param options.includeVariation - Include variation metadata when supported.
749
+ * @returns The workflow.
750
+ * @throws {NotFoundError} When no workflow matches the id or slug.
751
+ */
578
752
  async get(workflowId, options = {}) {
579
753
  validateId(workflowId, "workflow_id");
580
754
  const query = {};
@@ -600,10 +774,19 @@ function parseConnection(raw) {
600
774
  return raw;
601
775
  }
602
776
  var ConnectionsResource = class {
777
+ /** @internal */
603
778
  constructor(http, config) {
604
779
  this.http = http;
605
780
  this.config = config;
606
781
  }
782
+ /**
783
+ * List integration connections.
784
+ *
785
+ * @param options.pageSize - Maximum items per page (default 25).
786
+ * @param options.pageToken - Opaque token from a previous page.
787
+ * @param options.type - Integration category; exact match filter.
788
+ * @returns A page of connections.
789
+ */
607
790
  list(options = {}) {
608
791
  const pageSize = options.pageSize ?? 25;
609
792
  validatePageSize(pageSize);
@@ -622,6 +805,16 @@ var ConnectionsResource = class {
622
805
  (token) => this.listPage(pageSize, token, type)
623
806
  );
624
807
  }
808
+ /**
809
+ * Find the first connection whose name matches (case-insensitive).
810
+ *
811
+ * Pages through {@link ConnectionsResource.list} until a match is found.
812
+ *
813
+ * @param options.name - Connection name to search for.
814
+ * @param options.type - Optional integration category filter.
815
+ * @param options.pageSize - Page size when scanning (default 25).
816
+ * @returns The matching connection, or `undefined` if none is found.
817
+ */
625
818
  async find(options) {
626
819
  const pageSize = options.pageSize ?? 25;
627
820
  validatePageSize(pageSize);
@@ -656,10 +849,19 @@ function parseLookupResponse(raw) {
656
849
  return item;
657
850
  }
658
851
  var ContextItemsResource = class {
852
+ /** @internal */
659
853
  constructor(http, config) {
660
854
  this.http = http;
661
855
  this.config = config;
662
856
  }
857
+ /**
858
+ * List knowledge-base items.
859
+ *
860
+ * @param options.pageSize - Maximum items per page (default 25).
861
+ * @param options.pageToken - Opaque token from a previous page.
862
+ * @param options.contextType - Filter to a single context type.
863
+ * @returns A page of context items.
864
+ */
663
865
  list(options = {}) {
664
866
  const pageSize = options.pageSize ?? 25;
665
867
  validatePageSize(pageSize);
@@ -678,12 +880,27 @@ var ContextItemsResource = class {
678
880
  (token) => this.listPage(pageSize, token, contextType)
679
881
  );
680
882
  }
883
+ /**
884
+ * Retrieve a knowledge-base item by uid.
885
+ *
886
+ * @param uid - Item uid.
887
+ * @returns The context item.
888
+ * @throws {NotFoundError} When no item matches the uid.
889
+ */
681
890
  async get(uid) {
682
891
  const data = await invokeWithRetry(this.config, this.http, "ContextItemsController_get", {
683
892
  pathParams: { uid }
684
893
  });
685
894
  return parseContextItem(data);
686
895
  }
896
+ /**
897
+ * Look up a knowledge-base item by type and data path.
898
+ *
899
+ * @param options.contextType - Context type to match.
900
+ * @param options.dataPath - Hierarchical path segments that identify the item.
901
+ * @param options.contentProjection - Optional fields to include from item content.
902
+ * @returns The matching row, or `undefined` when no item is found (404).
903
+ */
687
904
  async lookup(options) {
688
905
  const body = omitUndefined({
689
906
  contextType: options.contextType,
@@ -702,11 +919,30 @@ var ContextItemsResource = class {
702
919
  throw error;
703
920
  }
704
921
  }
922
+ /**
923
+ * List values stored under a content key on a context item.
924
+ *
925
+ * @param uid - Item uid.
926
+ * @param contextType - Context type of the item.
927
+ * @param contentKeyPath - Dot path to the value field inside item content.
928
+ * @param options.pageSize - Maximum items per page (default 25).
929
+ * @param options.pageToken - Opaque token from a previous page.
930
+ * @returns A page of value rows.
931
+ */
705
932
  listValues(uid, contextType, contentKeyPath, options = {}) {
706
933
  const pageSize = options.pageSize ?? 25;
707
934
  validatePageSize(pageSize, DEFAULT_MAX_PAGE_SIZE);
708
935
  return this.listValuesPage(uid, contextType, contentKeyPath, pageSize, options.pageToken);
709
936
  }
937
+ /**
938
+ * List values for a context item already loaded via {@link ContextItemsResource.list} or {@link ContextItemsResource.get}.
939
+ *
940
+ * @param item - Context item (uses `item.uid` and `item.contextType`).
941
+ * @param contentKeyPath - Dot path to the value field inside item content.
942
+ * @param options.pageSize - Maximum items per page (default 25).
943
+ * @param options.pageToken - Opaque token from a previous page.
944
+ * @returns A page of value rows.
945
+ */
710
946
  listValuesFor(item, contentKeyPath, options = {}) {
711
947
  return this.listValues(item.uid, item.contextType, contentKeyPath, options);
712
948
  }
@@ -731,6 +967,7 @@ var ContextItemsResource = class {
731
967
 
732
968
  // src/resources/context/context.ts
733
969
  var ContextResource = class {
970
+ /** @internal */
734
971
  constructor(http, config) {
735
972
  this.items = new ContextItemsResource(http, config);
736
973
  this.customItems = new CustomContextItemsResource(http, config);
@@ -760,6 +997,14 @@ var ModusConversationsResource = class {
760
997
  this.http = http;
761
998
  this.config = config;
762
999
  }
1000
+ /**
1001
+ * List conversations.
1002
+ *
1003
+ * @param options.pageSize - Items per page (default 25).
1004
+ * @param options.pageToken - Opaque token from a previous page.
1005
+ * @param options.kind - `"modus"`, `"scopes"`, or `"all"`.
1006
+ * @returns Page of conversation list items.
1007
+ */
763
1008
  list(options = {}) {
764
1009
  const pageSize = options.pageSize ?? 25;
765
1010
  validatePageSize(pageSize);
@@ -778,6 +1023,12 @@ var ModusConversationsResource = class {
778
1023
  (token) => this.listPage(pageSize, token, kind)
779
1024
  );
780
1025
  }
1026
+ /**
1027
+ * Retrieve a conversation thread with full message history.
1028
+ *
1029
+ * @param threadId - Conversation thread id.
1030
+ * @returns Conversation with messages.
1031
+ */
781
1032
  async get(threadId) {
782
1033
  validateId(threadId, "thread_id");
783
1034
  const data = await invokeWithRetry(this.config, this.http, "ModusConversationsController_get", {
@@ -794,15 +1045,44 @@ var ModusResource = class {
794
1045
  this.config = config;
795
1046
  this.conversations = new ModusConversationsResource(http, config);
796
1047
  }
1048
+ /**
1049
+ * Return composed full-environment context for an intent, without running chat.
1050
+ *
1051
+ * @param message - User intent or question to compose context for.
1052
+ * @param options.limit - Optional cap on structured fallback items.
1053
+ * @returns Composed Modus context.
1054
+ */
797
1055
  async getContext(message, options = {}) {
798
1056
  const data = await invokeWithRetry(this.config, this.http, "ModusContextController_compose", {
799
1057
  jsonBody: omitUndefined({ message, limit: options.limit })
800
1058
  });
801
1059
  return data;
802
1060
  }
1061
+ /**
1062
+ * Send a message to Modus (org-wide assistant) and get the complete reply.
1063
+ *
1064
+ * @param message - Message to send.
1065
+ * @param options.model - Required model id (e.g. `"claude-sonnet-5"`).
1066
+ * @param options.threadId - Continue an existing conversation.
1067
+ * @returns Chat result with content and threadId.
1068
+ *
1069
+ * @example
1070
+ * ```ts
1071
+ * const result = await client.modus.chat('What tables describe revenue?', { model: 'claude-sonnet-5' })
1072
+ * console.log(result.content, result.threadId)
1073
+ * ```
1074
+ */
803
1075
  chat(message, options) {
804
1076
  return modusChatBuffered(this.http, message, options);
805
1077
  }
1078
+ /**
1079
+ * Stream a Modus reply token by token.
1080
+ *
1081
+ * @param message - Message to send.
1082
+ * @param options.model - Required model id (e.g. `"claude-sonnet-5"`).
1083
+ * @param options.threadId - Continue an existing conversation.
1084
+ * @returns Chat stream.
1085
+ */
806
1086
  chatStream(message, options) {
807
1087
  return modusChatStreamSession(this.http, this.config, message, options);
808
1088
  }
@@ -820,13 +1100,30 @@ function parseScope(raw) {
820
1100
  return raw;
821
1101
  }
822
1102
  var ScopesResource = class {
1103
+ /** @internal */
823
1104
  constructor(http, config) {
824
1105
  this.http = http;
825
1106
  this.config = config;
826
1107
  }
1108
+ /**
1109
+ * Return the conversations sub-resource scoped to `scopeId`.
1110
+ *
1111
+ * @param scopeId - Scope numeric id or slug.
1112
+ * @returns Conversations resource for the scope.
1113
+ */
827
1114
  conversations(scopeId) {
828
1115
  return new ScopeConversationsResource(this.http, this.config, scopeId);
829
1116
  }
1117
+ /**
1118
+ * List scopes in the organisation.
1119
+ *
1120
+ * @param options.pageSize - Items per page (default 25).
1121
+ * @param options.pageToken - Opaque token from a previous page.
1122
+ * @param options.search - Case-insensitive substring filter on the scope name.
1123
+ * @param options.view - `"active"` (deployed) or `"draft"`.
1124
+ * @param options.managerId - Only scopes supervised by this manager scope id.
1125
+ * @returns Page of scopes.
1126
+ */
830
1127
  list(options = {}) {
831
1128
  const pageSize = options.pageSize ?? 25;
832
1129
  validatePageSize(pageSize);
@@ -851,6 +1148,14 @@ var ScopesResource = class {
851
1148
  (token) => this.listPage(pageSize, token, search, view, managerId)
852
1149
  );
853
1150
  }
1151
+ /**
1152
+ * Retrieve a scope by ID or slug.
1153
+ *
1154
+ * @param scopeId - Scope numeric id or slug.
1155
+ * @param options.view - `"active"` (deployed) or `"draft"`.
1156
+ * @throws {NotFoundError} When no scope matches the id or slug.
1157
+ * @returns Scope.
1158
+ */
854
1159
  async get(scopeId, options = {}) {
855
1160
  validateId(scopeId, "scope_id");
856
1161
  const query = options.view !== void 0 ? { view: options.view } : void 0;
@@ -860,6 +1165,14 @@ var ScopesResource = class {
860
1165
  });
861
1166
  return parseScope(data);
862
1167
  }
1168
+ /**
1169
+ * Return composed context Modus would use for a scope query, without running chat.
1170
+ *
1171
+ * @param scopeId - Scope numeric id or slug.
1172
+ * @param message - User intent or question to compose context for.
1173
+ * @param options.limit - Optional cap on structured fallback items.
1174
+ * @returns Composed scope context.
1175
+ */
863
1176
  async getContext(scopeId, message, options = {}) {
864
1177
  validateId(scopeId, "scope_id");
865
1178
  const data = await invokeWithRetry(this.config, this.http, "ScopeContextController_compose", {
@@ -868,9 +1181,34 @@ var ScopesResource = class {
868
1181
  });
869
1182
  return data;
870
1183
  }
1184
+ /**
1185
+ * Send a message to a scope and get the complete reply.
1186
+ *
1187
+ * @param scopeId - Scope numeric id or slug.
1188
+ * @param message - Message to send.
1189
+ * @param options.model - Required model id (e.g. `"claude-sonnet-5"`).
1190
+ * @param options.threadId - Continue an existing conversation.
1191
+ * @returns Chat result with content and threadId.
1192
+ *
1193
+ * @example
1194
+ * ```ts
1195
+ * const result = await client.scopes.chat(scopeId, 'Hello', { model: 'claude-sonnet-5' })
1196
+ * console.log(result.content, result.threadId)
1197
+ * ```
1198
+ */
871
1199
  chat(scopeId, message, options) {
872
1200
  return chatBuffered(this.http, "scopes", scopeId, message, options);
873
1201
  }
1202
+ /**
1203
+ * Stream a scope reply token by token.
1204
+ *
1205
+ * @param scopeId - Scope numeric id or slug.
1206
+ * @param message - Message to send.
1207
+ * @param options.model - Required model id (e.g. `"claude-sonnet-5"`).
1208
+ * @param options.threadId - Continue an existing conversation.
1209
+ * @param options.version - `"published"` or `"draft"`.
1210
+ * @returns Chat stream.
1211
+ */
874
1212
  chatStream(scopeId, message, options) {
875
1213
  return chatStreamSession(this.http, this.config, "scopes", scopeId, message, options);
876
1214
  }
@@ -891,10 +1229,20 @@ function suggestionListParams(options) {
891
1229
  };
892
1230
  }
893
1231
  var SuggestionsResource = class {
1232
+ /** @internal */
894
1233
  constructor(http, config) {
895
1234
  this.http = http;
896
1235
  this.config = config;
897
1236
  }
1237
+ /**
1238
+ * List approved suggested questions.
1239
+ *
1240
+ * @param options.pageSize - Maximum items per page (default 5, max 12).
1241
+ * @param options.pageToken - Opaque token from a previous page.
1242
+ * @param options.scopeId - Filter to a single scope.
1243
+ * @param options.scopeIds - Filter to one or more scopes.
1244
+ * @returns A page of suggested questions.
1245
+ */
898
1246
  list(options = {}) {
899
1247
  const pageSize = options.pageSize ?? DEFAULT_SUGGESTIONS_PAGE_SIZE;
900
1248
  validatePageSize(pageSize, MAX_SUGGESTIONS_PAGE_SIZE);
@@ -913,6 +1261,12 @@ var SuggestionsResource = class {
913
1261
  (token) => this.listPage(pageSize, token, scopeId, scopeIds)
914
1262
  );
915
1263
  }
1264
+ /**
1265
+ * Record that a suggested question was shown, clicked, dismissed, or submitted.
1266
+ *
1267
+ * @param id - Suggestion id.
1268
+ * @param event - Event details, including `eventType` (`shown`, `clicked`, `dismissed`, or `submitted`).
1269
+ */
916
1270
  async recordEvent(id, event) {
917
1271
  validateId(id, "id");
918
1272
  await invokeWithRetry(this.config, this.http, "SuggestionsController_recordEvent", {