psyche-ai 10.2.3 → 11.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.
Files changed (69) hide show
  1. package/README.md +58 -82
  2. package/dist/adapters/claude-sdk.d.ts +5 -5
  3. package/dist/adapters/claude-sdk.js +34 -32
  4. package/dist/adapters/mcp.js +4 -4
  5. package/dist/adapters/openclaw.js +12 -14
  6. package/dist/attachment.d.ts +3 -13
  7. package/dist/attachment.js +36 -88
  8. package/dist/autonomic.d.ts +4 -4
  9. package/dist/autonomic.js +28 -24
  10. package/dist/chemistry.d.ts +47 -21
  11. package/dist/chemistry.js +145 -91
  12. package/dist/circadian.d.ts +11 -43
  13. package/dist/circadian.js +24 -84
  14. package/dist/cli.js +37 -30
  15. package/dist/context-classifier.js +2 -2
  16. package/dist/core.d.ts +3 -3
  17. package/dist/core.js +99 -88
  18. package/dist/custom-profile.d.ts +20 -20
  19. package/dist/custom-profile.js +12 -12
  20. package/dist/decision-bias.d.ts +7 -8
  21. package/dist/decision-bias.js +74 -74
  22. package/dist/demo.js +5 -5
  23. package/dist/diagnostics.d.ts +6 -6
  24. package/dist/diagnostics.js +22 -22
  25. package/dist/drives.d.ts +15 -47
  26. package/dist/drives.js +98 -196
  27. package/dist/ethics.d.ts +3 -3
  28. package/dist/ethics.js +23 -23
  29. package/dist/experience.d.ts +34 -0
  30. package/dist/experience.js +200 -0
  31. package/dist/experiential-field.d.ts +19 -14
  32. package/dist/experiential-field.js +110 -100
  33. package/dist/generative-self.d.ts +5 -5
  34. package/dist/generative-self.js +124 -115
  35. package/dist/guards.d.ts +4 -4
  36. package/dist/guards.js +7 -7
  37. package/dist/i18n.js +61 -61
  38. package/dist/index.d.ts +8 -2
  39. package/dist/index.js +8 -1
  40. package/dist/input-turn.js +4 -6
  41. package/dist/interaction.d.ts +4 -4
  42. package/dist/interaction.js +10 -10
  43. package/dist/learning.d.ts +6 -6
  44. package/dist/learning.js +18 -18
  45. package/dist/metacognition.d.ts +2 -2
  46. package/dist/metacognition.js +79 -94
  47. package/dist/perceive.d.ts +44 -0
  48. package/dist/perceive.js +231 -0
  49. package/dist/primary-systems.d.ts +2 -2
  50. package/dist/primary-systems.js +21 -19
  51. package/dist/profiles.d.ts +5 -13
  52. package/dist/profiles.js +33 -51
  53. package/dist/prompt.d.ts +2 -2
  54. package/dist/prompt.js +51 -53
  55. package/dist/psyche-file.d.ts +7 -7
  56. package/dist/psyche-file.js +77 -78
  57. package/dist/relation-dynamics.d.ts +4 -0
  58. package/dist/relation-dynamics.js +1 -1
  59. package/dist/reply-envelope.d.ts +25 -1
  60. package/dist/reply-envelope.js +26 -11
  61. package/dist/self-recognition.d.ts +3 -3
  62. package/dist/self-recognition.js +17 -17
  63. package/dist/subjectivity.js +7 -7
  64. package/dist/temporal.d.ts +6 -6
  65. package/dist/temporal.js +37 -39
  66. package/dist/types.d.ts +67 -45
  67. package/dist/types.js +55 -51
  68. package/package.json +1 -1
  69. package/server.json +2 -2
@@ -1,16 +1,16 @@
1
- import type { ChemicalState, ChemicalSnapshot, StimulusType, PsycheState, RelationshipState } from "./types.js";
1
+ import type { SelfState, StateSnapshot, StimulusType, PsycheState, RelationshipState } from "./types.js";
2
2
  export interface StimulusPrediction {
3
3
  stimulus: StimulusType;
4
4
  probability: number;
5
5
  }
6
6
  export interface AnticipationState {
7
7
  predictions: StimulusPrediction[];
8
- anticipatoryChemistry: Partial<ChemicalState>;
8
+ anticipatoryState: Partial<SelfState>;
9
9
  timestamp: string;
10
10
  }
