@tianshu-ai/tianshu 0.144.0 → 0.145.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/package.json +1 -1
- package/packages/server/builtinConfig/plugins/decision/locales/en.json +4 -0
- package/packages/server/builtinConfig/plugins/decision/locales/zh.json +4 -0
- package/packages/server/builtinConfig/plugins/decision/manifest.json +112 -0
- package/packages/server/dist/chat/handler.d.ts.map +1 -1
- package/packages/server/dist/chat/handler.js +117 -3
- package/packages/server/dist/chat/handler.js.map +1 -1
- package/packages/web/dist/assets/{DataSourceConfigForm-Drd4nTZk.js → DataSourceConfigForm-BLcKz4KU.js} +1 -1
- package/packages/web/dist/assets/{bundle-web-CMluE9Oy.js → bundle-web-BiMdkqSB.js} +1 -1
- package/packages/web/dist/assets/{index-BVhnQWHH.js → index-BGMLC3iy.js} +120 -120
- package/packages/web/dist/assets/{react-force-graph-2d-Dw3MtN3M.js → react-force-graph-2d-D10RRWha.js} +1 -1
- package/packages/web/dist/index.html +1 -1
- package/plugins/decision/dist/server.d.ts +6 -0
- package/plugins/decision/dist/server.d.ts.map +1 -0
- package/plugins/decision/dist/server.js +4598 -0
- package/plugins/decision/dist/server.js.map +7 -0
- package/plugins/decision/manifest.json +112 -0
- package/plugins/decision/package.json +34 -0
- package/plugins/reverse-mcp/dist/registry.d.ts +3 -0
- package/plugins/reverse-mcp/dist/registry.d.ts.map +1 -1
- package/plugins/reverse-mcp/dist/registry.js +29 -1
- package/plugins/reverse-mcp/dist/registry.js.map +1 -1
- package/plugins/reverse-mcp/dist/server.js +22 -1
- package/plugins/reverse-mcp/dist/server.js.map +2 -2
package/package.json
CHANGED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "decision",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"displayName": "Decision Model",
|
|
5
|
+
"description": "Route user messages to the right worker using a decision model (Clef, Jev, or any SystemOne-compatible endpoint). Supports local sidecar, Cloudflare Workers AI, and custom endpoints.",
|
|
6
|
+
"configSchema": {
|
|
7
|
+
"fields": [
|
|
8
|
+
{
|
|
9
|
+
"key": "driver",
|
|
10
|
+
"label": "Provider",
|
|
11
|
+
"kind": "select",
|
|
12
|
+
"description": "How to connect to the decision model",
|
|
13
|
+
"options": [
|
|
14
|
+
{
|
|
15
|
+
"value": "local",
|
|
16
|
+
"label": "Local sidecar (HTTP)"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"value": "cloudflare",
|
|
20
|
+
"label": "Cloudflare Workers AI"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"value": "custom",
|
|
24
|
+
"label": "Custom endpoint (Jev/SystemOne compatible)"
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"required": true
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"key": "endpoint",
|
|
31
|
+
"label": "Endpoint URL",
|
|
32
|
+
"kind": "string",
|
|
33
|
+
"description": "Local: http://127.0.0.1:8710/v1/systemone. Custom: your endpoint URL."
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"key": "model",
|
|
37
|
+
"label": "Model",
|
|
38
|
+
"kind": "select",
|
|
39
|
+
"description": "Which model to use",
|
|
40
|
+
"options": [
|
|
41
|
+
{
|
|
42
|
+
"value": "clef-flash",
|
|
43
|
+
"label": "Clef-flash (9B, fast)"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"value": "clef",
|
|
47
|
+
"label": "Clef (27B, accurate)"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"value": "custom",
|
|
51
|
+
"label": "Custom model ID"
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"key": "confidenceThreshold",
|
|
57
|
+
"label": "Confidence Threshold",
|
|
58
|
+
"kind": "string",
|
|
59
|
+
"description": "Minimum confidence (0-1) to auto-route. Below this, the agent decides. Default: 0.85"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"key": "enabled",
|
|
63
|
+
"label": "Enable auto-routing",
|
|
64
|
+
"kind": "boolean",
|
|
65
|
+
"description": "When enabled, incoming messages are routed through the decision model before the agent sees them"
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
},
|
|
69
|
+
"contributes": {
|
|
70
|
+
"tools": [
|
|
71
|
+
{
|
|
72
|
+
"id": "decide",
|
|
73
|
+
"module": "DecideTool",
|
|
74
|
+
"since": "0.1.0",
|
|
75
|
+
"tier": "ondemand",
|
|
76
|
+
"group": "decision"
|
|
77
|
+
}
|
|
78
|
+
],
|
|
79
|
+
"apiRoutes": [
|
|
80
|
+
{
|
|
81
|
+
"method": "GET",
|
|
82
|
+
"path": "/health",
|
|
83
|
+
"handler": "healthCheck"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"method": "POST",
|
|
87
|
+
"path": "/evaluate",
|
|
88
|
+
"handler": "evaluate"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"method": "GET",
|
|
92
|
+
"path": "/config",
|
|
93
|
+
"handler": "getConfig"
|
|
94
|
+
}
|
|
95
|
+
],
|
|
96
|
+
"systemPromptFragments": [
|
|
97
|
+
{
|
|
98
|
+
"id": "decision-routing",
|
|
99
|
+
"text": "The `decide` tool uses a fast decision model for classification, routing, and yes/no judgments. Much faster and cheaper than reasoning through options yourself. Use it when you need a quick structured decision with probabilities."
|
|
100
|
+
}
|
|
101
|
+
],
|
|
102
|
+
"toolGroups": [
|
|
103
|
+
{
|
|
104
|
+
"id": "decision",
|
|
105
|
+
"description": "Fast decision model for classification, routing, and structured judgments"
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
"server": {
|
|
110
|
+
"entry": "@tianshu-builtin/plugin-decision/server"
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../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AC9B,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,wBAAsB,SAAS,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAk0DlE;AAwZD,wBAAgB,uBAAuB,CACrC,oBAAoB,EAAE,WAAW,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,EAC3D,2BAA2B,CAAC,EAAE,MAAM,GACnC,MAAM,CAuCR;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,oBAAoB,EAAE,MAAM,GAAG,MAAM,EAAE,CAgB3E;AA0ED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,aAAa,EAClB,SAAS,EAAE,MAAM,GAChB,MAAM,GAAG,IAAI,CA0Ef;AAolBD,wBAAgB,cAAc,IAAI,WAAW,EAAE,CAkC9C;AAGD,YAAY,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -1233,9 +1233,119 @@ export async function runPrompt(args) {
|
|
|
1233
1233
|
const inboxDelivered = args.skipInboxDrain ? [] : drainInbox(ctx, session.id);
|
|
1234
1234
|
const inboxPrefix = renderInboxForPrompt(inboxDelivered);
|
|
1235
1235
|
const inboxEvents = inboxDelivered.length > 0 ? extractEvents(inboxDelivered) : undefined;
|
|
1236
|
-
|
|
1236
|
+
let promptText = inboxPrefix
|
|
1237
1237
|
? `${inboxPrefix}<user>\n${rawPromptText}\n</user>`
|
|
1238
1238
|
: rawPromptText;
|
|
1239
|
+
// ── Decision model pre-routing ──────────────────────────────
|
|
1240
|
+
// If the decision plugin is configured, call it before the LLM
|
|
1241
|
+
// sees the message. High-confidence results are injected into the
|
|
1242
|
+
// system prompt (not the user bubble) so the UI stays clean.
|
|
1243
|
+
let decisionRouteHint = "";
|
|
1244
|
+
if (!retryLastTurn && !args.skipInboxDrain) {
|
|
1245
|
+
try {
|
|
1246
|
+
// Read from plugins.decision (flat) or plugins.decision.config (nested)
|
|
1247
|
+
const pluginBlock = ctx.config?.plugins?.decision;
|
|
1248
|
+
const decisionCfg = pluginBlock?.config ?? pluginBlock;
|
|
1249
|
+
turnLog.info(`[decision] pluginBlock=${JSON.stringify(pluginBlock)?.slice(0, 200)} decisionCfg=${!!decisionCfg} enabled=${pluginBlock?.enabled}`);
|
|
1250
|
+
if (decisionCfg && pluginBlock?.enabled !== false) {
|
|
1251
|
+
const endpoint = decisionCfg.endpoint || "http://127.0.0.1:8710/v1/systemone";
|
|
1252
|
+
const model = decisionCfg.model || "clef-flash";
|
|
1253
|
+
const rawThreshold = String(decisionCfg.confidenceThreshold ?? "").trim();
|
|
1254
|
+
const threshold = rawThreshold ? parseFloat(rawThreshold) : 0.7;
|
|
1255
|
+
if (isNaN(threshold))
|
|
1256
|
+
turnLog.warn(`[decision] invalid confidenceThreshold: ${rawThreshold}, using 0.7`);
|
|
1257
|
+
const allWorkers = loadWorkerAgents(ctx.tenantId, ctx.home);
|
|
1258
|
+
const workers = allWorkers.filter(w => w.spec.enabled !== false && w.errors.length === 0);
|
|
1259
|
+
turnLog.info(`[decision] workers: ${allWorkers.length} total, ${workers.length} enabled: ${workers.map(w => w.slug).join(', ')}`);
|
|
1260
|
+
if (workers.length > 0) {
|
|
1261
|
+
const workerCriteria = {};
|
|
1262
|
+
for (const w of workers) {
|
|
1263
|
+
workerCriteria[w.slug] = w.spec.description || w.spec.displayName || w.slug;
|
|
1264
|
+
}
|
|
1265
|
+
const stateText = rawPromptText.slice(0, 2000);
|
|
1266
|
+
const callDecision = async (questions) => {
|
|
1267
|
+
for (let attempt = 1; attempt <= 3; attempt++) {
|
|
1268
|
+
try {
|
|
1269
|
+
const r = await fetch(endpoint, {
|
|
1270
|
+
method: "POST",
|
|
1271
|
+
headers: { "Content-Type": "application/json" },
|
|
1272
|
+
body: JSON.stringify({ model, state: stateText, questions }),
|
|
1273
|
+
signal: AbortSignal.timeout(15000),
|
|
1274
|
+
});
|
|
1275
|
+
if (r.ok)
|
|
1276
|
+
return await r.json();
|
|
1277
|
+
turnLog.info(`[decision] attempt ${attempt}/3 failed: HTTP ${r.status}`);
|
|
1278
|
+
}
|
|
1279
|
+
catch (err) {
|
|
1280
|
+
turnLog.info(`[decision] attempt ${attempt}/3 failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
1281
|
+
}
|
|
1282
|
+
if (attempt < 3)
|
|
1283
|
+
await new Promise(r => setTimeout(r, 1000));
|
|
1284
|
+
}
|
|
1285
|
+
return null;
|
|
1286
|
+
};
|
|
1287
|
+
// ── Phase 1: How many workers are needed? ──
|
|
1288
|
+
const countCriteria = {
|
|
1289
|
+
"0": "不需要 worker,自己处理(闲聊、简单问答、不涉及专业处理的请求)",
|
|
1290
|
+
};
|
|
1291
|
+
const maxWorkers = Math.min(workers.length, 5);
|
|
1292
|
+
for (let i = 1; i <= maxWorkers; i++) {
|
|
1293
|
+
countCriteria[String(i)] = `需要 ${i} 个 worker 分别处理不同部分`;
|
|
1294
|
+
}
|
|
1295
|
+
const phase1 = await callDecision({
|
|
1296
|
+
count: {
|
|
1297
|
+
type: "choice",
|
|
1298
|
+
instructions: `判断这条请求需要委派给几个 worker 处理。可用的 worker:${workers.map(w => w.slug).join("、")}。如果用户只是闲聊、简单问答或不需要专业处理,选 0。`,
|
|
1299
|
+
criteria: countCriteria,
|
|
1300
|
+
},
|
|
1301
|
+
});
|
|
1302
|
+
const countAnswer = phase1?.answers?.count;
|
|
1303
|
+
const neededCount = parseInt(countAnswer?.choice ?? "0", 10);
|
|
1304
|
+
turnLog.info(`[decision] phase1: count=${neededCount} conf=${countAnswer?.confidence?.toFixed(3) ?? "?"} ms=${phase1?._latencyMs ?? "?"}`);
|
|
1305
|
+
if (neededCount > 0) {
|
|
1306
|
+
// ── Phase 2: Which workers? ──
|
|
1307
|
+
// Build N questions, each asking "pick the best worker for slot N"
|
|
1308
|
+
// For simplicity: single call with one "route" question per slot.
|
|
1309
|
+
// Clef picks the top N from probabilities.
|
|
1310
|
+
const phase2 = await callDecision({
|
|
1311
|
+
route: {
|
|
1312
|
+
type: "choice",
|
|
1313
|
+
instructions: `根据用户的请求内容,选择最合适的 worker。`,
|
|
1314
|
+
criteria: workerCriteria,
|
|
1315
|
+
},
|
|
1316
|
+
});
|
|
1317
|
+
const route = phase2?.answers?.route;
|
|
1318
|
+
if (route) {
|
|
1319
|
+
// Pick top N workers by probability
|
|
1320
|
+
const probs = route.probabilities ?? {};
|
|
1321
|
+
const ranked = Object.entries(probs)
|
|
1322
|
+
.sort(([, a], [, b]) => b - a)
|
|
1323
|
+
.slice(0, neededCount)
|
|
1324
|
+
.map(([slug, prob]) => ({ slug, confidence: prob }));
|
|
1325
|
+
// Fallback: if no probabilities, use top choice
|
|
1326
|
+
if (ranked.length === 0) {
|
|
1327
|
+
ranked.push({ slug: route.choice, confidence: route.confidence });
|
|
1328
|
+
}
|
|
1329
|
+
const workerList = ranked.map(w => `「${w.slug}」`).join("、");
|
|
1330
|
+
if (ranked.length === 1) {
|
|
1331
|
+
decisionRouteHint = `\n\n[Decision Model Routing]\n决策模型建议:将用户的请求委派给 worker ${workerList}。请用 task_create 创建任务,除非你有充分理由自己处理。`;
|
|
1332
|
+
}
|
|
1333
|
+
else {
|
|
1334
|
+
decisionRouteHint = `\n\n[Decision Model Routing]\n决策模型建议:这条请求涉及 ${ranked.length} 个 worker,请制定完整的执行计划:\n1. 分别给以下 worker 创建任务:${workerList}。可以并行的任务同时创建。\n2. 重要:用户的最终需求必须得到落实。worker 只是中间步骤,你(main)负责确保最终产出完成。\n3. 所有 worker 完成后,你必须整合结果并交付用户要求的最终产出(如更新看板、生成报告、执行后续操作等)。不要只派任务就停下来。`;
|
|
1335
|
+
}
|
|
1336
|
+
turnLog.info(`[decision] phase2: routes=[${ranked.map(w => `${w.slug}:${w.confidence.toFixed(3)}`).join(",")}] ms=${phase2?._latencyMs ?? "?"}`);
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
else {
|
|
1340
|
+
turnLog.info(`[decision] route=main (count=0, self-handle)`);
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
catch (err) {
|
|
1346
|
+
turnLog.info(`[decision] unavailable: ${err instanceof Error ? err.message : String(err)}`);
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1239
1349
|
// Build the harness session ourselves so we can keep a handle
|
|
1240
1350
|
// on the storage — we need to stash sibling attachments on it
|
|
1241
1351
|
// before the harness's user-message persistence fires, and we
|
|
@@ -1352,7 +1462,11 @@ export async function runPrompt(args) {
|
|
|
1352
1462
|
customFragments: mainConfig.customFragments,
|
|
1353
1463
|
toolGroupsBlock,
|
|
1354
1464
|
}, { voiceMode: args.voiceMode === true, taskMode: args.taskMode === true });
|
|
1355
|
-
|
|
1465
|
+
// Append decision routing hint to system prompt (not user bubble)
|
|
1466
|
+
const finalSystemPrompt = decisionRouteHint
|
|
1467
|
+
? systemPrompt + decisionRouteHint
|
|
1468
|
+
: systemPrompt;
|
|
1469
|
+
dumpSystemPrompt({ ctx, role: "main", userId, systemPrompt: finalSystemPrompt });
|
|
1356
1470
|
// pi 0.85: Context threads through every harness / lane / session
|
|
1357
1471
|
// call. Root context cancels when `signal` aborts.
|
|
1358
1472
|
const piContext = withAbortSignal(signal, BACKGROUND_CONTEXT);
|
|
@@ -1561,7 +1675,7 @@ export async function runPrompt(args) {
|
|
|
1561
1675
|
...(effectiveToolset.ondemandGroups.size > 0
|
|
1562
1676
|
? { activeToolNames: effectiveToolset.coreToolNames }
|
|
1563
1677
|
: {}),
|
|
1564
|
-
systemPrompt,
|
|
1678
|
+
systemPrompt: finalSystemPrompt,
|
|
1565
1679
|
model: piModel,
|
|
1566
1680
|
...(modelInfo.thinkingLevel ? { thinkingLevel: modelInfo.thinkingLevel } : {}),
|
|
1567
1681
|
toProviderMessages,
|