@deepseek-harness-tui/dsh-tui 0.9.2 → 0.9.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 (214) hide show
  1. package/README.md +4 -4
  2. package/bin/dsh-tui.js +26 -4
  3. package/dsh-ecosystem-spec/protocols/profile-definitions.d.ts +13 -13
  4. package/dsh-ecosystem-spec/protocols/profile-definitions.js +59 -59
  5. package/dsh-ecosystem-spec/protocols/tui-channel-http.d.ts +15 -15
  6. package/dsh-ecosystem-spec/protocols/tui-channel-http.js +32 -32
  7. package/dsh-ecosystem-spec/protocols/tui-channel.d.ts +59 -59
  8. package/dsh-ecosystem-spec/protocols/tui-channel.js +166 -166
  9. package/dsh-ecosystem-spec/protocols/tui-contributions.d.ts +42 -42
  10. package/dsh-ecosystem-spec/protocols/tui-contributions.js +143 -143
  11. package/dsh-ecosystem-spec/registry/README.md +14 -14
  12. package/dsh-ecosystem-spec/registry/host-descriptor.tui.example.json +56 -56
  13. package/dsh-ecosystem-spec/registry/permissions-0.1.json +13 -13
  14. package/dsh-ecosystem-spec/registry/registry-0.15.json +149 -149
  15. package/lib/types/commands.d.ts.map +1 -1
  16. package/lib/types/commands.js +7 -8
  17. package/lib/types/components/BalanceReportRow.d.ts +24 -0
  18. package/lib/types/components/BalanceReportRow.d.ts.map +1 -0
  19. package/lib/types/components/BalanceReportRow.js +87 -0
  20. package/lib/types/components/HistorySearchDialog.js +1 -1
  21. package/lib/types/components/MessageList.d.ts +3 -1
  22. package/lib/types/components/MessageList.d.ts.map +1 -1
  23. package/lib/types/components/MessageList.js +11 -7
  24. package/lib/types/components/PluginSceneBoundary.d.ts +1 -1
  25. package/lib/types/components/PluginSceneBoundary.js +1 -1
  26. package/lib/types/components/PromptInput.d.ts.map +1 -1
  27. package/lib/types/components/PromptInput.js +16 -0
  28. package/lib/types/components/Whale.d.ts +15 -4
  29. package/lib/types/components/Whale.d.ts.map +1 -1
  30. package/lib/types/components/Whale.js +9 -8
  31. package/lib/types/components/messages/AssistantToolUseMessage.d.ts +7 -1
  32. package/lib/types/components/messages/AssistantToolUseMessage.d.ts.map +1 -1
  33. package/lib/types/components/messages/AssistantToolUseMessage.js +34 -4
  34. package/lib/types/deepseekBalance.d.ts +53 -0
  35. package/lib/types/deepseekBalance.d.ts.map +1 -0
  36. package/lib/types/deepseekBalance.js +86 -0
  37. package/lib/types/deepseekPricing.d.ts +82 -0
  38. package/lib/types/deepseekPricing.d.ts.map +1 -0
  39. package/lib/types/deepseekPricing.js +133 -0
  40. package/lib/types/dsh-adapter/channel.d.ts +46 -1
  41. package/lib/types/dsh-adapter/channel.d.ts.map +1 -1
  42. package/lib/types/dsh-adapter/channel.js +84 -10
  43. package/lib/types/dsh-adapter/index.d.ts +5 -0
  44. package/lib/types/dsh-adapter/index.d.ts.map +1 -1
  45. package/lib/types/dsh-adapter/index.js +1 -0
  46. package/lib/types/dsh-adapter/packaged-skills.d.ts +9 -0
  47. package/lib/types/dsh-adapter/packaged-skills.d.ts.map +1 -1
  48. package/lib/types/dsh-adapter/packaged-skills.js +19 -4
  49. package/lib/types/dsh-adapter/plugin.d.ts +6 -0
  50. package/lib/types/dsh-adapter/plugin.d.ts.map +1 -1
  51. package/lib/types/dsh-adapter/plugin.js +122 -18
  52. package/lib/types/dsh-adapter/settings-sections.d.ts +1 -0
  53. package/lib/types/dsh-adapter/settings-sections.d.ts.map +1 -1
  54. package/lib/types/dsh-adapter/settings-sections.js +35 -2
  55. package/lib/types/history.d.ts +4 -3
  56. package/lib/types/history.d.ts.map +1 -1
  57. package/lib/types/history.js +66 -18
  58. package/lib/types/i18n.d.ts +122 -55
  59. package/lib/types/i18n.d.ts.map +1 -1
  60. package/lib/types/i18n.js +39 -18
  61. package/lib/types/ink/ink.d.ts.map +1 -1
  62. package/lib/types/ink/ink.js +67 -17
  63. package/lib/types/ink/root.d.ts +16 -0
  64. package/lib/types/ink/root.d.ts.map +1 -1
  65. package/lib/types/ink/root.js +2 -0
  66. package/lib/types/ink/terminal-querier.d.ts +8 -0
  67. package/lib/types/ink/terminal-querier.d.ts.map +1 -1
  68. package/lib/types/ink/terminal-querier.js +13 -0
  69. package/lib/types/ink/terminal.d.ts +42 -0
  70. package/lib/types/ink/terminal.d.ts.map +1 -1
  71. package/lib/types/ink/terminal.js +52 -2
  72. package/lib/types/plugin-spec/registry.d.ts +1 -1
  73. package/lib/types/plugin-spec/registry.js +1 -1
  74. package/lib/types/screens/Chat.d.ts.map +1 -1
  75. package/lib/types/screens/Chat.js +72 -37
  76. package/lib/types/screens/SessionBrowser.d.ts.map +1 -1
  77. package/lib/types/screens/SessionBrowser.js +28 -13
  78. package/lib/types/screens/SessionTree.d.ts.map +1 -1
  79. package/lib/types/screens/SessionTree.js +33 -9
  80. package/lib/types/screens/Settings.d.ts +7 -5
  81. package/lib/types/screens/Settings.d.ts.map +1 -1
  82. package/lib/types/screens/Settings.js +206 -99
  83. package/lib/types/screens/StatusLine.d.ts.map +1 -1
  84. package/lib/types/screens/StatusLine.js +32 -1
  85. package/lib/types/sessionHistory.d.ts +11 -0
  86. package/lib/types/sessionHistory.d.ts.map +1 -1
  87. package/lib/types/sessionHistory.js +29 -0
  88. package/lib/types/sessions/format.d.ts.map +1 -1
  89. package/lib/types/sessions/format.js +14 -4
  90. package/lib/types/tips.js +2 -2
  91. package/lib/types/tuiDisplayPrefs.d.ts +3 -0
  92. package/lib/types/tuiDisplayPrefs.d.ts.map +1 -1
  93. package/lib/types/tuiDisplayPrefs.js +1 -0
  94. package/lib/types/update.d.ts +46 -0
  95. package/lib/types/update.d.ts.map +1 -1
  96. package/lib/types/update.js +232 -3
  97. package/node_modules/@deepseek-harness-tui/dsh-auth/LICENSE +21 -21
  98. package/node_modules/@deepseek-harness-tui/dsh-auth/dsh-plugin.json +44 -44
  99. package/node_modules/@dsh-std/command/CHANGELOG.md +8 -8
  100. package/node_modules/@dsh-std/command/LICENSE +21 -21
  101. package/node_modules/@dsh-std/command/README.md +26 -26
  102. package/node_modules/@dsh-std/command/README.zh.md +28 -28
  103. package/node_modules/@dsh-std/command/lib/index.js.map +1 -1
  104. package/node_modules/@dsh-std/command/package.json +22 -22
  105. package/node_modules/@dsh-std/connection/CHANGELOG.md +8 -8
  106. package/node_modules/@dsh-std/connection/LICENSE +21 -21
  107. package/node_modules/@dsh-std/connection/README.md +42 -42
  108. package/node_modules/@dsh-std/connection/README.zh.md +42 -42
  109. package/node_modules/@dsh-std/connection/lib/index.js.map +1 -1
  110. package/node_modules/@dsh-std/connection/lib/memory.js.map +1 -1
  111. package/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js.map +1 -1
  112. package/node_modules/@dsh-std/connection/package.json +20 -20
  113. package/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
  114. package/node_modules/@dsh-std/core/LICENSE +21 -21
  115. package/node_modules/@dsh-std/core/README.md +13 -13
  116. package/node_modules/@dsh-std/core/README.zh.md +13 -13
  117. package/node_modules/@dsh-std/core/lib/index.js.map +1 -1
  118. package/node_modules/@dsh-std/core/package.json +21 -21
  119. package/node_modules/@dsh-std/manifest/CHANGELOG.md +9 -9
  120. package/node_modules/@dsh-std/manifest/LICENSE +21 -21
  121. package/node_modules/@dsh-std/manifest/README.md +5 -5
  122. package/node_modules/@dsh-std/manifest/README.zh.md +5 -5
  123. package/node_modules/@dsh-std/manifest/lib/index.js.map +1 -1
  124. package/node_modules/@dsh-std/manifest/package.json +20 -20
  125. package/node_modules/@dsh-std/manifest/schema/dsh-plugin-0.15.schema.json +144 -144
  126. package/node_modules/@dsh-std/messages/CHANGELOG.md +8 -8
  127. package/node_modules/@dsh-std/messages/LICENSE +21 -21
  128. package/node_modules/@dsh-std/messages/README.md +5 -5
  129. package/node_modules/@dsh-std/messages/README.zh.md +7 -7
  130. package/node_modules/@dsh-std/messages/lib/index.js.map +1 -1
  131. package/node_modules/@dsh-std/messages/package.json +20 -20
  132. package/node_modules/@dsh-std/messages/schema/message-observer-envelope-0.15.schema.json +54 -54
  133. package/node_modules/@dsh-std/presentation/CHANGELOG.md +9 -9
  134. package/node_modules/@dsh-std/presentation/LICENSE +21 -21
  135. package/node_modules/@dsh-std/presentation/README.md +27 -27
  136. package/node_modules/@dsh-std/presentation/README.zh.md +29 -29
  137. package/node_modules/@dsh-std/presentation/lib/callback.js.map +1 -1
  138. package/node_modules/@dsh-std/presentation/lib/index.js.map +1 -1
  139. package/node_modules/@dsh-std/presentation/package.json +25 -25
  140. package/node_modules/@dsh-std/storage/CHANGELOG.md +8 -8
  141. package/node_modules/@dsh-std/storage/LICENSE +21 -21
  142. package/node_modules/@dsh-std/storage/README.md +5 -5
  143. package/node_modules/@dsh-std/storage/README.zh.md +7 -7
  144. package/node_modules/@dsh-std/storage/lib/index.js.map +1 -1
  145. package/node_modules/@dsh-std/storage/package.json +20 -20
  146. package/node_modules/@dsh-std/storage/schema/local-storage-0.15.schema.json +56 -56
  147. package/package.json +95 -5
  148. package/skills/pr-comments/SKILL.md +1 -1
  149. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/CHANGELOG.md +8 -8
  150. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/LICENSE +21 -21
  151. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/README.md +42 -42
  152. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/README.zh.md +42 -42
  153. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/index.js.map +1 -1
  154. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/memory.js.map +1 -1
  155. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js.map +1 -1
  156. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/package.json +20 -20
  157. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
  158. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/LICENSE +21 -21
  159. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/README.md +13 -13
  160. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/README.zh.md +13 -13
  161. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/lib/index.js.map +1 -1
  162. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/package.json +21 -21
  163. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/CHANGELOG.md +9 -9
  164. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/LICENSE +21 -21
  165. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/README.md +5 -5
  166. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/README.zh.md +5 -5
  167. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/lib/index.js.map +1 -1
  168. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/package.json +20 -20
  169. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/schema/dsh-plugin-0.15.schema.json +144 -144
  170. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/CHANGELOG.md +9 -9
  171. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/LICENSE +21 -21
  172. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/README.md +27 -27
  173. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/README.zh.md +29 -29
  174. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/callback.js.map +1 -1
  175. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/index.js.map +1 -1
  176. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/package.json +25 -25
  177. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
  178. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/LICENSE +21 -21
  179. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/README.md +13 -13
  180. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/README.zh.md +13 -13
  181. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/lib/index.js.map +1 -1
  182. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/package.json +21 -21
  183. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
  184. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/LICENSE +21 -21
  185. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/README.md +13 -13
  186. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/README.zh.md +13 -13
  187. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/lib/index.js.map +1 -1
  188. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/package.json +21 -21
  189. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
  190. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/LICENSE +21 -21
  191. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/README.md +13 -13
  192. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/README.zh.md +13 -13
  193. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/lib/index.js.map +1 -1
  194. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/package.json +21 -21
  195. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/CHANGELOG.md +8 -8
  196. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/LICENSE +21 -21
  197. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/README.md +42 -42
  198. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/README.zh.md +42 -42
  199. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/index.js.map +1 -1
  200. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/memory.js.map +1 -1
  201. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js.map +1 -1
  202. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/package.json +20 -20
  203. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
  204. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/LICENSE +21 -21
  205. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/README.md +13 -13
  206. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/README.zh.md +13 -13
  207. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/lib/index.js.map +1 -1
  208. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/package.json +21 -21
  209. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
  210. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/LICENSE +21 -21
  211. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/README.md +13 -13
  212. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/README.zh.md +13 -13
  213. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/lib/index.js.map +1 -1
  214. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/package.json +21 -21
