paracosm 0.0.1 → 0.2.0
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/LICENSE +190 -0
- package/README.md +224 -0
- package/dist/cli/sim-config.d.ts +100 -0
- package/dist/cli/sim-config.d.ts.map +1 -0
- package/dist/cli/sim-config.js +124 -0
- package/dist/cli/sim-config.js.map +1 -0
- package/dist/cli/types.d.ts +73 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/types.js +2 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/engine/_template/index.d.ts +9 -0
- package/dist/engine/_template/index.d.ts.map +1 -0
- package/dist/engine/_template/index.js +91 -0
- package/dist/engine/_template/index.js.map +1 -0
- package/dist/engine/compiler/cache.d.ts +12 -0
- package/dist/engine/compiler/cache.d.ts.map +1 -0
- package/dist/engine/compiler/cache.js +75 -0
- package/dist/engine/compiler/cache.js.map +1 -0
- package/dist/engine/compiler/generate-director.d.ts +9 -0
- package/dist/engine/compiler/generate-director.d.ts.map +1 -0
- package/dist/engine/compiler/generate-director.js +57 -0
- package/dist/engine/compiler/generate-director.js.map +1 -0
- package/dist/engine/compiler/generate-fingerprint.d.ts +12 -0
- package/dist/engine/compiler/generate-fingerprint.d.ts.map +1 -0
- package/dist/engine/compiler/generate-fingerprint.js +86 -0
- package/dist/engine/compiler/generate-fingerprint.js.map +1 -0
- package/dist/engine/compiler/generate-milestones.d.ts +11 -0
- package/dist/engine/compiler/generate-milestones.d.ts.map +1 -0
- package/dist/engine/compiler/generate-milestones.js +121 -0
- package/dist/engine/compiler/generate-milestones.js.map +1 -0
- package/dist/engine/compiler/generate-politics.d.ts +11 -0
- package/dist/engine/compiler/generate-politics.d.ts.map +1 -0
- package/dist/engine/compiler/generate-politics.js +85 -0
- package/dist/engine/compiler/generate-politics.js.map +1 -0
- package/dist/engine/compiler/generate-progression.d.ts +15 -0
- package/dist/engine/compiler/generate-progression.d.ts.map +1 -0
- package/dist/engine/compiler/generate-progression.js +104 -0
- package/dist/engine/compiler/generate-progression.js.map +1 -0
- package/dist/engine/compiler/generate-prompts.d.ts +11 -0
- package/dist/engine/compiler/generate-prompts.d.ts.map +1 -0
- package/dist/engine/compiler/generate-prompts.js +90 -0
- package/dist/engine/compiler/generate-prompts.js.map +1 -0
- package/dist/engine/compiler/generate-reactions.d.ts +12 -0
- package/dist/engine/compiler/generate-reactions.d.ts.map +1 -0
- package/dist/engine/compiler/generate-reactions.js +90 -0
- package/dist/engine/compiler/generate-reactions.js.map +1 -0
- package/dist/engine/compiler/index.d.ts +34 -0
- package/dist/engine/compiler/index.d.ts.map +1 -0
- package/dist/engine/compiler/index.js +270 -0
- package/dist/engine/compiler/index.js.map +1 -0
- package/dist/engine/compiler/seed-ingestion.d.ts +40 -0
- package/dist/engine/compiler/seed-ingestion.d.ts.map +1 -0
- package/dist/engine/compiler/seed-ingestion.js +232 -0
- package/dist/engine/compiler/seed-ingestion.js.map +1 -0
- package/dist/engine/compiler/types.d.ts +30 -0
- package/dist/engine/compiler/types.d.ts.map +1 -0
- package/dist/engine/compiler/types.js +5 -0
- package/dist/engine/compiler/types.js.map +1 -0
- package/dist/engine/compiler/validate.d.ts +37 -0
- package/dist/engine/compiler/validate.d.ts.map +1 -0
- package/dist/engine/compiler/validate.js +141 -0
- package/dist/engine/compiler/validate.js.map +1 -0
- package/dist/engine/core/agent-generator.d.ts +11 -0
- package/dist/engine/core/agent-generator.d.ts.map +1 -0
- package/dist/engine/core/agent-generator.js +85 -0
- package/dist/engine/core/agent-generator.js.map +1 -0
- package/dist/engine/core/kernel.d.ts +69 -0
- package/dist/engine/core/kernel.d.ts.map +1 -0
- package/dist/engine/core/kernel.js +223 -0
- package/dist/engine/core/kernel.js.map +1 -0
- package/dist/engine/core/progression.d.ts +38 -0
- package/dist/engine/core/progression.d.ts.map +1 -0
- package/dist/engine/core/progression.js +292 -0
- package/dist/engine/core/progression.js.map +1 -0
- package/dist/engine/core/rng.d.ts +19 -0
- package/dist/engine/core/rng.d.ts.map +1 -0
- package/dist/engine/core/rng.js +34 -0
- package/dist/engine/core/rng.js.map +1 -0
- package/dist/engine/core/state.d.ts +144 -0
- package/dist/engine/core/state.d.ts.map +1 -0
- package/dist/engine/core/state.js +5 -0
- package/dist/engine/core/state.js.map +1 -0
- package/dist/engine/effect-registry.d.ts +14 -0
- package/dist/engine/effect-registry.d.ts.map +1 -0
- package/dist/engine/effect-registry.js +28 -0
- package/dist/engine/effect-registry.js.map +1 -0
- package/dist/engine/event-taxonomy.d.ts +9 -0
- package/dist/engine/event-taxonomy.d.ts.map +1 -0
- package/dist/engine/event-taxonomy.js +13 -0
- package/dist/engine/event-taxonomy.js.map +1 -0
- package/dist/engine/index.d.ts +25 -0
- package/dist/engine/index.d.ts.map +1 -0
- package/dist/engine/index.js +19 -0
- package/dist/engine/index.js.map +1 -0
- package/dist/engine/lunar/effects.d.ts +7 -0
- package/dist/engine/lunar/effects.d.ts.map +1 -0
- package/dist/engine/lunar/effects.js +16 -0
- package/dist/engine/lunar/effects.js.map +1 -0
- package/dist/engine/lunar/events.d.ts +3 -0
- package/dist/engine/lunar/events.d.ts.map +1 -0
- package/dist/engine/lunar/events.js +11 -0
- package/dist/engine/lunar/events.js.map +1 -0
- package/dist/engine/lunar/fingerprint.d.ts +5 -0
- package/dist/engine/lunar/fingerprint.d.ts.map +1 -0
- package/dist/engine/lunar/fingerprint.js +17 -0
- package/dist/engine/lunar/fingerprint.js.map +1 -0
- package/dist/engine/lunar/hooks.d.ts +10 -0
- package/dist/engine/lunar/hooks.d.ts.map +1 -0
- package/dist/engine/lunar/hooks.js +10 -0
- package/dist/engine/lunar/hooks.js.map +1 -0
- package/dist/engine/lunar/index.d.ts +8 -0
- package/dist/engine/lunar/index.d.ts.map +1 -0
- package/dist/engine/lunar/index.js +38 -0
- package/dist/engine/lunar/index.js.map +1 -0
- package/dist/engine/lunar/metrics.d.ts +4 -0
- package/dist/engine/lunar/metrics.d.ts.map +1 -0
- package/dist/engine/lunar/metrics.js +14 -0
- package/dist/engine/lunar/metrics.js.map +1 -0
- package/dist/engine/lunar/milestones.d.ts +3 -0
- package/dist/engine/lunar/milestones.d.ts.map +1 -0
- package/dist/engine/lunar/milestones.js +53 -0
- package/dist/engine/lunar/milestones.js.map +1 -0
- package/dist/engine/lunar/names.d.ts +4 -0
- package/dist/engine/lunar/names.d.ts.map +1 -0
- package/dist/engine/lunar/names.js +23 -0
- package/dist/engine/lunar/names.js.map +1 -0
- package/dist/engine/lunar/politics.d.ts +6 -0
- package/dist/engine/lunar/politics.d.ts.map +1 -0
- package/dist/engine/lunar/politics.js +13 -0
- package/dist/engine/lunar/politics.js.map +1 -0
- package/dist/engine/lunar/presets.d.ts +25 -0
- package/dist/engine/lunar/presets.d.ts.map +1 -0
- package/dist/engine/lunar/presets.js +24 -0
- package/dist/engine/lunar/presets.js.map +1 -0
- package/dist/engine/lunar/progression-hooks.d.ts +7 -0
- package/dist/engine/lunar/progression-hooks.d.ts.map +1 -0
- package/dist/engine/lunar/progression-hooks.js +20 -0
- package/dist/engine/lunar/progression-hooks.js.map +1 -0
- package/dist/engine/lunar/prompts.d.ts +10 -0
- package/dist/engine/lunar/prompts.d.ts.map +1 -0
- package/dist/engine/lunar/prompts.js +64 -0
- package/dist/engine/lunar/prompts.js.map +1 -0
- package/dist/engine/lunar/reactions.d.ts +5 -0
- package/dist/engine/lunar/reactions.d.ts.map +1 -0
- package/dist/engine/lunar/reactions.js +15 -0
- package/dist/engine/lunar/reactions.js.map +1 -0
- package/dist/engine/lunar/research-bundle.d.ts +8 -0
- package/dist/engine/lunar/research-bundle.d.ts.map +1 -0
- package/dist/engine/lunar/research-bundle.js +157 -0
- package/dist/engine/lunar/research-bundle.js.map +1 -0
- package/dist/engine/lunar/scenario.json +117 -0
- package/dist/engine/mars/effects.d.ts +18 -0
- package/dist/engine/mars/effects.d.ts.map +1 -0
- package/dist/engine/mars/effects.js +21 -0
- package/dist/engine/mars/effects.js.map +1 -0
- package/dist/engine/mars/events.d.ts +9 -0
- package/dist/engine/mars/events.d.ts.map +1 -0
- package/dist/engine/mars/events.js +12 -0
- package/dist/engine/mars/events.js.map +1 -0
- package/dist/engine/mars/fingerprint.d.ts +6 -0
- package/dist/engine/mars/fingerprint.d.ts.map +1 -0
- package/dist/engine/mars/fingerprint.js +21 -0
- package/dist/engine/mars/fingerprint.js.map +1 -0
- package/dist/engine/mars/hooks.d.ts +11 -0
- package/dist/engine/mars/hooks.d.ts.map +1 -0
- package/dist/engine/mars/hooks.js +11 -0
- package/dist/engine/mars/hooks.js.map +1 -0
- package/dist/engine/mars/index.d.ts +8 -0
- package/dist/engine/mars/index.d.ts.map +1 -0
- package/dist/engine/mars/index.js +44 -0
- package/dist/engine/mars/index.js.map +1 -0
- package/dist/engine/mars/metrics.d.ts +21 -0
- package/dist/engine/mars/metrics.d.ts.map +1 -0
- package/dist/engine/mars/metrics.js +25 -0
- package/dist/engine/mars/metrics.js.map +1 -0
- package/dist/engine/mars/milestones.d.ts +15 -0
- package/dist/engine/mars/milestones.d.ts.map +1 -0
- package/dist/engine/mars/milestones.js +72 -0
- package/dist/engine/mars/milestones.js.map +1 -0
- package/dist/engine/mars/names.d.ts +12 -0
- package/dist/engine/mars/names.d.ts.map +1 -0
- package/dist/engine/mars/names.js +45 -0
- package/dist/engine/mars/names.js.map +1 -0
- package/dist/engine/mars/politics.d.ts +7 -0
- package/dist/engine/mars/politics.d.ts.map +1 -0
- package/dist/engine/mars/politics.js +14 -0
- package/dist/engine/mars/politics.js.map +1 -0
- package/dist/engine/mars/presets.d.ts +29 -0
- package/dist/engine/mars/presets.d.ts.map +1 -0
- package/dist/engine/mars/presets.js +28 -0
- package/dist/engine/mars/presets.js.map +1 -0
- package/dist/engine/mars/progression-hooks.d.ts +8 -0
- package/dist/engine/mars/progression-hooks.d.ts.map +1 -0
- package/dist/engine/mars/progression-hooks.js +21 -0
- package/dist/engine/mars/progression-hooks.js.map +1 -0
- package/dist/engine/mars/prompts.d.ts +12 -0
- package/dist/engine/mars/prompts.d.ts.map +1 -0
- package/dist/engine/mars/prompts.js +75 -0
- package/dist/engine/mars/prompts.js.map +1 -0
- package/dist/engine/mars/reactions.d.ts +7 -0
- package/dist/engine/mars/reactions.d.ts.map +1 -0
- package/dist/engine/mars/reactions.js +24 -0
- package/dist/engine/mars/reactions.js.map +1 -0
- package/dist/engine/mars/research-bundle.d.ts +7 -0
- package/dist/engine/mars/research-bundle.d.ts.map +1 -0
- package/dist/engine/mars/research-bundle.js +174 -0
- package/dist/engine/mars/research-bundle.js.map +1 -0
- package/dist/engine/mars/scenario.json +118 -0
- package/dist/engine/metric-registry.d.ts +12 -0
- package/dist/engine/metric-registry.d.ts.map +1 -0
- package/dist/engine/metric-registry.js +26 -0
- package/dist/engine/metric-registry.js.map +1 -0
- package/dist/engine/types.d.ts +349 -0
- package/dist/engine/types.d.ts.map +1 -0
- package/dist/engine/types.js +7 -0
- package/dist/engine/types.js.map +1 -0
- package/dist/runtime/agent-memory.d.ts +43 -0
- package/dist/runtime/agent-memory.d.ts.map +1 -0
- package/dist/runtime/agent-memory.js +201 -0
- package/dist/runtime/agent-memory.js.map +1 -0
- package/dist/runtime/agent-reactions.d.ts +55 -0
- package/dist/runtime/agent-reactions.d.ts.map +1 -0
- package/dist/runtime/agent-reactions.js +136 -0
- package/dist/runtime/agent-reactions.js.map +1 -0
- package/dist/runtime/batch.d.ts +43 -0
- package/dist/runtime/batch.d.ts.map +1 -0
- package/dist/runtime/batch.js +49 -0
- package/dist/runtime/batch.js.map +1 -0
- package/dist/runtime/contracts.d.ts +127 -0
- package/dist/runtime/contracts.d.ts.map +1 -0
- package/dist/runtime/contracts.js +2 -0
- package/dist/runtime/contracts.js.map +1 -0
- package/dist/runtime/departments.d.ts +28 -0
- package/dist/runtime/departments.d.ts.map +1 -0
- package/dist/runtime/departments.js +111 -0
- package/dist/runtime/departments.js.map +1 -0
- package/dist/runtime/director.d.ts +92 -0
- package/dist/runtime/director.d.ts.map +1 -0
- package/dist/runtime/director.js +220 -0
- package/dist/runtime/director.js.map +1 -0
- package/dist/runtime/index.d.ts +16 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +12 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/orchestrator.d.ts +66 -0
- package/dist/runtime/orchestrator.d.ts.map +1 -0
- package/dist/runtime/orchestrator.js +821 -0
- package/dist/runtime/orchestrator.js.map +1 -0
- package/dist/runtime/research/knowledge-base.d.ts +14 -0
- package/dist/runtime/research/knowledge-base.d.ts.map +1 -0
- package/dist/runtime/research/knowledge-base.js +229 -0
- package/dist/runtime/research/knowledge-base.js.map +1 -0
- package/dist/runtime/research/research-memory.d.ts +21 -0
- package/dist/runtime/research/research-memory.d.ts.map +1 -0
- package/dist/runtime/research/research-memory.js +118 -0
- package/dist/runtime/research/research-memory.js.map +1 -0
- package/dist/runtime/research/research.d.ts +4 -0
- package/dist/runtime/research/research.d.ts.map +1 -0
- package/dist/runtime/research/research.js +138 -0
- package/dist/runtime/research/research.js.map +1 -0
- package/dist/runtime/research/scenario-research.d.ts +13 -0
- package/dist/runtime/research/scenario-research.d.ts.map +1 -0
- package/dist/runtime/research/scenario-research.js +58 -0
- package/dist/runtime/research/scenario-research.js.map +1 -0
- package/dist/runtime/research/scenarios.d.ts +3 -0
- package/dist/runtime/research/scenarios.d.ts.map +1 -0
- package/dist/runtime/research/scenarios.js +252 -0
- package/dist/runtime/research/scenarios.js.map +1 -0
- package/dist/runtime/runtime-helpers.d.ts +12 -0
- package/dist/runtime/runtime-helpers.d.ts.map +1 -0
- package/dist/runtime/runtime-helpers.js +33 -0
- package/dist/runtime/runtime-helpers.js.map +1 -0
- package/package.json +78 -4
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module types
|
|
3
|
+
* Core type definitions for the Paracosm simulation engine.
|
|
4
|
+
* All types needed to define a ScenarioPackage and interact with the engine.
|
|
5
|
+
*/
|
|
6
|
+
import type { HexacoProfile, Agent, SimulationState } from './core/state.js';
|
|
7
|
+
/** Possible field values for agent/colonist custom fields. */
|
|
8
|
+
export type AgentFieldValue = number | string | boolean | string[];
|
|
9
|
+
/** Human-readable labels for a scenario, used in UI and output naming. */
|
|
10
|
+
export interface ScenarioLabels {
|
|
11
|
+
/** Full display name (e.g., "Mars Genesis") */
|
|
12
|
+
name: string;
|
|
13
|
+
/** Short identifier used in file names and localStorage keys */
|
|
14
|
+
shortName: string;
|
|
15
|
+
/** What to call population members (e.g., "colonists", "crew members") */
|
|
16
|
+
populationNoun: string;
|
|
17
|
+
/** What to call the settlement (e.g., "colony", "outpost") */
|
|
18
|
+
settlementNoun: string;
|
|
19
|
+
/** Currency unit (e.g., "credits") */
|
|
20
|
+
currency: string;
|
|
21
|
+
}
|
|
22
|
+
/** Visual theme for a scenario. Applied to the dashboard via CSS custom properties. */
|
|
23
|
+
export interface ScenarioTheme {
|
|
24
|
+
primaryColor: string;
|
|
25
|
+
accentColor: string;
|
|
26
|
+
/** CSS custom properties injected into :root on scenario load */
|
|
27
|
+
cssVariables: Record<string, string>;
|
|
28
|
+
}
|
|
29
|
+
/** Default values for the simulation setup form. */
|
|
30
|
+
export interface ScenarioSetupSchema {
|
|
31
|
+
defaultTurns: number;
|
|
32
|
+
defaultSeed: number;
|
|
33
|
+
defaultStartYear: number;
|
|
34
|
+
defaultYearsPerTurn?: number;
|
|
35
|
+
defaultPopulation: number;
|
|
36
|
+
/** Which setup form sections to expose in the dashboard */
|
|
37
|
+
configurableSections: Array<'leaders' | 'personnel' | 'resources' | 'departments' | 'events' | 'models' | 'advanced'>;
|
|
38
|
+
}
|
|
39
|
+
/** Schema for a single world metric, capacity, status, or political variable. */
|
|
40
|
+
export interface WorldMetricSchema {
|
|
41
|
+
id: string;
|
|
42
|
+
label: string;
|
|
43
|
+
unit: string;
|
|
44
|
+
type: 'number' | 'string' | 'boolean';
|
|
45
|
+
initial: number | string | boolean;
|
|
46
|
+
min?: number;
|
|
47
|
+
max?: number;
|
|
48
|
+
category: 'metric' | 'capacity' | 'status' | 'politic' | 'environment';
|
|
49
|
+
}
|
|
50
|
+
/** Declares all world state variables for a scenario. */
|
|
51
|
+
export interface ScenarioWorldSchema {
|
|
52
|
+
metrics: Record<string, WorldMetricSchema>;
|
|
53
|
+
capacities: Record<string, WorldMetricSchema>;
|
|
54
|
+
statuses: Record<string, WorldMetricSchema>;
|
|
55
|
+
politics: Record<string, WorldMetricSchema>;
|
|
56
|
+
environment: Record<string, WorldMetricSchema>;
|
|
57
|
+
}
|
|
58
|
+
/** Runtime world state with typed record bags. Not everything is a flat numeric resource. */
|
|
59
|
+
export interface WorldState {
|
|
60
|
+
/** Numeric gauges: food, power, water, population, morale */
|
|
61
|
+
metrics: Record<string, number>;
|
|
62
|
+
/** Capacity constraints: life support, housing */
|
|
63
|
+
capacities: Record<string, number>;
|
|
64
|
+
/** Categorical state: governance status, faction alignment */
|
|
65
|
+
statuses: Record<string, string | boolean>;
|
|
66
|
+
/** Political/social pressures */
|
|
67
|
+
politics: Record<string, number | string | boolean>;
|
|
68
|
+
/** Environment conditions */
|
|
69
|
+
environment: Record<string, number | string | boolean>;
|
|
70
|
+
}
|
|
71
|
+
/** Defines a custom field on agents/colonists for a scenario. */
|
|
72
|
+
export interface AgentFieldDefinition {
|
|
73
|
+
id: string;
|
|
74
|
+
label: string;
|
|
75
|
+
unit: string;
|
|
76
|
+
type: 'number' | 'string' | 'boolean' | 'tags';
|
|
77
|
+
initial: AgentFieldValue;
|
|
78
|
+
min?: number;
|
|
79
|
+
max?: number;
|
|
80
|
+
mortalityContribution?: {
|
|
81
|
+
threshold: number;
|
|
82
|
+
ratePerYear: number;
|
|
83
|
+
};
|
|
84
|
+
showInTooltip: boolean;
|
|
85
|
+
includeInReactionContext: boolean;
|
|
86
|
+
}
|
|
87
|
+
/** Defines a department (analysis group) in the scenario. */
|
|
88
|
+
export interface DepartmentDefinition {
|
|
89
|
+
id: string;
|
|
90
|
+
label: string;
|
|
91
|
+
role: string;
|
|
92
|
+
icon: string;
|
|
93
|
+
defaultModel: string;
|
|
94
|
+
instructions: string;
|
|
95
|
+
}
|
|
96
|
+
/** Defines a derived metric displayed in the dashboard header. */
|
|
97
|
+
export interface MetricDefinition {
|
|
98
|
+
id: string;
|
|
99
|
+
label: string;
|
|
100
|
+
source: string;
|
|
101
|
+
format: 'number' | 'percent' | 'currency' | 'duration';
|
|
102
|
+
}
|
|
103
|
+
/** Defines an effect category with base deltas applied on crisis outcomes. */
|
|
104
|
+
export interface EffectDefinition {
|
|
105
|
+
id: string;
|
|
106
|
+
type: string;
|
|
107
|
+
label: string;
|
|
108
|
+
/** Maps crisis category to base colony system deltas */
|
|
109
|
+
categoryDefaults: Record<string, Record<string, number>>;
|
|
110
|
+
}
|
|
111
|
+
/** Defines an event type with render metadata for the dashboard. */
|
|
112
|
+
export interface EventDefinition {
|
|
113
|
+
id: string;
|
|
114
|
+
label: string;
|
|
115
|
+
icon: string;
|
|
116
|
+
color: string;
|
|
117
|
+
}
|
|
118
|
+
/** Tells the dashboard how to render scenario-specific UI elements. */
|
|
119
|
+
export interface ScenarioUiDefinition {
|
|
120
|
+
headerMetrics: Array<{
|
|
121
|
+
id: string;
|
|
122
|
+
format: 'number' | 'percent' | 'currency' | 'duration';
|
|
123
|
+
}>;
|
|
124
|
+
tooltipFields: string[];
|
|
125
|
+
reportSections: Array<'crisis' | 'departments' | 'decision' | 'outcome' | 'quotes' | 'causality'>;
|
|
126
|
+
departmentIcons: Record<string, string>;
|
|
127
|
+
eventRenderers: Record<string, {
|
|
128
|
+
icon: string;
|
|
129
|
+
color: string;
|
|
130
|
+
}>;
|
|
131
|
+
setupSections: Array<'leaders' | 'personnel' | 'resources' | 'departments' | 'events' | 'models' | 'advanced'>;
|
|
132
|
+
}
|
|
133
|
+
/** A single research citation with optional DOI. */
|
|
134
|
+
export interface KnowledgeCitation {
|
|
135
|
+
claim: string;
|
|
136
|
+
source: string;
|
|
137
|
+
url: string;
|
|
138
|
+
doi?: string;
|
|
139
|
+
}
|
|
140
|
+
/** A research topic with facts, counterpoints, and department-specific notes. */
|
|
141
|
+
export interface KnowledgeTopic {
|
|
142
|
+
canonicalFacts: KnowledgeCitation[];
|
|
143
|
+
counterpoints: Array<{
|
|
144
|
+
claim: string;
|
|
145
|
+
source: string;
|
|
146
|
+
url: string;
|
|
147
|
+
}>;
|
|
148
|
+
departmentNotes: Record<string, string>;
|
|
149
|
+
}
|
|
150
|
+
/** Scenario-owned research knowledge organized by topic with crisis category mapping. */
|
|
151
|
+
export interface KnowledgeBundle {
|
|
152
|
+
topics: Record<string, KnowledgeTopic>;
|
|
153
|
+
/** Maps crisis category to relevant topic IDs */
|
|
154
|
+
categoryMapping: Record<string, string[]>;
|
|
155
|
+
}
|
|
156
|
+
/** Feature policies controlling what capabilities are enabled for a scenario. */
|
|
157
|
+
export interface ScenarioPolicies {
|
|
158
|
+
toolForging: {
|
|
159
|
+
enabled: boolean;
|
|
160
|
+
requiredPerDepartment?: boolean;
|
|
161
|
+
};
|
|
162
|
+
liveSearch: {
|
|
163
|
+
enabled: boolean;
|
|
164
|
+
mode: 'off' | 'manual' | 'auto';
|
|
165
|
+
};
|
|
166
|
+
bulletin: {
|
|
167
|
+
enabled: boolean;
|
|
168
|
+
};
|
|
169
|
+
characterChat: {
|
|
170
|
+
enabled: boolean;
|
|
171
|
+
};
|
|
172
|
+
sandbox: {
|
|
173
|
+
timeoutMs: number;
|
|
174
|
+
memoryMB: number;
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
/** A product-level preset with pre-configured leaders, personnel, and starting state. */
|
|
178
|
+
export interface ScenarioPreset {
|
|
179
|
+
id: string;
|
|
180
|
+
label: string;
|
|
181
|
+
leaders?: Array<{
|
|
182
|
+
name: string;
|
|
183
|
+
archetype: string;
|
|
184
|
+
hexaco: Record<string, number>;
|
|
185
|
+
instructions: string;
|
|
186
|
+
}>;
|
|
187
|
+
personnel?: Array<{
|
|
188
|
+
name: string;
|
|
189
|
+
department: string;
|
|
190
|
+
role: string;
|
|
191
|
+
specialization: string;
|
|
192
|
+
age: number;
|
|
193
|
+
featured: boolean;
|
|
194
|
+
}>;
|
|
195
|
+
startingState?: Partial<WorldState>;
|
|
196
|
+
}
|
|
197
|
+
/** Context passed to the scenario progression hook during between-turn advancement. */
|
|
198
|
+
export interface ProgressionHookContext {
|
|
199
|
+
/** All agents (mutable: the hook modifies health fields in place) */
|
|
200
|
+
agents: Agent[];
|
|
201
|
+
yearDelta: number;
|
|
202
|
+
year: number;
|
|
203
|
+
turn: number;
|
|
204
|
+
startYear: number;
|
|
205
|
+
/** Seeded RNG for deterministic random operations */
|
|
206
|
+
rng: {
|
|
207
|
+
chance(probability: number): boolean;
|
|
208
|
+
next(): number;
|
|
209
|
+
pick<T>(arr: readonly T[]): T;
|
|
210
|
+
int(min: number, max: number): number;
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
/** Context passed to the scenario department prompt hook. */
|
|
214
|
+
export interface PromptHookContext {
|
|
215
|
+
department: string;
|
|
216
|
+
state: SimulationState;
|
|
217
|
+
scenario: Scenario;
|
|
218
|
+
researchPacket: {
|
|
219
|
+
canonicalFacts: Array<{
|
|
220
|
+
claim: string;
|
|
221
|
+
source: string;
|
|
222
|
+
url: string;
|
|
223
|
+
}>;
|
|
224
|
+
counterpoints: Array<{
|
|
225
|
+
claim: string;
|
|
226
|
+
source: string;
|
|
227
|
+
url: string;
|
|
228
|
+
}>;
|
|
229
|
+
departmentNotes: Record<string, string>;
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
/** Outcome classification for a turn. */
|
|
233
|
+
export type TurnOutcomeType = 'risky_success' | 'risky_failure' | 'conservative_success' | 'conservative_failure';
|
|
234
|
+
/**
|
|
235
|
+
* Lifecycle hooks that a scenario provides to inject domain-specific behavior
|
|
236
|
+
* into the generic engine. All hooks are optional.
|
|
237
|
+
*/
|
|
238
|
+
export interface ScenarioHooks {
|
|
239
|
+
/** Called during between-turn progression for scenario-specific health/field changes (e.g., radiation, bone density) */
|
|
240
|
+
progressionHook?: (ctx: ProgressionHookContext) => void;
|
|
241
|
+
/** Builds department-specific prompt context lines for LLM department agents */
|
|
242
|
+
departmentPromptHook?: (ctx: PromptHookContext) => string[];
|
|
243
|
+
/** Returns the Event Director's system instructions for this scenario */
|
|
244
|
+
directorInstructions?: () => string;
|
|
245
|
+
/** Builds the Event Director's per-turn context prompt */
|
|
246
|
+
directorPromptHook?: (ctx: Record<string, unknown>) => string;
|
|
247
|
+
/** Returns location/identity/health phrasing for agent reaction prompts */
|
|
248
|
+
reactionContextHook?: (colonist: Agent, ctx: {
|
|
249
|
+
year: number;
|
|
250
|
+
turn: number;
|
|
251
|
+
}) => string;
|
|
252
|
+
/** Computes a timeline fingerprint classification from final simulation state */
|
|
253
|
+
fingerprintHook?: (finalState: SimulationState, outcomeLog: Array<{
|
|
254
|
+
turn: number;
|
|
255
|
+
year: number;
|
|
256
|
+
outcome: string;
|
|
257
|
+
}>, leader: LeaderConfig, toolRegs: Record<string, string[]>, maxTurns: number) => Record<string, string>;
|
|
258
|
+
/** Returns a milestone event for narrative anchor turns (turn 1, final turn) */
|
|
259
|
+
getMilestoneEvent?: (turn: number, maxTurns: number) => MilestoneEventDef | null;
|
|
260
|
+
/** Returns politics deltas for political/social events, null if not applicable */
|
|
261
|
+
politicsHook?: (category: string, outcome: string) => Record<string, number> | null;
|
|
262
|
+
}
|
|
263
|
+
/** An option presented to the commander for a turn event. */
|
|
264
|
+
export interface EventOptionDef {
|
|
265
|
+
id: string;
|
|
266
|
+
label: string;
|
|
267
|
+
description: string;
|
|
268
|
+
isRisky: boolean;
|
|
269
|
+
}
|
|
270
|
+
/** A milestone event (fixed narrative anchor, e.g., turn 1 founding or final assessment). */
|
|
271
|
+
export interface MilestoneEventDef {
|
|
272
|
+
title: string;
|
|
273
|
+
description: string;
|
|
274
|
+
/** Full detailed narrative text for the milestone event */
|
|
275
|
+
crisis?: string;
|
|
276
|
+
options: EventOptionDef[];
|
|
277
|
+
riskyOptionId: string;
|
|
278
|
+
riskSuccessProbability: number;
|
|
279
|
+
category: string;
|
|
280
|
+
researchKeywords: string[];
|
|
281
|
+
relevantDepartments: string[];
|
|
282
|
+
turnSummary: string;
|
|
283
|
+
}
|
|
284
|
+
/** Legacy turn-based scenario (used by static SCENARIOS array and department context). */
|
|
285
|
+
export interface Scenario {
|
|
286
|
+
turn: number;
|
|
287
|
+
year: number;
|
|
288
|
+
title: string;
|
|
289
|
+
crisis: string;
|
|
290
|
+
researchKeywords: string[];
|
|
291
|
+
snapshotHints: Record<string, unknown>;
|
|
292
|
+
riskyOption: string;
|
|
293
|
+
riskSuccessProbability: number;
|
|
294
|
+
options?: EventOptionDef[];
|
|
295
|
+
}
|
|
296
|
+
/** Configuration for a simulation leader/commander. */
|
|
297
|
+
export interface LeaderConfig {
|
|
298
|
+
name: string;
|
|
299
|
+
archetype: string;
|
|
300
|
+
colony: string;
|
|
301
|
+
hexaco: HexacoProfile;
|
|
302
|
+
instructions: string;
|
|
303
|
+
}
|
|
304
|
+
/** Supported LLM provider. */
|
|
305
|
+
export type LlmProvider = 'openai' | 'anthropic';
|
|
306
|
+
/** Model assignments for different simulation roles. */
|
|
307
|
+
export interface SimulationModelConfig {
|
|
308
|
+
commander: string;
|
|
309
|
+
departments: string;
|
|
310
|
+
judge: string;
|
|
311
|
+
director: string;
|
|
312
|
+
agentReactions?: string;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* The top-level contract for a Paracosm scenario.
|
|
316
|
+
* Defines everything the engine needs to run a closed-state, turn-based
|
|
317
|
+
* settlement simulation: world schema, departments, effects, UI metadata,
|
|
318
|
+
* research knowledge, policies, presets, and lifecycle hooks.
|
|
319
|
+
*
|
|
320
|
+
* @example
|
|
321
|
+
* ```typescript
|
|
322
|
+
* import type { ScenarioPackage } from 'paracosm';
|
|
323
|
+
* import { marsScenario } from 'paracosm/mars';
|
|
324
|
+
*
|
|
325
|
+
* const myScenario: ScenarioPackage = { ... };
|
|
326
|
+
* ```
|
|
327
|
+
*/
|
|
328
|
+
export interface ScenarioPackage {
|
|
329
|
+
/** Unique scenario identifier (e.g., "mars-genesis", "lunar-outpost") */
|
|
330
|
+
id: string;
|
|
331
|
+
/** Semantic version of this scenario definition */
|
|
332
|
+
version: string;
|
|
333
|
+
/** Engine archetype this scenario targets */
|
|
334
|
+
engineArchetype: 'closed_turn_based_settlement';
|
|
335
|
+
labels: ScenarioLabels;
|
|
336
|
+
theme: ScenarioTheme;
|
|
337
|
+
setup: ScenarioSetupSchema;
|
|
338
|
+
world: ScenarioWorldSchema;
|
|
339
|
+
departments: DepartmentDefinition[];
|
|
340
|
+
metrics: MetricDefinition[];
|
|
341
|
+
events: EventDefinition[];
|
|
342
|
+
effects: EffectDefinition[];
|
|
343
|
+
ui: ScenarioUiDefinition;
|
|
344
|
+
knowledge: KnowledgeBundle;
|
|
345
|
+
policies: ScenarioPolicies;
|
|
346
|
+
presets: ScenarioPreset[];
|
|
347
|
+
hooks: ScenarioHooks;
|
|
348
|
+
}
|
|
349
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/engine/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAM7E,8DAA8D;AAC9D,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,EAAE,CAAC;AAMnE,0EAA0E;AAC1E,MAAM,WAAW,cAAc;IAC7B,+CAA+C;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,gEAAgE;IAChE,SAAS,EAAE,MAAM,CAAC;IAClB,0EAA0E;IAC1E,cAAc,EAAE,MAAM,CAAC;IACvB,8DAA8D;IAC9D,cAAc,EAAE,MAAM,CAAC;IACvB,sCAAsC;IACtC,QA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ceRoot":"","sources":["../../src/engine/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Persistent Memory
|
|
3
|
+
*
|
|
4
|
+
* After each turn, agent reactions are distilled into persistent memory entries.
|
|
5
|
+
* Short-term memory holds the last several turns of detail. Older memories
|
|
6
|
+
* consolidate into long-term beliefs. Stances drift based on crisis outcomes.
|
|
7
|
+
* Relationships shift based on shared experiences.
|
|
8
|
+
*
|
|
9
|
+
* Memory is injected into agent reaction prompts so each agent recalls
|
|
10
|
+
* their prior experiences, beliefs, and relationships when reacting to new crises.
|
|
11
|
+
* Works with any scenario type, not just colony simulations.
|
|
12
|
+
*/
|
|
13
|
+
import type { Agent } from '../engine/core/state.js';
|
|
14
|
+
import type { AgentReaction } from './agent-reactions.js';
|
|
15
|
+
/**
|
|
16
|
+
* Record an agent's reaction as a persistent memory entry.
|
|
17
|
+
* Called after each turn's reactions are generated.
|
|
18
|
+
*/
|
|
19
|
+
export declare function recordReactionMemory(agent: Agent, reaction: AgentReaction, crisisTitle: string, crisisCategory: string, outcome: string, turn: number, year: number): void;
|
|
20
|
+
/**
|
|
21
|
+
* Consolidate short-term memories into long-term beliefs.
|
|
22
|
+
* Called when short-term memory exceeds the threshold.
|
|
23
|
+
* Keeps the most salient recent memories and summarizes older ones.
|
|
24
|
+
*/
|
|
25
|
+
export declare function consolidateMemory(agent: Agent): void;
|
|
26
|
+
/**
|
|
27
|
+
* Update relationship sentiment between agents after shared crisis experience.
|
|
28
|
+
* Agents who react with similar moods to the same crisis become closer.
|
|
29
|
+
*/
|
|
30
|
+
export declare function updateRelationshipsFromReactions(agents: Agent[], reactions: AgentReaction[]): void;
|
|
31
|
+
/**
|
|
32
|
+
* Build memory context lines for a agent's reaction prompt.
|
|
33
|
+
* Returns a string block that gets injected into the prompt.
|
|
34
|
+
*/
|
|
35
|
+
/**
|
|
36
|
+
* Build memory context lines for a agent's reaction prompt.
|
|
37
|
+
* Returns a string block that gets injected into the prompt.
|
|
38
|
+
*
|
|
39
|
+
* @param colonist - The agent whose memory to render
|
|
40
|
+
* @param allColonists - Optional full agent list for resolving relationship names
|
|
41
|
+
*/
|
|
42
|
+
export declare function buildMemoryContext(agent: Agent, allColonists?: Agent[]): string;
|
|
43
|
+
//# sourceMappingURL=agent-memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-memory.d.ts","sourceRoot":"","sources":["../../src/runtime/agent-memory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAiC,MAAM,yBAAyB,CAAC;AACpF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAK1D;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,aAAa,EACvB,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX,IAAI,CAoBN;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CA+CpD;AAsBD;;;GAGG;AACH,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,KAAK,EAAE,EACf,SAAS,EAAE,aAAa,EAAE,GACzB,IAAI,CAqCN;AAED;;;GAGG;AACH;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,YAAY,CAAC,EAAE,KAAK,EAAE,GAAG,MAAM,CAsD/E"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Persistent Memory
|
|
3
|
+
*
|
|
4
|
+
* After each turn, agent reactions are distilled into persistent memory entries.
|
|
5
|
+
* Short-term memory holds the last several turns of detail. Older memories
|
|
6
|
+
* consolidate into long-term beliefs. Stances drift based on crisis outcomes.
|
|
7
|
+
* Relationships shift based on shared experiences.
|
|
8
|
+
*
|
|
9
|
+
* Memory is injected into agent reaction prompts so each agent recalls
|
|
10
|
+
* their prior experiences, beliefs, and relationships when reacting to new crises.
|
|
11
|
+
* Works with any scenario type, not just colony simulations.
|
|
12
|
+
*/
|
|
13
|
+
const SHORT_TERM_MAX = 15; // Max short-term entries before consolidation
|
|
14
|
+
const LONG_TERM_MAX = 10; // Max long-term belief summaries
|
|
15
|
+
/**
|
|
16
|
+
* Record an agent's reaction as a persistent memory entry.
|
|
17
|
+
* Called after each turn's reactions are generated.
|
|
18
|
+
*/
|
|
19
|
+
export function recordReactionMemory(agent, reaction, crisisTitle, crisisCategory, outcome, turn, year) {
|
|
20
|
+
if (!agent.memory) {
|
|
21
|
+
agent.memory = { shortTerm: [], longTerm: [], stances: {}, relationships: {} };
|
|
22
|
+
}
|
|
23
|
+
const entry = {
|
|
24
|
+
turn,
|
|
25
|
+
year,
|
|
26
|
+
content: `Crisis "${crisisTitle}": ${reaction.quote}`,
|
|
27
|
+
valence: reaction.mood === 'positive' || reaction.mood === 'hopeful' ? 'positive'
|
|
28
|
+
: reaction.mood === 'neutral' ? 'neutral'
|
|
29
|
+
: 'negative',
|
|
30
|
+
category: crisisCategory,
|
|
31
|
+
salience: reaction.intensity,
|
|
32
|
+
};
|
|
33
|
+
agent.memory.shortTerm.push(entry);
|
|
34
|
+
// Update stance on crisis category based on outcome
|
|
35
|
+
updateStance(agent.memory, crisisCategory, outcome, reaction.mood);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Consolidate short-term memories into long-term beliefs.
|
|
39
|
+
* Called when short-term memory exceeds the threshold.
|
|
40
|
+
* Keeps the most salient recent memories and summarizes older ones.
|
|
41
|
+
*/
|
|
42
|
+
export function consolidateMemory(agent) {
|
|
43
|
+
if (!agent.memory)
|
|
44
|
+
return;
|
|
45
|
+
const mem = agent.memory;
|
|
46
|
+
if (mem.shortTerm.length <= SHORT_TERM_MAX)
|
|
47
|
+
return;
|
|
48
|
+
// Score each memory by salience + recency. Recent high-salience memories are
|
|
49
|
+
// most worth keeping. A memory from 2 turns ago with 0.8 salience beats a
|
|
50
|
+
// memory from 10 turns ago with 0.9 salience.
|
|
51
|
+
const maxTurn = Math.max(...mem.shortTerm.map(e => e.turn));
|
|
52
|
+
const scored = mem.shortTerm.map(e => {
|
|
53
|
+
const recency = 1 - (maxTurn - e.turn) / Math.max(maxTurn, 1);
|
|
54
|
+
return { entry: e, score: e.salience * 0.6 + recency * 0.4 };
|
|
55
|
+
});
|
|
56
|
+
scored.sort((a, b) => b.score - a.score);
|
|
57
|
+
const keep = scored.slice(0, 5).map(s => s.entry);
|
|
58
|
+
const consolidate = scored.slice(5).map(s => s.entry);
|
|
59
|
+
// Group consolidated memories by category
|
|
60
|
+
const byCategory = {};
|
|
61
|
+
for (const entry of consolidate) {
|
|
62
|
+
const cat = entry.category;
|
|
63
|
+
if (!byCategory[cat])
|
|
64
|
+
byCategory[cat] = [];
|
|
65
|
+
byCategory[cat].push(entry);
|
|
66
|
+
}
|
|
67
|
+
// Generate long-term belief summaries
|
|
68
|
+
for (const [category, entries] of Object.entries(byCategory)) {
|
|
69
|
+
const positiveCount = entries.filter(e => e.valence === 'positive').length;
|
|
70
|
+
const negativeCount = entries.filter(e => e.valence === 'negative').length;
|
|
71
|
+
const dominant = positiveCount > negativeCount ? 'positive' : negativeCount > positiveCount ? 'negative' : 'mixed';
|
|
72
|
+
const summary = dominant === 'positive'
|
|
73
|
+
? `Generally positive experiences with ${category} crises (${entries.length} events).`
|
|
74
|
+
: dominant === 'negative'
|
|
75
|
+
? `Mostly negative experiences with ${category} crises (${entries.length} events). Tends to be wary.`
|
|
76
|
+
: `Mixed experiences with ${category} crises (${entries.length} events).`;
|
|
77
|
+
mem.longTerm.push(summary);
|
|
78
|
+
}
|
|
79
|
+
// Trim long-term to max
|
|
80
|
+
if (mem.longTerm.length > LONG_TERM_MAX) {
|
|
81
|
+
mem.longTerm = mem.longTerm.slice(-LONG_TERM_MAX);
|
|
82
|
+
}
|
|
83
|
+
mem.shortTerm = keep;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Update an agent's stance on a topic based on a crisis outcome.
|
|
87
|
+
* Stances range from -1 (strongly against) to 1 (strongly for).
|
|
88
|
+
*/
|
|
89
|
+
function updateStance(mem, category, outcome, mood) {
|
|
90
|
+
const current = mem.stances[category] ?? 0;
|
|
91
|
+
const isSuccess = outcome.includes('success');
|
|
92
|
+
const isPositiveMood = mood === 'positive' || mood === 'hopeful';
|
|
93
|
+
// Success + positive mood = stance drifts positive (confidence in handling this category)
|
|
94
|
+
// Failure + negative mood = stance drifts negative (fear/wariness of this category)
|
|
95
|
+
const delta = (isSuccess ? 0.1 : -0.1) + (isPositiveMood ? 0.05 : -0.05);
|
|
96
|
+
mem.stances[category] = Math.max(-1, Math.min(1, current + delta));
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Update relationship sentiment between agents after shared crisis experience.
|
|
100
|
+
* Agents who react with similar moods to the same crisis become closer.
|
|
101
|
+
*/
|
|
102
|
+
export function updateRelationshipsFromReactions(agents, reactions) {
|
|
103
|
+
const reactionMap = new Map(reactions.map(r => [r.agentId, r]));
|
|
104
|
+
// All agents track relationships. The relationship update is pure CPU
|
|
105
|
+
// (mood string comparison + map update), not LLM calls. 100 agents x 100
|
|
106
|
+
// reactions = 10,000 iterations of trivial work. The LLM reaction generation
|
|
107
|
+
// that precedes this takes seconds per batch; this takes microseconds total.
|
|
108
|
+
for (const agent of agents) {
|
|
109
|
+
if (!agent.health.alive || !agent.memory)
|
|
110
|
+
continue;
|
|
111
|
+
const myReaction = reactionMap.get(agent.core.id);
|
|
112
|
+
if (!myReaction)
|
|
113
|
+
continue;
|
|
114
|
+
for (const [otherId, otherReaction] of reactionMap) {
|
|
115
|
+
if (otherId === agent.core.id)
|
|
116
|
+
continue;
|
|
117
|
+
const sameMood = myReaction.mood === otherReaction.mood;
|
|
118
|
+
const bothIntense = myReaction.intensity > 0.6 && otherReaction.intensity > 0.6;
|
|
119
|
+
if (sameMood && bothIntense) {
|
|
120
|
+
const current = agent.memory.relationships[otherId] ?? 0;
|
|
121
|
+
agent.memory.relationships[otherId] = Math.min(1, current + 0.1);
|
|
122
|
+
}
|
|
123
|
+
else if (!sameMood && bothIntense) {
|
|
124
|
+
const current = agent.memory.relationships[otherId] ?? 0;
|
|
125
|
+
agent.memory.relationships[otherId] = Math.max(-1, current - 0.05);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
// Prune weak relationships and cap at 20 strongest to bound memory size
|
|
129
|
+
for (const [id, val] of Object.entries(agent.memory.relationships)) {
|
|
130
|
+
if (Math.abs(val) < 0.05)
|
|
131
|
+
delete agent.memory.relationships[id];
|
|
132
|
+
}
|
|
133
|
+
const remaining = Object.entries(agent.memory.relationships);
|
|
134
|
+
if (remaining.length > 20) {
|
|
135
|
+
remaining.sort((a, b) => Math.abs(b[1]) - Math.abs(a[1]));
|
|
136
|
+
agent.memory.relationships = Object.fromEntries(remaining.slice(0, 20));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Build memory context lines for a agent's reaction prompt.
|
|
142
|
+
* Returns a string block that gets injected into the prompt.
|
|
143
|
+
*/
|
|
144
|
+
/**
|
|
145
|
+
* Build memory context lines for a agent's reaction prompt.
|
|
146
|
+
* Returns a string block that gets injected into the prompt.
|
|
147
|
+
*
|
|
148
|
+
* @param colonist - The agent whose memory to render
|
|
149
|
+
* @param allColonists - Optional full agent list for resolving relationship names
|
|
150
|
+
*/
|
|
151
|
+
export function buildMemoryContext(agent, allColonists) {
|
|
152
|
+
if (!agent.memory)
|
|
153
|
+
return '';
|
|
154
|
+
const lines = [];
|
|
155
|
+
const mem = agent.memory;
|
|
156
|
+
// Build a name lookup from agent IDs if the full list is available
|
|
157
|
+
const nameMap = new Map();
|
|
158
|
+
if (allColonists) {
|
|
159
|
+
for (const c of allColonists)
|
|
160
|
+
nameMap.set(c.core.id, c.core.name);
|
|
161
|
+
}
|
|
162
|
+
// Long-term beliefs
|
|
163
|
+
if (mem.longTerm.length > 0) {
|
|
164
|
+
lines.push('YOUR BELIEFS (from past experience):');
|
|
165
|
+
for (const belief of mem.longTerm.slice(-5)) {
|
|
166
|
+
lines.push(`- ${belief}`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
// Recent memories (last 3, most recent first)
|
|
170
|
+
const recent = mem.shortTerm.slice(-3).reverse();
|
|
171
|
+
if (recent.length > 0) {
|
|
172
|
+
lines.push('YOUR RECENT MEMORIES:');
|
|
173
|
+
for (const entry of recent) {
|
|
174
|
+
lines.push(`- Year ${entry.year}: ${entry.content}`);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
// Strong stances
|
|
178
|
+
const strongStances = Object.entries(mem.stances).filter(([, v]) => Math.abs(v) > 0.3);
|
|
179
|
+
if (strongStances.length > 0) {
|
|
180
|
+
lines.push('YOUR STANCES:');
|
|
181
|
+
for (const [topic, value] of strongStances) {
|
|
182
|
+
const label = value > 0.5 ? 'strongly confident' : value > 0 ? 'cautiously optimistic' : value > -0.5 ? 'wary' : 'deeply fearful';
|
|
183
|
+
lines.push(`- ${topic}: ${label}`);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
// Key relationships (resolve names from agent list when available)
|
|
187
|
+
const strongRelationships = Object.entries(mem.relationships)
|
|
188
|
+
.filter(([, v]) => Math.abs(v) > 0.3)
|
|
189
|
+
.sort((a, b) => Math.abs(b[1]) - Math.abs(a[1]))
|
|
190
|
+
.slice(0, 3);
|
|
191
|
+
if (strongRelationships.length > 0) {
|
|
192
|
+
lines.push('YOUR KEY RELATIONSHIPS:');
|
|
193
|
+
for (const [id, value] of strongRelationships) {
|
|
194
|
+
const label = value > 0.5 ? 'close ally' : value > 0 ? 'friendly' : value > -0.5 ? 'tense' : 'adversarial';
|
|
195
|
+
const name = nameMap.get(id) || id.replace('col-', '').replace(/-/g, ' ');
|
|
196
|
+
lines.push(`- ${name}: ${label}`);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return lines.length > 0 ? '\n' + lines.join('\n') : '';
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=agent-memory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-memory.js","sourceRoot":"","sources":["../../src/runtime/agent-memory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,MAAM,cAAc,GAAG,EAAE,CAAC,CAAC,8CAA8C;AACzE,MAAM,aAAa,GAAG,EAAE,CAAC,CAAC,iCAAiC;AAE3D;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAAY,EACZ,QAAuB,EACvB,WAAmB,EACnB,cAAsB,EACtB,OAAe,EACf,IAAY,EACZ,IAAY;IAEZ,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;QAClB,KAAK,CAAC,MAAM,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC;IACjF,CAAC;IAED,MAAM,KAAK,GAAqB;QAC9B,IAAI;QACJ,IAAI;QACJ,OAAO,EAAE,WAAW,WAAW,MAAM,QAAQ,CAAC,KAAK,EAAE;QACrD,OAAO,EAAE,QAAQ,CAAC,IAAI,KAAK,UAAU,IAAI,QAAQ,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,UAAU;YAC1E,CAAC,CAAC,QAAQ,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS;gBACzC,CAAC,CAAC,UAAU;QACnB,QAAQ,EAAE,cAAc;QACxB,QAAQ,EAAE,QAAQ,CAAC,SAAS;KAC7B,CAAC;IAEF,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,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