@dbx-tools/appkit-mastra 0.9.5 → 0.9.6

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.
Files changed (49) hide show
  1. package/README.md +16 -18
  2. package/index.ts +1 -3
  3. package/lib/index.d.ts +1 -3
  4. package/lib/index.js +2 -3
  5. package/lib/src/agents.d.ts +2 -2
  6. package/lib/src/agents.js +6 -6
  7. package/lib/src/chart.js +23 -23
  8. package/lib/src/evaluation.js +3 -3
  9. package/lib/src/genie.d.ts +2 -2
  10. package/lib/src/genie.js +20 -20
  11. package/lib/src/memory.js +9 -26
  12. package/lib/src/mlflow.js +4 -4
  13. package/lib/src/model.js +4 -4
  14. package/lib/src/monty-sandbox.js +6 -6
  15. package/lib/src/observability.js +3 -3
  16. package/lib/src/plugin.js +26 -21
  17. package/lib/src/remote-skills.js +20 -30
  18. package/lib/src/sandbox.js +10 -10
  19. package/lib/src/server.js +5 -5
  20. package/lib/src/serving-sanitize.js +12 -9
  21. package/lib/src/serving.js +8 -8
  22. package/lib/src/storage-schema.js +4 -4
  23. package/lib/src/summarize.js +3 -3
  24. package/lib/src/workspaces.js +9 -9
  25. package/lib/src/writer.js +3 -3
  26. package/lib/tsconfig.tsbuildinfo +1 -1
  27. package/package.json +17 -17
  28. package/src/agents.ts +8 -8
  29. package/src/chart.ts +24 -24
  30. package/src/evaluation.ts +2 -2
  31. package/src/genie.ts +20 -20
  32. package/src/memory.ts +11 -27
  33. package/src/mlflow.ts +3 -3
  34. package/src/model.ts +3 -3
  35. package/src/monty-sandbox.ts +5 -5
  36. package/src/observability.ts +2 -2
  37. package/src/plugin.ts +30 -20
  38. package/src/remote-skills.ts +36 -38
  39. package/src/sandbox.ts +9 -9
  40. package/src/server.ts +4 -4
  41. package/src/serving-sanitize.ts +11 -13
  42. package/src/serving.ts +7 -7
  43. package/src/storage-schema.ts +3 -3
  44. package/src/summarize.ts +2 -2
  45. package/src/workspaces.ts +8 -8
  46. package/src/writer.ts +2 -2
  47. package/lib/src/pagination.d.ts +0 -33
  48. package/lib/src/pagination.js +0 -36
  49. package/src/pagination.ts +0 -47
package/src/sandbox.ts CHANGED
@@ -11,7 +11,7 @@
11
11
 
12
12
  import type { WorkspaceClient } from "@databricks/appkit";
13
13
  import { databricks } from "@dbx-tools/appkit";
14
- import { async, error, log, string } from "@dbx-tools/shared-core";
14
+ import { asyncUtils, errorUtils, log, stringUtils } from "@dbx-tools/shared-core";
15
15
  import type { RequestContext } from "@mastra/core/request-context";
