@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/package.json
CHANGED
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
}
|
|
10
10
|
},
|
|
11
11
|
"name": "@dbx-tools/appkit-mastra",
|
|
12
|
-
"version": "0.1.
|
|
12
|
+
"version": "0.1.40",
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@databricks/sdk-experimental": "^0.17",
|
|
15
|
-
"@dbx-tools/appkit-mastra-shared": "0.1.
|
|
16
|
-
"@dbx-tools/genie": "0.1.
|
|
17
|
-
"@dbx-tools/genie-shared": "0.1.
|
|
18
|
-
"@dbx-tools/shared": "0.1.
|
|
15
|
+
"@dbx-tools/appkit-mastra-shared": "0.1.40",
|
|
16
|
+
"@dbx-tools/genie": "0.1.40",
|
|
17
|
+
"@dbx-tools/genie-shared": "0.1.40",
|
|
18
|
+
"@dbx-tools/shared": "0.1.40",
|
|
19
19
|
"@mastra/ai-sdk": "^1",
|
|
20
20
|
"@mastra/core": "^1",
|
|
21
21
|
"@mastra/express": "^1",
|
package/src/plugin.ts
CHANGED
|
@@ -339,10 +339,37 @@ export class MastraPlugin extends Plugin<MastraPluginConfig> {
|
|
|
339
339
|
|
|
340
340
|
router.use((req, res, next) => {
|
|
341
341
|
if (!this.mastraApp) return res.status(503).end();
|
|
342
|
-
|
|
342
|
+
// Dispatch through a real method, NOT the `mastraApp` property. The
|
|
343
|
+
// AppKit `asUser(req)` proxy wraps function-valued props with
|
|
344
|
+
// `value.bind(target)`. `mastraApp` is an express app whose `.bind` is
|
|
345
|
+
// the HTTP BIND route registrar (express defines a method per HTTP verb,
|
|
346
|
+
// and BIND is one), not `Function.prototype.bind` - so binding it through
|
|
347
|
+
// the proxy registers a bogus route and crashes `pathToRegexp`
|
|
348
|
+
// ("path must be a string ..."). This only manifests in production where
|
|
349
|
+
// an OBO token makes `userScopedSelf` return the proxy. `dispatchMastra`
|
|
350
|
+
// is a plain method (its `.bind` is the normal one) and invokes
|
|
351
|
+
// `this.mastraApp` off the real target, keeping the OBO scope active.
|
|
352
|
+
return this.userScopedSelf(req).dispatchMastra(req, res, next);
|
|
343
353
|
});
|
|
344
354
|
}
|
|
345
355
|
|
|
356
|
+
/**
|
|
357
|
+
* Invoke the Mastra express sub-app. Exists as a method (instead of reading
|
|
358
|
+
* `this.mastraApp` through the `asUser(req)` proxy at the call site) so the
|
|
359
|
+
* proxy binds this plain method - whose `.bind` is `Function.prototype.bind`
|
|
360
|
+
* - rather than the express app, whose `.bind` is the HTTP BIND route
|
|
361
|
+
* registrar (see the note in `injectRoutes`). Runs inside the user scope so
|
|
362
|
+
* `getExecutionContext()` returns the OBO client for the agent/model
|
|
363
|
+
* resolvers.
|
|
364
|
+
*/
|
|
365
|
+
private dispatchMastra(
|
|
366
|
+
req: express.Request,
|
|
367
|
+
res: express.Response,
|
|
368
|
+
next: express.NextFunction,
|
|
369
|
+
): void {
|
|
370
|
+
this.mastraApp!(req, res, next);
|
|
371
|
+
}
|
|
372
|
+
|
|
346
373
|
/**
|
|
347
374
|
* Implementation backing the `/suggestions` route. Runs inside the
|
|
348
375
|
* AppKit user-context proxy so `getExecutionContext()` returns the
|