@dbx-tools/appkit-mastra 0.3.28 → 0.3.29

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/package.json CHANGED
@@ -28,22 +28,21 @@
28
28
  "express": "^5.1.0",
29
29
  "pg": "^8.22.0",
30
30
  "zod": "^4.3.6",
31
- "@dbx-tools/appkit": "0.3.28",
32
- "@dbx-tools/core": "0.3.28",
33
- "@dbx-tools/model": "0.3.28",
34
- "@dbx-tools/shared-core": "0.3.28",
35
- "@dbx-tools/databricks": "0.3.28",
36
- "@dbx-tools/genie": "0.3.28",
37
- "@dbx-tools/shared-genie": "0.3.28",
38
- "@dbx-tools/shared-mastra": "0.3.28",
39
- "@dbx-tools/shared-model": "0.3.28"
31
+ "@dbx-tools/appkit": "0.3.29",
32
+ "@dbx-tools/core": "0.3.29",
33
+ "@dbx-tools/model": "0.3.29",
34
+ "@dbx-tools/genie": "0.3.29",
35
+ "@dbx-tools/shared-core": "0.3.29",
36
+ "@dbx-tools/shared-mastra": "0.3.29",
37
+ "@dbx-tools/shared-genie": "0.3.29",
38
+ "@dbx-tools/shared-model": "0.3.29"
40
39
  },
41
40
  "main": "index.ts",
42
41
  "license": "UNLICENSED",
43
42
  "publishConfig": {
44
43
  "access": "public"
45
44
  },
46
- "version": "0.3.28",
45
+ "version": "0.3.29",
47
46
  "types": "index.ts",
48
47
  "type": "module",
