dsh-deeppilot 0.6.0 → 0.6.2

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/index.d.ts CHANGED
@@ -1,7 +1,76 @@
1
1
  import { Context } from "@deepseek-ai/cordis";
2
2
  import z from "@deepseek-ai/schemastery";
3
+ //#region src/prompt-delivery.d.ts
4
+ type DeliveryStatus = 'accepted' | 'rejected' | 'unknown' | 'notFound' | 'expired';
5
+ interface DeliveryReceipt {
6
+ clientSendId: string;
7
+ status: DeliveryStatus;
8
+ userSeq?: number;
9
+ code?: string;
10
+ }
11
+ /** Durable at-most-once dispatch. Unknown outcomes are never automatically retried. */
12
+ declare class PromptDeliveryJournal {
13
+ private readonly path?;
14
+ private readonly capacity;
15
+ private entries;
16
+ private inFlight;
17
+ private healthy;
18
+ constructor(path?: string | undefined, capacity?: number);
19
+ private key;
20
+ private expired;
21
+ private save;
22
+ lookup(deviceId: string, sessionId: string, id: string): DeliveryReceipt;
23
+ dispatch(deviceId: string, sessionId: string, id: string, content: unknown, operation: () => Promise<{
24
+ ok: true;
25
+ value: number;
26
+ } | {
27
+ ok: false;
28
+ kind: string;
29
+ }>): Promise<DeliveryReceipt>;
30
+ }
31
+ //#endregion
32
+ //#region src/device-auth.d.ts
33
+ declare const DEVICE_SCOPES: readonly ['sessions.read', 'prompt.send', 'sessions.manage', 'interactions.respond', 'notifications.register'];
34
+ type DeviceScope = (typeof DEVICE_SCOPES)[number];
35
+ //#endregion
3
36
  //#region src/protocol.d.ts
4
37
  type SessionStatus = "running" | "idle" | "error" | "unknown";
38
+ /**
39
+ * Cumulative model/token statistics for one session, mirrored from the
40
+ * host's `sessionStats` (dsh-session-stats) + `tokenUsage` (dsh-token-meter)
41
+ * projections. Every counter is a non-negative integer; 0 means nothing
42
+ * recorded yet. Clients derive their display figures from the raw sums:
43
+ * average TTFT = ttftMs / ttftSteps; decode speed = decodeTokens /
44
+ * (decodeMs / 1000); cache hit ratio = cacheReadTokens / (inputTokens +
45
+ * cacheReadTokens + cacheWriteTokens); total prompt tokens = inputTokens +
46
+ * cacheReadTokens + cacheWriteTokens. Absent/null when the host exposes no
47
+ * stats projections (older DSH versions) or nothing has been measured —
48
+ * clients must tolerate missing stats and fall back.
49
+ */
50
+ interface SessionUsageStats {
51
+ turns: number;
52
+ steps: number;
53
+ /** Summed model wall time in ms. */
54
+ llmMs: number;
55
+ /** Summed tool wall time in ms. */
56
+ toolMs: number;
57
+ /** Summed first-token latency in ms over ttftSteps. */
58
+ ttftMs: number;
59
+ /** Steps that recorded a first token. */
60
+ ttftSteps: number;
61
+ /** Summed decode wall time in ms over the decode-timed steps. */
62
+ decodeMs: number;
63
+ /** Provider output tokens over the same decode-timed steps. */
64
+ decodeTokens: number;
65
+ /** Provider-reported uncached prompt tokens. */
66
+ inputTokens: number;
67
+ /** Provider-reported output tokens (reasoning included). */
68
+ outputTokens: number;
69
+ /** Prompt tokens served from the provider cache. */
70
+ cacheReadTokens: number;
71
+ /** Prompt tokens written to the provider cache. */
72
+ cacheWriteTokens: number;
73
+ }
5
74
  type SessionTodoStatus = "pending" | "in_progress" | "completed";
