@dbx-tools/appkit-mastra 0.1.39 → 0.1.40
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/dist/src/plugin.d.ts +10 -0
- package/dist/src/plugin.js +23 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/src/plugin.ts +28 -1
package/dist/src/plugin.d.ts
CHANGED
|
@@ -109,6 +109,16 @@ export declare class MastraPlugin extends Plugin<MastraPluginConfig> {
|
|
|
109
109
|
};
|
|
110
110
|
clientConfig(): Record<string, unknown>;
|
|
111
111
|
injectRoutes(router: IAppRouter): void;
|
|
112
|
+
/**
|
|
113
|
+
* Invoke the Mastra express sub-app. Exists as a method (instead of reading
|
|
114
|
+
* `this.mastraApp` through the `asUser(req)` proxy at the call site) so the
|
|
115
|
+
* proxy binds this plain method - whose `.bind` is `Function.prototype.bind`
|
|
116
|
+
* - rather than the express app, whose `.bind` is the HTTP BIND route
|
|
117
|
+
* registrar (see the note in `injectRoutes`). Runs inside the user scope so
|
|
118
|
+
* `getExecutionContext()` returns the OBO client for the agent/model
|
|
119
|
+
* resolvers.
|
|
120
|
+
*/
|
|
121
|
+
private dispatchMastra;
|
|
112
122
|
/**
|
|
113
123
|
* Implementation backing the `/suggestions` route. Runs inside the
|
|
114
124
|
* AppKit user-context proxy so `getExecutionContext()` returns the
|
package/dist/src/plugin.js
CHANGED
|
@@ -300,9 +300,31 @@ export class MastraPlugin extends Plugin {
|
|
|
300
300
|
router.use((req, res, next) => {
|
|
301
301
|
if (!this.mastraApp)
|
|
302
302
|
return res.status(503).end();
|
|
303
|
-
|
|
303
|
+
// Dispatch through a real method, NOT the `mastraApp` property. The
|
|
304
|
+
// AppKit `asUser(req)` proxy wraps function-valued props with
|
|
305
|
+
// `value.bind(target)`. `mastraApp` is an express app whose `.bind` is
|
|
306
|
+
// the HTTP BIND route registrar (express defines a method per HTTP verb,
|
|
307
|
+
// and BIND is one), not `Function.prototype.bind` - so binding it through
|
|
308
|
+
// the proxy registers a bogus route and crashes `pathToRegexp`
|
|
309
|
+
// ("path must be a string ..."). This only manifests in production where
|
|
310
|
+
// an OBO token makes `userScopedSelf` return the proxy. `dispatchMastra`
|
|
311
|
+
// is a plain method (its `.bind` is the normal one) and invokes
|
|
312
|
+
// `this.mastraApp` off the real target, keeping the OBO scope active.
|
|
313
|
+
return this.userScopedSelf(req).dispatchMastra(req, res, next);
|
|
304
314
|
});
|
|
305
315
|
}
|
|
316
|
+
/**
|
|
317
|
+
* Invoke the Mastra express sub-app. Exists as a method (instead of reading
|
|
318
|
+
* `this.mastraApp` through the `asUser(req)` proxy at the call site) so the
|
|
319
|
+
* proxy binds this plain method - whose `.bind` is `Function.prototype.bind`
|
|
320
|
+
* - rather than the express app, whose `.bind` is the HTTP BIND route
|
|
321
|
+
* registrar (see the note in `injectRoutes`). Runs inside the user scope so
|
|
322
|
+
* `getExecutionContext()` returns the OBO client for the agent/model
|
|
323
|
+
* resolvers.
|
|
324
|
+
*/
|
|
325
|
+
dispatchMastra(req, res, next) {
|
|
326
|
+
this.mastraApp(req, res, next);
|
|
327
|
+
}
|
|
306
328
|
/**
|
|
307
329
|
* Implementation backing the `/suggestions` route. Runs inside the
|
|
308
330
|
* AppKit user-context proxy so `getExecutionContext()` returns the
|