@getmodus/sdk 0.6.0 → 0.8.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/CHANGELOG.md +128 -4
- package/README.md +28 -1
- package/dist/{chunk-HEHHN4D6.js → chunk-GFS7CNON.js} +418 -26
- package/dist/chunk-GFS7CNON.js.map +1 -0
- package/dist/{conversations-BRg8gEKX.d.cts → conversations-COA6NW8I.d.cts} +11987 -3565
- package/dist/{conversations-BRg8gEKX.d.ts → conversations-COA6NW8I.d.ts} +11987 -3565
- package/dist/index.cjs +756 -79
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +409 -58
- package/dist/index.d.ts +409 -58
- package/dist/index.js +340 -55
- package/dist/index.js.map +1 -1
- package/dist/management/index.cjs +1443 -106
- package/dist/management/index.cjs.map +1 -1
- package/dist/management/index.d.cts +729 -12
- package/dist/management/index.d.ts +729 -12
- package/dist/management/index.js +1001 -50
- package/dist/management/index.js.map +1 -1
- package/package.json +3 -4
- package/dist/chunk-HEHHN4D6.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
validateChatModel,
|
|
30
30
|
validateId,
|
|
31
31
|
validatePageSize
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-GFS7CNON.js";
|
|
33
33
|
|
|
34
34
|
// src/_agent_run_request.ts
|
|
35
35
|
import { randomUUID } from "crypto";
|
|
@@ -388,7 +388,16 @@ var WorkflowRunsResource = class {
|
|
|
388
388
|
* @param options.timeframe - Filter by recency (`last_hour`, `last_day`, or `last_week`).
|
|
389
389
|
* @param options.approvalScope - Filter approval-related runs (`mine` or `all`).
|
|
390
390
|
* @param options.search - Free-text search filter.
|
|
391
|
-
* @returns A page of run summaries.
|
|
391
|
+
* @returns A page of run summaries — use `.autoPagingIter()` for all pages.
|
|
392
|
+
*
|
|
393
|
+
* @example
|
|
394
|
+
* ```ts
|
|
395
|
+
* for await (const run of (
|
|
396
|
+
* await client.workflows.runs.list(workflowId, { status: 'completed' })
|
|
397
|
+
* ).autoPagingIter()) {
|
|
398
|
+
* console.log(run.workflowId, run.status, run.startedAt)
|
|
399
|
+
* }
|
|
400
|
+
* ```
|
|
392
401
|
*/
|
|
393
402
|
list(workflowId, options = {}) {
|
|
394
403
|
validateId(workflowId, "workflow_id");
|
|
@@ -428,10 +437,16 @@ var WorkflowRunsResource = class {
|
|
|
428
437
|
* Retrieve a workflow run by id.
|
|
429
438
|
*
|
|
430
439
|
* @param workflowId - Workflow id or slug the run belongs to.
|
|
431
|
-
* @param runId - Run id.
|
|
440
|
+
* @param runId - Run id (the list row's `workflowId` field, not the composite `id`).
|
|
432
441
|
* @param options.temporalRunId - Optional internal execution id when disambiguating retries.
|
|
433
442
|
* @returns Run details including status and output.
|
|
434
443
|
* @throws {NotFoundError} When the run does not exist.
|
|
444
|
+
*
|
|
445
|
+
* @example
|
|
446
|
+
* ```ts
|
|
447
|
+
* const run = await client.workflows.runs.get(workflowId, runId)
|
|
448
|
+
* console.log(run.status)
|
|
449
|
+
* ```
|
|
435
450
|
*/
|
|
436
451
|
async get(workflowId, runId, options = {}) {
|
|
437
452
|
validateId(workflowId, "workflow_id");
|
|
@@ -454,8 +469,8 @@ var WorkflowRunsResource = class {
|
|
|
454
469
|
* @example
|
|
455
470
|
* ```ts
|
|
456
471
|
* const stream = client.workflows.runs.create(workflowId, {
|
|
457
|
-
* message:
|
|
458
|
-
*
|
|
472
|
+
* message: "Summarize yesterday's sales",
|
|
473
|
+
* config: { model: 'claude-sonnet-5' },
|
|
459
474
|
* })
|
|
460
475
|
* for await (const event of stream) {
|
|
461
476
|
* if (event.type === 'token') process.stdout.write(event.content)
|
|
@@ -470,21 +485,45 @@ var WorkflowRunsResource = class {
|
|
|
470
485
|
/**
|
|
471
486
|
* Start a scope run and stream run events.
|
|
472
487
|
*
|
|
488
|
+
* Same event stream shape as {@link create}, but targets a published scope.
|
|
489
|
+
*
|
|
473
490
|
* @param scopeId - Scope id to run.
|
|
474
491
|
* @param body - Run body (`message`, optional `sessionId`, optional `version` as `published` or `draft`).
|
|
475
492
|
* @param options.idempotencyKey - Client-supplied idempotency key; defaults to `body.runId` or a new uuid.
|
|
476
493
|
* @returns A stream of run events.
|
|
494
|
+
*
|
|
495
|
+
* @example
|
|
496
|
+
* ```ts
|
|
497
|
+
* const stream = client.workflows.runs.createScope(scopeId, {
|
|
498
|
+
* message: 'What is our ARR trend?',
|
|
499
|
+
* config: { model: 'claude-sonnet-5' },
|
|
500
|
+
* })
|
|
501
|
+
* for await (const event of stream) {
|
|
502
|
+
* if (event.type === 'token') process.stdout.write(event.content)
|
|
503
|
+
* }
|
|
504
|
+
* ```
|
|
477
505
|
*/
|
|
478
506
|
createScope(scopeId, body, options = {}) {
|
|
479
507
|
validateId(scopeId, "scope_id");
|
|
480
508
|
return this.createRun("ScopeRunsController_create", body, { id: scopeId }, options);
|
|
481
509
|
}
|
|
482
510
|
/**
|
|
483
|
-
* Start a Modus assistant run and stream run events.
|
|
511
|
+
* Start a Modus org-assistant run and stream run events.
|
|
484
512
|
*
|
|
485
513
|
* @param body - Run body (`message`, optional `sessionId`, optional `subordinateSkillIds` to narrow context).
|
|
486
514
|
* @param options.idempotencyKey - Client-supplied idempotency key; defaults to `body.runId` or a new uuid.
|
|
487
515
|
* @returns A stream of run events.
|
|
516
|
+
*
|
|
517
|
+
* @example
|
|
518
|
+
* ```ts
|
|
519
|
+
* const stream = client.workflows.runs.createModus({
|
|
520
|
+
* message: 'Summarize ARR in three bullets.',
|
|
521
|
+
* config: { model: 'claude-sonnet-5' },
|
|
522
|
+
* })
|
|
523
|
+
* for await (const event of stream) {
|
|
524
|
+
* if (event.type === 'token') process.stdout.write(event.content)
|
|
525
|
+
* }
|
|
526
|
+
* ```
|
|
488
527
|
*/
|
|
489
528
|
createModus(body, options = {}) {
|
|
490
529
|
return this.createRun("ModusRunsController_create", body, {}, options);
|
|
@@ -496,6 +535,18 @@ var WorkflowRunsResource = class {
|
|
|
496
535
|
* @param body - Resume body (`message`, `sessionId`, and `decision`: `approve` / `deny` / `connected` / `cancelled`).
|
|
497
536
|
* @param options.idempotencyKey - Client-supplied idempotency key; defaults to `body.runId` or a new uuid.
|
|
498
537
|
* @returns A stream of run events.
|
|
538
|
+
*
|
|
539
|
+
* @example
|
|
540
|
+
* ```ts
|
|
541
|
+
* const stream = client.workflows.runs.resume(runId, {
|
|
542
|
+
* decision: 'approve',
|
|
543
|
+
* message: 'Looks good — continue.',
|
|
544
|
+
* sessionId,
|
|
545
|
+
* })
|
|
546
|
+
* for await (const event of stream) {
|
|
547
|
+
* if (event.type === 'token') process.stdout.write(event.content)
|
|
548
|
+
* }
|
|
549
|
+
* ```
|
|
499
550
|
*/
|
|
500
551
|
resume(runId, body, options = {}) {
|
|
501
552
|
validateId(runId, "run_id");
|
|
@@ -505,6 +556,11 @@ var WorkflowRunsResource = class {
|
|
|
505
556
|
* Cancel a run that is still in progress.
|
|
506
557
|
*
|
|
507
558
|
* @param runId - Run id to cancel.
|
|
559
|
+
*
|
|
560
|
+
* @example
|
|
561
|
+
* ```ts
|
|
562
|
+
* await client.workflows.runs.cancel(runId)
|
|
563
|
+
* ```
|
|
508
564
|
*/
|
|
509
565
|
async cancel(runId) {
|
|
510
566
|
validateId(runId, "run_id");
|
|
@@ -698,15 +754,22 @@ var WorkflowsResource = class {
|
|
|
698
754
|
this.workflowActions = new AgentWorkflowActionsResource(http, config);
|
|
699
755
|
}
|
|
700
756
|
/**
|
|
701
|
-
* List workflows.
|
|
757
|
+
* List workflows in the organisation.
|
|
702
758
|
*
|
|
703
759
|
* @param options.pageSize - Maximum items per page (default 25).
|
|
704
760
|
* @param options.pageToken - Opaque token from a previous page.
|
|
705
|
-
* @param options.search -
|
|
761
|
+
* @param options.search - Case-insensitive substring filter on the workflow name.
|
|
706
762
|
* @param options.type - Workflow kind: `"task"` or `"workflow"`.
|
|
707
763
|
* @param options.view - Which saved version to return (`active` or `draft`).
|
|
708
764
|
* @param options.includeVariation - Include variation metadata when supported.
|
|
709
|
-
* @returns A page of workflows.
|
|
765
|
+
* @returns A page of workflows — use `.autoPagingIter()` for all pages.
|
|
766
|
+
*
|
|
767
|
+
* @example
|
|
768
|
+
* ```ts
|
|
769
|
+
* for await (const wf of (await client.workflows.list({ search: 'digest' })).autoPagingIter()) {
|
|
770
|
+
* console.log(wf.id, wf.name, wf.status)
|
|
771
|
+
* }
|
|
772
|
+
* ```
|
|
710
773
|
*/
|
|
711
774
|
list(options = {}) {
|
|
712
775
|
const pageSize = options.pageSize ?? 25;
|
|
@@ -746,8 +809,14 @@ var WorkflowsResource = class {
|
|
|
746
809
|
* @param workflowId - Numeric id or slug.
|
|
747
810
|
* @param options.view - Which saved version to return (`active` or `draft`).
|
|
748
811
|
* @param options.includeVariation - Include variation metadata when supported.
|
|
749
|
-
* @returns The workflow.
|
|
812
|
+
* @returns The workflow (`id`, `name`, `status`, …).
|
|
750
813
|
* @throws {NotFoundError} When no workflow matches the id or slug.
|
|
814
|
+
*
|
|
815
|
+
* @example
|
|
816
|
+
* ```ts
|
|
817
|
+
* const wf = await client.workflows.get('weekly-digest')
|
|
818
|
+
* console.log(wf.name, wf.status)
|
|
819
|
+
* ```
|
|
751
820
|
*/
|
|
752
821
|
async get(workflowId, options = {}) {
|
|
753
822
|
validateId(workflowId, "workflow_id");
|
|
@@ -832,9 +901,18 @@ var ConnectionsResource = class {
|
|
|
832
901
|
};
|
|
833
902
|
|
|
834
903
|
// src/resources/context/items.ts
|
|
835
|
-
function contextListParams(pageSize, pageToken,
|
|
904
|
+
function contextListParams(pageSize, pageToken, filters = {}) {
|
|
836
905
|
const extra = {};
|
|
837
|
-
if (contextType !== void 0) extra.contextTypes = [contextType];
|
|
906
|
+
if (filters.contextType !== void 0) extra.contextTypes = [filters.contextType];
|
|
907
|
+
if (filters.parentUids !== void 0) {
|
|
908
|
+
extra.parentUids = filters.parentUids.length === 0 ? "" : [...filters.parentUids];
|
|
909
|
+
}
|
|
910
|
+
if (filters.ancestorUids !== void 0) {
|
|
911
|
+
extra.ancestorUids = filters.ancestorUids.length === 0 ? "" : [...filters.ancestorUids];
|
|
912
|
+
}
|
|
913
|
+
if (filters.connectionIds !== void 0) {
|
|
914
|
+
extra.connectionIds = filters.connectionIds.length === 0 ? "" : [...filters.connectionIds];
|
|
915
|
+
}
|
|
838
916
|
return aipListParams(pageSize, pageToken, extra);
|
|
839
917
|
}
|
|
840
918
|
function parseContextItem(raw) {
|
|
@@ -859,33 +937,82 @@ var ContextItemsResource = class {
|
|
|
859
937
|
*
|
|
860
938
|
* @param options.pageSize - Maximum items per page (default 25).
|
|
861
939
|
* @param options.pageToken - Opaque token from a previous page.
|
|
862
|
-
* @param options.contextType - Filter to a single context type.
|
|
863
|
-
* @
|
|
940
|
+
* @param options.contextType - Filter to a single context type (e.g. `"note"`).
|
|
941
|
+
* @param options.parentUids - Exact ordered native ancestry chain for direct
|
|
942
|
+
* children. Omit to leave parent unrestricted; pass `[]` for the known-empty
|
|
943
|
+
* root. Native UIDs are exact tokens (including whitespace); do not use the
|
|
944
|
+
* hashed context-item `uid`. For a folder's children, send that item's
|
|
945
|
+
* `ancestry` UIDs plus its last `dataPath` token.
|
|
946
|
+
* @param options.ancestorUids - Ordered UID ancestry prefix for strict
|
|
947
|
+
* descendants. Omit to leave unrestricted; pass `[]` for every item with
|
|
948
|
+
* non-null ancestry.
|
|
949
|
+
* @param options.connectionIds - Restrict to these connection ids. Omit to
|
|
950
|
+
* leave unfiltered; pass `[]` to match none. The Files root is
|
|
951
|
+
* `connectionIds: ['files']` with `parentUids: []`.
|
|
952
|
+
* @returns A page of context items — use `.autoPagingIter()` for all pages.
|
|
953
|
+
*
|
|
954
|
+
* @example
|
|
955
|
+
* ```ts
|
|
956
|
+
* const notes = await client.context.items.list({ contextType: 'note', pageSize: 50 })
|
|
957
|
+
* for (const item of notes.items) {
|
|
958
|
+
* console.log(item.description ?? item.uid, item.uid)
|
|
959
|
+
* }
|
|
960
|
+
* ```
|
|
961
|
+
*
|
|
962
|
+
* @example
|
|
963
|
+
* ```ts
|
|
964
|
+
* const rootFolders = await client.context.items.list({
|
|
965
|
+
* connectionIds: ['files'],
|
|
966
|
+
* contextType: 'file_folder_metadata',
|
|
967
|
+
* parentUids: [],
|
|
968
|
+
* })
|
|
969
|
+
* const folder = rootFolders.items[0]
|
|
970
|
+
* const nativeUid = folder?.dataPath?.at(-1)
|
|
971
|
+
* // Known ancestry only — never treat null/omitted ancestry as a root chain.
|
|
972
|
+
* if (folder?.ancestry != null && nativeUid !== undefined) {
|
|
973
|
+
* const filesInFolder = await client.context.items.list({
|
|
974
|
+
* connectionIds: ['files'],
|
|
975
|
+
* contextType: 'file_upload',
|
|
976
|
+
* parentUids: [...folder.ancestry.map((a) => a.uid), nativeUid],
|
|
977
|
+
* })
|
|
978
|
+
* }
|
|
979
|
+
* ```
|
|
864
980
|
*/
|
|
865
981
|
list(options = {}) {
|
|
866
982
|
const pageSize = options.pageSize ?? 25;
|
|
867
983
|
validatePageSize(pageSize);
|
|
868
|
-
return this.listPage(pageSize, options.pageToken,
|
|
984
|
+
return this.listPage(pageSize, options.pageToken, {
|
|
985
|
+
contextType: options.contextType,
|
|
986
|
+
parentUids: options.parentUids,
|
|
987
|
+
ancestorUids: options.ancestorUids,
|
|
988
|
+
connectionIds: options.connectionIds
|
|
989
|
+
});
|
|
869
990
|
}
|
|
870
|
-
async listPage(pageSize, pageToken,
|
|
991
|
+
async listPage(pageSize, pageToken, filters) {
|
|
871
992
|
const data = asRecord(
|
|
872
993
|
await invokeWithRetry(this.config, this.http, "ContextItemsController_list", {
|
|
873
|
-
query: contextListParams(pageSize, pageToken,
|
|
994
|
+
query: contextListParams(pageSize, pageToken, filters)
|
|
874
995
|
})
|
|
875
996
|
);
|
|
876
997
|
return buildAipPage(
|
|
877
998
|
data,
|
|
878
999
|
"contextItems",
|
|
879
1000
|
parseContextItem,
|
|
880
|
-
(token) => this.listPage(pageSize, token,
|
|
1001
|
+
(token) => this.listPage(pageSize, token, filters)
|
|
881
1002
|
);
|
|
882
1003
|
}
|
|
883
1004
|
/**
|
|
884
1005
|
* Retrieve a knowledge-base item by uid.
|
|
885
1006
|
*
|
|
886
1007
|
* @param uid - Item uid.
|
|
887
|
-
* @returns The context item.
|
|
1008
|
+
* @returns The context item (`uid`, `contextType`, `content`, …).
|
|
888
1009
|
* @throws {NotFoundError} When no item matches the uid.
|
|
1010
|
+
*
|
|
1011
|
+
* @example
|
|
1012
|
+
* ```ts
|
|
1013
|
+
* const item = await client.context.items.get(uid)
|
|
1014
|
+
* console.log(item.contextType, item.description ?? item.uid)
|
|
1015
|
+
* ```
|
|
889
1016
|
*/
|
|
890
1017
|
async get(uid) {
|
|
891
1018
|
const data = await invokeWithRetry(this.config, this.http, "ContextItemsController_get", {
|
|
@@ -896,10 +1023,19 @@ var ContextItemsResource = class {
|
|
|
896
1023
|
/**
|
|
897
1024
|
* Look up a knowledge-base item by type and data path.
|
|
898
1025
|
*
|
|
899
|
-
* @param options.contextType - Context type to match.
|
|
1026
|
+
* @param options.contextType - Context type to match (e.g. `"note"`).
|
|
900
1027
|
* @param options.dataPath - Hierarchical path segments that identify the item.
|
|
901
1028
|
* @param options.contentProjection - Optional fields to include from item content.
|
|
902
1029
|
* @returns The matching row, or `undefined` when no item is found (404).
|
|
1030
|
+
*
|
|
1031
|
+
* @example
|
|
1032
|
+
* ```ts
|
|
1033
|
+
* const found = await client.context.items.lookup({
|
|
1034
|
+
* contextType: 'note',
|
|
1035
|
+
* dataPath: ['finance', 'arr-definition'],
|
|
1036
|
+
* })
|
|
1037
|
+
* if (found) console.log(found.uid, found.description ?? found.uid)
|
|
1038
|
+
* ```
|
|
903
1039
|
*/
|
|
904
1040
|
async lookup(options) {
|
|
905
1041
|
const body = omitUndefined({
|
|
@@ -924,10 +1060,22 @@ var ContextItemsResource = class {
|
|
|
924
1060
|
*
|
|
925
1061
|
* @param uid - Item uid.
|
|
926
1062
|
* @param contextType - Context type of the item.
|
|
927
|
-
* @param contentKeyPath - Dot path to the value field inside item content.
|
|
1063
|
+
* @param contentKeyPath - Dot path to the value field inside item content (e.g. `"enumValues"`).
|
|
928
1064
|
* @param options.pageSize - Maximum items per page (default 25).
|
|
929
1065
|
* @param options.pageToken - Opaque token from a previous page.
|
|
930
1066
|
* @returns A page of value rows.
|
|
1067
|
+
*
|
|
1068
|
+
* @example
|
|
1069
|
+
* ```ts
|
|
1070
|
+
* // Replace PLACEHOLDER_UID with a real uid whose content has enumValues.
|
|
1071
|
+
* const page = await client.context.items.listValues(
|
|
1072
|
+
* 'PLACEHOLDER_UID',
|
|
1073
|
+
* 'table_column',
|
|
1074
|
+
* 'enumValues',
|
|
1075
|
+
* { pageSize: 25 },
|
|
1076
|
+
* )
|
|
1077
|
+
* for (const row of page.items) console.log(row)
|
|
1078
|
+
* ```
|
|
931
1079
|
*/
|
|
932
1080
|
listValues(uid, contextType, contentKeyPath, options = {}) {
|
|
933
1081
|
const pageSize = options.pageSize ?? 25;
|
|
@@ -942,6 +1090,14 @@ var ContextItemsResource = class {
|
|
|
942
1090
|
* @param options.pageSize - Maximum items per page (default 25).
|
|
943
1091
|
* @param options.pageToken - Opaque token from a previous page.
|
|
944
1092
|
* @returns A page of value rows.
|
|
1093
|
+
*
|
|
1094
|
+
* @example
|
|
1095
|
+
* ```ts
|
|
1096
|
+
* // Replace PLACEHOLDER_UID with a real uid that has enumValues in content.
|
|
1097
|
+
* const item = await client.context.items.get('PLACEHOLDER_UID')
|
|
1098
|
+
* const page = await client.context.items.listValuesFor(item, 'enumValues')
|
|
1099
|
+
* for (const row of page.items) console.log(row)
|
|
1100
|
+
* ```
|
|
945
1101
|
*/
|
|
946
1102
|
listValuesFor(item, contentKeyPath, options = {}) {
|
|
947
1103
|
return this.listValues(item.uid, item.contextType, contentKeyPath, options);
|
|
@@ -974,9 +1130,51 @@ var ContextResource = class {
|
|
|
974
1130
|
}
|
|
975
1131
|
};
|
|
976
1132
|
|
|
1133
|
+
// src/resources/ingested-data.ts
|
|
1134
|
+
var IngestedDataResource = class {
|
|
1135
|
+
/** @internal */
|
|
1136
|
+
constructor(http, config) {
|
|
1137
|
+
this.http = http;
|
|
1138
|
+
this.config = config;
|
|
1139
|
+
}
|
|
1140
|
+
/**
|
|
1141
|
+
* Store a complete SQL or HTTP request and response exactly once.
|
|
1142
|
+
*
|
|
1143
|
+
* Identity covers the complete organization, integration, request, and response
|
|
1144
|
+
* content. A duplicate raises `ConflictError`, which means the identical payload
|
|
1145
|
+
* is already stored and may be treated as a safe retry outcome.
|
|
1146
|
+
*
|
|
1147
|
+
* @param options.integrationType - Canonical Modus integration identifier.
|
|
1148
|
+
* @param options.request - Exact SQL or HTTP request that produced the response.
|
|
1149
|
+
* @param options.response - Response format, optional source HTTP status, and exact string content. SQL requires CSV.
|
|
1150
|
+
* @returns The checksum of the stored envelope.
|
|
1151
|
+
* @throws {ConflictError} When the complete payload is already stored.
|
|
1152
|
+
*
|
|
1153
|
+
* @example
|
|
1154
|
+
* ```ts
|
|
1155
|
+
* const stored = await client.ingestedData.upload({
|
|
1156
|
+
* integrationType: 'generic',
|
|
1157
|
+
* request: { type: 'sql', query: 'SELECT id, total FROM orders' },
|
|
1158
|
+
* response: { format: 'csv', content: 'id,total\n1,42.00\n' },
|
|
1159
|
+
* })
|
|
1160
|
+
* console.log(stored.checksum)
|
|
1161
|
+
* ```
|
|
1162
|
+
*/
|
|
1163
|
+
async upload(options) {
|
|
1164
|
+
const data = await invokeWithRetry(this.config, this.http, "IngestedDataController_upload", {
|
|
1165
|
+
jsonBody: {
|
|
1166
|
+
integration_type: options.integrationType,
|
|
1167
|
+
request: options.request,
|
|
1168
|
+
response: options.response
|
|
1169
|
+
}
|
|
1170
|
+
});
|
|
1171
|
+
return data;
|
|
1172
|
+
}
|
|
1173
|
+
};
|
|
1174
|
+
|
|
977
1175
|
// src/resources/modus/conversations.ts
|
|
978
1176
|
var ALLOWED_KINDS = /* @__PURE__ */ new Set(["all", "modus", "scopes"]);
|
|
979
|
-
function listParams(pageSize, pageToken, kind) {
|
|
1177
|
+
function listParams(pageSize, pageToken, kind, source, sourceRef) {
|
|
980
1178
|
if (kind !== void 0 && !ALLOWED_KINDS.has(kind)) {
|
|
981
1179
|
throw new Error(
|
|
982
1180
|
`kind must be one of ${[...ALLOWED_KINDS].sort().join(", ")}, got ${JSON.stringify(kind)}`
|
|
@@ -984,6 +1182,8 @@ function listParams(pageSize, pageToken, kind) {
|
|
|
984
1182
|
}
|
|
985
1183
|
const extra = {};
|
|
986
1184
|
if (kind !== void 0) extra.kind = kind;
|
|
1185
|
+
if (source !== void 0) extra.source = source;
|
|
1186
|
+
if (sourceRef !== void 0) extra.sourceRef = sourceRef;
|
|
987
1187
|
return aipListParams(pageSize, pageToken, extra);
|
|
988
1188
|
}
|
|
989
1189
|
function parseListItem(raw) {
|
|
@@ -1003,24 +1203,32 @@ var ModusConversationsResource = class {
|
|
|
1003
1203
|
* @param options.pageSize - Items per page (default 25).
|
|
1004
1204
|
* @param options.pageToken - Opaque token from a previous page.
|
|
1005
1205
|
* @param options.kind - `"modus"`, `"scopes"`, or `"all"`.
|
|
1206
|
+
* @param options.source - Restrict to conversations started from this UI surface
|
|
1207
|
+
* (e.g. `"context_chat"`, `"dashboard_copilot"`, `"slack"`). Only valid with an
|
|
1208
|
+
* omitted `kind` or `kind: "all"`; the API throws an `UnprocessableError` (422)
|
|
1209
|
+
* if combined with `kind: "modus"` or `kind: "scopes"`.
|
|
1210
|
+
* @param options.sourceRef - Narrow `source` to one instance of that surface — for
|
|
1211
|
+
* `"dashboard_copilot"`, a dashboard id. Requires `source`; the API throws an
|
|
1212
|
+
* `UnprocessableError` (422) if sent on its own. Conversations recorded before
|
|
1213
|
+
* this filter shipped carry no instance key and never match it.
|
|
1006
1214
|
* @returns Page of conversation list items.
|
|
1007
1215
|
*/
|
|
1008
1216
|
list(options = {}) {
|
|
1009
1217
|
const pageSize = options.pageSize ?? 25;
|
|
1010
1218
|
validatePageSize(pageSize);
|
|
1011
|
-
return this.listPage(pageSize, options.pageToken, options.kind);
|
|
1219
|
+
return this.listPage(pageSize, options.pageToken, options.kind, options.source, options.sourceRef);
|
|
1012
1220
|
}
|
|
1013
|
-
async listPage(pageSize, pageToken, kind) {
|
|
1221
|
+
async listPage(pageSize, pageToken, kind, source, sourceRef) {
|
|
1014
1222
|
const data = asRecord(
|
|
1015
1223
|
await invokeWithRetry(this.config, this.http, "ModusConversationsController_list", {
|
|
1016
|
-
query: listParams(pageSize, pageToken, kind)
|
|
1224
|
+
query: listParams(pageSize, pageToken, kind, source, sourceRef)
|
|
1017
1225
|
})
|
|
1018
1226
|
);
|
|
1019
1227
|
return buildAipPage(
|
|
1020
1228
|
data,
|
|
1021
1229
|
"conversations",
|
|
1022
1230
|
parseListItem,
|
|
1023
|
-
(token) => this.listPage(pageSize, token, kind)
|
|
1231
|
+
(token) => this.listPage(pageSize, token, kind, source, sourceRef)
|
|
1024
1232
|
);
|
|
1025
1233
|
}
|
|
1026
1234
|
/**
|
|
@@ -1046,11 +1254,17 @@ var ModusResource = class {
|
|
|
1046
1254
|
this.conversations = new ModusConversationsResource(http, config);
|
|
1047
1255
|
}
|
|
1048
1256
|
/**
|
|
1049
|
-
*
|
|
1257
|
+
* Compose full-environment context for an intent without running chat.
|
|
1258
|
+
*
|
|
1259
|
+
* @param message - Natural-language intent used to select context.
|
|
1260
|
+
* @param options.limit - Maximum context items to return. Omit to return all selected items.
|
|
1261
|
+
* @returns Composition metadata (counts / session id). Use `chat` for a reply.
|
|
1050
1262
|
*
|
|
1051
|
-
* @
|
|
1052
|
-
*
|
|
1053
|
-
*
|
|
1263
|
+
* @example
|
|
1264
|
+
* ```ts
|
|
1265
|
+
* const ctx = await client.modus.getContext('What tables describe revenue?', { limit: 5 })
|
|
1266
|
+
* console.log(ctx.originalCount, ctx.sessionId)
|
|
1267
|
+
* ```
|
|
1054
1268
|
*/
|
|
1055
1269
|
async getContext(message, options = {}) {
|
|
1056
1270
|
const data = await invokeWithRetry(this.config, this.http, "ModusContextController_compose", {
|
|
@@ -1059,29 +1273,48 @@ var ModusResource = class {
|
|
|
1059
1273
|
return data;
|
|
1060
1274
|
}
|
|
1061
1275
|
/**
|
|
1062
|
-
* Send a message to Modus
|
|
1276
|
+
* Send a message to Modus and wait for the complete reply.
|
|
1063
1277
|
*
|
|
1064
|
-
* @param message -
|
|
1278
|
+
* @param message - User message text.
|
|
1065
1279
|
* @param options.model - Required model id (e.g. `"claude-sonnet-5"`).
|
|
1066
|
-
* @param options.threadId - Continue an existing conversation.
|
|
1067
|
-
* @returns Chat result
|
|
1280
|
+
* @param options.threadId - Continue an existing conversation; omit to start new.
|
|
1281
|
+
* @returns Chat result: `content`, `threadId` (for follow-ups), `runId`.
|
|
1068
1282
|
*
|
|
1069
1283
|
* @example
|
|
1070
1284
|
* ```ts
|
|
1071
|
-
* const result = await client.modus.chat('What tables describe revenue?', {
|
|
1285
|
+
* const result = await client.modus.chat('What tables describe revenue?', {
|
|
1286
|
+
* model: 'claude-sonnet-5',
|
|
1287
|
+
* })
|
|
1072
1288
|
* console.log(result.content, result.threadId)
|
|
1289
|
+
* const follow = await client.modus.chat('Break that down by region.', {
|
|
1290
|
+
* model: 'claude-sonnet-5',
|
|
1291
|
+
* threadId: result.threadId,
|
|
1292
|
+
* })
|
|
1073
1293
|
* ```
|
|
1074
1294
|
*/
|
|
1075
1295
|
chat(message, options) {
|
|
1076
1296
|
return modusChatBuffered(this.http, message, options);
|
|
1077
1297
|
}
|
|
1078
1298
|
/**
|
|
1079
|
-
* Stream a Modus reply token by token.
|
|
1299
|
+
* Stream a Modus reply token by token (SSE).
|
|
1300
|
+
*
|
|
1301
|
+
* The request starts when you consume `textStream()` or `eventStream()`.
|
|
1080
1302
|
*
|
|
1081
|
-
* @param message -
|
|
1303
|
+
* @param message - User message text.
|
|
1082
1304
|
* @param options.model - Required model id (e.g. `"claude-sonnet-5"`).
|
|
1083
|
-
* @param options.threadId - Continue an existing conversation.
|
|
1084
|
-
* @returns Chat stream.
|
|
1305
|
+
* @param options.threadId - Continue an existing conversation; omit to start new.
|
|
1306
|
+
* @returns Chat stream — iterate `textStream()` for tokens.
|
|
1307
|
+
*
|
|
1308
|
+
* @example
|
|
1309
|
+
* ```ts
|
|
1310
|
+
* const stream = client.modus.chatStream('Summarize ARR in three bullets.', {
|
|
1311
|
+
* model: 'claude-sonnet-5',
|
|
1312
|
+
* })
|
|
1313
|
+
* for await (const token of stream.textStream()) {
|
|
1314
|
+
* process.stdout.write(token)
|
|
1315
|
+
* }
|
|
1316
|
+
* console.log(stream.getFinalResult().threadId)
|
|
1317
|
+
* ```
|
|
1085
1318
|
*/
|
|
1086
1319
|
chatStream(message, options) {
|
|
1087
1320
|
return modusChatStreamSession(this.http, this.config, message, options);
|
|
@@ -1110,6 +1343,15 @@ var ScopesResource = class {
|
|
|
1110
1343
|
*
|
|
1111
1344
|
* @param scopeId - Scope numeric id or slug.
|
|
1112
1345
|
* @returns Conversations resource for the scope.
|
|
1346
|
+
*
|
|
1347
|
+
* @example
|
|
1348
|
+
* ```ts
|
|
1349
|
+
* for await (const row of (
|
|
1350
|
+
* await client.scopes.conversations(scopeId).list({ pageSize: 10 })
|
|
1351
|
+
* ).autoPagingIter()) {
|
|
1352
|
+
* console.log(row.threadId, row.firstMessage)
|
|
1353
|
+
* }
|
|
1354
|
+
* ```
|
|
1113
1355
|
*/
|
|
1114
1356
|
conversations(scopeId) {
|
|
1115
1357
|
return new ScopeConversationsResource(this.http, this.config, scopeId);
|
|
@@ -1122,7 +1364,14 @@ var ScopesResource = class {
|
|
|
1122
1364
|
* @param options.search - Case-insensitive substring filter on the scope name.
|
|
1123
1365
|
* @param options.view - `"active"` (deployed) or `"draft"`.
|
|
1124
1366
|
* @param options.managerId - Only scopes supervised by this manager scope id.
|
|
1125
|
-
* @returns Page of scopes.
|
|
1367
|
+
* @returns Page of scopes — use `.autoPagingIter()` for all pages.
|
|
1368
|
+
*
|
|
1369
|
+
* @example
|
|
1370
|
+
* ```ts
|
|
1371
|
+
* for await (const scope of (await client.scopes.list()).autoPagingIter()) {
|
|
1372
|
+
* console.log(scope.id, scope.name, scope.status)
|
|
1373
|
+
* }
|
|
1374
|
+
* ```
|
|
1126
1375
|
*/
|
|
1127
1376
|
list(options = {}) {
|
|
1128
1377
|
const pageSize = options.pageSize ?? 25;
|
|
@@ -1154,7 +1403,13 @@ var ScopesResource = class {
|
|
|
1154
1403
|
* @param scopeId - Scope numeric id or slug.
|
|
1155
1404
|
* @param options.view - `"active"` (deployed) or `"draft"`.
|
|
1156
1405
|
* @throws {NotFoundError} When no scope matches the id or slug.
|
|
1157
|
-
* @returns Scope.
|
|
1406
|
+
* @returns Scope (`id`, `name`, `status`, …).
|
|
1407
|
+
*
|
|
1408
|
+
* @example
|
|
1409
|
+
* ```ts
|
|
1410
|
+
* const scope = await client.scopes.get('revenue-analysis')
|
|
1411
|
+
* console.log(scope.name, scope.status)
|
|
1412
|
+
* ```
|
|
1158
1413
|
*/
|
|
1159
1414
|
async get(scopeId, options = {}) {
|
|
1160
1415
|
validateId(scopeId, "scope_id");
|
|
@@ -1166,12 +1421,20 @@ var ScopesResource = class {
|
|
|
1166
1421
|
return parseScope(data);
|
|
1167
1422
|
}
|
|
1168
1423
|
/**
|
|
1169
|
-
*
|
|
1424
|
+
* Compose context this scope would use for an intent, without running chat.
|
|
1170
1425
|
*
|
|
1171
1426
|
* @param scopeId - Scope numeric id or slug.
|
|
1172
|
-
* @param message -
|
|
1173
|
-
* @param options.limit -
|
|
1174
|
-
* @returns
|
|
1427
|
+
* @param message - Natural-language intent used to select context.
|
|
1428
|
+
* @param options.limit - Maximum context items to return. Omit to return all selected items.
|
|
1429
|
+
* @returns Composition metadata. Use `chat` when you need an assistant reply.
|
|
1430
|
+
*
|
|
1431
|
+
* @example
|
|
1432
|
+
* ```ts
|
|
1433
|
+
* const ctx = await client.scopes.getContext(scopeId, 'Which tables describe churn?', {
|
|
1434
|
+
* limit: 5,
|
|
1435
|
+
* })
|
|
1436
|
+
* console.log(ctx.originalCount, ctx.sessionId)
|
|
1437
|
+
* ```
|
|
1175
1438
|
*/
|
|
1176
1439
|
async getContext(scopeId, message, options = {}) {
|
|
1177
1440
|
validateId(scopeId, "scope_id");
|
|
@@ -1182,32 +1445,53 @@ var ScopesResource = class {
|
|
|
1182
1445
|
return data;
|
|
1183
1446
|
}
|
|
1184
1447
|
/**
|
|
1185
|
-
* Send a message to a scope and
|
|
1448
|
+
* Send a message to a published scope and wait for the complete reply.
|
|
1186
1449
|
*
|
|
1187
|
-
*
|
|
1188
|
-
*
|
|
1450
|
+
* For the org-wide assistant use `client.modus.chat` instead.
|
|
1451
|
+
*
|
|
1452
|
+
* @param scopeId - Scope numeric id or slug (must be active for chat).
|
|
1453
|
+
* @param message - User message text.
|
|
1189
1454
|
* @param options.model - Required model id (e.g. `"claude-sonnet-5"`).
|
|
1190
|
-
* @param options.threadId - Continue an existing conversation.
|
|
1191
|
-
* @returns Chat result
|
|
1455
|
+
* @param options.threadId - Continue an existing conversation; omit to start new.
|
|
1456
|
+
* @returns Chat result: `content`, `threadId`, `runId`.
|
|
1192
1457
|
*
|
|
1193
1458
|
* @example
|
|
1194
1459
|
* ```ts
|
|
1195
|
-
* const result = await client.scopes.chat(scopeId, '
|
|
1460
|
+
* const result = await client.scopes.chat(scopeId, 'What is our ARR trend?', {
|
|
1461
|
+
* model: 'claude-sonnet-5',
|
|
1462
|
+
* })
|
|
1196
1463
|
* console.log(result.content, result.threadId)
|
|
1464
|
+
* const follow = await client.scopes.chat(scopeId, 'Break that down by segment.', {
|
|
1465
|
+
* model: 'claude-sonnet-5',
|
|
1466
|
+
* threadId: result.threadId,
|
|
1467
|
+
* })
|
|
1197
1468
|
* ```
|
|
1198
1469
|
*/
|
|
1199
1470
|
chat(scopeId, message, options) {
|
|
1200
1471
|
return chatBuffered(this.http, "scopes", scopeId, message, options);
|
|
1201
1472
|
}
|
|
1202
1473
|
/**
|
|
1203
|
-
* Stream a scope reply token by token.
|
|
1474
|
+
* Stream a scope reply token by token (SSE).
|
|
1475
|
+
*
|
|
1476
|
+
* The request starts when you consume `textStream()` or `eventStream()`.
|
|
1204
1477
|
*
|
|
1205
1478
|
* @param scopeId - Scope numeric id or slug.
|
|
1206
|
-
* @param message -
|
|
1479
|
+
* @param message - User message text.
|
|
1207
1480
|
* @param options.model - Required model id (e.g. `"claude-sonnet-5"`).
|
|
1208
|
-
* @param options.threadId - Continue an existing conversation.
|
|
1481
|
+
* @param options.threadId - Continue an existing conversation; omit to start new.
|
|
1209
1482
|
* @param options.version - `"published"` or `"draft"`.
|
|
1210
|
-
* @returns Chat stream.
|
|
1483
|
+
* @returns Chat stream — iterate `textStream()` for tokens.
|
|
1484
|
+
*
|
|
1485
|
+
* @example
|
|
1486
|
+
* ```ts
|
|
1487
|
+
* const stream = client.scopes.chatStream(scopeId, 'Summarize in three bullets.', {
|
|
1488
|
+
* model: 'claude-sonnet-5',
|
|
1489
|
+
* })
|
|
1490
|
+
* for await (const token of stream.textStream()) {
|
|
1491
|
+
* process.stdout.write(token)
|
|
1492
|
+
* }
|
|
1493
|
+
* console.log(stream.getFinalResult().threadId)
|
|
1494
|
+
* ```
|
|
1211
1495
|
*/
|
|
1212
1496
|
chatStream(scopeId, message, options) {
|
|
1213
1497
|
return chatStreamSession(this.http, this.config, "scopes", scopeId, message, options);
|
|
@@ -1286,6 +1570,7 @@ var Modus = class extends ModusClientBase {
|
|
|
1286
1570
|
this.context = new ContextResource(this.http, this.config);
|
|
1287
1571
|
this.connections = new ConnectionsResource(this.http, this.config);
|
|
1288
1572
|
this.suggestions = new SuggestionsResource(this.http, this.config);
|
|
1573
|
+
this.ingestedData = new IngestedDataResource(this.http, this.config);
|
|
1289
1574
|
}
|
|
1290
1575
|
};
|
|
1291
1576
|
export {
|