@framers/agentos 0.5.6 → 0.5.7

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.
@@ -127,4 +127,6 @@ export { EntityRetrievalRanker, createEntityRetrievalRanker, } from './backends/
127
127
  export type { RankedCandidate, RankedCandidateWithBoost, EntityRetrievalRankerOptions, } from './backends/index.js';
128
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
129
  export type { RetrievalConfigId, RetrievalConfigSpec, } from './retrieval-config.js';
130
+ export { MIN_COST_BEST_CAT_2026_04_28_TABLE as READER_MIN_COST_BEST_CAT_2026_04_28_TABLE, MIN_COST_BEST_CAT_GPT5_TR_2026_04_29_TABLE as READER_MIN_COST_BEST_CAT_GPT5_TR_2026_04_29_TABLE, READER_ROUTER_PRESET_TABLES, ReaderRouterUnknownCategoryError, ReaderRouterUnknownPresetError, selectReader, } from './reader-router.js';
131
+ export type { ReaderTier, ReaderRouterPreset, ReaderRouterTable, } from './reader-router.js';
130
132
  //# 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,EACZ,2BAA2B,EAC3B,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC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,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;AAQ/B,OAAO,EACL,kCAAkC,IAAI,yCAAyC,EAC/E,0CAA0C,IAAI,iDAAiD,EAC/F,2BAA2B,EAC3B,gCAAgC,EAChC,8BAA8B,EAC9B,YAAY,GACb,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EACV,UAAU,EACV,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC"}
@@ -128,4 +128,10 @@ export { EntityRetrievalRanker, createEntityRetrievalRanker, } from './backends/
128
128
  // from 2026-04-26 LongMemEval-M Phase A N=54 ablation matrix)
129
129
  // ============================================================================
