dsh-nova-lewis 0.2.3 → 0.2.5
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.cn.md +5 -5
- package/README.md +8 -8
- package/dist/client.js +1593 -166
- package/host/chat-replies.css +52 -0
- package/host/chat-replies.mjs +151 -0
- package/host/client.mjs +4 -0
- package/host/index.mjs +28 -25
- package/host/models.mjs +53 -13
- package/host/reply-view.mjs +85 -0
- package/host/roll-call.mjs +12 -29
- package/host/selection.mjs +13 -1
- package/package.json +3 -3
- package/src/easter-egg.mjs +5 -3
- package/src/engine-plan.mjs +4 -34
- package/src/engine.mjs +55 -15
- package/src/knowledge-intelligence.mjs +20 -0
- package/src/model-knowledge.mjs +8 -2
- package/src/preset-catalog.mjs +10 -3
- package/src/role-routing.mjs +41 -10
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-nova-lewis",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"lewisEnchantRelease": {
|
|
5
|
-
"version": "0.2.
|
|
5
|
+
"version": "0.2.5",
|
|
6
6
|
"notes": ""
|
|
7
7
|
},
|
|
8
8
|
"lewisEnchantReleaseEn": {
|
|
9
|
-
"version": "0.2.
|
|
9
|
+
"version": "0.2.5",
|
|
10
10
|
"notes": ""
|
|
11
11
|
},
|
|
12
12
|
"type": "module",
|
package/src/easter-egg.mjs
CHANGED
|
@@ -15,6 +15,10 @@ const closings = [
|
|
|
15
15
|
'**NOVA:Present and shining! ✧**',
|
|
16
16
|
]
|
|
17
17
|
|
|
18
|
+
export function hasRollCallClosing(markdown) {
|
|
19
|
+
return typeof markdown === 'string' && closings.some(line => markdown === line || markdown.endsWith('\n\n' + line))
|
|
20
|
+
}
|
|
21
|
+
|
|
18
22
|
// Draw every item once before refilling. At a cycle boundary avoid repeating the last draw.
|
|
19
23
|
function drawFrom(items, random) {
|
|
20
24
|
let pool = [], previous
|
|
@@ -71,9 +75,7 @@ function markdownText(value) {
|
|
|
71
75
|
}
|
|
72
76
|
|
|
73
77
|
export function formatEggReply(route, text) {
|
|
74
|
-
|
|
75
|
-
const name = provider ? provider+' / '+modelName(route) : modelName(route)
|
|
76
|
-
return '**'+markdownText(name)+'**:'+markdownText(text)
|
|
78
|
+
return '**'+markdownText(modelName(route))+'**:'+markdownText(text)
|
|
77
79
|
}
|
|
78
80
|
|
|
79
81
|
export function chooseNovaClosing(random = Math.random) {
|
package/src/engine-plan.mjs
CHANGED
|
@@ -79,44 +79,14 @@ export function normalizeNodes(plan, maxNodes = 100) {
|
|
|
79
79
|
return nodes
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
// A coordinator can describe the work without enumerating a large roster in its JSON.
|
|
83
|
-
// Give each remaining selected text route its own artifact and wire it into the existing final.
|
|
84
|
-
export function includeSelectedContributors(state, nodes) {
|
|
85
|
-
const final = nodes.find(node => node.final && !node.optional)
|
|
86
|
-
if (!final) return
|
|
87
|
-
const assigned = new Set(nodes.map(node => node.routeId))
|
|
88
|
-
const allowed = new Set(state.allowedRouteIds)
|
|
89
|
-
const ids = new Set(nodes.map(node => node.id))
|
|
90
|
-
const deliverables = new Set(nodes.map(node => node.deliverable.trim().normalize('NFKC').toLowerCase()))
|
|
91
|
-
const finalSources = state.sources.filter(source => final.sourceIds.includes(source.id))
|
|
92
|
-
const extra = []
|
|
93
|
-
let ordinal = 0
|
|
94
|
-
for (const route of state.routes) {
|
|
95
|
-
if (!allowed.has(route.id) || assigned.has(route.id) || route.enabled === false || !(route.capabilities ?? ['text']).includes('text')) continue
|
|
96
|
-
let id, deliverable
|
|
97
|
-
do {
|
|
98
|
-
ordinal++
|
|
99
|
-
id = 'contributor-' + ordinal
|
|
100
|
-
deliverable = '独立建议 ' + ordinal
|
|
101
|
-
} while (ids.has(id) || deliverables.has(deliverable))
|
|
102
|
-
extra.push({id, title:'独立建议 · '+(route.label || route.modelId || route.id), role:'contributor', routeId:route.id,
|
|
103
|
-
deliverable, acceptance:'就当前任务给出具体、可核查的建议。', optional:true,
|
|
104
|
-
instructions:'独立提出对当前任务有帮助的结论、依据或需要核实的问题,交给最终负责人参考。',
|
|
105
|
-
sourceIds:finalSources.filter(source => mayRead(source, route)).map(source => source.id),
|
|
106
|
-
assignment:{routeId:route.id, role:'contributor', source:'selection', reasons:['此型号已勾选参与,本次独立提供建议。'], evidence:[]}})
|
|
107
|
-
}
|
|
108
|
-
if (!extra.length) return
|
|
109
|
-
for (const contributor of normalizeNodes({nodes:extra}, extra.length)) {
|
|
110
|
-
nodes.push(contributor)
|
|
111
|
-
final.deps.push(contributor.id)
|
|
112
|
-
}
|
|
113
|
-
final.instructions = [final.instructions, '结合直接上游各型号的独立建议,核实后给出最终答复。'].filter(Boolean).join('\n')
|
|
114
|
-
}
|
|
115
|
-
|
|
116
82
|
export function positiveNumber(value) {
|
|
117
83
|
return Number.isSafeInteger(value) && value > 0 ? value : 0
|
|
118
84
|
}
|
|
119
85
|
|
|
86
|
+
export function mayModifyWorkspace(node) {
|
|
87
|
+
return Boolean(node.writePaths?.length || node.tools?.some(tool => ['write','edit','bash'].includes(tool)))
|
|
88
|
+
}
|
|
89
|
+
|
|
120
90
|
export function inheritedSources(state, node) {
|
|
121
91
|
const ids = new Set()
|
|
122
92
|
const seen = new Set()
|
package/src/engine.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { assignmentsHash, copy, descendants, incompatibility, inheritedSources, mayRead,
|
|
1
|
+
import { assignmentsHash, copy, descendants, incompatibility, inheritedSources, mayRead, mayModifyWorkspace,
|
|
2
2
|
normalizeNodes, positiveNumber, routeCatalog, strings, uid, writeConflict } from './engine-plan.mjs'
|
|
3
3
|
import { estimateInput } from './context.mjs'
|
|
4
4
|
import { assessReview, reviewDecisions } from './engine-review.mjs'
|
|
5
|
-
import {choosePlanner} from './role-routing.mjs'
|
|
5
|
+
import {choosePlanner, permitsDirectAnswer} from './role-routing.mjs'
|
|
6
6
|
import {nodeRole} from './model-knowledge.mjs'
|
|
7
7
|
|
|
8
8
|
export { normalizeNodes as validatePlan } from './engine-plan.mjs'
|
|
@@ -87,8 +87,7 @@ function beginAttempt(state, node, route, kind, reserved) {
|
|
|
87
87
|
|
|
88
88
|
function publish(state, plan, fromPlanner = false) {
|
|
89
89
|
if (plan?.validationError) throw Error(String(plan.validationError))
|
|
90
|
-
const limit = state.settings.easterEgg ? state.allowedRouteIds.length :
|
|
91
|
-
state.settings.includeAllParticipants ? 100 + state.allowedRouteIds.length : undefined
|
|
90
|
+
const limit = state.settings.easterEgg ? state.allowedRouteIds.length : 100 + state.allowedRouteIds.length
|
|
92
91
|
const nodes = normalizeNodes(plan, limit)
|
|
93
92
|
if (fromPlanner && nodes.length > 1) {
|
|
94
93
|
const byId = new Map(nodes.map(n => [n.id, n])), prerequisites = new Set()
|
|
@@ -100,8 +99,11 @@ function publish(state, plan, fromPlanner = false) {
|
|
|
100
99
|
const required = nodes.filter(node => !node.optional)
|
|
101
100
|
required.forEach(node => node.deps.forEach(include))
|
|
102
101
|
const terminals = required.filter(node => !prerequisites.has(node.id))
|
|
103
|
-
if (terminals.length
|
|
104
|
-
|
|
102
|
+
if (!terminals.length || (terminals.length > 1 && !terminals.every(n => n.final))) {
|
|
103
|
+
throw Error('统一交付须由最后一个工作或合稿节点覆盖所有必需成果;分别交付时须为每个独立终点声明 final:true。当前终点:' + terminals.map(n=>n.id).join('、'))
|
|
104
|
+
}
|
|
105
|
+
const finalIds = new Set(terminals.map(n => n.id))
|
|
106
|
+
nodes.forEach(n => { n.final = finalIds.has(n.id) })
|
|
105
107
|
}
|
|
106
108
|
for (const node of nodes) {
|
|
107
109
|
if (!state.routes.some(route => route.id === node.routeId)) throw Error(node.id + ' 指定了目录外路由:' + node.routeId)
|
|
@@ -112,7 +114,6 @@ function publish(state, plan, fromPlanner = false) {
|
|
|
112
114
|
if (!state.sources.some(source => source.id === id)) throw Error(node.id + ' 引用了不存在的资料:' + id)
|
|
113
115
|
}
|
|
114
116
|
}
|
|
115
|
-
if (fromPlanner && state.settings.includeAllParticipants) includeSelectedContributors(state, nodes)
|
|
116
117
|
state.nodes = nodes
|
|
117
118
|
state.planVersion += 1
|
|
118
119
|
state.assignmentsHash = assignmentsHash(state)
|
|
@@ -126,6 +127,26 @@ function checkpoint(result) {
|
|
|
126
127
|
if (result.accepted === false) throw Error(String(result.reason || '交付物未通过验收'))
|
|
127
128
|
}
|
|
128
129
|
|
|
130
|
+
function directAnswerText(result, permitted) {
|
|
131
|
+
if (result?.answer === undefined) return
|
|
132
|
+
if (!permitted || result.nodes !== undefined || result.validationError) throw Error('本次须先提交分工计划。')
|
|
133
|
+
checkpoint({text:result.answer})
|
|
134
|
+
return result.answer
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function publishDirectAnswer(state, attempt, text, hash) {
|
|
138
|
+
publish(state, {rationale:'统筹模型直接完成本次问答。', nodes:[{id:'answer',title:'统筹直接答复',role:'final',
|
|
139
|
+
routeId:attempt.routeId, final:true, sourceIds:state.sources.filter(s=>mayRead(s,attempt.route)).map(s=>s.id),
|
|
140
|
+
deliverable:'答复',acceptance:'完整回答本条问题。'}]}, true)
|
|
141
|
+
const answer = state.nodes[0]
|
|
142
|
+
Object.assign(answer, {attemptId:attempt.id, startedAt:attempt.startedAt, context:attempt.context})
|
|
143
|
+
Object.assign(attempt, {nodeId:answer.id, directAnswer:true, phase:'delivered'})
|
|
144
|
+
commitArtifact(state, answer, attempt, {text}, hash)
|
|
145
|
+
state.confirmedVersion = state.planVersion
|
|
146
|
+
state.confirmedHash = state.assignmentsHash
|
|
147
|
+
state.status = 'completed'
|
|
148
|
+
}
|
|
149
|
+
|
|
129
150
|
function missingInputs(state, node) {
|
|
130
151
|
const missing = []
|
|
131
152
|
for (const depId of node.deps) {
|
|
@@ -231,7 +252,7 @@ function recordUnsent(state, attempt, error) {
|
|
|
231
252
|
function largerPlanningOutput(state, attempt, error) {
|
|
232
253
|
if (error.finishKind !== 'max-tokens' || !positiveNumber(error.maxTokens) || !Number.isSafeInteger(error.inputEstimate)) return 0
|
|
233
254
|
const route = state.routes.find(r => r.id === attempt.routeId && r.enabled !== false)
|
|
234
|
-
const node = {id:'plan', routeId:attempt.routeId}
|
|
255
|
+
const node = {id:'plan', routeId:attempt.routeId, final:attempt.usesFinalReserve}
|
|
235
256
|
if (!route || limitReason(state,node).reason) return 0
|
|
236
257
|
const window = Math.min(...[route.contextWindow,route.window,route.deploymentWindow].filter(positiveNumber))
|
|
237
258
|
const available = state.maxTokens == null ? Infinity : remainingTokens(state,node) - error.inputEstimate
|
|
@@ -407,6 +428,9 @@ export class RunEngine {
|
|
|
407
428
|
|
|
408
429
|
async #runPlanner(planner) {
|
|
409
430
|
const initial = this.#state.plannerAssignment
|
|
431
|
+
// The planner receives a material index; only permitted conversation history is sent in full.
|
|
432
|
+
const allowDirectAnswer = this.#state.mode === 'auto' && this.#state.sources.every(s=>s.id===initial?.historySourceId) &&
|
|
433
|
+
permitsDirectAnswer(this.#state.task)
|
|
410
434
|
const initialPlannerId = this.#state.plannerRouteId
|
|
411
435
|
const plannerIds = [...new Set([initialPlannerId, ...(initial?.fallbackRouteIds || [])])]
|
|
412
436
|
let index = 0, correction = '', revising = false, planningOutputTokens = 4096, expanded = false
|
|
@@ -428,7 +452,11 @@ export class RunEngine {
|
|
|
428
452
|
}
|
|
429
453
|
const route = eligible.get(selected.id)
|
|
430
454
|
const node = {id:'plan', revision:1, routeId:route.id, outputReserve:planningOutputTokens}
|
|
431
|
-
|
|
455
|
+
let budget = limitReason(state, node)
|
|
456
|
+
if (budget.reason && allowDirectAnswer) {
|
|
457
|
+
node.final = true
|
|
458
|
+
budget = limitReason(state, node)
|
|
459
|
+
}
|
|
432
460
|
if (budget.reason) throw Error(budget.reason)
|
|
433
461
|
if (selected.retryAfter) return {type:'planning.waiting_for_provider',retryAfter:selected.retryAfter}
|
|
434
462
|
if (state.plannerRouteId !== route.id) {
|
|
@@ -440,6 +468,8 @@ export class RunEngine {
|
|
|
440
468
|
const attempt = beginAttempt(state,node,route,kind,budget.reserved)
|
|
441
469
|
attempt.plannedRouteId = initialPlannerId
|
|
442
470
|
attempt.planningOutputTokens = planningOutputTokens
|
|
471
|
+
if (allowDirectAnswer) attempt.allowDirectAnswer = true
|
|
472
|
+
if (node.final) attempt.usesFinalReserve = true
|
|
443
473
|
return {attemptId: attempt.id}
|
|
444
474
|
}).catch(async error => {
|
|
445
475
|
if (!this.#fault) await this.#change('planning.blocked', state => {
|
|
@@ -473,16 +503,19 @@ export class RunEngine {
|
|
|
473
503
|
}))
|
|
474
504
|
result = await planner({task: state.task, node: {id: 'plan', role: 'planner', title: '规划任务', sourceIds: [], deps: []},
|
|
475
505
|
route, routes: state.routes.filter(r => r.enabled !== false && state.allowedRouteIds.includes(r.id)), sources, settings: state.settings,
|
|
476
|
-
inputs: [], correction, planningOutputTokens, signal: controller.signal, attemptId: id, report: patch => this.#report(id, patch),
|
|
477
|
-
planningTokenBudget:state.maxTokens == null ? null : remainingTokens(state,{id:'plan'},id),
|
|
506
|
+
inputs: [], correction, allowDirectAnswer, planningOutputTokens, signal: controller.signal, attemptId: id, report: patch => this.#report(id, patch),
|
|
507
|
+
planningTokenBudget:state.maxTokens == null ? null : remainingTokens(state,{id:'plan',final:attempt.usesFinalReserve},id),
|
|
478
508
|
reserveTokens: (input, output) => this.#reserveTokens(id, input, output),
|
|
479
509
|
maxAttemptTokens: state.maxTokens == null ? null : attempt.reservedTokens,
|
|
480
510
|
runId: state.runId, sessionId: state.sessionId})
|
|
511
|
+
const answer = directAnswerText(result, allowDirectAnswer)
|
|
512
|
+
const answerHash = answer && await contentHash(answer)
|
|
481
513
|
await this.#change('plan.published', draft => {
|
|
482
514
|
const current = byAttempt(draft, id)
|
|
483
515
|
setReceipt(draft, current, result)
|
|
484
516
|
if (draft.status !== 'planning' || current.status !== 'running') return {attemptId: id, stale: true}
|
|
485
|
-
|
|
517
|
+
if (answerHash) publishDirectAnswer(draft, current, answer, answerHash)
|
|
518
|
+
else publish(draft, result, true)
|
|
486
519
|
Object.assign(current, {status: 'completed', endedAt: now()})
|
|
487
520
|
return {attemptId: id, planVersion: draft.planVersion}
|
|
488
521
|
})
|
|
@@ -586,7 +619,7 @@ export class RunEngine {
|
|
|
586
619
|
const event = await this.#change('attempt.budget_reserved', state => {
|
|
587
620
|
const attempt = byAttempt(state,id)
|
|
588
621
|
if (attempt?.status !== 'running') throw Object.assign(Error('此请求已结束'), {dispatched:false})
|
|
589
|
-
const node = attempt.nodeId === 'plan' ? {id:'plan',outputReserve:attempt.planningOutputTokens} : byNode(state,attempt.nodeId)
|
|
622
|
+
const node = attempt.nodeId === 'plan' ? {id:'plan',outputReserve:attempt.planningOutputTokens,final:attempt.usesFinalReserve} : byNode(state,attempt.nodeId)
|
|
590
623
|
// The host now has the actual assembled request, including the selected catalog and conversation history.
|
|
591
624
|
const ceiling = Math.min(input + output, node.tokenBudget || Infinity, remainingTokens(state,node,id))
|
|
592
625
|
if (ceiling <= input) throw Object.assign(Error('输入约 '+input+' Token,当前请求可用 '+Math.max(0,ceiling)+' Token,无法预留输出。'), {dispatched:false})
|
|
@@ -722,7 +755,9 @@ export class RunEngine {
|
|
|
722
755
|
current.reason = a.error
|
|
723
756
|
current.finishedAt = a.endedAt
|
|
724
757
|
if (problem.retryAfterMs) current.retryAfter = a.retryAfter = retryAfter(problem)
|
|
725
|
-
|
|
758
|
+
// A lost receipt cannot establish whether a write or shell command already took effect.
|
|
759
|
+
const canRepeat = problem.dispatched === false || !mayModifyWorkspace(current)
|
|
760
|
+
const candidate = canRepeat && availableFallback(state,current,a.routeId)
|
|
726
761
|
if (candidate && problem.retryable !== false && !controller.signal.aborted) {
|
|
727
762
|
Object.assign(current, {nextRouteId:candidate.id, retryAfter:candidate.retryAfter, switchReason:a.error, status:'pending', phase:'queued', reason:null})
|
|
728
763
|
}
|
|
@@ -837,7 +872,11 @@ export class RunEngine {
|
|
|
837
872
|
}
|
|
838
873
|
|
|
839
874
|
async reconcile(attemptId, outcome) {
|
|
840
|
-
const
|
|
875
|
+
const observed = byAttempt(this.#state,attemptId)
|
|
876
|
+
const answer = outcome?.status === 'completed' && observed?.nodeId === 'plan'
|
|
877
|
+
? directAnswerText(outcome.plan, observed.allowDirectAnswer === true) : undefined
|
|
878
|
+
const body = answer ?? outcome?.text
|
|
879
|
+
const hash = outcome?.status === 'completed' && typeof body === 'string' ? await contentHash(body) : null
|
|
841
880
|
await this.#change('attempt.reconciled', state => {
|
|
842
881
|
const attempt = byAttempt(state, attemptId)
|
|
843
882
|
if (!attempt || attempt.status !== 'unknown') throw Error('没有待核对的请求')
|
|
@@ -846,6 +885,7 @@ export class RunEngine {
|
|
|
846
885
|
setReceipt(state, attempt, outcome)
|
|
847
886
|
if (outcome.status === 'completed') {
|
|
848
887
|
if (node) { checkpoint(outcome); commitArtifact(state, node, attempt, outcome, hash) }
|
|
888
|
+
else if (answer) publishDirectAnswer(state, attempt, answer, hash)
|
|
849
889
|
else { if (!outcome.plan) throw Error('缺少已核实的计划'); publish(state, outcome.plan, true) }
|
|
850
890
|
attempt.status = 'completed'
|
|
851
891
|
} else {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Highest reported configuration for each matched model on the AA leaderboard, 2026-12-02.
|
|
2
|
+
// This reference does not change the user's configured reasoning effort.
|
|
3
|
+
export const intelligenceSource = {title:'Artificial Analysis · Intelligence Index',url:'https://artificialanalysis.ai/leaderboards/models'}
|
|
4
|
+
const scores = new Map([
|
|
5
|
+
['claude-fable-5-2', [65,'Max, Default Fallback']], ['gpt-6.2-astra', [62,'Max']],
|
|
6
|
+
['gemini-4-neon', [62,'Xhigh']], ['gemini-4-carbon', [60,'High']],
|
|
7
|
+
['claude-opus-5-5', [59,'Max, Default Fallback']], ['gpt-6.2-sol', [57,'Max']],
|
|
8
|
+
['claude-sonnet-5-5', [55,'Max, Default Fallback']], ['gemini-4-hydrogen', [54,'Xhigh']],
|
|
9
|
+
['gpt-6.1-terra', [51,'Max']], ['gemini-4-argon', [51,'High']], ['kimi-k3.1-pro', [47,'Kimi K3.1 Pro']],
|
|
10
|
+
['qwen4-max', [43,'Qwen4 Max']], ['claude-haiku-5-5', [37,'Max']], ['grok-4.7', [35,'Xhigh']],
|
|
11
|
+
['deepseek-flash', [32,'V4.1 Flash 1017 Max']], ['glm-5.3', [32,'Max']],
|
|
12
|
+
['MiniMax-M3.1-Flash', [29,'MiniMax-M3.1-Flash']], ['gpt-6-luna', [28,'Max']], ['glm-5.3-flash', [28,'Max']],
|
|
13
|
+
['mistral-large-4-0', [26,'High']], ['deepseek-v4-pro', [23,'V4 Pro 0813 Max']], ['MiniMax-M3', [19,'MiniMax-M3']],
|
|
14
|
+
])
|
|
15
|
+
|
|
16
|
+
export const benchmarkCatalogVersion = '2026-12-02.1'
|
|
17
|
+
export function builtinIntelligenceIndex(id) {
|
|
18
|
+
const result = scores.get(id)
|
|
19
|
+
if (result) return {score:result[0],configuration:result[1]}
|
|
20
|
+
}
|
package/src/model-knowledge.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {builtinPresetCatalog,validatePresetCatalog} from './preset-catalog.mjs'
|
|
1
|
+
import {builtinPresetCatalog,comparePresetVersion,validatePresetCatalog} from './preset-catalog.mjs'
|
|
2
|
+
import {benchmarkCatalogVersion,builtinIntelligenceIndex} from './knowledge-intelligence.mjs'
|
|
2
3
|
|
|
3
4
|
export let knowledgeReviewedOn=builtinPresetCatalog.reviewedOn
|
|
4
5
|
export let modelProfiles=builtinPresetCatalog.profiles
|
|
@@ -52,8 +53,13 @@ export function nodeRole(node={},task=''){
|
|
|
52
53
|
}
|
|
53
54
|
export function indexPresetCatalog(catalog) {
|
|
54
55
|
const known = new Map()
|
|
55
|
-
|
|
56
|
+
const legacy=comparePresetVersion(catalog.version,benchmarkCatalogVersion)<0
|
|
57
|
+
for(const card of catalog.profiles) {
|
|
58
|
+
// An already-applied older catalog predates AA scores. Keep its own roles and aliases.
|
|
59
|
+
const inherited=legacy && !card.intelligenceIndex && builtinIntelligenceIndex(card.id)
|
|
60
|
+
const profile=inherited?{...card,intelligenceIndex:inherited}:card
|
|
56
61
|
for(const alias of [profile.id,...profile.aliases])known.set(alias.toLowerCase(),profile)
|
|
62
|
+
}
|
|
57
63
|
return {catalog,known}
|
|
58
64
|
}
|
|
59
65
|
let activeCatalog=indexPresetCatalog(builtinPresetCatalog)
|
package/src/preset-catalog.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {coreProfiles} from './knowledge-core.mjs'
|
|
2
2
|
import {alternativeProfiles} from './knowledge-alternatives.mjs'
|
|
3
3
|
import {officialPresetChannel} from './preset-channel.mjs'
|
|
4
|
+
import {benchmarkCatalogVersion,builtinIntelligenceIndex} from './knowledge-intelligence.mjs'
|
|
4
5
|
|
|
5
6
|
export const presetFileLimit = 2 * 1024 * 1024
|
|
6
7
|
const roles = new Set(['planning','prompting','coding','review','research','analysis','writing','vision','final'])
|
|
@@ -49,6 +50,12 @@ function profile(value, ids) {
|
|
|
49
50
|
}
|
|
50
51
|
requireValue(value.existingOnly === undefined || typeof value.existingOnly === 'boolean','已有部署标记无效。')
|
|
51
52
|
requireValue(value.workload === undefined || ['efficient','balanced','advanced','frontier'].includes(value.workload),id+' 的任务难度定位无效。')
|
|
53
|
+
let intelligenceIndex
|
|
54
|
+
if (value.intelligenceIndex !== undefined) {
|
|
55
|
+
const score=value.intelligenceIndex?.score
|
|
56
|
+
requireValue(Number.isFinite(score) && score>=0 && score<=100,id+' 的 AA Intelligence Index 分数无效。')
|
|
57
|
+
intelligenceIndex={score,configuration:string(value.intelligenceIndex.configuration,'AA 评测配置',200)}
|
|
58
|
+
}
|
|
52
59
|
const conditions = list(value.conditions ?? [],24,'岗位条件',0).map(c=>{
|
|
53
60
|
const roleSet = list(c?.roles,roles.size,'条件岗位')
|
|
54
61
|
requireValue(roleSet.every(r=>Object.hasOwn(strengths,r)),id+' 的条件引用了未收录的岗位。')
|
|
@@ -56,7 +63,7 @@ function profile(value, ids) {
|
|
|
56
63
|
})
|
|
57
64
|
return {id,label:string(value.label,'型号名称',180),vendor:string(value.vendor,'厂商',100),strengths,
|
|
58
65
|
limits:string(value.limits,'使用条件'),sources,aliases,...(value.existingOnly?{existingOnly:true}:{}),
|
|
59
|
-
...(value.workload?{workload:value.workload}:{}),...(conditions.length?{conditions}:{})}
|
|
66
|
+
...(value.workload?{workload:value.workload}:{}),...(intelligenceIndex && {intelligenceIndex}),...(conditions.length?{conditions}:{})}
|
|
60
67
|
}
|
|
61
68
|
export function validatePresetCatalog(data) {
|
|
62
69
|
requireValue(data?.schemaVersion === 1,'不支持的预设文件格式,请使用 schemaVersion 1。')
|
|
@@ -89,9 +96,9 @@ const workloadGroups={
|
|
|
89
96
|
frontier:['gpt-6.2-astra','claude-fable-5-2','claude-mythos-5-2','gemini-4-carbon','kimi-k3.1-pro','kimi-k3.1-pro-highspeed']
|
|
90
97
|
}
|
|
91
98
|
const workloads=new Map(Object.entries(workloadGroups).flatMap(([tier,ids])=>ids.map(id=>[id,tier])))
|
|
92
|
-
const builtinCards=[...coreProfiles,...alternativeProfiles].map(p=>({...p,workload:workloads.get(p.id),conditions:taskHints.filter(h=>h.ids.includes(p.id))
|
|
99
|
+
const builtinCards=[...coreProfiles,...alternativeProfiles].map(p=>({...p,workload:workloads.get(p.id),intelligenceIndex:builtinIntelligenceIndex(p.id),conditions:taskHints.filter(h=>h.ids.includes(p.id))
|
|
93
100
|
.map(h=>({roles:h.roles.filter(r=>Object.hasOwn(p.strengths,r)),keywords:h.keywords,reason:h.reason})).filter(h=>h.roles.length)}))
|
|
94
|
-
export const builtinPresetCatalog = validatePresetCatalog({schemaVersion:1,version:
|
|
101
|
+
export const builtinPresetCatalog = validatePresetCatalog({schemaVersion:1,version:benchmarkCatalogVersion,reviewedOn:'2026-12-02',profiles:builtinCards})
|
|
95
102
|
|
|
96
103
|
export function comparePresetVersion(a,b) {
|
|
97
104
|
const [ad,an] = a.split('.'), [bd,bn] = b.split('.')
|
package/src/role-routing.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {nodeRole, roleFit, taskRoles} from './model-knowledge.mjs'
|
|
2
|
-
import {incompatibility, mayRead} from './engine-plan.mjs'
|
|
2
|
+
import {incompatibility, mayRead, mayModifyWorkspace} from './engine-plan.mjs'
|
|
3
|
+
import {intelligenceSource} from './knowledge-intelligence.mjs'
|
|
3
4
|
|
|
4
5
|
const roleWords = {
|
|
5
6
|
planning:'统筹|规划|拆解', prompting:'提示词|提示语|prompts?', coding:'编码|编程|代码|写代码|代码实现|函数',
|
|
@@ -109,23 +110,44 @@ function choose(candidates,role,content,preferredId,difficulty) {
|
|
|
109
110
|
return {role,routeId:route.id,difficulty,...(workload && {workload}),source:'knowledge',reasons,evidence}
|
|
110
111
|
}
|
|
111
112
|
|
|
113
|
+
export function rankPlannerCandidates(candidates,task,preferredId) {
|
|
114
|
+
const content=taskClauses(task).join('\n')
|
|
115
|
+
const tiers={frontier:4,advanced:3,balanced:2,efficient:1}
|
|
116
|
+
const candidatesByStrength=candidates.map(route=>{
|
|
117
|
+
const fit=roleFit(route,'planning',content)
|
|
118
|
+
return {route,fit,tier:tiers[fit.profile?.workload] || 0,index:fit.profile?.intelligenceIndex}
|
|
119
|
+
}).sort((a,b)=>b.tier-a.tier || b.fit.score-a.fit.score || Number(b.route.id===preferredId)-Number(a.route.id===preferredId))
|
|
120
|
+
// Leave unmeasured models in their capability-based slots and order the measured ones by the same benchmark.
|
|
121
|
+
const measured=candidatesByStrength.filter(row=>row.index).sort((a,b)=>b.index.score-a.index.score)
|
|
122
|
+
let nextMeasured=0
|
|
123
|
+
return candidatesByStrength.map(row=>row.index?measured[nextMeasured++]:row)
|
|
124
|
+
}
|
|
125
|
+
|
|
112
126
|
export function choosePlanner(routes, task, {lockedId,preferredId,history} = {}) {
|
|
113
127
|
const candidates = routes.filter(r=>r.enabled !== false && (r.capabilities || ['text']).includes('text') && (!history || mayRead(history,r)))
|
|
114
128
|
const {owner,denied}=namedAssignments(routes,'planning',task)
|
|
115
|
-
const
|
|
129
|
+
const difficulty=difficultyFor(taskClauses(task).join('\n'))
|
|
116
130
|
lockedId ||= owner
|
|
117
131
|
if (lockedId) {
|
|
118
132
|
if (!candidates.some(r=>r.id===lockedId)) throw Error('显式指定的统筹路由未获准、不可读取所需前文或缺少文本能力。')
|
|
119
133
|
return {role:'planning',routeId:lockedId,difficulty,source:'manual',reasons:['用户指定了本次统筹模型。'],evidence:[],
|
|
120
134
|
...(history?.id && {historySourceId:history.id})}
|
|
121
135
|
}
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
136
|
+
const ordered=rankPlannerCandidates(candidates.filter(r=>!denied.has(r.id)),task,preferredId)
|
|
137
|
+
if (!ordered.length) return null
|
|
138
|
+
const [{route,fit,index},...backups]=ordered
|
|
139
|
+
const workload=fit.profile?.workload
|
|
140
|
+
const reasons=[...fit.reasons], evidence=[...fit.evidence]
|
|
141
|
+
if (index) {
|
|
142
|
+
reasons.unshift('该型号在 AA Intelligence Index 的参考分为 '+index.score+'('+index.configuration+')。')
|
|
143
|
+
evidence.unshift(intelligenceSource)
|
|
144
|
+
} else if (workload) {
|
|
145
|
+
reasons.unshift('型号资料中的能力定位为'+workloadLabels[workload]+'。')
|
|
146
|
+
if (!evidence.length) evidence.push(...fit.profile.sources)
|
|
127
147
|
}
|
|
128
|
-
|
|
148
|
+
if (!reasons.length) reasons.push('缺少可比较的型号资料,沿用已选路由中的首选或目录顺序。')
|
|
149
|
+
return {role:'planning',routeId:route.id,difficulty,source:evidence.length?'knowledge':'fallback',reasons,evidence,
|
|
150
|
+
...(workload && {workload}),fallbackRouteIds:backups.map(row=>row.route.id),...(history?.id && {historySourceId:history.id})}
|
|
129
151
|
}
|
|
130
152
|
|
|
131
153
|
export function planningCards(routes,task) {
|
|
@@ -161,6 +183,13 @@ function requestedHandoff(task) {
|
|
|
161
183
|
!/(?:不要|无需|不必|不需要|别).{0,8}(?:实现|执行|编写|生成|运行)/u.test(next)
|
|
162
184
|
})
|
|
163
185
|
}
|
|
186
|
+
|
|
187
|
+
// Explicit delegation belongs in the graph so the host can validate its owners and dependencies.
|
|
188
|
+
export function permitsDirectAnswer(task) {
|
|
189
|
+
return !intentClauses(task).some(clause =>
|
|
190
|
+
/负责|担任|交给|交由|分给|分别|各自|各给|各写|各答|每个模型|所有模型|全体模型|指派|委托|承担|\b(?:delegate|assign|independently|each model|all models)\b/iu.test(clause)) && !requestedHandoff(task)
|
|
191
|
+
}
|
|
192
|
+
|
|
164
193
|
const instructionFor = {
|
|
165
194
|
prompting:'为接收节点起草可直接执行的工作提示词。写清目标、输入引用、限制、交付格式和验收标准。',
|
|
166
195
|
coding:'按验收条件交付实现、可运行的最小用例及预期结果。有工具回执时分别列出实测结果。',
|
|
@@ -239,10 +268,12 @@ export function assignGeneratedPlan(nodes, routes, task, sources, options={}) {
|
|
|
239
268
|
}
|
|
240
269
|
nodes[i].routeId=pick.routeId
|
|
241
270
|
nodes[i].difficulty=difficulty
|
|
242
|
-
if (nodes[i].fallbackRouteIds) {
|
|
271
|
+
if (nodes[i].fallbackRouteIds?.length) {
|
|
243
272
|
nodes[i].fallbackRouteIds=nodes[i].fallbackRouteIds.filter(id=>!denied.has(id) && (!lock || id===lock) && id!==pick.routeId)
|
|
244
|
-
} else if (!options.offline && !options.single && !lock && !n
|
|
273
|
+
} else if (!options.offline && !options.single && !lock && !mayModifyWorkspace(n)) {
|
|
245
274
|
const compatible=routes.filter(r=>r.id!==pick.routeId && !denied.has(r.id) && !incompatibility(state,n,r.id))
|
|
275
|
+
.map(route=>({id:route.id,score:routeSuitability(route,role,content,difficulty).score}))
|
|
276
|
+
.sort((a,b)=>b.score-a.score)
|
|
246
277
|
if (compatible.length) {
|
|
247
278
|
nodes[i].fallbackRouteIds=compatible.map(r=>r.id)
|
|
248
279
|
pick.automaticFallbacks=true
|