@mastra/deployer 0.0.1-alpha.25 → 0.0.1-alpha.27
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 +16 -0
- package/dist/index.js +25 -5
- package/dist/server/index.js +333 -28
- package/package.json +2 -2
- package/src/build/bundle.ts +11 -2
- package/src/deploy/base.ts +17 -3
- package/src/server/handlers/vector.ts +149 -0
- package/src/server/index.ts +222 -0
- package/src/server/openapi.json +127 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @mastra/deployer
|
|
2
2
|
|
|
3
|
+
## 0.0.1-alpha.27
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 73d112c: Core and deployer fixes
|
|
8
|
+
- ac8c61a: Mastra server vector operations
|
|
9
|
+
- Updated dependencies [73d112c]
|
|
10
|
+
- @mastra/core@0.1.27-alpha.82
|
|
11
|
+
|
|
12
|
+
## 0.0.1-alpha.26
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [9fb3039]
|
|
17
|
+
- @mastra/core@0.1.27-alpha.81
|
|
18
|
+
|
|
3
19
|
## 0.0.1-alpha.25
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -318,7 +318,7 @@ async function bundle(entry, {
|
|
|
318
318
|
const { start } = buildWorkflow.createRun();
|
|
319
319
|
buildWorkflow.__setLogger(noopLogger);
|
|
320
320
|
try {
|
|
321
|
-
await start({
|
|
321
|
+
const result = await start({
|
|
322
322
|
triggerData: {
|
|
323
323
|
buildName,
|
|
324
324
|
entry,
|
|
@@ -327,8 +327,16 @@ async function bundle(entry, {
|
|
|
327
327
|
devMode
|
|
328
328
|
}
|
|
329
329
|
});
|
|
330
|
+
Object.entries(result.results).forEach(([stepName, stepResult]) => {
|
|
331
|
+
if (stepResult.status !== "success") {
|
|
332
|
+
logger.error(`${stepName}:`, stepResult);
|
|
333
|
+
throw new Error(`Step ${stepName} failed`);
|
|
334
|
+
}
|
|
335
|
+
});
|
|
330
336
|
} catch (error) {
|
|
331
|
-
|
|
337
|
+
if (error instanceof Error) {
|
|
338
|
+
logger.error(error.message, { stack: error.stack, message: error.message, name: error.name });
|
|
339
|
+
}
|
|
332
340
|
process.exit(1);
|
|
333
341
|
}
|
|
334
342
|
}
|
|
@@ -632,9 +640,21 @@ var Deployer = class extends MastraBase {
|
|
|
632
640
|
const dirPath = dir || path2.join(this.projectPath, "src/mastra");
|
|
633
641
|
this.writePackageJson();
|
|
634
642
|
this.writeServerFile();
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
643
|
+
try {
|
|
644
|
+
await this.install();
|
|
645
|
+
} catch (error) {
|
|
646
|
+
this.logger.error("Failed to install dependencies", { error });
|
|
647
|
+
}
|
|
648
|
+
try {
|
|
649
|
+
await this.build({ dir: dirPath, useBanner });
|
|
650
|
+
} catch (error) {
|
|
651
|
+
this.logger.error("Failed to build", { error });
|
|
652
|
+
}
|
|
653
|
+
try {
|
|
654
|
+
await this.buildServer({ playground, swaggerUI });
|
|
655
|
+
} catch (error) {
|
|
656
|
+
this.logger.error("Failed to build server", { error });
|
|
657
|
+
}
|
|
638
658
|
}
|
|
639
659
|
};
|
|
640
660
|
|
package/dist/server/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// ../../node_modules/.pnpm/@hono+node-server@1.13.7_hono@4.6.
|
|
1
|
+
// ../../node_modules/.pnpm/@hono+node-server@1.13.7_hono@4.6.19/node_modules/@hono/node-server/dist/index.mjs
|
|
2
2
|
import { createServer as createServerHTTP } from "http";
|
|
3
3
|
import { Http2ServerRequest } from "http2";
|
|
4
4
|
import { Readable } from "stream";
|
|
@@ -443,7 +443,7 @@ var serve = (options, listeningListener) => {
|
|
|
443
443
|
return server;
|
|
444
444
|
};
|
|
445
445
|
|
|
446
|
-
// ../../node_modules/.pnpm/hono@4.6.
|
|
446
|
+
// ../../node_modules/.pnpm/hono@4.6.19/node_modules/hono/dist/utils/filepath.js
|
|
447
447
|
var getFilePath = (options) => {
|
|
448
448
|
let filename = options.filename;
|
|
449
449
|
const defaultDocument = options.defaultDocument || "index.html";
|
|
@@ -475,7 +475,7 @@ var getFilePathWithoutDefaultDocument = (options) => {
|
|
|
475
475
|
return path;
|
|
476
476
|
};
|
|
477
477
|
|
|
478
|
-
// ../../node_modules/.pnpm/hono@4.6.
|
|
478
|
+
// ../../node_modules/.pnpm/hono@4.6.19/node_modules/hono/dist/utils/mime.js
|
|
479
479
|
var getMimeType = (filename, mimes = baseMimes) => {
|
|
480
480
|
const regexp = /\.([a-zA-Z0-9]+?)$/;
|
|
481
481
|
const match = filename.match(regexp);
|
|
@@ -547,7 +547,7 @@ var _baseMimes = {
|
|
|
547
547
|
};
|
|
548
548
|
var baseMimes = _baseMimes;
|
|
549
549
|
|
|
550
|
-
// ../../node_modules/.pnpm/@hono+node-server@1.13.7_hono@4.6.
|
|
550
|
+
// ../../node_modules/.pnpm/@hono+node-server@1.13.7_hono@4.6.19/node_modules/@hono/node-server/dist/serve-static.mjs
|
|
551
551
|
import { createReadStream, lstatSync } from "fs";
|
|
552
552
|
var COMPRESSIBLE_CONTENT_TYPE_REGEX = /^\s*(?:text\/[^;\s]+|application\/(?:javascript|json|xml|xml-dtd|ecmascript|dart|postscript|rtf|tar|toml|vnd\.dart|vnd\.ms-fontobject|vnd\.ms-opentype|wasm|x-httpd-php|x-javascript|x-ns-proxy-autoconfig|x-sh|x-tar|x-virtualbox-hdd|x-virtualbox-ova|x-virtualbox-ovf|x-virtualbox-vbox|x-virtualbox-vdi|x-virtualbox-vhd|x-virtualbox-vmdk|x-www-form-urlencoded)|font\/(?:otf|ttf)|image\/(?:bmp|vnd\.adobe\.photoshop|vnd\.microsoft\.icon|vnd\.ms-dds|x-icon|x-ms-bmp)|message\/rfc822|model\/gltf-binary|x-shader\/x-fragment|x-shader\/x-vertex|[^;\s]+?\+(?:json|text|xml|yaml))(?:[;\s]|$)/i;
|
|
553
553
|
var ENCODINGS = {
|
|
@@ -670,7 +670,7 @@ var serveStatic = (options = { root: "" }) => {
|
|
|
670
670
|
};
|
|
671
671
|
};
|
|
672
672
|
|
|
673
|
-
// ../../node_modules/.pnpm/hono@4.6.
|
|
673
|
+
// ../../node_modules/.pnpm/hono@4.6.19/node_modules/hono/dist/utils/html.js
|
|
674
674
|
var HtmlEscapedCallbackPhase = {
|
|
675
675
|
Stringify: 1,
|
|
676
676
|
BeforeStream: 2,
|
|
@@ -786,7 +786,7 @@ var resolveCallback = async (str, phase, preserveCallbacks, context, buffer) =>
|
|
|
786
786
|
}
|
|
787
787
|
};
|
|
788
788
|
|
|
789
|
-
// ../../node_modules/.pnpm/hono@4.6.
|
|
789
|
+
// ../../node_modules/.pnpm/hono@4.6.19/node_modules/hono/dist/helper/html/index.js
|
|
790
790
|
var html = (strings, ...values) => {
|
|
791
791
|
const buffer = [""];
|
|
792
792
|
for (let i2 = 0, len = strings.length - 1; i2 < len; i2++) {
|
|
@@ -823,7 +823,7 @@ var html = (strings, ...values) => {
|
|
|
823
823
|
return buffer.length === 1 ? "callbacks" in buffer ? raw(resolveCallbackSync(raw(buffer[0], buffer.callbacks))) : raw(buffer[0]) : stringBufferToString(buffer, buffer.callbacks);
|
|
824
824
|
};
|
|
825
825
|
|
|
826
|
-
// ../../node_modules/.pnpm/@hono+swagger-ui@0.5.0_hono@4.6.
|
|
826
|
+
// ../../node_modules/.pnpm/@hono+swagger-ui@0.5.0_hono@4.6.19/node_modules/@hono/swagger-ui/dist/index.js
|
|
827
827
|
var RENDER_TYPE = {
|
|
828
828
|
STRING_ARRAY: "string_array",
|
|
829
829
|
STRING: "string",
|
|
@@ -940,7 +940,7 @@ var middleware = (options) => async (c2) => {
|
|
|
940
940
|
);
|
|
941
941
|
};
|
|
942
942
|
|
|
943
|
-
// ../../node_modules/.pnpm/hono@4.6.
|
|
943
|
+
// ../../node_modules/.pnpm/hono@4.6.19/node_modules/hono/dist/utils/body.js
|
|
944
944
|
var parseBody = async (request, options = /* @__PURE__ */ Object.create(null)) => {
|
|
945
945
|
const { all = false, dot = false } = options;
|
|
946
946
|
const headers = request instanceof HonoRequest ? request.raw.headers : request.headers;
|
|
@@ -1005,7 +1005,7 @@ var handleParsingNestedValues = (form, key, value) => {
|
|
|
1005
1005
|
});
|
|
1006
1006
|
};
|
|
1007
1007
|
|
|
1008
|
-
// ../../node_modules/.pnpm/hono@4.6.
|
|
1008
|
+
// ../../node_modules/.pnpm/hono@4.6.19/node_modules/hono/dist/utils/url.js
|
|
1009
1009
|
var splitPath = (path) => {
|
|
1010
1010
|
const paths = path.split("/");
|
|
1011
1011
|
if (paths[0] === "") {
|
|
@@ -1219,7 +1219,7 @@ var getQueryParams = (url, key) => {
|
|
|
1219
1219
|
};
|
|
1220
1220
|
var decodeURIComponent_ = decodeURIComponent;
|
|
1221
1221
|
|
|
1222
|
-
// ../../node_modules/.pnpm/hono@4.6.
|
|
1222
|
+
// ../../node_modules/.pnpm/hono@4.6.19/node_modules/hono/dist/request.js
|
|
1223
1223
|
var tryDecodeURIComponent = (str) => tryDecode(str, decodeURIComponent_);
|
|
1224
1224
|
var HonoRequest = class {
|
|
1225
1225
|
raw;
|
|
@@ -1327,7 +1327,7 @@ var HonoRequest = class {
|
|
|
1327
1327
|
}
|
|
1328
1328
|
};
|
|
1329
1329
|
|
|
1330
|
-
// ../../node_modules/.pnpm/hono@4.6.
|
|
1330
|
+
// ../../node_modules/.pnpm/hono@4.6.19/node_modules/hono/dist/context.js
|
|
1331
1331
|
var TEXT_PLAIN = "text/plain; charset=UTF-8";
|
|
1332
1332
|
var setHeaders = (headers, map = {}) => {
|
|
1333
1333
|
for (const key of Object.keys(map)) {
|
|
@@ -1576,7 +1576,7 @@ var Context = class {
|
|
|
1576
1576
|
};
|
|
1577
1577
|
};
|
|
1578
1578
|
|
|
1579
|
-
// ../../node_modules/.pnpm/hono@4.6.
|
|
1579
|
+
// ../../node_modules/.pnpm/hono@4.6.19/node_modules/hono/dist/compose.js
|
|
1580
1580
|
var compose = (middleware2, onError, onNotFound) => {
|
|
1581
1581
|
return (context, next) => {
|
|
1582
1582
|
let index = -1;
|
|
@@ -1625,7 +1625,7 @@ var compose = (middleware2, onError, onNotFound) => {
|
|
|
1625
1625
|
};
|
|
1626
1626
|
};
|
|
1627
1627
|
|
|
1628
|
-
// ../../node_modules/.pnpm/hono@4.6.
|
|
1628
|
+
// ../../node_modules/.pnpm/hono@4.6.19/node_modules/hono/dist/router.js
|
|
1629
1629
|
var METHOD_NAME_ALL = "ALL";
|
|
1630
1630
|
var METHOD_NAME_ALL_LOWERCASE = "all";
|
|
1631
1631
|
var METHODS = ["get", "post", "put", "delete", "options", "patch"];
|
|
@@ -1633,10 +1633,10 @@ var MESSAGE_MATCHER_IS_ALREADY_BUILT = "Can not add a route since the matcher is
|
|
|
1633
1633
|
var UnsupportedPathError = class extends Error {
|
|
1634
1634
|
};
|
|
1635
1635
|
|
|
1636
|
-
// ../../node_modules/.pnpm/hono@4.6.
|
|
1636
|
+
// ../../node_modules/.pnpm/hono@4.6.19/node_modules/hono/dist/utils/constants.js
|
|
1637
1637
|
var COMPOSED_HANDLER = "__COMPOSED_HANDLER";
|
|
1638
1638
|
|
|
1639
|
-
// ../../node_modules/.pnpm/hono@4.6.
|
|
1639
|
+
// ../../node_modules/.pnpm/hono@4.6.19/node_modules/hono/dist/hono-base.js
|
|
1640
1640
|
var notFoundHandler = (c2) => {
|
|
1641
1641
|
return c2.text("404 Not Found", 404);
|
|
1642
1642
|
};
|
|
@@ -1861,7 +1861,7 @@ var Hono = class {
|
|
|
1861
1861
|
};
|
|
1862
1862
|
};
|
|
1863
1863
|
|
|
1864
|
-
// ../../node_modules/.pnpm/hono@4.6.
|
|
1864
|
+
// ../../node_modules/.pnpm/hono@4.6.19/node_modules/hono/dist/router/reg-exp-router/node.js
|
|
1865
1865
|
var LABEL_REG_EXP_STR = "[^/]+";
|
|
1866
1866
|
var ONLY_WILDCARD_REG_EXP_STR = ".*";
|
|
1867
1867
|
var TAIL_WILDCARD_REG_EXP_STR = "(?:|/.*)";
|
|
@@ -1966,7 +1966,7 @@ var Node = class {
|
|
|
1966
1966
|
}
|
|
1967
1967
|
};
|
|
1968
1968
|
|
|
1969
|
-
// ../../node_modules/.pnpm/hono@4.6.
|
|
1969
|
+
// ../../node_modules/.pnpm/hono@4.6.19/node_modules/hono/dist/router/reg-exp-router/trie.js
|
|
1970
1970
|
var Trie = class {
|
|
1971
1971
|
#context = { varIndex: 0 };
|
|
1972
1972
|
#root = new Node();
|
|
@@ -2022,7 +2022,7 @@ var Trie = class {
|
|
|
2022
2022
|
}
|
|
2023
2023
|
};
|
|
2024
2024
|
|
|
2025
|
-
// ../../node_modules/.pnpm/hono@4.6.
|
|
2025
|
+
// ../../node_modules/.pnpm/hono@4.6.19/node_modules/hono/dist/router/reg-exp-router/router.js
|
|
2026
2026
|
var emptyParam = [];
|
|
2027
2027
|
var nullMatcher = [/^$/, [], /* @__PURE__ */ Object.create(null)];
|
|
2028
2028
|
var wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
|
|
@@ -2218,7 +2218,7 @@ var RegExpRouter = class {
|
|
|
2218
2218
|
}
|
|
2219
2219
|
};
|
|
2220
2220
|
|
|
2221
|
-
// ../../node_modules/.pnpm/hono@4.6.
|
|
2221
|
+
// ../../node_modules/.pnpm/hono@4.6.19/node_modules/hono/dist/router/smart-router/router.js
|
|
2222
2222
|
var SmartRouter = class {
|
|
2223
2223
|
name = "SmartRouter";
|
|
2224
2224
|
#routers = [];
|
|
@@ -2273,7 +2273,7 @@ var SmartRouter = class {
|
|
|
2273
2273
|
}
|
|
2274
2274
|
};
|
|
2275
2275
|
|
|
2276
|
-
// ../../node_modules/.pnpm/hono@4.6.
|
|
2276
|
+
// ../../node_modules/.pnpm/hono@4.6.19/node_modules/hono/dist/router/trie-router/node.js
|
|
2277
2277
|
var emptyParams = /* @__PURE__ */ Object.create(null);
|
|
2278
2278
|
var Node2 = class {
|
|
2279
2279
|
#methods;
|
|
@@ -2420,7 +2420,7 @@ var Node2 = class {
|
|
|
2420
2420
|
}
|
|
2421
2421
|
};
|
|
2422
2422
|
|
|
2423
|
-
// ../../node_modules/.pnpm/hono@4.6.
|
|
2423
|
+
// ../../node_modules/.pnpm/hono@4.6.19/node_modules/hono/dist/router/trie-router/router.js
|
|
2424
2424
|
var TrieRouter = class {
|
|
2425
2425
|
name = "TrieRouter";
|
|
2426
2426
|
#node;
|
|
@@ -2442,7 +2442,7 @@ var TrieRouter = class {
|
|
|
2442
2442
|
}
|
|
2443
2443
|
};
|
|
2444
2444
|
|
|
2445
|
-
// ../../node_modules/.pnpm/hono@4.6.
|
|
2445
|
+
// ../../node_modules/.pnpm/hono@4.6.19/node_modules/hono/dist/hono.js
|
|
2446
2446
|
var Hono2 = class extends Hono {
|
|
2447
2447
|
constructor(options = {}) {
|
|
2448
2448
|
super(options);
|
|
@@ -2452,7 +2452,7 @@ var Hono2 = class extends Hono {
|
|
|
2452
2452
|
}
|
|
2453
2453
|
};
|
|
2454
2454
|
|
|
2455
|
-
// ../../node_modules/.pnpm/hono@4.6.
|
|
2455
|
+
// ../../node_modules/.pnpm/hono@4.6.19/node_modules/hono/dist/http-exception.js
|
|
2456
2456
|
var HTTPException = class extends Error {
|
|
2457
2457
|
res;
|
|
2458
2458
|
status;
|
|
@@ -2475,10 +2475,10 @@ var HTTPException = class extends Error {
|
|
|
2475
2475
|
}
|
|
2476
2476
|
};
|
|
2477
2477
|
|
|
2478
|
-
// ../../node_modules/.pnpm/hono-openapi@0.4.3_hono@4.6.
|
|
2478
|
+
// ../../node_modules/.pnpm/hono-openapi@0.4.3_hono@4.6.19_openapi-types@12.1.3_zod@3.24.1/node_modules/hono-openapi/utils.js
|
|
2479
2479
|
var e = Symbol("openapi");
|
|
2480
2480
|
|
|
2481
|
-
// ../../node_modules/.pnpm/hono-openapi@0.4.3_hono@4.6.
|
|
2481
|
+
// ../../node_modules/.pnpm/hono-openapi@0.4.3_hono@4.6.19_openapi-types@12.1.3_zod@3.24.1/node_modules/hono-openapi/index.js
|
|
2482
2482
|
function n(n2) {
|
|
2483
2483
|
const { validateResponse: s2, ...o2 } = n2;
|
|
2484
2484
|
return Object.assign(async (t, o3) => {
|
|
@@ -2577,7 +2577,7 @@ import { join } from "path";
|
|
|
2577
2577
|
import { pathToFileURL } from "url";
|
|
2578
2578
|
import { readFile as readFile2 } from "fs/promises";
|
|
2579
2579
|
|
|
2580
|
-
// ../../node_modules/.pnpm/hono@4.6.
|
|
2580
|
+
// ../../node_modules/.pnpm/hono@4.6.19/node_modules/hono/dist/middleware/cors/index.js
|
|
2581
2581
|
var cors = (options) => {
|
|
2582
2582
|
const defaults = {
|
|
2583
2583
|
origin: "*",
|
|
@@ -2654,14 +2654,14 @@ var cors = (options) => {
|
|
|
2654
2654
|
};
|
|
2655
2655
|
};
|
|
2656
2656
|
|
|
2657
|
-
// ../../node_modules/.pnpm/hono@4.6.
|
|
2657
|
+
// ../../node_modules/.pnpm/hono@4.6.19/node_modules/hono/dist/utils/color.js
|
|
2658
2658
|
function getColorEnabled() {
|
|
2659
2659
|
const { process: process2, Deno } = globalThis;
|
|
2660
2660
|
const isNoColor = typeof Deno?.noColor === "boolean" ? Deno.noColor : process2 !== void 0 ? "NO_COLOR" in process2?.env : false;
|
|
2661
2661
|
return !isNoColor;
|
|
2662
2662
|
}
|
|
2663
2663
|
|
|
2664
|
-
// ../../node_modules/.pnpm/hono@4.6.
|
|
2664
|
+
// ../../node_modules/.pnpm/hono@4.6.19/node_modules/hono/dist/middleware/logger/index.js
|
|
2665
2665
|
var humanize = (times) => {
|
|
2666
2666
|
const [delimiter, separator] = [",", "."];
|
|
2667
2667
|
const orderTimes = times.map((v) => v.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1" + delimiter));
|
|
@@ -9097,6 +9097,104 @@ async function executeAgentToolHandler(c2) {
|
|
|
9097
9097
|
}
|
|
9098
9098
|
}
|
|
9099
9099
|
|
|
9100
|
+
// src/server/handlers/vector.ts
|
|
9101
|
+
var getVector = (c2, vectorName) => {
|
|
9102
|
+
const vector = c2.get("mastra").getVector(vectorName);
|
|
9103
|
+
if (!vector) {
|
|
9104
|
+
throw new HTTPException(404, { message: `Vector store ${vectorName} not found` });
|
|
9105
|
+
}
|
|
9106
|
+
return vector;
|
|
9107
|
+
};
|
|
9108
|
+
async function upsertVectors(c2) {
|
|
9109
|
+
try {
|
|
9110
|
+
const vectorName = c2.req.param("vectorName");
|
|
9111
|
+
const { indexName, vectors, metadata, ids } = await c2.req.json();
|
|
9112
|
+
if (!indexName || !vectors || !Array.isArray(vectors)) {
|
|
9113
|
+
throw new HTTPException(400, { message: "Invalid request body. indexName and vectors array are required." });
|
|
9114
|
+
}
|
|
9115
|
+
const vector = getVector(c2, vectorName);
|
|
9116
|
+
const result = await vector.upsert(indexName, vectors, metadata, ids);
|
|
9117
|
+
return c2.json({ ids: result });
|
|
9118
|
+
} catch (error) {
|
|
9119
|
+
return handleError(error, "Error upserting vectors");
|
|
9120
|
+
}
|
|
9121
|
+
}
|
|
9122
|
+
async function createIndex(c2) {
|
|
9123
|
+
try {
|
|
9124
|
+
const vectorName = c2.req.param("vectorName");
|
|
9125
|
+
const { indexName, dimension, metric } = await c2.req.json();
|
|
9126
|
+
if (!indexName || typeof dimension !== "number" || dimension <= 0) {
|
|
9127
|
+
throw new HTTPException(400, {
|
|
9128
|
+
message: "Invalid request body. indexName and positive dimension number are required."
|
|
9129
|
+
});
|
|
9130
|
+
}
|
|
9131
|
+
if (metric && !["cosine", "euclidean", "dotproduct"].includes(metric)) {
|
|
9132
|
+
throw new HTTPException(400, { message: "Invalid metric. Must be one of: cosine, euclidean, dotproduct" });
|
|
9133
|
+
}
|
|
9134
|
+
const vector = getVector(c2, vectorName);
|
|
9135
|
+
await vector.createIndex(indexName, dimension, metric);
|
|
9136
|
+
return c2.json({ success: true });
|
|
9137
|
+
} catch (error) {
|
|
9138
|
+
return handleError(error, "Error creating index");
|
|
9139
|
+
}
|
|
9140
|
+
}
|
|
9141
|
+
async function queryVectors(c2) {
|
|
9142
|
+
try {
|
|
9143
|
+
const vectorName = c2.req.param("vectorName");
|
|
9144
|
+
const { indexName, queryVector, topK = 10, filter, includeVector = false } = await c2.req.json();
|
|
9145
|
+
if (!indexName || !queryVector || !Array.isArray(queryVector)) {
|
|
9146
|
+
throw new HTTPException(400, { message: "Invalid request body. indexName and queryVector array are required." });
|
|
9147
|
+
}
|
|
9148
|
+
const vector = getVector(c2, vectorName);
|
|
9149
|
+
const results = await vector.query(indexName, queryVector, topK, filter, includeVector);
|
|
9150
|
+
return c2.json({ results });
|
|
9151
|
+
} catch (error) {
|
|
9152
|
+
return handleError(error, "Error querying vectors");
|
|
9153
|
+
}
|
|
9154
|
+
}
|
|
9155
|
+
async function listIndexes(c2) {
|
|
9156
|
+
try {
|
|
9157
|
+
const vectorName = c2.req.param("vectorName");
|
|
9158
|
+
const vector = getVector(c2, vectorName);
|
|
9159
|
+
const indexes = await vector.listIndexes();
|
|
9160
|
+
return c2.json({ indexes: indexes.filter(Boolean) });
|
|
9161
|
+
} catch (error) {
|
|
9162
|
+
return handleError(error, "Error listing indexes");
|
|
9163
|
+
}
|
|
9164
|
+
}
|
|
9165
|
+
async function describeIndex(c2) {
|
|
9166
|
+
try {
|
|
9167
|
+
const vectorName = c2.req.param("vectorName");
|
|
9168
|
+
const indexName = c2.req.param("indexName");
|
|
9169
|
+
if (!indexName) {
|
|
9170
|
+
throw new HTTPException(400, { message: "Index name is required" });
|
|
9171
|
+
}
|
|
9172
|
+
const vector = getVector(c2, vectorName);
|
|
9173
|
+
const stats = await vector.describeIndex(indexName);
|
|
9174
|
+
return c2.json({
|
|
9175
|
+
dimension: stats.dimension,
|
|
9176
|
+
count: stats.count,
|
|
9177
|
+
metric: stats.metric?.toLowerCase()
|
|
9178
|
+
});
|
|
9179
|
+
} catch (error) {
|
|
9180
|
+
return handleError(error, "Error describing index");
|
|
9181
|
+
}
|
|
9182
|
+
}
|
|
9183
|
+
async function deleteIndex(c2) {
|
|
9184
|
+
try {
|
|
9185
|
+
const vectorName = c2.req.param("vectorName");
|
|
9186
|
+
const indexName = c2.req.param("indexName");
|
|
9187
|
+
if (!indexName) {
|
|
9188
|
+
throw new HTTPException(400, { message: "Index name is required" });
|
|
9189
|
+
}
|
|
9190
|
+
const vector = getVector(c2, vectorName);
|
|
9191
|
+
await vector.deleteIndex(indexName);
|
|
9192
|
+
return c2.json({ success: true });
|
|
9193
|
+
} catch (error) {
|
|
9194
|
+
return handleError(error, "Error deleting index");
|
|
9195
|
+
}
|
|
9196
|
+
}
|
|
9197
|
+
|
|
9100
9198
|
// src/server/handlers/workflows.ts
|
|
9101
9199
|
async function getWorkflowsHandler(c2) {
|
|
9102
9200
|
try {
|
|
@@ -9963,6 +10061,213 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
9963
10061
|
}),
|
|
9964
10062
|
executeToolHandler(tools)
|
|
9965
10063
|
);
|
|
10064
|
+
app.post(
|
|
10065
|
+
"/api/vector/:vectorName/upsert",
|
|
10066
|
+
n({
|
|
10067
|
+
description: "Upsert vectors into an index",
|
|
10068
|
+
tags: ["vector"],
|
|
10069
|
+
parameters: [
|
|
10070
|
+
{
|
|
10071
|
+
name: "vectorName",
|
|
10072
|
+
in: "path",
|
|
10073
|
+
required: true,
|
|
10074
|
+
schema: { type: "string" }
|
|
10075
|
+
}
|
|
10076
|
+
],
|
|
10077
|
+
requestBody: {
|
|
10078
|
+
required: true,
|
|
10079
|
+
content: {
|
|
10080
|
+
"application/json": {
|
|
10081
|
+
schema: {
|
|
10082
|
+
type: "object",
|
|
10083
|
+
properties: {
|
|
10084
|
+
indexName: { type: "string" },
|
|
10085
|
+
vectors: {
|
|
10086
|
+
type: "array",
|
|
10087
|
+
items: {
|
|
10088
|
+
type: "array",
|
|
10089
|
+
items: { type: "number" }
|
|
10090
|
+
}
|
|
10091
|
+
},
|
|
10092
|
+
metadata: {
|
|
10093
|
+
type: "array",
|
|
10094
|
+
items: { type: "object" }
|
|
10095
|
+
},
|
|
10096
|
+
ids: {
|
|
10097
|
+
type: "array",
|
|
10098
|
+
items: { type: "string" }
|
|
10099
|
+
}
|
|
10100
|
+
},
|
|
10101
|
+
required: ["indexName", "vectors"]
|
|
10102
|
+
}
|
|
10103
|
+
}
|
|
10104
|
+
}
|
|
10105
|
+
},
|
|
10106
|
+
responses: {
|
|
10107
|
+
200: {
|
|
10108
|
+
description: "Vectors upserted successfully"
|
|
10109
|
+
}
|
|
10110
|
+
}
|
|
10111
|
+
}),
|
|
10112
|
+
upsertVectors
|
|
10113
|
+
);
|
|
10114
|
+
app.post(
|
|
10115
|
+
"/api/vector/:vectorName/create-index",
|
|
10116
|
+
n({
|
|
10117
|
+
description: "Create a new vector index",
|
|
10118
|
+
tags: ["vector"],
|
|
10119
|
+
parameters: [
|
|
10120
|
+
{
|
|
10121
|
+
name: "vectorName",
|
|
10122
|
+
in: "path",
|
|
10123
|
+
required: true,
|
|
10124
|
+
schema: { type: "string" }
|
|
10125
|
+
}
|
|
10126
|
+
],
|
|
10127
|
+
requestBody: {
|
|
10128
|
+
required: true,
|
|
10129
|
+
content: {
|
|
10130
|
+
"application/json": {
|
|
10131
|
+
schema: {
|
|
10132
|
+
type: "object",
|
|
10133
|
+
properties: {
|
|
10134
|
+
indexName: { type: "string" },
|
|
10135
|
+
dimension: { type: "number" },
|
|
10136
|
+
metric: {
|
|
10137
|
+
type: "string",
|
|
10138
|
+
enum: ["cosine", "euclidean", "dotproduct"]
|
|
10139
|
+
}
|
|
10140
|
+
},
|
|
10141
|
+
required: ["indexName", "dimension"]
|
|
10142
|
+
}
|
|
10143
|
+
}
|
|
10144
|
+
}
|
|
10145
|
+
},
|
|
10146
|
+
responses: {
|
|
10147
|
+
200: {
|
|
10148
|
+
description: "Index created successfully"
|
|
10149
|
+
}
|
|
10150
|
+
}
|
|
10151
|
+
}),
|
|
10152
|
+
createIndex
|
|
10153
|
+
);
|
|
10154
|
+
app.post(
|
|
10155
|
+
"/api/vector/:vectorName/query",
|
|
10156
|
+
n({
|
|
10157
|
+
description: "Query vectors from an index",
|
|
10158
|
+
tags: ["vector"],
|
|
10159
|
+
parameters: [
|
|
10160
|
+
{
|
|
10161
|
+
name: "vectorName",
|
|
10162
|
+
in: "path",
|
|
10163
|
+
required: true,
|
|
10164
|
+
schema: { type: "string" }
|
|
10165
|
+
}
|
|
10166
|
+
],
|
|
10167
|
+
requestBody: {
|
|
10168
|
+
required: true,
|
|
10169
|
+
content: {
|
|
10170
|
+
"application/json": {
|
|
10171
|
+
schema: {
|
|
10172
|
+
type: "object",
|
|
10173
|
+
properties: {
|
|
10174
|
+
indexName: { type: "string" },
|
|
10175
|
+
queryVector: {
|
|
10176
|
+
type: "array",
|
|
10177
|
+
items: { type: "number" }
|
|
10178
|
+
},
|
|
10179
|
+
topK: { type: "number" },
|
|
10180
|
+
filter: { type: "object" },
|
|
10181
|
+
includeVector: { type: "boolean" }
|
|
10182
|
+
},
|
|
10183
|
+
required: ["indexName", "queryVector"]
|
|
10184
|
+
}
|
|
10185
|
+
}
|
|
10186
|
+
}
|
|
10187
|
+
},
|
|
10188
|
+
responses: {
|
|
10189
|
+
200: {
|
|
10190
|
+
description: "Query results"
|
|
10191
|
+
}
|
|
10192
|
+
}
|
|
10193
|
+
}),
|
|
10194
|
+
queryVectors
|
|
10195
|
+
);
|
|
10196
|
+
app.get(
|
|
10197
|
+
"/api/vector/:vectorName/indexes",
|
|
10198
|
+
n({
|
|
10199
|
+
description: "List all indexes for a vector store",
|
|
10200
|
+
tags: ["vector"],
|
|
10201
|
+
parameters: [
|
|
10202
|
+
{
|
|
10203
|
+
name: "vectorName",
|
|
10204
|
+
in: "path",
|
|
10205
|
+
required: true,
|
|
10206
|
+
schema: { type: "string" }
|
|
10207
|
+
}
|
|
10208
|
+
],
|
|
10209
|
+
responses: {
|
|
10210
|
+
200: {
|
|
10211
|
+
description: "List of indexes"
|
|
10212
|
+
}
|
|
10213
|
+
}
|
|
10214
|
+
}),
|
|
10215
|
+
listIndexes
|
|
10216
|
+
);
|
|
10217
|
+
app.get(
|
|
10218
|
+
"/api/vector/:vectorName/indexes/:indexName",
|
|
10219
|
+
n({
|
|
10220
|
+
description: "Get details about a specific index",
|
|
10221
|
+
tags: ["vector"],
|
|
10222
|
+
parameters: [
|
|
10223
|
+
{
|
|
10224
|
+
name: "vectorName",
|
|
10225
|
+
in: "path",
|
|
10226
|
+
required: true,
|
|
10227
|
+
schema: { type: "string" }
|
|
10228
|
+
},
|
|
10229
|
+
{
|
|
10230
|
+
name: "indexName",
|
|
10231
|
+
in: "path",
|
|
10232
|
+
required: true,
|
|
10233
|
+
schema: { type: "string" }
|
|
10234
|
+
}
|
|
10235
|
+
],
|
|
10236
|
+
responses: {
|
|
10237
|
+
200: {
|
|
10238
|
+
description: "Index details"
|
|
10239
|
+
}
|
|
10240
|
+
}
|
|
10241
|
+
}),
|
|
10242
|
+
describeIndex
|
|
10243
|
+
);
|
|
10244
|
+
app.delete(
|
|
10245
|
+
"/api/vector/:vectorName/indexes/:indexName",
|
|
10246
|
+
n({
|
|
10247
|
+
description: "Delete a specific index",
|
|
10248
|
+
tags: ["vector"],
|
|
10249
|
+
parameters: [
|
|
10250
|
+
{
|
|
10251
|
+
name: "vectorName",
|
|
10252
|
+
in: "path",
|
|
10253
|
+
required: true,
|
|
10254
|
+
schema: { type: "string" }
|
|
10255
|
+
},
|
|
10256
|
+
{
|
|
10257
|
+
name: "indexName",
|
|
10258
|
+
in: "path",
|
|
10259
|
+
required: true,
|
|
10260
|
+
schema: { type: "string" }
|
|
10261
|
+
}
|
|
10262
|
+
],
|
|
10263
|
+
responses: {
|
|
10264
|
+
200: {
|
|
10265
|
+
description: "Index deleted successfully"
|
|
10266
|
+
}
|
|
10267
|
+
}
|
|
10268
|
+
}),
|
|
10269
|
+
deleteIndex
|
|
10270
|
+
);
|
|
9966
10271
|
app.get(
|
|
9967
10272
|
"/openapi.json",
|
|
9968
10273
|
r(app, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/deployer",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.27",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"esbuild": "^0.24.2",
|
|
26
26
|
"fs-extra": "^11.2.0",
|
|
27
27
|
"zod": "^3.24.1",
|
|
28
|
-
"@mastra/core": "0.1.27-alpha.
|
|
28
|
+
"@mastra/core": "0.1.27-alpha.82"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@hono/node-server": "^1.13.7",
|
package/src/build/bundle.ts
CHANGED
|
@@ -227,7 +227,7 @@ export async function bundle(
|
|
|
227
227
|
buildWorkflow.__setLogger(noopLogger as unknown as Logger);
|
|
228
228
|
|
|
229
229
|
try {
|
|
230
|
-
await start({
|
|
230
|
+
const result = await start({
|
|
231
231
|
triggerData: {
|
|
232
232
|
buildName,
|
|
233
233
|
entry,
|
|
@@ -236,8 +236,17 @@ export async function bundle(
|
|
|
236
236
|
devMode,
|
|
237
237
|
},
|
|
238
238
|
});
|
|
239
|
+
|
|
240
|
+
Object.entries(result.results).forEach(([stepName, stepResult]) => {
|
|
241
|
+
if ((stepResult as any).status !== 'success') {
|
|
242
|
+
logger.error(`${stepName}:`, stepResult);
|
|
243
|
+
throw new Error(`Step ${stepName} failed`);
|
|
244
|
+
}
|
|
245
|
+
});
|
|
239
246
|
} catch (error) {
|
|
240
|
-
|
|
247
|
+
if (error instanceof Error) {
|
|
248
|
+
logger.error(error.message, { stack: error.stack, message: error.message, name: error.name });
|
|
249
|
+
}
|
|
241
250
|
process.exit(1);
|
|
242
251
|
}
|
|
243
252
|
}
|
package/src/deploy/base.ts
CHANGED
|
@@ -180,8 +180,22 @@ export class Deployer extends MastraBase {
|
|
|
180
180
|
const dirPath = dir || path.join(this.projectPath, 'src/mastra');
|
|
181
181
|
this.writePackageJson();
|
|
182
182
|
this.writeServerFile();
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
183
|
+
try {
|
|
184
|
+
await this.install();
|
|
185
|
+
} catch (error) {
|
|
186
|
+
this.logger.error('Failed to install dependencies', { error });
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
try {
|
|
190
|
+
await this.build({ dir: dirPath, useBanner });
|
|
191
|
+
} catch (error) {
|
|
192
|
+
this.logger.error('Failed to build', { error });
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
try {
|
|
196
|
+
await this.buildServer({ playground, swaggerUI });
|
|
197
|
+
} catch (error) {
|
|
198
|
+
this.logger.error('Failed to build server', { error });
|
|
199
|
+
}
|
|
186
200
|
}
|
|
187
201
|
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import type { MastraVector, QueryResult, IndexStats } from '@mastra/core';
|
|
2
|
+
import type { Context } from 'hono';
|
|
3
|
+
|
|
4
|
+
import { HTTPException } from 'hono/http-exception';
|
|
5
|
+
|
|
6
|
+
import { handleError } from './error';
|
|
7
|
+
|
|
8
|
+
interface UpsertRequest {
|
|
9
|
+
indexName: string;
|
|
10
|
+
vectors: number[][];
|
|
11
|
+
metadata?: Record<string, any>[];
|
|
12
|
+
ids?: string[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface CreateIndexRequest {
|
|
16
|
+
indexName: string;
|
|
17
|
+
dimension: number;
|
|
18
|
+
metric?: 'cosine' | 'euclidean' | 'dotproduct';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface QueryRequest {
|
|
22
|
+
indexName: string;
|
|
23
|
+
queryVector: number[];
|
|
24
|
+
topK?: number;
|
|
25
|
+
filter?: Record<string, any>;
|
|
26
|
+
includeVector?: boolean;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const getVector = (c: Context, vectorName: string): MastraVector => {
|
|
30
|
+
const vector = c.get('mastra').getVector(vectorName);
|
|
31
|
+
if (!vector) {
|
|
32
|
+
throw new HTTPException(404, { message: `Vector store ${vectorName} not found` });
|
|
33
|
+
}
|
|
34
|
+
return vector;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// Upsert vectors
|
|
38
|
+
export async function upsertVectors(c: Context) {
|
|
39
|
+
try {
|
|
40
|
+
const vectorName = c.req.param('vectorName');
|
|
41
|
+
const { indexName, vectors, metadata, ids } = await c.req.json<UpsertRequest>();
|
|
42
|
+
|
|
43
|
+
if (!indexName || !vectors || !Array.isArray(vectors)) {
|
|
44
|
+
throw new HTTPException(400, { message: 'Invalid request body. indexName and vectors array are required.' });
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const vector = getVector(c, vectorName);
|
|
48
|
+
const result = await vector.upsert(indexName, vectors, metadata, ids);
|
|
49
|
+
return c.json({ ids: result });
|
|
50
|
+
} catch (error) {
|
|
51
|
+
return handleError(error, 'Error upserting vectors');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Create index
|
|
56
|
+
export async function createIndex(c: Context) {
|
|
57
|
+
try {
|
|
58
|
+
const vectorName = c.req.param('vectorName');
|
|
59
|
+
const { indexName, dimension, metric } = await c.req.json<CreateIndexRequest>();
|
|
60
|
+
|
|
61
|
+
if (!indexName || typeof dimension !== 'number' || dimension <= 0) {
|
|
62
|
+
throw new HTTPException(400, {
|
|
63
|
+
message: 'Invalid request body. indexName and positive dimension number are required.',
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (metric && !['cosine', 'euclidean', 'dotproduct'].includes(metric)) {
|
|
68
|
+
throw new HTTPException(400, { message: 'Invalid metric. Must be one of: cosine, euclidean, dotproduct' });
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const vector = getVector(c, vectorName);
|
|
72
|
+
await vector.createIndex(indexName, dimension, metric);
|
|
73
|
+
return c.json({ success: true });
|
|
74
|
+
} catch (error) {
|
|
75
|
+
return handleError(error, 'Error creating index');
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Query vectors
|
|
80
|
+
export async function queryVectors(c: Context) {
|
|
81
|
+
try {
|
|
82
|
+
const vectorName = c.req.param('vectorName');
|
|
83
|
+
const { indexName, queryVector, topK = 10, filter, includeVector = false } = await c.req.json<QueryRequest>();
|
|
84
|
+
|
|
85
|
+
if (!indexName || !queryVector || !Array.isArray(queryVector)) {
|
|
86
|
+
throw new HTTPException(400, { message: 'Invalid request body. indexName and queryVector array are required.' });
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const vector = getVector(c, vectorName);
|
|
90
|
+
const results: QueryResult[] = await vector.query(indexName, queryVector, topK, filter, includeVector);
|
|
91
|
+
return c.json({ results });
|
|
92
|
+
} catch (error) {
|
|
93
|
+
return handleError(error, 'Error querying vectors');
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// List indexes
|
|
98
|
+
export async function listIndexes(c: Context) {
|
|
99
|
+
try {
|
|
100
|
+
const vectorName = c.req.param('vectorName');
|
|
101
|
+
const vector = getVector(c, vectorName);
|
|
102
|
+
|
|
103
|
+
const indexes = await vector.listIndexes();
|
|
104
|
+
return c.json({ indexes: indexes.filter(Boolean) });
|
|
105
|
+
} catch (error) {
|
|
106
|
+
return handleError(error, 'Error listing indexes');
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Describe index
|
|
111
|
+
export async function describeIndex(c: Context) {
|
|
112
|
+
try {
|
|
113
|
+
const vectorName = c.req.param('vectorName');
|
|
114
|
+
const indexName = c.req.param('indexName');
|
|
115
|
+
|
|
116
|
+
if (!indexName) {
|
|
117
|
+
throw new HTTPException(400, { message: 'Index name is required' });
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const vector = getVector(c, vectorName);
|
|
121
|
+
const stats: IndexStats = await vector.describeIndex(indexName);
|
|
122
|
+
|
|
123
|
+
return c.json({
|
|
124
|
+
dimension: stats.dimension,
|
|
125
|
+
count: stats.count,
|
|
126
|
+
metric: stats.metric?.toLowerCase(),
|
|
127
|
+
});
|
|
128
|
+
} catch (error) {
|
|
129
|
+
return handleError(error, 'Error describing index');
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Delete index
|
|
134
|
+
export async function deleteIndex(c: Context) {
|
|
135
|
+
try {
|
|
136
|
+
const vectorName = c.req.param('vectorName');
|
|
137
|
+
const indexName = c.req.param('indexName');
|
|
138
|
+
|
|
139
|
+
if (!indexName) {
|
|
140
|
+
throw new HTTPException(400, { message: 'Index name is required' });
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const vector = getVector(c, vectorName);
|
|
144
|
+
await vector.deleteIndex(indexName);
|
|
145
|
+
return c.json({ success: true });
|
|
146
|
+
} catch (error) {
|
|
147
|
+
return handleError(error, 'Error deleting index');
|
|
148
|
+
}
|
|
149
|
+
}
|
package/src/server/index.ts
CHANGED
|
@@ -41,6 +41,14 @@ import {
|
|
|
41
41
|
getToolResultHandler,
|
|
42
42
|
getToolsHandler,
|
|
43
43
|
} from './handlers/tools.js';
|
|
44
|
+
import {
|
|
45
|
+
upsertVectors,
|
|
46
|
+
createIndex,
|
|
47
|
+
queryVectors,
|
|
48
|
+
listIndexes,
|
|
49
|
+
describeIndex,
|
|
50
|
+
deleteIndex,
|
|
51
|
+
} from './handlers/vector.js';
|
|
44
52
|
import { executeWorkflowHandler, getWorkflowByIdHandler, getWorkflowsHandler } from './handlers/workflows.js';
|
|
45
53
|
import { html } from './welcome.js';
|
|
46
54
|
|
|
@@ -806,6 +814,220 @@ export async function createHonoServer(
|
|
|
806
814
|
executeToolHandler(tools),
|
|
807
815
|
);
|
|
808
816
|
|
|
817
|
+
// Vector routes
|
|
818
|
+
app.post(
|
|
819
|
+
'/api/vector/:vectorName/upsert',
|
|
820
|
+
describeRoute({
|
|
821
|
+
description: 'Upsert vectors into an index',
|
|
822
|
+
tags: ['vector'],
|
|
823
|
+
parameters: [
|
|
824
|
+
{
|
|
825
|
+
name: 'vectorName',
|
|
826
|
+
in: 'path',
|
|
827
|
+
required: true,
|
|
828
|
+
schema: { type: 'string' },
|
|
829
|
+
},
|
|
830
|
+
],
|
|
831
|
+
requestBody: {
|
|
832
|
+
required: true,
|
|
833
|
+
content: {
|
|
834
|
+
'application/json': {
|
|
835
|
+
schema: {
|
|
836
|
+
type: 'object',
|
|
837
|
+
properties: {
|
|
838
|
+
indexName: { type: 'string' },
|
|
839
|
+
vectors: {
|
|
840
|
+
type: 'array',
|
|
841
|
+
items: {
|
|
842
|
+
type: 'array',
|
|
843
|
+
items: { type: 'number' },
|
|
844
|
+
},
|
|
845
|
+
},
|
|
846
|
+
metadata: {
|
|
847
|
+
type: 'array',
|
|
848
|
+
items: { type: 'object' },
|
|
849
|
+
},
|
|
850
|
+
ids: {
|
|
851
|
+
type: 'array',
|
|
852
|
+
items: { type: 'string' },
|
|
853
|
+
},
|
|
854
|
+
},
|
|
855
|
+
required: ['indexName', 'vectors'],
|
|
856
|
+
},
|
|
857
|
+
},
|
|
858
|
+
},
|
|
859
|
+
},
|
|
860
|
+
responses: {
|
|
861
|
+
200: {
|
|
862
|
+
description: 'Vectors upserted successfully',
|
|
863
|
+
},
|
|
864
|
+
},
|
|
865
|
+
}),
|
|
866
|
+
upsertVectors,
|
|
867
|
+
);
|
|
868
|
+
|
|
869
|
+
app.post(
|
|
870
|
+
'/api/vector/:vectorName/create-index',
|
|
871
|
+
describeRoute({
|
|
872
|
+
description: 'Create a new vector index',
|
|
873
|
+
tags: ['vector'],
|
|
874
|
+
parameters: [
|
|
875
|
+
{
|
|
876
|
+
name: 'vectorName',
|
|
877
|
+
in: 'path',
|
|
878
|
+
required: true,
|
|
879
|
+
schema: { type: 'string' },
|
|
880
|
+
},
|
|
881
|
+
],
|
|
882
|
+
requestBody: {
|
|
883
|
+
required: true,
|
|
884
|
+
content: {
|
|
885
|
+
'application/json': {
|
|
886
|
+
schema: {
|
|
887
|
+
type: 'object',
|
|
888
|
+
properties: {
|
|
889
|
+
indexName: { type: 'string' },
|
|
890
|
+
dimension: { type: 'number' },
|
|
891
|
+
metric: {
|
|
892
|
+
type: 'string',
|
|
893
|
+
enum: ['cosine', 'euclidean', 'dotproduct'],
|
|
894
|
+
},
|
|
895
|
+
},
|
|
896
|
+
required: ['indexName', 'dimension'],
|
|
897
|
+
},
|
|
898
|
+
},
|
|
899
|
+
},
|
|
900
|
+
},
|
|
901
|
+
responses: {
|
|
902
|
+
200: {
|
|
903
|
+
description: 'Index created successfully',
|
|
904
|
+
},
|
|
905
|
+
},
|
|
906
|
+
}),
|
|
907
|
+
createIndex,
|
|
908
|
+
);
|
|
909
|
+
|
|
910
|
+
app.post(
|
|
911
|
+
'/api/vector/:vectorName/query',
|
|
912
|
+
describeRoute({
|
|
913
|
+
description: 'Query vectors from an index',
|
|
914
|
+
tags: ['vector'],
|
|
915
|
+
parameters: [
|
|
916
|
+
{
|
|
917
|
+
name: 'vectorName',
|
|
918
|
+
in: 'path',
|
|
919
|
+
required: true,
|
|
920
|
+
schema: { type: 'string' },
|
|
921
|
+
},
|
|
922
|
+
],
|
|
923
|
+
requestBody: {
|
|
924
|
+
required: true,
|
|
925
|
+
content: {
|
|
926
|
+
'application/json': {
|
|
927
|
+
schema: {
|
|
928
|
+
type: 'object',
|
|
929
|
+
properties: {
|
|
930
|
+
indexName: { type: 'string' },
|
|
931
|
+
queryVector: {
|
|
932
|
+
type: 'array',
|
|
933
|
+
items: { type: 'number' },
|
|
934
|
+
},
|
|
935
|
+
topK: { type: 'number' },
|
|
936
|
+
filter: { type: 'object' },
|
|
937
|
+
includeVector: { type: 'boolean' },
|
|
938
|
+
},
|
|
939
|
+
required: ['indexName', 'queryVector'],
|
|
940
|
+
},
|
|
941
|
+
},
|
|
942
|
+
},
|
|
943
|
+
},
|
|
944
|
+
responses: {
|
|
945
|
+
200: {
|
|
946
|
+
description: 'Query results',
|
|
947
|
+
},
|
|
948
|
+
},
|
|
949
|
+
}),
|
|
950
|
+
queryVectors,
|
|
951
|
+
);
|
|
952
|
+
|
|
953
|
+
app.get(
|
|
954
|
+
'/api/vector/:vectorName/indexes',
|
|
955
|
+
describeRoute({
|
|
956
|
+
description: 'List all indexes for a vector store',
|
|
957
|
+
tags: ['vector'],
|
|
958
|
+
parameters: [
|
|
959
|
+
{
|
|
960
|
+
name: 'vectorName',
|
|
961
|
+
in: 'path',
|
|
962
|
+
required: true,
|
|
963
|
+
schema: { type: 'string' },
|
|
964
|
+
},
|
|
965
|
+
],
|
|
966
|
+
responses: {
|
|
967
|
+
200: {
|
|
968
|
+
description: 'List of indexes',
|
|
969
|
+
},
|
|
970
|
+
},
|
|
971
|
+
}),
|
|
972
|
+
listIndexes,
|
|
973
|
+
);
|
|
974
|
+
|
|
975
|
+
app.get(
|
|
976
|
+
'/api/vector/:vectorName/indexes/:indexName',
|
|
977
|
+
describeRoute({
|
|
978
|
+
description: 'Get details about a specific index',
|
|
979
|
+
tags: ['vector'],
|
|
980
|
+
parameters: [
|
|
981
|
+
{
|
|
982
|
+
name: 'vectorName',
|
|
983
|
+
in: 'path',
|
|
984
|
+
required: true,
|
|
985
|
+
schema: { type: 'string' },
|
|
986
|
+
},
|
|
987
|
+
{
|
|
988
|
+
name: 'indexName',
|
|
989
|
+
in: 'path',
|
|
990
|
+
required: true,
|
|
991
|
+
schema: { type: 'string' },
|
|
992
|
+
},
|
|
993
|
+
],
|
|
994
|
+
responses: {
|
|
995
|
+
200: {
|
|
996
|
+
description: 'Index details',
|
|
997
|
+
},
|
|
998
|
+
},
|
|
999
|
+
}),
|
|
1000
|
+
describeIndex,
|
|
1001
|
+
);
|
|
1002
|
+
|
|
1003
|
+
app.delete(
|
|
1004
|
+
'/api/vector/:vectorName/indexes/:indexName',
|
|
1005
|
+
describeRoute({
|
|
1006
|
+
description: 'Delete a specific index',
|
|
1007
|
+
tags: ['vector'],
|
|
1008
|
+
parameters: [
|
|
1009
|
+
{
|
|
1010
|
+
name: 'vectorName',
|
|
1011
|
+
in: 'path',
|
|
1012
|
+
required: true,
|
|
1013
|
+
schema: { type: 'string' },
|
|
1014
|
+
},
|
|
1015
|
+
{
|
|
1016
|
+
name: 'indexName',
|
|
1017
|
+
in: 'path',
|
|
1018
|
+
required: true,
|
|
1019
|
+
schema: { type: 'string' },
|
|
1020
|
+
},
|
|
1021
|
+
],
|
|
1022
|
+
responses: {
|
|
1023
|
+
200: {
|
|
1024
|
+
description: 'Index deleted successfully',
|
|
1025
|
+
},
|
|
1026
|
+
},
|
|
1027
|
+
}),
|
|
1028
|
+
deleteIndex,
|
|
1029
|
+
);
|
|
1030
|
+
|
|
809
1031
|
app.get(
|
|
810
1032
|
'/openapi.json',
|
|
811
1033
|
openAPISpecs(app, {
|
package/src/server/openapi.json
CHANGED
|
@@ -27,6 +27,24 @@
|
|
|
27
27
|
"parameters": [{ "name": "agentId", "in": "path", "required": true, "schema": { "type": "string" } }]
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
|
+
"/api/agents/{agentId}/evals/ci": {
|
|
31
|
+
"get": {
|
|
32
|
+
"responses": { "200": { "description": "List of evals" } },
|
|
33
|
+
"operationId": "getApiAgentsByAgentIdEvalsCi",
|
|
34
|
+
"description": "Get CI evals by agent ID",
|
|
35
|
+
"tags": ["agents"],
|
|
36
|
+
"parameters": [{ "name": "agentId", "in": "path", "required": true, "schema": { "type": "string" } }]
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"/api/agents/{agentId}/evals/live": {
|
|
40
|
+
"get": {
|
|
41
|
+
"responses": { "200": { "description": "List of evals" } },
|
|
42
|
+
"operationId": "getApiAgentsByAgentIdEvalsLive",
|
|
43
|
+
"description": "Get live evals by agent ID",
|
|
44
|
+
"tags": ["agents"],
|
|
45
|
+
"parameters": [{ "name": "agentId", "in": "path", "required": true, "schema": { "type": "string" } }]
|
|
46
|
+
}
|
|
47
|
+
},
|
|
30
48
|
"/api/agents/{agentId}/generate": {
|
|
31
49
|
"post": {
|
|
32
50
|
"responses": { "200": { "description": "Generated response" }, "404": { "description": "Agent not found" } },
|
|
@@ -253,21 +271,6 @@
|
|
|
253
271
|
}
|
|
254
272
|
}
|
|
255
273
|
},
|
|
256
|
-
"/api/syncs/{syncId}/execute": {
|
|
257
|
-
"post": {
|
|
258
|
-
"responses": { "200": { "description": "Sync execution result" }, "404": { "description": "Sync not found" } },
|
|
259
|
-
"operationId": "postApiSyncsBySyncIdExecute",
|
|
260
|
-
"description": "Execute a sync",
|
|
261
|
-
"tags": ["syncs"],
|
|
262
|
-
"parameters": [{ "name": "syncId", "in": "path", "required": true, "schema": { "type": "string" } }],
|
|
263
|
-
"requestBody": {
|
|
264
|
-
"required": true,
|
|
265
|
-
"content": {
|
|
266
|
-
"application/json": { "schema": { "type": "object", "properties": { "input": { "type": "object" } } } }
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
},
|
|
271
274
|
"/api/logs": {
|
|
272
275
|
"get": {
|
|
273
276
|
"responses": { "200": { "description": "List of all logs" } },
|
|
@@ -341,6 +344,115 @@
|
|
|
341
344
|
}
|
|
342
345
|
}
|
|
343
346
|
}
|
|
347
|
+
},
|
|
348
|
+
"/api/vector/{vectorName}/upsert": {
|
|
349
|
+
"post": {
|
|
350
|
+
"responses": { "200": { "description": "Vectors upserted successfully" } },
|
|
351
|
+
"operationId": "postApiVectorByVectorNameUpsert",
|
|
352
|
+
"description": "Upsert vectors into an index",
|
|
353
|
+
"tags": ["vector"],
|
|
354
|
+
"parameters": [{ "name": "vectorName", "in": "path", "required": true, "schema": { "type": "string" } }],
|
|
355
|
+
"requestBody": {
|
|
356
|
+
"required": true,
|
|
357
|
+
"content": {
|
|
358
|
+
"application/json": {
|
|
359
|
+
"schema": {
|
|
360
|
+
"type": "object",
|
|
361
|
+
"properties": {
|
|
362
|
+
"indexName": { "type": "string" },
|
|
363
|
+
"vectors": { "type": "array", "items": { "type": "array", "items": { "type": "number" } } },
|
|
364
|
+
"metadata": { "type": "array", "items": { "type": "object" } },
|
|
365
|
+
"ids": { "type": "array", "items": { "type": "string" } }
|
|
366
|
+
},
|
|
367
|
+
"required": ["indexName", "vectors"]
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
},
|
|
374
|
+
"/api/vector/{vectorName}/create-index": {
|
|
375
|
+
"post": {
|
|
376
|
+
"responses": { "200": { "description": "Index created successfully" } },
|
|
377
|
+
"operationId": "postApiVectorByVectorNameCreate-index",
|
|
378
|
+
"description": "Create a new vector index",
|
|
379
|
+
"tags": ["vector"],
|
|
380
|
+
"parameters": [{ "name": "vectorName", "in": "path", "required": true, "schema": { "type": "string" } }],
|
|
381
|
+
"requestBody": {
|
|
382
|
+
"required": true,
|
|
383
|
+
"content": {
|
|
384
|
+
"application/json": {
|
|
385
|
+
"schema": {
|
|
386
|
+
"type": "object",
|
|
387
|
+
"properties": {
|
|
388
|
+
"indexName": { "type": "string" },
|
|
389
|
+
"dimension": { "type": "number" },
|
|
390
|
+
"metric": { "type": "string", "enum": ["cosine", "euclidean", "dotproduct"] }
|
|
391
|
+
},
|
|
392
|
+
"required": ["indexName", "dimension"]
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
},
|
|
399
|
+
"/api/vector/{vectorName}/query": {
|
|
400
|
+
"post": {
|
|
401
|
+
"responses": { "200": { "description": "Query results" } },
|
|
402
|
+
"operationId": "postApiVectorByVectorNameQuery",
|
|
403
|
+
"description": "Query vectors from an index",
|
|
404
|
+
"tags": ["vector"],
|
|
405
|
+
"parameters": [{ "name": "vectorName", "in": "path", "required": true, "schema": { "type": "string" } }],
|
|
406
|
+
"requestBody": {
|
|
407
|
+
"required": true,
|
|
408
|
+
"content": {
|
|
409
|
+
"application/json": {
|
|
410
|
+
"schema": {
|
|
411
|
+
"type": "object",
|
|
412
|
+
"properties": {
|
|
413
|
+
"indexName": { "type": "string" },
|
|
414
|
+
"queryVector": { "type": "array", "items": { "type": "number" } },
|
|
415
|
+
"topK": { "type": "number" },
|
|
416
|
+
"filter": { "type": "object" },
|
|
417
|
+
"includeVector": { "type": "boolean" }
|
|
418
|
+
},
|
|
419
|
+
"required": ["indexName", "queryVector"]
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
},
|
|
426
|
+
"/api/vector/{vectorName}/indexes": {
|
|
427
|
+
"get": {
|
|
428
|
+
"responses": { "200": { "description": "List of indexes" } },
|
|
429
|
+
"operationId": "getApiVectorByVectorNameIndexes",
|
|
430
|
+
"description": "List all indexes for a vector store",
|
|
431
|
+
"tags": ["vector"],
|
|
432
|
+
"parameters": [{ "name": "vectorName", "in": "path", "required": true, "schema": { "type": "string" } }]
|
|
433
|
+
}
|
|
434
|
+
},
|
|
435
|
+
"/api/vector/{vectorName}/indexes/{indexName}": {
|
|
436
|
+
"get": {
|
|
437
|
+
"responses": { "200": { "description": "Index details" } },
|
|
438
|
+
"operationId": "getApiVectorByVectorNameIndexesByIndexName",
|
|
439
|
+
"description": "Get details about a specific index",
|
|
440
|
+
"tags": ["vector"],
|
|
441
|
+
"parameters": [
|
|
442
|
+
{ "name": "vectorName", "in": "path", "required": true, "schema": { "type": "string" } },
|
|
443
|
+
{ "name": "indexName", "in": "path", "required": true, "schema": { "type": "string" } }
|
|
444
|
+
]
|
|
445
|
+
},
|
|
446
|
+
"delete": {
|
|
447
|
+
"responses": { "200": { "description": "Index deleted successfully" } },
|
|
448
|
+
"operationId": "deleteApiVectorByVectorNameIndexesByIndexName",
|
|
449
|
+
"description": "Delete a specific index",
|
|
450
|
+
"tags": ["vector"],
|
|
451
|
+
"parameters": [
|
|
452
|
+
{ "name": "vectorName", "in": "path", "required": true, "schema": { "type": "string" } },
|
|
453
|
+
{ "name": "indexName", "in": "path", "required": true, "schema": { "type": "string" } }
|
|
454
|
+
]
|
|
455
|
+
}
|
|
344
456
|
}
|
|
345
457
|
},
|
|
346
458
|
"components": { "schemas": {} }
|