psyche-ai 9.2.6 → 9.2.7

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.
@@ -172,9 +172,14 @@ function computeLengthBudget(locale, userText, replyProfile, expressionMode, ker
172
172
  }
173
173
  function buildStimulusReportingGuide(locale) {
174
174
  if (locale === "zh") {
175
- return "stimulus速记:闲聊casual/命令authority/认同validation/示弱vulnerability/冷淡neglect/批评criticism";
175
+ return "stimulus速记:闲聊/命令/认同/示弱/冷淡/批评";
176
176
  }
177
- return "stimulus map: chat=casual / command=authority / agreement=validation / vulnerable=vulnerability / cold=neglect / criticism=criticism";
177
+ return "stimulus map: chat/command/validation/vulnerability/neglect/criticism";
178
+ }
179
+ function buildWritebackGuide(locale) {
180
+ return locale === "zh"
181
+ ? "signals可写"
182
+ : "signals writable";
178
183
  }
179
184
  function detectToneParticles(userText, locale) {
180
185
  if (locale !== "zh")
@@ -195,6 +200,12 @@ export function computeResponseContract(kernel, opts) {
195
200
  const userText = opts?.userText ?? "";
196
201
  const personalityIntensity = opts?.personalityIntensity ?? 0.7;
197
202
  const { replyProfile, replyProfileBasis } = deriveReplyProfile(kernel);
203
+ const classificationConfidence = opts?.classificationConfidence ?? 0;
204
+ const overrideWindow = classificationConfidence >= 0.78
205
+ ? "narrow"
206
+ : classificationConfidence >= 0.62
207
+ ? "balanced"
208
+ : "wide";
198
209
  const { maxSentences, maxChars } = userText.length > 0
199
210
  ? computeLengthBudget(locale, userText, replyProfile, kernel.expressionMode, kernel)
200
211
  : {
@@ -267,6 +278,7 @@ export function computeResponseContract(kernel, opts) {
267
278
  return {
268
279
  replyProfile,
269
280
  replyProfileBasis,
281
+ overrideWindow,
270
282
  maxSentences,
271
283
  maxChars,
272
284
  expressionMode: kernel.expressionMode,
@@ -283,40 +295,54 @@ function describeReplyProfileBasis(basis, locale) {
283
295
  if (locale === "zh") {
284
296
  switch (basis) {
285
297
  case "task-focus":
286
- return "因:聚焦";
298
+ return "因:聚";
287
299
  case "discipline":
288
- return "因:纪律";
300
+ return "因:纪";
289
301
  case "task-focus+discipline":
290
- return "因:聚焦+纪律";
302
+ return "因:聚+纪";
291
303
  default:
292
- return "因:默认私人";
304
+ return "因:私";
293
305
  }
294
306
  }
295
307
  return `basis:${basis}`;
296
308
  }
309
+ function describeOverrideWindow(overrideWindow, locale) {
310
+ if (locale === "zh") {
311
+ switch (overrideWindow) {
312
+ case "narrow":
313
+ return "终判窗:窄";
314
+ case "balanced":
315
+ return "终判窗:中";
316
+ default:
317
+ return "终判窗:宽";
318
+ }
319
+ }
320
+ return `override:${overrideWindow}`;
321
+ }
297
322
  export function buildResponseContractContext(contract, locale = "zh") {
298
323
  if (locale === "zh") {
299
324
  const parts = [];
300
- parts.push(contract.replyProfile === "work" ? "工作面" : "私人面");
325
+ parts.push(contract.replyProfile === "work" ? "工作" : "私人");
301
326
  parts.push(describeReplyProfileBasis(contract.replyProfileBasis, locale));
327
+ parts.push(describeOverrideWindow(contract.overrideWindow, locale));
302
328
  const shape = contract.maxChars
303
- ? `${contract.maxSentences === 1 ? "1句内" : `最多${contract.maxSentences}句`},≤${contract.maxChars}字`
304
- : `${contract.maxSentences === 1 ? "1句内" : `最多${contract.maxSentences}句`}`;
329
+ ? `${contract.maxSentences === 1 ? "1句内" : `${contract.maxSentences}句`}≤${contract.maxChars}字`
330
+ : `${contract.maxSentences === 1 ? "1句内" : `${contract.maxSentences}句`}`;
305
331
  parts.push(shape);
306
332
  if (contract.initiativeMode === "reactive")
307
333
  parts.push("少主动");
308
334
  else if (contract.initiativeMode === "proactive")
309
335
  parts.push("可主动");
310
336
  if (contract.boundaryMode === "confirm-first")
311
- parts.push("行动前先确认");
337
+ parts.push("先确认");
312
338
  else if (contract.boundaryMode === "guarded")
313
- parts.push("先守边界");
339
+ parts.push("守边界");
314
340
  if (contract.socialDistance === "withdrawn")
315
- parts.push("被推开就退开");
341
+ parts.push("退开");
316
342
  else if (contract.socialDistance === "warm")
317
- parts.push("可稍微靠近");
343
+ parts.push("可靠近");
318
344
  if (contract.authenticityMode === "strict")
319
- parts.push("不贴不舔,不装开心");
345
+ parts.push("不贴不舔");
320
346
  else
321
347
  parts.push("自然友好");
322
348
  if (contract.toneParticles === "match")
@@ -328,16 +354,19 @@ export function buildResponseContractContext(contract, locale = "zh") {
328
354
  if (contract.updateMode === "stimulus")
329
355
  parts.push(buildStimulusReportingGuide(locale));
330
356
  else if (contract.updateMode === "empathy")
331
- parts.push("对方谈感受时再报empathy");
357
+ parts.push("谈感受再报empathy");
332
358
  else if (contract.updateMode === "stimulus+empathy") {
333
359
  parts.push(buildStimulusReportingGuide(locale));
334
- parts.push("对方谈感受时再报empathy");
360
+ parts.push("谈感受再报empathy");
335
361
  }
362
+ if (contract.overrideWindow !== "narrow")
363
+ parts.push(buildWritebackGuide(locale));
336
364
  return `[回应契约] ${parts.join(";")}。`;
337
365
  }
338
366
  const parts = [];
339
367
  parts.push(contract.replyProfile === "work" ? "work surface" : "private surface");
340
368
  parts.push(describeReplyProfileBasis(contract.replyProfileBasis, locale));
369
+ parts.push(describeOverrideWindow(contract.overrideWindow, locale));
341
370
  const shape = contract.maxChars
342
371
  ? `${contract.maxSentences === 1 ? "1 sentence" : `up to ${contract.maxSentences} sentences`}, <= ${contract.maxChars} chars`
343
372
  : `${contract.maxSentences === 1 ? "1 sentence" : `up to ${contract.maxSentences} sentences`}`;
@@ -370,5 +399,7 @@ export function buildResponseContractContext(contract, locale = "zh") {
370
399
  parts.push(buildStimulusReportingGuide(locale));
371
400
  parts.push("report empathy only when feelings are shared");
372
401
  }
402
+ if (contract.overrideWindow !== "narrow")
403
+ parts.push(buildWritebackGuide(locale));
373
404
  return `[Reply Contract] ${parts.join(", ")}.`;
374
405
  }
package/dist/types.d.ts CHANGED
@@ -80,12 +80,27 @@ export interface AttachmentData {
80
80
  /** Default attachment for new relationships */
81
81
  export declare const DEFAULT_ATTACHMENT: AttachmentData;
82
82
  /** Relationship tracking */
83
+ export interface WritebackSignalWeightMap {
84
+ trust_up: number;
85
+ trust_down: number;
86
+ boundary_set: number;
87
+ boundary_soften: number;
88
+ repair_attempt: number;
89
+ repair_landed: number;
90
+ closeness_invite: number;
91
+ withdrawal_mark: number;
92
+ self_assertion: number;
93
+ task_recenter: number;
94
+ }
83
95
  export interface RelationshipState {
84
96
  trust: number;
85
97
  intimacy: number;
86
98
  phase: "stranger" | "acquaintance" | "familiar" | "close" | "deep";
87
99
  memory?: string[];
88
100
  attachment?: AttachmentData;
101
+ repairCredibility?: number;
102
+ breachSensitivity?: number;
103
+ signalWeights?: Partial<WritebackSignalWeightMap>;
89
104
  }
90
105
  /** Chemical state snapshot for emotional memory */
91
106
  export interface ChemicalSnapshot {
@@ -281,6 +296,10 @@ export interface PsycheState {
281
296
  dyadicFields?: Record<string, DyadicFieldState>;
282
297
  /** v9.6: delayed relation signals that can activate in later turns */
283
298
  pendingRelationSignals?: Record<string, PendingRelationSignalState[]>;
299
+ /** v9.2.7: sparse writeback signals waiting for convergence evaluation */
300
+ pendingWritebackCalibrations?: PendingWritebackCalibration[];
301
+ /** v9.2.7: latest writeback calibration outcome, for host-facing feedback */
302
+ lastWritebackFeedback?: WritebackCalibrationFeedback[];
284
303
  meta: {
285
304
  agentName: string;
286
305
  createdAt: string;
@@ -449,6 +468,17 @@ export interface RelationPlaneState {
449
468
  /** Most recent dominant relation action */
450
469
  lastMove: RelationMoveType;
451
470
  }
471
+ /** Minimal cold-start carry derived from persisted relational state. */
472
+ export interface SessionBridgeState {
473
+ closenessFloor: number;
474
+ safetyFloor: number;
475
+ guardFloor: number;
476
+ residueFloor: number;
477
+ continuityFloor: number;
478
+ continuityMode: "warm-resume" | "guarded-resume" | "tense-resume";
479
+ activeLoopTypes: OpenLoopType[];
480
+ sourceMemoryCount: number;
481
+ }
452
482
  /**
453
483
  * Compact, machine-readable subjective state for AI-first integrations.
454
484
  *
@@ -502,6 +532,8 @@ export interface ResponseContract {
502
532
  replyProfile: "work" | "private";
503
533
  /** Why the current turn was classified into that conversational surface */
504
534
  replyProfileBasis: "task-focus" | "discipline" | "task-focus+discipline" | "default-private";
535
+ /** How much freedom the model has to override the algorithmic stimulus read */
536
+ overrideWindow: "narrow" | "balanced" | "wide";
505
537
  /** Maximum suggested sentence count */
506
538
  maxSentences: number;
507
539
  /** Maximum suggested character count, when a concrete cap is available */
@@ -523,6 +555,38 @@ export interface ResponseContract {
523
555
  /** Which internal report, if any, should be requested in <psyche_update> */
524
556
  updateMode: "none" | "stimulus" | "empathy" | "stimulus+empathy";
525
557
  }
558
+ /** Sparse agent-authored writeback signals. */
559
+ export type WritebackSignalType = "trust_up" | "trust_down" | "boundary_set" | "boundary_soften" | "repair_attempt" | "repair_landed" | "closeness_invite" | "withdrawal_mark" | "self_assertion" | "task_recenter";
560
+ export type WritebackCalibrationMetric = "trust" | "closeness" | "safety" | "boundary" | "repair" | "silent-carry" | "task-focus";
561
+ export type WritebackCalibrationEffect = "converging" | "holding" | "diverging";
562
+ export interface WritebackCalibrationBaseline {
563
+ trust: number;
564
+ closeness: number;
565
+ safety: number;
566
+ boundary: number;
567
+ repair: number;
568
+ silentCarry: number;
569
+ taskFocus: number;
570
+ }
571
+ export interface PendingWritebackCalibration {
572
+ signal: WritebackSignalType;
573
+ userKey: string;
574
+ confidence: number;
575
+ metric: WritebackCalibrationMetric;
576
+ direction: "up" | "down";
577
+ baseline: WritebackCalibrationBaseline;
578
+ createdAt: string;
579
+ remainingTurns: number;
580
+ }
581
+ export interface WritebackCalibrationFeedback {
582
+ signal: WritebackSignalType;
583
+ effect: WritebackCalibrationEffect;
584
+ metric: WritebackCalibrationMetric;
585
+ baseline: number;
586
+ current: number;
587
+ delta: number;
588
+ confidence: number;
589
+ }
526
590
  /**
527
591
  * Mechanical generation controls derived from the emotional state.
528
592
  *
package/dist/types.js CHANGED
@@ -126,6 +126,9 @@ export const DEFAULT_RELATIONSHIP = {
126
126
  trust: 50,
127
127
  intimacy: 30,
128
128
  phase: "acquaintance",
129
+ repairCredibility: 0.56,
130
+ breachSensitivity: 0.5,
131
+ signalWeights: {},
129
132
  };
130
133
  export const DEFAULT_APPRAISAL_AXES = {
131
134
  identityThreat: 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "psyche-ai",
3
- "version": "9.2.6",
3
+ "version": "9.2.7",
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",