@framers/agentos 0.3.1 → 0.3.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/store/Brain.d.ts +13 -0
- package/dist/memory/retrieval/store/Brain.d.ts.map +1 -1
- package/dist/memory/retrieval/store/Brain.js +35 -21
- package/dist/memory/retrieval/store/Brain.js.map +1 -1
- package/dist/memory/retrieval/store/migrations/MigrationRunner.d.ts +6 -0
- package/dist/memory/retrieval/store/migrations/MigrationRunner.d.ts.map +1 -1
- package/dist/memory/retrieval/store/migrations/MigrationRunner.js +24 -0
- package/dist/memory/retrieval/store/migrations/MigrationRunner.js.map +1 -1
- package/dist/memory/retrieval/store/postgresPasswordRedaction.d.ts +17 -0
- package/dist/memory/retrieval/store/postgresPasswordRedaction.d.ts.map +1 -0
- package/dist/memory/retrieval/store/postgresPasswordRedaction.js +26 -0
- package/dist/memory/retrieval/store/postgresPasswordRedaction.js.map +1 -0
- package/dist/memory/retrieval/typed-network/FourWayRrf.d.ts +51 -0
- package/dist/memory/retrieval/typed-network/FourWayRrf.d.ts.map +1 -0
- package/dist/memory/retrieval/typed-network/FourWayRrf.js +47 -0
- package/dist/memory/retrieval/typed-network/FourWayRrf.js.map +1 -0
- package/dist/memory/retrieval/typed-network/TemporalIntervalOverlap.d.ts +34 -0
- package/dist/memory/retrieval/typed-network/TemporalIntervalOverlap.d.ts.map +1 -0
- package/dist/memory/retrieval/typed-network/TemporalIntervalOverlap.js +86 -0
- package/dist/memory/retrieval/typed-network/TemporalIntervalOverlap.js.map +1 -0
- package/dist/memory/retrieval/typed-network/TypedNetworkObserver.d.ts +67 -0
- package/dist/memory/retrieval/typed-network/TypedNetworkObserver.d.ts.map +1 -0
- package/dist/memory/retrieval/typed-network/TypedNetworkObserver.js +80 -0
- package/dist/memory/retrieval/typed-network/TypedNetworkObserver.js.map +1 -0
- package/dist/memory/retrieval/typed-network/TypedNetworkStore.d.ts +83 -0
- package/dist/memory/retrieval/typed-network/TypedNetworkStore.d.ts.map +1 -0
- package/dist/memory/retrieval/typed-network/TypedNetworkStore.js +109 -0
- package/dist/memory/retrieval/typed-network/TypedNetworkStore.js.map +1 -0
- package/dist/memory/retrieval/typed-network/TypedSpreadingActivation.d.ts +80 -0
- package/dist/memory/retrieval/typed-network/TypedSpreadingActivation.d.ts.map +1 -0
- package/dist/memory/retrieval/typed-network/TypedSpreadingActivation.js +97 -0
- package/dist/memory/retrieval/typed-network/TypedSpreadingActivation.js.map +1 -0
- package/dist/memory/retrieval/typed-network/index.d.ts +18 -0
- package/dist/memory/retrieval/typed-network/index.d.ts.map +1 -0
- package/dist/memory/retrieval/typed-network/index.js +18 -0
- package/dist/memory/retrieval/typed-network/index.js.map +1 -0
- package/dist/memory/retrieval/typed-network/prompts/extraction-prompt.d.ts +30 -0
- package/dist/memory/retrieval/typed-network/prompts/extraction-prompt.d.ts.map +1 -0
- package/dist/memory/retrieval/typed-network/prompts/extraction-prompt.js +47 -0
- package/dist/memory/retrieval/typed-network/prompts/extraction-prompt.js.map +1 -0
- package/dist/memory/retrieval/typed-network/prompts/extraction-schema.d.ts +71 -0
- package/dist/memory/retrieval/typed-network/prompts/extraction-schema.d.ts.map +1 -0
- package/dist/memory/retrieval/typed-network/prompts/extraction-schema.js +39 -0
- package/dist/memory/retrieval/typed-network/prompts/extraction-schema.js.map +1 -0
- package/dist/memory/retrieval/typed-network/types.d.ts +123 -0
- package/dist/memory/retrieval/typed-network/types.d.ts.map +1 -0
- package/dist/memory/retrieval/typed-network/types.js +48 -0
- package/dist/memory/retrieval/typed-network/types.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file extraction-prompt.ts
|
|
3
|
+
* @description The 6-step extraction prompt for the Hindsight 4-network
|
|
4
|
+
* typed observer. The system prompt defines the six decomposition
|
|
5
|
+
* steps verbatim from Hindsight §2.3 (coreference resolution, temporal
|
|
6
|
+
* normalization, participant attribution, reasoning preservation, fact
|
|
7
|
+
* type classification, entity extraction). The user prompt frames the
|
|
8
|
+
* conversation as a single block and asks the model to emit structured
|
|
9
|
+
* JSON conforming to {@link TypedExtractionSchema}.
|
|
10
|
+
*
|
|
11
|
+
* @module @framers/agentos/memory/retrieval/typed-network/prompts/extraction-prompt
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* System prompt for the 6-step extraction. Verbatim from Hindsight
|
|
15
|
+
* §2.3 with one omission: the spec doesn't include the "do not
|
|
16
|
+
* commentate" line, but the LLM tends to drift into prose without it,
|
|
17
|
+
* which breaks JSON parsing. Included.
|
|
18
|
+
*/
|
|
19
|
+
export const TYPED_EXTRACTION_SYSTEM_PROMPT = `You are an information extractor for a typed memory network. Process the conversation below into structured facts.
|
|
20
|
+
|
|
21
|
+
For each fact, perform these six steps:
|
|
22
|
+
|
|
23
|
+
1. COREFERENCE: resolve "he/she/they/it/this/that" to the actual referent.
|
|
24
|
+
2. TEMPORAL: normalize times to ISO 8601. Extract ranges as (start, end) when applicable.
|
|
25
|
+
3. PARTICIPANTS: list every named participant and their role.
|
|
26
|
+
4. REASONING: preserve any explicit reasoning marker (because, since, therefore, etc.) verbatim.
|
|
27
|
+
5. FACT TYPE: classify into ONE of:
|
|
28
|
+
- WORLD: objective facts about the external world
|
|
29
|
+
- EXPERIENCE: biographical / first-person events
|
|
30
|
+
- OPINION: claims with confidence < 1.0
|
|
31
|
+
- OBSERVATION: preference-neutral summaries of entities
|
|
32
|
+
6. ENTITIES: list every named entity (proper nouns, organizations, places, products).
|
|
33
|
+
|
|
34
|
+
Output JSON matching the schema strictly. Do not add commentary.`;
|
|
35
|
+
/**
|
|
36
|
+
* Build the user prompt for a single conversation block. Wraps the
|
|
37
|
+
* source text in delimiters that resist accidental inline-injection
|
|
38
|
+
* if the conversation contains JSON-looking content.
|
|
39
|
+
*
|
|
40
|
+
* @param sessionText - The conversation text to extract from. Whole
|
|
41
|
+
* session passed as one block; the model decomposes per turn
|
|
42
|
+
* internally.
|
|
43
|
+
*/
|
|
44
|
+
export function buildExtractionUserPrompt(sessionText) {
|
|
45
|
+
return `CONVERSATION:\n<<<\n${sessionText}\n>>>`;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=extraction-prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extraction-prompt.js","sourceRoot":"","sources":["../../../../../src/memory/retrieval/typed-network/prompts/extraction-prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG;;;;;;;;;;;;;;;iEAemB,CAAC;AAElE;;;;;;;;GAQG;AACH,MAAM,UAAU,yBAAyB,CAAC,WAAmB;IAC3D,OAAO,uBAAuB,WAAW,OAAO,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file extraction-schema.ts
|
|
3
|
+
* @description Zod schema for parsing the LLM's structured-output
|
|
4
|
+
* response in the typed-network extraction pipeline. Mirrors
|
|
5
|
+
* {@link TypedFact} fields but uses snake_case for the LLM API
|
|
6
|
+
* boundary (LLMs tend to emit snake_case more reliably than
|
|
7
|
+
* camelCase). The {@link TypedNetworkObserver} translates from this
|
|
8
|
+
* schema's snake_case shape to the camelCase TypedFact at construction
|
|
9
|
+
* time.
|
|
10
|
+
*
|
|
11
|
+
* @module @framers/agentos/memory/retrieval/typed-network/prompts/extraction-schema
|
|
12
|
+
*/
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
/**
|
|
15
|
+
* Schema for one extracted fact, matching the LLM's expected output.
|
|
16
|
+
* `confidence` defaults to 1.0 when missing — the schema permits
|
|
17
|
+
* omission for non-Opinion facts where the value is structurally 1.0.
|
|
18
|
+
*/
|
|
19
|
+
export declare const TypedExtractionFactSchema: z.ZodObject<{
|
|
20
|
+
text: z.ZodString;
|
|
21
|
+
bank: z.ZodEnum<{
|
|
22
|
+
WORLD: "WORLD";
|
|
23
|
+
EXPERIENCE: "EXPERIENCE";
|
|
24
|
+
OPINION: "OPINION";
|
|
25
|
+
OBSERVATION: "OBSERVATION";
|
|
26
|
+
}>;
|
|
27
|
+
temporal: z.ZodObject<{
|
|
28
|
+
start: z.ZodOptional<z.ZodString>;
|
|
29
|
+
end: z.ZodOptional<z.ZodString>;
|
|
30
|
+
mention: z.ZodString;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
participants: z.ZodArray<z.ZodObject<{
|
|
33
|
+
name: z.ZodString;
|
|
34
|
+
role: z.ZodString;
|
|
35
|
+
}, z.core.$strip>>;
|
|
36
|
+
reasoning_markers: z.ZodArray<z.ZodString>;
|
|
37
|
+
entities: z.ZodArray<z.ZodString>;
|
|
38
|
+
confidence: z.ZodDefault<z.ZodNumber>;
|
|
39
|
+
}, z.core.$strip>;
|
|
40
|
+
/**
|
|
41
|
+
* Top-level schema. Wraps the fact array under a `facts` key so the
|
|
42
|
+
* LLM has a stable structural anchor to emit against.
|
|
43
|
+
*/
|
|
44
|
+
export declare const TypedExtractionSchema: z.ZodObject<{
|
|
45
|
+
facts: z.ZodArray<z.ZodObject<{
|
|
46
|
+
text: z.ZodString;
|
|
47
|
+
bank: z.ZodEnum<{
|
|
48
|
+
WORLD: "WORLD";
|
|
49
|
+
EXPERIENCE: "EXPERIENCE";
|
|
50
|
+
OPINION: "OPINION";
|
|
51
|
+
OBSERVATION: "OBSERVATION";
|
|
52
|
+
}>;
|
|
53
|
+
temporal: z.ZodObject<{
|
|
54
|
+
start: z.ZodOptional<z.ZodString>;
|
|
55
|
+
end: z.ZodOptional<z.ZodString>;
|
|
56
|
+
mention: z.ZodString;
|
|
57
|
+
}, z.core.$strip>;
|
|
58
|
+
participants: z.ZodArray<z.ZodObject<{
|
|
59
|
+
name: z.ZodString;
|
|
60
|
+
role: z.ZodString;
|
|
61
|
+
}, z.core.$strip>>;
|
|
62
|
+
reasoning_markers: z.ZodArray<z.ZodString>;
|
|
63
|
+
entities: z.ZodArray<z.ZodString>;
|
|
64
|
+
confidence: z.ZodDefault<z.ZodNumber>;
|
|
65
|
+
}, z.core.$strip>>;
|
|
66
|
+
}, z.core.$strip>;
|
|
67
|
+
/** TypeScript type inferred from {@link TypedExtractionSchema}. */
|
|
68
|
+
export type TypedExtractionOutput = z.infer<typeof TypedExtractionSchema>;
|
|
69
|
+
/** Per-fact type inferred from {@link TypedExtractionFactSchema}. */
|
|
70
|
+
export type TypedExtractionFact = z.infer<typeof TypedExtractionFactSchema>;
|
|
71
|
+
//# sourceMappingURL=extraction-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extraction-schema.d.ts","sourceRoot":"","sources":["../../../../../src/memory/retrieval/typed-network/prompts/extraction-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;GAIG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;iBAcpC,CAAC;AAEH;;;GAGG;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"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file extraction-schema.ts
|
|
3
|
+
* @description Zod schema for parsing the LLM's structured-output
|
|
4
|
+
* response in the typed-network extraction pipeline. Mirrors
|
|
5
|
+
* {@link TypedFact} fields but uses snake_case for the LLM API
|
|
6
|
+
* boundary (LLMs tend to emit snake_case more reliably than
|
|
7
|
+
* camelCase). The {@link TypedNetworkObserver} translates from this
|
|
8
|
+
* schema's snake_case shape to the camelCase TypedFact at construction
|
|
9
|
+
* time.
|
|
10
|
+
*
|
|
11
|
+
* @module @framers/agentos/memory/retrieval/typed-network/prompts/extraction-schema
|
|
12
|
+
*/
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
/**
|
|
15
|
+
* Schema for one extracted fact, matching the LLM's expected output.
|
|
16
|
+
* `confidence` defaults to 1.0 when missing — the schema permits
|
|
17
|
+
* omission for non-Opinion facts where the value is structurally 1.0.
|
|
18
|
+
*/
|
|
19
|
+
export const TypedExtractionFactSchema = z.object({
|
|
20
|
+
text: z.string().min(1),
|
|
21
|
+
bank: z.enum(['WORLD', 'EXPERIENCE', 'OPINION', 'OBSERVATION']),
|
|
22
|
+
temporal: z.object({
|
|
23
|
+
start: z.string().optional(),
|
|
24
|
+
end: z.string().optional(),
|
|
25
|
+
mention: z.string(),
|
|
26
|
+
}),
|
|
27
|
+
participants: z.array(z.object({ name: z.string(), role: z.string() })),
|
|
28
|
+
reasoning_markers: z.array(z.string()),
|
|
29
|
+
entities: z.array(z.string()),
|
|
30
|
+
confidence: z.number().min(0).max(1).default(1.0),
|
|
31
|
+
});
|
|
32
|
+
/**
|
|
33
|
+
* Top-level schema. Wraps the fact array under a `facts` key so the
|
|
34
|
+
* LLM has a stable structural anchor to emit against.
|
|
35
|
+
*/
|
|
36
|
+
export const TypedExtractionSchema = z.object({
|
|
37
|
+
facts: z.array(TypedExtractionFactSchema),
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=extraction-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extraction-schema.js","sourceRoot":"","sources":["../../../../../src/memory/retrieval/typed-network/prompts/extraction-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;GAIG;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,IAAI,CAAC,CAAC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;IAC/D,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC;QACjB,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;KACpB,CAAC;IACF,YAAY,EAAE,CAAC,CAAC,KAAK,CACnB,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CACjD;IACD,iBAAiB,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACtC,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAC7B,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;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,yBAAyB,CAAC;CAC1C,CAAC,CAAC"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file types.ts
|
|
3
|
+
* @description Core types for the Hindsight 4-network typed observer.
|
|
4
|
+
* Each fact lives in one of four typed banks: World (objective external
|
|
5
|
+
* facts), Experience (first-person biographical), Opinion (claims with
|
|
6
|
+
* confidence < 1), Observation (preference-neutral entity summaries).
|
|
7
|
+
*
|
|
8
|
+
* The schema follows Hindsight paper Equation 1
|
|
9
|
+
* (arxiv.org/html/2512.12818v1 §2.1):
|
|
10
|
+
*
|
|
11
|
+
* f = (u, b, t, v, τs, τe, τm, ℓ, c, x)
|
|
12
|
+
*
|
|
13
|
+
* mapped to TypeScript field names below. See spec
|
|
14
|
+
* `packages/agentos-bench/docs/specs/2026-04-26-hindsight-4network-observer-design.md`
|
|
15
|
+
* §2.1-§2.2 for the verbatim definition.
|
|
16
|
+
*
|
|
17
|
+
* @module @framers/agentos/memory/retrieval/typed-network/types
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Bank identifier — one of four typed networks per Hindsight §2.2. The
|
|
21
|
+
* bank determines retrieval semantics: World facts compose under
|
|
22
|
+
* objective truth, Experience under first-person continuity, Opinion
|
|
23
|
+
* under belief evolution, Observation under entity descriptions.
|
|
24
|
+
*/
|
|
25
|
+
export declare const BANK_IDS: readonly ["WORLD", "EXPERIENCE", "OPINION", "OBSERVATION"];
|
|
26
|
+
/** {@link BANK_IDS} as a TypeScript literal type. */
|
|
27
|
+
export type BankId = (typeof BANK_IDS)[number];
|
|
28
|
+
/**
|
|
29
|
+
* Type guard: narrows an arbitrary string to {@link BankId}. Use to
|
|
30
|
+
* validate untrusted inputs (LLM extraction output, deserialized
|
|
31
|
+
* persistence) before routing into the typed network.
|
|
32
|
+
*/
|
|
33
|
+
export declare function isBankId(s: string): s is BankId;
|
|
34
|
+
/**
|
|
35
|
+
* Edge kind in the typed-network graph. Each kind carries a different
|
|
36
|
+
* spreading-activation multiplier μ(ℓ) per Hindsight Eq. 12 (§2.4.1).
|
|
37
|
+
*
|
|
38
|
+
* - **temporal**: connects facts that share an occurrence-interval
|
|
39
|
+
* overlap. Weight derived from `exp(−Δt / σt)`.
|
|
40
|
+
* - **semantic**: connects facts whose embeddings exceed a cosine
|
|
41
|
+
* threshold θs.
|
|
42
|
+
* - **entity**: bidirectional link between facts mentioning the same
|
|
43
|
+
* named entity. Weight 1.0.
|
|
44
|
+
* - **causal**: explicit reasoning marker linking premise → conclusion
|
|
45
|
+
* facts. LLM-extracted at observation time; weight 1.0.
|
|
46
|
+
*/
|
|
47
|
+
export declare const EDGE_KINDS: readonly ["temporal", "semantic", "entity", "causal"];
|
|
48
|
+
/** {@link EDGE_KINDS} as a TypeScript literal type. */
|
|
49
|
+
export type EdgeKind = (typeof EDGE_KINDS)[number];
|
|
50
|
+
/**
|
|
51
|
+
* Single named participant in a fact (e.g. "Alice", "the deployment
|
|
52
|
+
* server"). Roles match the participant's grammatical / conversational
|
|
53
|
+
* function — speaker, addressee, subject, object, etc.
|
|
54
|
+
*/
|
|
55
|
+
export interface Participant {
|
|
56
|
+
/** Resolved name (after coreference). */
|
|
57
|
+
name: string;
|
|
58
|
+
/** Conversational or semantic role. */
|
|
59
|
+
role: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Temporal envelope per Hindsight Eq. 1 fields τs, τe, τm. ISO 8601
|
|
63
|
+
* strings; missing `start` / `end` indicates an instant rather than an
|
|
64
|
+
* interval. `mention` is always populated — it's the timestamp at
|
|
65
|
+
* which the fact was authored.
|
|
66
|
+
*/
|
|
67
|
+
export interface FactTemporal {
|
|
68
|
+
/** Interval start (inclusive). ISO 8601. Optional for instant facts. */
|
|
69
|
+
start?: string;
|
|
70
|
+
/** Interval end (inclusive). ISO 8601. Optional for instant facts. */
|
|
71
|
+
end?: string;
|
|
72
|
+
/** Mention timestamp — when the fact was first authored. ISO 8601. */
|
|
73
|
+
mention: string;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* A typed fact in the Hindsight memory schema. Carries narrative text,
|
|
77
|
+
* embedding, temporal envelope, participants, reasoning markers,
|
|
78
|
+
* extracted entities, and a confidence score in [0, 1]. Confidence
|
|
79
|
+
* defaults to 1.0 for World/Experience/Observation facts; the Opinion
|
|
80
|
+
* bank stores `(text, confidence, timestamp)` tuples per §2.2.
|
|
81
|
+
*/
|
|
82
|
+
export interface TypedFact {
|
|
83
|
+
/** Stable unique identifier. Convention: `<sessionId>-fact-<index>`. */
|
|
84
|
+
id: string;
|
|
85
|
+
/** Bank assignment from the LLM extractor's fact-type classification. */
|
|
86
|
+
bank: BankId;
|
|
87
|
+
/** Narrative text of the fact, post-coreference resolution. */
|
|
88
|
+
text: string;
|
|
89
|
+
/** Embedding vector. Empty until {@link IEmbeddingManager.embed} populates. */
|
|
90
|
+
embedding: number[];
|
|
91
|
+
/** Temporal envelope (occurrence interval + mention timestamp). */
|
|
92
|
+
temporal: FactTemporal;
|
|
93
|
+
/** Named participants and their roles. */
|
|
94
|
+
participants: Participant[];
|
|
95
|
+
/**
|
|
96
|
+
* Verbatim reasoning markers preserved from the source content
|
|
97
|
+
* ("because", "since", "therefore", etc.). Used downstream to
|
|
98
|
+
* extract causal edges.
|
|
99
|
+
*/
|
|
100
|
+
reasoningMarkers: string[];
|
|
101
|
+
/** Named entities mentioned in the fact (proper nouns, products, places). */
|
|
102
|
+
entities: string[];
|
|
103
|
+
/** Confidence ∈ [0, 1]. 1.0 for non-Opinion facts; LLM-output for Opinion. */
|
|
104
|
+
confidence: number;
|
|
105
|
+
/** Optional auxiliary metadata (source ID, conversation turn index, etc.). */
|
|
106
|
+
metadata?: Record<string, unknown>;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Typed edge between two facts in the network graph. Direction matters
|
|
110
|
+
* for causal edges (premise → conclusion); other kinds are
|
|
111
|
+
* bidirectional and stored as a pair of edges.
|
|
112
|
+
*/
|
|
113
|
+
export interface TypedEdge {
|
|
114
|
+
/** Source fact ID. */
|
|
115
|
+
fromFactId: string;
|
|
116
|
+
/** Target fact ID. */
|
|
117
|
+
toFactId: string;
|
|
118
|
+
/** Edge kind — drives μ(ℓ) multiplier in spreading activation. */
|
|
119
|
+
kind: EdgeKind;
|
|
120
|
+
/** Edge weight. Composed with decay δ and μ(ℓ) at activation time. */
|
|
121
|
+
weight: number;
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/memory/retrieval/typed-network/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,4DAA6D,CAAC;AAEnF,qDAAqD;AACrD,MAAM,MAAM,MAAM,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/C;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,IAAI,MAAM,CAE/C;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,UAAU,uDAAwD,CAAC;AAChF,uDAAuD;AACvD,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AAEnD;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,yCAAyC;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,wEAAwE;IACxE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sEAAsE;IACtE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,sEAAsE;IACtE,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,SAAS;IACxB,wEAAwE;IACxE,EAAE,EAAE,MAAM,CAAC;IACX,yEAAyE;IACzE,IAAI,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,IAAI,EAAE,MAAM,CAAC;IACb,+EAA+E;IAC/E,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,mEAAmE;IACnE,QAAQ,EAAE,YAAY,CAAC;IACvB,0CAA0C;IAC1C,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B;;;;OAIG;IACH,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,6EAA6E;IAC7E,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,8EAA8E;IAC9E,UAAU,EAAE,MAAM,CAAC;IACnB,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,sBAAsB;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,sBAAsB;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,kEAAkE;IAClE,IAAI,EAAE,QAAQ,CAAC;IACf,sEAAsE;IACtE,MAAM,EAAE,MAAM,CAAC;CAChB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file types.ts
|
|
3
|
+
* @description Core types for the Hindsight 4-network typed observer.
|
|
4
|
+
* Each fact lives in one of four typed banks: World (objective external
|
|
5
|
+
* facts), Experience (first-person biographical), Opinion (claims with
|
|
6
|
+
* confidence < 1), Observation (preference-neutral entity summaries).
|
|
7
|
+
*
|
|
8
|
+
* The schema follows Hindsight paper Equation 1
|
|
9
|
+
* (arxiv.org/html/2512.12818v1 §2.1):
|
|
10
|
+
*
|
|
11
|
+
* f = (u, b, t, v, τs, τe, τm, ℓ, c, x)
|
|
12
|
+
*
|
|
13
|
+
* mapped to TypeScript field names below. See spec
|
|
14
|
+
* `packages/agentos-bench/docs/specs/2026-04-26-hindsight-4network-observer-design.md`
|
|
15
|
+
* §2.1-§2.2 for the verbatim definition.
|
|
16
|
+
*
|
|
17
|
+
* @module @framers/agentos/memory/retrieval/typed-network/types
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Bank identifier — one of four typed networks per Hindsight §2.2. The
|
|
21
|
+
* bank determines retrieval semantics: World facts compose under
|
|
22
|
+
* objective truth, Experience under first-person continuity, Opinion
|
|
23
|
+
* under belief evolution, Observation under entity descriptions.
|
|
24
|
+
*/
|
|
25
|
+
export const BANK_IDS = ['WORLD', 'EXPERIENCE', 'OPINION', 'OBSERVATION'];
|
|
26
|
+
/**
|
|
27
|
+
* Type guard: narrows an arbitrary string to {@link BankId}. Use to
|
|
28
|
+
* validate untrusted inputs (LLM extraction output, deserialized
|
|
29
|
+
* persistence) before routing into the typed network.
|
|
30
|
+
*/
|
|
31
|
+
export function isBankId(s) {
|
|
32
|
+
return BANK_IDS.includes(s);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Edge kind in the typed-network graph. Each kind carries a different
|
|
36
|
+
* spreading-activation multiplier μ(ℓ) per Hindsight Eq. 12 (§2.4.1).
|
|
37
|
+
*
|
|
38
|
+
* - **temporal**: connects facts that share an occurrence-interval
|
|
39
|
+
* overlap. Weight derived from `exp(−Δt / σt)`.
|
|
40
|
+
* - **semantic**: connects facts whose embeddings exceed a cosine
|
|
41
|
+
* threshold θs.
|
|
42
|
+
* - **entity**: bidirectional link between facts mentioning the same
|
|
43
|
+
* named entity. Weight 1.0.
|
|
44
|
+
* - **causal**: explicit reasoning marker linking premise → conclusion
|
|
45
|
+
* facts. LLM-extracted at observation time; weight 1.0.
|
|
46
|
+
*/
|
|
47
|
+
export const EDGE_KINDS = ['temporal', 'semantic', 'entity', 'causal'];
|
|
48
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/memory/retrieval/typed-network/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,CAAU,CAAC;AAKnF;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,CAAS;IAChC,OAAQ,QAA8B,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;AACrD,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,CAAU,CAAC"}
|