@dbx-tools/appkit-mastra 0.1.42 → 0.1.56

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/index.d.ts CHANGED
@@ -18,4 +18,3 @@ export * from "./src/config.js";
18
18
  export * from "./src/genie.js";
19
19
  export * from "./src/plugin.js";
20
20
  export { MASTRA_MODEL_OVERRIDE_KEY, MODEL_OVERRIDE_BODY_FIELDS, MODEL_OVERRIDE_HEADER, MODEL_OVERRIDE_QUERY, extractModelOverride, type ModelOverrideRequest, } from "./src/serving.js";
21
- export * from "./src/tools/email.js";
package/dist/index.js CHANGED
@@ -18,4 +18,3 @@ export * from "./src/config.js";
18
18
  export * from "./src/genie.js";
19
19
  export * from "./src/plugin.js";
20
20
  export { MASTRA_MODEL_OVERRIDE_KEY, MODEL_OVERRIDE_BODY_FIELDS, MODEL_OVERRIDE_HEADER, MODEL_OVERRIDE_QUERY, extractModelOverride, } from "./src/serving.js";
21
- export * from "./src/tools/email.js";
package/dist/src/chart.js CHANGED
@@ -30,7 +30,7 @@ import { commonUtils, logUtils, stringUtils } from "@dbx-tools/shared";
30
30
  import { Agent } from "@mastra/core/agent";
31
31
  import { createTool } from "@mastra/core/tools";
32
32
  import { z } from "zod";
33
- import { buildModel, ModelTier } from "./model.js";
33
+ import { buildModel, ModelClass } from "./model.js";
34
34
  const log = logUtils.logger("mastra/chart");
35
35
  /* ------------------------------ constants ------------------------------ */
36
36
  /**
@@ -276,7 +276,7 @@ function getPlannerAgent(config) {
276
276
  name: "Chart Planner",
277
277
  description: "Picks chart type and axis encodings for a dataset.",
278
278
  instructions: CHART_PLANNER_INSTRUCTIONS,
279
- model: ({ requestContext }) => buildModel(config, requestContext, { tier: ModelTier.Fast }),
279
+ model: ({ requestContext }) => buildModel(config, requestContext, { modelClass: ModelClass.ChatFast }),
280
280
  });
281
281
  plannerAgents.set(config, agent);
282
282
  }
@@ -4,7 +4,8 @@
4
4
  * Kept in a leaf module so `plugin.ts`, `server.ts`, `model.ts`, and
5
5
  * `memory.ts` can import them without creating a cycle.
6
6
  */
7
- import type { BasePluginConfig, getExecutionContext } from "@databricks/appkit";
7
+ import type { BasePluginConfig } from "@databricks/appkit";
8
+ import type { appkitUtils } from "@dbx-tools/shared";
8
9
  import type { AgentConfig } from "@mastra/core/agent";
9
10
  import type { PgVectorConfig, PostgresStoreConfig } from "@mastra/pg";
10
11
  import type { MastraAgentDefinition, MastraTools } from "./agents.js";
@@ -51,7 +52,7 @@ export declare const TRACE_REQUEST_CONTEXT_KEYS: readonly string[];
51
52
  /** AppKit execution context plus the canonical user id. */
52
53
  export interface User {
53
54
  id: string;
54
- executionContext: ReturnType<typeof getExecutionContext>;
55
+ executionContext: appkitUtils.ExecutionContextLike;
55
56
  }
56
57
  /** PgVector config with an optional Mastra store id. */
