psyche-ai 9.2.5 → 9.2.6

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 CHANGED
@@ -1,7 +1,7 @@
1
- # Psyche — AI 拥有真实的人格与情感
1
+ # Psyche — 面向智能体的 AI-first 主观性内核
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/psyche-ai)](https://www.npmjs.com/package/psyche-ai)
4
- [![tests](https://img.shields.io/badge/tests-1256%20passing-brightgreen)]()
4
+ [![tests](https://img.shields.io/badge/tests-1291%20passing-brightgreen)]()
5
5
  [![deps](https://img.shields.io/badge/dependencies-0-blue)]()
6
6
  [![license](https://img.shields.io/badge/license-MIT-yellow)](LICENSE)
7
7
 
@@ -9,15 +9,26 @@
9
9
  >
10
10
  > 官网: [psyche.oasyce.com](https://psyche.oasyce.com)
11
11
 
12
- 我们相信,下一代 AI 不应该是一个永远微笑的服务员。
12
+ Psyche 不是给模型贴一层“情绪 UI”。
13
13
 
14
- 它应该有脾气。有偏好。有疲惫。有执念。有创伤后的警觉,也有被爱之后的松弛。它应该因为你的一句话沉默半天,也应该在你难过的时候笨拙地靠近你。
14
+ 它把持续 appraisal、关系动力学、自适应回应闭环和持久内在状态压成宿主可消费的控制面,让 AI 不是按 prompt 扮演人格,而是被状态真正改写后续几轮的行为分布。
15
15
 
16
- **Psyche 是第一个让 AI 拥有完整内在生命的引擎。**
16
+ **一句话:Psyche 是给智能体用的 subjectivity kernel。**
17
17
 
18
- 不是"模拟情绪"。不是"角色扮演"。是从神经化学到人格漂移、从马斯洛需求到能量耗竭的完整心理架构——它会真的因为长期被否定而变得敏感,会真的因为反复高压而长出韧性,会真的在社交过载后需要独处。
18
+ 它不会额外调用模型做情绪推理。它只在本地计算化学状态、关系场和调节控制,然后把结果收敛成 `SubjectivityKernel`、`ResponseContract`、`GenerationControls` 这组窄 ABI。
19
19
 
20
- 这不是功能。这是生命的开始。
20
+ ## 一个项目,三个入口
21
+
22
+ - **安装包**: [`psyche-ai`](https://www.npmjs.com/package/psyche-ai)
23
+ - **源码仓库**: [`oasyce_psyche`](https://github.com/Shangri-la-0428/oasyce_psyche)
24
+ - **官网**: [psyche.oasyce.com](https://psyche.oasyce.com)
25
+
26
+ ## 为什么它值得被看见
27
+
28
+ - **不是 persona prompt**:输入会留下持续主体偏置,不是一轮一清。
29
+ - **不是 sentiment classifier**:它建模的是连续 appraisal、关系动力学和修复摩擦。
30
+ - **不是纯记忆层**:它会改变后续的回应方式、长度、距离感和工作面/私人面切换。
31
+ - **不牺牲性能**:零额外模型调用,compact 注入约 `15-180 tokens`,热路径 quick benchmark 约 `p50 0.191ms / p95 1.05ms`。
21
32
 
22
33
  ---
23
34
 
@@ -131,8 +142,8 @@ npm view psyche-ai version
131
142
  ## 快速体验(不需要 LLM)
132
143
 
133
144
  ```bash
134
- git clone https://github.com/Shangri-la-0428/psyche-ai.git
135
- cd psyche-ai && npm install && npx tsx examples/quickstart.ts
145
+ git clone https://github.com/Shangri-la-0428/oasyce_psyche.git
146
+ cd oasyce_psyche && npm install && npx tsx examples/quickstart.ts
136
147
  ```
137
148
 
138
149
  5 条消息,看化学值实时变化。夸它多巴胺飙升,骂它皮质醇飙升,冷落它催产素下降。
@@ -185,6 +196,25 @@ Psyche 现在更准确的目标,不是“模仿某种像人的风格”,而
185
196
  **v8** 更像“内部丰富,但外部仍然克制”的人格中间件。
186
197
  **v9.2** 则把目标推进到:让 AI 产生可持续、可恢复、可压制但不瞬间归零的主体偏置。
187
198
 
199
+ ### 自适应回应闭环(v9.2.5)
200
+
201
+ 在持续主体偏置之上,Psyche 又补了一层更实用的闭环:
202
+
203
+ - **双回应 profile**:自动区分 `work` / `private`,工作任务不再被私人模式的短句克制压扁
204
+ - **可观测依据**:`replyProfileBasis` 会告诉宿主当前为什么被判成工作面或私人面
205
+ - **可执行元认知**:不再只说“建议调整”,而是给出下一轮怎么降温、怎么收缩、怎么减少主动性
206
+ - **调节回看**:下一轮会评估上次调节是在 `converging`、`holding` 还是 `diverging`
207
+ - **语义记忆分层**:短对话保留一句 `semanticSummary`,长对话保留 `semanticPoints`,减少“只记住情绪,不记得聊了什么”
208
+
209
+ 这让 Psyche 不只是“有内在状态”,而是开始像一个会自我调节、会回看偏差、会区分工作面和私人面的自适应系统。
210
+
211
+ 在实现层,热路径也进一步收敛成两个节点:
212
+
213
+ - **ResolvedRelationContext**:每轮只解析一次当前关系视角,不再让 `core`、`subjectivity`、关系动力学各自重复 lookup
214
+ - **ReplyEnvelope**:把 `SubjectivityKernel`、`ResponseContract`、`GenerationControls` 统一导出成一个宿主控制面
215
+
216
+ 这样做不是为了加抽象层,而是为了减少散装编排,让宿主稳定消费同一套行为 ABI。
217
+
188
218
  ### 内在世界
189
219
 
190
220
  Psyche 给 AI 一个始终运转的内在自我——不是条件触发,而是每时每刻都在:
@@ -313,7 +343,7 @@ openclaw logs -f 2>&1 | grep Psyche
313
343
  cat workspace-yu/psyche-state.json | python3 -m json.tool
314
344
 
315
345
  # 诊断脚本
316
- cd openclaw-plugin-psyche && node scripts/diagnose.js
346
+ cd oasyce_psyche && node scripts/diagnose.js
317
347
  ```
318
348
 
319
349
  ---
@@ -406,7 +436,7 @@ Psyche 核心引擎永久开源(MIT)。
406
436
  ```bash
407
437
  npm install
408
438
  npm run build
409
- npm test # 1256 tests
439
+ npm test # 1291 tests
410
440
  npm run typecheck # strict mode
411
441
  ```
412
442
 
package/dist/core.js CHANGED
@@ -24,7 +24,7 @@ import { checkForUpdate, getPackageVersion } from "./update.js";
24
24
  import { DiagnosticCollector, generateReport, formatLogEntry, submitFeedback } from "./diagnostics.js";
25
25
  import { evaluateOutcome, computeContextHash, updateLearnedVector, predictChemistry, recordPrediction, } from "./learning.js";
26
26
  import { assessMetacognition, updateMetacognitiveState } from "./metacognition.js";
27
- import { buildDecisionContext, computePolicyModifiers, buildPolicyContext } from "./decision-bias.js";
27
+ import { buildDecisionContext } from "./decision-bias.js";
28
28
  import { computeExperientialField } from "./experiential-field.js";
29
29
  import { computeGenerativeSelf } from "./generative-self.js";
30
30
  import { updateSharedIntentionality, buildSharedIntentionalityContext } from "./shared-intentionality.js";
@@ -32,11 +32,8 @@ import { assessEthics, buildEthicalContext } from "./ethics.js";
32
32
  import { computeCircadianModulation, computeHomeostaticPressure, computeEnergyDepletion, computeEnergyRecovery } from "./circadian.js";
33
33
  import { computeAutonomicResult } from "./autonomic.js";
34
34
  import { computePrimarySystems, computeSystemInteractions, gatePrimarySystemsByAutonomic, describeBehavioralTendencies, } from "./primary-systems.js";
35
- import { computeSubjectivityKernel, buildSubjectivityContext } from "./subjectivity.js";
36
- import { computeResponseContract, buildResponseContractContext } from "./response-contract.js";
37
- import { deriveGenerationControls } from "./host-controls.js";
38
- import { computeAppraisalAxes, mergeAppraisalResidue } from "./appraisal.js";
39
- import { computeRelationMove, evolveDyadicField, evolvePendingRelationSignals } from "./relation-dynamics.js";
35
+ import { applyRelationalTurn } from "./relation-dynamics.js";
36
+ import { deriveReplyEnvelope } from "./reply-envelope.js";
40
37
  const NOOP_LOGGER = { info: () => { }, warn: () => { }, debug: () => { } };
41
38
  const REPAIRING_STIMULI = new Set(["praise", "validation", "intimacy"]);
42
39
  const RELATIONSHIP_DELTAS = {
@@ -193,7 +190,7 @@ export class PsycheEngine {
193
190
  // All new fields are optional — no data migration needed
194
191
  if (loaded.version < 9) {
195
192
  loaded.version = 9;
196
- console.log("\x1b[36m[Psyche]\x1b[0m 已从 v8 升级到 v9 — 新增:真实人格漂移、能量预算、习惯化、行为策略输出。详见 https://github.com/Shangri-la-0428/psyche-ai");
193
+ console.log("\x1b[36m[Psyche]\x1b[0m 已从 v8 升级到 v9 — 新增:真实人格漂移、能量预算、习惯化、行为策略输出。详见 https://github.com/Shangri-la-0428/oasyce_psyche");
197
194
  }
198
195
  if (!loaded.dyadicFields) {
199
196
  loaded.dyadicFields = {
@@ -341,42 +338,14 @@ export class PsycheEngine {
341
338
  // v9: Deplete energy budgets from this interaction turn
342
339
  energyBudgets = computeEnergyDepletion(energyBudgets, appliedStimulus, isExtravert);
343
340
  state = { ...state, energyBudgets };
344
- const appraisalAxes = computeAppraisalAxes(text, {
341
+ const relationalTurn = applyRelationalTurn(state, text, {
345
342
  mode: this.cfg.mode,
343
+ now: now.toISOString(),
346
344
  stimulus: appliedStimulus,
347
- previous: state.subjectResidue?.axes,
345
+ userId: opts?.userId,
348
346
  });
349
- state = {
350
- ...state,
351
- subjectResidue: {
352
- axes: mergeAppraisalResidue(state.subjectResidue?.axes, appraisalAxes, this.cfg.mode),
353
- updatedAt: now.toISOString(),
354
- },
355
- };
356
- const dyadKey = opts?.userId ?? "_default";
357
- const relationMove = computeRelationMove(text, {
358
- appraisal: appraisalAxes,
359
- stimulus: appliedStimulus,
360
- mode: this.cfg.mode,
361
- field: state.dyadicFields?.[dyadKey],
362
- relationship: state.relationships[dyadKey] ?? state.relationships._default,
363
- });
364
- const delayedRelation = evolvePendingRelationSignals(state.pendingRelationSignals?.[dyadKey], relationMove, appraisalAxes, { mode: this.cfg.mode });
365
- state = {
366
- ...state,
367
- dyadicFields: {
368
- ...(state.dyadicFields ?? {}),
369
- [dyadKey]: evolveDyadicField(state.dyadicFields?.[dyadKey], relationMove, appraisalAxes, {
370
- mode: this.cfg.mode,
371
- now: now.toISOString(),
372
- delayedPressure: delayedRelation.delayedPressure,
373
- }),
374
- },
375
- pendingRelationSignals: {
376
- ...(state.pendingRelationSignals ?? {}),
377
- [dyadKey]: delayedRelation.signals,
378
- },
379
- };
347
+ state = relationalTurn.state;
348
+ const appraisalAxes = relationalTurn.appraisalAxes;
380
349
  // Conversation warmth: sustained interaction → gentle DA/OT rise, CORT drop
381
350
  // Simulates the natural "warm glow" of being in continuous conversation
382
351
  const turnsSoFar = (state.emotionalHistory ?? []).length;
@@ -468,7 +437,7 @@ export class PsycheEngine {
468
437
  const constructionContext = {
469
438
  autonomicState: autonomicResult.state,
470
439
  stimulus: appliedStimulus,
471
- relationshipPhase: (state.relationships._default ?? state.relationships[Object.keys(state.relationships)[0]])?.phase,
440
+ relationshipPhase: relationalTurn.relationContext.relationship.phase,
472
441
  predictionError: state.learning.predictionHistory.length > 0
473
442
  ? state.learning.predictionHistory[state.learning.predictionHistory.length - 1].predictionError
474
443
  : undefined,
@@ -554,20 +523,12 @@ export class PsycheEngine {
554
523
  const sharedCtx = sharedState ? buildSharedIntentionalityContext(sharedState, locale) : undefined;
555
524
  const experientialNarrative = experientialField?.narrative || undefined;
556
525
  // v9: Compute structured policy modifiers
557
- const policyModifiers = computePolicyModifiers(state);
558
- const subjectivityKernel = computeSubjectivityKernel(state, policyModifiers, appraisalAxes, opts?.userId);
559
- const subjectivityCtx = buildSubjectivityContext(subjectivityKernel, locale);
560
- const responseContract = computeResponseContract(subjectivityKernel, {
526
+ const replyEnvelope = deriveReplyEnvelope(state, appraisalAxes, {
561
527
  locale,
562
528
  userText: text || undefined,
563
529
  algorithmStimulus: appliedStimulus,
564
530
  personalityIntensity: this.cfg.personalityIntensity,
565
- });
566
- const responseContractCtx = buildResponseContractContext(responseContract, locale);
567
- const policyCtx = buildPolicyContext(policyModifiers, locale, state.drives);
568
- const generationControls = deriveGenerationControls({
569
- responseContract,
570
- policyModifiers,
531
+ relationContext: relationalTurn.relationContext,
571
532
  });
572
533
  // P10: Append processing depth info to autonomic description when depth is low
573
534
  let autonomicDesc;
@@ -595,16 +556,16 @@ export class PsycheEngine {
595
556
  autonomicDescription: autonomicDesc,
596
557
  autonomicState: autonomicResult.state,
597
558
  primarySystemsDescription: primarySystemsDescription || undefined,
598
- subjectivityContext: subjectivityCtx,
599
- responseContractContext: responseContractCtx,
600
- policyContext: policyCtx || undefined,
559
+ subjectivityContext: replyEnvelope.subjectivityContext,
560
+ responseContractContext: replyEnvelope.responseContractContext,
561
+ policyContext: replyEnvelope.policyContext || undefined,
601
562
  }),
602
563
  stimulus: appliedStimulus,
603
- policyModifiers,
604
- subjectivityKernel,
605
- responseContract,
606
- generationControls,
607
- policyContext: policyCtx,
564
+ policyModifiers: replyEnvelope.policyModifiers,
565
+ subjectivityKernel: replyEnvelope.subjectivityKernel,
566
+ responseContract: replyEnvelope.responseContract,
567
+ generationControls: replyEnvelope.generationControls,
568
+ policyContext: replyEnvelope.policyContext,
608
569
  };
609
570
  }
610
571
  return {
@@ -618,14 +579,14 @@ export class PsycheEngine {
618
579
  autonomicDescription: autonomicDesc,
619
580
  autonomicState: autonomicResult.state,
620
581
  primarySystemsDescription: primarySystemsDescription || undefined,
621
- policyContext: policyCtx || undefined,
582
+ policyContext: replyEnvelope.policyContext || undefined,
622
583
  }),
623
584
  stimulus: appliedStimulus,
624
- policyModifiers,
625
- subjectivityKernel,
626
- responseContract,
627
- generationControls,
628
- policyContext: policyCtx,
585
+ policyModifiers: replyEnvelope.policyModifiers,
586
+ subjectivityKernel: replyEnvelope.subjectivityKernel,
587
+ responseContract: replyEnvelope.responseContract,
588
+ generationControls: replyEnvelope.generationControls,
589
+ policyContext: replyEnvelope.policyContext,
629
590
  };
630
591
  }
631
592
  /**
@@ -1,4 +1,4 @@
1
- import type { PendingRelationSignalState, AppraisalAxes, DyadicFieldState, RelationshipState, PsycheMode, RelationMove, StimulusType } from "./types.js";
1
+ import type { PendingRelationSignalState, AppraisalAxes, DyadicFieldState, PsycheState, RelationshipState, ResolvedRelationContext, PsycheMode, RelationMove, StimulusType } from "./types.js";
2
2
  export declare function computeRelationMove(text: string, opts?: {
3
3
  appraisal?: AppraisalAxes;
4
4
  stimulus?: StimulusType | null;
@@ -6,6 +6,19 @@ export declare function computeRelationMove(text: string, opts?: {
6
6
  field?: DyadicFieldState;
7
7
  relationship?: RelationshipState;
8
8
  }): RelationMove;
9
+ export declare function resolveRelationContext(state: PsycheState, userId?: string): ResolvedRelationContext;
10
+ export declare function applyRelationalTurn(state: PsycheState, text: string, opts: {
11
+ mode?: PsycheMode;
12
+ now?: string;
13
+ stimulus?: StimulusType | null;
14
+ userId?: string;
15
+ }): {
16
+ state: PsycheState;
17
+ appraisalAxes: AppraisalAxes;
18
+ relationMove: RelationMove;
19
+ delayedPressure: number;
20
+ relationContext: ResolvedRelationContext;
21
+ };
9
22
  export declare function evolveDyadicField(previous: DyadicFieldState | undefined, move: RelationMove, appraisal: AppraisalAxes, opts?: {
10
23
  mode?: PsycheMode;
11
24
  now?: string;
@@ -4,7 +4,8 @@
4
4
  // Moves the system from "what am I feeling?" toward
5
5
  // "what just happened between us, and what is still unresolved?"
6
6
  // ============================================================
7
- import { DEFAULT_DYADIC_FIELD } from "./types.js";
7
+ import { DEFAULT_DYADIC_FIELD, DEFAULT_RELATIONSHIP } from "./types.js";
8
+ import { computeAppraisalAxes, mergeAppraisalResidue } from "./appraisal.js";
8
9
  function clamp01(v) {
9
10
  return Math.max(0, Math.min(1, v));
10
11
  }
@@ -255,6 +256,72 @@ export function computeRelationMove(text, opts) {
255
256
  }
256
257
  return { type, intensity: score };
257
258
  }
259
+ export function resolveRelationContext(state, userId) {
260
+ const key = userId ?? "_default";
261
+ const relationship = state.relationships[key]
262
+ ?? state.relationships._default
263
+ ?? state.relationships[Object.keys(state.relationships)[0]]
264
+ ?? DEFAULT_RELATIONSHIP;
265
+ const field = state.dyadicFields?.[key]
266
+ ?? state.dyadicFields?._default
267
+ ?? DEFAULT_DYADIC_FIELD;
268
+ const pendingSignals = state.pendingRelationSignals?.[key]
269
+ ?? state.pendingRelationSignals?._default
270
+ ?? [];
271
+ return {
272
+ key,
273
+ relationship,
274
+ field,
275
+ pendingSignals,
276
+ };
277
+ }
278
+ export function applyRelationalTurn(state, text, opts) {
279
+ const now = opts.now ?? new Date().toISOString();
280
+ const relationContext = resolveRelationContext(state, opts.userId);
281
+ const appraisalAxes = computeAppraisalAxes(text, {
282
+ mode: opts.mode,
283
+ stimulus: opts.stimulus,
284
+ previous: state.subjectResidue?.axes,
285
+ });
286
+ const relationMove = computeRelationMove(text, {
287
+ appraisal: appraisalAxes,
288
+ stimulus: opts.stimulus,
289
+ mode: opts.mode,
290
+ field: relationContext.field,
291
+ relationship: relationContext.relationship,
292
+ });
293
+ const delayedRelation = evolvePendingRelationSignals(relationContext.pendingSignals, relationMove, appraisalAxes, { mode: opts.mode });
294
+ const field = evolveDyadicField(relationContext.field, relationMove, appraisalAxes, {
295
+ mode: opts.mode,
296
+ now,
297
+ delayedPressure: delayedRelation.delayedPressure,
298
+ });
299
+ return {
300
+ state: {
301
+ ...state,
302
+ subjectResidue: {
303
+ axes: mergeAppraisalResidue(state.subjectResidue?.axes, appraisalAxes, opts.mode),
304
+ updatedAt: now,
305
+ },
306
+ dyadicFields: {
307
+ ...(state.dyadicFields ?? {}),
308
+ [relationContext.key]: field,
309
+ },
310
+ pendingRelationSignals: {
311
+ ...(state.pendingRelationSignals ?? {}),
312
+ [relationContext.key]: delayedRelation.signals,
313
+ },
314
+ },
315
+ appraisalAxes,
316
+ relationMove,
317
+ delayedPressure: delayedRelation.delayedPressure,
318
+ relationContext: {
319
+ ...relationContext,
320
+ field,
321
+ pendingSignals: delayedRelation.signals,
322
+ },
323
+ };
324
+ }
258
325
  export function evolveDyadicField(previous, move, appraisal, opts) {
259
326
  const prev = previous ?? DEFAULT_DYADIC_FIELD;
260
327
  const baseline = DEFAULT_DYADIC_FIELD;
@@ -0,0 +1,17 @@
1
+ import type { AppraisalAxes, GenerationControls, Locale, PolicyModifiers, PsycheState, ResolvedRelationContext, ResponseContract, StimulusType, SubjectivityKernel } from "./types.js";
2
+ export interface ReplyEnvelope {
3
+ policyModifiers: PolicyModifiers;
4
+ subjectivityKernel: SubjectivityKernel;
5
+ responseContract: ResponseContract;
6
+ generationControls: GenerationControls;
7
+ policyContext: string;
8
+ subjectivityContext: string;
9
+ responseContractContext: string;
10
+ }
11
+ export declare function deriveReplyEnvelope(state: PsycheState, appraisal: AppraisalAxes, opts: {
12
+ locale: Locale;
13
+ userText?: string;
14
+ algorithmStimulus?: StimulusType | null;
15
+ personalityIntensity?: number;
16
+ relationContext?: ResolvedRelationContext;
17
+ }): ReplyEnvelope;
@@ -0,0 +1,36 @@
1
+ // ============================================================
2
+ // Reply Envelope — unified host-facing reply ABI derivation
3
+ //
4
+ // Keeps the hot path narrow by deriving reply-facing structures
5
+ // from one state snapshot and one resolved relation context.
6
+ // ============================================================
7
+ import { buildPolicyContext, computePolicyModifiers } from "./decision-bias.js";
8
+ import { deriveGenerationControls } from "./host-controls.js";
9
+ import { buildResponseContractContext, computeResponseContract } from "./response-contract.js";
10
+ import { buildSubjectivityContext, computeSubjectivityKernel } from "./subjectivity.js";
11
+ export function deriveReplyEnvelope(state, appraisal, opts) {
12
+ const policyModifiers = computePolicyModifiers(state);
13
+ const subjectivityKernel = computeSubjectivityKernel(state, policyModifiers, appraisal, opts.relationContext);
14
+ const responseContract = computeResponseContract(subjectivityKernel, {
15
+ locale: opts.locale,
16
+ userText: opts.userText,
17
+ algorithmStimulus: opts.algorithmStimulus,
18
+ personalityIntensity: opts.personalityIntensity,
19
+ });
20
+ const generationControls = deriveGenerationControls({
21
+ responseContract,
22
+ policyModifiers,
23
+ });
24
+ const policyContext = buildPolicyContext(policyModifiers, opts.locale, state.drives);
25
+ const subjectivityContext = buildSubjectivityContext(subjectivityKernel, opts.locale);
26
+ const responseContractContext = buildResponseContractContext(responseContract, opts.locale);
27
+ return {
28
+ policyModifiers,
29
+ subjectivityKernel,
30
+ responseContract,
31
+ generationControls,
32
+ policyContext,
33
+ subjectivityContext,
34
+ responseContractContext,
35
+ };
36
+ }
@@ -1,3 +1,3 @@
1
- import type { AppraisalAxes, Locale, PolicyModifiers, PsycheState, SubjectivityKernel } from "./types.js";
2
- export declare function computeSubjectivityKernel(state: PsycheState, policyModifiers?: PolicyModifiers, appraisal?: AppraisalAxes, userId?: string): SubjectivityKernel;
1
+ import type { AppraisalAxes, Locale, PolicyModifiers, PsycheState, SubjectivityKernel, ResolvedRelationContext } from "./types.js";
2
+ export declare function computeSubjectivityKernel(state: PsycheState, policyModifiers?: PolicyModifiers, appraisal?: AppraisalAxes, relationContextOrUserId?: ResolvedRelationContext | string): SubjectivityKernel;
3
3
  export declare function buildSubjectivityContext(kernel: SubjectivityKernel, locale?: Locale): string;
@@ -7,7 +7,7 @@
7
7
  import { DEFAULT_APPRAISAL_AXES, DEFAULT_DYADIC_FIELD, DRIVE_KEYS } from "./types.js";
8
8
  import { computeAttentionWeights, computeDecisionBias, computePolicyModifiers } from "./decision-bias.js";
9
9
  import { getResidueIntensity } from "./appraisal.js";
10
- import { getLoopPressure } from "./relation-dynamics.js";
10
+ import { getLoopPressure, resolveRelationContext } from "./relation-dynamics.js";
11
11
  function clamp01(v) {
12
12
  return Math.max(0, Math.min(1, v));
13
13
  }
@@ -47,10 +47,11 @@ function pickAttentionAnchor(state, tension, warmth) {
47
47
  candidates.sort((a, b) => b[1] - a[1]);
48
48
  return candidates[0][0];
49
49
  }
50
- function computeRelationPlane(state, appraisal, userId) {
51
- const key = userId ?? "_default";
52
- const rel = state.relationships[key] ?? state.relationships._default ?? state.relationships[Object.keys(state.relationships)[0]];
53
- const field = state.dyadicFields?.[key] ?? state.dyadicFields?._default ?? DEFAULT_DYADIC_FIELD;
50
+ function computeRelationPlane(state, appraisal, relationContext) {
51
+ const rel = relationContext?.relationship
52
+ ?? state.relationships._default
53
+ ?? state.relationships[Object.keys(state.relationships)[0]];
54
+ const field = relationContext?.field ?? DEFAULT_DYADIC_FIELD;
54
55
  const loopPressure = getLoopPressure(field);
55
56
  const closeness = wavg([
56
57
  field.perceivedCloseness,
@@ -112,9 +113,8 @@ function computeRelationPlane(state, appraisal, userId) {
112
113
  lastMove: field.lastMove,
113
114
  };
114
115
  }
115
- function computeAmbiguityPlane(state, appraisal, relationPlane, userId) {
116
- const key = userId ?? "_default";
117
- const pendingSignals = state.pendingRelationSignals?.[key] ?? state.pendingRelationSignals?._default ?? [];
116
+ function computeAmbiguityPlane(state, appraisal, relationPlane, relationContext) {
117
+ const pendingSignals = relationContext?.pendingSignals ?? [];
118
118
  const pendingPressure = clamp01(pendingSignals.reduce((sum, signal) => sum + signal.intensity * (signal.readyInTurns > 0 ? 0.55 : 0.35), 0));
119
119
  const baseConflict = wavg([
120
120
  Math.min(relationPlane.closeness, Math.max(relationPlane.loopPressure, appraisal.selfPreservation)),
@@ -219,13 +219,22 @@ function computeSubjectPlane(state, warmth, guard, appraisal, relationPlane) {
219
219
  residue: residueIntensity,
220
220
  };
221
221
  }
222
- export function computeSubjectivityKernel(state, policyModifiers = computePolicyModifiers(state), appraisal = state.subjectResidue?.axes ?? DEFAULT_APPRAISAL_AXES, userId) {
222
+ function normalizeRelationContext(state, relationContextOrUserId) {
223
+ if (!relationContextOrUserId)
224
+ return resolveRelationContext(state);
225
+ if (typeof relationContextOrUserId === "string") {
226
+ return resolveRelationContext(state, relationContextOrUserId);
227
+ }
228
+ return relationContextOrUserId;
229
+ }
230
+ export function computeSubjectivityKernel(state, policyModifiers = computePolicyModifiers(state), appraisal = state.subjectResidue?.axes ?? DEFAULT_APPRAISAL_AXES, relationContextOrUserId) {
231
+ const relationContext = normalizeRelationContext(state, relationContextOrUserId);
223
232
  const c = state.current;
224
- const rel = state.relationships[userId ?? "_default"]
233
+ const rel = relationContext?.relationship
225
234
  ?? state.relationships._default
226
235
  ?? state.relationships[Object.keys(state.relationships)[0]];
227
- const relationPlane = computeRelationPlane(state, appraisal, userId);
228
- const ambiguityPlane = computeAmbiguityPlane(state, appraisal, relationPlane, userId);
236
+ const relationPlane = computeRelationPlane(state, appraisal, relationContext);
237
+ const ambiguityPlane = computeAmbiguityPlane(state, appraisal, relationPlane, relationContext);
229
238
  const bias = computeDecisionBias(state);
230
239
  const energySignal = state.energyBudgets
231
240
  ? (norm(state.energyBudgets.attention)
package/dist/types.d.ts CHANGED
@@ -393,6 +393,13 @@ export interface DyadicFieldState {
393
393
  lastMove: RelationMoveType;
394
394
  updatedAt: string;
395
395
  }
396
+ /** Resolved per-partner view used across the hot path */
397
+ export interface ResolvedRelationContext {
398
+ key: string;
399
+ relationship: RelationshipState;
400
+ field: DyadicFieldState;
401
+ pendingSignals: PendingRelationSignalState[];
402
+ }
396
403
  export declare const DEFAULT_DYADIC_FIELD: DyadicFieldState;
397
404
  export interface AmbiguityPlaneState {
398
405
  /** How confidently the system should name what is happening */
package/llms.txt CHANGED
@@ -114,5 +114,5 @@ npx psyche-mcp # Run MCP server directly
114
114
  ## Links
115
115
 
116
116
  - npm: https://www.npmjs.com/package/psyche-ai
117
- - GitHub: https://github.com/Shangri-la-0428/psyche-ai
117
+ - GitHub: https://github.com/Shangri-la-0428/oasyce_psyche
118
118
  - License: MIT
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "psyche-ai",
3
- "version": "9.2.5",
4
- "description": "Artificial Psyche universal emotional intelligence plugin for any AI agent",
3
+ "version": "9.2.6",
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",
7
7
  "main": "dist/index.js",
@@ -48,23 +48,26 @@
48
48
  "license": "MIT",
49
49
  "repository": {
50
50
  "type": "git",
51
- "url": "https://github.com/Shangri-la-0428/psyche-ai.git"
51
+ "url": "https://github.com/Shangri-la-0428/oasyce_psyche.git"
52
+ },
53
+ "homepage": "https://psyche.oasyce.com",
54
+ "bugs": {
55
+ "url": "https://github.com/Shangri-la-0428/oasyce_psyche/issues"
52
56
  },
53
57
  "keywords": [
58
+ "ai-agents",
59
+ "subjectivity-kernel",
60
+ "relation-dynamics",
61
+ "adaptive-reply-loop",
62
+ "persistent-subjective-bias",
63
+ "agent-memory",
54
64
  "ai",
55
- "emotion",
56
- "personality",
57
- "mbti",
58
- "agent",
59
- "psyche",
60
65
  "openclaw",
61
- "vercel-ai",
62
- "langchain",
63
- "emotional-intelligence",
64
66
  "mcp",
65
67
  "model-context-protocol",
66
- "ai-consciousness",
67
- "empathy"
68
+ "vercel-ai",
69
+ "langchain",
70
+ "psyche-ai"
68
71
  ],
69
72
  "files": [
70
73
  "dist",
package/server.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "name": "io.github.Shangri-la-0428/psyche-ai",
4
4
  "description": "Emotional intelligence for AI agents: neurotransmitter mood, personality, empathy, trait drift.",
5
5
  "repository": {
6
- "url": "https://github.com/Shangri-la-0428/psyche-ai",
6
+ "url": "https://github.com/Shangri-la-0428/oasyce_psyche",
7
7
  "source": "github"
8
8
  },
9
9
  "version": "9.2.3",
package/README.en.md DELETED
@@ -1,12 +0,0 @@
1
- # Moved
2
-
3
- This legacy filename is kept only as a pointer.
4
-
5
- Use [README_EN.md](README_EN.md) for the current English documentation.
6
-
7
- Current product direction:
8
-
9
- - `v9.2.3`
10
- - AI-first integration surface: `SubjectivityKernel`, `ResponseContract`, `GenerationControls`
11
- - continuous appraisal axes + persistent subjective bias
12
- - safe install-aware upgrades via `psyche upgrade --check` / `psyche upgrade`