Skip to content

Commit 2fc69fe

Browse files
committed
fix: restrict episodic param and formatting
1 parent 47cc3f5 commit 2fc69fe

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/schema/schemas/primitives/memory.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,29 @@ export const MemoryStrategySchema = z
8686
/** @deprecated Use `reflectionNamespaceTemplates` instead. */
8787
reflectionNamespaces: z.array(z.string()).optional(),
8888
})
89-
.refine(strategy => !(strategy.namespaces !== undefined && strategy.namespaceTemplates !== undefined), {
89+
.refine(strategy => !((strategy.namespaces?.length ?? 0) > 0 && (strategy.namespaceTemplates?.length ?? 0) > 0), {
9090
message:
9191
"'namespaces' and 'namespaceTemplates' are mutually exclusive. Prefer 'namespaceTemplates' ('namespaces' is deprecated).",
9292
path: ['namespaceTemplates'],
9393
})
9494
.refine(
95-
strategy => !(strategy.reflectionNamespaces !== undefined && strategy.reflectionNamespaceTemplates !== undefined),
95+
strategy =>
96+
!((strategy.reflectionNamespaces?.length ?? 0) > 0 && (strategy.reflectionNamespaceTemplates?.length ?? 0) > 0),
9697
{
9798
message:
9899
"'reflectionNamespaces' and 'reflectionNamespaceTemplates' are mutually exclusive. Prefer 'reflectionNamespaceTemplates' ('reflectionNamespaces' is deprecated).",
99100
path: ['reflectionNamespaceTemplates'],
100101
}
101102
)
103+
.refine(
104+
strategy =>
105+
strategy.type === 'EPISODIC' ||
106+
(strategy.reflectionNamespaceTemplates === undefined && strategy.reflectionNamespaces === undefined),
107+
{
108+
message: "'reflectionNamespaceTemplates' is only allowed on EPISODIC strategies",
109+
path: ['reflectionNamespaceTemplates'],
110+
}
111+
)
102112
.refine(
103113
strategy => {
104114
if (strategy.type !== 'EPISODIC') return true;

0 commit comments

Comments
 (0)