@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.
@@ -1,22 +1,31 @@
1
1
  interface ModusOptions {
2
+ /** Modus API key. Falls back to the `MODUS_API_KEY` environment variable. */
2
3
  apiKey?: string;
4
+ /** API origin without a path suffix (default `https://api.getmodus.com`). */
3
5
  baseUrl?: string;
4
- /** Agent host origin for streaming runs (default https://agent.getmodus.com). */
6
+ /**
7
+ * Agent-host origin for streaming runs.
8
+ * @internal Staging/local escape hatch — not part of the public client surface.
9
+ */
5
10
  agentHost?: string;
6
11
  /**
7
- * Optional Clerk organization id for agent-host run bodies. Usually omit —
8
- * agent-service uses the PAT principal's org.
12
+ * Optional org id for agent-host run bodies.
13
+ * @internal Usually omit; the PAT principal's org is used.
9
14
  */
10
15
  organizationId?: string;
11
16
  /**
12
- * Override service-specific API origins, for example:
13
- * `{ 'agent-service': 'http://localhost:3130' }`.
17
+ * Per-service origin overrides (e.g. agent-service).
18
+ * @internal Local/dev escape hatch — not part of the public client surface.
14
19
  */
15
20
  baseUrls?: Record<string, string>;
16
- /** Request timeout in milliseconds. */
21
+ /** Request timeout in milliseconds (default 300000). */
17
22
  timeoutMs?: number;
23
+ /** Retries on rate limits and server errors (default 2). */
18
24
  maxRetries?: number;
19
- /** Test injection only. */
25
+ /**
26
+ * Custom fetch implementation.
27
+ * @internal Test injection only.
28
+ */
20
29
  fetch?: typeof fetch;
21
30
  }
