@getmodus/sdk 0.7.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/dist/index.cjs CHANGED
@@ -191,7 +191,7 @@ var OPERATIONS = {
191
191
  service: "modus-api",
192
192
  serverUrl: "https://api.getmodus.com",
193
193
  pathParams: [],
194
- queryParams: ["pageToken", "pageSize", "contextTypes", "verificationStatuses", "searchQuery", "topics"],
194
+ queryParams: ["pageToken", "pageSize", "contextTypes", "verificationStatuses", "searchQuery", "topics", "connectionIds", "parentUids", "ancestorUids"],
195
195
  requestSchema: null,
196
196
  responseSchema: "ListContextItemsResponseDto"
197
197
  },
@@ -215,6 +215,16 @@ var OPERATIONS = {
215
215
  requestSchema: "LookupContextItemDto",
216
216
  responseSchema: "LookupContextItemResponseDto"
217
217
  },
218
+ "ContextItemsController_move": {
219
+ method: "POST",
220
+ path: "/api/v1/context/items/{uid}/move",
221
+ service: "modus-api",
222
+ serverUrl: "https://api.getmodus.com",
223
+ pathParams: ["uid"],
224
+ queryParams: [],
225
+ requestSchema: "MoveContextItemDto",
226
+ responseSchema: "MoveContextItemResponseDto"
227
+ },
218
228
  "ContextItemsController_update": {
219
229
  method: "PATCH",
220
230
  path: "/api/v1/context/items/{uid}",
@@ -755,6 +765,46 @@ var OPERATIONS = {
755
765
  requestSchema: null,
756
766
  responseSchema: "ListConversationsResponseDto"
757
767
  },
768
+ "ScopeInterfacesController_add": {
769
+ method: "POST",
770
+ path: "/api/v1/scopes/{id}/interfaces",
771
+ service: "modus-api",
772
+ serverUrl: "https://api.getmodus.com",
773
+ pathParams: ["id"],
774
+ queryParams: [],
775
+ requestSchema: "AddScopeInterfaceDto",
776
+ responseSchema: "ScopeInterfaceDto"
777
+ },
778
+ "ScopeInterfacesController_delete": {
779
+ method: "DELETE",
780
+ path: "/api/v1/scopes/{id}/interfaces/{interfaceId}",
781
+ service: "modus-api",
782
+ serverUrl: "https://api.getmodus.com",
783
+ pathParams: ["id", "interfaceId"],
784
+ queryParams: [],
785
+ requestSchema: null,
786
+ responseSchema: null
787
+ },
788
+ "ScopeInterfacesController_list": {
789
+ method: "GET",
790
+ path: "/api/v1/scopes/{id}/interfaces",
791
+ service: "modus-api",
792
+ serverUrl: "https://api.getmodus.com",
793
+ pathParams: ["id"],
794
+ queryParams: [],
795
+ requestSchema: null,
796
+ responseSchema: "ListScopeInterfacesResponseDto"
797
+ },
798
+ "ScopeInterfacesController_update": {
799
+ method: "PATCH",
800
+ path: "/api/v1/scopes/{id}/interfaces/{interfaceId}",
801
+ service: "modus-api",
802
+ serverUrl: "https://api.getmodus.com",
803
+ pathParams: ["id", "interfaceId"],
804
+ queryParams: ["updateMask"],
805
+ requestSchema: "UpdateScopeInterfaceDto",
806
+ responseSchema: "ScopeInterfaceDto"
807
+ },
758
808
  "ScopeMemoriesController_delete": {
759
809
  method: "DELETE",
760
810
  path: "/api/v1/scopes/{id}/memories/{memoryId}",
@@ -1402,6 +1452,7 @@ var WRITE_BODY_ALLOWED_KEYS = {
1402
1452
  ContextFilesController_uploadUrl: ["fileName", "contentType", "fileSize"],
1403
1453
  ContextFilesController_uploadUrls: ["files"],
1404
1454
  ContextItemsController_lookup: ["contextType", "dataPath", "contentProjection"],
1455
+ ContextItemsController_move: ["destinationFolderUid"],
1405
1456
  ContextItemsController_update: ["contextType", "content", "description", "userFeedback", "topics"],
1406
1457
  CustomContextItemsController_batchCreate: ["items"],
1407
1458
  CustomContextItemsController_create: ["kind", "sourceId", "sourceName", "collectionId", "collectionName", "externalId", "fieldName", "name", "entityType", "description", "content", "url", "attributes", "dataType", "value", "samples", "raw", "topics", "idempotencyKey", "access"],
@@ -1427,11 +1478,13 @@ var WRITE_BODY_ALLOWED_KEYS = {
1427
1478
  RunLifecycleController_interrupt: [],
1428
1479
  ScopeChatController_chat: ["message", "model"],
1429
1480
  ScopeContextController_compose: ["message", "limit"],
1481
+ ScopeInterfacesController_add: ["type", "name", "config"],
1482
+ ScopeInterfacesController_update: ["name", "config"],
1430
1483
  ScopeMemoriesController_search: ["query", "userId", "limit"],
1431
1484
  ScopeMemoriesController_update: ["memory", "metadata"],
1432
1485
  ScopeRunsController_create: ["message", "sessionId", "organizationId", "version", "fileThreadId", "config", "attachments", "userContext", "source", "runId", "subordinateSkillIds"],
1433
1486
  ScopesController_acceptOwnershipTransfer: [],
1434
- ScopesController_create: ["name", "description", "expectedOutput", "instructions", "toolset", "model", "connectionSet", "contextSelections", "interfaces", "accessConfig"],
1487
+ ScopesController_create: ["name", "description", "expectedOutput", "instructions", "toolset", "model", "connectionSet", "contextSelections", "includeOwnLearnings", "interfaces", "accessConfig"],
1435
1488
  ScopesController_deploy: [],
1436
1489
  ScopesController_patchMcpConfig: ["config"],
1437
1490
  ScopesController_requestOwnershipTransfer: ["newOwnerUserId"],
@@ -1471,11 +1524,15 @@ function validateId(resourceId, name = "id") {
1471
1524
  }
1472
1525
  var ALLOWED_CHAT_MODELS = /* @__PURE__ */ new Set([
1473
1526
  "claude-sonnet-5",
1527
+ "claude-sonnet-5.5",
1474
1528
  "claude-sonnet-4.6",
1475
1529
  "claude-opus-4.8",
1530
+ "claude-opus-5.5",
1476
1531
  "gpt-5.2",
1477
1532
  "gpt-5.5",
1478
1533
  "gpt-5-mini",
1534
+ "gpt-5.6-luna",
1535
+ "gpt-6-luna",
1479
1536
  "gpt-oss-120b",
1480
1537
  "gpt-oss-20b",
1481
1538
  "qwen3-235b-a22b-2507",
@@ -1491,7 +1548,9 @@ var ALLOWED_CHAT_MODELS = /* @__PURE__ */ new Set([
1491
1548
  "gemini-3.1-pro-preview",
1492
1549
  "gemini-3-flash-preview",
1493
1550
  "grok-4.3-fast",
1494
- "grok-4.3"
1551
+ "grok-4.3",
1552
+ "grok-4.7",
1553
+ "kimi-k3"
1495
1554
  ]);
1496
1555
  function validateChatModel(model) {
1497
1556
  if (!ALLOWED_CHAT_MODELS.has(model)) {
@@ -1892,6 +1951,7 @@ function createModusConfig(options = {}) {
1892
1951
  }),
1893
1952
  timeoutMs: resolveTimeoutMs(options.timeoutMs) ?? DEFAULT_TIMEOUT_MS,
1894
1953
  maxRetries,
1954
+ defaultHeaders: Object.freeze({ ...options.defaultHeaders }),
1895
1955
  fetch: options.fetch ?? globalThis.fetch.bind(globalThis)
1896
1956
  });
1897
1957
  }
@@ -1907,7 +1967,7 @@ function formatConfigForLog(config) {
1907
1967
  }
1908
1968
 
1909
1969
  // src/_http.ts
1910
- var USER_AGENT = `modus-typescript/${"0.7.0"} (node/${process.version}; ${process.platform})`;
1970
+ var USER_AGENT = `modus-typescript/${"0.8.0"} (node/${process.version}; ${process.platform})`;
1911
1971
  function buildUrl(baseUrl, path, params) {
1912
1972
  const url = new URL(path.startsWith("/") ? path : `/${path}`, baseUrl);
1913
1973
  if (params) {
@@ -1922,6 +1982,15 @@ function buildUrl(baseUrl, path, params) {
1922
1982
  }
1923
1983
  return url.toString();
1924
1984
  }
1985
+ function mergeHeaders(...layers) {
1986
+ const merged = /* @__PURE__ */ new Map();
1987
+ for (const layer of layers) {
1988
+ for (const [name, value] of Object.entries(layer ?? {})) {
1989
+ merged.set(name.toLowerCase(), [name, value]);
1990
+ }
1991
+ }
1992
+ return Object.fromEntries(merged.values());
1993
+ }
1925
1994
  function headersToRecord(headers) {
1926
1995
  const out = {};
1927
1996
  headers.forEach((value, key) => {
@@ -2027,12 +2096,15 @@ var HttpClient = class {
2027
2096
  this.config = config;
2028
2097
  }
2029
2098
  defaultHeaders() {
2030
- return {
2031
- ...authHeaders(this.config.apiKey),
2032
- Accept: "application/json",
2033
- "Content-Type": "application/json",
2034
- "User-Agent": USER_AGENT
2035
- };
2099
+ return mergeHeaders(
2100
+ {
2101
+ Accept: "application/json",
2102
+ "Content-Type": "application/json",
2103
+ "User-Agent": USER_AGENT,
2104
+ "X-Modus-Client": "sdk"
2105
+ },
2106
+ this.config.defaultHeaders
2107
+ );
2036
2108
  }
2037
2109
  async request(method, path, options = {}) {
2038
2110
  const baseUrl = options.baseUrl ?? this.config.baseUrl;
@@ -2040,7 +2112,7 @@ var HttpClient = class {
2040
2112
  try {
2041
2113
  const response = await this.config.fetch(url, {
2042
2114
  method,
2043
- headers: { ...this.defaultHeaders(), ...options.headers },
2115
+ headers: mergeHeaders(this.defaultHeaders(), options.headers, authHeaders(this.config.apiKey)),
2044
2116
  body: options.json !== void 0 ? JSON.stringify(options.json) : void 0,
2045
2117
  signal: AbortSignal.timeout(this.config.timeoutMs)
2046
2118
  });
@@ -2079,11 +2151,12 @@ var HttpClient = class {
2079
2151
  method,
2080
2152
  // Agent-service negotiates SSE vs JSON polling on Accept; JSON-only
2081
2153
  // Accept returns {"runId","status":"pending"} instead of token SSE.
2082
- headers: {
2083
- ...this.defaultHeaders(),
2084
- ...options.headers,
2085
- Accept: "text/event-stream"
2086
- },
2154
+ headers: mergeHeaders(
2155
+ this.defaultHeaders(),
2156
+ options.headers,
2157
+ { Accept: "text/event-stream" },
2158
+ authHeaders(this.config.apiKey)
2159
+ ),
2087
2160
  body: options.json !== void 0 ? JSON.stringify(options.json) : void 0,
2088
2161
  signal: AbortSignal.timeout(this.config.timeoutMs)
2089
2162
  });
@@ -3051,9 +3124,18 @@ var CustomContextItemsResource = class {
3051
3124
  };
3052
3125
 
3053
3126
  // src/resources/context/items.ts
3054
- function contextListParams(pageSize, pageToken, contextType) {
3127
+ function contextListParams(pageSize, pageToken, filters = {}) {
3055
3128
  const extra = {};
3056
- if (contextType !== void 0) extra.contextTypes = [contextType];
3129
+ if (filters.contextType !== void 0) extra.contextTypes = [filters.contextType];
3130
+ if (filters.parentUids !== void 0) {
3131
+ extra.parentUids = filters.parentUids.length === 0 ? "" : [...filters.parentUids];
3132
+ }
3133
+ if (filters.ancestorUids !== void 0) {
3134
+ extra.ancestorUids = filters.ancestorUids.length === 0 ? "" : [...filters.ancestorUids];
3135
+ }
3136
+ if (filters.connectionIds !== void 0) {
3137
+ extra.connectionIds = filters.connectionIds.length === 0 ? "" : [...filters.connectionIds];
3138
+ }
3057
3139
  return aipListParams(pageSize, pageToken, extra);
3058
3140
  }
3059
3141
  function parseContextItem2(raw) {
@@ -3079,6 +3161,17 @@ var ContextItemsResource = class {
3079
3161
  * @param options.pageSize - Maximum items per page (default 25).
3080
3162
  * @param options.pageToken - Opaque token from a previous page.
3081
3163
  * @param options.contextType - Filter to a single context type (e.g. `"note"`).
3164
+ * @param options.parentUids - Exact ordered native ancestry chain for direct
3165
+ * children. Omit to leave parent unrestricted; pass `[]` for the known-empty
3166
+ * root. Native UIDs are exact tokens (including whitespace); do not use the
3167
+ * hashed context-item `uid`. For a folder's children, send that item's
3168
+ * `ancestry` UIDs plus its last `dataPath` token.
3169
+ * @param options.ancestorUids - Ordered UID ancestry prefix for strict
3170
+ * descendants. Omit to leave unrestricted; pass `[]` for every item with
3171
+ * non-null ancestry.
3172
+ * @param options.connectionIds - Restrict to these connection ids. Omit to
3173
+ * leave unfiltered; pass `[]` to match none. The Files root is
3174
+ * `connectionIds: ['files']` with `parentUids: []`.
3082
3175
  * @returns A page of context items — use `.autoPagingIter()` for all pages.
3083
3176
  *
3084
3177
  * @example
@@ -3088,23 +3181,47 @@ var ContextItemsResource = class {
3088
3181
  * console.log(item.description ?? item.uid, item.uid)
3089
3182
  * }
3090
3183
  * ```
3184
+ *
3185
+ * @example
3186
+ * ```ts
3187
+ * const rootFolders = await client.context.items.list({
3188
+ * connectionIds: ['files'],
3189
+ * contextType: 'file_folder_metadata',
3190
+ * parentUids: [],
3191
+ * })
3192
+ * const folder = rootFolders.items[0]
3193
+ * const nativeUid = folder?.dataPath?.at(-1)
3194
+ * // Known ancestry only — never treat null/omitted ancestry as a root chain.
3195
+ * if (folder?.ancestry != null && nativeUid !== undefined) {
3196
+ * const filesInFolder = await client.context.items.list({
3197
+ * connectionIds: ['files'],
3198
+ * contextType: 'file_upload',
3199
+ * parentUids: [...folder.ancestry.map((a) => a.uid), nativeUid],
3200
+ * })
3201
+ * }
3202
+ * ```
3091
3203
  */
3092
3204
  list(options = {}) {
3093
3205
  const pageSize = options.pageSize ?? 25;
3094
3206
  validatePageSize(pageSize);
3095
- return this.listPage(pageSize, options.pageToken, options.contextType);
3207
+ return this.listPage(pageSize, options.pageToken, {
3208
+ contextType: options.contextType,
3209
+ parentUids: options.parentUids,
3210
+ ancestorUids: options.ancestorUids,
3211
+ connectionIds: options.connectionIds
3212
+ });
3096
3213
  }
3097
- async listPage(pageSize, pageToken, contextType) {
3214
+ async listPage(pageSize, pageToken, filters) {
3098
3215
  const data = asRecord(
3099
3216
  await invokeWithRetry(this.config, this.http, "ContextItemsController_list", {
3100
- query: contextListParams(pageSize, pageToken, contextType)
3217
+ query: contextListParams(pageSize, pageToken, filters)
3101
3218
  })
3102
3219
  );
3103
3220
  return buildAipPage(
3104
3221
  data,
3105
3222
  "contextItems",
3106
3223
  parseContextItem2,
3107
- (token) => this.listPage(pageSize, token, contextType)
3224
+ (token) => this.listPage(pageSize, token, filters)
3108
3225
  );
3109
3226
  }
3110
3227
  /**