dsh-deeppilot 0.9.11 → 0.9.13

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
@@ -30,6 +30,7 @@ declare const ERROR_CODES: {
30
30
  readonly E_BUSY: 'session is busy';
31
31
  readonly E_UNSUPPORTED: 'protocol version or capability unsupported';
32
32
  readonly E_INTERNAL: 'internal error';
33
+ readonly E_STEER_UNAVAILABLE: 'queued item can no longer steer the current turn';
33
34
  };
34
35
  type WireErrorCode = keyof typeof ERROR_CODES;
35
36
  //#endregion
@@ -243,6 +244,12 @@ interface PermissionCatalog {
243
244
  }
244
245
  //#endregion
245
246
  //#region src/protocol.d.ts
247
+ /**
248
+ * `format` 缺省为 `zip`,与扩展出现前的行为逐字节相同;`markdown` 需要
249
+ * `welcome.capabilities.sessionMarkdown`,否则 Bridge 回 E_UNSUPPORTED。
250
+ * 不认识该字段的旧 Bridge 会忽略它并照常返回 ZIP,所以客户端必须先看能力位。
251
+ */
252
+ type SessionExportFormat = 'zip' | 'markdown';
246
253
  interface WelcomeCapabilities {
247
254
  /** 会话命令目录、执行、权限与原生日志导出入口。缺省不支持。 */
248
255
  commands?: boolean;
@@ -276,6 +283,21 @@ interface WelcomeCapabilities {
276
283
  * deleting its local credentials. Absent on older bridges; older clients
277
284
  * ignore the extra field. */
278
285
  deviceRevoke?: boolean;
286
+ /** Host exposes DSH session.updateQueue and the inbox projection: running
287
+ * sessions accept mode:"steer", s2c.session.queue snapshots are pushed and
288
+ * c2s.session.queue.update is served. Absent ⇒ running sessions only stop. */
289
+ promptQueue?: boolean;
290
+ /** Bridge pushes s2c.session.delta while a turn runs: transient assistant and
291
+ * reasoning increments that never occupy a replay seq. Absent ⇒ the client
292
+ * keeps the old "text appears when the step lands" rendering. */
293
+ assistantStream?: boolean;
294
+ /** Bridge serves c2s.session.export with format:"markdown" (the host's
295
+ * /api/session.markdown route). Absent ⇒ only the ZIP archive is available. */
296
+ sessionMarkdown?: boolean;
297
+ /** Bridge serves c2s.plugin.update.check / c2s.plugin.update.apply, letting
298
+ * the phone replace this plugin with a published version. Absent ⇒ the phone
299
+ * can only link out to npm. */
300
+ pluginUpdate?: boolean;
279
301
  }
280
302
  type SessionStatus = "running" | "idle" | "error" | "unknown";
281
303
  /**
@@ -462,8 +484,10 @@ interface CommandsApiLike {
462
484
  text: string;
463
485
  category?: string;
464
486
  }>): Promise<RpcResponseLike<void>>;
487
+ readonly markdownAvailable?: boolean;
465
488
  export(req: RpcRequestLike<{
466
489
  sessionId: string;
490
+ format?: SessionExportFormat;
467
491
  }>, signal: AbortSignal): Promise<Response>;
468
492
  }
469
493
  interface RpcOk<T> {
@@ -549,6 +573,11 @@ interface SessionsApiLike {
549
573
  };
550
574
  data: string;
551
575
  }>>;
576
+ /** Remove or steer one pending inbox item. Absent on hosts without the
577
+ * DSH session.updateQueue RPC; the promptQueue capability bit probes it. */
578
+ updateQueue?(req: RpcRequestLike<QueueUpdateArgs>): Promise<RpcResponseLike<{
579
+ accepted: true;
580
+ }>>;
552
581
  /** Complete projection baseline for one session; null when it is gone. */
553
582
  projections(req: RpcRequestLike<{
554
583
  sessionId: string;
@@ -749,6 +778,16 @@ interface PromptArgs {
749
778
  }>;
750
779
  clientTimeZone?: string;
751
780
  }
781
+ /** DSH session.updateQueue request; `edit` is reserved on the wire and never sent. */
782
+ interface QueueUpdateArgs {
783
+ sessionId: string;
784
+ itemId: string;
785
+ action: {
786
+ kind: 'remove';
787
+ } | {
788
+ kind: 'steer';
789
+ };
790
+ }
752
791
  interface PhoneSessionRow {
753
792
  sessionId: string;
754
793
  updatedAt: number;
@@ -809,6 +848,8 @@ interface ApiStreamItemLike {
809
848
  payload: MuxFrameLike;
810
849
  }
811
850
  interface ApiProxyLike {
851
+ /** 真实宿主反射声明了助手流帧时才为 true;旧代理缺省关闭。 */
852
+ readonly assistantStreamAvailable?: boolean;
812
853
  commands?: CommandsApiLike;
813
854
  sessions: SessionsApiLike;
814
855
  workspace?: WorkspaceApiLike;
@@ -916,7 +957,13 @@ declare class HostBridge {
916
957
  * and restore them. Excluded from `summaries` and from the live broadcast. */
917
958
  private archivedSummaries;
918
959
  private subagentSessionIds;
960
+ /**
961
+ * 每个会话最近一次已知的队列(inbox 投影的折叠结果)及其指纹。来源是实时
962
+ * 投影通知或打开会话时读到的基线;指纹用来丢掉内容没变的重复通知。
963
+ */
964
+ private queues;
919
965
  private sinks;
966
+ private readonly assistantStream;
920
967
  private ring;
921
968
  private cursor;
922
969
  private userReceiptSeq;
@@ -957,6 +1004,9 @@ declare class HostBridge {
957
1004
  markSinkOpen(sink: BridgeSink, sessionId: string): void;
958
1005
  markSinkClosed(sink: BridgeSink, sessionId: string): void;
959
1006
  dropSinkSessions(sink: BridgeSink): void;
1007
+ private hasStreamViewer;
1008
+ /** Instant publications bypass record(): no cursor, ring, notification or push side effect. */
1009
+ private pushAssistantDelta;
960
1010
  private isViewedBy;
961
1011
  /** F-9: when a notification-worthy event fires, mirror it to every
962
1012
  * online device that is not currently viewing the session (the s2c.notify
@@ -1000,6 +1050,19 @@ declare class HostBridge {
1000
1050
  private deriveTitleFallback;
1001
1051
  private captureActivity;
1002
1052
  private noteActivity;
1053
+ /**
1054
+ * 折叠一次 inbox 投影。只有实时变化才广播 s2c.session.queue;基线只补缓存,
1055
+ * 打开会话的那台设备另由 pushQueueSnapshot 点对点拿到快照。
1056
+ *
1057
+ * 基线只补缺不覆盖:实时通知带的是完整投影值,收到过就以它为准;基线读取与
1058
+ * 实时变化并发时,较早算出的基线不得盖掉较新的实时值。
1059
+ */
1060
+ private applyInbox;
1061
+ /**
1062
+ * 打开会话时补发的快照:不占 seq,与 tail 同属打开响应。还没读到过该会话的
1063
+ * 投影(基线失败、Host 不提供或子代理会话)时不发,因为未知不等于空队列。
1064
+ */
1065
+ private pushQueueSnapshot;
1003
1066
  private applyProjection;
1004
1067
  private bumpPendingFlags;
1005
1068
  private pushSummary;
@@ -1038,7 +1101,7 @@ declare class HostBridge {
1038
1101
  data: string;
1039
1102
  } | null>;
1040
1103
  commandOperation(operation: 'list' | 'execute' | 'permissions' | 'feedback', payload: Record<string, unknown>): Promise<SessionManagementResult<unknown>>;
1041
- exportSession(sessionId: string, signal: AbortSignal): Promise<Response>;
1104
+ exportSession(sessionId: string, signal: AbortSignal, format?: SessionExportFormat): Promise<Response>;
1042
1105
  /** 由会话目录决定技能可见性;不读取正文,也不把本机路径发给移动端。 */
1043
1106
  sessionSkills(sessionId: string): Promise<SessionManagementResult<{
1044
1107
  skills: SkillSummary[];
@@ -1048,6 +1111,14 @@ declare class HostBridge {
1048
1111
  renameSession(sessionId: string, title: string): Promise<SessionManagementResult<string>>;
1049
1112
  archiveSession(sessionId: string): Promise<SessionManagementResult<true>>;
1050
1113
  unarchiveSession(sessionId: string): Promise<SessionManagementResult<true>>;
1114
+ /**
1115
+ * 删除或转向一条排队项。ack 只表示 Host 已提交变更,真实状态以随后的
1116
+ * s2c.session.queue 为准;不做幂等,项已消失时 Host 回 queue-item-not-found。
1117
+ */
1118
+ updateQueue(sessionId: string, itemId: string, action: 'remove' | 'steer'): Promise<SessionManagementResult<{
1119
+ sessionId: string;
1120
+ itemId: string;
1121
+ }>>;
1051
1122
  cancelSession(sessionId: string): Promise<SessionManagementResult<true>>;
1052
1123
  listWorkspaces(): Promise<SessionManagementResult<Array<{
1053
1124
  id: string;
@@ -1104,7 +1175,10 @@ declare class HostBridge {
1104
1175
  mediaType: 'image/png' | 'image/jpeg' | 'image/webp' | 'image/gif';
1105
1176
  data: string;
1106
1177
  name?: string;
1107
- }>, documents?: PromptDocument[]): Promise<SessionManagementResult<number>>;
1178
+ }>, documents?: PromptDocument[], options?: {
1179
+ mode?: 'queue' | 'steer';
1180
+ clientSendId?: string;
1181
+ }): Promise<SessionManagementResult<number>>;
1108
1182
  respondApproval(requestId: string, decision: 'allow' | 'deny', reason?: string): Promise<PendingResponseOutcome>;
1109
1183
  respondQuestion(requestId: string, answers: unknown): Promise<PendingResponseOutcome>;
1110
1184
  }