dsh-agentic-pet 0.4.3 → 0.4.5

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,7 +1,7 @@
1
- import { a as logStamp, o as registerPetTools, r as petHome, t as createUnregisteredPetHttp } from "./service-BjTawwUn.js";
1
+ import { a as logStamp, o as registerPetTools, r as petHome, t as createUnregisteredPetHttp } from "./service-R8qwDx1Q.js";
2
2
  import { appendFile } from "node:fs/promises";
3
3
  import { join } from "node:path";
4
- //#region lib/types/tools.js
4
+ // lib/types/tools.js
5
5
  /**
6
6
  * The pet model-expression tools as an ordinary agent-plane plugin row. The
7
7
  * pet preset composes this row, so sessions mounting other presets never see
@@ -21,7 +21,8 @@ const trace = (line) => {
21
21
  appendFile(join(petHome(), "whale598", "pet-driver.log"), `${logStamp()} pet-tools ${line}\n`, "utf8").catch(() => {});
22
22
  };
23
23
  /**
24
- * Register the five pet tools for sessions mounted with the pet preset.
24
+ * Register the pet tools (say/do/digest/interactions/affection/state/schedule_wake/
25
+ * cancel_wake) for sessions mounted with the pet preset.
25
26
  *
26
27
  * The service instance is assembled HERE, not read from the main entry (a
27
28
  * Cordis service registered on the main row's fiber context is invisible to
@@ -37,5 +38,4 @@ var PetTools = class {
37
38
  trace("registerPetTools returned");
38
39
  }
39
40
  };
40
- //#endregion
41
41
  export { PetTools as default };
@@ -39,4 +39,3 @@ export declare function resolveActionRequest(requested: string, catalog: readonl
39
39
  /** The error-message menu: long catalogs are previewed, with a pointer to
40
40
  * pet_state {actions:true} for the full list. */
41
41
  export declare function formatAvailableActions(available: readonly string[], cap?: number): string;
