@framers/agentos 0.2.7 → 0.2.9
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/cognitive-pipeline/index.d.ts +197 -0
- package/dist/cognitive-pipeline/index.d.ts.map +1 -0
- package/dist/cognitive-pipeline/index.js +193 -0
- package/dist/cognitive-pipeline/index.js.map +1 -0
- package/dist/ingest-router/IngestRouter.d.ts +72 -0
- package/dist/ingest-router/IngestRouter.d.ts.map +1 -0
- package/dist/ingest-router/IngestRouter.js +98 -0
- package/dist/ingest-router/IngestRouter.js.map +1 -0
- package/dist/ingest-router/classifier.d.ts +63 -0
- package/dist/ingest-router/classifier.d.ts.map +1 -0
- package/dist/ingest-router/classifier.js +111 -0
- package/dist/ingest-router/classifier.js.map +1 -0
- package/dist/ingest-router/costs.d.ts +48 -0
- package/dist/ingest-router/costs.d.ts.map +1 -0
- package/dist/ingest-router/costs.js +63 -0
- package/dist/ingest-router/costs.js.map +1 -0
- package/dist/ingest-router/dispatcher.d.ts +35 -0
- package/dist/ingest-router/dispatcher.d.ts.map +1 -0
- package/dist/ingest-router/dispatcher.js +32 -0
- package/dist/ingest-router/dispatcher.js.map +1 -0
- package/dist/ingest-router/index.d.ts +43 -0
- package/dist/ingest-router/index.d.ts.map +1 -0
- package/dist/ingest-router/index.js +37 -0
- package/dist/ingest-router/index.js.map +1 -0
- package/dist/ingest-router/routing-tables.d.ts +122 -0
- package/dist/ingest-router/routing-tables.d.ts.map +1 -0
- package/dist/ingest-router/routing-tables.js +145 -0
- package/dist/ingest-router/routing-tables.js.map +1 -0
- package/dist/ingest-router/select-strategy.d.ts +67 -0
- package/dist/ingest-router/select-strategy.d.ts.map +1 -0
- package/dist/ingest-router/select-strategy.js +100 -0
- package/dist/ingest-router/select-strategy.js.map +1 -0
- package/dist/memory-router/adaptive.d.ts +142 -0
- package/dist/memory-router/adaptive.d.ts.map +1 -0
- package/dist/memory-router/adaptive.js +202 -0
- package/dist/memory-router/adaptive.js.map +1 -0
- package/dist/memory-router/index.d.ts +2 -0
- package/dist/memory-router/index.d.ts.map +1 -1
- package/dist/memory-router/index.js +1 -0
- package/dist/memory-router/index.js.map +1 -1
- package/dist/read-router/ReadRouter.d.ts +58 -0
- package/dist/read-router/ReadRouter.d.ts.map +1 -0
- package/dist/read-router/ReadRouter.js +91 -0
- package/dist/read-router/ReadRouter.js.map +1 -0
- package/dist/read-router/classifier.d.ts +54 -0
- package/dist/read-router/classifier.d.ts.map +1 -0
- package/dist/read-router/classifier.js +104 -0
- package/dist/read-router/classifier.js.map +1 -0
- package/dist/read-router/costs.d.ts +23 -0
- package/dist/read-router/costs.d.ts.map +1 -0
- package/dist/read-router/costs.js +51 -0
- package/dist/read-router/costs.js.map +1 -0
- package/dist/read-router/dispatcher.d.ts +33 -0
- package/dist/read-router/dispatcher.d.ts.map +1 -0
- package/dist/read-router/dispatcher.js +29 -0
- package/dist/read-router/dispatcher.js.map +1 -0
- package/dist/read-router/index.d.ts +23 -0
- package/dist/read-router/index.d.ts.map +1 -0
- package/dist/read-router/index.js +17 -0
- package/dist/read-router/index.js.map +1 -0
- package/dist/read-router/routing-tables.d.ts +85 -0
- package/dist/read-router/routing-tables.d.ts.map +1 -0
- package/dist/read-router/routing-tables.js +79 -0
- package/dist/read-router/routing-tables.js.map +1 -0
- package/dist/read-router/select-strategy.d.ts +42 -0
- package/dist/read-router/select-strategy.d.ts.map +1 -0
- package/dist/read-router/select-strategy.js +92 -0
- package/dist/read-router/select-strategy.js.map +1 -0
- package/package.json +16 -1
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file classifier.ts
|
|
3
|
+
* @description LLM-as-judge classifier that maps a piece of content to
|
|
4
|
+
* one of the six {@link IngestContentKind} values.
|
|
5
|
+
*
|
|
6
|
+
* Same shape as the memory-router classifier — deliberately so the
|
|
7
|
+
* multi-stage guardrails orchestrator can compose them with one mental
|
|
8
|
+
* model.
|
|
9
|
+
*
|
|
10
|
+
* @module @framers/agentos/ingest-router/classifier
|
|
11
|
+
*/
|
|
12
|
+
import { INGEST_CONTENT_KINDS, } from './routing-tables.js';
|
|
13
|
+
// ============================================================================
|
|
14
|
+
// Prompts
|
|
15
|
+
// ============================================================================
|
|
16
|
+
export const INGEST_CLASSIFIER_SYSTEM_PROMPT = `You are classifying a piece of content into one of six ingest kinds for memory storage.
|
|
17
|
+
|
|
18
|
+
Return ONLY the kind token (no explanation, no quotes, no punctuation).
|
|
19
|
+
|
|
20
|
+
Kinds:
|
|
21
|
+
- short-conversation: 1-3 turns of chat dialog. Examples: a one-message Q&A, a brief support exchange.
|
|
22
|
+
- long-conversation: extended chat sessions across many turns. Examples: a 50-turn coding conversation, a 30-turn customer support thread.
|
|
23
|
+
- long-article: prose document over ~500 words. Examples: a blog post, a research paper section, a long email.
|
|
24
|
+
- code: source code, configuration files, schemas. Examples: a TypeScript module, a SQL migration, a JSON schema.
|
|
25
|
+
- structured-data: tabular or JSON-style records. Examples: a CSV, a JSON list of records, a database export.
|
|
26
|
+
- multimodal: content that includes images, video frames, or audio. Examples: a PDF with figures, a presentation slide.`;
|
|
27
|
+
export const INGEST_CLASSIFIER_SYSTEM_PROMPT_FEWSHOT = `You are classifying a piece of content into one of six ingest kinds for memory storage.
|
|
28
|
+
|
|
29
|
+
Return ONLY the kind token (no explanation, no quotes, no punctuation).
|
|
30
|
+
|
|
31
|
+
Kinds:
|
|
32
|
+
- short-conversation: 1-3 turns of chat dialog.
|
|
33
|
+
- long-conversation: extended chat sessions across many turns.
|
|
34
|
+
- long-article: prose document over ~500 words.
|
|
35
|
+
- code: source code, configuration files, schemas.
|
|
36
|
+
- structured-data: tabular or JSON-style records.
|
|
37
|
+
- multimodal: content that includes images, video frames, or audio.
|
|
38
|
+
|
|
39
|
+
Examples:
|
|
40
|
+
|
|
41
|
+
Content: "user: hi\\nassistant: hi! how can I help?"
|
|
42
|
+
Kind: short-conversation
|
|
43
|
+
|
|
44
|
+
Content: "[3000 words of a research paper introduction]"
|
|
45
|
+
Kind: long-article
|
|
46
|
+
|
|
47
|
+
Content: "export function fibonacci(n: number): number { return n < 2 ? n : fibonacci(n-1) + fibonacci(n-2); }"
|
|
48
|
+
Kind: code
|
|
49
|
+
|
|
50
|
+
Content: "[CSV with 50 rows of user records]"
|
|
51
|
+
Kind: structured-data
|
|
52
|
+
|
|
53
|
+
Content: "[40 turns of a customer-support thread]"
|
|
54
|
+
Kind: long-conversation
|
|
55
|
+
|
|
56
|
+
Content: "[image bytes + caption text]"
|
|
57
|
+
Kind: multimodal`;
|
|
58
|
+
export const SAFE_INGEST_FALLBACK_KIND = 'short-conversation';
|
|
59
|
+
export function normalizeIngestClassifierOutput(raw) {
|
|
60
|
+
const lines = raw.split('\n');
|
|
61
|
+
let firstLine = '';
|
|
62
|
+
for (const ln of lines) {
|
|
63
|
+
if (ln.trim().length > 0) {
|
|
64
|
+
firstLine = ln;
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
let cleaned = firstLine.trim().toLowerCase();
|
|
69
|
+
cleaned = cleaned.replace(/^(kind|category|type|answer|label|class)\s*[:\-=]\s*/, '');
|
|
70
|
+
cleaned = cleaned.replace(/^["'`]+|["'`]+$/g, '');
|
|
71
|
+
cleaned = cleaned.replace(/[.,;!?]+$/g, '');
|
|
72
|
+
return cleaned.trim();
|
|
73
|
+
}
|
|
74
|
+
export function parseIngestClassifierOutput(raw) {
|
|
75
|
+
const cleaned = normalizeIngestClassifierOutput(raw);
|
|
76
|
+
for (const token of INGEST_CONTENT_KINDS) {
|
|
77
|
+
if (cleaned === token ||
|
|
78
|
+
cleaned.startsWith(`${token} `) ||
|
|
79
|
+
cleaned.startsWith(`${token}\n`)) {
|
|
80
|
+
return token;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return SAFE_INGEST_FALLBACK_KIND;
|
|
84
|
+
}
|
|
85
|
+
export class LLMIngestClassifier {
|
|
86
|
+
constructor(options) {
|
|
87
|
+
this.llm = options.llm;
|
|
88
|
+
this.maxTokens = options.maxTokens ?? 16;
|
|
89
|
+
this.maxContentChars = options.maxContentChars ?? 1000;
|
|
90
|
+
}
|
|
91
|
+
async classify(content, options) {
|
|
92
|
+
const system = options?.useFewShotPrompt
|
|
93
|
+
? INGEST_CLASSIFIER_SYSTEM_PROMPT_FEWSHOT
|
|
94
|
+
: INGEST_CLASSIFIER_SYSTEM_PROMPT;
|
|
95
|
+
const truncated = content.slice(0, this.maxContentChars);
|
|
96
|
+
const user = `Content: ${truncated}\n\nKind:`;
|
|
97
|
+
const response = await this.llm.invoke({
|
|
98
|
+
system,
|
|
99
|
+
user,
|
|
100
|
+
maxTokens: this.maxTokens,
|
|
101
|
+
temperature: 0,
|
|
102
|
+
});
|
|
103
|
+
return {
|
|
104
|
+
kind: parseIngestClassifierOutput(response.text),
|
|
105
|
+
tokensIn: response.tokensIn,
|
|
106
|
+
tokensOut: response.tokensOut,
|
|
107
|
+
model: response.model,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=classifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classifier.js","sourceRoot":"","sources":["../../src/ingest-router/classifier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,oBAAoB,GAErB,MAAM,qBAAqB,CAAC;AAiD7B,+EAA+E;AAC/E,UAAU;AACV,+EAA+E;AAE/E,MAAM,CAAC,MAAM,+BAA+B,GAAG;;;;;;;;;;wHAUyE,CAAC;AAEzH,MAAM,CAAC,MAAM,uCAAuC,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA8BtC,CAAC;AAElB,MAAM,CAAC,MAAM,yBAAyB,GAAsB,oBAAoB,CAAC;AAEjF,MAAM,UAAU,+BAA+B,CAAC,GAAW;IACzD,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC9B,IAAI,SAAS,GAAG,EAAE,CAAC;IACnB,KAAK,MAAM,EAAE,IAAI,KAAK,EAAE,CAAC;QACvB,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzB,SAAS,GAAG,EAAE,CAAC;YACf,MAAM;QACR,CAAC;IACH,CAAC;IACD,IAAI,OAAO,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC7C,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,sDAAsD,EAAE,EAAE,CAAC,CAAC;IACtF,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;IAClD,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;IAC5C,OAAO,OAAO,CAAC,IAAI,EAAE,CAAC;AACxB,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,GAAW;IACrD,MAAM,OAAO,GAAG,+BAA+B,CAAC,GAAG,CAAC,CAAC;IACrD,KAAK,MAAM,KAAK,IAAI,oBAAoB,EAAE,CAAC;QACzC,IACE,OAAO,KAAK,KAAK;YACjB,OAAO,CAAC,UAAU,CAAC,GAAG,KAAK,GAAG,CAAC;YAC/B,OAAO,CAAC,UAAU,CAAC,GAAG,KAAK,IAAI,CAAC,EAChC,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IACD,OAAO,yBAAyB,CAAC;AACnC,CAAC;AAiBD,MAAM,OAAO,mBAAmB;IAK9B,YAAY,OAAmC;QAC7C,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC;QACzC,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,IAAI,IAAI,CAAC;IACzD,CAAC;IAED,KAAK,CAAC,QAAQ,CACZ,OAAe,EACf,OAAyC;QAEzC,MAAM,MAAM,GAAG,OAAO,EAAE,gBAAgB;YACtC,CAAC,CAAC,uCAAuC;YACzC,CAAC,CAAC,+BAA+B,CAAC;QACpC,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;QACzD,MAAM,IAAI,GAAG,YAAY,SAAS,WAAW,CAAC;QAE9C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC;YACrC,MAAM;YACN,IAAI;YACJ,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,WAAW,EAAE,CAAC;SACf,CAAC,CAAC;QAEH,OAAO;YACL,IAAI,EAAE,2BAA2B,CAAC,QAAQ,CAAC,IAAI,CAAC;YAChD,QAAQ,EAAE,QAAQ,CAAC,QAAQ;YAC3B,SAAS,EAAE,QAAQ,CAAC,SAAS;YAC7B,KAAK,EAAE,QAAQ,CAAC,KAAK;SACtB,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file costs.ts
|
|
3
|
+
* @description Cost-points for ingest strategies.
|
|
4
|
+
*
|
|
5
|
+
* Unlike retrieval where Phase B measurements give us per-category
|
|
6
|
+
* accuracy + cost data, ingest cost is dominated by LLM-call counts at
|
|
7
|
+
* write time and is much more workload-dependent (a long-article may
|
|
8
|
+
* have 1 summarize call; a long-conversation may have 30 observation
|
|
9
|
+
* extraction calls). The numbers below are illustrative averages; for
|
|
10
|
+
* production-budget enforcement, consumers should override with measured
|
|
11
|
+
* values from their own workload.
|
|
12
|
+
*
|
|
13
|
+
* @module @framers/agentos/ingest-router/costs
|
|
14
|
+
*/
|
|
15
|
+
import type { IngestStrategyId } from './routing-tables.js';
|
|
16
|
+
/**
|
|
17
|
+
* Cost-point for one ingest strategy. The router uses this to apply
|
|
18
|
+
* budget constraints + pick a cheaper fallback when a strategy doesn't
|
|
19
|
+
* fit a per-ingest USD ceiling.
|
|
20
|
+
*/
|
|
21
|
+
export interface IngestStrategyCostPoint {
|
|
22
|
+
readonly strategy: IngestStrategyId;
|
|
23
|
+
/** Average USD per ingest event (one session / one document). */
|
|
24
|
+
readonly avgCostPerIngest: number;
|
|
25
|
+
/**
|
|
26
|
+
* Average latency per ingest in milliseconds. For short content this
|
|
27
|
+
* is roughly proportional to the number of LLM calls.
|
|
28
|
+
*/
|
|
29
|
+
readonly avgLatencyMs: number;
|
|
30
|
+
/**
|
|
31
|
+
* Free-form label describing what this strategy actually writes
|
|
32
|
+
* (chunks, summarized chunks, observations, fact triples, etc.).
|
|
33
|
+
* Useful for telemetry + dashboards.
|
|
34
|
+
*/
|
|
35
|
+
readonly outputDescription: string;
|
|
36
|
+
}
|
|
37
|
+
export declare const RAW_CHUNKS_COST: IngestStrategyCostPoint;
|
|
38
|
+
export declare const SUMMARIZED_COST: IngestStrategyCostPoint;
|
|
39
|
+
export declare const OBSERVATIONAL_COST: IngestStrategyCostPoint;
|
|
40
|
+
export declare const FACT_GRAPH_COST: IngestStrategyCostPoint;
|
|
41
|
+
export declare const HYBRID_COST: IngestStrategyCostPoint;
|
|
42
|
+
export declare const SKIP_COST: IngestStrategyCostPoint;
|
|
43
|
+
/**
|
|
44
|
+
* Default cost-points registry. Override per workload by passing a
|
|
45
|
+
* custom map to {@link IngestRouter} at construction.
|
|
46
|
+
*/
|
|
47
|
+
export declare const DEFAULT_INGEST_COSTS: Readonly<Record<IngestStrategyId, IngestStrategyCostPoint>>;
|
|
48
|
+
//# sourceMappingURL=costs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"costs.d.ts","sourceRoot":"","sources":["../../src/ingest-router/costs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,iEAAiE;IACjE,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC;;;OAGG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;CACpC;AAED,eAAO,MAAM,eAAe,EAAE,uBAKD,CAAC;AAE9B,eAAO,MAAM,eAAe,EAAE,uBAKD,CAAC;AAE9B,eAAO,MAAM,kBAAkB,EAAE,uBAKJ,CAAC;AAE9B,eAAO,MAAM,eAAe,EAAE,uBAKD,CAAC;AAE9B,eAAO,MAAM,WAAW,EAAE,uBAKG,CAAC;AAE9B,eAAO,MAAM,SAAS,EAAE,uBAKK,CAAC;AAE9B;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CACzC,MAAM,CAAC,gBAAgB,EAAE,uBAAuB,CAAC,CAQjD,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file costs.ts
|
|
3
|
+
* @description Cost-points for ingest strategies.
|
|
4
|
+
*
|
|
5
|
+
* Unlike retrieval where Phase B measurements give us per-category
|
|
6
|
+
* accuracy + cost data, ingest cost is dominated by LLM-call counts at
|
|
7
|
+
* write time and is much more workload-dependent (a long-article may
|
|
8
|
+
* have 1 summarize call; a long-conversation may have 30 observation
|
|
9
|
+
* extraction calls). The numbers below are illustrative averages; for
|
|
10
|
+
* production-budget enforcement, consumers should override with measured
|
|
11
|
+
* values from their own workload.
|
|
12
|
+
*
|
|
13
|
+
* @module @framers/agentos/ingest-router/costs
|
|
14
|
+
*/
|
|
15
|
+
export const RAW_CHUNKS_COST = Object.freeze({
|
|
16
|
+
strategy: 'raw-chunks',
|
|
17
|
+
avgCostPerIngest: 0.0001, // embedding-only
|
|
18
|
+
avgLatencyMs: 200,
|
|
19
|
+
outputDescription: 'raw turns/chunks with embeddings',
|
|
20
|
+
});
|
|
21
|
+
export const SUMMARIZED_COST = Object.freeze({
|
|
22
|
+
strategy: 'summarized',
|
|
23
|
+
avgCostPerIngest: 0.005, // one LLM summarize call per session/document
|
|
24
|
+
avgLatencyMs: 1500,
|
|
25
|
+
outputDescription: 'session/document summary prefixed to every chunk',
|
|
26
|
+
});
|
|
27
|
+
export const OBSERVATIONAL_COST = Object.freeze({
|
|
28
|
+
strategy: 'observational',
|
|
29
|
+
avgCostPerIngest: 0.020, // multi-call observation extraction
|
|
30
|
+
avgLatencyMs: 6000,
|
|
31
|
+
outputDescription: 'structured observation log replacing raw turns',
|
|
32
|
+
});
|
|
33
|
+
export const FACT_GRAPH_COST = Object.freeze({
|
|
34
|
+
strategy: 'fact-graph',
|
|
35
|
+
avgCostPerIngest: 0.015, // triple extraction
|
|
36
|
+
avgLatencyMs: 4500,
|
|
37
|
+
outputDescription: 'fact triples + entity-relation graph',
|
|
38
|
+
});
|
|
39
|
+
export const HYBRID_COST = Object.freeze({
|
|
40
|
+
strategy: 'hybrid',
|
|
41
|
+
avgCostPerIngest: 0.030, // raw + summarized + observational
|
|
42
|
+
avgLatencyMs: 8000,
|
|
43
|
+
outputDescription: 'parallel raw-chunks + summarized + observational outputs',
|
|
44
|
+
});
|
|
45
|
+
export const SKIP_COST = Object.freeze({
|
|
46
|
+
strategy: 'skip',
|
|
47
|
+
avgCostPerIngest: 0,
|
|
48
|
+
avgLatencyMs: 0,
|
|
49
|
+
outputDescription: 'content discarded; nothing written to memory',
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* Default cost-points registry. Override per workload by passing a
|
|
53
|
+
* custom map to {@link IngestRouter} at construction.
|
|
54
|
+
*/
|
|
55
|
+
export const DEFAULT_INGEST_COSTS = Object.freeze({
|
|
56
|
+
'raw-chunks': RAW_CHUNKS_COST,
|
|
57
|
+
summarized: SUMMARIZED_COST,
|
|
58
|
+
observational: OBSERVATIONAL_COST,
|
|
59
|
+
'fact-graph': FACT_GRAPH_COST,
|
|
60
|
+
hybrid: HYBRID_COST,
|
|
61
|
+
skip: SKIP_COST,
|
|
62
|
+
});
|
|
63
|
+
//# sourceMappingURL=costs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"costs.js","sourceRoot":"","sources":["../../src/ingest-router/costs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AA0BH,MAAM,CAAC,MAAM,eAAe,GAA4B,MAAM,CAAC,MAAM,CAAC;IACpE,QAAQ,EAAE,YAAqB;IAC/B,gBAAgB,EAAE,MAAM,EAAE,iBAAiB;IAC3C,YAAY,EAAE,GAAG;IACjB,iBAAiB,EAAE,kCAAkC;CACtD,CAA4B,CAAC;AAE9B,MAAM,CAAC,MAAM,eAAe,GAA4B,MAAM,CAAC,MAAM,CAAC;IACpE,QAAQ,EAAE,YAAqB;IAC/B,gBAAgB,EAAE,KAAK,EAAE,8CAA8C;IACvE,YAAY,EAAE,IAAI;IAClB,iBAAiB,EAAE,kDAAkD;CACtE,CAA4B,CAAC;AAE9B,MAAM,CAAC,MAAM,kBAAkB,GAA4B,MAAM,CAAC,MAAM,CAAC;IACvE,QAAQ,EAAE,eAAwB;IAClC,gBAAgB,EAAE,KAAK,EAAE,oCAAoC;IAC7D,YAAY,EAAE,IAAI;IAClB,iBAAiB,EAAE,gDAAgD;CACpE,CAA4B,CAAC;AAE9B,MAAM,CAAC,MAAM,eAAe,GAA4B,MAAM,CAAC,MAAM,CAAC;IACpE,QAAQ,EAAE,YAAqB;IAC/B,gBAAgB,EAAE,KAAK,EAAE,oBAAoB;IAC7C,YAAY,EAAE,IAAI;IAClB,iBAAiB,EAAE,sCAAsC;CAC1D,CAA4B,CAAC;AAE9B,MAAM,CAAC,MAAM,WAAW,GAA4B,MAAM,CAAC,MAAM,CAAC;IAChE,QAAQ,EAAE,QAAiB;IAC3B,gBAAgB,EAAE,KAAK,EAAE,mCAAmC;IAC5D,YAAY,EAAE,IAAI;IAClB,iBAAiB,EAAE,0DAA0D;CAC9E,CAA4B,CAAC;AAE9B,MAAM,CAAC,MAAM,SAAS,GAA4B,MAAM,CAAC,MAAM,CAAC;IAC9D,QAAQ,EAAE,MAAe;IACzB,gBAAgB,EAAE,CAAC;IACnB,YAAY,EAAE,CAAC;IACf,iBAAiB,EAAE,8CAA8C;CAClE,CAA4B,CAAC;AAE9B;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAE7B,MAAM,CAAC,MAAM,CAAC;IAChB,YAAY,EAAE,eAAe;IAC7B,UAAU,EAAE,eAAe;IAC3B,aAAa,EAAE,kBAAkB;IACjC,YAAY,EAAE,eAAe;IAC7B,MAAM,EAAE,WAAW;IACnB,IAAI,EAAE,SAAS;CAChB,CAAC,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file dispatcher.ts
|
|
3
|
+
* @description Backend-execution layer for {@link IngestRouter}.
|
|
4
|
+
*
|
|
5
|
+
* Same routing-table-of-functions pattern as memory-router's
|
|
6
|
+
* {@link FunctionMemoryDispatcher}. Caller registers per-strategy
|
|
7
|
+
* executors at construction; dispatcher picks the right one per call.
|
|
8
|
+
*
|
|
9
|
+
* @module @framers/agentos/ingest-router/dispatcher
|
|
10
|
+
*/
|
|
11
|
+
import type { IngestStrategyId } from './routing-tables.js';
|
|
12
|
+
export type IngestStrategyExecutor<TOutcome, TPayload = undefined> = (content: string, payload: TPayload) => Promise<TOutcome>;
|
|
13
|
+
export interface IngestDispatchArgs<TPayload = undefined> {
|
|
14
|
+
readonly strategy: IngestStrategyId;
|
|
15
|
+
readonly content: string;
|
|
16
|
+
readonly payload?: TPayload;
|
|
17
|
+
}
|
|
18
|
+
export interface IngestDispatchResult<TOutcome> {
|
|
19
|
+
readonly outcome: TOutcome;
|
|
20
|
+
readonly strategy: IngestStrategyId;
|
|
21
|
+
}
|
|
22
|
+
export interface IIngestDispatcher<TOutcome = unknown, TPayload = unknown> {
|
|
23
|
+
dispatch(args: IngestDispatchArgs<TPayload>): Promise<IngestDispatchResult<TOutcome>>;
|
|
24
|
+
}
|
|
25
|
+
export declare class UnsupportedIngestStrategyError extends Error {
|
|
26
|
+
readonly strategy: IngestStrategyId;
|
|
27
|
+
constructor(strategy: IngestStrategyId);
|
|
28
|
+
}
|
|
29
|
+
export type IngestStrategyRegistry<TOutcome, TPayload> = Partial<Record<IngestStrategyId, IngestStrategyExecutor<TOutcome, TPayload>>>;
|
|
30
|
+
export declare class FunctionIngestDispatcher<TOutcome, TPayload = undefined> implements IIngestDispatcher<TOutcome, TPayload> {
|
|
31
|
+
private readonly registry;
|
|
32
|
+
constructor(registry: IngestStrategyRegistry<TOutcome, TPayload>);
|
|
33
|
+
dispatch(args: IngestDispatchArgs<TPayload>): Promise<IngestDispatchResult<TOutcome>>;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=dispatcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatcher.d.ts","sourceRoot":"","sources":["../../src/ingest-router/dispatcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,MAAM,MAAM,sBAAsB,CAAC,QAAQ,EAAE,QAAQ,GAAG,SAAS,IAAI,CACnE,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,QAAQ,KACd,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEvB,MAAM,WAAW,kBAAkB,CAAC,QAAQ,GAAG,SAAS;IACtD,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC;CAC7B;AAED,MAAM,WAAW,oBAAoB,CAAC,QAAQ;IAC5C,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;CACrC;AAED,MAAM,WAAW,iBAAiB,CAAC,QAAQ,GAAG,OAAO,EAAE,QAAQ,GAAG,OAAO;IACvE,QAAQ,CACN,IAAI,EAAE,kBAAkB,CAAC,QAAQ,CAAC,GACjC,OAAO,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC,CAAC;CAC5C;AAED,qBAAa,8BAA+B,SAAQ,KAAK;aAC3B,QAAQ,EAAE,gBAAgB;gBAA1B,QAAQ,EAAE,gBAAgB;CAOvD;AAED,MAAM,MAAM,sBAAsB,CAAC,QAAQ,EAAE,QAAQ,IAAI,OAAO,CAC9D,MAAM,CAAC,gBAAgB,EAAE,sBAAsB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CACrE,CAAC;AAEF,qBAAa,wBAAwB,CAAC,QAAQ,EAAE,QAAQ,GAAG,SAAS,CAClE,YAAW,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAEhD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA6C;gBAE1D,QAAQ,EAAE,sBAAsB,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAI1D,QAAQ,CACZ,IAAI,EAAE,kBAAkB,CAAC,QAAQ,CAAC,GACjC,OAAO,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;CAQ3C"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file dispatcher.ts
|
|
3
|
+
* @description Backend-execution layer for {@link IngestRouter}.
|
|
4
|
+
*
|
|
5
|
+
* Same routing-table-of-functions pattern as memory-router's
|
|
6
|
+
* {@link FunctionMemoryDispatcher}. Caller registers per-strategy
|
|
7
|
+
* executors at construction; dispatcher picks the right one per call.
|
|
8
|
+
*
|
|
9
|
+
* @module @framers/agentos/ingest-router/dispatcher
|
|
10
|
+
*/
|
|
11
|
+
export class UnsupportedIngestStrategyError extends Error {
|
|
12
|
+
constructor(strategy) {
|
|
13
|
+
super(`IngestDispatcher: strategy '${strategy}' is not registered. ` +
|
|
14
|
+
`Supply an executor for this strategy at construction.`);
|
|
15
|
+
this.strategy = strategy;
|
|
16
|
+
this.name = 'UnsupportedIngestStrategyError';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export class FunctionIngestDispatcher {
|
|
20
|
+
constructor(registry) {
|
|
21
|
+
this.registry = registry;
|
|
22
|
+
}
|
|
23
|
+
async dispatch(args) {
|
|
24
|
+
const exec = this.registry[args.strategy];
|
|
25
|
+
if (!exec) {
|
|
26
|
+
throw new UnsupportedIngestStrategyError(args.strategy);
|
|
27
|
+
}
|
|
28
|
+
const outcome = await exec(args.content, args.payload);
|
|
29
|
+
return { outcome, strategy: args.strategy };
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=dispatcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatcher.js","sourceRoot":"","sources":["../../src/ingest-router/dispatcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA0BH,MAAM,OAAO,8BAA+B,SAAQ,KAAK;IACvD,YAA4B,QAA0B;QACpD,KAAK,CACH,+BAA+B,QAAQ,uBAAuB;YAC5D,uDAAuD,CAC1D,CAAC;QAJwB,aAAQ,GAAR,QAAQ,CAAkB;QAKpD,IAAI,CAAC,IAAI,GAAG,gCAAgC,CAAC;IAC/C,CAAC;CACF;AAMD,MAAM,OAAO,wBAAwB;IAKnC,YAAY,QAAoD;QAC9D,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,QAAQ,CACZ,IAAkC;QAElC,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC1C,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,8BAA8B,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC1D,CAAC;QACD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,OAAmB,CAAC,CAAC;QACnE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC9C,CAAC;CACF"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentOS IngestRouter Module
|
|
3
|
+
*
|
|
4
|
+
* Input-stage LLM-as-judge orchestrator for memory ingest. Sibling of
|
|
5
|
+
* {@link MemoryRouter} (recall-stage), {@link QueryRouter} (Q&A-stage),
|
|
6
|
+
* and the output-stage guardrails. Together they form the agentos
|
|
7
|
+
* multi-stage guardrails pattern.
|
|
8
|
+
*
|
|
9
|
+
* Where MemoryRouter picks the recall architecture for a query,
|
|
10
|
+
* IngestRouter picks the storage architecture for incoming content. The
|
|
11
|
+
* choice affects what's STORED, which downstream MemoryRouter then queries.
|
|
12
|
+
*
|
|
13
|
+
* **Architecture Overview:**
|
|
14
|
+
* ```
|
|
15
|
+
* Content stream
|
|
16
|
+
* │
|
|
17
|
+
* ▼
|
|
18
|
+
* ┌────────────────────────────────────────────────┐
|
|
19
|
+
* │ IngestRouter │
|
|
20
|
+
* │ classify content → pick strategy → store │
|
|
21
|
+
* └────────────────────────────────────────────────┘
|
|
22
|
+
* │ │ │
|
|
23
|
+
* ▼ ▼ ▼
|
|
24
|
+
* raw-chunks summarized observational
|
|
25
|
+
* fact-graph hybrid skip
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @module @framers/agentos/ingest-router
|
|
29
|
+
*/
|
|
30
|
+
export type { IngestContentKind, IngestStrategyId, IngestRouterPreset, IngestRoutingTable, } from './routing-tables.js';
|
|
31
|
+
export { INGEST_CONTENT_KINDS } from './routing-tables.js';
|
|
32
|
+
export type { IngestStrategyCostPoint } from './costs.js';
|
|
33
|
+
export type { IngestBudgetMode, IngestRouterConfig, IngestRoutingDecision, } from './select-strategy.js';
|
|
34
|
+
export type { IIngestClassifier, IIngestClassifierLLM, IngestClassifierLLMRequest, IngestClassifierLLMResponse, IngestClassifierClassifyOptions, IngestClassifierResult, LLMIngestClassifierOptions, } from './classifier.js';
|
|
35
|
+
export type { IIngestDispatcher, IngestDispatchArgs, IngestDispatchResult, IngestStrategyExecutor, IngestStrategyRegistry, } from './dispatcher.js';
|
|
36
|
+
export type { IngestBudgetPolicy, IngestRouterOptions, IngestRouterDecideOptions, IngestRouterDecision, IngestRouterDispatchedResult, } from './IngestRouter.js';
|
|
37
|
+
export { RAW_CHUNKS_TABLE, SUMMARIZED_TABLE, OBSERVATIONAL_TABLE, HYBRID_TABLE, PRESET_INGEST_TABLES, } from './routing-tables.js';
|
|
38
|
+
export { RAW_CHUNKS_COST, SUMMARIZED_COST, OBSERVATIONAL_COST, FACT_GRAPH_COST, HYBRID_COST, SKIP_COST, DEFAULT_INGEST_COSTS, } from './costs.js';
|
|
39
|
+
export { selectIngestStrategy, IngestRouterUnknownKindError, IngestRouterBudgetExceededError, } from './select-strategy.js';
|
|
40
|
+
export { INGEST_CLASSIFIER_SYSTEM_PROMPT, INGEST_CLASSIFIER_SYSTEM_PROMPT_FEWSHOT, SAFE_INGEST_FALLBACK_KIND, LLMIngestClassifier, normalizeIngestClassifierOutput, parseIngestClassifierOutput, } from './classifier.js';
|
|
41
|
+
export { FunctionIngestDispatcher, UnsupportedIngestStrategyError, } from './dispatcher.js';
|
|
42
|
+
export { IngestRouter, IngestRouterDispatcherMissingError, } from './IngestRouter.js';
|
|
43
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ingest-router/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,YAAY,EACV,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,YAAY,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAE1D,YAAY,EACV,gBAAgB,EAChB,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAE9B,YAAY,EACV,iBAAiB,EACjB,oBAAoB,EACpB,0BAA0B,EAC1B,2BAA2B,EAC3B,+BAA+B,EAC/B,sBAAsB,EACtB,0BAA0B,GAC3B,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EACV,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EACV,kBAAkB,EAClB,mBAAmB,EACnB,yBAAyB,EACzB,oBAAoB,EACpB,4BAA4B,GAC7B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,YAAY,EACZ,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,WAAW,EACX,SAAS,EACT,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,oBAAoB,EACpB,4BAA4B,EAC5B,+BAA+B,GAChC,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,+BAA+B,EAC/B,uCAAuC,EACvC,yBAAyB,EACzB,mBAAmB,EACnB,+BAA+B,EAC/B,2BAA2B,GAC5B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,wBAAwB,EACxB,8BAA8B,GAC/B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,YAAY,EACZ,kCAAkC,GACnC,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentOS IngestRouter Module
|
|
3
|
+
*
|
|
4
|
+
* Input-stage LLM-as-judge orchestrator for memory ingest. Sibling of
|
|
5
|
+
* {@link MemoryRouter} (recall-stage), {@link QueryRouter} (Q&A-stage),
|
|
6
|
+
* and the output-stage guardrails. Together they form the agentos
|
|
7
|
+
* multi-stage guardrails pattern.
|
|
8
|
+
*
|
|
9
|
+
* Where MemoryRouter picks the recall architecture for a query,
|
|
10
|
+
* IngestRouter picks the storage architecture for incoming content. The
|
|
11
|
+
* choice affects what's STORED, which downstream MemoryRouter then queries.
|
|
12
|
+
*
|
|
13
|
+
* **Architecture Overview:**
|
|
14
|
+
* ```
|
|
15
|
+
* Content stream
|
|
16
|
+
* │
|
|
17
|
+
* ▼
|
|
18
|
+
* ┌────────────────────────────────────────────────┐
|
|
19
|
+
* │ IngestRouter │
|
|
20
|
+
* │ classify content → pick strategy → store │
|
|
21
|
+
* └────────────────────────────────────────────────┘
|
|
22
|
+
* │ │ │
|
|
23
|
+
* ▼ ▼ ▼
|
|
24
|
+
* raw-chunks summarized observational
|
|
25
|
+
* fact-graph hybrid skip
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @module @framers/agentos/ingest-router
|
|
29
|
+
*/
|
|
30
|
+
export { INGEST_CONTENT_KINDS } from './routing-tables.js';
|
|
31
|
+
export { RAW_CHUNKS_TABLE, SUMMARIZED_TABLE, OBSERVATIONAL_TABLE, HYBRID_TABLE, PRESET_INGEST_TABLES, } from './routing-tables.js';
|
|
32
|
+
export { RAW_CHUNKS_COST, SUMMARIZED_COST, OBSERVATIONAL_COST, FACT_GRAPH_COST, HYBRID_COST, SKIP_COST, DEFAULT_INGEST_COSTS, } from './costs.js';
|
|
33
|
+
export { selectIngestStrategy, IngestRouterUnknownKindError, IngestRouterBudgetExceededError, } from './select-strategy.js';
|
|
34
|
+
export { INGEST_CLASSIFIER_SYSTEM_PROMPT, INGEST_CLASSIFIER_SYSTEM_PROMPT_FEWSHOT, SAFE_INGEST_FALLBACK_KIND, LLMIngestClassifier, normalizeIngestClassifierOutput, parseIngestClassifierOutput, } from './classifier.js';
|
|
35
|
+
export { FunctionIngestDispatcher, UnsupportedIngestStrategyError, } from './dispatcher.js';
|
|
36
|
+
export { IngestRouter, IngestRouterDispatcherMissingError, } from './IngestRouter.js';
|
|
37
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ingest-router/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAQH,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAoC3D,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,YAAY,EACZ,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,WAAW,EACX,SAAS,EACT,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,oBAAoB,EACpB,4BAA4B,EAC5B,+BAA+B,GAChC,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,+BAA+B,EAC/B,uCAAuC,EACvC,yBAAyB,EACzB,mBAAmB,EACnB,+BAA+B,EAC/B,2BAA2B,GAC5B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,wBAAwB,EACxB,8BAA8B,GAC/B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,YAAY,EACZ,kCAAkC,GACnC,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file routing-tables.ts
|
|
3
|
+
* @description Preset routing tables for {@link IngestRouter}.
|
|
4
|
+
*
|
|
5
|
+
* IngestRouter is the input-stage sibling of MemoryRouter. Where MemoryRouter
|
|
6
|
+
* picks the recall architecture for a query, IngestRouter picks the storage
|
|
7
|
+
* architecture for incoming content. The choice affects what's STORED, which
|
|
8
|
+
* downstream MemoryRouter then queries.
|
|
9
|
+
*
|
|
10
|
+
* Four shipping presets express different cost-vs-recall priorities:
|
|
11
|
+
*
|
|
12
|
+
* - {@link RAW_CHUNKS_TABLE}: stores everything as raw chunks. Cheapest at
|
|
13
|
+
* ingest time. Pushes all complexity to retrieval. Default for cost-
|
|
14
|
+
* sensitive workloads.
|
|
15
|
+
* - {@link SUMMARIZED_TABLE}: applies session/article summarization on long
|
|
16
|
+
* content. Anthropic-style "contextual retrieval" — every chunk gets a
|
|
17
|
+
* dense session-summary prefix before embedding.
|
|
18
|
+
* - {@link OBSERVATIONAL_TABLE}: extracts observation logs (Mastra-style)
|
|
19
|
+
* from long conversational content. Most expensive at ingest, best for
|
|
20
|
+
* multi-session synthesis recall.
|
|
21
|
+
* - {@link HYBRID_TABLE}: applies multiple ingest strategies in parallel
|
|
22
|
+
* for long content (raw chunks + summary + observations). Highest cost,
|
|
23
|
+
* highest recall flexibility — every retrieval strategy has its substrate.
|
|
24
|
+
*
|
|
25
|
+
* @module @framers/agentos/ingest-router/routing-tables
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* The six content kinds the LLM-as-judge ingest classifier can emit.
|
|
29
|
+
* Coarse taxonomy chosen to map cleanly onto distinct ingest strategies —
|
|
30
|
+
* extending the taxonomy means extending the routing tables consistently.
|
|
31
|
+
*/
|
|
32
|
+
export declare const INGEST_CONTENT_KINDS: readonly ["short-conversation", "long-conversation", "long-article", "code", "structured-data", "multimodal"];
|
|
33
|
+
export type IngestContentKind = (typeof INGEST_CONTENT_KINDS)[number];
|
|
34
|
+
/**
|
|
35
|
+
* The six storage strategies an IngestDispatcher can execute.
|
|
36
|
+
*
|
|
37
|
+
* - `raw-chunks`: standard turn-by-turn (or semantic) chunking, no LLM at
|
|
38
|
+
* ingest. The Memory.remember() default.
|
|
39
|
+
* - `summarized`: every chunk prepended with a dense session/document
|
|
40
|
+
* summary before embedding (Anthropic Sep 2024 "contextual retrieval").
|
|
41
|
+
* One LLM summarize call per session/document at ingest time.
|
|
42
|
+
* - `observational`: extract a structured observation log from the content
|
|
43
|
+
* (Mastra Observational Memory pattern). Multiple LLM extraction calls
|
|
44
|
+
* per session at ingest time. Recalled traces are observations rather
|
|
45
|
+
* than raw turns.
|
|
46
|
+
* - `fact-graph`: extract atomic fact triples from the content (Mem0-style).
|
|
47
|
+
* LLM-triple-extraction at ingest. Recall queries the fact graph.
|
|
48
|
+
* - `hybrid`: apply multiple strategies in parallel (e.g., raw-chunks +
|
|
49
|
+
* summarized + observational). Most expensive at ingest. Highest recall
|
|
50
|
+
* flexibility.
|
|
51
|
+
* - `skip`: do not ingest the content. For low-value session noise that
|
|
52
|
+
* wastes recall slots and inflates retrieval cost.
|
|
53
|
+
*/
|
|
54
|
+
export type IngestStrategyId = 'raw-chunks' | 'summarized' | 'observational' | 'fact-graph' | 'hybrid' | 'skip';
|
|
55
|
+
/**
|
|
56
|
+
* The shipping preset names. Each names a cost-vs-recall point.
|
|
57
|
+
*/
|
|
58
|
+
export type IngestRouterPreset = 'raw-chunks' | 'summarized' | 'observational' | 'hybrid';
|
|
59
|
+
/**
|
|
60
|
+
* A routing table maps every {@link IngestContentKind} to its preferred
|
|
61
|
+
* {@link IngestStrategyId}. Tables are frozen so consumers cannot mutate
|
|
62
|
+
* the routing surface from outside the module.
|
|
63
|
+
*/
|
|
64
|
+
export interface IngestRoutingTable {
|
|
65
|
+
readonly preset: IngestRouterPreset;
|
|
66
|
+
readonly defaultMapping: Readonly<Record<IngestContentKind, IngestStrategyId>>;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Preset: raw-chunks (default for cost-sensitive workloads).
|
|
70
|
+
*
|
|
71
|
+
* Stores everything as raw chunks regardless of content kind. Zero LLM
|
|
72
|
+
* cost at ingest time. All complexity is pushed to retrieval where the
|
|
73
|
+
* MemoryRouter can compose hybrid retrieval over the raw chunks.
|
|
74
|
+
*
|
|
75
|
+
* Recommended when: ingest volume is high, retrieval-side compute is
|
|
76
|
+
* cheap, and you trust the retrieval stage to do the heavy lifting.
|
|
77
|
+
*/
|
|
78
|
+
export declare const RAW_CHUNKS_TABLE: IngestRoutingTable;
|
|
79
|
+
/**
|
|
80
|
+
* Preset: summarized (contextual retrieval for long content).
|
|
81
|
+
*
|
|
82
|
+
* Long content (long-conversation, long-article) gets a session/document
|
|
83
|
+
* summary prepended to every chunk before embedding. Short content stays
|
|
84
|
+
* as raw chunks. Code and structured data are summarized for the
|
|
85
|
+
* cross-file context. Multimodal stays raw — embedding modality is
|
|
86
|
+
* orthogonal to summarization.
|
|
87
|
+
*
|
|
88
|
+
* Recommended when: documents and conversations have meaningful global
|
|
89
|
+
* context that improves retrieval recall.
|
|
90
|
+
*/
|
|
91
|
+
export declare const SUMMARIZED_TABLE: IngestRoutingTable;
|
|
92
|
+
/**
|
|
93
|
+
* Preset: observational (Mastra-style for multi-session synthesis).
|
|
94
|
+
*
|
|
95
|
+
* Long conversational content (long-conversation) becomes a structured
|
|
96
|
+
* observation log via LLM extraction at ingest. Long articles get the
|
|
97
|
+
* cheaper summarized treatment. Short content, code, structured, and
|
|
98
|
+
* multimodal stay raw.
|
|
99
|
+
*
|
|
100
|
+
* Recommended when: workload is conversational and includes many
|
|
101
|
+
* multi-session synthesis questions ("what have we agreed to so far",
|
|
102
|
+
* "across our chats, what topics recur").
|
|
103
|
+
*/
|
|
104
|
+
export declare const OBSERVATIONAL_TABLE: IngestRoutingTable;
|
|
105
|
+
/**
|
|
106
|
+
* Preset: hybrid (maximum-recall workloads).
|
|
107
|
+
*
|
|
108
|
+
* Applies multiple ingest strategies in parallel for long content. Every
|
|
109
|
+
* downstream retrieval architecture has its substrate (raw chunks for
|
|
110
|
+
* canonical hybrid, summary prefix for contextual retrieval, observation
|
|
111
|
+
* log for OM-style synthesis). Highest cost at ingest; highest flexibility
|
|
112
|
+
* at retrieval.
|
|
113
|
+
*
|
|
114
|
+
* Recommended when: cost-per-ingest is acceptable AND retrieval workload
|
|
115
|
+
* is heterogeneous enough that no single strategy dominates.
|
|
116
|
+
*/
|
|
117
|
+
export declare const HYBRID_TABLE: IngestRoutingTable;
|
|
118
|
+
/**
|
|
119
|
+
* Preset registry keyed by name.
|
|
120
|
+
*/
|
|
121
|
+
export declare const PRESET_INGEST_TABLES: Readonly<Record<IngestRouterPreset, IngestRoutingTable>>;
|
|
122
|
+
//# sourceMappingURL=routing-tables.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routing-tables.d.ts","sourceRoot":"","sources":["../../src/ingest-router/routing-tables.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAMH;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,+GAOvB,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,gBAAgB,GACxB,YAAY,GACZ,YAAY,GACZ,eAAe,GACf,YAAY,GACZ,QAAQ,GACR,MAAM,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC1B,YAAY,GACZ,YAAY,GACZ,eAAe,GACf,QAAQ,CAAC;AAEb;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;IACpC,QAAQ,CAAC,cAAc,EAAE,QAAQ,CAC/B,MAAM,CAAC,iBAAiB,EAAE,gBAAgB,CAAC,CAC5C,CAAC;CACH;AAMD;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,EAAE,kBAUP,CAAC;AAEzB;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB,EAAE,kBAUP,CAAC;AAEzB;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB,EAAE,kBAUV,CAAC;AAEzB;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,YAAY,EAAE,kBAUH,CAAC;AAEzB;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CACzC,MAAM,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAM9C,CAAC"}
|