@dsh-plus/subagent-model 0.1.10 → 0.2.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.
@@ -1,65 +0,0 @@
1
- /**
2
- * 配置卡片文案(zh/en)。经 ctx.locale.register 注册、bind 取用,与官方卡片同机制。
3
- * 公共键(save/discard/unsaved 等)来自 shared 的 common 字典,本文件只维护业务键。
4
- * @module subagent-model/client/i18n
5
- */
6
- import { commonEn, commonZh, mergeDict } from '@dsh-plus/shared/client'
7
-
8
- export const NS = 'dsh-plus-subagent-model'
9
-
10
- const ownZh = {
11
- title: '子代理模型配置',
12
- description: '为 subagent / subagent_fork 等子代理单独指定提供商、模型与思考程度,或继承主代理。',
13
- enabled: '启用插件',
14
- rowEnabled: '启用该行',
15
- provider: '提供商',
16
- model: '模型',
17
- effort: '思考程度',
18
- inheritProvider: '继承主代理',
19
- inheritModel: '继承主代理',
20
- effortInherit: '继承主代理',
21
- effortDefault: '跟随模型默认',
22
- providerHint: '留空 = 子代理沿用主代理的提供商与模型。',
23
- modelHint: '留空 = 沿用主代理的模型(需与所选提供商匹配)。',
24
- effortHint: 'inherit = 不干预(fork 会随会话继承);default = 显式使用模型默认档位。',
25
- rowHint:
26
- '按子代理 provider 名匹配;standard preset 中 spawn ↔ subagent 工具、fork ↔ subagent_fork 工具。',
27
- rowDesc: '未注册的 provider 行不生效,可保留待用。',
28
- noRows: '当前未发现子代理 provider;配置将在 provider 注册后生效。',
29
- catalogError: '提供商目录加载失败:',
30
- catalogRetry: '重试',
31
- catalogLoading: '目录加载中…',
32
- unknownValue: '目录外',
33
- invalidModel: '模型不能脱离提供商单独配置。',
34
- }
35
-
36
- const ownEn = {
37
- title: 'Subagent model config',
38
- description:
39
- 'Pick a provider, model, and thinking effort for subagent / subagent_fork children, or inherit from the main agent.',
40
- enabled: 'Enable plugin',
41
- rowEnabled: 'Enable row',
42
- provider: 'Provider',
43
- model: 'Model',
44
- effort: 'Effort',
45
- inheritProvider: 'Inherit from main agent',
46
- inheritModel: 'Inherit from main agent',
47
- effortInherit: 'Inherit from main agent',
48
- effortDefault: 'Follow model default',
49
- providerHint: 'Empty = the child follows the main agent\u2019s provider and model.',
50
- modelHint: 'Empty = follow the main agent\u2019s model (must match the chosen provider).',
51
- effortHint:
52
- 'inherit = do not touch (forks inherit via session seed); default = explicitly use the model\u2019s default level.',
53
- rowHint:
54
- 'Matched by subagent provider name; in the standard preset spawn \u2194 subagent tool, fork \u2194 subagent_fork tool.',
55
- rowDesc: 'Rows for unregistered providers are inert; keep them for later.',
56
- noRows: 'No subagent provider registered yet; config takes effect once one appears.',
57
- catalogError: 'Failed to load provider catalog: ',
58
- catalogRetry: 'Retry',
59
- catalogLoading: 'Loading catalog\u2026',
60
- unknownValue: 'outside catalog',
61
- invalidModel: 'Model cannot be set without a provider.',
62
- }
63
-
64
- export const zh: Record<string, string> = mergeDict(commonZh, ownZh)
65
- export const en: Record<string, string> = mergeDict(commonEn, ownEn)
@@ -1,30 +0,0 @@
1
- /**
2
- * 配置卡片样式:基础规则走 @dsh-plus/shared/client 的 cardCss('dsm'),
3
- * 本文件只补插件特有规则(provider 行块 / banner / 目录空态)。
4
- * 沿用官方 data-plugin / data-plugin-css 约定(HMR 据此卸载)。
5
- * @module subagent-model/client/styles
6
- */
7
- import { cardCss, injectCardStyle } from '@dsh-plus/shared/client'
8
-
9
- export const PLUGIN_ID = '@dsh-plus/subagent-model'
10
-
11
- const extraCss = `
12
- .dsm-row{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-2);border-radius:10px;margin:12px 0 0;padding:4px 12px 10px}
13
- .dsm-rowHead{align-items:center;gap:8px;padding:8px 0 2px;display:flex}
14
- .dsm-rowName{min-width:0;color:var(--dsw-alias-label-primary);flex:1;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:13px;font-weight:600;line-height:1.5}
15
- .dsm-rowHint{color:var(--dsw-alias-label-tertiary);margin:0 0 4px;font-size:12px;line-height:1.5}
16
- .dsm-banner{background:var(--dsw-alias-interactive-bg-hover-danger);color:var(--dsw-alias-state-error-primary);justify-content:space-between;align-items:center;gap:8px;border-radius:8px;margin-top:12px;padding:7px 8px;font-size:12px;line-height:18px;display:flex}
17
- .dsm-bannerRetry{color:inherit;font:inherit;cursor:pointer;background:0 0;border:none;flex:none;padding:0;font-weight:600}
18
- .dsm-empty{color:var(--dsw-alias-label-tertiary);margin:12px 0 0;font-size:12px;line-height:1.5}
19
- @media (max-width:767px){
20
- .dsm-row{padding:2px 8px 8px}
21
- .dsm-rowHead{flex-wrap:wrap}
22
- }
23
- `
24
-
25
- export const cardCssAll = cardCss('dsm', extraCss)
26
-
27
- /** 幂等注入样式标签;返回标签(已存在或环境无 document 时为 null)。 */
28
- export function injectStyle(): HTMLStyleElement | null {
29
- return injectCardStyle(PLUGIN_ID, cardCssAll)
30
- }
package/src/config-api.ts DELETED
@@ -1,53 +0,0 @@
1
- /**
2
- * 自定义端点 HTTP 通道:配置读写已迁移到官方 settings RPC(rc7 起第三方
3
- * 命名空间全量开放),这里只保留官方传输没有的「模型目录」端点。
4
- * 仅监听 dsh web 同源(webserver 默认 127.0.0.1),与 GUI 其余面同等暴露面。
5
- * @module subagent-model/config-api
6
- */
7
- import type { IncomingMessage, ServerResponse } from 'node:http'
8
-
9
- import type { Context } from '@deepseek-ai/cordis'
10
-
11
- import { buildModelCatalog, type ModelCatalog } from './catalog.ts'
12
-
13
- const ROUTE_CATALOG = '/dsh-plus/subagent-model/catalog'
14
-
15
- function sendJson(res: ServerResponse, status: number, body: unknown): void {
16
- res.writeHead(status, { 'content-type': 'application/json; charset=utf-8' })
17
- res.end(JSON.stringify(body))
18
- }
19
-
20
- async function handleCatalog(ctx: Context, res: ServerResponse): Promise<void> {
21
- const catalog: ModelCatalog = await buildModelCatalog(ctx)
22
- sendJson(res, 200, catalog)
23
- }
24
-
25
- /** 注册目录路由;返回是否注册成功(webServer 缺失时由调用方保证不调用)。 */
26
- export function registerCatalogApi(ctx: Context): void {
27
- const logger = ctx.logger('subagent-model')
28
- const guard = (
29
- handler: (req: IncomingMessage, res: ServerResponse) => Promise<void>,
30
- ): ((req: IncomingMessage, res: ServerResponse) => Promise<void>) => {
31
- return async (req, res) => {
32
- try {
33
- await handler(req, res)
34
- } catch (error) {
35
- const message = error instanceof Error ? error.message : String(error)
36
- logger.warn(`catalog api ${req.method ?? '?'} ${req.url ?? '?'} failed: ${message}`)
37
- if (!res.headersSent) sendJson(res, 400, { error: message })
38
- else res.end()
39
- }
40
- }
41
- }
42
- ctx.webServer.register({
43
- kind: 'exact',
44
- path: ROUTE_CATALOG,
45
- handler: guard(async (req, res) => {
46
- if (req.method !== 'GET') {
47
- sendJson(res, 405, { error: 'method not allowed' })
48
- return
49
- }
50
- await handleCatalog(ctx, res)
51
- }),
52
- })
53
- }