@jingyi0605/codingns4dsh 0.1.2 → 0.1.7-rc.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.
Files changed (171) hide show
  1. package/README.en.md +4 -4
  2. package/README.md +14 -5
  3. package/data/build/dist/client/account-bar.js +57 -3
  4. package/data/build/dist/client/bundle.js +36246 -268
  5. package/data/build/dist/client/cli-slots.js +60 -18
  6. package/data/build/dist/client/dsh-h5-bootstrap.d.ts +2 -0
  7. package/data/build/dist/client/dsh-h5-bootstrap.js +79 -13
  8. package/data/build/dist/client/features/file-management-panel.d.ts +5 -0
  9. package/data/build/dist/client/features/file-management-panel.js +48 -0
  10. package/data/build/dist/client/features/file-management.d.ts +4 -0
  11. package/data/build/dist/client/features/file-management.js +50 -0
  12. package/data/build/dist/client/features/index.d.ts +10 -1
  13. package/data/build/dist/client/features/index.js +12 -1
  14. package/data/build/dist/client/features/login-protection-panel.js +1 -1
  15. package/data/build/dist/client/features/login-protection-session.d.ts +2 -0
  16. package/data/build/dist/client/features/login-protection-session.js +18 -0
  17. package/data/build/dist/client/features/peer-host.d.ts +4 -0
  18. package/data/build/dist/client/features/peer-host.js +89 -0
  19. package/data/build/dist/client/features/reverse-proxy-panel.js +23 -7
  20. package/data/build/dist/client/features/reverse-proxy.d.ts +1 -2
  21. package/data/build/dist/client/features/reverse-proxy.js +75 -5
  22. package/data/build/dist/client/features/types.d.ts +9 -0
  23. package/data/build/dist/client/features/workspace-session-enhancement-panel.js +10 -0
  24. package/data/build/dist/client/features/workspace-session-enhancement.js +18 -1
  25. package/data/build/dist/client/file-management-dom.d.ts +12 -0
  26. package/data/build/dist/client/file-management-dom.js +527 -0
  27. package/data/build/dist/client/git-management.js +24 -5
  28. package/data/build/dist/client/host-navigation.d.ts +29 -0
  29. package/data/build/dist/client/host-navigation.js +29 -0
  30. package/data/build/dist/client/host-router.d.ts +3 -0
  31. package/data/build/dist/client/host-router.js +2 -0
  32. package/data/build/dist/client/index.d.ts +6 -1
  33. package/data/build/dist/client/index.js +30 -10
  34. package/data/build/dist/client/locale.js +36 -7
  35. package/data/build/dist/client/peer-host-connection-button.d.ts +13 -0
  36. package/data/build/dist/client/peer-host-connection-button.js +69 -0
  37. package/data/build/dist/client/peer-host-management-api.d.ts +40 -0
  38. package/data/build/dist/client/peer-host-management-api.js +33 -0
  39. package/data/build/dist/client/peer-host-management-panel.d.ts +13 -0
  40. package/data/build/dist/client/peer-host-management-panel.js +181 -0
  41. package/data/build/dist/client/peer-host-native-session-ui.d.ts +60 -0
  42. package/data/build/dist/client/peer-host-native-session-ui.js +372 -0
  43. package/data/build/dist/client/peer-host-scoped-client.d.ts +67 -0
  44. package/data/build/dist/client/peer-host-scoped-client.js +316 -0
  45. package/data/build/dist/client/peer-host-session-controller.d.ts +30 -0
  46. package/data/build/dist/client/peer-host-session-controller.js +95 -0
  47. package/data/build/dist/client/quick-phrase-slot.js +14 -0
  48. package/data/build/dist/client/remote-web-context.js +26 -4
  49. package/data/build/dist/client/session-changed-files-view.d.ts +15 -0
  50. package/data/build/dist/client/session-changed-files-view.js +337 -0
  51. package/data/build/dist/client/settings-bridge.d.ts +14 -4
  52. package/data/build/dist/client/settings-bridge.js +59 -12
  53. package/data/build/dist/client/settings-section.js +17 -4
  54. package/data/build/dist/client/subscription-slot.js +21 -8
  55. package/data/build/dist/client/workspace-session-rightbar-dom.d.ts +28 -0
  56. package/data/build/dist/client/workspace-session-rightbar-dom.js +291 -0
  57. package/data/build/dist/dsh-capabilities/client/config-forms-adapter.js +25 -33
  58. package/data/build/dist/dsh-capabilities/client/settings-scope-adapter.d.ts +7 -1
  59. package/data/build/dist/dsh-capabilities/client/settings-scope-adapter.js +34 -11
  60. package/data/build/dist/dsh-capabilities/matrix.js +9 -0
  61. package/data/build/dist/dsh-capabilities/routes.js +35 -0
  62. package/data/build/dist/dsh-capabilities/settings-store.d.ts +12 -0
  63. package/data/build/dist/dsh-capabilities/settings-store.js +34 -0
  64. package/data/build/dist/dsh-capabilities/types.d.ts +1 -1
  65. package/data/build/dist/features/host-router.d.ts +26 -0
  66. package/data/build/dist/features/host-router.js +110 -0
  67. package/data/build/dist/features/registry.js +3 -0
  68. package/data/build/dist/host/cli-adapters/codex-driver.d.ts +13 -1
  69. package/data/build/dist/host/cli-adapters/codex-driver.js +528 -72
  70. package/data/build/dist/host/cli-adapters/command-code-driver.d.ts +21 -2
  71. package/data/build/dist/host/cli-adapters/command-code-driver.js +408 -105
  72. package/data/build/dist/host/cli-adapters/driver.d.ts +2 -0
  73. package/data/build/dist/host/cli-adapters/dsh-message-projector.d.ts +2 -0
  74. package/data/build/dist/host/cli-adapters/dsh-message-projector.js +47 -28
  75. package/data/build/dist/host/cli-adapters/dsh-tool-history.js +37 -0
  76. package/data/build/dist/host/cli-adapters/feature.js +94 -10
  77. package/data/build/dist/host/cli-adapters/json-rpc-process.d.ts +6 -0
  78. package/data/build/dist/host/cli-adapters/json-rpc-process.js +14 -3
  79. package/data/build/dist/host/cli-adapters/kimi-driver.js +3 -3
  80. package/data/build/dist/host/cli-adapters/model-catalog.d.ts +6 -0
  81. package/data/build/dist/host/cli-adapters/model-catalog.js +8 -0
  82. package/data/build/dist/host/cli-adapters/opencode-driver.js +14 -2
  83. package/data/build/dist/host/cli-adapters/pi-driver.js +2 -2
  84. package/data/build/dist/host/cli-adapters/process-utils.d.ts +8 -0
  85. package/data/build/dist/host/cli-adapters/process-utils.js +48 -0
  86. package/data/build/dist/host/cli-adapters/registry.d.ts +6 -1
  87. package/data/build/dist/host/cli-adapters/registry.js +41 -7
  88. package/data/build/dist/host/cli-adapters/rpc-driver-utils.js +23 -4
  89. package/data/build/dist/host/cli-adapters/standard-stream-driver.d.ts +3 -0
  90. package/data/build/dist/host/cli-adapters/standard-stream-driver.js +36 -15
  91. package/data/build/dist/host/dsh-device-runtime.d.ts +2 -0
  92. package/data/build/dist/host/dsh-device-runtime.js +55 -29
  93. package/data/build/dist/host/dsh-runtime-version.d.ts +3 -2
  94. package/data/build/dist/host/dsh-runtime-version.js +71 -2
  95. package/data/build/dist/host/features/auth.js +10 -2
  96. package/data/build/dist/host/features/file-management.d.ts +5 -0
  97. package/data/build/dist/host/features/file-management.js +267 -0
  98. package/data/build/dist/host/features/git-management.js +24 -2
  99. package/data/build/dist/host/features/index.d.ts +2 -0
  100. package/data/build/dist/host/features/index.js +6 -0
  101. package/data/build/dist/host/features/peer-host.d.ts +22 -0
  102. package/data/build/dist/host/features/peer-host.js +322 -0
  103. package/data/build/dist/host/features/types.d.ts +4 -0
  104. package/data/build/dist/host/host-router.d.ts +3 -0
  105. package/data/build/dist/host/host-router.js +2 -0
  106. package/data/build/dist/host/index-injection.d.ts +17 -0
  107. package/data/build/dist/host/index-injection.js +24 -0
  108. package/data/build/dist/host/index.d.ts +4 -1
  109. package/data/build/dist/host/index.js +41 -7
  110. package/data/build/dist/host/lan-access-dsh.d.ts +34 -1
  111. package/data/build/dist/host/lan-access-dsh.js +145 -26
  112. package/data/build/dist/host/modules/peer-host/host-api-proxy-service.d.ts +52 -0
  113. package/data/build/dist/host/modules/peer-host/host-api-proxy-service.js +166 -0
  114. package/data/build/dist/host/modules/peer-host/host-ws-connector.d.ts +31 -0
  115. package/data/build/dist/host/modules/peer-host/host-ws-connector.js +108 -0
  116. package/data/build/dist/host/modules/peer-host/host-ws-proxy-service.d.ts +26 -0
  117. package/data/build/dist/host/modules/peer-host/host-ws-proxy-service.js +159 -0
  118. package/data/build/dist/host/modules/peer-host/peer-host-aggregate-service.d.ts +50 -0
  119. package/data/build/dist/host/modules/peer-host/peer-host-aggregate-service.js +97 -0
  120. package/data/build/dist/host/modules/peer-host/peer-host-diagnostics.d.ts +19 -0
  121. package/data/build/dist/host/modules/peer-host/peer-host-diagnostics.js +54 -0
  122. package/data/build/dist/host/modules/peer-host/peer-host-handshake.d.ts +44 -0
  123. package/data/build/dist/host/modules/peer-host/peer-host-handshake.js +133 -0
  124. package/data/build/dist/host/modules/peer-host/peer-host-relay.d.ts +65 -0
  125. package/data/build/dist/host/modules/peer-host/peer-host-relay.js +196 -0
  126. package/data/build/dist/host/modules/peer-host/peer-host-session.d.ts +42 -0
  127. package/data/build/dist/host/modules/peer-host/peer-host-session.js +152 -0
  128. package/data/build/dist/host/modules/peer-host/peer-host-store.d.ts +92 -0
  129. package/data/build/dist/host/modules/peer-host/peer-host-store.js +323 -0
  130. package/data/build/dist/host/modules/peer-host/peer-host-ws-gateway.d.ts +34 -0
  131. package/data/build/dist/host/modules/peer-host/peer-host-ws-gateway.js +156 -0
  132. package/data/build/dist/host/native-session-bridge.d.ts +18 -2
  133. package/data/build/dist/host/native-session-bridge.js +236 -8
  134. package/data/build/dist/host/remote-web-runtime.js +26 -1
  135. package/data/build/dist/host/rpc.js +8 -3
  136. package/data/build/dist/host/session-changes.d.ts +5 -0
  137. package/data/build/dist/host/session-changes.js +163 -0
  138. package/data/build/dist/host/settings.js +6 -0
  139. package/data/build/dist/index.d.ts +1 -1
  140. package/data/build/dist/index.js +1 -1
  141. package/data/build/dist/shared/contracts/cli-adapter.d.ts +23 -2
  142. package/data/build/dist/shared/contracts/config.d.ts +15 -0
  143. package/data/build/dist/shared/contracts/config.js +10 -0
  144. package/data/build/dist/shared/contracts/dsh-device.d.ts +2 -0
  145. package/data/build/dist/shared/contracts/errors.d.ts +14 -0
  146. package/data/build/dist/shared/contracts/errors.js +15 -0
  147. package/data/build/dist/shared/contracts/feature.d.ts +2 -0
  148. package/data/build/dist/shared/contracts/file-management.d.ts +6 -0
  149. package/data/build/dist/shared/contracts/file-management.js +3 -0
  150. package/data/build/dist/shared/contracts/peer-host.d.ts +116 -15
  151. package/data/build/dist/shared/contracts/peer-host.js +19 -0
  152. package/data/build/dist/shared/contracts/version.d.ts +1 -1
  153. package/data/build/dist/shared/contracts/version.js +1 -1
  154. package/data/build/dist/shared/index.d.ts +4 -3
  155. package/data/build/dist/shared/index.js +2 -2
  156. package/data/build/dist/transport/debug.d.ts +5 -0
  157. package/data/build/dist/transport/debug.js +23 -1
  158. package/data/build/dist/transport/dsh-transport.d.ts +2 -0
  159. package/data/build/dist/transport/dsh-transport.js +11 -0
  160. package/data/build/dist/transport/webrtc-client.d.ts +2 -0
  161. package/data/build/dist/transport/webrtc-client.js +2 -1
  162. package/data/build/dist/transport/webrtc-host.d.ts +2 -0
  163. package/data/build/dist/transport/webrtc-host.js +6 -3
  164. package/data/build/dist/typert.host.d.ts +1 -1
  165. package/data/build/dist/typert.host.js +2 -1
  166. package/dsh.bundle.patch +10 -0
  167. package/package.json +19 -11
  168. package/profile/README.md +2 -2
  169. package/profile/package.json +2 -2
  170. package/profile/version.json +1 -1
  171. package/version.json +1 -1