49
48
  "exports": {
@@ -17,6 +17,17 @@ import { posix as path } from "node:path";
17
17
  import { getExecutionContext } from "@databricks/appkit";
18
18
  import { WorkspaceClient } from "@databricks/sdk-experimental";
19
19
  import { error, functionModule, hash, log } from "@dbx-tools/shared-core";
20
+ import {
21
+ DirectoryNotEmptyError,
22
+ DirectoryNotFoundError,
23
+ FileExistsError,
24
+ FileNotFoundError,
25
+ IsDirectoryError,
26
+ MastraFilesystem,
27
+ NotDirectoryError,
28
+ PermissionError,
29
+ WorkspaceReadOnlyError,
30
+ } from "@mastra/core/workspace";
20
31
  import type {
21
32
  CopyOptions,
22
33
  FileContent,
@@ -24,20 +35,11 @@ import type {
24
35
  FileStat,
25
36
  FilesystemInfo,
26
37
  ListOptions,
38
+ MastraFilesystemOptions,
27
39
  ProviderStatus,
28
40
  ReadOptions,
29
41
  RemoveOptions,
30
42
  WriteOptions,
31
- DirectoryNotEmptyError,
32
- DirectoryNotFoundError,
33
- FileExistsError,
34
- FileNotFoundError,
35
- IsDirectoryError,
36
- MastraFilesystem,
37
- NotDirectoryError,
38
- PermissionError,
39
- WorkspaceReadOnlyError,
40
- type MastraFilesystemOptions,
41
43
  } from "@mastra/core/workspace";
42
44
 
43
45
  /* ------------------------------ constants ------------------------------ */
package/src/genie.ts CHANGED
@@ -50,7 +50,8 @@ import { z } from "zod";
50
50
 
51
51
  import type { MastraTools } from "./agents";
52
52
  import { chartPlannerRequestSchema, prepareChart } from "./chart";
53
- import type { MastraPluginConfig, MASTRA_USER_KEY, type User } from "./config";
53
+ import { MASTRA_USER_KEY } from "./config";
54
+ import type { MastraPluginConfig, User } from "./config";
54
55
  import { fetchStatementData } from "./statement";
55
56
  import { safeWrite } from "./writer";
56
57
 
package/src/memory.ts CHANGED
@@ -29,9 +29,8 @@
29
29
  * @module
30
30
  */
31
31
 
32
- import { randomUUID } from "node:crypto";
33
32
  import { getUsernameWithApiLookup } from "@databricks/appkit";
34
- import { log } from "@dbx-tools/shared-core";
33
+ import { hash, log } from "@dbx-tools/shared-core";
35
34
  import { fastembed } from "@mastra/fastembed";
36
35
  import { Memory } from "@mastra/memory";
37
36
  import { PgVector, PostgresStore } from "@mastra/pg";
@@ -252,7 +251,7 @@ export class MemoryBuilder {
252
251
  */
253
252
  function buildSharedPgVector(pool: Pool): PgVector {
254
253
  const vector = new PgVector({
255
- id: `pg${randomUUID()}`,
254
+ id: `pg${hash.id()}`,
256
255
  // Keep the recall index out of `public`: on a Lakebase database the app
257
256
  // service principal has no CREATE on `public` (PG15+ locks it down), so a
258
257
  // default-schema PgVector fails on CREATE INDEX with "permission denied for
@@ -276,7 +275,7 @@ function buildSharedPgVector(pool: Pool): PgVector {
276
275
  /** Per-agent dedicated `PgVector` (rare; opt-in via object override). */
277
276
  function buildPgVector(setting: MastraMemoryConfigOverride): PgVector {
278
277
  return new PgVector(
279
- withId(setting, `pg-vector__${randomUUID()}`) as ConstructorParameters<typeof PgVector>[0],
278
+ withId(setting, `pg-vector__${hash.id()}`) as ConstructorParameters<typeof PgVector>[0],
280
279
  );
281
280
  }
282
281
 
package/src/model.ts CHANGED
@@ -25,7 +25,7 @@
25
25
 
26
26
  import { getExecutionContext } from "@databricks/appkit";
27
27
  import { classes, resolve } from "@dbx-tools/model";
28
- import { functionModule, log, net } from "@dbx-tools/shared-core";
28
+ import { functionModule, json, log, net } from "@dbx-tools/shared-core";
29
29
  import { model } from "@dbx-tools/shared-model";
30
30
  import type { MastraModelConfig } from "@mastra/core/llm";
31
31
  import type { RequestContext } from "@mastra/core/request-context";
@@ -155,11 +155,13 @@ const setupFetchInterceptor = functionModule.memoize((): void => {
155
155
  if (rewritten !== init.body) {
156
156
  init = { ...init, body: rewritten };
157
157
  }
158
- try {
159
- logger.debug("POST", { url: url.toString(), body: JSON.parse(rewritten) });
160
- } catch {
161
- logger.debug("POST", { url: url.toString(), bodyType: "non-JSON" });
162
- }
158
+ const parsed = json.parse<unknown>(rewritten);
159
+ logger.debug(
160
+ "POST",
161
+ parsed === undefined
162
+ ? { url: url.toString(), bodyType: "non-JSON" }
163
+ : { url: url.toString(), body: parsed },
164
+ );
163
165
  return original(input, init);
164
166
  }) as typeof globalThis.fetch;
165
167
  });
package/src/rest.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { appkit } from "@dbx-tools/appkit";
2
+ import { json } from "@dbx-tools/shared-core";
2
3
  /**
3
4
  * Minimal authenticated Databricks REST helper. Pulls the workspace
4
5
  * host and a fresh bearer header off an OBO-scoped `WorkspaceClient`
@@ -58,10 +59,5 @@ export async function readResponseText(res: Response): Promise<string> {
58
59
  /** Parse a response body as JSON, returning `{}` on empty / invalid bodies. */
59
60
  export async function readResponseJson(res: Response): Promise<unknown> {
60
61
  const text = await readResponseText(res);
61
- if (!text) return {};
62
- try {
63
- return JSON.parse(text);
64
- } catch {
65
- return {};
66
- }
62
+ return json.parse<unknown>(text, {});
67
63
  }
package/src/server.ts CHANGED
@@ -7,9 +7,8 @@
7
7
  * @module
8
8
  */
9
9
 
10
- import { randomUUID } from "node:crypto";
11
10
  import { getExecutionContext } from "@databricks/appkit";
12
- import { http, log, object, string, token } from "@dbx-tools/shared-core";
11
+ import { hash, http, log, object, string, token } from "@dbx-tools/shared-core";
13
12
  import { feedback, thread } from "@dbx-tools/shared-mastra";
14
13
  import {
15
14
  MASTRA_RESOURCE_ID_KEY,
@@ -142,7 +141,7 @@ export class MastraServer extends MastraServerExpress {
142
141
  if (requestContext.get(MASTRA_REQUEST_ID_KEY)) return;
143
142
  const headerValue = req.headers["x-request-id"];
144
143
  const upstream = Array.isArray(headerValue) ? headerValue[0] : headerValue;
145
- const requestId = upstream?.trim() || randomUUID();
144
+ const requestId = upstream?.trim() || hash.id();
146
145
  requestContext.set(MASTRA_REQUEST_ID_KEY, requestId);
147
146
  res.setHeader("X-Request-Id", requestId);
148
147
  }
@@ -218,7 +217,7 @@ export class MastraServer extends MastraServerExpress {
218
217
  );
219
218
  let sessionId = cookies[cookieName];
220
219
  if (!sessionId) {
221
- sessionId = randomUUID();
220
+ sessionId = hash.id();
222
221
  res.cookie(cookieName, sessionId, {
223
222
  httpOnly: true,
224
223
  sameSite: "lax",
@@ -1,5 +1,10 @@
1
- import { string } from "@dbx-tools/shared-core";
2
- import { type ChatMessage, type ChatRole, openaiChat } from "@dbx-tools/shared-model";
1
+ import { json, string } from "@dbx-tools/shared-core";
2
+ import {
3
+ type ChatMessage,
4
+ type ChatRole,
5
+ openaiChat,
6
+ openaiResponses,
7
+ } from "@dbx-tools/shared-model";
3
8
  /**
4
9
  * Repairs Mastra / AI SDK message replays sent to Databricks Model
5
10
  * Serving before they hit the OpenAI-compatible `/chat/completions`
@@ -19,7 +24,9 @@ export interface ServingChatMessage extends ChatMessage {
19
24
  reasoning_content?: unknown;
20
25
  }
21
26
 
22
- const REASONING_PART_TYPES = new Set(["reasoning", "thinking", "redacted_thinking"]);
27
+ // Shared with the Responses sanitize path so both wire surfaces agree on what
28
+ // counts as a signed reasoning block.
29
+ const REASONING_PART_TYPES = openaiResponses.REASONING_TYPES;
23
30
 
24
31
  /**
25
32
  * Parse, sanitize, and re-serialize a `/serving-endpoints/...` POST
@@ -27,12 +34,8 @@ const REASONING_PART_TYPES = new Set(["reasoning", "thinking", "redacted_thinkin
27
34
  * JSON or no rewrite was needed.
28
35
  */
29
36
  export function rewriteServingBody(body: string): string {
30
- let parsed: Record<string, unknown>;
31
- try {
32
- parsed = JSON.parse(body) as Record<string, unknown>;
33
- } catch {
34
- return body;
35
- }
37
+ const parsed = json.parseRecord(body);
38
+ if (!parsed) return body;
36
39
 
37
40
  // Runs regardless of `messages`: Databricks refuses to parse a body carrying
38
41
  // an unknown top-level field, so this failure is not specific to a transcript.