22
31
  interface ModusConfig {
@@ -972,6 +981,28 @@ interface paths {
972
981
  patch?: never;
973
982
  trace?: never;
974
983
  };
984
+ "/api/v1/tools": {
985
+ parameters: {
986
+ query?: never;
987
+ header?: never;
988
+ path?: never;
989
+ cookie?: never;
990
+ };
991
+ /**
992
+ * List available tools
993
+ * @description Returns a page of known tool/integration surfaces a scope can select in its toolset, with the fixed actions for built-in tools.
994
+ *
995
+ * **Requires:** `scopes:read`
996
+ */
997
+ get: operations["ToolsController_list"];
998
+ put?: never;
999
+ post?: never;
1000
+ delete?: never;
1001
+ options?: never;
1002
+ head?: never;
1003
+ patch?: never;
1004
+ trace?: never;
1005
+ };
975
1006
  "/api/v1/usage": {
976
1007
  parameters: {
977
1008
  query?: never;
@@ -1133,7 +1164,7 @@ interface paths {
1133
1164
  put?: never;
1134
1165
  /**
1135
1166
  * Deploy a workflow
1136
- * @description Publishes the workflow’s latest draft as the active version. The first deploy enables the workflow’s schedule; later deploys keep its enabled state. Returns the published workflow and a `deployedAt` timestamp.
1167
+ * @description Publishes the workflow’s latest draft as the active version. The first deploy enables the workflow’s schedule; later deploys keep its enabled state. Returns the published workflow and a `deployedAt` timestamp. Returns `422` when an action node is unconfigured; `info.invalidNodes` names each node and field.
1137
1168
  *
1138
1169
  * **Requires:** `workflows:write`
1139
1170
  */
@@ -2982,6 +3013,15 @@ interface components {
2982
3013
  */
2983
3014
  nextPageToken: string | null;
2984
3015
  };
3016
+ ListToolsResponseDto: {
3017
+ /** @description Known tool/integration surfaces a scope can select in its toolset. */
3018
+ tools: components["schemas"]["ToolCatalogEntryDto"][];
3019
+ /**
3020
+ * @description Opaque token for the next page; null when this was the last page. Pass as `pageToken` on the next request.
3021
+ * @example null
3022
+ */
3023
+ nextPageToken: string | null;
3024
+ };
2985
3025
  ListUsageResponseDto: {
2986
3026
  /** @description Organization id (`org_xxx`) the result is scoped to. */
2987
3027
  org_id: string;
@@ -3524,6 +3564,47 @@ interface components {
3524
3564
  */
3525
3565
  active: boolean;
3526
3566
  };
3567
+ ToolCatalogActionDto: {
3568
+ /**
3569
+ * @description Stable action id — the exact string to put in `toolset.<id>.actions`.
3570
+ * @example list_dags
3571
+ */
3572
+ name: string;
3573
+ /**
3574
+ * @description Human-readable label for display.
3575
+ * @example List DAGs
3576
+ */
3577
+ displayName: string;
3578
+ /**
3579
+ * @description What this action does.
3580
+ * @example List the selected DAGs with their schedule, owners, tags, and paused state.
3581
+ */
3582
+ description: string;
3583
+ };
3584
+ ToolCatalogEntryDto: {
3585
+ /**
3586
+ * @description Stable id — use as the key in a toolset object, e.g. `{ [id]: { enabled: true } }`.
3587
+ * @example sql_runner
3588
+ */
3589
+ id: string;
3590
+ /**
3591
+ * @description Human-readable name for display.
3592
+ * @example SQL Runner
3593
+ */
3594
+ displayName: string;
3595
+ /**
3596
+ * @description Grouping category, e.g. "data", "messaging", "general".
3597
+ * @example data
3598
+ */
3599
+ category?: string;
3600
+ /**
3601
+ * @description True if this tool requires a connected integration/account before it can be used.
3602
+ * @example false
3603
+ */
3604
+ requiresConnection: boolean;
3605
+ /** @description Fixed set of actions this tool exposes. Present only when the action list does not depend on a live connection (built-in tools). Connected integrations expose connection-specific actions not listed here. */
3606
+ actions?: components["schemas"]["ToolCatalogActionDto"][];
3607
+ };
3527
3608
  ToolsetDto: {
3528
3609
  /**
3529
3610
  * @description List of tools the scope may invoke.
@@ -4106,7 +4187,14 @@ interface components {
4106
4187
  images?: components["schemas"]["ImageAttachmentDto"][];
4107
4188
  documents?: components["schemas"]["DocumentAttachmentDto"][];
4108
4189
  };
4109
- CancelRunDto: Record<string, never>;
4190
+ CancelRunDto: {
4191
+ /** @description Organization the run belongs to. Omit for PAT/SDK callers — falls back to the authenticated principal's org. */
4192
+ organizationId?: string;
4193
+ /** @description Human-readable reason for the cancel, logged server-side only. */
4194
+ reason?: string;
4195
+ /** @description Redis Stream id of the last SSE frame the client rendered, so the persisted partial message matches what the client saw. Falls back to the server-side accumulator when absent. */
4196
+ lastSeenEventId?: string;
4197
+ };
4110
4198
  DocumentAttachmentDto: {
4111
4199
  /** @description Original file name. */
4112
4200
  fileName: string;
@@ -4119,7 +4207,12 @@ interface components {
4119
4207
  sizeBytes?: number;
4120
4208
  summary?: string | null;
4121
4209
  };
4122
- EditQueuedRunDto: Record<string, never>;
4210
+ EditQueuedRunDto: {
4211
+ /** @description Organization the run belongs to. Omit for PAT/SDK callers — falls back to the authenticated principal's org. */
4212
+ organizationId?: string;
4213
+ /** @description New payload replacing the queued run. */
4214
+ nextRun: components["schemas"]["FollowUpRunDto"];
4215
+ };
4123
4216
  ErrorEnvelopeDto1: {
4124
4217
  /** @description Modus-specific machine code. */
4125
4218
  code: components["schemas"]["ApiErrorCode"];
@@ -4142,6 +4235,38 @@ interface components {
4142
4235
  ErrorResponseDto1: {
4143
4236
  error: components["schemas"]["ErrorEnvelopeDto1"];
4144
4237
  };
4238
+ FollowUpRunDto: {
4239
+ /** @description The user message to send. */
4240
+ message: string;
4241
+ /** @description Opaque client-generated conversation token for continuity. The server NEVER derives the run target identity (scope/workflow/modus) from this string — target identity comes only from the request path and DTO (see RunTarget). It is used solely to thread successive turns of the same conversation together. */
4242
+ sessionId: string;
4243
+ /** @description Organization id. Ignored for authenticated callers — the server uses the principal's org. */
4244
+ organizationId?: string;
4245
+ /**
4246
+ * @description Saved version to run (scope/workflow; ignored for Modus).
4247
+ * @enum {string}
4248
+ */
4249
+ version?: "published" | "draft";
4250
+ /** @description Document-scoped conversation thread id. */
4251
+ fileThreadId?: string;
4252
+ config?: components["schemas"]["RunConfigDto"];
4253
+ attachments?: components["schemas"]["AttachmentsDto"];
4254
+ userContext?: components["schemas"]["UserContextDto"];
4255
+ supplementalContext?: components["schemas"]["SupplementalContextDto"];
4256
+ /** @description Origin of the run. */
4257
+ source?: components["schemas"]["RunSource"];
4258
+ /** @description Client-supplied run id (Idempotency-Key header wins). */
4259
+ runId?: string;
4260
+ /**
4261
+ * @description Streaming protocol version. Version 2 supports assistant-content replacement events.
4262
+ * @enum {number}
4263
+ */
4264
+ streamProtocolVersion?: 2;
4265
+ experimentalFeatures?: boolean;
4266
+ debug?: boolean;
4267
+ /** @description Saved scope ids to subordinate under this Modus run. */
4268
+ subordinateSkillIds?: number[];
4269
+ };
4145
4270
  ImageAttachmentDto: {
4146
4271
  data?: string;
4147
4272
  mimeType?: string;
@@ -4149,7 +4274,14 @@ interface components {
4149
4274
  s3Key?: string;
4150
4275
  uploadId?: string;
4151
4276
  };
4152
- InterruptRunDto: Record<string, never>;
4277
+ InterruptRunDto: {
4278
+ /** @description Organization the run belongs to. Omit for PAT/SDK callers — falls back to the authenticated principal's org. */
4279
+ organizationId?: string;
4280
+ /** @description Redis Stream id of the last SSE frame the client rendered (see CancelRunDto). */
4281
+ lastSeenEventId?: string;
4282
+ /** @description Follow-up message that supersedes the current turn. */
4283
+ nextRun: components["schemas"]["FollowUpRunDto"];
4284
+ };
4153
4285
  ModusRunDto: {
4154
4286
  /** @description The user message to send. */
4155
4287
  message: string;
@@ -4305,8 +4437,8 @@ interface components {
4305
4437
  userId?: string;
4306
4438
  };
4307
4439
  WorkflowActionDto: {
4308
- /** @description Organization ID the run belongs to. Must match the authenticated principal's org. */
4309
- organizationId: string;
4440
+ /** @description Organization the run belongs to. Omit for PAT/SDK callers — falls back to the authenticated principal's org. */
4441
+ organizationId?: string;
4310
4442
  /** @description Client-generated session identifier. */
4311
4443
  sessionId: string;
4312
4444
  /** @description File thread ID for document-scoped execution. */
@@ -12047,6 +12179,111 @@ interface operations {
12047
12179
  };
12048
12180
  };
12049
12181
  };
12182
+ ToolsController_list: {
12183
+ parameters: {
12184
+ query?: {
12185
+ /** @description Opaque page token from a previous response's `nextPageToken`. Omit for the first page. */
12186
+ pageToken?: string;
12187
+ /** @description Max items per page. Defaults to 25, clamped to 100. */
12188
+ pageSize?: number;
12189
+ };
12190
+ header?: never;
12191
+ path?: never;
12192
+ cookie?: never;
12193
+ };
12194
+ requestBody?: never;
12195
+ responses: {
12196
+ 200: {
12197
+ headers: {
12198
+ [name: string]: unknown;
12199
+ };
12200
+ content: {
12201
+ "application/json": components["schemas"]["ListToolsResponseDto"];
12202
+ };
12203
+ };
12204
+ /** @description Malformed request — invalid query parameters or request body (`code: BAD_REQUEST`). */
12205
+ 400: {
12206
+ headers: {
12207
+ [name: string]: unknown;
12208
+ };
12209
+ content: {
12210
+ /**
12211
+ * @example {
12212
+ * "error": {
12213
+ * "code": "BAD_REQUEST",
12214
+ * "status": "INVALID_ARGUMENT",
12215
+ * "message": "Invalid value for query parameter `pageSize`.",
12216
+ * "requestId": "req_01HQ7K8ABCDEFGHIJKLMNOPQRS"
12217
+ * }
12218
+ * }
12219
+ */
12220
+ "application/json": components["schemas"]["ErrorResponseDto"];
12221
+ };
12222
+ };
12223
+ /** @description Missing, invalid, or expired access token (`code: UNAUTHORIZED`). */
12224
+ 401: {
12225
+ headers: {
12226
+ [name: string]: unknown;
12227
+ };
12228
+ content: {
12229
+ /**
12230
+ * @example {
12231
+ * "error": {
12232
+ * "code": "UNAUTHORIZED",
12233
+ * "status": "UNAUTHENTICATED",
12234
+ * "message": "Missing or invalid access token.",
12235
+ * "requestId": "req_01HQ7K8ABCDEFGHIJKLMNOPQRS"
12236
+ * }
12237
+ * }
12238
+ */
12239
+ "application/json": components["schemas"]["ErrorResponseDto"];
12240
+ };
12241
+ };
12242
+ /** @description Authenticated, but the token lacks a required scope (`code: FORBIDDEN`). The missing scopes are listed in `info`. */
12243
+ 403: {
12244
+ headers: {
12245
+ [name: string]: unknown;
12246
+ };
12247
+ content: {
12248
+ /**
12249
+ * @example {
12250
+ * "error": {
12251
+ * "code": "FORBIDDEN",
12252
+ * "status": "PERMISSION_DENIED",
12253
+ * "message": "Missing required scope(s) for this operation.",
12254
+ * "requestId": "req_01HQ7K8ABCDEFGHIJKLMNOPQRS",
12255
+ * "info": {
12256
+ * "missing": [
12257
+ * "<required-scope>"
12258
+ * ]
12259
+ * }
12260
+ * }
12261
+ * }
12262
+ */
12263
+ "application/json": components["schemas"]["ErrorResponseDto"];
12264
+ };
12265
+ };
12266
+ /** @description An unexpected server error occurred (`code: INTERNAL_ERROR`). */
12267
+ 500: {
12268
+ headers: {
12269
+ [name: string]: unknown;
12270
+ };
12271
+ content: {
12272
+ /**
12273
+ * @example {
12274
+ * "error": {
12275
+ * "code": "INTERNAL_ERROR",
12276
+ * "status": "INTERNAL",
12277
+ * "message": "An unexpected error occurred.",
12278
+ * "requestId": "req_01HQ7K8ABCDEFGHIJKLMNOPQRS"
12279
+ * }
12280
+ * }
12281
+ */
12282
+ "application/json": components["schemas"]["ErrorResponseDto"];
12283
+ };
12284
+ };
12285
+ };
12286
+ };
12050
12287
  UsageController_list: {
12051
12288
  parameters: {
12052
12289
  query: {
@@ -16294,6 +16531,16 @@ declare const OPERATIONS: {
16294
16531
  readonly requestSchema: "RecordSuggestionEventDto";
16295
16532
  readonly responseSchema: null;
16296
16533
  };
16534
+ readonly ToolsController_list: {
16535
+ readonly method: "GET";
16536
+ readonly path: "/api/v1/tools";
16537
+ readonly service: "modus-api";
16538
+ readonly serverUrl: "https://api.getmodus.com";
16539
+ readonly pathParams: readonly [];
16540
+ readonly queryParams: readonly ["pageToken", "pageSize"];
16541
+ readonly requestSchema: null;
16542
+ readonly responseSchema: "ListToolsResponseDto";
16543
+ };
16297
16544
  readonly UsageController_list: {
16298
16545
  readonly method: "GET";
16299
16546
  readonly path: "/api/v1/usage";
@@ -16548,14 +16795,42 @@ declare class HttpClient {
16548
16795
  streamPost(path: string, json?: unknown, options?: RequestOptions): AsyncGenerator<string>;
16549
16796
  }
16550
16797
 
16798
+ /**
16799
+ * A single page of results from a paginated list call.
16800
+ *
16801
+ * Each response includes an `items` array and an optional `nextPageToken`.
16802
+ * Pass that token back on the next list request to fetch the following page.
16803
+ * Iterating a `Page` directly yields only the current page's items; use
16804
+ * {@link Page.autoPagingIter} to walk every page automatically.
16805
+ */
16551
16806
  declare class Page<T> {
16807
+ /** Items returned for this page. */
16552
16808
  readonly items: T[];
16809
+ /** Opaque token for the next page, or `undefined` when there are no more results. */
16553
16810
  readonly nextPageToken?: string;
16554
16811
  private readonly fetchPage;
16555
16812
  constructor(items: T[], nextPageToken: string | undefined, fetchPage: (token: string) => Page<T> | Promise<Page<T>>);
16813
+ /**
16814
+ * Whether another page of results is available.
16815
+ *
16816
+ * @returns `true` when {@link Page.nextPageToken} is set.
16817
+ */
16556
16818
  hasNextPage(): boolean;
16819
+ /**
16820
+ * Fetch the next page using {@link Page.nextPageToken}.
16821
+ *
16822
+ * @returns The following page of results.
16823
+ * @throws {Error} When there is no next page. Check {@link Page.hasNextPage} first.
16824
+ */
16557
16825
  getNextPage(): Promise<Page<T>>;
16826
+ /**
16827
+ * Async-iterate over all items across every page, fetching additional pages as needed.
16828
+ *
16829
+ * @returns An async generator yielding every item in the result set.
16830
+ * @throws {ModusError} When a follow-up page request fails.
16831
+ */
16558
16832
  autoPagingIter(): AsyncGenerator<T>;
16833
+ /** Iterate over the current page's items only. */
16559
16834
  [Symbol.iterator](): Iterator<T>;
16560
16835
  }
16561
16836
 
@@ -16666,10 +16941,23 @@ interface CustomContextItemDeletion {
16666
16941
  uid: string;
16667
16942
  contextType: string;
16668
16943
  }
16944
+ /**
16945
+ * Create, update, and delete custom context items.
16946
+ */
16669
16947
  declare class CustomContextItemsResource {
16670
16948
  private readonly http;
16671
16949
  private readonly config;
16950
+ /** @internal */
16672
16951
  constructor(http: HttpClient, config: ModusConfig);
16952
+ /**
16953
+ * List custom context items.
16954
+ *
16955
+ * @param options.pageSize - Maximum items per page (default 25).
16956
+ * @param options.pageToken - Opaque token from a previous page.
16957
+ * @param options.searchQuery - Free-text search filter.
16958
+ * @param options.topics - Filter to items tagged with any of these topics.
16959
+ * @returns A page of custom context items.
16960
+ */
16673
16961
  list(options?: {
16674
16962
  pageSize?: number;
16675
16963
  pageToken?: string;
@@ -16677,26 +16965,95 @@ declare class CustomContextItemsResource {
16677
16965
  topics?: string[];
16678
16966
  }): Promise<Page<ContextItem>>;
16679
16967
  private listPage;
16968
+ /**
16969
+ * Retrieve a custom context item by uid.
16970
+ *
16971
+ * @param uid - Item uid.
16972
+ * @returns The custom context item.
16973
+ * @throws {NotFoundError} When no item matches the uid.
16974
+ */
16680
16975
  get(uid: string): Promise<ContextItem>;
16976
+ /**
16977
+ * Create a custom context item.
16978
+ *
16979
+ * @param input.kind - Item kind (`source`, `collection`, `entity`, `field`, or `entity_samples`).
16980
+ * @param input.sourceId - Source identifier for the item hierarchy.
16981
+ * @param input.name - Display name when applicable.
16982
+ * @param input.content - Item payload.
16983
+ * @param input.idempotencyKey - Optional idempotency key for safe retries.
16984
+ * @returns Created item ids and hierarchy metadata.
16985
+ *
16986
+ * @example
16987
+ * ```ts
16988
+ * const created = await client.context.customItems.create({
16989
+ * kind: 'entity',
16990
+ * sourceId: 'my-source',
16991
+ * name: 'Q3 churn notes',
16992
+ * content: { summary: 'Key findings…' },
16993
+ * })
16994
+ * ```
16995
+ */
16681
16996
  create(input: CreateCustomContextItemInput): Promise<CreatedCustomContextItem>;
16997
+ /**
16998
+ * Create multiple custom context items in one request.
16999
+ *
17000
+ * @param inputs - Items to create (same fields as {@link CustomContextItemsResource.create}).
17001
+ * @returns Created item metadata for each input.
17002
+ *
17003
+ * @example
17004
+ * ```ts
17005
+ * const created = await client.context.customItems.batchCreate([
17006
+ * { kind: 'field', sourceId: 'src', fieldName: 'region', dataType: 'string' },
17007
+ * { kind: 'field', sourceId: 'src', fieldName: 'amount', dataType: 'number' },
17008
+ * ])
17009
+ * ```
17010
+ */
16682
17011
  batchCreate(inputs: CreateCustomContextItemInput[]): Promise<CreatedCustomContextItem[]>;
17012
+ /**
17013
+ * Update a custom context item.
17014
+ *
17015
+ * @param uid - Item uid.
17016
+ * @param input - Fields to change (kind and hierarchy ids cannot be changed).
17017
+ * @returns The updated item uid.
17018
+ */
16683
17019
  update(uid: string, input: UpdateCustomContextItemInput): Promise<{
16684
17020
  uid: string;
16685
17021
  }>;
17022
+ /**
17023
+ * Delete a custom context item.
17024
+ *
17025
+ * @param uid - Item uid.
17026
+ * @returns Deletion confirmation with uid and context type.
17027
+ */
16686
17028
  delete(uid: string): Promise<CustomContextItemDeletion>;
16687
17029
  }
16688
17030
 
16689
- /** Read access to a scope's conversation threads (`/api/v1/scopes/:id/conversations`). */
17031
+ /** Conversation threads for a single scope. */
16690
17032
  declare class ScopeConversationsResource {
16691
17033
  private readonly http;
16692
17034
  private readonly config;
16693
17035
  private readonly scopeId;
16694
17036
  constructor(http: HttpClient, config: ModusConfig, scopeId: number | string);
17037
+ /**
17038
+ * List conversation threads for this scope, newest first.
17039
+ *
17040
+ * @param options.pageSize - Items per page (default 25).
17041
+ * @param options.pageToken - Opaque token from a previous page.
17042
+ * @returns Page of conversation list items.
17043
+ */
16695
17044
  list(options?: {
16696
17045
  pageSize?: number;
16697
17046
  pageToken?: string;
16698
17047
  }): Promise<Page<ConversationListItem>>;
16699
17048
  private listPage;
17049
+ /**
17050
+ * Retrieve a thread with full message history.
17051
+ *
17052
+ * @param threadId - Conversation thread id.
17053
+ * @param options.messageLimit - Maximum messages to return (1–100).
17054
+ * @param options.beforeMessageIndex - Return messages before this index (requires messageLimit).
17055
+ * @returns Conversation with messages.
17056
+ */
16700
17057
  get(threadId: string, options?: {
16701
17058
  messageLimit?: number;
16702
17059
  beforeMessageIndex?: number;