@mastra/deployer 1.37.0-alpha.1 → 1.37.0-alpha.3
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/_types/@hono_node-server/dist/index.d.ts +8 -0
- package/dist/_types/@hono_node-server/dist/listener.d.ts +13 -0
- package/dist/_types/@hono_node-server/dist/request.d.ts +25 -0
- package/dist/_types/@hono_node-server/dist/server.d.ts +10 -0
- package/dist/_types/@hono_node-server/dist/types.d.ts +44 -0
- package/dist/_types/@mastra_hono/dist/auth-middleware.d.ts +8 -0
- package/dist/_types/@mastra_hono/dist/browser-stream/index.d.ts +35 -0
- package/dist/_types/@mastra_hono/dist/index.d.ts +59 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/server/index.cjs +16 -205
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.js +12 -201
- package/dist/server/index.js.map +1 -1
- package/package.json +6 -6
package/dist/server/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Mastra } from '@mastra/core/mastra';
|
|
2
|
-
import type { HonoBindings, HonoVariables } from '
|
|
2
|
+
import type { HonoBindings, HonoVariables } from '../_types/@mastra_hono/dist/index.d.ts';
|
|
3
3
|
import { Hono } from 'hono';
|
|
4
4
|
import type { ServerBundleOptions } from './types.js';
|
|
5
5
|
type Bindings = HonoBindings;
|
|
@@ -13,6 +13,6 @@ export declare function createHonoServer(mastra: Mastra, options?: ServerBundleO
|
|
|
13
13
|
Bindings: Bindings;
|
|
14
14
|
Variables: Variables;
|
|
15
15
|
}, import("hono/types").BlankSchema, "/">>;
|
|
16
|
-
export declare function createNodeServer(mastra: Mastra, options?: ServerBundleOptions): Promise<import("
|
|
16
|
+
export declare function createNodeServer(mastra: Mastra, options?: ServerBundleOptions): Promise<import("../_types/@hono_node-server/dist/index.d.ts").ServerType>;
|
|
17
17
|
export {};
|
|
18
18
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/server/index.js
CHANGED
|
@@ -12,9 +12,11 @@ import { existsSync, createReadStream, statSync } from 'fs';
|
|
|
12
12
|
import { versions } from 'process';
|
|
13
13
|
import { html } from 'hono/html';
|
|
14
14
|
import { Tool } from '@mastra/core/tools';
|
|
15
|
-
import { MastraServer as MastraServer$1, normalizeQueryParams, checkRouteFGA
|
|
15
|
+
import { MastraServer as MastraServer$1, redactStreamChunk, normalizeQueryParams, checkRouteFGA } from '@mastra/server/server-adapter';
|
|
16
16
|
import util from 'util';
|
|
17
17
|
import { Buffer as Buffer$1 } from 'buffer';
|
|
18
|
+
import { bodyLimit } from 'hono/body-limit';
|
|
19
|
+
import { stream } from 'hono/streaming';
|
|
18
20
|
import { findMatchingCustomRoute } from '@mastra/server/auth';
|
|
19
21
|
import { ViewerRegistry, handleInputMessage } from '@mastra/server/browser-stream';
|
|
20
22
|
import { InMemoryTaskStore } from '@mastra/server/a2a/store';
|
|
@@ -23,7 +25,7 @@ import { compress } from 'hono/compress';
|
|
|
23
25
|
import { cors } from 'hono/cors';
|
|
24
26
|
import { logger } from 'hono/logger';
|
|
25
27
|
import { timeout } from 'hono/timeout';
|
|
26
|
-
import { HTTPException
|
|
28
|
+
import { HTTPException } from 'hono/http-exception';
|
|
27
29
|
|
|
28
30
|
var RequestError = class extends Error {
|
|
29
31
|
constructor(message, options) {
|
|
@@ -38,7 +40,7 @@ var toRequestError = (e) => {
|
|
|
38
40
|
return new RequestError(e.message, { cause: e });
|
|
39
41
|
};
|
|
40
42
|
var GlobalRequest = global.Request;
|
|
41
|
-
var
|
|
43
|
+
var Request = class extends GlobalRequest {
|
|
42
44
|
constructor(input, options) {
|
|
43
45
|
if (typeof input === "object" && getRequestCache in input) {
|
|
44
46
|
input = input[getRequestCache]();
|
|
@@ -70,7 +72,7 @@ var newRequestFromIncoming = (method, url, headers, incoming, abortController) =
|
|
|
70
72
|
};
|
|
71
73
|
if (method === "TRACE") {
|
|
72
74
|
init.method = "GET";
|
|
73
|
-
const req = new
|
|
75
|
+
const req = new Request(url, init);
|
|
74
76
|
Object.defineProperty(req, "method", {
|
|
75
77
|
get() {
|
|
76
78
|
return "TRACE";
|
|
@@ -107,7 +109,7 @@ var newRequestFromIncoming = (method, url, headers, incoming, abortController) =
|
|
|
107
109
|
init.body = Readable.toWeb(incoming);
|
|
108
110
|
}
|
|
109
111
|
}
|
|
110
|
-
return new
|
|
112
|
+
return new Request(url, init);
|
|
111
113
|
};
|
|
112
114
|
var getRequestCache = /* @__PURE__ */ Symbol("getRequestCache");
|
|
113
115
|
var requestCache = /* @__PURE__ */ Symbol("requestCache");
|
|
@@ -179,7 +181,7 @@ Object.defineProperty(requestPrototype, /* @__PURE__ */ Symbol.for("nodejs.util.
|
|
|
179
181
|
return `Request (lightweight) ${inspectFn(props, { ...options, depth: depth == null ? null : depth - 1 })}`;
|
|
180
182
|
}
|
|
181
183
|
});
|
|
182
|
-
Object.setPrototypeOf(requestPrototype,
|
|
184
|
+
Object.setPrototypeOf(requestPrototype, Request.prototype);
|
|
183
185
|
var newRequest = (incoming, defaultHostname) => {
|
|
184
186
|
const req = Object.create(requestPrototype);
|
|
185
187
|
req[incomingKey] = incoming;
|
|
@@ -548,9 +550,9 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
|
|
|
548
550
|
};
|
|
549
551
|
var getRequestListener = (fetchCallback, options = {}) => {
|
|
550
552
|
const autoCleanupIncoming = options.autoCleanupIncoming ?? true;
|
|
551
|
-
if (options.overrideGlobalObjects !== false && global.Request !==
|
|
553
|
+
if (options.overrideGlobalObjects !== false && global.Request !== Request) {
|
|
552
554
|
Object.defineProperty(global, "Request", {
|
|
553
|
-
value:
|
|
555
|
+
value: Request
|
|
554
556
|
});
|
|
555
557
|
Object.defineProperty(global, "Response", {
|
|
556
558
|
value: Response2
|
|
@@ -2757,197 +2759,6 @@ function toFetchResponse(res) {
|
|
|
2757
2759
|
}
|
|
2758
2760
|
return res.fetchResponse;
|
|
2759
2761
|
}
|
|
2760
|
-
var HTTPException = class extends Error {
|
|
2761
|
-
res;
|
|
2762
|
-
status;
|
|
2763
|
-
/**
|
|
2764
|
-
* Creates an instance of `HTTPException`.
|
|
2765
|
-
* @param status - HTTP status code for the exception. Defaults to 500.
|
|
2766
|
-
* @param options - Additional options for the exception.
|
|
2767
|
-
*/
|
|
2768
|
-
constructor(status = 500, options) {
|
|
2769
|
-
super(options?.message, { cause: options?.cause });
|
|
2770
|
-
this.res = options?.res;
|
|
2771
|
-
this.status = status;
|
|
2772
|
-
}
|
|
2773
|
-
/**
|
|
2774
|
-
* Returns the response object associated with the exception.
|
|
2775
|
-
* If a response object is not provided, a new response is created with the error message and status code.
|
|
2776
|
-
* @returns The response object.
|
|
2777
|
-
*/
|
|
2778
|
-
getResponse() {
|
|
2779
|
-
if (this.res) {
|
|
2780
|
-
const newResponse = new Response(this.res.body, {
|
|
2781
|
-
status: this.status,
|
|
2782
|
-
headers: this.res.headers
|
|
2783
|
-
});
|
|
2784
|
-
return newResponse;
|
|
2785
|
-
}
|
|
2786
|
-
return new Response(this.message, {
|
|
2787
|
-
status: this.status
|
|
2788
|
-
});
|
|
2789
|
-
}
|
|
2790
|
-
};
|
|
2791
|
-
var ERROR_MESSAGE = "Payload Too Large";
|
|
2792
|
-
var bodyLimit = (options) => {
|
|
2793
|
-
const onError3 = options.onError || (() => {
|
|
2794
|
-
const res = new Response(ERROR_MESSAGE, {
|
|
2795
|
-
status: 413
|
|
2796
|
-
});
|
|
2797
|
-
throw new HTTPException(413, { res });
|
|
2798
|
-
});
|
|
2799
|
-
const maxSize = options.maxSize;
|
|
2800
|
-
return async function bodyLimit2(c, next) {
|
|
2801
|
-
if (!c.req.raw.body) {
|
|
2802
|
-
return next();
|
|
2803
|
-
}
|
|
2804
|
-
const hasTransferEncoding = c.req.raw.headers.has("transfer-encoding");
|
|
2805
|
-
const hasContentLength = c.req.raw.headers.has("content-length");
|
|
2806
|
-
if (hasContentLength && !hasTransferEncoding) {
|
|
2807
|
-
const contentLength = parseInt(c.req.raw.headers.get("content-length") || "0", 10);
|
|
2808
|
-
return contentLength > maxSize ? onError3(c) : next();
|
|
2809
|
-
}
|
|
2810
|
-
let size = 0;
|
|
2811
|
-
const chunks = [];
|
|
2812
|
-
const rawReader = c.req.raw.body.getReader();
|
|
2813
|
-
for (; ; ) {
|
|
2814
|
-
const { done, value } = await rawReader.read();
|
|
2815
|
-
if (done) {
|
|
2816
|
-
break;
|
|
2817
|
-
}
|
|
2818
|
-
size += value.length;
|
|
2819
|
-
if (size > maxSize) {
|
|
2820
|
-
return onError3(c);
|
|
2821
|
-
}
|
|
2822
|
-
chunks.push(value);
|
|
2823
|
-
}
|
|
2824
|
-
const requestInit = {
|
|
2825
|
-
body: new ReadableStream({
|
|
2826
|
-
start(controller) {
|
|
2827
|
-
for (const chunk of chunks) {
|
|
2828
|
-
controller.enqueue(chunk);
|
|
2829
|
-
}
|
|
2830
|
-
controller.close();
|
|
2831
|
-
}
|
|
2832
|
-
}),
|
|
2833
|
-
duplex: "half"
|
|
2834
|
-
};
|
|
2835
|
-
c.req.raw = new Request(c.req.raw, requestInit);
|
|
2836
|
-
return next();
|
|
2837
|
-
};
|
|
2838
|
-
};
|
|
2839
|
-
var StreamingApi = class {
|
|
2840
|
-
writer;
|
|
2841
|
-
encoder;
|
|
2842
|
-
writable;
|
|
2843
|
-
abortSubscribers = [];
|
|
2844
|
-
responseReadable;
|
|
2845
|
-
/**
|
|
2846
|
-
* Whether the stream has been aborted.
|
|
2847
|
-
*/
|
|
2848
|
-
aborted = false;
|
|
2849
|
-
/**
|
|
2850
|
-
* Whether the stream has been closed normally.
|
|
2851
|
-
*/
|
|
2852
|
-
closed = false;
|
|
2853
|
-
constructor(writable, _readable) {
|
|
2854
|
-
this.writable = writable;
|
|
2855
|
-
this.writer = writable.getWriter();
|
|
2856
|
-
this.encoder = new TextEncoder();
|
|
2857
|
-
const reader = _readable.getReader();
|
|
2858
|
-
this.abortSubscribers.push(async () => {
|
|
2859
|
-
await reader.cancel();
|
|
2860
|
-
});
|
|
2861
|
-
this.responseReadable = new ReadableStream({
|
|
2862
|
-
async pull(controller) {
|
|
2863
|
-
const { done, value } = await reader.read();
|
|
2864
|
-
done ? controller.close() : controller.enqueue(value);
|
|
2865
|
-
},
|
|
2866
|
-
cancel: () => {
|
|
2867
|
-
this.abort();
|
|
2868
|
-
}
|
|
2869
|
-
});
|
|
2870
|
-
}
|
|
2871
|
-
async write(input) {
|
|
2872
|
-
try {
|
|
2873
|
-
if (typeof input === "string") {
|
|
2874
|
-
input = this.encoder.encode(input);
|
|
2875
|
-
}
|
|
2876
|
-
await this.writer.write(input);
|
|
2877
|
-
} catch {
|
|
2878
|
-
}
|
|
2879
|
-
return this;
|
|
2880
|
-
}
|
|
2881
|
-
async writeln(input) {
|
|
2882
|
-
await this.write(input + "\n");
|
|
2883
|
-
return this;
|
|
2884
|
-
}
|
|
2885
|
-
sleep(ms) {
|
|
2886
|
-
return new Promise((res) => setTimeout(res, ms));
|
|
2887
|
-
}
|
|
2888
|
-
async close() {
|
|
2889
|
-
try {
|
|
2890
|
-
await this.writer.close();
|
|
2891
|
-
} catch {
|
|
2892
|
-
}
|
|
2893
|
-
this.closed = true;
|
|
2894
|
-
}
|
|
2895
|
-
async pipe(body) {
|
|
2896
|
-
this.writer.releaseLock();
|
|
2897
|
-
await body.pipeTo(this.writable, { preventClose: true });
|
|
2898
|
-
this.writer = this.writable.getWriter();
|
|
2899
|
-
}
|
|
2900
|
-
onAbort(listener) {
|
|
2901
|
-
this.abortSubscribers.push(listener);
|
|
2902
|
-
}
|
|
2903
|
-
/**
|
|
2904
|
-
* Abort the stream.
|
|
2905
|
-
* You can call this method when stream is aborted by external event.
|
|
2906
|
-
*/
|
|
2907
|
-
abort() {
|
|
2908
|
-
if (!this.aborted) {
|
|
2909
|
-
this.aborted = true;
|
|
2910
|
-
this.abortSubscribers.forEach((subscriber) => subscriber());
|
|
2911
|
-
}
|
|
2912
|
-
}
|
|
2913
|
-
};
|
|
2914
|
-
var isOldBunVersion = () => {
|
|
2915
|
-
const version2 = typeof Bun !== "undefined" ? Bun.version : void 0;
|
|
2916
|
-
if (version2 === void 0) {
|
|
2917
|
-
return false;
|
|
2918
|
-
}
|
|
2919
|
-
const result = version2.startsWith("1.1") || version2.startsWith("1.0") || version2.startsWith("0.");
|
|
2920
|
-
isOldBunVersion = () => result;
|
|
2921
|
-
return result;
|
|
2922
|
-
};
|
|
2923
|
-
var contextStash = /* @__PURE__ */ new WeakMap();
|
|
2924
|
-
var stream = (c, cb, onError3) => {
|
|
2925
|
-
const { readable, writable } = new TransformStream();
|
|
2926
|
-
const stream2 = new StreamingApi(writable, readable);
|
|
2927
|
-
if (isOldBunVersion()) {
|
|
2928
|
-
c.req.raw.signal.addEventListener("abort", () => {
|
|
2929
|
-
if (!stream2.closed) {
|
|
2930
|
-
stream2.abort();
|
|
2931
|
-
}
|
|
2932
|
-
});
|
|
2933
|
-
}
|
|
2934
|
-
contextStash.set(stream2.responseReadable, c);
|
|
2935
|
-
(async () => {
|
|
2936
|
-
try {
|
|
2937
|
-
await cb(stream2);
|
|
2938
|
-
} catch (e) {
|
|
2939
|
-
if (e === void 0) ;
|
|
2940
|
-
else if (e instanceof Error && onError3) {
|
|
2941
|
-
await onError3(e, stream2);
|
|
2942
|
-
} else {
|
|
2943
|
-
console.error(e);
|
|
2944
|
-
}
|
|
2945
|
-
} finally {
|
|
2946
|
-
stream2.close();
|
|
2947
|
-
}
|
|
2948
|
-
})();
|
|
2949
|
-
return c.newResponse(stream2.responseReadable);
|
|
2950
|
-
};
|
|
2951
2762
|
// @__NO_SIDE_EFFECTS__
|
|
2952
2763
|
function $constructor(name, initializer3, params) {
|
|
2953
2764
|
function init(inst, def) {
|
|
@@ -3854,13 +3665,13 @@ function isHotReloadDisabled() {
|
|
|
3854
3665
|
}
|
|
3855
3666
|
function handleError(error, defaultMessage) {
|
|
3856
3667
|
const apiError = error;
|
|
3857
|
-
throw new HTTPException
|
|
3668
|
+
throw new HTTPException(apiError.status || 500, {
|
|
3858
3669
|
message: apiError.message || defaultMessage,
|
|
3859
3670
|
cause: apiError.cause
|
|
3860
3671
|
});
|
|
3861
3672
|
}
|
|
3862
3673
|
function errorHandler(err, c, isDev) {
|
|
3863
|
-
if (err instanceof HTTPException
|
|
3674
|
+
if (err instanceof HTTPException) {
|
|
3864
3675
|
if (isDev) {
|
|
3865
3676
|
return c.json({ error: err.message, cause: err.cause, stack: err.stack }, err.status);
|
|
3866
3677
|
}
|