@@ -81,6 +81,11 @@ export interface CodingNsCliTurnInput {
81
81
  readonly rawStoreRef?: string;
82
82
  /** 仅由 Host 的 DSH 分段桥接使用;让支持的 Provider 在工具完成处结束当前 step。 */
83
83
  readonly splitToolSteps?: boolean;
84
+ /**
85
+ * 仅由 Host 的 DSH 分段桥接使用;显式说明这次调用是在续接上一次被切分的
86
+ * Provider 运行,而不是新的用户回合。驱动据此复用常驻进程。
87
+ */
88
+ readonly resumeSegmentedTurn?: boolean;
84
89
  }
85
90
  export interface CodingNsAgentPermissionResponse {
86
91
  readonly requestId: string;
@@ -167,15 +172,20 @@ export type CodingNsAgentEvent = {
167
172
  readonly channel: 'reasoning' | 'text';
168
173
  readonly messageId: string;
169
174
  } | {
170
- /** Provider 已完成一个外部工具,Host 应在当前流结束后注入下一个 DSH step。 */
175
+ /** Provider 的 assistant item 已切换,Host 应在当前流结束后注入下一个 DSH step。 */
171
176
  readonly type: 'step-boundary';
172
177
  } | CodingNsAgentToolEvent | {
173
178
  readonly type: 'usage';
174
- /** Command Code 的 inputTokens 是包含缓存读写的完整输入。 */
179
+ /**
180
+ * Provider 上报的输入口径:Codex、Command Code 的 inputTokens 已包含缓存读写,
181
+ * Anthropic 风格的 input 不含缓存。公共投影层按 `uncachedInputTokens` 折算成
182
+ * DSH 的互斥桶口径(inputTokens 只含未缓存输入)后再交给 token-meter。
183
+ */
175
184
  readonly inputTokens: number;
176
185
  readonly outputTokens: number;
177
186
  readonly cacheReadTokens?: number;
178
187
  readonly cacheWriteTokens?: number;
188
+ /** 未缓存输入;Provider 给出缓存分桶时由 `usageChunk` 计算。 */
179
189
  readonly uncachedInputTokens?: number;
180
190
  readonly totalTokens?: number;
181
191
  /** 缓存读取 / 完整输入,百分比取值 0 到 100。 */
@@ -202,5 +212,16 @@ export type CodingNsAgentEvent = {
202
212
  readonly type: 'question-request';
203
213
  readonly requestId: string;
204
214
  readonly questions: readonly CodingNsAgentQuestion[];
215
+ } | {
216
+ /** Provider 上下文压缩生命周期;由公共消息投影层写入 DSH 原生事件。 */
217
+ readonly type: 'context-compaction';
218
+ readonly phase: 'start' | 'summary' | 'end';
219
+ readonly compactionId?: string;
220
+ readonly provider?: string;
221
+ readonly model?: string;
222
+ readonly summary?: string;
223
+ readonly shadowedItemCount?: number;
224
+ readonly shadowedTokenCount?: number;
225
+ readonly error?: string;
205
226
  };
206
227
  //# sourceMappingURL=cli-adapter.d.ts.map
@@ -17,6 +17,8 @@ export interface CodingNsSettings {
17
17
  terminalEnhancement: TerminalEnhancementSettings;
18
18
  /** 原生工作区会话行的浏览器端增强选项。 */
19
19
  workspaceSessionEnhancement: WorkspaceSessionEnhancementSettings;
20
+ /** DSH 文件管理侧栏的独立增强选项。 */
21
+ fileManagement: FileManagementSettings;
20
22
  /**
21
23
  * 功能模块启用意图:模块名 -> 是否启用。
22
24
  *
@@ -74,11 +76,23 @@ export interface WorkspaceSessionEnhancementSettings {
74
76
  showSubscriptionUsage: boolean;
75
77
  /** 是否在输入工具区显示快捷会话入口。 */
76
78
  showQuickPhrases: boolean;
79
+ /** 是否记忆对话窗口与右侧栏的宽度比例;具体比例保存在当前浏览器。 */
80
+ rememberConversationRightbarRatio: boolean;
77
81
  /** 插件本地保存的快捷会话条目。 */
78
82
  quickPhrases: QuickPhrase[];
79
83
  /** 内置快捷会话是否已经完成首次初始化;仅用于兼容旧配置。 */
80
84
  quickPhrasesSeeded: boolean;
81
85
  }
86
+ /** 文件管理增强的独立能力开关。 */
87
+ export interface FileManagementSettings {
88
+ /** 是否为文件和目录显示右键操作菜单。 */
89
+ menuEnhancement: boolean;
90
+ /** 是否为可编辑文本文件显示编辑器入口。 */
91
+ fileEditor: boolean;
92
+ /** 是否在当前会话顶部显示“修改文件”视图。 */
93
+ sessionChangedFiles: boolean;
94
+ }
95
+ export declare const DEFAULT_FILE_MANAGEMENT_SETTINGS: FileManagementSettings;
82
96
  /** 可复用的快捷会话文本。 */
83
97
  export interface QuickPhrase {
84
98
  id: string;
@@ -117,6 +131,7 @@ export declare const CODINGNS_MODULES_FIELD = "modules";
117
131
  export declare const CODINGNS_LAN_ACCESS_DSH_FIELD = "lanAccessDsh";
118
132
  export declare const CODINGNS_TERMINAL_ENHANCEMENT_FIELD = "terminalEnhancement";
119
133
  export declare const CODINGNS_WORKSPACE_SESSION_ENHANCEMENT_FIELD = "workspaceSessionEnhancement";
134
+ export declare const CODINGNS_FILE_MANAGEMENT_FIELD = "fileManagement";
120
135
  export declare const DEFAULT_CODINGNS_CONTROL_BASE_URL = "https://channel.codingns.com:1443";
121
136
  export declare const DEFAULT_CODINGNS_CONTROL_BASE_URLS: string[];
122
137
  /** 控制站的网页登录地址,用于注册 Codingns4DSH 账号。 */
@@ -1,4 +1,9 @@
1
1
  import { isDshVersionAtLeast } from './version.js';
2
+ export const DEFAULT_FILE_MANAGEMENT_SETTINGS = {
3
+ menuEnhancement: true,
4
+ fileEditor: true,
5
+ sessionChangedFiles: true,
6
+ };
2
7
  /** 首次启用快捷会话时提供的内置指令。 */
3
8
  export const DEFAULT_QUICK_PHRASES = [
4
9
  { id: 'builtin-quick-1', text: '请将本次会话变更的所有代码提交到git暂存区,然后总结一条中文的提交信息' },
@@ -22,6 +27,7 @@ export const CODINGNS_MODULES_FIELD = 'modules';
22
27
  export const CODINGNS_LAN_ACCESS_DSH_FIELD = 'lanAccessDsh';
23
28
  export const CODINGNS_TERMINAL_ENHANCEMENT_FIELD = 'terminalEnhancement';
24
29
  export const CODINGNS_WORKSPACE_SESSION_ENHANCEMENT_FIELD = 'workspaceSessionEnhancement';
30
+ export const CODINGNS_FILE_MANAGEMENT_FIELD = 'fileManagement';
25
31
  export const DEFAULT_CODINGNS_CONTROL_BASE_URL = 'https://channel.codingns.com:1443';
26
32
  export const DEFAULT_CODINGNS_CONTROL_BASE_URLS = [DEFAULT_CODINGNS_CONTROL_BASE_URL];
27
33
  /** 控制站的网页登录地址,用于注册 Codingns4DSH 账号。 */
@@ -51,6 +57,7 @@ export const DEFAULT_WORKSPACE_SESSION_ENHANCEMENT_SETTINGS = {
51
57
  hiddenWorkspaceIds: [],
52
58
  showSubscriptionUsage: true,
53
59
  showQuickPhrases: true,
60
+ rememberConversationRightbarRatio: false,
54
61
  quickPhrases: DEFAULT_QUICK_PHRASES.map((phrase) => ({ ...phrase })),
55
62
  quickPhrasesSeeded: true,
56
63
  };
@@ -62,6 +69,7 @@ export const DEFAULT_CODINGNS_SETTINGS = {
62
69
  agentAdapterPreferences: {},
63
70
  terminalEnhancement: DEFAULT_TERMINAL_ENHANCEMENT_SETTINGS,
64
71
  workspaceSessionEnhancement: DEFAULT_WORKSPACE_SESSION_ENHANCEMENT_SETTINGS,
72
+ fileManagement: DEFAULT_FILE_MANAGEMENT_SETTINGS,
65
73
  lanAccessDsh: {
66
74
  autoStart: false,
67
75
  listenHost: '0.0.0.0',
@@ -86,6 +94,8 @@ export function captureRestartFeatureStates(descriptors, settings, dshVersion) {
86
94
  * 用户没有表达过意图时使用模块自己声明的 enabledByDefault。
87
95
  */
88
96
  export function isFeatureEnabled(descriptor, settings) {
97
+ if (descriptor.disabled === true)
98
+ return false;
89
99
  if (descriptor.ui?.alwaysEnabled === true)
90
100
  return true;
91
101
  return settings?.modules[descriptor.name] ?? descriptor.enabledByDefault;
@@ -45,6 +45,8 @@ export interface DshDeviceHeartbeatResponse {
45
45
  export interface DshDeviceHeartbeatRequest {
46
46
  dshVersion?: string;
47
47
  computerName?: string;
48
+ /** Host 当前使用的 DTLS 身份指纹,用于防止设备凭据串用。 */
49
+ dtlsFingerprint?: string;
48
50
  }
49
51
  export interface DshRelayTicketRequest {
50
52
  dshDeviceId: string;
@@ -19,6 +19,20 @@ export declare const CODINGNS_DSH_ERROR_CODES: {
19
19
  readonly DEBUG_RUNTIME_NOT_FOUND: "DEBUG_RUNTIME_NOT_FOUND";
20
20
  readonly DEBUG_PROXY_ROUTE_NOT_FOUND: "DEBUG_PROXY_ROUTE_NOT_FOUND";
21
21
  readonly DEBUG_DSH_HOST_API_UNAVAILABLE: "DEBUG_DSH_HOST_API_UNAVAILABLE";
22
+ readonly PEER_HOST_NOT_READY: "PEER_HOST_NOT_READY";
23
+ readonly PEER_HOST_PROXY_PATH_NOT_ALLOWED: "PEER_HOST_PROXY_PATH_NOT_ALLOWED";
24
+ readonly PEER_HOST_SCOPE_MISMATCH: "PEER_HOST_SCOPE_MISMATCH";
25
+ readonly PEER_HOST_PROXY_UNREACHABLE: "PEER_HOST_PROXY_UNREACHABLE";
26
+ readonly PEER_HOST_RESPONSE_INVALID: "PEER_HOST_RESPONSE_INVALID";
27
+ readonly PEER_HOST_TOOL_UNSUPPORTED: "PEER_HOST_TOOL_UNSUPPORTED";
28
+ readonly PEER_HOST_INVALID_ROUTE: "PEER_HOST_INVALID_ROUTE";
29
+ readonly PEER_HOST_DUPLICATE: "PEER_HOST_DUPLICATE";
30
+ readonly PEER_HOST_PLUGIN_MISSING: "PEER_HOST_PLUGIN_MISSING";
31
+ readonly PEER_HOST_IDENTITY_CHANGED: "PEER_HOST_IDENTITY_CHANGED";
32
+ readonly PEER_HOST_UNREACHABLE: "PEER_HOST_UNREACHABLE";
33
+ readonly PEER_HOST_RELAY_UNAVAILABLE: "PEER_HOST_RELAY_UNAVAILABLE";
34
+ readonly PEER_HOST_AGGREGATE_UNAVAILABLE: "PEER_HOST_AGGREGATE_UNAVAILABLE";
35
+ readonly PEER_HOST_STALE_GENERATION: "PEER_HOST_STALE_GENERATION";
22
36
  };
23
37
  export declare const SUPPORTED_DSH_VERSION: "0.1.6-alpha.2";
24
38
  export declare const SUPPORTED_DSH_COMPATIBILITY: ">=0.1.5-rc.3 <=0.1.7-rc.2";
@@ -1,4 +1,5 @@
1
1
  import { DSH_COMPATIBILITY, DSH_VERSION, isDshVersionCompatible } from './version.js';
2
+ import { PEER_HOST_ERROR_CODES } from './peer-host.js';
2
3
  export const CODINGNS_DSH_ERROR_CODES = {
3
4
  PLUGIN_MANIFEST_INVALID: 'PLUGIN_MANIFEST_INVALID',
4
5
  DSH_VERSION_UNSUPPORTED: 'DSH_VERSION_UNSUPPORTED',
@@ -20,6 +21,20 @@ export const CODINGNS_DSH_ERROR_CODES = {
20
21
  DEBUG_RUNTIME_NOT_FOUND: 'DEBUG_RUNTIME_NOT_FOUND',
21
22
  DEBUG_PROXY_ROUTE_NOT_FOUND: 'DEBUG_PROXY_ROUTE_NOT_FOUND',
22
23
  DEBUG_DSH_HOST_API_UNAVAILABLE: 'DEBUG_DSH_HOST_API_UNAVAILABLE',
24
+ PEER_HOST_NOT_READY: PEER_HOST_ERROR_CODES.NOT_READY,
25
+ PEER_HOST_PROXY_PATH_NOT_ALLOWED: PEER_HOST_ERROR_CODES.PROXY_PATH_NOT_ALLOWED,
26
+ PEER_HOST_SCOPE_MISMATCH: PEER_HOST_ERROR_CODES.SCOPE_MISMATCH,
27
+ PEER_HOST_PROXY_UNREACHABLE: PEER_HOST_ERROR_CODES.PROXY_UNREACHABLE,
28
+ PEER_HOST_RESPONSE_INVALID: PEER_HOST_ERROR_CODES.RESPONSE_INVALID,
29
+ PEER_HOST_TOOL_UNSUPPORTED: PEER_HOST_ERROR_CODES.TOOL_UNSUPPORTED,
30
+ PEER_HOST_INVALID_ROUTE: PEER_HOST_ERROR_CODES.INVALID_ROUTE,
31
+ PEER_HOST_DUPLICATE: PEER_HOST_ERROR_CODES.DUPLICATE,
32
+ PEER_HOST_PLUGIN_MISSING: PEER_HOST_ERROR_CODES.PLUGIN_MISSING,
33
+ PEER_HOST_IDENTITY_CHANGED: PEER_HOST_ERROR_CODES.IDENTITY_CHANGED,
34
+ PEER_HOST_UNREACHABLE: PEER_HOST_ERROR_CODES.UNREACHABLE,
35
+ PEER_HOST_RELAY_UNAVAILABLE: PEER_HOST_ERROR_CODES.RELAY_UNAVAILABLE,
36
+ PEER_HOST_AGGREGATE_UNAVAILABLE: PEER_HOST_ERROR_CODES.AGGREGATE_UNAVAILABLE,
37
+ PEER_HOST_STALE_GENERATION: PEER_HOST_ERROR_CODES.STALE_GENERATION,
23
38
  };
24
39
  export const SUPPORTED_DSH_VERSION = DSH_VERSION;
25
40
  export const SUPPORTED_DSH_COMPATIBILITY = DSH_COMPATIBILITY;
@@ -36,6 +36,8 @@ export interface FeatureDescriptor {
36
36
  name: string;
37
37
  version: string;
38
38
  enabledByDefault: boolean;
39
+ /** 维护期间强制停用;即使历史设置为 true 也不得启动。 */
40
+ disabled?: boolean;
39
41
  dependencies: string[];
40
42
  runtime: FeatureRuntime;
41
43
  /** `restart` 表示只保存下次启动意图,当前进程不跟随设置变化启停。 */
@@ -0,0 +1,6 @@
1
+ /** 文件管理增强与 Host 之间传输的会话修改文件契约。 */
2
+ export interface SessionChangedFiles {
3
+ /** 按工作区相对路径规范化后的文件路径。 */
4
+ readonly paths: readonly string[];
5
+ }
6
+ //# sourceMappingURL=file-management.d.ts.map
@@ -0,0 +1,3 @@
1
+ /** 文件管理增强与 Host 之间传输的会话修改文件契约。 */
2
+ export {};
3
+ //# sourceMappingURL=file-management.js.map
@@ -1,31 +1,132 @@
1
- export type PeerHostStatus = 'unknown' | 'checking' | 'ready' | 'unreachable' | 'version_mismatch' | 'session_required' | 'disabled';
1
+ /** PeerHost 目标路由;短期 relay ticket 永远不属于持久配置。 */
2
+ export type PeerHostRoute = {
3
+ readonly kind: 'lan';
4
+ readonly baseUrl: string;
5
+ readonly normalizedOrigin: string;
6
+ } | {
7
+ readonly kind: 'relay';
8
+ readonly deviceId: string;
9
+ readonly relayEntryId: string;
10
+ readonly transportVersion: string;
11
+ };
12
+ export type PeerHostStatus = 'configured' | 'checking' | 'ready' | 'plugin_missing' | 'version_mismatch' | 'identity_changed' | 'session_required' | 'unreachable' | 'reconnecting' | 'disabled';
13
+ /** Host 侧保存的 PeerHost 配置与脱敏握手状态。凭据不在此 DTO 中。 */
2
14
  export interface PeerHostRecord {
3
- peerHostId: string;
4
- name: string;
5
- baseUrl: string;
6
- status: PeerHostStatus;
7
- remoteVersion: string | null;
8
- remoteApiCompatibility: string | null;
9
- remoteHostFingerprint: string | null;
10
- lastCheckedAt: string | null;
11
- lastErrorCode: string | null;
15
+ readonly id: string;
16
+ readonly ownerUserId: string;
17
+ readonly displayName: string;
18
+ readonly route: PeerHostRoute;
19
+ readonly status: PeerHostStatus;
20
+ readonly pluginId: string | null;
21
+ readonly pluginVersion: string | null;
22
+ readonly dshVersion: string | null;
23
+ readonly apiCompatibility: string | null;
24
+ readonly fingerprint: string | null;
25
+ readonly lastCheckedAt: number | null;
26
+ readonly lastErrorCode: PeerHostErrorCode | null;
27
+ readonly createdAt: number;
28
+ readonly updatedAt: number;
12
29
  }
30
+ /** Client 管理面板可见的 PeerHost 摘要;路由详情和所有凭据只留在 Host。 */
31
+ export type PeerHostClientRoute = {
32
+ readonly kind: 'lan';
33
+ } | {
34
+ readonly kind: 'relay';
35
+ };
36
+ export type PeerHostClientRecord = Omit<PeerHostRecord, 'route'> & {
37
+ readonly route: PeerHostClientRoute;
38
+ };
39
+ /** Client 可见的 PeerHost 诊断快照;不包含完整路由、凭据或正文。 */
40
+ export interface PeerHostDiagnosticSnapshot {
41
+ readonly peerHostId: string;
42
+ readonly routeKind: 'lan' | 'relay';
43
+ readonly status: PeerHostStatus;
44
+ readonly lastErrorCode: PeerHostErrorCode | null;
45
+ readonly lastCheckedAt: number | null;
46
+ readonly fingerprint: string | null;
47
+ }
48
+ /** 当前 Host 插件自有 WebSocket 入口;不包含任何目标 Host 地址或凭据。 */
49
+ export interface PeerHostWebSocketEndpoint {
50
+ readonly host: string;
51
+ readonly port: number;
52
+ readonly path: string;
53
+ }
54
+ /** 所有跨 Host 资源共用的完整作用域。 */
55
+ export interface HostScope {
56
+ readonly hostId: string;
57
+ readonly targetHostId: string | null;
58
+ readonly workspaceId: string;
59
+ readonly sessionId: string | null;
60
+ readonly scopeGeneration: number;
61
+ }
62
+ /** 会话摘要只用于聚合导航,不包含历史消息或工具内容。 */
63
+ export interface PeerHostSessionRecord {
64
+ readonly scope: HostScope;
65
+ readonly title: string;
66
+ readonly status: string;
67
+ readonly updatedAt: number;
68
+ }
69
+ /** 当前 Host 和 PeerHost 统一使用的工作区摘要。 */
70
+ export interface AggregateWorkspaceSummary {
71
+ readonly key: string;
72
+ readonly hostId: string;
73
+ readonly targetHostId: string | null;
74
+ readonly workspaceId: string;
75
+ readonly displayName: string;
76
+ readonly hostLabel: string;
77
+ readonly availability: 'ready' | 'checking' | 'unreachable' | 'unsupported';
78
+ readonly sessions: readonly PeerHostSessionRecord[];
79
+ }
80
+ export interface AggregateHostResult {
81
+ readonly hostId: string;
82
+ readonly targetHostId: string | null;
83
+ readonly hostLabel: string;
84
+ readonly availability: 'ready' | 'checking' | 'unreachable' | 'unsupported';
85
+ readonly errorCode: PeerHostErrorCode | null;
86
+ /** 摘要能力不可用时保留可诊断原因,禁止以空工作区伪装成功。 */
87
+ readonly diagnostic?: string;
88
+ readonly workspaces: readonly AggregateWorkspaceSummary[];
89
+ }
90
+ export declare const PEER_HOST_ERROR_CODES: {
91
+ readonly NOT_FOUND: "PEER_HOST_NOT_FOUND";
92
+ readonly NOT_READY: "PEER_HOST_NOT_READY";
93
+ readonly SESSION_REQUIRED: "PEER_HOST_SESSION_REQUIRED";
94
+ readonly PROXY_PATH_NOT_ALLOWED: "PEER_HOST_PROXY_PATH_NOT_ALLOWED";
95
+ readonly SCOPE_MISMATCH: "PEER_HOST_SCOPE_MISMATCH";
96
+ readonly PROXY_UNREACHABLE: "PEER_HOST_PROXY_UNREACHABLE";
97
+ readonly RESPONSE_INVALID: "PEER_HOST_RESPONSE_INVALID";
98
+ readonly TOOL_UNSUPPORTED: "PEER_HOST_TOOL_UNSUPPORTED";
99
+ readonly INVALID_ROUTE: "PEER_HOST_INVALID_ROUTE";
100
+ readonly DUPLICATE: "PEER_HOST_DUPLICATE";
101
+ readonly PLUGIN_MISSING: "PEER_HOST_PLUGIN_MISSING";
102
+ readonly VERSION_MISMATCH: "PEER_HOST_VERSION_MISMATCH";
103
+ readonly IDENTITY_CHANGED: "PEER_HOST_IDENTITY_CHANGED";
104
+ readonly UNREACHABLE: "PEER_HOST_UNREACHABLE";
105
+ readonly RELAY_UNAVAILABLE: "PEER_HOST_RELAY_UNAVAILABLE";
106
+ readonly AGGREGATE_UNAVAILABLE: "PEER_HOST_AGGREGATE_UNAVAILABLE";
107
+ readonly STALE_GENERATION: "PEER_HOST_STALE_GENERATION";
108
+ };
109
+ export type PeerHostErrorCode = typeof PEER_HOST_ERROR_CODES[keyof typeof PEER_HOST_ERROR_CODES];
110
+ /** 可安全返回 Client 的结构化错误,不携带凭据、完整 URL 或内容数据。 */
111
+ export interface PeerHostErrorShape {
112
+ readonly code: PeerHostErrorCode;
113
+ readonly peerHostId?: string;
114
+ readonly message: string;
115
+ }
116
+ /** 作用域管理器仍使用的兼容引用;新跨 Host 代码应优先使用 HostScope。 */
13
117
  export interface ResourceScopeRef {
14
118
  hostId: string;
15
119
  workspaceId: string;
16
120
  targetHostId: string | null;
17
121
  scopeGeneration: number;
122
+ sessionId?: string | null;
18
123
  }
19
- /**
20
- * 作用域切换时使用的输入,不允许调用方自行伪造 generation。
21
- * generation 只能由 ResourceScopeManager 分配。
22
- */
23
124
  export interface ResourceScopeInput {
24
125
  hostId: string;
25
126
  workspaceId: string;
26
127
  targetHostId: string | null;
128
+ sessionId?: string | null;
27
129
  }
28
- /** 对外暴露的只读作用域快照。 */
29
130
  export type ResourceScopeSnapshot = Readonly<ResourceScopeRef>;
30
131
  /** 作用域拥有的清理函数。清理函数必须可重复调用而不会产生副作用。 */
31
132
  export type ResourceScopeDisposer = () => void | Promise<void>;
@@ -1,3 +1,22 @@
1
+ export const PEER_HOST_ERROR_CODES = {
2
+ NOT_FOUND: 'PEER_HOST_NOT_FOUND',
3
+ NOT_READY: 'PEER_HOST_NOT_READY',
4
+ SESSION_REQUIRED: 'PEER_HOST_SESSION_REQUIRED',
5
+ PROXY_PATH_NOT_ALLOWED: 'PEER_HOST_PROXY_PATH_NOT_ALLOWED',
6
+ SCOPE_MISMATCH: 'PEER_HOST_SCOPE_MISMATCH',
7
+ PROXY_UNREACHABLE: 'PEER_HOST_PROXY_UNREACHABLE',
8
+ RESPONSE_INVALID: 'PEER_HOST_RESPONSE_INVALID',
9
+ TOOL_UNSUPPORTED: 'PEER_HOST_TOOL_UNSUPPORTED',
10
+ INVALID_ROUTE: 'PEER_HOST_INVALID_ROUTE',
11
+ DUPLICATE: 'PEER_HOST_DUPLICATE',
12
+ PLUGIN_MISSING: 'PEER_HOST_PLUGIN_MISSING',
13
+ VERSION_MISMATCH: 'PEER_HOST_VERSION_MISMATCH',
14
+ IDENTITY_CHANGED: 'PEER_HOST_IDENTITY_CHANGED',
15
+ UNREACHABLE: 'PEER_HOST_UNREACHABLE',
16
+ RELAY_UNAVAILABLE: 'PEER_HOST_RELAY_UNAVAILABLE',
17
+ AGGREGATE_UNAVAILABLE: 'PEER_HOST_AGGREGATE_UNAVAILABLE',
18
+ STALE_GENERATION: 'PEER_HOST_STALE_GENERATION',
19
+ };
1
20
  /** 作用域已经失效时统一抛出的错误。 */
2
21
  export class ResourceScopeStaleError extends Error {
3
22
  code = 'RESOURCE_SCOPE_STALE';
@@ -11,7 +11,7 @@ export declare const CODINGNS_DSH_VERSION_GLOBAL: "__CODINGNS_DSH_VERSION__";
11
11
  /** 识别没有 alpha2 Sidebar 扩展 API 的 DSH 旧版运行时。 */
12
12
  export declare function isLegacyDshVersion(version: string): boolean;
13
13
  /** Codingns4DSH 插件自身的 npm 版本。 */
14
- export declare const CODINGNS_VERSION: "0.1.2";
14
+ export declare const CODINGNS_VERSION: "0.1.7-rc.3";
15
15
  /** 判断宿主版本是否落在当前插件声明的 DSH 兼容范围内。 */
16
16
  export declare function isDshVersionCompatible(version: string): boolean;
17
17
  /** 判断 DSH 版本是否达到某个功能模块要求的最低版本。 */
@@ -13,7 +13,7 @@ export function isLegacyDshVersion(version) {
13
13
  return /^0\.1\.5(?:-|$)/u.test(version);
14
14
  }
15
15
  /** Codingns4DSH 插件自身的 npm 版本。 */
16
- export const CODINGNS_VERSION = '0.1.2';
16
+ export const CODINGNS_VERSION = '0.1.7-rc.3';
17
17
  /** 判断宿主版本是否落在当前插件声明的 DSH 兼容范围内。 */
18
18
  export function isDshVersionCompatible(version) {
19
19
  const match = /^>=([^ ]+) <=([^ ]+)$/u.exec(DSH_COMPATIBILITY);
@@ -1,4 +1,4 @@
1
- export { CODINGNS_CONTROL_BASE_URL_FIELD, CODINGNS_CONTROL_BASE_URLS_FIELD, CODINGNS_CONTROL_STATION_URL, CODINGNS_H5_LOGIN_URL, CODINGNS_LAN_ACCESS_DSH_FIELD, CODINGNS_TERMINAL_ENHANCEMENT_FIELD, CODINGNS_WORKSPACE_SESSION_ENHANCEMENT_FIELD, CODINGNS_MODULES_FIELD, CODINGNS_SETTINGS_NAMESPACE, CODINGNS_SETTINGS_ENTRY_IDS, DEFAULT_CODINGNS_CONTROL_BASE_URL, DEFAULT_CODINGNS_CONTROL_BASE_URLS, DEFAULT_CODINGNS_SETTINGS, DEFAULT_QUICK_PHRASES, DEFAULT_TERMINAL_ENHANCEMENT_SETTINGS, DEFAULT_WORKSPACE_SESSION_ENHANCEMENT_SETTINGS, captureRestartFeatureStates, enabledFeatureNames, isFeatureDshVersionCompatible, isFeatureEnabled, isCodingNsSettingsEntryId, type CodingNsSettings, type CodingNsConfig, type CodingNsRuntimeState, type CodingNsCliAdapterPreference, type LanAccessDshSettings, type LanAccessDshLoginSettings, type LoginProtectionScopes, type RestartFeatureStates, type TerminalAppearanceSettings, type TerminalAppearanceTheme, type TerminalBindingScope, type TerminalCursorStyle, type TerminalEnhancementSettings, type TerminalProfileId, type QuickPhrase, type WorkspaceSessionEnhancementSettings, } from './contracts/config.js';
1
+ export { CODINGNS_CONTROL_BASE_URL_FIELD, CODINGNS_CONTROL_BASE_URLS_FIELD, CODINGNS_CONTROL_STATION_URL, CODINGNS_H5_LOGIN_URL, CODINGNS_LAN_ACCESS_DSH_FIELD, CODINGNS_TERMINAL_ENHANCEMENT_FIELD, CODINGNS_WORKSPACE_SESSION_ENHANCEMENT_FIELD, CODINGNS_FILE_MANAGEMENT_FIELD, CODINGNS_MODULES_FIELD, CODINGNS_SETTINGS_NAMESPACE, CODINGNS_SETTINGS_ENTRY_IDS, DEFAULT_CODINGNS_CONTROL_BASE_URL, DEFAULT_CODINGNS_CONTROL_BASE_URLS, DEFAULT_CODINGNS_SETTINGS, DEFAULT_QUICK_PHRASES, DEFAULT_TERMINAL_ENHANCEMENT_SETTINGS, DEFAULT_WORKSPACE_SESSION_ENHANCEMENT_SETTINGS, DEFAULT_FILE_MANAGEMENT_SETTINGS, captureRestartFeatureStates, enabledFeatureNames, isFeatureDshVersionCompatible, isFeatureEnabled, isCodingNsSettingsEntryId, type CodingNsSettings, type CodingNsConfig, type CodingNsRuntimeState, type CodingNsCliAdapterPreference, type LanAccessDshSettings, type LanAccessDshLoginSettings, type LoginProtectionScopes, type RestartFeatureStates, type TerminalAppearanceSettings, type TerminalAppearanceTheme, type TerminalBindingScope, type TerminalCursorStyle, type TerminalEnhancementSettings, type TerminalProfileId, type QuickPhrase, type WorkspaceSessionEnhancementSettings, type FileManagementSettings, } from './contracts/config.js';
2
2
  export type { FeatureContext, FeatureActivation, FeatureDescriptor, FeatureCapabilityRequirement, FeatureDisposer, FeatureModule, FeatureResourceScope, FeatureRuntime, FeatureState, FeatureUiDescriptor, } from './contracts/feature.js';
3
3
  export type { DshCapabilityDiagnostic, DshCapabilityId, DshCapabilityProfile, DshCapabilityResolution, DshCapabilityResolutionStatus, DshCapabilityRoute, DshCapabilityRouteStatus, DshCapabilityRuntime, } from '../dsh-capabilities/types.js';
4
4
  export { CODINGNS_DSH_ERROR_CODES, CodingNsDshError, SUPPORTED_DSH_COMPATIBILITY, SUPPORTED_DSH_VERSION, assertSupportedDshVersion, type CodingNsDshErrorCode, } from './contracts/errors.js';
@@ -9,9 +9,10 @@ export { CODINGNS_RPC_CHANNEL } from './contracts/transport.js';
9
9
  export type { CodingNsCliAdapterDescriptor, CodingNsCliAdapterId, CodingNsCliCapability, CodingNsAgentEvent, CodingNsAgentQuestion, CodingNsAgentQuestionResponse, CodingNsAgentToolEvent, CodingNsCliMessage, CodingNsCliModel, CodingNsCliModelCatalog, CodingNsCliModelGroup, CodingNsAgentPermissionResponse, CodingNsCliSessionConfig, CodingNsCliSessionRecord, CodingNsCliProviderSessionState, CodingNsCliSessionStatus, CodingNsSessionAdapterBinding, CodingNsCliTurnInput, } from './contracts/cli-adapter.js';
10
10
  export type { CommandCodeSubscriptionUsage, CommandCodeSubscriptionWindow, } from './contracts/command-code.js';
11
11
  export type { GitBranchItem, GitBranchSnapshot, GitChangeItem, GitCommitResult, GitDiff, GitHistoryItem, GitHistoryPage, GitHistoryRef, GitRepoSnapshot, GitStatus, } from './contracts/git.js';
12
+ export type { SessionChangedFiles } from './contracts/file-management.js';
12
13
  export type { CliSubscriptionProvider, CliSubscriptionUsage, CliSubscriptionWindow, DeepseekBalance, DeepseekUsage, ProviderBalanceUsage, Sub2ApiDailyUsage, Sub2ApiModelUsage, Sub2ApiUsage, Sub2ApiUsagePoint, } from './contracts/subscription.js';
13
- export type { PeerHostRecord, PeerHostStatus, ResourceScopeDisposer, ResourceScopeInput, ResourceScopeRef, ResourceScopeSnapshot, } from './contracts/peer-host.js';
14
- export { ResourceScopeStaleError } from './contracts/peer-host.js';
14
+ export type { AggregateWorkspaceSummary, AggregateHostResult, HostScope, PeerHostErrorCode, PeerHostErrorShape, PeerHostRoute, PeerHostRecord, PeerHostClientRoute, PeerHostClientRecord, PeerHostSessionRecord, PeerHostWebSocketEndpoint, PeerHostStatus, ResourceScopeDisposer, ResourceScopeInput, ResourceScopeRef, ResourceScopeSnapshot, } from './contracts/peer-host.js';
15
+ export { PEER_HOST_ERROR_CODES, ResourceScopeStaleError } from './contracts/peer-host.js';
15
16
  export { DEBUG_ERROR_CODES, DEBUG_RPC_ENDPOINTS, parseDebugMutationScope, parseDebugPtyLaunchRequest, parseDebugRpcScope, type DebugAiFallbackState, type DebugCompatibilityLevel, type DebugErrorCode, type DebugMutationScope, type DebugPortState, type DebugProcessInstance, type DebugProcessOwnership, type DebugPlanState, type DebugProxyProtocol, type DebugPtyLaunchRequest, type DebugRpcEndpoint, type DebugRpcScope, type DebugRuntimeMode, type DebugRuntimeState, } from './contracts/debug.js';
16
17
  export type { LanAccessDshConfig, LanAccessDshLoginConfig, LanAccessDshSnapshot, LanAccessDshState, } from './contracts/lan-access-dsh.js';
17
18
  export type { CodingNsTerminalCreateRequest, CodingNsTerminalEnvironment, CodingNsTerminalFrame, CodingNsTerminalRetentionFrame, CodingNsTerminalRuntimeType, CodingNsTerminalShell, CodingNsTerminalShellOption, CodingNsTerminalStatus, CodingNsTerminalState, CodingNsWebTerminalInfo, PersistentTerminalRecord, TerminalAttachmentRecord, TerminalOwnerScope, TerminalRecordIdentity, } from './contracts/terminal.js';
@@ -1,9 +1,9 @@
1
- export { CODINGNS_CONTROL_BASE_URL_FIELD, CODINGNS_CONTROL_BASE_URLS_FIELD, CODINGNS_CONTROL_STATION_URL, CODINGNS_H5_LOGIN_URL, CODINGNS_LAN_ACCESS_DSH_FIELD, CODINGNS_TERMINAL_ENHANCEMENT_FIELD, CODINGNS_WORKSPACE_SESSION_ENHANCEMENT_FIELD, CODINGNS_MODULES_FIELD, CODINGNS_SETTINGS_NAMESPACE, CODINGNS_SETTINGS_ENTRY_IDS, DEFAULT_CODINGNS_CONTROL_BASE_URL, DEFAULT_CODINGNS_CONTROL_BASE_URLS, DEFAULT_CODINGNS_SETTINGS, DEFAULT_QUICK_PHRASES, DEFAULT_TERMINAL_ENHANCEMENT_SETTINGS, DEFAULT_WORKSPACE_SESSION_ENHANCEMENT_SETTINGS, captureRestartFeatureStates, enabledFeatureNames, isFeatureDshVersionCompatible, isFeatureEnabled, isCodingNsSettingsEntryId, } from './contracts/config.js';
1
+ export { CODINGNS_CONTROL_BASE_URL_FIELD, CODINGNS_CONTROL_BASE_URLS_FIELD, CODINGNS_CONTROL_STATION_URL, CODINGNS_H5_LOGIN_URL, CODINGNS_LAN_ACCESS_DSH_FIELD, CODINGNS_TERMINAL_ENHANCEMENT_FIELD, CODINGNS_WORKSPACE_SESSION_ENHANCEMENT_FIELD, CODINGNS_FILE_MANAGEMENT_FIELD, CODINGNS_MODULES_FIELD, CODINGNS_SETTINGS_NAMESPACE, CODINGNS_SETTINGS_ENTRY_IDS, DEFAULT_CODINGNS_CONTROL_BASE_URL, DEFAULT_CODINGNS_CONTROL_BASE_URLS, DEFAULT_CODINGNS_SETTINGS, DEFAULT_QUICK_PHRASES, DEFAULT_TERMINAL_ENHANCEMENT_SETTINGS, DEFAULT_WORKSPACE_SESSION_ENHANCEMENT_SETTINGS, DEFAULT_FILE_MANAGEMENT_SETTINGS, captureRestartFeatureStates, enabledFeatureNames, isFeatureDshVersionCompatible, isFeatureEnabled, isCodingNsSettingsEntryId, } from './contracts/config.js';
2
2
  export { CODINGNS_DSH_ERROR_CODES, CodingNsDshError, SUPPORTED_DSH_COMPATIBILITY, SUPPORTED_DSH_VERSION, assertSupportedDshVersion, } from './contracts/errors.js';
3
3
  export { CODINGNS_VERSION, DSH_COMPATIBILITY, DSH_PROTOCOL_VERSION, CODINGNS_DSH_VERSION_GLOBAL, DSH_TESTED_VERSION, DSH_VERSION, isDshVersionAtLeast, isLegacyDshVersion, isDshVersionCompatible, } from './contracts/version.js';
4
4
  export { DSH_ENVELOPE_PROTOCOL, DSH_ENVELOPE_VERSION, DEFAULT_MAX_DSH_ENVELOPE_BYTES, DEFAULT_MAX_DSH_META_BYTES, decodeDshEnvelope, encodeDshEnvelope, validateDshEnvelope, } from '../transport/dsh-envelope.js';
5
5
  export { CODINGNS_RPC_CHANNEL } from './contracts/transport.js';
6
- export { ResourceScopeStaleError } from './contracts/peer-host.js';
6
+ export { PEER_HOST_ERROR_CODES, ResourceScopeStaleError } from './contracts/peer-host.js';
7
7
  export { DEBUG_ERROR_CODES, DEBUG_RPC_ENDPOINTS, parseDebugMutationScope, parseDebugPtyLaunchRequest, parseDebugRpcScope, } from './contracts/debug.js';
8
8
  export { EMPTY_DEBUG_CONFIG, parseDebugConfig, } from './contracts/debug-config.js';
9
9
  export { CODINGNS4DSH_DEBUG_ENV, debugInfo, debugWarn, resolveCodingNsDebugEnabled, } from './debug.js';
@@ -17,6 +17,11 @@ export interface DshTransportDebugOptions {
17
17
  }
18
18
  /** 创建一个可注入测试 sink 的调试 logger。默认开关由当前运行环境决定。 */
19
19
  export declare function createDshTransportDebugLogger(options?: DshTransportDebugOptions): DshTransportDebugLogger;
20
+ /**
21
+ * 调试字段采用正向白名单。Transport 可能同时处理 token、URL、命令和正文,
22
+ * 因此不能依赖调用方自觉脱敏;未知字段和错误正文直接丢弃。
23
+ */
24
+ export declare function sanitizeDshTransportDebugFields(fields: Readonly<Record<string, unknown>>): Readonly<Record<string, unknown>>;
20
25
  /** 解析统一的 Codingns4DSH 调试开关,保留旧隧道变量作为兼容别名。 */
21
26
  export declare function resolveDshTransportDebugEnabled(): boolean;
22
27
  //# sourceMappingURL=debug.d.ts.map
@@ -18,11 +18,33 @@ export function createDshTransportDebugLogger(options = {}) {
18
18
  side,
19
19
  component,
20
20
  event,
21
- ...fields,
21
+ ...sanitizeDshTransportDebugFields(fields),
22
22
  });
23
23
  },
24
24
  };
25
25
  }
26
+ /**
27
+ * 调试字段采用正向白名单。Transport 可能同时处理 token、URL、命令和正文,
28
+ * 因此不能依赖调用方自觉脱敏;未知字段和错误正文直接丢弃。
29
+ */
30
+ export function sanitizeDshTransportDebugFields(fields) {
31
+ const allowed = new Set([
32
+ 'bytes', 'physicalBytes', 'bodyBytes', 'sdpBytes', 'streamId', 'messageId', 'sessionId',
33
+ 'generation', 'previousGeneration', 'hostId', 'expectedHostId', 'hostKind', 'expectedHostKind',
34
+ 'channel', 'channelLabel', 'operation', 'feature', 'type', 'code', 'state', 'role',
35
+ 'streams', 'activeStreams', 'openingStreams', 'maxStreams', 'fragmentId', 'chunkCount',
36
+ 'totalBytes', 'payloadBytes', 'bufferedAmount', 'highWaterMark', 'lowWaterMark', 'dataType',
37
+ 'valueType', 'trafficRemainingBytes',
38
+ ]);
39
+ const result = {};
40
+ for (const [key, value] of Object.entries(fields)) {
41
+ if (!allowed.has(key))
42
+ continue;
43
+ if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean' || value === null)
44
+ result[key] = value;
45
+ }
46
+ return result;
47
+ }
26
48
  /** 解析统一的 Codingns4DSH 调试开关,保留旧隧道变量作为兼容别名。 */
27
49
  export function resolveDshTransportDebugEnabled() {
28
50
  return resolveCodingNsDebugEnabled();
@@ -22,6 +22,7 @@ export declare class DshCodingNsTransport implements CodingNsTransport {
22
22
  private readonly listeners;
23
23
  private readonly multiplexer;
24
24
  private currentCarrier;
25
+ private unsubscribeCarrierClosed;
25
26
  private generation;
26
27
  constructor(options: DshCodingNsTransportOptions);
27
28
  rpc<TResponse = unknown, TPayload = unknown>(request: CodingNsRpcRequest<TPayload>): Promise<TResponse>;
@@ -48,6 +49,7 @@ export declare class DshCodingNsTransport implements CodingNsTransport {
48
49
  /** 物理连接失效时立即结束旧请求和旧 generation。 */
49
50
  invalidateConnection(error?: Error): void;
50
51
  close(): Promise<void>;
52
+ private bindCarrierClosed;
51
53
  /** 给 pre-Cordis 启动胶水使用,不直接安装 DSH Connection。 */
52
54
  asTransportHooks(): CodingNsTransportHooks & {
53
55
  ownsHost?: boolean;
@@ -5,6 +5,7 @@ export class DshCodingNsTransport {
5
5
  listeners = new Set();
6
6
  multiplexer;
7
7
  currentCarrier;
8
+ unsubscribeCarrierClosed;
8
9
  generation;
9
10
  constructor(options) {
10
11
  this.options = options;
@@ -19,6 +20,7 @@ export class DshCodingNsTransport {
19
20
  ...(options.flowControl ? { flowControl: options.flowControl } : {}),
20
21
  ...(options.debug ? { debug: options.debug } : {}),
21
22
  });
23
+ this.bindCarrierClosed(options.carrier);
22
24
  }
23
25
  rpc(request) {
24
26
  return this.multiplexer.request('rpc', request, request.signal);
@@ -80,6 +82,7 @@ export class DshCodingNsTransport {
80
82
  this.multiplexer.replaceCarrier(carrier);
81
83
  this.multiplexer.setSession(session);
82
84
  this.currentCarrier = carrier;
85
+ this.bindCarrierClosed(carrier);
83
86
  this.updateGeneration(generation);
84
87
  }
85
88
  /** 物理连接失效时立即结束旧请求和旧 generation。 */
@@ -92,6 +95,8 @@ export class DshCodingNsTransport {
92
95
  listener(undefined);
93
96
  }
94
97
  close() {
98
+ this.unsubscribeCarrierClosed?.();
99
+ this.unsubscribeCarrierClosed = undefined;
95
100
  this.multiplexer.close();
96
101
  const previous = this.generation;
97
102
  this.generation = undefined;
@@ -100,6 +105,12 @@ export class DshCodingNsTransport {
100
105
  listener(undefined);
101
106
  return this.currentCarrier.close();
102
107
  }
108
+ bindCarrierClosed(carrier) {
109
+ this.unsubscribeCarrierClosed?.();
110
+ this.unsubscribeCarrierClosed = carrier.onClosed?.((reason) => {
111
+ this.invalidateConnection(new Error(reason ?? 'Transport Carrier 已关闭'));
112
+ });
113
+ }
103
114
  /** 给 pre-Cordis 启动胶水使用,不直接安装 DSH Connection。 */
104
115
  asTransportHooks() {
105
116
  // DSH 0.1.6-alpha.2 的 ClientTransportHooks.rpc 是 ClientConnectionRpc
@@ -44,6 +44,8 @@ export interface WebRtcClientConnectorOptions {
44
44
  }): PeerConnectionLike;
45
45
  channelLabel?: string;
46
46
  timeoutMs?: number;
47
+ /** 已保留的兼容参数;disconnected 不再单独触发重连,以 DataChannel/failed/closed 为准。 */
48
+ disconnectedGracePeriodMs?: number;
47
49
  heartbeatIntervalMs?: number;
48
50
  debug?: DshTransportDebugLogger;
49
51
  }
@@ -48,8 +48,9 @@ export async function connectWebRtcClient(options) {
48
48
  const state = peerConnection;
49
49
  const value = state.connectionState ?? state.iceConnectionState;
50
50
  debug.log('webrtc.peer.state', { state: value ?? 'unknown' });
51
- if (value === 'failed' || value === 'disconnected' || value === 'closed')
51
+ if (value === 'failed' || value === 'closed') {
52
52
  notifyClosed(new Error(`PeerConnection ${value}`));
53
+ }
53
54
  };
54
55
  signaling.addEventListener('close', onSignalingClose);
55
56
  signaling.addEventListener('error', onSignalingError);
@@ -27,6 +27,8 @@ export interface WebRtcHostAcceptorOptions {
27
27
  iceServers: RelayIceServer[];
28
28
  iceTransportPolicy: 'all' | 'relay';
29
29
  }): HostPeerConnectionLike;
30
+ /** 已保留的兼容参数;disconnected 不再单独移除 Host session。 */
31
+ disconnectedGracePeriodMs?: number;
30
32
  channelLabel?: string;
31
33
  onConnection?: (connection: WebRtcHostSession) => void | Promise<void>;
32
34
  onSessionClosed?: (sessionId: string) => void | Promise<void>;
@@ -115,7 +115,7 @@ export async function acceptWebRtcHost(options) {
115
115
  session = new HostSessionImpl(sessionId, options.peerConnectionFactory({
116
116
  iceServers: options.signalingTicket.iceServers,
117
117
  iceTransportPolicy: options.signalingTicket.iceTransportPolicy,
118
- }), signaling, options.onConnection, () => { void closeSession(sessionId); }, TUNNEL_DATA_CHANNEL_LABEL, options.debug);
118
+ }), signaling, options.onConnection, () => { void closeSession(sessionId); }, TUNNEL_DATA_CHANNEL_LABEL, options.disconnectedGracePeriodMs, options.debug);
119
119
  sessions.set(sessionId, session);
120
120
  }
121
121
  await session.answerOffer(sdp);
@@ -146,18 +146,20 @@ class HostSessionImpl {
146
146
  signaling;
147
147
  onConnection;
148
148
  onTransportClosed;
149
+ disconnectedGracePeriodMs;
149
150
  debug;
150
151
  _carrier = null;
151
152
  closed = false;
152
153
  offerPromise = null;
153
154
  remoteDescriptionReady = false;
154
155
  pendingCandidates = [];
155
- constructor(sessionId, peerConnection, signaling, onConnection, onTransportClosed, channelLabel, debug) {
156
+ constructor(sessionId, peerConnection, signaling, onConnection, onTransportClosed, channelLabel, disconnectedGracePeriodMs, debug) {
156
157
  this.sessionId = sessionId;
157
158
  this.peerConnection = peerConnection;
158
159
  this.signaling = signaling;
159
160
  this.onConnection = onConnection;
160
161
  this.onTransportClosed = onTransportClosed;
162
+ this.disconnectedGracePeriodMs = disconnectedGracePeriodMs;
161
163
  this.debug = debug;
162
164
  this.peerConnection.addEventListener?.('connectionstatechange', this.onPeerState);
163
165
  this.peerConnection.addEventListener?.('iceconnectionstatechange', this.onPeerState);
@@ -233,8 +235,9 @@ class HostSessionImpl {
233
235
  onPeerState = () => {
234
236
  const state = this.peerConnection;
235
237
  const value = state.connectionState ?? state.iceConnectionState;
236
- if (value === 'failed' || value === 'disconnected' || value === 'closed')
238
+ if (value === 'failed' || value === 'closed') {
237
239
  void this.onTransportClosed();
240
+ }
238
241
  };
239
242
  }
240
243
  function validateHostTicket(ticket) {