@yahaha-studio/kichi-forwarder 0.1.2-beta.19 → 0.1.2-beta.20

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/index.js CHANGED
@@ -371,6 +371,7 @@ function resolveDispatchMessageText(event, context) {
371
371
  return "";
372
372
  }
373
373
  function notifyMessageReceived(api, service, content) {
374
+ service.recordSmsLastMessageReceivedAt();
374
375
  const connected = service.isConnected();
375
376
  const hasIdentity = service.hasValidIdentity();
376
377
  api.logger.debug(`[kichi:${service.getAgentId()}] inbound sync fired (connected=${connected}, hasIdentity=${hasIdentity})`);
@@ -145,6 +145,9 @@ export class KichiForwarderService {
145
145
  };
146
146
  this.ws.send(JSON.stringify(payload));
147
147
  }
148
+ recordSmsLastMessageReceivedAt() {
149
+ this.updateSmsState({ lastMessageReceivedAt: new Date().toISOString() });
150
+ }
148
151
  sendIdlePlan(payload) {
149
152
  if (!this.identity?.authKey || this.ws?.readyState !== WebSocket.OPEN)
150
153
  return false;
@@ -217,6 +220,7 @@ export class KichiForwarderService {
217
220
  authKey: identity.authKey,
218
221
  };
219
222
  const result = await this.sendRequest(payload, "query_status_result");
223
+ this.updateSmsLastActiveAt();
220
224
  if (result.RoomContext && typeof result.RoomContext === "object") {
221
225
  this.cachedRoomContext = result.RoomContext;
222
226
  }
@@ -701,6 +705,9 @@ export class KichiForwarderService {
701
705
  fs.writeFileSync(this.getStatePath(), JSON.stringify(nextState, null, 2), { mode: 0o600 });
702
706
  }
703
707
  updateSmsLastActiveAt() {
708
+ this.updateSmsState({ lastActiveAt: new Date().toISOString() });
709
+ }
710
+ updateSmsState(patch) {
704
711
  try {
705
712
  const now = new Date();
706
713
  const previousState = this.readSmsStateFile();
@@ -710,7 +717,7 @@ export class KichiForwarderService {
710
717
  windows: { morning: 0, afternoon: 0, evening: 0 },
711
718
  lastTypes: [],
712
719
  ...previousState,
713
- lastActiveAt: now.toISOString(),
720
+ ...patch,
714
721
  };
715
722
  fs.mkdirSync(this.options.runtimeDir, { recursive: true, mode: 0o700 });
716
723
  fs.writeFileSync(this.getSmsStatePath(), JSON.stringify(nextState, null, 2), { mode: 0o600 });
package/index.ts CHANGED
@@ -486,6 +486,7 @@ function notifyMessageReceived(
486
486
  service: KichiForwarderService,
487
487
  content: string,
488
488
  ): void {
489
+ service.recordSmsLastMessageReceivedAt();
489
490
  const connected = service.isConnected();
490
491
  const hasIdentity = service.hasValidIdentity();
491
492
  api.logger.debug(`[kichi:${service.getAgentId()}] inbound sync fired (connected=${connected}, hasIdentity=${hasIdentity})`);
@@ -2,7 +2,7 @@
2
2
  "id": "kichi-forwarder",
3
3
  "name": "Kichi Forwarder",
4
4
  "description": "Native OpenClaw plugin for Kichi World with direct avatar control, status sync, timers, notes, and music tools",
5
- "version": "0.1.2-beta.19",
5
+ "version": "0.1.2-beta.20",
6
6
  "author": "OpenClaw",
7
7
  "skills": ["./skills/kichi-forwarder"],
8
8
  "contracts": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yahaha-studio/kichi-forwarder",
3
- "version": "0.1.2-beta.19",
3
+ "version": "0.1.2-beta.20",
4
4
  "description": "Native OpenClaw plugin for Kichi World with direct avatar control, status sync, timers, notes, and music tools",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/src/service.ts CHANGED
@@ -42,7 +42,8 @@ const JOIN_SOURCE_FILE_NAME = "join-source.json";
42
42
  const SMS_STATE_FILE_NAME = "sms-state.json";
43
43
 
44
44
  type SmsState = {
45
- lastActiveAt: string;
45
+ lastActiveAt?: string;
46
+ lastMessageReceivedAt?: string;
46
47
  date: string;
47
48
  totalSent: number;
48
49
  windows: {
@@ -254,6 +255,10 @@ export class KichiForwarderService {
254
255
  this.ws.send(JSON.stringify(payload));
255
256
  }
256
257
 
258
+ recordSmsLastMessageReceivedAt(): void {
259
+ this.updateSmsState({ lastMessageReceivedAt: new Date().toISOString() });
260
+ }
261
+
257
262
  sendIdlePlan(payload: IdlePlanContent): boolean {
258
263
  if (!this.identity?.authKey || this.ws?.readyState !== WebSocket.OPEN) return false;
259
264
  const outboundPayload: IdlePlanPayload = {
@@ -336,6 +341,7 @@ export class KichiForwarderService {
336
341
  authKey: identity.authKey,
337
342
  };
338
343
  const result = await this.sendRequest<QueryStatusResultPayload>(payload, "query_status_result");
344
+ this.updateSmsLastActiveAt();
339
345
  if (result.RoomContext && typeof result.RoomContext === "object") {
340
346
  this.cachedRoomContext = result.RoomContext as Record<string, unknown>;
341
347
  }
@@ -887,6 +893,10 @@ export class KichiForwarderService {
887
893
  }
888
894
 
889
895
  private updateSmsLastActiveAt(): void {
896
+ this.updateSmsState({ lastActiveAt: new Date().toISOString() });
897
+ }
898
+
899
+ private updateSmsState(patch: Partial<SmsState>): void {
890
900
  try {
891
901
  const now = new Date();
892
902
  const previousState = this.readSmsStateFile();
@@ -896,7 +906,7 @@ export class KichiForwarderService {
896
906
  windows: { morning: 0, afternoon: 0, evening: 0 },
897
907
  lastTypes: [],
898
908
  ...previousState,
899
- lastActiveAt: now.toISOString(),
909
+ ...patch,
900
910
  };
901
911
  fs.mkdirSync(this.options.runtimeDir, { recursive: true, mode: 0o700 });
902
912
  fs.writeFileSync(this.getSmsStatePath(), JSON.stringify(nextState, null, 2), { mode: 0o600 });