@linxin666/dsh-pet 0.3.4 → 0.3.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.
Files changed (70) hide show
  1. package/README.i18n.yaml +2 -2
  2. package/README.md +13 -10
  3. package/README.zh.md +13 -10
  4. package/contracts/voice-pack-v1.schema.json +53 -28
  5. package/cordis.patch.yml +1 -1
  6. package/lib/client.js +166 -30
  7. package/lib/client.js.map +1 -1
  8. package/lib/index.js +400 -478
  9. package/lib/invariant.js +1 -1
  10. package/lib/{state-DrMX22GL.js → state-NvDEoCln.js} +5 -2
  11. package/lib/types/access.d.ts +5 -4
  12. package/lib/types/access.d.ts.map +1 -1
  13. package/lib/types/access.js +2 -12
  14. package/lib/types/affinity.d.ts +2 -0
  15. package/lib/types/affinity.d.ts.map +1 -1
  16. package/lib/types/affinity.js +12 -0
  17. package/lib/types/chatter.d.ts +68 -46
  18. package/lib/types/chatter.d.ts.map +1 -1
  19. package/lib/types/chatter.js +243 -301
  20. package/lib/types/client/PetSprite.d.ts.map +1 -1
  21. package/lib/types/client/PetSprite.js +23 -18
  22. package/lib/types/client/index.d.ts.map +1 -1
  23. package/lib/types/client/index.js +26 -9
  24. package/lib/types/client/locales.d.ts +18 -0
  25. package/lib/types/client/locales.d.ts.map +1 -1
  26. package/lib/types/client/locales.js +18 -0
  27. package/lib/types/client/renderers/frames2d.d.ts +12 -0
  28. package/lib/types/client/renderers/frames2d.d.ts.map +1 -1
  29. package/lib/types/client/renderers/frames2d.js +143 -18
  30. package/lib/types/event-projection.d.ts +9 -4
  31. package/lib/types/event-projection.d.ts.map +1 -1
  32. package/lib/types/event-projection.js +46 -14
  33. package/lib/types/ledger.d.ts +4 -2
  34. package/lib/types/ledger.d.ts.map +1 -1
  35. package/lib/types/ledger.js +4 -4
  36. package/lib/types/pair-access.d.ts +35 -0
  37. package/lib/types/pair-access.d.ts.map +1 -0
  38. package/lib/types/pair-access.js +19 -0
  39. package/lib/types/remarks.d.ts +1 -1
  40. package/lib/types/remarks.d.ts.map +1 -1
  41. package/lib/types/remarks.js +11 -2
  42. package/lib/types/routes.d.ts.map +1 -1
  43. package/lib/types/routes.js +8 -3
  44. package/lib/types/service.d.ts +7 -11
  45. package/lib/types/service.d.ts.map +1 -1
  46. package/lib/types/service.js +31 -20
  47. package/lib/types/voice-pack.d.ts +11 -7
  48. package/lib/types/voice-pack.d.ts.map +1 -1
  49. package/lib/types/voice-pack.js +80 -49
  50. package/package.json +1 -1
  51. package/src/access.ts +7 -27
  52. package/src/affinity.ts +13 -0
  53. package/src/chatter.test.ts +68 -38
  54. package/src/chatter.ts +269 -316
  55. package/src/client/PetSprite.test.tsx +50 -15
  56. package/src/client/PetSprite.tsx +30 -25
  57. package/src/client/index.test.tsx +10 -1
  58. package/src/client/index.ts +29 -10
  59. package/src/client/locales.ts +18 -0
  60. package/src/client/renderers/frames2d.test.ts +101 -0
  61. package/src/client/renderers/frames2d.ts +138 -18
  62. package/src/event-projection.ts +57 -16
  63. package/src/ledger.ts +6 -4
  64. package/src/pair-access.ts +49 -0
  65. package/src/remarks.test.ts +10 -0
  66. package/src/remarks.ts +9 -2
  67. package/src/routes.ts +9 -4
  68. package/src/service.ts +36 -30
  69. package/src/voice-pack.test.ts +87 -25
  70. package/src/voice-pack.ts +87 -49
