dsh-my-go 0.4.1 → 0.4.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/lib/index.js +37 -28
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -589,19 +589,21 @@ export async function apply(ctx, config = {}) {
|
|
|
589
589
|
// mjs files degrades to defaults instead of failing the preset mount.
|
|
590
590
|
const mod = await import('@deepseek-ai/schemastery')
|
|
591
591
|
const z = mod.default ?? mod
|
|
592
|
+
// schemastery 字段默认 nullable(missing→undefined),.required() 才强制;
|
|
593
|
+
// 无 .optional() 方法——直接不加 .required() 即为可选。
|
|
592
594
|
const agentSchema = z.object({
|
|
593
|
-
provider: z.string(),
|
|
594
|
-
model: z.string(),
|
|
595
|
-
reasoningEffort: z.string(),
|
|
596
|
-
dsv4p0813: z.boolean(),
|
|
595
|
+
provider: z.string().default(''),
|
|
596
|
+
model: z.string().default(''),
|
|
597
|
+
reasoningEffort: z.string().default(''),
|
|
598
|
+
dsv4p0813: z.boolean().default(false),
|
|
597
599
|
// 错峰路由(peak routing):开启后按北京时间高峰/非高峰时段在
|
|
598
|
-
// 两套 provider/model
|
|
599
|
-
//
|
|
600
|
-
peakRouting: z.boolean()
|
|
601
|
-
peakProvider: z.string()
|
|
602
|
-
peakModel: z.string()
|
|
603
|
-
offpeakProvider: z.string()
|
|
604
|
-
offpeakModel: z.string()
|
|
600
|
+
// 两套 provider/model 之间切换。不加 .required() 即为可选,
|
|
601
|
+
// 旧存储配置无这些字段时自动兼容(missing→undefined)。
|
|
602
|
+
peakRouting: z.boolean(),
|
|
603
|
+
peakProvider: z.string(),
|
|
604
|
+
peakModel: z.string(),
|
|
605
|
+
offpeakProvider: z.string(),
|
|
606
|
+
offpeakModel: z.string(),
|
|
605
607
|
})
|
|
606
608
|
settingsScope = settings.register(
|
|
607
609
|
'dsh-my-go',
|
|
@@ -662,8 +664,8 @@ export async function apply(ctx, config = {}) {
|
|
|
662
664
|
bindings = merged
|
|
663
665
|
}
|
|
664
666
|
})
|
|
665
|
-
} catch {
|
|
666
|
-
|
|
667
|
+
} catch (e) {
|
|
668
|
+
console.warn('[dsh-my-go] settings registration failed (defaults apply):', e)
|
|
667
669
|
}
|
|
668
670
|
}
|
|
669
671
|
|
|
@@ -883,30 +885,37 @@ export async function apply(ctx, config = {}) {
|
|
|
883
885
|
}
|
|
884
886
|
if (endpoint === 'saveSettings') {
|
|
885
887
|
const draft = payload
|
|
886
|
-
if (!draft || typeof draft !== 'object') return { ok: false, error: { code: '
|
|
888
|
+
if (!draft || typeof draft !== 'object') return { ok: false, error: { code: 'internal', message: 'payload must be an object', details: {} } }
|
|
887
889
|
const settingsService = ctx.get('settings')
|
|
888
|
-
if (!settingsService) return { ok: false, error: { code: '
|
|
890
|
+
if (!settingsService) return { ok: false, error: { code: 'internal', message: 'settings service not available', details: {} } }
|
|
889
891
|
try {
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
892
|
+
// 优先使用 settingsScope.replace(整段替换),比 mutate 更稳健;
|
|
893
|
+
// 降级到 mutate(path ops)兜底。
|
|
894
|
+
if (settingsScope && typeof settingsScope.replace === 'function') {
|
|
895
|
+
await settingsScope.replace(draft)
|
|
896
|
+
} else {
|
|
897
|
+
const agentTypes = ['sisyphus', 'hermes', 'explore', 'librarian', 'looker', 'hephaestus', 'prometheus', 'oracle']
|
|
898
|
+
const fields = ['provider', 'model', 'reasoningEffort', 'dsv4p0813', 'peakRouting', 'peakProvider', 'peakModel', 'offpeakProvider', 'offpeakModel']
|
|
899
|
+
const ops = []
|
|
900
|
+
for (const type of agentTypes) {
|
|
901
|
+
for (const field of fields) {
|
|
902
|
+
const val = draft[type]?.[field]
|
|
903
|
+
if (val === undefined || val === null || val === '') {
|
|
904
|
+
ops.push({ op: 'unset', path: [type, field] })
|
|
905
|
+
} else {
|
|
906
|
+
ops.push({ op: 'set', path: [type, field], value: val })
|
|
907
|
+
}
|
|
900
908
|
}
|
|
901
909
|
}
|
|
910
|
+
if (ops.length > 0) await settingsService.mutate('dsh-my-go', ops)
|
|
902
911
|
}
|
|
903
|
-
if (ops.length > 0) await settingsService.mutate('dsh-my-go', ops)
|
|
904
912
|
return { ok: true, value: null }
|
|
905
913
|
} catch (e) {
|
|
906
|
-
|
|
914
|
+
console.error('[dsh-my-go] saveSettings failed:', e)
|
|
915
|
+
return { ok: false, error: { code: 'settings-rejected', message: String(e), details: { ns: 'dsh-my-go' } } }
|
|
907
916
|
}
|
|
908
917
|
}
|
|
909
|
-
return { ok: false, error: { code: '
|
|
918
|
+
return { ok: false, error: { code: 'internal', message: `unknown endpoint: ${endpoint}`, details: {} } }
|
|
910
919
|
}, { authority: 'trusted-host' })
|
|
911
920
|
})
|
|
912
921
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-my-go",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "DSH plugin: Sisyphus agent orchestration — star topology, single-line blocking, 7 specialist sub-agents (Hermes/Explore/Librarian/Looker/Hephaestus/Prometheus/Oracle) with per-type model binding, go_work/continue/need_help/forward communication tools, Web UI tree panel and settings.",
|
|
5
5
|
"author": "Tisitan",
|
|
6
6
|
"license": "MIT",
|