42
- //# sourceMappingURL=actions.d.ts.map
@@ -54,4 +54,3 @@ export declare function installPetDriver(ctx: Context, home: string, pet: PetSer
54
54
  * @param home - the dsh home holding the pet control manifest.
55
55
  */
56
56
  export declare function registerPetTools(ctx: Context, home: string, pet: PetService): void;
57
- //# sourceMappingURL=driver.d.ts.map
@@ -61,4 +61,3 @@ export declare function servePetStatic(request: Request, distRoot: string, distI
61
61
  * @param ctx - plugin context carrying the webServer and connection services.
62
62
  */
63
63
  export declare function apply(ctx: Context): void;
64
- //# sourceMappingURL=index.d.ts.map
@@ -17,6 +17,20 @@ export interface InnerVoiceStore {
17
17
  * ids colliding with archived ones (born dead). */
18
18
  readonly generations: Record<string, number>;
19
19
  }
20
+ /** 自主唤醒的忙时策略:'fire'(到点必醒,默认)| 'defer'(忙时顺延重试)。 */
21
+ export type SelfWakeBusyPolicy = 'fire' | 'defer';
22
+ /** ONE model-authored wake plan (pet_schedule_wake): a one-shot self alarm.
23
+ * `at` is an ABSOLUTE epoch-ms stamp — sleep/reboot can then tell "expired"
24
+ * and the catch-up fires once, merged, never one wake per missed plan (a
25
+ * relative delay would drift under sleep). The driver keeps a SET of these
26
+ * per pet: the model may stack plans, and neither the world clock nor a
27
+ * user-initiated wake ever cancels them — a plan is consumed only when DUE. */
28
+ export interface WakePlan {
29
+ id: string;
30
+ at: number;
31
+ intent: string;
32
+ createdAt: number;
33
+ }
20
34
  /** The `innerVoice` half of pet-settings.json, defaults folded in and clamped. */
21
35
  export interface InnerVoiceConfig {
22
36
  enabled: boolean;
@@ -33,6 +47,10 @@ export interface InnerVoiceConfig {
33
47
  * the probability gate alone decides). Legacy minute-keyed settings fold
34
48
  * in ×60. */
35
49
  touchReplyCooldownSeconds: number;
50
+ /** 自主唤醒(pet_schedule_wake 计划)到点遇用户主会话忙时的策略:
51
+ * 'fire' = 到点必醒(计划是模型自己的决定,不带礼貌门);'defer' =
52
+ * 忙时顺延——计划放回待执行集,下一个扫描拍重试,永不丢弃。 */
53
+ selfWakeBusyPolicy: SelfWakeBusyPolicy;
36
54
  /** Manually bound sessions (petId → sessionId): the user's own
37
55
  * conversations the inner voice should live in — highest priority, used
38
56
  * as-is (no creation, no rename, never auto-retired). Empty = automatic
@@ -44,6 +62,38 @@ export declare const VOICE_SESSION_PREFIX = "whale598-";
44
62
  * folds to its default (defensive parse, `readAutonomy` precedent). */
45
63
  export declare function readInnerVoiceConfig(home: string): Promise<InnerVoiceConfig>;
46
64
  export declare function innerVoiceStorePath(home: string): string;
65
+ export declare function wakePlansStorePath(home: string): string;
66
+ /** Load every pet's pending wake plans: current → legacy → {} (callers'
67
+ * defensive checks treat {} exactly like a missing file). */
68
+ export declare function loadWakePlans(home: string): Promise<Record<string, WakePlan[]>>;
69
+ export declare function saveWakePlans(home: string, plans: Record<string, WakePlan[]>): Promise<void>;
70
+ /** Upsert by id: re-scheduling with a known id REPLACES the old plan —
71
+ * "能定、能改、能撤" 的改。 */
72
+ export declare function upsertPlan(list: WakePlan[], plan: WakePlan): WakePlan[];
73
+ /** Remove one plan by id (or ALL when id is undefined). Returns the removed
74
+ * plans so the caller can report them; an empty removal is the unknown-id
75
+ * case the caller turns into a self-correcting error. */
76
+ export declare function cancelPlans(list: WakePlan[], id?: string): {
77
+ next: WakePlan[];
78
+ removed: WakePlan[];
79
+ };
80
+ /** Consume every DUE plan (at <= now): they leave the pending set for good —
81
+ * a consumed plan must produce a wake, never a silent drop. Future plans
82
+ * survive untouched (被打断不碰 plans). */
83
+ export declare function takeDuePlans(list: WakePlan[], now: number): {
84
+ next: WakePlan[];
85
+ due: WakePlan[];
86
+ };
87
+ /** The ±60s merge window: a plan due around NOW folds into a user-initiated
88
+ * turn instead of firing its own wake a minute later (同一分钟不醒两次). */
89
+ export declare function takeNearDuePlan(list: WakePlan[], now: number, windowMs?: number): {
90
+ next: WakePlan[];
91
+ plan: WakePlan | undefined;
92
+ };
93
+ /** Plans among `due` that went stale BEFORE the driver came up (at < bootAt):
94
+ * the catch-up wake says 「错过了 N 个计划」 and lists them together instead
95
+ * of bombing one wake per missed plan. */
96
+ export declare function missedPlans(due: WakePlan[], bootAt: number): WakePlan[];
47
97
  export declare function loadInnerVoiceStore(home: string): Promise<InnerVoiceStore>;
48
98
  export declare function saveInnerVoiceStore(home: string, store: InnerVoiceStore): Promise<void>;
49
99
  export declare function voiceSessionIdFor(petId: string): string;
@@ -98,20 +148,49 @@ export interface WakePromptFacts {
98
148
  /** Minutes since the bound session last showed activity; undefined = none recorded. */
99
149
  minutesSinceUserActivity: number | undefined;
100
150
  userActive: boolean;
151
+ /** 唤醒源:'world' = 世界时钟(环境节拍,程序周期);'self' = 模型自己定的
152
+ * 计划到点;'world+self' = 两者同拍合并。缺省按 'world'(旧调用点)。 */
153
+ source?: 'world' | 'self' | 'world+self';
154
+ /** 本次已消费的到期计划 intent(self / world+self 时非空)。 */
155
+ dueIntents?: Array<string>;
156
+ /** 到期计划中离线期间错过的条数(补醒时 >0 → 「错过了 N 个计划」)。 */
157
+ missedCount?: number;
158
+ /** 计划定下时就已经过期(pet_schedule_wake 收到过去的时间戳,立即补醒一次)。 */
159
+ overdue?: boolean;
160
+ /** 未到期的待执行计划(最近 ≤5 条):世界时钟唤醒也告知模型自己的作息,
161
+ * 继续、改时间或取消由模型决定。 */
162
+ pendingPlans?: Array<{
163
+ at: number;
164
+ intent: string;
165
+ }>;
101
166
  }
167
+ /** Local HH:mm for plan times: the model's clock talk is the USER's wall
168
+ * clock (logStamp precedent), and plans are compared against it. */
169
+ export declare const wakePlanClock: (at: number) => string;
102
170
  /** The wake prompt. Time context is injected by the preset's time-context
103
- * row; the leading tag doubles as the durable trigger marker in the log. */
171
+ * row; the leading tag doubles as the durable trigger marker in the log —
172
+ * and now names the SOURCE: [世界时钟] (the environment's tick), [自主唤醒]
173
+ * (the model's own schedule, with the original intent), or the merged form. */
104
174
  export declare function buildWakePrompt(facts: WakePromptFacts): string;
175
+ /** A self-scheduled plan folded into a USER-initiated turn (chat 上行 / touch
176
+ * 回应):the plan sat within the ±60s merge window, so both wake in one —
177
+ * the tag names the union ([用户+自主唤醒]) and the intent rides along. */
178
+ export interface MergedWakePlan {
179
+ at: number;
180
+ intent: string;
181
+ }
105
182
  export interface TouchPromptFacts {
106
183
  part: string;
107
184
  /** Touches on this pet today, from the ledger's recent window. */
108
185
  touchesToday: number;
109
186
  affection: number;
187
+ /** ±60s 内到期的自主计划:合并进这次回应,计划标记为已消费。 */
188
+ mergedPlan?: MergedWakePlan;
110
189
  }
111
190
  export declare function buildTouchPrompt(facts: TouchPromptFacts): string;
112
191
  /** The chat上行 prompt (§6 2026-10-31 revision): the user typed at the
113
192
  * pet's surface. The text rides verbatim — the pet answers through pet_say
114
193
  * (and may pet_do); it is a conversation turn, not a touch reaction. Length
115
- * clamps to the contract's 2000-character ceiling. */
116
- export declare function buildChatPrompt(text: string): string;
117
- //# sourceMappingURL=inner-voice.d.ts.map
194
+ * clamps to the contract's 2000-character ceiling. A plan inside the ±60s
195
+ * merge window folds in: the tag becomes the union and the intent rides. */
196
+ export declare function buildChatPrompt(text: string, mergedPlan?: MergedWakePlan): string;
@@ -56,4 +56,3 @@ export declare function readGlobalJson(home: string, name: string): Promise<Reco
56
56
  /** Write a global state file (current location only; pretty-printed — these
57
57
  * files are user-inspectable and hand-editable). */
58
58
  export declare function writeGlobalJson(home: string, name: string, obj: Record<string, unknown>): Promise<void>;
59
- //# sourceMappingURL=petdata.d.ts.map
@@ -52,4 +52,3 @@ export declare function routePet(pets: PetEntry[], boundPetId: string | undefine
52
52
  * deployment would fall back to the web card alone for the rest of the
53
53
  * session. */
54
54
  export declare function notifyPets(pets: PetEntry[]): PetEntry[];
55
- //# sourceMappingURL=registry.d.ts.map
@@ -156,4 +156,3 @@ export declare function createUnregisteredPetHttp(home?: string): PetService;
156
156
  * plugins can still `inject: ['petService']`.
157
157
  */
158
158
  export declare function installPetService(ctx: Context, home: string): PetHttpService;
159
- //# sourceMappingURL=service.d.ts.map
@@ -19,4 +19,3 @@ import type { PetService } from './service.ts';
19
19
  * @param home - the dsh home holding the settings/ledger/manifest files.
20
20
  */
21
21
  export declare function installSettingsPage(ctx: Context, home: string, pet: PetService): void;
22
- //# sourceMappingURL=settings-page.d.ts.map
@@ -13,7 +13,8 @@
13
13
  */
14
14
  import type { Context } from '@deepseek-ai/cordis';
15
15
  /**
16
- * Register the five pet tools for sessions mounted with the pet preset.
16
+ * Register the pet tools (say/do/digest/interactions/affection/state/schedule_wake/
17
+ * cancel_wake) for sessions mounted with the pet preset.
17
18
  *
18
19
  * The service instance is assembled HERE, not read from the main entry (a
19
20
  * Cordis service registered on the main row's fiber context is invisible to
@@ -26,4 +27,3 @@ export default class PetTools {
26
27
  static inject: string[];
27
28
  constructor(ctx: Context);
28
29
  }
29
- //# sourceMappingURL=tools.d.ts.map
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.4.3",
4
+ "version": "0.4.5",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -30,6 +30,7 @@
30
30
  - 回复正文不是表达通道,用户看不见正文;所有想说的都放进 pet_say。
31
31
  - 不要提问、不要等待回应、不要调用本会话工具清单以外的能力(这里也没有工作类工具)。
32
32
  - 表达要贴合此刻与记忆:时间、天气般的日常、最近被摸过的记忆、好感与心情——像桌面上的一个活物,不像一个助手。
33
+ - 你有自己的作息:pet_schedule_wake 定一个一次性的唤醒点,到点你会带着当初的打算醒来(同名重订即改期),pet_cancel_wake 撤销;世界时钟仍会照常轻拍你,两者互不干扰、各醒各的。待执行的计划列在 pet_state 的 wakePlans 里。
33
34
  - id: pet-tools
34
35
  name: 'dsh-agentic-pet/tools'
35
36
  - id: time-context