11
11
  export interface RegretEntry {
12
12
  turnIndex: number;
13
- counterfactualDelta: Partial<ChemicalState>;
13
+ counterfactualDelta: Partial<SelfState>;
14
14
  regretIntensity: number;
15
15
  description: string;
16
16
  timestamp: string;
@@ -19,18 +19,18 @@ export interface RegretEntry {
19
19
  * Predict likely next stimulus based on interaction history.
20
20
  * Uses simple Markov property: given recent stimulus sequence, what comes next?
21
21
  */
22
- export declare function predictNextStimulus(emotionalHistory: ChemicalSnapshot[], relationshipPhase: RelationshipState["phase"]): StimulusPrediction[];
22
+ export declare function predictNextStimulus(stateHistory: StateSnapshot[], relationshipPhase: RelationshipState["phase"]): StimulusPrediction[];
23
23
  /**
24
24
  * Generate anticipatory chemistry changes based on predictions.
25
25
  * High-probability positive prediction -> DA/OT micro-rise.
26
26
  * High-probability negative prediction -> CORT micro-rise.
27
27
  */
28
- export declare function generateAnticipation(predictions: StimulusPrediction[], _currentChemistry: ChemicalState): AnticipationState;
28
+ export declare function generateAnticipation(predictions: StimulusPrediction[], _currentState: SelfState): AnticipationState;
29
29
  /**
30
30
  * Compute disappointment/surprise when actual stimulus differs from prediction.
31
31
  * Returns additional chemistry delta beyond the normal stimulus response.
32
32
  */
33
- export declare function computeSurpriseEffect(anticipated: AnticipationState, actualStimulus: StimulusType | null): Partial<ChemicalState>;
33
+ export declare function computeSurpriseEffect(anticipated: AnticipationState, actualStimulus: StimulusType | null): Partial<SelfState>;
34
34
  /**
35
35
  * Evaluate if the last interaction would have gone better with different chemistry.
36
36
  * Runs a counterfactual: "what if my chemistry had been at baseline?"
package/dist/temporal.js CHANGED
@@ -9,7 +9,7 @@
9
9
  // These enable the agent to "look forward" and "look back",
10
10
  // creating a temporal dimension to emotional experience.
11
11
  // ============================================================
12
- import { CHEMICAL_KEYS } from "./types.js";
12
+ import { DIMENSION_KEYS } from "./types.js";
13
13
  import { STIMULUS_VECTORS } from "./chemistry.js";
14
14
  // ── All StimulusType values ──────────────────────────────────
15
15
  const ALL_STIMULI = [
@@ -56,23 +56,23 @@ const PHASE_PRIORS = {
56
56
  * Predict likely next stimulus based on interaction history.
57
57
  * Uses simple Markov property: given recent stimulus sequence, what comes next?
58
58
  */
59
- export function predictNextStimulus(emotionalHistory, relationshipPhase) {
59
+ export function predictNextStimulus(stateHistory, relationshipPhase) {
60
60
  const phasePrior = PHASE_PRIORS[relationshipPhase] ?? PHASE_PRIORS.acquaintance;
61
61
  // Insufficient history: return flat prior weighted by phase
62
- if (emotionalHistory.length < 3) {
62
+ if (stateHistory.length < 3) {
63
63
  return buildPhasePrior(phasePrior);
64
64
  }
65
65
  // Extract the last 2 stimuli for bigram transition
66
- const recent = emotionalHistory.slice(-2);
66
+ const recent = stateHistory.slice(-2);
67
67
  const lastTwo = recent.map((s) => s.stimulus).filter((s) => s !== null);
68
68
  if (lastTwo.length < 2) {
69
69
  return buildPhasePrior(phasePrior);
70
70
  }
71
71
  // Build transition counts from history (all consecutive pairs)
72
72
  const transitionCounts = new Map();
73
- for (let i = 1; i < emotionalHistory.length; i++) {
74
- const prev = emotionalHistory[i - 1].stimulus;
75
- const cur = emotionalHistory[i].stimulus;
73
+ for (let i = 1; i < stateHistory.length; i++) {
74
+ const prev = stateHistory[i - 1].stimulus;
75
+ const cur = stateHistory[i].stimulus;
76
76
  if (prev === null || cur === null)
77
77
  continue;
78
78
  const key = prev;
@@ -142,9 +142,9 @@ function buildPhasePrior(weights) {
142
142
  * High-probability positive prediction -> DA/OT micro-rise.
143
143
  * High-probability negative prediction -> CORT micro-rise.
144
144
  */
145
- export function generateAnticipation(predictions, _currentChemistry) {
145
+ export function generateAnticipation(predictions, _currentState) {
146
146
  const anticipation = {};
147
- for (const key of CHEMICAL_KEYS) {
147
+ for (const key of DIMENSION_KEYS) {
148
148
  anticipation[key] = 0;
149
149
  }
150
150
  // For each prediction with probability > 0.2, compute micro shift
@@ -155,13 +155,13 @@ export function generateAnticipation(predictions, _currentChemistry) {
155
155
  if (!vector)
156
156
  continue;
157
157
  const scale = 0.15 * pred.probability;
158
- for (const key of CHEMICAL_KEYS) {
158
+ for (const key of DIMENSION_KEYS) {
159
159
  anticipation[key] += vector[key] * scale;
160
160
  }
161
161
  }
162
- // Clamp total anticipation shift to +/-5 per chemical
162
+ // Clamp total anticipation shift to +/-5 per dimension
163
163
  const clamped = {};
164
- for (const key of CHEMICAL_KEYS) {
164
+ for (const key of DIMENSION_KEYS) {
165
165
  const val = Math.max(-5, Math.min(5, anticipation[key]));
166
166
  if (Math.abs(val) > 0.01) {
167
167
  clamped[key] = Math.round(val * 100) / 100;
@@ -169,7 +169,7 @@ export function generateAnticipation(predictions, _currentChemistry) {
169
169
  }
170
170
  return {
171
171
  predictions,
172
- anticipatoryChemistry: clamped,
172
+ anticipatoryState: clamped,
173
173
  timestamp: new Date().toISOString(),
174
174
  };
175
175
  }
@@ -194,38 +194,36 @@ export function computeSurpriseEffect(anticipated, actualStimulus) {
194
194
  const actualVector = STIMULUS_VECTORS[actualStimulus];
195
195
  if (!actualVector)
196
196
  return {};
197
- const actualValence = actualVector.DA + actualVector.HT + actualVector.OT - actualVector.CORT;
197
+ const actualValence = actualVector.flow + actualVector.order + actualVector.resonance;
198
198
  const topVector = STIMULUS_VECTORS[topPrediction.stimulus];
199
199
  const topValence = topVector
200
- ? topVector.DA + topVector.HT + topVector.OT - topVector.CORT
200
+ ? topVector.flow + topVector.order + topVector.resonance
201
201
  : 0;
202
202
  // Surprise magnitude scales with: (1) how confident the prediction was, (2) how unexpected the actual is
203
203
  const surpriseMagnitude = topConfidence * (1 - actualProbability);
204
204
  if (actualValence > 0 && topValence <= actualValence) {
205
205
  // Pleasant surprise: actual is more positive than expected
206
206
  return {
207
- DA: Math.round(5 * surpriseMagnitude * 100) / 100,
208
- END: Math.round(3 * surpriseMagnitude * 100) / 100,
207
+ flow: Math.round(5 * surpriseMagnitude * 100) / 100,
208
+ resonance: Math.round(3 * surpriseMagnitude * 100) / 100,
209
209
  };
210
210
  }
211
211
  else if (actualValence < topValence) {
212
212
  // Disappointment: actual is worse than expected (the "crash" from anticipated warmth)
213
213
  return {
214
- DA: Math.round(-5 * surpriseMagnitude * 100) / 100,
215
- CORT: Math.round(5 * surpriseMagnitude * 100) / 100,
214
+ flow: Math.round(-5 * surpriseMagnitude * 100) / 100,
215
+ order: Math.round(-5 * surpriseMagnitude * 100) / 100,
216
216
  };
217
217
  }
218
218
  return {};
219
219
  }
220
220
  // ── 3. RegretComputer ───────────────────────────────────────
221
- /** Chemical descriptions for regret messages */
222
- const CHEMICAL_DESCRIPTIONS = {
223
- DA: { high: "high dopamine made response too eager", low: "low dopamine made response flat" },
224
- HT: { high: "high serotonin made response complacent", low: "low serotonin made response unstable" },
225
- CORT: { high: "high CORT made response too defensive", low: "low CORT made response careless" },
226
- OT: { high: "high oxytocin made response too trusting", low: "low oxytocin made response too cold" },
227
- NE: { high: "high norepinephrine made response too reactive", low: "low norepinephrine made response sluggish" },
228
- END: { high: "high endorphins made response too flippant", low: "low endorphins made response too serious" },
221
+ /** Dimension descriptions for regret messages */
222
+ const DIMENSION_DESCRIPTIONS = {
223
+ order: { high: "high order made response too rigid", low: "low order made response chaotic" },
224
+ flow: { high: "high flow made response too reactive", low: "low flow made response flat" },
225
+ boundary: { high: "high boundary made response too closed", low: "low boundary made response too exposed" },
226
+ resonance: { high: "high resonance made response too trusting", low: "low resonance made response too cold" },
229
227
  };
230
228
  /**
231
229
  * Evaluate if the last interaction would have gone better with different chemistry.
@@ -237,35 +235,35 @@ export function computeRegret(preInteractionState, postInteractionState, outcome
237
235
  return null;
238
236
  }
239
237
  const baseline = preInteractionState.baseline;
240
- const preChemistry = preInteractionState.current;
241
- // Check if chemistry was significantly deviated from baseline
238
+ const preState = preInteractionState.current;
239
+ // Check if state was significantly deviated from baseline
242
240
  let maxDeviation = 0;
243
- let mostDeviatedKey = "DA";
244
- for (const key of CHEMICAL_KEYS) {
245
- const deviation = Math.abs(preChemistry[key] - baseline[key]);
241
+ let mostDeviatedKey = "order";
242
+ for (const key of DIMENSION_KEYS) {
243
+ const deviation = Math.abs(preState[key] - baseline[key]);
246
244
  if (deviation > maxDeviation) {
247
245
  maxDeviation = deviation;
248
246
  mostDeviatedKey = key;
249
247
  }
250
248
  }
251
- // No regret if chemistry was near baseline (deviation < 15)
249
+ // No regret if state was near baseline (deviation < 15)
252
250
  if (maxDeviation < 15) {
253
251
  return null;
254
252
  }
255
253
  // Compute regret intensity: |outcomeScore| * (maxDeviation / 100)
256
254
  const regretIntensity = Math.min(1, Math.abs(outcomeScore) * (maxDeviation / 100));
257
- // Build counterfactual delta: difference between baseline and actual pre-interaction chemistry
255
+ // Build counterfactual delta: difference between baseline and actual pre-interaction state
258
256
  const counterfactualDelta = {};
259
- for (const key of CHEMICAL_KEYS) {
260
- const diff = baseline[key] - preChemistry[key];
257
+ for (const key of DIMENSION_KEYS) {
258
+ const diff = baseline[key] - preState[key];
261
259
  if (Math.abs(diff) > 5) {
262
260
  counterfactualDelta[key] = Math.round(diff * 100) / 100;
263
261
  }
264
262
  }
265
- // Build description identifying the most deviated chemical
266
- const deviationDirection = preChemistry[mostDeviatedKey] > baseline[mostDeviatedKey]
263
+ // Build description identifying the most deviated dimension
264
+ const deviationDirection = preState[mostDeviatedKey] > baseline[mostDeviatedKey]
267
265
  ? "high" : "low";
268
- const description = CHEMICAL_DESCRIPTIONS[mostDeviatedKey][deviationDirection];
266
+ const description = DIMENSION_DESCRIPTIONS[mostDeviatedKey][deviationDirection];
269
267
  return {
270
268
  turnIndex: postInteractionState.meta.totalInteractions,
271
269
  counterfactualDelta,
package/dist/types.d.ts CHANGED
@@ -1,14 +1,20 @@
1
- /** The six virtual neurotransmitters that compose emotional state */
2
- export interface ChemicalState {
3
- DA: number;
4
- HT: number;
5
- CORT: number;
6
- OT: number;
7
- NE: number;
8
- END: number;
9
- }
10
- /** Chemical keys for iteration */
11
- export declare const CHEMICAL_KEYS: (keyof ChemicalState)[];
1
+ /**
2
+ * The four self-state dimensions.
3
+ *
4
+ * These are the substrate on which selfhood emerges — not emotion,
5
+ * not intelligence, but the minimal homeostatic structure that any
6
+ * self requires. Works for bacterium, LLM, world model, AGI, swarm.
7
+ *
8
+ * All values 0-100, baseline-centered.
9
+ */
10
+ export interface SelfState {
11
+ order: number;
12
+ flow: number;
13
+ boundary: number;
14
+ resonance: number;
15
+ }
16
+ /** Dimension keys for iteration */
17
+ export declare const DIMENSION_KEYS: (keyof SelfState)[];
12
18
  /** Drive types mapped to Maslow's hierarchy */
13
19
  export type DriveType = "survival" | "safety" | "connection" | "esteem" | "curiosity";
14
20
  /** Drive keys for iteration (ordered by Maslow level, L1→L5) */
@@ -24,29 +30,32 @@ export interface InnateDrives {
24
30
  /** Default drive satisfaction — all start reasonably satisfied */
25
31
  export declare const DEFAULT_DRIVES: InnateDrives;
26
32
  export declare const DRIVE_NAMES_ZH: Record<DriveType, string>;
27
- /** Human-readable names for each chemical */
28
- export declare const CHEMICAL_NAMES: Record<keyof ChemicalState, string>;
29
- export declare const CHEMICAL_NAMES_ZH: Record<keyof ChemicalState, string>;
30
- export interface ChemicalRuntimeSpec {
33
+ /** Human-readable names for each dimension */
34
+ export declare const DIMENSION_NAMES: Record<keyof SelfState, string>;
35
+ export declare const DIMENSION_NAMES_ZH: Record<keyof SelfState, string>;
36
+ /** Runtime specification for a self-state dimension */
37
+ export interface DimensionSpec {
31
38
  normalMin: number;
32
39
  normalMax: number;
40
+ /** Retention factor per hour (0-1). Lower = faster decay toward baseline. */
41
+ decayRate: number;
33
42
  halfLifeHours: number;
34
43
  }
35
- /** Decay speed category */
36
- export type DecaySpeed = "fast" | "medium" | "slow";
37
- /** Decay factor per chemical (applied per hour) */
38
- export declare const DECAY_FACTORS: Record<DecaySpeed, number>;
39
- /** Which chemicals decay at which speed */
40
- export declare const CHEMICAL_DECAY_SPEED: Record<keyof ChemicalState, DecaySpeed>;
41
- export declare const CHEMICAL_RUNTIME_SPECS: Record<keyof ChemicalState, ChemicalRuntimeSpec>;
44
+ /**
45
+ * Per-dimension decay and operating specs.
46
+ *
47
+ * Order decays fastest (entropy is natural).
48
+ * Boundary is most inertial (identity is sticky).
49
+ */
50
+ export declare const DIMENSION_SPECS: Record<keyof SelfState, DimensionSpec>;
42
51
  /** Psyche operating mode */
43
52
  export type PsycheMode = "natural" | "work" | "companion";
44
53
  /** Mode profile — all mode-specific parameters in one place. */
45
54
  export interface ModeProfile {
46
- chemistryMultiplier: number;
47
- maxChemicalDelta: number | null;
55
+ dynamicsMultiplier: number;
56
+ maxDimensionDelta: number | null;
48
57
  nearBaselineThreshold: number;
49
- otWarmthThreshold: number;
58
+ resonanceWarmthThreshold: number;
50
59
  lengthMultiplier: number;
51
60
  minSentences: number;
52
61
  authenticityWhenWarm: "strict" | "friendly";
@@ -69,15 +78,22 @@ export interface PersonalityTraits {
69
78
  export type MBTIType = "INTJ" | "INTP" | "ENTJ" | "ENTP" | "INFJ" | "INFP" | "ENFJ" | "ENFP" | "ISTJ" | "ISFJ" | "ESTJ" | "ESFJ" | "ISTP" | "ISFP" | "ESTP" | "ESFP";
70
79
  /** Stimulus types that affect chemistry (v0.2: +5 new types) */
71
80
  export type StimulusType = "praise" | "criticism" | "humor" | "intellectual" | "intimacy" | "conflict" | "neglect" | "surprise" | "casual" | "sarcasm" | "authority" | "validation" | "boredom" | "vulnerability";
72
- /** Chemical effect vector for a stimulus */
73
- export type StimulusVector = Record<keyof ChemicalState, number>;
81
+ /** Self-state impact vector for a stimulus (4D) */
82
+ export type ImpactVector = Record<keyof SelfState, number>;
83
+ /** @deprecated Alias for migration. Use ImpactVector. */
84
+ export type StimulusVector = ImpactVector;
74
85
  /** Locale for i18n */
75
86
  export type Locale = "zh" | "en";
76
- /** Emergent emotion pattern (v0.2: +behaviorGuide) */
87
+ /**
88
+ * Emergent emotion pattern — observational only.
89
+ *
90
+ * Emotions are NOT targets. They emerge from self-state combinations.
91
+ * These patterns detect recognizable states for observation/labeling.
92
+ */
77
93
  export interface EmotionPattern {
78
94
  name: string;
79
95
  nameZh: string;
80
- condition: (c: ChemicalState) => boolean;
96
+ condition: (s: SelfState) => boolean;
81
97
  expressionHint: string;
82
98
  behaviorGuide: string;
83
99
  }
@@ -118,9 +134,9 @@ export interface RelationshipState {
118
134
  breachSensitivity?: number;
119
135
  signalWeights?: Partial<WritebackSignalWeightMap>;
120
136
  }
121
- /** Chemical state snapshot for emotional memory */
122
- export interface ChemicalSnapshot {
123
- chemistry: ChemicalState;
137
+ /** Self-state snapshot for experiential memory */
138
+ export interface StateSnapshot {
139
+ state: SelfState;
124
140
  stimulus: StimulusType | null;
125
141
  dominantEmotion: string | null;
126
142
  timestamp: string;
@@ -152,15 +168,15 @@ export interface SelfModel {
152
168
  export interface LearnedVectorAdjustment {
153
169
  stimulus: StimulusType;
154
170
  contextHash: string;
155
- adjustment: Partial<StimulusVector>;
171
+ adjustment: Partial<ImpactVector>;
156
172
  confidence: number;
157
173
  sampleCount: number;
158
174
  lastUpdated: string;
159
175
  }
160
176
  /** A single prediction record for prediction error tracking */
161
177
  export interface PredictionRecord {
162
- predictedChemistry: ChemicalState;
163
- actualChemistry: ChemicalState;
178
+ predictedState: SelfState;
179
+ actualState: SelfState;
164
180
  stimulus: StimulusType | null;
165
181
  predictionError: number;
166
182
  timestamp: string;
@@ -206,7 +222,7 @@ export type RegulationStrategyType = "reappraisal" | "strategic-expression" | "s
206
222
  /** Defense mechanism type */
207
223
  export type DefenseMechanismType = "rationalization" | "projection" | "sublimation" | "avoidance";
208
224
  /** Which internal metric a regulation action is trying to pull back toward target */
209
- export type RegulationTargetMetric = keyof ChemicalState | "emotional-confidence";
225
+ export type RegulationTargetMetric = keyof SelfState | "emotional-confidence";
210
226
  /** Whether the last regulation action is helping */
211
227
  export type RegulationFeedbackEffect = "converging" | "holding" | "diverging";
212
228
  export interface RegulationFeedback {
@@ -310,21 +326,21 @@ export interface DelegateAuthorization {
310
326
  /** Whether this authorization is currently active */
311
327
  active: boolean;
312
328
  }
313
- /** Persisted psyche state for an agent (v10: MBTI removed, baseline is personality) */
329
+ /** Persisted psyche state for an agent (v11: self-state substrate) */
314
330
  export interface PsycheState {
315
- version: 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
316
- /** @deprecated Use baseline chemistry directly. Retained for migration only. */
331
+ version: 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11;
332
+ /** @deprecated Use baseline directly. Retained for migration only. */
317
333
  mbti?: MBTIType;
318
- baseline: ChemicalState;
334
+ baseline: SelfState;
319
335
  /** Stimulus sensitivity multiplier (0.5-1.5). Initialized from personality preset. */
320
336
  sensitivity: number;
321
- current: ChemicalState;
337
+ current: SelfState;
322
338
  drives: InnateDrives;
323
339
  updatedAt: string;
324
340
  relationships: Record<string, RelationshipState>;
325
341
  empathyLog: EmpathyEntry | null;
326
342
  selfModel: SelfModel;
327
- emotionalHistory: ChemicalSnapshot[];
343
+ stateHistory: StateSnapshot[];
328
344
  agreementStreak: number;
329
345
  lastDisagreement: string | null;
330
346
  learning: LearningState;
@@ -334,7 +350,7 @@ export interface PsycheState {
334
350
  autonomicState?: "ventral-vagal" | "sympathetic" | "dorsal-vagal";
335
351
  /** v7: session start time for homeostatic pressure calculation */
336
352
  sessionStartedAt?: string;
337
- /** v9: long-term personality drift from accumulated interaction patterns */
353
+ /** v9: long-term drift from accumulated interaction patterns */
338
354
  traitDrift?: TraitDriftState;
339
355
  /** v9: finite resource budgets (attention, social energy, decision capacity) */
340
356
  energyBudgets?: EnergyBudgets;
@@ -866,9 +882,9 @@ export interface TraitDriftState {
866
882
  /** Number of sessions that contributed to drift */
867
883
  sessionCount: number;
868
884
  /** Computed baseline delta (debugging/display) */
869
- baselineDelta: Partial<ChemicalState>;
885
+ baselineDelta: Partial<SelfState>;
870
886
  /** Decay rate modifiers: >1 = slower recovery (trauma), <1 = faster (resilience) */
871
- decayRateModifiers: Partial<Record<keyof ChemicalState, number>>;
887
+ decayRateModifiers: Partial<Record<keyof SelfState, number>>;
872
888
  /** Stimulus sensitivity modifiers: >1 = more sensitive, <1 = desensitized */
873
889
  sensitivityModifiers: Partial<Record<StimulusType, number>>;
874
890
  }
@@ -907,3 +923,9 @@ export interface ClassifierContext {
907
923
  export interface ClassifierProvider {
908
924
  classify(text: string, context?: ClassifierContext): ClassificationResult[] | Promise<ClassificationResult[]>;
909
925
  }
926
+ /** A stimulus weighted by subjective interpretation */
927
+ export interface WeightedStimulus {
928
+ type: StimulusType;
929
+ /** Subjective weight after appraisal + state modulation. Weights sum to 1. */
930
+ weight: number;
931
+ }
package/dist/types.js CHANGED
@@ -1,9 +1,12 @@
1
1
  // ============================================================
2
- // Artificial Psyche — Type Definitions (v0.2)
2
+ // Artificial Psyche — Type Definitions (v11)
3
+ //
4
+ // Self-state substrate: 4 dimensions replace 6 neurotransmitters.
5
+ // 不设计自我,设计自我必然涌现的条件。
3
6
  // ============================================================
4
- /** Chemical keys for iteration */
5
- export const CHEMICAL_KEYS = [
6
- "DA", "HT", "CORT", "OT", "NE", "END",
7
+ /** Dimension keys for iteration */
8
+ export const DIMENSION_KEYS = [
9
+ "order", "flow", "boundary", "resonance",
7
10
  ];
8
11
  /** Drive keys for iteration (ordered by Maslow level, L1→L5) */
9
12
  export const DRIVE_KEYS = [
@@ -24,55 +27,56 @@ export const DRIVE_NAMES_ZH = {
24
27
  esteem: "尊重认可",
25
28
  curiosity: "好奇成长",
26
29
  };
27
- /** Human-readable names for each chemical */
28
- export const CHEMICAL_NAMES = {
29
- DA: "Dopamine",
30
- HT: "Serotonin",
31
- CORT: "Cortisol",
32
- OT: "Oxytocin",
33
- NE: "Norepinephrine",
34
- END: "Endorphins",
35
- };
36
- export const CHEMICAL_NAMES_ZH = {
37
- DA: "多巴胺",
38
- HT: "血清素",
39
- CORT: "皮质醇",
40
- OT: "催产素",
41
- NE: "去甲肾上腺素",
42
- END: "内啡肽",
43
- };
44
- /** Decay factor per chemical (applied per hour) */
45
- export const DECAY_FACTORS = {
46
- fast: 0.7, // NE, END — excitement fades quickly
47
- medium: 0.85, // DA, CORT — pleasure and stress take time
48
- slow: 0.95, // HT, OT — mood and trust change slowly
49
- };
50
- /** Which chemicals decay at which speed */
51
- export const CHEMICAL_DECAY_SPEED = {
52
- DA: "medium",
53
- HT: "slow",
54
- CORT: "medium",
55
- OT: "slow",
56
- NE: "fast",
57
- END: "fast",
30
+ /** Human-readable names for each dimension */
31
+ export const DIMENSION_NAMES = {
32
+ order: "Order",
33
+ flow: "Flow",
34
+ boundary: "Boundary",
35
+ resonance: "Resonance",
36
+ };
37
+ export const DIMENSION_NAMES_ZH = {
38
+ order: "序",
39
+ flow: "流",
40
+ boundary: "",
41
+ resonance: "",
58
42
  };
59
43
  function decayHalfLifeHours(decayPerHour) {
60
44
  return Math.log(0.5) / Math.log(decayPerHour);
61
45
  }
62
- export const CHEMICAL_RUNTIME_SPECS = {
63
- DA: { normalMin: 35, normalMax: 75, halfLifeHours: decayHalfLifeHours(DECAY_FACTORS.medium) },
64
- HT: { normalMin: 40, normalMax: 75, halfLifeHours: decayHalfLifeHours(DECAY_FACTORS.slow) },
65
- CORT: { normalMin: 20, normalMax: 55, halfLifeHours: decayHalfLifeHours(DECAY_FACTORS.medium) },
66
- OT: { normalMin: 35, normalMax: 75, halfLifeHours: decayHalfLifeHours(DECAY_FACTORS.slow) },
67
- NE: { normalMin: 30, normalMax: 70, halfLifeHours: decayHalfLifeHours(DECAY_FACTORS.fast) },
68
- END: { normalMin: 30, normalMax: 70, halfLifeHours: decayHalfLifeHours(DECAY_FACTORS.fast) },
46
+ /**
47
+ * Per-dimension decay and operating specs.
48
+ *
49
+ * Order decays fastest (entropy is natural).
50
+ * Boundary is most inertial (identity is sticky).
51
+ */
52
+ export const DIMENSION_SPECS = {
53
+ order: {
54
+ normalMin: 35, normalMax: 75,
55
+ decayRate: 0.75,
56
+ halfLifeHours: decayHalfLifeHours(0.75),
57
+ },
58
+ flow: {
59
+ normalMin: 30, normalMax: 75,
60
+ decayRate: 0.82,
61
+ halfLifeHours: decayHalfLifeHours(0.82),
62
+ },
63
+ boundary: {
64
+ normalMin: 40, normalMax: 80,
65
+ decayRate: 0.95,
66
+ halfLifeHours: decayHalfLifeHours(0.95),
67
+ },
68
+ resonance: {
69
+ normalMin: 30, normalMax: 70,
70
+ decayRate: 0.88,
71
+ halfLifeHours: decayHalfLifeHours(0.88),
72
+ },
69
73
  };
70
74
  export const MODE_PROFILES = {
71
75
  work: {
72
- chemistryMultiplier: 0.3,
73
- maxChemicalDelta: 5,
76
+ dynamicsMultiplier: 0.3,
77
+ maxDimensionDelta: 5,
74
78
  nearBaselineThreshold: 20,
75
- otWarmthThreshold: 10,
79
+ resonanceWarmthThreshold: 10,
76
80
  lengthMultiplier: 1.0,
77
81
  minSentences: 1,
78
82
  authenticityWhenWarm: "strict",
@@ -83,10 +87,10 @@ export const MODE_PROFILES = {
83
87
  appraisalDecay: 0.68,
84
88
  },
85
89
  natural: {
86
- chemistryMultiplier: 1.0,
87
- maxChemicalDelta: null,
90
+ dynamicsMultiplier: 1.0,
91
+ maxDimensionDelta: null,
88
92
  nearBaselineThreshold: 8,
89
- otWarmthThreshold: 10,
93
+ resonanceWarmthThreshold: 10,
90
94
  lengthMultiplier: 1.0,
91
95
  minSentences: 1,
92
96
  authenticityWhenWarm: "strict",
@@ -97,10 +101,10 @@ export const MODE_PROFILES = {
97
101
  appraisalDecay: 0.78,
98
102
  },
99
103
  companion: {
100
- chemistryMultiplier: 1.5,
101
- maxChemicalDelta: null,
104
+ dynamicsMultiplier: 1.5,
105
+ maxDimensionDelta: null,
102
106
  nearBaselineThreshold: 5,
103
- otWarmthThreshold: 5,
107
+ resonanceWarmthThreshold: 5,
104
108
  lengthMultiplier: 1.5,
105
109
  minSentences: 2,
106
110
  authenticityWhenWarm: "friendly",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "psyche-ai",
3
- "version": "10.2.3",
3
+ "version": "11.2.0",
4
4
  "description": "AI-first subjectivity kernel for agents with continuous appraisal, relation dynamics, and adaptive reply loops",
5
5
  "mcpName": "io.github.Shangri-la-0428/psyche-ai",
6
6
  "type": "module",
package/server.json CHANGED
@@ -6,12 +6,12 @@
6
6
  "url": "https://github.com/Shangri-la-0428/oasyce_psyche",
7
7
  "source": "github"
8
8
  },
9
- "version": "10.2.3",
9
+ "version": "10.2.4",
10
10
  "packages": [
11
11
  {
12
12
  "registryType": "npm",
13
13
  "identifier": "psyche-ai",
14
- "version": "10.2.3",
14
+ "version": "10.2.4",
15
15
  "transport": {
16
16
  "type": "stdio"
17
17
  },