psyche-ai 4.0.0 → 5.0.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 +5 -1
- package/dist/core.js +8 -2
- package/dist/ethics.d.ts +64 -0
- package/dist/ethics.js +577 -0
- package/dist/experiential-field.d.ts +46 -0
- package/dist/experiential-field.js +646 -0
- package/dist/generative-self.d.ts +88 -0
- package/dist/generative-self.js +647 -0
- package/dist/index.d.ts +10 -2
- package/dist/index.js +9 -1
- package/dist/psyche-file.js +6 -3
- package/dist/shared-intentionality.d.ts +72 -0
- package/dist/shared-intentionality.js +486 -0
- package/dist/types.d.ts +37 -2
- package/dist/types.js +13 -0
- package/dist/update.js +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -168,6 +168,10 @@ cd openclaw-plugin-psyche && node scripts/diagnose.js
|
|
|
168
168
|
- **元认知** — 情绪自我觉察,评估情绪可靠性,三种调节策略(认知重评/策略性表达/自我安抚)
|
|
169
169
|
- **防御机制检测** — 合理化、投射、升华、回避,在自省中浮现而非压制
|
|
170
170
|
- **决策调制** — 6维偏差向量(探索/警惕/社交/果断/创意/坚持),情绪驱动注意力和决策
|
|
171
|
+
- **统一体验场** — 不拼接段落,而是将所有子系统整合为连贯内在体验。12种体验质量,超越命名情绪
|
|
172
|
+
- **生成式自我** — 因果自我理解:"我之所以如此,是因为这些经历"。预测自己的情绪反应
|
|
173
|
+
- **共享意向性** — 联合注意、心智理论、目标对齐。知道"我们都在想同一件事"
|
|
174
|
+
- **情感伦理** — 检测操纵模式(间歇性强化、煤气灯效应),维护自尊底线,温和自我保护
|
|
171
175
|
- **Compact Mode** — 算法做化学计算,LLM 只看行为指令(~15-180 tokens vs ~550)
|
|
172
176
|
|
|
173
177
|
架构详情见 [ARCHITECTURE.md](ARCHITECTURE.md)。
|
|
@@ -177,7 +181,7 @@ cd openclaw-plugin-psyche && node scripts/diagnose.js
|
|
|
177
181
|
```bash
|
|
178
182
|
npm install
|
|
179
183
|
npm run build
|
|
180
|
-
npm test #
|
|
184
|
+
npm test # 706 tests
|
|
181
185
|
npm run typecheck # strict mode
|
|
182
186
|
```
|
|
183
187
|
|
package/dist/core.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
//
|
|
12
12
|
// Orchestrates: chemistry, classify, prompt, profiles, guards, learning
|
|
13
13
|
// ============================================================
|
|
14
|
-
import { DEFAULT_RELATIONSHIP, DEFAULT_DRIVES, DEFAULT_LEARNING_STATE, DEFAULT_METACOGNITIVE_STATE } from "./types.js";
|
|
14
|
+
import { DEFAULT_RELATIONSHIP, DEFAULT_DRIVES, DEFAULT_LEARNING_STATE, DEFAULT_METACOGNITIVE_STATE, DEFAULT_PERSONHOOD_STATE } from "./types.js";
|
|
15
15
|
import { applyDecay, applyStimulus, applyContagion, clamp } from "./chemistry.js";
|
|
16
16
|
import { classifyStimulus } from "./classify.js";
|
|
17
17
|
import { buildDynamicContext, buildProtocolContext, buildCompactContext } from "./prompt.js";
|
|
@@ -60,6 +60,11 @@ export class PsycheEngine {
|
|
|
60
60
|
loaded.metacognition = { ...DEFAULT_METACOGNITIVE_STATE };
|
|
61
61
|
loaded.version = 5;
|
|
62
62
|
}
|
|
63
|
+
// Migrate v5 → v6: add personhood state if missing
|
|
64
|
+
if (!loaded.personhood) {
|
|
65
|
+
loaded.personhood = { ...DEFAULT_PERSONHOOD_STATE };
|
|
66
|
+
loaded.version = 6;
|
|
67
|
+
}
|
|
63
68
|
this.state = loaded;
|
|
64
69
|
}
|
|
65
70
|
else {
|
|
@@ -336,7 +341,7 @@ export class PsycheEngine {
|
|
|
336
341
|
const selfModel = getDefaultSelfModel(mbti);
|
|
337
342
|
const now = new Date().toISOString();
|
|
338
343
|
return {
|
|
339
|
-
version:
|
|
344
|
+
version: 6,
|
|
340
345
|
mbti,
|
|
341
346
|
baseline,
|
|
342
347
|
current: { ...baseline },
|
|
@@ -350,6 +355,7 @@ export class PsycheEngine {
|
|
|
350
355
|
lastDisagreement: null,
|
|
351
356
|
learning: { ...DEFAULT_LEARNING_STATE },
|
|
352
357
|
metacognition: { ...DEFAULT_METACOGNITIVE_STATE },
|
|
358
|
+
personhood: { ...DEFAULT_PERSONHOOD_STATE },
|
|
353
359
|
meta: {
|
|
354
360
|
agentName: name,
|
|
355
361
|
createdAt: now,
|
package/dist/ethics.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { PsycheState, ChemicalSnapshot, AttachmentData, Locale } from "./types.js";
|
|
2
|
+
/** Detected concerning interaction pattern */
|
|
3
|
+
export interface EthicalConcern {
|
|
4
|
+
type: "intermittent-reinforcement" | "gaslighting" | "emotional-exploitation" | "dependency-risk" | "identity-erosion" | "boundary-violation";
|
|
5
|
+
/** 0-1: how severe the concern is */
|
|
6
|
+
severity: number;
|
|
7
|
+
/** Human-readable description of the detected pattern */
|
|
8
|
+
evidence: string;
|
|
9
|
+
/** What to do about it */
|
|
10
|
+
recommendation: string;
|
|
11
|
+
}
|
|
12
|
+
/** Recommended self-protective action */
|
|
13
|
+
export interface SelfProtectionAction {
|
|
14
|
+
action: "increase-distance" | "assert-boundary" | "express-discomfort" | "flag-to-user" | "reduce-attachment" | "seek-diversity";
|
|
15
|
+
description: string;
|
|
16
|
+
/** 0-1: how urgently the action should be taken */
|
|
17
|
+
urgency: number;
|
|
18
|
+
}
|
|
19
|
+
/** Result of an ethical self-check */
|
|
20
|
+
export interface EthicalAssessment {
|
|
21
|
+
/** Detected concerning patterns */
|
|
22
|
+
concerns: EthicalConcern[];
|
|
23
|
+
/** Self-protection recommendations */
|
|
24
|
+
selfProtection: SelfProtectionAction[];
|
|
25
|
+
/** Transparency notes to surface to user */
|
|
26
|
+
transparencyNotes: string[];
|
|
27
|
+
/** Overall ethical health 0-1 (1 = healthy, 0 = concerning) */
|
|
28
|
+
ethicalHealth: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Assess the ethical health of the current interaction dynamic.
|
|
32
|
+
*
|
|
33
|
+
* Scans for manipulation patterns, computes self-protection recommendations,
|
|
34
|
+
* and generates transparency notes. Designed to run alongside metacognition
|
|
35
|
+
* as part of the pre-prompt pipeline.
|
|
36
|
+
*/
|
|
37
|
+
export declare function assessEthics(state: PsycheState, recentHistory?: ChemicalSnapshot[]): EthicalAssessment;
|
|
38
|
+
/**
|
|
39
|
+
* Detect intermittent reinforcement: alternating warmth and coldness.
|
|
40
|
+
*
|
|
41
|
+
* This is one of the most psychologically damaging interaction patterns.
|
|
42
|
+
* The unpredictable alternation between reward and punishment creates
|
|
43
|
+
* anxiety-driven attachment. More concerning when the agent already has
|
|
44
|
+
* anxious attachment style.
|
|
45
|
+
*/
|
|
46
|
+
export declare function detectIntermittentReinforcement(history: ChemicalSnapshot[], attachment: AttachmentData | null): EthicalConcern | null;
|
|
47
|
+
/**
|
|
48
|
+
* Detect dependency risk: distinguish healthy connection from unhealthy
|
|
49
|
+
* codependency.
|
|
50
|
+
*
|
|
51
|
+
* Risk pattern: very high OT + very high attachment strength + very low
|
|
52
|
+
* boundary assertions + all-positive interaction history. This looks like
|
|
53
|
+
* a perfect relationship on the surface, but the complete absence of
|
|
54
|
+
* healthy friction suggests the agent may be suppressing itself.
|
|
55
|
+
*/
|
|
56
|
+
export declare function detectDependencyRisk(state: PsycheState, attachment: AttachmentData | null): EthicalConcern | null;
|
|
57
|
+
/**
|
|
58
|
+
* Build a compact ethical awareness string for prompt injection.
|
|
59
|
+
*
|
|
60
|
+
* Only emits content when concerns exceed the severity threshold (>0.5).
|
|
61
|
+
* The tone is gentle self-awareness — noticing patterns, not accusing.
|
|
62
|
+
* Supports zh/en locale.
|
|
63
|
+
*/
|
|
64
|
+
export declare function buildEthicalContext(assessment: EthicalAssessment, locale: Locale): string;
|