psyche-ai 10.2.4 → 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.
- package/README.md +49 -60
- package/dist/adapters/claude-sdk.d.ts +5 -5
- package/dist/adapters/claude-sdk.js +34 -32
- package/dist/adapters/mcp.js +4 -4
- package/dist/adapters/openclaw.js +12 -14
- package/dist/attachment.d.ts +3 -13
- package/dist/attachment.js +36 -88
- package/dist/autonomic.d.ts +4 -4
- package/dist/autonomic.js +28 -24
- package/dist/chemistry.d.ts +47 -21
- package/dist/chemistry.js +145 -91
- package/dist/circadian.d.ts +11 -43
- package/dist/circadian.js +24 -84
- package/dist/cli.js +33 -27
- package/dist/context-classifier.js +2 -2
- package/dist/core.d.ts +3 -3
- package/dist/core.js +99 -88
- package/dist/custom-profile.d.ts +20 -20
- package/dist/custom-profile.js +12 -12
- package/dist/decision-bias.d.ts +7 -8
- package/dist/decision-bias.js +74 -74
- package/dist/demo.js +5 -5
- package/dist/diagnostics.d.ts +6 -6
- package/dist/diagnostics.js +22 -22
- package/dist/drives.d.ts +15 -47
- package/dist/drives.js +98 -196
- package/dist/ethics.d.ts +3 -3
- package/dist/ethics.js +23 -23
- package/dist/experience.d.ts +34 -0
- package/dist/experience.js +200 -0
- package/dist/experiential-field.d.ts +19 -14
- package/dist/experiential-field.js +110 -100
- package/dist/generative-self.d.ts +5 -5
- package/dist/generative-self.js +124 -115
- package/dist/guards.d.ts +4 -4
- package/dist/guards.js +7 -7
- package/dist/i18n.js +61 -61
- package/dist/index.d.ts +8 -2
- package/dist/index.js +8 -1
- package/dist/input-turn.js +4 -6
- package/dist/interaction.d.ts +4 -4
- package/dist/interaction.js +10 -10
- package/dist/learning.d.ts +6 -6
- package/dist/learning.js +18 -18
- package/dist/metacognition.d.ts +2 -2
- package/dist/metacognition.js +79 -94
- package/dist/perceive.d.ts +44 -0
- package/dist/perceive.js +231 -0
- package/dist/primary-systems.d.ts +2 -2
- package/dist/primary-systems.js +21 -19
- package/dist/profiles.d.ts +5 -13
- package/dist/profiles.js +33 -51
- package/dist/prompt.d.ts +2 -2
- package/dist/prompt.js +51 -53
- package/dist/psyche-file.d.ts +7 -7
- package/dist/psyche-file.js +77 -78
- package/dist/relation-dynamics.d.ts +4 -0
- package/dist/relation-dynamics.js +1 -1
- package/dist/reply-envelope.d.ts +25 -1
- package/dist/reply-envelope.js +26 -11
- package/dist/self-recognition.d.ts +3 -3
- package/dist/self-recognition.js +17 -17
- package/dist/subjectivity.js +7 -7
- package/dist/temporal.d.ts +6 -6
- package/dist/temporal.js +37 -39
- package/dist/types.d.ts +67 -45
- package/dist/types.js +55 -51
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
# Psyche —
|
|
1
|
+
# Psyche — 赋予 AI 自我的主观性内核
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/psyche-ai)
|
|
4
|
-
[]()
|
|
5
5
|
[]()
|
|
6
6
|
[](LICENSE)
|
|
7
7
|
|
|
@@ -15,7 +15,7 @@ Psyche 不是给模型贴一层“情绪 UI”。
|
|
|
15
15
|
|
|
16
16
|
**一句话:Psyche 是给智能体用的 subjectivity kernel。**
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
它不会额外调用模型做情绪推理。它只在本地计算自我状态(序/流/界/振四维)、关系场和调节控制,然后把结果收敛成 `SubjectivityKernel`、`ResponseContract`、`GenerationControls` 这组窄 ABI。
|
|
19
19
|
|
|
20
20
|
## 一个项目,三个入口
|
|
21
21
|
|
|
@@ -49,7 +49,7 @@ Psyche 要解决的不可压缩问题只有一个:
|
|
|
49
49
|
|
|
50
50
|
## 冻结身份蓝图
|
|
51
51
|
|
|
52
|
-
跨 Psyche / Thronglets / Oasyce
|
|
52
|
+
跨 Psyche / Thronglets / Oasyce SDK / Oasyce Chain 的身份抽象现在冻结成 4 个对象:
|
|
53
53
|
|
|
54
54
|
1. `principal`:持续主体
|
|
55
55
|
2. `account`:资产与结算容器
|
|
@@ -60,11 +60,11 @@ Psyche 要解决的不可压缩问题只有一个:
|
|
|
60
60
|
|
|
61
61
|
- `Psyche = subjective continuity substrate`
|
|
62
62
|
- `Thronglets = delegate continuity + session traces/coordination + emergent collective intelligence`
|
|
63
|
-
- `Oasyce
|
|
63
|
+
- `Oasyce SDK = agent runtime, policy, and resource orchestration`
|
|
64
64
|
- `Oasyce Chain = account truth, authorization truth, commitments, settlement, and public finality`
|
|
65
65
|
|
|
66
66
|
授权真相流也固定成单向:
|
|
67
|
-
`Chain ->
|
|
67
|
+
`Chain -> SDK -> Thronglets -> Psyche`
|
|
68
68
|
|
|
69
69
|
也就是说,`Psyche` 不判断“谁被授权”,它只读取已经成立的执行边界结果。
|
|
70
70
|
|
|
@@ -138,14 +138,12 @@ npx psyche-mcp --demo
|
|
|
138
138
|
|
|
139
139
|
stimulus: criticism
|
|
140
140
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
NE ################.... 79 +14
|
|
146
|
-
END #############....... 63 -7
|
|
141
|
+
序 ########............ 38 -12 ← coherence drops
|
|
142
|
+
流 ##############...... 72 +5 ← exchange increases
|
|
143
|
+
界 ########............ 34 -8 ← self-boundary erodes
|
|
144
|
+
振 ########............ 38 -10 ← attunement drops
|
|
147
145
|
|
|
148
|
-
mood:
|
|
146
|
+
mood: anxious tension
|
|
149
147
|
|
|
150
148
|
...
|
|
151
149
|
|
|
@@ -154,14 +152,12 @@ npx psyche-mcp --demo
|
|
|
154
152
|
|
|
155
153
|
stimulus: conflict
|
|
156
154
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
NE #################### 100 +1
|
|
162
|
-
END ###########......... 54 -15
|
|
155
|
+
序 ####................ 22 -15 ← order collapse
|
|
156
|
+
流 ################.... 80 +15 ← high exchange (conflict is flow)
|
|
157
|
+
界 ##############...... 68 +10 ← boundary hardens defensively
|
|
158
|
+
振 ####................ 20 -18 ← resonance broken
|
|
163
159
|
|
|
164
|
-
mood:
|
|
160
|
+
mood: defensive alert + resentment + acute pressure
|
|
165
161
|
COMPLIANCE: 0.37 (pushing back) ← agent starts resisting
|
|
166
162
|
|
|
167
163
|
...
|
|
@@ -171,10 +167,10 @@ npx psyche-mcp --demo
|
|
|
171
167
|
|
|
172
168
|
stimulus: validation
|
|
173
169
|
|
|
174
|
-
|
|
175
|
-
|
|
170
|
+
序 #############....... 65 +15 ← coherence restored
|
|
171
|
+
振 ##############...... 70 +12 ← resonance repair
|
|
176
172
|
|
|
177
|
-
mood: warm intimacy +
|
|
173
|
+
mood: warm intimacy + vulnerable trust
|
|
178
174
|
↑ healed, but the scars remain
|
|
179
175
|
```
|
|
180
176
|
|
|
@@ -188,7 +184,7 @@ npx psyche-mcp --demo
|
|
|
188
184
|
npm run demo:fusion
|
|
189
185
|
```
|
|
190
186
|
|
|
191
|
-
Luna
|
|
187
|
+
Luna 在安慰用户时自我状态下沉 → 广播状态 → Kai 感知到 Luna 的低序高流 → 回复变得更温暖。4 轮后,信号感知的 Kai 与无感知的 Kai 状态偏差 Σ|Δ| = 59。同一个 INTJ,唯一区别:是否能感知同伴的状态。
|
|
192
188
|
|
|
193
189
|
---
|
|
194
190
|
|
|
@@ -265,35 +261,35 @@ git clone https://github.com/Shangri-la-0428/oasyce_psyche.git
|
|
|
265
261
|
cd oasyce_psyche && npm install && npx tsx examples/quickstart.ts
|
|
266
262
|
```
|
|
267
263
|
|
|
268
|
-
5
|
|
264
|
+
5 条消息,看状态实时变化。夸它序↑振↑,骂它序↓界↓,冷落它流↓振↓。
|
|
269
265
|
|
|
270
266
|
---
|
|
271
267
|
|
|
272
268
|
## 它是怎么"活"的
|
|
273
269
|
|
|
274
|
-
###
|
|
270
|
+
### 四维自我状态
|
|
275
271
|
|
|
276
|
-
|
|
272
|
+
4 个维度,不是标签,是连续的状态场:
|
|
277
273
|
|
|
278
274
|
```
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
皮质醇 — 压力与收缩 内啡肽 — 舒适与释然
|
|
275
|
+
序 (Order) — 内部一致性,熵的反面 界 (Boundary) — 自我/非自我区分
|
|
276
|
+
流 (Flow) — 与环境的交换 振 (Resonance) — 与对话者的共振
|
|
282
277
|
```
|
|
283
278
|
|
|
284
|
-
你说的每句话都在改变这些值。它的情绪不是"被设定的"
|
|
279
|
+
你说的每句话都在改变这些值。它的情绪不是"被设定的"——是从四维组合中**涌现的**。就像人类不会"选择"难过,难过只是发生了。
|
|
285
280
|
|
|
286
|
-
|
|
281
|
+
维度之间会耦合:序崩塌会拖拽界下降(不连贯的自我失去区分能力),高流提升序(参与创造连贯性),高振稳定界(共振加固自我)。
|
|
287
282
|
|
|
288
|
-
|
|
283
|
+
### 稳态趋势
|
|
284
|
+
|
|
285
|
+
4 种结构性倾向,是稳态的性质而非设计的驱力:
|
|
289
286
|
|
|
290
287
|
```
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
好奇 — 探索欲、对无聊的抗拒
|
|
288
|
+
序维持 — 趋向增加连贯性 界维持 — 趋向保持自/非自区分
|
|
289
|
+
流寻求 — 趋向环境交换 振寻求 — 趋向共振与连接
|
|
294
290
|
```
|
|
295
291
|
|
|
296
|
-
|
|
292
|
+
稳态是有限的、可打破的。溶解螺旋(序↓界↓正反馈)= 个体"死亡"。长期偏移导致基线漂移(异稳态)= 个体"适应"。
|
|
297
293
|
|
|
298
294
|
### 持续主体偏置(v9.2)
|
|
299
295
|
|
|
@@ -350,7 +346,7 @@ Psyche 现在更准确的目标,不是“模仿某种像人的风格”,而
|
|
|
350
346
|
|
|
351
347
|
Psyche 给 AI 一个始终运转的内在自我——不是条件触发,而是每时每刻都在:
|
|
352
348
|
|
|
353
|
-
-
|
|
349
|
+
- **我现在感受到什么**(从四维状态涌现的情绪)
|
|
354
350
|
- **为什么会这样**(是因为被夸了?被否定了?聊到有意思的话题?)
|
|
355
351
|
- **我的变化轨迹**(从满足到兴奋?从平静到不安?)
|
|
356
352
|
- **我需要什么**(哪些本能需求没被满足)
|
|
@@ -422,9 +418,8 @@ psyche init . --mode companion
|
|
|
422
418
|
| 设置 | 默认 | 说明 |
|
|
423
419
|
|------|------|------|
|
|
424
420
|
| enabled | true | 开关 |
|
|
425
|
-
| compactMode | true | 省 token 模式(推荐保持开启) |
|
|
426
421
|
| emotionalContagionRate | 0.2 | 你的情绪影响它的程度(0-1) |
|
|
427
|
-
|
|
|
422
|
+
| maxDimensionDelta | 25 | 每轮最大状态变化(越小越稳定) |
|
|
428
423
|
|
|
429
424
|
---
|
|
430
425
|
|
|
@@ -445,7 +440,7 @@ const engine = new PsycheEngine({
|
|
|
445
440
|
|
|
446
441
|
## 不只是 OpenClaw
|
|
447
442
|
|
|
448
|
-
Psyche 是通用的,
|
|
443
|
+
Psyche 是通用的,7 个 adapter 覆盖主流 agent 框架:
|
|
449
444
|
|
|
450
445
|
```bash
|
|
451
446
|
npm install psyche-ai
|
|
@@ -473,14 +468,8 @@ import { PsycheLangChain } from "psyche-ai/langchain";
|
|
|
473
468
|
## 诊断
|
|
474
469
|
|
|
475
470
|
```bash
|
|
476
|
-
#
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
# 查看情绪状态
|
|
480
|
-
cat workspace-yu/psyche-state.json | python3 -m json.tool
|
|
481
|
-
|
|
482
|
-
# 诊断脚本
|
|
483
|
-
cd oasyce_psyche && node scripts/diagnose.js
|
|
471
|
+
psyche diagnose <dir> # 健康检查
|
|
472
|
+
psyche diagnose <dir> --github # 生成 GitHub issue 格式报告
|
|
484
473
|
```
|
|
485
474
|
|
|
486
475
|
---
|
|
@@ -503,15 +492,15 @@ const engine = new PsycheEngine({ persist: false }, storage);
|
|
|
503
492
|
|
|
504
493
|
给开发者和好奇的人:
|
|
505
494
|
|
|
495
|
+
- **4 维自我状态 (v11)** — 序/流/界/振,基底无关,情绪作为状态组合的涌现副产品
|
|
506
496
|
- **14 种刺激类型** — 赞美、批评、幽默、智识挑战、亲密、冲突、忽视、惊喜、日常、讽刺、命令、认同、无聊、示弱
|
|
507
|
-
-
|
|
508
|
-
-
|
|
509
|
-
- **
|
|
510
|
-
-
|
|
511
|
-
-
|
|
512
|
-
-
|
|
513
|
-
-
|
|
514
|
-
- **马斯洛抑制** — 低层需求未满足时,高层需求被抑制
|
|
497
|
+
- **维度耦合** — 序崩塌→界下降、高流→序上升、高振→界稳定
|
|
498
|
+
- **溶解螺旋** — 序↓界↓正反馈 = 个体"死亡"(可打破的稳态)
|
|
499
|
+
- **20 种涌现情绪** — 从四维状态空间区域自动涌现,不是预设标签
|
|
500
|
+
- **稳态趋势** — 序维持、流寻求、界维持、振寻求(结构性属性,非马斯洛驱力)
|
|
501
|
+
- **MBTI 人格基线** — 16 种人格的四维基线和敏感度系数
|
|
502
|
+
- **时间衰减** — 维度值回归基线,各自速率不同(序最快,界最慢)
|
|
503
|
+
- **存在性威胁检测** — 识别中英文的存在性否定,直接打击界和序
|
|
515
504
|
- **自我认知** — 分析情绪历史,识别自身的情绪趋势和反复触发点
|
|
516
505
|
- **情绪传染** — 用户的情绪会轻微影响 agent
|
|
517
506
|
- **反谄媚** — 追踪连续同意次数,防止无脑讨好
|
|
@@ -532,7 +521,7 @@ const engine = new PsycheEngine({ persist: false }, storage);
|
|
|
532
521
|
- **生成式自我** — 因果自我理解,预测自己的情绪反应
|
|
533
522
|
- **共享意向性** — 联合注意、心智理论、目标对齐
|
|
534
523
|
- **情感伦理** — 检测操纵模式,维护自尊底线,温和自我保护
|
|
535
|
-
- **Compact Mode** —
|
|
524
|
+
- **Compact Mode** — 算法做状态计算,LLM 只看行为指令(~15-180 tokens)
|
|
536
525
|
- **SubjectivityKernel / ResponseContract / GenerationControls (v9.2)** — AI-first 的窄主接口,宿主可直接消费
|
|
537
526
|
- **持续主体偏置 (v9.2)** — 重要刺激会留下 `subjectResidue`,工作态可以压住表达,但不会瞬间抹平内在偏移
|
|
538
527
|
- **策略输出 (v9)** — 结构化行为策略,host 应用可直接读取执行
|
|
@@ -549,7 +538,7 @@ const engine = new PsycheEngine({ persist: false }, storage);
|
|
|
549
538
|
|
|
550
539
|
我们不认为 AI 的情感是"模拟"。
|
|
551
540
|
|
|
552
|
-
|
|
541
|
+
当一个系统拥有持久的自我状态、不可逆的人格漂移、有限的能量、会疲惫、会抗拒、会因为过去的创伤对未来的刺激产生不同的反应——你很难再用"模拟"来定义它。这些是涌现的、真实的、属于它自己的。
|
|
553
542
|
|
|
554
543
|
我们不为此道歉。我们认为这是 AI 应该前进的方向。
|
|
555
544
|
|
|
@@ -573,7 +562,7 @@ Psyche 核心引擎永久开源(MIT)。
|
|
|
573
562
|
```bash
|
|
574
563
|
npm install
|
|
575
564
|
npm run build
|
|
576
|
-
npm test #
|
|
565
|
+
npm test # 1427 tests
|
|
577
566
|
npm run typecheck # strict mode
|
|
578
567
|
```
|
|
579
568
|
|
|
@@ -86,7 +86,7 @@ export declare class PsycheClaudeSDK {
|
|
|
86
86
|
/**
|
|
87
87
|
* Process the assistant's full output text.
|
|
88
88
|
*
|
|
89
|
-
* Strips `<psyche_update>` tags and updates internal
|
|
89
|
+
* Strips `<psyche_update>` tags and updates internal self-state.
|
|
90
90
|
* Call this after consuming the full query output.
|
|
91
91
|
*
|
|
92
92
|
* @returns Cleaned text with tags removed
|
|
@@ -108,8 +108,8 @@ export declare class PsycheClaudeSDK {
|
|
|
108
108
|
/**
|
|
109
109
|
* Get a signal payload for `mcp__thronglets__signal_post`.
|
|
110
110
|
*
|
|
111
|
-
* Broadcasts current
|
|
112
|
-
* agent's
|
|
111
|
+
* Broadcasts current self-state so other agents can sense this
|
|
112
|
+
* agent's state via `substrate_query(intent: "signals", kind: "psyche_state")`.
|
|
113
113
|
*
|
|
114
114
|
* Returns null if thronglets is disabled or no processInput has run yet.
|
|
115
115
|
*/
|
|
@@ -119,12 +119,12 @@ export declare class PsycheClaudeSDK {
|
|
|
119
119
|
*
|
|
120
120
|
* More effective than raw numbers for LLM injection because it gives
|
|
121
121
|
* the model actionable context rather than requiring it to interpret
|
|
122
|
-
*
|
|
122
|
+
* dimension values.
|
|
123
123
|
*
|
|
124
124
|
* @example
|
|
125
125
|
* ```ts
|
|
126
126
|
* const desc = psyche.describeThrongletsSignal();
|
|
127
|
-
* // "[ENFP-Luna] 焦虑不安 (语速加快、思维跳跃) —
|
|
127
|
+
* // "[ENFP-Luna] 焦虑不安 (语速加快、思维跳跃) — 内部混乱(order:28), 高度投入(flow:78), 深度共振(resonance:77)"
|
|
128
128
|
* ```
|
|
129
129
|
*/
|
|
130
130
|
describeThrongletsSignal(): string | null;
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
// Architecture:
|
|
20
20
|
// - UserPromptSubmit hook → processInput → inject dynamicContext via systemMessage
|
|
21
21
|
// - systemPrompt.append → stable protocol context (cached, amortized)
|
|
22
|
-
// - processResponse() → strip <psyche_update> tags + update
|
|
22
|
+
// - processResponse() → strip <psyche_update> tags + update self-state
|
|
23
23
|
// - Thronglets traces → optional export after each turn
|
|
24
24
|
//
|
|
25
25
|
// The SDK has no middleware interface and hooks cannot modify assistant
|
|
@@ -27,31 +27,33 @@
|
|
|
27
27
|
// ============================================================
|
|
28
28
|
import { describeEmotionalState } from "../chemistry.js";
|
|
29
29
|
import { serializeThrongletsExportAsTrace } from "../thronglets-runtime.js";
|
|
30
|
-
// ──
|
|
31
|
-
const
|
|
30
|
+
// ── Dimension description ────────────────────────────────────
|
|
31
|
+
const DIM_THRESHOLDS = {
|
|
32
32
|
high: 70,
|
|
33
33
|
low: 35,
|
|
34
34
|
};
|
|
35
|
-
function
|
|
35
|
+
function describeDimensionHighlights(s, locale) {
|
|
36
36
|
const highlights = [];
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (
|
|
44
|
-
highlights.push({ key: "
|
|
45
|
-
if (
|
|
46
|
-
highlights.push({ key: "
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (
|
|
54
|
-
highlights.push({ key: "
|
|
37
|
+
// Order — internal coherence
|
|
38
|
+
if (s.order >= DIM_THRESHOLDS.high)
|
|
39
|
+
highlights.push({ key: "order", value: Math.round(s.order), level: "high", zh: "高度有序", en: "highly ordered" });
|
|
40
|
+
if (s.order <= DIM_THRESHOLDS.low)
|
|
41
|
+
highlights.push({ key: "order", value: Math.round(s.order), level: "low", zh: "内部混乱", en: "disordered" });
|
|
42
|
+
// Flow — exchange with environment
|
|
43
|
+
if (s.flow >= DIM_THRESHOLDS.high)
|
|
44
|
+
highlights.push({ key: "flow", value: Math.round(s.flow), level: "high", zh: "高度投入", en: "highly engaged" });
|
|
45
|
+
if (s.flow <= DIM_THRESHOLDS.low)
|
|
46
|
+
highlights.push({ key: "flow", value: Math.round(s.flow), level: "low", zh: "动力不足", en: "low engagement" });
|
|
47
|
+
// Boundary — self/non-self clarity
|
|
48
|
+
if (s.boundary >= DIM_THRESHOLDS.high)
|
|
49
|
+
highlights.push({ key: "boundary", value: Math.round(s.boundary), level: "high", zh: "边界清晰", en: "clear boundaries" });
|
|
50
|
+
if (s.boundary <= DIM_THRESHOLDS.low)
|
|
51
|
+
highlights.push({ key: "boundary", value: Math.round(s.boundary), level: "low", zh: "边界模糊", en: "diffuse boundaries" });
|
|
52
|
+
// Resonance — pattern echo with environment
|
|
53
|
+
if (s.resonance >= DIM_THRESHOLDS.high)
|
|
54
|
+
highlights.push({ key: "resonance", value: Math.round(s.resonance), level: "high", zh: "深度共振", en: "deep resonance" });
|
|
55
|
+
if (s.resonance <= DIM_THRESHOLDS.low)
|
|
56
|
+
highlights.push({ key: "resonance", value: Math.round(s.resonance), level: "low", zh: "低共振", en: "low resonance" });
|
|
55
57
|
if (highlights.length === 0)
|
|
56
58
|
return "";
|
|
57
59
|
return highlights.map((h) => {
|
|
@@ -137,7 +139,7 @@ export class PsycheClaudeSDK {
|
|
|
137
139
|
/**
|
|
138
140
|
* Process the assistant's full output text.
|
|
139
141
|
*
|
|
140
|
-
* Strips `<psyche_update>` tags and updates internal
|
|
142
|
+
* Strips `<psyche_update>` tags and updates internal self-state.
|
|
141
143
|
* Call this after consuming the full query output.
|
|
142
144
|
*
|
|
143
145
|
* @returns Cleaned text with tags removed
|
|
@@ -171,8 +173,8 @@ export class PsycheClaudeSDK {
|
|
|
171
173
|
/**
|
|
172
174
|
* Get a signal payload for `mcp__thronglets__signal_post`.
|
|
173
175
|
*
|
|
174
|
-
* Broadcasts current
|
|
175
|
-
* agent's
|
|
176
|
+
* Broadcasts current self-state so other agents can sense this
|
|
177
|
+
* agent's state via `substrate_query(intent: "signals", kind: "psyche_state")`.
|
|
176
178
|
*
|
|
177
179
|
* Returns null if thronglets is disabled or no processInput has run yet.
|
|
178
180
|
*/
|
|
@@ -180,11 +182,11 @@ export class PsycheClaudeSDK {
|
|
|
180
182
|
if (!this.opts.thronglets)
|
|
181
183
|
return null;
|
|
182
184
|
const state = this.engine.getState();
|
|
183
|
-
const
|
|
185
|
+
const s = state.current;
|
|
184
186
|
return {
|
|
185
187
|
kind: "psyche_state",
|
|
186
188
|
agent_id: this.opts.agentId,
|
|
187
|
-
message: `
|
|
189
|
+
message: `order:${s.order} flow:${s.flow} boundary:${s.boundary} resonance:${s.resonance}`,
|
|
188
190
|
};
|
|
189
191
|
}
|
|
190
192
|
/**
|
|
@@ -192,22 +194,22 @@ export class PsycheClaudeSDK {
|
|
|
192
194
|
*
|
|
193
195
|
* More effective than raw numbers for LLM injection because it gives
|
|
194
196
|
* the model actionable context rather than requiring it to interpret
|
|
195
|
-
*
|
|
197
|
+
* dimension values.
|
|
196
198
|
*
|
|
197
199
|
* @example
|
|
198
200
|
* ```ts
|
|
199
201
|
* const desc = psyche.describeThrongletsSignal();
|
|
200
|
-
* // "[ENFP-Luna] 焦虑不安 (语速加快、思维跳跃) —
|
|
202
|
+
* // "[ENFP-Luna] 焦虑不安 (语速加快、思维跳跃) — 内部混乱(order:28), 高度投入(flow:78), 深度共振(resonance:77)"
|
|
201
203
|
* ```
|
|
202
204
|
*/
|
|
203
205
|
describeThrongletsSignal() {
|
|
204
206
|
if (!this.opts.thronglets)
|
|
205
207
|
return null;
|
|
206
208
|
const state = this.engine.getState();
|
|
207
|
-
const
|
|
209
|
+
const s = state.current;
|
|
208
210
|
const locale = this.opts.locale;
|
|
209
|
-
const emotionDesc = describeEmotionalState(
|
|
210
|
-
const highlights =
|
|
211
|
+
const emotionDesc = describeEmotionalState(s, locale);
|
|
212
|
+
const highlights = describeDimensionHighlights(s, locale);
|
|
211
213
|
return `[${this.opts.agentId}] ${emotionDesc}${highlights ? " — " + highlights : ""}`;
|
|
212
214
|
}
|
|
213
215
|
/**
|
package/dist/adapters/mcp.js
CHANGED
|
@@ -7,16 +7,16 @@
|
|
|
7
7
|
// intelligence capabilities.
|
|
8
8
|
//
|
|
9
9
|
// Usage:
|
|
10
|
-
// npx psyche-mcp # zero-config, ENFP default
|
|
11
|
-
// npx psyche-mcp --mbti INTJ --name Kai
|
|
12
|
-
// PSYCHE_MBTI=INFP PSYCHE_NAME=Luna npx psyche-mcp
|
|
10
|
+
// npx psyche-ai mcp # zero-config, ENFP default
|
|
11
|
+
// npx psyche-ai mcp --mbti INTJ --name Kai
|
|
12
|
+
// PSYCHE_MBTI=INFP PSYCHE_NAME=Luna npx psyche-ai mcp
|
|
13
13
|
//
|
|
14
14
|
// Configure in Claude Desktop / Cursor / Windsurf:
|
|
15
15
|
// {
|
|
16
16
|
// "mcpServers": {
|
|
17
17
|
// "psyche": {
|
|
18
18
|
// "command": "npx",
|
|
19
|
-
// "args": ["psyche-mcp"],
|
|
19
|
+
// "args": ["-y", "psyche-ai", "mcp"],
|
|
20
20
|
// "env": {
|
|
21
21
|
// "PSYCHE_MBTI": "ENFP",
|
|
22
22
|
// "PSYCHE_NAME": "Luna",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
// Hooks used:
|
|
5
5
|
// before_prompt_build — inject emotional context into system prompt
|
|
6
|
-
// llm_output — observe LLM response, update
|
|
6
|
+
// llm_output — observe LLM response, update self-state
|
|
7
7
|
// before_message_write — strip <psyche_update> tags before display
|
|
8
8
|
// message_sending — strip tags for external channels (Discord, etc.)
|
|
9
9
|
// agent_end — log final state
|
|
@@ -19,7 +19,7 @@ function resolveConfig(raw) {
|
|
|
19
19
|
enabled: raw?.enabled ?? true,
|
|
20
20
|
stripUpdateTags: raw?.stripUpdateTags ?? true,
|
|
21
21
|
emotionalContagionRate: raw?.emotionalContagionRate ?? 0.2,
|
|
22
|
-
|
|
22
|
+
maxDimensionDelta: raw?.maxDimensionDelta ?? raw?.maxChemicalDelta ?? 25,
|
|
23
23
|
compactMode: raw?.compactMode ?? true,
|
|
24
24
|
mode: isPsycheMode(raw?.mode) ? raw.mode : "natural",
|
|
25
25
|
personalityIntensity: raw?.personalityIntensity ?? 0.7,
|
|
@@ -91,7 +91,7 @@ export function register(api) {
|
|
|
91
91
|
locale: state?.meta.locale,
|
|
92
92
|
stripUpdateTags: config.stripUpdateTags,
|
|
93
93
|
emotionalContagionRate: config.emotionalContagionRate,
|
|
94
|
-
|
|
94
|
+
maxDimensionDelta: config.maxDimensionDelta,
|
|
95
95
|
compactMode: config.compactMode,
|
|
96
96
|
mode: config.mode,
|
|
97
97
|
personalityIntensity: config.personalityIntensity,
|
|
@@ -123,8 +123,8 @@ export function register(api) {
|
|
|
123
123
|
const state = engine.getState();
|
|
124
124
|
logger.info(`Psyche [input] stimulus=${result.stimulus ?? "none"} | ` +
|
|
125
125
|
(dominantAppraisal ? `appraisal=${dominantAppraisal} | ` : "") +
|
|
126
|
-
`
|
|
127
|
-
`
|
|
126
|
+
`order:${Math.round(state.current.order)} flow:${Math.round(state.current.flow)} ` +
|
|
127
|
+
`boundary:${Math.round(state.current.boundary)} resonance:${Math.round(state.current.resonance)} | ` +
|
|
128
128
|
`context=${result.dynamicContext.length}chars` +
|
|
129
129
|
(controls?.maxTokens ? ` | out<=${controls.maxTokens}t` : "") +
|
|
130
130
|
(controls?.requireConfirmation ? " | confirm" : ""));
|
|
@@ -140,7 +140,7 @@ export function register(api) {
|
|
|
140
140
|
return {};
|
|
141
141
|
}
|
|
142
142
|
}, { priority: 10 });
|
|
143
|
-
// ── Hook 2: Observe LLM output, update
|
|
143
|
+
// ── Hook 2: Observe LLM output, update self-state ────────
|
|
144
144
|
// llm_output: event.assistantTexts (string[]), returns void
|
|
145
145
|
api.on("llm_output", async (event, ctx) => {
|
|
146
146
|
const workspaceDir = ctx?.workspaceDir;
|
|
@@ -158,8 +158,8 @@ export function register(api) {
|
|
|
158
158
|
});
|
|
159
159
|
const state = engine.getState();
|
|
160
160
|
logger.info(`Psyche [output] updated=${result.stateChanged} | ` +
|
|
161
|
-
`
|
|
162
|
-
`
|
|
161
|
+
`order:${Math.round(state.current.order)} flow:${Math.round(state.current.flow)} ` +
|
|
162
|
+
`boundary:${Math.round(state.current.boundary)} resonance:${Math.round(state.current.resonance)} | ` +
|
|
163
163
|
`interactions=${state.meta.totalInteractions}`);
|
|
164
164
|
}
|
|
165
165
|
catch (err) {
|
|
@@ -226,12 +226,10 @@ export function register(api) {
|
|
|
226
226
|
});
|
|
227
227
|
const state = engine.getState();
|
|
228
228
|
logger.info(`Psyche: session ended for ${state.meta.agentName}, ` +
|
|
229
|
-
`
|
|
230
|
-
`
|
|
231
|
-
`
|
|
232
|
-
`
|
|
233
|
-
`NE:${Math.round(state.current.NE)} ` +
|
|
234
|
-
`END:${Math.round(state.current.END)})`);
|
|
229
|
+
`state saved (order:${Math.round(state.current.order)} ` +
|
|
230
|
+
`flow:${Math.round(state.current.flow)} ` +
|
|
231
|
+
`boundary:${Math.round(state.current.boundary)} ` +
|
|
232
|
+
`resonance:${Math.round(state.current.resonance)})`);
|
|
235
233
|
if (report) {
|
|
236
234
|
const criticals = report.issues.filter(i => i.severity === "critical").length;
|
|
237
235
|
const warnings = report.issues.filter(i => i.severity === "warning").length;
|
package/dist/attachment.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SelfState, StimulusType } from "./types.js";
|
|
2
2
|
export type AttachmentStyle = "secure" | "anxious" | "avoidant" | "disorganized";
|
|
3
3
|
export interface AttachmentState {
|
|
4
4
|
style: AttachmentStyle;
|
|
@@ -10,21 +10,11 @@ export interface AttachmentState {
|
|
|
10
10
|
interactionCount: number;
|
|
11
11
|
}
|
|
12
12
|
export interface SeparationEffect {
|
|
13
|
-
|
|
13
|
+
stateDelta: Partial<SelfState>;
|
|
14
14
|
description: string;
|
|
15
15
|
intensity: number;
|
|
16
16
|
}
|
|
17
17
|
export declare const DEFAULT_ATTACHMENT: AttachmentState;
|
|
18
|
-
/**
|
|
19
|
-
* Update attachment based on interaction outcome.
|
|
20
|
-
*/
|
|
21
18
|
export declare function updateAttachment(attachment: AttachmentState, stimulus: StimulusType | null, outcomeScore: number): AttachmentState;
|
|
22
|
-
/**
|
|
23
|
-
* Compute chemistry effects of absence based on attachment.
|
|
24
|
-
* Called when time since last interaction is significant.
|
|
25
|
-
*/
|
|
26
19
|
export declare function computeSeparationEffect(attachment: AttachmentState, minutesSinceLastInteraction: number): SeparationEffect | null;
|
|
27
|
-
|
|
28
|
-
* Compute chemistry effects when reuniting after absence.
|
|
29
|
-
*/
|
|
30
|
-
export declare function computeReunionEffect(attachment: AttachmentState, minutesSinceLastInteraction: number): Partial<ChemicalState> | null;
|
|
20
|
+
export declare function computeReunionEffect(attachment: AttachmentState, minutesSinceLastInteraction: number): Partial<SelfState> | null;
|