lumiverse-spindle-types 0.2.1 → 0.2.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lumiverse-spindle-types",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "types": "./src/index.ts",
5
5
  "keywords": [
6
6
  "lumiverse",
package/src/api.ts CHANGED
@@ -637,7 +637,10 @@ export type WorkerToHost =
637
637
  // ─── Chat Memories (gated: "chats") ───────────────────────────────
638
638
  | { type: "chats_get_memories"; requestId: string; chatId: string; topK?: number; userId?: string }
639
639
  // ─── Toast (free tier) ───────────────────────────────────────────────
640
- | { type: "toast_show"; toastType: "success" | "warning" | "error" | "info"; message: string; title?: string; duration?: number };
640
+ | { type: "toast_show"; toastType: "success" | "warning" | "error" | "info"; message: string; title?: string; duration?: number }
641
+ // ─── Push Notifications (gated: "push_notification") ────────────────
642
+ | { type: "push_send"; requestId: string; title: string; body: string; tag?: string; url?: string; userId?: string }
643
+ | { type: "push_get_status"; requestId: string; userId?: string };
641
644
 
642
645
  // ─── Host → Worker messages ──────────────────────────────────────────────
643
646
 
@@ -28,7 +28,8 @@ export type SpindlePermission =
28
28
  | "characters"
29
29
  | "chats"
30
30
  | "world_books"
31
- | "personas";
31
+ | "personas"
32
+ | "push_notification";
32
33
 
33
34
  export const ALL_PERMISSIONS: readonly SpindlePermission[] = [
34
35
  "generation",
@@ -46,6 +47,7 @@ export const ALL_PERMISSIONS: readonly SpindlePermission[] = [
46
47
  "chats",
47
48
  "world_books",
48
49
  "personas",
50
+ "push_notification",
49
51
  ] as const;
50
52
 
51
53
  export function isValidPermission(p: string): p is SpindlePermission {
@@ -376,6 +376,48 @@ export interface SpindleAPI {
376
376
  error(msg: string): void;
377
377
  };
378
378
 
379
+ /**
380
+ * Push notifications (permission: "push_notification").
381
+ * Send OS-level push notifications to users and check push status.
382
+ * Notifications are attributed to your extension name.
383
+ */
384
+ push: {
385
+ /**
386
+ * Send a push notification to a user's registered devices.
387
+ * Only delivered when the app is not focused (avoids double-notification).
388
+ */
389
+ send(input: {
390
+ title: string;
391
+ body: string;
392
+ tag?: string;
393
+ url?: string;
394
+ }, userId?: string): Promise<{ sent: number }>;
395
+ /**
396
+ * Check if push notifications are available for a user.
397
+ * Returns subscription count and whether the push system is active.
398
+ */
399
+ getStatus(userId?: string): Promise<{
400
+ available: boolean;
401
+ subscriptionCount: number;
402
+ }>;
403
+ };
404
+
405
+ /**
406
+ * User presence queries (free tier — no permission needed).
407
+ * Check whether a user currently has the Lumiverse app visible/focused
408
+ * in at least one browser tab or PWA window.
409
+ */
410
+ users: {
411
+ /**
412
+ * Returns true if the user has the app visible in at least one session.
413
+ * Returns false if all sessions are hidden/backgrounded or the user has no
414
+ * active WebSocket connections.
415
+ * For user-scoped extensions, userId is inferred from the extension owner.
416
+ * For operator-scoped extensions, pass userId explicitly.
417
+ */
418
+ isVisible(userId?: string): Promise<boolean>;
419
+ };
420
+
379
421
  /** Show toast notifications in the frontend UI (free tier — no permission needed) */
380
422
  toast: {
381
423
  success(message: string, options?: { title?: string; duration?: number }): void;