@mastra/spanner 0.0.0 → 1.0.0
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/CHANGELOG.md +21 -5
- package/dist/docs/SKILL.md +22 -0
- package/dist/docs/assets/SOURCE_MAP.json +6 -0
- package/dist/docs/references/reference-storage-spanner.md +213 -0
- package/dist/index.cjs +9781 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9765 -0
- package/dist/index.js.map +1 -0
- package/dist/storage/db/index.d.ts +344 -0
- package/dist/storage/db/index.d.ts.map +1 -0
- package/dist/storage/db/utils.d.ts +27 -0
- package/dist/storage/db/utils.d.ts.map +1 -0
- package/dist/storage/domains/agents/index.d.ts +44 -0
- package/dist/storage/domains/agents/index.d.ts.map +1 -0
- package/dist/storage/domains/background-tasks/index.d.ts +27 -0
- package/dist/storage/domains/background-tasks/index.d.ts.map +1 -0
- package/dist/storage/domains/blobs/index.d.ts +36 -0
- package/dist/storage/domains/blobs/index.d.ts.map +1 -0
- package/dist/storage/domains/mcp-clients/index.d.ts +64 -0
- package/dist/storage/domains/mcp-clients/index.d.ts.map +1 -0
- package/dist/storage/domains/mcp-servers/index.d.ts +64 -0
- package/dist/storage/domains/mcp-servers/index.d.ts.map +1 -0
- package/dist/storage/domains/memory/index.d.ts +101 -0
- package/dist/storage/domains/memory/index.d.ts.map +1 -0
- package/dist/storage/domains/observability/index.d.ts +67 -0
- package/dist/storage/domains/observability/index.d.ts.map +1 -0
- package/dist/storage/domains/observability/metrics.d.ts +119 -0
- package/dist/storage/domains/observability/metrics.d.ts.map +1 -0
- package/dist/storage/domains/prompt-blocks/index.d.ts +65 -0
- package/dist/storage/domains/prompt-blocks/index.d.ts.map +1 -0
- package/dist/storage/domains/schedules/index.d.ts +55 -0
- package/dist/storage/domains/schedules/index.d.ts.map +1 -0
- package/dist/storage/domains/scorer-definitions/index.d.ts +64 -0
- package/dist/storage/domains/scorer-definitions/index.d.ts.map +1 -0
- package/dist/storage/domains/scores/index.d.ts +46 -0
- package/dist/storage/domains/scores/index.d.ts.map +1 -0
- package/dist/storage/domains/skills/index.d.ts +64 -0
- package/dist/storage/domains/skills/index.d.ts.map +1 -0
- package/dist/storage/domains/utils.d.ts +17 -0
- package/dist/storage/domains/utils.d.ts.map +1 -0
- package/dist/storage/domains/workflows/index.d.ts +97 -0
- package/dist/storage/domains/workflows/index.d.ts.map +1 -0
- package/dist/storage/index.d.ts +178 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/package.json +5 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/mcp-servers/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,iBAAiB,EAMlB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,kBAAkB,EAClB,oBAAoB,EACpB,2BAA2B,EAC3B,0BAA0B,EAC1B,2BAA2B,EAC3B,2BAA2B,EAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,2BAA2B,EAC3B,0BAA0B,EAC1B,2BAA2B,EAC3B,gBAAgB,EACjB,MAAM,0CAA0C,CAAC;AAElD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAIpD;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,iBAAiB;IACtD,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,EAAE,CAAY;IACtB,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAU;IAC9C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAuB;IAEhD,MAAM,CAAC,QAAQ,CAAC,cAAc,gEAA2D;gBAE7E,MAAM,EAAE,mBAAmB;IAUvC,uFAAuF;IACjF,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAS3B;;;OAGG;YACW,kBAAkB;IAmBhC,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AAK,EAAE,0BAA0B,GAAG,OAAO,CAAC,2BAA2B,CAAC;IA8D3F,0CAA0C;IACpC,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoB9C,mEAAmE;IAC7D,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoB/D,yEAAyE;IACnE,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAqB1D"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { MastraMessageContentV2 } from '@mastra/core/agent';
|
|
2
|
+
import type { MastraDBMessage, StorageThreadType } from '@mastra/core/memory';
|
|
3
|
+
import { MemoryStorage } from '@mastra/core/storage';
|
|
4
|
+
import type { StorageResourceType, StorageListMessagesInput, StorageListMessagesOutput, StorageListThreadsInput, StorageListThreadsOutput, CreateIndexOptions } from '@mastra/core/storage';
|
|
5
|
+
import type { SpannerDomainConfig } from '../../db/index.js';
|
|
6
|
+
/**
|
|
7
|
+
* Spanner-backed storage for memory primitives: threads, messages, and resources
|
|
8
|
+
* (the durable state surface used by `@mastra/memory`).
|
|
9
|
+
*/
|
|
10
|
+
export declare class MemorySpanner extends MemoryStorage {
|
|
11
|
+
private database;
|
|
12
|
+
private db;
|
|
13
|
+
private readonly skipDefaultIndexes?;
|
|
14
|
+
private readonly indexes?;
|
|
15
|
+
static readonly MANAGED_TABLES: readonly ["mastra_threads", "mastra_messages", "mastra_resources"];
|
|
16
|
+
constructor(config: SpannerDomainConfig);
|
|
17
|
+
/** Creates the threads/messages/resources tables and any indexes. */
|
|
18
|
+
init(): Promise<void>;
|
|
19
|
+
/** Returns the default index set this domain creates during `init()`. */
|
|
20
|
+
getDefaultIndexDefinitions(): CreateIndexOptions[];
|
|
21
|
+
/** Creates the default indexes; no-op when `skipDefaultIndexes` was set. */
|
|
22
|
+
createDefaultIndexes(): Promise<void>;
|
|
23
|
+
/** Creates custom indexes routed to this domain's tables; no-op when none supplied. */
|
|
24
|
+
createCustomIndexes(): Promise<void>;
|
|
25
|
+
/** Removes every row from threads/messages/resources tables. Intended for tests. */
|
|
26
|
+
dangerouslyClearAll(): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Fetches a thread row by id, or `null` when absent.
|
|
29
|
+
*
|
|
30
|
+
* When `resourceId` is supplied (including the empty string) it scopes the
|
|
31
|
+
* lookup so callers can enforce multi-tenant isolation: a thread that
|
|
32
|
+
* exists under a different resourceId is reported as missing rather than
|
|
33
|
+
* leaking across tenants.
|
|
34
|
+
*/
|
|
35
|
+
getThreadById({ threadId, resourceId, }: {
|
|
36
|
+
threadId: string;
|
|
37
|
+
resourceId?: string;
|
|
38
|
+
}): Promise<StorageThreadType | null>;
|
|
39
|
+
private formatThreadRow;
|
|
40
|
+
/** Paginated thread listing with optional resourceId/metadata/date-range filters. */
|
|
41
|
+
listThreads(args: StorageListThreadsInput): Promise<StorageListThreadsOutput>;
|
|
42
|
+
/** Upserts a thread row by id (`INSERT OR UPDATE` semantics). */
|
|
43
|
+
saveThread({ thread }: {
|
|
44
|
+
thread: StorageThreadType;
|
|
45
|
+
}): Promise<StorageThreadType>;
|
|
46
|
+
/** Updates a thread's title and merges the metadata payload. */
|
|
47
|
+
updateThread({ id, title, metadata, }: {
|
|
48
|
+
id: string;
|
|
49
|
+
title: string;
|
|
50
|
+
metadata: Record<string, unknown>;
|
|
51
|
+
}): Promise<StorageThreadType>;
|
|
52
|
+
/** Deletes a thread and all its messages atomically. */
|
|
53
|
+
deleteThread({ threadId }: {
|
|
54
|
+
threadId: string;
|
|
55
|
+
}): Promise<void>;
|
|
56
|
+
/** Parses raw message rows and converts them into the requested API format ('v1' or 'v2'). */
|
|
57
|
+
private parseAndFormatMessages;
|
|
58
|
+
/** Fetches a batch of messages by id; missing ids are silently dropped. */
|
|
59
|
+
listMessagesById({ messageIds }: {
|
|
60
|
+
messageIds: string[];
|
|
61
|
+
}): Promise<{
|
|
62
|
+
messages: MastraDBMessage[];
|
|
63
|
+
}>;
|
|
64
|
+
/** Resolves the `include` clause: pinned messages plus their before/after windows. */
|
|
65
|
+
private getIncludedMessages;
|
|
66
|
+
/** Paginated message listing for a thread, with optional pinned-include and date-range filters. */
|
|
67
|
+
listMessages(args: StorageListMessagesInput): Promise<StorageListMessagesOutput>;
|
|
68
|
+
/** Upserts a batch of messages and bumps every touched thread's `updatedAt` in a single transaction. */
|
|
69
|
+
saveMessages({ messages }: {
|
|
70
|
+
messages: MastraDBMessage[];
|
|
71
|
+
}): Promise<{
|
|
72
|
+
messages: MastraDBMessage[];
|
|
73
|
+
}>;
|
|
74
|
+
/** Merges partial updates onto existing messages and bumps affected thread `updatedAt`. */
|
|
75
|
+
updateMessages({ messages, }: {
|
|
76
|
+
messages: (Partial<Omit<MastraDBMessage, 'createdAt'>> & {
|
|
77
|
+
id: string;
|
|
78
|
+
content?: {
|
|
79
|
+
metadata?: MastraMessageContentV2['metadata'];
|
|
80
|
+
content?: MastraMessageContentV2['content'];
|
|
81
|
+
};
|
|
82
|
+
})[];
|
|
83
|
+
}): Promise<MastraDBMessage[]>;
|
|
84
|
+
/** Deletes a batch of messages and bumps the affected threads' `updatedAt`. */
|
|
85
|
+
deleteMessages(messageIds: string[]): Promise<void>;
|
|
86
|
+
/** Fetches a resource row by id, or `null` when absent. */
|
|
87
|
+
getResourceById({ resourceId }: {
|
|
88
|
+
resourceId: string;
|
|
89
|
+
}): Promise<StorageResourceType | null>;
|
|
90
|
+
/** Upserts a resource row by id (`INSERT OR UPDATE` semantics). */
|
|
91
|
+
saveResource({ resource }: {
|
|
92
|
+
resource: StorageResourceType;
|
|
93
|
+
}): Promise<StorageResourceType>;
|
|
94
|
+
/** Updates a resource's `workingMemory` and merges its `metadata`. */
|
|
95
|
+
updateResource({ resourceId, workingMemory, metadata, }: {
|
|
96
|
+
resourceId: string;
|
|
97
|
+
workingMemory?: string;
|
|
98
|
+
metadata?: Record<string, unknown>;
|
|
99
|
+
}): Promise<StorageResourceType>;
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/memory/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,KAAK,EAAmB,eAAe,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC/F,OAAO,EAEL,aAAa,EAOd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EACzB,uBAAuB,EACvB,wBAAwB,EACxB,kBAAkB,EACnB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAIpD;;;GAGG;AACH,qBAAa,aAAc,SAAQ,aAAa;IAC9C,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,EAAE,CAAY;IACtB,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAU;IAC9C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAuB;IAEhD,MAAM,CAAC,QAAQ,CAAC,cAAc,qEAA6D;gBAE/E,MAAM,EAAE,mBAAmB;IASvC,qEAAqE;IAC/D,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ3B,yEAAyE;IACzE,0BAA0B,IAAI,kBAAkB,EAAE;IAelD,4EAA4E;IACtE,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAK3C,uFAAuF;IACjF,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAK1C,oFAAoF;IAC9E,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAM1C;;;;;;;OAOG;IACG,aAAa,CAAC,EAClB,QAAQ,EACR,UAAU,GACX,EAAE;QACD,QAAQ,EAAE,MAAM,CA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Ac,CAAC,EACnB,QAAQ,GACT,EAAE;QACD,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC,GAAG;YACvD,EAAE,EAAE,MAAM,CAAC;YACX,OAAO,CAAC,EAAE;gBACR,QAAQ,CAAC,EAAE,sBAAsB,CAAC,UAAU,CAAC,CAAC;gBAC9C,OAAO,CAAC,EAAE,sBAAsB,CAAC,SAAS,CAAC,CAAC;aAC7C,CAAC;SACH,CAAC,EAAE,CAAC;KACN,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IA8H9B,+EAA+E;IACzE,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAwDzD,2DAA2D;IACrD,eAAe,CAAC,EAAE,UAAU,EAAE,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;IAmClG,mEAAmE;IAC7D,YAAY,CAAC,EAAE,QAAQ,EAAE,EAAE;QAAE,QAAQ,EAAE,mBAAmB,CAAA;KAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAcjG,sEAAsE;IAChE,cAAc,CAAC,EACnB,UAAU,EACV,aAAa,EACb,QAAQ,GACT,EAAE;QACD,UAAU,EAAE,MAAM,CAAC;QACnB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACpC,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAyFjC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { ObservabilityStorage } from '@mastra/core/storage';
|
|
2
|
+
import type { BatchCreateMetricsArgs, BatchCreateSpansArgs, BatchDeleteTracesArgs, BatchUpdateSpansArgs, CreateIndexOptions, CreateSpanArgs, GetMetricAggregateArgs, GetMetricAggregateResponse, GetMetricBreakdownArgs, GetMetricBreakdownResponse, GetMetricLabelKeysArgs, GetMetricLabelKeysResponse, GetMetricLabelValuesArgs, GetMetricLabelValuesResponse, GetMetricNamesArgs, GetMetricNamesResponse, GetMetricPercentilesArgs, GetMetricPercentilesResponse, GetMetricTimeSeriesArgs, GetMetricTimeSeriesResponse, GetRootSpanArgs, GetRootSpanResponse, GetSpanArgs, GetSpanResponse, GetTraceArgs, GetTraceLightResponse, GetTraceResponse, ListMetricsArgs, ListMetricsResponse, ListTracesArgs, ListTracesResponse, TracingStorageStrategy, UpdateSpanArgs } from '@mastra/core/storage';
|
|
3
|
+
import type { SpannerDomainConfig } from '../../db/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* Observability domain for Spanner. Stores AI tracing spans in `mastra_ai_spans`
|
|
6
|
+
* and supports the trace read/write surface that powers the Mastra observability
|
|
7
|
+
* UI: per-span CRUD, per-trace fetch, lightweight trace skeletons for the
|
|
8
|
+
* waterfall view, and root-span pagination with the listTraces filters.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ObservabilitySpanner extends ObservabilityStorage {
|
|
11
|
+
private database;
|
|
12
|
+
private db;
|
|
13
|
+
private readonly skipDefaultIndexes?;
|
|
14
|
+
private readonly indexes?;
|
|
15
|
+
private readonly initMode;
|
|
16
|
+
/**
|
|
17
|
+
* Bounded-staleness window (in ms) applied to every metrics read path.
|
|
18
|
+
* Default 10000 (weak reads).
|
|
19
|
+
*/
|
|
20
|
+
private readonly dashboardStalenessMs;
|
|
21
|
+
/**
|
|
22
|
+
* When true (the default), every metric method throws the base-class
|
|
23
|
+
* `*_NOT_IMPLEMENTED` error and the metrics table is not created during
|
|
24
|
+
* `init()`. See the option doc on `SpannerDomainDatabaseConfig` for the
|
|
25
|
+
* full rationale.
|
|
26
|
+
*/
|
|
27
|
+
private readonly disableMetrics;
|
|
28
|
+
/** Tables managed by this domain */
|
|
29
|
+
static readonly MANAGED_TABLES: readonly ["mastra_ai_spans", "mastra_ai_metrics"];
|
|
30
|
+
constructor(config: SpannerDomainConfig);
|
|
31
|
+
/** Build the read-options object that every metrics read path threads through. */
|
|
32
|
+
private readOptions;
|
|
33
|
+
/**
|
|
34
|
+
* Throw the same shape of NOT_IMPLEMENTED error the base class would when
|
|
35
|
+
* a method isn't overridden
|
|
36
|
+
*/
|
|
37
|
+
private metricsDisabledError;
|
|
38
|
+
init(): Promise<void>;
|
|
39
|
+
getDefaultIndexDefinitions(): CreateIndexOptions[];
|
|
40
|
+
createDefaultIndexes(): Promise<void>;
|
|
41
|
+
createCustomIndexes(): Promise<void>;
|
|
42
|
+
dangerouslyClearAll(): Promise<void>;
|
|
43
|
+
get tracingStrategy(): {
|
|
44
|
+
preferred: TracingStorageStrategy;
|
|
45
|
+
supported: TracingStorageStrategy[];
|
|
46
|
+
};
|
|
47
|
+
createSpan(args: CreateSpanArgs): Promise<void>;
|
|
48
|
+
batchCreateSpans(args: BatchCreateSpansArgs): Promise<void>;
|
|
49
|
+
updateSpan(args: UpdateSpanArgs): Promise<void>;
|
|
50
|
+
batchUpdateSpans(args: BatchUpdateSpansArgs): Promise<void>;
|
|
51
|
+
getSpan(args: GetSpanArgs): Promise<GetSpanResponse | null>;
|
|
52
|
+
getRootSpan(args: GetRootSpanArgs): Promise<GetRootSpanResponse | null>;
|
|
53
|
+
getTrace(args: GetTraceArgs): Promise<GetTraceResponse | null>;
|
|
54
|
+
getTraceLight(args: GetTraceArgs): Promise<GetTraceLightResponse | null>;
|
|
55
|
+
listTraces(args: ListTracesArgs): Promise<ListTracesResponse>;
|
|
56
|
+
batchDeleteTraces(args: BatchDeleteTracesArgs): Promise<void>;
|
|
57
|
+
batchCreateMetrics(args: BatchCreateMetricsArgs): Promise<void>;
|
|
58
|
+
listMetrics(args: ListMetricsArgs): Promise<ListMetricsResponse>;
|
|
59
|
+
getMetricAggregate(args: GetMetricAggregateArgs): Promise<GetMetricAggregateResponse>;
|
|
60
|
+
getMetricBreakdown(args: GetMetricBreakdownArgs): Promise<GetMetricBreakdownResponse>;
|
|
61
|
+
getMetricTimeSeries(args: GetMetricTimeSeriesArgs): Promise<GetMetricTimeSeriesResponse>;
|
|
62
|
+
getMetricPercentiles(args: GetMetricPercentilesArgs): Promise<GetMetricPercentilesResponse>;
|
|
63
|
+
getMetricNames(args: GetMetricNamesArgs): Promise<GetMetricNamesResponse>;
|
|
64
|
+
getMetricLabelKeys(args: GetMetricLabelKeysArgs): Promise<GetMetricLabelKeysResponse>;
|
|
65
|
+
getMetricLabelValues(args: GetMetricLabelValuesArgs): Promise<GetMetricLabelValuesResponse>;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/observability/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,oBAAoB,EAKrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,sBAAsB,EACtB,0BAA0B,EAC1B,sBAAsB,EACtB,0BAA0B,EAC1B,sBAAsB,EACtB,0BAA0B,EAC1B,wBAAwB,EACxB,4BAA4B,EAC5B,kBAAkB,EAClB,sBAAsB,EACtB,wBAAwB,EACxB,4BAA4B,EAC5B,uBAAuB,EACvB,2BAA2B,EAC3B,eAAe,EACf,mBAAmB,EACnB,WAAW,EACX,eAAe,EACf,YAAY,EACZ,qBAAqB,EACrB,gBAAgB,EAEhB,eAAe,EACf,mBAAmB,EACnB,cAAc,EACd,kBAAkB,EAElB,sBAAsB,EACtB,cAAc,EACf,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,mBAAmB,EAAmB,MAAM,UAAU,CAAC;AAgBrE;;;;;GAKG;AACH,qBAAa,oBAAqB,SAAQ,oBAAoB;IAC5D,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,EAAE,CAAY;IACtB,OAAO,CAAC,QA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,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IA6B9D,aAAa,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;IAqCxE,UAAU,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA0L7D,iBAAiB,CAAC,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IA0BpD,kBAAkB,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAK/D,WAAW,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAKhE,kBAAkB,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAKrF,kBAAkB,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAKrF,mBAAmB,CAAC,IAAI,EAAE,uBAAuB,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAKxF,oBAAoB,CAAC,IAAI,EAAE,wBAAwB,GAAG,OAAO,CAAC,4BAA4B,CAAC;IAK3F,cAAc,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAKzE,kBAAkB,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAKrF,oBAAoB,CAAC,IAAI,EAAE,wBAAwB,GAAG,OAAO,CAAC,4BAA4B,CAAC;CAI3G"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { Database } from '@google-cloud/spanner';
|
|
2
|
+
import type { BatchCreateMetricsArgs, GetMetricAggregateArgs, GetMetricAggregateResponse, GetMetricBreakdownArgs, GetMetricBreakdownResponse, GetMetricLabelKeysArgs, GetMetricLabelKeysResponse, GetMetricLabelValuesArgs, GetMetricLabelValuesResponse, GetMetricNamesArgs, GetMetricNamesResponse, GetMetricPercentilesArgs, GetMetricPercentilesResponse, GetMetricTimeSeriesArgs, GetMetricTimeSeriesResponse, ListMetricsArgs, ListMetricsResponse } from '@mastra/core/storage';
|
|
3
|
+
import type { SpannerInitMode } from '../../db/index.js';
|
|
4
|
+
/** Physical table name. Not exposed by `@mastra/core/storage` (no TABLE_METRICS
|
|
5
|
+
* constant exists), so the Spanner adapter owns the name itself. Follows the
|
|
6
|
+
* same `mastra_ai_*` convention as `TABLE_SPANS = 'mastra_ai_spans'`. */
|
|
7
|
+
export declare const TABLE_AI_METRICS = "mastra_ai_metrics";
|
|
8
|
+
export type MetricIndexDef = {
|
|
9
|
+
name: string;
|
|
10
|
+
columns: string[];
|
|
11
|
+
/**
|
|
12
|
+
* Non-key columns copied into the secondary index so common aggregate reads
|
|
13
|
+
* can be index-only instead of joining back to the base metrics table.
|
|
14
|
+
*/
|
|
15
|
+
storing?: string[];
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Default secondary indexes. Every analytical query starts with a name filter
|
|
19
|
+
* and a timestamp range, so the leading composite index is `(name, timestamp DESC)`.
|
|
20
|
+
*
|
|
21
|
+
* Intentionally NOT here: a bare `(timestamp DESC)` index. A monotonically
|
|
22
|
+
* increasing leading column funnels every new row through a single Spanner
|
|
23
|
+
* split until the planner re-splits, capping per-region write throughput
|
|
24
|
+
* regardless of node count. The `(name, ...)` and `(provider, model, ...)`
|
|
25
|
+
* composites give the planner index access for the common queries while
|
|
26
|
+
* smearing writes across many splits via the leading low-cardinality column.
|
|
27
|
+
* Unfiltered "latest metrics" reads fall back to a full scan + sort, which
|
|
28
|
+
* is acceptable because they're bounded by `perPage` and rarely on the
|
|
29
|
+
* dashboard hot path.
|
|
30
|
+
*/
|
|
31
|
+
export declare function defaultMetricIndexDefs(): MetricIndexDef[];
|
|
32
|
+
/**
|
|
33
|
+
* Create the metrics table + default indexes idempotently. Under
|
|
34
|
+
* `initMode: 'validate'` the function issues no DDL and instead verifies that
|
|
35
|
+
* the table and every default index already exist, throwing a typed user
|
|
36
|
+
* error otherwise. Mirrors the contract `SpannerDB.createTable` exposes for
|
|
37
|
+
* the core tables.
|
|
38
|
+
*/
|
|
39
|
+
export declare function ensureMetricsTable(database: Database, options: {
|
|
40
|
+
initMode: SpannerInitMode;
|
|
41
|
+
skipDefaultIndexes?: boolean;
|
|
42
|
+
}): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Insert a batch of metric records as a single mutation.
|
|
45
|
+
*
|
|
46
|
+
* Uses the Spanner Mutations API (`tx.insert(table, rows)`) rather than DML
|
|
47
|
+
* because metrics are append-heavy: a single mutation commits the whole batch
|
|
48
|
+
* in one RPC, where the DML equivalent would round-trip per row. At dashboard
|
|
49
|
+
* scales this is several × the throughput, and it also avoids the per-row
|
|
50
|
+
* parameter-binding overhead.
|
|
51
|
+
*
|
|
52
|
+
* Encoding rules for mutations:
|
|
53
|
+
* - JS `Date` instances are accepted directly for TIMESTAMP columns (the
|
|
54
|
+
* client serializes via `.toJSON()`).
|
|
55
|
+
* - Plain objects / arrays are accepted directly for JSON columns (the
|
|
56
|
+
* client serializes with `JSON.stringify`); the server parses them
|
|
57
|
+
* because the column schema is JSON.
|
|
58
|
+
* - Whole-number JS numbers wrapped in `Spanner.float(n)` to force FLOAT64
|
|
59
|
+
* encoding — without the wrapper the client serializes `100` as a string
|
|
60
|
+
* and the server rejects it (same root cause as the DML path).
|
|
61
|
+
* - `null` is passed through and respected per the column's nullability.
|
|
62
|
+
*/
|
|
63
|
+
export declare function batchCreateMetrics(database: Database, args: BatchCreateMetricsArgs): Promise<void>;
|
|
64
|
+
/** Per-call read options accepted by every read function in this module. */
|
|
65
|
+
export type MetricsReadOptions = {
|
|
66
|
+
/**
|
|
67
|
+
* Maximum acceptable staleness in milliseconds for the read. When set to a
|
|
68
|
+
* positive value, the query is issued as a single-use read-only transaction
|
|
69
|
+
* with `maxStaleness`, which lets Spanner serve it from any replica that
|
|
70
|
+
* already has data at least that fresh. The benefit is twofold:
|
|
71
|
+
*
|
|
72
|
+
* 1. Dashboard reads stop competing with leader-region writes for CPU.
|
|
73
|
+
* 2. The planner can route the query to the closest replica, often
|
|
74
|
+
* shaving 10-50ms off the round-trip vs. a strong read.
|
|
75
|
+
*
|
|
76
|
+
* For metrics specifically, observability dashboards routinely tolerate a
|
|
77
|
+
* few seconds of staleness. `ObservabilitySpanner` defaults to 0 for
|
|
78
|
+
* backwards-compatible strong reads, and callers can opt into bounded
|
|
79
|
+
* staleness with `dashboardStalenessMs`. Note: maxStaleness is only valid
|
|
80
|
+
* for single-use read-only transactions, which is what `database.run` issues.
|
|
81
|
+
*/
|
|
82
|
+
stalenessMs?: number;
|
|
83
|
+
};
|
|
84
|
+
/** Paginated listing with the metric-records filter surface. */
|
|
85
|
+
export declare function listMetrics(database: Database, args: ListMetricsArgs, options?: MetricsReadOptions): Promise<ListMetricsResponse>;
|
|
86
|
+
/** Single-value aggregate with optional period-over-period comparison. */
|
|
87
|
+
export declare function getMetricAggregate(database: Database, args: GetMetricAggregateArgs, options?: MetricsReadOptions): Promise<GetMetricAggregateResponse>;
|
|
88
|
+
/** Breakdown by one or more dimensions (columns or label keys). */
|
|
89
|
+
export declare function getMetricBreakdown(database: Database, args: GetMetricBreakdownArgs, options?: MetricsReadOptions): Promise<GetMetricBreakdownResponse>;
|
|
90
|
+
/** Bucketed time-series, optionally split into multiple series by groupBy. */
|
|
91
|
+
export declare function getMetricTimeSeries(database: Database, args: GetMetricTimeSeriesArgs, options?: MetricsReadOptions): Promise<GetMetricTimeSeriesResponse>;
|
|
92
|
+
/**
|
|
93
|
+
* Bucketed percentile series. Spanner GoogleSQL exposes `PERCENTILE_CONT`
|
|
94
|
+
* only as an analytic (window) function, which neither the local emulator
|
|
95
|
+
* nor older production releases support inside our query shape. Pulling raw
|
|
96
|
+
* values one-by-one to compute percentiles in JS would round-trip per row.
|
|
97
|
+
*
|
|
98
|
+
* Instead we use `ARRAY_AGG(value ORDER BY value) GROUP BY bucket` to ship
|
|
99
|
+
* one pre-sorted array per bucket, then interpolate every requested
|
|
100
|
+
* percentile in JS. That's:
|
|
101
|
+
* - one SQL query for any number of percentiles (vs. one-per-p with a
|
|
102
|
+
* window function), so listing p50/p90/p95/p99 is the same cost as one;
|
|
103
|
+
* - portable across every Spanner version because ARRAY_AGG is a core
|
|
104
|
+
* aggregate (not an analytic function);
|
|
105
|
+
* - exact (linear-interpolation form, matching `PERCENTILE_CONT`'s
|
|
106
|
+
* definition) rather than HyperLogLog-approximate.
|
|
107
|
+
*
|
|
108
|
+
* The trade-off is that each bucket's array materializes server-side; for
|
|
109
|
+
* pathological queries with millions of points per bucket the row could
|
|
110
|
+
* exceed Spanner's 4MB row limit. Typical dashboard percentile queries
|
|
111
|
+
* (single metric, recent window, modest cardinality) stay well under that.
|
|
112
|
+
*/
|
|
113
|
+
export declare function getMetricPercentiles(database: Database, args: GetMetricPercentilesArgs, options?: MetricsReadOptions): Promise<GetMetricPercentilesResponse>;
|
|
114
|
+
export declare function getMetricNames(database: Database, args: GetMetricNamesArgs, options?: MetricsReadOptions): Promise<GetMetricNamesResponse>;
|
|
115
|
+
export declare function getMetricLabelKeys(database: Database, args: GetMetricLabelKeysArgs, options?: MetricsReadOptions): Promise<GetMetricLabelKeysResponse>;
|
|
116
|
+
export declare function getMetricLabelValues(database: Database, args: GetMetricLabelValuesArgs, options?: MetricsReadOptions): Promise<GetMetricLabelValuesResponse>;
|
|
117
|
+
/** Wipes every metric row. Intended for `dangerouslyClearAll()`. */
|
|
118
|
+
export declare function clearMetrics(database: Database): Promise<void>;
|
|
119
|
+
//# sourceMappingURL=metrics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/observability/metrics.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAe,MAAM,uBAAuB,CAAC;AAInE,OAAO,KAAK,EAGV,sBAAsB,EACtB,sBAAsB,EACtB,0BAA0B,EAC1B,sBAAsB,E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|
|
|
1
|
+
import { PromptBlocksStorage } from '@mastra/core/storage';
|
|
2
|
+
import type { CreateIndexOptions, StoragePromptBlockType, StorageCreatePromptBlockInput, StorageListPromptBlocksInput, StorageListPromptBlocksOutput, StorageUpdatePromptBlockInput } from '@mastra/core/storage';
|
|
3
|
+
import type { CreatePromptBlockVersionInput, ListPromptBlockVersionsInput, ListPromptBlockVersionsOutput, PromptBlockVersion } from '@mastra/core/storage/domains/prompt-blocks';
|
|
4
|
+
import type { SpannerDomainConfig } from '../../db/index.js';
|
|
5
|
+
/**
|
|
6
|
+
* Spanner-backed storage for prompt blocks and their immutable versions.
|
|
7
|
+
* Mirrors the thin-record + versions pattern used by agents/skills/scorer-definitions.
|
|
8
|
+
*/
|
|
9
|
+
export declare class PromptBlocksSpanner extends PromptBlocksStorage {
|
|
10
|
+
private database;
|
|
11
|
+
private db;
|
|
12
|
+
private readonly skipDefaultIndexes?;
|
|
13
|
+
private readonly indexes?;
|
|
14
|
+
static readonly MANAGED_TABLES: readonly ["mastra_prompt_blocks", "mastra_prompt_block_versions"];
|
|
15
|
+
constructor(config: SpannerDomainConfig);
|
|
16
|
+
/** Creates the prompt-block tables, indexes, and (when opted in) sweeps stale drafts. */
|
|
17
|
+
init(): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Removes orphaned draft prompt-block records where the paired version row
|
|
20
|
+
* was never written. Skipped under `initMode: 'validate'` (no destructive
|
|
21
|
+
* DML in validate mode).
|
|
22
|
+
*/
|
|
23
|
+
private cleanupStaleDrafts;
|
|
24
|
+
/** Returns the default index set this domain creates during `init()`. */
|
|
25
|
+
getDefaultIndexDefinitions(): CreateIndexOptions[];
|
|
26
|
+
/** Creates the default indexes; no-op when `skipDefaultIndexes` was set. */
|
|
27
|
+
createDefaultIndexes(): Promise<void>;
|
|
28
|
+
/** Creates custom indexes routed to this domain's tables; no-op when none supplied. */
|
|
29
|
+
createCustomIndexes(): Promise<void>;
|
|
30
|
+
/** Removes every row from this domain's tables. Intended for tests. */
|
|
31
|
+
dangerouslyClearAll(): Promise<void>;
|
|
32
|
+
/** Decodes a raw Spanner thin-row into the public prompt-block shape. */
|
|
33
|
+
private parsePromptBlockRow;
|
|
34
|
+
/** Decodes a raw Spanner version row into the public version shape. */
|
|
35
|
+
private parseVersionRow;
|
|
36
|
+
/** Fetches the thin prompt-block record by id, or `null` when absent. */
|
|
37
|
+
getById(id: string): Promise<StoragePromptBlockType | null>;
|
|
38
|
+
/** Atomically inserts a draft thin row + version 1 in a single Spanner transaction. */
|
|
39
|
+
create(input: {
|
|
40
|
+
promptBlock: StorageCreatePromptBlockInput;
|
|
41
|
+
}): Promise<StoragePromptBlockType>;
|
|
42
|
+
/** Updates thin-record fields (status, activeVersionId, authorId, metadata). */
|
|
43
|
+
update(input: StorageUpdatePromptBlockInput): Promise<StoragePromptBlockType>;
|
|
44
|
+
/** Removes a prompt block and all its versions atomically in a single transaction. */
|
|
45
|
+
delete(id: string): Promise<void>;
|
|
46
|
+
/** Paginated listing with optional status / authorId / metadata filters. */
|
|
47
|
+
list(args?: StorageListPromptBlocksInput): Promise<StorageListPromptBlocksOutput>;
|
|
48
|
+
/** Inserts a new immutable version row for an existing prompt block. */
|
|
49
|
+
createVersion(input: CreatePromptBlockVersionInput): Promise<PromptBlockVersion>;
|
|
50
|
+
/** Fetches a version row by its id, or `null` when absent. */
|
|
51
|
+
getVersion(id: string): Promise<PromptBlockVersion | null>;
|
|
52
|
+
/** Fetches a specific version by `(blockId, versionNumber)`. */
|
|
53
|
+
getVersionByNumber(blockId: string, versionNumber: number): Promise<PromptBlockVersion | null>;
|
|
54
|
+
/** Returns the highest-numbered version for a prompt block. */
|
|
55
|
+
getLatestVersion(blockId: string): Promise<PromptBlockVersion | null>;
|
|
56
|
+
/** Paginated listing of versions for a single prompt block. */
|
|
57
|
+
listVersions(input: ListPromptBlockVersionsInput): Promise<ListPromptBlockVersionsOutput>;
|
|
58
|
+
/** Deletes a single version row by id. */
|
|
59
|
+
deleteVersion(id: string): Promise<void>;
|
|
60
|
+
/** Deletes every version row belonging to the given prompt block. */
|
|
61
|
+
deleteVersionsByParentId(entityId: string): Promise<void>;
|
|
62
|
+
/** Returns the total number of version rows for the given prompt block. */
|
|
63
|
+
countVersions(blockId: string): Promise<number>;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/prompt-blocks/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,mBAAmB,EAKpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,kBAAkB,EAClB,sBAAsB,EACtB,6BAA6B,EAC7B,4BAA4B,EAC5B,6BAA6B,EAC7B,6BAA6B,EAC9B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,6BAA6B,EAC7B,4BAA4B,EAC5B,6BAA6B,EAC7B,kBAAkB,EACnB,MAAM,4CAA4C,CAAC;AAEpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAIpD;;;GAGG;AACH,qBAAa,mBAAoB,SAAQ,mBAAmB;IAC1D,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,EAAE,CAAY;IACtB,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAU;IAC9C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAuB;IAEhD,MAAM,CAAC,QAAQ,CAAC,cAAc,oEAA+D;gBAEjF,MAAM,EAAE,mBAAmB;IAYvC,yFAAyF;IACnF,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAS3B;;;;OAIG;YACW,kBAAkB;IAmBhC,yEAAyE;IACzE,0BAA0B,IAAI,kBAAkB,EAAE;IAuBlD,4EAA4E;IACtE,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAK3C,uFAAuF;IACjF,mBAAmB,IAAI,OAAO,CAAC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E;IAC/D,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoB/D,2EAA2E;IACrE,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAqBtD"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { SchedulesStorage } from '@mastra/core/storage';
|
|
2
|
+
import type { CreateIndexOptions, Schedule, ScheduleFilter, ScheduleTrigger, ScheduleTriggerListOptions, ScheduleUpdate } from '@mastra/core/storage';
|
|
3
|
+
import type { SpannerDomainConfig } from '../../db/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* Spanner-backed storage for `WorkflowScheduler` schedules and trigger history.
|
|
6
|
+
*
|
|
7
|
+
* `mastra_schedule_triggers.id` is the table's only primary-key column
|
|
8
|
+
* (matches `TABLE_SCHEMAS[TABLE_SCHEDULE_TRIGGERS]`). `schedule_id` is filtered
|
|
9
|
+
* via a secondary index registered in {@link getDefaultIndexDefinitions}.
|
|
10
|
+
*/
|
|
11
|
+
export declare class SchedulesSpanner extends SchedulesStorage {
|
|
12
|
+
private database;
|
|
13
|
+
private db;
|
|
14
|
+
private readonly skipDefaultIndexes?;
|
|
15
|
+
private readonly indexes?;
|
|
16
|
+
static readonly MANAGED_TABLES: readonly ["mastra_schedules", "mastra_schedule_triggers"];
|
|
17
|
+
constructor(config: SpannerDomainConfig);
|
|
18
|
+
init(): Promise<void>;
|
|
19
|
+
getDefaultIndexDefinitions(): CreateIndexOptions[];
|
|
20
|
+
/**
|
|
21
|
+
* Creates the default indexes; no-op when `skipDefaultIndexes` was set.
|
|
22
|
+
* Filters out the target_workflow_id index when that generated column is
|
|
23
|
+
* absent (e.g. ensureTargetWorkflowIdColumn() failed, or `initMode: 'validate'`
|
|
24
|
+
* skipped the DDL). Otherwise the createIndex call would fail on a missing
|
|
25
|
+
* column.
|
|
26
|
+
*/
|
|
27
|
+
createDefaultIndexes(): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Spanner-specific optimization: add a STORED generated column that extracts
|
|
30
|
+
* `workflowId` from the JSON `target` payload, so the listSchedules workflowId
|
|
31
|
+
* filter can use a regular secondary index instead of a full JSON_VALUE scan.
|
|
32
|
+
*/
|
|
33
|
+
private ensureTargetWorkflowIdColumn;
|
|
34
|
+
/**
|
|
35
|
+
* Cached lookup for whether the `target_workflow_id` generated column exists.
|
|
36
|
+
* Resolves true after `ensureTargetWorkflowIdColumn()` succeeds, otherwise
|
|
37
|
+
* falls back to an INFORMATION_SCHEMA probe (lets us still pick up the fast
|
|
38
|
+
* path on databases that already had the column from a prior deploy).
|
|
39
|
+
*/
|
|
40
|
+
private targetWorkflowIdColumnAvailable;
|
|
41
|
+
/** Returns true when the `target_workflow_id` generated column exists. */
|
|
42
|
+
private hasTargetWorkflowIdColumn;
|
|
43
|
+
createCustomIndexes(): Promise<void>;
|
|
44
|
+
dangerouslyClearAll(): Promise<void>;
|
|
45
|
+
createSchedule(schedule: Schedule): Promise<Schedule>;
|
|
46
|
+
getSchedule(id: string): Promise<Schedule | null>;
|
|
47
|
+
listSchedules(filter?: ScheduleFilter): Promise<Schedule[]>;
|
|
48
|
+
listDueSchedules(now: number, limit?: number): Promise<Schedule[]>;
|
|
49
|
+
updateSchedule(id: string, patch: ScheduleUpdate): Promise<Schedule>;
|
|
50
|
+
updateScheduleNextFire(id: string, expectedNextFireAt: number, newNextFireAt: number, lastFireAt: number, lastRunId: string): Promise<boolean>;
|
|
51
|
+
deleteSchedule(id: string): Promise<void>;
|
|
52
|
+
recordTrigger(trigger: ScheduleTrigger): Promise<void>;
|
|
53
|
+
listTriggers(scheduleId: string, opts?: ScheduleTriggerListOptions): Promise<ScheduleTrigger[]>;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/schedules/index.ts"],"names":[],"mappings":"AA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CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC;IAuDpE,sBAAsB,CAC1B,EAAE,EAAE,MAAM,EACV,kBAAkB,EAAE,MAAM,EAC1B,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,OAAO,CAAC;IA0Cb,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAmCzC,aAAa,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IA+BtD,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,0BAA0B,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;CA0CtG"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ScorerDefinitionsStorage } from '@mastra/core/storage';
|
|
2
|
+
import type { CreateIndexOptions, StorageScorerDefinitionType, StorageCreateScorerDefinitionInput, StorageListScorerDefinitionsInput, StorageListScorerDefinitionsOutput, StorageUpdateScorerDefinitionInput } from '@mastra/core/storage';
|
|
3
|
+
import type { CreateScorerDefinitionVersionInput, ListScorerDefinitionVersionsInput, ListScorerDefinitionVersionsOutput, ScorerDefinitionVersion } from '@mastra/core/storage/domains/scorer-definitions';
|
|
4
|
+
import type { SpannerDomainConfig } from '../../db/index.js';
|
|
5
|
+
/**
|
|
6
|
+
* Spanner-backed storage for scorer definitions and their immutable versions.
|
|
7
|
+
* Mirrors the thin-record + versions pattern used by agents/skills/prompt-blocks.
|
|
8
|
+
*/
|
|
9
|
+
export declare class ScorerDefinitionsSpanner extends ScorerDefinitionsStorage {
|
|
10
|
+
private database;
|
|
11
|
+
private db;
|
|
12
|
+
private skipDefaultIndexes?;
|
|
13
|
+
private indexes?;
|
|
14
|
+
static readonly MANAGED_TABLES: readonly ["mastra_scorer_definitions", "mastra_scorer_definition_versions"];
|
|
15
|
+
constructor(config: SpannerDomainConfig);
|
|
16
|
+
/** Creates the scorer-definition tables, indexes, and (when opted in) sweeps stale drafts. */
|
|
17
|
+
init(): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Sweeps orphaned draft thin-rows whose paired version row was never written.
|
|
20
|
+
* Skipped under `initMode: 'validate'` (no destructive DML in validate mode).
|
|
21
|
+
*/
|
|
22
|
+
private cleanupStaleDrafts;
|
|
23
|
+
/** Returns the default index set this domain creates during `init()`. */
|
|
24
|
+
getDefaultIndexDefinitions(): CreateIndexOptions[];
|
|
25
|
+
/** Creates the default indexes; no-op when `skipDefaultIndexes` was set. */
|
|
26
|
+
createDefaultIndexes(): Promise<void>;
|
|
27
|
+
/** Creates custom indexes routed to this domain's tables; no-op when none supplied. */
|
|
28
|
+
createCustomIndexes(): Promise<void>;
|
|
29
|
+
/** Removes every row from this domain's tables. Intended for tests. */
|
|
30
|
+
dangerouslyClearAll(): Promise<void>;
|
|
31
|
+
/** Decodes a raw Spanner thin-row into the public scorer-definition shape. */
|
|
32
|
+
private parseScorerRow;
|
|
33
|
+
/** Decodes a raw Spanner version row into the public version shape. */
|
|
34
|
+
private parseVersionRow;
|
|
35
|
+
/** Fetches the thin scorer-definition record by id, or `null` when absent. */
|
|
36
|
+
getById(id: string): Promise<StorageScorerDefinitionType | null>;
|
|
37
|
+
/** Atomically inserts a draft thin row + version 1 in a single Spanner transaction. */
|
|
38
|
+
create(input: {
|
|
39
|
+
scorerDefinition: StorageCreateScorerDefinitionInput;
|
|
40
|
+
}): Promise<StorageScorerDefinitionType>;
|
|
41
|
+
/** Updates thin-record fields (status, activeVersionId, authorId, metadata). */
|
|
42
|
+
update(input: StorageUpdateScorerDefinitionInput): Promise<StorageScorerDefinitionType>;
|
|
43
|
+
/** Removes a scorer definition and all its versions atomically in a single transaction. */
|
|
44
|
+
delete(id: string): Promise<void>;
|
|
45
|
+
/** Paginated listing with optional status / authorId / metadata filters. */
|
|
46
|
+
list(args?: StorageListScorerDefinitionsInput): Promise<StorageListScorerDefinitionsOutput>;
|
|
47
|
+
/** Inserts a new immutable version row for an existing scorer definition. */
|
|
48
|
+
createVersion(input: CreateScorerDefinitionVersionInput): Promise<ScorerDefinitionVersion>;
|
|
49
|
+
/** Fetches a version row by its id, or `null` when absent. */
|
|
50
|
+
getVersion(id: string): Promise<ScorerDefinitionVersion | null>;
|
|
51
|
+
/** Fetches a specific version by `(scorerDefinitionId, versionNumber)`. */
|
|
52
|
+
getVersionByNumber(scorerDefinitionId: string, versionNumber: number): Promise<ScorerDefinitionVersion | null>;
|
|
53
|
+
/** Returns the highest-numbered version for a scorer definition. */
|
|
54
|
+
getLatestVersion(scorerDefinitionId: string): Promise<ScorerDefinitionVersion | null>;
|
|
55
|
+
/** Paginated listing of versions for a single scorer definition. */
|
|
56
|
+
listVersions(input: ListScorerDefinitionVersionsInput): Promise<ListScorerDefinitionVersionsOutput>;
|
|
57
|
+
/** Deletes a single version row by id. */
|
|
58
|
+
deleteVersion(id: string): Promise<void>;
|
|
59
|
+
/** Deletes every version row belonging to the given scorer definition. */
|
|
60
|
+
deleteVersionsByParentId(entityId: string): Promise<void>;
|
|
61
|
+
/** Returns the total number of version rows for the given scorer definition. */
|
|
62
|
+
countVersions(scorerDefinitionId: string): Promise<number>;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/scorer-definitions/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,wBAAwB,EAKzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,kBAAkB,EAClB,2BAA2B,EAC3B,kCAAkC,EAClC,iCAAiC,EACjC,kCAAkC,EAClC,kCAAkC,EACnC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,kCAAkC,EAClC,iCAAiC,EACjC,kCAAkC,EAClC,uBAAuB,EACxB,MAAM,i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EAA6E;IACvE,aAAa,CAAC,KAAK,EAAE,kCAAkC,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAqChG,8DAA8D;IACxD,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC;IAuBrE,2EAA2E;IACrE,kBAAkB,CAAC,kBAAkB,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC;IA0BpH,oEAAoE;IAC9D,gBAAgB,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC;IA0B3F,oEAAoE;IAC9D,YAAY,CAAC,KAAK,EAAE,iCAAiC,GAAG,OAAO,CAAC,kCAAkC,CAAC;IA8DzG,0CAA0C;IACpC,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoB9C,0EAA0E;IACpE,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoB/D,gFAAgF;IAC1E,aAAa,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAqBjE"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ListScoresResponse, SaveScorePayload, ScoreRowData, ScoringSource } from '@mastra/core/evals';
|
|
2
|
+
import type { StoragePagination, CreateIndexOptions } from '@mastra/core/storage';
|
|
3
|
+
import { ScoresStorage } from '@mastra/core/storage';
|
|
4
|
+
import type { SpannerDomainConfig } from '../../db/index.js';
|
|
5
|
+
export declare class ScoresSpanner extends ScoresStorage {
|
|
6
|
+
private database;
|
|
7
|
+
private db;
|
|
8
|
+
private readonly skipDefaultIndexes?;
|
|
9
|
+
private readonly indexes?;
|
|
10
|
+
static readonly MANAGED_TABLES: readonly ["mastra_scorers"];
|
|
11
|
+
constructor(config: SpannerDomainConfig);
|
|
12
|
+
init(): Promise<void>;
|
|
13
|
+
getDefaultIndexDefinitions(): CreateIndexOptions[];
|
|
14
|
+
createDefaultIndexes(): Promise<void>;
|
|
15
|
+
createCustomIndexes(): Promise<void>;
|
|
16
|
+
dangerouslyClearAll(): Promise<void>;
|
|
17
|
+
getScoreById({ id }: {
|
|
18
|
+
id: string;
|
|
19
|
+
}): Promise<ScoreRowData | null>;
|
|
20
|
+
saveScore(score: SaveScorePayload): Promise<{
|
|
21
|
+
score: ScoreRowData;
|
|
22
|
+
}>;
|
|
23
|
+
private listScoresByConditions;
|
|
24
|
+
listScoresByScorerId({ scorerId, pagination, entityId, entityType, source, }: {
|
|
25
|
+
scorerId: string;
|
|
26
|
+
pagination: StoragePagination;
|
|
27
|
+
entityId?: string;
|
|
28
|
+
entityType?: string;
|
|
29
|
+
source?: ScoringSource;
|
|
30
|
+
}): Promise<ListScoresResponse>;
|
|
31
|
+
listScoresByRunId({ runId, pagination, }: {
|
|
32
|
+
runId: string;
|
|
33
|
+
pagination: StoragePagination;
|
|
34
|
+
}): Promise<ListScoresResponse>;
|
|
35
|
+
listScoresByEntityId({ entityId, entityType, pagination, }: {
|
|
36
|
+
pagination: StoragePagination;
|
|
37
|
+
entityId: string;
|
|
38
|
+
entityType: string;
|
|
39
|
+
}): Promise<ListScoresResponse>;
|
|
40
|
+
listScoresBySpan({ traceId, spanId, pagination, }: {
|
|
41
|
+
traceId: string;
|
|
42
|
+
spanId: string;
|
|
43
|
+
pagination: StoragePagination;
|
|
44
|
+
}): Promise<ListScoresResponse>;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/scores/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAE5G,OAAO,KAAK,EAAE,iBAAiB,EAAE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