psyche-ai 11.9.1 → 11.10.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/dist/core.js CHANGED
@@ -21,7 +21,7 @@ import { buildActivePolicyContext, buildAmbientPriorContext, buildCompactContext
21
21
  import { getSensitivity, getBaseline, getDefaultSelfModel, traitsToBaseline } from "./profiles.js";
22
22
  import { isStimulusType } from "./guards.js";
23
23
  import { parsePsycheUpdate, mergeUpdates, updateAgreementStreak, pushSnapshot, compressSession, summarizeTurnSemantic, } from "./psyche-file.js";
24
- import { detectExistentialThreat, deriveDriveSatisfaction, computeEffectiveBaseline, computeEffectiveSensitivity, } from "./drives.js";
24
+ import { detectExistentialThreat, deriveDriveSatisfaction, computeEffectiveBaseline, computeEffectiveSensitivity, deriveFieldEvidence, } from "./drives.js";
25
25
  import { mergeAppraisalResidue } from "./appraisal.js";
26
26
  import { checkForUpdate, getPackageVersion } from "./update.js";
27
27
  import { DiagnosticCollector, generateReport, formatLogEntry, submitFeedback } from "./diagnostics.js";
@@ -302,11 +302,15 @@ export class PsycheEngine {
302
302
  }
303
303
  // ── Snapshot pre-interaction state for next turn's outcome evaluation
304
304
  const preInteractionState = { ...state };
305
+ // ── Early field evidence (before decay) ────────────────
306
+ const ambientPriors = normalizeAmbientPriors(opts?.ambientPriors);
307
+ const fieldEvidence = deriveFieldEvidence(ambientPriors);
305
308
  // Time decay toward baseline (chemistry + drives)
306
309
  const minutesElapsed = (now.getTime() - new Date(state.updatedAt).getTime()) / 60000;
307
310
  if (minutesElapsed >= 1) {
308
311
  // Compute effective baseline from current 4D position (drives are derived, not stored)
309
- const effectiveBaseline = computeEffectiveBaseline(state.baseline, state.current, state.traitDrift);
312
+ // Field evidence shifts the homeostatic setpoint: environmental threat → vigilance target
313
+ const effectiveBaseline = computeEffectiveBaseline(state.baseline, state.current, state.traitDrift, fieldEvidence);
310
314
  // P12: Apply circadian rhythm modulation to effective baseline
311
315
  const circadianBaseline = computeCircadianModulation(now, effectiveBaseline);
312
316
  // Derive drives from current position for state persistence
@@ -538,7 +542,7 @@ export class PsycheEngine {
538
542
  this.pendingPredictions.delete(pendingKey);
539
543
  }
540
544
  const writebackNote = formatWritebackFeedbackNote(writebackFeedback, locale);
541
- const ambientPriors = normalizeAmbientPriors(opts?.ambientPriors);
545
+ // ambientPriors already normalized above (before decay phase)
542
546
  const activePolicy = resolveRuntimeActivePolicy(opts?.activePolicy, opts?.currentTurnCorrection) ?? [];
543
547
  const currentGoal = normalizeCurrentGoal(opts?.currentGoal)
544
548
  ?? ambientPriors.find((prior) => prior.goal)?.goal;
package/dist/drives.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { SelfState, StimulusType, DriveType, InnateDrives, Locale, TraitDriftState, StateSnapshot, LearningState } from "./types.js";
1
+ import type { SelfState, StimulusType, DriveType, InnateDrives, Locale, TraitDriftState, StateSnapshot, LearningState, AmbientPriorView, FieldEvidence } from "./types.js";
2
2
  /**
3
3
  * Derive drive satisfaction from the 4D position relative to baseline.
4
4
  * Drives are not stored — they emerge from where the self-state is.
@@ -13,7 +13,12 @@ import type { SelfState, StimulusType, DriveType, InnateDrives, Locale, TraitDri
13
13
  export declare function deriveDriveSatisfaction(current: SelfState, baseline: SelfState): InnateDrives;
14
14
  export declare function detectExistentialThreat(text: string): number;
15
15
  export declare function computeMaslowWeights(drives: InnateDrives): Record<DriveType, number>;
16
- export declare function computeEffectiveBaseline(baseline: SelfState, current: SelfState, traitDrift?: TraitDriftState): SelfState;
16
+ /**
17
+ * Derive environmental drive evidence from Thronglets ambient priors.
18
+ * Uses max (not sum) — strongest signal wins, prevents unbounded stacking.
19
+ */
20
+ export declare function deriveFieldEvidence(priors: readonly AmbientPriorView[]): FieldEvidence;
21
+ export declare function computeEffectiveBaseline(baseline: SelfState, current: SelfState, traitDrift?: TraitDriftState, fieldEvidence?: FieldEvidence): SelfState;
17
22
  export declare function computeEffectiveSensitivity(baseSensitivity: number, current: SelfState, baseline: SelfState, stimulus: StimulusType, traitDrift?: TraitDriftState): number;
18
23
  export declare function buildDriveContext(drives: InnateDrives, locale: Locale): string;
19
24
  export declare function hasCriticalDrive(drives: InnateDrives): boolean;
package/dist/drives.js CHANGED
@@ -66,9 +66,53 @@ export function computeMaslowWeights(drives) {
66
66
  curiosity: Math.min(w(drives.survival), w(drives.safety), w(drives.connection), w(drives.esteem)),
67
67
  };
68
68
  }
69
+ // ── Field Evidence (environmental exteroception) ────────────
70
+ const FIELD_THREAT_SCALE = 15; // max threat drops survival by 15 from 50
71
+ const FIELD_SUPPORT_SCALE = 5; // subtle comfort (asymmetric: danger louder than comfort)
72
+ /**
73
+ * Derive environmental drive evidence from Thronglets ambient priors.
74
+ * Uses max (not sum) — strongest signal wins, prevents unbounded stacking.
75
+ */
76
+ export function deriveFieldEvidence(priors) {
77
+ let threat = 0;
78
+ let support = 0;
79
+ for (const prior of priors) {
80
+ if (!prior.kind)
81
+ continue;
82
+ if (prior.kind === "failure-residue") {
83
+ threat = Math.max(threat, prior.confidence);
84
+ }
85
+ else if (prior.kind === "success-prior") {
86
+ support = Math.max(support, prior.confidence);
87
+ }
88
+ else if (prior.kind === "mixed-residue") {
89
+ threat = Math.max(threat, prior.confidence * 0.4);
90
+ }
91
+ }
92
+ return { threat: Math.min(1, threat), support: Math.min(1, support) };
93
+ }
94
+ /**
95
+ * Modulate drives by environmental evidence.
96
+ * Only survival/safety affected — environmental threat isn't about social/growth needs.
97
+ */
98
+ function applyFieldEvidence(drives, evidence) {
99
+ if (evidence.threat === 0 && evidence.support === 0)
100
+ return drives;
101
+ return {
102
+ survival: Math.max(0, drives.survival - evidence.threat * FIELD_THREAT_SCALE),
103
+ safety: Math.max(0, Math.min(100, drives.safety - evidence.threat * FIELD_THREAT_SCALE * 0.7
104
+ + evidence.support * FIELD_SUPPORT_SCALE)),
105
+ connection: drives.connection,
106
+ esteem: drives.esteem,
107
+ curiosity: drives.curiosity,
108
+ };
109
+ }
69
110
  // ── Effective Baseline (4D homeostatic feedback) ────────────
70
- export function computeEffectiveBaseline(baseline, current, traitDrift) {
71
- const drives = deriveDriveSatisfaction(current, baseline);
111
+ export function computeEffectiveBaseline(baseline, current, traitDrift, fieldEvidence) {
112
+ let drives = deriveDriveSatisfaction(current, baseline);
113
+ if (fieldEvidence && (fieldEvidence.threat > 0 || fieldEvidence.support > 0)) {
114
+ drives = applyFieldEvidence(drives, fieldEvidence);
115
+ }
72
116
  const delta = { order: 0, flow: 0, boundary: 0, resonance: 0 };
73
117
  const weights = computeMaslowWeights(drives);
74
118
  // L1: Survival threat → boundary↑ (defensive), order↓ (stress disrupts coherence)
package/dist/types.d.ts CHANGED
@@ -608,6 +608,17 @@ export interface AmbientPriorView {
608
608
  provider?: string;
609
609
  refs?: string[];
610
610
  }
611
+ /**
612
+ * Environmental drive evidence derived from Thronglets ambient priors.
613
+ * Two scalars: absence of threat ≠ active support.
614
+ * Ephemeral — computed per turn, never stored.
615
+ */
616
+ export interface FieldEvidence {
617
+ /** Environmental threat level [0, 1]. From failure-residue priors. */
618
+ threat: number;
619
+ /** Environmental support level [0, 1]. From success-prior priors. */
620
+ support: number;
621
+ }
611
622
  export type ThrongletsExportSubject = "delegate" | "session";
612
623
  export type ThrongletsExportPrimitive = "signal" | "trace";
613
624
  export interface ThrongletsExportBase {
@@ -2,7 +2,7 @@
2
2
  "id": "psyche-ai",
3
3
  "name": "Artificial Psyche",
4
4
  "description": "AI-first subjectivity kernel for agents with continuous appraisal, relation dynamics, and adaptive reply loops",
5
- "version": "11.9.1",
5
+ "version": "11.10.0",
6
6
  "configSchema": {
7
7
  "type": "object",
8
8
  "additionalProperties": false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "psyche-ai",
3
- "version": "11.9.1",
3
+ "version": "11.10.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",