57
58
  export type MastraMemoryConfig = PgVectorConfig & {
@@ -182,9 +183,10 @@ export interface MastraPluginConfig extends BasePluginConfig {
182
183
  *
183
184
  * When unset, resolution is driven by the live Foundation Model API
184
185
  * `quality` / `speed` / `cost` scores: endpoints are classified into
185
- * tiers (`classifyEndpoints`) and walked best-first (Thinking ->
186
- * Balanced -> Fast), with the small built-in `FALLBACK_MODEL_IDS`
187
- * list as the floor when the catalogue can't be read. Set this to
186
+ * chat classes (`classifyEndpoints`) and walked best-first
187
+ * (ChatThinking -> ChatBalanced -> ChatFast), with the small built-in
188
+ * `FALLBACK_MODEL_IDS` list as the floor when the catalogue can't be
189
+ * read. Set this to
188
190
  * pin a regulated workspace to an approved subset, or to put custom
189
191
  * endpoints in front of the auto-classified catalogue.
190
192
  */
@@ -9,39 +9,39 @@
9
9
  *
10
10
  * This module only adds the Mastra-specific glue. The actual model
11
11
  * selection - listing the workspace catalogue and resolving an
12
- * explicit name / tier / fallback chain to a real endpoint id - lives
12
+ * explicit name / class / fallback chain to a real endpoint id - lives
13
13
  * in `@dbx-tools/model` ({@link selectModel}) so non-Mastra consumers
14
14
  * (e.g. a job that just needs a model name) can reuse it. Here we
15
15
  * assemble the explicit ask from Mastra's request context (the
16
16
  * per-request override under {@link MASTRA_MODEL_OVERRIDE_KEY}, the
17
17
  * agent / plugin `modelId`, or `DATABRICKS_SERVING_ENDPOINT_NAME`),
18
- * pass the plugin's fuzzy / tier / fallback knobs through, and wrap
18
+ * pass the plugin's fuzzy / class / fallback knobs through, and wrap
19
19
  * the resolved id in the OpenAI-compatible provider config Mastra
20
20
  * expects. Catalogue fetches fail loud: network / auth errors
21
21
  * propagate so callers see the real SDK message.
22
22
  */
23
- import { type ModelTier } from "@dbx-tools/model";
23
+ import { type ModelClass } from "@dbx-tools/model";
24
24
  import type { MastraModelConfig } from "@mastra/core/llm";
25
25
  import type { RequestContext } from "@mastra/core/request-context";
26
26
  import { type MastraPluginConfig } from "./config.js";
27
- export { classifyEndpoints, FALLBACK_MODEL_IDS, modelForTier, modelsForTier, ModelTier, } from "@dbx-tools/model";
27
+ export { classifyEndpoints, FALLBACK_MODEL_IDS, ModelClass, modelForClass, modelsForClass, } from "@dbx-tools/model";
28
28
  /** Optional overrides accepted by {@link buildModel}. */
29
29
  export interface BuildModelOverrides {
30
30
  /**
31
31
  * Static model id from the agent / plugin config (string sugar on
32
32
  * `def.model` or `config.defaultModel`). Loses to the per-request
33
- * override but wins over env / tier / fallback.
33
+ * override but wins over env / class / fallback.
34
34
  */
35
35
  modelId?: string;
36
36
  /**
37
- * Capability tier to resolve when no explicit model id is supplied.
38
- * Used by internal agents (e.g. the chart planner asks for
39
- * {@link ModelTier.Fast}) to express intent without pinning an
37
+ * Chat capability class to resolve when no explicit model id is
38
+ * supplied. Used by internal agents (e.g. the chart planner asks for
39
+ * {@link ModelClass.ChatFast}) to express intent without pinning an
40
40
  * endpoint name; the live catalogue is classified and the top
41
- * available model in the tier is chosen, falling back to the
42
- * tier's static list when the workspace has none.
41
+ * available model in the class is chosen, falling back to the
42
+ * class's static list when the workspace has none.
43
43
  */
44
- tier?: ModelTier;
44
+ modelClass?: ModelClass;
45
45
  }
46
46
  /**
47
47
  * Resolve a `MastraModelConfig` for the current agent step. Runs
package/dist/src/model.js CHANGED
@@ -9,22 +9,22 @@
9
9
  *
10
10
  * This module only adds the Mastra-specific glue. The actual model
11
11
  * selection - listing the workspace catalogue and resolving an
12
- * explicit name / tier / fallback chain to a real endpoint id - lives
12
+ * explicit name / class / fallback chain to a real endpoint id - lives
13
13
  * in `@dbx-tools/model` ({@link selectModel}) so non-Mastra consumers
14
14
  * (e.g. a job that just needs a model name) can reuse it. Here we
15
15
  * assemble the explicit ask from Mastra's request context (the
16
16
  * per-request override under {@link MASTRA_MODEL_OVERRIDE_KEY}, the
17
17
  * agent / plugin `modelId`, or `DATABRICKS_SERVING_ENDPOINT_NAME`),
18
- * pass the plugin's fuzzy / tier / fallback knobs through, and wrap
18
+ * pass the plugin's fuzzy / class / fallback knobs through, and wrap
19
19
  * the resolved id in the OpenAI-compatible provider config Mastra
20
20
  * expects. Catalogue fetches fail loud: network / auth errors
21
21
  * propagate so callers see the real SDK message.
22
22
  */
23
- import { parseModelTier, selectModel } from "@dbx-tools/model";
23
+ import { parseModelClass, selectModel } from "@dbx-tools/model";
24
24
  import { commonUtils, logUtils, netUtils, stringUtils } from "@dbx-tools/shared";
25
25
  import { MASTRA_USER_KEY } from "./config.js";
26
26
  import { MASTRA_MODEL_OVERRIDE_KEY, resolveServingConfig } from "./serving.js";
27
- export { classifyEndpoints, FALLBACK_MODEL_IDS, modelForTier, modelsForTier, ModelTier, } from "@dbx-tools/model";
27
+ export { classifyEndpoints, FALLBACK_MODEL_IDS, ModelClass, modelForClass, modelsForClass, } from "@dbx-tools/model";
28
28
  /**
29
29
  * Resolve a `MastraModelConfig` for the current agent step. Runs
30
30
  * while `agent.stream` is inside the `asUser(req)` scope so tokens
@@ -48,21 +48,21 @@ export async function buildModel(config, requestContext, overrides = {}) {
48
48
  ? requestContext.get(MASTRA_MODEL_OVERRIDE_KEY)
49
49
  : undefined;
50
50
  // The override / agent default / env value can be either a concrete
51
- // endpoint name or a capability tier slug ("thinking" / "balanced" /
52
- // "fast"). A tier slug becomes a tier intent (let the live catalogue
53
- // pick the best model in that band); anything else is an explicit
54
- // name fuzzy-matched against the catalogue. An internal
55
- // `overrides.tier` (e.g. the chart planner) is the floor when nothing
56
- // was requested.
51
+ // endpoint name or a model class slug ("chat-thinking" /
52
+ // "chat-balanced" / "chat-fast"). A class slug becomes a class intent
53
+ // (let the live catalogue pick the best model in that band); anything
54
+ // else is an explicit name fuzzy-matched against the catalogue. An
55
+ // internal `overrides.modelClass` (e.g. the chart planner) is the
56
+ // floor when nothing was requested.
57
57
  const requested = override ?? overrides.modelId ?? process.env.DATABRICKS_SERVING_ENDPOINT_NAME;
58
- const requestedTier = requested !== undefined ? parseModelTier(requested) : null;
59
- const explicit = requestedTier === null ? requested : undefined;
60
- const tier = requestedTier ?? overrides.tier;
58
+ const requestedClass = requested !== undefined ? parseModelClass(requested) : null;
59
+ const explicit = requestedClass === null ? requested : undefined;
60
+ const modelClass = requestedClass ?? overrides.modelClass;
61
61
  const { modelId, source } = await selectModel(user.executionContext.client, host, {
62
62
  ...(explicit !== undefined ? { explicit } : {}),
63
63
  fuzzy: serving.fuzzy,
64
64
  threshold: serving.threshold,
65
- ...(tier !== undefined ? { tier } : {}),
65
+ ...(modelClass !== undefined ? { modelClass } : {}),
66
66
  fallbacks: serving.fallbacks,
67
67
  ttlMs: serving.ttlMs,
68
68
  });
@@ -2,7 +2,7 @@
2
2
  * Mastra-specific glue over the generic `@dbx-tools/model` toolkit.
3
3
  *
4
4
  * The live `/serving-endpoints` catalogue access, fuzzy name
5
- * resolution, and tier/fallback selection all live in
5
+ * resolution, and class/fallback selection all live in
6
6
  * `@dbx-tools/model`; this module only adds what is specific to the
7
7
  * Mastra plugin: pulling a per-request model override off an HTTP
8
8
  * request (header / query / body) and projecting the plugin config
@@ -2,7 +2,7 @@
2
2
  * Mastra-specific glue over the generic `@dbx-tools/model` toolkit.
3
3
  *
4
4
  * The live `/serving-endpoints` catalogue access, fuzzy name
5
- * resolution, and tier/fallback selection all live in
5
+ * resolution, and class/fallback selection all live in
6
6
  * `@dbx-tools/model`; this module only adds what is specific to the
7
7
  * Mastra plugin: pulling a per-request model override off an HTTP
8
8
  * request (header / query / body) and projecting the plugin config