130
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';
131
+ // ============================================================================
132
+ // ReaderRouter (per-query reader-tier dispatch, calibrated from
133
+ // 2026-04-28 LongMemEval-S Phase B N=500 per-category gpt-4o vs
134
+ // gpt-5-mini split)
135
+ // ============================================================================
136
+ export { MIN_COST_BEST_CAT_2026_04_28_TABLE as READER_MIN_COST_BEST_CAT_2026_04_28_TABLE, MIN_COST_BEST_CAT_GPT5_TR_2026_04_29_TABLE as READER_MIN_COST_BEST_CAT_GPT5_TR_2026_04_29_TABLE, READER_ROUTER_PRESET_TABLES, ReaderRouterUnknownCategoryError, ReaderRouterUnknownPresetError, selectReader, } from './reader-router.js';
131
137
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/memory-router/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6GG;AAeH,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAuC9D,+EAA+E;AAC/E,SAAS;AACT,+EAA+E;AAE/E,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,uBAAuB,EACvB,aAAa,EACb,6BAA6B,EAC7B,mCAAmC,EACnC,2CAA2C,EAC3C,uBAAuB,EACvB,qBAAqB,EACrB,0BAA0B,EAC1B,uBAAuB,GACxB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,EACjB,4BAA4B,GAC7B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,aAAa,EACb,gCAAgC,EAChC,+BAA+B,GAChC,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,wBAAwB,EACxB,gCAAgC,EAChC,sBAAsB,EACtB,mBAAmB,EACnB,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,wBAAwB,EACxB,6BAA6B,GAC9B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,YAAY,EACZ,kCAAkC,EAClC,sCAAsC,GACvC,MAAM,mBAAmB,CAAC;AAgB3B,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,eAAe,CAAC;AAEvB,+EAA+E;AAC/E,0EAA0E;AAC1E,+EAA+E;AAE/E,OAAO,EACL,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,qBAAqB,CAAC;AAO7B,+EAA+E;AAC/E,yEAAyE;AACzE,8DAA8D;AAC9D,+EAA+E;AAE/E,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,+BAA+B,EAC/B,0BAA0B,EAC1B,0BAA0B,EAC1B,yBAAyB,EACzB,sBAAsB,EACtB,2BAA2B,GAC5B,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/memory-router/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6GG;AAeH,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAuC9D,+EAA+E;AAC/E,SAAS;AACT,+EAA+E;AAE/E,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,uBAAuB,EACvB,aAAa,EACb,6BAA6B,EAC7B,mCAAmC,EACnC,2CAA2C,EAC3C,uBAAuB,EACvB,qBAAqB,EACrB,0BAA0B,EAC1B,uBAAuB,GACxB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,EACjB,4BAA4B,GAC7B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,aAAa,EACb,gCAAgC,EAChC,+BAA+B,GAChC,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,wBAAwB,EACxB,gCAAgC,EAChC,sBAAsB,EACtB,mBAAmB,EACnB,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,wBAAwB,EACxB,6BAA6B,GAC9B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,YAAY,EACZ,kCAAkC,EAClC,sCAAsC,GACvC,MAAM,mBAAmB,CAAC;AAgB3B,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,eAAe,CAAC;AAEvB,+EAA+E;AAC/E,0EAA0E;AAC1E,+EAA+E;AAE/E,OAAO,EACL,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,qBAAqB,CAAC;AAO7B,+EAA+E;AAC/E,yEAAyE;AACzE,8DAA8D;AAC9D,+EAA+E;AAE/E,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,+BAA+B,EAC/B,0BAA0B,EAC1B,0BAA0B,EAC1B,yBAAyB,EACzB,sBAAsB,EACtB,2BAA2B,GAC5B,MAAM,uBAAuB,CAAC;AAO/B,+EAA+E;AAC/E,gEAAgE;AAChE,gEAAgE;AAChE,oBAAoB;AACpB,+EAA+E;AAE/E,OAAO,EACL,kCAAkC,IAAI,yCAAyC,EAC/E,0CAA0C,IAAI,iDAAiD,EAC/F,2BAA2B,EAC3B,gCAAgC,EAChC,8BAA8B,EAC9B,YAAY,GACb,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,155 @@
1
+ /**
2
+ * @file reader-router.ts
3
+ * @description ReaderRouter primitive — per-query reader-tier dispatch.
4
+ *
5
+ * **What this primitive does:**
6
+ *
7
+ * The shipping {@link MemoryRouter} dispatches per-query among recall
8
+ * BACKENDS (canonical-hybrid, OM-v10, OM-v11). The
9
+ * {@link RetrievalConfigRouter} dispatches per-query retrieval-CONFIG
10
+ * (canonical, hyde, topk50-mult5, etc.). The ReaderRouter completes
11
+ * the orchestration triplet by dispatching per-query among READER
12
+ * MODELS (`gpt-4o`, `gpt-5`, `gpt-5-mini`) using the same
13
+ * `gpt-5-mini` classifier output.
14
+ *
15
+ * **Why this exists:**
16
+ *
17
+ * The 2026-04-28 LongMemEval-S Phase B per-category accuracy split
18
+ * between `gpt-4o` and `gpt-5-mini` at the canonical-hybrid retrieval
19
+ * stack revealed dramatic per-category preference: `gpt-4o` wins TR
20
+ * (+11.8 pp) and SSU (+4.3 pp); `gpt-5-mini` wins SSP (+23.4 pp), and
21
+ * the rest are statistically tied with `gpt-5-mini` cheaper. A static
22
+ * always-on reader at either tier leaves ~3 pp of accuracy on the table
23
+ * vs per-category-oracle dispatch (which the gpt-5-mini classifier
24
+ * already provides through the policy router and retrieval-config
25
+ * router pipelines).
26
+ *
27
+ * **Calibration sources:**
28
+ *
29
+ * `MIN_COST_BEST_CAT_2026_04_28_TABLE` (the v1 publication preset) is
30
+ * calibrated from LongMemEval-S Phase B N=500 runs:
31
+ *
32
+ * - results/runs/2026-04-27T06-27-24-170--longmemeval-s--gpt-4o--full-cognitive--ingest.json
33
+ * - results/runs/2026-04-28T08-07-48-754--longmemeval-s--gpt-5-mini--full-cognitive--ingest.json
34
+ *
35
+ * Per-category accuracy (judge `gpt-4o-2024-08-06`, rubric 2026-04-18.1):
36
+ *
37
+ * | Category | gpt-4o | gpt-5-mini | Pick | Δ |
38
+ * | ------------------------- | -----: | ---------: | :-------- | -------- |
39
+ * | temporal-reasoning (n=133)| 84.7% | 72.9% | gpt-4o | +11.8 pp |
40
+ * | single-session-user (n=70)| 94.3% | 90.0% | gpt-4o | +4.3 pp |
41
+ * | single-session-pref (n=30)| 63.3% | 86.7% | gpt-5-mini| +23.4 pp |
42
+ * | single-session-asst (n=56)| 98.2% | 100.0% | gpt-5-mini| +1.8 pp |
43
+ * | knowledge-update (n=78)| 85.7% | 87.2% | gpt-5-mini| +1.5 pp |
44
+ * | multi-session (n=133)| 76.2% | 79.7% | gpt-5-mini| +3.5 pp |
45
+ *
46
+ * Oracle aggregate at this calibration: 435/500 = 87.0% (+3.8 pp over
47
+ * either reader alone). Realized at ~80% classifier accuracy: ~85-86%
48
+ * (validated at 85.6% Phase B N=500 with the standalone classifier).
49
+ *
50
+ * `MIN_COST_BEST_CAT_GPT5_TR_2026_04_29_TABLE` (the v1.1 follow-up)
51
+ * replaces the gpt-4o picks for TR and SSU with `gpt-5`, on Phase A
52
+ * signal of +4 pp on TR + cheaper input pricing (gpt-5 input is half
53
+ * gpt-4o's per-1K-token rate). Phase B at N=500 is the validation
54
+ * gate.
55
+ *
56
+ * **Opt-in by registration:**
57
+ *
58
+ * Consumers register only the {@link ReaderRouterPreset} they support
59
+ * in their dispatcher. The selector throws a typed error if asked for
60
+ * a category that's missing from the active preset's table — the
61
+ * shipped presets cover every {@link MemoryQueryCategory}.
62
+ *
63
+ * @module @framers/agentos/memory-router/reader-router
64
+ */
65
+ import type { MemoryQueryCategory } from './routing-tables.js';
66
+ /**
67
+ * Reader tier the router can dispatch to. Restricted to OpenAI models
68
+ * the shipped presets were calibrated against. Future presets (e.g.
69
+ * `claude-opus-4-7` + `gpt-5-mini`) would extend this union.
70
+ */
71
+ export type ReaderTier = 'gpt-4o' | 'gpt-5' | 'gpt-5-mini';
72
+ /**
73
+ * Registered preset identifier. Each preset names the calibration
74
+ * source + the date the calibration table was derived, mirroring the
75
+ * `MINIMIZE_COST_*` preset naming convention in this package.
76
+ */
77
+ export type ReaderRouterPreset = 'min-cost-best-cat-2026-04-28' | 'min-cost-best-cat-gpt5-tr-2026-04-29';
78
+ /**
79
+ * A complete reader-router calibration: every {@link MemoryQueryCategory}
80
+ * MUST map to a {@link ReaderTier}. The runtime guard in
81
+ * {@link selectReader} fires if a future table addition forgets a
82
+ * category.
83
+ */
84
+ export interface ReaderRouterTable {
85
+ readonly preset: ReaderRouterPreset;
86
+ /** Per-category reader assignment. */
87
+ readonly mapping: Readonly<Record<MemoryQueryCategory, ReaderTier>>;
88
+ }
89
+ /**
90
+ * Error thrown when {@link selectReader} is called with a category
91
+ * that is not present in the active routing table. Should never fire
92
+ * in production (TypeScript guards exhaustive {@link MemoryQueryCategory}
93
+ * at compile time), but the runtime check protects against structural
94
+ * casts and future table refactors that introduce a partial mapping.
95
+ */
96
+ export declare class ReaderRouterUnknownCategoryError extends Error {
97
+ constructor(category: string, preset: string);
98
+ }
99
+ /**
100
+ * Error thrown when {@link selectReader} is called with a preset that
101
+ * is not registered in {@link READER_ROUTER_PRESET_TABLES}. Guards
102
+ * against typos in CLI flag passthrough — `min-cost-best-cat-2026-04-27`
103
+ * (off-by-one date) would fail fast here rather than silently routing
104
+ * every case to a default reader.
105
+ */
106
+ export declare class ReaderRouterUnknownPresetError extends Error {
107
+ constructor(preset: string);
108
+ }
109
+ /**
110
+ * The MIN_COST_BEST_CAT_2026_04_28 calibration. See file header for
111
+ * the derivation table and source runs.
112
+ */
113
+ export declare const MIN_COST_BEST_CAT_2026_04_28_TABLE: ReaderRouterTable;
114
+ /**
115
+ * The MIN_COST_BEST_CAT_GPT5_TR_2026_04_29 calibration. Replaces the
116
+ * gpt-4o picks for `temporal-reasoning` and `single-session-user`
117
+ * with `gpt-5` (cheaper input than gpt-4o + Phase A signal of +4 pp
118
+ * on TR). Keeps the gpt-5-mini picks for `single-session-assistant`,
119
+ * `single-session-preference`, `knowledge-update`, and `multi-session`
120
+ * unchanged.
121
+ *
122
+ * **Calibration source:** Phase A N=54 stratified probe at
123
+ * canonical+RR + `--reader gpt-5` (no router) measured TR 88.9%
124
+ * [66.7%, 100%] vs the gpt-4o Phase B baseline 84.7% — a +4.2 pp
125
+ * point estimate at small sample. SSU was 100% at N=9 vs 94.3%
126
+ * baseline. Phase A only; Phase B at N=500 is the validation gate.
127
+ *
128
+ * **Why ship as a preset rather than defaulting:** preset is opt-in
129
+ * via the bench's `--reader-router min-cost-best-cat-gpt5-tr-2026-04-29`
130
+ * flag. Phase B may show the gpt-5 lift collapses (Phase A → Phase B
131
+ * compressions have happened repeatedly in this benchmark on small
132
+ * samples).
133
+ */
134
+ export declare const MIN_COST_BEST_CAT_GPT5_TR_2026_04_29_TABLE: ReaderRouterTable;
135
+ /**
136
+ * Registry of all calibrated reader-router tables. Adding a new
137
+ * preset means (a) extending {@link ReaderRouterPreset}, (b) defining
138
+ * a `*_TABLE` const with the calibration, (c) adding the entry here.
139
+ * Frozen at module load.
140
+ */
141
+ export declare const READER_ROUTER_PRESET_TABLES: Readonly<Record<ReaderRouterPreset, ReaderRouterTable>>;
142
+ /**
143
+ * Pick a reader tier for a given predicted category under a calibration
144
+ * preset. Stateless. Deterministic. No I/O. Suitable for use inside
145
+ * cache-key construction and hot dispatch loops.
146
+ *
147
+ * @throws {ReaderRouterUnknownPresetError} when `preset` is not in
148
+ * {@link READER_ROUTER_PRESET_TABLES}.
149
+ * @throws {ReaderRouterUnknownCategoryError} when the table for
150
+ * `preset` is missing an entry for `category`. (Defensive runtime
151
+ * guard; not reachable through the type system on a properly-
152
+ * constructed table.)
153
+ */
154
+ export declare function selectReader(category: MemoryQueryCategory, preset: ReaderRouterPreset): ReaderTier;
155
+ //# sourceMappingURL=reader-router.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reader-router.d.ts","sourceRoot":"","sources":["../../src/memory-router/reader-router.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE/D;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,OAAO,GAAG,YAAY,CAAC;AAE3D;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAC1B,8BAA8B,GAC9B,sCAAsC,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;IACpC,sCAAsC;IACtC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,mBAAmB,EAAE,UAAU,CAAC,CAAC,CAAC;CACrE;AAED;;;;;;GAMG;AACH,qBAAa,gCAAiC,SAAQ,KAAK;gBAC7C,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAM7C;AAED;;;;;;GAMG;AACH,qBAAa,8BAA+B,SAAQ,KAAK;gBAC3C,MAAM,EAAE,MAAM;CAO3B;AAED;;;GAGG;AACH,eAAO,MAAM,kCAAkC,EAAE,iBAU1B,CAAC;AAExB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,0CAA0C,EAAE,iBAUlC,CAAC;AAExB;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAChD,MAAM,CAAC,kBAAkB,EAAE,iBAAiB,CAAC,CAI7C,CAAC;AAEH;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,mBAAmB,EAC7B,MAAM,EAAE,kBAAkB,GACzB,UAAU,CAUZ"}
@@ -0,0 +1,171 @@
1
+ /**
2
+ * @file reader-router.ts
3
+ * @description ReaderRouter primitive — per-query reader-tier dispatch.
4
+ *
5
+ * **What this primitive does:**
6
+ *
7
+ * The shipping {@link MemoryRouter} dispatches per-query among recall
8
+ * BACKENDS (canonical-hybrid, OM-v10, OM-v11). The
9
+ * {@link RetrievalConfigRouter} dispatches per-query retrieval-CONFIG
10
+ * (canonical, hyde, topk50-mult5, etc.). The ReaderRouter completes
11
+ * the orchestration triplet by dispatching per-query among READER
12
+ * MODELS (`gpt-4o`, `gpt-5`, `gpt-5-mini`) using the same
13
+ * `gpt-5-mini` classifier output.
14
+ *
15
+ * **Why this exists:**
16
+ *
17
+ * The 2026-04-28 LongMemEval-S Phase B per-category accuracy split
18
+ * between `gpt-4o` and `gpt-5-mini` at the canonical-hybrid retrieval
19
+ * stack revealed dramatic per-category preference: `gpt-4o` wins TR
20
+ * (+11.8 pp) and SSU (+4.3 pp); `gpt-5-mini` wins SSP (+23.4 pp), and
21
+ * the rest are statistically tied with `gpt-5-mini` cheaper. A static
22
+ * always-on reader at either tier leaves ~3 pp of accuracy on the table
23
+ * vs per-category-oracle dispatch (which the gpt-5-mini classifier
24
+ * already provides through the policy router and retrieval-config
25
+ * router pipelines).
26
+ *
27
+ * **Calibration sources:**
28
+ *
29
+ * `MIN_COST_BEST_CAT_2026_04_28_TABLE` (the v1 publication preset) is
30
+ * calibrated from LongMemEval-S Phase B N=500 runs:
31
+ *
32
+ * - results/runs/2026-04-27T06-27-24-170--longmemeval-s--gpt-4o--full-cognitive--ingest.json
33
+ * - results/runs/2026-04-28T08-07-48-754--longmemeval-s--gpt-5-mini--full-cognitive--ingest.json
34
+ *
35
+ * Per-category accuracy (judge `gpt-4o-2024-08-06`, rubric 2026-04-18.1):
36
+ *
37
+ * | Category | gpt-4o | gpt-5-mini | Pick | Δ |
38
+ * | ------------------------- | -----: | ---------: | :-------- | -------- |
39
+ * | temporal-reasoning (n=133)| 84.7% | 72.9% | gpt-4o | +11.8 pp |
40
+ * | single-session-user (n=70)| 94.3% | 90.0% | gpt-4o | +4.3 pp |
41
+ * | single-session-pref (n=30)| 63.3% | 86.7% | gpt-5-mini| +23.4 pp |
42
+ * | single-session-asst (n=56)| 98.2% | 100.0% | gpt-5-mini| +1.8 pp |
43
+ * | knowledge-update (n=78)| 85.7% | 87.2% | gpt-5-mini| +1.5 pp |
44
+ * | multi-session (n=133)| 76.2% | 79.7% | gpt-5-mini| +3.5 pp |
45
+ *
46
+ * Oracle aggregate at this calibration: 435/500 = 87.0% (+3.8 pp over
47
+ * either reader alone). Realized at ~80% classifier accuracy: ~85-86%
48
+ * (validated at 85.6% Phase B N=500 with the standalone classifier).
49
+ *
50
+ * `MIN_COST_BEST_CAT_GPT5_TR_2026_04_29_TABLE` (the v1.1 follow-up)
51
+ * replaces the gpt-4o picks for TR and SSU with `gpt-5`, on Phase A
52
+ * signal of +4 pp on TR + cheaper input pricing (gpt-5 input is half
53
+ * gpt-4o's per-1K-token rate). Phase B at N=500 is the validation
54
+ * gate.
55
+ *
56
+ * **Opt-in by registration:**
57
+ *
58
+ * Consumers register only the {@link ReaderRouterPreset} they support
59
+ * in their dispatcher. The selector throws a typed error if asked for
60
+ * a category that's missing from the active preset's table — the
61
+ * shipped presets cover every {@link MemoryQueryCategory}.
62
+ *
63
+ * @module @framers/agentos/memory-router/reader-router
64
+ */
65
+ /**
66
+ * Error thrown when {@link selectReader} is called with a category
67
+ * that is not present in the active routing table. Should never fire
68
+ * in production (TypeScript guards exhaustive {@link MemoryQueryCategory}
69
+ * at compile time), but the runtime check protects against structural
70
+ * casts and future table refactors that introduce a partial mapping.
71
+ */
72
+ export class ReaderRouterUnknownCategoryError extends Error {
73
+ constructor(category, preset) {
74
+ super(`ReaderRouter: category '${category}' not in routing table for preset '${preset}'`);
75
+ this.name = 'ReaderRouterUnknownCategoryError';
76
+ }
77
+ }
78
+ /**
79
+ * Error thrown when {@link selectReader} is called with a preset that
80
+ * is not registered in {@link READER_ROUTER_PRESET_TABLES}. Guards
81
+ * against typos in CLI flag passthrough — `min-cost-best-cat-2026-04-27`
82
+ * (off-by-one date) would fail fast here rather than silently routing
83
+ * every case to a default reader.
84
+ */
85
+ export class ReaderRouterUnknownPresetError extends Error {
86
+ constructor(preset) {
87
+ super(`ReaderRouter: preset '${preset}' is not registered. ` +
88
+ `Known presets: ${Object.keys(READER_ROUTER_PRESET_TABLES).join(', ')}`);
89
+ this.name = 'ReaderRouterUnknownPresetError';
90
+ }
91
+ }
92
+ /**
93
+ * The MIN_COST_BEST_CAT_2026_04_28 calibration. See file header for
94
+ * the derivation table and source runs.
95
+ */
96
+ export const MIN_COST_BEST_CAT_2026_04_28_TABLE = Object.freeze({
97
+ preset: 'min-cost-best-cat-2026-04-28',
98
+ mapping: Object.freeze({
99
+ 'temporal-reasoning': 'gpt-4o',
100
+ 'single-session-user': 'gpt-4o',
101
+ 'single-session-preference': 'gpt-5-mini',
102
+ 'single-session-assistant': 'gpt-5-mini',
103
+ 'knowledge-update': 'gpt-5-mini',
104
+ 'multi-session': 'gpt-5-mini',
105
+ }),
106
+ });
107
+ /**
108
+ * The MIN_COST_BEST_CAT_GPT5_TR_2026_04_29 calibration. Replaces the
109
+ * gpt-4o picks for `temporal-reasoning` and `single-session-user`
110
+ * with `gpt-5` (cheaper input than gpt-4o + Phase A signal of +4 pp
111
+ * on TR). Keeps the gpt-5-mini picks for `single-session-assistant`,
112
+ * `single-session-preference`, `knowledge-update`, and `multi-session`
113
+ * unchanged.
114
+ *
115
+ * **Calibration source:** Phase A N=54 stratified probe at
116
+ * canonical+RR + `--reader gpt-5` (no router) measured TR 88.9%
117
+ * [66.7%, 100%] vs the gpt-4o Phase B baseline 84.7% — a +4.2 pp
118
+ * point estimate at small sample. SSU was 100% at N=9 vs 94.3%
119
+ * baseline. Phase A only; Phase B at N=500 is the validation gate.
120
+ *
121
+ * **Why ship as a preset rather than defaulting:** preset is opt-in
122
+ * via the bench's `--reader-router min-cost-best-cat-gpt5-tr-2026-04-29`
123
+ * flag. Phase B may show the gpt-5 lift collapses (Phase A → Phase B
124
+ * compressions have happened repeatedly in this benchmark on small
125
+ * samples).
126
+ */
127
+ export const MIN_COST_BEST_CAT_GPT5_TR_2026_04_29_TABLE = Object.freeze({
128
+ preset: 'min-cost-best-cat-gpt5-tr-2026-04-29',
129
+ mapping: Object.freeze({
130
+ 'temporal-reasoning': 'gpt-5',
131
+ 'single-session-user': 'gpt-5',
132
+ 'single-session-preference': 'gpt-5-mini',
133
+ 'single-session-assistant': 'gpt-5-mini',
134
+ 'knowledge-update': 'gpt-5-mini',
135
+ 'multi-session': 'gpt-5-mini',
136
+ }),
137
+ });
138
+ /**
139
+ * Registry of all calibrated reader-router tables. Adding a new
140
+ * preset means (a) extending {@link ReaderRouterPreset}, (b) defining
141
+ * a `*_TABLE` const with the calibration, (c) adding the entry here.
142
+ * Frozen at module load.
143
+ */
144
+ export const READER_ROUTER_PRESET_TABLES = Object.freeze({
145
+ 'min-cost-best-cat-2026-04-28': MIN_COST_BEST_CAT_2026_04_28_TABLE,
146
+ 'min-cost-best-cat-gpt5-tr-2026-04-29': MIN_COST_BEST_CAT_GPT5_TR_2026_04_29_TABLE,
147
+ });
148
+ /**
149
+ * Pick a reader tier for a given predicted category under a calibration
150
+ * preset. Stateless. Deterministic. No I/O. Suitable for use inside
151
+ * cache-key construction and hot dispatch loops.
152
+ *
153
+ * @throws {ReaderRouterUnknownPresetError} when `preset` is not in
154
+ * {@link READER_ROUTER_PRESET_TABLES}.
155
+ * @throws {ReaderRouterUnknownCategoryError} when the table for
156
+ * `preset` is missing an entry for `category`. (Defensive runtime
157
+ * guard; not reachable through the type system on a properly-
158
+ * constructed table.)
159
+ */
160
+ export function selectReader(category, preset) {
161
+ const table = READER_ROUTER_PRESET_TABLES[preset];
162
+ if (!table) {
163
+ throw new ReaderRouterUnknownPresetError(preset);
164
+ }
165
+ const reader = table.mapping[category];
166
+ if (!reader) {
167
+ throw new ReaderRouterUnknownCategoryError(category, preset);
168
+ }
169
+ return reader;
170
+ }
171
+ //# sourceMappingURL=reader-router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reader-router.js","sourceRoot":"","sources":["../../src/memory-router/reader-router.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AAgCH;;;;;;GAMG;AACH,MAAM,OAAO,gCAAiC,SAAQ,KAAK;IACzD,YAAY,QAAgB,EAAE,MAAc;QAC1C,KAAK,CACH,2BAA2B,QAAQ,sCAAsC,MAAM,GAAG,CACnF,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,kCAAkC,CAAC;IACjD,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,OAAO,8BAA+B,SAAQ,KAAK;IACvD,YAAY,MAAc;QACxB,KAAK,CACH,yBAAyB,MAAM,uBAAuB;YACpD,kBAAkB,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC1E,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,gCAAgC,CAAC;IAC/C,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAsB,MAAM,CAAC,MAAM,CAAC;IACjF,MAAM,EAAE,8BAAuC;IAC/C,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC;QACrB,oBAAoB,EAAE,QAAiB;QACvC,qBAAqB,EAAE,QAAiB;QACxC,2BAA2B,EAAE,YAAqB;QAClD,0BAA0B,EAAE,YAAqB;QACjD,kBAAkB,EAAE,YAAqB;QACzC,eAAe,EAAE,YAAqB;KACvC,CAAC;CACH,CAAsB,CAAC;AAExB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,0CAA0C,GAAsB,MAAM,CAAC,MAAM,CAAC;IACzF,MAAM,EAAE,sCAA+C;IACvD,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC;QACrB,oBAAoB,EAAE,OAAgB;QACtC,qBAAqB,EAAE,OAAgB;QACvC,2BAA2B,EAAE,YAAqB;QAClD,0BAA0B,EAAE,YAAqB;QACjD,kBAAkB,EAAE,YAAqB;QACzC,eAAe,EAAE,YAAqB;KACvC,CAAC;CACH,CAAsB,CAAC;AAExB;;;;;GAKG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAEpC,MAAM,CAAC,MAAM,CAAC;IAChB,8BAA8B,EAAE,kCAAkC;IAClE,sCAAsC,EAAE,0CAA0C;CACnF,CAAC,CAAC;AAEH;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,YAAY,CAC1B,QAA6B,EAC7B,MAA0B;IAE1B,MAAM,KAAK,GAAG,2BAA2B,CAAC,MAAM,CAAC,CAAC;IAClD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,8BAA8B,CAAC,MAAM,CAAC,CAAC;IACnD,CAAC;IACD,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACvC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,gCAAgC,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC/D,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@framers/agentos",
3
- "version": "0.5.6",
3
+ "version": "0.5.7",
4
4
  "description": "Modular AgentOS orchestration library",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",