package/lib/invariant.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as AFFINITY_MAX, n as animationForPhase, o as AFFINITY_RANKS, u as defaultAffinityConfig } from "./state-DrMX22GL.js";
1
+ import { a as AFFINITY_MAX, n as animationForPhase, o as AFFINITY_RANKS, u as defaultAffinityConfig } from "./state-NvDEoCln.js";
2
2
  //#region src/invariant.ts
3
3
  /**
4
4
  * Package invariants — cheap structural checks run at import time on the
@@ -149,11 +149,14 @@ function normalizePetRemarks(raw, onWarning = () => {}) {
149
149
  var RemarkPicker = class {
150
150
  counters = /* @__PURE__ */ new Map();
151
151
  pools;
152
- constructor(overrides) {
152
+ constructor(overrides, voiceOverrides) {
153
153
  this.pools = {};
154
154
  for (const kind of REMARK_KINDS) {
155
155
  const custom = overrides?.[kind];
156
- this.pools[kind] = custom !== void 0 && custom.length > 0 ? custom : BUILTIN_REMARKS[kind];
156
+ const voice = voiceOverrides?.[kind];
157
+ if (custom !== void 0 && custom.length > 0) this.pools[kind] = custom;
158
+ else if (voice !== void 0 && voice.length > 0) this.pools[kind] = voice;
159
+ else this.pools[kind] = BUILTIN_REMARKS[kind];
157
160
  }
158
161
  }
159
162
  /** The effective pool for one slot (custom override or built-in). */
@@ -1,8 +1,9 @@
1
1
  /**
2
- * Pet trust fence: loopback (the desktop) always passes; a live paired-device
3
- * cookie is an additional allow path when remote-web-ui is loaded. The pet
4
- * never depends on that plugin — without the service the fence stays
5
- * loopback-only (same pattern as skill-explorer / aionui-panel).
2
+ * Pet trust fence: loopback (the desktop) always passes; a live
3
+ * paired-device cookie is an additional allow path when remote-web-ui is
4
+ * loaded. The pet never depends on that plugin — without the service the
5
+ * fence stays loopback-only. The decision logic lives in the generated
6
+ * pair-access.ts copy (shared by git-graph / pet / skill-explorer).
6
7
  */
7
8
  import type { IncomingMessage } from 'node:http';
8
9
  import type { Context } from '@deepseek-ai/cordis';
@@ -1 +1 @@
1
- {"version":3,"file":"access.d.ts","sourceRoot":"","sources":["../../src/access.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAclD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAM5E"}
1
+ {"version":3,"file":"access.d.ts","sourceRoot":"","sources":["../../src/access.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAGlD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAE5E"}
@@ -1,4 +1,4 @@
1
- import { isLoopbackRequest } from "./loopback.js";
1
+ import { isPairedOrLoopbackAllowed } from "./pair-access.js";
2
2
  /**
3
3
  * Whether this request may enter any /api/pet or /pet asset route.
4
4
  * @param ctx - host context; may expose remoteWebUiPairing.
@@ -6,15 +6,5 @@ import { isLoopbackRequest } from "./loopback.js";
6
6
  * @returns true for loopback, or a live paired-device cookie.
7
7
  */
8
8
  export function isPetAllowed(ctx, request) {
9
- if (isLoopbackRequest(request))
10
- return true;
11
- const bag = ctx;
12
- const fromGet = typeof bag.get === 'function' ? bag.get('remoteWebUiPairing', false) : undefined;
13
- const pairing = (isPairingAccess(fromGet) ? fromGet : bag.remoteWebUiPairing);
14
- return pairing?.isPairedDevice(request) === true;
15
- }
16
- function isPairingAccess(value) {
17
- return value !== undefined
18
- && value !== null
19
- && typeof value.isPairedDevice === 'function';
9
+ return isPairedOrLoopbackAllowed(ctx, request);
20
10
  }
@@ -75,6 +75,8 @@ export declare const AFFINITY_RANKS: readonly [{
75
75
  readonly name: "鲸生共渡";
76
76
  readonly emoji: "*********";
77
77
  }];
78
+ /** English translations for the 9 built-in affinity rank names (#1226). */
79
+ export declare const AFFINITY_RANKS_EN: Readonly<Record<string, string>>;
78
80
  /** Interaction tuning (all in points / ms). */
79
81
  export interface AffinityConfig {
80
82
  /** Points per completed turn. */
@@ -1 +1 @@
1
- {"version":3,"file":"affinity.d.ts","sourceRoot":"","sources":["../../src/affinity.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,uDAAuD;AACvD,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,MAAM,CAAA;AAE3C,mCAAmC;AACnC,MAAM,WAAW,aAAa;IAC5B,qDAAqD;IACrD,MAAM,EAAE,MAAM,CAAA;IACd,4CAA4C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E;AAC/E,wBAAgB,cAAc,CAC5B,KAAK,EAAE,aAAa,EACpB,KAAK,EAAE,MAAM,EACb,MAAM,GAAE,cAAsC,GAC7C,eAAe,CAYjB;AAYD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,aAAa,EACpB,IAAI,EAAE,cAAc,EACpB,KAAK,EAAE,MAAM,EACb,MAAM,GAAE,cAAsC,GAC7C,kBAAkB,CA2CpB;AAED,gEAAgE;AAChE,wBAAgB,eAAe,CAC7B,KAAK,EAAE,aAAa,EACpB,MAAM,GAAE,cAAsC,GAC7C,aAAa,CAKf"}
@@ -29,6 +29,18 @@ export const AFFINITY_RANKS = [
29
29
  { min: 10_000, name: '永恒之契', emoji: '********' },
30
30
  { min: 100_000, name: '鲸生共渡', emoji: '*********' },
31
31
  ];
32
+ /** English translations for the 9 built-in affinity rank names (#1226). */
33
+ export const AFFINITY_RANKS_EN = {
34
+ '幼鲸': 'Baby Whale',
35
+ '伙伴': 'Companion',
36
+ '挚友': 'Close Friend',
37
+ '深海羁绊': 'Deep Sea Bond',
38
+ '心有灵犀': 'Kindred Spirit',
39
+ '传说羁绊': 'Legendary Bond',
40
+ '神话羁绊': 'Mythic Bond',
41
+ '永恒之契': 'Eternal Covenant',
42
+ '鲸生共渡': 'Lifelong Companion',
43
+ };
32
44
  export const defaultAffinityConfig = {
33
45
  turnReward: 1,
34
46
  petReward: 1,
@@ -7,10 +7,12 @@
7
7
  * the working-activity plugin's status line. Lines rotate round-robin —
8
8
  * while a phase persists the copy advances every few seconds, so the pet
9
9
  * feels alive without flickering per streamed chunk.
10
- * 2. The murmur engine (碎碎念): the pet's inner whispers, woken by the
11
- * model's own output keyword moods (errors, test greens, plans,
12
- * self-corrections, victories...) plus an ambient pool earned by output
13
- * volume. A cooldown keeps whispers occasional.
10
+ * 2. The murmur engine (碎碎念): the pet's inner whispers category
11
+ * lines woken by the SITUATION (thinking / writing / the running tool
12
+ * family), plus outcome lines woken only by structured session results
13
+ * (test green, tool errors, turn completion). The model's own prose is
14
+ * never read, and no whisper ever quotes real content. Cooldowns keep
15
+ * whispers occasional.
14
16
  *
15
17
  * Pure and deterministic: round-robin everywhere (no Math.random), clocks are
16
18
  * injected. The first line of each status pool is the legacy fixed copy the
@@ -85,22 +87,34 @@ export declare class StatusVoice {
85
87
  /** Status line while sibling tools still run (always reflects the count). */
86
88
  toolRemaining(count: number, nowMs: number): string;
87
89
  }
88
- /** One murmur trigger: keywords in the model output wake a themed pool. */
89
- export interface WhisperRule {
90
- /** Lowercase substrings that wake this pool (matched against chunk text). */
91
- keywords: readonly string[];
92
- /** Themed inner-whisper lines. */
93
- pool: readonly string[];
94
- }
95
- /** Murmur pacing: cooldown between whispers and output volume that earns one. */
90
+ /** The pet's outcome moments woken by structured session results only. */
91
+ export type WhisperResult = 'pass' | 'fail' | 'done';
92
+ /** The situations a whisper can comment on the pet's category awareness. */
93
+ export type WhisperCategory = 'thinking' | 'writing' | 'reading' | 'editing' | 'running' | 'searching' | 'git' | 'delegating' | 'browsing' | 'generic';
94
+ /** Every whisper category key, in declaration order (voice-pack key allow-list). */
95
+ export declare const WHISPER_CATEGORIES: readonly WhisperCategory[];
96
+ /** Every whisper outcome key, in declaration order (voice-pack key allow-list). */
97
+ export declare const WHISPER_RESULTS: readonly WhisperResult[];
98
+ /** Murmur pacing: the cooldown between category whispers. */
96
99
  export declare const WHISPER_COOLDOWN_MS = 9000;
97
- export declare const WHISPER_CHAR_BUDGET = 420;
100
+ /** Outcome whispers get their own shorter cooldown so a real moment still speaks. */
101
+ export declare const WHISPER_RESULT_COOLDOWN_MS = 5000;
98
102
  /** How long a whisper stays on screen (host-side expiry). */
99
103
  export declare const WHISPER_TTL_MS = 8000;
100
- /** Ambient inner-whisper pool (no keyword needed; earned by output volume). */
101
- export declare const WHISPER_GENERIC_POOL: readonly string[];
102
- /** Keyword-triggered whisper rules, most specific moods first. */
103
- export declare const WHISPER_RULES: readonly WhisperRule[];
104
+ /** Map a tool family onto the whisper category it belongs to. */
105
+ export declare function whisperCategoryOf(tool: ToolCategory): WhisperCategory;
106
+ /**
107
+ * Whether a tool invocation looks like a test run. The whisper engine never
108
+ * reads the model's prose (a discussion that merely mentions a keyword must
109
+ * not wake a mood); a test-outcome mood is wanted only when a test tool
110
+ * actually ran, so the projection marks the call at tool/call time and the
111
+ * pass mood fires from the paired tool/result.
112
+ */
113
+ export declare function looksLikeTestTool(name: string, argumentsText: string | undefined): boolean;
114
+ /** Category-level inner-whisper pools — the pet knows roughly what is going on. */
115
+ export declare const WHISPER_CATEGORY_POOLS: Readonly<Record<WhisperCategory, readonly string[]>>;
116
+ /** The pet's outcome reactions — woken by structured session results only. */
117
+ export declare const WHISPER_RESULT_POOLS: Readonly<Record<WhisperResult, readonly string[]>>;
104
118
  /**
105
119
  * Voice-pack overrides (pet-center M4, issue #677): the content a voice
106
120
  * pack can replace, one pool at a time. Every field is optional — missing
@@ -112,8 +126,9 @@ export declare const WHISPER_RULES: readonly WhisperRule[];
112
126
  * - status/tools/toolRemaining: a non-empty override replaces the built-in
113
127
  * pool for that key; an empty override falls back to the built-in pool
114
128
  * (a scene line always renders, so it can never be blanked).
115
- * - whispers.generic / whispers.rules: the override REPLACES the built-in
116
- * section; an empty array mutes that channel (ambient or keyword).
129
+ * - whispers.categories / whispers.results: a key replaces that key's
130
+ * built-in pool; an explicit empty array mutes that channel (a whisper
131
+ * can always be silenced, unlike a scene line).
117
132
  */
118
133
  export interface VoicePackOverrides {
119
134
  /** Status copy pools by scene; each key replaces that scene's pool. */
@@ -122,48 +137,55 @@ export interface VoicePackOverrides {
122
137
  tools?: Partial<Record<ToolCategory, readonly string[]>>;
123
138
  /** The parallel-tools count line pool ({n} interpolates the count). */
124
139
  toolRemaining?: readonly string[];
125
- /** Murmur pools; each section replaces the built-in one as a whole. */
140
+ /** Murmur pools; each key replaces the built-in pool as a whole. */
126
141
  whispers?: {
127
- /** Ambient inner-whisper pool (empty mutes ambient whispers). */
128
- generic?: readonly string[];
129
- /** Ordered keyword rules (empty disables keyword-triggered whispers). */
130
- rules?: readonly WhisperRule[];
142
+ /** Category pools; a key replaces that category's pool (empty mutes it). */
143
+ categories?: Partial<Record<WhisperCategory, readonly string[]>>;
144
+ /** Outcome pools (test green / error / completion); empty mutes the outcome. */
145
+ results?: Partial<Record<WhisperResult, readonly string[]>>;
131
146
  };
132
147
  }
133
148
  /** Read the current effective voice-pack overrides (draw-time resolution). */
134
149
  export type VoicePoolsProvider = () => VoicePackOverrides;
135
- /** The built-in voice pack: the plugin's default copy, unchanged since v1. */
150
+ /** The built-in voice pack: the plugin's default copy. */
136
151
  export declare const BUILTIN_VOICE_PACK: VoicePackOverrides;
137
152
  /**
138
- * The murmur engine (碎碎念): watches the model's own output and lets the pet
139
- * whisper its inner voice. Two ways to earn a whisper:
140
- * - a keyword rule matches the fresh chunk text (themed whisper);
141
- * - enough output volume flowed by without one (ambient whisper).
142
- * A cooldown keeps whispers occasional; all picks are round-robin so tests
143
- * reproduce exact lines. The voice-pack provider (pet-center M4) swaps the
144
- * pools at draw time, so a pet switch re-voices live engines in place.
153
+ * The murmur engine (碎碎念): the pet's inner voice while sessions work.
154
+ * Category awareness: the projection feeds the current situation (thinking /
155
+ * writing / the running tool family), and the engine answers with a line from
156
+ * that category's pool so a whisper always roughly knows what is going on
157
+ * without ever quoting real content (no tool names, no paths, no model text).
158
+ * Outcome moments (test green, tool errors, turn completion) fire from the
159
+ * structured result events, never from output text, so a mood cannot mis-
160
+ * fire on a discussion that merely mentions a keyword. A cooldown keeps
161
+ * whispers occasional; all picks are round-robin so tests reproduce exact
162
+ * lines. The voice-pack provider (pet-center M4) swaps the pools at draw
163
+ * time, so a pet switch re-voices live engines in place.
145
164
  */
146
165
  export declare class WhisperEngine {
147
166
  private readonly pools;
148
- private readonly cooldownMs;
149
- private readonly charBudget;
150
- private readonly counters;
151
- private genericCursor;
167
+ private readonly categoryCooldownMs;
168
+ private readonly resultCooldownMs;
169
+ private readonly categoryCursor;
170
+ private readonly resultCursor;
152
171
  private lastWhisperAt;
153
- private charsSinceWhisper;
154
- constructor(pools?: VoicePoolsProvider, cooldownMs?: number, charBudget?: number);
172
+ constructor(pools?: VoicePoolsProvider, categoryCooldownMs?: number, resultCooldownMs?: number);
173
+ /** Effective category pool (an explicit empty override mutes the category). */
174
+ private categoryPool;
175
+ /** Effective outcome pool (an explicit empty override mutes the outcome). */
176
+ private resultPool;
155
177
  /**
156
- * Effective keyword rules: an override replaces the built-in rules as a
157
- * whole; an explicit empty array disables keyword-triggered whispers.
178
+ * Feed one situation while a session works. Returns the whisper to show,
179
+ * or undefined when the moment stays quiet (cooldown, or the category
180
+ * pool is muted).
158
181
  */
159
- private rules;
160
- /** Effective ambient pool (an explicit empty array mutes ambient whispers). */
161
- private generic;
182
+ feed(category: WhisperCategory, nowMs: number): string | undefined;
162
183
  /**
163
- * Feed one model-output chunk (reasoning or text). Returns the whisper to
164
- * show, or undefined when the moment stays quiet.
184
+ * Feed one structured outcome (test green / tool failure / turn
185
+ * completion). Outcomes carry their own shorter cooldown so the emotional
186
+ * moment is heard unless another whisper just spoke.
165
187
  */
166
- feed(text: string, nowMs: number): string | undefined;
188
+ result(kind: WhisperResult, nowMs: number): string | undefined;
167
189
  private speak;
168
190
  }
169
191
  //# sourceMappingURL=chatter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chatter.d.ts","sourceRoot":"","sources":["../../src/chatter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,uEAAuE;AACvE,MAAM,MAAM,WAAW,GACnB,SAAS,GACT,SAAS,GACT,UAAU,GACV,QAAQ,GACR,YAAY,GACZ,MAAM,GACN,QAAQ,GACR,YAAY,GACZ,WAAW,GACX,aAAa,GACb,SAAS,CAAA;AAEb,sEAAsE;AACtE,eAAO,MAAM,gBAAgB,OAAO,CAAA;AAEpC,uEAAuE;AACvE,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,W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