@dbx-tools/appkit-mastra 0.3.3 → 0.3.5

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 CHANGED
@@ -278,6 +278,13 @@ Use `serving.extractModelOverride()` and `serving.resolveServingConfig()` when
278
278
  building custom routes that should behave like the plugin's `/models` and stream
279
279
  routes.
280
280
 
281
+ The plugin also serves `GET /default-model` (and `/default-model/:agentId`),
282
+ returning `{ agentId, model, displayName }` - the static serving-endpoint an
283
+ agent falls back to when the client pins no model, plus its humanized label.
284
+ `model` / `displayName` are `null` when the agent resolves its model
285
+ dynamically at call time. This lets a model picker label its default option
286
+ without waiting on the `/models` catalogue (so it never flashes a raw id).
287
+
281
288
  ## Threads, History, And Suggestions
282
289
 
283
290
  When storage is enabled, the plugin provides route helpers and in-process
package/package.json CHANGED
@@ -27,22 +27,22 @@
27
27
  "@opentelemetry/api": "^1.9.1",
28
28
  "pg": "^8.22.0",
29
29
  "zod": "^4.3.6",
30
- "@dbx-tools/appkit": "0.3.3",
31
- "@dbx-tools/databricks": "0.3.3",
32
- "@dbx-tools/model": "0.3.3",
33
- "@dbx-tools/shared-genie": "0.3.3",
34
- "@dbx-tools/shared-core": "0.3.3",
35
- "@dbx-tools/core": "0.3.3",
36
- "@dbx-tools/genie": "0.3.3",
37
- "@dbx-tools/shared-mastra": "0.3.3",
38
- "@dbx-tools/shared-model": "0.3.3"
30
+ "@dbx-tools/appkit": "0.3.5",
31
+ "@dbx-tools/core": "0.3.5",
32
+ "@dbx-tools/genie": "0.3.5",
33
+ "@dbx-tools/databricks": "0.3.5",
34
+ "@dbx-tools/model": "0.3.5",
35
+ "@dbx-tools/shared-core": "0.3.5",
36
+ "@dbx-tools/shared-genie": "0.3.5",
37
+ "@dbx-tools/shared-mastra": "0.3.5",
38
+ "@dbx-tools/shared-model": "0.3.5"
39
39
  },
40
40
  "main": "index.ts",
41
41
  "license": "UNLICENSED",
42
42
  "publishConfig": {
43
43
  "access": "public"
44
44
  },
45
- "version": "0.3.3",
45
+ "version": "0.3.5",
46
46
  "types": "index.ts",
47
47
  "type": "module",
48
48
  "exports": {
package/src/agents.ts CHANGED
@@ -331,8 +331,9 @@ export interface BuiltAgents {
331
331
  /**
332
332
  * Static default serving-endpoint id per agent id, as resolved by
333
333
  * {@link describeAgentDefaultModel}. `"<dynamic>"` when the model is a
334
- * function decided at call time. Surfaced so `clientConfig()` can label
335
- * the picker's "Server default" option with the real endpoint.
334
+ * function decided at call time. Consumed by the plugin's
335
+ * `GET /default-model` route handler so the client's model picker can label
336
+ * its default option with the real endpoint's humanized name.
336
337
  */
337
338
  defaultModels: Record<string, string>;
338
339
  /**
package/src/plugin.ts CHANGED
@@ -62,7 +62,7 @@ import {
62
62
  type StatementData,
63
63
  } from "@dbx-tools/shared-mastra";
64
64
  import { serving as nodeServing } from "@dbx-tools/model";
65
- import { type ServingEndpointSummary } from "@dbx-tools/shared-model";
65
+ import { display, type ServingEndpointSummary } from "@dbx-tools/shared-model";
66
66
  import { buildAgents, FALLBACK_AGENT_ID, type BuiltAgents } from "./agents";
67
67
  import { fetchChart } from "./chart";
68
68
  import type { MastraPluginConfig } from "./config";
@@ -318,19 +318,31 @@ export class MastraPlugin extends Plugin<MastraPluginConfig> {
318
318
  .catch(next);
319
319
  });
320
320
 
321
- // `GET /default-model[?agentId=]` reports the static serving-endpoint id
322
- // an agent falls back to when the client pins no model, so the picker can
323
- // name its "Server default" option. Agent-scoped (defaults to the default
324
- // agent); `model` is null when the agent has no static default (a dynamic,
325
- // call-time model) or the agent id is unknown. Registered before the
326
- // catch-all, same as `/models`.
327
- router.get(routes.MASTRA_ROUTES.defaultModel, (req, res) => {
328
- const requested = string.firstNonEmpty(req.query["agentId"]);
321
+ // `GET /default-model` (and `/default-model/:agentId`) reports the static
322
+ // serving-endpoint an agent falls back to when the client pins no model,
323
+ // so the picker can label its default option with the model's humanized
324
+ // name. Agent-scoped via the optional `/:agentId` suffix (URL symmetry
325
+ // with the history / threads / suggestions routes), defaulting to the
326
+ // default agent. `model` / `displayName` are null when the agent has no
327
+ // static default (a dynamic, call-time model) or the agent id is unknown.
328
+ // Reads only in-memory build state, so it's synchronous and needs no OBO
329
+ // scoping. Registered before the catch-all, same as `/models`.
330
+ const handleDefaultModel = (req: express.Request, res: express.Response): void => {
331
+ const requested = string.firstNonEmpty(req.params["agentId"]);
329
332
  const agentId = requested ?? this.built?.defaultAgentId ?? FALLBACK_AGENT_ID;
330
- const model = this.built?.defaultModels[agentId];
333
+ const raw = this.built?.defaultModels[agentId];
331
334
  // `"<dynamic>"` (a call-time function) has no fixed id to advertise.
332
- res.json({ agentId, model: model && model !== "<dynamic>" ? model : null });
333
- });
335
+ const model = raw && raw !== "<dynamic>" ? raw : null;
336
+ // Return the humanized label too, so the picker shows a friendly name on
337
+ // load without waiting on the `/models` catalogue (no raw-id flash).
338
+ res.json({
339
+ agentId,
340
+ model,
341
+ displayName: model ? display.toModelDisplayName(model) : null,
342
+ });
343
+ };
344
+ router.get(routes.MASTRA_ROUTES.defaultModel, handleDefaultModel);
345
+ router.get(`${routes.MASTRA_ROUTES.defaultModel}/:agentId`, handleDefaultModel);
334
346
 
335
347
  // `GET /embed/:type/:id` is the single resolver for every embed
336
348
  // marker the agent emits in prose (`[chart:<id>]`,