@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.
- package/README.md +4 -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 +46 -0
- package/lib/types/update.d.ts.map +1 -1
- package/lib/types/update.js +232 -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,44 +1,44 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://dsh.community/schemas/dsh-plugin-0.15.json",
|
|
3
|
-
"id": "com.dsh-tui.dsh-auth",
|
|
4
|
-
"name": "dsh-auth",
|
|
5
|
-
"version": "0.1.0",
|
|
6
|
-
"manifestVersion": "0.15",
|
|
7
|
-
"description": "Subscription OAuth sign-in (ChatGPT/Codex, Claude Pro/Max, SuperGrok) as LLM provider routes for DeepSeek Harness. Registers llm adapter routes through the cordis llm registry; interactive login runs over the user-questions seam and degrades to a clear refusal when no interactive surface is present.",
|
|
8
|
-
"facets": {
|
|
9
|
-
"host": {
|
|
10
|
-
"entry": "lib/index.js",
|
|
11
|
-
"apiVersion": "v1alpha1"
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
"requires": {
|
|
15
|
-
"contracts": [
|
|
16
|
-
{
|
|
17
|
-
"apiVersion": "commands.dsh/v1alpha1",
|
|
18
|
-
"kind": "Command"
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"apiVersion": "user-questions.dsh/v1alpha1",
|
|
22
|
-
"kind": "UserQuestions",
|
|
23
|
-
"optional": true,
|
|
24
|
-
"fallback": "login refuses with guidance instead of assuming a browser or GUI is present (TUI-RUN-001)"
|
|
25
|
-
}
|
|
26
|
-
]
|
|
27
|
-
},
|
|
28
|
-
"contributes": {
|
|
29
|
-
"commands": [
|
|
30
|
-
{
|
|
31
|
-
"id": "dsh.auth",
|
|
32
|
-
"title": "Sign in with a provider subscription (OAuth)"
|
|
33
|
-
}
|
|
34
|
-
]
|
|
35
|
-
},
|
|
36
|
-
"permissions": [
|
|
37
|
-
{
|
|
38
|
-
"name": "commands.invoke",
|
|
39
|
-
"scope": "dsh.auth",
|
|
40
|
-
"reason": "run /auth status|login|logout from any composed command surface"
|
|
41
|
-
}
|
|
42
|
-
],
|
|
43
|
-
"license": "MIT"
|
|
44
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://dsh.community/schemas/dsh-plugin-0.15.json",
|
|
3
|
+
"id": "com.dsh-tui.dsh-auth",
|
|
4
|
+
"name": "dsh-auth",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"manifestVersion": "0.15",
|
|
7
|
+
"description": "Subscription OAuth sign-in (ChatGPT/Codex, Claude Pro/Max, SuperGrok) as LLM provider routes for DeepSeek Harness. Registers llm adapter routes through the cordis llm registry; interactive login runs over the user-questions seam and degrades to a clear refusal when no interactive surface is present.",
|
|
8
|
+
"facets": {
|
|
9
|
+
"host": {
|
|
10
|
+
"entry": "lib/index.js",
|
|
11
|
+
"apiVersion": "v1alpha1"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"requires": {
|
|
15
|
+
"contracts": [
|
|
16
|
+
{
|
|
17
|
+
"apiVersion": "commands.dsh/v1alpha1",
|
|
18
|
+
"kind": "Command"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"apiVersion": "user-questions.dsh/v1alpha1",
|
|
22
|
+
"kind": "UserQuestions",
|
|
23
|
+
"optional": true,
|
|
24
|
+
"fallback": "login refuses with guidance instead of assuming a browser or GUI is present (TUI-RUN-001)"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
"contributes": {
|
|
29
|
+
"commands": [
|
|
30
|
+
{
|
|
31
|
+
"id": "dsh.auth",
|
|
32
|
+
"title": "Sign in with a provider subscription (OAuth)"
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
},
|
|
36
|
+
"permissions": [
|
|
37
|
+
{
|
|
38
|
+
"name": "commands.invoke",
|
|
39
|
+
"scope": "dsh.auth",
|
|
40
|
+
"reason": "run /auth status|login|logout from any composed command surface"
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
"license": "MIT"
|
|
44
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
Changes to `@dsh-std/command` are recorded here.
|
|
4
|
-
|
|
5
|
-
## 0.1.0 (draft)
|
|
6
|
-
|
|
7
|
-
- Defined portable command trees, arguments, options, catalogs, and invocation.
|
|
8
|
-
- Added owner-aware command resource and runtime capability definitions.
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
Changes to `@dsh-std/command` are recorded here.
|
|
4
|
+
|
|
5
|
+
## 0.1.0 (draft)
|
|
6
|
+
|
|
7
|
+
- Defined portable command trees, arguments, options, catalogs, and invocation.
|
|
8
|
+
- Added owner-aware command resource and runtime capability definitions.
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 DSH Standard contributors
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 DSH Standard contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
# @dsh-std/command
|
|
2
|
-
|
|
3
|
-
English | [中文](README.zh.md)
|
|
4
|
-
|
|
5
|
-
Named human-command resources and their shared callable Runtime dispatcher.
|
|
6
|
-
|
|
7
|
-
## Contract
|
|
8
|
-
|
|
9
|
-
A `Command` resource describes one root command and its nested subcommands. Nodes provide a title, localized titles, description, aliases, positional arguments, options, and child nodes. Arguments may be required, variadic, or restricted to documented values. Options declare every literal spelling and may accept one value.
|
|
10
|
-
|
|
11
|
-
`CommandRuntime` defines the generic `catalog` and `execute` operations once for every command extension. A runtime adapter joins extensions published by active facets with its authoritative command registry and implements that capability. The execution context id remains opaque to the standard; a DSH adapter maps it to a session. Results contain only the command outcome. Invocation-scoped UI work uses typed clients from `@dsh-std/presentation`.
|
|
12
|
-
|
|
13
|
-
`commandRuntime()` wraps a consumer-scoped `CapabilityClient` with typed methods, and `commandRuntimeImplementation()` builds the operation dispatcher for an adapter. Consumers and adapters do not repeat operation strings or payload validation.
|
|
14
|
-
|
|
15
|
-
Presentation clients can build completion trees and forms without importing the owning component. A component such as dsh-codex declares `Command/codex`; its selected facet publishes the handler in its local runtime and never defines a connection-specific method.
|
|
16
|
-
|
|
17
|
-
Names and aliases are single tokens. Sibling names and aliases, argument names, option spellings, and enumerated values must be unique. A variadic argument must be last.
|
|
18
|
-
|
|
19
|
-
## Extension points
|
|
20
|
-
|
|
21
|
-
Fields prefixed with `x-` may carry experimental metadata. Portable clients ignore extensions they do not understand. Incompatible command semantics require a new contract major version rather than redefining an existing field.
|
|
22
|
-
|
|
23
|
-
## Known Limitations and Deferred Work
|
|
24
|
-
|
|
25
|
-
- The contract does not define a command-line parser or quoting rules.
|
|
26
|
-
- Dynamic completion is not part of `v1alpha1`; declared values are static.
|
|
1
|
+
# @dsh-std/command
|
|
2
|
+
|
|
3
|
+
English | [中文](README.zh.md)
|
|
4
|
+
|
|
5
|
+
Named human-command resources and their shared callable Runtime dispatcher.
|
|
6
|
+
|
|
7
|
+
## Contract
|
|
8
|
+
|
|
9
|
+
A `Command` resource describes one root command and its nested subcommands. Nodes provide a title, localized titles, description, aliases, positional arguments, options, and child nodes. Arguments may be required, variadic, or restricted to documented values. Options declare every literal spelling and may accept one value.
|
|
10
|
+
|
|
11
|
+
`CommandRuntime` defines the generic `catalog` and `execute` operations once for every command extension. A runtime adapter joins extensions published by active facets with its authoritative command registry and implements that capability. The execution context id remains opaque to the standard; a DSH adapter maps it to a session. Results contain only the command outcome. Invocation-scoped UI work uses typed clients from `@dsh-std/presentation`.
|
|
12
|
+
|
|
13
|
+
`commandRuntime()` wraps a consumer-scoped `CapabilityClient` with typed methods, and `commandRuntimeImplementation()` builds the operation dispatcher for an adapter. Consumers and adapters do not repeat operation strings or payload validation.
|
|
14
|
+
|
|
15
|
+
Presentation clients can build completion trees and forms without importing the owning component. A component such as dsh-codex declares `Command/codex`; its selected facet publishes the handler in its local runtime and never defines a connection-specific method.
|
|
16
|
+
|
|
17
|
+
Names and aliases are single tokens. Sibling names and aliases, argument names, option spellings, and enumerated values must be unique. A variadic argument must be last.
|
|
18
|
+
|
|
19
|
+
## Extension points
|
|
20
|
+
|
|
21
|
+
Fields prefixed with `x-` may carry experimental metadata. Portable clients ignore extensions they do not understand. Incompatible command semantics require a new contract major version rather than redefining an existing field.
|
|
22
|
+
|
|
23
|
+
## Known Limitations and Deferred Work
|
|
24
|
+
|
|
25
|
+
- The contract does not define a command-line parser or quoting rules.
|
|
26
|
+
- Dynamic completion is not part of `v1alpha1`; declared values are static.
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
# @dsh-std/command
|
|
2
|
-
|
|
3
|
-
[English](README.md) | 中文
|
|
4
|
-
|
|
5
|
-
拟议设计见 [Command Resources and Runtime](../../docs/proposals/command.zh.md)。
|
|
6
|
-
|
|
7
|
-
具名用户命令资源及其共享的可调用 Runtime 分派器。
|
|
8
|
-
|
|
9
|
-
## 协议
|
|
10
|
-
|
|
11
|
-
一项 `Command` 资源描述一个根命令及其嵌套子命令。节点可以提供标题、本地化标题、说明、别名、位置参数、选项和子节点。参数可以是必需、可变长或受已声明值限制;选项声明全部字面拼写,并可接收一个值。
|
|
12
|
-
|
|
13
|
-
`CommandRuntime` 为全部命令 extension 统一定义 `catalog` 与 `execute` 操作。运行时适配器把 active facets 发布的 extension 与自身权威命令注册表关联,并实现该能力。执行上下文 id 对标准保持不透明;DSH 适配器将其映射为会话。结果只包含命令结果;调用作用域内的 UI 操作使用 `@dsh-std/presentation` 的类型化 client。
|
|
14
|
-
|
|
15
|
-
`commandRuntime()` 用类型化方法包装按消费方隔离的 `CapabilityClient`,`commandRuntimeImplementation()` 为适配器创建操作分派器。消费方与适配器都无需重复操作字符串或载荷校验。
|
|
16
|
-
|
|
17
|
-
表现客户端无需导入所属 component,即可构建补全树和表单。dsh-codex 之类的 component 声明 `Command/codex`,由选中的 facet 在本地运行时发布 handler;它不定义 connection 专用方法。
|
|
18
|
-
|
|
19
|
-
名称与别名必须是单个 token。同级名称与别名、参数名、选项拼写和枚举值必须唯一。可变长参数必须位于末尾。
|
|
20
|
-
|
|
21
|
-
## 扩展点
|
|
22
|
-
|
|
23
|
-
以 `x-` 开头的字段可以承载实验性元数据。可移植客户端忽略无法理解的扩展。不兼容的命令语义需要新的协议主版本,不能重新定义现有字段。
|
|
24
|
-
|
|
25
|
-
## 已知限制与暂缓事项
|
|
26
|
-
|
|
27
|
-
- 协议不定义命令行解析器或引号规则。
|
|
28
|
-
- `v1alpha1` 不包含动态补全;已声明值是静态的。
|
|
1
|
+
# @dsh-std/command
|
|
2
|
+
|
|
3
|
+
[English](README.md) | 中文
|
|
4
|
+
|
|
5
|
+
拟议设计见 [Command Resources and Runtime](../../docs/proposals/command.zh.md)。
|
|
6
|
+
|
|
7
|
+
具名用户命令资源及其共享的可调用 Runtime 分派器。
|
|
8
|
+
|
|
9
|
+
## 协议
|
|
10
|
+
|
|
11
|
+
一项 `Command` 资源描述一个根命令及其嵌套子命令。节点可以提供标题、本地化标题、说明、别名、位置参数、选项和子节点。参数可以是必需、可变长或受已声明值限制;选项声明全部字面拼写,并可接收一个值。
|
|
12
|
+
|
|
13
|
+
`CommandRuntime` 为全部命令 extension 统一定义 `catalog` 与 `execute` 操作。运行时适配器把 active facets 发布的 extension 与自身权威命令注册表关联,并实现该能力。执行上下文 id 对标准保持不透明;DSH 适配器将其映射为会话。结果只包含命令结果;调用作用域内的 UI 操作使用 `@dsh-std/presentation` 的类型化 client。
|
|
14
|
+
|
|
15
|
+
`commandRuntime()` 用类型化方法包装按消费方隔离的 `CapabilityClient`,`commandRuntimeImplementation()` 为适配器创建操作分派器。消费方与适配器都无需重复操作字符串或载荷校验。
|
|
16
|
+
|
|
17
|
+
表现客户端无需导入所属 component,即可构建补全树和表单。dsh-codex 之类的 component 声明 `Command/codex`,由选中的 facet 在本地运行时发布 handler;它不定义 connection 专用方法。
|
|
18
|
+
|
|
19
|
+
名称与别名必须是单个 token。同级名称与别名、参数名、选项拼写和枚举值必须唯一。可变长参数必须位于末尾。
|
|
20
|
+
|
|
21
|
+
## 扩展点
|
|
22
|
+
|
|
23
|
+
以 `x-` 开头的字段可以承载实验性元数据。可移植客户端忽略无法理解的扩展。不兼容的命令语义需要新的协议主版本,不能重新定义现有字段。
|
|
24
|
+
|
|
25
|
+
## 已知限制与暂缓事项
|
|
26
|
+
|
|
27
|
+
- 协议不定义命令行解析器或引号规则。
|
|
28
|
+
- `v1alpha1` 不包含动态补全;已声明值是静态的。
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type {\r\n ProtocolCatalog,\r\n ProtocolDefinition,\r\n ProtocolIssue,\r\n ProtocolSupport,\r\n} from '@dsh-std/core'\r\nimport type { ManifestDefinitionCatalog, ManifestExtension } from '@dsh-std/manifest'\r\nimport type {\r\n CapabilityCall,\r\n CapabilityClient,\r\n CapabilityHandlerContext,\r\n CapabilityImplementation,\r\n} from '@dsh-std/connection'\r\nimport { defineCapabilityProtocol } from '@dsh-std/connection'\r\nimport {\r\n validatePresentationDescriptor,\r\n type PresentationClients,\r\n type PresentationDescriptor,\r\n} from '@dsh-std/presentation'\r\n\r\nexport const API_VERSION = 'commands.dsh/v1alpha1'\r\nexport const KIND = 'Command'\r\nexport const RUNTIME_KIND = 'CommandRuntime'\r\n\r\n/** Stable reference to one declared command path. */\r\nexport interface CommandReference {\r\n readonly name: string\r\n readonly path?: readonly string[]\r\n}\r\n\r\nexport interface CommandValueSpec {\r\n readonly value: string\r\n readonly title?: string\r\n readonly titles?: Readonly<Record<string, string>>\r\n}\r\n\r\nexport interface CommandArgumentSpec {\r\n readonly name: string\r\n readonly title?: string\r\n readonly titles?: Readonly<Record<string, string>>\r\n readonly required?: boolean\r\n readonly variadic?: boolean\r\n readonly values?: readonly CommandValueSpec[]\r\n}\r\n\r\nexport interface CommandOptionSpec {\r\n /** Literal spellings such as `--verbose` and `-v`. */\r\n readonly names: readonly string[]\r\n readonly title: string\r\n readonly titles?: Readonly<Record<string, string>>\r\n readonly value?: CommandArgumentSpec\r\n}\r\n\r\nexport interface CommandNodeSpec {\r\n readonly title: string\r\n readonly titles?: Readonly<Record<string, string>>\r\n readonly description?: string\r\n readonly aliases?: readonly string[]\r\n readonly arguments?: readonly CommandArgumentSpec[]\r\n readonly options?: readonly CommandOptionSpec[]\r\n readonly children?: readonly CommandNode[]\r\n}\r\n\r\nexport interface CommandNode {\r\n readonly name: string\r\n readonly spec: CommandNodeSpec\r\n}\r\n\r\nexport type CommandSpec = CommandNodeSpec\r\n\r\nexport type CommandResource = ManifestExtension<CommandSpec>\r\n\r\nexport interface CommandOwnerReference {\r\n readonly component: string\r\n readonly facet: string\r\n readonly participantId?: string\r\n}\r\n\r\nexport interface CommandDescriptor {\r\n readonly name: string\r\n readonly description: string\r\n readonly input?: { readonly hint: string }\r\n readonly owner: CommandOwnerReference\r\n readonly resource: CommandResource\r\n readonly available: boolean\r\n readonly missingPresentation: readonly ProtocolSupport[]\r\n readonly issues: readonly { readonly code: string; readonly message: string }[]\r\n}\r\n\r\nexport interface CommandCatalog {\r\n readonly apiVersion: typeof API_VERSION\r\n readonly commands: readonly CommandDescriptor[]\r\n}\r\n\r\nexport interface CommandCatalogInput {\r\n /** Opaque execution context selected by the consuming product. */\r\n readonly contextId: string\r\n readonly presentation?: PresentationDescriptor\r\n}\r\n\r\nexport interface CommandExecutionInput extends CommandCatalogInput {\r\n readonly line: string\r\n}\r\n\r\nexport interface CommandExecution {\r\n readonly apiVersion: typeof API_VERSION\r\n readonly commandId: string\r\n readonly result: {\r\n readonly kind: 'success' | 'error'\r\n readonly text?: string\r\n readonly sourceEventSeq?: number\r\n }\r\n}\r\n\r\nexport type CommandRuntimeCall =\r\n | { readonly operation: 'catalog'; readonly input: CommandCatalogInput; readonly output: CommandCatalog }\r\n | { readonly operation: 'execute'; readonly input: CommandExecutionInput; readonly output: CommandExecution | undefined }\r\n\r\nexport interface CommandRuntimeClient {\r\n catalog(input: CommandCatalogInput, options?: { readonly signal?: AbortSignal }): CapabilityCall<CommandCatalog>\r\n execute(input: CommandExecutionInput, options?: { readonly signal?: AbortSignal }): CapabilityCall<CommandExecution | undefined>\r\n}\r\n\r\nexport interface CommandRuntimeHandler {\r\n catalog(input: CommandCatalogInput, context: CapabilityHandlerContext): CommandCatalog | Promise<CommandCatalog>\r\n execute(\r\n input: CommandExecutionInput,\r\n context: CapabilityHandlerContext,\r\n ): CommandExecution | undefined | Promise<CommandExecution | undefined>\r\n}\r\n\r\nexport interface CommandHandlerInput {\r\n readonly rawInput: string\r\n}\r\n\r\nexport interface CommandHandlerContext {\r\n readonly signal: AbortSignal\r\n /** Host-bound clients for Presentation agreements active in this invocation. */\r\n readonly presentation?: PresentationClients\r\n}\r\n\r\nexport interface CommandHandler {\r\n execute(\r\n input: CommandHandlerInput,\r\n context: CommandHandlerContext,\r\n ): CommandExecution['result'] | Promise<CommandExecution['result']>\r\n}\r\n\r\nexport function assertCommandHandler(value: unknown): asserts value is CommandHandler {\r\n if (!record(value) || typeof value.execute !== 'function') {\r\n throw new TypeError('Command handler must provide execute(input, context)')\r\n }\r\n}\r\n\r\nexport const extensionDefinition = Object.freeze({\r\n apiVersion: API_VERSION,\r\n kind: KIND,\r\n validateMetadata(metadata: { readonly name: string }): void {\r\n if (!/^[a-z][a-z0-9_-]*$/u.test(metadata.name)) throw new TypeError('Command metadata.name is invalid')\r\n },\r\n validateSpec(value: unknown): void {\r\n validateNodeSpec(value, 'Command spec')\r\n },\r\n})\r\n\r\n/** Host support for accepting and owning Command resource publications. */\r\nexport const resourceProtocol: ProtocolDefinition = Object.freeze({\r\n apiVersion: API_VERSION,\r\n kind: KIND,\r\n validateRequirement: emptyProtocolSpec,\r\n validateSupport: emptyProtocolSpec,\r\n negotiate(input) {\r\n const issues: ProtocolIssue[] = []\r\n for (const row of input.requirements) {\r\n if (input.supports.some(candidate => candidate.participant !== row.participant)) continue\r\n issues.push(Object.freeze({\r\n code: row.requirement.optional === true ? 'optional-support-missing' : 'required-support-missing',\r\n severity: row.requirement.optional === true ? 'warning' : 'error',\r\n participant: row.participant,\r\n message: `no participant accepts ${row.requirement.apiVersion} ${row.requirement.kind} resources`,\r\n }))\r\n }\r\n return {\r\n agreement: Object.freeze({ kind: 'ResourcePublication' as const }),\r\n issues: Object.freeze(issues),\r\n }\r\n },\r\n} satisfies ProtocolDefinition)\r\n\r\nexport const resourceSupport: ProtocolSupport = Object.freeze({\r\n apiVersion: API_VERSION,\r\n kind: KIND,\r\n})\r\n\r\n/** Callable, resource-keyed command dispatcher implemented once by a Runtime adapter. */\r\nexport const runtimeProtocol = defineCapabilityProtocol({\r\n apiVersion: API_VERSION,\r\n kind: RUNTIME_KIND,\r\n})\r\n\r\nexport const runtimeSupport: ProtocolSupport = Object.freeze({\r\n apiVersion: API_VERSION,\r\n kind: RUNTIME_KIND,\r\n})\r\n\r\n/** Bind the typed CommandRuntime operations to a consumer-scoped connection client. */\r\nexport function commandRuntime(client: CapabilityClient): CommandRuntimeClient {\r\n return Object.freeze({\r\n catalog(input: CommandCatalogInput, options?: { readonly signal?: AbortSignal }) {\r\n return client.invoke<CommandCatalogInput, CommandCatalog>(runtimeSupport, 'catalog', validateCatalogInput(input), options)\r\n },\r\n execute(input: CommandExecutionInput, options?: { readonly signal?: AbortSignal }) {\r\n return client.invoke<CommandExecutionInput, CommandExecution | undefined>(runtimeSupport, 'execute', validateExecutionInput(input), options)\r\n },\r\n })\r\n}\r\n\r\n/** Create the sole Runtime-side dispatcher implementation for every Command resource. */\r\nexport function commandRuntimeImplementation(\r\n participantId: string,\r\n handler: CommandRuntimeHandler,\r\n): CapabilityImplementation {\r\n return Object.freeze({\r\n participantId,\r\n protocol: runtimeSupport,\r\n handle(operation: string, input: unknown, context: CapabilityHandlerContext) {\r\n if (operation === 'catalog') return handler.catalog(validateCatalogInput(input), context)\r\n if (operation === 'execute') return handler.execute(validateExecutionInput(input), context)\r\n throw new TypeError(`unsupported CommandRuntime operation ${JSON.stringify(operation)}`)\r\n },\r\n })\r\n}\r\n\r\nexport function register(protocols: ProtocolCatalog, manifest?: ManifestDefinitionCatalog): () => void {\r\n const disposeResource = manifest?.registerExtension(extensionDefinition) ?? (() => undefined)\r\n const disposeResourceProtocol = protocols.register(resourceProtocol)\r\n const disposeRuntime = protocols.register(runtimeProtocol)\r\n return () => {\r\n disposeRuntime()\r\n disposeResourceProtocol()\r\n disposeResource()\r\n }\r\n}\r\n\r\nfunction emptyProtocolSpec(value: unknown): undefined {\r\n if (value !== undefined) throw new TypeError('Command resource protocol does not accept spec')\r\n return undefined\r\n}\r\n\r\nfunction record(value: unknown): value is Record<string, unknown> {\r\n return typeof value === 'object' && value !== null && !Array.isArray(value)\r\n}\r\n\r\nfunction validateCatalogInput(value: unknown): CommandCatalogInput {\r\n if (!record(value)) throw new TypeError('CommandRuntime.catalog input must be an object')\r\n exact(value, ['contextId', 'presentation'], 'CommandRuntime.catalog input')\r\n text(value.contextId, 'CommandRuntime.catalog input.contextId')\r\n if (value.presentation !== undefined) validatePresentationDescriptor(value.presentation)\r\n return Object.freeze({\r\n contextId: value.contextId as string,\r\n ...(value.presentation === undefined ? {} : { presentation: value.presentation as PresentationDescriptor }),\r\n })\r\n}\r\n\r\nfunction validateExecutionInput(value: unknown): CommandExecutionInput {\r\n if (!record(value)) throw new TypeError('CommandRuntime.execute input must be an object')\r\n exact(value, ['contextId', 'line', 'presentation'], 'CommandRuntime.execute input')\r\n const catalog = validateCatalogInput({\r\n contextId: value.contextId,\r\n ...(value.presentation === undefined ? {} : { presentation: value.presentation }),\r\n })\r\n text(value.line, 'CommandRuntime.execute input.line')\r\n return Object.freeze({ ...catalog, line: value.line as string })\r\n}\r\n\r\nfunction validateNodeSpec(value: unknown, label: string): void {\r\n if (!record(value)) throw new TypeError(`${label} must be an object`)\r\n exact(value, ['title', 'titles', 'description', 'aliases', 'arguments', 'options', 'children'], label)\r\n text(value.title, `${label}.title`)\r\n if (value.description !== undefined) text(value.description, `${label}.description`)\r\n if (value.titles !== undefined) localized(value.titles, `${label}.titles`)\r\n if (value.aliases !== undefined) tokens(value.aliases, `${label}.aliases`)\r\n if (value.arguments !== undefined) argumentsList(value.arguments, `${label}.arguments`)\r\n if (value.options !== undefined) optionsList(value.options, `${label}.options`)\r\n if (value.children !== undefined) children(value.children, `${label}.children`)\r\n}\r\n\r\nfunction argumentsList(value: unknown, label: string): void {\r\n if (!Array.isArray(value)) throw new TypeError(`${label} must be an array`)\r\n const names = new Set<string>()\r\n for (const [index, argument] of value.entries()) {\r\n const item = `${label}[${index}]`\r\n if (!record(argument)) throw new TypeError(`${item} must be an object`)\r\n exact(argument, ['name', 'title', 'titles', 'required', 'variadic', 'values'], item)\r\n token(argument.name, `${item}.name`)\r\n if (names.has(argument.name as string)) throw new TypeError(`${label} contains a duplicate argument`)\r\n names.add(argument.name as string)\r\n if (argument.title !== undefined) text(argument.title, `${item}.title`)\r\n if (argument.titles !== undefined) localized(argument.titles, `${item}.titles`)\r\n if (argument.required !== undefined && typeof argument.required !== 'boolean') throw new TypeError(`${item}.required must be boolean`)\r\n if (argument.variadic !== undefined && typeof argument.variadic !== 'boolean') throw new TypeError(`${item}.variadic must be boolean`)\r\n if (argument.variadic === true && index !== value.length - 1) throw new TypeError(`${item} must be the last argument when variadic`)\r\n if (argument.values !== undefined) values(argument.values, `${item}.values`)\r\n }\r\n}\r\n\r\nfunction optionsList(value: unknown, label: string): void {\r\n if (!Array.isArray(value)) throw new TypeError(`${label} must be an array`)\r\n const names = new Set<string>()\r\n for (const [index, option] of value.entries()) {\r\n const item = `${label}[${index}]`\r\n if (!record(option)) throw new TypeError(`${item} must be an object`)\r\n exact(option, ['names', 'title', 'titles', 'value'], item)\r\n text(option.title, `${item}.title`)\r\n if (option.titles !== undefined) localized(option.titles, `${item}.titles`)\r\n if (!Array.isArray(option.names) || option.names.length === 0) throw new TypeError(`${item}.names must be a non-empty array`)\r\n for (const name of option.names) {\r\n if (typeof name !== 'string' || !/^-{1,2}[^\\s-][^\\s]*$/u.test(name)) throw new TypeError(`${item}.names contains an invalid option`)\r\n if (names.has(name)) throw new TypeError(`${label} contains a duplicate option name`)\r\n names.add(name)\r\n }\r\n if (option.value !== undefined) argumentsList([option.value], `${item}.value`)\r\n }\r\n}\r\n\r\nfunction children(value: unknown, label: string): void {\r\n if (!Array.isArray(value)) throw new TypeError(`${label} must be an array`)\r\n const names = new Set<string>()\r\n for (const [index, child] of value.entries()) {\r\n const item = `${label}[${index}]`\r\n if (!record(child)) throw new TypeError(`${item} must be an object`)\r\n exact(child, ['name', 'spec'], item)\r\n token(child.name, `${item}.name`)\r\n for (const name of [child.name, ...(Array.isArray((child.spec as Record<string, unknown> | undefined)?.aliases) ? (child.spec as { aliases: unknown[] }).aliases : [])]) {\r\n if (typeof name !== 'string') continue\r\n if (names.has(name)) throw new TypeError(`${label} contains a duplicate name or alias`)\r\n names.add(name)\r\n }\r\n validateNodeSpec(child.spec, `${item}.spec`)\r\n }\r\n}\r\n\r\nfunction values(value: unknown, label: string): void {\r\n if (!Array.isArray(value)) throw new TypeError(`${label} must be an array`)\r\n const seen = new Set<string>()\r\n for (const [index, choice] of value.entries()) {\r\n const item = `${label}[${index}]`\r\n if (!record(choice)) throw new TypeError(`${item} must be an object`)\r\n exact(choice, ['value', 'title', 'titles'], item)\r\n text(choice.value, `${item}.value`)\r\n if (seen.has(choice.value as string)) throw new TypeError(`${label} contains a duplicate value`)\r\n seen.add(choice.value as string)\r\n if (choice.title !== undefined) text(choice.title, `${item}.title`)\r\n if (choice.titles !== undefined) localized(choice.titles, `${item}.titles`)\r\n }\r\n}\r\n\r\nfunction localized(value: unknown, label: string): void {\r\n if (!record(value)) throw new TypeError(`${label} must be an object`)\r\n for (const [locale, translation] of Object.entries(value)) {\r\n if (locale.trim() === '') throw new TypeError(`${label} contains an empty locale`)\r\n text(translation, `${label}.${locale}`)\r\n }\r\n}\r\n\r\nfunction tokens(value: unknown, label: string): void {\r\n if (!Array.isArray(value)) throw new TypeError(`${label} must be an array`)\r\n const seen = new Set<string>()\r\n for (const valueItem of value) {\r\n token(valueItem, label)\r\n if (seen.has(valueItem as string)) throw new TypeError(`${label} contains a duplicate token`)\r\n seen.add(valueItem as string)\r\n }\r\n}\r\n\r\nfunction token(value: unknown, label: string): void {\r\n if (typeof value !== 'string' || !/^[^\\s/]+$/u.test(value)) throw new TypeError(`${label} must be one token`)\r\n}\r\n\r\nfunction text(value: unknown, label: string): void {\r\n if (typeof value !== 'string' || value.trim() === '') throw new TypeError(`${label} must be a non-empty string`)\r\n}\r\n\r\nfunction exact(value: Record<string, unknown>, allowed: readonly string[], label: string): void {\r\n const unknown = Object.keys(value).filter(key => !allowed.includes(key) && !key.startsWith('x-'))\r\n if (unknown.length > 0) throw new TypeError(`${label} contains unknown field ${JSON.stringify(unknown[0])}`)\r\n}\r\n"],"mappings":";;;AAoBA,MAAa,cAAc;AAC3B,MAAa,OAAO;AACpB,MAAa,eAAe;AA8H5B,SAAgB,qBAAqB,OAAiD;CACpF,IAAI,CAAC,OAAO,KAAK,KAAK,OAAO,MAAM,YAAY,YAC7C,MAAM,IAAI,UAAU,sDAAsD;AAE9E;AAEA,MAAa,sBAAsB,OAAO,OAAO;CAC/C,YAAY;CACZ,MAAM;CACN,iBAAiB,UAA2C;EAC1D,IAAI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4B;EAC5F,KAAK,IAAI,SAAmB;CAC9B;AACF;AAEA,SAAS,MAAM,OAAgB,OAAqB;CAClD,IAAI,OAAO,UAAU,YAAY,CAAC,aAAa,KAAK,KAAK,GAAG,MAAM,IAAI,UAAU,GAAG,MAAM,mBAAmB;AAC9G;AAEA,SAAS,KAAK,OAAgB,OAAqB;CACjD,IAAI,OAAO,UAAU,YAAY,MAAM,KAAK,MAAM,IAAI,MAAM,IAAI,UAAU,GAAG,MAAM,4BAA4B;AACjH;AAEA,SAAS,MAAM,OAAgC,SAA4B,OAAqB;CAC9F,MAAM,UAAU,OAAO,KAAK,KAAK,CAAC,CAAC,QAAO,QAAO,CAAC,QAAQ,SAAS,GAAG,KAAK,CAAC,IAAI,WAAW,IAAI,CAAC;CAChG,IAAI,QAAQ,SAAS,GAAG,MAAM,IAAI,UAAU,GAAG,MAAM,0BAA0B,KAAK,UAAU,QAAQ,EAAE,GAAG;AAC7G"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type {\n ProtocolCatalog,\n ProtocolDefinition,\n ProtocolIssue,\n ProtocolSupport,\n} from '@dsh-std/core'\nimport type { ManifestDefinitionCatalog, ManifestExtension } from '@dsh-std/manifest'\nimport type {\n CapabilityCall,\n CapabilityClient,\n CapabilityHandlerContext,\n CapabilityImplementation,\n} from '@dsh-std/connection'\nimport { defineCapabilityProtocol } from '@dsh-std/connection'\nimport {\n validatePresentationDescriptor,\n type PresentationClients,\n type PresentationDescriptor,\n} from '@dsh-std/presentation'\n\nexport const API_VERSION = 'commands.dsh/v1alpha1'\nexport const KIND = 'Command'\nexport const RUNTIME_KIND = 'CommandRuntime'\n\n/** Stable reference to one declared command path. */\nexport interface CommandReference {\n readonly name: string\n readonly path?: readonly string[]\n}\n\nexport interface CommandValueSpec {\n readonly value: string\n readonly title?: string\n readonly titles?: Readonly<Record<string, string>>\n}\n\nexport interface CommandArgumentSpec {\n readonly name: string\n readonly title?: string\n readonly titles?: Readonly<Record<string, string>>\n readonly required?: boolean\n readonly variadic?: boolean\n readonly values?: readonly CommandValueSpec[]\n}\n\nexport interface CommandOptionSpec {\n /** Literal spellings such as `--verbose` and `-v`. */\n readonly names: readonly string[]\n readonly title: string\n readonly titles?: Readonly<Record<string, string>>\n readonly value?: CommandArgumentSpec\n}\n\nexport interface CommandNodeSpec {\n readonly title: string\n readonly titles?: Readonly<Record<string, string>>\n readonly description?: string\n readonly aliases?: readonly string[]\n readonly arguments?: readonly CommandArgumentSpec[]\n readonly options?: readonly CommandOptionSpec[]\n readonly children?: readonly CommandNode[]\n}\n\nexport interface CommandNode {\n readonly name: string\n readonly spec: CommandNodeSpec\n}\n\nexport type CommandSpec = CommandNodeSpec\n\nexport type CommandResource = ManifestExtension<CommandSpec>\n\nexport interface CommandOwnerReference {\n readonly component: string\n readonly facet: string\n readonly participantId?: string\n}\n\nexport interface CommandDescriptor {\n readonly name: string\n readonly description: string\n readonly input?: { readonly hint: string }\n readonly owner: CommandOwnerReference\n readonly resource: CommandResource\n readonly available: boolean\n readonly missingPresentation: readonly ProtocolSupport[]\n readonly issues: readonly { readonly code: string; readonly message: string }[]\n}\n\nexport interface CommandCatalog {\n readonly apiVersion: typeof API_VERSION\n readonly commands: readonly CommandDescriptor[]\n}\n\nexport interface CommandCatalogInput {\n /** Opaque execution context selected by the consuming product. */\n readonly contextId: string\n readonly presentation?: PresentationDescriptor\n}\n\nexport interface CommandExecutionInput extends CommandCatalogInput {\n readonly line: string\n}\n\nexport interface CommandExecution {\n readonly apiVersion: typeof API_VERSION\n readonly commandId: string\n readonly result: {\n readonly kind: 'success' | 'error'\n readonly text?: string\n readonly sourceEventSeq?: number\n }\n}\n\nexport type CommandRuntimeCall =\n | { readonly operation: 'catalog'; readonly input: CommandCatalogInput; readonly output: CommandCatalog }\n | { readonly operation: 'execute'; readonly input: CommandExecutionInput; readonly output: CommandExecution | undefined }\n\nexport interface CommandRuntimeClient {\n catalog(input: CommandCatalogInput, options?: { readonly signal?: AbortSignal }): CapabilityCall<CommandCatalog>\n execute(input: CommandExecutionInput, options?: { readonly signal?: AbortSignal }): CapabilityCall<CommandExecution | undefined>\n}\n\nexport interface CommandRuntimeHandler {\n catalog(input: CommandCatalogInput, context: CapabilityHandlerContext): CommandCatalog | Promise<CommandCatalog>\n execute(\n input: CommandExecutionInput,\n context: CapabilityHandlerContext,\n ): CommandExecution | undefined | Promise<CommandExecution | undefined>\n}\n\nexport interface CommandHandlerInput {\n readonly rawInput: string\n}\n\nexport interface CommandHandlerContext {\n readonly signal: AbortSignal\n /** Host-bound clients for Presentation agreements active in this invocation. */\n readonly presentation?: PresentationClients\n}\n\nexport interface CommandHandler {\n execute(\n input: CommandHandlerInput,\n context: CommandHandlerContext,\n ): CommandExecution['result'] | Promise<CommandExecution['result']>\n}\n\nexport function assertCommandHandler(value: unknown): asserts value is CommandHandler {\n if (!record(value) || typeof value.execute !== 'function') {\n throw new TypeError('Command handler must provide execute(input, context)')\n }\n}\n\nexport const extensionDefinition = Object.freeze({\n apiVersion: API_VERSION,\n kind: KIND,\n validateMetadata(metadata: { readonly name: string }): void {\n if (!/^[a-z][a-z0-9_-]*$/u.test(metadata.name)) throw new TypeError('Command metadata.name is invalid')\n },\n validateSpec(value: unknown): void {\n validateNodeSpec(value, 'Command spec')\n },\n})\n\n/** Host support for accepting and owning Command resource publications. */\nexport const resourceProtocol: ProtocolDefinition = Object.freeze({\n apiVersion: API_VERSION,\n kind: KIND,\n validateRequirement: emptyProtocolSpec,\n validateSupport: emptyProtocolSpec,\n negotiate(input) {\n const issues: ProtocolIssue[] = []\n for (const row of input.requirements) {\n if (input.supports.some(candidate => candidate.participant !== row.participant)) continue\n issues.push(Object.freeze({\n code: row.requirement.optional === true ? 'optional-support-missing' : 'required-support-missing',\n severity: row.requirement.optional === true ? 'warning' : 'error',\n participant: row.participant,\n message: `no participant accepts ${row.requirement.apiVersion} ${row.requirement.kind} resources`,\n }))\n }\n return {\n agreement: Object.freeze({ kind: 'ResourcePublication' as const }),\n issues: Object.freeze(issues),\n }\n },\n} satisfies ProtocolDefinition)\n\nexport const resourceSupport: ProtocolSupport = Object.freeze({\n apiVersion: API_VERSION,\n kind: KIND,\n})\n\n/** Callable, resource-keyed command dispatcher implemented once by a Runtime adapter. */\nexport const runtimeProtocol = defineCapabilityProtocol({\n apiVersion: API_VERSION,\n kind: RUNTIME_KIND,\n})\n\nexport const runtimeSupport: ProtocolSupport = Object.freeze({\n apiVersion: API_VERSION,\n kind: RUNTIME_KIND,\n})\n\n/** Bind the typed CommandRuntime operations to a consumer-scoped connection client. */\nexport function commandRuntime(client: CapabilityClient): CommandRuntimeClient {\n return Object.freeze({\n catalog(input: CommandCatalogInput, options?: { readonly signal?: AbortSignal }) {\n return client.invoke<CommandCatalogInput, CommandCatalog>(runtimeSupport, 'catalog', validateCatalogInput(input), options)\n },\n execute(input: CommandExecutionInput, options?: { readonly signal?: AbortSignal }) {\n return client.invoke<CommandExecutionInput, CommandExecution | undefined>(runtimeSupport, 'execute', validateExecutionInput(input), options)\n },\n })\n}\n\n/** Create the sole Runtime-side dispatcher implementation for every Command resource. */\nexport function commandRuntimeImplementation(\n participantId: string,\n handler: CommandRuntimeHandler,\n): CapabilityImplementation {\n return Object.freeze({\n participantId,\n protocol: runtimeSupport,\n handle(operation: string, input: unknown, context: CapabilityHandlerContext) {\n if (operation === 'catalog') return handler.catalog(validateCatalogInput(input), context)\n if (operation === 'execute') return handler.execute(validateExecutionInput(input), context)\n throw new TypeError(`unsupported CommandRuntime operation ${JSON.stringify(operation)}`)\n },\n })\n}\n\nexport function register(protocols: ProtocolCatalog, manifest?: ManifestDefinitionCatalog): () => void {\n const disposeResource = manifest?.registerExtension(extensionDefinition) ?? (() => undefined)\n const disposeResourceProtocol = protocols.register(resourceProtocol)\n const disposeRuntime = protocols.register(runtimeProtocol)\n return () => {\n disposeRuntime()\n disposeResourceProtocol()\n disposeResource()\n }\n}\n\nfunction emptyProtocolSpec(value: unknown): undefined {\n if (value !== undefined) throw new TypeError('Command resource protocol does not accept spec')\n return undefined\n}\n\nfunction record(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction validateCatalogInput(value: unknown): CommandCatalogInput {\n if (!record(value)) throw new TypeError('CommandRuntime.catalog input must be an object')\n exact(value, ['contextId', 'presentation'], 'CommandRuntime.catalog input')\n text(value.contextId, 'CommandRuntime.catalog input.contextId')\n if (value.presentation !== undefined) validatePresentationDescriptor(value.presentation)\n return Object.freeze({\n contextId: value.contextId as string,\n ...(value.presentation === undefined ? {} : { presentation: value.presentation as PresentationDescriptor }),\n })\n}\n\nfunction validateExecutionInput(value: unknown): CommandExecutionInput {\n if (!record(value)) throw new TypeError('CommandRuntime.execute input must be an object')\n exact(value, ['contextId', 'line', 'presentation'], 'CommandRuntime.execute input')\n const catalog = validateCatalogInput({\n contextId: value.contextId,\n ...(value.presentation === undefined ? {} : { presentation: value.presentation }),\n })\n text(value.line, 'CommandRuntime.execute input.line')\n return Object.freeze({ ...catalog, line: value.line as string })\n}\n\nfunction validateNodeSpec(value: unknown, label: string): void {\n if (!record(value)) throw new TypeError(`${label} must be an object`)\n exact(value, ['title', 'titles', 'description', 'aliases', 'arguments', 'options', 'children'], label)\n text(value.title, `${label}.title`)\n if (value.description !== undefined) text(value.description, `${label}.description`)\n if (value.titles !== undefined) localized(value.titles, `${label}.titles`)\n if (value.aliases !== undefined) tokens(value.aliases, `${label}.aliases`)\n if (value.arguments !== undefined) argumentsList(value.arguments, `${label}.arguments`)\n if (value.options !== undefined) optionsList(value.options, `${label}.options`)\n if (value.children !== undefined) children(value.children, `${label}.children`)\n}\n\nfunction argumentsList(value: unknown, label: string): void {\n if (!Array.isArray(value)) throw new TypeError(`${label} must be an array`)\n const names = new Set<string>()\n for (const [index, argument] of value.entries()) {\n const item = `${label}[${index}]`\n if (!record(argument)) throw new TypeError(`${item} must be an object`)\n exact(argument, ['name', 'title', 'titles', 'required', 'variadic', 'values'], item)\n token(argument.name, `${item}.name`)\n if (names.has(argument.name as string)) throw new TypeError(`${label} contains a duplicate argument`)\n names.add(argument.name as string)\n if (argument.title !== undefined) text(argument.title, `${item}.title`)\n if (argument.titles !== undefined) localized(argument.titles, `${item}.titles`)\n if (argument.required !== undefined && typeof argument.required !== 'boolean') throw new TypeError(`${item}.required must be boolean`)\n if (argument.variadic !== undefined && typeof argument.variadic !== 'boolean') throw new TypeError(`${item}.variadic must be boolean`)\n if (argument.variadic === true && index !== value.length - 1) throw new TypeError(`${item} must be the last argument when variadic`)\n if (argument.values !== undefined) values(argument.values, `${item}.values`)\n }\n}\n\nfunction optionsList(value: unknown, label: string): void {\n if (!Array.isArray(value)) throw new TypeError(`${label} must be an array`)\n const names = new Set<string>()\n for (const [index, option] of value.entries()) {\n const item = `${label}[${index}]`\n if (!record(option)) throw new TypeError(`${item} must be an object`)\n exact(option, ['names', 'title', 'titles', 'value'], item)\n text(option.title, `${item}.title`)\n if (option.titles !== undefined) localized(option.titles, `${item}.titles`)\n if (!Array.isArray(option.names) || option.names.length === 0) throw new TypeError(`${item}.names must be a non-empty array`)\n for (const name of option.names) {\n if (typeof name !== 'string' || !/^-{1,2}[^\\s-][^\\s]*$/u.test(name)) throw new TypeError(`${item}.names contains an invalid option`)\n if (names.has(name)) throw new TypeError(`${label} contains a duplicate option name`)\n names.add(name)\n }\n if (option.value !== undefined) argumentsList([option.value], `${item}.value`)\n }\n}\n\nfunction children(value: unknown, label: string): void {\n if (!Array.isArray(value)) throw new TypeError(`${label} must be an array`)\n const names = new Set<string>()\n for (const [index, child] of value.entries()) {\n const item = `${label}[${index}]`\n if (!record(child)) throw new TypeError(`${item} must be an object`)\n exact(child, ['name', 'spec'], item)\n token(child.name, `${item}.name`)\n for (const name of [child.name, ...(Array.isArray((child.spec as Record<string, unknown> | undefined)?.aliases) ? (child.spec as { aliases: unknown[] }).aliases : [])]) {\n if (typeof name !== 'string') continue\n if (names.has(name)) throw new TypeError(`${label} contains a duplicate name or alias`)\n names.add(name)\n }\n validateNodeSpec(child.spec, `${item}.spec`)\n }\n}\n\nfunction values(value: unknown, label: string): void {\n if (!Array.isArray(value)) throw new TypeError(`${label} must be an array`)\n const seen = new Set<string>()\n for (const [index, choice] of value.entries()) {\n const item = `${label}[${index}]`\n if (!record(choice)) throw new TypeError(`${item} must be an object`)\n exact(choice, ['value', 'title', 'titles'], item)\n text(choice.value, `${item}.value`)\n if (seen.has(choice.value as string)) throw new TypeError(`${label} contains a duplicate value`)\n seen.add(choice.value as string)\n if (choice.title !== undefined) text(choice.title, `${item}.title`)\n if (choice.titles !== undefined) localized(choice.titles, `${item}.titles`)\n }\n}\n\nfunction localized(value: unknown, label: string): void {\n if (!record(value)) throw new TypeError(`${label} must be an object`)\n for (const [locale, translation] of Object.entries(value)) {\n if (locale.trim() === '') throw new TypeError(`${label} contains an empty locale`)\n text(translation, `${label}.${locale}`)\n }\n}\n\nfunction tokens(value: unknown, label: string): void {\n if (!Array.isArray(value)) throw new TypeError(`${label} must be an array`)\n const seen = new Set<string>()\n for (const valueItem of value) {\n token(valueItem, label)\n if (seen.has(valueItem as string)) throw new TypeError(`${label} contains a duplicate token`)\n seen.add(valueItem as string)\n }\n}\n\nfunction token(value: unknown, label: string): void {\n if (typeof value !== 'string' || !/^[^\\s/]+$/u.test(value)) throw new TypeError(`${label} must be one token`)\n}\n\nfunction text(value: unknown, label: string): void {\n if (typeof value !== 'string' || value.trim() === '') throw new TypeError(`${label} must be a non-empty string`)\n}\n\nfunction exact(value: Record<string, unknown>, allowed: readonly string[], label: string): void {\n const unknown = Object.keys(value).filter(key => !allowed.includes(key) && !key.startsWith('x-'))\n if (unknown.length > 0) throw new TypeError(`${label} contains unknown field ${JSON.stringify(unknown[0])}`)\n}\n"],"mappings":";;;AAoBA,MAAa,cAAc;AAC3B,MAAa,OAAO;AACpB,MAAa,eAAe;AA8H5B,SAAgB,qBAAqB,OAAiD;CACpF,IAAI,CAAC,OAAO,KAAK,KAAK,OAAO,MAAM,YA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IAAY;CAC7B,KAAK,MAAM,aAAa,OAAO;EAC7B,MAAM,WAAW,KAAK;EACtB,IAAI,KAAK,IAAI,SAAmB,GAAG,MAAM,IAAI,UAAU,GAAG,MAAM,4BAA4B;EAC5F,KAAK,IAAI,SAAmB;CAC9B;AACF;AAEA,SAAS,MAAM,OAAgB,OAAqB;CAClD,IAAI,OAAO,UAAU,YAAY,CAAC,aAAa,KAAK,KAAK,GAAG,MAAM,IAAI,UAAU,GAAG,MAAM,mBAAmB;AAC9G;AAEA,SAAS,KAAK,OAAgB,OAAqB;CACjD,IAAI,OAAO,UAAU,YAAY,MAAM,KAAK,MAAM,IAAI,MAAM,IAAI,UAAU,GAAG,MAAM,4BAA4B;AACjH;AAEA,SAAS,MAAM,OAAgC,SAA4B,OAAqB;CAC9F,MAAM,UAAU,OAAO,KAAK,KAAK,CAAC,CAAC,QAAO,QAAO,CAAC,QAAQ,SAAS,GAAG,KAAK,CAAC,IAAI,WAAW,IAAI,CAAC;CAChG,IAAI,QAAQ,SAAS,GAAG,MAAM,IAAI,UAAU,GAAG,MAAM,0BAA0B,KAAK,UAAU,QAAQ,EAAE,GAAG;AAC7G"}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@dsh-std/command",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"license": "MIT",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "lib/index.js",
|
|
7
|
-
"types": "lib/index.d.ts",
|
|
8
|
-
"exports": { ".": { "types": "./lib/index.d.ts", "default": "./lib/index.js" } },
|
|
9
|
-
"files": ["lib", "CHANGELOG.md"],
|
|
10
|
-
"scripts": {
|
|
11
|
-
"build": "pnpm run typecheck && tsdown",
|
|
12
|
-
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
13
|
-
"test": "vitest run --passWithNoTests"
|
|
14
|
-
},
|
|
15
|
-
"dependencies": {
|
|
16
|
-
"@dsh-std/core": "workspace:*",
|
|
17
|
-
"@dsh-std/manifest": "workspace:*",
|
|
18
|
-
"@dsh-std/connection": "workspace:*",
|
|
19
|
-
"@dsh-std/presentation": "workspace:*"
|
|
20
|
-
},
|
|
21
|
-
"engines": { "node": "^22.19 || >=24" }
|
|
22
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@dsh-std/command",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"types": "lib/index.d.ts",
|
|
8
|
+
"exports": { ".": { "types": "./lib/index.d.ts", "default": "./lib/index.js" } },
|
|
9
|
+
"files": ["lib", "CHANGELOG.md"],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "pnpm run typecheck && tsdown",
|
|
12
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
13
|
+
"test": "vitest run --passWithNoTests"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@dsh-std/core": "workspace:*",
|
|
17
|
+
"@dsh-std/manifest": "workspace:*",
|
|
18
|
+
"@dsh-std/connection": "workspace:*",
|
|
19
|
+
"@dsh-std/presentation": "workspace:*"
|
|
20
|
+
},
|
|
21
|
+
"engines": { "node": "^22.19 || >=24" }
|
|
22
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
Changes to `@dsh-std/connection` are recorded here.
|
|
4
|
-
|
|
5
|
-
## 0.1.0 (draft)
|
|
6
|
-
|
|
7
|
-
- Defined connection services, endpoint views, participant publication, capability bindings, and attachments.
|
|
8
|
-
- Added an in-memory transport for protocol conformance and host integration tests.
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
Changes to `@dsh-std/connection` are recorded here.
|
|
4
|
+
|
|
5
|
+
## 0.1.0 (draft)
|
|
6
|
+
|
|
7
|
+
- Defined connection services, endpoint views, participant publication, capability bindings, and attachments.
|
|
8
|
+
- Added an in-memory transport for protocol conformance and host integration tests.
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 DSH Standard contributors
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 DSH Standard contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
# @dsh-std/connection
|
|
2
|
-
|
|
3
|
-
English | [中文](README.zh.md)
|
|
4
|
-
|
|
5
|
-
The proposed design is documented in [Endpoint Connection](../../docs/proposals/endpoint-connection.zh.md). It separates the application-facing `ConnectionService` from the Connection Host provider SPI. The remainder of this page describes the current reference implementation, which does not yet complete that split.
|
|
6
|
-
|
|
7
|
-
Host-provided communication service, two-endpoint capability negotiation, and implementation-neutral invocation for the DSH Standard.
|
|
8
|
-
|
|
9
|
-
## Endpoint offers
|
|
10
|
-
|
|
11
|
-
An endpoint offer contains an endpoint identity, a revision, and the live participant declarations admitted by endpoint policy. It carries no component manifests, installation inventory, or plugin registry.
|
|
12
|
-
|
|
13
|
-
`resolveConnection()` passes both sets of declarations to a caller-owned `ProtocolCatalog`. Each protocol definition owns its negotiation and may place invocation bindings in its agreement; connection does not impose consumer/provider semantics on every protocol. `defineCapabilityProtocol()` is an explicit helper for domain protocols that do use RPC-shaped bindings.
|
|
14
|
-
|
|
15
|
-
Each invocation binding is participant-scoped and plan-revision-scoped. A client for one participant cannot discover or invoke bindings granted to another participant.
|
|
16
|
-
|
|
17
|
-
## Current reference API
|
|
18
|
-
|
|
19
|
-
`StandardConnection` exposes endpoint identities, the active plan, consumer-scoped clients, plan-change observation, and close. `CapabilityClient.invoke()` returns an invocation id, a result promise, an asynchronous progress stream, and cancellation. Domain protocol packages own operation names and input, output, and progress values.
|
|
20
|
-
|
|
21
|
-
`ConnectionBroker` selects one registered `ConnectionConnector` for an implementation-neutral target URI. Zero matches and multiple matches are both explicit errors. The broker does not expose the selected connector type through `StandardConnection`.
|
|
22
|
-
|
|
23
|
-
These types are an early reference implementation. They do not require a TUI, Web UI, GUI, or business plugin to register and operate its own connector. The protocol direction places the broker, connector/provider registry, carrier, and wire behind a Connection Host's `ConnectionService`. A consumer submits a target and uses scoped typed clients for the negotiated protocols.
|
|
24
|
-
|
|
25
|
-
A Connection Host may install or discover a remote service, own authentication, ports, forwarding and reconnection, and produce the `StandardConnection`. An SSH target facet contributes resolution and bootstrap integration while system OpenSSH or another provider may supply the physical SSH implementation. Applications do not observe the selected provider, ports, credentials, or wire.
|
|
26
|
-
|
|
27
|
-
## Lifecycle
|
|
28
|
-
|
|
29
|
-
Renegotiation creates a complete new plan revision and publishes it atomically. An invocation admitted under the old revision retains its binding until settlement; later invocations use the new revision. Closing a connection cancels active work and rejects new work with `connection-closed`.
|
|
30
|
-
|
|
31
|
-
Transport implementations must preserve invocation isolation, progress order, cancellation, and the error classification exposed by `ConnectionInvocationError`. They are also responsible for authenticating the peer and preventing one connection from reusing another connection's grants.
|
|
32
|
-
|
|
33
|
-
## Reference implementation
|
|
34
|
-
|
|
35
|
-
The `@dsh-std/connection/memory` export provides a process-local implementation for tests, adapters, and conformance experiments. It demonstrates symmetric calls, progress, cancellation, isolation, and renegotiation. It is not a required carrier or a wire-format specification.
|
|
36
|
-
|
|
37
|
-
## Known Limitations and Deferred Work
|
|
38
|
-
|
|
39
|
-
- The consumer-facing `ConnectionService` and Host provider SPI are not implemented in the current code yet.
|
|
40
|
-
- The package does not yet standardize discovery, authentication, encryption, reconnect policy, framing, or serialization.
|
|
41
|
-
- A connection has exactly two endpoints in `v1alpha1`; multi-party routing is composed from separate connections.
|
|
42
|
-
- The capability helper requires one peer provider by default. Protocols that allow multiple providers must opt into and define that behavior explicitly.
|
|
1
|
+
# @dsh-std/connection
|
|
2
|
+
|
|
3
|
+
English | [中文](README.zh.md)
|
|
4
|
+
|
|
5
|
+
The proposed design is documented in [Endpoint Connection](../../docs/proposals/endpoint-connection.zh.md). It separates the application-facing `ConnectionService` from the Connection Host provider SPI. The remainder of this page describes the current reference implementation, which does not yet complete that split.
|
|
6
|
+
|
|
7
|
+
Host-provided communication service, two-endpoint capability negotiation, and implementation-neutral invocation for the DSH Standard.
|
|
8
|
+
|
|
9
|
+
## Endpoint offers
|
|
10
|
+
|
|
11
|
+
An endpoint offer contains an endpoint identity, a revision, and the live participant declarations admitted by endpoint policy. It carries no component manifests, installation inventory, or plugin registry.
|
|
12
|
+
|
|
13
|
+
`resolveConnection()` passes both sets of declarations to a caller-owned `ProtocolCatalog`. Each protocol definition owns its negotiation and may place invocation bindings in its agreement; connection does not impose consumer/provider semantics on every protocol. `defineCapabilityProtocol()` is an explicit helper for domain protocols that do use RPC-shaped bindings.
|
|
14
|
+
|
|
15
|
+
Each invocation binding is participant-scoped and plan-revision-scoped. A client for one participant cannot discover or invoke bindings granted to another participant.
|
|
16
|
+
|
|
17
|
+
## Current reference API
|
|
18
|
+
|
|
19
|
+
`StandardConnection` exposes endpoint identities, the active plan, consumer-scoped clients, plan-change observation, and close. `CapabilityClient.invoke()` returns an invocation id, a result promise, an asynchronous progress stream, and cancellation. Domain protocol packages own operation names and input, output, and progress values.
|
|
20
|
+
|
|
21
|
+
`ConnectionBroker` selects one registered `ConnectionConnector` for an implementation-neutral target URI. Zero matches and multiple matches are both explicit errors. The broker does not expose the selected connector type through `StandardConnection`.
|
|
22
|
+
|
|
23
|
+
These types are an early reference implementation. They do not require a TUI, Web UI, GUI, or business plugin to register and operate its own connector. The protocol direction places the broker, connector/provider registry, carrier, and wire behind a Connection Host's `ConnectionService`. A consumer submits a target and uses scoped typed clients for the negotiated protocols.
|
|
24
|
+
|
|
25
|
+
A Connection Host may install or discover a remote service, own authentication, ports, forwarding and reconnection, and produce the `StandardConnection`. An SSH target facet contributes resolution and bootstrap integration while system OpenSSH or another provider may supply the physical SSH implementation. Applications do not observe the selected provider, ports, credentials, or wire.
|
|
26
|
+
|
|
27
|
+
## Lifecycle
|
|
28
|
+
|
|
29
|
+
Renegotiation creates a complete new plan revision and publishes it atomically. An invocation admitted under the old revision retains its binding until settlement; later invocations use the new revision. Closing a connection cancels active work and rejects new work with `connection-closed`.
|
|
30
|
+
|
|
31
|
+
Transport implementations must preserve invocation isolation, progress order, cancellation, and the error classification exposed by `ConnectionInvocationError`. They are also responsible for authenticating the peer and preventing one connection from reusing another connection's grants.
|
|
32
|
+
|
|
33
|
+
## Reference implementation
|
|
34
|
+
|
|
35
|
+
The `@dsh-std/connection/memory` export provides a process-local implementation for tests, adapters, and conformance experiments. It demonstrates symmetric calls, progress, cancellation, isolation, and renegotiation. It is not a required carrier or a wire-format specification.
|
|
36
|
+
|
|
37
|
+
## Known Limitations and Deferred Work
|
|
38
|
+
|
|
39
|
+
- The consumer-facing `ConnectionService` and Host provider SPI are not implemented in the current code yet.
|
|
40
|
+
- The package does not yet standardize discovery, authentication, encryption, reconnect policy, framing, or serialization.
|
|
41
|
+
- A connection has exactly two endpoints in `v1alpha1`; multi-party routing is composed from separate connections.
|
|
42
|
+
- The capability helper requires one peer provider by default. Protocols that allow multiple providers must opt into and define that behavior explicitly.
|