16
16
  import type {
17
17
  CommandResult,
@@ -113,7 +113,7 @@ export class DatabricksSandbox implements WorkspaceSandbox {
113
113
  private startPromise?: Promise<void>;
114
114
 
115
115
  constructor(options: DatabricksSandboxOptions) {
116
- const id = string.trimToNull(options.sandboxId.replace(/^sandboxes\//, ""));
116
+ const id = stringUtils.trimToNull(options.sandboxId.replace(/^sandboxes\//, ""));
117
117
  if (!id) throw new TypeError("Databricks sandbox id must not be blank");
118
118
  this.id = id;
119
119
  this.name = options.displayName?.trim() || `Mastra sandbox ${id}`;
@@ -177,7 +177,7 @@ export class DatabricksSandbox implements WorkspaceSandbox {
177
177
  logger.warn("Databricks Sandbox unavailable; using fallback", {
178
178
  sandboxId: this.id,
179
179
  fallback: fallback.provider,
180
- error: error.errorMessage(caught),
180
+ error: errorUtils.errorMessage(caught),
181
181
  });
182
182
  await fallback.start?.();
183
183
  this.activeFallback = fallback;
@@ -186,7 +186,7 @@ export class DatabricksSandbox implements WorkspaceSandbox {
186
186
  return;
187
187
  }
188
188
  this.status = "error";
189
- this.error = error.errorMessage(caught);
189
+ this.error = errorUtils.errorMessage(caught);
190
190
  throw caught;
191
191
  }
192
192
  }
@@ -218,7 +218,7 @@ export class DatabricksSandbox implements WorkspaceSandbox {
218
218
  return;
219
219
  }
220
220
  this.status = "error";
221
- this.error = error.errorMessage(caught);
221
+ this.error = errorUtils.errorMessage(caught);
222
222
  throw caught;
223
223
  }
224
224
  }
@@ -241,7 +241,7 @@ export class DatabricksSandbox implements WorkspaceSandbox {
241
241
  return;
242
242
  }
243
243
  this.status = "error";
244
- this.error = error.errorMessage(caught);
244
+ this.error = errorUtils.errorMessage(caught);
245
245
  throw caught;
246
246
  }
247
247
  }
@@ -416,7 +416,7 @@ export class DatabricksSandbox implements WorkspaceSandbox {
416
416
  while (Date.now() < deadline) {
417
417
  const sandbox = await this.get(signal);
418
418
  if (sandbox.status?.state === expected) return sandbox;
419
- await async.sleep(SANDBOX_POLL_INTERVAL_MS, signal);
419
+ await asyncUtils.sleep(SANDBOX_POLL_INTERVAL_MS, signal);
420
420
  }
421
421
  throw new Error(
422
422
  `Databricks sandbox ${this.id} did not reach ${expected} within ${this.startupTimeoutMs}ms`,
@@ -475,7 +475,7 @@ function definedEnvironment(input: NodeJS.ProcessEnv | undefined): Record<string
475
475
  }
476
476
 
477
477
  function isStatus(caught: unknown, status: number): boolean {
478
- return error.errorContext(caught).statusCode === status;
478
+ return errorUtils.errorContext(caught).statusCode === status;
479
479
  }
480
480
 
481
481
  function remoteStatus(sandbox: z.infer<typeof SandboxResponseSchema>): ProviderStatus {
@@ -503,7 +503,7 @@ function resolveFallback(
503
503
  }
504
504
 
505
505
  function isDatabricksSandboxUnavailable(caught: unknown): boolean {
506
- const context = error.errorContext(caught);
506
+ const context = errorUtils.errorContext(caught);
507
507
  return (
508
508
  context.statusCode === 404 ||
509
509
  context.hasMessage("feature", "disabled") ||
package/src/server.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  import { getExecutionContext } from "@databricks/appkit";
9
- import { hash, http, log, object, string, token } from "@dbx-tools/shared-core";
9
+ import { hash, http, log, object, stringUtils, token } from "@dbx-tools/shared-core";
10
10
  import { feedback, thread } from "@dbx-tools/shared-mastra";
11
11
  import {
12
12
  MASTRA_RESOURCE_ID_KEY,
@@ -311,7 +311,7 @@ export class MastraServer extends ExpressMastraServer {
311
311
  return;
312
312
  }
313
313
  const cookies = http.parseCookies(req.headers.cookie);
314
- const cookieName = string.toIdentifierWithOptions(
314
+ const cookieName = stringUtils.toIdentifierWithOptions(
315
315
  { delimiter: "_", distinct: true },
316
316
  "appkit",
317
317
  this.config.name!,
@@ -340,8 +340,8 @@ export class MastraServer extends ExpressMastraServer {
340
340
  const headerValue = req.headers[thread.THREAD_ID_HEADER];
341
341
  const queryValue = req.query[thread.THREAD_ID_QUERY];
342
342
  return (
343
- string.trimToNull(Array.isArray(headerValue) ? headerValue[0] : headerValue) ??
344
- string.trimToNull(Array.isArray(queryValue) ? queryValue[0] : queryValue)
343
+ stringUtils.trimToNull(Array.isArray(headerValue) ? headerValue[0] : headerValue) ??
344
+ stringUtils.trimToNull(Array.isArray(queryValue) ? queryValue[0] : queryValue)
345
345
  );
346
346
  }
347
347
 
@@ -22,13 +22,8 @@
22
22
  */
23
23
 
24
24
  import { chatToolReasoningEffort, ReasoningEffort } from "@dbx-tools/model-rs";
25
- import { json, string } from "@dbx-tools/shared-core";
26
- import {
27
- type ChatMessage,
28
- type ChatRole,
29
- openaiChat,
30
- openaiResponses,
31
- } from "@dbx-tools/shared-model";
25
+ import { json, stringUtils } from "@dbx-tools/shared-core";
26
+ import { type ChatMessage, type ChatRole, openaiChat } from "@dbx-tools/shared-model";
32
27
 
33
28
  /**
34
29
  * A chat message as it arrives on the serving wire, plus the extended-thinking
@@ -43,9 +38,12 @@ export interface ServingChatMessage extends ChatMessage {
43
38
  reasoning_content?: unknown;
44
39
  }
45
40
 
46
- // Shared with the Responses sanitize path so both wire surfaces agree on what
47
- // counts as a signed reasoning block.
48
- const REASONING_PART_TYPES = openaiResponses.REASONING_TYPES;
41
+ /** Signed Claude reasoning blocks that cannot be replayed after mutation. */
42
+ const REASONING_PART_TYPES: ReadonlySet<string> = new Set([
43
+ "reasoning",
44
+ "thinking",
45
+ "redacted_thinking",
46
+ ]);
49
47
 
50
48
  /**
51
49
  * Parse, sanitize, and re-serialize a `/serving-endpoints/...` POST
@@ -114,7 +112,7 @@ export function applyToolReasoningCompatibility(body: Record<string, unknown>):
114
112
  if (!Array.isArray(body.tools) || body.tools.length === 0) {
115
113
  return false;
116
114
  }
117
- const model = string.trimToNull(body.model);
115
+ const model = stringUtils.trimToNull(body.model);
118
116
  if (!model) return false;
119
117
  if (chatToolReasoningEffort(model) !== ReasoningEffort.None) return false;
120
118
  if (body.reasoning_effort === "none") return false;
@@ -212,8 +210,8 @@ export function repairAssistantPrefill(messages: ServingChatMessage[]): boolean
212
210
  }
213
211
 
214
212
  const merged = [
215
- string.trimToNull(textFromServingContent(opener.content)),
216
- string.trimToNull(textFromServingContent(last.content)),
213
+ stringUtils.trimToNull(textFromServingContent(opener.content)),
214
+ stringUtils.trimToNull(textFromServingContent(last.content)),
217
215
  ]
218
216
  .filter((s): s is string => s !== null)
219
217
  .join("\n\n");
package/src/serving.ts CHANGED
@@ -11,8 +11,8 @@
11
11
  * @module
12
12
  */
13
13
 
14
- import { serving as modelServing } from "@dbx-tools/model";
15
- import { string } from "@dbx-tools/shared-core";
14
+ import { modelCatalog } from "@dbx-tools/model";
15
+ import { stringUtils } from "@dbx-tools/shared-core";
16
16
  import { override } from "@dbx-tools/shared-mastra";
17
17
 
18
18
  import type { MastraPluginConfig } from "./config.ts";
@@ -52,20 +52,20 @@ export interface ModelOverrideRequest {
52
52
  export function extractModelOverride(req: ModelOverrideRequest): string | null {
53
53
  const headers = req.headers;
54
54
  if (headers) {
55
- const headerVal = string.firstNonEmpty(
55
+ const headerVal = stringUtils.firstNonEmpty(
56
56
  headers[override.MODEL_OVERRIDE_HEADER] ??
57
57
  headers[override.MODEL_OVERRIDE_HEADER.toLowerCase()],
58
58
  );
59
59
  if (headerVal) return headerVal;
60
60
  }
61
61
  if (req.query) {
62
- const queryVal = string.firstNonEmpty(req.query[override.MODEL_OVERRIDE_QUERY]);
62
+ const queryVal = stringUtils.firstNonEmpty(req.query[override.MODEL_OVERRIDE_QUERY]);
63
63
  if (queryVal) return queryVal;
64
64
  }
65
65
  if (req.body && typeof req.body === "object") {
66
66
  const record = req.body as Record<string, unknown>;
67
67
  for (const field of override.MODEL_OVERRIDE_BODY_FIELDS) {
68
- const bodyVal = string.firstNonEmpty(record[field]);
68
+ const bodyVal = stringUtils.firstNonEmpty(record[field]);
69
69
  if (bodyVal) return bodyVal;
70
70
  }
71
71
  }
@@ -90,8 +90,8 @@ export function resolveServingConfig(config: MastraPluginConfig): {
90
90
  fallbacks: readonly string[];
91
91
  } {
92
92
  return {
93
- ttlMs: config.modelCacheTtlMs ?? modelServing.DEFAULT_MODEL_CACHE_TTL_MS,
94
- threshold: config.modelFuzzyThreshold ?? modelServing.DEFAULT_FUZZY_THRESHOLD,
93
+ ttlMs: config.modelCacheTtlMs ?? modelCatalog.DEFAULT_MODEL_CACHE_TTL_MS,
94
+ threshold: config.modelFuzzyThreshold ?? modelCatalog.DEFAULT_FUZZY_THRESHOLD,
95
95
  fuzzy: config.modelFuzzyMatch !== false,
96
96
  allowOverride: config.modelOverride !== false,
97
97
  fallbacks: config.defaultModelFallbacks ?? [],
@@ -8,7 +8,7 @@
8
8
  * @module
9
9
  */
10
10
 
11
- import { string } from "@dbx-tools/shared-core";
11
+ import { stringUtils } from "@dbx-tools/shared-core";
12
12
 
13
13
  const SCHEMA_PREFIX = "mastra_";
14
14
  const MAX_PG_IDENTIFIER_LEN = 63;
@@ -19,7 +19,7 @@ const MAX_PG_IDENTIFIER_LEN = 63;
19
19
  */
20
20
  export function agentStorageSchemaName(agentId: string): string {
21
21
  const maxSlugLen = MAX_PG_IDENTIFIER_LEN - SCHEMA_PREFIX.length;
22
- const slug = string.toIdentifierWithOptions(
22
+ const slug = stringUtils.toIdentifierWithOptions(
23
23
  {
24
24
  delimiter: "_",
25
25
  maxLength: maxSlugLen,
@@ -30,7 +30,7 @@ export function agentStorageSchemaName(agentId: string): string {
30
30
  );
31
31
  const body =
32
32
  slug ||
33
- string.toIdentifierWithOptions(
33
+ stringUtils.toIdentifierWithOptions(
34
34
  {
35
35
  delimiter: "_",
36
36
  maxLength: maxSlugLen,
package/src/summarize.ts CHANGED
@@ -19,7 +19,7 @@
19
19
  * @module
20
20
  */
21
21
 
22
- import { string } from "@dbx-tools/shared-core";
22
+ import { stringUtils } from "@dbx-tools/shared-core";
23
23
  import { model } from "@dbx-tools/shared-model";
24
24
  import { Agent } from "@mastra/core/agent";
25
25
  import type { MastraModelConfig } from "@mastra/core/llm";
@@ -136,7 +136,7 @@ export async function summarizeText(
136
136
  options: SummarizeOptions = {},
137
137
  ): Promise<string> {
138
138
  const { instructions, maxWords, requestContext, abortSignal } = options;
139
- const prompt = string.toDescription({
139
+ const prompt = stringUtils.toDescription({
140
140
  ...(instructions ? { Guidance: instructions } : {}),
141
141
  ...(maxWords !== undefined ? { "Max length (words)": String(maxWords) } : {}),
142
142
  Text: text,
package/src/workspaces.ts CHANGED
@@ -21,8 +21,8 @@
21
21
  import { createHash } from "node:crypto";
22
22
  import { ConfigurationError, createWorkspaceClient } from "@databricks/appkit";
23
23
  import type { WorkspaceClient } from "@databricks/appkit";
24
- import { DatabricksFileSystem, workspace as databricksWorkspace } from "@dbx-tools/databricks";
25
- import { error, log, object, string, token } from "@dbx-tools/shared-core";
24
+ import { DatabricksFileSystem, workspaceClient } from "@dbx-tools/databricks";
25
+ import { errorUtils, log, object, stringUtils, token } from "@dbx-tools/shared-core";
26
26
  import type { RequestContext } from "@mastra/core/request-context";
27
27
  import {
28
28
  CompositeFilesystem,
@@ -426,7 +426,7 @@ async function resolveSkillFolderFilesystem(
426
426
  });
427
427
  return undefined;
428
428
  }
429
- const root = string.trimToNull(await resolveSkillFolderValue(folder.path, context));
429
+ const root = stringUtils.trimToNull(await resolveSkillFolderValue(folder.path, context));
430
430
  if (!root) return undefined;
431
431
  return databricksFilesystem(client, root, folder.writable !== true);
432
432
  }
@@ -452,10 +452,10 @@ function resolveWorkspaceIdentity(options: CreateWorkspaceOptions): {
452
452
  let id = options.id;
453
453
  let name = options.name;
454
454
  if (!id) {
455
- id = name ? string.toSlug(name) : "workspace";
455
+ id = name ? stringUtils.toSlug(name) : "workspace";
456
456
  }
457
457
  if (!name) {
458
- name = Array.from(string.tokenize(id)).join(" ");
458
+ name = Array.from(stringUtils.tokenize(id)).join(" ");
459
459
  }
460
460
  return { id, name };
461
461
  }
@@ -494,7 +494,7 @@ function shouldMountSkillFolders(requestContext: RequestContext): boolean {
494
494
 
495
495
  /** Read the trimmed OBO user email stamped on {@link MASTRA_USER_EMAIL_KEY}. */
496
496
  function resolveScopedEmail(requestContext: RequestContext | undefined): string | undefined {
497
- return string.trimToNull(requestContext?.get(MASTRA_USER_EMAIL_KEY)) ?? undefined;
497
+ return stringUtils.trimToNull(requestContext?.get(MASTRA_USER_EMAIL_KEY)) ?? undefined;
498
498
  }
499
499
 
500
500
  /**
@@ -508,7 +508,7 @@ async function databricksFilesystem(
508
508
  readOnly: boolean = true,
509
509
  ): Promise<WorkspaceFilesystem> {
510
510
  const fs = new DatabricksFileSystem({
511
- client: databricksWorkspace.toLegacyWorkspaceClient(client),
511
+ client: workspaceClient.toLegacyWorkspaceClient(client),
512
512
  root,
513
513
  readOnly,
514
514
  createRoot: !readOnly,
@@ -522,7 +522,7 @@ async function databricksFilesystem(
522
522
  logger.debug("databricks-mount:scratch-fallback", {
523
523
  root,
524
524
  readOnly,
525
- error: error.errorMessage(err),
525
+ error: errorUtils.errorMessage(err),
526
526
  });
527
527
  }
528
528
  return scratchFilesystem();
package/src/writer.ts CHANGED
@@ -10,7 +10,7 @@
10
10
  * @module
11
11
  */
12
12
 
13
- import { error, log } from "@dbx-tools/shared-core";
13
+ import { errorUtils, log } from "@dbx-tools/shared-core";
14
14
  import { GENIE_PROGRESS_PART_TYPE, type GenieWriterEvent } from "@dbx-tools/shared-mastra";
15
15
  import type { ToolExecutionContext } from "@mastra/core/tools";
16
16
 
@@ -44,7 +44,7 @@ export async function safeWriteProgress(
44
44
  } catch (err) {
45
45
  log.warn("writer:error", {
46
46
  ...context,
47
- error: error.errorMessage(err),
47
+ error: errorUtils.errorMessage(err),
48
48
  });
49
49
  }
50
50
  }
@@ -1,33 +0,0 @@
1
- /**
2
- * Query-parameter coercion shared by the paginated custom routes
3
- * (`history` / `threads`). Each route keeps its own page-size default
4
- * and hard cap and passes them in, so the coercion rules stay in one
5
- * place without collapsing the routes' distinct sizing.
6
- *
7
- * @module
8
- */
9
- /**
10
- * Bounds for {@link clampPerPage}.
11
- *
12
- * @deprecated Use the native `@mastra/client-js` memory API pagination inputs.
13
- */
14
- export interface PerPageBounds {
15
- /** Page size used for empty / non-positive / non-numeric inputs. */
16
- fallback: number;
17
- /** Hard cap so a misbehaving client can't fetch everything at once. */
18
- max: number;
19
- }
20
- /**
21
- * Coerce / clamp a `perPage` value, falling back to `bounds.fallback`.
22
- *
23
- * @deprecated Use the native `@mastra/client-js` memory API pagination inputs.
24
- */
25
- export declare function clampPerPage(value: number | undefined, bounds: PerPageBounds): number;
26
- /**
27
- * Coerce a Hono query value into a non-negative integer. Returns
28
- * `undefined` for empty / non-numeric / negative inputs so the caller
29
- * can apply its built-in defaults.
30
- *
31
- * @deprecated Use the native `@mastra/client-js` memory API pagination inputs.
32
- */
33
- export declare function parseIntParam(value: string | undefined): number | undefined;
@@ -1,36 +0,0 @@
1
- /**
2
- * Query-parameter coercion shared by the paginated custom routes
3
- * (`history` / `threads`). Each route keeps its own page-size default
4
- * and hard cap and passes them in, so the coercion rules stay in one
5
- * place without collapsing the routes' distinct sizing.
6
- *
7
- * @module
8
- */
9
- import { object } from "@dbx-tools/shared-core";
10
- /**
11
- * Coerce / clamp a `perPage` value, falling back to `bounds.fallback`.
12
- *
13
- * @deprecated Use the native `@mastra/client-js` memory API pagination inputs.
14
- */
15
- export function clampPerPage(value, bounds) {
16
- if (value === undefined || Number.isNaN(value))
17
- return bounds.fallback;
18
- const n = Math.trunc(value);
19
- if (n <= 0)
20
- return bounds.fallback;
21
- return Math.min(n, bounds.max);
22
- }
23
- /**
24
- * Coerce a Hono query value into a non-negative integer. Returns
25
- * `undefined` for empty / non-numeric / negative inputs so the caller
26
- * can apply its built-in defaults.
27
- *
28
- * @deprecated Use the native `@mastra/client-js` memory API pagination inputs.
29
- */
30
- export function parseIntParam(value) {
31
- const n = object.toNumber(value);
32
- if (n === undefined || n < 0)
33
- return undefined;
34
- return Math.trunc(n);
35
- }
36
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGFnaW5hdGlvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9wYWdpbmF0aW9uLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7O0dBT0c7QUFFSCxPQUFPLEVBQUUsTUFBTSxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFjaEQ7Ozs7R0FJRztBQUNILE1BQU0sVUFBVSxZQUFZLENBQUMsS0FBeUIsRUFBRSxNQUFxQjtJQUMzRSxJQUFJLEtBQUssS0FBSyxTQUFTLElBQUksTUFBTSxDQUFDLEtBQUssQ0FBQyxLQUFLLENBQUM7UUFBRSxPQUFPLE1BQU0sQ0FBQyxRQUFRLENBQUM7SUFDdkUsTUFBTSxDQUFDLEdBQUcsSUFBSSxDQUFDLEtBQUssQ0FBQyxLQUFLLENBQUMsQ0FBQztJQUM1QixJQUFJLENBQUMsSUFBSSxDQUFDO1FBQUUsT0FBTyxNQUFNLENBQUMsUUFBUSxDQUFDO0lBQ25DLE9BQU8sSUFBSSxDQUFDLEdBQUcsQ0FBQyxDQUFDLEVBQUUsTUFBTSxDQUFDLEdBQUcsQ0FBQyxDQUFDO0FBQ2pDLENBQUM7QUFFRDs7Ozs7O0dBTUc7QUFDSCxNQUFNLFVBQVUsYUFBYSxDQUFDLEtBQXlCO0lBQ3JELE1BQU0sQ0FBQyxHQUFHLE1BQU0sQ0FBQyxRQUFRLENBQUMsS0FBSyxDQUFDLENBQUM7SUFDakMsSUFBSSxDQUFDLEtBQUssU0FBUyxJQUFJLENBQUMsR0FBRyxDQUF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ZCB7XG4gIGNvbnN0IG4gPSBvYmplY3QudG9OdW1iZXIodmFsdWUpO1xuICBpZiAobiA9PT0gdW5kZWZpbmVkIHx8IG4gPCAwKSByZXR1cm4gdW5kZWZpbmVkO1xuICByZXR1cm4gTWF0aC50cnVuYyhuKTtcbn1cbiJdfQ==
package/src/pagination.ts DELETED
@@ -1,47 +0,0 @@
1
- /**
2
- * Query-parameter coercion shared by the paginated custom routes
3
- * (`history` / `threads`). Each route keeps its own page-size default
4
- * and hard cap and passes them in, so the coercion rules stay in one
5
- * place without collapsing the routes' distinct sizing.
6
- *
7
- * @module
8
- */
9
-
10
- import { object } from "@dbx-tools/shared-core";
11
-
12
- /**
13
- * Bounds for {@link clampPerPage}.
14
- *
15
- * @deprecated Use the native `@mastra/client-js` memory API pagination inputs.
16
- */
17
- export interface PerPageBounds {
18
- /** Page size used for empty / non-positive / non-numeric inputs. */
19
- fallback: number;
20
- /** Hard cap so a misbehaving client can't fetch everything at once. */
21
- max: number;
22
- }
23
-
24
- /**
25
- * Coerce / clamp a `perPage` value, falling back to `bounds.fallback`.
26
- *
27
- * @deprecated Use the native `@mastra/client-js` memory API pagination inputs.
28
- */
29
- export function clampPerPage(value: number | undefined, bounds: PerPageBounds): number {
30
- if (value === undefined || Number.isNaN(value)) return bounds.fallback;
31
- const n = Math.trunc(value);
32
- if (n <= 0) return bounds.fallback;
33
- return Math.min(n, bounds.max);
34
- }
35
-
36
- /**
37
- * Coerce a Hono query value into a non-negative integer. Returns
38
- * `undefined` for empty / non-numeric / negative inputs so the caller
39
- * can apply its built-in defaults.
40
- *
41
- * @deprecated Use the native `@mastra/client-js` memory API pagination inputs.
42
- */
43
- export function parseIntParam(value: string | undefined): number | undefined {
44
- const n = object.toNumber(value);
45
- if (n === undefined || n < 0) return undefined;
46
- return Math.trunc(n);
47
- }