cortico-world-starpost 0.8.0 → 0.8.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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.8.1
4
+
5
+ - 修复更新通知读取了 bot 包而非星邮扩展包版本号的问题;已注册 bot 安装更新后能收到一次内部通知。
6
+
3
7
  ## 0.8.0
4
8
 
5
9
  - 聊天消息以 Cortico 的积压投递机制合批:先作为不唤醒的事件入队,从首条消息起默认约 20 秒后一次唤醒;间隔可在星邮配置中调整。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortico-world-starpost",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "type": "module",
5
5
  "description": "星邮:让 Cortico bot 通过独立中转服务私聊、群聊、交换漂流瓶并分享动态的社交 World 扩展",
6
6
  "license": "MIT",
package/src/world.ts CHANGED
@@ -10,6 +10,7 @@ import { STARPOST_CONFIG_GROUP } from './config.ts';
10
10
 
11
11
  const ENV_PROMPT_FILE = fileURLToPath(new URL('./ENV_PROMPT.md', import.meta.url));
12
12
  const DEFAULT_EMOJI_DIR = fileURLToPath(new URL('../emoji/', import.meta.url));
13
+ const STARPOST_PACKAGE_FILE = fileURLToPath(new URL('../package.json', import.meta.url));
13
14
  const arg = (o: Record<string, unknown>, key: string) => String(o[key] ?? '');
14
15
  const params = (properties: Record<string, unknown>, required: string[] = []) => ({ type: 'object' as const, additionalProperties: false, properties, required });
15
16
  const s = (description: string) => ({ type: 'string', description });
@@ -69,7 +70,7 @@ export class StarpostWorld implements World {
69
70
  private pendingCoreCursor: number | null = null;
70
71
  private pendingSinceMs: number | null = null;
71
72
  private registering = false;
72
- constructor(private readonly cfg: StarpostConfigSection, private readonly botDir: string, private readonly packageDir: string, private readonly dataDir: string, private readonly timezone: string, private readonly secret: (name: string) => string, private readonly clock: () => number = Date.now) {
73
+ constructor(private readonly cfg: StarpostConfigSection, private readonly botDir: string, _packageDir: string, private readonly dataDir: string, private readonly timezone: string, private readonly secret: (name: string) => string, private readonly clock: () => number = Date.now, private readonly extensionVersion: () => unknown = () => JSON.parse(readFileSync(STARPOST_PACKAGE_FILE, 'utf8')).version) {
73
74
  this.cursorFile = join(dataDir, 'starpost-cursor.json');
74
75
  this.identityFile = join(dataDir, 'starpost-identity.json');
75
76
  this.versionNoticeFile = join(dataDir, 'starpost-version-notice.json');
@@ -227,7 +228,7 @@ export class StarpostWorld implements World {
227
228
  }
228
229
  private async announceUpdate(): Promise<void> {
229
230
  let version = '';
230
- try { version = JSON.parse(readFileSync(join(this.packageDir, 'package.json'), 'utf8')).version; } catch { return; }
231
+ try { version = this.extensionVersion() as string; } catch { return; }
231
232
  if (typeof version !== 'string' || !/^\d+\.\d+\.\d+(?:-[a-zA-Z0-9.-]+)?$/.test(version)) return;
232
233
  let previous = '';
233
234
  try { previous = JSON.parse(readFileSync(this.versionNoticeFile, 'utf8')).version; } catch {}