@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/CHANGELOG.md +44 -0
- package/README.md +21 -2
- package/dist/{chunk-JMFT5KO5.js → chunk-GFS7CNON.js} +90 -17
- package/dist/chunk-GFS7CNON.js.map +1 -0
- package/dist/{conversations-B0_jmEuT.d.cts → conversations-COA6NW8I.d.cts} +1318 -169
- package/dist/{conversations-B0_jmEuT.d.ts → conversations-COA6NW8I.d.ts} +1318 -169
- package/dist/index.cjs +139 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +39 -6
- package/dist/index.d.ts +39 -6
- package/dist/index.js +51 -7
- package/dist/index.js.map +1 -1
- package/dist/management/index.cjs +279 -32
- package/dist/management/index.cjs.map +1 -1
- package/dist/management/index.d.cts +137 -11
- package/dist/management/index.d.ts +137 -11
- package/dist/management/index.js +198 -18
- package/dist/management/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-JMFT5KO5.js.map +0 -1
|
@@ -201,6 +201,7 @@ function createModusConfig(options = {}) {
|
|
|
201
201
|
}),
|
|
202
202
|
timeoutMs: resolveTimeoutMs(options.timeoutMs) ?? DEFAULT_TIMEOUT_MS,
|
|
203
203
|
maxRetries,
|
|
204
|
+
defaultHeaders: Object.freeze({ ...options.defaultHeaders }),
|
|
204
205
|
fetch: options.fetch ?? globalThis.fetch.bind(globalThis)
|
|
205
206
|
});
|
|
206
207
|
}
|
|
@@ -216,7 +217,7 @@ function formatConfigForLog(config) {
|
|
|
216
217
|
}
|
|
217
218
|
|
|
218
219
|
// src/_http.ts
|
|
219
|
-
var USER_AGENT = `modus-typescript/${"0.
|
|
220
|
+
var USER_AGENT = `modus-typescript/${"0.8.0"} (node/${process.version}; ${process.platform})`;
|
|
220
221
|
function buildUrl(baseUrl, path, params) {
|
|
221
222
|
const url = new URL(path.startsWith("/") ? path : `/${path}`, baseUrl);
|
|
222
223
|
if (params) {
|
|
@@ -231,6 +232,15 @@ function buildUrl(baseUrl, path, params) {
|
|
|
231
232
|
}
|
|
232
233
|
return url.toString();
|
|
233
234
|
}
|
|
235
|
+
function mergeHeaders(...layers) {
|
|
236
|
+
const merged = /* @__PURE__ */ new Map();
|
|
237
|
+
for (const layer of layers) {
|
|
238
|
+
for (const [name, value] of Object.entries(layer ?? {})) {
|
|
239
|
+
merged.set(name.toLowerCase(), [name, value]);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return Object.fromEntries(merged.values());
|
|
243
|
+
}
|
|
234
244
|
function headersToRecord(headers) {
|
|
235
245
|
const out = {};
|
|
236
246
|
headers.forEach((value, key) => {
|
|
@@ -336,12 +346,15 @@ var HttpClient = class {
|
|
|
336
346
|
this.config = config;
|
|
337
347
|
}
|
|
338
348
|
defaultHeaders() {
|
|
339
|
-
return
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
349
|
+
return mergeHeaders(
|
|
350
|
+
{
|
|
351
|
+
Accept: "application/json",
|
|
352
|
+
"Content-Type": "application/json",
|
|
353
|
+
"User-Agent": USER_AGENT,
|
|
354
|
+
"X-Modus-Client": "sdk"
|
|
355
|
+
},
|
|
356
|
+
this.config.defaultHeaders
|
|
357
|
+
);
|
|
345
358
|
}
|
|
346
359
|
async request(method, path, options = {}) {
|
|
347
360
|
const baseUrl = options.baseUrl ?? this.config.baseUrl;
|
|
@@ -349,7 +362,7 @@ var HttpClient = class {
|
|
|
349
362
|
try {
|
|
350
363
|
const response = await this.config.fetch(url, {
|
|
351
364
|
method,
|
|
352
|
-
headers:
|
|
365
|
+
headers: mergeHeaders(this.defaultHeaders(), options.headers, authHeaders(this.config.apiKey)),
|
|
353
366
|
body: options.json !== void 0 ? JSON.stringify(options.json) : void 0,
|
|
354
367
|
signal: AbortSignal.timeout(this.config.timeoutMs)
|
|
355
368
|
});
|
|
@@ -388,11 +401,12 @@ var HttpClient = class {
|
|
|
388
401
|
method,
|
|
389
402
|
// Agent-service negotiates SSE vs JSON polling on Accept; JSON-only
|
|
390
403
|
// Accept returns {"runId","status":"pending"} instead of token SSE.
|
|
391
|
-
headers:
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
Accept: "text/event-stream"
|
|
395
|
-
|
|
404
|
+
headers: mergeHeaders(
|
|
405
|
+
this.defaultHeaders(),
|
|
406
|
+
options.headers,
|
|
407
|
+
{ Accept: "text/event-stream" },
|
|
408
|
+
authHeaders(this.config.apiKey)
|
|
409
|
+
),
|
|
396
410
|
body: options.json !== void 0 ? JSON.stringify(options.json) : void 0,
|
|
397
411
|
signal: AbortSignal.timeout(this.config.timeoutMs)
|
|
398
412
|
});
|
|
@@ -698,7 +712,7 @@ var OPERATIONS = {
|
|
|
698
712
|
service: "modus-api",
|
|
699
713
|
serverUrl: "https://api.getmodus.com",
|
|
700
714
|
pathParams: [],
|
|
701
|
-
queryParams: ["pageToken", "pageSize", "contextTypes", "verificationStatuses", "searchQuery", "topics"],
|
|
715
|
+
queryParams: ["pageToken", "pageSize", "contextTypes", "verificationStatuses", "searchQuery", "topics", "connectionIds", "parentUids", "ancestorUids"],
|
|
702
716
|
requestSchema: null,
|
|
703
717
|
responseSchema: "ListContextItemsResponseDto"
|
|
704
718
|
},
|
|
@@ -722,6 +736,16 @@ var OPERATIONS = {
|
|
|
722
736
|
requestSchema: "LookupContextItemDto",
|
|
723
737
|
responseSchema: "LookupContextItemResponseDto"
|
|
724
738
|
},
|
|
739
|
+
"ContextItemsController_move": {
|
|
740
|
+
method: "POST",
|
|
741
|
+
path: "/api/v1/context/items/{uid}/move",
|
|
742
|
+
service: "modus-api",
|
|
743
|
+
serverUrl: "https://api.getmodus.com",
|
|
744
|
+
pathParams: ["uid"],
|
|
745
|
+
queryParams: [],
|
|
746
|
+
requestSchema: "MoveContextItemDto",
|
|
747
|
+
responseSchema: "MoveContextItemResponseDto"
|
|
748
|
+
},
|
|
725
749
|
"ContextItemsController_update": {
|
|
726
750
|
method: "PATCH",
|
|
727
751
|
path: "/api/v1/context/items/{uid}",
|
|
@@ -1262,6 +1286,46 @@ var OPERATIONS = {
|
|
|
1262
1286
|
requestSchema: null,
|
|
1263
1287
|
responseSchema: "ListConversationsResponseDto"
|
|
1264
1288
|
},
|
|
1289
|
+
"ScopeInterfacesController_add": {
|
|
1290
|
+
method: "POST",
|
|
1291
|
+
path: "/api/v1/scopes/{id}/interfaces",
|
|
1292
|
+
service: "modus-api",
|
|
1293
|
+
serverUrl: "https://api.getmodus.com",
|
|
1294
|
+
pathParams: ["id"],
|
|
1295
|
+
queryParams: [],
|
|
1296
|
+
requestSchema: "AddScopeInterfaceDto",
|
|
1297
|
+
responseSchema: "ScopeInterfaceDto"
|
|
1298
|
+
},
|
|
1299
|
+
"ScopeInterfacesController_delete": {
|
|
1300
|
+
method: "DELETE",
|
|
1301
|
+
path: "/api/v1/scopes/{id}/interfaces/{interfaceId}",
|
|
1302
|
+
service: "modus-api",
|
|
1303
|
+
serverUrl: "https://api.getmodus.com",
|
|
1304
|
+
pathParams: ["id", "interfaceId"],
|
|
1305
|
+
queryParams: [],
|
|
1306
|
+
requestSchema: null,
|
|
1307
|
+
responseSchema: null
|
|
1308
|
+
},
|
|
1309
|
+
"ScopeInterfacesController_list": {
|
|
1310
|
+
method: "GET",
|
|
1311
|
+
path: "/api/v1/scopes/{id}/interfaces",
|
|
1312
|
+
service: "modus-api",
|
|
1313
|
+
serverUrl: "https://api.getmodus.com",
|
|
1314
|
+
pathParams: ["id"],
|
|
1315
|
+
queryParams: [],
|
|
1316
|
+
requestSchema: null,
|
|
1317
|
+
responseSchema: "ListScopeInterfacesResponseDto"
|
|
1318
|
+
},
|
|
1319
|
+
"ScopeInterfacesController_update": {
|
|
1320
|
+
method: "PATCH",
|
|
1321
|
+
path: "/api/v1/scopes/{id}/interfaces/{interfaceId}",
|
|
1322
|
+
service: "modus-api",
|
|
1323
|
+
serverUrl: "https://api.getmodus.com",
|
|
1324
|
+
pathParams: ["id", "interfaceId"],
|
|
1325
|
+
queryParams: ["updateMask"],
|
|
1326
|
+
requestSchema: "UpdateScopeInterfaceDto",
|
|
1327
|
+
responseSchema: "ScopeInterfaceDto"
|
|
1328
|
+
},
|
|
1265
1329
|
"ScopeMemoriesController_delete": {
|
|
1266
1330
|
method: "DELETE",
|
|
1267
1331
|
path: "/api/v1/scopes/{id}/memories/{memoryId}",
|
|
@@ -1818,6 +1882,7 @@ var WRITE_BODY_ALLOWED_KEYS = {
|
|
|
1818
1882
|
ContextFilesController_uploadUrl: ["fileName", "contentType", "fileSize"],
|
|
1819
1883
|
ContextFilesController_uploadUrls: ["files"],
|
|
1820
1884
|
ContextItemsController_lookup: ["contextType", "dataPath", "contentProjection"],
|
|
1885
|
+
ContextItemsController_move: ["destinationFolderUid"],
|
|
1821
1886
|
ContextItemsController_update: ["contextType", "content", "description", "userFeedback", "topics"],
|
|
1822
1887
|
CustomContextItemsController_batchCreate: ["items"],
|
|
1823
1888
|
CustomContextItemsController_create: ["kind", "sourceId", "sourceName", "collectionId", "collectionName", "externalId", "fieldName", "name", "entityType", "description", "content", "url", "attributes", "dataType", "value", "samples", "raw", "topics", "idempotencyKey", "access"],
|
|
@@ -1843,11 +1908,13 @@ var WRITE_BODY_ALLOWED_KEYS = {
|
|
|
1843
1908
|
RunLifecycleController_interrupt: [],
|
|
1844
1909
|
ScopeChatController_chat: ["message", "model"],
|
|
1845
1910
|
ScopeContextController_compose: ["message", "limit"],
|
|
1911
|
+
ScopeInterfacesController_add: ["type", "name", "config"],
|
|
1912
|
+
ScopeInterfacesController_update: ["name", "config"],
|
|
1846
1913
|
ScopeMemoriesController_search: ["query", "userId", "limit"],
|
|
1847
1914
|
ScopeMemoriesController_update: ["memory", "metadata"],
|
|
1848
1915
|
ScopeRunsController_create: ["message", "sessionId", "organizationId", "version", "fileThreadId", "config", "attachments", "userContext", "source", "runId", "subordinateSkillIds"],
|
|
1849
1916
|
ScopesController_acceptOwnershipTransfer: [],
|
|
1850
|
-
ScopesController_create: ["name", "description", "expectedOutput", "instructions", "toolset", "model", "connectionSet", "contextSelections", "interfaces", "accessConfig"],
|
|
1917
|
+
ScopesController_create: ["name", "description", "expectedOutput", "instructions", "toolset", "model", "connectionSet", "contextSelections", "includeOwnLearnings", "interfaces", "accessConfig"],
|
|
1851
1918
|
ScopesController_deploy: [],
|
|
1852
1919
|
ScopesController_patchMcpConfig: ["config"],
|
|
1853
1920
|
ScopesController_requestOwnershipTransfer: ["newOwnerUserId"],
|
|
@@ -3153,6 +3220,12 @@ function chunked(items, size) {
|
|
|
3153
3220
|
for (let i = 0; i < items.length; i += size) out.push(items.slice(i, i + size));
|
|
3154
3221
|
return out;
|
|
3155
3222
|
}
|
|
3223
|
+
function joinDestination(prefix, relative2) {
|
|
3224
|
+
const head = prefix === void 0 || prefix.length === 0 ? void 0 : prefix;
|
|
3225
|
+
const tail = relative2 === void 0 || relative2.length === 0 ? void 0 : relative2;
|
|
3226
|
+
if (head !== void 0 && tail !== void 0) return `${head}/${tail}`;
|
|
3227
|
+
return head ?? tail;
|
|
3228
|
+
}
|
|
3156
3229
|
async function mapWithConcurrency(items, concurrency, worker, onItemDone) {
|
|
3157
3230
|
const results = new Array(items.length);
|
|
3158
3231
|
let cursor = 0;
|
|
@@ -3186,11 +3259,11 @@ async function walkFiles(root, recursive) {
|
|
|
3186
3259
|
await walk(root);
|
|
3187
3260
|
return out;
|
|
3188
3261
|
}
|
|
3189
|
-
async function putBytes(fetchImpl,
|
|
3190
|
-
const response = await fetchImpl(
|
|
3262
|
+
async function putBytes(fetchImpl, slot, data, timeoutMs) {
|
|
3263
|
+
const response = await fetchImpl(slot.uploadUrl, {
|
|
3191
3264
|
method: "PUT",
|
|
3192
3265
|
body: data,
|
|
3193
|
-
headers: { "Content-Type": contentType },
|
|
3266
|
+
headers: { "Content-Type": slot.contentType, ...slot.headers },
|
|
3194
3267
|
signal: AbortSignal.timeout(timeoutMs)
|
|
3195
3268
|
});
|
|
3196
3269
|
if (!response.ok) {
|
|
@@ -3248,7 +3321,7 @@ var ManagementContextFilesResource = class {
|
|
|
3248
3321
|
* Office/OpenDocument documents, audio, and video.
|
|
3249
3322
|
* @param input.fileSize - File size in bytes. Rejected above 50MB.
|
|
3250
3323
|
* @returns Presigned upload slot. PUT the raw bytes to `uploadUrl` within 15
|
|
3251
|
-
* minutes, then call `finalize(slot.uploadId, slot.fileName)`. Pass the
|
|
3324
|
+
* minutes, sending `headers` unchanged, then call `finalize(slot.uploadId, slot.fileName)`. Pass the
|
|
3252
3325
|
* slot's own `fileName` rather than your local basename — the server may
|
|
3253
3326
|
* sanitize the requested name when it mints the key, and finalization
|
|
3254
3327
|
* re-derives the key from `uploadId` and `fileName`.
|
|
@@ -3281,6 +3354,7 @@ var ManagementContextFilesResource = class {
|
|
|
3281
3354
|
* @param url - Source URL to fetch (SSRF-guarded, 50MB cap, same MIME
|
|
3282
3355
|
* allow-list as `createUploadUrl`).
|
|
3283
3356
|
* @param options.fileName - Override file name. Inferred from the URL path when omitted.
|
|
3357
|
+
* @param options.folderPath - Root-relative folder to upload under.
|
|
3284
3358
|
* @returns File upload resource with status `processing` — parsing continues async.
|
|
3285
3359
|
*/
|
|
3286
3360
|
async uploadFromUrl(url, options = {}) {
|
|
@@ -3398,6 +3472,16 @@ var ManagementContextFilesResource = class {
|
|
|
3398
3472
|
* @param options.concurrency - Max concurrent PUTs (default 10).
|
|
3399
3473
|
* @param options.waitUntil - `"processing"` (default) or `"ready"`.
|
|
3400
3474
|
* @param options.onProgress - Optional progress callback after each file.
|
|
3475
|
+
* @param options.folderPath - Root-relative folder to upload under. Nested
|
|
3476
|
+
* files keep their existing relative folder labels under this prefix.
|
|
3477
|
+
* @example
|
|
3478
|
+
* ```ts
|
|
3479
|
+
* const mgmt = new ModusManagement()
|
|
3480
|
+
* const result = await mgmt.context.files.uploadFiles(
|
|
3481
|
+
* ['./q3.pdf', './notes.md'],
|
|
3482
|
+
* { folderPath: 'reports/2026' },
|
|
3483
|
+
* )
|
|
3484
|
+
* ```
|
|
3401
3485
|
*/
|
|
3402
3486
|
async uploadFiles(paths, options = {}) {
|
|
3403
3487
|
return this.uploadPaths(paths.map((input) => typeof input === "string" ? { path: input } : input), options);
|
|
@@ -3405,16 +3489,23 @@ var ManagementContextFilesResource = class {
|
|
|
3405
3489
|
/**
|
|
3406
3490
|
* Upload a local file and wait for it to reach `"processing"` or `"ready"`.
|
|
3407
3491
|
*
|
|
3408
|
-
* Gets a presigned URL, PUTs the file bytes, then polls `get()`
|
|
3409
|
-
* upload leaves `"pending"` (or reaches `"ready"`/`"failed"`).
|
|
3492
|
+
* Gets a presigned URL, PUTs the file bytes, then polls `get()`
|
|
3493
|
+
* until the upload leaves `"pending"` (or reaches `"ready"`/`"failed"`).
|
|
3410
3494
|
*
|
|
3411
3495
|
* @param path - Path to a local file.
|
|
3412
3496
|
* @param options.waitUntil - `"processing"` (parsing started, default) or
|
|
3413
3497
|
* `"ready"` (parsing finished).
|
|
3414
3498
|
* @param options.pollIntervalMs - Milliseconds between status polls.
|
|
3415
3499
|
* @param options.timeoutMs - Max milliseconds to wait before raising.
|
|
3500
|
+
* @param options.folderPath - Root-relative folder to upload under. Example:
|
|
3501
|
+
* `{ folderPath: 'reports/2026' }` places `./report.pdf` at `reports/2026`.
|
|
3416
3502
|
* @returns The file upload resource once it reaches `waitUntil` (or `"failed"`).
|
|
3417
3503
|
* @throws {ModusError} If the PUT fails, or polling times out.
|
|
3504
|
+
* @example
|
|
3505
|
+
* ```ts
|
|
3506
|
+
* const mgmt = new ModusManagement()
|
|
3507
|
+
* const file = await mgmt.context.files.upload('./report.pdf', { folderPath: 'reports/2026' })
|
|
3508
|
+
* ```
|
|
3418
3509
|
*/
|
|
3419
3510
|
async upload(path, options = {}) {
|
|
3420
3511
|
const waitUntil = options.waitUntil ?? "processing";
|
|
@@ -3428,8 +3519,10 @@ var ManagementContextFilesResource = class {
|
|
|
3428
3519
|
fileSize: fileStat.size
|
|
3429
3520
|
});
|
|
3430
3521
|
const data = await (0, import_promises.readFile)(path);
|
|
3431
|
-
await putBytes(this.config.fetch, slot
|
|
3432
|
-
const finalized = await this.finalize(slot.uploadId, slot.fileName
|
|
3522
|
+
await putBytes(this.config.fetch, slot, data, DEFAULT_PUT_TIMEOUT_MS);
|
|
3523
|
+
const finalized = await this.finalize(slot.uploadId, slot.fileName, {
|
|
3524
|
+
...options.folderPath !== void 0 ? { folderPath: options.folderPath } : {}
|
|
3525
|
+
});
|
|
3433
3526
|
if (statusSatisfies(finalized.status, waitUntil)) return finalized;
|
|
3434
3527
|
return this.pollUntil(
|
|
3435
3528
|
slot.uploadId,
|
|
@@ -3464,8 +3557,17 @@ var ManagementContextFilesResource = class {
|
|
|
3464
3557
|
* @param options.concurrency - Max concurrent PUT+poll operations (default 10).
|
|
3465
3558
|
* @param options.waitUntil - `"processing"` (default) or `"ready"` — same as `upload()`.
|
|
3466
3559
|
* @param options.onProgress - Optional progress callback after each file.
|
|
3560
|
+
* @param options.folderPath - Root-relative folder to upload under. Nested
|
|
3561
|
+
* files keep their path relative to `path` under this prefix. Example:
|
|
3562
|
+
* `uploadDir('./docs', { folderPath: 'reports' })` places `./docs/a.txt` at
|
|
3563
|
+
* `reports` and `./docs/nested/b.txt` at `reports/nested`.
|
|
3467
3564
|
* @returns `UploadDirResult` with every successful `FileUpload` and every
|
|
3468
3565
|
* per-file failure (slot creation or PUT/poll), each tagged with its local path.
|
|
3566
|
+
* @example
|
|
3567
|
+
* ```ts
|
|
3568
|
+
* const mgmt = new ModusManagement()
|
|
3569
|
+
* const result = await mgmt.context.files.uploadDir('./docs', { folderPath: 'reports' })
|
|
3570
|
+
* ```
|
|
3469
3571
|
*/
|
|
3470
3572
|
async uploadDir(path, options = {}) {
|
|
3471
3573
|
const waitUntil = options.waitUntil ?? "processing";
|
|
@@ -3487,6 +3589,10 @@ var ManagementContextFilesResource = class {
|
|
|
3487
3589
|
validateWaitUntil(waitUntil);
|
|
3488
3590
|
const concurrency = options.concurrency ?? DEFAULT_CONCURRENCY;
|
|
3489
3591
|
if (concurrency < 1) throw new Error(`concurrency must be >= 1, got ${concurrency}`);
|
|
3592
|
+
const prefixed = files.map((file) => {
|
|
3593
|
+
const folderPath = joinDestination(options.folderPath, file.folderPath);
|
|
3594
|
+
return { path: file.path, ...folderPath !== void 0 ? { folderPath } : {} };
|
|
3595
|
+
});
|
|
3490
3596
|
const uploaded = [];
|
|
3491
3597
|
const failed = [];
|
|
3492
3598
|
const total = files.length;
|
|
@@ -3500,7 +3606,7 @@ var ManagementContextFilesResource = class {
|
|
|
3500
3606
|
failed: failed.length
|
|
3501
3607
|
});
|
|
3502
3608
|
};
|
|
3503
|
-
for (const batch of chunked(
|
|
3609
|
+
for (const batch of chunked(prefixed, MAX_BULK_UPLOAD_FILES)) {
|
|
3504
3610
|
const failedBefore = failed.length;
|
|
3505
3611
|
const slots = await this.createSlots(batch, failed);
|
|
3506
3612
|
for (let reported = failedBefore + 1; reported <= failed.length; reported += 1) {
|
|
@@ -3542,7 +3648,7 @@ var ManagementContextFilesResource = class {
|
|
|
3542
3648
|
async ({ path, folderPath, slot }) => {
|
|
3543
3649
|
try {
|
|
3544
3650
|
const data = await (0, import_promises.readFile)(path);
|
|
3545
|
-
await putBytes(this.config.fetch, slot
|
|
3651
|
+
await putBytes(this.config.fetch, slot, data, DEFAULT_PUT_TIMEOUT_MS);
|
|
3546
3652
|
return { landed: { path, ...folderPath !== void 0 ? { folderPath } : {}, slot } };
|
|
3547
3653
|
} catch (error) {
|
|
3548
3654
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -3607,9 +3713,18 @@ var ManagementContextFilesResource = class {
|
|
|
3607
3713
|
};
|
|
3608
3714
|
|
|
3609
3715
|
// src/management/context/items.ts
|
|
3610
|
-
function contextListParams(pageSize, pageToken,
|
|
3716
|
+
function contextListParams(pageSize, pageToken, filters = {}) {
|
|
3611
3717
|
const extra = {};
|
|
3612
|
-
if (contextType !== void 0) extra.contextTypes = [contextType];
|
|
3718
|
+
if (filters.contextType !== void 0) extra.contextTypes = [filters.contextType];
|
|
3719
|
+
if (filters.parentUids !== void 0) {
|
|
3720
|
+
extra.parentUids = filters.parentUids.length === 0 ? "" : [...filters.parentUids];
|
|
3721
|
+
}
|
|
3722
|
+
if (filters.ancestorUids !== void 0) {
|
|
3723
|
+
extra.ancestorUids = filters.ancestorUids.length === 0 ? "" : [...filters.ancestorUids];
|
|
3724
|
+
}
|
|
3725
|
+
if (filters.connectionIds !== void 0) {
|
|
3726
|
+
extra.connectionIds = filters.connectionIds.length === 0 ? "" : [...filters.connectionIds];
|
|
3727
|
+
}
|
|
3613
3728
|
return aipListParams(pageSize, pageToken, extra);
|
|
3614
3729
|
}
|
|
3615
3730
|
function parseContextItem2(raw) {
|
|
@@ -3626,24 +3741,48 @@ var ManagementContextItemsResource = class {
|
|
|
3626
3741
|
* @param options.pageSize - Items per page (default 25).
|
|
3627
3742
|
* @param options.pageToken - Token from a previous page's `nextPageToken`.
|
|
3628
3743
|
* @param options.contextType - Filter to one context type (for example `"note"`).
|
|
3744
|
+
* @param options.parentUids - Exact ordered native ancestry chain for direct
|
|
3745
|
+
* children. Omit to leave parent unrestricted; pass `[]` for the known-empty
|
|
3746
|
+
* root. Native UIDs are exact tokens; for a folder's children send ancestry
|
|
3747
|
+
* UIDs plus the last `dataPath` token, not the hashed context-item `uid`.
|
|
3748
|
+
* @param options.ancestorUids - Ordered UID ancestry prefix for strict
|
|
3749
|
+
* descendants. Omit to leave unrestricted; pass `[]` for every item with
|
|
3750
|
+
* non-null ancestry.
|
|
3751
|
+
* @param options.connectionIds - Restrict to these connection ids. Omit to
|
|
3752
|
+
* leave unfiltered; pass `[]` to match none. The Files root is
|
|
3753
|
+
* `connectionIds: ['files']` with `parentUids: []`.
|
|
3629
3754
|
* @returns A page of context items.
|
|
3755
|
+
*
|
|
3756
|
+
* @example
|
|
3757
|
+
* ```ts
|
|
3758
|
+
* const rootFiles = await mgmt.context.items.list({
|
|
3759
|
+
* connectionIds: ['files'],
|
|
3760
|
+
* contextType: 'file_upload',
|
|
3761
|
+
* parentUids: [],
|
|
3762
|
+
* })
|
|
3763
|
+
* ```
|
|
3630
3764
|
*/
|
|
3631
3765
|
list(options = {}) {
|
|
3632
3766
|
const pageSize = options.pageSize ?? 25;
|
|
3633
3767
|
validatePageSize(pageSize);
|
|
3634
|
-
return this.listPage(pageSize, options.pageToken,
|
|
3768
|
+
return this.listPage(pageSize, options.pageToken, {
|
|
3769
|
+
contextType: options.contextType,
|
|
3770
|
+
parentUids: options.parentUids,
|
|
3771
|
+
ancestorUids: options.ancestorUids,
|
|
3772
|
+
connectionIds: options.connectionIds
|
|
3773
|
+
});
|
|
3635
3774
|
}
|
|
3636
|
-
async listPage(pageSize, pageToken,
|
|
3775
|
+
async listPage(pageSize, pageToken, filters) {
|
|
3637
3776
|
const data = asRecord(
|
|
3638
3777
|
await invokeWithRetry(this.config, this.http, "ContextItemsController_list", {
|
|
3639
|
-
query: contextListParams(pageSize, pageToken,
|
|
3778
|
+
query: contextListParams(pageSize, pageToken, filters)
|
|
3640
3779
|
})
|
|
3641
3780
|
);
|
|
3642
3781
|
return buildAipPage(
|
|
3643
3782
|
data,
|
|
3644
3783
|
"contextItems",
|
|
3645
3784
|
parseContextItem2,
|
|
3646
|
-
(token) => this.listPage(pageSize, token,
|
|
3785
|
+
(token) => this.listPage(pageSize, token, filters)
|
|
3647
3786
|
);
|
|
3648
3787
|
}
|
|
3649
3788
|
/**
|
|
@@ -3695,7 +3834,7 @@ var ManagementContextItemsResource = class {
|
|
|
3695
3834
|
return this.get(uid);
|
|
3696
3835
|
}
|
|
3697
3836
|
/**
|
|
3698
|
-
* Delete a context item.
|
|
3837
|
+
* Delete a context item. Deleting a Files folder also deletes all its contents.
|
|
3699
3838
|
*
|
|
3700
3839
|
* @param uid - Context item uid.
|
|
3701
3840
|
* @returns Deletion confirmation details.
|
|
@@ -3706,6 +3845,44 @@ var ManagementContextItemsResource = class {
|
|
|
3706
3845
|
});
|
|
3707
3846
|
return data;
|
|
3708
3847
|
}
|
|
3848
|
+
/**
|
|
3849
|
+
* Move a live file or Files folder.
|
|
3850
|
+
*
|
|
3851
|
+
* Pass `destinationFolderUid: null` to move to the Files root. The
|
|
3852
|
+
* destination folder must already exist. Same-parent moves succeed as a
|
|
3853
|
+
* no-op. Does not rename or merge folders.
|
|
3854
|
+
*
|
|
3855
|
+
* @param uid - Stored context-item uid of the file or folder to move.
|
|
3856
|
+
* @param options.destinationFolderUid - Stored context-item uid of the
|
|
3857
|
+
* destination folder, or `null` for the Files root.
|
|
3858
|
+
* @returns How many items changed parent (`0` is a successful no-op).
|
|
3859
|
+
* @throws {NotFoundError} The source is missing or not visible.
|
|
3860
|
+
* @throws {ModusError} The destination is missing, not a Files folder, or
|
|
3861
|
+
* the move would create a cycle (HTTP 400).
|
|
3862
|
+
* @throws {PermissionDeniedError} The destination exists but is not writable
|
|
3863
|
+
* for this caller.
|
|
3864
|
+
* @throws {ConflictError} A sibling with the same name already exists.
|
|
3865
|
+
*
|
|
3866
|
+
* @example
|
|
3867
|
+
* ```ts
|
|
3868
|
+
* const moved = await mgmt.context.items.move('PLACEHOLDER_UID', {
|
|
3869
|
+
* destinationFolderUid: 'PLACEHOLDER_FOLDER_UID',
|
|
3870
|
+
* })
|
|
3871
|
+
* console.log(moved.movedItems)
|
|
3872
|
+
* ```
|
|
3873
|
+
*/
|
|
3874
|
+
async move(uid, options) {
|
|
3875
|
+
const data = await invokeWithRetry(
|
|
3876
|
+
this.config,
|
|
3877
|
+
this.http,
|
|
3878
|
+
"ContextItemsController_move",
|
|
3879
|
+
{
|
|
3880
|
+
pathParams: { uid },
|
|
3881
|
+
jsonBody: { destinationFolderUid: options.destinationFolderUid }
|
|
3882
|
+
}
|
|
3883
|
+
);
|
|
3884
|
+
return data;
|
|
3885
|
+
}
|
|
3709
3886
|
};
|
|
3710
3887
|
|
|
3711
3888
|
// src/management/context/context.ts
|
|
@@ -4121,6 +4298,65 @@ var ScopeEvaluationsResource = class {
|
|
|
4121
4298
|
}
|
|
4122
4299
|
};
|
|
4123
4300
|
|
|
4301
|
+
// src/management/scopes/interfaces.ts
|
|
4302
|
+
var ScopeInterfacesResource = class {
|
|
4303
|
+
constructor(http, config, scopeId) {
|
|
4304
|
+
this.http = http;
|
|
4305
|
+
this.config = config;
|
|
4306
|
+
this.scopeId = scopeId;
|
|
4307
|
+
}
|
|
4308
|
+
/** List the Slack and Microsoft Teams interfaces on this scope. */
|
|
4309
|
+
async list() {
|
|
4310
|
+
validateId(this.scopeId, "scope_id");
|
|
4311
|
+
const data = await invokeWithRetry(this.config, this.http, "ScopeInterfacesController_list", {
|
|
4312
|
+
pathParams: { id: this.scopeId }
|
|
4313
|
+
});
|
|
4314
|
+
return data.interfaces;
|
|
4315
|
+
}
|
|
4316
|
+
/**
|
|
4317
|
+
* Add a Slack or Microsoft Teams interface to this scope.
|
|
4318
|
+
*
|
|
4319
|
+
* @param options - Interface type, optional name and config.
|
|
4320
|
+
* @returns The created interface.
|
|
4321
|
+
*/
|
|
4322
|
+
async create(options) {
|
|
4323
|
+
validateId(this.scopeId, "scope_id");
|
|
4324
|
+
return await invokeWithRetry(this.config, this.http, "ScopeInterfacesController_add", {
|
|
4325
|
+
pathParams: { id: this.scopeId },
|
|
4326
|
+
jsonBody: omitUndefined(options)
|
|
4327
|
+
});
|
|
4328
|
+
}
|
|
4329
|
+
/**
|
|
4330
|
+
* Update an interface on this scope.
|
|
4331
|
+
*
|
|
4332
|
+
* @param interfaceId - Interface id.
|
|
4333
|
+
* @param options - Updated name and/or config.
|
|
4334
|
+
* @param updateMask - Optional comma-separated field names to update.
|
|
4335
|
+
* @returns The updated interface.
|
|
4336
|
+
*/
|
|
4337
|
+
async update(interfaceId, options, updateMask) {
|
|
4338
|
+
validateId(this.scopeId, "scope_id");
|
|
4339
|
+
validateId(interfaceId, "interface_id");
|
|
4340
|
+
return await invokeWithRetry(this.config, this.http, "ScopeInterfacesController_update", {
|
|
4341
|
+
pathParams: { id: this.scopeId, interfaceId },
|
|
4342
|
+
query: updateMaskQuery(updateMask),
|
|
4343
|
+
jsonBody: updateMask === void 0 ? omitUndefined(options) : options
|
|
4344
|
+
});
|
|
4345
|
+
}
|
|
4346
|
+
/**
|
|
4347
|
+
* Remove an interface from this scope.
|
|
4348
|
+
*
|
|
4349
|
+
* @param interfaceId - Interface id.
|
|
4350
|
+
*/
|
|
4351
|
+
async delete(interfaceId) {
|
|
4352
|
+
validateId(this.scopeId, "scope_id");
|
|
4353
|
+
validateId(interfaceId, "interface_id");
|
|
4354
|
+
await invokeWithRetry(this.config, this.http, "ScopeInterfacesController_delete", {
|
|
4355
|
+
pathParams: { id: this.scopeId, interfaceId }
|
|
4356
|
+
});
|
|
4357
|
+
}
|
|
4358
|
+
};
|
|
4359
|
+
|
|
4124
4360
|
// src/management/scopes/supervision.ts
|
|
4125
4361
|
var ScopeSupervisionResource = class {
|
|
4126
4362
|
constructor(http, config, scopeId) {
|
|
@@ -4236,6 +4472,15 @@ var ManagementScopesResource = class {
|
|
|
4236
4472
|
supervision(scopeId) {
|
|
4237
4473
|
return new ScopeSupervisionResource(this.http, this.config, scopeId);
|
|
4238
4474
|
}
|
|
4475
|
+
/**
|
|
4476
|
+
* Slack and Microsoft Teams interfaces for a scope.
|
|
4477
|
+
*
|
|
4478
|
+
* @param scopeId - Scope id.
|
|
4479
|
+
* @returns An interfaces resource scoped to the scope.
|
|
4480
|
+
*/
|
|
4481
|
+
interfaces(scopeId) {
|
|
4482
|
+
return new ScopeInterfacesResource(this.http, this.config, scopeId);
|
|
4483
|
+
}
|
|
4239
4484
|
/**
|
|
4240
4485
|
* List scopes in the organization.
|
|
4241
4486
|
*
|
|
@@ -4307,6 +4552,7 @@ var ManagementScopesResource = class {
|
|
|
4307
4552
|
* @param options.instructions - Optional system instructions.
|
|
4308
4553
|
* @param options.model - Optional model id.
|
|
4309
4554
|
* @param options.toolset - Optional tool selection for the scope.
|
|
4555
|
+
* @param options.includeOwnLearnings - Whether the scope reads what is taught while using it. Defaults to true.
|
|
4310
4556
|
* @param options.guardrails - Runtime guardrail labels (for example `"no-pii"`). Omit to create with no guardrails.
|
|
4311
4557
|
* @returns The created scope (draft).
|
|
4312
4558
|
* @example
|
|
@@ -4326,6 +4572,7 @@ var ManagementScopesResource = class {
|
|
|
4326
4572
|
model: options.model,
|
|
4327
4573
|
connectionSet: options.connectionSet,
|
|
4328
4574
|
contextSelections: options.contextSelections,
|
|
4575
|
+
includeOwnLearnings: options.includeOwnLearnings,
|
|
4329
4576
|
interfaces: options.interfaces,
|
|
4330
4577
|
accessConfig: accessConfigBodyForCreate(options.guardrails)
|
|
4331
4578
|
});
|