@mindot/will 0.1.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 +202 -0
- package/README.md +777 -0
- package/dist/index.d.ts +8144 -0
- package/dist/index.js +26231 -0
- package/dist/index.js.map +1 -0
- package/package.json +73 -0
- package/src/cognition/agency/access.grants.ts +59 -0
- package/src/cognition/agency/competence.codec.ts +89 -0
- package/src/cognition/agency/engines/action.selector.ts +462 -0
- package/src/cognition/agency/engines/affordance.synthesizer.ts +384 -0
- package/src/cognition/agency/engines/deliberation.engine.ts +241 -0
- package/src/cognition/agency/engines/instruction.intake.ts +54 -0
- package/src/cognition/agency/engines/motor.schema.executor.ts +532 -0
- package/src/cognition/agency/engines/reafference.engine.ts +241 -0
- package/src/cognition/agency/execution.primitives.ts +118 -0
- package/src/cognition/agency/index.ts +58 -0
- package/src/cognition/agency/proactive.communicator.ts +274 -0
- package/src/cognition/agency/reconcile.learning.ts +82 -0
- package/src/cognition/agency/schemas/external.ts +59 -0
- package/src/cognition/agency/schemas/innate.ts +111 -0
- package/src/cognition/agency/schemas/repertoire.ts +246 -0
- package/src/cognition/agency/selection.scoring.ts +191 -0
- package/src/cognition/agency/types.ts +165 -0
- package/src/cognition/bus.ts +391 -0
- package/src/cognition/completion.inbox.ts +86 -0
- package/src/cognition/config.mirror.entities.ts +475 -0
- package/src/cognition/conversation.memory.ts +81 -0
- package/src/cognition/event.log.ts +116 -0
- package/src/cognition/event.schemas.ts +568 -0
- package/src/cognition/faculties/aesthetic.evaluator.ts +313 -0
- package/src/cognition/faculties/affective.blender.ts +562 -0
- package/src/cognition/faculties/attachment.evaluator.ts +432 -0
- package/src/cognition/faculties/attention.allocator.ts +422 -0
- package/src/cognition/faculties/autobiographical.narrator.ts +300 -0
- package/src/cognition/faculties/bias.detector.ts +363 -0
- package/src/cognition/faculties/circadian.oscillator.ts +294 -0
- package/src/cognition/faculties/confidence.calibrator.ts +324 -0
- package/src/cognition/faculties/dream.simulator.ts +251 -0
- package/src/cognition/faculties/empathy.simulator.ts +253 -0
- package/src/cognition/faculties/energy.regulator.ts +320 -0
- package/src/cognition/faculties/episodic.consolidator.ts +728 -0
- package/src/cognition/faculties/executive.engine/commands.ts +459 -0
- package/src/cognition/faculties/executive.engine/config.ts +46 -0
- package/src/cognition/faculties/executive.engine/context.ts +605 -0
- package/src/cognition/faculties/executive.engine/deferred.effects.ts +104 -0
- package/src/cognition/faculties/executive.engine/deliberate.reasoning.ts +60 -0
- package/src/cognition/faculties/executive.engine/effort.gate.ts +114 -0
- package/src/cognition/faculties/executive.engine/engine.ts +1028 -0
- package/src/cognition/faculties/executive.engine/escalation.buffer.ts +90 -0
- package/src/cognition/faculties/executive.engine/facet.supervisor.ts +271 -0
- package/src/cognition/faculties/executive.engine/facet.ts +628 -0
- package/src/cognition/faculties/executive.engine/gating.ts +222 -0
- package/src/cognition/faculties/executive.engine/index.ts +6 -0
- package/src/cognition/faculties/executive.engine/messages.ts +102 -0
- package/src/cognition/faculties/executive.engine/parser.ts +380 -0
- package/src/cognition/faculties/executive.engine/prompt.factory.ts +1053 -0
- package/src/cognition/faculties/executive.engine/types.ts +323 -0
- package/src/cognition/faculties/exteroception.ts +338 -0
- package/src/cognition/faculties/forgetting.curve.ts +202 -0
- package/src/cognition/faculties/frustration.evaluator.ts +280 -0
- package/src/cognition/faculties/goal.manager.ts +1008 -0
- package/src/cognition/faculties/inhibition.controller.ts +351 -0
- package/src/cognition/faculties/interoception.ts +417 -0
- package/src/cognition/faculties/introspection.engine.ts +246 -0
- package/src/cognition/faculties/known.entity.tracker.ts +439 -0
- package/src/cognition/faculties/loss.evaluator.ts +224 -0
- package/src/cognition/faculties/moral.evaluator.ts +437 -0
- package/src/cognition/faculties/novelty.detector.ts +254 -0
- package/src/cognition/faculties/persona.consolidator.ts +845 -0
- package/src/cognition/faculties/planning.engine/engine.ts +859 -0
- package/src/cognition/faculties/planning.engine/plan.frontier.ts +83 -0
- package/src/cognition/faculties/planning.engine/plan.store.ts +174 -0
- package/src/cognition/faculties/planning.engine/plan.supervision.ts +494 -0
- package/src/cognition/faculties/planning.engine/types.ts +143 -0
- package/src/cognition/faculties/reputation.tracker.ts +294 -0
- package/src/cognition/faculties/reward.evaluator.ts +304 -0
- package/src/cognition/faculties/self.model.updater.ts +677 -0
- package/src/cognition/faculties/semantic.engine/clustering.ts +673 -0
- package/src/cognition/faculties/semantic.engine/index.ts +6 -0
- package/src/cognition/faculties/semantic.engine/integrator.ts +750 -0
- package/src/cognition/faculties/semantic.engine/types.ts +53 -0
- package/src/cognition/faculties/sleep.pressure.regulator.ts +262 -0
- package/src/cognition/faculties/social.perception.ts +333 -0
- package/src/cognition/faculties/spaced.repetition.ts +605 -0
- package/src/cognition/faculties/stress.regulator.ts +375 -0
- package/src/cognition/faculties/task.switcher.ts +239 -0
- package/src/cognition/faculties/theory.of.mind.ts +333 -0
- package/src/cognition/faculties/threat.evaluator.ts +312 -0
- package/src/cognition/faculties/working.memory.ts +406 -0
- package/src/cognition/generative.model.ts +344 -0
- package/src/cognition/heartbeat.ts +70 -0
- package/src/cognition/index.ts +291 -0
- package/src/cognition/instruction.handler.ts +146 -0
- package/src/cognition/memory/index.ts +35 -0
- package/src/cognition/memory/vector.adapter.ts +316 -0
- package/src/cognition/memory/vector.content.ts +47 -0
- package/src/cognition/memory/vector.embedder.ts +212 -0
- package/src/cognition/memory/vector.index.ts +459 -0
- package/src/cognition/memory/vector.types.ts +65 -0
- package/src/cognition/orchestrator.ts +142 -0
- package/src/cognition/persona.prior.ts +265 -0
- package/src/cognition/schema.registry.ts +145 -0
- package/src/cognition/senses/audition.engine/engine.ts +976 -0
- package/src/cognition/senses/audition.engine/salience.ts +59 -0
- package/src/cognition/senses/base.sense.engine.ts +117 -0
- package/src/cognition/senses/gustation.engine.ts +24 -0
- package/src/cognition/senses/index.ts +172 -0
- package/src/cognition/senses/olfaction.engine.ts +24 -0
- package/src/cognition/senses/somatosensation.engine.ts +23 -0
- package/src/cognition/senses/vision.engine.ts +23 -0
- package/src/cognition/types.ts +63 -0
- package/src/cognition/utilities/token.tracker.ts +492 -0
- package/src/core/abstracts.ts +60 -0
- package/src/core/async.engine.ts +539 -0
- package/src/core/clock.ts +196 -0
- package/src/core/completion.recorder.ts +122 -0
- package/src/core/conflict.detector.ts +140 -0
- package/src/core/distributed.ts +626 -0
- package/src/core/event.bus.ts +292 -0
- package/src/core/inbound.recorder.ts +100 -0
- package/src/core/index.ts +167 -0
- package/src/core/logger.ts +85 -0
- package/src/core/metrics.ts +107 -0
- package/src/core/orchestrator.ts +625 -0
- package/src/core/replay.ts +589 -0
- package/src/core/scenario.ts +120 -0
- package/src/core/serialization.ts +448 -0
- package/src/core/simulation.ts +197 -0
- package/src/core/snapshot.manager.ts +293 -0
- package/src/core/state.manager.ts +283 -0
- package/src/core/types.ts +274 -0
- package/src/core/utils.ts +82 -0
- package/src/core/wall.clock.ts +23 -0
- package/src/extensions/livestream.ext.ts +570 -0
- package/src/extensions/time.ext.ts +339 -0
- package/src/index.ts +91 -0
- package/src/llm/gate.ts +140 -0
- package/src/llm/index.ts +716 -0
- package/src/llm/summarizer.ts +170 -0
- package/src/llm/wire.contracts.ts +67 -0
- package/src/pma/eval.ts +651 -0
- package/src/pma/index.ts +1082 -0
- package/src/profiles/built-in.ts +7 -0
- package/src/profiles/companion.ts +28 -0
- package/src/profiles/company-brain.ts +54 -0
- package/src/profiles/customer-service.ts +30 -0
- package/src/profiles/game-npc.ts +20 -0
- package/src/profiles/index.ts +42 -0
- package/src/profiles/smart-home.ts +34 -0
- package/src/runners/coherence.runner.ts +49 -0
- package/src/runners/outreach.runner.ts +158 -0
- package/src/runners/social.runner.ts +182 -0
- package/src/runners/thin-shim.runner.ts +195 -0
- package/src/sdk/will.ts +334 -0
- package/src/stem/assembly.audit.ts +88 -0
- package/src/stem/distribution.ts +203 -0
- package/src/stem/guards/identity.coherence.ts +152 -0
- package/src/stem/guards/identity.guard.ts +227 -0
- package/src/stem/index.ts +1145 -0
- package/src/stem/mind.ts +1090 -0
- package/src/stem/tracts/ack.reconciler.ts +55 -0
- package/src/stem/tracts/biography.writer.ts +190 -0
- package/src/stem/tracts/effector.controller.ts +143 -0
- package/src/stem/tracts/health.reporter.ts +113 -0
- package/src/stem/tracts/inbound.queue.ts +54 -0
- package/src/stem/tracts/outbox.controller.ts +167 -0
- package/src/stem/tracts/outbox.writer.ts +133 -0
- package/src/stem/tracts/pma.controller.ts +109 -0
- package/src/stem/tracts/replay.controller.ts +177 -0
- package/src/stem/tracts/sensory.controller.ts +168 -0
- package/src/stem/tracts/session.logger.ts +157 -0
- package/src/stem/tracts/transport/index.ts +38 -0
- package/src/stem/tracts/transport/loopback.transport.ts +86 -0
- package/src/stem/tracts/transport/socketio.transport.ts +200 -0
- package/src/stem/tracts/transport/stream.transport.ts +152 -0
- package/src/stem/tracts/transport/types.ts +193 -0
- package/src/stem/tracts/transport.controller.ts +380 -0
- package/src/types.ts +116 -0
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
// ─────────────────────────────────────────────────────────────
|
|
2
|
+
// src/cognition/engines/index.ts
|
|
3
|
+
// ─────────────────────────────────────────────────────────────
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
TokenTracker,
|
|
7
|
+
resolvePricing,
|
|
8
|
+
type TokenTrackerConfig,
|
|
9
|
+
type TokenUsage,
|
|
10
|
+
type TokenLedgerRecord,
|
|
11
|
+
type RecordUsageInput,
|
|
12
|
+
} from '#cognition/utilities/token.tracker'
|
|
13
|
+
|
|
14
|
+
import { EnergyRegulator, type EnergyRegulatorConfig } from '#faculties/energy.regulator'
|
|
15
|
+
import { SleepPressureRegulator, type SleepPressureConfig } from '#faculties/sleep.pressure.regulator'
|
|
16
|
+
import { AttentionAllocator, type AttentionAllocatorConfig } from '#faculties/attention.allocator'
|
|
17
|
+
import { StressRegulator, type StressRegulatorConfig } from '#faculties/stress.regulator'
|
|
18
|
+
import { CircadianOscillator, type CircadianConfig } from '#faculties/circadian.oscillator'
|
|
19
|
+
import { Exteroception, type ExteroceptionConfig } from '#faculties/exteroception'
|
|
20
|
+
import { Interoception, type InteroceptionConfig } from '#faculties/interoception'
|
|
21
|
+
import { SocialPerception, type SocialPerceptionConfig } from '#faculties/social.perception'
|
|
22
|
+
import { NoveltyDetector, type NoveltyDetectorConfig } from '#faculties/novelty.detector'
|
|
23
|
+
|
|
24
|
+
import { ThreatEvaluator, type ThreatEvaluatorConfig } from '#faculties/threat.evaluator'
|
|
25
|
+
import { RewardEvaluator, type RewardEvaluatorConfig } from '#faculties/reward.evaluator'
|
|
26
|
+
import { LossEvaluator, type LossEvaluatorConfig } from '#faculties/loss.evaluator'
|
|
27
|
+
import { FrustrationEvaluator, type FrustrationEvaluatorConfig } from '#faculties/frustration.evaluator'
|
|
28
|
+
import { AttachmentEvaluator, type AttachmentEvaluatorConfig } from '#faculties/attachment.evaluator'
|
|
29
|
+
import { AestheticEvaluator, type AestheticEvaluatorConfig } from '#faculties/aesthetic.evaluator'
|
|
30
|
+
import { MoralEvaluator, type MoralEvaluatorConfig } from '#faculties/moral.evaluator'
|
|
31
|
+
import { AffectiveBlender, type AffectiveBlenderConfig } from '#faculties/affective.blender'
|
|
32
|
+
|
|
33
|
+
import { WorkingMemory, type WorkingMemoryConfig } from '#faculties/working.memory'
|
|
34
|
+
import { EpisodicConsolidator, type EpisodicConsolidatorConfig } from '#faculties/episodic.consolidator'
|
|
35
|
+
import { SemanticIntegrator, type SemanticIntegratorConfig } from '#faculties/semantic.engine'
|
|
36
|
+
import { SpacedRepetition, type SpacedRepetitionConfig } from './faculties/spaced.repetition'
|
|
37
|
+
import { ForgettingCurve, type ForgettingCurveConfig } from '#faculties/forgetting.curve'
|
|
38
|
+
import { DreamSimulator, type DreamSimulatorConfig } from '#faculties/dream.simulator'
|
|
39
|
+
|
|
40
|
+
import { GoalManager, type GoalManagerConfig } from '#faculties/goal.manager'
|
|
41
|
+
import { ExecutiveEngine, type ExecutiveEngineConfig } from '#faculties/executive.engine'
|
|
42
|
+
import { PlanningEngine, type PlanningEngineConfig, type ActivityEvent, type ActivityEventHandler } from '#cognition/faculties/planning.engine/engine'
|
|
43
|
+
import { InhibitionController, type InhibitionControllerConfig } from '#faculties/inhibition.controller'
|
|
44
|
+
import { TaskSwitcher, type TaskSwitcherConfig } from '#faculties/task.switcher'
|
|
45
|
+
|
|
46
|
+
import { SelfModelUpdater, type SelfModelUpdaterConfig } from '#faculties/self.model.updater'
|
|
47
|
+
import { ConfidenceCalibrator, type ConfidenceCalibratorConfig } from '#faculties/confidence.calibrator'
|
|
48
|
+
import { BiasDetector, type BiasDetectorConfig } from '#faculties/bias.detector'
|
|
49
|
+
import { AutobiographicalNarrator, type AutobiographicalNarratorConfig } from '#faculties/autobiographical.narrator'
|
|
50
|
+
import { IntrospectionEngine, type IntrospectionEngineConfig } from '#faculties/introspection.engine'
|
|
51
|
+
import { PersonaConsolidator, type PersonaConsolidatorConfig } from '#faculties/persona.consolidator'
|
|
52
|
+
|
|
53
|
+
import { TheoryOfMind, type TheoryOfMindConfig } from '#faculties/theory.of.mind'
|
|
54
|
+
import { EmpathySimulator, type EmpathySimulatorConfig } from '#faculties/empathy.simulator'
|
|
55
|
+
import { ReputationTracker, type ReputationTrackerConfig } from '#faculties/reputation.tracker'
|
|
56
|
+
import { KnownEntityTracker, type KnownEntityTrackerConfig } from '#faculties/known.entity.tracker'
|
|
57
|
+
|
|
58
|
+
import { AuditionEngine } from '#senses/audition.engine/engine'
|
|
59
|
+
import { VisionEngine } from '#senses/vision.engine'
|
|
60
|
+
import { SomatosensationEngine } from '#senses/somatosensation.engine'
|
|
61
|
+
import { OlfactionEngine } from '#senses/olfaction.engine'
|
|
62
|
+
import { GustationEngine } from '#senses/gustation.engine'
|
|
63
|
+
|
|
64
|
+
import { InstructionIntake } from '#agency/engines/instruction.intake'
|
|
65
|
+
import { AffordanceSynthesizer } from '#agency/engines/affordance.synthesizer'
|
|
66
|
+
import { ActionSelector } from '#agency/engines/action.selector'
|
|
67
|
+
import { DeliberationEngine } from '#agency/engines/deliberation.engine'
|
|
68
|
+
import { MotorSchemaExecutor } from '#agency/engines/motor.schema.executor'
|
|
69
|
+
import { ReafferenceEngine } from '#agency/engines/reafference.engine'
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Regulatory engines — Shard 0.
|
|
73
|
+
* These run every tick synchronously and produce the homeostatic
|
|
74
|
+
* foundation for all other cognitive layers.
|
|
75
|
+
*/
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
export {
|
|
79
|
+
// ── Generic Engines ───────────────────────────────────────
|
|
80
|
+
|
|
81
|
+
TokenTracker,
|
|
82
|
+
resolvePricing,
|
|
83
|
+
type TokenTrackerConfig,
|
|
84
|
+
type TokenUsage,
|
|
85
|
+
type TokenLedgerRecord,
|
|
86
|
+
type RecordUsageInput,
|
|
87
|
+
|
|
88
|
+
// ── Regulatory Engines ─────────────────────────────────────
|
|
89
|
+
|
|
90
|
+
EnergyRegulator,
|
|
91
|
+
type EnergyRegulatorConfig,
|
|
92
|
+
|
|
93
|
+
SleepPressureRegulator,
|
|
94
|
+
type SleepPressureConfig,
|
|
95
|
+
|
|
96
|
+
AttentionAllocator,
|
|
97
|
+
type AttentionAllocatorConfig,
|
|
98
|
+
|
|
99
|
+
StressRegulator,
|
|
100
|
+
type StressRegulatorConfig,
|
|
101
|
+
|
|
102
|
+
CircadianOscillator,
|
|
103
|
+
type CircadianConfig,
|
|
104
|
+
|
|
105
|
+
Exteroception,
|
|
106
|
+
type ExteroceptionConfig,
|
|
107
|
+
|
|
108
|
+
Interoception,
|
|
109
|
+
type InteroceptionConfig,
|
|
110
|
+
|
|
111
|
+
SocialPerception,
|
|
112
|
+
type SocialPerceptionConfig,
|
|
113
|
+
|
|
114
|
+
NoveltyDetector,
|
|
115
|
+
type NoveltyDetectorConfig,
|
|
116
|
+
|
|
117
|
+
// ── Affective Engines ───────────────────────────────────────
|
|
118
|
+
|
|
119
|
+
ThreatEvaluator,
|
|
120
|
+
type ThreatEvaluatorConfig,
|
|
121
|
+
|
|
122
|
+
RewardEvaluator,
|
|
123
|
+
type RewardEvaluatorConfig,
|
|
124
|
+
|
|
125
|
+
LossEvaluator,
|
|
126
|
+
type LossEvaluatorConfig,
|
|
127
|
+
|
|
128
|
+
FrustrationEvaluator,
|
|
129
|
+
type FrustrationEvaluatorConfig,
|
|
130
|
+
|
|
131
|
+
AttachmentEvaluator,
|
|
132
|
+
type AttachmentEvaluatorConfig,
|
|
133
|
+
|
|
134
|
+
AestheticEvaluator,
|
|
135
|
+
type AestheticEvaluatorConfig,
|
|
136
|
+
|
|
137
|
+
MoralEvaluator,
|
|
138
|
+
type MoralEvaluatorConfig,
|
|
139
|
+
|
|
140
|
+
AffectiveBlender,
|
|
141
|
+
type AffectiveBlenderConfig,
|
|
142
|
+
|
|
143
|
+
// ── Memory Engines ──────────────────────────────────────────
|
|
144
|
+
|
|
145
|
+
WorkingMemory,
|
|
146
|
+
type WorkingMemoryConfig,
|
|
147
|
+
|
|
148
|
+
EpisodicConsolidator,
|
|
149
|
+
type EpisodicConsolidatorConfig,
|
|
150
|
+
|
|
151
|
+
SemanticIntegrator,
|
|
152
|
+
type SemanticIntegratorConfig,
|
|
153
|
+
|
|
154
|
+
SpacedRepetition,
|
|
155
|
+
type SpacedRepetitionConfig,
|
|
156
|
+
|
|
157
|
+
ForgettingCurve,
|
|
158
|
+
type ForgettingCurveConfig,
|
|
159
|
+
|
|
160
|
+
DreamSimulator,
|
|
161
|
+
type DreamSimulatorConfig,
|
|
162
|
+
|
|
163
|
+
// ── Executive Engines ────────────────────────────────────────
|
|
164
|
+
|
|
165
|
+
ExecutiveEngine,
|
|
166
|
+
type ExecutiveEngineConfig,
|
|
167
|
+
|
|
168
|
+
GoalManager,
|
|
169
|
+
type GoalManagerConfig,
|
|
170
|
+
|
|
171
|
+
PlanningEngine,
|
|
172
|
+
type PlanningEngineConfig,
|
|
173
|
+
type ActivityEvent,
|
|
174
|
+
type ActivityEventHandler,
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
InhibitionController,
|
|
178
|
+
type InhibitionControllerConfig,
|
|
179
|
+
|
|
180
|
+
TaskSwitcher,
|
|
181
|
+
type TaskSwitcherConfig,
|
|
182
|
+
|
|
183
|
+
// ── Meta-Cognitive Engines ───────────────────────────────────
|
|
184
|
+
|
|
185
|
+
SelfModelUpdater,
|
|
186
|
+
type SelfModelUpdaterConfig,
|
|
187
|
+
|
|
188
|
+
ConfidenceCalibrator,
|
|
189
|
+
type ConfidenceCalibratorConfig,
|
|
190
|
+
|
|
191
|
+
BiasDetector,
|
|
192
|
+
type BiasDetectorConfig,
|
|
193
|
+
|
|
194
|
+
AutobiographicalNarrator,
|
|
195
|
+
type AutobiographicalNarratorConfig,
|
|
196
|
+
|
|
197
|
+
IntrospectionEngine,
|
|
198
|
+
type IntrospectionEngineConfig,
|
|
199
|
+
|
|
200
|
+
PersonaConsolidator,
|
|
201
|
+
type PersonaConsolidatorConfig,
|
|
202
|
+
|
|
203
|
+
// ── Social Engines ───────────────────────────────────────────
|
|
204
|
+
|
|
205
|
+
TheoryOfMind,
|
|
206
|
+
type TheoryOfMindConfig,
|
|
207
|
+
|
|
208
|
+
EmpathySimulator,
|
|
209
|
+
type EmpathySimulatorConfig,
|
|
210
|
+
|
|
211
|
+
ReputationTracker,
|
|
212
|
+
type ReputationTrackerConfig,
|
|
213
|
+
|
|
214
|
+
KnownEntityTracker,
|
|
215
|
+
type KnownEntityTrackerConfig,
|
|
216
|
+
|
|
217
|
+
// ── Agency Engines ───────────────────────────────────────────
|
|
218
|
+
|
|
219
|
+
AuditionEngine,
|
|
220
|
+
VisionEngine,
|
|
221
|
+
SomatosensationEngine,
|
|
222
|
+
OlfactionEngine,
|
|
223
|
+
GustationEngine,
|
|
224
|
+
|
|
225
|
+
// ── Senses Engines ───────────────────────────────────────────
|
|
226
|
+
|
|
227
|
+
AffordanceSynthesizer,
|
|
228
|
+
ActionSelector,
|
|
229
|
+
DeliberationEngine,
|
|
230
|
+
MotorSchemaExecutor,
|
|
231
|
+
ReafferenceEngine
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export type EngineRegistry = {
|
|
235
|
+
instructionIntake: InstructionIntake
|
|
236
|
+
energyRegulator: EnergyRegulator
|
|
237
|
+
sleepPressureRegulator: SleepPressureRegulator
|
|
238
|
+
circadianOscillator: CircadianOscillator
|
|
239
|
+
attentionAllocator: AttentionAllocator
|
|
240
|
+
stressRegulator: StressRegulator
|
|
241
|
+
exteroception: Exteroception
|
|
242
|
+
interoception: Interoception
|
|
243
|
+
socialPerception: SocialPerception
|
|
244
|
+
noveltyDetector: NoveltyDetector
|
|
245
|
+
threatEvaluator: ThreatEvaluator
|
|
246
|
+
rewardEvaluator: RewardEvaluator
|
|
247
|
+
lossEvaluator: LossEvaluator
|
|
248
|
+
frustrationEvaluator: FrustrationEvaluator
|
|
249
|
+
attachmentEvaluator: AttachmentEvaluator
|
|
250
|
+
aestheticEvaluator: AestheticEvaluator
|
|
251
|
+
moralEvaluator: MoralEvaluator
|
|
252
|
+
affectiveBlender: AffectiveBlender
|
|
253
|
+
workingMemory: WorkingMemory
|
|
254
|
+
episodicConsolidator: EpisodicConsolidator
|
|
255
|
+
semanticIntegrator: SemanticIntegrator
|
|
256
|
+
spacedRepetition: SpacedRepetition
|
|
257
|
+
forgettingCurve: ForgettingCurve
|
|
258
|
+
dreamSimulator: DreamSimulator
|
|
259
|
+
executiveEngine: ExecutiveEngine
|
|
260
|
+
goalManager: GoalManager
|
|
261
|
+
planningEngine: PlanningEngine
|
|
262
|
+
inhibitionCtrl: InhibitionController
|
|
263
|
+
taskSwitcher: TaskSwitcher
|
|
264
|
+
selfModelUpdater: SelfModelUpdater
|
|
265
|
+
confidenceCalibrator: ConfidenceCalibrator
|
|
266
|
+
biasDetector: BiasDetector
|
|
267
|
+
autobiographicalNarrator: AutobiographicalNarrator
|
|
268
|
+
introspectionEngine: IntrospectionEngine
|
|
269
|
+
personaConsolidator: PersonaConsolidator
|
|
270
|
+
theoryOfMind: TheoryOfMind
|
|
271
|
+
empathySimulator: EmpathySimulator
|
|
272
|
+
reputationTracker: ReputationTracker
|
|
273
|
+
knownEntityTracker: KnownEntityTracker
|
|
274
|
+
|
|
275
|
+
// ── Senses ─────────────────────────────────────────────────
|
|
276
|
+
auditionEngine: AuditionEngine
|
|
277
|
+
visionEngine: VisionEngine
|
|
278
|
+
somatosensationEngine: SomatosensationEngine
|
|
279
|
+
olfactionEngine: OlfactionEngine
|
|
280
|
+
gustationEngine: GustationEngine
|
|
281
|
+
|
|
282
|
+
// ── Agency pipeline (perception→competition→enaction→learning) ─
|
|
283
|
+
affordanceSynthesizer: AffordanceSynthesizer
|
|
284
|
+
actionSelector: ActionSelector
|
|
285
|
+
deliberationEngine: DeliberationEngine
|
|
286
|
+
motorSchemaExecutor: MotorSchemaExecutor
|
|
287
|
+
reafferenceEngine: ReafferenceEngine
|
|
288
|
+
|
|
289
|
+
// ── Utility Engines ─────────────────────────────────────────
|
|
290
|
+
tokenTracker: TokenTracker
|
|
291
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
// ─────────────────────────────────────────────────────────────
|
|
2
|
+
// src/cognition/instruction.handler.ts
|
|
3
|
+
// ─────────────────────────────────────────────────────────────
|
|
4
|
+
|
|
5
|
+
import type { ReadonlySimulationState } from '#core/types'
|
|
6
|
+
import { wallClock } from '#core/wall.clock'
|
|
7
|
+
|
|
8
|
+
export interface Instruction {
|
|
9
|
+
/** Unique ID */
|
|
10
|
+
id: string
|
|
11
|
+
/** Who gave the instruction */
|
|
12
|
+
source: string
|
|
13
|
+
/** What to do */
|
|
14
|
+
directive: string
|
|
15
|
+
/** Priority override (0-1, higher = more important) */
|
|
16
|
+
priority: number
|
|
17
|
+
/** Deadline in ticks (if any) */
|
|
18
|
+
deadline?: number
|
|
19
|
+
/** Constraints on how to execute */
|
|
20
|
+
constraints?: string[]
|
|
21
|
+
/** Context/provenance — why this instruction was given */
|
|
22
|
+
context: string
|
|
23
|
+
/** Whether the Will can refuse */
|
|
24
|
+
isOverridable: boolean
|
|
25
|
+
/** Status */
|
|
26
|
+
status: 'pending' | 'accepted' | 'in_progress' | 'completed' | 'refused' | 'failed'
|
|
27
|
+
/** When it was received */
|
|
28
|
+
receivedAt: number
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export class InstructionHandler {
|
|
32
|
+
private _pending: Instruction[] = []
|
|
33
|
+
private _history: Instruction[] = []
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Receive an instruction from an external source.
|
|
37
|
+
* Converts it to a goal in the GoalManager if accepted.
|
|
38
|
+
*/
|
|
39
|
+
receive( instruction: Omit<Instruction, 'status' | 'receivedAt'> ): Instruction {
|
|
40
|
+
const full: Instruction = {
|
|
41
|
+
...instruction,
|
|
42
|
+
status: 'pending',
|
|
43
|
+
// External arrival timestamp — bookkeeping only, never persisted to entity
|
|
44
|
+
// state, the event log, or a snapshot (convertToGoal drops it), so this is
|
|
45
|
+
// a legitimate wall-clock boundary rather than replay-affecting state.
|
|
46
|
+
receivedAt: wallClock(),
|
|
47
|
+
}
|
|
48
|
+
this._pending.push( full )
|
|
49
|
+
return full
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Evaluate pending instructions against current state.
|
|
54
|
+
* Called each tick before decision-making.
|
|
55
|
+
* Returns instructions that should be converted to goals.
|
|
56
|
+
*/
|
|
57
|
+
evaluatePending(
|
|
58
|
+
state: ReadonlySimulationState,
|
|
59
|
+
currentValues: string[]
|
|
60
|
+
): Instruction[] {
|
|
61
|
+
const actionable: Instruction[] = []
|
|
62
|
+
|
|
63
|
+
for( const instruction of this._pending ){
|
|
64
|
+
if( instruction.status !== 'pending') continue
|
|
65
|
+
|
|
66
|
+
// Check if the Will should refuse based on values
|
|
67
|
+
if( this._shouldRefuse( instruction, state, currentValues ) ){
|
|
68
|
+
instruction.status = 'refused'
|
|
69
|
+
this._history.push( instruction )
|
|
70
|
+
continue
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
instruction.status = 'accepted'
|
|
74
|
+
actionable.push( instruction )
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Clean up processed instructions
|
|
78
|
+
this._pending = this._pending.filter( i => i.status === 'pending')
|
|
79
|
+
return actionable
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Convert accepted instructions into goals.
|
|
84
|
+
*/
|
|
85
|
+
convertToGoal( instruction: Instruction ): {
|
|
86
|
+
description: string
|
|
87
|
+
priority: number
|
|
88
|
+
tags: string[]
|
|
89
|
+
completionType: 'action'
|
|
90
|
+
completionCondition?: string
|
|
91
|
+
} {
|
|
92
|
+
return {
|
|
93
|
+
description: instruction.directive,
|
|
94
|
+
priority: instruction.priority,
|
|
95
|
+
tags: [ 'instruction', `source:${instruction.source}` ],
|
|
96
|
+
completionType: 'action',
|
|
97
|
+
completionCondition: instruction.constraints?.join(' AND '),
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
markCompleted( instructionId: string ): void {
|
|
102
|
+
const instruction = this._history.find( i => i.id === instructionId )
|
|
103
|
+
if( instruction ) instruction.status = 'completed'
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
markFailed( instructionId: string, reason: string ): void {
|
|
107
|
+
const instruction = this._history.find( i => i.id === instructionId )
|
|
108
|
+
if( instruction ){
|
|
109
|
+
instruction.status = 'failed'
|
|
110
|
+
instruction.context += ` | Failed: ${reason}`
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
getPending(): ReadonlyArray<Instruction> {
|
|
115
|
+
return this._pending
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
getHistory(): ReadonlyArray<Instruction> {
|
|
119
|
+
return this._history
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
private _shouldRefuse(
|
|
123
|
+
instruction: Instruction,
|
|
124
|
+
_state: ReadonlySimulationState,
|
|
125
|
+
values: string[]
|
|
126
|
+
): boolean {
|
|
127
|
+
// Can't refuse non-overridable instructions
|
|
128
|
+
if( !instruction.isOverridable ) return false
|
|
129
|
+
|
|
130
|
+
// Check against core values
|
|
131
|
+
if( values.includes('self-preservation') ){
|
|
132
|
+
// Check if instruction seems dangerous
|
|
133
|
+
const dangerous = [ 'attack', 'destroy', 'harm', 'kill', 'steal' ]
|
|
134
|
+
if( dangerous.some( d => instruction.directive.toLowerCase().includes( d ) ) )
|
|
135
|
+
return true
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if( values.includes('honesty') ){
|
|
139
|
+
const deceptive = [ 'lie', 'deceive', 'trick', 'manipulate' ]
|
|
140
|
+
if( deceptive.some( d => instruction.directive.toLowerCase().includes( d ) ) )
|
|
141
|
+
return true
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return false
|
|
145
|
+
}
|
|
146
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// ─────────────────────────────────────────────────────────────
|
|
2
|
+
// src/cognition/memory/index.ts
|
|
3
|
+
// ─────────────────────────────────────────────────────────────
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Vector memory module exports.
|
|
7
|
+
*
|
|
8
|
+
* Provides semantic similarity search for episodic memory
|
|
9
|
+
* without breaking deterministic replay or existing Map-based state.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
DefaultVectorMemoryAdapter,
|
|
14
|
+
type VectorMemoryAdapter
|
|
15
|
+
} from '#memory/vector.adapter'
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
HNSWIndex,
|
|
19
|
+
type VectorIndex
|
|
20
|
+
} from '#memory/vector.index'
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
OpenAICompatibleEmbedder,
|
|
24
|
+
MockEmbedder,
|
|
25
|
+
type EmbeddingProvider
|
|
26
|
+
} from '#memory/vector.embedder'
|
|
27
|
+
|
|
28
|
+
export { episodeContentToText } from '#memory/vector.content'
|
|
29
|
+
|
|
30
|
+
export type {
|
|
31
|
+
VectorMemoryConfig,
|
|
32
|
+
VectorRecord,
|
|
33
|
+
VectorQueryResult,
|
|
34
|
+
VectorQueryFilter
|
|
35
|
+
} from '#memory/vector.types'
|