@getmodus/sdk 0.5.0 → 0.7.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 +85 -5
- package/README.md +9 -1
- package/dist/{chunk-H76PTY5G.js → chunk-JMFT5KO5.js} +395 -10
- package/dist/chunk-JMFT5KO5.js.map +1 -0
- package/dist/{conversations-Pe3kNikF.d.cts → conversations-B0_jmEuT.d.cts} +11469 -2916
- package/dist/{conversations-Pe3kNikF.d.ts → conversations-B0_jmEuT.d.ts} +11469 -2916
- package/dist/index.cjs +683 -57
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +373 -55
- package/dist/index.d.ts +373 -55
- package/dist/index.js +290 -49
- package/dist/index.js.map +1 -1
- package/dist/management/index.cjs +1538 -55
- package/dist/management/index.cjs.map +1 -1
- package/dist/management/index.d.cts +747 -9
- package/dist/management/index.d.ts +747 -9
- package/dist/management/index.js +1108 -7
- package/dist/management/index.js.map +1 -1
- package/package.json +2 -3
- package/dist/chunk-H76PTY5G.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-JMFT5KO5.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");
|
|
@@ -859,8 +928,16 @@ var ContextItemsResource = class {
|
|
|
859
928
|
*
|
|
860
929
|
* @param options.pageSize - Maximum items per page (default 25).
|
|
861
930
|
* @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.
|
|
931
|
+
* @param options.contextType - Filter to a single context type (e.g. `"note"`).
|
|
932
|
+
* @returns A page of context items — use `.autoPagingIter()` for all pages.
|
|
933
|
+
*
|
|
934
|
+
* @example
|
|
935
|
+
* ```ts
|
|
936
|
+
* const notes = await client.context.items.list({ contextType: 'note', pageSize: 50 })
|
|
937
|
+
* for (const item of notes.items) {
|
|
938
|
+
* console.log(item.description ?? item.uid, item.uid)
|
|
939
|
+
* }
|
|
940
|
+
* ```
|
|
864
941
|
*/
|
|
865
942
|
list(options = {}) {
|
|
866
943
|
const pageSize = options.pageSize ?? 25;
|
|
@@ -884,8 +961,14 @@ var ContextItemsResource = class {
|
|
|
884
961
|
* Retrieve a knowledge-base item by uid.
|
|
885
962
|
*
|
|
886
963
|
* @param uid - Item uid.
|
|
887
|
-
* @returns The context item.
|
|
964
|
+
* @returns The context item (`uid`, `contextType`, `content`, …).
|
|
888
965
|
* @throws {NotFoundError} When no item matches the uid.
|
|
966
|
+
*
|
|
967
|
+
* @example
|
|
968
|
+
* ```ts
|
|
969
|
+
* const item = await client.context.items.get(uid)
|
|
970
|
+
* console.log(item.contextType, item.description ?? item.uid)
|
|
971
|
+
* ```
|
|
889
972
|
*/
|
|
890
973
|
async get(uid) {
|
|
891
974
|
const data = await invokeWithRetry(this.config, this.http, "ContextItemsController_get", {
|
|
@@ -896,10 +979,19 @@ var ContextItemsResource = class {
|
|
|
896
979
|
/**
|
|
897
980
|
* Look up a knowledge-base item by type and data path.
|
|
898
981
|
*
|
|
899
|
-
* @param options.contextType - Context type to match.
|
|
982
|
+
* @param options.contextType - Context type to match (e.g. `"note"`).
|
|
900
983
|
* @param options.dataPath - Hierarchical path segments that identify the item.
|
|
901
984
|
* @param options.contentProjection - Optional fields to include from item content.
|
|
902
985
|
* @returns The matching row, or `undefined` when no item is found (404).
|
|
986
|
+
*
|
|
987
|
+
* @example
|
|
988
|
+
* ```ts
|
|
989
|
+
* const found = await client.context.items.lookup({
|
|
990
|
+
* contextType: 'note',
|
|
991
|
+
* dataPath: ['finance', 'arr-definition'],
|
|
992
|
+
* })
|
|
993
|
+
* if (found) console.log(found.uid, found.description ?? found.uid)
|
|
994
|
+
* ```
|
|
903
995
|
*/
|
|
904
996
|
async lookup(options) {
|
|
905
997
|
const body = omitUndefined({
|
|
@@ -924,10 +1016,22 @@ var ContextItemsResource = class {
|
|
|
924
1016
|
*
|
|
925
1017
|
* @param uid - Item uid.
|
|
926
1018
|
* @param contextType - Context type of the item.
|
|
927
|
-
* @param contentKeyPath - Dot path to the value field inside item content.
|
|
1019
|
+
* @param contentKeyPath - Dot path to the value field inside item content (e.g. `"enumValues"`).
|
|
928
1020
|
* @param options.pageSize - Maximum items per page (default 25).
|
|
929
1021
|
* @param options.pageToken - Opaque token from a previous page.
|
|
930
1022
|
* @returns A page of value rows.
|
|
1023
|
+
*
|
|
1024
|
+
* @example
|
|
1025
|
+
* ```ts
|
|
1026
|
+
* // Replace PLACEHOLDER_UID with a real uid whose content has enumValues.
|
|
1027
|
+
* const page = await client.context.items.listValues(
|
|
1028
|
+
* 'PLACEHOLDER_UID',
|
|
1029
|
+
* 'table_column',
|
|
1030
|
+
* 'enumValues',
|
|
1031
|
+
* { pageSize: 25 },
|
|
1032
|
+
* )
|
|
1033
|
+
* for (const row of page.items) console.log(row)
|
|
1034
|
+
* ```
|
|
931
1035
|
*/
|
|
932
1036
|
listValues(uid, contextType, contentKeyPath, options = {}) {
|
|
933
1037
|
const pageSize = options.pageSize ?? 25;
|
|
@@ -942,6 +1046,14 @@ var ContextItemsResource = class {
|
|
|
942
1046
|
* @param options.pageSize - Maximum items per page (default 25).
|
|
943
1047
|
* @param options.pageToken - Opaque token from a previous page.
|
|
944
1048
|
* @returns A page of value rows.
|
|
1049
|
+
*
|
|
1050
|
+
* @example
|
|
1051
|
+
* ```ts
|
|
1052
|
+
* // Replace PLACEHOLDER_UID with a real uid that has enumValues in content.
|
|
1053
|
+
* const item = await client.context.items.get('PLACEHOLDER_UID')
|
|
1054
|
+
* const page = await client.context.items.listValuesFor(item, 'enumValues')
|
|
1055
|
+
* for (const row of page.items) console.log(row)
|
|
1056
|
+
* ```
|
|
945
1057
|
*/
|
|
946
1058
|
listValuesFor(item, contentKeyPath, options = {}) {
|
|
947
1059
|
return this.listValues(item.uid, item.contextType, contentKeyPath, options);
|
|
@@ -974,9 +1086,51 @@ var ContextResource = class {
|
|
|
974
1086
|
}
|
|
975
1087
|
};
|
|
976
1088
|
|
|
1089
|
+
// src/resources/ingested-data.ts
|
|
1090
|
+
var IngestedDataResource = class {
|
|
1091
|
+
/** @internal */
|
|
1092
|
+
constructor(http, config) {
|
|
1093
|
+
this.http = http;
|
|
1094
|
+
this.config = config;
|
|
1095
|
+
}
|
|
1096
|
+
/**
|
|
1097
|
+
* Store a complete SQL or HTTP request and response exactly once.
|
|
1098
|
+
*
|
|
1099
|
+
* Identity covers the complete organization, integration, request, and response
|
|
1100
|
+
* content. A duplicate raises `ConflictError`, which means the identical payload
|
|
1101
|
+
* is already stored and may be treated as a safe retry outcome.
|
|
1102
|
+
*
|
|
1103
|
+
* @param options.integrationType - Canonical Modus integration identifier.
|
|
1104
|
+
* @param options.request - Exact SQL or HTTP request that produced the response.
|
|
1105
|
+
* @param options.response - Response format, optional source HTTP status, and exact string content. SQL requires CSV.
|
|
1106
|
+
* @returns The checksum of the stored envelope.
|
|
1107
|
+
* @throws {ConflictError} When the complete payload is already stored.
|
|
1108
|
+
*
|
|
1109
|
+
* @example
|
|
1110
|
+
* ```ts
|
|
1111
|
+
* const stored = await client.ingestedData.upload({
|
|
1112
|
+
* integrationType: 'generic',
|
|
1113
|
+
* request: { type: 'sql', query: 'SELECT id, total FROM orders' },
|
|
1114
|
+
* response: { format: 'csv', content: 'id,total\n1,42.00\n' },
|
|
1115
|
+
* })
|
|
1116
|
+
* console.log(stored.checksum)
|
|
1117
|
+
* ```
|
|
1118
|
+
*/
|
|
1119
|
+
async upload(options) {
|
|
1120
|
+
const data = await invokeWithRetry(this.config, this.http, "IngestedDataController_upload", {
|
|
1121
|
+
jsonBody: {
|
|
1122
|
+
integration_type: options.integrationType,
|
|
1123
|
+
request: options.request,
|
|
1124
|
+
response: options.response
|
|
1125
|
+
}
|
|
1126
|
+
});
|
|
1127
|
+
return data;
|
|
1128
|
+
}
|
|
1129
|
+
};
|
|
1130
|
+
|
|
977
1131
|
// src/resources/modus/conversations.ts
|
|
978
1132
|
var ALLOWED_KINDS = /* @__PURE__ */ new Set(["all", "modus", "scopes"]);
|
|
979
|
-
function listParams(pageSize, pageToken, kind) {
|
|
1133
|
+
function listParams(pageSize, pageToken, kind, source, sourceRef) {
|
|
980
1134
|
if (kind !== void 0 && !ALLOWED_KINDS.has(kind)) {
|
|
981
1135
|
throw new Error(
|
|
982
1136
|
`kind must be one of ${[...ALLOWED_KINDS].sort().join(", ")}, got ${JSON.stringify(kind)}`
|
|
@@ -984,6 +1138,8 @@ function listParams(pageSize, pageToken, kind) {
|
|
|
984
1138
|
}
|
|
985
1139
|
const extra = {};
|
|
986
1140
|
if (kind !== void 0) extra.kind = kind;
|
|
1141
|
+
if (source !== void 0) extra.source = source;
|
|
1142
|
+
if (sourceRef !== void 0) extra.sourceRef = sourceRef;
|
|
987
1143
|
return aipListParams(pageSize, pageToken, extra);
|
|
988
1144
|
}
|
|
989
1145
|
function parseListItem(raw) {
|
|
@@ -1003,24 +1159,32 @@ var ModusConversationsResource = class {
|
|
|
1003
1159
|
* @param options.pageSize - Items per page (default 25).
|
|
1004
1160
|
* @param options.pageToken - Opaque token from a previous page.
|
|
1005
1161
|
* @param options.kind - `"modus"`, `"scopes"`, or `"all"`.
|
|
1162
|
+
* @param options.source - Restrict to conversations started from this UI surface
|
|
1163
|
+
* (e.g. `"context_chat"`, `"dashboard_copilot"`, `"slack"`). Only valid with an
|
|
1164
|
+
* omitted `kind` or `kind: "all"`; the API throws an `UnprocessableError` (422)
|
|
1165
|
+
* if combined with `kind: "modus"` or `kind: "scopes"`.
|
|
1166
|
+
* @param options.sourceRef - Narrow `source` to one instance of that surface — for
|
|
1167
|
+
* `"dashboard_copilot"`, a dashboard id. Requires `source`; the API throws an
|
|
1168
|
+
* `UnprocessableError` (422) if sent on its own. Conversations recorded before
|
|
1169
|
+
* this filter shipped carry no instance key and never match it.
|
|
1006
1170
|
* @returns Page of conversation list items.
|
|
1007
1171
|
*/
|
|
1008
1172
|
list(options = {}) {
|
|
1009
1173
|
const pageSize = options.pageSize ?? 25;
|
|
1010
1174
|
validatePageSize(pageSize);
|
|
1011
|
-
return this.listPage(pageSize, options.pageToken, options.kind);
|
|
1175
|
+
return this.listPage(pageSize, options.pageToken, options.kind, options.source, options.sourceRef);
|
|
1012
1176
|
}
|
|
1013
|
-
async listPage(pageSize, pageToken, kind) {
|
|
1177
|
+
async listPage(pageSize, pageToken, kind, source, sourceRef) {
|
|
1014
1178
|
const data = asRecord(
|
|
1015
1179
|
await invokeWithRetry(this.config, this.http, "ModusConversationsController_list", {
|
|
1016
|
-
query: listParams(pageSize, pageToken, kind)
|
|
1180
|
+
query: listParams(pageSize, pageToken, kind, source, sourceRef)
|
|
1017
1181
|
})
|
|
1018
1182
|
);
|
|
1019
1183
|
return buildAipPage(
|
|
1020
1184
|
data,
|
|
1021
1185
|
"conversations",
|
|
1022
1186
|
parseListItem,
|
|
1023
|
-
(token) => this.listPage(pageSize, token, kind)
|
|
1187
|
+
(token) => this.listPage(pageSize, token, kind, source, sourceRef)
|
|
1024
1188
|
);
|
|
1025
1189
|
}
|
|
1026
1190
|
/**
|
|
@@ -1046,11 +1210,17 @@ var ModusResource = class {
|
|
|
1046
1210
|
this.conversations = new ModusConversationsResource(http, config);
|
|
1047
1211
|
}
|
|
1048
1212
|
/**
|
|
1049
|
-
*
|
|
1213
|
+
* Compose full-environment context for an intent without running chat.
|
|
1050
1214
|
*
|
|
1051
|
-
* @param message -
|
|
1052
|
-
* @param options.limit -
|
|
1053
|
-
* @returns
|
|
1215
|
+
* @param message - Natural-language intent used to select context.
|
|
1216
|
+
* @param options.limit - Maximum context items to return. Omit to return all selected items.
|
|
1217
|
+
* @returns Composition metadata (counts / session id). Use `chat` for a reply.
|
|
1218
|
+
*
|
|
1219
|
+
* @example
|
|
1220
|
+
* ```ts
|
|
1221
|
+
* const ctx = await client.modus.getContext('What tables describe revenue?', { limit: 5 })
|
|
1222
|
+
* console.log(ctx.originalCount, ctx.sessionId)
|
|
1223
|
+
* ```
|
|
1054
1224
|
*/
|
|
1055
1225
|
async getContext(message, options = {}) {
|
|
1056
1226
|
const data = await invokeWithRetry(this.config, this.http, "ModusContextController_compose", {
|
|
@@ -1059,29 +1229,48 @@ var ModusResource = class {
|
|
|
1059
1229
|
return data;
|
|
1060
1230
|
}
|
|
1061
1231
|
/**
|
|
1062
|
-
* Send a message to Modus
|
|
1232
|
+
* Send a message to Modus and wait for the complete reply.
|
|
1063
1233
|
*
|
|
1064
|
-
* @param message -
|
|
1234
|
+
* @param message - User message text.
|
|
1065
1235
|
* @param options.model - Required model id (e.g. `"claude-sonnet-5"`).
|
|
1066
|
-
* @param options.threadId - Continue an existing conversation.
|
|
1067
|
-
* @returns Chat result
|
|
1236
|
+
* @param options.threadId - Continue an existing conversation; omit to start new.
|
|
1237
|
+
* @returns Chat result: `content`, `threadId` (for follow-ups), `runId`.
|
|
1068
1238
|
*
|
|
1069
1239
|
* @example
|
|
1070
1240
|
* ```ts
|
|
1071
|
-
* const result = await client.modus.chat('What tables describe revenue?', {
|
|
1241
|
+
* const result = await client.modus.chat('What tables describe revenue?', {
|
|
1242
|
+
* model: 'claude-sonnet-5',
|
|
1243
|
+
* })
|
|
1072
1244
|
* console.log(result.content, result.threadId)
|
|
1245
|
+
* const follow = await client.modus.chat('Break that down by region.', {
|
|
1246
|
+
* model: 'claude-sonnet-5',
|
|
1247
|
+
* threadId: result.threadId,
|
|
1248
|
+
* })
|
|
1073
1249
|
* ```
|
|
1074
1250
|
*/
|
|
1075
1251
|
chat(message, options) {
|
|
1076
1252
|
return modusChatBuffered(this.http, message, options);
|
|
1077
1253
|
}
|
|
1078
1254
|
/**
|
|
1079
|
-
* Stream a Modus reply token by token.
|
|
1255
|
+
* Stream a Modus reply token by token (SSE).
|
|
1080
1256
|
*
|
|
1081
|
-
*
|
|
1257
|
+
* The request starts when you consume `textStream()` or `eventStream()`.
|
|
1258
|
+
*
|
|
1259
|
+
* @param message - User message text.
|
|
1082
1260
|
* @param options.model - Required model id (e.g. `"claude-sonnet-5"`).
|
|
1083
|
-
* @param options.threadId - Continue an existing conversation.
|
|
1084
|
-
* @returns Chat stream.
|
|
1261
|
+
* @param options.threadId - Continue an existing conversation; omit to start new.
|
|
1262
|
+
* @returns Chat stream — iterate `textStream()` for tokens.
|
|
1263
|
+
*
|
|
1264
|
+
* @example
|
|
1265
|
+
* ```ts
|
|
1266
|
+
* const stream = client.modus.chatStream('Summarize ARR in three bullets.', {
|
|
1267
|
+
* model: 'claude-sonnet-5',
|
|
1268
|
+
* })
|
|
1269
|
+
* for await (const token of stream.textStream()) {
|
|
1270
|
+
* process.stdout.write(token)
|
|
1271
|
+
* }
|
|
1272
|
+
* console.log(stream.getFinalResult().threadId)
|
|
1273
|
+
* ```
|
|
1085
1274
|
*/
|
|
1086
1275
|
chatStream(message, options) {
|
|
1087
1276
|
return modusChatStreamSession(this.http, this.config, message, options);
|
|
@@ -1110,6 +1299,15 @@ var ScopesResource = class {
|
|
|
1110
1299
|
*
|
|
1111
1300
|
* @param scopeId - Scope numeric id or slug.
|
|
1112
1301
|
* @returns Conversations resource for the scope.
|
|
1302
|
+
*
|
|
1303
|
+
* @example
|
|
1304
|
+
* ```ts
|
|
1305
|
+
* for await (const row of (
|
|
1306
|
+
* await client.scopes.conversations(scopeId).list({ pageSize: 10 })
|
|
1307
|
+
* ).autoPagingIter()) {
|
|
1308
|
+
* console.log(row.threadId, row.firstMessage)
|
|
1309
|
+
* }
|
|
1310
|
+
* ```
|
|
1113
1311
|
*/
|
|
1114
1312
|
conversations(scopeId) {
|
|
1115
1313
|
return new ScopeConversationsResource(this.http, this.config, scopeId);
|
|
@@ -1122,7 +1320,14 @@ var ScopesResource = class {
|
|
|
1122
1320
|
* @param options.search - Case-insensitive substring filter on the scope name.
|
|
1123
1321
|
* @param options.view - `"active"` (deployed) or `"draft"`.
|
|
1124
1322
|
* @param options.managerId - Only scopes supervised by this manager scope id.
|
|
1125
|
-
* @returns Page of scopes.
|
|
1323
|
+
* @returns Page of scopes — use `.autoPagingIter()` for all pages.
|
|
1324
|
+
*
|
|
1325
|
+
* @example
|
|
1326
|
+
* ```ts
|
|
1327
|
+
* for await (const scope of (await client.scopes.list()).autoPagingIter()) {
|
|
1328
|
+
* console.log(scope.id, scope.name, scope.status)
|
|
1329
|
+
* }
|
|
1330
|
+
* ```
|
|
1126
1331
|
*/
|
|
1127
1332
|
list(options = {}) {
|
|
1128
1333
|
const pageSize = options.pageSize ?? 25;
|
|
@@ -1154,7 +1359,13 @@ var ScopesResource = class {
|
|
|
1154
1359
|
* @param scopeId - Scope numeric id or slug.
|
|
1155
1360
|
* @param options.view - `"active"` (deployed) or `"draft"`.
|
|
1156
1361
|
* @throws {NotFoundError} When no scope matches the id or slug.
|
|
1157
|
-
* @returns Scope.
|
|
1362
|
+
* @returns Scope (`id`, `name`, `status`, …).
|
|
1363
|
+
*
|
|
1364
|
+
* @example
|
|
1365
|
+
* ```ts
|
|
1366
|
+
* const scope = await client.scopes.get('revenue-analysis')
|
|
1367
|
+
* console.log(scope.name, scope.status)
|
|
1368
|
+
* ```
|
|
1158
1369
|
*/
|
|
1159
1370
|
async get(scopeId, options = {}) {
|
|
1160
1371
|
validateId(scopeId, "scope_id");
|
|
@@ -1166,12 +1377,20 @@ var ScopesResource = class {
|
|
|
1166
1377
|
return parseScope(data);
|
|
1167
1378
|
}
|
|
1168
1379
|
/**
|
|
1169
|
-
*
|
|
1380
|
+
* Compose context this scope would use for an intent, without running chat.
|
|
1170
1381
|
*
|
|
1171
1382
|
* @param scopeId - Scope numeric id or slug.
|
|
1172
|
-
* @param message -
|
|
1173
|
-
* @param options.limit -
|
|
1174
|
-
* @returns
|
|
1383
|
+
* @param message - Natural-language intent used to select context.
|
|
1384
|
+
* @param options.limit - Maximum context items to return. Omit to return all selected items.
|
|
1385
|
+
* @returns Composition metadata. Use `chat` when you need an assistant reply.
|
|
1386
|
+
*
|
|
1387
|
+
* @example
|
|
1388
|
+
* ```ts
|
|
1389
|
+
* const ctx = await client.scopes.getContext(scopeId, 'Which tables describe churn?', {
|
|
1390
|
+
* limit: 5,
|
|
1391
|
+
* })
|
|
1392
|
+
* console.log(ctx.originalCount, ctx.sessionId)
|
|
1393
|
+
* ```
|
|
1175
1394
|
*/
|
|
1176
1395
|
async getContext(scopeId, message, options = {}) {
|
|
1177
1396
|
validateId(scopeId, "scope_id");
|
|
@@ -1182,32 +1401,53 @@ var ScopesResource = class {
|
|
|
1182
1401
|
return data;
|
|
1183
1402
|
}
|
|
1184
1403
|
/**
|
|
1185
|
-
* Send a message to a scope and
|
|
1404
|
+
* Send a message to a published scope and wait for the complete reply.
|
|
1186
1405
|
*
|
|
1187
|
-
*
|
|
1188
|
-
*
|
|
1406
|
+
* For the org-wide assistant use `client.modus.chat` instead.
|
|
1407
|
+
*
|
|
1408
|
+
* @param scopeId - Scope numeric id or slug (must be active for chat).
|
|
1409
|
+
* @param message - User message text.
|
|
1189
1410
|
* @param options.model - Required model id (e.g. `"claude-sonnet-5"`).
|
|
1190
|
-
* @param options.threadId - Continue an existing conversation.
|
|
1191
|
-
* @returns Chat result
|
|
1411
|
+
* @param options.threadId - Continue an existing conversation; omit to start new.
|
|
1412
|
+
* @returns Chat result: `content`, `threadId`, `runId`.
|
|
1192
1413
|
*
|
|
1193
1414
|
* @example
|
|
1194
1415
|
* ```ts
|
|
1195
|
-
* const result = await client.scopes.chat(scopeId, '
|
|
1416
|
+
* const result = await client.scopes.chat(scopeId, 'What is our ARR trend?', {
|
|
1417
|
+
* model: 'claude-sonnet-5',
|
|
1418
|
+
* })
|
|
1196
1419
|
* console.log(result.content, result.threadId)
|
|
1420
|
+
* const follow = await client.scopes.chat(scopeId, 'Break that down by segment.', {
|
|
1421
|
+
* model: 'claude-sonnet-5',
|
|
1422
|
+
* threadId: result.threadId,
|
|
1423
|
+
* })
|
|
1197
1424
|
* ```
|
|
1198
1425
|
*/
|
|
1199
1426
|
chat(scopeId, message, options) {
|
|
1200
1427
|
return chatBuffered(this.http, "scopes", scopeId, message, options);
|
|
1201
1428
|
}
|
|
1202
1429
|
/**
|
|
1203
|
-
* Stream a scope reply token by token.
|
|
1430
|
+
* Stream a scope reply token by token (SSE).
|
|
1431
|
+
*
|
|
1432
|
+
* The request starts when you consume `textStream()` or `eventStream()`.
|
|
1204
1433
|
*
|
|
1205
1434
|
* @param scopeId - Scope numeric id or slug.
|
|
1206
|
-
* @param message -
|
|
1435
|
+
* @param message - User message text.
|
|
1207
1436
|
* @param options.model - Required model id (e.g. `"claude-sonnet-5"`).
|
|
1208
|
-
* @param options.threadId - Continue an existing conversation.
|
|
1437
|
+
* @param options.threadId - Continue an existing conversation; omit to start new.
|
|
1209
1438
|
* @param options.version - `"published"` or `"draft"`.
|
|
1210
|
-
* @returns Chat stream.
|
|
1439
|
+
* @returns Chat stream — iterate `textStream()` for tokens.
|
|
1440
|
+
*
|
|
1441
|
+
* @example
|
|
1442
|
+
* ```ts
|
|
1443
|
+
* const stream = client.scopes.chatStream(scopeId, 'Summarize in three bullets.', {
|
|
1444
|
+
* model: 'claude-sonnet-5',
|
|
1445
|
+
* })
|
|
1446
|
+
* for await (const token of stream.textStream()) {
|
|
1447
|
+
* process.stdout.write(token)
|
|
1448
|
+
* }
|
|
1449
|
+
* console.log(stream.getFinalResult().threadId)
|
|
1450
|
+
* ```
|
|
1211
1451
|
*/
|
|
1212
1452
|
chatStream(scopeId, message, options) {
|
|
1213
1453
|
return chatStreamSession(this.http, this.config, "scopes", scopeId, message, options);
|
|
@@ -1286,6 +1526,7 @@ var Modus = class extends ModusClientBase {
|
|
|
1286
1526
|
this.context = new ContextResource(this.http, this.config);
|
|
1287
1527
|
this.connections = new ConnectionsResource(this.http, this.config);
|
|
1288
1528
|
this.suggestions = new SuggestionsResource(this.http, this.config);
|
|
1529
|
+
this.ingestedData = new IngestedDataResource(this.http, this.config);
|
|
1289
1530
|
}
|
|
1290
1531
|
};
|
|
1291
1532
|
export {
|