@@ -1,166 +1,166 @@
1
- import { defineCapabilityProtocol } from '@dsh-std/connection'
2
-
3
- export const TUI_CHANNEL = Object.freeze({
4
- apiVersion: 'tui.dsh/v1alpha1',
5
- kind: 'Channel',
6
- })
7
-
8
- export const TUI_CHANNEL_WIRE_REVISION = 6
9
-
10
- export const TUI_CHANNEL_FEATURES = Object.freeze([
11
- 'commands',
12
- 'credentials',
13
- 'diagnostics',
14
- 'files',
15
- 'models',
16
- 'modes',
17
- 'presets',
18
- 'presentation',
19
- 'provider-setup',
20
- 'scenes',
21
- 'session-history',
22
- 'session-input',
23
- 'session-lifecycle',
24
- 'session-state',
25
- 'settings',
26
- 'skills',
27
- 'subagents',
28
- 'trace',
29
- 'workspaces',
30
- ])
31
-
32
- export const tuiChannelDefinition = defineCapabilityProtocol({
33
- ...TUI_CHANNEL,
34
- validateRequirement: validateTuiChannelRequirement,
35
- validateSupport: validateTuiChannelSupport,
36
- })
37
-
38
- export function validateTuiChannelRequirement(value) {
39
- const spec = exactRecord(value, ['wireRevision', 'features'], 'Channel requirement')
40
- const wireRevision = positiveInteger(spec.wireRevision, 'Channel requirement.wireRevision')
41
- const features = featureList(spec.features, 'Channel requirement.features')
42
- return Object.freeze({ wireRevision, features })
43
- }
44
-
45
- export function validateTuiChannelSupport(value) {
46
- const spec = exactRecord(value, ['wireRevision', 'features'], 'Channel support')
47
- const wireRevision = positiveInteger(spec.wireRevision, 'Channel support.wireRevision')
48
- const features = featureList(spec.features, 'Channel support.features')
49
- return Object.freeze({ wireRevision, features })
50
- }
51
-
52
- export function validateTuiChannelInput(operation, value) {
53
- switch (operation) {
54
- case 'open': {
55
- const input = exactRecord(value, ['workspace', 'sessionId', 'options'], 'Channel.open input')
56
- optionalString(input.workspace, 'Channel.open input.workspace')
57
- optionalString(input.sessionId, 'Channel.open input.sessionId')
58
- if (input.options !== undefined) jsonValue(input.options, 'Channel.open input.options', new Set())
59
- return input
60
- }
61
- case 'subscribe': {
62
- const input = exactRecord(value, ['channelId', 'afterVersion'], 'Channel.subscribe input')
63
- nonEmpty(input.channelId, 'Channel.subscribe input.channelId')
64
- nonNegativeInteger(input.afterVersion, 'Channel.subscribe input.afterVersion')
65
- return input
66
- }
67
- case 'invoke': {
68
- const input = exactRecord(value, ['channelId', 'method', 'arguments'], 'Channel.invoke input')
69
- nonEmpty(input.channelId, 'Channel.invoke input.channelId')
70
- nonEmpty(input.method, 'Channel.invoke input.method')
71
- if (!Array.isArray(input.arguments)) throw new TypeError('Channel.invoke input.arguments must be an array')
72
- jsonValue(input.arguments, 'Channel.invoke input.arguments', new Set())
73
- return input
74
- }
75
- case 'close': {
76
- const input = exactRecord(value, ['channelId'], 'Channel.close input')
77
- nonEmpty(input.channelId, 'Channel.close input.channelId')
78
- return input
79
- }
80
- default:
81
- throw new TypeError(`Channel operation ${JSON.stringify(operation)} is not defined`)
82
- }
83
- }
84
-
85
- export function validateTuiChannelSnapshot(value) {
86
- const snapshot = exactRecord(value, ['wireRevision', 'channelId', 'version', 'state'], 'Channel snapshot')
87
- positiveInteger(snapshot.wireRevision, 'Channel snapshot.wireRevision')
88
- nonEmpty(snapshot.channelId, 'Channel snapshot.channelId')
89
- nonNegativeInteger(snapshot.version, 'Channel snapshot.version')
90
- const state = exactRecord(snapshot.state, Object.keys(snapshot.state ?? {}), 'Channel snapshot.state')
91
- jsonValue(state, 'Channel snapshot.state', new Set())
92
- return snapshot
93
- }
94
-
95
- export function validateTuiChannelOutput(operation, value) {
96
- if (operation === 'open' || operation === 'subscribe') return validateTuiChannelSnapshot(value)
97
- if (operation === 'invoke') {
98
- const output = exactRecord(value, ['value', 'valueDefined', 'snapshot'], 'Channel.invoke output')
99
- jsonValue(output.value, 'Channel.invoke output.value', new Set())
100
- if (output.valueDefined !== undefined && typeof output.valueDefined !== 'boolean') {
101
- throw new TypeError('Channel.invoke output.valueDefined must be boolean')
102
- }
103
- if (output.snapshot !== undefined) validateTuiChannelSnapshot(output.snapshot)
104
- return output
105
- }
106
- if (operation === 'close') {
107
- const output = exactRecord(value, ['closed'], 'Channel.close output')
108
- if (output.closed !== true) throw new TypeError('Channel.close output.closed must be true')
109
- return output
110
- }
111
- throw new TypeError(`Channel operation ${JSON.stringify(operation)} is not defined`)
112
- }
113
-
114
- function exactRecord(value, allowed, label) {
115
- if (typeof value !== 'object' || value === null || Array.isArray(value)) throw new TypeError(`${label} must be an object`)
116
- const unknown = Object.keys(value).filter(key => !allowed.includes(key) && !key.startsWith('x-'))
117
- if (unknown.length > 0) throw new TypeError(`${label} contains unknown field ${JSON.stringify(unknown[0])}`)
118
- return value
119
- }
120
-
121
- function featureList(value, label) {
122
- if (!Array.isArray(value) || value.length === 0) throw new TypeError(`${label} must be a non-empty array`)
123
- const features = value.map((feature, index) => {
124
- nonEmpty(feature, `${label}[${index}]`)
125
- return feature
126
- })
127
- if (new Set(features).size !== features.length) throw new TypeError(`${label} contains duplicates`)
128
- return Object.freeze([...features].sort())
129
- }
130
-
131
- function positiveInteger(value, label) {
132
- if (!Number.isSafeInteger(value) || value < 1) throw new TypeError(`${label} must be a positive integer`)
133
- return value
134
- }
135
-
136
- function nonNegativeInteger(value, label) {
137
- if (!Number.isSafeInteger(value) || value < 0) throw new TypeError(`${label} must be a non-negative integer`)
138
- return value
139
- }
140
-
141
- function nonEmpty(value, label) {
142
- if (typeof value !== 'string' || value.trim() === '') throw new TypeError(`${label} must be a non-empty string`)
143
- }
144
-
145
- function optionalString(value, label) {
146
- if (value !== undefined) nonEmpty(value, label)
147
- }
148
-
149
- function jsonValue(value, label, ancestors) {
150
- if (value === null || typeof value === 'boolean' || typeof value === 'string') return
151
- if (typeof value === 'number') {
152
- if (!Number.isFinite(value)) throw new TypeError(`${label} must contain only finite numbers`)
153
- return
154
- }
155
- if (typeof value !== 'object') throw new TypeError(`${label} must be a JSON value`)
156
- if (ancestors.has(value)) throw new TypeError(`${label} must not contain cycles`)
157
- ancestors.add(value)
158
- if (Array.isArray(value)) {
159
- for (const [index, item] of value.entries()) jsonValue(item, `${label}[${index}]`, ancestors)
160
- } else {
161
- const prototype = Object.getPrototypeOf(value)
162
- if (prototype !== Object.prototype && prototype !== null) throw new TypeError(`${label} must contain only plain objects`)
163
- for (const [key, item] of Object.entries(value)) jsonValue(item, `${label}.${key}`, ancestors)
164
- }
165
- ancestors.delete(value)
166
- }
1
+ import { defineCapabilityProtocol } from '@dsh-std/connection'
2
+
3
+ export const TUI_CHANNEL = Object.freeze({
4
+ apiVersion: 'tui.dsh/v1alpha1',
5
+ kind: 'Channel',
6
+ })
7
+
8
+ export const TUI_CHANNEL_WIRE_REVISION = 6
9
+
10
+ export const TUI_CHANNEL_FEATURES = Object.freeze([
11
+ 'commands',
12
+ 'credentials',
13
+ 'diagnostics',
14
+ 'files',
15
+ 'models',
16
+ 'modes',
17
+ 'presets',
18
+ 'presentation',
19
+ 'provider-setup',
20
+ 'scenes',
21
+ 'session-history',
22
+ 'session-input',
23
+ 'session-lifecycle',
24
+ 'session-state',
25
+ 'settings',
26
+ 'skills',
27
+ 'subagents',
28
+ 'trace',
29
+ 'workspaces',
30
+ ])
31
+
32
+ export const tuiChannelDefinition = defineCapabilityProtocol({
33
+ ...TUI_CHANNEL,
34
+ validateRequirement: validateTuiChannelRequirement,
35
+ validateSupport: validateTuiChannelSupport,
36
+ })
37
+
38
+ export function validateTuiChannelRequirement(value) {
39
+ const spec = exactRecord(value, ['wireRevision', 'features'], 'Channel requirement')
40
+ const wireRevision = positiveInteger(spec.wireRevision, 'Channel requirement.wireRevision')
41
+ const features = featureList(spec.features, 'Channel requirement.features')
42
+ return Object.freeze({ wireRevision, features })
43
+ }
44
+
45
+ export function validateTuiChannelSupport(value) {
46
+ const spec = exactRecord(value, ['wireRevision', 'features'], 'Channel support')
47
+ const wireRevision = positiveInteger(spec.wireRevision, 'Channel support.wireRevision')
48
+ const features = featureList(spec.features, 'Channel support.features')
49
+ return Object.freeze({ wireRevision, features })
50
+ }
51
+
52
+ export function validateTuiChannelInput(operation, value) {
53
+ switch (operation) {
54
+ case 'open': {
55
+ const input = exactRecord(value, ['workspace', 'sessionId', 'options'], 'Channel.open input')
56
+ optionalString(input.workspace, 'Channel.open input.workspace')
57
+ optionalString(input.sessionId, 'Channel.open input.sessionId')
58
+ if (input.options !== undefined) jsonValue(input.options, 'Channel.open input.options', new Set())
59
+ return input
60
+ }
61
+ case 'subscribe': {
62
+ const input = exactRecord(value, ['channelId', 'afterVersion'], 'Channel.subscribe input')
63
+ nonEmpty(input.channelId, 'Channel.subscribe input.channelId')
64
+ nonNegativeInteger(input.afterVersion, 'Channel.subscribe input.afterVersion')
65
+ return input
66
+ }
67
+ case 'invoke': {
68
+ const input = exactRecord(value, ['channelId', 'method', 'arguments'], 'Channel.invoke input')
69
+ nonEmpty(input.channelId, 'Channel.invoke input.channelId')
70
+ nonEmpty(input.method, 'Channel.invoke input.method')
71
+ if (!Array.isArray(input.arguments)) throw new TypeError('Channel.invoke input.arguments must be an array')
72
+ jsonValue(input.arguments, 'Channel.invoke input.arguments', new Set())
73
+ return input
74
+ }
75
+ case 'close': {
76
+ const input = exactRecord(value, ['channelId'], 'Channel.close input')
77
+ nonEmpty(input.channelId, 'Channel.close input.channelId')
78
+ return input
79
+ }
80
+ default:
81
+ throw new TypeError(`Channel operation ${JSON.stringify(operation)} is not defined`)
82
+ }
83
+ }
84
+
85
+ export function validateTuiChannelSnapshot(value) {
86
+ const snapshot = exactRecord(value, ['wireRevision', 'channelId', 'version', 'state'], 'Channel snapshot')
87
+ positiveInteger(snapshot.wireRevision, 'Channel snapshot.wireRevision')
88
+ nonEmpty(snapshot.channelId, 'Channel snapshot.channelId')
89
+ nonNegativeInteger(snapshot.version, 'Channel snapshot.version')
90
+ const state = exactRecord(snapshot.state, Object.keys(snapshot.state ?? {}), 'Channel snapshot.state')
91
+ jsonValue(state, 'Channel snapshot.state', new Set())
92
+ return snapshot
93
+ }
94
+
95
+ export function validateTuiChannelOutput(operation, value) {
96
+ if (operation === 'open' || operation === 'subscribe') return validateTuiChannelSnapshot(value)
97
+ if (operation === 'invoke') {
98
+ const output = exactRecord(value, ['value', 'valueDefined', 'snapshot'], 'Channel.invoke output')
99
+ jsonValue(output.value, 'Channel.invoke output.value', new Set())
100
+ if (output.valueDefined !== undefined && typeof output.valueDefined !== 'boolean') {
101
+ throw new TypeError('Channel.invoke output.valueDefined must be boolean')
102
+ }
103
+ if (output.snapshot !== undefined) validateTuiChannelSnapshot(output.snapshot)
104
+ return output
105
+ }
106
+ if (operation === 'close') {
107
+ const output = exactRecord(value, ['closed'], 'Channel.close output')
108
+ if (output.closed !== true) throw new TypeError('Channel.close output.closed must be true')
109
+ return output
110
+ }
111
+ throw new TypeError(`Channel operation ${JSON.stringify(operation)} is not defined`)
112
+ }
113
+
114
+ function exactRecord(value, allowed, label) {
115
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) throw new TypeError(`${label} must be an object`)
116
+ const unknown = Object.keys(value).filter(key => !allowed.includes(key) && !key.startsWith('x-'))
117
+ if (unknown.length > 0) throw new TypeError(`${label} contains unknown field ${JSON.stringify(unknown[0])}`)
118
+ return value
119
+ }
120
+
121
+ function featureList(value, label) {
122
+ if (!Array.isArray(value) || value.length === 0) throw new TypeError(`${label} must be a non-empty array`)
123
+ const features = value.map((feature, index) => {
124
+ nonEmpty(feature, `${label}[${index}]`)
125
+ return feature
126
+ })
127
+ if (new Set(features).size !== features.length) throw new TypeError(`${label} contains duplicates`)
128
+ return Object.freeze([...features].sort())
129
+ }
130
+
131
+ function positiveInteger(value, label) {
132
+ if (!Number.isSafeInteger(value) || value < 1) throw new TypeError(`${label} must be a positive integer`)
133
+ return value
134
+ }
135
+
136
+ function nonNegativeInteger(value, label) {
137
+ if (!Number.isSafeInteger(value) || value < 0) throw new TypeError(`${label} must be a non-negative integer`)
138
+ return value
139
+ }
140
+
141
+ function nonEmpty(value, label) {
142
+ if (typeof value !== 'string' || value.trim() === '') throw new TypeError(`${label} must be a non-empty string`)
143
+ }
144
+
145
+ function optionalString(value, label) {
146
+ if (value !== undefined) nonEmpty(value, label)
147
+ }
148
+
149
+ function jsonValue(value, label, ancestors) {
150
+ if (value === null || typeof value === 'boolean' || typeof value === 'string') return
151
+ if (typeof value === 'number') {
152
+ if (!Number.isFinite(value)) throw new TypeError(`${label} must contain only finite numbers`)
153
+ return
154
+ }
155
+ if (typeof value !== 'object') throw new TypeError(`${label} must be a JSON value`)
156
+ if (ancestors.has(value)) throw new TypeError(`${label} must not contain cycles`)
157
+ ancestors.add(value)
158
+ if (Array.isArray(value)) {
159
+ for (const [index, item] of value.entries()) jsonValue(item, `${label}[${index}]`, ancestors)
160
+ } else {
161
+ const prototype = Object.getPrototypeOf(value)
162
+ if (prototype !== Object.prototype && prototype !== null) throw new TypeError(`${label} must contain only plain objects`)
163
+ for (const [key, item] of Object.entries(value)) jsonValue(item, `${label}.${key}`, ancestors)
164
+ }
165
+ ancestors.delete(value)
166
+ }
@@ -1,42 +1,42 @@
1
- import type { ApiReference } from '@dsh-std/core'
2
- import type { ManifestDefinitionCatalog, ManifestObjectDefinition } from '@dsh-std/manifest'
3
-
4
- export const API_VERSION: 'tui.dsh/v1alpha1'
5
- export const SETTINGS_SECTION: Readonly<ApiReference & { kind: 'SettingsSection' }>
6
- export const SCENE: Readonly<ApiReference & { kind: 'Scene' }>
7
-
8
- export type LocalizedText = Readonly<Record<string, string>>
9
- export type SettingsFieldKind = 'text' | 'number' | 'boolean' | 'select'
10
- export interface SettingsFieldOption { readonly value: string; readonly label: string; readonly titles?: LocalizedText }
11
- export interface SettingsFieldSpec {
12
- readonly path: readonly string[]
13
- readonly label: string
14
- readonly titles?: LocalizedText
15
- readonly hint?: string
16
- readonly hintTitles?: LocalizedText
17
- readonly kind: SettingsFieldKind
18
- readonly options?: readonly SettingsFieldOption[]
19
- readonly placeholder?: string
20
- readonly secretRef?: string
21
- }
22
- export interface SettingsSectionSpec {
23
- readonly namespace: string
24
- readonly title: string
25
- readonly titles?: LocalizedText
26
- readonly fields: readonly SettingsFieldSpec[]
27
- }
28
- export interface SettingsSectionHandler {}
29
-
30
- export interface SceneSpec { readonly title?: string; readonly titles?: LocalizedText }
31
- export interface SceneHandler<Props = unknown, Result = unknown> {
32
- readonly component: (props: Props) => Result
33
- }
34
-
35
- export const settingsSectionExtensionDefinition: ManifestObjectDefinition
36
- export const sceneExtensionDefinition: ManifestObjectDefinition
37
- export const contributionExtensionDefinitions: readonly ManifestObjectDefinition[]
38
- export function validateSettingsSectionSpec(value: unknown): Readonly<SettingsSectionSpec>
39
- export function validateSceneSpec(value: unknown): Readonly<SceneSpec>
40
- export function registerTuiContributionExtensions(catalog: ManifestDefinitionCatalog): () => void
41
- export function assertSettingsSectionHandler(value: unknown): asserts value is SettingsSectionHandler
42
- export function assertSceneHandler(value: unknown): asserts value is SceneHandler
1
+ import type { ApiReference } from '@dsh-std/core'
2
+ import type { ManifestDefinitionCatalog, ManifestObjectDefinition } from '@dsh-std/manifest'
3
+
4
+ export const API_VERSION: 'tui.dsh/v1alpha1'
5
+ export const SETTINGS_SECTION: Readonly<ApiReference & { kind: 'SettingsSection' }>
6
+ export const SCENE: Readonly<ApiReference & { kind: 'Scene' }>
7
+
8
+ export type LocalizedText = Readonly<Record<string, string>>
9
+ export type SettingsFieldKind = 'text' | 'number' | 'boolean' | 'select'
10
+ export interface SettingsFieldOption { readonly value: string; readonly label: string; readonly titles?: LocalizedText }
11
+ export interface SettingsFieldSpec {
12
+ readonly path: readonly string[]
13
+ readonly label: string
14
+ readonly titles?: LocalizedText
15
+ readonly hint?: string
16
+ readonly hintTitles?: LocalizedText
17
+ readonly kind: SettingsFieldKind
18
+ readonly options?: readonly SettingsFieldOption[]
19
+ readonly placeholder?: string
20
+ readonly secretRef?: string
21
+ }
22
+ export interface SettingsSectionSpec {
23
+ readonly namespace: string
24
+ readonly title: string
25
+ readonly titles?: LocalizedText
26
+ readonly fields: readonly SettingsFieldSpec[]
27
+ }
28
+ export interface SettingsSectionHandler {}
29
+
30
+ export interface SceneSpec { readonly title?: string; readonly titles?: LocalizedText }
31
+ export interface SceneHandler<Props = unknown, Result = unknown> {
32
+ readonly component: (props: Props) => Result
33
+ }
34
+
35
+ export const settingsSectionExtensionDefinition: ManifestObjectDefinition
36
+ export const sceneExtensionDefinition: ManifestObjectDefinition
37
+ export const contributionExtensionDefinitions: readonly ManifestObjectDefinition[]
38
+ export function validateSettingsSectionSpec(value: unknown): Readonly<SettingsSectionSpec>
39
+ export function validateSceneSpec(value: unknown): Readonly<SceneSpec>
40
+ export function registerTuiContributionExtensions(catalog: ManifestDefinitionCatalog): () => void
41
+ export function assertSettingsSectionHandler(value: unknown): asserts value is SettingsSectionHandler
42
+ export function assertSceneHandler(value: unknown): asserts value is SceneHandler