@zltquant/zlt-mcp 0.6.1-beta.6 → 0.6.1-beta.7
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/config.json +1 -1
- package/package.json +1 -1
- package/zlt-mcp-proxy.bundle.cjs +32 -7
package/config.json
CHANGED
|
@@ -416,7 +416,7 @@
|
|
|
416
416
|
},
|
|
417
417
|
{
|
|
418
418
|
"name": "mcp-get-cache-diff",
|
|
419
|
-
"description": "比对云端与本地缓存,直接回答「还差哪些区间、多少个文件、多大」。只读,不创建任务,不改本地缓存。Data 返回 series、nextAction 和 resultKind=cache-diff(结果类型标记,向用户转述时可忽略):series 每项含 missing(本地没有的区间)与 changed(已覆盖但元数据对不上的区间),两者都已按序列合并相邻与交叠段。\n\n**changed 的文件同样要整份重下,所以补齐全部缺口的下载量是 missingBytes 与 changedBytes 两者之和**;向用户报体量时必须相加,只报 missingBytes 会少算。nextAction=
|
|
419
|
+
"description": "比对云端与本地缓存,直接回答「还差哪些区间、多少个文件、多大」。只读,不创建任务,不改本地缓存。Data 返回 series、nextAction、assessment、evidence 和 resultKind=cache-diff(结果类型标记,向用户转述时可忽略):series 每项含 missing(本地没有的区间)与 changed(已覆盖但元数据对不上的区间),两者都已按序列合并相邻与交叠段。\n\n**changed 的文件同样要整份重下,所以补齐全部缺口的下载量是 missingBytes 与 changedBytes 两者之和**;向用户报体量时必须相加,只报 missingBytes 会少算。nextAction=plan-download 只表示返回的有效 series 中发现缺口;report-unknown 表示上游响应没有提供足够的全请求覆盖证据,不能据此声称本地已经齐了,须同时说明 assessment 和 evidence。本工具需要云端枚举,开销相当于一次下载的列举阶段,不要在轮询循环里反复调用。",
|
|
420
420
|
"inputSchema": {
|
|
421
421
|
"type": "object",
|
|
422
422
|
"properties": {
|
package/package.json
CHANGED
package/zlt-mcp-proxy.bundle.cjs
CHANGED
|
@@ -26171,17 +26171,30 @@ function toCacheDiffWindows(value) {
|
|
|
26171
26171
|
}
|
|
26172
26172
|
return unionDataRangeIntervals(intervals).map(([startDate, endDate]) => ({ startDate, endDate }));
|
|
26173
26173
|
}
|
|
26174
|
+
function hasInvalidCacheDiffWindow(value) {
|
|
26175
|
+
return value.some((item) => !isRecord2(item) || !compactDataRangeDate(item.begin ?? item.start) || !compactDataRangeDate(item.end));
|
|
26176
|
+
}
|
|
26174
26177
|
function formatCacheDiffResult(rawResult) {
|
|
26175
26178
|
if (!isRecord2(rawResult)) return rawResult;
|
|
26176
|
-
if (isRecord2(rawResult.Data) && rawResult.Data.resultKind === CACHE_DIFF_RESULT_KIND) return rawResult;
|
|
26179
|
+
if (isRecord2(rawResult.Data) && rawResult.Data.resultKind === CACHE_DIFF_RESULT_KIND && typeof rawResult.Data.assessment === "string" && isRecord2(rawResult.Data.evidence)) return rawResult;
|
|
26177
26180
|
const { Data: upstream, ...envelope } = rawResult;
|
|
26178
26181
|
const payload = isRecord2(upstream) ? upstream : {};
|
|
26182
|
+
const hasResultsField = Object.prototype.hasOwnProperty.call(payload, "results");
|
|
26179
26183
|
const results = Array.isArray(payload.results) ? payload.results : [];
|
|
26184
|
+
const resultsShape = !hasResultsField ? "missing" : !Array.isArray(payload.results) ? "invalid" : results.length === 0 ? "empty" : "array";
|
|
26180
26185
|
const series = [];
|
|
26186
|
+
let uncertainSeries = 0;
|
|
26181
26187
|
for (const item of results) {
|
|
26182
|
-
if (!isRecord2(item)) continue;
|
|
26183
|
-
const
|
|
26188
|
+
if (!isRecord2(item) || typeof item.data_type !== "string" || item.data_type.length === 0) continue;
|
|
26189
|
+
const differenceFields = ["missing", "changed", "files"];
|
|
26190
|
+
const presentFields = differenceFields.filter((field) => Object.prototype.hasOwnProperty.call(item, field));
|
|
26191
|
+
if (presentFields.length === 0 || presentFields.some((field) => !Array.isArray(item[field]))) continue;
|
|
26192
|
+
const token = splitDataTypeToken(item.data_type);
|
|
26193
|
+
const missing = Array.isArray(item.missing) ? item.missing : [];
|
|
26194
|
+
const changed = Array.isArray(item.changed) ? item.changed : [];
|
|
26184
26195
|
const files = Array.isArray(item.files) ? item.files : [];
|
|
26196
|
+
const hasUnusableMember = hasInvalidCacheDiffWindow(missing) || hasInvalidCacheDiffWindow(changed) || files.some((file) => !isRecord2(file) || file.state !== "missing" && file.state !== "changed");
|
|
26197
|
+
if (hasUnusableMember) uncertainSeries += 1;
|
|
26185
26198
|
let missingFiles = 0;
|
|
26186
26199
|
let changedFiles = 0;
|
|
26187
26200
|
let missingBytes = 0;
|
|
@@ -26200,8 +26213,8 @@ function formatCacheDiffResult(rawResult) {
|
|
|
26200
26213
|
market: describeDataRangeMarket(item.exchange_id, MARKET_ID_TO_NAME, MARKET_CODE_TO_NAME),
|
|
26201
26214
|
datatype: DATATYPE_TO_NAME[token.family] || token.family || "\u672A\u77E5\u9891\u7387",
|
|
26202
26215
|
sectype: describeDataRangeSecurityClass(void 0, token.securityClass, SECTYPE_TO_NAME),
|
|
26203
|
-
missing: toCacheDiffWindows(
|
|
26204
|
-
changed: toCacheDiffWindows(
|
|
26216
|
+
missing: toCacheDiffWindows(missing),
|
|
26217
|
+
changed: toCacheDiffWindows(changed),
|
|
26205
26218
|
missingFiles,
|
|
26206
26219
|
changedFiles,
|
|
26207
26220
|
missingBytes,
|
|
@@ -26210,12 +26223,24 @@ function formatCacheDiffResult(rawResult) {
|
|
|
26210
26223
|
}
|
|
26211
26224
|
const errNo = Number(rawResult.ErrNo);
|
|
26212
26225
|
const upstreamFailed = Number.isFinite(errNo) && errNo !== 0;
|
|
26213
|
-
const hasWork = series.some((s) => s.missing.length > 0 || s.changed.length > 0);
|
|
26226
|
+
const hasWork = series.some((s) => s.missing.length > 0 || s.changed.length > 0 || s.missingFiles > 0 || s.changedFiles > 0);
|
|
26227
|
+
const rejectedSeries = results.length - series.length;
|
|
26228
|
+
const partialResult = resultsShape === "array" && (rejectedSeries > 0 || uncertainSeries > 0);
|
|
26229
|
+
const assessment = upstreamFailed ? "upstream-error" : partialResult ? "partial-result" : resultsShape !== "array" ? "indeterminate-result" : hasWork ? "differences-found" : "no-differences-in-returned-series";
|
|
26230
|
+
const nextAction = upstreamFailed ? "report-error" : partialResult || resultsShape !== "array" || !hasWork ? "report-unknown" : "plan-download";
|
|
26214
26231
|
return {
|
|
26215
26232
|
...envelope,
|
|
26216
26233
|
Data: {
|
|
26217
26234
|
series: upstreamFailed ? [] : series,
|
|
26218
|
-
nextAction
|
|
26235
|
+
nextAction,
|
|
26236
|
+
assessment,
|
|
26237
|
+
evidence: {
|
|
26238
|
+
resultsShape,
|
|
26239
|
+
resultCount: results.length,
|
|
26240
|
+
interpretedSeries: series.length,
|
|
26241
|
+
rejectedSeries,
|
|
26242
|
+
uncertainSeries
|
|
26243
|
+
},
|
|
26219
26244
|
resultKind: CACHE_DIFF_RESULT_KIND
|
|
26220
26245
|
}
|
|
26221
26246
|
};
|