@mastra/pg 1.2.0-alpha.0 → 1.3.0-alpha.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 +180 -0
- package/dist/docs/SKILL.md +28 -25
- package/dist/docs/{SOURCE_MAP.json → assets/SOURCE_MAP.json} +1 -1
- package/dist/docs/{memory/03-semantic-recall.md → references/docs-memory-semantic-recall.md} +33 -17
- package/dist/docs/{memory/01-storage.md → references/docs-memory-storage.md} +29 -39
- package/dist/docs/{memory/02-working-memory.md → references/docs-memory-working-memory.md} +16 -27
- package/dist/docs/{rag/01-overview.md → references/docs-rag-overview.md} +2 -4
- package/dist/docs/{rag/03-retrieval.md → references/docs-rag-retrieval.md} +26 -53
- package/dist/docs/{rag/02-vector-databases.md → references/docs-rag-vector-databases.md} +198 -202
- package/dist/docs/{memory/04-reference.md → references/reference-memory-memory-class.md} +28 -14
- package/dist/docs/references/reference-processors-message-history-processor.md +85 -0
- package/dist/docs/references/reference-processors-semantic-recall-processor.md +123 -0
- package/dist/docs/references/reference-processors-working-memory-processor.md +154 -0
- package/dist/docs/{rag/04-reference.md → references/reference-rag-metadata-filters.md} +26 -179
- package/dist/docs/references/reference-storage-composite.md +235 -0
- package/dist/docs/references/reference-storage-dynamodb.md +282 -0
- package/dist/docs/references/reference-storage-postgresql.md +529 -0
- package/dist/docs/{tools/01-reference.md → references/reference-tools-vector-query-tool.md} +137 -118
- package/dist/docs/{vectors/01-reference.md → references/reference-vectors-pg.md} +115 -14
- package/dist/index.cjs +1998 -217
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1998 -219
- package/dist/index.js.map +1 -1
- package/dist/storage/db/constraint-utils.d.ts +16 -0
- package/dist/storage/db/constraint-utils.d.ts.map +1 -0
- package/dist/storage/db/index.d.ts.map +1 -1
- package/dist/storage/domains/agents/index.d.ts +9 -12
- package/dist/storage/domains/agents/index.d.ts.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +7 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/prompt-blocks/index.d.ts +33 -0
- package/dist/storage/domains/prompt-blocks/index.d.ts.map +1 -0
- package/dist/storage/domains/scorer-definitions/index.d.ts +33 -0
- package/dist/storage/domains/scorer-definitions/index.d.ts.map +1 -0
- package/dist/storage/index.d.ts +3 -1
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +5 -6
- package/dist/docs/README.md +0 -36
- package/dist/docs/processors/01-reference.md +0 -296
- package/dist/docs/storage/01-reference.md +0 -905
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const POSTGRES_IDENTIFIER_MAX_LENGTH = 63;
|
|
2
|
+
export declare function truncateIdentifier(value: string, maxLength?: number): string;
|
|
3
|
+
/**
|
|
4
|
+
* Builds a constraint name with an optional schema prefix, truncated to fit
|
|
5
|
+
* within Postgres' identifier length limit. The result is always lowercased
|
|
6
|
+
* because PostgreSQL folds unquoted identifiers to lowercase when storing them
|
|
7
|
+
* in system catalogs (pg_constraint.conname, pg_indexes.indexname, etc.).
|
|
8
|
+
* Without this normalisation, runtime lookups that compare a mixed-case name
|
|
9
|
+
* against the catalog would silently fail.
|
|
10
|
+
*/
|
|
11
|
+
export declare function buildConstraintName({ baseName, schemaName, maxLength, }: {
|
|
12
|
+
baseName: string;
|
|
13
|
+
schemaName?: string;
|
|
14
|
+
maxLength?: number;
|
|
15
|
+
}): string;
|
|
16
|
+
//# sourceMappingURL=constraint-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constraint-utils.d.ts","sourceRoot":"","sources":["../../../src/storage/db/constraint-utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,8BAA8B,KAAK,CAAC;AAEjD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,SAAiC,GAAG,MAAM,CAapG;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,QAAQ,EACR,UAAU,EACV,SAA0C,GAC3C,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,MAAM,CAGT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/db/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAU/C,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,SAAS,EACT,iBAAiB,EAClB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/db/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAU/C,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,SAAS,EACT,iBAAiB,EAClB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAK1C,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,oBAAoB,GAAG,kBAAkB,GAAG,kBAAkB,CAAC;AAE5F;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,0BAA0B;IAC1B,MAAM,EAAE,QAAQ,CAAC;IACjB,kDAAkD;IAClD,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put, StorageListAgentsInput, StorageListAgentsOutput,
|
|
2
|
+
import type { StorageAgentType, StorageCreateAgentInput, StorageUpdateAgentInput, StorageListAgentsInput, StorageListAgentsOutput, CreateIndexOptions } from '@mastra/core/storage';
|
|
3
3
|
import type { AgentVersion, CreateVersionInput, ListVersionsInput, ListVersionsOutput } from '@mastra/core/storage/domains/agents';
|
|
4
4
|
import type { PgDomainConfig } from '../../db/index.js';
|
|
5
5
|
export declare class AgentsPG extends AgentsStorage {
|
|
@@ -25,26 +25,23 @@ export declare class AgentsPG extends AgentsStorage {
|
|
|
25
25
|
dangerouslyClearAll(): Promise<void>;
|
|
26
26
|
private parseJson;
|
|
27
27
|
private parseRow;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}): Promise<StorageAgentType | null>;
|
|
31
|
-
createAgent({ agent }: {
|
|
28
|
+
getById(id: string): Promise<StorageAgentType | null>;
|
|
29
|
+
create(input: {
|
|
32
30
|
agent: StorageCreateAgentInput;
|
|
33
31
|
}): Promise<StorageAgentType>;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}): Promise<void>;
|
|
38
|
-
listAgents(args?: StorageListAgentsInput): Promise<StorageListAgentsOutput>;
|
|
39
|
-
listAgentsResolved(args?: StorageListAgentsInput): Promise<StorageListAgentsResolvedOutput>;
|
|
32
|
+
update(input: StorageUpdateAgentInput): Promise<StorageAgentType>;
|
|
33
|
+
delete(id: string): Promise<void>;
|
|
34
|
+
list(args?: StorageListAgentsInput): Promise<StorageListAgentsOutput>;
|
|
40
35
|
createVersion(input: CreateVersionInput): Promise<AgentVersion>;
|
|
41
36
|
getVersion(id: string): Promise<AgentVersion | null>;
|
|
42
37
|
getVersionByNumber(agentId: string, versionNumber: number): Promise<AgentVersion | null>;
|
|
43
38
|
getLatestVersion(agentId: string): Promise<AgentVersion | null>;
|
|
44
39
|
listVersions(input: ListVersionsInput): Promise<ListVersionsOutput>;
|
|
45
40
|
deleteVersion(id: string): Promise<void>;
|
|
46
|
-
|
|
41
|
+
deleteVersionsByParentId(entityId: string): Promise<void>;
|
|
47
42
|
countVersions(agentId: string): Promise<number>;
|
|
43
|
+
private serializeInstructions;
|
|
44
|
+
private deserializeInstructions;
|
|
48
45
|
private parseVersionRow;
|
|
49
46
|
}
|
|
50
47
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/agents/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EAOd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,gBAAgB,EAChB,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACvB
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/agents/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EAOd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,gBAAgB,EAChB,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,EAEnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG/C,qBAAa,QAAS,SAAQ,aAAa;;IAMzC,oCAAoC;IACpC,MAAM,CAAC,QAAQ,CAAC,cAAc,sDAAiD;gBAEnE,MAAM,EAAE,cAAc;IAUlC;;;OAGG;IACH,0BAA0B,IAAI,kBAAkB,EAAE;IAIlD;;;OAGG;IACG,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAOrC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IA8M3B;;OAEG;IACG,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAepC,mBAAmB,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
|
1
1
|
import type { MastraMessageContentV2 } from '@mastra/core/agent';
|
|
2
2
|
import type { MastraDBMessage, StorageThreadType } from '@mastra/core/memory';
|
|
3
3
|
import { MemoryStorage } from '@mastra/core/storage';
|
|
4
|
-
import type { StorageResourceType, StorageListMessagesInput, StorageListMessagesByResourceIdInput, StorageListMessagesOutput, StorageListThreadsInput, StorageListThreadsOutput, CreateIndexOptions, StorageCloneThreadInput, StorageCloneThreadOutput, ObservationalMemoryRecord, CreateObservationalMemoryInput, UpdateActiveObservationsInput, CreateReflectionGenerationInput } from '@mastra/core/storage';
|
|
4
|
+
import type { StorageResourceType, StorageListMessagesInput, StorageListMessagesByResourceIdInput, StorageListMessagesOutput, StorageListThreadsInput, StorageListThreadsOutput, CreateIndexOptions, StorageCloneThreadInput, StorageCloneThreadOutput, ObservationalMemoryRecord, CreateObservationalMemoryInput, UpdateActiveObservationsInput, UpdateBufferedObservationsInput, SwapBufferedToActiveInput, SwapBufferedToActiveResult, UpdateBufferedReflectionInput, SwapBufferedReflectionToActiveInput, CreateReflectionGenerationInput } from '@mastra/core/storage';
|
|
5
5
|
import type { PgDomainConfig } from '../../db/index.js';
|
|
6
6
|
export declare class MemoryPG extends MemoryStorage {
|
|
7
7
|
#private;
|
|
@@ -97,7 +97,13 @@ export declare class MemoryPG extends MemoryStorage {
|
|
|
97
97
|
createReflectionGeneration(input: CreateReflectionGenerationInput): Promise<ObservationalMemoryRecord>;
|
|
98
98
|
setReflectingFlag(id: string, isReflecting: boolean): Promise<void>;
|
|
99
99
|
setObservingFlag(id: string, isObserving: boolean): Promise<void>;
|
|
100
|
+
setBufferingObservationFlag(id: string, isBuffering: boolean, lastBufferedAtTokens?: number): Promise<void>;
|
|
101
|
+
setBufferingReflectionFlag(id: string, isBuffering: boolean): Promise<void>;
|
|
100
102
|
clearObservationalMemory(threadId: string | null, resourceId: string): Promise<void>;
|
|
101
103
|
addPendingMessageTokens(id: string, tokenCount: number): Promise<void>;
|
|
104
|
+
updateBufferedObservations(input: UpdateBufferedObservationsInput): Promise<void>;
|
|
105
|
+
swapBufferedToActive(input: SwapBufferedToActiveInput): Promise<SwapBufferedToActiveResult>;
|
|
106
|
+
updateBufferedReflection(input: UpdateBufferedReflectionInput): Promise<void>;
|
|
107
|
+
swapBufferedReflectionToActive(input: SwapBufferedReflectionToActiveInput): Promise<ObservationalMemoryRecord>;
|
|
102
108
|
}
|
|
103
109
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/memory/index.ts"],"names":[],"mappings":"
|
|
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,EACL,aAAa,EAQd,MAAM,sBAAsB,CAAC;AAQ9B,OAAO,KAAK,EACV,mBAAmB,EACnB,wBAAwB,EACxB,oCAAoC,EACpC,yBAAyB,EACzB,uBAAuB,EACvB,wBAAwB,EACxB,kBAAkB,EAClB,uBAAuB,EACvB,wBAAwB,EAExB,yBAAyB,EAEzB,8BAA8B,EAC9B,6BAA6B,EAC7B,+BAA+B,EAC/B,yBAAyB,EACzB,0BAA0B,EAC1B,6BAA6B,EAC7B,mCAAmC,EACnC,+BAA+B,EAChC,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAiC/C,qBAAa,QAAS,SAAQ,aAAa;;IACzC,QAAQ,CAAC,2BAA2B,QAAQ;IAO5C,oCAAoC;IACpC,MAAM,CAAC,QAAQ,CAAC,cAAc,oGAAuE;gBAEzF,MAAM,EAAE,cAAc;IAU5B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;I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yB,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAkL3F,wBAAwB,CAAC,KAAK,EAAE,6BAA6B,GAAG,OAAO,CAAC,IAAI,CAAC;IA0D7E,8BAA8B,CAAC,KAAK,EAAE,mCAAmC,GAAG,OAAO,CAAC,yBAAyB,CAAC;CAqFrH"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { PromptBlocksStorage } from '@mastra/core/storage';
|
|
2
|
+
import type { StoragePromptBlockType, StorageCreatePromptBlockInput, StorageUpdatePromptBlockInput, StorageListPromptBlocksInput, StorageListPromptBlocksOutput, CreateIndexOptions } from '@mastra/core/storage';
|
|
3
|
+
import type { PromptBlockVersion, CreatePromptBlockVersionInput, ListPromptBlockVersionsInput, ListPromptBlockVersionsOutput } from '@mastra/core/storage/domains/prompt-blocks';
|
|
4
|
+
import type { PgDomainConfig } from '../../db/index.js';
|
|
5
|
+
export declare class PromptBlocksPG extends PromptBlocksStorage {
|
|
6
|
+
#private;
|
|
7
|
+
static readonly MANAGED_TABLES: readonly ["mastra_prompt_blocks", "mastra_prompt_block_versions"];
|
|
8
|
+
constructor(config: PgDomainConfig);
|
|
9
|
+
getDefaultIndexDefinitions(): CreateIndexOptions[];
|
|
10
|
+
createDefaultIndexes(): Promise<void>;
|
|
11
|
+
init(): Promise<void>;
|
|
12
|
+
createCustomIndexes(): Promise<void>;
|
|
13
|
+
dangerouslyClearAll(): Promise<void>;
|
|
14
|
+
getById(id: string): Promise<StoragePromptBlockType | null>;
|
|
15
|
+
create(input: {
|
|
16
|
+
promptBlock: StorageCreatePromptBlockInput;
|
|
17
|
+
}): Promise<StoragePromptBlockType>;
|
|
18
|
+
update(input: StorageUpdatePromptBlockInput): Promise<StoragePromptBlockType>;
|
|
19
|
+
delete(id: string): Promise<void>;
|
|
20
|
+
list(args?: StorageListPromptBlocksInput): Promise<StorageListPromptBlocksOutput>;
|
|
21
|
+
createVersion(input: CreatePromptBlockVersionInput): Promise<PromptBlockVersion>;
|
|
22
|
+
getVersion(id: string): Promise<PromptBlockVersion | null>;
|
|
23
|
+
getVersionByNumber(blockId: string, versionNumber: number): Promise<PromptBlockVersion | null>;
|
|
24
|
+
getLatestVersion(blockId: string): Promise<PromptBlockVersion | null>;
|
|
25
|
+
listVersions(input: ListPromptBlockVersionsInput): Promise<ListPromptBlockVersionsOutput>;
|
|
26
|
+
deleteVersion(id: string): Promise<void>;
|
|
27
|
+
deleteVersionsByParentId(entityId: string): Promise<void>;
|
|
28
|
+
countVersions(blockId: string): Promise<number>;
|
|
29
|
+
private parseJson;
|
|
30
|
+
private parseBlockRow;
|
|
31
|
+
private parseVersionRow;
|
|
32
|
+
}
|
|
33
|
+
//# 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":"AACA,OAAO,EACL,mBAAmB,EAOpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,sBAAsB,EACtB,6BAA6B,EAC7B,6BAA6B,EAC7B,4BAA4B,EAC5B,6BAA6B,EAC7B,kBAAkB,EACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,kBAAkB,EAClB,6BAA6B,EAC7B,4BAA4B,EAC5B,6BAA6B,EAC9B,MAAM,4CAA4C,CAAC;AAEpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAK/C,qBAAa,cAAe,SAAQ,mBAAmB;;IAMrD,MAAM,CAAC,QAAQ,CAAC,cAAc,oEAA+D;gBAEjF,MAAM,EAAE,cAAc;IASlC,0BAA0B,IAAI,kBAAkB,EAAE;IAW5C,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAarC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAUrB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAapC,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAA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Type, StorageCreateScorerDefinitionInput, StorageUpdateScorerDefinitionInput, StorageListScorerDefinitionsInput, StorageListScorerDefinitionsOutput, CreateIndexOptions } from '@mastra/core/storage';
|
|
3
|
+
import type { ScorerDefinitionVersion, CreateScorerDefinitionVersionInput, ListScorerDefinitionVersionsInput, ListScorerDefinitionVersionsOutput } from '@mastra/core/storage/domains/scorer-definitions';
|
|
4
|
+
import type { PgDomainConfig } from '../../db/index.js';
|
|
5
|
+
export declare class ScorerDefinitionsPG extends ScorerDefinitionsStorage {
|
|
6
|
+
#private;
|
|
7
|
+
static readonly MANAGED_TABLES: readonly ["mastra_scorer_definitions", "mastra_scorer_definition_versions"];
|
|
8
|
+
constructor(config: PgDomainConfig);
|
|
9
|
+
getDefaultIndexDefinitions(): CreateIndexOptions[];
|
|
10
|
+
createDefaultIndexes(): Promise<void>;
|
|
11
|
+
init(): Promise<void>;
|
|
12
|
+
createCustomIndexes(): Promise<void>;
|
|
13
|
+
dangerouslyClearAll(): Promise<void>;
|
|
14
|
+
getById(id: string): Promise<StorageScorerDefinitionType | null>;
|
|
15
|
+
create(input: {
|
|
16
|
+
scorerDefinition: StorageCreateScorerDefinitionInput;
|
|
17
|
+
}): Promise<StorageScorerDefinitionType>;
|
|
18
|
+
update(input: StorageUpdateScorerDefinitionInput): Promise<StorageScorerDefinitionType>;
|
|
19
|
+
delete(id: string): Promise<void>;
|
|
20
|
+
list(args?: StorageListScorerDefinitionsInput): Promise<StorageListScorerDefinitionsOutput>;
|
|
21
|
+
createVersion(input: CreateScorerDefinitionVersionInput): Promise<ScorerDefinitionVersion>;
|
|
22
|
+
getVersion(id: string): Promise<ScorerDefinitionVersion | null>;
|
|
23
|
+
getVersionByNumber(scorerDefinitionId: string, versionNumber: number): Promise<ScorerDefinitionVersion | null>;
|
|
24
|
+
getLatestVersion(scorerDefinitionId: string): Promise<ScorerDefinitionVersion | null>;
|
|
25
|
+
listVersions(input: ListScorerDefinitionVersionsInput): Promise<ListScorerDefinitionVersionsOutput>;
|
|
26
|
+
deleteVersion(id: string): Promise<void>;
|
|
27
|
+
deleteVersionsByParentId(entityId: string): Promise<void>;
|
|
28
|
+
countVersions(scorerDefinitionId: string): Promise<number>;
|
|
29
|
+
private parseJson;
|
|
30
|
+
private parseScorerRow;
|
|
31
|
+
private parseVersionRow;
|
|
32
|
+
}
|
|
33
|
+
//# 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":"AACA,OAAO,EACL,wBAAwB,EAOzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,2BAA2B,EAC3B,kCAAkC,EAClC,kCAAkC,EAClC,iCAAiC,EACjC,kCAAkC,EAClC,kBAAkB,EACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,uBAAuB,EACvB,kCAAkC,EAClC,iCAAiC,EACjC,kCAAkC,EACnC,MAAM,iDAAiD,CAAC;AAEzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAc/C,qBAAa,mBAAoB,SAAQ,wBAAwB;;IAM/D,MAAM,CAAC,QAAQ,CAAC,cAAc,8EAAyE;gBAE3F,MAAM,EAAE,cAAc;IAWlC,0BAA0B,IAAI,kBAAkB,EAAE;IAW5C,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAarC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAarB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAapC,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IASpC,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,2BAA2B,GAAG,IAAI,CAAC;IAwBhE,MAAM,CAAC,KAAK,EAAE;QAAE,gBAAgB,EAAE,kCAAkC,CAAA;KAAE,GAAG,OAAO,CAAC,2BAA2B,CAAC;IA2E7G,MAAM,CAAC,KAAK,EAAE,kCAAkC,GAAG,OAAO,CAAC,2BAA2B,CAAC;IA2IvF,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBjC,IAAI,CAAC,IAAI,CAAC,EAAE,iCAAiC,GAAG,OAAO,CAAC,kCAAkC,CAAC;IAwF3F,aAAa,CAAC,KAAK,EAAE,kCAAkC,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAqD1F,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC;IA2B/D,kBAAkB,CAAC,kBAAkB,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC;IA8B9G,gBAAgB,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC;IA8BrF,YAAY,CAAC,KAAK,EAAE,iCAAiC,GAAG,OAAO,CAAC,kCAAkC,CAAC;IAsEnG,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBxC,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBzD,aAAa,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA6BhE,OAAO,CAAC,SAAS;IA4BjB,OAAO,CAAC,cAAc;IAYtB,OAAO,CAAC,eAAe;CAkBxB"}
|
package/dist/storage/index.d.ts
CHANGED
|
@@ -6,10 +6,12 @@ import type { DbClient } from './client.js';
|
|
|
6
6
|
import { AgentsPG } from './domains/agents/index.js';
|
|
7
7
|
import { MemoryPG } from './domains/memory/index.js';
|
|
8
8
|
import { ObservabilityPG } from './domains/observability/index.js';
|
|
9
|
+
import { PromptBlocksPG } from './domains/prompt-blocks/index.js';
|
|
10
|
+
import { ScorerDefinitionsPG } from './domains/scorer-definitions/index.js';
|
|
9
11
|
import { ScoresPG } from './domains/scores/index.js';
|
|
10
12
|
import { WorkflowsPG } from './domains/workflows/index.js';
|
|
11
13
|
export { exportSchemas } from './db/index.js';
|
|
12
|
-
export { AgentsPG, MemoryPG, ObservabilityPG, ScoresPG, WorkflowsPG };
|
|
14
|
+
export { AgentsPG, MemoryPG, ObservabilityPG, PromptBlocksPG, ScorerDefinitionsPG, ScoresPG, WorkflowsPG };
|
|
13
15
|
export { PoolAdapter } from './client.js';
|
|
14
16
|
export type { DbClient, TxClient, QueryValues, Pool, PoolClient, QueryResult } from './client.js';
|
|
15
17
|
export type { PgDomainConfig, PgDomainClientConfig, PgDomainPoolConfig, PgDomainRestConfig } from './db/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAClF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAQ1B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAOlD,OAAO,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAErC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,eAAe,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"index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C,aAAa,CAAkB;IAEvC,MAAM,EAAE,cAAc,CAAC;gBAEX,MAAM,EAAE,mBAAmB;IA6CvC,OAAO,CAAC,UAAU;IA8BZ,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAyB3B;;;;;;;;OAQG;IACH,IAAW,EAAE,IAAI,QAAQ,CAExB;IAED;;OAEG;IACH,IAAW,IAAI,IAAI,IAAI,CAEtB;IAED;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAK7B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/pg",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0-alpha.0",
|
|
4
4
|
"description": "Postgres provider for Mastra - includes both vector and db storage capabilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"tsup": "^8.5.1",
|
|
34
34
|
"typescript": "^5.9.3",
|
|
35
35
|
"vitest": "4.0.16",
|
|
36
|
-
"@internal/lint": "0.0.
|
|
37
|
-
"@internal/storage-test-utils": "0.0.
|
|
38
|
-
"@
|
|
39
|
-
"@
|
|
36
|
+
"@internal/lint": "0.0.57",
|
|
37
|
+
"@internal/storage-test-utils": "0.0.53",
|
|
38
|
+
"@mastra/core": "1.3.0-alpha.1",
|
|
39
|
+
"@internal/types-builder": "0.0.32"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@mastra/core": ">=1.1.0-0 <2.0.0-0"
|
|
@@ -59,7 +59,6 @@
|
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
61
61
|
"build:lib": "tsup --silent --config tsup.config.ts",
|
|
62
|
-
"build:docs": "pnpx tsx ../../scripts/generate-package-docs.ts stores/pg",
|
|
63
62
|
"build:watch": "pnpm build:lib --watch",
|
|
64
63
|
"pretest": "docker compose up -d && (for i in $(seq 1 30); do docker compose exec -T db pg_isready -U postgres && break || (sleep 1; [ $i -eq 30 ] && exit 1); done)",
|
|
65
64
|
"test": "vitest run",
|
package/dist/docs/README.md
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# @mastra/pg Documentation
|
|
2
|
-
|
|
3
|
-
> Embedded documentation for coding agents
|
|
4
|
-
|
|
5
|
-
## Quick Start
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
# Read the skill overview
|
|
9
|
-
cat docs/SKILL.md
|
|
10
|
-
|
|
11
|
-
# Get the source map
|
|
12
|
-
cat docs/SOURCE_MAP.json
|
|
13
|
-
|
|
14
|
-
# Read topic documentation
|
|
15
|
-
cat docs/<topic>/01-overview.md
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## Structure
|
|
19
|
-
|
|
20
|
-
```
|
|
21
|
-
docs/
|
|
22
|
-
├── SKILL.md # Entry point
|
|
23
|
-
├── README.md # This file
|
|
24
|
-
├── SOURCE_MAP.json # Export index
|
|
25
|
-
├── memory/ (4 files)
|
|
26
|
-
├── processors/ (3 files)
|
|
27
|
-
├── rag/ (4 files)
|
|
28
|
-
├── storage/ (3 files)
|
|
29
|
-
├── tools/ (1 files)
|
|
30
|
-
├── vectors/ (1 files)
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
## Version
|
|
34
|
-
|
|
35
|
-
Package: @mastra/pg
|
|
36
|
-
Version: 1.2.0-alpha.0
|
|
@@ -1,296 +0,0 @@
|
|
|
1
|
-
# Processors API Reference
|
|
2
|
-
|
|
3
|
-
> API reference for processors - 3 entries
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
## Reference: Message History Processor
|
|
9
|
-
|
|
10
|
-
> Documentation for the MessageHistory processor in Mastra, which handles retrieval and persistence of conversation history.
|
|
11
|
-
|
|
12
|
-
The `MessageHistory` is a **hybrid processor** that handles both retrieval and persistence of message history. On input, it fetches historical messages from storage and prepends them to the conversation. On output, it persists new messages to storage.
|
|
13
|
-
|
|
14
|
-
## Usage example
|
|
15
|
-
|
|
16
|
-
```typescript
|
|
17
|
-
import { MessageHistory } from "@mastra/core/processors";
|
|
18
|
-
|
|
19
|
-
const processor = new MessageHistory({
|
|
20
|
-
storage: memoryStorage,
|
|
21
|
-
lastMessages: 50,
|
|
22
|
-
});
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## Constructor parameters
|
|
26
|
-
|
|
27
|
-
### Options
|
|
28
|
-
|
|
29
|
-
## Returns
|
|
30
|
-
|
|
31
|
-
## Extended usage example
|
|
32
|
-
|
|
33
|
-
```typescript title="src/mastra/agents/memory-agent.ts"
|
|
34
|
-
import { Agent } from "@mastra/core/agent";
|
|
35
|
-
import { MessageHistory } from "@mastra/core/processors";
|
|
36
|
-
import { PostgresStorage } from "@mastra/pg";
|
|
37
|
-
|
|
38
|
-
const storage = new PostgresStorage({
|
|
39
|
-
connectionString: process.env.DATABASE_URL,
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
export const agent = new Agent({
|
|
43
|
-
name: "memory-agent",
|
|
44
|
-
instructions: "You are a helpful assistant with conversation memory",
|
|
45
|
-
model: "openai:gpt-4o",
|
|
46
|
-
inputProcessors: [
|
|
47
|
-
new MessageHistory({
|
|
48
|
-
storage,
|
|
49
|
-
lastMessages: 100,
|
|
50
|
-
}),
|
|
51
|
-
],
|
|
52
|
-
outputProcessors: [
|
|
53
|
-
new MessageHistory({
|
|
54
|
-
storage,
|
|
55
|
-
}),
|
|
56
|
-
],
|
|
57
|
-
});
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
## Behavior
|
|
61
|
-
|
|
62
|
-
### Input processing
|
|
63
|
-
1. Retrieves `threadId` from the request context
|
|
64
|
-
2. Fetches historical messages from storage (ordered by creation date, descending)
|
|
65
|
-
3. Filters out system messages (they should not be stored in the database)
|
|
66
|
-
4. Merges historical messages with incoming messages, avoiding duplicates by ID
|
|
67
|
-
5. Adds historical messages with `source: 'memory'` tag
|
|
68
|
-
|
|
69
|
-
### Output processing
|
|
70
|
-
1. Retrieves `threadId` from the request context
|
|
71
|
-
2. Skips persistence if `readOnly` is set in memory config
|
|
72
|
-
3. Filters out incomplete tool calls from messages
|
|
73
|
-
4. Persists new user input and assistant response messages to storage
|
|
74
|
-
5. Updates the thread's `updatedAt` timestamp
|
|
75
|
-
|
|
76
|
-
## Related
|
|
77
|
-
|
|
78
|
-
- [Guardrails](https://mastra.ai/docs/agents/guardrails)
|
|
79
|
-
|
|
80
|
-
---
|
|
81
|
-
|
|
82
|
-
## Reference: Semantic Recall Processor
|
|
83
|
-
|
|
84
|
-
> Documentation for the SemanticRecall processor in Mastra, which enables semantic search over conversation history using vector embeddings.
|
|
85
|
-
|
|
86
|
-
The `SemanticRecall` is a **hybrid processor** that enables semantic search over conversation history using vector embeddings. On input, it performs semantic search to find relevant historical messages. On output, it creates embeddings for new messages to enable future semantic retrieval.
|
|
87
|
-
|
|
88
|
-
## Usage example
|
|
89
|
-
|
|
90
|
-
```typescript
|
|
91
|
-
import { SemanticRecall } from "@mastra/core/processors";
|
|
92
|
-
import { openai } from "@ai-sdk/openai";
|
|
93
|
-
|
|
94
|
-
const processor = new SemanticRecall({
|
|
95
|
-
storage: memoryStorage,
|
|
96
|
-
vector: vectorStore,
|
|
97
|
-
embedder: openai.embedding("text-embedding-3-small"),
|
|
98
|
-
topK: 5,
|
|
99
|
-
messageRange: 2,
|
|
100
|
-
scope: "resource",
|
|
101
|
-
});
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
## Constructor parameters
|
|
105
|
-
|
|
106
|
-
### Options
|
|
107
|
-
|
|
108
|
-
## Returns
|
|
109
|
-
|
|
110
|
-
## Extended usage example
|
|
111
|
-
|
|
112
|
-
```typescript title="src/mastra/agents/semantic-memory-agent.ts"
|
|
113
|
-
import { Agent } from "@mastra/core/agent";
|
|
114
|
-
import { SemanticRecall, MessageHistory } from "@mastra/core/processors";
|
|
115
|
-
import { PostgresStorage } from "@mastra/pg";
|
|
116
|
-
import { PgVector } from "@mastra/pg";
|
|
117
|
-
import { openai } from "@ai-sdk/openai";
|
|
118
|
-
|
|
119
|
-
const storage = new PostgresStorage({
|
|
120
|
-
id: 'pg-storage',
|
|
121
|
-
connectionString: process.env.DATABASE_URL,
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
const vector = new PgVector({
|
|
125
|
-
id: 'pg-vector',
|
|
126
|
-
connectionString: process.env.DATABASE_URL,
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
const semanticRecall = new SemanticRecall({
|
|
130
|
-
storage,
|
|
131
|
-
vector,
|
|
132
|
-
embedder: openai.embedding("text-embedding-3-small"),
|
|
133
|
-
topK: 5,
|
|
134
|
-
messageRange: { before: 2, after: 1 },
|
|
135
|
-
scope: "resource",
|
|
136
|
-
threshold: 0.7,
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
export const agent = new Agent({
|
|
140
|
-
name: "semantic-memory-agent",
|
|
141
|
-
instructions: "You are a helpful assistant with semantic memory recall",
|
|
142
|
-
model: "openai:gpt-4o",
|
|
143
|
-
inputProcessors: [
|
|
144
|
-
semanticRecall,
|
|
145
|
-
new MessageHistory({ storage, lastMessages: 50 }),
|
|
146
|
-
],
|
|
147
|
-
outputProcessors: [
|
|
148
|
-
semanticRecall,
|
|
149
|
-
new MessageHistory({ storage }),
|
|
150
|
-
],
|
|
151
|
-
});
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
## Behavior
|
|
155
|
-
|
|
156
|
-
### Input processing
|
|
157
|
-
1. Extracts the user query from the last user message
|
|
158
|
-
2. Generates embeddings for the query
|
|
159
|
-
3. Performs vector search to find semantically similar messages
|
|
160
|
-
4. Retrieves matched messages along with surrounding context (based on `messageRange`)
|
|
161
|
-
5. For `scope: 'resource'`, formats cross-thread messages as a system message with timestamps
|
|
162
|
-
6. Adds recalled messages with `source: 'memory'` tag
|
|
163
|
-
|
|
164
|
-
### Output processing
|
|
165
|
-
1. Extracts text content from new user and assistant messages
|
|
166
|
-
2. Generates embeddings for each message
|
|
167
|
-
3. Stores embeddings in the vector store with metadata (message ID, thread ID, resource ID, role, content, timestamp)
|
|
168
|
-
4. Uses LRU caching for embeddings to avoid redundant API calls
|
|
169
|
-
|
|
170
|
-
### Cross-thread recall
|
|
171
|
-
When `scope` is set to `'resource'`, the processor can recall messages from other threads. These cross-thread messages are formatted as a system message with timestamps and conversation labels to provide context about when and where the conversation occurred.
|
|
172
|
-
|
|
173
|
-
## Related
|
|
174
|
-
|
|
175
|
-
- [Guardrails](https://mastra.ai/docs/agents/guardrails)
|
|
176
|
-
|
|
177
|
-
---
|
|
178
|
-
|
|
179
|
-
## Reference: Working Memory Processor
|
|
180
|
-
|
|
181
|
-
> Documentation for the WorkingMemory processor in Mastra, which injects persistent user/context data as system instructions.
|
|
182
|
-
|
|
183
|
-
The `WorkingMemory` is an **input processor** that injects working memory data as a system message. It retrieves persistent information from storage and formats it as instructions for the LLM, enabling the agent to maintain context about users across conversations.
|
|
184
|
-
|
|
185
|
-
## Usage example
|
|
186
|
-
|
|
187
|
-
```typescript
|
|
188
|
-
import { WorkingMemory } from "@mastra/core/processors";
|
|
189
|
-
|
|
190
|
-
const processor = new WorkingMemory({
|
|
191
|
-
storage: memoryStorage,
|
|
192
|
-
scope: "resource",
|
|
193
|
-
template: {
|
|
194
|
-
format: "markdown",
|
|
195
|
-
content: `# User Profile
|
|
196
|
-
- **Name**:
|
|
197
|
-
- **Preferences**:
|
|
198
|
-
- **Goals**:
|
|
199
|
-
`,
|
|
200
|
-
},
|
|
201
|
-
});
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
## Constructor parameters
|
|
205
|
-
|
|
206
|
-
### Options
|
|
207
|
-
|
|
208
|
-
### WorkingMemoryTemplate
|
|
209
|
-
|
|
210
|
-
## Returns
|
|
211
|
-
|
|
212
|
-
## Extended usage example
|
|
213
|
-
|
|
214
|
-
```typescript title="src/mastra/agents/personalized-agent.ts"
|
|
215
|
-
import { Agent } from "@mastra/core/agent";
|
|
216
|
-
import { WorkingMemory, MessageHistory } from "@mastra/core/processors";
|
|
217
|
-
import { PostgresStorage } from "@mastra/pg";
|
|
218
|
-
|
|
219
|
-
const storage = new PostgresStorage({
|
|
220
|
-
connectionString: process.env.DATABASE_URL,
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
export const agent = new Agent({
|
|
224
|
-
name: "personalized-agent",
|
|
225
|
-
instructions: "You are a helpful assistant that remembers user preferences",
|
|
226
|
-
model: "openai:gpt-4o",
|
|
227
|
-
inputProcessors: [
|
|
228
|
-
new WorkingMemory({
|
|
229
|
-
storage,
|
|
230
|
-
scope: "resource",
|
|
231
|
-
template: {
|
|
232
|
-
format: "markdown",
|
|
233
|
-
content: `# User Information
|
|
234
|
-
- **Name**:
|
|
235
|
-
- **Location**:
|
|
236
|
-
- **Preferences**:
|
|
237
|
-
- **Communication Style**:
|
|
238
|
-
- **Current Projects**:
|
|
239
|
-
`,
|
|
240
|
-
},
|
|
241
|
-
}),
|
|
242
|
-
new MessageHistory({ storage, lastMessages: 50 }),
|
|
243
|
-
],
|
|
244
|
-
outputProcessors: [
|
|
245
|
-
new MessageHistory({ storage }),
|
|
246
|
-
],
|
|
247
|
-
});
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
## JSON format example
|
|
251
|
-
|
|
252
|
-
```typescript
|
|
253
|
-
import { WorkingMemory } from "@mastra/core/processors";
|
|
254
|
-
|
|
255
|
-
const processor = new WorkingMemory({
|
|
256
|
-
storage: memoryStorage,
|
|
257
|
-
scope: "resource",
|
|
258
|
-
template: {
|
|
259
|
-
format: "json",
|
|
260
|
-
content: JSON.stringify({
|
|
261
|
-
user: {
|
|
262
|
-
name: { type: "string" },
|
|
263
|
-
preferences: { type: "object" },
|
|
264
|
-
goals: { type: "array" },
|
|
265
|
-
},
|
|
266
|
-
}),
|
|
267
|
-
},
|
|
268
|
-
});
|
|
269
|
-
```
|
|
270
|
-
|
|
271
|
-
## Behavior
|
|
272
|
-
|
|
273
|
-
### Input processing
|
|
274
|
-
1. Retrieves `threadId` and `resourceId` from the request context
|
|
275
|
-
2. Based on scope, fetches working memory from either:
|
|
276
|
-
- Thread metadata (`scope: 'thread'`)
|
|
277
|
-
- Resource record (`scope: 'resource'`)
|
|
278
|
-
3. Resolves the template (from provider, options, or default)
|
|
279
|
-
4. Generates system instructions based on mode:
|
|
280
|
-
- **Normal mode**: Includes guidelines for storing/updating information, template structure, and current data
|
|
281
|
-
- **Read-only mode** (`readOnly: true`): Includes only the current data as context without update instructions
|
|
282
|
-
5. Adds the instruction as a system message with `source: 'memory'` tag
|
|
283
|
-
|
|
284
|
-
### Working memory updates
|
|
285
|
-
Working memory updates happen through the `updateWorkingMemory` tool provided by the Memory class, not through this processor. The processor only handles injecting the current working memory state into conversations.
|
|
286
|
-
|
|
287
|
-
### Default template
|
|
288
|
-
If no template is provided, the processor uses a default markdown template with fields for:
|
|
289
|
-
- First Name, Last Name
|
|
290
|
-
- Location, Occupation
|
|
291
|
-
- Interests, Goals
|
|
292
|
-
- Events, Facts, Projects
|
|
293
|
-
|
|
294
|
-
## Related
|
|
295
|
-
|
|
296
|
-
- [Guardrails](https://mastra.ai/docs/agents/guardrails)
|