@vinaverse/server 0.0.0-stage → 0.1.0-alpha.1
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/README.md +165 -2
- package/dist/api.cjs +528 -0
- package/dist/api.cjs.map +1 -0
- package/dist/api.d.cts +453 -0
- package/dist/api.d.ts +453 -0
- package/dist/api.js +516 -0
- package/dist/api.js.map +1 -0
- package/dist/chunk-FEEJNQXV.js +64 -0
- package/dist/chunk-FEEJNQXV.js.map +1 -0
- package/dist/chunk-GTPMQKGX.js +277 -0
- package/dist/chunk-GTPMQKGX.js.map +1 -0
- package/dist/chunk-NPXO6SMZ.js +84 -0
- package/dist/chunk-NPXO6SMZ.js.map +1 -0
- package/dist/chunk-SDJFZPHJ.js +141 -0
- package/dist/chunk-SDJFZPHJ.js.map +1 -0
- package/dist/express.cjs +397 -0
- package/dist/express.cjs.map +1 -0
- package/dist/express.d.cts +43 -0
- package/dist/express.d.ts +43 -0
- package/dist/express.js +87 -0
- package/dist/express.js.map +1 -0
- package/dist/fastify.cjs +363 -0
- package/dist/fastify.cjs.map +1 -0
- package/dist/fastify.d.cts +62 -0
- package/dist/fastify.d.ts +62 -0
- package/dist/fastify.js +54 -0
- package/dist/fastify.js.map +1 -0
- package/dist/hono.cjs +421 -0
- package/dist/hono.cjs.map +1 -0
- package/dist/hono.d.cts +21 -0
- package/dist/hono.d.ts +21 -0
- package/dist/hono.js +34 -0
- package/dist/hono.js.map +1 -0
- package/dist/index.cjs +1481 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +196 -0
- package/dist/index.d.ts +196 -0
- package/dist/index.js +920 -0
- package/dist/index.js.map +1 -0
- package/dist/lambda.cjs +405 -0
- package/dist/lambda.cjs.map +1 -0
- package/dist/lambda.d.cts +53 -0
- package/dist/lambda.d.ts +53 -0
- package/dist/lambda.js +86 -0
- package/dist/lambda.js.map +1 -0
- package/dist/nonces-scwljZwl.d.cts +92 -0
- package/dist/nonces-scwljZwl.d.ts +92 -0
- package/dist/provider-BqfTvF3g.d.ts +2016 -0
- package/dist/provider-Miaa9V7I.d.cts +2016 -0
- package/dist/stores.cjs +315 -0
- package/dist/stores.cjs.map +1 -0
- package/dist/stores.d.cts +52 -0
- package/dist/stores.d.ts +52 -0
- package/dist/stores.js +306 -0
- package/dist/stores.js.map +1 -0
- package/dist/testing.cjs +135 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +29 -0
- package/dist/testing.d.ts +29 -0
- package/dist/testing.js +49 -0
- package/dist/testing.js.map +1 -0
- package/dist/vinaverse-v1.d-BVc4uyUd.d.cts +3460 -0
- package/dist/vinaverse-v1.d-BVc4uyUd.d.ts +3460 -0
- package/package.json +226 -4
package/dist/hono.d.cts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { T as ToolProvider, W as WebhookHandlerOptions } from './provider-Miaa9V7I.cjs';
|
|
2
|
+
import './vinaverse-v1.d-BVc4uyUd.cjs';
|
|
3
|
+
import './nonces-scwljZwl.cjs';
|
|
4
|
+
|
|
5
|
+
/** The part of Hono's `Context` the handler uses. */
|
|
6
|
+
interface HonoContextLike {
|
|
7
|
+
req: {
|
|
8
|
+
raw: Request;
|
|
9
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
declare function vinaverseWebhook(options: WebhookHandlerOptions): (c: HonoContextLike) => Promise<Response>;
|
|
13
|
+
/**
|
|
14
|
+
* Serves a tenant's tools on every route below the provider's `basePath`:
|
|
15
|
+
* `app.all('/api/v2/ai/*', vinaverseTools(provider))`.
|
|
16
|
+
*/
|
|
17
|
+
declare function vinaverseTools(provider: ToolProvider, options?: {
|
|
18
|
+
maxBodyBytes?: number;
|
|
19
|
+
}): (c: HonoContextLike) => Promise<Response>;
|
|
20
|
+
|
|
21
|
+
export { type HonoContextLike, WebhookHandlerOptions, vinaverseTools, vinaverseWebhook };
|
package/dist/hono.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { T as ToolProvider, W as WebhookHandlerOptions } from './provider-BqfTvF3g.js';
|
|
2
|
+
import './vinaverse-v1.d-BVc4uyUd.js';
|
|
3
|
+
import './nonces-scwljZwl.js';
|
|
4
|
+
|
|
5
|
+
/** The part of Hono's `Context` the handler uses. */
|
|
6
|
+
interface HonoContextLike {
|
|
7
|
+
req: {
|
|
8
|
+
raw: Request;
|
|
9
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
declare function vinaverseWebhook(options: WebhookHandlerOptions): (c: HonoContextLike) => Promise<Response>;
|
|
13
|
+
/**
|
|
14
|
+
* Serves a tenant's tools on every route below the provider's `basePath`:
|
|
15
|
+
* `app.all('/api/v2/ai/*', vinaverseTools(provider))`.
|
|
16
|
+
*/
|
|
17
|
+
declare function vinaverseTools(provider: ToolProvider, options?: {
|
|
18
|
+
maxBodyBytes?: number;
|
|
19
|
+
}): (c: HonoContextLike) => Promise<Response>;
|
|
20
|
+
|
|
21
|
+
export { type HonoContextLike, WebhookHandlerOptions, vinaverseTools, vinaverseWebhook };
|
package/dist/hono.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createFetchWebhookHandler, createFetchToolHandler } from './chunk-NPXO6SMZ.js';
|
|
2
|
+
import './chunk-FEEJNQXV.js';
|
|
3
|
+
import './chunk-GTPMQKGX.js';
|
|
4
|
+
|
|
5
|
+
// src/adapters/hono.ts
|
|
6
|
+
function vinaverseWebhook(options) {
|
|
7
|
+
const handle = createFetchWebhookHandler(options);
|
|
8
|
+
return async (c) => {
|
|
9
|
+
if (!c.req.raw.bodyUsed) return handle(c.req.raw);
|
|
10
|
+
const body = await c.req.arrayBuffer();
|
|
11
|
+
return handle(
|
|
12
|
+
new Request(c.req.raw.url, {
|
|
13
|
+
method: "POST",
|
|
14
|
+
headers: c.req.raw.headers,
|
|
15
|
+
body
|
|
16
|
+
})
|
|
17
|
+
);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function vinaverseTools(provider, options = {}) {
|
|
21
|
+
const handle = createFetchToolHandler(provider, options);
|
|
22
|
+
return async (c) => {
|
|
23
|
+
if (!c.req.raw.bodyUsed) return handle(c.req.raw);
|
|
24
|
+
const { method } = c.req.raw;
|
|
25
|
+
const hasBody = method !== "GET" && method !== "HEAD";
|
|
26
|
+
const init = { method, headers: c.req.raw.headers };
|
|
27
|
+
if (hasBody) init.body = await c.req.arrayBuffer();
|
|
28
|
+
return handle(new Request(c.req.raw.url, init));
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { vinaverseTools, vinaverseWebhook };
|
|
33
|
+
//# sourceMappingURL=hono.js.map
|
|
34
|
+
//# sourceMappingURL=hono.js.map
|
package/dist/hono.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/adapters/hono.ts"],"names":[],"mappings":";;;;;AAaO,SAAS,iBACd,OAAA,EAC2C;AAC3C,EAAA,MAAM,MAAA,GAAS,0BAA0B,OAAO,CAAA;AAChD,EAAA,OAAO,OAAO,CAAA,KAAM;AAClB,IAAA,IAAI,CAAC,EAAE,GAAA,CAAI,GAAA,CAAI,UAAU,OAAO,MAAA,CAAO,CAAA,CAAE,GAAA,CAAI,GAAG,CAAA;AAGhD,IAAA,MAAM,IAAA,GAAO,MAAM,CAAA,CAAE,GAAA,CAAI,WAAA,EAAY;AACrC,IAAA,OAAO,MAAA;AAAA,MACL,IAAI,OAAA,CAAQ,CAAA,CAAE,GAAA,CAAI,IAAI,GAAA,EAAK;AAAA,QACzB,MAAA,EAAQ,MAAA;AAAA,QACR,OAAA,EAAS,CAAA,CAAE,GAAA,CAAI,GAAA,CAAI,OAAA;AAAA,QACnB;AAAA,OACD;AAAA,KACH;AAAA,EACF,CAAA;AACF;AAMO,SAAS,cAAA,CACd,QAAA,EACA,OAAA,GAAqC,EAAC,EACK;AAC3C,EAAA,MAAM,MAAA,GAAS,sBAAA,CAAuB,QAAA,EAAU,OAAO,CAAA;AACvD,EAAA,OAAO,OAAO,CAAA,KAAM;AAClB,IAAA,IAAI,CAAC,EAAE,GAAA,CAAI,GAAA,CAAI,UAAU,OAAO,MAAA,CAAO,CAAA,CAAE,GAAA,CAAI,GAAG,CAAA;AAEhD,IAAA,MAAM,EAAE,MAAA,EAAO,GAAI,CAAA,CAAE,GAAA,CAAI,GAAA;AACzB,IAAA,MAAM,OAAA,GAAU,MAAA,KAAW,KAAA,IAAS,MAAA,KAAW,MAAA;AAC/C,IAAA,MAAM,OAAoB,EAAE,MAAA,EAAQ,SAAS,CAAA,CAAE,GAAA,CAAI,IAAI,OAAA,EAAQ;AAC/D,IAAA,IAAI,SAAS,IAAA,CAAK,IAAA,GAAO,MAAM,CAAA,CAAE,IAAI,WAAA,EAAY;AACjD,IAAA,OAAO,MAAA,CAAO,IAAI,OAAA,CAAQ,CAAA,CAAE,IAAI,GAAA,CAAI,GAAA,EAAK,IAAI,CAAC,CAAA;AAAA,EAChD,CAAA;AACF","file":"hono.js","sourcesContent":["// Hono: a handler for a route, `app.post('/webhooks/vinaverse', vinaverseWebhook({ secret, onEvent }))`.\n// It reads the raw request (`c.req.raw`), so no body parser may run before it.\nimport type { ToolProvider } from '../tools/provider.js';\nimport { createFetchToolHandler, createFetchWebhookHandler } from './fetch.js';\nimport type { WebhookHandlerOptions } from './handler.js';\n\nexport type { WebhookHandlerOptions } from './handler.js';\n\n/** The part of Hono's `Context` the handler uses. */\nexport interface HonoContextLike {\n req: { raw: Request; arrayBuffer(): Promise<ArrayBuffer> };\n}\n\nexport function vinaverseWebhook(\n options: WebhookHandlerOptions,\n): (c: HonoContextLike) => Promise<Response> {\n const handle = createFetchWebhookHandler(options);\n return async (c) => {\n if (!c.req.raw.bodyUsed) return handle(c.req.raw); // streamed, with the size cap\n // An earlier middleware read the body (c.req.json(), say): Hono kept the\n // bytes, so the handler verifies those, still within the size cap.\n const body = await c.req.arrayBuffer();\n return handle(\n new Request(c.req.raw.url, {\n method: 'POST',\n headers: c.req.raw.headers,\n body,\n }),\n );\n };\n}\n\n/**\n * Serves a tenant's tools on every route below the provider's `basePath`:\n * `app.all('/api/v2/ai/*', vinaverseTools(provider))`.\n */\nexport function vinaverseTools(\n provider: ToolProvider,\n options: { maxBodyBytes?: number } = {},\n): (c: HonoContextLike) => Promise<Response> {\n const handle = createFetchToolHandler(provider, options);\n return async (c) => {\n if (!c.req.raw.bodyUsed) return handle(c.req.raw); // streamed, with the size cap\n // An earlier middleware read the body: Hono kept the bytes; still capped.\n const { method } = c.req.raw;\n const hasBody = method !== 'GET' && method !== 'HEAD';\n const init: RequestInit = { method, headers: c.req.raw.headers };\n if (hasBody) init.body = await c.req.arrayBuffer();\n return handle(new Request(c.req.raw.url, init));\n };\n}\n"]}
|