psyche-ai 11.3.1 → 11.4.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 +16 -0
- package/dist/adapters/http.js +11 -2
- package/dist/adapters/mcp.js +3 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/overlay.d.ts +39 -0
- package/dist/overlay.js +51 -0
- package/llms.txt +15 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -291,6 +291,22 @@ cd oasyce_psyche && npm install && npx tsx examples/quickstart.ts
|
|
|
291
291
|
|
|
292
292
|
稳态是有限的、可打破的。溶解螺旋(序↓界↓正反馈)= 个体"死亡"。长期偏移导致基线漂移(异稳态)= 个体"适应"。
|
|
293
293
|
|
|
294
|
+
### Overlay — 自我状态的广播信号(v11.4)
|
|
295
|
+
|
|
296
|
+
4 维自我状态对外部系统来说太"内部"了。`computeOverlay()` 把状态偏差投影成 4 个语义稳定的效应信号——Psyche 的"激素":
|
|
297
|
+
|
|
298
|
+
```typescript
|
|
299
|
+
import { computeOverlay } from "psyche-ai";
|
|
300
|
+
|
|
301
|
+
const overlay = computeOverlay(engine.getState());
|
|
302
|
+
// overlay.arousal [-1, 1] 激活水平
|
|
303
|
+
// overlay.valence [-1, 1] 正负效价
|
|
304
|
+
// overlay.agency [-1, 1] 行动能力
|
|
305
|
+
// overlay.vulnerability [-1, 1] 易感性
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
纯函数,无副作用。也可以通过 `GET /overlay`(HTTP)或 `get_state`(MCP)获取。
|
|
309
|
+
|
|
294
310
|
### 持续主体偏置(v9.2)
|
|
295
311
|
|
|
296
312
|
Psyche 现在更准确的目标,不是“模仿某种像人的风格”,而是让 AI 形成**持续主体偏置**:
|
package/dist/adapters/http.js
CHANGED
|
@@ -9,12 +9,14 @@
|
|
|
9
9
|
// Endpoints:
|
|
10
10
|
// POST /process-input { text, userId? } → { systemContext, dynamicContext, stimulus, replyEnvelope?, ...compat aliases, sessionBridge?, writebackFeedback?, externalContinuity?, throngletsExports?, policyContext }
|
|
11
11
|
// POST /process-output { text, userId?, signals?, signalConfidence? } → { cleanedText, stateChanged }
|
|
12
|
-
// GET /state → PsycheState
|
|
12
|
+
// GET /state → PsycheState + overlay
|
|
13
|
+
// GET /overlay → PsycheOverlay (arousal/valence/agency/vulnerability)
|
|
13
14
|
// GET /protocol?locale=zh → { protocol }
|
|
14
15
|
//
|
|
15
16
|
// Zero dependencies — uses node:http only.
|
|
16
17
|
// ============================================================
|
|
17
18
|
import { createServer } from "node:http";
|
|
19
|
+
import { computeOverlay } from "../overlay.js";
|
|
18
20
|
const VALID_WRITEBACK_SIGNALS = new Set([
|
|
19
21
|
"trust_up",
|
|
20
22
|
"trust_down",
|
|
@@ -68,7 +70,14 @@ export function createPsycheServer(engine, opts) {
|
|
|
68
70
|
const url = new URL(req.url ?? "/", `http://${req.headers.host ?? "localhost"}`);
|
|
69
71
|
// GET /state
|
|
70
72
|
if (req.method === "GET" && url.pathname === "/state") {
|
|
71
|
-
|
|
73
|
+
const state = engine.getState();
|
|
74
|
+
json(res, 200, { ...state, overlay: computeOverlay(state) });
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
// GET /overlay
|
|
78
|
+
if (req.method === "GET" && url.pathname === "/overlay") {
|
|
79
|
+
const state = engine.getState();
|
|
80
|
+
json(res, 200, computeOverlay(state));
|
|
72
81
|
return;
|
|
73
82
|
}
|
|
74
83
|
// GET /protocol
|
package/dist/adapters/mcp.js
CHANGED
|
@@ -201,6 +201,8 @@ server.tool("get_state", "Get the current emotional state — self-state dimensi
|
|
|
201
201
|
const eng = await getEngine();
|
|
202
202
|
const state = eng.getState();
|
|
203
203
|
const summary = eng.getStatusSummary();
|
|
204
|
+
const { computeOverlay } = await import("../overlay.js");
|
|
205
|
+
const overlay = computeOverlay({ current: state.current, baseline: state.baseline });
|
|
204
206
|
return {
|
|
205
207
|
content: [{
|
|
206
208
|
type: "text",
|
|
@@ -208,6 +210,7 @@ server.tool("get_state", "Get the current emotional state — self-state dimensi
|
|
|
208
210
|
summary,
|
|
209
211
|
current: state.current,
|
|
210
212
|
baseline: state.baseline,
|
|
213
|
+
overlay,
|
|
211
214
|
drives: state.drives,
|
|
212
215
|
mbti: state.mbti,
|
|
213
216
|
mode: state.meta?.mode,
|
package/dist/index.d.ts
CHANGED
|
@@ -16,5 +16,7 @@ export { getBaseline, getSensitivity, getDefaultSelfModel, getTemperament, trait
|
|
|
16
16
|
export { createCustomProfile, PRESET_PROFILES } from "./custom-profile.js";
|
|
17
17
|
export { LLMExpressionAdapter } from "./reply-envelope.js";
|
|
18
18
|
export type { ExpressionPort, ExpressionOutput, ReplyEnvelope } from "./reply-envelope.js";
|
|
19
|
+
export { computeOverlay, OVERLAY_KEYS } from "./overlay.js";
|
|
20
|
+
export type { PsycheOverlay } from "./overlay.js";
|
|
19
21
|
export { computeLayerHealthSummary } from "./diagnostics.js";
|
|
20
22
|
export type { LayerHealthSummary, LayerHealthDetail, LayerStatus, DiagnosticLayer } from "./diagnostics.js";
|
package/dist/index.js
CHANGED
|
@@ -33,6 +33,8 @@ export { getBaseline, getSensitivity, getDefaultSelfModel, getTemperament, trait
|
|
|
33
33
|
export { createCustomProfile, PRESET_PROFILES } from "./custom-profile.js";
|
|
34
34
|
// ── Expression ──────────────────────────────────────────────
|
|
35
35
|
export { LLMExpressionAdapter } from "./reply-envelope.js";
|
|
36
|
+
// ── Overlay (effect signals for external consumers) ─────────
|
|
37
|
+
export { computeOverlay, OVERLAY_KEYS } from "./overlay.js";
|
|
36
38
|
// ── Diagnostics ─────────────────────────────────────────────
|
|
37
39
|
export { computeLayerHealthSummary } from "./diagnostics.js";
|
|
38
40
|
// ============================================================
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { SelfState } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Semantic-stable effect signals derived from 4D self-state.
|
|
4
|
+
*
|
|
5
|
+
* All values [-1, 1]. 0 = at baseline (no effect).
|
|
6
|
+
*/
|
|
7
|
+
export interface PsycheOverlay {
|
|
8
|
+
/** Activation level. High flow + disrupted order = high arousal. */
|
|
9
|
+
arousal: number;
|
|
10
|
+
/** Positive/negative quality. High order + high resonance = positive. */
|
|
11
|
+
valence: number;
|
|
12
|
+
/** Capacity for intentional action. High boundary + high flow. */
|
|
13
|
+
agency: number;
|
|
14
|
+
/** Susceptibility to perturbation. Low boundary + low order. */
|
|
15
|
+
vulnerability: number;
|
|
16
|
+
}
|
|
17
|
+
/** Overlay dimension keys for iteration. */
|
|
18
|
+
export declare const OVERLAY_KEYS: (keyof PsycheOverlay)[];
|
|
19
|
+
/**
|
|
20
|
+
* Project self-state into overlay effect signals.
|
|
21
|
+
*
|
|
22
|
+
* Pure linear projection from dimension deviations:
|
|
23
|
+
*
|
|
24
|
+
* ```
|
|
25
|
+
* order flow boundary resonance
|
|
26
|
+
* arousal = [ -0.4 0.6 0 0 ]
|
|
27
|
+
* valence = [ 0.5 0 0 0.5 ]
|
|
28
|
+
* agency = [ 0 0.4 0.6 0 ]
|
|
29
|
+
* vulnerability = [ -0.4 0 -0.6 0 ]
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* Each signal reads exactly 2 dimensions. Sparse and interpretable.
|
|
33
|
+
* arousal/valence are the classic activation×evaluation axes;
|
|
34
|
+
* agency/vulnerability reflect structural integrity.
|
|
35
|
+
*/
|
|
36
|
+
export declare function computeOverlay(state: {
|
|
37
|
+
current: SelfState;
|
|
38
|
+
baseline: SelfState;
|
|
39
|
+
}): PsycheOverlay;
|
package/dist/overlay.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// Overlay — semantic-stable effect signals for external consumers
|
|
3
|
+
//
|
|
4
|
+
// The overlay is a projection of self-state, not an interface adapter.
|
|
5
|
+
// arousal/valence/agency/vulnerability have meaning independent of
|
|
6
|
+
// any consumer. Psyche secretes these like hormones — broadcast,
|
|
7
|
+
// not point-to-point.
|
|
8
|
+
// ============================================================
|
|
9
|
+
/** Overlay dimension keys for iteration. */
|
|
10
|
+
export const OVERLAY_KEYS = [
|
|
11
|
+
"arousal", "valence", "agency", "vulnerability",
|
|
12
|
+
];
|
|
13
|
+
/**
|
|
14
|
+
* Normalization range. A 50-point deviation from baseline maps to full scale.
|
|
15
|
+
*
|
|
16
|
+
* Dimensions are 0-100, so ±50 is the theoretical max. In practice most
|
|
17
|
+
* deviations are ±20 (overlay ~±0.4), keeping the signal informative.
|
|
18
|
+
*/
|
|
19
|
+
const RANGE = 50;
|
|
20
|
+
/**
|
|
21
|
+
* Project self-state into overlay effect signals.
|
|
22
|
+
*
|
|
23
|
+
* Pure linear projection from dimension deviations:
|
|
24
|
+
*
|
|
25
|
+
* ```
|
|
26
|
+
* order flow boundary resonance
|
|
27
|
+
* arousal = [ -0.4 0.6 0 0 ]
|
|
28
|
+
* valence = [ 0.5 0 0 0.5 ]
|
|
29
|
+
* agency = [ 0 0.4 0.6 0 ]
|
|
30
|
+
* vulnerability = [ -0.4 0 -0.6 0 ]
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* Each signal reads exactly 2 dimensions. Sparse and interpretable.
|
|
34
|
+
* arousal/valence are the classic activation×evaluation axes;
|
|
35
|
+
* agency/vulnerability reflect structural integrity.
|
|
36
|
+
*/
|
|
37
|
+
export function computeOverlay(state) {
|
|
38
|
+
const c = state.current;
|
|
39
|
+
const b = state.baseline;
|
|
40
|
+
const dO = (c.order - b.order) / RANGE;
|
|
41
|
+
const dF = (c.flow - b.flow) / RANGE;
|
|
42
|
+
const dB = (c.boundary - b.boundary) / RANGE;
|
|
43
|
+
const dR = (c.resonance - b.resonance) / RANGE;
|
|
44
|
+
const clamp = (v) => Math.max(-1, Math.min(1, v)) || 0;
|
|
45
|
+
return {
|
|
46
|
+
arousal: clamp(-0.4 * dO + 0.6 * dF),
|
|
47
|
+
valence: clamp(0.5 * dO + 0.5 * dR),
|
|
48
|
+
agency: clamp(0.4 * dF + 0.6 * dB),
|
|
49
|
+
vulnerability: clamp(-0.4 * dO - 0.6 * dB),
|
|
50
|
+
};
|
|
51
|
+
}
|
package/llms.txt
CHANGED
|
@@ -146,6 +146,21 @@ await psyche.processResponse(text);
|
|
|
146
146
|
- `generationControls`
|
|
147
147
|
- `writebackFeedback`
|
|
148
148
|
|
|
149
|
+
### Overlay (v11.4)
|
|
150
|
+
|
|
151
|
+
`computeOverlay(state)` projects 4D self-state deviations into 4 semantic-stable effect signals — Psyche's "hormones." These are broadcast signals any external system can consume without coupling to Psyche internals.
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
interface PsycheOverlay {
|
|
155
|
+
arousal: number; // [-1, 1] activation level (flow↑ + order↓)
|
|
156
|
+
valence: number; // [-1, 1] positive/negative (order↑ + resonance↑)
|
|
157
|
+
agency: number; // [-1, 1] action capacity (boundary↑ + flow↑)
|
|
158
|
+
vulnerability: number; // [-1, 1] susceptibility (boundary↓ + order↓)
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Pure function, no side effects. Exported from `psyche-ai` public API. Also available via `GET /overlay` (HTTP adapter) and `get_state` MCP tool (overlay field included in response).
|
|
163
|
+
|
|
149
164
|
### MCP tools
|
|
150
165
|
|
|
151
166
|
- `process_input`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "psyche-ai",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.4.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",
|