@vectros-ai/mcp-server 0.18.2 → 0.19.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 +31 -0
- package/README.md +83 -27
- package/dist/cli-http.js +1169 -193
- package/dist/cli-http.js.map +1 -1
- package/dist/cli-http.mjs +1169 -193
- package/dist/cli-http.mjs.map +1 -1
- package/dist/cli.js +1167 -191
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +1167 -191
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +6 -4
- package/dist/index.d.ts +6 -4
- package/dist/index.js +1167 -191
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1167 -191
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/server.ts
|
|
2
2
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
3
3
|
|
|
4
|
-
//
|
|
4
|
+
// node_modules/@vectros-ai/sdk/dist/index.mjs
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
6
6
|
var __export = (target, all) => {
|
|
7
7
|
for (var name in all)
|
|
@@ -22,6 +22,7 @@ __export(api_exports, {
|
|
|
22
22
|
ContentTooLargeError: () => ContentTooLargeError,
|
|
23
23
|
DocumentAskRequest: () => DocumentAskRequest,
|
|
24
24
|
DocumentContextEvent: () => DocumentContextEvent,
|
|
25
|
+
DocumentExtraction: () => DocumentExtraction,
|
|
25
26
|
DocumentLookupRequest: () => DocumentLookupRequest,
|
|
26
27
|
DocumentPatchRequest: () => DocumentPatchRequest,
|
|
27
28
|
DocumentRequest: () => DocumentRequest,
|
|
@@ -74,6 +75,7 @@ __export(api_exports, {
|
|
|
74
75
|
UserExistsResponse: () => UserExistsResponse,
|
|
75
76
|
UserRequest: () => UserRequest,
|
|
76
77
|
UserResponse: () => UserResponse,
|
|
78
|
+
agents: () => agents_exports,
|
|
77
79
|
auth: () => auth_exports,
|
|
78
80
|
compliance: () => compliance_exports,
|
|
79
81
|
documents: () => documents_exports,
|
|
@@ -339,6 +341,7 @@ var UnprocessableEntityError = class extends VectrosError {
|
|
|
339
341
|
this.name = this.constructor.name;
|
|
340
342
|
}
|
|
341
343
|
};
|
|
344
|
+
var agents_exports = {};
|
|
342
345
|
var auth_exports = {};
|
|
343
346
|
var ErasureRequest;
|
|
344
347
|
((ErasureRequest2) => {
|
|
@@ -543,6 +546,18 @@ var DocumentContextEvent;
|
|
|
543
546
|
DocumentContext: "document_context"
|
|
544
547
|
};
|
|
545
548
|
})(DocumentContextEvent || (DocumentContextEvent = {}));
|
|
549
|
+
var DocumentExtraction;
|
|
550
|
+
((DocumentExtraction2) => {
|
|
551
|
+
DocumentExtraction2.Outcome = {
|
|
552
|
+
Ok: "OK",
|
|
553
|
+
Truncated: "TRUNCATED",
|
|
554
|
+
NoText: "NO_TEXT",
|
|
555
|
+
Encrypted: "ENCRYPTED",
|
|
556
|
+
Unsupported: "UNSUPPORTED",
|
|
557
|
+
TooLarge: "TOO_LARGE",
|
|
558
|
+
Unreadable: "UNREADABLE"
|
|
559
|
+
};
|
|
560
|
+
})(DocumentExtraction || (DocumentExtraction = {}));
|
|
546
561
|
var DocumentRequest;
|
|
547
562
|
((DocumentRequest2) => {
|
|
548
563
|
DocumentRequest2.IndexMode = {
|
|
@@ -1848,13 +1863,13 @@ function joinPathSegments(left, right) {
|
|
|
1848
1863
|
}
|
|
1849
1864
|
return `${left}/${right}`;
|
|
1850
1865
|
}
|
|
1851
|
-
function trimSlashes(
|
|
1852
|
-
if (!
|
|
1866
|
+
function trimSlashes(str2) {
|
|
1867
|
+
if (!str2) return str2;
|
|
1853
1868
|
let start = 0;
|
|
1854
|
-
let end =
|
|
1855
|
-
if (
|
|
1856
|
-
if (
|
|
1857
|
-
return start === 0 && end ===
|
|
1869
|
+
let end = str2.length;
|
|
1870
|
+
if (str2.startsWith("/")) start = 1;
|
|
1871
|
+
if (str2.endsWith("/")) end = str2.length - 1;
|
|
1872
|
+
return start === 0 && end === str2.length ? str2 : str2.slice(start, end);
|
|
1858
1873
|
}
|
|
1859
1874
|
var Supplier = {
|
|
1860
1875
|
get: async (supplier) => {
|
|
@@ -2369,48 +2384,675 @@ function normalizeClientOptionsWithAuth(options) {
|
|
|
2369
2384
|
normalized.authProvider = options.auth;
|
|
2370
2385
|
return normalized;
|
|
2371
2386
|
}
|
|
2372
|
-
Object.assign(normalized, options.auth);
|
|
2373
|
-
}
|
|
2374
|
-
const normalizedWithNoOpAuthProvider = withNoOpAuthProvider(normalized);
|
|
2375
|
-
normalized.authProvider ?? (normalized.authProvider = new BearerAuthProvider(normalizedWithNoOpAuthProvider));
|
|
2376
|
-
return normalized;
|
|
2377
|
-
}
|
|
2378
|
-
function withNoOpAuthProvider(options) {
|
|
2379
|
-
return {
|
|
2380
|
-
...options,
|
|
2381
|
-
authProvider: new NoOpAuthProvider()
|
|
2382
|
-
};
|
|
2383
|
-
}
|
|
2384
|
-
function handleNonStatusCodeError(error, rawResponse, method, path) {
|
|
2385
|
-
switch (error.reason) {
|
|
2386
|
-
case "non-json":
|
|
2387
|
-
throw new VectrosError({
|
|
2388
|
-
statusCode: error.statusCode,
|
|
2389
|
-
body: error.rawBody,
|
|
2390
|
-
rawResponse
|
|
2391
|
-
});
|
|
2392
|
-
case "body-is-null":
|
|
2393
|
-
throw new VectrosError({
|
|
2394
|
-
statusCode: error.statusCode,
|
|
2395
|
-
rawResponse
|
|
2396
|
-
});
|
|
2397
|
-
case "timeout":
|
|
2398
|
-
throw new VectrosTimeoutError(`Timeout exceeded when calling ${method} ${path}.`, {
|
|
2399
|
-
cause: error.cause
|
|
2400
|
-
});
|
|
2401
|
-
case "unknown":
|
|
2402
|
-
throw new VectrosError({
|
|
2403
|
-
message: error.errorMessage,
|
|
2404
|
-
rawResponse,
|
|
2405
|
-
cause: error.cause
|
|
2406
|
-
});
|
|
2407
|
-
default:
|
|
2408
|
-
throw new VectrosError({
|
|
2409
|
-
message: "Unknown error",
|
|
2410
|
-
rawResponse
|
|
2411
|
-
});
|
|
2387
|
+
Object.assign(normalized, options.auth);
|
|
2388
|
+
}
|
|
2389
|
+
const normalizedWithNoOpAuthProvider = withNoOpAuthProvider(normalized);
|
|
2390
|
+
normalized.authProvider ?? (normalized.authProvider = new BearerAuthProvider(normalizedWithNoOpAuthProvider));
|
|
2391
|
+
return normalized;
|
|
2392
|
+
}
|
|
2393
|
+
function withNoOpAuthProvider(options) {
|
|
2394
|
+
return {
|
|
2395
|
+
...options,
|
|
2396
|
+
authProvider: new NoOpAuthProvider()
|
|
2397
|
+
};
|
|
2398
|
+
}
|
|
2399
|
+
function handleNonStatusCodeError(error, rawResponse, method, path) {
|
|
2400
|
+
switch (error.reason) {
|
|
2401
|
+
case "non-json":
|
|
2402
|
+
throw new VectrosError({
|
|
2403
|
+
statusCode: error.statusCode,
|
|
2404
|
+
body: error.rawBody,
|
|
2405
|
+
rawResponse
|
|
2406
|
+
});
|
|
2407
|
+
case "body-is-null":
|
|
2408
|
+
throw new VectrosError({
|
|
2409
|
+
statusCode: error.statusCode,
|
|
2410
|
+
rawResponse
|
|
2411
|
+
});
|
|
2412
|
+
case "timeout":
|
|
2413
|
+
throw new VectrosTimeoutError(`Timeout exceeded when calling ${method} ${path}.`, {
|
|
2414
|
+
cause: error.cause
|
|
2415
|
+
});
|
|
2416
|
+
case "unknown":
|
|
2417
|
+
throw new VectrosError({
|
|
2418
|
+
message: error.errorMessage,
|
|
2419
|
+
rawResponse,
|
|
2420
|
+
cause: error.cause
|
|
2421
|
+
});
|
|
2422
|
+
default:
|
|
2423
|
+
throw new VectrosError({
|
|
2424
|
+
message: "Unknown error",
|
|
2425
|
+
rawResponse
|
|
2426
|
+
});
|
|
2427
|
+
}
|
|
2428
|
+
}
|
|
2429
|
+
var AgentsClient = class {
|
|
2430
|
+
constructor(options) {
|
|
2431
|
+
this._options = normalizeClientOptionsWithAuth(options);
|
|
2432
|
+
}
|
|
2433
|
+
/**
|
|
2434
|
+
* Returns a page of the agents in the app context, newest first, each at its latest version. A caller holding `runs:c` but not `agents:r` gets only each agent's `id`, `name`, `description`, `latestVersion` and `status`. Retired and purged agents are left out unless `includeRetired=true`. Requires `agents:r` or `runs:c`.
|
|
2435
|
+
*
|
|
2436
|
+
* @param {Vectros.ListAgentsRequest} request
|
|
2437
|
+
* @param {AgentsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
2438
|
+
*
|
|
2439
|
+
* @throws {@link Vectros.ForbiddenError}
|
|
2440
|
+
*
|
|
2441
|
+
* @example
|
|
2442
|
+
* await client.agents.listAgents()
|
|
2443
|
+
*/
|
|
2444
|
+
listAgents(request = {}, requestOptions) {
|
|
2445
|
+
return HttpResponsePromise.fromPromise(this.__listAgents(request, requestOptions));
|
|
2446
|
+
}
|
|
2447
|
+
async __listAgents(request = {}, requestOptions) {
|
|
2448
|
+
const { contextId, includeRetired, startFrom, limit } = request;
|
|
2449
|
+
const _queryParams = {
|
|
2450
|
+
contextId,
|
|
2451
|
+
includeRetired,
|
|
2452
|
+
startFrom,
|
|
2453
|
+
limit
|
|
2454
|
+
};
|
|
2455
|
+
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
2456
|
+
const _headers = mergeHeaders(
|
|
2457
|
+
_authRequest.headers,
|
|
2458
|
+
this._options?.headers,
|
|
2459
|
+
requestOptions?.headers
|
|
2460
|
+
);
|
|
2461
|
+
const _response = await fetcher({
|
|
2462
|
+
url: url_exports.join(
|
|
2463
|
+
await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
|
|
2464
|
+
"v1/agents"
|
|
2465
|
+
),
|
|
2466
|
+
method: "GET",
|
|
2467
|
+
headers: _headers,
|
|
2468
|
+
queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
|
|
2469
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
|
|
2470
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
2471
|
+
abortSignal: requestOptions?.abortSignal,
|
|
2472
|
+
fetchFn: this._options?.fetch,
|
|
2473
|
+
logging: this._options.logging
|
|
2474
|
+
});
|
|
2475
|
+
if (_response.ok) {
|
|
2476
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
2477
|
+
}
|
|
2478
|
+
if (_response.error.reason === "status-code") {
|
|
2479
|
+
switch (_response.error.statusCode) {
|
|
2480
|
+
case 403:
|
|
2481
|
+
throw new ForbiddenError(_response.error.body, _response.rawResponse);
|
|
2482
|
+
default:
|
|
2483
|
+
throw new VectrosError({
|
|
2484
|
+
statusCode: _response.error.statusCode,
|
|
2485
|
+
body: _response.error.body,
|
|
2486
|
+
rawResponse: _response.rawResponse
|
|
2487
|
+
});
|
|
2488
|
+
}
|
|
2489
|
+
}
|
|
2490
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/agents");
|
|
2491
|
+
}
|
|
2492
|
+
/**
|
|
2493
|
+
* Stores a new agent at version 1, or returns the existing agent of this name unchanged. With `?upsert=true` an existing agent whose definition differs gets a new version instead. Requires the `agents:c` scope (also `agents:u` with `?upsert=true`).
|
|
2494
|
+
*
|
|
2495
|
+
* @param {Vectros.CreateAgentRequest} request
|
|
2496
|
+
* @param {AgentsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
2497
|
+
*
|
|
2498
|
+
* @throws {@link Vectros.BadRequestError}
|
|
2499
|
+
* @throws {@link Vectros.ForbiddenError}
|
|
2500
|
+
* @throws {@link Vectros.ConflictError}
|
|
2501
|
+
* @throws {@link Vectros.TooManyRequestsError}
|
|
2502
|
+
*
|
|
2503
|
+
* @example
|
|
2504
|
+
* await client.agents.createAgent({
|
|
2505
|
+
* body: {
|
|
2506
|
+
* model: "claude-sonnet-5-5"
|
|
2507
|
+
* }
|
|
2508
|
+
* })
|
|
2509
|
+
*/
|
|
2510
|
+
createAgent(request, requestOptions) {
|
|
2511
|
+
return HttpResponsePromise.fromPromise(this.__createAgent(request, requestOptions));
|
|
2512
|
+
}
|
|
2513
|
+
async __createAgent(request, requestOptions) {
|
|
2514
|
+
const { upsert, contextId, body: _body } = request;
|
|
2515
|
+
const _queryParams = {
|
|
2516
|
+
upsert,
|
|
2517
|
+
contextId
|
|
2518
|
+
};
|
|
2519
|
+
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
2520
|
+
const _headers = mergeHeaders(
|
|
2521
|
+
_authRequest.headers,
|
|
2522
|
+
this._options?.headers,
|
|
2523
|
+
requestOptions?.headers
|
|
2524
|
+
);
|
|
2525
|
+
const _response = await fetcher({
|
|
2526
|
+
url: url_exports.join(
|
|
2527
|
+
await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
|
|
2528
|
+
"v1/agents"
|
|
2529
|
+
),
|
|
2530
|
+
method: "POST",
|
|
2531
|
+
headers: _headers,
|
|
2532
|
+
contentType: "application/json",
|
|
2533
|
+
queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
|
|
2534
|
+
requestType: "json",
|
|
2535
|
+
body: _body,
|
|
2536
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
|
|
2537
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
2538
|
+
abortSignal: requestOptions?.abortSignal,
|
|
2539
|
+
fetchFn: this._options?.fetch,
|
|
2540
|
+
logging: this._options.logging
|
|
2541
|
+
});
|
|
2542
|
+
if (_response.ok) {
|
|
2543
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
2544
|
+
}
|
|
2545
|
+
if (_response.error.reason === "status-code") {
|
|
2546
|
+
switch (_response.error.statusCode) {
|
|
2547
|
+
case 400:
|
|
2548
|
+
throw new BadRequestError(_response.error.body, _response.rawResponse);
|
|
2549
|
+
case 403:
|
|
2550
|
+
throw new ForbiddenError(_response.error.body, _response.rawResponse);
|
|
2551
|
+
case 409:
|
|
2552
|
+
throw new ConflictError(_response.error.body, _response.rawResponse);
|
|
2553
|
+
case 429:
|
|
2554
|
+
throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
|
|
2555
|
+
default:
|
|
2556
|
+
throw new VectrosError({
|
|
2557
|
+
statusCode: _response.error.statusCode,
|
|
2558
|
+
body: _response.error.body,
|
|
2559
|
+
rawResponse: _response.rawResponse
|
|
2560
|
+
});
|
|
2561
|
+
}
|
|
2562
|
+
}
|
|
2563
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/agents");
|
|
2564
|
+
}
|
|
2565
|
+
/**
|
|
2566
|
+
* Returns the agent at its latest version, or at `version`. Requires the `agents:r` scope.
|
|
2567
|
+
*
|
|
2568
|
+
* @param {Vectros.GetAgentRequest} request
|
|
2569
|
+
* @param {AgentsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
2570
|
+
*
|
|
2571
|
+
* @throws {@link Vectros.ForbiddenError}
|
|
2572
|
+
* @throws {@link Vectros.NotFoundError}
|
|
2573
|
+
*
|
|
2574
|
+
* @example
|
|
2575
|
+
* await client.agents.getAgent({
|
|
2576
|
+
* id: "id"
|
|
2577
|
+
* })
|
|
2578
|
+
*/
|
|
2579
|
+
getAgent(request, requestOptions) {
|
|
2580
|
+
return HttpResponsePromise.fromPromise(this.__getAgent(request, requestOptions));
|
|
2581
|
+
}
|
|
2582
|
+
async __getAgent(request, requestOptions) {
|
|
2583
|
+
const { id, contextId, version } = request;
|
|
2584
|
+
const _queryParams = {
|
|
2585
|
+
contextId,
|
|
2586
|
+
version
|
|
2587
|
+
};
|
|
2588
|
+
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
2589
|
+
const _headers = mergeHeaders(
|
|
2590
|
+
_authRequest.headers,
|
|
2591
|
+
this._options?.headers,
|
|
2592
|
+
requestOptions?.headers
|
|
2593
|
+
);
|
|
2594
|
+
const _response = await fetcher({
|
|
2595
|
+
url: url_exports.join(
|
|
2596
|
+
await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
|
|
2597
|
+
`v1/agents/${url_exports.encodePathParam(id)}`
|
|
2598
|
+
),
|
|
2599
|
+
method: "GET",
|
|
2600
|
+
headers: _headers,
|
|
2601
|
+
queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
|
|
2602
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
|
|
2603
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
2604
|
+
abortSignal: requestOptions?.abortSignal,
|
|
2605
|
+
fetchFn: this._options?.fetch,
|
|
2606
|
+
logging: this._options.logging
|
|
2607
|
+
});
|
|
2608
|
+
if (_response.ok) {
|
|
2609
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
2610
|
+
}
|
|
2611
|
+
if (_response.error.reason === "status-code") {
|
|
2612
|
+
switch (_response.error.statusCode) {
|
|
2613
|
+
case 403:
|
|
2614
|
+
throw new ForbiddenError(_response.error.body, _response.rawResponse);
|
|
2615
|
+
case 404:
|
|
2616
|
+
throw new NotFoundError(_response.error.body, _response.rawResponse);
|
|
2617
|
+
default:
|
|
2618
|
+
throw new VectrosError({
|
|
2619
|
+
statusCode: _response.error.statusCode,
|
|
2620
|
+
body: _response.error.body,
|
|
2621
|
+
rawResponse: _response.rawResponse
|
|
2622
|
+
});
|
|
2623
|
+
}
|
|
2624
|
+
}
|
|
2625
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/agents/{id}");
|
|
2626
|
+
}
|
|
2627
|
+
/**
|
|
2628
|
+
* Stores the body as the agent's next version. Earlier versions never change. Every optional field you leave out takes its default; `model` is required. With `?restore=true` a retired agent becomes active again with this version. Requires the `agents:u` scope.
|
|
2629
|
+
*
|
|
2630
|
+
* @param {Vectros.UpdateAgentRequest} request
|
|
2631
|
+
* @param {AgentsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
2632
|
+
*
|
|
2633
|
+
* @throws {@link Vectros.BadRequestError}
|
|
2634
|
+
* @throws {@link Vectros.ForbiddenError}
|
|
2635
|
+
* @throws {@link Vectros.NotFoundError}
|
|
2636
|
+
* @throws {@link Vectros.ConflictError}
|
|
2637
|
+
* @throws {@link Vectros.TooManyRequestsError}
|
|
2638
|
+
*
|
|
2639
|
+
* @example
|
|
2640
|
+
* await client.agents.updateAgent({
|
|
2641
|
+
* id: "id",
|
|
2642
|
+
* body: {
|
|
2643
|
+
* model: "claude-sonnet-5-5"
|
|
2644
|
+
* }
|
|
2645
|
+
* })
|
|
2646
|
+
*/
|
|
2647
|
+
updateAgent(request, requestOptions) {
|
|
2648
|
+
return HttpResponsePromise.fromPromise(this.__updateAgent(request, requestOptions));
|
|
2649
|
+
}
|
|
2650
|
+
async __updateAgent(request, requestOptions) {
|
|
2651
|
+
const { id, restore, contextId, body: _body } = request;
|
|
2652
|
+
const _queryParams = {
|
|
2653
|
+
restore,
|
|
2654
|
+
contextId
|
|
2655
|
+
};
|
|
2656
|
+
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
2657
|
+
const _headers = mergeHeaders(
|
|
2658
|
+
_authRequest.headers,
|
|
2659
|
+
this._options?.headers,
|
|
2660
|
+
requestOptions?.headers
|
|
2661
|
+
);
|
|
2662
|
+
const _response = await fetcher({
|
|
2663
|
+
url: url_exports.join(
|
|
2664
|
+
await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
|
|
2665
|
+
`v1/agents/${url_exports.encodePathParam(id)}`
|
|
2666
|
+
),
|
|
2667
|
+
method: "PUT",
|
|
2668
|
+
headers: _headers,
|
|
2669
|
+
contentType: "application/json",
|
|
2670
|
+
queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
|
|
2671
|
+
requestType: "json",
|
|
2672
|
+
body: _body,
|
|
2673
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
|
|
2674
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
2675
|
+
abortSignal: requestOptions?.abortSignal,
|
|
2676
|
+
fetchFn: this._options?.fetch,
|
|
2677
|
+
logging: this._options.logging
|
|
2678
|
+
});
|
|
2679
|
+
if (_response.ok) {
|
|
2680
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
2681
|
+
}
|
|
2682
|
+
if (_response.error.reason === "status-code") {
|
|
2683
|
+
switch (_response.error.statusCode) {
|
|
2684
|
+
case 400:
|
|
2685
|
+
throw new BadRequestError(_response.error.body, _response.rawResponse);
|
|
2686
|
+
case 403:
|
|
2687
|
+
throw new ForbiddenError(_response.error.body, _response.rawResponse);
|
|
2688
|
+
case 404:
|
|
2689
|
+
throw new NotFoundError(_response.error.body, _response.rawResponse);
|
|
2690
|
+
case 409:
|
|
2691
|
+
throw new ConflictError(_response.error.body, _response.rawResponse);
|
|
2692
|
+
case 429:
|
|
2693
|
+
throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
|
|
2694
|
+
default:
|
|
2695
|
+
throw new VectrosError({
|
|
2696
|
+
statusCode: _response.error.statusCode,
|
|
2697
|
+
body: _response.error.body,
|
|
2698
|
+
rawResponse: _response.rawResponse
|
|
2699
|
+
});
|
|
2700
|
+
}
|
|
2701
|
+
}
|
|
2702
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/v1/agents/{id}");
|
|
2703
|
+
}
|
|
2704
|
+
/**
|
|
2705
|
+
* Retires the agent: its versions stay readable, it leaves the default listing, and it can be restored. With `?purge=true` a retired agent's content (every version's prompt, description, tools, model, limits and budget) is erased, leaving its id, name, version numbers and timestamps; its change history keeps only a one-way hash of the prompt, description and tools. If the agent is restored while a purge is running, the purge stops (409) and versions it already erased stay erased; purge it again after retiring it. With `?purge=true&version=N` one version that is not the latest is erased. The name of a purged agent stays reserved. Requires the `agents:d` scope.
|
|
2706
|
+
*
|
|
2707
|
+
* @param {Vectros.DeleteAgentRequest} request
|
|
2708
|
+
* @param {AgentsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
2709
|
+
*
|
|
2710
|
+
* @throws {@link Vectros.BadRequestError}
|
|
2711
|
+
* @throws {@link Vectros.ForbiddenError}
|
|
2712
|
+
* @throws {@link Vectros.NotFoundError}
|
|
2713
|
+
* @throws {@link Vectros.ConflictError}
|
|
2714
|
+
* @throws {@link Vectros.TooManyRequestsError}
|
|
2715
|
+
*
|
|
2716
|
+
* @example
|
|
2717
|
+
* await client.agents.deleteAgent({
|
|
2718
|
+
* id: "id"
|
|
2719
|
+
* })
|
|
2720
|
+
*/
|
|
2721
|
+
deleteAgent(request, requestOptions) {
|
|
2722
|
+
return HttpResponsePromise.fromPromise(this.__deleteAgent(request, requestOptions));
|
|
2723
|
+
}
|
|
2724
|
+
async __deleteAgent(request, requestOptions) {
|
|
2725
|
+
const { id, purge, version, contextId } = request;
|
|
2726
|
+
const _queryParams = {
|
|
2727
|
+
purge,
|
|
2728
|
+
version,
|
|
2729
|
+
contextId
|
|
2730
|
+
};
|
|
2731
|
+
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
2732
|
+
const _headers = mergeHeaders(
|
|
2733
|
+
_authRequest.headers,
|
|
2734
|
+
this._options?.headers,
|
|
2735
|
+
requestOptions?.headers
|
|
2736
|
+
);
|
|
2737
|
+
const _response = await fetcher({
|
|
2738
|
+
url: url_exports.join(
|
|
2739
|
+
await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
|
|
2740
|
+
`v1/agents/${url_exports.encodePathParam(id)}`
|
|
2741
|
+
),
|
|
2742
|
+
method: "DELETE",
|
|
2743
|
+
headers: _headers,
|
|
2744
|
+
queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
|
|
2745
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
|
|
2746
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
2747
|
+
abortSignal: requestOptions?.abortSignal,
|
|
2748
|
+
fetchFn: this._options?.fetch,
|
|
2749
|
+
logging: this._options.logging
|
|
2750
|
+
});
|
|
2751
|
+
if (_response.ok) {
|
|
2752
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
2753
|
+
}
|
|
2754
|
+
if (_response.error.reason === "status-code") {
|
|
2755
|
+
switch (_response.error.statusCode) {
|
|
2756
|
+
case 400:
|
|
2757
|
+
throw new BadRequestError(_response.error.body, _response.rawResponse);
|
|
2758
|
+
case 403:
|
|
2759
|
+
throw new ForbiddenError(_response.error.body, _response.rawResponse);
|
|
2760
|
+
case 404:
|
|
2761
|
+
throw new NotFoundError(_response.error.body, _response.rawResponse);
|
|
2762
|
+
case 409:
|
|
2763
|
+
throw new ConflictError(_response.error.body, _response.rawResponse);
|
|
2764
|
+
case 429:
|
|
2765
|
+
throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
|
|
2766
|
+
default:
|
|
2767
|
+
throw new VectrosError({
|
|
2768
|
+
statusCode: _response.error.statusCode,
|
|
2769
|
+
body: _response.error.body,
|
|
2770
|
+
rawResponse: _response.rawResponse
|
|
2771
|
+
});
|
|
2772
|
+
}
|
|
2773
|
+
}
|
|
2774
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/v1/agents/{id}");
|
|
2775
|
+
}
|
|
2776
|
+
/**
|
|
2777
|
+
* Returns a page of the agent's versions, newest first: who wrote each and when, and whether it was purged. With `includeContent=true` each entry carries its full definition. Requires the `agents:r` scope.
|
|
2778
|
+
*
|
|
2779
|
+
* @param {Vectros.ListAgentVersionsRequest} request
|
|
2780
|
+
* @param {AgentsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
2781
|
+
*
|
|
2782
|
+
* @throws {@link Vectros.ForbiddenError}
|
|
2783
|
+
* @throws {@link Vectros.NotFoundError}
|
|
2784
|
+
*
|
|
2785
|
+
* @example
|
|
2786
|
+
* await client.agents.listAgentVersions({
|
|
2787
|
+
* id: "id"
|
|
2788
|
+
* })
|
|
2789
|
+
*/
|
|
2790
|
+
listAgentVersions(request, requestOptions) {
|
|
2791
|
+
return HttpResponsePromise.fromPromise(this.__listAgentVersions(request, requestOptions));
|
|
2792
|
+
}
|
|
2793
|
+
async __listAgentVersions(request, requestOptions) {
|
|
2794
|
+
const { id, contextId, includeContent, startFrom, limit } = request;
|
|
2795
|
+
const _queryParams = {
|
|
2796
|
+
contextId,
|
|
2797
|
+
includeContent,
|
|
2798
|
+
startFrom,
|
|
2799
|
+
limit
|
|
2800
|
+
};
|
|
2801
|
+
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
2802
|
+
const _headers = mergeHeaders(
|
|
2803
|
+
_authRequest.headers,
|
|
2804
|
+
this._options?.headers,
|
|
2805
|
+
requestOptions?.headers
|
|
2806
|
+
);
|
|
2807
|
+
const _response = await fetcher({
|
|
2808
|
+
url: url_exports.join(
|
|
2809
|
+
await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
|
|
2810
|
+
`v1/agents/${url_exports.encodePathParam(id)}/versions`
|
|
2811
|
+
),
|
|
2812
|
+
method: "GET",
|
|
2813
|
+
headers: _headers,
|
|
2814
|
+
queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
|
|
2815
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
|
|
2816
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
2817
|
+
abortSignal: requestOptions?.abortSignal,
|
|
2818
|
+
fetchFn: this._options?.fetch,
|
|
2819
|
+
logging: this._options.logging
|
|
2820
|
+
});
|
|
2821
|
+
if (_response.ok) {
|
|
2822
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
2823
|
+
}
|
|
2824
|
+
if (_response.error.reason === "status-code") {
|
|
2825
|
+
switch (_response.error.statusCode) {
|
|
2826
|
+
case 403:
|
|
2827
|
+
throw new ForbiddenError(_response.error.body, _response.rawResponse);
|
|
2828
|
+
case 404:
|
|
2829
|
+
throw new NotFoundError(_response.error.body, _response.rawResponse);
|
|
2830
|
+
default:
|
|
2831
|
+
throw new VectrosError({
|
|
2832
|
+
statusCode: _response.error.statusCode,
|
|
2833
|
+
body: _response.error.body,
|
|
2834
|
+
rawResponse: _response.rawResponse
|
|
2835
|
+
});
|
|
2836
|
+
}
|
|
2837
|
+
}
|
|
2838
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/agents/{id}/versions");
|
|
2839
|
+
}
|
|
2840
|
+
/**
|
|
2841
|
+
* Stops a run. The answer is `202` with the run still `RUNNING`: read it with `GET /v1/runs/{id}` to see it end. A model call in progress is cut within a few seconds; a tool call in progress is first allowed to finish, for up to about 30 seconds, so its change is recorded and billed, and the run stops as soon as it has. The run then ends `CANCELLED` with `errorCode` `CANCELLED_BY_CALLER`, unless it had already completed, in which case it stays `COMPLETED`. Its reservation is settled once, like any run's: a model call in progress when it stopped is charged up to its maximum. A run that has ended (or that had not started, which this cancel ends) answers `200` with its final state, so a cancel can always be retried. A run can be cancelled by the credential that started it (for a token bound to a user, by that user) and by your root key. Requires the `runs:c` scope; with `runs:r` as well the answer is the whole run, otherwise only its `id`, `status`, `terminal`, `reason` and `errorCode`. Takes no body.
|
|
2842
|
+
*
|
|
2843
|
+
* @param {Vectros.CancelRunRequest} request
|
|
2844
|
+
* @param {AgentsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
2845
|
+
*
|
|
2846
|
+
* @throws {@link Vectros.BadRequestError}
|
|
2847
|
+
* @throws {@link Vectros.UnauthorizedError}
|
|
2848
|
+
* @throws {@link Vectros.ForbiddenError}
|
|
2849
|
+
* @throws {@link Vectros.NotFoundError}
|
|
2850
|
+
* @throws {@link Vectros.TooManyRequestsError}
|
|
2851
|
+
*
|
|
2852
|
+
* @example
|
|
2853
|
+
* await client.agents.cancelRun({
|
|
2854
|
+
* id: "id"
|
|
2855
|
+
* })
|
|
2856
|
+
*/
|
|
2857
|
+
cancelRun(request, requestOptions) {
|
|
2858
|
+
return HttpResponsePromise.fromPromise(this.__cancelRun(request, requestOptions));
|
|
2859
|
+
}
|
|
2860
|
+
async __cancelRun(request, requestOptions) {
|
|
2861
|
+
const { id, contextId } = request;
|
|
2862
|
+
const _queryParams = {
|
|
2863
|
+
contextId
|
|
2864
|
+
};
|
|
2865
|
+
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
2866
|
+
const _headers = mergeHeaders(
|
|
2867
|
+
_authRequest.headers,
|
|
2868
|
+
this._options?.headers,
|
|
2869
|
+
requestOptions?.headers
|
|
2870
|
+
);
|
|
2871
|
+
const _response = await fetcher({
|
|
2872
|
+
url: url_exports.join(
|
|
2873
|
+
await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
|
|
2874
|
+
`v1/runs/${url_exports.encodePathParam(id)}/cancel`
|
|
2875
|
+
),
|
|
2876
|
+
method: "POST",
|
|
2877
|
+
headers: _headers,
|
|
2878
|
+
queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
|
|
2879
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
|
|
2880
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
2881
|
+
abortSignal: requestOptions?.abortSignal,
|
|
2882
|
+
fetchFn: this._options?.fetch,
|
|
2883
|
+
logging: this._options.logging
|
|
2884
|
+
});
|
|
2885
|
+
if (_response.ok) {
|
|
2886
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
2887
|
+
}
|
|
2888
|
+
if (_response.error.reason === "status-code") {
|
|
2889
|
+
switch (_response.error.statusCode) {
|
|
2890
|
+
case 400:
|
|
2891
|
+
throw new BadRequestError(_response.error.body, _response.rawResponse);
|
|
2892
|
+
case 401:
|
|
2893
|
+
throw new UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
2894
|
+
case 403:
|
|
2895
|
+
throw new ForbiddenError(_response.error.body, _response.rawResponse);
|
|
2896
|
+
case 404:
|
|
2897
|
+
throw new NotFoundError(_response.error.body, _response.rawResponse);
|
|
2898
|
+
case 429:
|
|
2899
|
+
throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
|
|
2900
|
+
default:
|
|
2901
|
+
throw new VectrosError({
|
|
2902
|
+
statusCode: _response.error.statusCode,
|
|
2903
|
+
body: _response.error.body,
|
|
2904
|
+
rawResponse: _response.rawResponse
|
|
2905
|
+
});
|
|
2906
|
+
}
|
|
2907
|
+
}
|
|
2908
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/runs/{id}/cancel");
|
|
2909
|
+
}
|
|
2910
|
+
/**
|
|
2911
|
+
* Returns the status and metadata of one run: the agent version that ran, how it ended, its tool calls (never their arguments or results) and what it was charged. It never returns text: the answer is delivered only in the run's stream. A run is visible to the credential that started it (for a token bound to a user, to that user) and to your root key, and is kept for 30 days after it ends. Requires the `runs:r` scope.
|
|
2912
|
+
*
|
|
2913
|
+
* @param {Vectros.GetRunRequest} request
|
|
2914
|
+
* @param {AgentsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
2915
|
+
*
|
|
2916
|
+
* @throws {@link Vectros.BadRequestError}
|
|
2917
|
+
* @throws {@link Vectros.UnauthorizedError}
|
|
2918
|
+
* @throws {@link Vectros.ForbiddenError}
|
|
2919
|
+
* @throws {@link Vectros.NotFoundError}
|
|
2920
|
+
*
|
|
2921
|
+
* @example
|
|
2922
|
+
* await client.agents.getRun({
|
|
2923
|
+
* id: "id"
|
|
2924
|
+
* })
|
|
2925
|
+
*/
|
|
2926
|
+
getRun(request, requestOptions) {
|
|
2927
|
+
return HttpResponsePromise.fromPromise(this.__getRun(request, requestOptions));
|
|
2928
|
+
}
|
|
2929
|
+
async __getRun(request, requestOptions) {
|
|
2930
|
+
const { id, contextId } = request;
|
|
2931
|
+
const _queryParams = {
|
|
2932
|
+
contextId
|
|
2933
|
+
};
|
|
2934
|
+
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
2935
|
+
const _headers = mergeHeaders(
|
|
2936
|
+
_authRequest.headers,
|
|
2937
|
+
this._options?.headers,
|
|
2938
|
+
requestOptions?.headers
|
|
2939
|
+
);
|
|
2940
|
+
const _response = await fetcher({
|
|
2941
|
+
url: url_exports.join(
|
|
2942
|
+
await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
|
|
2943
|
+
`v1/runs/${url_exports.encodePathParam(id)}`
|
|
2944
|
+
),
|
|
2945
|
+
method: "GET",
|
|
2946
|
+
headers: _headers,
|
|
2947
|
+
queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
|
|
2948
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
|
|
2949
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
2950
|
+
abortSignal: requestOptions?.abortSignal,
|
|
2951
|
+
fetchFn: this._options?.fetch,
|
|
2952
|
+
logging: this._options.logging
|
|
2953
|
+
});
|
|
2954
|
+
if (_response.ok) {
|
|
2955
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
2956
|
+
}
|
|
2957
|
+
if (_response.error.reason === "status-code") {
|
|
2958
|
+
switch (_response.error.statusCode) {
|
|
2959
|
+
case 400:
|
|
2960
|
+
throw new BadRequestError(_response.error.body, _response.rawResponse);
|
|
2961
|
+
case 401:
|
|
2962
|
+
throw new UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
2963
|
+
case 403:
|
|
2964
|
+
throw new ForbiddenError(_response.error.body, _response.rawResponse);
|
|
2965
|
+
case 404:
|
|
2966
|
+
throw new NotFoundError(_response.error.body, _response.rawResponse);
|
|
2967
|
+
default:
|
|
2968
|
+
throw new VectrosError({
|
|
2969
|
+
statusCode: _response.error.statusCode,
|
|
2970
|
+
body: _response.error.body,
|
|
2971
|
+
rawResponse: _response.rawResponse
|
|
2972
|
+
});
|
|
2973
|
+
}
|
|
2974
|
+
}
|
|
2975
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/runs/{id}");
|
|
2976
|
+
}
|
|
2977
|
+
/**
|
|
2978
|
+
* Starts a run of a stored agent and streams what it does as Server-Sent Events. The response is always `text/event-stream`, whatever `Accept` you send; its `X-Vectros-Run-Id` header names the run. The run's tool calls act as you, with your own permissions, and only through the tools the agent lists. On a prepaid account the run reserves its budget from your inference balance when it starts and returns what its model calls did not use when it ends; a fixed fee per run, tool calls and run time are billed separately, against your plan. Read each event's `type`; ignore types and fields you do not know; stop at the event with `terminal: true`. A stream that ends without one: read the run with `GET /v1/runs/{id}`. Closing the stream stops the run only on a best-effort basis. Requires the `runs:c` scope, and agent runs switched on for your tenant by an account owner.
|
|
2979
|
+
*/
|
|
2980
|
+
createRun(request, requestOptions) {
|
|
2981
|
+
return HttpResponsePromise.fromPromise(this.__createRun(request, requestOptions));
|
|
2982
|
+
}
|
|
2983
|
+
async __createRun(request, requestOptions) {
|
|
2984
|
+
const { "Idempotency-Key": idempotencyKey, ..._body } = request;
|
|
2985
|
+
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
2986
|
+
const _headers = mergeHeaders(
|
|
2987
|
+
_authRequest.headers,
|
|
2988
|
+
this._options?.headers,
|
|
2989
|
+
mergeOnlyDefinedHeaders({ "Idempotency-Key": idempotencyKey }),
|
|
2990
|
+
requestOptions?.headers
|
|
2991
|
+
);
|
|
2992
|
+
const _response = await fetcher({
|
|
2993
|
+
url: url_exports.join(
|
|
2994
|
+
await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
|
|
2995
|
+
"v1/runs"
|
|
2996
|
+
),
|
|
2997
|
+
method: "POST",
|
|
2998
|
+
headers: _headers,
|
|
2999
|
+
contentType: "application/json",
|
|
3000
|
+
queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
|
|
3001
|
+
requestType: "json",
|
|
3002
|
+
body: _body,
|
|
3003
|
+
responseType: "sse",
|
|
3004
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
|
|
3005
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
3006
|
+
abortSignal: requestOptions?.abortSignal,
|
|
3007
|
+
fetchFn: this._options?.fetch,
|
|
3008
|
+
logging: this._options.logging
|
|
3009
|
+
});
|
|
3010
|
+
if (_response.ok) {
|
|
3011
|
+
return {
|
|
3012
|
+
data: new Stream({
|
|
3013
|
+
stream: _response.body,
|
|
3014
|
+
parse: (data) => data,
|
|
3015
|
+
signal: requestOptions?.abortSignal,
|
|
3016
|
+
eventShape: {
|
|
3017
|
+
type: "sse"
|
|
3018
|
+
}
|
|
3019
|
+
}),
|
|
3020
|
+
rawResponse: _response.rawResponse
|
|
3021
|
+
};
|
|
3022
|
+
}
|
|
3023
|
+
if (_response.error.reason === "status-code") {
|
|
3024
|
+
switch (_response.error.statusCode) {
|
|
3025
|
+
case 400:
|
|
3026
|
+
throw new BadRequestError(_response.error.body, _response.rawResponse);
|
|
3027
|
+
case 401:
|
|
3028
|
+
throw new UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
3029
|
+
case 402:
|
|
3030
|
+
throw new PaymentRequiredError(_response.error.body, _response.rawResponse);
|
|
3031
|
+
case 403:
|
|
3032
|
+
throw new ForbiddenError(_response.error.body, _response.rawResponse);
|
|
3033
|
+
case 404:
|
|
3034
|
+
throw new NotFoundError(_response.error.body, _response.rawResponse);
|
|
3035
|
+
case 409:
|
|
3036
|
+
throw new ConflictError(_response.error.body, _response.rawResponse);
|
|
3037
|
+
case 413:
|
|
3038
|
+
throw new ContentTooLargeError(_response.error.body, _response.rawResponse);
|
|
3039
|
+
case 422:
|
|
3040
|
+
throw new UnprocessableEntityError(_response.error.body, _response.rawResponse);
|
|
3041
|
+
case 429:
|
|
3042
|
+
throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
|
|
3043
|
+
case 503:
|
|
3044
|
+
throw new ServiceUnavailableError(_response.error.body, _response.rawResponse);
|
|
3045
|
+
default:
|
|
3046
|
+
throw new VectrosError({
|
|
3047
|
+
statusCode: _response.error.statusCode,
|
|
3048
|
+
body: _response.error.body,
|
|
3049
|
+
rawResponse: _response.rawResponse
|
|
3050
|
+
});
|
|
3051
|
+
}
|
|
3052
|
+
}
|
|
3053
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/runs");
|
|
2412
3054
|
}
|
|
2413
|
-
}
|
|
3055
|
+
};
|
|
2414
3056
|
var AuthClient = class {
|
|
2415
3057
|
constructor(options) {
|
|
2416
3058
|
this._options = normalizeClientOptionsWithAuth(options);
|
|
@@ -2958,9 +3600,7 @@ var AuthClient = class {
|
|
|
2958
3600
|
* @example
|
|
2959
3601
|
* await client.auth.createAccessProfile({
|
|
2960
3602
|
* contextId: "contextId",
|
|
2961
|
-
* body: {
|
|
2962
|
-
* principalId: "usr_6ba7b810-9dad-11d1-80b4-00c04fd430c8"
|
|
2963
|
-
* }
|
|
3603
|
+
* body: {}
|
|
2964
3604
|
* })
|
|
2965
3605
|
*/
|
|
2966
3606
|
createAccessProfile(request, requestOptions) {
|
|
@@ -3096,10 +3736,7 @@ var AuthClient = class {
|
|
|
3096
3736
|
*
|
|
3097
3737
|
* @example
|
|
3098
3738
|
* await client.auth.createAppContext({
|
|
3099
|
-
* body: {
|
|
3100
|
-
* contextId: "myapp",
|
|
3101
|
-
* name: "My Internal App"
|
|
3102
|
-
* }
|
|
3739
|
+
* body: {}
|
|
3103
3740
|
* })
|
|
3104
3741
|
*/
|
|
3105
3742
|
createAppContext(request, requestOptions) {
|
|
@@ -3242,13 +3879,7 @@ var AuthClient = class {
|
|
|
3242
3879
|
* @example
|
|
3243
3880
|
* await client.auth.createRole({
|
|
3244
3881
|
* contextId: "contextId",
|
|
3245
|
-
* body: {
|
|
3246
|
-
* roleId: "engineering-member",
|
|
3247
|
-
* name: "Engineering Team Member",
|
|
3248
|
-
* scopes: [{
|
|
3249
|
-
* allowed_actions: ["records:cru", "search:r"]
|
|
3250
|
-
* }]
|
|
3251
|
-
* }
|
|
3882
|
+
* body: {}
|
|
3252
3883
|
* })
|
|
3253
3884
|
*/
|
|
3254
3885
|
createRole(request, requestOptions) {
|
|
@@ -3392,9 +4023,7 @@ var AuthClient = class {
|
|
|
3392
4023
|
* await client.auth.updateAccessProfile({
|
|
3393
4024
|
* contextId: "contextId",
|
|
3394
4025
|
* principalId: "principalId",
|
|
3395
|
-
* body: {
|
|
3396
|
-
* principalId: "usr_6ba7b810-9dad-11d1-80b4-00c04fd430c8"
|
|
3397
|
-
* }
|
|
4026
|
+
* body: {}
|
|
3398
4027
|
* })
|
|
3399
4028
|
*/
|
|
3400
4029
|
updateAccessProfile(request, requestOptions) {
|
|
@@ -3597,10 +4226,7 @@ var AuthClient = class {
|
|
|
3597
4226
|
* @example
|
|
3598
4227
|
* await client.auth.updateAppContext({
|
|
3599
4228
|
* contextId: "contextId",
|
|
3600
|
-
* body: {
|
|
3601
|
-
* contextId: "myapp",
|
|
3602
|
-
* name: "My Internal App"
|
|
3603
|
-
* }
|
|
4229
|
+
* body: {}
|
|
3604
4230
|
* })
|
|
3605
4231
|
*/
|
|
3606
4232
|
updateAppContext(request, requestOptions) {
|
|
@@ -3805,13 +4431,7 @@ var AuthClient = class {
|
|
|
3805
4431
|
* await client.auth.updateRole({
|
|
3806
4432
|
* contextId: "contextId",
|
|
3807
4433
|
* roleId: "roleId",
|
|
3808
|
-
* body: {
|
|
3809
|
-
* roleId: "engineering-member",
|
|
3810
|
-
* name: "Engineering Team Member",
|
|
3811
|
-
* scopes: [{
|
|
3812
|
-
* allowed_actions: ["records:cru", "search:r"]
|
|
3813
|
-
* }]
|
|
3814
|
-
* }
|
|
4434
|
+
* body: {}
|
|
3815
4435
|
* })
|
|
3816
4436
|
*/
|
|
3817
4437
|
updateRole(request, requestOptions) {
|
|
@@ -5263,7 +5883,7 @@ var DocumentsClient = class {
|
|
|
5263
5883
|
this._options = normalizeClientOptionsWithAuth(options);
|
|
5264
5884
|
}
|
|
5265
5885
|
/**
|
|
5266
|
-
* Returns a paginated list of your documents, optionally filtered by folder (`folderId`)
|
|
5886
|
+
* Returns a paginated list of your documents, optionally filtered by folder (`folderId`), owner (`userId` or `scope`) and/or type (`type`). The response is a `{data, nextCursor}` envelope; pass `nextCursor` back as `startFrom` to fetch the next page. A page can hold fewer documents than `limit`, or none, while `nextCursor` is still set: keep paging until `nextCursor` is null. Requires the `documents:r` scope.
|
|
5267
5887
|
*
|
|
5268
5888
|
* @param {Vectros.ListDocumentsRequest} request
|
|
5269
5889
|
* @param {DocumentsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
@@ -5273,6 +5893,7 @@ var DocumentsClient = class {
|
|
|
5273
5893
|
* userId: "550e8400-e29b-41d4-a716-446655440000",
|
|
5274
5894
|
* scope: "group:eng-team",
|
|
5275
5895
|
* folderId: "f47ac10b-58cc-4372-a567-0e02b2c3d479",
|
|
5896
|
+
* type: "investigation_report",
|
|
5276
5897
|
* startFrom: "b3BhcXVlLWN1cnNvci1mcm9tLXRoZS1wcmV2aW91cy1wYWdl"
|
|
5277
5898
|
* })
|
|
5278
5899
|
*/
|
|
@@ -5280,11 +5901,12 @@ var DocumentsClient = class {
|
|
|
5280
5901
|
return HttpResponsePromise.fromPromise(this.__listDocuments(request, requestOptions));
|
|
5281
5902
|
}
|
|
5282
5903
|
async __listDocuments(request = {}, requestOptions) {
|
|
5283
|
-
const { userId, scope, folderId, startFrom, limit } = request;
|
|
5904
|
+
const { userId, scope, folderId, type: type_, startFrom, limit } = request;
|
|
5284
5905
|
const _queryParams = {
|
|
5285
5906
|
userId,
|
|
5286
5907
|
scope,
|
|
5287
5908
|
folderId,
|
|
5909
|
+
type: type_,
|
|
5288
5910
|
startFrom,
|
|
5289
5911
|
limit
|
|
5290
5912
|
};
|
|
@@ -5334,9 +5956,7 @@ var DocumentsClient = class {
|
|
|
5334
5956
|
*
|
|
5335
5957
|
* @example
|
|
5336
5958
|
* await client.documents.ingestDocument({
|
|
5337
|
-
* body: {
|
|
5338
|
-
* title: "Patient Intake Form \u2014 Jane Doe"
|
|
5339
|
-
* }
|
|
5959
|
+
* body: {}
|
|
5340
5960
|
* })
|
|
5341
5961
|
*/
|
|
5342
5962
|
ingestDocument(request, requestOptions) {
|
|
@@ -5466,9 +6086,7 @@ var DocumentsClient = class {
|
|
|
5466
6086
|
* @example
|
|
5467
6087
|
* await client.documents.updateDocument({
|
|
5468
6088
|
* id: "id",
|
|
5469
|
-
* body: {
|
|
5470
|
-
* title: "Patient Intake Form \u2014 Jane Doe"
|
|
5471
|
-
* }
|
|
6089
|
+
* body: {}
|
|
5472
6090
|
* })
|
|
5473
6091
|
*/
|
|
5474
6092
|
updateDocument(request, requestOptions) {
|
|
@@ -5866,11 +6484,12 @@ var DocumentsClient = class {
|
|
|
5866
6484
|
return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/documents/{id}/download");
|
|
5867
6485
|
}
|
|
5868
6486
|
/**
|
|
5869
|
-
* Returns the document's full text body when it is retained: retained for text-ingested documents, and for file-uploaded documents unless they were uploaded with `storeText=false` (which discards the extracted text once indexing completes — the original file remains available via `GET /v1/documents/{id}/download`). Returns 404 when the document does not exist, its text was not retained,
|
|
6487
|
+
* Returns the document's full text body when it is retained: retained for text-ingested documents, and for file-uploaded documents unless they were uploaded with `storeText=false` (which discards the extracted text once indexing completes — the original file remains available via `GET /v1/documents/{id}/download`). Returns 404 when the document does not exist, its text was not retained, extraction has not yet completed, or no text could be extracted from its file (see the document's `extraction`). To read a long text in parts, pass `limit` (and `offset` from the second part on): offsets and lengths count Unicode characters (code points), `totalLength` is the length of the whole text, and `nextOffset` is where the next part starts, absent once the end is reached. Requires the `documents:r` scope.
|
|
5870
6488
|
*
|
|
5871
6489
|
* @param {Vectros.GetDocumentTextRequest} request
|
|
5872
6490
|
* @param {DocumentsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
5873
6491
|
*
|
|
6492
|
+
* @throws {@link Vectros.BadRequestError}
|
|
5874
6493
|
* @throws {@link Vectros.NotFoundError}
|
|
5875
6494
|
*
|
|
5876
6495
|
* @example
|
|
@@ -5882,7 +6501,11 @@ var DocumentsClient = class {
|
|
|
5882
6501
|
return HttpResponsePromise.fromPromise(this.__getDocumentText(request, requestOptions));
|
|
5883
6502
|
}
|
|
5884
6503
|
async __getDocumentText(request, requestOptions) {
|
|
5885
|
-
const { id } = request;
|
|
6504
|
+
const { id, offset, limit } = request;
|
|
6505
|
+
const _queryParams = {
|
|
6506
|
+
offset,
|
|
6507
|
+
limit
|
|
6508
|
+
};
|
|
5886
6509
|
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
5887
6510
|
const _headers = mergeHeaders(
|
|
5888
6511
|
_authRequest.headers,
|
|
@@ -5896,7 +6519,7 @@ var DocumentsClient = class {
|
|
|
5896
6519
|
),
|
|
5897
6520
|
method: "GET",
|
|
5898
6521
|
headers: _headers,
|
|
5899
|
-
queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
|
|
6522
|
+
queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
|
|
5900
6523
|
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
|
|
5901
6524
|
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
5902
6525
|
abortSignal: requestOptions?.abortSignal,
|
|
@@ -5908,6 +6531,8 @@ var DocumentsClient = class {
|
|
|
5908
6531
|
}
|
|
5909
6532
|
if (_response.error.reason === "status-code") {
|
|
5910
6533
|
switch (_response.error.statusCode) {
|
|
6534
|
+
case 400:
|
|
6535
|
+
throw new BadRequestError(_response.error.body, _response.rawResponse);
|
|
5911
6536
|
case 404:
|
|
5912
6537
|
throw new NotFoundError(_response.error.body, _response.rawResponse);
|
|
5913
6538
|
default:
|
|
@@ -6127,9 +6752,7 @@ var FoldersClient = class {
|
|
|
6127
6752
|
*
|
|
6128
6753
|
* @example
|
|
6129
6754
|
* await client.folders.createFolder({
|
|
6130
|
-
* body: {
|
|
6131
|
-
* name: "Patient Records 2024"
|
|
6132
|
-
* }
|
|
6755
|
+
* body: {}
|
|
6133
6756
|
* })
|
|
6134
6757
|
*/
|
|
6135
6758
|
createFolder(request, requestOptions) {
|
|
@@ -6257,9 +6880,7 @@ var FoldersClient = class {
|
|
|
6257
6880
|
* @example
|
|
6258
6881
|
* await client.folders.updateFolder({
|
|
6259
6882
|
* id: "id",
|
|
6260
|
-
* body: {
|
|
6261
|
-
* name: "Patient Records 2024"
|
|
6262
|
-
* }
|
|
6883
|
+
* body: {}
|
|
6263
6884
|
* })
|
|
6264
6885
|
*/
|
|
6265
6886
|
updateFolder(request, requestOptions) {
|
|
@@ -6392,9 +7013,7 @@ var FoldersClient = class {
|
|
|
6392
7013
|
* @example
|
|
6393
7014
|
* await client.folders.patchFolder({
|
|
6394
7015
|
* id: "id",
|
|
6395
|
-
* body: {
|
|
6396
|
-
* name: "Patient Records 2024"
|
|
6397
|
-
* }
|
|
7016
|
+
* body: {}
|
|
6398
7017
|
* })
|
|
6399
7018
|
*/
|
|
6400
7019
|
patchFolder(request, requestOptions) {
|
|
@@ -6609,9 +7228,7 @@ var IdentityClient = class {
|
|
|
6609
7228
|
* await client.identity.createEntity({
|
|
6610
7229
|
* namespace: "team",
|
|
6611
7230
|
* contextId: "myapp",
|
|
6612
|
-
* body: {
|
|
6613
|
-
* externalId: "team_eng_platform"
|
|
6614
|
-
* }
|
|
7231
|
+
* body: {}
|
|
6615
7232
|
* })
|
|
6616
7233
|
*/
|
|
6617
7234
|
createEntity(request, requestOptions) {
|
|
@@ -6747,9 +7364,7 @@ var IdentityClient = class {
|
|
|
6747
7364
|
* namespace: "team",
|
|
6748
7365
|
* id: "id",
|
|
6749
7366
|
* contextId: "myapp",
|
|
6750
|
-
* body: {
|
|
6751
|
-
* externalId: "team_eng_platform"
|
|
6752
|
-
* }
|
|
7367
|
+
* body: {}
|
|
6753
7368
|
* })
|
|
6754
7369
|
*/
|
|
6755
7370
|
updateEntity(request, requestOptions) {
|
|
@@ -7089,10 +7704,7 @@ var IdentityClient = class {
|
|
|
7089
7704
|
* @example
|
|
7090
7705
|
* await client.identity.updateNamespace({
|
|
7091
7706
|
* namespace: "team",
|
|
7092
|
-
* body: {
|
|
7093
|
-
* namespace: "team",
|
|
7094
|
-
* specificityRank: 1500
|
|
7095
|
-
* }
|
|
7707
|
+
* body: {}
|
|
7096
7708
|
* })
|
|
7097
7709
|
*/
|
|
7098
7710
|
updateNamespace(request, requestOptions) {
|
|
@@ -7279,10 +7891,7 @@ var IdentityClient = class {
|
|
|
7279
7891
|
*
|
|
7280
7892
|
* @example
|
|
7281
7893
|
* await client.identity.registerNamespace({
|
|
7282
|
-
* body: {
|
|
7283
|
-
* namespace: "team",
|
|
7284
|
-
* specificityRank: 1500
|
|
7285
|
-
* }
|
|
7894
|
+
* body: {}
|
|
7286
7895
|
* })
|
|
7287
7896
|
*/
|
|
7288
7897
|
registerNamespace(request, requestOptions) {
|
|
@@ -7415,9 +8024,7 @@ var IdentityClient = class {
|
|
|
7415
8024
|
*
|
|
7416
8025
|
* @example
|
|
7417
8026
|
* await client.identity.createUser({
|
|
7418
|
-
* body: {
|
|
7419
|
-
* externalId: "usr_12345"
|
|
7420
|
-
* }
|
|
8027
|
+
* body: {}
|
|
7421
8028
|
* })
|
|
7422
8029
|
*/
|
|
7423
8030
|
createUser(request, requestOptions) {
|
|
@@ -7536,6 +8143,7 @@ var IdentityClient = class {
|
|
|
7536
8143
|
* @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
7537
8144
|
*
|
|
7538
8145
|
* @throws {@link Vectros.BadRequestError}
|
|
8146
|
+
* @throws {@link Vectros.ForbiddenError}
|
|
7539
8147
|
* @throws {@link Vectros.NotFoundError}
|
|
7540
8148
|
* @throws {@link Vectros.ConflictError}
|
|
7541
8149
|
* @throws {@link Vectros.TooManyRequestsError}
|
|
@@ -7543,9 +8151,7 @@ var IdentityClient = class {
|
|
|
7543
8151
|
* @example
|
|
7544
8152
|
* await client.identity.updateUser({
|
|
7545
8153
|
* id: "550e8400-e29b-41d4-a716-446655440000",
|
|
7546
|
-
* body: {
|
|
7547
|
-
* externalId: "usr_12345"
|
|
7548
|
-
* }
|
|
8154
|
+
* body: {}
|
|
7549
8155
|
* })
|
|
7550
8156
|
*/
|
|
7551
8157
|
updateUser(request, requestOptions) {
|
|
@@ -7583,6 +8189,8 @@ var IdentityClient = class {
|
|
|
7583
8189
|
switch (_response.error.statusCode) {
|
|
7584
8190
|
case 400:
|
|
7585
8191
|
throw new BadRequestError(_response.error.body, _response.rawResponse);
|
|
8192
|
+
case 403:
|
|
8193
|
+
throw new ForbiddenError(_response.error.body, _response.rawResponse);
|
|
7586
8194
|
case 404:
|
|
7587
8195
|
throw new NotFoundError(_response.error.body, _response.rawResponse);
|
|
7588
8196
|
case 409:
|
|
@@ -7605,6 +8213,7 @@ var IdentityClient = class {
|
|
|
7605
8213
|
* @param {Vectros.DeleteUserRequest} request
|
|
7606
8214
|
* @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
7607
8215
|
*
|
|
8216
|
+
* @throws {@link Vectros.ForbiddenError}
|
|
7608
8217
|
* @throws {@link Vectros.NotFoundError}
|
|
7609
8218
|
* @throws {@link Vectros.ConflictError}
|
|
7610
8219
|
* @throws {@link Vectros.TooManyRequestsError}
|
|
@@ -7644,6 +8253,8 @@ var IdentityClient = class {
|
|
|
7644
8253
|
}
|
|
7645
8254
|
if (_response.error.reason === "status-code") {
|
|
7646
8255
|
switch (_response.error.statusCode) {
|
|
8256
|
+
case 403:
|
|
8257
|
+
throw new ForbiddenError(_response.error.body, _response.rawResponse);
|
|
7647
8258
|
case 404:
|
|
7648
8259
|
throw new NotFoundError(_response.error.body, _response.rawResponse);
|
|
7649
8260
|
case 409:
|
|
@@ -7848,7 +8459,7 @@ var InferenceClient = class {
|
|
|
7848
8459
|
this._options = normalizeClientOptionsWithAuth(options);
|
|
7849
8460
|
}
|
|
7850
8461
|
/**
|
|
7851
|
-
* Returns the whole platform model catalog, whatever your plan: `availableOn` names each model's plan tiers. Each entry also carries the context window and the credit rates per 1K input and output tokens: `regionPricing.base` for global-region requests, `regionPricing.us` for default requests,
|
|
8462
|
+
* Returns the whole platform model catalog, whatever your plan: `availableOn` names each model's plan tiers. Each entry also carries the context window and the credit rates per 1K input and output tokens: `regionPricing.base` for global-region requests, `regionPricing.us` for default requests, `longContext` for prompts over its threshold, and `cachePricing` for prompt-cache tokens on a model that has cache prices. A model reached through a `providerAlias` is not listed. Use this to populate model pickers and to validate a request before calling `/v1/chat`, `/v1/rag`, or `/v1/documents/{id}/ask`.
|
|
7852
8463
|
*
|
|
7853
8464
|
* @param {InferenceClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
7854
8465
|
*
|
|
@@ -7892,7 +8503,7 @@ var InferenceClient = class {
|
|
|
7892
8503
|
return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/models");
|
|
7893
8504
|
}
|
|
7894
8505
|
/**
|
|
7895
|
-
* Streams a model response as Server-Sent Events (SSE). Send the full conversation history in the `messages` array; a message with role `system` is extracted and used as the system prompt. On a pre-paid account, token cost is debited from your inference balance; usage-billed accounts accrue it for post-billing. A request routed through your own `providerAlias` incurs no Vectros token cost. A
|
|
8506
|
+
* Streams a model response as Server-Sent Events (SSE). Send the full conversation history in the `messages` array; a message with role `system` is extracted and used as the system prompt. On a pre-paid account, token cost is debited from your inference balance; usage-billed accounts accrue it for post-billing. A request routed through your own `providerAlias` incurs no Vectros token cost. A per-call platform fee is charged to your monthly credit allowance, except when the call fails on the server side: 0.2 credits for a call of up to 60 seconds, then 1 credit per 5 minutes of the call's duration. Requires the `inference:r` scope.
|
|
7896
8507
|
*/
|
|
7897
8508
|
chatInference(request, requestOptions) {
|
|
7898
8509
|
return HttpResponsePromise.fromPromise(this.__chatInference(request, requestOptions));
|
|
@@ -7964,7 +8575,7 @@ var InferenceClient = class {
|
|
|
7964
8575
|
return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/chat");
|
|
7965
8576
|
}
|
|
7966
8577
|
/**
|
|
7967
|
-
* Loads a single document's extracted text, supplies it as context, and streams a model answer about it. The document must
|
|
8578
|
+
* Loads a single document's extracted text, supplies it as context, and streams a model answer about it. The document must have finished processing and have text. If the document exceeds the 32K-token cap, the call returns 413 with no credits charged — use `POST /v1/rag` instead to answer over larger or multi-document collections. Requires the `inference:r` scope.
|
|
7968
8579
|
*/
|
|
7969
8580
|
documentAsk(request, requestOptions) {
|
|
7970
8581
|
return HttpResponsePromise.fromPromise(this.__documentAsk(request, requestOptions));
|
|
@@ -9099,8 +9710,7 @@ var SchemasClient = class {
|
|
|
9099
9710
|
* }],
|
|
9100
9711
|
* capabilities: {
|
|
9101
9712
|
* "auditHistory": true
|
|
9102
|
-
* }
|
|
9103
|
-
* allowedSurfaces: ["record"]
|
|
9713
|
+
* }
|
|
9104
9714
|
* }
|
|
9105
9715
|
* })
|
|
9106
9716
|
*/
|
|
@@ -9230,11 +9840,7 @@ var SchemasClient = class {
|
|
|
9230
9840
|
* @example
|
|
9231
9841
|
* await client.schemas.updateSchema({
|
|
9232
9842
|
* id: "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
|
|
9233
|
-
* body: {
|
|
9234
|
-
* typeName: "intake_form",
|
|
9235
|
-
* displayName: "Client Intake Form",
|
|
9236
|
-
* allowedSurfaces: ["record"]
|
|
9237
|
-
* }
|
|
9843
|
+
* body: {}
|
|
9238
9844
|
* })
|
|
9239
9845
|
*/
|
|
9240
9846
|
updateSchema(request, requestOptions) {
|
|
@@ -9774,7 +10380,7 @@ var ScriptsClient = class {
|
|
|
9774
10380
|
return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/v1/scripts/{id}");
|
|
9775
10381
|
}
|
|
9776
10382
|
/**
|
|
9777
|
-
* Permanently deletes one script version by ID. Deleting one version does not affect any other version of the same name. Requires the `scripts:d` scope. Refused with 409 if a live trigger rule still references this version — either directly (a pinned `scriptRef`), or via `"latest"` when this IS the newest version of its name. Delete or re-point those rules first.
|
|
10383
|
+
* Permanently deletes one script version by ID. Deleting one version does not affect any other version of the same name. Requires the `scripts:d` scope. Refused with 409 if a live trigger rule still references this version — either directly (a pinned `scriptRef`), or via `"latest"` when this IS the newest version of its name. Delete or re-point those rules first. Also refused with a retryable 409, deleting nothing, when it cannot be told yet whether this is the newest version (for example just after several of this name's newest versions were deleted, or while its first version is gone and the listing has not caught up) and a `"latest"` rule depends on the script: try again shortly.
|
|
9778
10384
|
*
|
|
9779
10385
|
* @param {Vectros.DeleteScriptRequest} request
|
|
9780
10386
|
* @param {ScriptsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
@@ -10038,17 +10644,7 @@ var TriggersClient = class {
|
|
|
10038
10644
|
*
|
|
10039
10645
|
* @example
|
|
10040
10646
|
* await client.triggers.createTrigger({
|
|
10041
|
-
* body: {
|
|
10042
|
-
* name: "on-intake-create",
|
|
10043
|
-
* firingSource: {
|
|
10044
|
-
* schemaId: "sch_9f8e7d6c",
|
|
10045
|
-
* event: "CREATE"
|
|
10046
|
-
* },
|
|
10047
|
-
* scriptRef: {
|
|
10048
|
-
* name: "notify-assignee",
|
|
10049
|
-
* version: "3"
|
|
10050
|
-
* }
|
|
10051
|
-
* }
|
|
10647
|
+
* body: {}
|
|
10052
10648
|
* })
|
|
10053
10649
|
*/
|
|
10054
10650
|
createTrigger(request, requestOptions) {
|
|
@@ -10177,17 +10773,7 @@ var TriggersClient = class {
|
|
|
10177
10773
|
* @example
|
|
10178
10774
|
* await client.triggers.updateTrigger({
|
|
10179
10775
|
* id: "id",
|
|
10180
|
-
* body: {
|
|
10181
|
-
* name: "on-intake-create",
|
|
10182
|
-
* firingSource: {
|
|
10183
|
-
* schemaId: "sch_9f8e7d6c",
|
|
10184
|
-
* event: "CREATE"
|
|
10185
|
-
* },
|
|
10186
|
-
* scriptRef: {
|
|
10187
|
-
* name: "notify-assignee",
|
|
10188
|
-
* version: "3"
|
|
10189
|
-
* }
|
|
10190
|
-
* }
|
|
10776
|
+
* body: {}
|
|
10191
10777
|
* })
|
|
10192
10778
|
*/
|
|
10193
10779
|
updateTrigger(request, requestOptions) {
|
|
@@ -10312,6 +10898,9 @@ var VectrosClient = class {
|
|
|
10312
10898
|
get auth() {
|
|
10313
10899
|
return this._auth ?? (this._auth = new AuthClient(this._options));
|
|
10314
10900
|
}
|
|
10901
|
+
get agents() {
|
|
10902
|
+
return this._agents ?? (this._agents = new AgentsClient(this._options));
|
|
10903
|
+
}
|
|
10315
10904
|
get documents() {
|
|
10316
10905
|
return this._documents ?? (this._documents = new DocumentsClient(this._options));
|
|
10317
10906
|
}
|
|
@@ -10382,7 +10971,7 @@ import {
|
|
|
10382
10971
|
ListToolsRequestSchema,
|
|
10383
10972
|
ReadResourceRequestSchema
|
|
10384
10973
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
10385
|
-
import { z as
|
|
10974
|
+
import { z as z28 } from "zod";
|
|
10386
10975
|
|
|
10387
10976
|
// src/auth.ts
|
|
10388
10977
|
var KEY_RE = /^(sk|ssk|st)_(live|test)_/;
|
|
@@ -10426,8 +11015,8 @@ function warnOnSuboptimalKey(key, log) {
|
|
|
10426
11015
|
|
|
10427
11016
|
// src/build-info.ts
|
|
10428
11017
|
var BUILD_INFO = {
|
|
10429
|
-
mcpServer: true ? "0.
|
|
10430
|
-
sdk: true ? "0.
|
|
11018
|
+
mcpServer: true ? "0.19.0" : "dev",
|
|
11019
|
+
sdk: true ? "0.49.0" : "dev"
|
|
10431
11020
|
};
|
|
10432
11021
|
|
|
10433
11022
|
// src/log.ts
|
|
@@ -10683,6 +11272,11 @@ ${detail}${trailer}`
|
|
|
10683
11272
|
};
|
|
10684
11273
|
}
|
|
10685
11274
|
|
|
11275
|
+
// src/tools/limits.ts
|
|
11276
|
+
var MAX_OWNERSHIP_SCOPES = 2;
|
|
11277
|
+
var MAX_SCOPE_FILTERS = 16;
|
|
11278
|
+
var MAX_CONTENT_TYPES = 2;
|
|
11279
|
+
|
|
10686
11280
|
// src/tools/hybrid_search.ts
|
|
10687
11281
|
var MCP_DEFAULT_LIMIT = 3;
|
|
10688
11282
|
var MCP_MAX_LIMIT = 50;
|
|
@@ -10725,11 +11319,11 @@ var inputSchema = {
|
|
|
10725
11319
|
folderId: z.string().optional().describe("Scope to content in this EXACT folder (Vectros folder id)."),
|
|
10726
11320
|
rootFolderId: z.string().optional().describe("Scope to content under this folder AND all its descendants (subtree-root folder id)."),
|
|
10727
11321
|
// Content narrowing.
|
|
10728
|
-
contentTypes: z.array(z.enum(["documents", "records"])).optional().describe('Narrow to content types. ["documents"] or ["records"]; omit for unified (both).'),
|
|
11322
|
+
contentTypes: z.array(z.enum(["documents", "records"])).max(MAX_CONTENT_TYPES, `contentTypes accepts at most ${MAX_CONTENT_TYPES} entries`).optional().describe('Narrow to content types. ["documents"] or ["records"]; omit for unified (both).'),
|
|
10729
11323
|
typeName: z.string().optional().describe(
|
|
10730
11324
|
'Restrict hits to this schema type (e.g. "patient", "runbook"). Applies to BOTH documents and records \u2014 combine with contentTypes to scope within one content type. Untyped content never matches.'
|
|
10731
11325
|
),
|
|
10732
|
-
filters: z.record(z.unknown()).optional().describe(
|
|
11326
|
+
filters: z.record(z.string(), z.unknown()).optional().describe(
|
|
10733
11327
|
'Field-level metadata filters (AND-combined). Value = scalar (equality), array (OR-set), or operator map: $eq/$ne/$gt/$gte/$lt/$lte (scalar) or $in/$nin (array). e.g. {"status":"open"} or {"price":{"$gte":100,"$lte":500}}.'
|
|
10734
11328
|
),
|
|
10735
11329
|
// Ownership.
|
|
@@ -10737,7 +11331,7 @@ var inputSchema = {
|
|
|
10737
11331
|
scope: z.string().optional().describe(
|
|
10738
11332
|
'Restrict to content carrying this scope value, in `namespace:value` form (e.g. "org:<uuid>", "client:<uuid>", "group:eng-team"). `org` and `client` are reserved namespace names, registered like any other; others are namespaces you registered yourself. Mutually exclusive with `scopeFilters` \u2014 use this for ONE dimension.'
|
|
10739
11333
|
),
|
|
10740
|
-
scopeFilters: z.array(z.string()).min(1, "scopeFilters must name at least one dimension when supplied").optional().describe(
|
|
11334
|
+
scopeFilters: z.array(z.string()).min(1, "scopeFilters must name at least one dimension when supplied").max(MAX_SCOPE_FILTERS, `scopeFilters accepts at most ${MAX_SCOPE_FILTERS} entries`).optional().describe(
|
|
10741
11335
|
'Restrict to content matching ALL of these scope values \u2014 one per namespace \u2014 for a credential whose access spans more than one ownership dimension. e.g. ["org:<uuid>", "client:<uuid>"] narrows to one specific client WITHIN one specific org, which `scope` alone cannot express. Same `namespace:value` form as `scope`; naming the same namespace twice is rejected. Mutually exclusive with `scope` \u2014 use `scope` for a single dimension.'
|
|
10742
11336
|
),
|
|
10743
11337
|
// Date window.
|
|
@@ -11258,7 +11852,7 @@ var inputSchema5 = {
|
|
|
11258
11852
|
status: z5.string().optional().describe("Record lifecycle status. Defaults to ACTIVE server-side."),
|
|
11259
11853
|
folderId: z5.string().optional().describe("Group this record into a folder."),
|
|
11260
11854
|
userId: z5.string().optional().describe("Owning user id."),
|
|
11261
|
-
scopes: z5.array(z5.string()).optional().describe(
|
|
11855
|
+
scopes: z5.array(z5.string()).max(MAX_OWNERSHIP_SCOPES, `scopes accepts at most ${MAX_OWNERSHIP_SCOPES} entries`).optional().describe(
|
|
11262
11856
|
'Scope ownership as `namespace:value` entries, at most 2 (e.g. ["org:<uuid>", "group:eng-team"]). `org` and `client` are reserved namespace names, registered like any other; others are namespaces you registered yourself. This is the record\'s COMPLETE scope declaration, and each entry must fall inside the `data_scope` of a single clause of your credential that also grants this write \u2014 your identity supplies the DEFAULT when you state none, it does not limit which value you may state. An empty array `[]` creates a PRIVATE record owned by the calling user alone. Omit to stamp the credential\'s full identity \u2014 the default.'
|
|
11263
11857
|
)
|
|
11264
11858
|
};
|
|
@@ -11316,7 +11910,7 @@ var itemSchema = z6.strictObject({
|
|
|
11316
11910
|
status: z6.string().optional().describe("Record lifecycle status. Defaults to ACTIVE server-side."),
|
|
11317
11911
|
folderId: z6.string().optional().describe("Group this record into a folder."),
|
|
11318
11912
|
userId: z6.string().optional().describe("Owning user id."),
|
|
11319
|
-
scopes: z6.array(z6.string()).optional().describe(
|
|
11913
|
+
scopes: z6.array(z6.string()).max(MAX_OWNERSHIP_SCOPES, `scopes accepts at most ${MAX_OWNERSHIP_SCOPES} entries`).optional().describe(
|
|
11320
11914
|
"Scope ownership as `namespace:value` entries, at most 2 namespaces. When supplied this is the record's COMPLETE scope declaration, and each entry must fall inside the `data_scope` of a single clause of your credential that also grants this write \u2014 your identity supplies the DEFAULT when you state none, it does not limit which value you may state. `[]` creates a PRIVATE record owned by the calling user alone. Omit to inherit the credential's full identity."
|
|
11321
11915
|
)
|
|
11322
11916
|
});
|
|
@@ -11473,7 +12067,7 @@ import { z as z10 } from "zod";
|
|
|
11473
12067
|
// src/tools/provider-alias.ts
|
|
11474
12068
|
import { z as z9 } from "zod";
|
|
11475
12069
|
var providerAliasInput = z9.string().min(1, "providerAlias must be non-empty when supplied").optional().describe(
|
|
11476
|
-
"Route THIS call through your own model provider instead of the platform-hosted default, by the alias of a provider config your account has activated. It works only after your account has set up that provider and signed the platform's risk-acceptance waiver; without both, the platform refuses the call with a 403, which is returned to you as written. When the waiver is the cause, the 403 carries an `errorCode` that says which case it is: `WAIVER_NOT_SIGNED` (the waiver has not been signed), `WAIVER_TEXT_CHANGED` (
|
|
12070
|
+
"Route THIS call through your own model provider instead of the platform-hosted default, by the alias of a provider config your account has activated. It works only after your account has set up that provider and signed the platform's risk-acceptance waiver; without both, the platform refuses the call with a 403, which is returned to you as written. When the waiver is the cause, the 403 carries an `errorCode` that says which case it is: `WAIVER_NOT_SIGNED` (the waiver has not been signed), `WAIVER_TEXT_CHANGED` (Vectros now requires a newer version of the waiver than the one in force for your account), or `WAIVER_REVOKED` (an owner revoked it). An account owner resolves each in the developer portal (Model Providers); retrying the call does not help. If your account has accepted the Business Associate Agreement with Vectros in the developer portal, an account owner must also have attested that provider config in the developer portal (Model Providers); until then the platform refuses the call with a 403 that says it needs a BAA-holder attestation. A call served by your own provider leaves the Vectros perimeter. Omit it (the default) to use the platform-hosted path. When set, `model` names the model on your provider's own id space, and falls back to that provider config's default model when omitted."
|
|
11477
12071
|
);
|
|
11478
12072
|
|
|
11479
12073
|
// src/tools/rag_ask.ts
|
|
@@ -11500,14 +12094,14 @@ var inputSchema9 = {
|
|
|
11500
12094
|
scope: z10.string().optional().describe(
|
|
11501
12095
|
'Restrict retrieval to content carrying this scope value, in `namespace:value` form (e.g. "org:<uuid>", "client:<uuid>", "group:eng-team"). `org` and `client` are reserved namespace names, registered like any other; others are namespaces you registered yourself. Mutually exclusive with `scopeFilters` \u2014 use this for ONE dimension.'
|
|
11502
12096
|
),
|
|
11503
|
-
scopeFilters: z10.array(z10.string()).min(1, "scopeFilters must name at least one dimension when supplied").optional().describe(
|
|
12097
|
+
scopeFilters: z10.array(z10.string()).min(1, "scopeFilters must name at least one dimension when supplied").max(MAX_SCOPE_FILTERS, `scopeFilters accepts at most ${MAX_SCOPE_FILTERS} entries`).optional().describe(
|
|
11504
12098
|
'Restrict retrieval to content matching ALL of these scope values \u2014 one per namespace \u2014 for a credential whose access spans more than one ownership dimension. e.g. ["org:<uuid>", "client:<uuid>"] grounds the answer on one specific client WITHIN one specific org, which `scope` alone cannot express. Naming the same namespace twice is rejected. Mutually exclusive with `scope`.'
|
|
11505
12099
|
),
|
|
11506
12100
|
folderId: z10.string().optional().describe("Restrict retrieval to this exact folder."),
|
|
11507
12101
|
rootFolderId: z10.string().optional().describe("Restrict retrieval to this folder and all its descendants."),
|
|
11508
12102
|
typeName: z10.string().optional().describe("Restrict record retrieval to this schema type."),
|
|
11509
|
-
contentTypes: z10.array(z10.enum(["documents", "records"])).optional().describe('Narrow retrieval to content types. ["documents"] or ["records"]; omit for both.'),
|
|
11510
|
-
filters: z10.record(z10.unknown()).optional().describe(
|
|
12103
|
+
contentTypes: z10.array(z10.enum(["documents", "records"])).max(MAX_CONTENT_TYPES, `contentTypes accepts at most ${MAX_CONTENT_TYPES} entries`).optional().describe('Narrow retrieval to content types. ["documents"] or ["records"]; omit for both.'),
|
|
12104
|
+
filters: z10.record(z10.string(), z10.unknown()).optional().describe(
|
|
11511
12105
|
'Field-level metadata filters (AND-combined). Value = scalar (equality), array (OR-set), or operator map ($eq/$ne/$gt/$gte/$lt/$lte, $in/$nin). e.g. {"status":"open"}.'
|
|
11512
12106
|
),
|
|
11513
12107
|
createdAfter: z10.string().optional().describe(
|
|
@@ -11782,7 +12376,7 @@ function isNotAvailable(err) {
|
|
|
11782
12376
|
var documentGet = ({ client, log }) => ({
|
|
11783
12377
|
name: "document_get",
|
|
11784
12378
|
title: "Get document metadata (and optionally text)",
|
|
11785
|
-
description: "Fetch metadata for a single document \u2014 select it by its Vectros `documentId` OR by your own `externalId` + `type` (resolved for you). Pass `includeText: true` to also fetch the text body (capped at ~8K tokens; `truncated: true` flag if cut). Text is available for every text-ingested document and for file-ingested documents unless they were uploaded with `storeText: false` (extracted text discarded after indexing) \u2014 then `textAvailable: false` is set; the original file is still retrievable via `includeDownloadUrl`. Pass `includeDownloadUrl: true` to also get a short-lived presigned `downloadUrl` for the original file (file-backed documents only). Returns the full document metadata, including its lifecycle `status` (ACTIVE, or ARCHIVED when soft-retracted from search \u2014 restorable via document_update) and its processing `indexStatus`. When `indexStatus` is FAILED the response also carries `indexFailure` with a machine-readable `code` telling you whether the content is still findable \u2014 e.g. TEXT_INDEX_FAILED / VECTOR_LIMIT_EXCEEDED (one leg still serves it) vs INDEXING_FAILED (not findable by search at all). Branch on `code`, not on the message.",
|
|
12379
|
+
description: "Fetch metadata for a single document \u2014 select it by its Vectros `documentId` OR by your own `externalId` + `type` (resolved for you). Pass `includeText: true` to also fetch the text body (capped at ~8K tokens; `truncated: true` flag if cut). Text is available for every text-ingested document and for file-ingested documents unless they were uploaded with `storeText: false` (extracted text discarded after indexing) or no text could be extracted from the file (`extraction.outcome` other than OK/TRUNCATED, e.g. an image or a scanned page) \u2014 then `textAvailable: false` is set; the original file is still retrievable via `includeDownloadUrl`. Pass `includeDownloadUrl: true` to also get a short-lived presigned `downloadUrl` for the original file (file-backed documents only). Returns the full document metadata, including its lifecycle `status` (ACTIVE, or ARCHIVED when soft-retracted from search \u2014 restorable via document_update) and its processing `indexStatus`. When `indexStatus` is FAILED the response also carries `indexFailure` with a machine-readable `code` telling you whether the content is still findable \u2014 e.g. TEXT_INDEX_FAILED / VECTOR_LIMIT_EXCEEDED (one leg still serves it) vs INDEXING_FAILED (not findable by search at all). Branch on `code`, not on the message.",
|
|
11786
12380
|
inputSchema: inputSchema12,
|
|
11787
12381
|
// A pure read — never creates, modifies, or deletes anything server-side.
|
|
11788
12382
|
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },
|
|
@@ -11808,7 +12402,7 @@ var documentGet = ({ client, log }) => ({
|
|
|
11808
12402
|
if (isNotAvailable(textErr)) {
|
|
11809
12403
|
log.debug(
|
|
11810
12404
|
{ tool: "document_get", id },
|
|
11811
|
-
"document_get text unavailable (not retained
|
|
12405
|
+
"document_get text unavailable (not retained, or no text could be extracted from the file)"
|
|
11812
12406
|
);
|
|
11813
12407
|
extra = { ...extra, textAvailable: false };
|
|
11814
12408
|
} else {
|
|
@@ -11861,10 +12455,12 @@ var inputSchema13 = {
|
|
|
11861
12455
|
to: z14.string().optional().describe("Lookup mode (range): inclusive upper bound; requires `from`."),
|
|
11862
12456
|
prefix: z14.string().optional().describe("Lookup mode (prefix): match values starting with this. Range-enabled string fields only."),
|
|
11863
12457
|
order: z14.enum(["asc", "desc"]).optional().describe(
|
|
11864
|
-
"Lookup mode: sort direction by the looked-up field. `asc` (default) or `desc` \u2014 use `desc` with a range/prefix lookup to get the most-recent / highest values first (e.g. latest-N).
|
|
12458
|
+
"Lookup mode: sort direction by the looked-up field. `asc` (default) or `desc` \u2014 use `desc` with a range/prefix lookup to get the most-recent / highest values first (e.g. latest-N). Refused without `field`."
|
|
11865
12459
|
),
|
|
11866
|
-
type: z14.string().
|
|
11867
|
-
|
|
12460
|
+
type: z14.string().min(1, "type must be non-empty: omit it to list every type").optional().describe(
|
|
12461
|
+
"The document type (the bound schema's type). Required with `field` (lookup mode); in list mode it narrows the list to documents of this type. The list filter applies page by page: a page can hold fewer documents than `limit`, or none, while `nextCursor` is set, so keep paging until `nextCursor` is null before concluding there are none. For a large collection, hybrid_search with `typeName` finds documents of one type directly."
|
|
12462
|
+
),
|
|
12463
|
+
// List-mode args (`type` above applies to both modes):
|
|
11868
12464
|
folderId: z14.string().optional().describe("List mode: only documents in this folder (Vectros folder id)."),
|
|
11869
12465
|
userId: z14.string().optional().describe("List mode: scope to documents owned by this user."),
|
|
11870
12466
|
scope: z14.string().optional().describe(
|
|
@@ -11878,7 +12474,7 @@ var inputSchema13 = {
|
|
|
11878
12474
|
var documentQuery = ({ client, log }) => ({
|
|
11879
12475
|
name: "document_query",
|
|
11880
12476
|
title: "Document query (list or lookup)",
|
|
11881
|
-
description: "Query document metadata. Two modes:\n \u2022 Lookup on a lookup-indexed field: pass `type` and `field` plus exactly one of `value` (exact), `from`+`to` (range), or `prefix`. Works on sensitive fields (equality only there); range/prefix need a range-enabled field.\n \u2022 List: omit `field`; optionally filter by `folderId`/`userId`/`scope` (`namespace:value`).\nReturns a `{ data, nextCursor }` page: `data` holds up to `limit` documents (default 3, max 100 \u2014 raise it in one call when you can accept the payload), and a non-null `nextCursor` means more remain \u2014 pass it back as `startFrom` to page. Mode is auto-detected. Use document_get for the full text/download URL of one document.",
|
|
12477
|
+
description: "Query document metadata. Two modes:\n \u2022 Lookup on a lookup-indexed field: pass `type` and `field` plus exactly one of `value` (exact), `from`+`to` (range), or `prefix`. Works on sensitive fields (equality only there); range/prefix need a range-enabled field.\n \u2022 List: omit `field`; optionally filter by `type`/`folderId`/`userId`/`scope` (`namespace:value`). The `type` filter is applied page by page, so a page can be short or empty while `nextCursor` is set: keep paging before concluding there are none.\nReturns a `{ data, nextCursor }` page: `data` holds up to `limit` documents (default 3, max 100 \u2014 raise it in one call when you can accept the payload), and a non-null `nextCursor` means more remain \u2014 pass it back as `startFrom` to page. Mode is auto-detected. Use document_get for the full text/download URL of one document.",
|
|
11882
12478
|
inputSchema: inputSchema13,
|
|
11883
12479
|
// A pure read — never creates, modifies, or deletes anything server-side.
|
|
11884
12480
|
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },
|
|
@@ -11937,7 +12533,19 @@ var documentQuery = ({ client, log }) => ({
|
|
|
11937
12533
|
"document_query lookup ok"
|
|
11938
12534
|
);
|
|
11939
12535
|
} else {
|
|
12536
|
+
const strayLookupArgs = ["value", "from", "to", "prefix", "order"].filter(
|
|
12537
|
+
(k) => args[k] !== void 0
|
|
12538
|
+
);
|
|
12539
|
+
if (strayLookupArgs.length > 0) {
|
|
12540
|
+
return toolError(
|
|
12541
|
+
"document_query",
|
|
12542
|
+
new Error(
|
|
12543
|
+
`Lookup arguments need 'field' (and 'type'): ${strayLookupArgs.map((k) => `'${k}'`).join(", ")}. Without 'field' the call lists documents: filter the list with 'type', 'folderId', 'userId' or 'scope'.`
|
|
12544
|
+
)
|
|
12545
|
+
);
|
|
12546
|
+
}
|
|
11940
12547
|
page = await client.documents.listDocuments({
|
|
12548
|
+
type,
|
|
11941
12549
|
folderId: args.folderId,
|
|
11942
12550
|
userId: args.userId,
|
|
11943
12551
|
scope: args.scope,
|
|
@@ -11945,7 +12553,7 @@ var documentQuery = ({ client, log }) => ({
|
|
|
11945
12553
|
limit
|
|
11946
12554
|
});
|
|
11947
12555
|
log.debug(
|
|
11948
|
-
{ tool: "document_query", mode: "list", limit, returned: pageItems(page).length },
|
|
12556
|
+
{ tool: "document_query", mode: "list", type, limit, returned: pageItems(page).length },
|
|
11949
12557
|
"document_query list ok"
|
|
11950
12558
|
);
|
|
11951
12559
|
}
|
|
@@ -11980,7 +12588,7 @@ var inputSchema14 = {
|
|
|
11980
12588
|
"Lifecycle status. `ARCHIVED` soft-retracts the document \u2014 it is pulled from search and recall but kept and recoverable; set it back to `ACTIVE` to re-index and restore it. The way to retire superseded content when the credential has no delete authority. Omit to leave unchanged."
|
|
11981
12589
|
),
|
|
11982
12590
|
userId: z15.string().optional().describe("Reassign the owning user (Vectros UUID)."),
|
|
11983
|
-
scopes: z15.array(z15.string()).optional().describe(
|
|
12591
|
+
scopes: z15.array(z15.string()).max(MAX_OWNERSHIP_SCOPES, `scopes accepts at most ${MAX_OWNERSHIP_SCOPES} entries`).optional().describe(
|
|
11984
12592
|
'Reassign scope ownership as `namespace:value` entries, at most 2 (e.g. ["org:<uuid>", "group:eng-team"]) \u2014 the COMPLETE new parent set. `org`/`client` are reserved namespace names, registered like any other. Omit to leave ownership unchanged; `[]` clears it (private to the owning user).'
|
|
11985
12593
|
),
|
|
11986
12594
|
expectedVersion: z15.number().int().optional().describe(
|
|
@@ -12124,7 +12732,7 @@ var inputSchema17 = {
|
|
|
12124
12732
|
"Optional stable slug (sibling-unique; idempotency key). Lowercase letters/digits/hyphens. SUPPLY THIS to make a retry safe \u2014 if omitted, a derived slug is only ever a freshly-proved-free one, so a redelivered call creates a new sibling folder every time rather than matching the first."
|
|
12125
12733
|
),
|
|
12126
12734
|
userId: z18.string().optional().describe("Owning user (Vectros UUID)."),
|
|
12127
|
-
scopes: z18.array(z18.string()).optional().describe(
|
|
12735
|
+
scopes: z18.array(z18.string()).max(MAX_OWNERSHIP_SCOPES, `scopes accepts at most ${MAX_OWNERSHIP_SCOPES} entries`).optional().describe(
|
|
12128
12736
|
'Scope ownership as `namespace:value` entries, at most 2 (e.g. ["org:<uuid>", "group:eng-team"]). `org` and `client` are reserved namespace names, registered like any other; others are namespaces you registered yourself. This is the folder\'s COMPLETE scope declaration and values must come from the credential\'s own identity. An empty array `[]` creates a PRIVATE folder owned by the calling user alone. Omit to stamp the credential\'s full identity \u2014 the default.'
|
|
12129
12737
|
)
|
|
12130
12738
|
};
|
|
@@ -12170,7 +12778,7 @@ var inputSchema18 = {
|
|
|
12170
12778
|
name: z19.string().optional().describe("New folder name. Omit to keep the current name."),
|
|
12171
12779
|
description: z19.string().optional().describe("New description. Omit to leave unchanged."),
|
|
12172
12780
|
userId: z19.string().optional().describe("Reassign the owning user (Vectros UUID)."),
|
|
12173
|
-
scopes: z19.array(z19.string()).optional().describe(
|
|
12781
|
+
scopes: z19.array(z19.string()).max(MAX_OWNERSHIP_SCOPES, `scopes accepts at most ${MAX_OWNERSHIP_SCOPES} entries`).optional().describe(
|
|
12174
12782
|
'Reassign scope ownership as `namespace:value` entries, at most 2 (e.g. ["org:<uuid>", "group:eng-team"]) \u2014 the COMPLETE new parent set. `org`/`client` are reserved namespace names, registered like any other. Omit to leave ownership unchanged; `[]` clears it (private to the owning user).'
|
|
12175
12783
|
),
|
|
12176
12784
|
expectedVersion: z19.number().int().optional().describe(
|
|
@@ -12219,7 +12827,7 @@ var inputSchema19 = {
|
|
|
12219
12827
|
var folderDelete = ({ client, log }) => ({
|
|
12220
12828
|
name: "folder_delete",
|
|
12221
12829
|
title: "Delete a folder",
|
|
12222
|
-
description: 'Permanently delete a folder by id. The folder must be EMPTY first \u2014 it must contain no documents, no records, and no sub-folders \u2014 and a non-empty folder is refused, which is the most common way this call fails. Use record_query with this folderId, and document_query, to see what is in it. Clearing it differs by content type: a document can be moved out (document_update with a different folderId) or deleted. A RECORD can also be re-filed into another folder \u2014 the API supports it \u2014 but THIS SERVER does not expose that
|
|
12830
|
+
description: 'Permanently delete a folder by id. The folder must be EMPTY first \u2014 it must contain no documents, no records, and no sub-folders \u2014 and a non-empty folder is refused, which is the most common way this call fails. Use record_query with this folderId, and document_query, to see what is in it. Clearing it differs by content type: a document can be moved out (document_update with a different folderId) or deleted. A RECORD can also be re-filed into another folder \u2014 the API supports it \u2014 but THIS SERVER does not expose that: record_update has no folderId argument, so from here your only option is record_delete (needs records:d). Do NOT read that as "the record cannot be moved" and delete the record on that basis: if the record should be kept, tell the user to move it with the Vectros API/SDK directly rather than deleting it here. A sub-folder cannot be re-parented at all, so nested folders have to be emptied and deleted innermost-first. Note the emptiness check counts everything in the folder, INCLUDING items your credential cannot read \u2014 so a refusal you cannot account for from what you can list is expected behaviour, not a bug, and retrying will not clear it. Requires the key to allow folders:d \u2014 a key without it gets a permission error. Protected folders (e.g. a context root) cannot be deleted at all, however empty.',
|
|
12223
12831
|
inputSchema: inputSchema19,
|
|
12224
12832
|
// Deletes. Idempotent in the standard REST sense: the end state ("this id no longer
|
|
12225
12833
|
// resolves") is the same whether this is the first delete or a repeat of one.
|
|
@@ -12372,14 +12980,14 @@ var inputSchema21 = {
|
|
|
12372
12980
|
// Common (both modes):
|
|
12373
12981
|
folderId: z21.string().optional().describe("Optional folder to ingest into. Default: tenant root."),
|
|
12374
12982
|
userId: z21.string().optional().describe("Owning user ID. Optional."),
|
|
12375
|
-
scopes: z21.array(z21.string()).optional().describe(
|
|
12983
|
+
scopes: z21.array(z21.string()).max(MAX_OWNERSHIP_SCOPES, `scopes accepts at most ${MAX_OWNERSHIP_SCOPES} entries`).optional().describe(
|
|
12376
12984
|
"TEXT MODE ONLY. Scope ownership as `namespace:value` entries, at most 2 (e.g. [\"org:<uuid>\", \"group:eng-team\"]). `org` and `client` are reserved namespace names, registered like any other; others are namespaces you registered yourself. This is the document's COMPLETE scope declaration and values must come from the credential's own identity. An empty array `[]` creates a PRIVATE document owned by the calling user alone. Omit to stamp the credential's full identity \u2014 the default. Rejected with `filePath` (file uploads do not accept a scope declaration): a file-uploaded document is stamped with the credential's full identity."
|
|
12377
12985
|
)
|
|
12378
12986
|
};
|
|
12379
12987
|
var documentIngest = ({ client, log, transport, ingestRoot }) => ({
|
|
12380
12988
|
name: "document_ingest",
|
|
12381
12989
|
title: "Ingest a new document (text body or file upload)",
|
|
12382
|
-
description: "Create a new document in your Vectros tenant. Two modes:\n \u2022 Text mode: pass `text` (string body). Single-call. Use for crawled content, notes, generated text.\n \u2022 File mode: pass `filePath` (local path on the MCP server's host machine). STDIO-TRANSPORT ONLY \u2014 rejected on HTTP transport. MCP server reads the bytes, requests a presigned upload URL, and PUTs them. Returns when the upload is accepted (indexStatus: PENDING_INDEX); poll `document_get` until indexStatus is INDEXED. EXCEPTION \u2014 re-ingesting file mode against an externalId that already has a document (response `created:false`): the file body is replaced by ANY such re-ingest, whether or not `upsert` was set (`upsert` there only additionally applies `payload`/`title` to the matched document). The document keeps serving the OLD file's bytes until the new one is adopted, and indexStatus already reads INDEXED left over from that old file, so polling it returns immediately without waiting for the new content. Poll `document_get` and watch `fileItemId` instead \u2014 once it differs from the value it held before this call, the new file has been adopted. Re-request any download URL after that: one minted before adoption can stop working even within its stated `downloadExpires`.\nEither `text` or `filePath` must be present; both is an error. Idempotent by `externalId` (re-ingest returns the existing document, not a duplicate \u2014 requires documents:r in addition to documents:c, since being handed the existing document is a read of it; in FILE MODE a re-ingest against an existing externalId needs documents:u). TEXT MODE: without `upsert`, the existing document's content is genuinely unchanged. FILE MODE: as noted above, a re-ingest against an existing externalId always replaces the file body regardless of `upsert` \u2014 only the `payload`/`title` metadata overwrite is gated by it. To UPDATE an existing document instead \u2014 re-index an edited body \u2014 pass `upsert:true` with the same `externalId` (and the same `schemaId`); this is the re-sync primitive for keeping a knowledge base current. Pass `schemaId` + `payload` for a typed, lookup-queryable document (records parity). An `externalId` with no `schemaId` is refused (400) unless you also pass `confirmUntyped:true` to confirm that an untyped document is intended. indexMode defaults to HYBRID for untyped documents (omit to inherit a bound schema's default). storeText is a FILE-MODE knob (default true): false discards the uploaded file's extracted text after indexing (search + file download keep working; text retrieval and document_ask do not). Text-mode bodies are always retained, so storeText is not accepted with `text`.",
|
|
12990
|
+
description: "Create a new document in your Vectros tenant. Two modes:\n \u2022 Text mode: pass `text` (string body). Single-call. Use for crawled content, notes, generated text.\n \u2022 File mode: pass `filePath` (local path on the MCP server's host machine). STDIO-TRANSPORT ONLY \u2014 rejected on HTTP transport. MCP server reads the bytes, requests a presigned upload URL, and PUTs them. Returns when the upload is accepted (indexStatus: PENDING_INDEX); poll `document_get` until indexStatus is terminal: INDEXED, SKIPPED (no indexable text: `extraction.outcome` says why, e.g. NO_TEXT for an image or a scanned page), STORED (indexMode NONE) or FAILED. EXCEPTION \u2014 re-ingesting file mode against an externalId that already has a document (response `created:false`): the file body is replaced by ANY such re-ingest, whether or not `upsert` was set (`upsert` there only additionally applies `payload`/`title` to the matched document). The document keeps serving the OLD file's bytes until the new one is adopted, and indexStatus already reads INDEXED left over from that old file, so polling it returns immediately without waiting for the new content. Poll `document_get` and watch `fileItemId` instead \u2014 once it differs from the value it held before this call, the new file has been adopted. Re-request any download URL after that: one minted before adoption can stop working even within its stated `downloadExpires`.\nEither `text` or `filePath` must be present; both is an error. Idempotent by `externalId` (re-ingest returns the existing document, not a duplicate \u2014 requires documents:r in addition to documents:c, since being handed the existing document is a read of it; in FILE MODE a re-ingest against an existing externalId needs documents:u). TEXT MODE: without `upsert`, the existing document's content is genuinely unchanged. FILE MODE: as noted above, a re-ingest against an existing externalId always replaces the file body regardless of `upsert` \u2014 only the `payload`/`title` metadata overwrite is gated by it. To UPDATE an existing document instead \u2014 re-index an edited body \u2014 pass `upsert:true` with the same `externalId` (and the same `schemaId`); this is the re-sync primitive for keeping a knowledge base current. Pass `schemaId` + `payload` for a typed, lookup-queryable document (records parity). An `externalId` with no `schemaId` is refused (400) unless you also pass `confirmUntyped:true` to confirm that an untyped document is intended. indexMode defaults to HYBRID for untyped documents (omit to inherit a bound schema's default). storeText is a FILE-MODE knob (default true): false discards the uploaded file's extracted text after indexing (search + file download keep working; text retrieval and document_ask do not). Text-mode bodies are always retained, so storeText is not accepted with `text`.",
|
|
12383
12991
|
inputSchema: inputSchema21,
|
|
12384
12992
|
// Creates by default, idempotent ONLY when the caller supplies `externalId` (optional,
|
|
12385
12993
|
// per the doc comment above) — re-ingest then returns the existing document rather than
|
|
@@ -12521,7 +13129,7 @@ var documentIngest = ({ client, log, transport, ingestRoot }) => ({
|
|
|
12521
13129
|
"document_ingest file ok"
|
|
12522
13130
|
);
|
|
12523
13131
|
const uploadCreated = upload?.created;
|
|
12524
|
-
const note = uploadCreated === false ? "File replaced: this re-ingest matched an existing externalId, which always replaces that document's file body (upsert or not \u2014 upsert only additionally applies payload/title to it). The next document_get call may already show indexStatus: INDEXED \u2014 that is left over from the PREVIOUS file, not confirmation the new one is ready, and the document keeps serving the old file's bytes until adoption completes. Poll document_get(id) and watch fileItemId instead: once it differs from the value it held before this call, the new file has been adopted. Any download URL already held for this document was minted for the old file and can stop working before its stated downloadExpires once adoption happens \u2014 request a fresh one after fileItemId changes." : "File uploaded; indexing is asynchronous. Poll document_get(id) until indexStatus is INDEXED.";
|
|
13132
|
+
const note = uploadCreated === false ? "File replaced: this re-ingest matched an existing externalId, which always replaces that document's file body (upsert or not \u2014 upsert only additionally applies payload/title to it). The next document_get call may already show indexStatus: INDEXED \u2014 that is left over from the PREVIOUS file, not confirmation the new one is ready, and the document keeps serving the old file's bytes until adoption completes. Poll document_get(id) and watch fileItemId instead: once it differs from the value it held before this call, the new file has been adopted. Any download URL already held for this document was minted for the old file and can stop working before its stated downloadExpires once adoption happens \u2014 request a fresh one after fileItemId changes." : "File uploaded; indexing is asynchronous. Poll document_get(id) until indexStatus is INDEXED, SKIPPED (no indexable text; see extraction.outcome), STORED or FAILED.";
|
|
12525
13133
|
return {
|
|
12526
13134
|
content: [
|
|
12527
13135
|
{
|
|
@@ -12694,6 +13302,365 @@ var versionHistory = ({ client, log }) => ({
|
|
|
12694
13302
|
});
|
|
12695
13303
|
var version_history_default = versionHistory;
|
|
12696
13304
|
|
|
13305
|
+
// src/tools/agent_list.ts
|
|
13306
|
+
import { z as z24 } from "zod";
|
|
13307
|
+
var MCP_DEFAULT_LIMIT6 = 10;
|
|
13308
|
+
var MCP_MAX_LIMIT6 = 100;
|
|
13309
|
+
function toAgentSummary(agent) {
|
|
13310
|
+
return {
|
|
13311
|
+
id: agent.id,
|
|
13312
|
+
name: agent.name,
|
|
13313
|
+
description: agent.description,
|
|
13314
|
+
latestVersion: agent.latestVersion,
|
|
13315
|
+
status: agent.status
|
|
13316
|
+
};
|
|
13317
|
+
}
|
|
13318
|
+
var inputSchema24 = {
|
|
13319
|
+
includeRetired: z24.boolean().optional().describe("Also list retired and purged agents (neither can be run). Default false."),
|
|
13320
|
+
startFrom: z24.string().optional().describe("Pagination cursor: pass the `nextCursor` from the previous page to fetch the next."),
|
|
13321
|
+
limit: z24.number().int().min(1).max(MCP_MAX_LIMIT6).optional().describe(`Max agents per page. Default ${MCP_DEFAULT_LIMIT6}, max ${MCP_MAX_LIMIT6}.`)
|
|
13322
|
+
};
|
|
13323
|
+
var agentList = ({ client, log }) => ({
|
|
13324
|
+
name: "agent_list",
|
|
13325
|
+
title: "List agents",
|
|
13326
|
+
description: "List the stored agents you can run with agent_run, newest first. Each is returned as its `id`, `name`, `description`, `latestVersion` and `status`; only an `ACTIVE` agent can be run. Retired and purged agents are left out unless `includeRetired` is true. Returns a `{ data, nextCursor }` page: a non-null `nextCursor` means more remain, pass it back as `startFrom`. Needs the `runs:c` or `agents:r` scope; running a listed agent needs `runs:c`, so a credential with only `agents:r` can list agents but not run them.",
|
|
13327
|
+
inputSchema: inputSchema24,
|
|
13328
|
+
// A pure read: it lists definitions and changes nothing.
|
|
13329
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },
|
|
13330
|
+
handler: async (args) => {
|
|
13331
|
+
const limit = args.limit ?? MCP_DEFAULT_LIMIT6;
|
|
13332
|
+
try {
|
|
13333
|
+
const page = await client.agents.listAgents({
|
|
13334
|
+
includeRetired: args.includeRetired,
|
|
13335
|
+
startFrom: args.startFrom,
|
|
13336
|
+
limit
|
|
13337
|
+
});
|
|
13338
|
+
const data = (page.data ?? []).map(toAgentSummary);
|
|
13339
|
+
const nextCursor = page.nextCursor ?? null;
|
|
13340
|
+
log.debug({ tool: "agent_list", limit, returned: data.length }, "agent_list ok");
|
|
13341
|
+
return { content: [{ type: "text", text: JSON.stringify({ data, nextCursor }, null, 2) }] };
|
|
13342
|
+
} catch (err) {
|
|
13343
|
+
log.warn({ tool: "agent_list", err: String(err) }, "agent_list failed");
|
|
13344
|
+
return toolError("agent_list", err);
|
|
13345
|
+
}
|
|
13346
|
+
}
|
|
13347
|
+
});
|
|
13348
|
+
var agent_list_default = agentList;
|
|
13349
|
+
|
|
13350
|
+
// src/tools/agent_run.ts
|
|
13351
|
+
import { randomUUID } from "crypto";
|
|
13352
|
+
import { z as z25 } from "zod";
|
|
13353
|
+
|
|
13354
|
+
// src/run-stream.ts
|
|
13355
|
+
var TEXT_PROGRESS_CHARS = 256;
|
|
13356
|
+
var HEARTBEAT_MS = 15e3;
|
|
13357
|
+
var TERMINAL_STATUS = {
|
|
13358
|
+
"run.completed": "COMPLETED",
|
|
13359
|
+
"run.failed": "FAILED",
|
|
13360
|
+
"run.cancelled": "CANCELLED"
|
|
13361
|
+
};
|
|
13362
|
+
function str(v) {
|
|
13363
|
+
return typeof v === "string" && v.length > 0 ? v : void 0;
|
|
13364
|
+
}
|
|
13365
|
+
function num(v) {
|
|
13366
|
+
return typeof v === "number" && Number.isFinite(v) ? v : void 0;
|
|
13367
|
+
}
|
|
13368
|
+
async function consumeRunStream(stream, initialRunId, onProgress, heartbeatMs = HEARTBEAT_MS) {
|
|
13369
|
+
const result = {
|
|
13370
|
+
runId: initialRunId,
|
|
13371
|
+
terminal: false,
|
|
13372
|
+
status: "UNKNOWN",
|
|
13373
|
+
text: "",
|
|
13374
|
+
toolCalls: []
|
|
13375
|
+
};
|
|
13376
|
+
const blocks = [];
|
|
13377
|
+
let pending = "";
|
|
13378
|
+
let unsentChars = 0;
|
|
13379
|
+
const emit = async (message) => {
|
|
13380
|
+
if (!onProgress) return;
|
|
13381
|
+
try {
|
|
13382
|
+
await onProgress(message);
|
|
13383
|
+
} catch {
|
|
13384
|
+
}
|
|
13385
|
+
};
|
|
13386
|
+
let heartbeat;
|
|
13387
|
+
let lastEventAt = Date.now();
|
|
13388
|
+
if (onProgress) {
|
|
13389
|
+
heartbeat = setInterval(() => {
|
|
13390
|
+
if (Date.now() - lastEventAt >= heartbeatMs) {
|
|
13391
|
+
lastEventAt = Date.now();
|
|
13392
|
+
void emit("run still working");
|
|
13393
|
+
}
|
|
13394
|
+
}, Math.max(1, Math.floor(heartbeatMs / 3)));
|
|
13395
|
+
heartbeat.unref?.();
|
|
13396
|
+
}
|
|
13397
|
+
try {
|
|
13398
|
+
for await (const raw of stream) {
|
|
13399
|
+
lastEventAt = Date.now();
|
|
13400
|
+
if (!raw || typeof raw !== "object") continue;
|
|
13401
|
+
const ev = raw;
|
|
13402
|
+
result.runId ??= str(ev.runId);
|
|
13403
|
+
const type = typeof ev.type === "string" ? ev.type : "";
|
|
13404
|
+
switch (type) {
|
|
13405
|
+
case "run.started":
|
|
13406
|
+
result.agentId = str(ev.agentId) ?? result.agentId;
|
|
13407
|
+
result.agentVersion = num(ev.agentVersion) ?? result.agentVersion;
|
|
13408
|
+
await emit("run started");
|
|
13409
|
+
break;
|
|
13410
|
+
case "message.delta": {
|
|
13411
|
+
const piece = typeof ev.text === "string" ? ev.text : "";
|
|
13412
|
+
pending += piece;
|
|
13413
|
+
unsentChars += piece.length;
|
|
13414
|
+
if (unsentChars >= TEXT_PROGRESS_CHARS) {
|
|
13415
|
+
unsentChars = 0;
|
|
13416
|
+
await emit(`answer: ${blocks.join("\n\n").length + pending.length} characters so far`);
|
|
13417
|
+
}
|
|
13418
|
+
break;
|
|
13419
|
+
}
|
|
13420
|
+
case "message.completed": {
|
|
13421
|
+
const full = str(ev.text) ?? pending;
|
|
13422
|
+
if (full.length > 0) blocks.push(full);
|
|
13423
|
+
pending = "";
|
|
13424
|
+
unsentChars = 0;
|
|
13425
|
+
await emit("model call completed");
|
|
13426
|
+
break;
|
|
13427
|
+
}
|
|
13428
|
+
case "tool.completed": {
|
|
13429
|
+
const call = {
|
|
13430
|
+
tool: str(ev.tool),
|
|
13431
|
+
outcome: str(ev.outcome),
|
|
13432
|
+
code: str(ev.code)
|
|
13433
|
+
};
|
|
13434
|
+
result.toolCalls.push(call);
|
|
13435
|
+
await emit(`tool ${call.tool ?? "call"}: ${call.outcome ?? "ended"}`);
|
|
13436
|
+
break;
|
|
13437
|
+
}
|
|
13438
|
+
default:
|
|
13439
|
+
break;
|
|
13440
|
+
}
|
|
13441
|
+
if (ev.terminal === true || Object.hasOwn(TERMINAL_STATUS, type)) {
|
|
13442
|
+
result.terminal = true;
|
|
13443
|
+
result.status = str(ev.status) ?? TERMINAL_STATUS[type] ?? "ENDED";
|
|
13444
|
+
result.reason = str(ev.reason);
|
|
13445
|
+
result.errorCode = str(ev.errorCode);
|
|
13446
|
+
if (typeof ev.settled === "boolean" || ev.inferenceBalanceCentsChargedMilli !== void 0 || ev.inferenceBalanceCentsRefundedMilli !== void 0) {
|
|
13447
|
+
result.charged = {
|
|
13448
|
+
settled: typeof ev.settled === "boolean" ? ev.settled : void 0,
|
|
13449
|
+
inferenceBalanceCentsChargedMilli: num(ev.inferenceBalanceCentsChargedMilli),
|
|
13450
|
+
inferenceBalanceCentsRefundedMilli: num(ev.inferenceBalanceCentsRefundedMilli)
|
|
13451
|
+
};
|
|
13452
|
+
}
|
|
13453
|
+
break;
|
|
13454
|
+
}
|
|
13455
|
+
}
|
|
13456
|
+
} catch (err) {
|
|
13457
|
+
result.streamError = err instanceof Error ? err.message : String(err);
|
|
13458
|
+
} finally {
|
|
13459
|
+
if (heartbeat) clearInterval(heartbeat);
|
|
13460
|
+
}
|
|
13461
|
+
if (pending.length > 0) blocks.push(pending);
|
|
13462
|
+
result.text = blocks.join("\n\n");
|
|
13463
|
+
return result;
|
|
13464
|
+
}
|
|
13465
|
+
|
|
13466
|
+
// src/tools/agent_run.ts
|
|
13467
|
+
var RUN_ID_HEADER = "x-vectros-run-id";
|
|
13468
|
+
var MAX_INPUT_CHARS = 1e5;
|
|
13469
|
+
var MAX_INPUT_BYTES = 24e4;
|
|
13470
|
+
function encodedInputBytes(v) {
|
|
13471
|
+
return Buffer.byteLength(JSON.stringify(v), "utf8");
|
|
13472
|
+
}
|
|
13473
|
+
var TERMINAL_EVENT_TYPES = /* @__PURE__ */ new Set(["run.completed", "run.failed", "run.cancelled"]);
|
|
13474
|
+
var ENDED_STATUSES = /* @__PURE__ */ new Set(["COMPLETED", "FAILED", "CANCELLED", "EXPIRED"]);
|
|
13475
|
+
var inputSchema25 = {
|
|
13476
|
+
agentId: z25.string().min(1, "agentId must be non-empty").describe("The agent to run: an `id` from agent_list."),
|
|
13477
|
+
input: z25.string().min(1, "input must be non-empty").max(MAX_INPUT_CHARS, `input accepts at most ${MAX_INPUT_CHARS} characters`).refine(
|
|
13478
|
+
(v) => encodedInputBytes(v) <= MAX_INPUT_BYTES,
|
|
13479
|
+
`input accepts at most ${MAX_INPUT_BYTES} bytes as sent (a JSON string in UTF-8)`
|
|
13480
|
+
).describe(
|
|
13481
|
+
`What the agent is asked, 1 to ${MAX_INPUT_CHARS} characters and at most ${MAX_INPUT_BYTES} bytes as sent (a JSON string in UTF-8; most control characters other than newline and tab count six bytes).`
|
|
13482
|
+
),
|
|
13483
|
+
agentVersion: z25.number().int().min(1).optional().describe("The agent version to run. Default: its latest version."),
|
|
13484
|
+
maxInferenceCents: z25.number().int().min(1).optional().describe(
|
|
13485
|
+
"The most this run's model calls may cost, in US cents. It can only lower the agent's own budget (a higher value is refused); a value below the platform minimum is refused with errorCode `BUDGET_TOO_LOW`, whose message names the minimum. Default: the agent's budget. A run that reaches it ends `FAILED` with errorCode `BUDGET_EXCEEDED`."
|
|
13486
|
+
),
|
|
13487
|
+
readOnly: z25.boolean().optional().describe("When true, every tool call that would change data is refused in this run. Default false."),
|
|
13488
|
+
idempotencyKey: z25.string().regex(/^[A-Za-z0-9._:-]{1,128}$/, "idempotencyKey is 1 to 128 letters, digits, `.`, `_`, `:` or `-`").optional().describe(
|
|
13489
|
+
"Makes a retried call safe: the same key with the same arguments never starts a second run; the retry returns that run's id and status (`alreadyStarted: true`) instead. Its answer text is not returned again; read how it ended with run_get. Default: a new key per call."
|
|
13490
|
+
)
|
|
13491
|
+
};
|
|
13492
|
+
var agentRun = ({ client, log }) => ({
|
|
13493
|
+
name: "agent_run",
|
|
13494
|
+
title: "Run an agent",
|
|
13495
|
+
description: "Run a stored agent (from agent_list) on one `input` and return its answer. The agent's tool calls act as you, with your own permissions, and only through the tools the agent lists; set `readOnly` to refuse every tool call that would change data. Cap the run's model cost with `maxInferenceCents` (it can only lower the agent's own budget). The run is billed: model calls against your inference balance, and a fee per run, tool calls and run time against your plan. An agent can search the web or fetch a page when its definition lists that web tool (web fetch also needs your tenant's owner to switch it on, and a run of an agent that lists `web_search` is refused while the platform has web search disabled). Returns `{ runId, agentId, agentVersion, status, terminal, reason, errorCode, text, toolCalls, charged }`; `charged` carries the run's charge and refund in milli-cents (1 cent = 1000). Progress notifications keep the call alive while the run works for a client that resets its timeout on progress; cancelling the call cancels the run once the run is named (almost at once). If `terminal` is false the result arrived before the run ended: read it with run_get, which needs `runs:r` as well. Calling again without `idempotencyKey` starts a new, billed run. Needs the `runs:c` scope.",
|
|
13496
|
+
inputSchema: inputSchema25,
|
|
13497
|
+
// Not a read: a run is billed, and its tool calls may create, change or delete data with the
|
|
13498
|
+
// caller's permissions, so a host should confirm it. Not idempotent: each call is a new paid run
|
|
13499
|
+
// unless the same idempotencyKey is passed again.
|
|
13500
|
+
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
|
|
13501
|
+
handler: async (args, extra) => {
|
|
13502
|
+
const agentId = args.agentId;
|
|
13503
|
+
const maxInferenceCents = args.maxInferenceCents;
|
|
13504
|
+
const idempotencyKey = args.idempotencyKey ?? randomUUID();
|
|
13505
|
+
const request = {
|
|
13506
|
+
"Idempotency-Key": idempotencyKey,
|
|
13507
|
+
agentId,
|
|
13508
|
+
agentVersion: args.agentVersion,
|
|
13509
|
+
input: { text: args.input },
|
|
13510
|
+
budget: maxInferenceCents !== void 0 ? { maxInferenceCents } : void 0,
|
|
13511
|
+
readOnly: args.readOnly
|
|
13512
|
+
};
|
|
13513
|
+
const progressToken = extra._meta?.progressToken;
|
|
13514
|
+
let progressCount = 0;
|
|
13515
|
+
const onProgress = progressToken !== void 0 && extra.sendNotification ? async (message) => {
|
|
13516
|
+
progressCount += 1;
|
|
13517
|
+
await extra.sendNotification({
|
|
13518
|
+
method: "notifications/progress",
|
|
13519
|
+
params: { progressToken, progress: progressCount, message }
|
|
13520
|
+
});
|
|
13521
|
+
} : void 0;
|
|
13522
|
+
const streamAbort = new AbortController();
|
|
13523
|
+
const callSignal = extra.signal;
|
|
13524
|
+
let knownRunId;
|
|
13525
|
+
let headersReceived = false;
|
|
13526
|
+
let cancelRequested = false;
|
|
13527
|
+
let cancelSent = false;
|
|
13528
|
+
let runEnded = false;
|
|
13529
|
+
const sendCancel = () => {
|
|
13530
|
+
if (!cancelRequested || cancelSent || !knownRunId || runEnded) return;
|
|
13531
|
+
cancelSent = true;
|
|
13532
|
+
const id = knownRunId;
|
|
13533
|
+
client.agents.cancelRun({ id }).then(
|
|
13534
|
+
() => log.info({ tool: "agent_run", runId: id }, "agent_run cancelled by the client"),
|
|
13535
|
+
(err) => log.warn({ tool: "agent_run", runId: id, err: String(err) }, "agent_run cancel failed")
|
|
13536
|
+
);
|
|
13537
|
+
};
|
|
13538
|
+
const cancelIfNamed = () => {
|
|
13539
|
+
if (!cancelRequested || !headersReceived || !knownRunId) return;
|
|
13540
|
+
sendCancel();
|
|
13541
|
+
streamAbort.abort();
|
|
13542
|
+
};
|
|
13543
|
+
const onCancel = () => {
|
|
13544
|
+
cancelRequested = true;
|
|
13545
|
+
cancelIfNamed();
|
|
13546
|
+
};
|
|
13547
|
+
if (callSignal?.aborted) {
|
|
13548
|
+
return toolError("agent_run", new Error("The call was cancelled before the run started."));
|
|
13549
|
+
}
|
|
13550
|
+
callSignal?.addEventListener("abort", onCancel, { once: true });
|
|
13551
|
+
try {
|
|
13552
|
+
const { data: stream, rawResponse } = await client.agents.createRun(request, { abortSignal: streamAbort.signal }).withRawResponse();
|
|
13553
|
+
headersReceived = true;
|
|
13554
|
+
knownRunId = rawResponse.headers.get(RUN_ID_HEADER) ?? void 0;
|
|
13555
|
+
cancelIfNamed();
|
|
13556
|
+
const naming = async function* () {
|
|
13557
|
+
for await (const ev of stream) {
|
|
13558
|
+
if (!knownRunId && ev && typeof ev === "object") {
|
|
13559
|
+
const id = ev.runId;
|
|
13560
|
+
if (typeof id === "string" && id.length > 0) {
|
|
13561
|
+
knownRunId = id;
|
|
13562
|
+
cancelIfNamed();
|
|
13563
|
+
}
|
|
13564
|
+
}
|
|
13565
|
+
if (ev && typeof ev === "object") {
|
|
13566
|
+
const e = ev;
|
|
13567
|
+
if (e.terminal === true || typeof e.type === "string" && TERMINAL_EVENT_TYPES.has(e.type)) runEnded = true;
|
|
13568
|
+
}
|
|
13569
|
+
yield ev;
|
|
13570
|
+
}
|
|
13571
|
+
};
|
|
13572
|
+
const run = await consumeRunStream(naming(), knownRunId, onProgress);
|
|
13573
|
+
knownRunId ??= run.runId;
|
|
13574
|
+
if (run.terminal) runEnded = true;
|
|
13575
|
+
sendCancel();
|
|
13576
|
+
log.debug(
|
|
13577
|
+
{
|
|
13578
|
+
tool: "agent_run",
|
|
13579
|
+
runId: run.runId,
|
|
13580
|
+
status: run.status,
|
|
13581
|
+
terminal: run.terminal,
|
|
13582
|
+
toolCalls: run.toolCalls.length,
|
|
13583
|
+
textLength: run.text.length
|
|
13584
|
+
},
|
|
13585
|
+
"agent_run ok"
|
|
13586
|
+
);
|
|
13587
|
+
const body = {
|
|
13588
|
+
runId: run.runId,
|
|
13589
|
+
agentId: run.agentId ?? agentId,
|
|
13590
|
+
agentVersion: run.agentVersion,
|
|
13591
|
+
status: run.status,
|
|
13592
|
+
terminal: run.terminal,
|
|
13593
|
+
reason: run.reason,
|
|
13594
|
+
errorCode: run.errorCode,
|
|
13595
|
+
text: run.text,
|
|
13596
|
+
toolCalls: run.toolCalls,
|
|
13597
|
+
charged: run.charged
|
|
13598
|
+
};
|
|
13599
|
+
if (!run.terminal) {
|
|
13600
|
+
body.note = cancelRequested ? "The call was cancelled and the run was asked to stop. Read it with run_get (needs the `runs:r` scope) to see how it ended." : "The stream ended before the run did" + (run.streamError ? ` (${run.streamError})` : "") + ". The run may still be working: read it with run_get until `terminal` is true (run_get needs the `runs:r` scope).";
|
|
13601
|
+
}
|
|
13602
|
+
return { content: [{ type: "text", text: JSON.stringify(body, null, 2) }] };
|
|
13603
|
+
} catch (err) {
|
|
13604
|
+
const e = err;
|
|
13605
|
+
if (e?.body?.errorCode === "IDEMPOTENCY_IN_PROGRESS") {
|
|
13606
|
+
const runId = (typeof e.body.runId === "string" ? e.body.runId : void 0) ?? e.rawResponse?.headers?.get?.(RUN_ID_HEADER) ?? void 0;
|
|
13607
|
+
if (runId) {
|
|
13608
|
+
const status = typeof e.body.status === "string" ? e.body.status : void 0;
|
|
13609
|
+
log.info({ tool: "agent_run", runId }, "agent_run: the idempotency key already started a run");
|
|
13610
|
+
const body = {
|
|
13611
|
+
runId,
|
|
13612
|
+
agentId,
|
|
13613
|
+
status,
|
|
13614
|
+
// The 409 names the run's status at the time; an ended status is final.
|
|
13615
|
+
terminal: status !== void 0 && ENDED_STATUSES.has(status),
|
|
13616
|
+
alreadyStarted: true,
|
|
13617
|
+
note: "This idempotency key already started this run, so no new run was started. Its answer text is not returned again and cannot be read back: run_get (needs the `runs:r` scope) shows how the run ended and what it was charged, never its text. To start another run, pass a new idempotencyKey."
|
|
13618
|
+
};
|
|
13619
|
+
return { content: [{ type: "text", text: JSON.stringify(body, null, 2) }] };
|
|
13620
|
+
}
|
|
13621
|
+
}
|
|
13622
|
+
log.warn({ tool: "agent_run", agentId, err: String(err) }, "agent_run failed");
|
|
13623
|
+
const result = toolError("agent_run", err);
|
|
13624
|
+
const statusCode = err?.statusCode;
|
|
13625
|
+
if (typeof statusCode !== "number" || statusCode === 408 || statusCode >= 500) {
|
|
13626
|
+
result.content[0].text += `
|
|
13627
|
+
idempotencyKey: ${idempotencyKey}
|
|
13628
|
+
A run may have started before this error. Call agent_run again with the same arguments and this idempotencyKey: if a run started, the call names it; if not, it starts one.` + (cancelRequested ? " (The call was cancelled; a run that started could not be cancelled.)" : "");
|
|
13629
|
+
}
|
|
13630
|
+
return result;
|
|
13631
|
+
} finally {
|
|
13632
|
+
callSignal?.removeEventListener("abort", onCancel);
|
|
13633
|
+
}
|
|
13634
|
+
}
|
|
13635
|
+
});
|
|
13636
|
+
var agent_run_default = agentRun;
|
|
13637
|
+
|
|
13638
|
+
// src/tools/run_get.ts
|
|
13639
|
+
import { z as z26 } from "zod";
|
|
13640
|
+
var inputSchema26 = {
|
|
13641
|
+
runId: z26.string().min(1, "runId must be non-empty").describe("The run id agent_run returned (`runId`).")
|
|
13642
|
+
};
|
|
13643
|
+
var runGet = ({ client, log }) => ({
|
|
13644
|
+
name: "run_get",
|
|
13645
|
+
title: "Get an agent run",
|
|
13646
|
+
description: "Read one agent run by id: `status` (`RUNNING`, `COMPLETED`, `FAILED`, `CANCELLED` or `EXPIRED`), `terminal` (whether it has ended; poll until true), `reason`, `errorCode`, `steps`, its `toolCalls` (each tool and how it ended, never its arguments or result) and `usage` (what it was charged, in milli-cents). It does not return the answer text: agent_run returns that. Use it when agent_run returned `terminal: false`. Needs the `runs:r` scope, which starting a run (`runs:c`) does not include: a credential with only `runs:c` gets `403` here, and learns how its runs end only from agent_run's own result.",
|
|
13647
|
+
inputSchema: inputSchema26,
|
|
13648
|
+
// A pure read: polling a run does not change it.
|
|
13649
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },
|
|
13650
|
+
handler: async (args) => {
|
|
13651
|
+
const runId = args.runId;
|
|
13652
|
+
try {
|
|
13653
|
+
const run = await client.agents.getRun({ id: runId });
|
|
13654
|
+
log.debug({ tool: "run_get", runId, status: run.status, terminal: run.terminal }, "run_get ok");
|
|
13655
|
+
return { content: [{ type: "text", text: JSON.stringify(run, null, 2) }] };
|
|
13656
|
+
} catch (err) {
|
|
13657
|
+
log.warn({ tool: "run_get", runId, err: String(err) }, "run_get failed");
|
|
13658
|
+
return toolError("run_get", err);
|
|
13659
|
+
}
|
|
13660
|
+
}
|
|
13661
|
+
});
|
|
13662
|
+
var run_get_default = runGet;
|
|
13663
|
+
|
|
12697
13664
|
// src/tools/types.ts
|
|
12698
13665
|
var TOOL_NAMES = [
|
|
12699
13666
|
"hybrid_search",
|
|
@@ -12718,7 +13685,10 @@ var TOOL_NAMES = [
|
|
|
12718
13685
|
"current_identity",
|
|
12719
13686
|
"document_ingest",
|
|
12720
13687
|
"lookup_principal",
|
|
12721
|
-
"version_history"
|
|
13688
|
+
"version_history",
|
|
13689
|
+
"agent_list",
|
|
13690
|
+
"agent_run",
|
|
13691
|
+
"run_get"
|
|
12722
13692
|
];
|
|
12723
13693
|
|
|
12724
13694
|
// src/tools/index.ts
|
|
@@ -12745,7 +13715,10 @@ var ALL_TOOL_FACTORIES = {
|
|
|
12745
13715
|
current_identity: current_identity_default,
|
|
12746
13716
|
document_ingest: document_ingest_default,
|
|
12747
13717
|
lookup_principal: lookup_principal_default,
|
|
12748
|
-
version_history: version_history_default
|
|
13718
|
+
version_history: version_history_default,
|
|
13719
|
+
agent_list: agent_list_default,
|
|
13720
|
+
agent_run: agent_run_default,
|
|
13721
|
+
run_get: run_get_default
|
|
12749
13722
|
};
|
|
12750
13723
|
|
|
12751
13724
|
// src/resources/schemas.ts
|
|
@@ -12788,11 +13761,12 @@ var ALL_RESOURCE_FACTORIES = {
|
|
|
12788
13761
|
};
|
|
12789
13762
|
|
|
12790
13763
|
// src/zod-to-json-schema.ts
|
|
12791
|
-
import { z as
|
|
13764
|
+
import { z as z27 } from "zod";
|
|
12792
13765
|
function zodShapeToJsonSchema(shape) {
|
|
12793
13766
|
const properties = {};
|
|
12794
13767
|
const required = [];
|
|
12795
|
-
for (const [name,
|
|
13768
|
+
for (const [name, entry] of Object.entries(shape)) {
|
|
13769
|
+
const schema = entry;
|
|
12796
13770
|
properties[name] = zodTypeToJsonSchema(schema);
|
|
12797
13771
|
if (!schema.isOptional()) required.push(name);
|
|
12798
13772
|
}
|
|
@@ -12801,43 +13775,45 @@ function zodShapeToJsonSchema(shape) {
|
|
|
12801
13775
|
return out;
|
|
12802
13776
|
}
|
|
12803
13777
|
function zodTypeToJsonSchema(schema) {
|
|
12804
|
-
const
|
|
13778
|
+
const descriptionOf = (s) => s.description;
|
|
13779
|
+
let description = descriptionOf(schema);
|
|
12805
13780
|
let current = schema;
|
|
12806
|
-
while (current instanceof
|
|
13781
|
+
while (current instanceof z27.ZodOptional || current instanceof z27.ZodDefault || current instanceof z27.ZodNullable) {
|
|
12807
13782
|
current = current._def.innerType;
|
|
13783
|
+
description ??= descriptionOf(current);
|
|
12808
13784
|
}
|
|
12809
13785
|
const base = description ? { description } : {};
|
|
12810
|
-
if (current instanceof
|
|
13786
|
+
if (current instanceof z27.ZodString) {
|
|
12811
13787
|
return { ...base, type: "string" };
|
|
12812
13788
|
}
|
|
12813
|
-
if (current instanceof
|
|
13789
|
+
if (current instanceof z27.ZodNumber) {
|
|
12814
13790
|
return { ...base, type: "number" };
|
|
12815
13791
|
}
|
|
12816
|
-
if (current instanceof
|
|
13792
|
+
if (current instanceof z27.ZodBoolean) {
|
|
12817
13793
|
return { ...base, type: "boolean" };
|
|
12818
13794
|
}
|
|
12819
|
-
if (current instanceof
|
|
13795
|
+
if (current instanceof z27.ZodEnum) {
|
|
12820
13796
|
return {
|
|
12821
13797
|
...base,
|
|
12822
13798
|
type: "string",
|
|
12823
13799
|
enum: current.options
|
|
12824
13800
|
};
|
|
12825
13801
|
}
|
|
12826
|
-
if (current instanceof
|
|
13802
|
+
if (current instanceof z27.ZodArray) {
|
|
12827
13803
|
return {
|
|
12828
13804
|
...base,
|
|
12829
13805
|
type: "array",
|
|
12830
13806
|
items: zodTypeToJsonSchema(current.element)
|
|
12831
13807
|
};
|
|
12832
13808
|
}
|
|
12833
|
-
if (current instanceof
|
|
13809
|
+
if (current instanceof z27.ZodObject) {
|
|
12834
13810
|
return {
|
|
12835
13811
|
...base,
|
|
12836
13812
|
...zodShapeToJsonSchema(current.shape)
|
|
12837
13813
|
};
|
|
12838
13814
|
}
|
|
12839
|
-
if (current instanceof
|
|
12840
|
-
const valueType = current.
|
|
13815
|
+
if (current instanceof z27.ZodRecord) {
|
|
13816
|
+
const valueType = current.valueType;
|
|
12841
13817
|
return {
|
|
12842
13818
|
...base,
|
|
12843
13819
|
type: "object",
|
|
@@ -12965,7 +13941,7 @@ var VectrosMCPServer = class {
|
|
|
12965
13941
|
if (!tool) {
|
|
12966
13942
|
result = toolError(req.params.name ?? "unknown", new Error("No such tool."));
|
|
12967
13943
|
} else {
|
|
12968
|
-
const parsed =
|
|
13944
|
+
const parsed = z28.object(tool.inputSchema).strict().safeParse(req.params.arguments ?? {});
|
|
12969
13945
|
if (!parsed.success) {
|
|
12970
13946
|
result = toolError(tool.name, new Error(formatArgError(tool, parsed.error)));
|
|
12971
13947
|
} else {
|
|
@@ -13028,7 +14004,7 @@ var VectrosMCPServer = class {
|
|
|
13028
14004
|
*
|
|
13029
14005
|
* If `validateOnStart` (default true) is enabled, performs a
|
|
13030
14006
|
* GET /v1/ping check BEFORE wiring the transport. On failure,
|
|
13031
|
-
* throws —
|
|
14007
|
+
* throws — your MCP client sees a startup error instead
|
|
13032
14008
|
* of a confusing "tools work but the first call 401s" experience.
|
|
13033
14009
|
*/
|
|
13034
14010
|
async connect(transport) {
|