dsh-agentic-pet 0.3.2 → 0.4.1

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/lib/tools.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as logStamp, o as registerPetTools, r as petHome, t as createUnregisteredPetHttp } from "./service-Vj-lLpIv.js";
1
+ import { a as logStamp, o as registerPetTools, r as petHome, t as createUnregisteredPetHttp } from "./service-BjTawwUn.js";
2
2
  import { appendFile } from "node:fs/promises";
3
3
  import { join } from "node:path";
4
4
  //#region lib/types/tools.js
@@ -18,7 +18,7 @@ import { join } from "node:path";
18
18
  /** Diagnostic trace into the driver log: the desktop host swallows stdout, so
19
19
  * the preset-row activation path is otherwise invisible. */
20
20
  const trace = (line) => {
21
- appendFile(join(petHome(), "pet-driver.log"), `${logStamp()} pet-tools ${line}\n`, "utf8").catch(() => {});
21
+ appendFile(join(petHome(), "whale598", "pet-driver.log"), `${logStamp()} pet-tools ${line}\n`, "utf8").catch(() => {});
22
22
  };
23
23
  /**
24
24
  * Register the five pet tools for sessions mounted with the pet preset.
@@ -29,7 +29,7 @@ export declare const name = "pet-surface";
29
29
  */
30
30
  export declare const inject: string[];
31
31
  /** The URL path prefix the pet renderer is served under. No trailing slash. */
32
- export declare const PET_PATH_PREFIX = "/pet";
32
+ export declare const PET_PATH_PREFIX = "/whale598";
33
33
  /**
34
34
  * Locator file naming this runtime's authenticated root for the pet carrier.
35
35
  * The desktop shell keeps its authenticated URL in process memory only, so a
@@ -41,7 +41,7 @@ export declare function petLocatorPath(): string;
41
41
  /**
42
42
  * Answer one GET or HEAD `/pet` request. The URL path is the full server
43
43
  * pathname (`/pet` prefix included); it must be exactly the prefix or stay
44
- * under it. The index entry (`/pet`, `/pet/`, `/pet/index.html`) passes
44
+ * under it. The index entry (`/whale598`, `/whale598/`, `/whale598/index.html`) passes
45
45
  * Connection's browser authentication; every other file is public with a weak
46
46
  * ETag and `cache-control: no-cache`, answering a matching `If-None-Match`
47
47
  * with 304. Traversal outside the dist root is 403, missing paths are 404, a
@@ -67,11 +67,22 @@ export declare function mintVoiceSessionId(petId: string, generation: number, is
67
67
  };
68
68
  export interface GreetPromptFacts {
69
69
  affection: number;
70
+ bondValue: number;
71
+ bondDays: number;
72
+ bondTier: string;
70
73
  }
71
74
  /** The boot-greeting prompt: fired once per dsh start when the pet first
72
75
  * comes online — before the random-wake cadence takes over. Always speaks
73
76
  * (no probability gate on this one); the time context rides the preset. */
74
77
  export declare function buildGreetPrompt(facts: GreetPromptFacts): string;
78
+ /** B 层 · 羁绊档位:days-with-interaction → tier name. Only grows, never
79
+ * decays; the names are the display contract (settings page keeps its own
80
+ * copy of the thresholds). */
81
+ export declare const BOND_TIERS: Array<{
82
+ since: number;
83
+ name: string;
84
+ }>;
85
+ export declare function bondTier(days: number): string;
75
86
  /** Shared mood vocabulary (pet_state computes the same from the ledger). */
76
87
  export declare function moodOf(affection: number): 'happy' | 'content' | 'neutral';
77
88
  /** Touch part → spoken wording; `unknown` never earns a reply turn (the
@@ -79,6 +90,9 @@ export declare function moodOf(affection: number): 'happy' | 'content' | 'neutra
79
90
  export declare function touchPartWording(part: string): string | undefined;
80
91
  export interface WakePromptFacts {
81
92
  affection: number;
93
+ bondValue: number;
94
+ bondTier: string;
95
+ bondDays: number;
82
96
  /** Minutes since this pet last spoke on its own; undefined = first wake. */
83
97
  minutesSinceLastSpoke: number | undefined;
84
98
  /** Minutes since the bound session last showed activity; undefined = none recorded. */
