@dbx-tools/appkit-mastra 0.1.42 → 0.1.48
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 +115 -455
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/src/chart.js +2 -2
- package/dist/src/config.d.ts +7 -5
- package/dist/src/model.d.ts +11 -11
- package/dist/src/model.js +14 -14
- package/dist/src/serving.d.ts +1 -1
- package/dist/src/serving.js +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/index.ts +0 -1
- package/package.json +6 -11
- package/src/chart.ts +2 -2
- package/src/config.ts +7 -5
- package/src/model.ts +23 -23
- package/src/serving.ts +1 -1
- package/dist/src/tools/email.d.ts +0 -83
- package/dist/src/tools/email.js +0 -121
- package/src/tools/email.ts +0 -158
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,
|
|
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, {
|
|
279
|
+
model: ({ requestContext }) => buildModel(config, requestContext, { modelClass: ModelClass.ChatFast }),
|
|
280
280
|
});
|
|
281
281
|
plannerAgents.set(config, agent);
|
|
282
282
|
}
|
package/dist/src/config.d.ts
CHANGED
|
@@ -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
|
|
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:
|
|
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
|
-
*
|
|
186
|
-
*
|
|
187
|
-
* list as the floor when the catalogue can't be
|
|
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
|
*/
|
package/dist/src/model.d.ts
CHANGED
|
@@ -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 /
|
|
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 /
|
|
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
|
|
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,
|
|
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 /
|
|
33
|
+
* override but wins over env / class / fallback.
|
|
34
34
|
*/
|
|
35
35
|
modelId?: string;
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
38
|
-
* Used by internal agents (e.g. the chart planner asks for
|
|
39
|
-
* {@link
|
|
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
|
|
42
|
-
*
|
|
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
|
-
|
|
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 /
|
|
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 /
|
|
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 {
|
|
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,
|
|
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
|
|
52
|
-
// "fast"). A
|
|
53
|
-
// pick the best model in that band); anything
|
|
54
|
-
// name fuzzy-matched against the catalogue. An
|
|
55
|
-
// `overrides.
|
|
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
|
|
59
|
-
const explicit =
|
|
60
|
-
const
|
|
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
|
-
...(
|
|
65
|
+
...(modelClass !== undefined ? { modelClass } : {}),
|
|
66
66
|
fallbacks: serving.fallbacks,
|
|
67
67
|
ttlMs: serving.ttlMs,
|
|
68
68
|
});
|
package/dist/src/serving.d.ts
CHANGED
|
@@ -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
|
|
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
|
package/dist/src/serving.js
CHANGED
|
@@ -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
|
|
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
|