@aiwayds/dsh-opentui 0.27.1 → 0.28.0
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/CHANGELOG.md +38 -15
- package/README.md +38 -182
- package/bin/dsh-opentui.mjs +54 -258
- package/bin/lib/launcher.mjs +29 -187
- package/dist/client/index.js +7585 -16584
- package/dist/client/index.js.map +26 -51
- package/dist/locales/en.json +21 -8
- package/dist/locales/zh-CN.json +21 -8
- package/package.json +7 -11
- package/scripts/lib/companion-policy.mjs +16 -0
- package/scripts/lib/inproc-companions.mjs +128 -38
- package/scripts/lib/migration-io.mjs +231 -0
- package/scripts/lib/migration.mjs +724 -0
- package/scripts/lib/patch-ownership-state.mjs +42 -0
- package/scripts/lib/patch-ownership.mjs +1428 -0
- package/scripts/lib/profile-lock.mjs +185 -0
- package/scripts/lib/profile-name.d.mts +1 -0
- package/scripts/lib/profile-name.mjs +2 -0
- package/scripts/lib/provision-run-lock.mjs +223 -0
- package/scripts/provision-inproc-profile.mjs +601 -286
- package/dist/host-launch.mjs +0 -1293
- package/dist/host-launch.mjs.map +0 -19
- package/dist/scripts/idle-reaper.mjs +0 -173
- package/dist/watchdog.mjs +0 -476
- package/dist/watchdog.mjs.map +0 -16
- package/scripts/e2e-client.mjs +0 -1122
- package/scripts/e2e-sweep.mjs +0 -932
- package/scripts/idle-reaper.mjs +0 -173
- package/scripts/lib/provision-plan.mjs +0 -899
- package/scripts/lib/provision-state.mjs +0 -294
- package/scripts/lib/upgrade-plan.mjs +0 -489
- package/scripts/provision-opentui-profile.mjs +0 -806
- package/scripts/upgrade.mjs +0 -1149
package/dist/locales/en.json
CHANGED
|
@@ -22,7 +22,18 @@
|
|
|
22
22
|
"command.model.discovered": "discovered {n} models: {list}",
|
|
23
23
|
"command.model.discoverEmpty": "no models discovered from the endpoint",
|
|
24
24
|
"command.model.discoverUnavailable": "model discovery unavailable — {reason}",
|
|
25
|
-
"command.login.description": "log in
|
|
25
|
+
"command.login.description": "log in (DeepSeek account / third-party / custom provider)",
|
|
26
|
+
"command.login.mode.title": "Sign in — choose a method",
|
|
27
|
+
"command.login.mode.account.title": "DeepSeek account",
|
|
28
|
+
"command.login.mode.account.hint": "Sign in through your DeepSeek account",
|
|
29
|
+
"command.login.mode.thirdParty.title": "Third-party provider",
|
|
30
|
+
"command.login.mode.thirdParty.hint": "Pick a known provider and enter its API key",
|
|
31
|
+
"command.login.mode.custom.title": "Custom provider",
|
|
32
|
+
"command.login.mode.custom.hint": "Route id, base URL, models and API key",
|
|
33
|
+
"command.login.account.title": "DeepSeek account",
|
|
34
|
+
"command.login.account.state": "Show account state",
|
|
35
|
+
"command.login.account.signin": "Sign in",
|
|
36
|
+
"command.login.account.signout": "Sign out",
|
|
26
37
|
"command.login.routeRegistrationFailed": "{id}: route registration failed — key not stored",
|
|
27
38
|
"command.login.keyStoreFailed": "{id}: key store failed — {detail}",
|
|
28
39
|
"command.login.subscribed": "{name} subscribed — key stored, route registered (in /model next session)",
|
|
@@ -32,8 +43,10 @@
|
|
|
32
43
|
"command.login.unavailable": "/login unavailable in this session",
|
|
33
44
|
"command.login.directoryDegraded": "provider directory unavailable — showing the built-in provider list",
|
|
34
45
|
"command.login.directoryPartial": "provider directory partly unavailable — showing the providers that responded",
|
|
46
|
+
"command.profile.mismatch": "Profile mismatch: profile files would go to {clientDir}, but the running dsh process reads {hostDir}. Nothing was written. Next: restart dsh-opentui so both use {hostDir} (remove any one-sided profile override), then retry.",
|
|
35
47
|
"command.account.description": "show account sign-in state (signin/signout)",
|
|
36
48
|
"command.account.unavailable": "/account unavailable in this session",
|
|
49
|
+
"command.account.signinUnavailable": "Browser sign-in is not available in this build.",
|
|
37
50
|
"command.account.state": "account: status={status} phase={phase} urlReady={urlReady} links={links}",
|
|
38
51
|
"command.account.failed": "account action failed: {reason}",
|
|
39
52
|
"command.account.unknownAction": "unknown account action: {action} (use signin/signout)",
|
|
@@ -63,7 +76,7 @@
|
|
|
63
76
|
"command.logout.routeFailed": "{id}: logout failed — {reason}",
|
|
64
77
|
"command.logout.done": "{name} logged out — key removed (route kept)",
|
|
65
78
|
"command.logout.routeRemoved": "{name} logged out — key + route removed (leaves /model next session)",
|
|
66
|
-
"command.logout.routeRemoveFailed": "{name} logged out — key removed, route
|
|
79
|
+
"command.logout.routeRemoveFailed": "{name} logged out — key removed, but the {id} route stayed: {reason}. Next: fix that settings write (retry after the host recovers) or remove the {id} route in /settings; no key is stored now.",
|
|
67
80
|
"command.logout.unavailable": "/logout unavailable in this session",
|
|
68
81
|
"command.logout.none": "no logged-in providers",
|
|
69
82
|
"command.quit.description": "exit the app",
|
|
@@ -306,8 +319,8 @@
|
|
|
306
319
|
"settings.status.instantSave": "changes are saved instantly",
|
|
307
320
|
"settings.exit.title": "Exit settings?",
|
|
308
321
|
"settings.exit.message": "Every change is already saved.",
|
|
309
|
-
"settings.exit.confirm": "
|
|
310
|
-
"settings.exit.cancel": "
|
|
322
|
+
"settings.exit.confirm": "Yes",
|
|
323
|
+
"settings.exit.cancel": "No",
|
|
311
324
|
"settings.hint.navSections": "↑↓ select section · →/Enter open",
|
|
312
325
|
"settings.hint.rows": "↑↓ select row · Enter edit · ←/Esc back",
|
|
313
326
|
"settings.hint.escBack": "esc back",
|
|
@@ -721,12 +734,12 @@
|
|
|
721
734
|
"turn.stop.confirmChildrenOne": "1 live subagent",
|
|
722
735
|
"turn.stop.confirmChildrenMany": "{count} live subagents",
|
|
723
736
|
"turn.stop.confirmMessage": "Stop {parts} now? Queued prompts stay and the session remains resumable.",
|
|
724
|
-
"turn.stop.confirmLabel": "
|
|
725
|
-
"turn.stop.cancelLabel": "
|
|
737
|
+
"turn.stop.confirmLabel": "yes",
|
|
738
|
+
"turn.stop.cancelLabel": "no",
|
|
726
739
|
"turn.quit.confirmTitle": "Quit dsh-opentui?",
|
|
727
740
|
"turn.quit.confirmMessage": "This ends the session and returns you to your shell.",
|
|
728
|
-
"turn.quit.confirmLabel": "
|
|
729
|
-
"turn.quit.cancelLabel": "
|
|
741
|
+
"turn.quit.confirmLabel": "yes",
|
|
742
|
+
"turn.quit.cancelLabel": "no",
|
|
730
743
|
"footer.msgs.one": "💬 {n} msg",
|
|
731
744
|
"footer.msgs.many": "💬 {n} msgs",
|
|
732
745
|
"footer.hint.quit": "ctrl+c quit",
|
package/dist/locales/zh-CN.json
CHANGED
|
@@ -22,7 +22,18 @@
|
|
|
22
22
|
"command.model.discovered": "发现 {n} 个模型:{list}",
|
|
23
23
|
"command.model.discoverEmpty": "端点未返回模型",
|
|
24
24
|
"command.model.discoverUnavailable": "模型发现不可用 — {reason}",
|
|
25
|
-
"command.login.description": "
|
|
25
|
+
"command.login.description": "登录(DeepSeek 账号 / 第三方 / 自定义 provider)",
|
|
26
|
+
"command.login.mode.title": "登录 — 选择方式",
|
|
27
|
+
"command.login.mode.account.title": "DeepSeek 账号",
|
|
28
|
+
"command.login.mode.account.hint": "通过 DeepSeek 账号登录",
|
|
29
|
+
"command.login.mode.thirdParty.title": "第三方 provider",
|
|
30
|
+
"command.login.mode.thirdParty.hint": "选择已知 provider 并填写 API key",
|
|
31
|
+
"command.login.mode.custom.title": "自定义 provider",
|
|
32
|
+
"command.login.mode.custom.hint": "路由 id、base URL、模型列表与 API key",
|
|
33
|
+
"command.login.account.title": "DeepSeek 账号",
|
|
34
|
+
"command.login.account.state": "查看账号状态",
|
|
35
|
+
"command.login.account.signin": "登录",
|
|
36
|
+
"command.login.account.signout": "退出登录",
|
|
26
37
|
"command.login.routeRegistrationFailed": "{id}:路由注册失败 — 密钥未保存",
|
|
27
38
|
"command.login.keyStoreFailed": "{id}:密钥保存失败 — {detail}",
|
|
28
39
|
"command.login.subscribed": "{name} 已订阅 — 密钥已保存,路由已注册(下次会话在 /model 中生效)",
|
|
@@ -32,8 +43,10 @@
|
|
|
32
43
|
"command.login.unavailable": "本会话中 /login 不可用",
|
|
33
44
|
"command.login.directoryDegraded": "provider 目录不可用 — 显示内置 provider 列表",
|
|
34
45
|
"command.login.directoryPartial": "provider 目录部分不可用 — 显示已响应的 provider",
|
|
46
|
+
"command.profile.mismatch": "profile 不一致:本会写入 {clientDir},但正在运行的 dsh 进程读取 {hostDir}。未写入任何内容。下一步:重启 dsh-opentui,让两边都使用 {hostDir}(去掉只对一边生效的 profile 覆盖设置),然后重试。",
|
|
35
47
|
"command.account.description": "查看账号登录态(signin/signout)",
|
|
36
48
|
"command.account.unavailable": "本会话中 /account 不可用",
|
|
49
|
+
"command.account.signinUnavailable": "本版本暂不支持浏览器登录。",
|
|
37
50
|
"command.account.state": "账号:状态={status} 阶段={phase} 链接就绪={urlReady} 链接存在={links}",
|
|
38
51
|
"command.account.failed": "账号操作失败:{reason}",
|
|
39
52
|
"command.account.unknownAction": "未知账号操作:{action}(用 signin/signout)",
|
|
@@ -63,7 +76,7 @@
|
|
|
63
76
|
"command.logout.routeFailed": "{id}:登出失败 — {reason}",
|
|
64
77
|
"command.logout.done": "{name} 已登出 — 密钥已删除(路由保留)",
|
|
65
78
|
"command.logout.routeRemoved": "{name} 已登出 — 密钥与路由已删除(下次会话停在 /model)",
|
|
66
|
-
"command.logout.routeRemoveFailed": "{name}
|
|
79
|
+
"command.logout.routeRemoveFailed": "{name} 密钥已删除,但 {id} 路由未清除:{reason}。下一步:待宿主设置服务恢复后重试,或在 /settings 中删除 {id} 路由;当前没有保存任何密钥。",
|
|
67
80
|
"command.logout.unavailable": "本会话中 /logout 不可用",
|
|
68
81
|
"command.logout.none": "没有已登录的 provider",
|
|
69
82
|
"command.quit.description": "退出应用",
|
|
@@ -306,8 +319,8 @@
|
|
|
306
319
|
"settings.status.instantSave": "变更即时保存",
|
|
307
320
|
"settings.exit.title": "退出设置?",
|
|
308
321
|
"settings.exit.message": "所有变更均已保存。",
|
|
309
|
-
"settings.exit.confirm": "
|
|
310
|
-
"settings.exit.cancel": "
|
|
322
|
+
"settings.exit.confirm": "是",
|
|
323
|
+
"settings.exit.cancel": "否",
|
|
311
324
|
"settings.hint.navSections": "↑↓ 选择分区 · →/Enter 进入",
|
|
312
325
|
"settings.hint.rows": "↑↓ 选择行 · Enter 编辑 · ←/Esc 返回",
|
|
313
326
|
"settings.hint.escBack": "esc 返回",
|
|
@@ -723,12 +736,12 @@
|
|
|
723
736
|
"turn.stop.confirmChildrenOne": "1 个运行中的 subagent",
|
|
724
737
|
"turn.stop.confirmChildrenMany": "{count} 个运行中的 subagent",
|
|
725
738
|
"turn.stop.confirmMessage": "立即停止 {parts}?队列中的提示词会保留,会话仍可恢复。",
|
|
726
|
-
"turn.stop.confirmLabel": "
|
|
727
|
-
"turn.stop.cancelLabel": "
|
|
739
|
+
"turn.stop.confirmLabel": "是",
|
|
740
|
+
"turn.stop.cancelLabel": "否",
|
|
728
741
|
"turn.quit.confirmTitle": "退出 dsh-opentui?",
|
|
729
742
|
"turn.quit.confirmMessage": "结束当前会话并返回终端。",
|
|
730
|
-
"turn.quit.confirmLabel": "
|
|
731
|
-
"turn.quit.cancelLabel": "
|
|
743
|
+
"turn.quit.confirmLabel": "是",
|
|
744
|
+
"turn.quit.cancelLabel": "否",
|
|
732
745
|
"footer.hint.quit": "ctrl+c 退出",
|
|
733
746
|
"footer.hint.quit.busy": "ctrl+c 打断",
|
|
734
747
|
"footer.hint.scroll": "pgup/pgdn 滚动",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiwayds/dsh-opentui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -16,12 +16,7 @@
|
|
|
16
16
|
"scripts",
|
|
17
17
|
"dist/client",
|
|
18
18
|
"dist/bridge",
|
|
19
|
-
"dist/scripts",
|
|
20
19
|
"dist/locales",
|
|
21
|
-
"dist/host-launch.mjs",
|
|
22
|
-
"dist/host-launch.mjs.map",
|
|
23
|
-
"dist/watchdog.mjs",
|
|
24
|
-
"dist/watchdog.mjs.map",
|
|
25
20
|
"README.md",
|
|
26
21
|
"LICENSE",
|
|
27
22
|
"NOTICE",
|
|
@@ -34,18 +29,19 @@
|
|
|
34
29
|
},
|
|
35
30
|
"dependencies": {
|
|
36
31
|
"@opentui/core": "0.8.1",
|
|
37
|
-
"@opentui/solid": "0.8.1",
|
|
38
32
|
"@opentui/keymap": "0.8.1",
|
|
33
|
+
"@opentui/solid": "0.8.1",
|
|
39
34
|
"solid-js": "1.9.17",
|
|
40
|
-
"ws": "^8.22.1"
|
|
35
|
+
"ws": "^8.22.1",
|
|
36
|
+
"yaml": "2.9.1"
|
|
41
37
|
},
|
|
42
38
|
"devDependencies": {
|
|
43
|
-
"typescript": "^5.7.0",
|
|
44
|
-
"@types/bun": "latest",
|
|
45
39
|
"@deepseek-ai/cordis": "4.1.0",
|
|
46
40
|
"@deepseek-ai/dsh-llm": "0.2.2-rc.1",
|
|
47
41
|
"@deepseek-ai/schemastery": "~3.19.0",
|
|
48
|
-
"@dsh-opentui/runtime": "workspace:*"
|
|
42
|
+
"@dsh-opentui/runtime": "workspace:*",
|
|
43
|
+
"@types/bun": "latest",
|
|
44
|
+
"typescript": "^5.7.0"
|
|
49
45
|
},
|
|
50
46
|
"engines": {
|
|
51
47
|
"node": ">=26.4.0",
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// D2 user decision (2026-11-24): the companion IDs installed by default for
|
|
2
|
+
// the opentui-monday profile. IDs match `COMPANIONS[].short`; package specs and
|
|
3
|
+
// version guards stay in the catalog. `workflow` was explicitly dropped.
|
|
4
|
+
export const DEFAULT_COMPANION_IDS = [
|
|
5
|
+
'registry',
|
|
6
|
+
'ask-router',
|
|
7
|
+
'approval-policy',
|
|
8
|
+
'llm-net-retry',
|
|
9
|
+
'model-sync',
|
|
10
|
+
'llm-stats',
|
|
11
|
+
'mcp-adapter',
|
|
12
|
+
'vault',
|
|
13
|
+
'web-search',
|
|
14
|
+
'topics-memory',
|
|
15
|
+
'cron',
|
|
16
|
+
]
|
|
@@ -1,36 +1,43 @@
|
|
|
1
|
-
// Pure decision table for the `opentui-
|
|
1
|
+
// Pure decision table for the `opentui-monday` profile's companion step.
|
|
2
2
|
//
|
|
3
3
|
// No filesystem I/O, no process spawn and no ambient process.env reads in the
|
|
4
4
|
// policy functions: every input is passed in, so the catalog, the selection and
|
|
5
5
|
// the per-package install decision are unit-testable without a registry or a
|
|
6
|
-
// real dsh profile. Only `queryDistTagLatest
|
|
7
|
-
// injectable
|
|
6
|
+
// real dsh profile. Only the `queryDistTagLatest*` functions perform I/O, and
|
|
7
|
+
// they take injectable executors for the same reason.
|
|
8
8
|
//
|
|
9
9
|
// Why this table exists: the inproc profile is deliberately minimal
|
|
10
|
-
// (dsh-base + the in-process bridge + the bridge-owned approval gate).
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
// one are listed explicitly with `defaultOn: false` and are opt-in only.
|
|
10
|
+
// (dsh-base + the in-process bridge + the bridge-owned approval gate). The
|
|
11
|
+
// default roster is the D2 user decision recorded on 2026-11-24; package specs
|
|
12
|
+
// and version guards live here while the ordered default IDs live in
|
|
13
|
+
// companion-policy.mjs.
|
|
15
14
|
//
|
|
16
15
|
// Reference precedent: dsh-tui-pi 2.38.2's `bin/companion-policy.mjs` +
|
|
17
16
|
// `DSH_TUI_COMPANION_LATEST`. The switch name here follows the same style with
|
|
18
17
|
// the opentui prefix.
|
|
19
18
|
|
|
20
|
-
import { execFileSync } from 'node:child_process'
|
|
19
|
+
import { execFile, execFileSync } from 'node:child_process'
|
|
20
|
+
import { promisify } from 'node:util'
|
|
21
|
+
import { DEFAULT_COMPANION_IDS } from './companion-policy.mjs'
|
|
22
|
+
|
|
23
|
+
// One `npm view` must never hold provisioning hostage; the batch below adds a
|
|
24
|
+
// second, outer bound so a slow registry cannot stretch a launch indefinitely.
|
|
25
|
+
export const COMPANION_QUERY_TIMEOUT_MS = 9_000
|
|
26
|
+
export const COMPANION_QUERY_BUDGET_MS = 20_000
|
|
27
|
+
export const COMPANION_QUERY_CONCURRENCY = 4
|
|
21
28
|
|
|
22
29
|
/** Master kill switch. Anything other than 0/false/off (including unset) = enabled. */
|
|
23
30
|
export const COMPANION_LATEST_ENV = 'DSH_OPENTUI_COMPANION_LATEST'
|
|
24
|
-
/**
|
|
31
|
+
/** Override list of companions (comma-separated catalog IDs or full package names). */
|
|
25
32
|
export const COMPANIONS_ENV = 'DSH_OPENTUI_COMPANIONS'
|
|
26
33
|
|
|
27
34
|
/**
|
|
28
35
|
* The companion catalog.
|
|
29
36
|
*
|
|
30
|
-
* `short` is the
|
|
31
|
-
* the caret range used ONLY as a breaking-version guard against a moved
|
|
37
|
+
* `short` is the catalog ID accepted by DSH_OPENTUI_COMPANIONS. `declaredRange`
|
|
38
|
+
* is the caret range used ONLY as a breaking-version guard against a moved
|
|
32
39
|
* `latest` dist-tag (major, plus minor while still 0.x) — it is never
|
|
33
|
-
* installed. `defaultOn` marks the
|
|
40
|
+
* installed. `defaultOn` marks the D2 default roster.
|
|
34
41
|
*/
|
|
35
42
|
export const COMPANIONS = Object.freeze([
|
|
36
43
|
Object.freeze({
|
|
@@ -43,58 +50,72 @@ export const COMPANIONS = Object.freeze([
|
|
|
43
50
|
Object.freeze({
|
|
44
51
|
name: '@aiwayds/dsh-ask-router',
|
|
45
52
|
short: 'ask-router',
|
|
46
|
-
declaredRange: '^0.
|
|
47
|
-
defaultOn:
|
|
48
|
-
reason: '
|
|
53
|
+
declaredRange: '^0.8.0',
|
|
54
|
+
defaultOn: true,
|
|
55
|
+
reason: 'retained by the D2 user decision to own the ask surface for companion UI bundles.',
|
|
49
56
|
}),
|
|
50
57
|
Object.freeze({
|
|
51
58
|
name: '@aiwayds/dsh-approval-policy',
|
|
52
59
|
short: 'approval-policy',
|
|
53
60
|
declaredRange: '^0.3.0',
|
|
54
|
-
defaultOn:
|
|
55
|
-
reason: '
|
|
61
|
+
defaultOn: true,
|
|
62
|
+
reason: 'retained by the D2 user decision for tool-approval policy shared with shell approval cards.',
|
|
56
63
|
}),
|
|
57
64
|
Object.freeze({
|
|
58
65
|
name: '@aiwayds/dsh-llm-net-retry',
|
|
59
66
|
short: 'llm-net-retry',
|
|
60
67
|
declaredRange: '^0.8.0',
|
|
61
|
-
defaultOn:
|
|
62
|
-
reason: '
|
|
68
|
+
defaultOn: true,
|
|
69
|
+
reason: 'retained by the D2 user decision to retry transient provider and network failures.',
|
|
63
70
|
}),
|
|
64
71
|
Object.freeze({
|
|
65
72
|
name: '@aiwayds/dsh-model-sync',
|
|
66
73
|
short: 'model-sync',
|
|
67
|
-
declaredRange: '^0.
|
|
68
|
-
defaultOn:
|
|
69
|
-
reason: 'the
|
|
74
|
+
declaredRange: '^0.10.0',
|
|
75
|
+
defaultOn: true,
|
|
76
|
+
reason: 'retained by the D2 user decision to keep the profile model list in sync with the provider catalog.',
|
|
70
77
|
}),
|
|
71
78
|
Object.freeze({
|
|
72
79
|
name: '@aiwayds/dsh-llm-stats',
|
|
73
80
|
short: 'llm-stats',
|
|
74
81
|
declaredRange: '^0.9.0',
|
|
75
|
-
defaultOn:
|
|
76
|
-
reason: '
|
|
82
|
+
defaultOn: true,
|
|
83
|
+
reason: 'retained by the D2 user decision for token and cost accounting behind /usage.',
|
|
77
84
|
}),
|
|
78
85
|
Object.freeze({
|
|
79
86
|
name: '@aiwayds/dsh-mcp-adapter',
|
|
80
87
|
short: 'mcp-adapter',
|
|
81
88
|
declaredRange: '^0.8.0',
|
|
82
|
-
defaultOn:
|
|
83
|
-
reason: 'the
|
|
89
|
+
defaultOn: true,
|
|
90
|
+
reason: 'retained by the D2 user decision for MCP catalog and dispatch meta-tools paired with the context7 server row.',
|
|
91
|
+
}),
|
|
92
|
+
Object.freeze({
|
|
93
|
+
name: '@aiwayds/dsh-vault',
|
|
94
|
+
short: 'vault',
|
|
95
|
+
declaredRange: '^0.8.2',
|
|
96
|
+
defaultOn: true,
|
|
97
|
+
reason: 'retained by the D2 user decision for secret storage used by companion plugins.',
|
|
84
98
|
}),
|
|
85
99
|
Object.freeze({
|
|
86
100
|
name: '@aiwayds/dsh-web-search-anysearch',
|
|
87
101
|
short: 'web-search',
|
|
88
102
|
declaredRange: '^0.9.0',
|
|
89
|
-
defaultOn:
|
|
90
|
-
reason: '
|
|
103
|
+
defaultOn: true,
|
|
104
|
+
reason: 'retained by the D2 user decision for web search without a per-provider key.',
|
|
91
105
|
}),
|
|
92
106
|
Object.freeze({
|
|
93
|
-
name: '@aiwayds/dsh-
|
|
94
|
-
short: '
|
|
95
|
-
declaredRange: '^0.
|
|
96
|
-
defaultOn:
|
|
97
|
-
reason: '
|
|
107
|
+
name: '@aiwayds/dsh-topics-memory',
|
|
108
|
+
short: 'topics-memory',
|
|
109
|
+
declaredRange: '^0.26.0',
|
|
110
|
+
defaultOn: true,
|
|
111
|
+
reason: 'added by the D2 user decision for cross-session topic memory.',
|
|
112
|
+
}),
|
|
113
|
+
Object.freeze({
|
|
114
|
+
name: '@aiwayds/dsh-cron',
|
|
115
|
+
short: 'cron',
|
|
116
|
+
declaredRange: '^0.7.0',
|
|
117
|
+
defaultOn: true,
|
|
118
|
+
reason: 'added by the D2 user decision for scheduled prompts.',
|
|
98
119
|
}),
|
|
99
120
|
])
|
|
100
121
|
|
|
@@ -109,14 +130,18 @@ export function companionLatestEnabled(env = process.env) {
|
|
|
109
130
|
* The companions this launch should satisfy.
|
|
110
131
|
* - master switch off => no companions at all (non-destructive: already
|
|
111
132
|
* installed packages are left in place, they are just not queried/installed)
|
|
112
|
-
* - DSH_OPENTUI_COMPANIONS unset =>
|
|
113
|
-
* - explicit list =>
|
|
133
|
+
* - DSH_OPENTUI_COMPANIONS unset => DEFAULT_COMPANION_IDS, in policy order
|
|
134
|
+
* - explicit list => default set is replaced by the named entries;
|
|
114
135
|
* `none` means empty, `all` means the whole catalog.
|
|
115
136
|
*/
|
|
116
137
|
export function selectCompanions(env = process.env) {
|
|
117
138
|
if (!companionLatestEnabled(env)) return []
|
|
118
139
|
const raw = env[COMPANIONS_ENV]
|
|
119
|
-
if (raw === undefined || String(raw).trim() === '')
|
|
140
|
+
if (raw === undefined || String(raw).trim() === '') {
|
|
141
|
+
return DEFAULT_COMPANION_IDS
|
|
142
|
+
.map((id) => COMPANIONS.find((entry) => entry.short === id))
|
|
143
|
+
.filter(Boolean)
|
|
144
|
+
}
|
|
120
145
|
const tokens = String(raw).split(',').map((token) => token.trim()).filter(Boolean)
|
|
121
146
|
if (tokens.includes('none')) return []
|
|
122
147
|
if (tokens.includes('all')) return [...COMPANIONS]
|
|
@@ -203,7 +228,7 @@ export function queryDistTagLatest(name, { cwd, env, exec } = {}) {
|
|
|
203
228
|
cwd,
|
|
204
229
|
env,
|
|
205
230
|
encoding: 'utf8',
|
|
206
|
-
timeout:
|
|
231
|
+
timeout: COMPANION_QUERY_TIMEOUT_MS,
|
|
207
232
|
})
|
|
208
233
|
const tags = JSON.parse(typeof out === 'string' ? out : String(out?.stdout ?? ''))
|
|
209
234
|
return typeof tags?.latest === 'string' ? normalizeVersion(tags.latest) : null
|
|
@@ -211,3 +236,68 @@ export function queryDistTagLatest(name, { cwd, env, exec } = {}) {
|
|
|
211
236
|
return null
|
|
212
237
|
}
|
|
213
238
|
}
|
|
239
|
+
|
|
240
|
+
const execFileAsync = promisify(execFile)
|
|
241
|
+
|
|
242
|
+
/** Async twin of `queryDistTagLatest`, used by the bounded concurrent batch. */
|
|
243
|
+
export async function queryDistTagLatestAsync(name, { cwd, env, exec } = {}) {
|
|
244
|
+
const run = exec ?? execFileAsync
|
|
245
|
+
try {
|
|
246
|
+
const out = await run('npm', ['view', name, 'dist-tags', '--json'], {
|
|
247
|
+
cwd,
|
|
248
|
+
env,
|
|
249
|
+
encoding: 'utf8',
|
|
250
|
+
timeout: COMPANION_QUERY_TIMEOUT_MS,
|
|
251
|
+
})
|
|
252
|
+
const stdout = typeof out === 'string' ? out : String(out?.stdout ?? '')
|
|
253
|
+
const tags = JSON.parse(stdout)
|
|
254
|
+
return typeof tags?.latest === 'string' ? normalizeVersion(tags.latest) : null
|
|
255
|
+
} catch {
|
|
256
|
+
return null
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Query every name with bounded concurrency and a total wall-clock budget.
|
|
262
|
+
*
|
|
263
|
+
* Results land at the INPUT index (never completion order), so callers stay
|
|
264
|
+
* deterministic. A per-item failure — including a thrown injected query — is
|
|
265
|
+
* swallowed into `null`, which is exactly the existing "unresolved" fallback;
|
|
266
|
+
* provisioning never aborts because one registry lookup failed or timed out.
|
|
267
|
+
* New lookups stop once the budget is spent; lookups already in flight still
|
|
268
|
+
* settle on their own shorter timeout.
|
|
269
|
+
*/
|
|
270
|
+
export async function queryDistTagLatestBatch(
|
|
271
|
+
names,
|
|
272
|
+
{
|
|
273
|
+
cwd,
|
|
274
|
+
env,
|
|
275
|
+
query = queryDistTagLatestAsync,
|
|
276
|
+
concurrency = COMPANION_QUERY_CONCURRENCY,
|
|
277
|
+
budgetMs = COMPANION_QUERY_BUDGET_MS,
|
|
278
|
+
now = () => Date.now(),
|
|
279
|
+
} = {},
|
|
280
|
+
) {
|
|
281
|
+
const results = new Array(names.length).fill(null)
|
|
282
|
+
const deadline = now() + budgetMs
|
|
283
|
+
let cursor = 0
|
|
284
|
+
const worker = async () => {
|
|
285
|
+
while (cursor < names.length && now() < deadline) {
|
|
286
|
+
const index = cursor++
|
|
287
|
+
try {
|
|
288
|
+
results[index] = await query(names[index], { cwd, env })
|
|
289
|
+
} catch {
|
|
290
|
+
results[index] = null
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
const lanes = Math.max(1, Math.min(concurrency, names.length))
|
|
295
|
+
await Promise.all(Array.from({ length: lanes }, worker))
|
|
296
|
+
return results
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/** One summary line for skipped companions, or null when every one succeeded. */
|
|
300
|
+
export function formatSkippedCompanionsWarning(shortNames = []) {
|
|
301
|
+
if (shortNames.length === 0) return null
|
|
302
|
+
return `${shortNames.length} companion(s) skipped (version query failed or outside declared range): ${shortNames.join(', ')}`
|
|
303
|
+
}
|