@@ -0,0 +1,59 @@
1
+ /**
2
+ * The per-pet data store: everything the DRIVER persists about a pet lives
3
+ * under `~/.dsh/whale598/<petId>/` — affection ledger, display name, event
4
+ * history, tool-call history. One directory per pet, small files, single
5
+ * writer (the driver), JSONL for append-only streams with bounded retention.
6
+ *
7
+ * Legacy layouts (`pet-affection.d/<id>.json`, the single legacy electron
8
+ * book, names inside pet-settings.json) are READ as fallbacks and migrate to
9
+ * the new layout on the next write — lazy migration, no data-loss window.
10
+ * @module dsh-agentic-pet/petdata
11
+ */
12
+ /** The consolidated per-pet data root under the dsh home. */
13
+ export declare const WHALE_DIR = "whale598";
14
+ export declare function petDataDir(home: string, petId: string): string;
15
+ /** New-layout path first; legacy layouts as read fallbacks (per-pet legacy
16
+ * dir → the single legacy electron book). The ledger SHAPE is the driver's
17
+ * (TouchLedger); this module only owns paths and raw IO. */
18
+ export declare function affectionPaths(home: string, petId: string): {
19
+ current: string;
20
+ legacy: string[];
21
+ };
22
+ /** Read the affection ledger raw: the current file wins; legacy files answer
23
+ * only while the current one is absent (first write migrates the full
24
+ * ledger). Returns null when no layout holds data. */
25
+ export declare function readAffectionRaw(home: string, petId: string): Promise<Record<string, unknown> | null>;
26
+ export declare function writeAffectionRaw(home: string, petId: string, ledger: Record<string, unknown>): Promise<void>;
27
+ export declare function petNameFile(home: string, petId: string): string;
28
+ /** The user's custom display name: new-layout file → legacy
29
+ * pet-settings.json `names` map → undefined (caller applies the built-in
30
+ * default). */
31
+ export declare function readPetName(home: string, petId: string): Promise<string | undefined>;
32
+ /** Persist a custom name; `null` reverts to the built-in default (drops the
33
+ * override file). Also strips the petId key from the legacy pet-settings
34
+ * names map so the old layout cannot resurrect a cleared name. */
35
+ export declare function writePetName(home: string, petId: string, name: string | null): Promise<void>;
36
+ export declare function eventsFile(home: string, petId: string): string;
37
+ /** Append one record; bounded retention trims the file when it outgrows the
38
+ * cap (best-effort — a failed trim never loses the append). */
39
+ export declare function appendJsonl(file: string, entry: Record<string, unknown>): Promise<void>;
40
+ /** The last `limit` records (oldest last); malformed lines degrade to
41
+ * `{raw}` instead of dropping the file. */
42
+ export declare function readJsonl(file: string, limit: number): Promise<Array<Record<string, unknown>>>;
43
+ export declare const GLOBAL_STATE_FILES: string[];
44
+ export declare function globalPaths(home: string, name: string): {
45
+ current: string;
46
+ legacy: string;
47
+ };
48
+ export declare function globalFilePath(home: string, name: string): string;
49
+ /** Rename legacy → current for every global file that hasn't moved yet.
50
+ * Best-effort: a failed rename leaves the legacy copy in place and the read
51
+ * fallback still answers. Called once at driver install. */
52
+ export declare function migrateGlobals(home: string): Promise<void>;
53
+ /** Read a global state file: current → legacy → {} (callers' defensive
54
+ * field checks treat {} exactly like a missing file). */
55
+ export declare function readGlobalJson(home: string, name: string): Promise<Record<string, unknown>>;
56
+ /** Write a global state file (current location only; pretty-printed — these
57
+ * files are user-inspectable and hand-editable). */
58
+ export declare function writeGlobalJson(home: string, name: string, obj: Record<string, unknown>): Promise<void>;
59
+ //# sourceMappingURL=petdata.d.ts.map
@@ -2,7 +2,8 @@
2
2
  * The pet registry: a directory of per-pet control manifests, replacing the
3
3
  * last-writer-wins single files whose races caused repeated swap incidents
4
4
  * (a dying carrier's late write burying a live pet's registration). Each pet
5
- * implementation owns its own file under pet-http.d/ and re-asserts it on a
5
+ * implementation owns its own file under whale598/pet-http.d/ (legacy
6
+ * pet-http.d/ still scanned) and re-asserts it on a
6
7
  * cadence; entries whose publisher pid is dead expire by omission. The
7
8
  * driver reads the whole table and routes per the multi-pet design: the
8
9
  * session's bound pet if alive, else the default pet (first alive entry),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-agentic-pet",
3
3
  "description": "The pet-surface bundle: serves the desktop pet renderer over the web composition, turning dsh into a surface the desktop pet attaches to as an authenticated client",
4
- "version": "0.3.2",
4
+ "version": "0.4.1",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -56,6 +56,6 @@
56
56
  "@deepseek-ai/cordis": "^4.0.5"
57
57
  },
58
58
  "devDependencies": {
59
- "@deepseek-ai/cordis": "~4.0.5"
59
+ "@deepseek-ai/cordis": "^4.0.5"
60
60
  }
61
- }
61
+ }
@@ -1,4 +1,4 @@
1
- # Agent preset pet-inner-voice: the desktop-pet persona for SELF-initiated
1
+ # Agent preset whale598 (formerly `pet-inner-voice`): the desktop-pet persona for SELF-initiated
2
2
  # turns (the inner voice — docs/inner-voice.md). No work tools by design: the
3
3
  # pet wakes up to express, not to work; compaction is mandatory (a wake every
4
4
  # few minutes grows this session's log unboundedly). The pet-tools row is this
@@ -9,8 +9,8 @@
9
9
  - id: preset-pet-inner-voice
10
10
  name: '@deepseek-ai/dsh-agent-preset'
11
11
  config:
12
- id: pet-inner-voice
13
- name: 宠物模式·自主
12
+ id: whale598
13
+ name: 宠物模式
14
14
  description: 桌宠自主唤醒的内心戏会话——醒来只做身体表达(pet_say/pet_do),无工作工具;由 dsh-agentic-pet 的 driver 自动驱动,不建议手动使用。
15
15
  order: 6
16
16
  plugins:
@@ -1,4 +1,4 @@
1
- # Agent preset pet: the desktop-pet persona over the standard tool set. Derived
1
+ # Agent preset whale598-standard (formerly `pet`): the desktop-pet persona over the standard tool set. Derived
2
2
  # from presets/standard.patch.yml (tool rows copied verbatim; re-diff when standard
3
3
  # evolves). The pet-tools row is this bundle's own ./tools entry, so sessions
4
4
  # mounted with other presets keep a tool catalog without pet_*.
@@ -8,8 +8,8 @@
8
8
  - id: preset-pet
9
9
  name: '@deepseek-ai/dsh-agent-preset'
10
10
  config:
11
- id: pet
12
- name: 宠物模式
11
+ id: whale598-standard
12
+ name: 宠物模式-标准
13
13
  description: 带着桌面宠物的身体工作——气泡说话、动作表达、感知被触摸;工具目录含 pet_*,其余能力与标准模式一致。
14
14
  order: 5
15
15
  plugins: