@deepseek-harness-tui/dsh-tui 0.9.1 → 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.
- package/README.md +14 -4
- package/bin/dsh-tui.js +26 -4
- package/dsh-ecosystem-spec/protocols/profile-definitions.d.ts +13 -13
- package/dsh-ecosystem-spec/protocols/profile-definitions.js +59 -59
- package/dsh-ecosystem-spec/protocols/tui-channel-http.d.ts +15 -15
- package/dsh-ecosystem-spec/protocols/tui-channel-http.js +32 -32
- package/dsh-ecosystem-spec/protocols/tui-channel.d.ts +59 -59
- package/dsh-ecosystem-spec/protocols/tui-channel.js +166 -166
- package/dsh-ecosystem-spec/protocols/tui-contributions.d.ts +42 -42
- package/dsh-ecosystem-spec/protocols/tui-contributions.js +143 -143
- package/dsh-ecosystem-spec/registry/README.md +14 -14
- package/dsh-ecosystem-spec/registry/host-descriptor.tui.example.json +56 -56
- package/dsh-ecosystem-spec/registry/permissions-0.1.json +13 -13
- package/dsh-ecosystem-spec/registry/registry-0.15.json +149 -149
- package/lib/types/commands.d.ts.map +1 -1
- package/lib/types/commands.js +7 -8
- package/lib/types/components/BalanceReportRow.d.ts +24 -0
- package/lib/types/components/BalanceReportRow.d.ts.map +1 -0
- package/lib/types/components/BalanceReportRow.js +87 -0
- package/lib/types/components/HistorySearchDialog.js +1 -1
- package/lib/types/components/MessageList.d.ts +3 -1
- package/lib/types/components/MessageList.d.ts.map +1 -1
- package/lib/types/components/MessageList.js +11 -7
- package/lib/types/components/PluginSceneBoundary.d.ts +1 -1
- package/lib/types/components/PluginSceneBoundary.js +1 -1
- package/lib/types/components/PromptInput.d.ts.map +1 -1
- package/lib/types/components/PromptInput.js +16 -0
- package/lib/types/components/Whale.d.ts +15 -4
- package/lib/types/components/Whale.d.ts.map +1 -1
- package/lib/types/components/Whale.js +9 -8
- package/lib/types/components/messages/AssistantToolUseMessage.d.ts +7 -1
- package/lib/types/components/messages/AssistantToolUseMessage.d.ts.map +1 -1
- package/lib/types/components/messages/AssistantToolUseMessage.js +34 -4
- package/lib/types/deepseekBalance.d.ts +53 -0
- package/lib/types/deepseekBalance.d.ts.map +1 -0
- package/lib/types/deepseekBalance.js +86 -0
- package/lib/types/deepseekPricing.d.ts +82 -0
- package/lib/types/deepseekPricing.d.ts.map +1 -0
- package/lib/types/deepseekPricing.js +133 -0
- package/lib/types/dsh-adapter/channel.d.ts +46 -1
- package/lib/types/dsh-adapter/channel.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel.js +84 -10
- package/lib/types/dsh-adapter/index.d.ts +5 -0
- package/lib/types/dsh-adapter/index.d.ts.map +1 -1
- package/lib/types/dsh-adapter/index.js +1 -0
- package/lib/types/dsh-adapter/packaged-skills.d.ts +9 -0
- package/lib/types/dsh-adapter/packaged-skills.d.ts.map +1 -1
- package/lib/types/dsh-adapter/packaged-skills.js +19 -4
- package/lib/types/dsh-adapter/plugin.d.ts +6 -0
- package/lib/types/dsh-adapter/plugin.d.ts.map +1 -1
- package/lib/types/dsh-adapter/plugin.js +122 -18
- package/lib/types/dsh-adapter/settings-sections.d.ts +1 -0
- package/lib/types/dsh-adapter/settings-sections.d.ts.map +1 -1
- package/lib/types/dsh-adapter/settings-sections.js +35 -2
- package/lib/types/history.d.ts +4 -3
- package/lib/types/history.d.ts.map +1 -1
- package/lib/types/history.js +66 -18
- package/lib/types/i18n.d.ts +122 -55
- package/lib/types/i18n.d.ts.map +1 -1
- package/lib/types/i18n.js +39 -18
- package/lib/types/ink/ink.d.ts.map +1 -1
- package/lib/types/ink/ink.js +67 -17
- package/lib/types/ink/root.d.ts +16 -0
- package/lib/types/ink/root.d.ts.map +1 -1
- package/lib/types/ink/root.js +2 -0
- package/lib/types/ink/terminal-querier.d.ts +8 -0
- package/lib/types/ink/terminal-querier.d.ts.map +1 -1
- package/lib/types/ink/terminal-querier.js +13 -0
- package/lib/types/ink/terminal.d.ts +42 -0
- package/lib/types/ink/terminal.d.ts.map +1 -1
- package/lib/types/ink/terminal.js +52 -2
- package/lib/types/plugin-spec/registry.d.ts +1 -1
- package/lib/types/plugin-spec/registry.js +1 -1
- package/lib/types/screens/Chat.d.ts.map +1 -1
- package/lib/types/screens/Chat.js +72 -37
- package/lib/types/screens/SessionBrowser.d.ts.map +1 -1
- package/lib/types/screens/SessionBrowser.js +28 -13
- package/lib/types/screens/SessionTree.d.ts.map +1 -1
- package/lib/types/screens/SessionTree.js +33 -9
- package/lib/types/screens/Settings.d.ts +7 -5
- package/lib/types/screens/Settings.d.ts.map +1 -1
- package/lib/types/screens/Settings.js +206 -99
- package/lib/types/screens/StatusLine.d.ts.map +1 -1
- package/lib/types/screens/StatusLine.js +32 -1
- package/lib/types/sessionHistory.d.ts +11 -0
- package/lib/types/sessionHistory.d.ts.map +1 -1
- package/lib/types/sessionHistory.js +29 -0
- package/lib/types/sessions/format.d.ts.map +1 -1
- package/lib/types/sessions/format.js +14 -4
- package/lib/types/tips.js +2 -2
- package/lib/types/tuiDisplayPrefs.d.ts +3 -0
- package/lib/types/tuiDisplayPrefs.d.ts.map +1 -1
- package/lib/types/tuiDisplayPrefs.js +1 -0
- package/lib/types/update.d.ts +66 -0
- package/lib/types/update.d.ts.map +1 -1
- package/lib/types/update.js +346 -3
- package/node_modules/@deepseek-harness-tui/dsh-auth/LICENSE +21 -21
- package/node_modules/@deepseek-harness-tui/dsh-auth/dsh-plugin.json +44 -44
- package/node_modules/@dsh-std/command/CHANGELOG.md +8 -8
- package/node_modules/@dsh-std/command/LICENSE +21 -21
- package/node_modules/@dsh-std/command/README.md +26 -26
- package/node_modules/@dsh-std/command/README.zh.md +28 -28
- package/node_modules/@dsh-std/command/lib/index.js.map +1 -1
- package/node_modules/@dsh-std/command/package.json +22 -22
- package/node_modules/@dsh-std/connection/CHANGELOG.md +8 -8
- package/node_modules/@dsh-std/connection/LICENSE +21 -21
- package/node_modules/@dsh-std/connection/README.md +42 -42
- package/node_modules/@dsh-std/connection/README.zh.md +42 -42
- package/node_modules/@dsh-std/connection/lib/index.js.map +1 -1
- package/node_modules/@dsh-std/connection/lib/memory.js.map +1 -1
- package/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js.map +1 -1
- package/node_modules/@dsh-std/connection/package.json +20 -20
- package/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
- package/node_modules/@dsh-std/core/LICENSE +21 -21
- package/node_modules/@dsh-std/core/README.md +13 -13
- package/node_modules/@dsh-std/core/README.zh.md +13 -13
- package/node_modules/@dsh-std/core/lib/index.js.map +1 -1
- package/node_modules/@dsh-std/core/package.json +21 -21
- package/node_modules/@dsh-std/manifest/CHANGELOG.md +9 -9
- package/node_modules/@dsh-std/manifest/LICENSE +21 -21
- package/node_modules/@dsh-std/manifest/README.md +5 -5
- package/node_modules/@dsh-std/manifest/README.zh.md +5 -5
- package/node_modules/@dsh-std/manifest/lib/index.js.map +1 -1
- package/node_modules/@dsh-std/manifest/package.json +20 -20
- package/node_modules/@dsh-std/manifest/schema/dsh-plugin-0.15.schema.json +144 -144
- package/node_modules/@dsh-std/messages/CHANGELOG.md +8 -8
- package/node_modules/@dsh-std/messages/LICENSE +21 -21
- package/node_modules/@dsh-std/messages/README.md +5 -5
- package/node_modules/@dsh-std/messages/README.zh.md +7 -7
- package/node_modules/@dsh-std/messages/lib/index.js.map +1 -1
- package/node_modules/@dsh-std/messages/package.json +20 -20
- package/node_modules/@dsh-std/messages/schema/message-observer-envelope-0.15.schema.json +54 -54
- package/node_modules/@dsh-std/presentation/CHANGELOG.md +9 -9
- package/node_modules/@dsh-std/presentation/LICENSE +21 -21
- package/node_modules/@dsh-std/presentation/README.md +27 -27
- package/node_modules/@dsh-std/presentation/README.zh.md +29 -29
- package/node_modules/@dsh-std/presentation/lib/callback.js.map +1 -1
- package/node_modules/@dsh-std/presentation/lib/index.js.map +1 -1
- package/node_modules/@dsh-std/presentation/package.json +25 -25
- package/node_modules/@dsh-std/storage/CHANGELOG.md +8 -8
- package/node_modules/@dsh-std/storage/LICENSE +21 -21
- package/node_modules/@dsh-std/storage/README.md +5 -5
- package/node_modules/@dsh-std/storage/README.zh.md +7 -7
- package/node_modules/@dsh-std/storage/lib/index.js.map +1 -1
- package/node_modules/@dsh-std/storage/package.json +20 -20
- package/node_modules/@dsh-std/storage/schema/local-storage-0.15.schema.json +56 -56
- package/package.json +95 -5
- package/skills/pr-comments/SKILL.md +1 -1
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/CHANGELOG.md +8 -8
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/LICENSE +21 -21
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/README.md +42 -42
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/README.zh.md +42 -42
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/index.js.map +1 -1
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/memory.js.map +1 -1
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js.map +1 -1
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/package.json +20 -20
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/LICENSE +21 -21
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/README.md +13 -13
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/README.zh.md +13 -13
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/lib/index.js.map +1 -1
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/package.json +21 -21
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/CHANGELOG.md +9 -9
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/LICENSE +21 -21
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/README.md +5 -5
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/README.zh.md +5 -5
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/lib/index.js.map +1 -1
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/package.json +20 -20
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/schema/dsh-plugin-0.15.schema.json +144 -144
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/CHANGELOG.md +9 -9
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/LICENSE +21 -21
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/README.md +27 -27
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/README.zh.md +29 -29
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/callback.js.map +1 -1
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/index.js.map +1 -1
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/package.json +25 -25
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/LICENSE +21 -21
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/README.md +13 -13
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/README.zh.md +13 -13
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/lib/index.js.map +1 -1
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/package.json +21 -21
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/LICENSE +21 -21
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/README.md +13 -13
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/README.zh.md +13 -13
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/lib/index.js.map +1 -1
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/package.json +21 -21
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/LICENSE +21 -21
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/README.md +13 -13
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/README.zh.md +13 -13
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/lib/index.js.map +1 -1
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/package.json +21 -21
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/CHANGELOG.md +8 -8
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/LICENSE +21 -21
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/README.md +42 -42
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/README.zh.md +42 -42
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/index.js.map +1 -1
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/memory.js.map +1 -1
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js.map +1 -1
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/package.json +20 -20
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/LICENSE +21 -21
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/README.md +13 -13
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/README.zh.md +13 -13
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/lib/index.js.map +1 -1
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/package.json +21 -21
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/LICENSE +21 -21
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/README.md +13 -13
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/README.zh.md +13 -13
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/lib/index.js.map +1 -1
- 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
|