@framers/agentos 0.5.2 → 0.5.3
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/dist/memory/retrieval/typed-network/TypedNetworkObserver.d.ts +17 -0
- package/dist/memory/retrieval/typed-network/TypedNetworkObserver.d.ts.map +1 -1
- package/dist/memory/retrieval/typed-network/TypedNetworkObserver.js +45 -6
- package/dist/memory/retrieval/typed-network/TypedNetworkObserver.js.map +1 -1
- package/dist/memory/retrieval/typed-network/prompts/extraction-schema.d.ts +4 -3
- package/dist/memory/retrieval/typed-network/prompts/extraction-schema.d.ts.map +1 -1
- package/dist/memory/retrieval/typed-network/prompts/extraction-schema.js +4 -3
- package/dist/memory/retrieval/typed-network/prompts/extraction-schema.js.map +1 -1
- package/dist/memory-router/MemoryRouter.d.ts +85 -1
- package/dist/memory-router/MemoryRouter.d.ts.map +1 -1
- package/dist/memory-router/MemoryRouter.js +88 -1
- package/dist/memory-router/MemoryRouter.js.map +1 -1
- package/dist/memory-router/dispatcher.d.ts +39 -1
- package/dist/memory-router/dispatcher.d.ts.map +1 -1
- package/dist/memory-router/dispatcher.js +9 -1
- package/dist/memory-router/dispatcher.js.map +1 -1
- package/dist/memory-router/index.d.ts +7 -5
- package/dist/memory-router/index.d.ts.map +1 -1
- package/dist/memory-router/index.js +7 -2
- package/dist/memory-router/index.js.map +1 -1
- package/dist/memory-router/retrieval-config.d.ts +147 -0
- package/dist/memory-router/retrieval-config.d.ts.map +1 -0
- package/dist/memory-router/retrieval-config.js +268 -0
- package/dist/memory-router/retrieval-config.js.map +1 -0
- package/dist/memory-router/routing-tables.d.ts +112 -0
- package/dist/memory-router/routing-tables.d.ts.map +1 -1
- package/dist/memory-router/routing-tables.js +113 -0
- package/dist/memory-router/routing-tables.js.map +1 -1
- package/package.json +1 -1
|
@@ -62,6 +62,14 @@ export interface TypedNetworkObserverOptions {
|
|
|
62
62
|
maxTokens?: number;
|
|
63
63
|
/** Temperature. Default 0 for deterministic extraction. */
|
|
64
64
|
temperature?: number;
|
|
65
|
+
/**
|
|
66
|
+
* Per-attempt request timeout in milliseconds. When the underlying
|
|
67
|
+
* `llm.invoke()` does not resolve within this window the attempt is
|
|
68
|
+
* abandoned and the observer falls through to the retry path. Used
|
|
69
|
+
* to prevent stale TCP sockets / hung OpenAI requests from
|
|
70
|
+
* deadlocking long-running ingest pipelines. Default 30 000 ms (30 s).
|
|
71
|
+
*/
|
|
72
|
+
timeoutMs?: number;
|
|
65
73
|
}
|
|
66
74
|
/**
|
|
67
75
|
* The 6-step extractor. Stateless aside from its constructor options;
|
|
@@ -71,6 +79,7 @@ export declare class TypedNetworkObserver {
|
|
|
71
79
|
private readonly llm;
|
|
72
80
|
private readonly maxTokens;
|
|
73
81
|
private readonly temperature;
|
|
82
|
+
private readonly timeoutMs;
|
|
74
83
|
constructor(options: TypedNetworkObserverOptions);
|
|
75
84
|
/**
|
|
76
85
|
* Extract typed facts from a conversation block.
|
|
@@ -92,5 +101,13 @@ export declare class TypedNetworkObserver {
|
|
|
92
101
|
* @returns Array of {@link TypedFact}s, possibly empty.
|
|
93
102
|
*/
|
|
94
103
|
extract(sessionText: string, sessionId: string): Promise<TypedFact[]>;
|
|
104
|
+
/**
|
|
105
|
+
* Run `this.llm.invoke()` with a per-attempt timeout. Throws an
|
|
106
|
+
* `Error('TypedNetworkObserver: extraction timed out after Nms')`
|
|
107
|
+
* when the timer fires before the LLM responds. The timer is cleared
|
|
108
|
+
* on resolution to avoid leaking pending timeouts into subsequent
|
|
109
|
+
* extractions.
|
|
110
|
+
*/
|
|
111
|
+
private invokeWithTimeout;
|
|
95
112
|
}
|
|
96
113
|
//# sourceMappingURL=TypedNetworkObserver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypedNetworkObserver.d.ts","sourceRoot":"","sources":["../../../../src/memory/retrieval/typed-network/TypedNetworkObserver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAOH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,IAAI,EAAE;QACX,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;KACrB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,2DAA2D;IAC3D,GAAG,EAAE,mBAAmB,CAAC;IACzB,4GAA4G;IAC5G,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,WAAW,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"TypedNetworkObserver.d.ts","sourceRoot":"","sources":["../../../../src/memory/retrieval/typed-network/TypedNetworkObserver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAOH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,IAAI,EAAE;QACX,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;KACrB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,2DAA2D;IAC3D,GAAG,EAAE,mBAAmB,CAAC;IACzB,4GAA4G;IAC5G,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AASD;;;GAGG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAsB;IAC1C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;gBAEvB,OAAO,EAAE,2BAA2B;IAOhD;;;;;;;;;;;;;;;;;;OAkBG;IACG,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAuE3E;;;;;;OAMG;YACW,iBAAiB;CAuBhC"}
|
|
@@ -53,6 +53,7 @@ export class TypedNetworkObserver {
|
|
|
53
53
|
this.llm = options.llm;
|
|
54
54
|
this.maxTokens = options.maxTokens ?? 4096;
|
|
55
55
|
this.temperature = options.temperature ?? 0;
|
|
56
|
+
this.timeoutMs = options.timeoutMs ?? 30000;
|
|
56
57
|
}
|
|
57
58
|
/**
|
|
58
59
|
* Extract typed facts from a conversation block.
|
|
@@ -82,12 +83,22 @@ export class TypedNetworkObserver {
|
|
|
82
83
|
const userPrompt = lastValidationError === null
|
|
83
84
|
? baseUserPrompt
|
|
84
85
|
: `${baseUserPrompt}\n\nThe previous response failed validation: ${lastValidationError}\nReturn JSON matching the schema strictly. Do not add commentary.`;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
86
|
+
// Race the underlying invoke against a per-attempt timeout. A
|
|
87
|
+
// hung TCP socket / unresponsive provider would otherwise
|
|
88
|
+
// deadlock long-running ingest pipelines — at concurrency=1 a
|
|
89
|
+
// single hung request stalls every subsequent session forever.
|
|
90
|
+
// The timeout fires from the agentos side without requiring the
|
|
91
|
+
// adapter to surface AbortSignal support; the underlying request
|
|
92
|
+
// is abandoned (its socket leaks until GC / process exit) but
|
|
93
|
+
// the observer moves to its retry path.
|
|
94
|
+
let raw;
|
|
95
|
+
try {
|
|
96
|
+
raw = await this.invokeWithTimeout(userPrompt);
|
|
97
|
+
}
|
|
98
|
+
catch (err) {
|
|
99
|
+
lastValidationError = err instanceof Error ? err.message : String(err);
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
91
102
|
const stripped = stripCodeFence(raw);
|
|
92
103
|
// Parse JSON. SyntaxError captures bad-JSON outer failures into
|
|
93
104
|
// the retry path.
|
|
@@ -121,6 +132,34 @@ export class TypedNetworkObserver {
|
|
|
121
132
|
// semantics.
|
|
122
133
|
return [];
|
|
123
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Run `this.llm.invoke()` with a per-attempt timeout. Throws an
|
|
137
|
+
* `Error('TypedNetworkObserver: extraction timed out after Nms')`
|
|
138
|
+
* when the timer fires before the LLM responds. The timer is cleared
|
|
139
|
+
* on resolution to avoid leaking pending timeouts into subsequent
|
|
140
|
+
* extractions.
|
|
141
|
+
*/
|
|
142
|
+
async invokeWithTimeout(userPrompt) {
|
|
143
|
+
let timeoutHandle = null;
|
|
144
|
+
const invokePromise = this.llm.invoke({
|
|
145
|
+
system: TYPED_EXTRACTION_SYSTEM_PROMPT,
|
|
146
|
+
user: userPrompt,
|
|
147
|
+
maxTokens: this.maxTokens,
|
|
148
|
+
temperature: this.temperature,
|
|
149
|
+
});
|
|
150
|
+
const timeoutPromise = new Promise((_resolve, reject) => {
|
|
151
|
+
timeoutHandle = setTimeout(() => {
|
|
152
|
+
reject(new Error(`TypedNetworkObserver: extraction timed out after ${this.timeoutMs}ms`));
|
|
153
|
+
}, this.timeoutMs);
|
|
154
|
+
});
|
|
155
|
+
try {
|
|
156
|
+
return await Promise.race([invokePromise, timeoutPromise]);
|
|
157
|
+
}
|
|
158
|
+
finally {
|
|
159
|
+
if (timeoutHandle !== null)
|
|
160
|
+
clearTimeout(timeoutHandle);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
124
163
|
}
|
|
125
164
|
/**
|
|
126
165
|
* Run per-fact tolerance over a candidate array. Returns only the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypedNetworkObserver.js","sourceRoot":"","sources":["../../../../src/memory/retrieval/typed-network/TypedNetworkObserver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EACL,8BAA8B,EAC9B,yBAAyB,GAC1B,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"TypedNetworkObserver.js","sourceRoot":"","sources":["../../../../src/memory/retrieval/typed-network/TypedNetworkObserver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EACL,8BAA8B,EAC9B,yBAAyB,GAC1B,MAAM,gCAAgC,CAAC;AAuCxC;;;;GAIG;AACH,MAAM,YAAY,GAAG,CAAC,CAAC;AAEvB;;;GAGG;AACH,MAAM,OAAO,oBAAoB;IAM/B,YAAY,OAAoC;QAC9C,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC;QAC3C,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,CAAC,CAAC;QAC5C,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,KAAM,CAAC;IAC/C,CAAC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,KAAK,CAAC,OAAO,CAAC,WAAmB,EAAE,SAAiB;QAClD,MAAM,cAAc,GAAG,yBAAyB,CAAC,WAAW,CAAC,CAAC;QAC9D,IAAI,mBAAmB,GAAkB,IAAI,CAAC;QAE9C,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,GAAG,YAAY,EAAE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B,EACrB,SAAiB;IAEjB,MAAM,KAAK,GAAgB,EAAE,CAAC;IAC9B,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,MAAM,MAAM,GAAG,yBAAyB,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC9D,IAAI,CAAC,MAAM,CAAC,OAAO;YAAE,SAAS;QAC9B,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC;QACtB,KAAK,CAAC,IAAI,CAAC;YACT,EAAE,EAAE,GAAG,SAAS,SAAS,KAAK,CAAC,MAAM,EAAE;YACvC,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE,CAAC,CAAC,QAAQ;YACpB,YAAY,EAAE,CAAC,CAAC,YAAY;YAC5B,gBAAgB,EAAE,CAAC,CAAC,iBAAiB;YACrC,QAAQ,EAAE,CAAC,CAAC,QAAQ;YACpB,UAAU,EAAE,CAAC,CAAC,UAAU;SACzB,CAAC,CAAC;IACL,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACH,SAAS,cAAc,CAAC,CAAS;IAC/B,MAAM,OAAO,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IACzB,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC;IAC/C,sFAAsF;IACtF,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,wBAAwB,EAAE,EAAE,CAAC,CAAC;IAClE,OAAO,WAAW,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -25,9 +25,10 @@
|
|
|
25
25
|
* The model frequently emits the fact without these keys when no
|
|
26
26
|
* participants/entities/markers apply.
|
|
27
27
|
*
|
|
28
|
-
* Per-fact failures (text below minimum length, bank not in
|
|
29
|
-
* after uppercase coercion,
|
|
30
|
-
* INDIVIDUAL fact to drop.
|
|
28
|
+
* Per-fact failures (text below minimum length, bank not in
|
|
29
|
+
* WORLD/EXPERIENCE/OPINION/OBSERVATION after uppercase coercion,
|
|
30
|
+
* confidence outside [0, 1]) still cause the INDIVIDUAL fact to drop.
|
|
31
|
+
* The {@link TypedNetworkObserver} validates
|
|
31
32
|
* facts one by one (`safeParse` per fact) and keeps the valid ones.
|
|
32
33
|
*
|
|
33
34
|
* @module @framers/agentos/memory/retrieval/typed-network/prompts/extraction-schema
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extraction-schema.d.ts","sourceRoot":"","sources":["../../../../../src/memory/retrieval/typed-network/prompts/extraction-schema.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"extraction-schema.d.ts","sourceRoot":"","sources":["../../../../../src/memory/retrieval/typed-network/prompts/extraction-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;iBAwBpC,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;iBAEhC,CAAC;AAEH,mEAAmE;AACnE,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAC1E,qEAAqE;AACrE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC"}
|
|
@@ -25,9 +25,10 @@
|
|
|
25
25
|
* The model frequently emits the fact without these keys when no
|
|
26
26
|
* participants/entities/markers apply.
|
|
27
27
|
*
|
|
28
|
-
* Per-fact failures (text below minimum length, bank not in
|
|
29
|
-
* after uppercase coercion,
|
|
30
|
-
* INDIVIDUAL fact to drop.
|
|
28
|
+
* Per-fact failures (text below minimum length, bank not in
|
|
29
|
+
* WORLD/EXPERIENCE/OPINION/OBSERVATION after uppercase coercion,
|
|
30
|
+
* confidence outside [0, 1]) still cause the INDIVIDUAL fact to drop.
|
|
31
|
+
* The {@link TypedNetworkObserver} validates
|
|
31
32
|
* facts one by one (`safeParse` per fact) and keeps the valid ones.
|
|
32
33
|
*
|
|
33
34
|
* @module @framers/agentos/memory/retrieval/typed-network/prompts/extraction-schema
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extraction-schema.js","sourceRoot":"","sources":["../../../../../src/memory/retrieval/typed-network/prompts/extraction-schema.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"extraction-schema.js","sourceRoot":"","sources":["../../../../../src/memory/retrieval/typed-network/prompts/extraction-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChD,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,IAAI,EAAE,CAAC,CAAC,UAAU,CAChB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EACpD,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC,CAC1D;IACD,QAAQ,EAAE,CAAC;SACR,MAAM,CAAC;QACN,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAC5B,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAC1B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;KAC3C,CAAC;SACD,OAAO,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAC3B,YAAY,EAAE,CAAC;SACZ,KAAK,CACJ,CAAC,CAAC,MAAM,CAAC;QACP,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;QAChB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;KAC7B,CAAC,CACH;SACA,OAAO,CAAC,EAAE,CAAC;IACd,iBAAiB,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IAClD,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IACzC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC;CAClD,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,yBAAyB,CAAC;CAC1C,CAAC,CAAC"}
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import type { IMemoryClassifier, MemoryClassifierResult } from './classifier.js';
|
|
21
21
|
import { type MemoryBackendCostPoint } from './backend-costs.js';
|
|
22
|
-
import { type MemoryBackendId, type MemoryQueryCategory, type MemoryRouterPreset, type RoutingTable } from './routing-tables.js';
|
|
22
|
+
import { type AugmentedRoutingTable, type MemoryBackendId, type MemoryDispatchKey, type MemoryQueryCategory, type MemoryRouterPreset, type RoutingTable } from './routing-tables.js';
|
|
23
23
|
import { type MemoryBudgetMode, type MemoryRoutingDecision } from './select-backend.js';
|
|
24
24
|
import type { IMemoryDispatcher } from './dispatcher.js';
|
|
25
25
|
/**
|
|
@@ -83,6 +83,17 @@ export interface MemoryRouterOptions {
|
|
|
83
83
|
* execute the chosen backend themselves.
|
|
84
84
|
*/
|
|
85
85
|
readonly dispatcher?: IMemoryDispatcher<unknown, unknown>;
|
|
86
|
+
/**
|
|
87
|
+
* Optional augmented routing table. When supplied,
|
|
88
|
+
* {@link MemoryRouter.decideAugmented} and
|
|
89
|
+
* {@link MemoryRouter.decideAndDispatchAugmented} resolve each query
|
|
90
|
+
* to a composite {@link MemoryDispatchKey} (backend × retrieval-config)
|
|
91
|
+
* instead of the legacy single-axis backend pick.
|
|
92
|
+
*
|
|
93
|
+
* Existing consumers see no behavioral change unless they call the
|
|
94
|
+
* new augmented methods.
|
|
95
|
+
*/
|
|
96
|
+
readonly augmentedTable?: AugmentedRoutingTable;
|
|
86
97
|
}
|
|
87
98
|
/**
|
|
88
99
|
* Per-call options for {@link MemoryRouter.decide}.
|
|
@@ -119,6 +130,24 @@ export interface MemoryRouterDispatchedDecision<TTrace> {
|
|
|
119
130
|
readonly traces: TTrace[];
|
|
120
131
|
readonly backend: MemoryBackendId;
|
|
121
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Bundled result of a `decideAugmented()` call. Carries the classifier
|
|
135
|
+
* result and the composite {@link MemoryDispatchKey} (backend ×
|
|
136
|
+
* retrieval-config) the augmented router resolved.
|
|
137
|
+
*/
|
|
138
|
+
export interface MemoryRouterAugmentedDecision {
|
|
139
|
+
readonly classifier: MemoryClassifierResult;
|
|
140
|
+
readonly dispatch: MemoryDispatchKey;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Bundled result of a `decideAndDispatchAugmented()` call. Combines
|
|
144
|
+
* the augmented decision with the dispatched traces.
|
|
145
|
+
*/
|
|
146
|
+
export interface MemoryRouterAugmentedDispatchedDecision<TTrace> {
|
|
147
|
+
readonly decision: MemoryRouterAugmentedDecision;
|
|
148
|
+
readonly traces: TTrace[];
|
|
149
|
+
readonly dispatch: MemoryDispatchKey;
|
|
150
|
+
}
|
|
122
151
|
/**
|
|
123
152
|
* Thrown when `decideAndDispatch` is called on a router that was
|
|
124
153
|
* constructed without a dispatcher.
|
|
@@ -126,6 +155,14 @@ export interface MemoryRouterDispatchedDecision<TTrace> {
|
|
|
126
155
|
export declare class MemoryRouterDispatcherMissingError extends Error {
|
|
127
156
|
constructor();
|
|
128
157
|
}
|
|
158
|
+
/**
|
|
159
|
+
* Thrown when `decideAugmented` or `decideAndDispatchAugmented` is
|
|
160
|
+
* called on a router that was constructed without an
|
|
161
|
+
* {@link AugmentedRoutingTable}.
|
|
162
|
+
*/
|
|
163
|
+
export declare class MemoryRouterAugmentedTableMissingError extends Error {
|
|
164
|
+
constructor();
|
|
165
|
+
}
|
|
129
166
|
/**
|
|
130
167
|
* The public MemoryRouter primitive. One instance per memory-recall
|
|
131
168
|
* endpoint; construct once at app startup with the chosen preset and
|
|
@@ -159,6 +196,7 @@ export declare class MemoryRouter {
|
|
|
159
196
|
private readonly classifier;
|
|
160
197
|
private readonly preset;
|
|
161
198
|
private readonly routingTable;
|
|
199
|
+
private readonly augmentedTable;
|
|
162
200
|
private readonly budgetPerQuery;
|
|
163
201
|
private readonly budgetMode;
|
|
164
202
|
private readonly backendCosts;
|
|
@@ -191,5 +229,51 @@ export declare class MemoryRouter {
|
|
|
191
229
|
* was supplied at construction.
|
|
192
230
|
*/
|
|
193
231
|
decideAndDispatch<TTrace, TPayload = undefined>(query: string, dispatchPayload?: TPayload, options?: MemoryRouterDecideOptions): Promise<MemoryRouterDispatchedDecision<TTrace>>;
|
|
232
|
+
/**
|
|
233
|
+
* Decide-only routing using the augmented table. Classifies the
|
|
234
|
+
* query, resolves a composite {@link MemoryDispatchKey} (backend ×
|
|
235
|
+
* retrieval-config) from the configured
|
|
236
|
+
* {@link AugmentedRoutingTable}, and returns both pieces.
|
|
237
|
+
*
|
|
238
|
+
* Does NOT execute the recall — pair with {@link IMemoryDispatcher}
|
|
239
|
+
* for the end-to-end flow, or call
|
|
240
|
+
* {@link MemoryRouter.decideAndDispatchAugmented} when both an
|
|
241
|
+
* augmented table and a dispatcher are wired.
|
|
242
|
+
*
|
|
243
|
+
* @param query - The user's memory-recall query text.
|
|
244
|
+
* @param options - Per-call overrides (ground-truth telemetry,
|
|
245
|
+
* prompt variant). The `groundTruthCategory` field is unused on
|
|
246
|
+
* this path because augmented routing has no `selectBackend`-style
|
|
247
|
+
* telemetry surface; tests pass it through anyway for parity.
|
|
248
|
+
* @returns The classifier result + composite dispatch key.
|
|
249
|
+
*
|
|
250
|
+
* @throws {@link MemoryRouterAugmentedTableMissingError} when no
|
|
251
|
+
* augmented table was supplied at construction.
|
|
252
|
+
*/
|
|
253
|
+
decideAugmented(query: string, options?: MemoryRouterDecideOptions): Promise<MemoryRouterAugmentedDecision>;
|
|
254
|
+
/**
|
|
255
|
+
* Decide + dispatch in one call, using the augmented table.
|
|
256
|
+
* Requires the router to have been constructed with both an
|
|
257
|
+
* {@link AugmentedRoutingTable} and a {@link IMemoryDispatcher}.
|
|
258
|
+
*
|
|
259
|
+
* The selected {@link RetrievalConfigId} is forwarded to the
|
|
260
|
+
* dispatcher's `retrievalConfig` arg; consumer-defined executors
|
|
261
|
+
* read it via the third-arg
|
|
262
|
+
* {@link MemoryBackendExecutorContext} parameter.
|
|
263
|
+
*
|
|
264
|
+
* @typeParam TTrace - Caller's trace shape (passed through verbatim).
|
|
265
|
+
* @typeParam TPayload - Caller's payload shape for the dispatcher.
|
|
266
|
+
* @param query - User memory-recall query.
|
|
267
|
+
* @param dispatchPayload - Optional payload forwarded to the
|
|
268
|
+
* per-backend executor (e.g. topK, retrieval policy).
|
|
269
|
+
* @param options - Per-call overrides (ground-truth telemetry,
|
|
270
|
+
* prompt variant).
|
|
271
|
+
*
|
|
272
|
+
* @throws {@link MemoryRouterAugmentedTableMissingError} when no
|
|
273
|
+
* augmented table was supplied at construction.
|
|
274
|
+
* @throws {@link MemoryRouterDispatcherMissingError} when no
|
|
275
|
+
* dispatcher was supplied at construction.
|
|
276
|
+
*/
|
|
277
|
+
decideAndDispatchAugmented<TTrace, TPayload = undefined>(query: string, dispatchPayload?: TPayload, options?: MemoryRouterDecideOptions): Promise<MemoryRouterAugmentedDispatchedDecision<TTrace>>;
|
|
194
278
|
}
|
|
195
279
|
//# sourceMappingURL=MemoryRouter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemoryRouter.d.ts","sourceRoot":"","sources":["../../src/memory-router/MemoryRouter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EACV,iBAAiB,EACjB,sBAAsB,EACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,
|
|
1
|
+
{"version":3,"file":"MemoryRouter.d.ts","sourceRoot":"","sources":["../../src/memory-router/MemoryRouter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EACV,iBAAiB,EACjB,sBAAsB,EACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAGL,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EAClB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC3B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EACV,iBAAiB,EAElB,MAAM,iBAAiB,CAAC;AAMzB;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,QAAQ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B,CAAC;IAuBhC;;;;;;;;;;;;;OAaG;IACG,iBAAiB,CAAC,MAAM,EAAE,QAAQ,GAAG,SAAS,EAClD,KAAK,EAAE,MAAM,EACb,eAAe,CAAC,EAAE,QAAQ,EAC1B,OAAO,CAAC,EAAE,yBAAyB,GAClC,OAAO,CAAC,8BAA8B,CAAC,MAAM,CAAC,CAAC;IAmBlD;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,eAAe,CACnB,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,yBAAyB,GAClC,OAAO,CAAC,6BAA6B,CAAC;IAmBzC;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACG,0BAA0B,CAAC,MAAM,EAAE,QAAQ,GAAG,SAAS,EAC3D,KAAK,EAAE,MAAM,EACb,eAAe,CAAC,EAAE,QAAQ,EAC1B,OAAO,CAAC,EAAE,yBAAyB,GAClC,OAAO,CAAC,uCAAuC,CAAC,MAAM,CAAC,CAAC;CAmB5D"}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* @module @framers/agentos/memory-router/MemoryRouter
|
|
19
19
|
*/
|
|
20
20
|
import { DEFAULT_MEMORY_BACKEND_COSTS, } from './backend-costs.js';
|
|
21
|
-
import { PRESET_TABLES, } from './routing-tables.js';
|
|
21
|
+
import { PRESET_TABLES, selectAugmentedDispatch, } from './routing-tables.js';
|
|
22
22
|
import { selectBackend, } from './select-backend.js';
|
|
23
23
|
/**
|
|
24
24
|
* Thrown when `decideAndDispatch` is called on a router that was
|
|
@@ -31,6 +31,19 @@ export class MemoryRouterDispatcherMissingError extends Error {
|
|
|
31
31
|
this.name = 'MemoryRouterDispatcherMissingError';
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Thrown when `decideAugmented` or `decideAndDispatchAugmented` is
|
|
36
|
+
* called on a router that was constructed without an
|
|
37
|
+
* {@link AugmentedRoutingTable}.
|
|
38
|
+
*/
|
|
39
|
+
export class MemoryRouterAugmentedTableMissingError extends Error {
|
|
40
|
+
constructor() {
|
|
41
|
+
super('MemoryRouter.decideAugmented requires an augmentedTable. ' +
|
|
42
|
+
'Pass one in MemoryRouterOptions (e.g. MINIMIZE_COST_AUGMENTED_TABLE), ' +
|
|
43
|
+
'or use the legacy `decide` / `decideAndDispatch` methods.');
|
|
44
|
+
this.name = 'MemoryRouterAugmentedTableMissingError';
|
|
45
|
+
}
|
|
46
|
+
}
|
|
34
47
|
// ============================================================================
|
|
35
48
|
// Class
|
|
36
49
|
// ============================================================================
|
|
@@ -68,6 +81,7 @@ export class MemoryRouter {
|
|
|
68
81
|
this.classifier = options.classifier;
|
|
69
82
|
this.preset = options.preset ?? 'minimize-cost';
|
|
70
83
|
this.dispatcher = options.dispatcher ?? null;
|
|
84
|
+
this.augmentedTable = options.augmentedTable ?? null;
|
|
71
85
|
// Resolve routing table: explicit > preset's default.
|
|
72
86
|
const baseTable = options.routingTable ?? PRESET_TABLES[this.preset];
|
|
73
87
|
// Apply optional per-category mapping override.
|
|
@@ -151,5 +165,78 @@ export class MemoryRouter {
|
|
|
151
165
|
backend: dispatched.backend,
|
|
152
166
|
};
|
|
153
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* Decide-only routing using the augmented table. Classifies the
|
|
170
|
+
* query, resolves a composite {@link MemoryDispatchKey} (backend ×
|
|
171
|
+
* retrieval-config) from the configured
|
|
172
|
+
* {@link AugmentedRoutingTable}, and returns both pieces.
|
|
173
|
+
*
|
|
174
|
+
* Does NOT execute the recall — pair with {@link IMemoryDispatcher}
|
|
175
|
+
* for the end-to-end flow, or call
|
|
176
|
+
* {@link MemoryRouter.decideAndDispatchAugmented} when both an
|
|
177
|
+
* augmented table and a dispatcher are wired.
|
|
178
|
+
*
|
|
179
|
+
* @param query - The user's memory-recall query text.
|
|
180
|
+
* @param options - Per-call overrides (ground-truth telemetry,
|
|
181
|
+
* prompt variant). The `groundTruthCategory` field is unused on
|
|
182
|
+
* this path because augmented routing has no `selectBackend`-style
|
|
183
|
+
* telemetry surface; tests pass it through anyway for parity.
|
|
184
|
+
* @returns The classifier result + composite dispatch key.
|
|
185
|
+
*
|
|
186
|
+
* @throws {@link MemoryRouterAugmentedTableMissingError} when no
|
|
187
|
+
* augmented table was supplied at construction.
|
|
188
|
+
*/
|
|
189
|
+
async decideAugmented(query, options) {
|
|
190
|
+
if (!this.augmentedTable) {
|
|
191
|
+
throw new MemoryRouterAugmentedTableMissingError();
|
|
192
|
+
}
|
|
193
|
+
const useFewShot = options?.useFewShotPrompt ?? this.defaultUseFewShotPrompt;
|
|
194
|
+
const classifierOptions = useFewShot
|
|
195
|
+
? { useFewShotPrompt: true }
|
|
196
|
+
: undefined;
|
|
197
|
+
const classifier = await this.classifier.classify(query, classifierOptions);
|
|
198
|
+
const dispatch = selectAugmentedDispatch(classifier.category, this.augmentedTable);
|
|
199
|
+
return { classifier, dispatch };
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Decide + dispatch in one call, using the augmented table.
|
|
203
|
+
* Requires the router to have been constructed with both an
|
|
204
|
+
* {@link AugmentedRoutingTable} and a {@link IMemoryDispatcher}.
|
|
205
|
+
*
|
|
206
|
+
* The selected {@link RetrievalConfigId} is forwarded to the
|
|
207
|
+
* dispatcher's `retrievalConfig` arg; consumer-defined executors
|
|
208
|
+
* read it via the third-arg
|
|
209
|
+
* {@link MemoryBackendExecutorContext} parameter.
|
|
210
|
+
*
|
|
211
|
+
* @typeParam TTrace - Caller's trace shape (passed through verbatim).
|
|
212
|
+
* @typeParam TPayload - Caller's payload shape for the dispatcher.
|
|
213
|
+
* @param query - User memory-recall query.
|
|
214
|
+
* @param dispatchPayload - Optional payload forwarded to the
|
|
215
|
+
* per-backend executor (e.g. topK, retrieval policy).
|
|
216
|
+
* @param options - Per-call overrides (ground-truth telemetry,
|
|
217
|
+
* prompt variant).
|
|
218
|
+
*
|
|
219
|
+
* @throws {@link MemoryRouterAugmentedTableMissingError} when no
|
|
220
|
+
* augmented table was supplied at construction.
|
|
221
|
+
* @throws {@link MemoryRouterDispatcherMissingError} when no
|
|
222
|
+
* dispatcher was supplied at construction.
|
|
223
|
+
*/
|
|
224
|
+
async decideAndDispatchAugmented(query, dispatchPayload, options) {
|
|
225
|
+
if (!this.dispatcher) {
|
|
226
|
+
throw new MemoryRouterDispatcherMissingError();
|
|
227
|
+
}
|
|
228
|
+
const decision = await this.decideAugmented(query, options);
|
|
229
|
+
const dispatched = (await this.dispatcher.dispatch({
|
|
230
|
+
backend: decision.dispatch.backend,
|
|
231
|
+
retrievalConfig: decision.dispatch.retrievalConfig,
|
|
232
|
+
query,
|
|
233
|
+
payload: dispatchPayload,
|
|
234
|
+
}));
|
|
235
|
+
return {
|
|
236
|
+
decision,
|
|
237
|
+
traces: dispatched.traces,
|
|
238
|
+
dispatch: decision.dispatch,
|
|
239
|
+
};
|
|
240
|
+
}
|
|
154
241
|
}
|
|
155
242
|
//# sourceMappingURL=MemoryRouter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemoryRouter.js","sourceRoot":"","sources":["../../src/memory-router/MemoryRouter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAMH,OAAO,EACL,4BAA4B,GAE7B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,aAAa,
|
|
1
|
+
{"version":3,"file":"MemoryRouter.js","sourceRoot":"","sources":["../../src/memory-router/MemoryRouter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAMH,OAAO,EACL,4BAA4B,GAE7B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,aAAa,EACb,uBAAuB,GAOxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,aAAa,GAGd,MAAM,qBAAqB,CAAC;AAiJ7B;;;GAGG;AACH,MAAM,OAAO,kCAAmC,SAAQ,KAAK;IAC3D;QACE,KAAK,CACH,wDAAwD;YACtD,8EAA8E,CACjF,CAAC;QACF,IAAI,CA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C,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,MAAM,IAAI,kCAAkC,EAAE,CAAC;QACjD,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAE5D,MAAM,UAAU,GAAG,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;YACjD,OAAO,EAAE,QAAQ,CAAC,QAAQ,CAAC,OAAO;YAClC,eAAe,EAAE,QAAQ,CAAC,QAAQ,CAAC,eAAe;YAClD,KAAK;YACL,OAAO,EAAE,eAA0B;SACpC,CAAC,CAAiC,CAAC;QAEpC,OAAO;YACL,QAAQ;YACR,MAAM,EAAE,UAAU,CAAC,MAAM;YACzB,QAAQ,EAAE,QAAQ,CAAC,QAAQ;SAC5B,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -29,17 +29,47 @@
|
|
|
29
29
|
* @module @framers/agentos/memory-router/dispatcher
|
|
30
30
|
*/
|
|
31
31
|
import type { MemoryBackendId } from './routing-tables.js';
|
|
32
|
+
import type { RetrievalConfigId } from './retrieval-config.js';
|
|
33
|
+
/**
|
|
34
|
+
* Optional execution context passed as the third argument to a
|
|
35
|
+
* {@link MemoryBackendExecutor}. Carries cross-cutting per-call hints
|
|
36
|
+
* the dispatcher knows about but the user-defined payload should not
|
|
37
|
+
* have to encode (e.g. the {@link RetrievalConfigId} chosen by the
|
|
38
|
+
* augmented router).
|
|
39
|
+
*
|
|
40
|
+
* Existing executors with the older two-argument signature
|
|
41
|
+
* `(query, payload) => traces` remain assignable to
|
|
42
|
+
* {@link MemoryBackendExecutor} because the context arg is optional —
|
|
43
|
+
* functions are contravariant in their parameters and JavaScript
|
|
44
|
+
* silently ignores unused trailing arguments.
|
|
45
|
+
*/
|
|
46
|
+
export interface MemoryBackendExecutorContext {
|
|
47
|
+
/**
|
|
48
|
+
* Augmented router's per-query retrieval-config pick. When set, the
|
|
49
|
+
* executor SHOULD apply the corresponding flags
|
|
50
|
+
* (see `RETRIEVAL_CONFIG_SPECS`) to its retrieval pipeline.
|
|
51
|
+
* Undefined when the dispatcher was called via the legacy backend-
|
|
52
|
+
* only path.
|
|
53
|
+
*/
|
|
54
|
+
readonly retrievalConfig?: RetrievalConfigId;
|
|
55
|
+
}
|
|
32
56
|
/**
|
|
33
57
|
* Per-backend execution function. Takes the query string + an optional
|
|
34
58
|
* caller-defined payload (e.g. topK, retrieval policy, session filter),
|
|
35
59
|
* returns the trace array.
|
|
36
60
|
*
|
|
61
|
+
* The optional third arg, {@link MemoryBackendExecutorContext}, carries
|
|
62
|
+
* cross-cutting hints the dispatcher routes through — currently the
|
|
63
|
+
* augmented router's per-query {@link RetrievalConfigId}. Executors
|
|
64
|
+
* written before augmented routing existed remain assignable because
|
|
65
|
+
* the third arg is optional.
|
|
66
|
+
*
|
|
37
67
|
* @typeParam TTrace - Shape of the trace the caller's memory layer emits.
|
|
38
68
|
* Defaults to the {@link ScoredTrace} shape from `@framers/agentos/memory`
|
|
39
69
|
* but any shape is accepted since the dispatcher is a pass-through.
|
|
40
70
|
* @typeParam TPayload - Shape of the optional payload argument.
|
|
41
71
|
*/
|
|
42
|
-
export type MemoryBackendExecutor<TTrace, TPayload = undefined> = (query: string, payload: TPayload) => Promise<TTrace[]>;
|
|
72
|
+
export type MemoryBackendExecutor<TTrace, TPayload = undefined> = (query: string, payload: TPayload, context?: MemoryBackendExecutorContext) => Promise<TTrace[]>;
|
|
43
73
|
/**
|
|
44
74
|
* Args passed to {@link IMemoryDispatcher.dispatch}.
|
|
45
75
|
*/
|
|
@@ -48,6 +78,14 @@ export interface MemoryDispatchArgs<TPayload = undefined> {
|
|
|
48
78
|
readonly query: string;
|
|
49
79
|
/** Optional payload forwarded to the per-backend executor verbatim. */
|
|
50
80
|
readonly payload?: TPayload;
|
|
81
|
+
/**
|
|
82
|
+
* Optional augmented-router pick. When supplied, the dispatcher
|
|
83
|
+
* forwards it as the third executor arg
|
|
84
|
+
* ({@link MemoryBackendExecutorContext.retrievalConfig}). Existing
|
|
85
|
+
* legacy callers omit this field; existing executors ignore the
|
|
86
|
+
* third arg unless they opt in.
|
|
87
|
+
*/
|
|
88
|
+
readonly retrievalConfig?: RetrievalConfigId;
|
|
51
89
|
}
|
|
52
90
|
/**
|
|
53
91
|
* Result of a dispatch call. Carries the traces plus the backend that
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatcher.d.ts","sourceRoot":"","sources":["../../src/memory-router/dispatcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"dispatcher.d.ts","sourceRoot":"","sources":["../../src/memory-router/dispatcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAM/D;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,4BAA4B;IAC3C;;;;;;OAMG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,iBAAiB,CAAC;CAC9C;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,qBAAqB,CAAC,MAAM,EAAE,QAAQ,GAAG,SAAS,IAAI,CAChE,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,QAAQ,EACjB,OAAO,CAAC,EAAE,4BAA4B,KACnC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AAEvB;;GAEG;AACH,MAAM,WAAW,kBAAkB,CAAC,QAAQ,GAAG,SAAS;IACtD,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,uEAAuE;IACvE,QAAQ,CAAC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.backend);
|
|
79
79
|
}
|
|
80
|
-
|
|
80
|
+
// Preserve the legacy two-argument call shape on legacy dispatch
|
|
81
|
+
// calls (no retrievalConfig). Only pass the context arg when the
|
|
82
|
+
// augmented router has supplied a retrievalConfig — keeps existing
|
|
83
|
+
// mocks asserting `executor(query, payload)` working unchanged.
|
|
84
|
+
const traces = args.retrievalConfig !== undefined
|
|
85
|
+
? await executor(args.query, args.payload, {
|
|
86
|
+
retrievalConfig: args.retrievalConfig,
|
|
87
|
+
})
|
|
88
|
+
: await executor(args.query, args.payload);
|
|
81
89
|
return { traces, backend: args.backend };
|
|
82
90
|
}
|
|
83
91
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatcher.js","sourceRoot":"","sources":["../../src/memory-router/dispatcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;
|
|
1
|
+
{"version":3,"file":"dispatcher.js","sourceRoot":"","sources":["../../src/memory-router/dispatcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AA6FH;;;;GAIG;AACH,MAAM,OAAO,6BAA8B,SAAQ,KAAK;IACtD,YAA4B,OAAwB;QAClD,KAAK,CACH,8BAA8B,OAAO,uBAAuB;YAC1D,2DAA2D,CAC9D,CAAC;QAJwB,YAAO,GAAP,OAAO,CAAiB;QAKlD,IAAI,CAAC,IAAI,GAAG,+BAA+B,CAAC;IAC9C,CAAC;CACF;AAeD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,OAAO,wBAAwB;IAKnC,YAAY,QAAiD;QAC3D,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,QAAQ,CACZ,IAAkC;QAElC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC7C,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,6BAA6B,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACxD,CAAC;QACD,iEAAiE;QACjE,iEAAiE;QACjE,mEAAmE;QACnE,gEAAgE;QAChE,MAAM,MAAM,GACV,IAAI,CAAC,eAAe,KAAK,SAAS;YAChC,CAAC,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,OAAmB,EAAE;gBACnD,eAAe,EAAE,IAAI,CAAC,eAAe;aACtC,CAAC;YACJ,CAAC,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,OAAmB,CAAC,CAAC;QAC3D,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;IAC3C,CAAC;CACF"}
|
|
@@ -108,21 +108,23 @@
|
|
|
108
108
|
* );
|
|
109
109
|
* ```
|
|
110
110
|
*/
|
|
111
|
-
export type { MemoryQueryCategory, MemoryBackendId, MemoryRouterPreset, RoutingTable, } from './routing-tables.js';
|
|
111
|
+
export type { MemoryQueryCategory, MemoryBackendId, MemoryRouterPreset, RoutingTable, AugmentedMemoryRouterPreset, AugmentedRoutingTable, MemoryDispatchKey, } from './routing-tables.js';
|
|
112
112
|
export { MEMORY_QUERY_CATEGORIES } from './routing-tables.js';
|
|
113
113
|
export type { MemoryBackendCostPoint } from './backend-costs.js';
|
|
114
114
|
export type { MemoryBudgetMode, MemoryRouterConfig, MemoryRoutingDecision, } from './select-backend.js';
|
|
115
115
|
export type { IMemoryClassifier, IMemoryClassifierLLM, MemoryClassifierLLMRequest, MemoryClassifierLLMResponse, MemoryClassifierClassifyOptions, MemoryClassifierResult, LLMMemoryClassifierOptions, } from './classifier.js';
|
|
116
|
-
export type { IMemoryDispatcher, MemoryDispatchArgs, MemoryDispatchResult, MemoryBackendExecutor, MemoryBackendRegistry, } from './dispatcher.js';
|
|
117
|
-
export type { MemoryBudgetPolicy, MemoryRouterOptions, MemoryRouterDecideOptions, MemoryRouterDecision, MemoryRouterDispatchedDecision, } from './MemoryRouter.js';
|
|
118
|
-
export { MINIMIZE_COST_TABLE, BALANCED_TABLE, MAXIMIZE_ACCURACY_TABLE, PRESET_TABLES, } from './routing-tables.js';
|
|
116
|
+
export type { IMemoryDispatcher, MemoryDispatchArgs, MemoryDispatchResult, MemoryBackendExecutor, MemoryBackendExecutorContext, MemoryBackendRegistry, } from './dispatcher.js';
|
|
117
|
+
export type { MemoryBudgetPolicy, MemoryRouterOptions, MemoryRouterDecideOptions, MemoryRouterDecision, MemoryRouterDispatchedDecision, MemoryRouterAugmentedDecision, MemoryRouterAugmentedDispatchedDecision, } from './MemoryRouter.js';
|
|
118
|
+
export { MINIMIZE_COST_TABLE, BALANCED_TABLE, MAXIMIZE_ACCURACY_TABLE, PRESET_TABLES, MINIMIZE_COST_AUGMENTED_TABLE, AUGMENTED_PRESET_TABLES, SAFE_FALLBACK_BACKEND, SAFE_FALLBACK_DISPATCH_KEY, selectAugmentedDispatch, } from './routing-tables.js';
|
|
119
119
|
export { TIER_1_CANONICAL_COSTS, TIER_2A_V10_COSTS, TIER_2B_V11_COSTS, DEFAULT_MEMORY_BACKEND_COSTS, } from './backend-costs.js';
|
|
120
120
|
export { selectBackend, MemoryRouterUnknownCategoryError, MemoryRouterBudgetExceededError, } from './select-backend.js';
|
|
121
121
|
export { CLASSIFIER_SYSTEM_PROMPT, CLASSIFIER_SYSTEM_PROMPT_FEWSHOT, SAFE_FALLBACK_CATEGORY, LLMMemoryClassifier, normalizeClassifierOutput, parseClassifierOutput, } from './classifier.js';
|
|
122
122
|
export { FunctionMemoryDispatcher, UnsupportedMemoryBackendError, } from './dispatcher.js';
|
|
123
|
-
export { MemoryRouter, MemoryRouterDispatcherMissingError, } from './MemoryRouter.js';
|
|
123
|
+
export { MemoryRouter, MemoryRouterDispatcherMissingError, MemoryRouterAugmentedTableMissingError, } from './MemoryRouter.js';
|
|
124
124
|
export type { CalibrationSample, CalibrationCell, AggregatedCalibration, AdaptivePresetRule, SelectByPresetArgs, BuildAdaptiveRoutingTableArgs, AdaptiveMemoryRouterOptions, } from './adaptive.js';
|
|
125
125
|
export { aggregateCalibration, selectByPreset, buildAdaptiveRoutingTable, AdaptiveMemoryRouter, } from './adaptive.js';
|
|
126
126
|
export { EntityRetrievalRanker, createEntityRetrievalRanker, } from './backends/index.js';
|
|
127
127
|
export type { RankedCandidate, RankedCandidateWithBoost, EntityRetrievalRankerOptions, } from './backends/index.js';
|
|
128
|
+
export { RETRIEVAL_CONFIG_IDS, RETRIEVAL_CONFIG_SPECS, M_PHASE_A_PER_CATEGORY_ACCURACY, M_PHASE_A_COST_PER_CORRECT, M_TUNED_PER_CATEGORY_TABLE, selectBestRetrievalConfig, computeOracleAggregate, computeOracleCostPerCorrect, } from './retrieval-config.js';
|
|
129
|
+
export type { RetrievalConfigId, RetrievalConfigSpec, } from './retrieval-config.js';
|
|
128
130
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/memory-router/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6GG;AAMH,YAAY,EACV,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/memory-router/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6GG;AAMH,YAAY,EACV,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,YAAY,EACZ,2BAA2B,EAC3B,qBAAqB,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vC,MAAM,mBAAmB,CAAC;AAM3B,YAAY,EACV,iBAAiB,EACjB,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,6BAA6B,EAC7B,2BAA2B,GAC5B,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,eAAe,CAAC;AAMvB,OAAO,EACL,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,eAAe,EACf,wBAAwB,EACxB,4BAA4B,GAC7B,MAAM,qBAAqB,CAAC;AAO7B,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,+BAA+B,EAC/B,0BAA0B,EAC1B,0BAA0B,EAC1B,yBAAyB,EACzB,sBAAsB,EACtB,2BAA2B,GAC5B,MAAM,uBAAuB,CAAC;AAE/B,YAAY,EACV,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,uBAAuB,CAAC"}
|
|
@@ -112,15 +112,20 @@ export { MEMORY_QUERY_CATEGORIES } from './routing-tables.js';
|
|
|
112
112
|
// ============================================================================
|
|
113
113
|
// Values
|
|
114
114
|
// ============================================================================
|
|
115
|
-
export { MINIMIZE_COST_TABLE, BALANCED_TABLE, MAXIMIZE_ACCURACY_TABLE, PRESET_TABLES, } from './routing-tables.js';
|
|
115
|
+
export { MINIMIZE_COST_TABLE, BALANCED_TABLE, MAXIMIZE_ACCURACY_TABLE, PRESET_TABLES, MINIMIZE_COST_AUGMENTED_TABLE, AUGMENTED_PRESET_TABLES, SAFE_FALLBACK_BACKEND, SAFE_FALLBACK_DISPATCH_KEY, selectAugmentedDispatch, } from './routing-tables.js';
|
|
116
116
|
export { TIER_1_CANONICAL_COSTS, TIER_2A_V10_COSTS, TIER_2B_V11_COSTS, DEFAULT_MEMORY_BACKEND_COSTS, } from './backend-costs.js';
|
|
117
117
|
export { selectBackend, MemoryRouterUnknownCategoryError, MemoryRouterBudgetExceededError, } from './select-backend.js';
|
|
118
118
|
export { CLASSIFIER_SYSTEM_PROMPT, CLASSIFIER_SYSTEM_PROMPT_FEWSHOT, SAFE_FALLBACK_CATEGORY, LLMMemoryClassifier, normalizeClassifierOutput, parseClassifierOutput, } from './classifier.js';
|
|
119
119
|
export { FunctionMemoryDispatcher, UnsupportedMemoryBackendError, } from './dispatcher.js';
|
|
120
|
-
export { MemoryRouter, MemoryRouterDispatcherMissingError, } from './MemoryRouter.js';
|
|
120
|
+
export { MemoryRouter, MemoryRouterDispatcherMissingError, MemoryRouterAugmentedTableMissingError, } from './MemoryRouter.js';
|
|
121
121
|
export { aggregateCalibration, selectByPreset, buildAdaptiveRoutingTable, AdaptiveMemoryRouter, } from './adaptive.js';
|
|
122
122
|
// ============================================================================
|
|
123
123
|
// Reference recall-stage backends (Stage I: Mem0-v3-style entity-linking)
|
|
124
124
|
// ============================================================================
|
|
125
125
|
export { EntityRetrievalRanker, createEntityRetrievalRanker, } from './backends/index.js';
|
|
126
|
+
// ============================================================================
|
|
127
|
+
// RetrievalConfigRouter (per-query retrieval-config dispatch, calibrated
|
|
128
|
+
// from 2026-04-26 LongMemEval-M Phase A N=54 ablation matrix)
|
|
129
|
+
// ============================================================================
|
|
130
|
+
export { RETRIEVAL_CONFIG_IDS, RETRIEVAL_CONFIG_SPECS, M_PHASE_A_PER_CATEGORY_ACCURACY, M_PHASE_A_COST_PER_CORRECT, M_TUNED_PER_CATEGORY_TABLE, selectBestRetrievalConfig, computeOracleAggregate, computeOracleCostPerCorrect, } from './retrieval-config.js';
|
|
126
131
|
//# sourceMappingURL=index.js.map
|