@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/cli.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// src/server.ts
|
|
4
4
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
5
5
|
|
|
6
|
-
//
|
|
6
|
+
// node_modules/@vectros-ai/sdk/dist/index.mjs
|
|
7
7
|
var __defProp = Object.defineProperty;
|
|
8
8
|
var __export = (target, all) => {
|
|
9
9
|
for (var name in all)
|
|
@@ -24,6 +24,7 @@ __export(api_exports, {
|
|
|
24
24
|
ContentTooLargeError: () => ContentTooLargeError,
|
|
25
25
|
DocumentAskRequest: () => DocumentAskRequest,
|
|
26
26
|
DocumentContextEvent: () => DocumentContextEvent,
|
|
27
|
+
DocumentExtraction: () => DocumentExtraction,
|
|
27
28
|
DocumentLookupRequest: () => DocumentLookupRequest,
|
|
28
29
|
DocumentPatchRequest: () => DocumentPatchRequest,
|
|
29
30
|
DocumentRequest: () => DocumentRequest,
|
|
@@ -76,6 +77,7 @@ __export(api_exports, {
|
|
|
76
77
|
UserExistsResponse: () => UserExistsResponse,
|
|
77
78
|
UserRequest: () => UserRequest,
|
|
78
79
|
UserResponse: () => UserResponse,
|
|
80
|
+
agents: () => agents_exports,
|
|
79
81
|
auth: () => auth_exports,
|
|
80
82
|
compliance: () => compliance_exports,
|
|
81
83
|
documents: () => documents_exports,
|
|
@@ -341,6 +343,7 @@ var UnprocessableEntityError = class extends VectrosError {
|
|
|
341
343
|
this.name = this.constructor.name;
|
|
342
344
|
}
|
|
343
345
|
};
|
|
346
|
+
var agents_exports = {};
|
|
344
347
|
var auth_exports = {};
|
|
345
348
|
var ErasureRequest;
|
|
346
349
|
((ErasureRequest2) => {
|
|
@@ -545,6 +548,18 @@ var DocumentContextEvent;
|
|
|
545
548
|
DocumentContext: "document_context"
|
|
546
549
|
};
|
|
547
550
|
})(DocumentContextEvent || (DocumentContextEvent = {}));
|
|
551
|
+
var DocumentExtraction;
|
|
552
|
+
((DocumentExtraction2) => {
|
|
553
|
+
DocumentExtraction2.Outcome = {
|
|
554
|
+
Ok: "OK",
|
|
555
|
+
Truncated: "TRUNCATED",
|
|
556
|
+
NoText: "NO_TEXT",
|
|
557
|
+
Encrypted: "ENCRYPTED",
|
|
558
|
+
Unsupported: "UNSUPPORTED",
|
|
559
|
+
TooLarge: "TOO_LARGE",
|
|
560
|
+
Unreadable: "UNREADABLE"
|
|
561
|
+
};
|
|
562
|
+
})(DocumentExtraction || (DocumentExtraction = {}));
|
|
548
563
|
var DocumentRequest;
|
|
549
564
|
((DocumentRequest2) => {
|
|
550
565
|
DocumentRequest2.IndexMode = {
|
|
@@ -1850,13 +1865,13 @@ function joinPathSegments(left, right) {
|
|
|
1850
1865
|
}
|
|
1851
1866
|
return `${left}/${right}`;
|
|
1852
1867
|
}
|
|
1853
|
-
function trimSlashes(
|
|
1854
|
-
if (!
|
|
1868
|
+
function trimSlashes(str2) {
|
|
1869
|
+
if (!str2) return str2;
|
|
1855
1870
|
let start = 0;
|
|
1856
|
-
let end =
|
|
1857
|
-
if (
|
|
1858
|
-
if (
|
|
1859
|
-
return start === 0 && end ===
|
|
1871
|
+
let end = str2.length;
|
|
1872
|
+
if (str2.startsWith("/")) start = 1;
|
|
1873
|
+
if (str2.endsWith("/")) end = str2.length - 1;
|
|
1874
|
+
return start === 0 && end === str2.length ? str2 : str2.slice(start, end);
|
|
1860
1875
|
}
|
|
1861
1876
|
var Supplier = {
|
|
1862
1877
|
get: async (supplier) => {
|
|
@@ -2371,48 +2386,675 @@ function normalizeClientOptionsWithAuth(options) {
|
|
|
2371
2386
|
normalized.authProvider = options.auth;
|
|
2372
2387
|
return normalized;
|
|
2373
2388
|
}
|
|
2374
|
-
Object.assign(normalized, options.auth);
|
|
2375
|
-
}
|
|
2376
|
-
const normalizedWithNoOpAuthProvider = withNoOpAuthProvider(normalized);
|
|
2377
|
-
normalized.authProvider ?? (normalized.authProvider = new BearerAuthProvider(normalizedWithNoOpAuthProvider));
|
|
2378
|
-
return normalized;
|
|
2379
|
-
}
|
|
2380
|
-
function withNoOpAuthProvider(options) {
|
|
2381
|
-
return {
|
|
2382
|
-
...options,
|
|
2383
|
-
authProvider: new NoOpAuthProvider()
|
|
2384
|
-
};
|
|
2385
|
-
}
|
|
2386
|
-
function handleNonStatusCodeError(error, rawResponse, method, path2) {
|
|
2387
|
-
switch (error.reason) {
|
|
2388
|
-
case "non-json":
|
|
2389
|
-
throw new VectrosError({
|
|
2390
|
-
statusCode: error.statusCode,
|
|
2391
|
-
body: error.rawBody,
|
|
2392
|
-
rawResponse
|
|
2393
|
-
});
|
|
2394
|
-
case "body-is-null":
|
|
2395
|
-
throw new VectrosError({
|
|
2396
|
-
statusCode: error.statusCode,
|
|
2397
|
-
rawResponse
|
|
2398
|
-
});
|
|
2399
|
-
case "timeout":
|
|
2400
|
-
throw new VectrosTimeoutError(`Timeout exceeded when calling ${method} ${path2}.`, {
|
|
2401
|
-
cause: error.cause
|
|
2402
|
-
});
|
|
2403
|
-
case "unknown":
|
|
2404
|
-
throw new VectrosError({
|
|
2405
|
-
message: error.errorMessage,
|
|
2406
|
-
rawResponse,
|
|
2407
|
-
cause: error.cause
|
|
2408
|
-
});
|
|
2409
|
-
default:
|
|
2410
|
-
throw new VectrosError({
|
|
2411
|
-
message: "Unknown error",
|
|
2412
|
-
rawResponse
|
|
2413
|
-
});
|
|
2389
|
+
Object.assign(normalized, options.auth);
|
|
2390
|
+
}
|
|
2391
|
+
const normalizedWithNoOpAuthProvider = withNoOpAuthProvider(normalized);
|
|
2392
|
+
normalized.authProvider ?? (normalized.authProvider = new BearerAuthProvider(normalizedWithNoOpAuthProvider));
|
|
2393
|
+
return normalized;
|
|
2394
|
+
}
|
|
2395
|
+
function withNoOpAuthProvider(options) {
|
|
2396
|
+
return {
|
|
2397
|
+
...options,
|
|
2398
|
+
authProvider: new NoOpAuthProvider()
|
|
2399
|
+
};
|
|
2400
|
+
}
|
|
2401
|
+
function handleNonStatusCodeError(error, rawResponse, method, path2) {
|
|
2402
|
+
switch (error.reason) {
|
|
2403
|
+
case "non-json":
|
|
2404
|
+
throw new VectrosError({
|
|
2405
|
+
statusCode: error.statusCode,
|
|
2406
|
+
body: error.rawBody,
|
|
2407
|
+
rawResponse
|
|
2408
|
+
});
|
|
2409
|
+
case "body-is-null":
|
|
2410
|
+
throw new VectrosError({
|
|
2411
|
+
statusCode: error.statusCode,
|
|
2412
|
+
rawResponse
|
|
2413
|
+
});
|
|
2414
|
+
case "timeout":
|
|
2415
|
+
throw new VectrosTimeoutError(`Timeout exceeded when calling ${method} ${path2}.`, {
|
|
2416
|
+
cause: error.cause
|
|
2417
|
+
});
|
|
2418
|
+
case "unknown":
|
|
2419
|
+
throw new VectrosError({
|
|
2420
|
+
message: error.errorMessage,
|
|
2421
|
+
rawResponse,
|
|
2422
|
+
cause: error.cause
|
|
2423
|
+
});
|
|
2424
|
+
default:
|
|
2425
|
+
throw new VectrosError({
|
|
2426
|
+
message: "Unknown error",
|
|
2427
|
+
rawResponse
|
|
2428
|
+
});
|
|
2429
|
+
}
|
|
2430
|
+
}
|
|
2431
|
+
var AgentsClient = class {
|
|
2432
|
+
constructor(options) {
|
|
2433
|
+
this._options = normalizeClientOptionsWithAuth(options);
|
|
2434
|
+
}
|
|
2435
|
+
/**
|
|
2436
|
+
* 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`.
|
|
2437
|
+
*
|
|
2438
|
+
* @param {Vectros.ListAgentsRequest} request
|
|
2439
|
+
* @param {AgentsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
2440
|
+
*
|
|
2441
|
+
* @throws {@link Vectros.ForbiddenError}
|
|
2442
|
+
*
|
|
2443
|
+
* @example
|
|
2444
|
+
* await client.agents.listAgents()
|
|
2445
|
+
*/
|
|
2446
|
+
listAgents(request = {}, requestOptions) {
|
|
2447
|
+
return HttpResponsePromise.fromPromise(this.__listAgents(request, requestOptions));
|
|
2448
|
+
}
|
|
2449
|
+
async __listAgents(request = {}, requestOptions) {
|
|
2450
|
+
const { contextId, includeRetired, startFrom, limit } = request;
|
|
2451
|
+
const _queryParams = {
|
|
2452
|
+
contextId,
|
|
2453
|
+
includeRetired,
|
|
2454
|
+
startFrom,
|
|
2455
|
+
limit
|
|
2456
|
+
};
|
|
2457
|
+
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
2458
|
+
const _headers = mergeHeaders(
|
|
2459
|
+
_authRequest.headers,
|
|
2460
|
+
this._options?.headers,
|
|
2461
|
+
requestOptions?.headers
|
|
2462
|
+
);
|
|
2463
|
+
const _response = await fetcher({
|
|
2464
|
+
url: url_exports.join(
|
|
2465
|
+
await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
|
|
2466
|
+
"v1/agents"
|
|
2467
|
+
),
|
|
2468
|
+
method: "GET",
|
|
2469
|
+
headers: _headers,
|
|
2470
|
+
queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
|
|
2471
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
|
|
2472
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
2473
|
+
abortSignal: requestOptions?.abortSignal,
|
|
2474
|
+
fetchFn: this._options?.fetch,
|
|
2475
|
+
logging: this._options.logging
|
|
2476
|
+
});
|
|
2477
|
+
if (_response.ok) {
|
|
2478
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
2479
|
+
}
|
|
2480
|
+
if (_response.error.reason === "status-code") {
|
|
2481
|
+
switch (_response.error.statusCode) {
|
|
2482
|
+
case 403:
|
|
2483
|
+
throw new ForbiddenError(_response.error.body, _response.rawResponse);
|
|
2484
|
+
default:
|
|
2485
|
+
throw new VectrosError({
|
|
2486
|
+
statusCode: _response.error.statusCode,
|
|
2487
|
+
body: _response.error.body,
|
|
2488
|
+
rawResponse: _response.rawResponse
|
|
2489
|
+
});
|
|
2490
|
+
}
|
|
2491
|
+
}
|
|
2492
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/agents");
|
|
2493
|
+
}
|
|
2494
|
+
/**
|
|
2495
|
+
* 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`).
|
|
2496
|
+
*
|
|
2497
|
+
* @param {Vectros.CreateAgentRequest} request
|
|
2498
|
+
* @param {AgentsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
2499
|
+
*
|
|
2500
|
+
* @throws {@link Vectros.BadRequestError}
|
|
2501
|
+
* @throws {@link Vectros.ForbiddenError}
|
|
2502
|
+
* @throws {@link Vectros.ConflictError}
|
|
2503
|
+
* @throws {@link Vectros.TooManyRequestsError}
|
|
2504
|
+
*
|
|
2505
|
+
* @example
|
|
2506
|
+
* await client.agents.createAgent({
|
|
2507
|
+
* body: {
|
|
2508
|
+
* model: "claude-sonnet-5-5"
|
|
2509
|
+
* }
|
|
2510
|
+
* })
|
|
2511
|
+
*/
|
|
2512
|
+
createAgent(request, requestOptions) {
|
|
2513
|
+
return HttpResponsePromise.fromPromise(this.__createAgent(request, requestOptions));
|
|
2514
|
+
}
|
|
2515
|
+
async __createAgent(request, requestOptions) {
|
|
2516
|
+
const { upsert, contextId, body: _body } = request;
|
|
2517
|
+
const _queryParams = {
|
|
2518
|
+
upsert,
|
|
2519
|
+
contextId
|
|
2520
|
+
};
|
|
2521
|
+
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
2522
|
+
const _headers = mergeHeaders(
|
|
2523
|
+
_authRequest.headers,
|
|
2524
|
+
this._options?.headers,
|
|
2525
|
+
requestOptions?.headers
|
|
2526
|
+
);
|
|
2527
|
+
const _response = await fetcher({
|
|
2528
|
+
url: url_exports.join(
|
|
2529
|
+
await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
|
|
2530
|
+
"v1/agents"
|
|
2531
|
+
),
|
|
2532
|
+
method: "POST",
|
|
2533
|
+
headers: _headers,
|
|
2534
|
+
contentType: "application/json",
|
|
2535
|
+
queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
|
|
2536
|
+
requestType: "json",
|
|
2537
|
+
body: _body,
|
|
2538
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
|
|
2539
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
2540
|
+
abortSignal: requestOptions?.abortSignal,
|
|
2541
|
+
fetchFn: this._options?.fetch,
|
|
2542
|
+
logging: this._options.logging
|
|
2543
|
+
});
|
|
2544
|
+
if (_response.ok) {
|
|
2545
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
2546
|
+
}
|
|
2547
|
+
if (_response.error.reason === "status-code") {
|
|
2548
|
+
switch (_response.error.statusCode) {
|
|
2549
|
+
case 400:
|
|
2550
|
+
throw new BadRequestError(_response.error.body, _response.rawResponse);
|
|
2551
|
+
case 403:
|
|
2552
|
+
throw new ForbiddenError(_response.error.body, _response.rawResponse);
|
|
2553
|
+
case 409:
|
|
2554
|
+
throw new ConflictError(_response.error.body, _response.rawResponse);
|
|
2555
|
+
case 429:
|
|
2556
|
+
throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
|
|
2557
|
+
default:
|
|
2558
|
+
throw new VectrosError({
|
|
2559
|
+
statusCode: _response.error.statusCode,
|
|
2560
|
+
body: _response.error.body,
|
|
2561
|
+
rawResponse: _response.rawResponse
|
|
2562
|
+
});
|
|
2563
|
+
}
|
|
2564
|
+
}
|
|
2565
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/agents");
|
|
2566
|
+
}
|
|
2567
|
+
/**
|
|
2568
|
+
* Returns the agent at its latest version, or at `version`. Requires the `agents:r` scope.
|
|
2569
|
+
*
|
|
2570
|
+
* @param {Vectros.GetAgentRequest} request
|
|
2571
|
+
* @param {AgentsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
2572
|
+
*
|
|
2573
|
+
* @throws {@link Vectros.ForbiddenError}
|
|
2574
|
+
* @throws {@link Vectros.NotFoundError}
|
|
2575
|
+
*
|
|
2576
|
+
* @example
|
|
2577
|
+
* await client.agents.getAgent({
|
|
2578
|
+
* id: "id"
|
|
2579
|
+
* })
|
|
2580
|
+
*/
|
|
2581
|
+
getAgent(request, requestOptions) {
|
|
2582
|
+
return HttpResponsePromise.fromPromise(this.__getAgent(request, requestOptions));
|
|
2583
|
+
}
|
|
2584
|
+
async __getAgent(request, requestOptions) {
|
|
2585
|
+
const { id, contextId, version } = request;
|
|
2586
|
+
const _queryParams = {
|
|
2587
|
+
contextId,
|
|
2588
|
+
version
|
|
2589
|
+
};
|
|
2590
|
+
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
2591
|
+
const _headers = mergeHeaders(
|
|
2592
|
+
_authRequest.headers,
|
|
2593
|
+
this._options?.headers,
|
|
2594
|
+
requestOptions?.headers
|
|
2595
|
+
);
|
|
2596
|
+
const _response = await fetcher({
|
|
2597
|
+
url: url_exports.join(
|
|
2598
|
+
await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
|
|
2599
|
+
`v1/agents/${url_exports.encodePathParam(id)}`
|
|
2600
|
+
),
|
|
2601
|
+
method: "GET",
|
|
2602
|
+
headers: _headers,
|
|
2603
|
+
queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
|
|
2604
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
|
|
2605
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
2606
|
+
abortSignal: requestOptions?.abortSignal,
|
|
2607
|
+
fetchFn: this._options?.fetch,
|
|
2608
|
+
logging: this._options.logging
|
|
2609
|
+
});
|
|
2610
|
+
if (_response.ok) {
|
|
2611
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
2612
|
+
}
|
|
2613
|
+
if (_response.error.reason === "status-code") {
|
|
2614
|
+
switch (_response.error.statusCode) {
|
|
2615
|
+
case 403:
|
|
2616
|
+
throw new ForbiddenError(_response.error.body, _response.rawResponse);
|
|
2617
|
+
case 404:
|
|
2618
|
+
throw new NotFoundError(_response.error.body, _response.rawResponse);
|
|
2619
|
+
default:
|
|
2620
|
+
throw new VectrosError({
|
|
2621
|
+
statusCode: _response.error.statusCode,
|
|
2622
|
+
body: _response.error.body,
|
|
2623
|
+
rawResponse: _response.rawResponse
|
|
2624
|
+
});
|
|
2625
|
+
}
|
|
2626
|
+
}
|
|
2627
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/agents/{id}");
|
|
2628
|
+
}
|
|
2629
|
+
/**
|
|
2630
|
+
* 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.
|
|
2631
|
+
*
|
|
2632
|
+
* @param {Vectros.UpdateAgentRequest} request
|
|
2633
|
+
* @param {AgentsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
2634
|
+
*
|
|
2635
|
+
* @throws {@link Vectros.BadRequestError}
|
|
2636
|
+
* @throws {@link Vectros.ForbiddenError}
|
|
2637
|
+
* @throws {@link Vectros.NotFoundError}
|
|
2638
|
+
* @throws {@link Vectros.ConflictError}
|
|
2639
|
+
* @throws {@link Vectros.TooManyRequestsError}
|
|
2640
|
+
*
|
|
2641
|
+
* @example
|
|
2642
|
+
* await client.agents.updateAgent({
|
|
2643
|
+
* id: "id",
|
|
2644
|
+
* body: {
|
|
2645
|
+
* model: "claude-sonnet-5-5"
|
|
2646
|
+
* }
|
|
2647
|
+
* })
|
|
2648
|
+
*/
|
|
2649
|
+
updateAgent(request, requestOptions) {
|
|
2650
|
+
return HttpResponsePromise.fromPromise(this.__updateAgent(request, requestOptions));
|
|
2651
|
+
}
|
|
2652
|
+
async __updateAgent(request, requestOptions) {
|
|
2653
|
+
const { id, restore, contextId, body: _body } = request;
|
|
2654
|
+
const _queryParams = {
|
|
2655
|
+
restore,
|
|
2656
|
+
contextId
|
|
2657
|
+
};
|
|
2658
|
+
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
2659
|
+
const _headers = mergeHeaders(
|
|
2660
|
+
_authRequest.headers,
|
|
2661
|
+
this._options?.headers,
|
|
2662
|
+
requestOptions?.headers
|
|
2663
|
+
);
|
|
2664
|
+
const _response = await fetcher({
|
|
2665
|
+
url: url_exports.join(
|
|
2666
|
+
await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
|
|
2667
|
+
`v1/agents/${url_exports.encodePathParam(id)}`
|
|
2668
|
+
),
|
|
2669
|
+
method: "PUT",
|
|
2670
|
+
headers: _headers,
|
|
2671
|
+
contentType: "application/json",
|
|
2672
|
+
queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
|
|
2673
|
+
requestType: "json",
|
|
2674
|
+
body: _body,
|
|
2675
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
|
|
2676
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
2677
|
+
abortSignal: requestOptions?.abortSignal,
|
|
2678
|
+
fetchFn: this._options?.fetch,
|
|
2679
|
+
logging: this._options.logging
|
|
2680
|
+
});
|
|
2681
|
+
if (_response.ok) {
|
|
2682
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
2683
|
+
}
|
|
2684
|
+
if (_response.error.reason === "status-code") {
|
|
2685
|
+
switch (_response.error.statusCode) {
|
|
2686
|
+
case 400:
|
|
2687
|
+
throw new BadRequestError(_response.error.body, _response.rawResponse);
|
|
2688
|
+
case 403:
|
|
2689
|
+
throw new ForbiddenError(_response.error.body, _response.rawResponse);
|
|
2690
|
+
case 404:
|
|
2691
|
+
throw new NotFoundError(_response.error.body, _response.rawResponse);
|
|
2692
|
+
case 409:
|
|
2693
|
+
throw new ConflictError(_response.error.body, _response.rawResponse);
|
|
2694
|
+
case 429:
|
|
2695
|
+
throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
|
|
2696
|
+
default:
|
|
2697
|
+
throw new VectrosError({
|
|
2698
|
+
statusCode: _response.error.statusCode,
|
|
2699
|
+
body: _response.error.body,
|
|
2700
|
+
rawResponse: _response.rawResponse
|
|
2701
|
+
});
|
|
2702
|
+
}
|
|
2703
|
+
}
|
|
2704
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/v1/agents/{id}");
|
|
2705
|
+
}
|
|
2706
|
+
/**
|
|
2707
|
+
* 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.
|
|
2708
|
+
*
|
|
2709
|
+
* @param {Vectros.DeleteAgentRequest} request
|
|
2710
|
+
* @param {AgentsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
2711
|
+
*
|
|
2712
|
+
* @throws {@link Vectros.BadRequestError}
|
|
2713
|
+
* @throws {@link Vectros.ForbiddenError}
|
|
2714
|
+
* @throws {@link Vectros.NotFoundError}
|
|
2715
|
+
* @throws {@link Vectros.ConflictError}
|
|
2716
|
+
* @throws {@link Vectros.TooManyRequestsError}
|
|
2717
|
+
*
|
|
2718
|
+
* @example
|
|
2719
|
+
* await client.agents.deleteAgent({
|
|
2720
|
+
* id: "id"
|
|
2721
|
+
* })
|
|
2722
|
+
*/
|
|
2723
|
+
deleteAgent(request, requestOptions) {
|
|
2724
|
+
return HttpResponsePromise.fromPromise(this.__deleteAgent(request, requestOptions));
|
|
2725
|
+
}
|
|
2726
|
+
async __deleteAgent(request, requestOptions) {
|
|
2727
|
+
const { id, purge, version, contextId } = request;
|
|
2728
|
+
const _queryParams = {
|
|
2729
|
+
purge,
|
|
2730
|
+
version,
|
|
2731
|
+
contextId
|
|
2732
|
+
};
|
|
2733
|
+
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
2734
|
+
const _headers = mergeHeaders(
|
|
2735
|
+
_authRequest.headers,
|
|
2736
|
+
this._options?.headers,
|
|
2737
|
+
requestOptions?.headers
|
|
2738
|
+
);
|
|
2739
|
+
const _response = await fetcher({
|
|
2740
|
+
url: url_exports.join(
|
|
2741
|
+
await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
|
|
2742
|
+
`v1/agents/${url_exports.encodePathParam(id)}`
|
|
2743
|
+
),
|
|
2744
|
+
method: "DELETE",
|
|
2745
|
+
headers: _headers,
|
|
2746
|
+
queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
|
|
2747
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
|
|
2748
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
2749
|
+
abortSignal: requestOptions?.abortSignal,
|
|
2750
|
+
fetchFn: this._options?.fetch,
|
|
2751
|
+
logging: this._options.logging
|
|
2752
|
+
});
|
|
2753
|
+
if (_response.ok) {
|
|
2754
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
2755
|
+
}
|
|
2756
|
+
if (_response.error.reason === "status-code") {
|
|
2757
|
+
switch (_response.error.statusCode) {
|
|
2758
|
+
case 400:
|
|
2759
|
+
throw new BadRequestError(_response.error.body, _response.rawResponse);
|
|
2760
|
+
case 403:
|
|
2761
|
+
throw new ForbiddenError(_response.error.body, _response.rawResponse);
|
|
2762
|
+
case 404:
|
|
2763
|
+
throw new NotFoundError(_response.error.body, _response.rawResponse);
|
|
2764
|
+
case 409:
|
|
2765
|
+
throw new ConflictError(_response.error.body, _response.rawResponse);
|
|
2766
|
+
case 429:
|
|
2767
|
+
throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
|
|
2768
|
+
default:
|
|
2769
|
+
throw new VectrosError({
|
|
2770
|
+
statusCode: _response.error.statusCode,
|
|
2771
|
+
body: _response.error.body,
|
|
2772
|
+
rawResponse: _response.rawResponse
|
|
2773
|
+
});
|
|
2774
|
+
}
|
|
2775
|
+
}
|
|
2776
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/v1/agents/{id}");
|
|
2777
|
+
}
|
|
2778
|
+
/**
|
|
2779
|
+
* 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.
|
|
2780
|
+
*
|
|
2781
|
+
* @param {Vectros.ListAgentVersionsRequest} request
|
|
2782
|
+
* @param {AgentsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
2783
|
+
*
|
|
2784
|
+
* @throws {@link Vectros.ForbiddenError}
|
|
2785
|
+
* @throws {@link Vectros.NotFoundError}
|
|
2786
|
+
*
|
|
2787
|
+
* @example
|
|
2788
|
+
* await client.agents.listAgentVersions({
|
|
2789
|
+
* id: "id"
|
|
2790
|
+
* })
|
|
2791
|
+
*/
|
|
2792
|
+
listAgentVersions(request, requestOptions) {
|
|
2793
|
+
return HttpResponsePromise.fromPromise(this.__listAgentVersions(request, requestOptions));
|
|
2794
|
+
}
|
|
2795
|
+
async __listAgentVersions(request, requestOptions) {
|
|
2796
|
+
const { id, contextId, includeContent, startFrom, limit } = request;
|
|
2797
|
+
const _queryParams = {
|
|
2798
|
+
contextId,
|
|
2799
|
+
includeContent,
|
|
2800
|
+
startFrom,
|
|
2801
|
+
limit
|
|
2802
|
+
};
|
|
2803
|
+
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
2804
|
+
const _headers = mergeHeaders(
|
|
2805
|
+
_authRequest.headers,
|
|
2806
|
+
this._options?.headers,
|
|
2807
|
+
requestOptions?.headers
|
|
2808
|
+
);
|
|
2809
|
+
const _response = await fetcher({
|
|
2810
|
+
url: url_exports.join(
|
|
2811
|
+
await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
|
|
2812
|
+
`v1/agents/${url_exports.encodePathParam(id)}/versions`
|
|
2813
|
+
),
|
|
2814
|
+
method: "GET",
|
|
2815
|
+
headers: _headers,
|
|
2816
|
+
queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
|
|
2817
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
|
|
2818
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
2819
|
+
abortSignal: requestOptions?.abortSignal,
|
|
2820
|
+
fetchFn: this._options?.fetch,
|
|
2821
|
+
logging: this._options.logging
|
|
2822
|
+
});
|
|
2823
|
+
if (_response.ok) {
|
|
2824
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
2825
|
+
}
|
|
2826
|
+
if (_response.error.reason === "status-code") {
|
|
2827
|
+
switch (_response.error.statusCode) {
|
|
2828
|
+
case 403:
|
|
2829
|
+
throw new ForbiddenError(_response.error.body, _response.rawResponse);
|
|
2830
|
+
case 404:
|
|
2831
|
+
throw new NotFoundError(_response.error.body, _response.rawResponse);
|
|
2832
|
+
default:
|
|
2833
|
+
throw new VectrosError({
|
|
2834
|
+
statusCode: _response.error.statusCode,
|
|
2835
|
+
body: _response.error.body,
|
|
2836
|
+
rawResponse: _response.rawResponse
|
|
2837
|
+
});
|
|
2838
|
+
}
|
|
2839
|
+
}
|
|
2840
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/agents/{id}/versions");
|
|
2841
|
+
}
|
|
2842
|
+
/**
|
|
2843
|
+
* 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.
|
|
2844
|
+
*
|
|
2845
|
+
* @param {Vectros.CancelRunRequest} request
|
|
2846
|
+
* @param {AgentsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
2847
|
+
*
|
|
2848
|
+
* @throws {@link Vectros.BadRequestError}
|
|
2849
|
+
* @throws {@link Vectros.UnauthorizedError}
|
|
2850
|
+
* @throws {@link Vectros.ForbiddenError}
|
|
2851
|
+
* @throws {@link Vectros.NotFoundError}
|
|
2852
|
+
* @throws {@link Vectros.TooManyRequestsError}
|
|
2853
|
+
*
|
|
2854
|
+
* @example
|
|
2855
|
+
* await client.agents.cancelRun({
|
|
2856
|
+
* id: "id"
|
|
2857
|
+
* })
|
|
2858
|
+
*/
|
|
2859
|
+
cancelRun(request, requestOptions) {
|
|
2860
|
+
return HttpResponsePromise.fromPromise(this.__cancelRun(request, requestOptions));
|
|
2861
|
+
}
|
|
2862
|
+
async __cancelRun(request, requestOptions) {
|
|
2863
|
+
const { id, contextId } = request;
|
|
2864
|
+
const _queryParams = {
|
|
2865
|
+
contextId
|
|
2866
|
+
};
|
|
2867
|
+
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
2868
|
+
const _headers = mergeHeaders(
|
|
2869
|
+
_authRequest.headers,
|
|
2870
|
+
this._options?.headers,
|
|
2871
|
+
requestOptions?.headers
|
|
2872
|
+
);
|
|
2873
|
+
const _response = await fetcher({
|
|
2874
|
+
url: url_exports.join(
|
|
2875
|
+
await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
|
|
2876
|
+
`v1/runs/${url_exports.encodePathParam(id)}/cancel`
|
|
2877
|
+
),
|
|
2878
|
+
method: "POST",
|
|
2879
|
+
headers: _headers,
|
|
2880
|
+
queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
|
|
2881
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
|
|
2882
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
2883
|
+
abortSignal: requestOptions?.abortSignal,
|
|
2884
|
+
fetchFn: this._options?.fetch,
|
|
2885
|
+
logging: this._options.logging
|
|
2886
|
+
});
|
|
2887
|
+
if (_response.ok) {
|
|
2888
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
2889
|
+
}
|
|
2890
|
+
if (_response.error.reason === "status-code") {
|
|
2891
|
+
switch (_response.error.statusCode) {
|
|
2892
|
+
case 400:
|
|
2893
|
+
throw new BadRequestError(_response.error.body, _response.rawResponse);
|
|
2894
|
+
case 401:
|
|
2895
|
+
throw new UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
2896
|
+
case 403:
|
|
2897
|
+
throw new ForbiddenError(_response.error.body, _response.rawResponse);
|
|
2898
|
+
case 404:
|
|
2899
|
+
throw new NotFoundError(_response.error.body, _response.rawResponse);
|
|
2900
|
+
case 429:
|
|
2901
|
+
throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
|
|
2902
|
+
default:
|
|
2903
|
+
throw new VectrosError({
|
|
2904
|
+
statusCode: _response.error.statusCode,
|
|
2905
|
+
body: _response.error.body,
|
|
2906
|
+
rawResponse: _response.rawResponse
|
|
2907
|
+
});
|
|
2908
|
+
}
|
|
2909
|
+
}
|
|
2910
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/runs/{id}/cancel");
|
|
2911
|
+
}
|
|
2912
|
+
/**
|
|
2913
|
+
* 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.
|
|
2914
|
+
*
|
|
2915
|
+
* @param {Vectros.GetRunRequest} request
|
|
2916
|
+
* @param {AgentsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
2917
|
+
*
|
|
2918
|
+
* @throws {@link Vectros.BadRequestError}
|
|
2919
|
+
* @throws {@link Vectros.UnauthorizedError}
|
|
2920
|
+
* @throws {@link Vectros.ForbiddenError}
|
|
2921
|
+
* @throws {@link Vectros.NotFoundError}
|
|
2922
|
+
*
|
|
2923
|
+
* @example
|
|
2924
|
+
* await client.agents.getRun({
|
|
2925
|
+
* id: "id"
|
|
2926
|
+
* })
|
|
2927
|
+
*/
|
|
2928
|
+
getRun(request, requestOptions) {
|
|
2929
|
+
return HttpResponsePromise.fromPromise(this.__getRun(request, requestOptions));
|
|
2930
|
+
}
|
|
2931
|
+
async __getRun(request, requestOptions) {
|
|
2932
|
+
const { id, contextId } = request;
|
|
2933
|
+
const _queryParams = {
|
|
2934
|
+
contextId
|
|
2935
|
+
};
|
|
2936
|
+
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
2937
|
+
const _headers = mergeHeaders(
|
|
2938
|
+
_authRequest.headers,
|
|
2939
|
+
this._options?.headers,
|
|
2940
|
+
requestOptions?.headers
|
|
2941
|
+
);
|
|
2942
|
+
const _response = await fetcher({
|
|
2943
|
+
url: url_exports.join(
|
|
2944
|
+
await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
|
|
2945
|
+
`v1/runs/${url_exports.encodePathParam(id)}`
|
|
2946
|
+
),
|
|
2947
|
+
method: "GET",
|
|
2948
|
+
headers: _headers,
|
|
2949
|
+
queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
|
|
2950
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
|
|
2951
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
2952
|
+
abortSignal: requestOptions?.abortSignal,
|
|
2953
|
+
fetchFn: this._options?.fetch,
|
|
2954
|
+
logging: this._options.logging
|
|
2955
|
+
});
|
|
2956
|
+
if (_response.ok) {
|
|
2957
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
2958
|
+
}
|
|
2959
|
+
if (_response.error.reason === "status-code") {
|
|
2960
|
+
switch (_response.error.statusCode) {
|
|
2961
|
+
case 400:
|
|
2962
|
+
throw new BadRequestError(_response.error.body, _response.rawResponse);
|
|
2963
|
+
case 401:
|
|
2964
|
+
throw new UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
2965
|
+
case 403:
|
|
2966
|
+
throw new ForbiddenError(_response.error.body, _response.rawResponse);
|
|
2967
|
+
case 404:
|
|
2968
|
+
throw new NotFoundError(_response.error.body, _response.rawResponse);
|
|
2969
|
+
default:
|
|
2970
|
+
throw new VectrosError({
|
|
2971
|
+
statusCode: _response.error.statusCode,
|
|
2972
|
+
body: _response.error.body,
|
|
2973
|
+
rawResponse: _response.rawResponse
|
|
2974
|
+
});
|
|
2975
|
+
}
|
|
2976
|
+
}
|
|
2977
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/runs/{id}");
|
|
2978
|
+
}
|
|
2979
|
+
/**
|
|
2980
|
+
* 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.
|
|
2981
|
+
*/
|
|
2982
|
+
createRun(request, requestOptions) {
|
|
2983
|
+
return HttpResponsePromise.fromPromise(this.__createRun(request, requestOptions));
|
|
2984
|
+
}
|
|
2985
|
+
async __createRun(request, requestOptions) {
|
|
2986
|
+
const { "Idempotency-Key": idempotencyKey, ..._body } = request;
|
|
2987
|
+
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
2988
|
+
const _headers = mergeHeaders(
|
|
2989
|
+
_authRequest.headers,
|
|
2990
|
+
this._options?.headers,
|
|
2991
|
+
mergeOnlyDefinedHeaders({ "Idempotency-Key": idempotencyKey }),
|
|
2992
|
+
requestOptions?.headers
|
|
2993
|
+
);
|
|
2994
|
+
const _response = await fetcher({
|
|
2995
|
+
url: url_exports.join(
|
|
2996
|
+
await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
|
|
2997
|
+
"v1/runs"
|
|
2998
|
+
),
|
|
2999
|
+
method: "POST",
|
|
3000
|
+
headers: _headers,
|
|
3001
|
+
contentType: "application/json",
|
|
3002
|
+
queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
|
|
3003
|
+
requestType: "json",
|
|
3004
|
+
body: _body,
|
|
3005
|
+
responseType: "sse",
|
|
3006
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
|
|
3007
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
3008
|
+
abortSignal: requestOptions?.abortSignal,
|
|
3009
|
+
fetchFn: this._options?.fetch,
|
|
3010
|
+
logging: this._options.logging
|
|
3011
|
+
});
|
|
3012
|
+
if (_response.ok) {
|
|
3013
|
+
return {
|
|
3014
|
+
data: new Stream({
|
|
3015
|
+
stream: _response.body,
|
|
3016
|
+
parse: (data) => data,
|
|
3017
|
+
signal: requestOptions?.abortSignal,
|
|
3018
|
+
eventShape: {
|
|
3019
|
+
type: "sse"
|
|
3020
|
+
}
|
|
3021
|
+
}),
|
|
3022
|
+
rawResponse: _response.rawResponse
|
|
3023
|
+
};
|
|
3024
|
+
}
|
|
3025
|
+
if (_response.error.reason === "status-code") {
|
|
3026
|
+
switch (_response.error.statusCode) {
|
|
3027
|
+
case 400:
|
|
3028
|
+
throw new BadRequestError(_response.error.body, _response.rawResponse);
|
|
3029
|
+
case 401:
|
|
3030
|
+
throw new UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
3031
|
+
case 402:
|
|
3032
|
+
throw new PaymentRequiredError(_response.error.body, _response.rawResponse);
|
|
3033
|
+
case 403:
|
|
3034
|
+
throw new ForbiddenError(_response.error.body, _response.rawResponse);
|
|
3035
|
+
case 404:
|
|
3036
|
+
throw new NotFoundError(_response.error.body, _response.rawResponse);
|
|
3037
|
+
case 409:
|
|
3038
|
+
throw new ConflictError(_response.error.body, _response.rawResponse);
|
|
3039
|
+
case 413:
|
|
3040
|
+
throw new ContentTooLargeError(_response.error.body, _response.rawResponse);
|
|
3041
|
+
case 422:
|
|
3042
|
+
throw new UnprocessableEntityError(_response.error.body, _response.rawResponse);
|
|
3043
|
+
case 429:
|
|
3044
|
+
throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
|
|
3045
|
+
case 503:
|
|
3046
|
+
throw new ServiceUnavailableError(_response.error.body, _response.rawResponse);
|
|
3047
|
+
default:
|
|
3048
|
+
throw new VectrosError({
|
|
3049
|
+
statusCode: _response.error.statusCode,
|
|
3050
|
+
body: _response.error.body,
|
|
3051
|
+
rawResponse: _response.rawResponse
|
|
3052
|
+
});
|
|
3053
|
+
}
|
|
3054
|
+
}
|
|
3055
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/runs");
|
|
2414
3056
|
}
|
|
2415
|
-
}
|
|
3057
|
+
};
|
|
2416
3058
|
var AuthClient = class {
|
|
2417
3059
|
constructor(options) {
|
|
2418
3060
|
this._options = normalizeClientOptionsWithAuth(options);
|
|
@@ -2960,9 +3602,7 @@ var AuthClient = class {
|
|
|
2960
3602
|
* @example
|
|
2961
3603
|
* await client.auth.createAccessProfile({
|
|
2962
3604
|
* contextId: "contextId",
|
|
2963
|
-
* body: {
|
|
2964
|
-
* principalId: "usr_6ba7b810-9dad-11d1-80b4-00c04fd430c8"
|
|
2965
|
-
* }
|
|
3605
|
+
* body: {}
|
|
2966
3606
|
* })
|
|
2967
3607
|
*/
|
|
2968
3608
|
createAccessProfile(request, requestOptions) {
|
|
@@ -3098,10 +3738,7 @@ var AuthClient = class {
|
|
|
3098
3738
|
*
|
|
3099
3739
|
* @example
|
|
3100
3740
|
* await client.auth.createAppContext({
|
|
3101
|
-
* body: {
|
|
3102
|
-
* contextId: "myapp",
|
|
3103
|
-
* name: "My Internal App"
|
|
3104
|
-
* }
|
|
3741
|
+
* body: {}
|
|
3105
3742
|
* })
|
|
3106
3743
|
*/
|
|
3107
3744
|
createAppContext(request, requestOptions) {
|
|
@@ -3244,13 +3881,7 @@ var AuthClient = class {
|
|
|
3244
3881
|
* @example
|
|
3245
3882
|
* await client.auth.createRole({
|
|
3246
3883
|
* contextId: "contextId",
|
|
3247
|
-
* body: {
|
|
3248
|
-
* roleId: "engineering-member",
|
|
3249
|
-
* name: "Engineering Team Member",
|
|
3250
|
-
* scopes: [{
|
|
3251
|
-
* allowed_actions: ["records:cru", "search:r"]
|
|
3252
|
-
* }]
|
|
3253
|
-
* }
|
|
3884
|
+
* body: {}
|
|
3254
3885
|
* })
|
|
3255
3886
|
*/
|
|
3256
3887
|
createRole(request, requestOptions) {
|
|
@@ -3394,9 +4025,7 @@ var AuthClient = class {
|
|
|
3394
4025
|
* await client.auth.updateAccessProfile({
|
|
3395
4026
|
* contextId: "contextId",
|
|
3396
4027
|
* principalId: "principalId",
|
|
3397
|
-
* body: {
|
|
3398
|
-
* principalId: "usr_6ba7b810-9dad-11d1-80b4-00c04fd430c8"
|
|
3399
|
-
* }
|
|
4028
|
+
* body: {}
|
|
3400
4029
|
* })
|
|
3401
4030
|
*/
|
|
3402
4031
|
updateAccessProfile(request, requestOptions) {
|
|
@@ -3599,10 +4228,7 @@ var AuthClient = class {
|
|
|
3599
4228
|
* @example
|
|
3600
4229
|
* await client.auth.updateAppContext({
|
|
3601
4230
|
* contextId: "contextId",
|
|
3602
|
-
* body: {
|
|
3603
|
-
* contextId: "myapp",
|
|
3604
|
-
* name: "My Internal App"
|
|
3605
|
-
* }
|
|
4231
|
+
* body: {}
|
|
3606
4232
|
* })
|
|
3607
4233
|
*/
|
|
3608
4234
|
updateAppContext(request, requestOptions) {
|
|
@@ -3807,13 +4433,7 @@ var AuthClient = class {
|
|
|
3807
4433
|
* await client.auth.updateRole({
|
|
3808
4434
|
* contextId: "contextId",
|
|
3809
4435
|
* roleId: "roleId",
|
|
3810
|
-
* body: {
|
|
3811
|
-
* roleId: "engineering-member",
|
|
3812
|
-
* name: "Engineering Team Member",
|
|
3813
|
-
* scopes: [{
|
|
3814
|
-
* allowed_actions: ["records:cru", "search:r"]
|
|
3815
|
-
* }]
|
|
3816
|
-
* }
|
|
4436
|
+
* body: {}
|
|
3817
4437
|
* })
|
|
3818
4438
|
*/
|
|
3819
4439
|
updateRole(request, requestOptions) {
|
|
@@ -5265,7 +5885,7 @@ var DocumentsClient = class {
|
|
|
5265
5885
|
this._options = normalizeClientOptionsWithAuth(options);
|
|
5266
5886
|
}
|
|
5267
5887
|
/**
|
|
5268
|
-
* Returns a paginated list of your documents, optionally filtered by folder (`folderId`)
|
|
5888
|
+
* 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.
|
|
5269
5889
|
*
|
|
5270
5890
|
* @param {Vectros.ListDocumentsRequest} request
|
|
5271
5891
|
* @param {DocumentsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
@@ -5275,6 +5895,7 @@ var DocumentsClient = class {
|
|
|
5275
5895
|
* userId: "550e8400-e29b-41d4-a716-446655440000",
|
|
5276
5896
|
* scope: "group:eng-team",
|
|
5277
5897
|
* folderId: "f47ac10b-58cc-4372-a567-0e02b2c3d479",
|
|
5898
|
+
* type: "investigation_report",
|
|
5278
5899
|
* startFrom: "b3BhcXVlLWN1cnNvci1mcm9tLXRoZS1wcmV2aW91cy1wYWdl"
|
|
5279
5900
|
* })
|
|
5280
5901
|
*/
|
|
@@ -5282,11 +5903,12 @@ var DocumentsClient = class {
|
|
|
5282
5903
|
return HttpResponsePromise.fromPromise(this.__listDocuments(request, requestOptions));
|
|
5283
5904
|
}
|
|
5284
5905
|
async __listDocuments(request = {}, requestOptions) {
|
|
5285
|
-
const { userId, scope, folderId, startFrom, limit } = request;
|
|
5906
|
+
const { userId, scope, folderId, type: type_, startFrom, limit } = request;
|
|
5286
5907
|
const _queryParams = {
|
|
5287
5908
|
userId,
|
|
5288
5909
|
scope,
|
|
5289
5910
|
folderId,
|
|
5911
|
+
type: type_,
|
|
5290
5912
|
startFrom,
|
|
5291
5913
|
limit
|
|
5292
5914
|
};
|
|
@@ -5336,9 +5958,7 @@ var DocumentsClient = class {
|
|
|
5336
5958
|
*
|
|
5337
5959
|
* @example
|
|
5338
5960
|
* await client.documents.ingestDocument({
|
|
5339
|
-
* body: {
|
|
5340
|
-
* title: "Patient Intake Form \u2014 Jane Doe"
|
|
5341
|
-
* }
|
|
5961
|
+
* body: {}
|
|
5342
5962
|
* })
|
|
5343
5963
|
*/
|
|
5344
5964
|
ingestDocument(request, requestOptions) {
|
|
@@ -5468,9 +6088,7 @@ var DocumentsClient = class {
|
|
|
5468
6088
|
* @example
|
|
5469
6089
|
* await client.documents.updateDocument({
|
|
5470
6090
|
* id: "id",
|
|
5471
|
-
* body: {
|
|
5472
|
-
* title: "Patient Intake Form \u2014 Jane Doe"
|
|
5473
|
-
* }
|
|
6091
|
+
* body: {}
|
|
5474
6092
|
* })
|
|
5475
6093
|
*/
|
|
5476
6094
|
updateDocument(request, requestOptions) {
|
|
@@ -5868,11 +6486,12 @@ var DocumentsClient = class {
|
|
|
5868
6486
|
return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/documents/{id}/download");
|
|
5869
6487
|
}
|
|
5870
6488
|
/**
|
|
5871
|
-
* 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,
|
|
6489
|
+
* 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.
|
|
5872
6490
|
*
|
|
5873
6491
|
* @param {Vectros.GetDocumentTextRequest} request
|
|
5874
6492
|
* @param {DocumentsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
5875
6493
|
*
|
|
6494
|
+
* @throws {@link Vectros.BadRequestError}
|
|
5876
6495
|
* @throws {@link Vectros.NotFoundError}
|
|
5877
6496
|
*
|
|
5878
6497
|
* @example
|
|
@@ -5884,7 +6503,11 @@ var DocumentsClient = class {
|
|
|
5884
6503
|
return HttpResponsePromise.fromPromise(this.__getDocumentText(request, requestOptions));
|
|
5885
6504
|
}
|
|
5886
6505
|
async __getDocumentText(request, requestOptions) {
|
|
5887
|
-
const { id } = request;
|
|
6506
|
+
const { id, offset, limit } = request;
|
|
6507
|
+
const _queryParams = {
|
|
6508
|
+
offset,
|
|
6509
|
+
limit
|
|
6510
|
+
};
|
|
5888
6511
|
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
5889
6512
|
const _headers = mergeHeaders(
|
|
5890
6513
|
_authRequest.headers,
|
|
@@ -5898,7 +6521,7 @@ var DocumentsClient = class {
|
|
|
5898
6521
|
),
|
|
5899
6522
|
method: "GET",
|
|
5900
6523
|
headers: _headers,
|
|
5901
|
-
queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
|
|
6524
|
+
queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
|
|
5902
6525
|
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
|
|
5903
6526
|
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
5904
6527
|
abortSignal: requestOptions?.abortSignal,
|
|
@@ -5910,6 +6533,8 @@ var DocumentsClient = class {
|
|
|
5910
6533
|
}
|
|
5911
6534
|
if (_response.error.reason === "status-code") {
|
|
5912
6535
|
switch (_response.error.statusCode) {
|
|
6536
|
+
case 400:
|
|
6537
|
+
throw new BadRequestError(_response.error.body, _response.rawResponse);
|
|
5913
6538
|
case 404:
|
|
5914
6539
|
throw new NotFoundError(_response.error.body, _response.rawResponse);
|
|
5915
6540
|
default:
|
|
@@ -6129,9 +6754,7 @@ var FoldersClient = class {
|
|
|
6129
6754
|
*
|
|
6130
6755
|
* @example
|
|
6131
6756
|
* await client.folders.createFolder({
|
|
6132
|
-
* body: {
|
|
6133
|
-
* name: "Patient Records 2024"
|
|
6134
|
-
* }
|
|
6757
|
+
* body: {}
|
|
6135
6758
|
* })
|
|
6136
6759
|
*/
|
|
6137
6760
|
createFolder(request, requestOptions) {
|
|
@@ -6259,9 +6882,7 @@ var FoldersClient = class {
|
|
|
6259
6882
|
* @example
|
|
6260
6883
|
* await client.folders.updateFolder({
|
|
6261
6884
|
* id: "id",
|
|
6262
|
-
* body: {
|
|
6263
|
-
* name: "Patient Records 2024"
|
|
6264
|
-
* }
|
|
6885
|
+
* body: {}
|
|
6265
6886
|
* })
|
|
6266
6887
|
*/
|
|
6267
6888
|
updateFolder(request, requestOptions) {
|
|
@@ -6394,9 +7015,7 @@ var FoldersClient = class {
|
|
|
6394
7015
|
* @example
|
|
6395
7016
|
* await client.folders.patchFolder({
|
|
6396
7017
|
* id: "id",
|
|
6397
|
-
* body: {
|
|
6398
|
-
* name: "Patient Records 2024"
|
|
6399
|
-
* }
|
|
7018
|
+
* body: {}
|
|
6400
7019
|
* })
|
|
6401
7020
|
*/
|
|
6402
7021
|
patchFolder(request, requestOptions) {
|
|
@@ -6611,9 +7230,7 @@ var IdentityClient = class {
|
|
|
6611
7230
|
* await client.identity.createEntity({
|
|
6612
7231
|
* namespace: "team",
|
|
6613
7232
|
* contextId: "myapp",
|
|
6614
|
-
* body: {
|
|
6615
|
-
* externalId: "team_eng_platform"
|
|
6616
|
-
* }
|
|
7233
|
+
* body: {}
|
|
6617
7234
|
* })
|
|
6618
7235
|
*/
|
|
6619
7236
|
createEntity(request, requestOptions) {
|
|
@@ -6749,9 +7366,7 @@ var IdentityClient = class {
|
|
|
6749
7366
|
* namespace: "team",
|
|
6750
7367
|
* id: "id",
|
|
6751
7368
|
* contextId: "myapp",
|
|
6752
|
-
* body: {
|
|
6753
|
-
* externalId: "team_eng_platform"
|
|
6754
|
-
* }
|
|
7369
|
+
* body: {}
|
|
6755
7370
|
* })
|
|
6756
7371
|
*/
|
|
6757
7372
|
updateEntity(request, requestOptions) {
|
|
@@ -7091,10 +7706,7 @@ var IdentityClient = class {
|
|
|
7091
7706
|
* @example
|
|
7092
7707
|
* await client.identity.updateNamespace({
|
|
7093
7708
|
* namespace: "team",
|
|
7094
|
-
* body: {
|
|
7095
|
-
* namespace: "team",
|
|
7096
|
-
* specificityRank: 1500
|
|
7097
|
-
* }
|
|
7709
|
+
* body: {}
|
|
7098
7710
|
* })
|
|
7099
7711
|
*/
|
|
7100
7712
|
updateNamespace(request, requestOptions) {
|
|
@@ -7281,10 +7893,7 @@ var IdentityClient = class {
|
|
|
7281
7893
|
*
|
|
7282
7894
|
* @example
|
|
7283
7895
|
* await client.identity.registerNamespace({
|
|
7284
|
-
* body: {
|
|
7285
|
-
* namespace: "team",
|
|
7286
|
-
* specificityRank: 1500
|
|
7287
|
-
* }
|
|
7896
|
+
* body: {}
|
|
7288
7897
|
* })
|
|
7289
7898
|
*/
|
|
7290
7899
|
registerNamespace(request, requestOptions) {
|
|
@@ -7417,9 +8026,7 @@ var IdentityClient = class {
|
|
|
7417
8026
|
*
|
|
7418
8027
|
* @example
|
|
7419
8028
|
* await client.identity.createUser({
|
|
7420
|
-
* body: {
|
|
7421
|
-
* externalId: "usr_12345"
|
|
7422
|
-
* }
|
|
8029
|
+
* body: {}
|
|
7423
8030
|
* })
|
|
7424
8031
|
*/
|
|
7425
8032
|
createUser(request, requestOptions) {
|
|
@@ -7538,6 +8145,7 @@ var IdentityClient = class {
|
|
|
7538
8145
|
* @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
7539
8146
|
*
|
|
7540
8147
|
* @throws {@link Vectros.BadRequestError}
|
|
8148
|
+
* @throws {@link Vectros.ForbiddenError}
|
|
7541
8149
|
* @throws {@link Vectros.NotFoundError}
|
|
7542
8150
|
* @throws {@link Vectros.ConflictError}
|
|
7543
8151
|
* @throws {@link Vectros.TooManyRequestsError}
|
|
@@ -7545,9 +8153,7 @@ var IdentityClient = class {
|
|
|
7545
8153
|
* @example
|
|
7546
8154
|
* await client.identity.updateUser({
|
|
7547
8155
|
* id: "550e8400-e29b-41d4-a716-446655440000",
|
|
7548
|
-
* body: {
|
|
7549
|
-
* externalId: "usr_12345"
|
|
7550
|
-
* }
|
|
8156
|
+
* body: {}
|
|
7551
8157
|
* })
|
|
7552
8158
|
*/
|
|
7553
8159
|
updateUser(request, requestOptions) {
|
|
@@ -7585,6 +8191,8 @@ var IdentityClient = class {
|
|
|
7585
8191
|
switch (_response.error.statusCode) {
|
|
7586
8192
|
case 400:
|
|
7587
8193
|
throw new BadRequestError(_response.error.body, _response.rawResponse);
|
|
8194
|
+
case 403:
|
|
8195
|
+
throw new ForbiddenError(_response.error.body, _response.rawResponse);
|
|
7588
8196
|
case 404:
|
|
7589
8197
|
throw new NotFoundError(_response.error.body, _response.rawResponse);
|
|
7590
8198
|
case 409:
|
|
@@ -7607,6 +8215,7 @@ var IdentityClient = class {
|
|
|
7607
8215
|
* @param {Vectros.DeleteUserRequest} request
|
|
7608
8216
|
* @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
7609
8217
|
*
|
|
8218
|
+
* @throws {@link Vectros.ForbiddenError}
|
|
7610
8219
|
* @throws {@link Vectros.NotFoundError}
|
|
7611
8220
|
* @throws {@link Vectros.ConflictError}
|
|
7612
8221
|
* @throws {@link Vectros.TooManyRequestsError}
|
|
@@ -7646,6 +8255,8 @@ var IdentityClient = class {
|
|
|
7646
8255
|
}
|
|
7647
8256
|
if (_response.error.reason === "status-code") {
|
|
7648
8257
|
switch (_response.error.statusCode) {
|
|
8258
|
+
case 403:
|
|
8259
|
+
throw new ForbiddenError(_response.error.body, _response.rawResponse);
|
|
7649
8260
|
case 404:
|
|
7650
8261
|
throw new NotFoundError(_response.error.body, _response.rawResponse);
|
|
7651
8262
|
case 409:
|
|
@@ -7850,7 +8461,7 @@ var InferenceClient = class {
|
|
|
7850
8461
|
this._options = normalizeClientOptionsWithAuth(options);
|
|
7851
8462
|
}
|
|
7852
8463
|
/**
|
|
7853
|
-
* 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,
|
|
8464
|
+
* 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`.
|
|
7854
8465
|
*
|
|
7855
8466
|
* @param {InferenceClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
7856
8467
|
*
|
|
@@ -7894,7 +8505,7 @@ var InferenceClient = class {
|
|
|
7894
8505
|
return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/models");
|
|
7895
8506
|
}
|
|
7896
8507
|
/**
|
|
7897
|
-
* 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
|
|
8508
|
+
* 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.
|
|
7898
8509
|
*/
|
|
7899
8510
|
chatInference(request, requestOptions) {
|
|
7900
8511
|
return HttpResponsePromise.fromPromise(this.__chatInference(request, requestOptions));
|
|
@@ -7966,7 +8577,7 @@ var InferenceClient = class {
|
|
|
7966
8577
|
return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/chat");
|
|
7967
8578
|
}
|
|
7968
8579
|
/**
|
|
7969
|
-
* Loads a single document's extracted text, supplies it as context, and streams a model answer about it. The document must
|
|
8580
|
+
* 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.
|
|
7970
8581
|
*/
|
|
7971
8582
|
documentAsk(request, requestOptions) {
|
|
7972
8583
|
return HttpResponsePromise.fromPromise(this.__documentAsk(request, requestOptions));
|
|
@@ -9101,8 +9712,7 @@ var SchemasClient = class {
|
|
|
9101
9712
|
* }],
|
|
9102
9713
|
* capabilities: {
|
|
9103
9714
|
* "auditHistory": true
|
|
9104
|
-
* }
|
|
9105
|
-
* allowedSurfaces: ["record"]
|
|
9715
|
+
* }
|
|
9106
9716
|
* }
|
|
9107
9717
|
* })
|
|
9108
9718
|
*/
|
|
@@ -9232,11 +9842,7 @@ var SchemasClient = class {
|
|
|
9232
9842
|
* @example
|
|
9233
9843
|
* await client.schemas.updateSchema({
|
|
9234
9844
|
* id: "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
|
|
9235
|
-
* body: {
|
|
9236
|
-
* typeName: "intake_form",
|
|
9237
|
-
* displayName: "Client Intake Form",
|
|
9238
|
-
* allowedSurfaces: ["record"]
|
|
9239
|
-
* }
|
|
9845
|
+
* body: {}
|
|
9240
9846
|
* })
|
|
9241
9847
|
*/
|
|
9242
9848
|
updateSchema(request, requestOptions) {
|
|
@@ -9776,7 +10382,7 @@ var ScriptsClient = class {
|
|
|
9776
10382
|
return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/v1/scripts/{id}");
|
|
9777
10383
|
}
|
|
9778
10384
|
/**
|
|
9779
|
-
* 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.
|
|
10385
|
+
* 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.
|
|
9780
10386
|
*
|
|
9781
10387
|
* @param {Vectros.DeleteScriptRequest} request
|
|
9782
10388
|
* @param {ScriptsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
@@ -10040,17 +10646,7 @@ var TriggersClient = class {
|
|
|
10040
10646
|
*
|
|
10041
10647
|
* @example
|
|
10042
10648
|
* await client.triggers.createTrigger({
|
|
10043
|
-
* body: {
|
|
10044
|
-
* name: "on-intake-create",
|
|
10045
|
-
* firingSource: {
|
|
10046
|
-
* schemaId: "sch_9f8e7d6c",
|
|
10047
|
-
* event: "CREATE"
|
|
10048
|
-
* },
|
|
10049
|
-
* scriptRef: {
|
|
10050
|
-
* name: "notify-assignee",
|
|
10051
|
-
* version: "3"
|
|
10052
|
-
* }
|
|
10053
|
-
* }
|
|
10649
|
+
* body: {}
|
|
10054
10650
|
* })
|
|
10055
10651
|
*/
|
|
10056
10652
|
createTrigger(request, requestOptions) {
|
|
@@ -10179,17 +10775,7 @@ var TriggersClient = class {
|
|
|
10179
10775
|
* @example
|
|
10180
10776
|
* await client.triggers.updateTrigger({
|
|
10181
10777
|
* id: "id",
|
|
10182
|
-
* body: {
|
|
10183
|
-
* name: "on-intake-create",
|
|
10184
|
-
* firingSource: {
|
|
10185
|
-
* schemaId: "sch_9f8e7d6c",
|
|
10186
|
-
* event: "CREATE"
|
|
10187
|
-
* },
|
|
10188
|
-
* scriptRef: {
|
|
10189
|
-
* name: "notify-assignee",
|
|
10190
|
-
* version: "3"
|
|
10191
|
-
* }
|
|
10192
|
-
* }
|
|
10778
|
+
* body: {}
|
|
10193
10779
|
* })
|
|
10194
10780
|
*/
|
|
10195
10781
|
updateTrigger(request, requestOptions) {
|
|
@@ -10314,6 +10900,9 @@ var VectrosClient = class {
|
|
|
10314
10900
|
get auth() {
|
|
10315
10901
|
return this._auth ?? (this._auth = new AuthClient(this._options));
|
|
10316
10902
|
}
|
|
10903
|
+
get agents() {
|
|
10904
|
+
return this._agents ?? (this._agents = new AgentsClient(this._options));
|
|
10905
|
+
}
|
|
10317
10906
|
get documents() {
|
|
10318
10907
|
return this._documents ?? (this._documents = new DocumentsClient(this._options));
|
|
10319
10908
|
}
|
|
@@ -10384,7 +10973,7 @@ import {
|
|
|
10384
10973
|
ListToolsRequestSchema,
|
|
10385
10974
|
ReadResourceRequestSchema
|
|
10386
10975
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
10387
|
-
import { z as
|
|
10976
|
+
import { z as z28 } from "zod";
|
|
10388
10977
|
|
|
10389
10978
|
// src/auth.ts
|
|
10390
10979
|
var KEY_RE = /^(sk|ssk|st)_(live|test)_/;
|
|
@@ -10428,8 +11017,8 @@ function warnOnSuboptimalKey(key, log) {
|
|
|
10428
11017
|
|
|
10429
11018
|
// src/build-info.ts
|
|
10430
11019
|
var BUILD_INFO = {
|
|
10431
|
-
mcpServer: true ? "0.
|
|
10432
|
-
sdk: true ? "0.
|
|
11020
|
+
mcpServer: true ? "0.19.0" : "dev",
|
|
11021
|
+
sdk: true ? "0.49.0" : "dev"
|
|
10433
11022
|
};
|
|
10434
11023
|
function formatBuildInfo() {
|
|
10435
11024
|
return `vectros-mcp-server ${BUILD_INFO.mcpServer} (sdk ${BUILD_INFO.sdk})`;
|
|
@@ -10688,6 +11277,11 @@ ${detail}${trailer}`
|
|
|
10688
11277
|
};
|
|
10689
11278
|
}
|
|
10690
11279
|
|
|
11280
|
+
// src/tools/limits.ts
|
|
11281
|
+
var MAX_OWNERSHIP_SCOPES = 2;
|
|
11282
|
+
var MAX_SCOPE_FILTERS = 16;
|
|
11283
|
+
var MAX_CONTENT_TYPES = 2;
|
|
11284
|
+
|
|
10691
11285
|
// src/tools/hybrid_search.ts
|
|
10692
11286
|
var MCP_DEFAULT_LIMIT = 3;
|
|
10693
11287
|
var MCP_MAX_LIMIT = 50;
|
|
@@ -10730,11 +11324,11 @@ var inputSchema = {
|
|
|
10730
11324
|
folderId: z.string().optional().describe("Scope to content in this EXACT folder (Vectros folder id)."),
|
|
10731
11325
|
rootFolderId: z.string().optional().describe("Scope to content under this folder AND all its descendants (subtree-root folder id)."),
|
|
10732
11326
|
// Content narrowing.
|
|
10733
|
-
contentTypes: z.array(z.enum(["documents", "records"])).optional().describe('Narrow to content types. ["documents"] or ["records"]; omit for unified (both).'),
|
|
11327
|
+
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).'),
|
|
10734
11328
|
typeName: z.string().optional().describe(
|
|
10735
11329
|
'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.'
|
|
10736
11330
|
),
|
|
10737
|
-
filters: z.record(z.unknown()).optional().describe(
|
|
11331
|
+
filters: z.record(z.string(), z.unknown()).optional().describe(
|
|
10738
11332
|
'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}}.'
|
|
10739
11333
|
),
|
|
10740
11334
|
// Ownership.
|
|
@@ -10742,7 +11336,7 @@ var inputSchema = {
|
|
|
10742
11336
|
scope: z.string().optional().describe(
|
|
10743
11337
|
'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.'
|
|
10744
11338
|
),
|
|
10745
|
-
scopeFilters: z.array(z.string()).min(1, "scopeFilters must name at least one dimension when supplied").optional().describe(
|
|
11339
|
+
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(
|
|
10746
11340
|
'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.'
|
|
10747
11341
|
),
|
|
10748
11342
|
// Date window.
|
|
@@ -11263,7 +11857,7 @@ var inputSchema5 = {
|
|
|
11263
11857
|
status: z5.string().optional().describe("Record lifecycle status. Defaults to ACTIVE server-side."),
|
|
11264
11858
|
folderId: z5.string().optional().describe("Group this record into a folder."),
|
|
11265
11859
|
userId: z5.string().optional().describe("Owning user id."),
|
|
11266
|
-
scopes: z5.array(z5.string()).optional().describe(
|
|
11860
|
+
scopes: z5.array(z5.string()).max(MAX_OWNERSHIP_SCOPES, `scopes accepts at most ${MAX_OWNERSHIP_SCOPES} entries`).optional().describe(
|
|
11267
11861
|
'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.'
|
|
11268
11862
|
)
|
|
11269
11863
|
};
|
|
@@ -11321,7 +11915,7 @@ var itemSchema = z6.strictObject({
|
|
|
11321
11915
|
status: z6.string().optional().describe("Record lifecycle status. Defaults to ACTIVE server-side."),
|
|
11322
11916
|
folderId: z6.string().optional().describe("Group this record into a folder."),
|
|
11323
11917
|
userId: z6.string().optional().describe("Owning user id."),
|
|
11324
|
-
scopes: z6.array(z6.string()).optional().describe(
|
|
11918
|
+
scopes: z6.array(z6.string()).max(MAX_OWNERSHIP_SCOPES, `scopes accepts at most ${MAX_OWNERSHIP_SCOPES} entries`).optional().describe(
|
|
11325
11919
|
"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."
|
|
11326
11920
|
)
|
|
11327
11921
|
});
|
|
@@ -11478,7 +12072,7 @@ import { z as z10 } from "zod";
|
|
|
11478
12072
|
// src/tools/provider-alias.ts
|
|
11479
12073
|
import { z as z9 } from "zod";
|
|
11480
12074
|
var providerAliasInput = z9.string().min(1, "providerAlias must be non-empty when supplied").optional().describe(
|
|
11481
|
-
"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` (
|
|
12075
|
+
"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."
|
|
11482
12076
|
);
|
|
11483
12077
|
|
|
11484
12078
|
// src/tools/rag_ask.ts
|
|
@@ -11505,14 +12099,14 @@ var inputSchema9 = {
|
|
|
11505
12099
|
scope: z10.string().optional().describe(
|
|
11506
12100
|
'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.'
|
|
11507
12101
|
),
|
|
11508
|
-
scopeFilters: z10.array(z10.string()).min(1, "scopeFilters must name at least one dimension when supplied").optional().describe(
|
|
12102
|
+
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(
|
|
11509
12103
|
'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`.'
|
|
11510
12104
|
),
|
|
11511
12105
|
folderId: z10.string().optional().describe("Restrict retrieval to this exact folder."),
|
|
11512
12106
|
rootFolderId: z10.string().optional().describe("Restrict retrieval to this folder and all its descendants."),
|
|
11513
12107
|
typeName: z10.string().optional().describe("Restrict record retrieval to this schema type."),
|
|
11514
|
-
contentTypes: z10.array(z10.enum(["documents", "records"])).optional().describe('Narrow retrieval to content types. ["documents"] or ["records"]; omit for both.'),
|
|
11515
|
-
filters: z10.record(z10.unknown()).optional().describe(
|
|
12108
|
+
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.'),
|
|
12109
|
+
filters: z10.record(z10.string(), z10.unknown()).optional().describe(
|
|
11516
12110
|
'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"}.'
|
|
11517
12111
|
),
|
|
11518
12112
|
createdAfter: z10.string().optional().describe(
|
|
@@ -11787,7 +12381,7 @@ function isNotAvailable(err) {
|
|
|
11787
12381
|
var documentGet = ({ client, log }) => ({
|
|
11788
12382
|
name: "document_get",
|
|
11789
12383
|
title: "Get document metadata (and optionally text)",
|
|
11790
|
-
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.",
|
|
12384
|
+
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.",
|
|
11791
12385
|
inputSchema: inputSchema12,
|
|
11792
12386
|
// A pure read — never creates, modifies, or deletes anything server-side.
|
|
11793
12387
|
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },
|
|
@@ -11813,7 +12407,7 @@ var documentGet = ({ client, log }) => ({
|
|
|
11813
12407
|
if (isNotAvailable(textErr)) {
|
|
11814
12408
|
log.debug(
|
|
11815
12409
|
{ tool: "document_get", id },
|
|
11816
|
-
"document_get text unavailable (not retained
|
|
12410
|
+
"document_get text unavailable (not retained, or no text could be extracted from the file)"
|
|
11817
12411
|
);
|
|
11818
12412
|
extra = { ...extra, textAvailable: false };
|
|
11819
12413
|
} else {
|
|
@@ -11866,10 +12460,12 @@ var inputSchema13 = {
|
|
|
11866
12460
|
to: z14.string().optional().describe("Lookup mode (range): inclusive upper bound; requires `from`."),
|
|
11867
12461
|
prefix: z14.string().optional().describe("Lookup mode (prefix): match values starting with this. Range-enabled string fields only."),
|
|
11868
12462
|
order: z14.enum(["asc", "desc"]).optional().describe(
|
|
11869
|
-
"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).
|
|
12463
|
+
"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`."
|
|
11870
12464
|
),
|
|
11871
|
-
type: z14.string().
|
|
11872
|
-
|
|
12465
|
+
type: z14.string().min(1, "type must be non-empty: omit it to list every type").optional().describe(
|
|
12466
|
+
"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."
|
|
12467
|
+
),
|
|
12468
|
+
// List-mode args (`type` above applies to both modes):
|
|
11873
12469
|
folderId: z14.string().optional().describe("List mode: only documents in this folder (Vectros folder id)."),
|
|
11874
12470
|
userId: z14.string().optional().describe("List mode: scope to documents owned by this user."),
|
|
11875
12471
|
scope: z14.string().optional().describe(
|
|
@@ -11883,7 +12479,7 @@ var inputSchema13 = {
|
|
|
11883
12479
|
var documentQuery = ({ client, log }) => ({
|
|
11884
12480
|
name: "document_query",
|
|
11885
12481
|
title: "Document query (list or lookup)",
|
|
11886
|
-
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.",
|
|
12482
|
+
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.",
|
|
11887
12483
|
inputSchema: inputSchema13,
|
|
11888
12484
|
// A pure read — never creates, modifies, or deletes anything server-side.
|
|
11889
12485
|
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },
|
|
@@ -11942,7 +12538,19 @@ var documentQuery = ({ client, log }) => ({
|
|
|
11942
12538
|
"document_query lookup ok"
|
|
11943
12539
|
);
|
|
11944
12540
|
} else {
|
|
12541
|
+
const strayLookupArgs = ["value", "from", "to", "prefix", "order"].filter(
|
|
12542
|
+
(k) => args[k] !== void 0
|
|
12543
|
+
);
|
|
12544
|
+
if (strayLookupArgs.length > 0) {
|
|
12545
|
+
return toolError(
|
|
12546
|
+
"document_query",
|
|
12547
|
+
new Error(
|
|
12548
|
+
`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'.`
|
|
12549
|
+
)
|
|
12550
|
+
);
|
|
12551
|
+
}
|
|
11945
12552
|
page = await client.documents.listDocuments({
|
|
12553
|
+
type,
|
|
11946
12554
|
folderId: args.folderId,
|
|
11947
12555
|
userId: args.userId,
|
|
11948
12556
|
scope: args.scope,
|
|
@@ -11950,7 +12558,7 @@ var documentQuery = ({ client, log }) => ({
|
|
|
11950
12558
|
limit
|
|
11951
12559
|
});
|
|
11952
12560
|
log.debug(
|
|
11953
|
-
{ tool: "document_query", mode: "list", limit, returned: pageItems(page).length },
|
|
12561
|
+
{ tool: "document_query", mode: "list", type, limit, returned: pageItems(page).length },
|
|
11954
12562
|
"document_query list ok"
|
|
11955
12563
|
);
|
|
11956
12564
|
}
|
|
@@ -11985,7 +12593,7 @@ var inputSchema14 = {
|
|
|
11985
12593
|
"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."
|
|
11986
12594
|
),
|
|
11987
12595
|
userId: z15.string().optional().describe("Reassign the owning user (Vectros UUID)."),
|
|
11988
|
-
scopes: z15.array(z15.string()).optional().describe(
|
|
12596
|
+
scopes: z15.array(z15.string()).max(MAX_OWNERSHIP_SCOPES, `scopes accepts at most ${MAX_OWNERSHIP_SCOPES} entries`).optional().describe(
|
|
11989
12597
|
'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).'
|
|
11990
12598
|
),
|
|
11991
12599
|
expectedVersion: z15.number().int().optional().describe(
|
|
@@ -12129,7 +12737,7 @@ var inputSchema17 = {
|
|
|
12129
12737
|
"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."
|
|
12130
12738
|
),
|
|
12131
12739
|
userId: z18.string().optional().describe("Owning user (Vectros UUID)."),
|
|
12132
|
-
scopes: z18.array(z18.string()).optional().describe(
|
|
12740
|
+
scopes: z18.array(z18.string()).max(MAX_OWNERSHIP_SCOPES, `scopes accepts at most ${MAX_OWNERSHIP_SCOPES} entries`).optional().describe(
|
|
12133
12741
|
'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.'
|
|
12134
12742
|
)
|
|
12135
12743
|
};
|
|
@@ -12175,7 +12783,7 @@ var inputSchema18 = {
|
|
|
12175
12783
|
name: z19.string().optional().describe("New folder name. Omit to keep the current name."),
|
|
12176
12784
|
description: z19.string().optional().describe("New description. Omit to leave unchanged."),
|
|
12177
12785
|
userId: z19.string().optional().describe("Reassign the owning user (Vectros UUID)."),
|
|
12178
|
-
scopes: z19.array(z19.string()).optional().describe(
|
|
12786
|
+
scopes: z19.array(z19.string()).max(MAX_OWNERSHIP_SCOPES, `scopes accepts at most ${MAX_OWNERSHIP_SCOPES} entries`).optional().describe(
|
|
12179
12787
|
'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).'
|
|
12180
12788
|
),
|
|
12181
12789
|
expectedVersion: z19.number().int().optional().describe(
|
|
@@ -12224,7 +12832,7 @@ var inputSchema19 = {
|
|
|
12224
12832
|
var folderDelete = ({ client, log }) => ({
|
|
12225
12833
|
name: "folder_delete",
|
|
12226
12834
|
title: "Delete a folder",
|
|
12227
|
-
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
|
|
12835
|
+
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.',
|
|
12228
12836
|
inputSchema: inputSchema19,
|
|
12229
12837
|
// Deletes. Idempotent in the standard REST sense: the end state ("this id no longer
|
|
12230
12838
|
// resolves") is the same whether this is the first delete or a repeat of one.
|
|
@@ -12377,14 +12985,14 @@ var inputSchema21 = {
|
|
|
12377
12985
|
// Common (both modes):
|
|
12378
12986
|
folderId: z21.string().optional().describe("Optional folder to ingest into. Default: tenant root."),
|
|
12379
12987
|
userId: z21.string().optional().describe("Owning user ID. Optional."),
|
|
12380
|
-
scopes: z21.array(z21.string()).optional().describe(
|
|
12988
|
+
scopes: z21.array(z21.string()).max(MAX_OWNERSHIP_SCOPES, `scopes accepts at most ${MAX_OWNERSHIP_SCOPES} entries`).optional().describe(
|
|
12381
12989
|
"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."
|
|
12382
12990
|
)
|
|
12383
12991
|
};
|
|
12384
12992
|
var documentIngest = ({ client, log, transport, ingestRoot }) => ({
|
|
12385
12993
|
name: "document_ingest",
|
|
12386
12994
|
title: "Ingest a new document (text body or file upload)",
|
|
12387
|
-
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`.",
|
|
12995
|
+
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`.",
|
|
12388
12996
|
inputSchema: inputSchema21,
|
|
12389
12997
|
// Creates by default, idempotent ONLY when the caller supplies `externalId` (optional,
|
|
12390
12998
|
// per the doc comment above) — re-ingest then returns the existing document rather than
|
|
@@ -12526,7 +13134,7 @@ var documentIngest = ({ client, log, transport, ingestRoot }) => ({
|
|
|
12526
13134
|
"document_ingest file ok"
|
|
12527
13135
|
);
|
|
12528
13136
|
const uploadCreated = upload?.created;
|
|
12529
|
-
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.";
|
|
13137
|
+
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.";
|
|
12530
13138
|
return {
|
|
12531
13139
|
content: [
|
|
12532
13140
|
{
|
|
@@ -12699,6 +13307,365 @@ var versionHistory = ({ client, log }) => ({
|
|
|
12699
13307
|
});
|
|
12700
13308
|
var version_history_default = versionHistory;
|
|
12701
13309
|
|
|
13310
|
+
// src/tools/agent_list.ts
|
|
13311
|
+
import { z as z24 } from "zod";
|
|
13312
|
+
var MCP_DEFAULT_LIMIT6 = 10;
|
|
13313
|
+
var MCP_MAX_LIMIT6 = 100;
|
|
13314
|
+
function toAgentSummary(agent) {
|
|
13315
|
+
return {
|
|
13316
|
+
id: agent.id,
|
|
13317
|
+
name: agent.name,
|
|
13318
|
+
description: agent.description,
|
|
13319
|
+
latestVersion: agent.latestVersion,
|
|
13320
|
+
status: agent.status
|
|
13321
|
+
};
|
|
13322
|
+
}
|
|
13323
|
+
var inputSchema24 = {
|
|
13324
|
+
includeRetired: z24.boolean().optional().describe("Also list retired and purged agents (neither can be run). Default false."),
|
|
13325
|
+
startFrom: z24.string().optional().describe("Pagination cursor: pass the `nextCursor` from the previous page to fetch the next."),
|
|
13326
|
+
limit: z24.number().int().min(1).max(MCP_MAX_LIMIT6).optional().describe(`Max agents per page. Default ${MCP_DEFAULT_LIMIT6}, max ${MCP_MAX_LIMIT6}.`)
|
|
13327
|
+
};
|
|
13328
|
+
var agentList = ({ client, log }) => ({
|
|
13329
|
+
name: "agent_list",
|
|
13330
|
+
title: "List agents",
|
|
13331
|
+
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.",
|
|
13332
|
+
inputSchema: inputSchema24,
|
|
13333
|
+
// A pure read: it lists definitions and changes nothing.
|
|
13334
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },
|
|
13335
|
+
handler: async (args) => {
|
|
13336
|
+
const limit = args.limit ?? MCP_DEFAULT_LIMIT6;
|
|
13337
|
+
try {
|
|
13338
|
+
const page = await client.agents.listAgents({
|
|
13339
|
+
includeRetired: args.includeRetired,
|
|
13340
|
+
startFrom: args.startFrom,
|
|
13341
|
+
limit
|
|
13342
|
+
});
|
|
13343
|
+
const data = (page.data ?? []).map(toAgentSummary);
|
|
13344
|
+
const nextCursor = page.nextCursor ?? null;
|
|
13345
|
+
log.debug({ tool: "agent_list", limit, returned: data.length }, "agent_list ok");
|
|
13346
|
+
return { content: [{ type: "text", text: JSON.stringify({ data, nextCursor }, null, 2) }] };
|
|
13347
|
+
} catch (err) {
|
|
13348
|
+
log.warn({ tool: "agent_list", err: String(err) }, "agent_list failed");
|
|
13349
|
+
return toolError("agent_list", err);
|
|
13350
|
+
}
|
|
13351
|
+
}
|
|
13352
|
+
});
|
|
13353
|
+
var agent_list_default = agentList;
|
|
13354
|
+
|
|
13355
|
+
// src/tools/agent_run.ts
|
|
13356
|
+
import { randomUUID } from "crypto";
|
|
13357
|
+
import { z as z25 } from "zod";
|
|
13358
|
+
|
|
13359
|
+
// src/run-stream.ts
|
|
13360
|
+
var TEXT_PROGRESS_CHARS = 256;
|
|
13361
|
+
var HEARTBEAT_MS = 15e3;
|
|
13362
|
+
var TERMINAL_STATUS = {
|
|
13363
|
+
"run.completed": "COMPLETED",
|
|
13364
|
+
"run.failed": "FAILED",
|
|
13365
|
+
"run.cancelled": "CANCELLED"
|
|
13366
|
+
};
|
|
13367
|
+
function str(v) {
|
|
13368
|
+
return typeof v === "string" && v.length > 0 ? v : void 0;
|
|
13369
|
+
}
|
|
13370
|
+
function num(v) {
|
|
13371
|
+
return typeof v === "number" && Number.isFinite(v) ? v : void 0;
|
|
13372
|
+
}
|
|
13373
|
+
async function consumeRunStream(stream, initialRunId, onProgress, heartbeatMs = HEARTBEAT_MS) {
|
|
13374
|
+
const result = {
|
|
13375
|
+
runId: initialRunId,
|
|
13376
|
+
terminal: false,
|
|
13377
|
+
status: "UNKNOWN",
|
|
13378
|
+
text: "",
|
|
13379
|
+
toolCalls: []
|
|
13380
|
+
};
|
|
13381
|
+
const blocks = [];
|
|
13382
|
+
let pending = "";
|
|
13383
|
+
let unsentChars = 0;
|
|
13384
|
+
const emit = async (message) => {
|
|
13385
|
+
if (!onProgress) return;
|
|
13386
|
+
try {
|
|
13387
|
+
await onProgress(message);
|
|
13388
|
+
} catch {
|
|
13389
|
+
}
|
|
13390
|
+
};
|
|
13391
|
+
let heartbeat;
|
|
13392
|
+
let lastEventAt = Date.now();
|
|
13393
|
+
if (onProgress) {
|
|
13394
|
+
heartbeat = setInterval(() => {
|
|
13395
|
+
if (Date.now() - lastEventAt >= heartbeatMs) {
|
|
13396
|
+
lastEventAt = Date.now();
|
|
13397
|
+
void emit("run still working");
|
|
13398
|
+
}
|
|
13399
|
+
}, Math.max(1, Math.floor(heartbeatMs / 3)));
|
|
13400
|
+
heartbeat.unref?.();
|
|
13401
|
+
}
|
|
13402
|
+
try {
|
|
13403
|
+
for await (const raw of stream) {
|
|
13404
|
+
lastEventAt = Date.now();
|
|
13405
|
+
if (!raw || typeof raw !== "object") continue;
|
|
13406
|
+
const ev = raw;
|
|
13407
|
+
result.runId ??= str(ev.runId);
|
|
13408
|
+
const type = typeof ev.type === "string" ? ev.type : "";
|
|
13409
|
+
switch (type) {
|
|
13410
|
+
case "run.started":
|
|
13411
|
+
result.agentId = str(ev.agentId) ?? result.agentId;
|
|
13412
|
+
result.agentVersion = num(ev.agentVersion) ?? result.agentVersion;
|
|
13413
|
+
await emit("run started");
|
|
13414
|
+
break;
|
|
13415
|
+
case "message.delta": {
|
|
13416
|
+
const piece = typeof ev.text === "string" ? ev.text : "";
|
|
13417
|
+
pending += piece;
|
|
13418
|
+
unsentChars += piece.length;
|
|
13419
|
+
if (unsentChars >= TEXT_PROGRESS_CHARS) {
|
|
13420
|
+
unsentChars = 0;
|
|
13421
|
+
await emit(`answer: ${blocks.join("\n\n").length + pending.length} characters so far`);
|
|
13422
|
+
}
|
|
13423
|
+
break;
|
|
13424
|
+
}
|
|
13425
|
+
case "message.completed": {
|
|
13426
|
+
const full = str(ev.text) ?? pending;
|
|
13427
|
+
if (full.length > 0) blocks.push(full);
|
|
13428
|
+
pending = "";
|
|
13429
|
+
unsentChars = 0;
|
|
13430
|
+
await emit("model call completed");
|
|
13431
|
+
break;
|
|
13432
|
+
}
|
|
13433
|
+
case "tool.completed": {
|
|
13434
|
+
const call = {
|
|
13435
|
+
tool: str(ev.tool),
|
|
13436
|
+
outcome: str(ev.outcome),
|
|
13437
|
+
code: str(ev.code)
|
|
13438
|
+
};
|
|
13439
|
+
result.toolCalls.push(call);
|
|
13440
|
+
await emit(`tool ${call.tool ?? "call"}: ${call.outcome ?? "ended"}`);
|
|
13441
|
+
break;
|
|
13442
|
+
}
|
|
13443
|
+
default:
|
|
13444
|
+
break;
|
|
13445
|
+
}
|
|
13446
|
+
if (ev.terminal === true || Object.hasOwn(TERMINAL_STATUS, type)) {
|
|
13447
|
+
result.terminal = true;
|
|
13448
|
+
result.status = str(ev.status) ?? TERMINAL_STATUS[type] ?? "ENDED";
|
|
13449
|
+
result.reason = str(ev.reason);
|
|
13450
|
+
result.errorCode = str(ev.errorCode);
|
|
13451
|
+
if (typeof ev.settled === "boolean" || ev.inferenceBalanceCentsChargedMilli !== void 0 || ev.inferenceBalanceCentsRefundedMilli !== void 0) {
|
|
13452
|
+
result.charged = {
|
|
13453
|
+
settled: typeof ev.settled === "boolean" ? ev.settled : void 0,
|
|
13454
|
+
inferenceBalanceCentsChargedMilli: num(ev.inferenceBalanceCentsChargedMilli),
|
|
13455
|
+
inferenceBalanceCentsRefundedMilli: num(ev.inferenceBalanceCentsRefundedMilli)
|
|
13456
|
+
};
|
|
13457
|
+
}
|
|
13458
|
+
break;
|
|
13459
|
+
}
|
|
13460
|
+
}
|
|
13461
|
+
} catch (err) {
|
|
13462
|
+
result.streamError = err instanceof Error ? err.message : String(err);
|
|
13463
|
+
} finally {
|
|
13464
|
+
if (heartbeat) clearInterval(heartbeat);
|
|
13465
|
+
}
|
|
13466
|
+
if (pending.length > 0) blocks.push(pending);
|
|
13467
|
+
result.text = blocks.join("\n\n");
|
|
13468
|
+
return result;
|
|
13469
|
+
}
|
|
13470
|
+
|
|
13471
|
+
// src/tools/agent_run.ts
|
|
13472
|
+
var RUN_ID_HEADER = "x-vectros-run-id";
|
|
13473
|
+
var MAX_INPUT_CHARS = 1e5;
|
|
13474
|
+
var MAX_INPUT_BYTES = 24e4;
|
|
13475
|
+
function encodedInputBytes(v) {
|
|
13476
|
+
return Buffer.byteLength(JSON.stringify(v), "utf8");
|
|
13477
|
+
}
|
|
13478
|
+
var TERMINAL_EVENT_TYPES = /* @__PURE__ */ new Set(["run.completed", "run.failed", "run.cancelled"]);
|
|
13479
|
+
var ENDED_STATUSES = /* @__PURE__ */ new Set(["COMPLETED", "FAILED", "CANCELLED", "EXPIRED"]);
|
|
13480
|
+
var inputSchema25 = {
|
|
13481
|
+
agentId: z25.string().min(1, "agentId must be non-empty").describe("The agent to run: an `id` from agent_list."),
|
|
13482
|
+
input: z25.string().min(1, "input must be non-empty").max(MAX_INPUT_CHARS, `input accepts at most ${MAX_INPUT_CHARS} characters`).refine(
|
|
13483
|
+
(v) => encodedInputBytes(v) <= MAX_INPUT_BYTES,
|
|
13484
|
+
`input accepts at most ${MAX_INPUT_BYTES} bytes as sent (a JSON string in UTF-8)`
|
|
13485
|
+
).describe(
|
|
13486
|
+
`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).`
|
|
13487
|
+
),
|
|
13488
|
+
agentVersion: z25.number().int().min(1).optional().describe("The agent version to run. Default: its latest version."),
|
|
13489
|
+
maxInferenceCents: z25.number().int().min(1).optional().describe(
|
|
13490
|
+
"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`."
|
|
13491
|
+
),
|
|
13492
|
+
readOnly: z25.boolean().optional().describe("When true, every tool call that would change data is refused in this run. Default false."),
|
|
13493
|
+
idempotencyKey: z25.string().regex(/^[A-Za-z0-9._:-]{1,128}$/, "idempotencyKey is 1 to 128 letters, digits, `.`, `_`, `:` or `-`").optional().describe(
|
|
13494
|
+
"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."
|
|
13495
|
+
)
|
|
13496
|
+
};
|
|
13497
|
+
var agentRun = ({ client, log }) => ({
|
|
13498
|
+
name: "agent_run",
|
|
13499
|
+
title: "Run an agent",
|
|
13500
|
+
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.",
|
|
13501
|
+
inputSchema: inputSchema25,
|
|
13502
|
+
// Not a read: a run is billed, and its tool calls may create, change or delete data with the
|
|
13503
|
+
// caller's permissions, so a host should confirm it. Not idempotent: each call is a new paid run
|
|
13504
|
+
// unless the same idempotencyKey is passed again.
|
|
13505
|
+
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
|
|
13506
|
+
handler: async (args, extra) => {
|
|
13507
|
+
const agentId = args.agentId;
|
|
13508
|
+
const maxInferenceCents = args.maxInferenceCents;
|
|
13509
|
+
const idempotencyKey = args.idempotencyKey ?? randomUUID();
|
|
13510
|
+
const request = {
|
|
13511
|
+
"Idempotency-Key": idempotencyKey,
|
|
13512
|
+
agentId,
|
|
13513
|
+
agentVersion: args.agentVersion,
|
|
13514
|
+
input: { text: args.input },
|
|
13515
|
+
budget: maxInferenceCents !== void 0 ? { maxInferenceCents } : void 0,
|
|
13516
|
+
readOnly: args.readOnly
|
|
13517
|
+
};
|
|
13518
|
+
const progressToken = extra._meta?.progressToken;
|
|
13519
|
+
let progressCount = 0;
|
|
13520
|
+
const onProgress = progressToken !== void 0 && extra.sendNotification ? async (message) => {
|
|
13521
|
+
progressCount += 1;
|
|
13522
|
+
await extra.sendNotification({
|
|
13523
|
+
method: "notifications/progress",
|
|
13524
|
+
params: { progressToken, progress: progressCount, message }
|
|
13525
|
+
});
|
|
13526
|
+
} : void 0;
|
|
13527
|
+
const streamAbort = new AbortController();
|
|
13528
|
+
const callSignal = extra.signal;
|
|
13529
|
+
let knownRunId;
|
|
13530
|
+
let headersReceived = false;
|
|
13531
|
+
let cancelRequested = false;
|
|
13532
|
+
let cancelSent = false;
|
|
13533
|
+
let runEnded = false;
|
|
13534
|
+
const sendCancel = () => {
|
|
13535
|
+
if (!cancelRequested || cancelSent || !knownRunId || runEnded) return;
|
|
13536
|
+
cancelSent = true;
|
|
13537
|
+
const id = knownRunId;
|
|
13538
|
+
client.agents.cancelRun({ id }).then(
|
|
13539
|
+
() => log.info({ tool: "agent_run", runId: id }, "agent_run cancelled by the client"),
|
|
13540
|
+
(err) => log.warn({ tool: "agent_run", runId: id, err: String(err) }, "agent_run cancel failed")
|
|
13541
|
+
);
|
|
13542
|
+
};
|
|
13543
|
+
const cancelIfNamed = () => {
|
|
13544
|
+
if (!cancelRequested || !headersReceived || !knownRunId) return;
|
|
13545
|
+
sendCancel();
|
|
13546
|
+
streamAbort.abort();
|
|
13547
|
+
};
|
|
13548
|
+
const onCancel = () => {
|
|
13549
|
+
cancelRequested = true;
|
|
13550
|
+
cancelIfNamed();
|
|
13551
|
+
};
|
|
13552
|
+
if (callSignal?.aborted) {
|
|
13553
|
+
return toolError("agent_run", new Error("The call was cancelled before the run started."));
|
|
13554
|
+
}
|
|
13555
|
+
callSignal?.addEventListener("abort", onCancel, { once: true });
|
|
13556
|
+
try {
|
|
13557
|
+
const { data: stream, rawResponse } = await client.agents.createRun(request, { abortSignal: streamAbort.signal }).withRawResponse();
|
|
13558
|
+
headersReceived = true;
|
|
13559
|
+
knownRunId = rawResponse.headers.get(RUN_ID_HEADER) ?? void 0;
|
|
13560
|
+
cancelIfNamed();
|
|
13561
|
+
const naming = async function* () {
|
|
13562
|
+
for await (const ev of stream) {
|
|
13563
|
+
if (!knownRunId && ev && typeof ev === "object") {
|
|
13564
|
+
const id = ev.runId;
|
|
13565
|
+
if (typeof id === "string" && id.length > 0) {
|
|
13566
|
+
knownRunId = id;
|
|
13567
|
+
cancelIfNamed();
|
|
13568
|
+
}
|
|
13569
|
+
}
|
|
13570
|
+
if (ev && typeof ev === "object") {
|
|
13571
|
+
const e = ev;
|
|
13572
|
+
if (e.terminal === true || typeof e.type === "string" && TERMINAL_EVENT_TYPES.has(e.type)) runEnded = true;
|
|
13573
|
+
}
|
|
13574
|
+
yield ev;
|
|
13575
|
+
}
|
|
13576
|
+
};
|
|
13577
|
+
const run = await consumeRunStream(naming(), knownRunId, onProgress);
|
|
13578
|
+
knownRunId ??= run.runId;
|
|
13579
|
+
if (run.terminal) runEnded = true;
|
|
13580
|
+
sendCancel();
|
|
13581
|
+
log.debug(
|
|
13582
|
+
{
|
|
13583
|
+
tool: "agent_run",
|
|
13584
|
+
runId: run.runId,
|
|
13585
|
+
status: run.status,
|
|
13586
|
+
terminal: run.terminal,
|
|
13587
|
+
toolCalls: run.toolCalls.length,
|
|
13588
|
+
textLength: run.text.length
|
|
13589
|
+
},
|
|
13590
|
+
"agent_run ok"
|
|
13591
|
+
);
|
|
13592
|
+
const body = {
|
|
13593
|
+
runId: run.runId,
|
|
13594
|
+
agentId: run.agentId ?? agentId,
|
|
13595
|
+
agentVersion: run.agentVersion,
|
|
13596
|
+
status: run.status,
|
|
13597
|
+
terminal: run.terminal,
|
|
13598
|
+
reason: run.reason,
|
|
13599
|
+
errorCode: run.errorCode,
|
|
13600
|
+
text: run.text,
|
|
13601
|
+
toolCalls: run.toolCalls,
|
|
13602
|
+
charged: run.charged
|
|
13603
|
+
};
|
|
13604
|
+
if (!run.terminal) {
|
|
13605
|
+
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).";
|
|
13606
|
+
}
|
|
13607
|
+
return { content: [{ type: "text", text: JSON.stringify(body, null, 2) }] };
|
|
13608
|
+
} catch (err) {
|
|
13609
|
+
const e = err;
|
|
13610
|
+
if (e?.body?.errorCode === "IDEMPOTENCY_IN_PROGRESS") {
|
|
13611
|
+
const runId = (typeof e.body.runId === "string" ? e.body.runId : void 0) ?? e.rawResponse?.headers?.get?.(RUN_ID_HEADER) ?? void 0;
|
|
13612
|
+
if (runId) {
|
|
13613
|
+
const status = typeof e.body.status === "string" ? e.body.status : void 0;
|
|
13614
|
+
log.info({ tool: "agent_run", runId }, "agent_run: the idempotency key already started a run");
|
|
13615
|
+
const body = {
|
|
13616
|
+
runId,
|
|
13617
|
+
agentId,
|
|
13618
|
+
status,
|
|
13619
|
+
// The 409 names the run's status at the time; an ended status is final.
|
|
13620
|
+
terminal: status !== void 0 && ENDED_STATUSES.has(status),
|
|
13621
|
+
alreadyStarted: true,
|
|
13622
|
+
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."
|
|
13623
|
+
};
|
|
13624
|
+
return { content: [{ type: "text", text: JSON.stringify(body, null, 2) }] };
|
|
13625
|
+
}
|
|
13626
|
+
}
|
|
13627
|
+
log.warn({ tool: "agent_run", agentId, err: String(err) }, "agent_run failed");
|
|
13628
|
+
const result = toolError("agent_run", err);
|
|
13629
|
+
const statusCode = err?.statusCode;
|
|
13630
|
+
if (typeof statusCode !== "number" || statusCode === 408 || statusCode >= 500) {
|
|
13631
|
+
result.content[0].text += `
|
|
13632
|
+
idempotencyKey: ${idempotencyKey}
|
|
13633
|
+
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.)" : "");
|
|
13634
|
+
}
|
|
13635
|
+
return result;
|
|
13636
|
+
} finally {
|
|
13637
|
+
callSignal?.removeEventListener("abort", onCancel);
|
|
13638
|
+
}
|
|
13639
|
+
}
|
|
13640
|
+
});
|
|
13641
|
+
var agent_run_default = agentRun;
|
|
13642
|
+
|
|
13643
|
+
// src/tools/run_get.ts
|
|
13644
|
+
import { z as z26 } from "zod";
|
|
13645
|
+
var inputSchema26 = {
|
|
13646
|
+
runId: z26.string().min(1, "runId must be non-empty").describe("The run id agent_run returned (`runId`).")
|
|
13647
|
+
};
|
|
13648
|
+
var runGet = ({ client, log }) => ({
|
|
13649
|
+
name: "run_get",
|
|
13650
|
+
title: "Get an agent run",
|
|
13651
|
+
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.",
|
|
13652
|
+
inputSchema: inputSchema26,
|
|
13653
|
+
// A pure read: polling a run does not change it.
|
|
13654
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },
|
|
13655
|
+
handler: async (args) => {
|
|
13656
|
+
const runId = args.runId;
|
|
13657
|
+
try {
|
|
13658
|
+
const run = await client.agents.getRun({ id: runId });
|
|
13659
|
+
log.debug({ tool: "run_get", runId, status: run.status, terminal: run.terminal }, "run_get ok");
|
|
13660
|
+
return { content: [{ type: "text", text: JSON.stringify(run, null, 2) }] };
|
|
13661
|
+
} catch (err) {
|
|
13662
|
+
log.warn({ tool: "run_get", runId, err: String(err) }, "run_get failed");
|
|
13663
|
+
return toolError("run_get", err);
|
|
13664
|
+
}
|
|
13665
|
+
}
|
|
13666
|
+
});
|
|
13667
|
+
var run_get_default = runGet;
|
|
13668
|
+
|
|
12702
13669
|
// src/tools/types.ts
|
|
12703
13670
|
var TOOL_NAMES = [
|
|
12704
13671
|
"hybrid_search",
|
|
@@ -12723,7 +13690,10 @@ var TOOL_NAMES = [
|
|
|
12723
13690
|
"current_identity",
|
|
12724
13691
|
"document_ingest",
|
|
12725
13692
|
"lookup_principal",
|
|
12726
|
-
"version_history"
|
|
13693
|
+
"version_history",
|
|
13694
|
+
"agent_list",
|
|
13695
|
+
"agent_run",
|
|
13696
|
+
"run_get"
|
|
12727
13697
|
];
|
|
12728
13698
|
|
|
12729
13699
|
// src/tools/index.ts
|
|
@@ -12750,7 +13720,10 @@ var ALL_TOOL_FACTORIES = {
|
|
|
12750
13720
|
current_identity: current_identity_default,
|
|
12751
13721
|
document_ingest: document_ingest_default,
|
|
12752
13722
|
lookup_principal: lookup_principal_default,
|
|
12753
|
-
version_history: version_history_default
|
|
13723
|
+
version_history: version_history_default,
|
|
13724
|
+
agent_list: agent_list_default,
|
|
13725
|
+
agent_run: agent_run_default,
|
|
13726
|
+
run_get: run_get_default
|
|
12754
13727
|
};
|
|
12755
13728
|
|
|
12756
13729
|
// src/resources/schemas.ts
|
|
@@ -12793,11 +13766,12 @@ var ALL_RESOURCE_FACTORIES = {
|
|
|
12793
13766
|
};
|
|
12794
13767
|
|
|
12795
13768
|
// src/zod-to-json-schema.ts
|
|
12796
|
-
import { z as
|
|
13769
|
+
import { z as z27 } from "zod";
|
|
12797
13770
|
function zodShapeToJsonSchema(shape) {
|
|
12798
13771
|
const properties = {};
|
|
12799
13772
|
const required = [];
|
|
12800
|
-
for (const [name,
|
|
13773
|
+
for (const [name, entry] of Object.entries(shape)) {
|
|
13774
|
+
const schema = entry;
|
|
12801
13775
|
properties[name] = zodTypeToJsonSchema(schema);
|
|
12802
13776
|
if (!schema.isOptional()) required.push(name);
|
|
12803
13777
|
}
|
|
@@ -12806,43 +13780,45 @@ function zodShapeToJsonSchema(shape) {
|
|
|
12806
13780
|
return out;
|
|
12807
13781
|
}
|
|
12808
13782
|
function zodTypeToJsonSchema(schema) {
|
|
12809
|
-
const
|
|
13783
|
+
const descriptionOf = (s) => s.description;
|
|
13784
|
+
let description = descriptionOf(schema);
|
|
12810
13785
|
let current = schema;
|
|
12811
|
-
while (current instanceof
|
|
13786
|
+
while (current instanceof z27.ZodOptional || current instanceof z27.ZodDefault || current instanceof z27.ZodNullable) {
|
|
12812
13787
|
current = current._def.innerType;
|
|
13788
|
+
description ??= descriptionOf(current);
|
|
12813
13789
|
}
|
|
12814
13790
|
const base = description ? { description } : {};
|
|
12815
|
-
if (current instanceof
|
|
13791
|
+
if (current instanceof z27.ZodString) {
|
|
12816
13792
|
return { ...base, type: "string" };
|
|
12817
13793
|
}
|
|
12818
|
-
if (current instanceof
|
|
13794
|
+
if (current instanceof z27.ZodNumber) {
|
|
12819
13795
|
return { ...base, type: "number" };
|
|
12820
13796
|
}
|
|
12821
|
-
if (current instanceof
|
|
13797
|
+
if (current instanceof z27.ZodBoolean) {
|
|
12822
13798
|
return { ...base, type: "boolean" };
|
|
12823
13799
|
}
|
|
12824
|
-
if (current instanceof
|
|
13800
|
+
if (current instanceof z27.ZodEnum) {
|
|
12825
13801
|
return {
|
|
12826
13802
|
...base,
|
|
12827
13803
|
type: "string",
|
|
12828
13804
|
enum: current.options
|
|
12829
13805
|
};
|
|
12830
13806
|
}
|
|
12831
|
-
if (current instanceof
|
|
13807
|
+
if (current instanceof z27.ZodArray) {
|
|
12832
13808
|
return {
|
|
12833
13809
|
...base,
|
|
12834
13810
|
type: "array",
|
|
12835
13811
|
items: zodTypeToJsonSchema(current.element)
|
|
12836
13812
|
};
|
|
12837
13813
|
}
|
|
12838
|
-
if (current instanceof
|
|
13814
|
+
if (current instanceof z27.ZodObject) {
|
|
12839
13815
|
return {
|
|
12840
13816
|
...base,
|
|
12841
13817
|
...zodShapeToJsonSchema(current.shape)
|
|
12842
13818
|
};
|
|
12843
13819
|
}
|
|
12844
|
-
if (current instanceof
|
|
12845
|
-
const valueType = current.
|
|
13820
|
+
if (current instanceof z27.ZodRecord) {
|
|
13821
|
+
const valueType = current.valueType;
|
|
12846
13822
|
return {
|
|
12847
13823
|
...base,
|
|
12848
13824
|
type: "object",
|
|
@@ -12970,7 +13946,7 @@ var VectrosMCPServer = class {
|
|
|
12970
13946
|
if (!tool) {
|
|
12971
13947
|
result = toolError(req.params.name ?? "unknown", new Error("No such tool."));
|
|
12972
13948
|
} else {
|
|
12973
|
-
const parsed =
|
|
13949
|
+
const parsed = z28.object(tool.inputSchema).strict().safeParse(req.params.arguments ?? {});
|
|
12974
13950
|
if (!parsed.success) {
|
|
12975
13951
|
result = toolError(tool.name, new Error(formatArgError(tool, parsed.error)));
|
|
12976
13952
|
} else {
|
|
@@ -13033,7 +14009,7 @@ var VectrosMCPServer = class {
|
|
|
13033
14009
|
*
|
|
13034
14010
|
* If `validateOnStart` (default true) is enabled, performs a
|
|
13035
14011
|
* GET /v1/ping check BEFORE wiring the transport. On failure,
|
|
13036
|
-
* throws —
|
|
14012
|
+
* throws — your MCP client sees a startup error instead
|
|
13037
14013
|
* of a confusing "tools work but the first call 401s" experience.
|
|
13038
14014
|
*/
|
|
13039
14015
|
async connect(transport) {
|