6
75
  /** One checklist entry of the session todo projection. */
7
76
  interface SessionTodoItem {
@@ -21,6 +90,9 @@ interface SessionSummary {
21
90
  todoItems?: SessionTodoItem[] | null;
22
91
  pendingApproval: boolean;
23
92
  pendingQuestion: boolean;
93
+ /** Optional cumulative usage stats (see SessionUsageStats); hosts without
94
+ * the stats projections omit it, and clients must tolerate its absence. */
95
+ stats?: SessionUsageStats | null;
24
96
  workspaceLabel: string | null;
25
97
  workspaceId?: string | null;
26
98
  workspacePath?: string | null;
@@ -78,6 +150,7 @@ type NotifyCategory = 'turn.completed' | 'approval.required' | 'question.asked'
78
150
  * an APNs token and no live WebSocket.
79
151
  */
80
152
  interface PushNotification {
153
+ hostAudience?: string;
81
154
  notificationId: string;
82
155
  category: NotifyCategory;
83
156
  sessionId: string;
@@ -386,6 +459,12 @@ interface BridgeSink {
386
459
  }>): void;
387
460
  replayDone(): void;
388
461
  resync(): void;
462
+ /**
463
+ * S→C permission gate (R1/P2): whether this sink may receive broadcast or
464
+ * replayed frames that require `scope`. The bridge consults this before
465
+ * every push/replay delivery; unknown broadcast types are denied.
466
+ */
467
+ canReceive(scope: DeviceScope): boolean;
389
468
  }
390
469
  /**
391
470
  * Offline push fan-out (F-9 离线推送). The bridge forwards every
@@ -394,6 +473,8 @@ interface BridgeSink {
394
473
  */
395
474
  interface PushOutlet {
396
475
  fanOut(notification: PushNotification): void;
476
+ widgetChanged?(): void;
477
+ liveActivityChanged?(sessions: SessionSummary[]): void;
397
478
  /**
398
479
  * Whether offline push is currently configured and usable. Drives the
399
480
  * welcome capability bit: advertising push while no APNs credentials are
@@ -428,8 +509,10 @@ declare class HostBridge {
428
509
  private abort;
429
510
  private started;
430
511
  private disposed;
431
- constructor(apiProxy: ApiProxyLike, historyBufferMax?: number);
512
+ readonly promptDeliveries: PromptDeliveryJournal;
513
+ constructor(apiProxy: ApiProxyLike, historyBufferMax?: number, deliveryJournalPath?: string);
432
514
  private pushOutlet;
515
+ private widgetFingerprint;
433
516
  /**
434
517
  * Wire the offline-push fan-out. Present ⇒ welcome advertises the `push`
435
518
  * capability and notify-worthy events are mirrored to APNs.
@@ -441,11 +524,14 @@ declare class HostBridge {
441
524
  approvals: boolean;
442
525
  questions: boolean;
443
526
  pendingSnapshot: boolean;
527
+ promptDelivery: boolean;
444
528
  notifyAllCategories: boolean;
445
529
  models: boolean;
446
530
  sessionManagement: boolean;
447
531
  projectSelection: boolean;
448
532
  push: boolean;
533
+ widgetPush: boolean;
534
+ liveActivityPush: boolean;
449
535
  };
450
536
  diagnostic(message: string): void;
451
537
  currentCursor(): number;
@@ -479,8 +565,12 @@ declare class HostBridge {
479
565
  * Replay buffered pushes after the given cursor; false when the gap is
480
566
  * unrecoverable. Frames go to `target` only — replaying into every sink
481
567
  * duplicated the whole window onto devices that never asked for it.
568
+ * Each frame is filtered by the S→C permission policy per sink, so a
569
+ * reader without interactions.respond never gets the missed approval
570
+ * frames back (R1/P2).
482
571
  */
483
572
  resumeFrom(cursor: number, target?: BridgeSink): boolean;
573
+ refreshLiveActivities(): void;
484
574
  private record;
485
575
  /** Start consuming host + mux streams. Idempotent; aborts on dispose(). */
486
576
  start(): void;
@@ -586,6 +676,8 @@ interface Config {
586
676
  push?: {
587
677
  /** `none` (default), `apns`, or `relay`. */
588
678
  provider?: 'none' | 'apns' | 'relay';
679
+ /** Generic mode removes conversation-derived titles and bodies before outbound push. */
680
+ contentMode?: 'preview' | 'generic';
589
681
  /** Apple Developer team id (JWT iss claim). */
590
682
  teamId?: string;
591
683
  /** APNs auth key id (JWT kid header). */
@@ -631,6 +723,7 @@ declare const Config: z<Schemastery.ObjectS<{
631
723
  }>>;
632
724
  push: z<Schemastery.ObjectS<{
633
725
  provider: z<"apns" | "none" | "relay", "apns" | "none" | "relay">;
726
+ contentMode: z<"generic" | "preview", "generic" | "preview">;
634
727
  teamId: z<string, string>;
635
728
  keyId: z<string, string>;
636
729
  keyPath: z<string, string>;
@@ -639,6 +732,7 @@ declare const Config: z<Schemastery.ObjectS<{
639
732
  relayToken: z<string, string>;
640
733
  }>, Schemastery.ObjectT<{
641
734
  provider: z<"apns" | "none" | "relay", "apns" | "none" | "relay">;
735
+ contentMode: z<"generic" | "preview", "generic" | "preview">;
642
736
  teamId: z<string, string>;
643
737
  keyId: z<string, string>;
644
738
  keyPath: z<string, string>;
@@ -677,6 +771,7 @@ declare const Config: z<Schemastery.ObjectS<{
677
771
  }>>;
678
772
  push: z<Schemastery.ObjectS<{
679
773
  provider: z<"apns" | "none" | "relay", "apns" | "none" | "relay">;
774
+ contentMode: z<"generic" | "preview", "generic" | "preview">;
680
775
  teamId: z<string, string>;
681
776
  keyId: z<string, string>;
682
777
  keyPath: z<string, string>;
@@ -685,6 +780,7 @@ declare const Config: z<Schemastery.ObjectS<{
685
780
  relayToken: z<string, string>;
686
781
  }>, Schemastery.ObjectT<{
687
782
  provider: z<"apns" | "none" | "relay", "apns" | "none" | "relay">;
783
+ contentMode: z<"generic" | "preview", "generic" | "preview">;
688
784
  teamId: z<string, string>;
689
785
  keyId: z<string, string>;
690
786
  keyPath: z<string, string>;
@@ -697,6 +793,10 @@ declare const Config: z<Schemastery.ObjectS<{
697
793
  //#region src/push-policy.d.ts
698
794
  /** Prune only when the provider supplies an authoritative token-lifecycle verdict. */
699
795
  declare function shouldPrunePushToken(outcome: 'sent' | 'invalid-token' | 'failed', reason?: string): boolean;
796
+ /** APNs requires both registration and the same content permission as WS. */
797
+ declare function mayReceivePush(device: {
798
+ scopes?: readonly string[];
799
+ }, notification: unknown): boolean;
700
800
  /**
701
801
  * Zero-touch relay self-heal: HTTP 401 means the relay no longer honors the
702
802
  * cached credential. Only auto-enrolled cells with a still-current token may
@@ -729,5 +829,5 @@ declare const name = "deeppilot";
729
829
  declare const inject: string[];
730
830
  declare function apply(ctx: Context, options: unknown): void;
731
831
  //#endregion
732
- export { Config, HostBridge, apply, inject, name, shouldPrunePushToken, shouldReEnrollRelayToken };
832
+ export { Config, HostBridge, apply, inject, mayReceivePush, name, shouldPrunePushToken, shouldReEnrollRelayToken };
733
833
  //# sourceMappingURL=index.d.ts.map