dsh-stock-analysis 0.2.9 → 0.2.11

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.
Files changed (39) hide show
  1. package/README.md +16 -3
  2. package/dist/client.js +88 -0
  3. package/dist/index.js +860 -126
  4. package/dist/web/app.js +871 -0
  5. package/dist/web/index.html +87 -0
  6. package/dist/web/style.css +292 -0
  7. package/package.json +13 -3
  8. package/scripts/profile-offline.py +127 -0
  9. package/scripts/profile-workflows.py +87 -0
  10. package/skills/growth-quality/SKILL.md +2 -0
  11. package/skills/stock-analysis/SKILL.md +14 -3
  12. package/skills/stock-analysis/references/stateless-analysis.md +16 -2
  13. package/skills/stock-screener/SKILL.md +4 -0
  14. package/skills/strategy-backtest/SKILL.md +8 -3
  15. package/tools/_cache.py +93 -21
  16. package/tools/_subproc.py +43 -8
  17. package/tools/alert_rules.py +63 -14
  18. package/tools/anomaly_detect.py +11 -6
  19. package/tools/backtest.py +225 -70
  20. package/tools/capabilities.py +1 -0
  21. package/tools/gather.py +63 -8
  22. package/tools/market_regime.py +26 -15
  23. package/tools/market_review.py +2 -2
  24. package/tools/name_resolver.py +16 -14
  25. package/tools/position_context.py +5 -2
  26. package/tools/requirements.txt +4 -4
  27. package/tools/risk_screening.py +40 -15
  28. package/tools/screener.py +44 -18
  29. package/tools/search_intel.py +95 -33
  30. package/tools/sec_holders.py +27 -25
  31. package/tools/signal_tracker.py +106 -54
  32. package/tools/stateless_analysis.py +600 -33
  33. package/tools/stock_data.py +366 -50
  34. package/tools/technical.py +42 -40
  35. package/tools/tiaa_disclosures.py +263 -0
  36. package/tools/trading_calendar.py +26 -21
  37. package/tools/value_data.py +6 -2
  38. package/tools/watchlist.py +24 -15
  39. package/tools/watchlist_context.py +63 -49
package/dist/index.js CHANGED
@@ -81,11 +81,11 @@ function commandTimeout(script, args) {
81
81
  }
82
82
 
83
83
  // dsh/index.ts
84
- import { existsSync, readdirSync, readFileSync } from "node:fs";
84
+ import { existsSync as existsSync2, readdirSync, readFileSync as readFileSync2 } from "node:fs";
85
85
  import * as cp from "node:child_process";
86
86
  import { promisify } from "node:util";
87
- import { dirname, join as join3 } from "node:path";
88
- import { fileURLToPath } from "node:url";
87
+ import { dirname as dirname2, join as join4 } from "node:path";
88
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
89
89
  import {
90
90
  defineTool as defineTool2
91
91
  } from "@deepseek-ai/dsh-tools";
@@ -100,9 +100,16 @@ function venvPythonPath(rootDir) {
100
100
  // dsh/discovery.ts
101
101
  import { defineTool } from "@deepseek-ai/dsh-tools";
102
102
  var SEARCH = "stock_tool_search";
103
- function registerToolDiscovery(ctx, names) {
104
- if (typeof ctx.on !== "function" || typeof ctx.tools.get !== "function" || typeof ctx.tools.presentAs !== "function" || names.size === 0 || ctx.tools.get(SEARCH)) return;
105
- const states = /* @__PURE__ */ new WeakMap();
103
+ function createToolDiscovery(ctx) {
104
+ if (typeof ctx.tools.resolve !== "function" || ctx.tools.get(SEARCH)) return () => void 0;
105
+ const names = /* @__PURE__ */ new Map();
106
+ const loaded = /* @__PURE__ */ new WeakMap();
107
+ const ptc = /* @__PURE__ */ new WeakSet();
108
+ const active = (agent) => {
109
+ if (ctx.tools.get(SEARCH, agent) && !ptc.has(agent)) return true;
110
+ loaded.delete(agent);
111
+ return false;
112
+ };
106
113
  ctx.tools.register(defineTool({
107
114
  name: SEARCH,
108
115
  description: "\u641C\u7D22\u5E76\u52A0\u8F7D\u80A1\u7968\u5206\u6790\u5DE5\u5177\uFF1B\u652F\u6301\u4E2D\u6587\u3001\u82F1\u6587\u5173\u952E\u8BCD\u6216\u786E\u5207\u5DE5\u5177\u540D\uFF0C\u5982\u8D22\u52A1\u3001get_quote\u3001run_backtest\u3002\u5339\u914D\u5DE5\u5177\u5C06\u5728\u4E0B\u4E00\u6B21\u6A21\u578B\u8BF7\u6C42\u63D0\u4F9B\u5B8C\u6574\u53C2\u6570\uFF0C\u53EF\u6309\u539F\u540D\u76F4\u63A5\u8C03\u7528\u3002\u4E0D\u4F1A\u6267\u884C\u5206\u6790\u6216\u6269\u5927\u6743\u9650\u3002",
@@ -113,41 +120,541 @@ function registerToolDiscovery(ctx, names) {
113
120
  output: { schema: { type: "string" }, render: (_args, value) => [{ type: "text", text: value }] },
114
121
  async execute({ query, limit = 5 }, exec) {
115
122
  const needle = query.trim().toLowerCase();
116
- const terms = [...new Set(needle.match(/[a-z0-9_]+|\p{Script=Han}/gu) ?? [])];
123
+ const tokens = needle.match(/[a-z0-9_]+|\p{Script=Han}/gu) ?? [];
124
+ const bigrams = (needle.match(/\p{Script=Han}+/gu) ?? []).flatMap((text) => [...text].slice(0, -1).map((_, index) => text.slice(index, index + 2)));
125
+ const terms = [.../* @__PURE__ */ new Set([...tokens, ...bigrams])];
117
126
  if (!terms.length || !Number.isInteger(limit) || limit < 1 || limit > 20) {
118
127
  return JSON.stringify({ error: "query must contain searchable text and limit must be an integer from 1 to 20" });
119
128
  }
120
- const state = exec.agent && states.get(exec.agent);
121
- if (!state) return JSON.stringify({ error: "Tool discovery is unavailable for this agent; use its directly exposed tools" });
122
- const candidates = state.catalog.filter((tool) => ctx.tools.get(tool.name, exec.agent)).map((tool) => ({ tool, text: `${tool.name} ${tool.description}`.toLowerCase() }));
129
+ if (!exec.agent) return JSON.stringify({ error: "Tool discovery is unavailable for this agent; use its directly exposed tools" });
130
+ const agent = exec.agent;
131
+ const candidates = [...names].filter(([name2]) => ctx.tools.get(name2, agent)).map(([name2, description]) => ({ tool: { name: name2, description }, text: `${name2} ${description}`.toLowerCase() }));
123
132
  const weights = terms.map((term) => 1 / (1 + candidates.filter(({ text }) => text.includes(term)).length));
124
133
  const matches = candidates.map(({ tool, text }) => {
125
134
  const score = (tool.name === needle ? 1e3 : 0) + (text.includes(needle) ? 10 : 0) + terms.reduce((sum, term, index) => sum + weights[index] * (tool.name.includes(term) ? 3 : text.includes(term) ? 1 : 0), 0);
126
135
  return { tool, score };
127
- }).filter((match) => match.score > 0).sort((a, b) => b.score - a.score || a.tool.name.localeCompare(b.tool.name)).slice(0, limit);
128
- for (const { tool } of matches) state.loaded.add(tool.name);
129
- return JSON.stringify({ loaded: matches.map(({ tool }) => ({ name: tool.name, description: tool.description })) });
136
+ }).filter((match) => match.score > 0).sort((a, b) => b.score - a.score || a.tool.name.length - b.tool.name.length || a.tool.name.localeCompare(b.tool.name)).slice(0, limit);
137
+ const set = loaded.get(agent) ?? /* @__PURE__ */ new Set();
138
+ for (const { tool } of matches) set.add(tool.name);
139
+ loaded.set(agent, set);
140
+ return JSON.stringify({ loaded: matches.map(({ tool }) => tool) });
130
141
  }
131
142
  }));
132
143
  ctx.on("system-prompt/assemble", async (_assembly, context, next) => {
133
144
  const result = await next();
134
- if (!context.scope) return result;
135
- if (!result.tools.some((tool) => tool.name === SEARCH) || result.tools.some((tool) => tool.name === "run_code")) {
136
- states.delete(context.scope);
137
- return result;
145
+ if (context.scope) {
146
+ if (result.sections.some((section) => section.name === "tools:sdk")) ptc.add(context.scope);
147
+ else ptc.delete(context.scope);
138
148
  }
139
- const state = states.get(context.scope) ?? { catalog: [], loaded: /* @__PURE__ */ new Set() };
140
- state.catalog = result.tools.filter((tool) => names.has(tool.name));
141
- states.set(context.scope, state);
142
- return { ...result, tools: result.tools.filter((tool) => !names.has(tool.name) || state.loaded.has(tool.name)) };
149
+ return result;
150
+ });
151
+ return ({ name: name2, description }) => {
152
+ names.set(name2, description);
153
+ return { when: ({ agent }) => !active(agent) || (loaded.get(agent)?.has(name2) ?? false) };
154
+ };
155
+ }
156
+
157
+ // dsh/dashboard.ts
158
+ import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
159
+ import { homedir } from "node:os";
160
+ import { dirname, join as join3 } from "node:path";
161
+ import { fileURLToPath } from "node:url";
162
+ import { randomUUID } from "node:crypto";
163
+ var DASHBOARD_BASE = "/stock-analysis";
164
+ var REGIONS = ["cn", "hk", "us", "jp", "kr", "tw"];
165
+ var STATIC_FILES = /* @__PURE__ */ new Map([
166
+ ["/", ["index.html", "text/html; charset=utf-8"]],
167
+ ["/app.js", ["app.js", "text/javascript; charset=utf-8"]],
168
+ ["/style.css", ["style.css", "text/css; charset=utf-8"]]
169
+ ]);
170
+ var MAX_WATCHLIST = 30;
171
+ var MAX_PYTHON = 4;
172
+ var TICK_MS = 1e4;
173
+ var SECOND = 1e3;
174
+ var MINUTE = 60 * SECOND;
175
+ var CN_INDEX_SYMBOLS = ["sh000001", "sz399001", "sz399006", "sh000688", "sh000300", "sh000016"];
176
+ var INDEX_SYMBOLS = {
177
+ cn: CN_INDEX_SYMBOLS,
178
+ hk: ["^HSI", "^HSCE", "^HSTECH"],
179
+ us: ["^DJI", "^IXIC", "^GSPC", "^RUT"],
180
+ jp: ["^N225", "^TOPX"],
181
+ kr: ["^KS11", "^KQ11"],
182
+ tw: ["^TWII"]
183
+ };
184
+ var RIBBON = [
185
+ ["cn", "sh000001"],
186
+ ["cn", "sz399001"],
187
+ ["cn", "sz399006"],
188
+ ["hk", "^HSI"],
189
+ ["hk", "^HSTECH"],
190
+ ["us", "^IXIC"],
191
+ ["us", "^GSPC"],
192
+ ["us", "^DJI"],
193
+ ["jp", "^N225"],
194
+ ["kr", "^KS11"],
195
+ ["tw", "^TWII"]
196
+ ];
197
+ var TRADING_PHASES = /* @__PURE__ */ new Set(["morning", "afternoon", "intraday"]);
198
+ var HttpError = class extends Error {
199
+ constructor(status, message) {
200
+ super(message);
201
+ this.status = status;
202
+ }
203
+ status;
204
+ };
205
+ function assertApiAccess(req) {
206
+ let hostname = "";
207
+ try {
208
+ hostname = new URL(`http://${req.headers.host}`).hostname.replace(/^\[|\]$/g, "").split("%")[0];
209
+ } catch {
210
+ }
211
+ if (!["127.0.0.1", "localhost", "::1"].includes(hostname)) throw new HttpError(403, "\u53EA\u5141\u8BB8\u672C\u673A\u8BBF\u95EE\u4EEA\u8868\u76D8 API");
212
+ const site = req.headers["sec-fetch-site"];
213
+ if (site && !["same-origin", "none"].includes(site)) throw new HttpError(403, "\u53EA\u5141\u8BB8\u540C\u6E90\u9875\u9762\u8BBF\u95EE\u4EEA\u8868\u76D8 API");
214
+ const origin = req.headers.origin;
215
+ if (origin && origin.replace(/^https?:\/\//, "") !== req.headers.host) throw new HttpError(403, "\u53EA\u5141\u8BB8\u540C\u6E90\u9875\u9762\u8BBF\u95EE\u4EEA\u8868\u76D8 API");
216
+ }
217
+ function normalizeWatchlist(input) {
218
+ if (!Array.isArray(input)) throw new HttpError(400, "symbols \u5FC5\u987B\u662F\u80A1\u7968\u4EE3\u7801\u6570\u7EC4");
219
+ const symbols = [...new Set(input.map((value) => {
220
+ if (typeof value !== "string") throw new HttpError(400, "\u80A1\u7968\u4EE3\u7801\u5FC5\u987B\u662F\u5B57\u7B26\u4E32");
221
+ const symbol = value.trim().toUpperCase();
222
+ if (!/^[A-Z0-9][A-Z0-9.-]{0,31}$/.test(symbol)) throw new HttpError(400, "\u80A1\u7968\u4EE3\u7801\u683C\u5F0F\u4E0D\u6B63\u786E");
223
+ return /^(?:SH|SZ|BJ)\d{6}$/.test(symbol) ? symbol.toLowerCase() : symbol;
224
+ }))];
225
+ if (symbols.length > MAX_WATCHLIST) throw new HttpError(400, `\u81EA\u9009\u80A1\u6700\u591A\u4FDD\u5B58 ${MAX_WATCHLIST} \u53EA`);
226
+ return symbols;
227
+ }
228
+ function readWatchlist(file) {
229
+ let raw;
230
+ try {
231
+ raw = readFileSync(file, "utf8");
232
+ } catch (error) {
233
+ if (error.code === "ENOENT") return [];
234
+ throw new Error("\u65E0\u6CD5\u8BFB\u53D6\u81EA\u9009\u80A1\u6587\u4EF6");
235
+ }
236
+ try {
237
+ const value = JSON.parse(raw);
238
+ return normalizeWatchlist(value.symbols);
239
+ } catch {
240
+ throw new Error("\u81EA\u9009\u80A1\u6587\u4EF6\u5DF2\u635F\u574F\uFF0C\u8BF7\u5148\u4FEE\u590D\u6216\u79FB\u8D70\u8BE5\u6587\u4EF6");
241
+ }
242
+ }
243
+ function writeWatchlist(file, input) {
244
+ readWatchlist(file);
245
+ const symbols = normalizeWatchlist(input);
246
+ mkdirSync(dirname(file), { recursive: true });
247
+ const temp = `${file}.${process.pid}-${randomUUID()}.tmp`;
248
+ try {
249
+ writeFileSync(temp, `${JSON.stringify({ version: 1, symbols }, null, 2)}
250
+ `, { encoding: "utf8", mode: 384 });
251
+ renameSync(temp, file);
252
+ } finally {
253
+ rmSync(temp, { force: true });
254
+ }
255
+ return symbols;
256
+ }
257
+ function sendJson(res, status, value) {
258
+ res.writeHead(status, { "content-type": "application/json; charset=utf-8", "cache-control": "no-store" });
259
+ res.end(JSON.stringify(value));
260
+ }
261
+ async function readJson(req, max = 16 * 1024) {
262
+ if (!/^application\/json\b/.test(req.headers["content-type"] ?? "")) throw new HttpError(415, "\u8BF7\u4F7F\u7528 JSON \u8BF7\u6C42");
263
+ return new Promise((resolve, reject) => {
264
+ let size = 0;
265
+ let tooLarge = false;
266
+ const chunks = [];
267
+ req.on("data", (chunk) => {
268
+ size += chunk.length;
269
+ if (size > max) tooLarge = true;
270
+ else chunks.push(chunk);
271
+ });
272
+ req.on("end", () => {
273
+ if (tooLarge) return reject(new HttpError(413, "\u8BF7\u6C42\u5185\u5BB9\u8FC7\u5927"));
274
+ try {
275
+ resolve(JSON.parse(Buffer.concat(chunks).toString("utf8") || "{}"));
276
+ } catch {
277
+ reject(new HttpError(400, "JSON \u8BF7\u6C42\u683C\u5F0F\u4E0D\u6B63\u786E"));
278
+ }
279
+ });
280
+ req.on("error", reject);
281
+ });
282
+ }
283
+ function dashboardQuoteSymbol(symbol) {
284
+ if (!/^\d{6}$/.test(symbol)) return symbol;
285
+ if (/^(?:43|81|82|83|87|88|92)/.test(symbol)) return `bj${symbol}`;
286
+ return `${/^[569]/.test(symbol) ? "sh" : "sz"}${symbol}`;
287
+ }
288
+ function symbolRegion(symbol) {
289
+ if (/^(?:sh|sz|bj)?\d{6}$/.test(symbol)) return "cn";
290
+ if (/\.HK$/.test(symbol)) return "hk";
291
+ if (/\.T$/.test(symbol)) return "jp";
292
+ if (/\.K[SQ]$/.test(symbol)) return "kr";
293
+ if (/\.TWO?$/.test(symbol)) return "tw";
294
+ return "us";
295
+ }
296
+ function safeError(value, fallback) {
297
+ return typeof value === "string" && value && value.length <= 160 && !/[/\\\n]/.test(value) ? value : fallback;
298
+ }
299
+ function createPriorityLimiter(limit) {
300
+ let active = 0;
301
+ const waiting = [];
302
+ const next = () => {
303
+ while (active < limit && waiting.length) {
304
+ waiting.sort((a, b) => a.priority - b.priority);
305
+ active++;
306
+ waiting.shift().start();
307
+ }
308
+ };
309
+ return {
310
+ run(priority, fn) {
311
+ return new Promise((resolve, reject) => {
312
+ waiting.push({
313
+ priority,
314
+ start: () => fn().then(resolve, reject).finally(() => {
315
+ active--;
316
+ next();
317
+ })
318
+ });
319
+ next();
320
+ });
321
+ },
322
+ get queued() {
323
+ return waiting.length + active;
324
+ }
325
+ };
326
+ }
327
+ function parseJson(raw) {
328
+ try {
329
+ return JSON.parse(raw);
330
+ } catch {
331
+ return { error: "\u884C\u60C5\u547D\u4EE4\u8FD4\u56DE\u4E86\u65E0\u6CD5\u89E3\u6790\u7684\u6570\u636E" };
332
+ }
333
+ }
334
+ function trendRows(value) {
335
+ if (!Array.isArray(value)) throw new Error("K\u7EBF\u6570\u636E\u683C\u5F0F\u4E0D\u6B63\u786E");
336
+ return value.map((row) => ({ date: String(row?.date ?? ""), close: Number(row?.close) })).filter((row) => Number.isFinite(row.close) && row.close > 0);
337
+ }
338
+ function createDashboardHandler(options) {
339
+ const { runPy: runPy2, watchlistFile, webDir } = options;
340
+ const limiter = createPriorityLimiter(MAX_PYTHON);
341
+ const slots = /* @__PURE__ */ new Map();
342
+ const inflight = /* @__PURE__ */ new Set();
343
+ let viewedRegion = "cn";
344
+ let lastSeen = 0;
345
+ const slot = (key) => {
346
+ let value = slots.get(key);
347
+ if (!value) slots.set(key, value = { value: null, error: null, updatedAt: 0, checkedAt: 0, running: false, force: false, failures: 0 });
348
+ return value;
349
+ };
350
+ const trading = (region) => TRADING_PHASES.has(slots.get(`phase:${region}`)?.value?.phase ?? "");
351
+ function freshFor(kind, region) {
352
+ const open = trading(region);
353
+ const watched = Date.now() - lastSeen < 2 * MINUTE;
354
+ if (kind === "phase") return watched ? MINUTE : 5 * MINUTE;
355
+ if (slots.get(`phase:${region}`)?.value?.phase === "closed") return 2 * 60 * MINUTE;
356
+ switch (kind) {
357
+ case "quote":
358
+ case "indices":
359
+ return open ? watched ? 30 * SECOND : 5 * MINUTE : 30 * MINUTE;
360
+ case "trend":
361
+ return open ? 10 * MINUTE : 60 * MINUTE;
362
+ case "sectors":
363
+ return open ? watched ? MINUTE : 5 * MINUTE : 30 * MINUTE;
364
+ case "stats":
365
+ return open ? watched ? 2 * MINUTE : 10 * MINUTE : 60 * MINUTE;
366
+ }
367
+ }
368
+ const py = async (script, args, timeoutMs) => parseJson(await runPy2(script, args, timeoutMs));
369
+ function quoteJob(symbol, priority) {
370
+ return {
371
+ key: `quote:${symbol}`,
372
+ kind: "quote",
373
+ region: symbolRegion(symbol),
374
+ priority,
375
+ run: async () => {
376
+ const value = await py("stock_data.py", ["quote", dashboardQuoteSymbol(symbol)], 2e4);
377
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("\u62A5\u4EF7\u6570\u636E\u683C\u5F0F\u4E0D\u6B63\u786E");
378
+ if (value.error) throw new Error(safeError(value.error, "\u62A5\u4EF7\u6682\u4E0D\u53EF\u7528"));
379
+ return { ...value, symbol };
380
+ }
381
+ };
382
+ }
383
+ function trendJob(symbol, region, priority) {
384
+ return {
385
+ key: `trend:${symbol}`,
386
+ kind: "trend",
387
+ region,
388
+ priority,
389
+ // Yahoo-backed regions regularly need 20-30 s from mainland networks.
390
+ run: async () => trendRows(await py("stock_data.py", ["kline", symbol, "--period", "daily", "--count", "30"], region === "cn" ? 2e4 : 4e4))
391
+ };
392
+ }
393
+ function jobs(symbols) {
394
+ const list = [];
395
+ for (const region of REGIONS) {
396
+ list.push({
397
+ key: `phase:${region}`,
398
+ kind: "phase",
399
+ region,
400
+ priority: 0,
401
+ run: async () => {
402
+ const value = await py("trading_calendar.py", ["phase", region.toUpperCase()], 1e4);
403
+ if (!value || typeof value !== "object" || value.error) throw new Error("\u4EA4\u6613\u9636\u6BB5\u6682\u4E0D\u53EF\u7528");
404
+ return value;
405
+ }
406
+ });
407
+ }
408
+ for (const symbol of symbols) list.push(quoteJob(symbol, 1));
409
+ for (const region of REGIONS) {
410
+ const indexPriority = region === viewedRegion ? 1 : 2;
411
+ if (region === "cn") {
412
+ for (const code of CN_INDEX_SYMBOLS) list.push(quoteJob(code, indexPriority));
413
+ } else {
414
+ list.push({
415
+ key: `indices:${region}`,
416
+ kind: "indices",
417
+ region,
418
+ priority: indexPriority,
419
+ run: async () => {
420
+ const value = await py("stock_data.py", ["market_indices", "--region", region], 6e4);
421
+ if (!Array.isArray(value)) throw new Error(safeError(value?.error, "\u6307\u6570\u6682\u4E0D\u53EF\u7528"));
422
+ return value;
423
+ }
424
+ });
425
+ }
426
+ }
427
+ for (const symbol of symbols) list.push(trendJob(symbol, symbolRegion(symbol), 3));
428
+ for (const region of REGIONS) {
429
+ for (const code of INDEX_SYMBOLS[region]) {
430
+ const ribbon = RIBBON.some(([, item]) => item === code);
431
+ list.push(trendJob(code, region, ribbon || region === viewedRegion ? 3 : 4));
432
+ }
433
+ }
434
+ list.push({
435
+ key: "sectors",
436
+ kind: "sectors",
437
+ region: "cn",
438
+ priority: 4,
439
+ run: async () => {
440
+ const value = await py("stock_data.py", ["sector_rankings", "--top", "5", "--direction", "both", "--board-type", "industry"], 25e3);
441
+ if (!value || !Array.isArray(value.top)) throw new Error(safeError(value?.error, "\u884C\u4E1A\u6392\u884C\u6682\u4E0D\u53EF\u7528"));
442
+ return { top: value.top, bottom: Array.isArray(value.bottom) ? value.bottom : [] };
443
+ }
444
+ });
445
+ list.push({
446
+ // Slow (~15 s alone) but first-viewport content: start it in the first wave on its own worker.
447
+ key: "stats",
448
+ kind: "stats",
449
+ region: "cn",
450
+ priority: 2,
451
+ run: async () => {
452
+ const value = await py("stock_data.py", ["market_stats"], 13e4);
453
+ if (!value || typeof value !== "object" || value.error) throw new Error(safeError(value?.error, "\u5E02\u573A\u5BBD\u5EA6\u6682\u4E0D\u53EF\u7528"));
454
+ return value;
455
+ }
456
+ });
457
+ return list;
458
+ }
459
+ function due(job, now) {
460
+ const entry = slot(job.key);
461
+ if (entry.running) return false;
462
+ if (entry.force || entry.checkedAt === 0) return true;
463
+ const fresh = freshFor(job.kind, job.region);
464
+ const retry = Math.min(fresh, MINUTE * 2 ** Math.min(entry.failures - 1, 5));
465
+ return now - entry.checkedAt >= (entry.error ? retry : fresh);
466
+ }
467
+ function start(job) {
468
+ const entry = slot(job.key);
469
+ entry.running = true;
470
+ entry.force = false;
471
+ const task = limiter.run(job.priority, job.run).then(
472
+ (value) => {
473
+ entry.value = value;
474
+ entry.error = null;
475
+ entry.failures = 0;
476
+ entry.updatedAt = Date.now();
477
+ },
478
+ (error) => {
479
+ entry.error = safeError(error instanceof Error ? error.message : null, "\u6570\u636E\u6682\u4E0D\u53EF\u7528");
480
+ entry.failures++;
481
+ }
482
+ ).finally(() => {
483
+ entry.running = false;
484
+ entry.checkedAt = Date.now();
485
+ inflight.delete(task);
486
+ });
487
+ inflight.add(task);
488
+ return task;
489
+ }
490
+ function currentSymbols() {
491
+ try {
492
+ return readWatchlist(watchlistFile);
493
+ } catch {
494
+ return [];
495
+ }
496
+ }
497
+ async function tick() {
498
+ const symbols = currentSymbols();
499
+ const list = jobs(symbols);
500
+ const keep = new Set(list.map((job) => job.key));
501
+ for (const key of slots.keys()) if (!keep.has(key) && !slots.get(key).running) slots.delete(key);
502
+ const now = Date.now();
503
+ await Promise.all(list.filter((job) => due(job, now)).sort((a, b) => a.priority - b.priority).map(start));
504
+ }
505
+ async function settle() {
506
+ while (inflight.size) await Promise.all([...inflight]);
507
+ }
508
+ const kick = () => {
509
+ void tick();
510
+ };
511
+ function slotView(key) {
512
+ const entry = slots.get(key);
513
+ return {
514
+ value: entry?.value ?? null,
515
+ error: entry?.error ?? null,
516
+ updatedAt: entry?.updatedAt ? new Date(entry.updatedAt).toISOString() : null,
517
+ loading: !entry || entry.running || entry.checkedAt === 0
518
+ };
519
+ }
520
+ function indexRow(region, code) {
521
+ const trend = slotView(`trend:${code}`);
522
+ if (region === "cn") {
523
+ const quote2 = slotView(`quote:${code}`);
524
+ return { region, code, quote: quote2.value, error: quote2.error, loading: quote2.loading, trend: trend.value };
525
+ }
526
+ const indices = slotView(`indices:${region}`);
527
+ const quote = Array.isArray(indices.value) ? indices.value.find((row) => row?.code === code) ?? null : null;
528
+ return { region, code, quote, error: indices.error, loading: indices.loading, trend: trend.value };
529
+ }
530
+ function snapshot(region) {
531
+ lastSeen = Date.now();
532
+ viewedRegion = region;
533
+ const symbols = readWatchlist(watchlistFile);
534
+ kick();
535
+ return {
536
+ watchlist: symbols.map((symbol) => {
537
+ const quote = slotView(`quote:${symbol}`);
538
+ const trend = slotView(`trend:${symbol}`);
539
+ return {
540
+ symbol,
541
+ region: symbolRegion(symbol),
542
+ quote: quote.value,
543
+ quoteError: quote.error,
544
+ quoteLoading: quote.loading,
545
+ trend: trend.value,
546
+ trendError: trend.error
547
+ };
548
+ }),
549
+ ribbon: RIBBON.map(([item, code]) => indexRow(item, code)),
550
+ phases: Object.fromEntries(REGIONS.map((item) => [item, slotView(`phase:${item}`).value])),
551
+ market: { region, indices: INDEX_SYMBOLS[region].map((code) => indexRow(region, code)) },
552
+ // A-share breadth and sectors are the only whole-market statistics; other regions stay honest blanks.
553
+ stats: slotView("stats"),
554
+ sectors: slotView("sectors"),
555
+ pending: limiter.queued,
556
+ fetchedAt: (/* @__PURE__ */ new Date()).toISOString()
557
+ };
558
+ }
559
+ function parseRegion(value) {
560
+ const region = value ?? "cn";
561
+ if (!REGIONS.includes(region)) throw new HttpError(400, "\u4E0D\u652F\u6301\u7684\u5E02\u573A\u533A\u57DF");
562
+ return region;
563
+ }
564
+ let timer;
565
+ if (options.warm) {
566
+ kick();
567
+ timer = setInterval(kick, TICK_MS);
568
+ timer.unref();
569
+ }
570
+ const handler = (async (req, res) => {
571
+ try {
572
+ const url = new URL(req.url ?? "/", "http://dashboard.local");
573
+ if (url.pathname !== DASHBOARD_BASE && !url.pathname.startsWith(`${DASHBOARD_BASE}/`)) return sendJson(res, 404, { error: "Not found" });
574
+ const rest = url.pathname.slice(DASHBOARD_BASE.length) || "/";
575
+ if (rest.startsWith("/api/")) assertApiAccess(req);
576
+ if (rest === "/api/snapshot") {
577
+ if (req.method !== "GET") return sendJson(res, 405, { error: "Method not allowed" });
578
+ return sendJson(res, 200, snapshot(parseRegion(url.searchParams.get("region"))));
579
+ }
580
+ if (rest === "/api/refresh") {
581
+ if (req.method !== "POST") return sendJson(res, 405, { error: "Method not allowed" });
582
+ for (const entry of slots.values()) if (!entry.running) entry.force = true;
583
+ kick();
584
+ return sendJson(res, 202, { ok: true, pending: limiter.queued });
585
+ }
586
+ if (rest === "/api/watchlist") {
587
+ if (req.method === "GET") return sendJson(res, 200, { symbols: readWatchlist(watchlistFile) });
588
+ if (req.method === "POST") {
589
+ const body2 = await readJson(req);
590
+ if (!body2?.op) throw new HttpError(400, "\u5FC5\u987B\u6307\u5B9A add \u6216 remove \u64CD\u4F5C");
591
+ const symbols = normalizeWatchlist(body2.symbols);
592
+ const current = readWatchlist(watchlistFile);
593
+ let saved;
594
+ if (body2.op === "add") saved = writeWatchlist(watchlistFile, [...current, ...symbols]);
595
+ else if (body2.op === "remove") saved = writeWatchlist(watchlistFile, current.filter((symbol) => !symbols.includes(symbol)));
596
+ else throw new HttpError(400, "\u4E0D\u652F\u6301\u81EA\u9009\u80A1\u64CD\u4F5C");
597
+ kick();
598
+ return sendJson(res, 200, { symbols: saved });
599
+ }
600
+ return sendJson(res, 405, { error: "Method not allowed" });
601
+ }
602
+ if (rest.startsWith("/api/")) return sendJson(res, 404, { error: "Not found" });
603
+ if (req.method !== "GET" && req.method !== "HEAD") return sendJson(res, 404, { error: "Not found" });
604
+ const asset = STATIC_FILES.get(rest);
605
+ if (!asset) return sendJson(res, 404, { error: "Not found" });
606
+ const [file, contentType] = asset;
607
+ let body;
608
+ try {
609
+ body = readFileSync(join3(webDir, file));
610
+ } catch {
611
+ return sendJson(res, 404, { error: "Not found" });
612
+ }
613
+ res.writeHead(200, {
614
+ "content-type": contentType,
615
+ "content-length": body.length,
616
+ "cache-control": "no-cache",
617
+ "x-content-type-options": "nosniff"
618
+ });
619
+ res.end(req.method === "HEAD" ? void 0 : body);
620
+ } catch (error) {
621
+ if (error instanceof HttpError) return sendJson(res, error.status, { error: error.message });
622
+ const message = error instanceof Error && !/[/\\]/.test(error.message) ? error.message : "\u4EEA\u8868\u76D8\u670D\u52A1\u6682\u65F6\u4E0D\u53EF\u7528";
623
+ return sendJson(res, 500, { error: message });
624
+ }
625
+ });
626
+ handler.tick = tick;
627
+ handler.settle = settle;
628
+ handler.dispose = () => {
629
+ if (timer) clearInterval(timer);
630
+ timer = void 0;
631
+ };
632
+ return handler;
633
+ }
634
+ function registerDashboard(ctx, runPy2) {
635
+ if (typeof ctx.inject !== "function") return;
636
+ const here2 = dirname(fileURLToPath(import.meta.url));
637
+ const webDir = [join3(here2, "web"), join3(here2, "dist", "web")].find((dir) => existsSync(join3(dir, "app.js"))) ?? join3(here2, "web");
638
+ const dataRoot = process.env.DSH_HOME || join3(homedir(), ".dsh");
639
+ const watchlistFile = process.env.STOCK_WATCHLIST_FILE || join3(dataRoot, "stock-analysis", "watchlist.json");
640
+ ctx.inject(["webServer"], (nested) => {
641
+ const c = nested;
642
+ c.effect(() => {
643
+ const handler = createDashboardHandler({ runPy: runPy2, watchlistFile, webDir, warm: true });
644
+ const disposeRoute = c.webServer.register({ kind: "prefix", path: DASHBOARD_BASE, handler });
645
+ return () => {
646
+ handler.dispose();
647
+ disposeRoute();
648
+ };
649
+ });
143
650
  });
144
651
  }
145
652
 
146
653
  // dsh/index.ts
147
- var defaultExecutor = async (bin, argv) => {
654
+ var defaultExecutor = async (bin, argv, timeoutMs) => {
148
655
  const exec = promisify(cp.execFile);
149
656
  try {
150
- const { stdout } = await exec(bin, argv, { maxBuffer: 32 * 1024 * 1024, timeout: commandTimeout(argv[0], argv.slice(1)) });
657
+ const { stdout } = await exec(bin, argv, { maxBuffer: 32 * 1024 * 1024, timeout: timeoutMs ?? commandTimeout(argv[0], argv.slice(1)) });
151
658
  return stdout;
152
659
  } catch (error) {
153
660
  const stdout = error.stdout;
@@ -163,47 +670,56 @@ var executor = defaultExecutor;
163
670
  function __setExecutor(fn) {
164
671
  executor = fn;
165
672
  }
166
- var here = dirname(fileURLToPath(import.meta.url));
167
- var toolsDir = join3(here, "..", "tools");
168
- var pkgRoot = dirname(toolsDir);
673
+ var here = dirname2(fileURLToPath2(import.meta.url));
674
+ var pkgRoot = [join4(here, ".."), join4(here, "..", "..")].find((root) => existsSync2(join4(root, "tools"))) ?? join4(here, "..");
675
+ var toolsDir = join4(pkgRoot, "tools");
169
676
  var isWin2 = process.platform === "win32";
170
677
  function pythonBin() {
171
- for (const root of [pkgRoot, join3(pkgRoot, "..")]) {
678
+ for (const root of [pkgRoot, join4(pkgRoot, "..")]) {
172
679
  const candidate = venvPythonPath(root);
173
- if (existsSync(candidate)) return candidate;
680
+ if (existsSync2(candidate)) return candidate;
174
681
  }
175
682
  return isWin2 ? "python" : "python3";
176
683
  }
177
- async function runPy(script, args) {
178
- return executor(pythonBin(), [join3(toolsDir, script), ...args]);
684
+ async function runPy(script, args, timeoutMs) {
685
+ return executor(pythonBin(), [join4(toolsDir, script), ...args], timeoutMs);
179
686
  }
687
+ var textOutput = {
688
+ schema: { type: "string" },
689
+ render: (_args, value) => [{ type: "text", text: value }]
690
+ };
180
691
  function pyTool(opts) {
181
692
  return defineTool2({
182
693
  name: opts.name,
183
694
  description: opts.description,
184
695
  parameters: opts.parameters,
185
- output: {
186
- schema: { type: "string" },
187
- render: (_args, value) => [{ type: "text", text: value }]
188
- },
696
+ output: textOutput,
189
697
  async execute(args) {
190
698
  return runPy(opts.script, opts.argv(args));
191
699
  }
192
700
  });
193
701
  }
194
- var skillsDir = join3(here, "..", "skills");
702
+ function closedTool(opts) {
703
+ const tool = defineTool2({
704
+ ...opts,
705
+ output: textOutput
706
+ });
707
+ tool.parameters.additionalProperties = false;
708
+ return tool;
709
+ }
710
+ var skillsDir = join4(pkgRoot, "skills");
195
711
  function frontmatterValue(raw, key) {
196
712
  const block = raw.match(/^---\r?\n([\s\S]*?)\r?\n---/);
197
713
  const line = block?.[1].match(new RegExp(`^${key}:\\s*(.+)$`, "m"));
198
714
  return line?.[1].trim();
199
715
  }
200
716
  function registerSkills(ctx) {
201
- if (!existsSync(skillsDir)) return;
717
+ if (!existsSync2(skillsDir)) return;
202
718
  for (const child of readdirSync(skillsDir, { withFileTypes: true })) {
203
719
  if (!child.isDirectory()) continue;
204
- const skillFile = join3(skillsDir, child.name, "SKILL.md");
205
- if (!existsSync(skillFile)) continue;
206
- const raw = readFileSync(skillFile, "utf-8");
720
+ const skillFile = join4(skillsDir, child.name, "SKILL.md");
721
+ if (!existsSync2(skillFile)) continue;
722
+ const raw = readFileSync2(skillFile, "utf-8");
207
723
  ctx.skills.register({
208
724
  name: child.name,
209
725
  description: frontmatterValue(raw, "description") ?? child.name,
@@ -212,7 +728,7 @@ function registerSkills(ctx) {
212
728
  content: raw.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/, "").trimStart(),
213
729
  source: "bundled",
214
730
  path: skillFile,
215
- resourceBase: { kind: "directory", path: join3(skillsDir, child.name) }
731
+ resourceBase: { kind: "directory", path: join4(skillsDir, child.name) }
216
732
  });
217
733
  }
218
734
  }
@@ -222,8 +738,9 @@ function apply(ctx, config = {}) {
222
738
  if (config.toolDiscovery !== void 0 && typeof config.toolDiscovery !== "boolean") {
223
739
  throw new TypeError("toolDiscovery must be a boolean");
224
740
  }
225
- const previousTools = new Set(ctx.tools.schemas?.().map((tool) => tool.name));
226
- ctx.tools.register(
741
+ const discovery = config.toolDiscovery === false ? void 0 : createToolDiscovery(ctx);
742
+ const register = (tool) => ctx.tools.register(tool, discovery?.(tool));
743
+ register(
227
744
  pyTool({
228
745
  name: "get_announcements",
229
746
  description: "\u67E5\u8BE2A\u80A1\u5DE8\u6F6E\u516C\u544A\u6807\u9898\u3001\u65E5\u671F\u3001\u7C7B\u578B\u548C\u539F\u6587PDF\u94FE\u63A5\uFF1B\u6309\u65E5\u671F\u8303\u56F4/\u7C7B\u522B\u7B5B\u9009\uFF0C\u9ED8\u8BA4\u8FD190\u5929\uFF0Ctop=1..500\u3002\u7B2C\u4E00\u7248\u4E0D\u63D0\u53D6\u6B63\u6587\uFF0Ctruncated\u63D0\u793A\u622A\u65AD\u3002",
@@ -266,7 +783,7 @@ function apply(ctx, config = {}) {
266
783
  argv: (p) => ["announcements", p.symbol, "--category", p.category ?? "all", "--start-date", p.start_date ?? "", "--end-date", p.end_date ?? "", "--top", String(p.top ?? 50)]
267
784
  })
268
785
  );
269
- ctx.tools.register(
786
+ register(
270
787
  pyTool({
271
788
  name: "get_us_holdings",
272
789
  description: "\u67E5\u8BE2SEC 13F\uFF1Amode=auto\u9ED8\u8BA4\u670913F\u7533\u62A5\u65F6\u67E5\u673A\u6784\uFF0C\u5426\u5219\u6309\u53D1\u884C\u4EBACIK\u53CD\u67E5\u6301\u4ED3\u673A\u6784\uFF1Bmanager/issuer\u53EF\u663E\u5F0F\u6307\u5B9A\u3002\u53D1\u884C\u4EBA\u901A\u8FC7\u5B98\u65B913D/G\u7CBE\u786E\u6620\u5C04CUSIP\uFF0C\u626B\u63CF\u6700\u65B0\u5DF2\u53D1\u5E0313F\u7A97\u53E3\uFF0C\u5904\u7406\u91CD\u8FF0/\u8865\u5145\u4FEE\u8BA2\uFF0C\u8FD4\u56DE\u5B9E\u9645\u62A5\u544A\u671F\u3001\u622A\u6B62\u65E5\u53CA\u6620\u5C04\u8986\u76D6\u3002\u9996\u6B21\u7EA6100MB\u4E0B\u8F7D\uFF0C\u540E\u7EED\u7F13\u5B58\uFF1B\u65E0\u6620\u5C04\u660E\u786E\u62A5\u9519\uFF0C\u4E0D\u505A\u540D\u79F0\u731C\u6D4B\u3002\u9700SEC_USER_AGENT\u542B\u771F\u5B9E\u8054\u7CFB\u90AE\u7BB1\uFF0C\u4E0D\u662F\u5B9E\u65F6\u6216\u5168\u90E8\u8BC1\u5238\u6301\u4ED3\u3002",
@@ -282,7 +799,7 @@ function apply(ctx, config = {}) {
282
799
  argv: (p) => ["holdings", p.cik, ...p.mode ? ["--mode", p.mode] : []]
283
800
  })
284
801
  );
285
- ctx.tools.register(
802
+ register(
286
803
  pyTool({
287
804
  name: "get_insider_trades",
288
805
  description: "\u67E5\u8BE2\u7F8E\u80A1\u53D1\u884C\u4EBA\u8FD1\u671FForm 4/4-A\u5185\u90E8\u4EBA\u4EA4\u6613\uFF08SEC\u5B98\u65B9XML\uFF09\uFF0C\u4FDD\u7559\u4EBA\u5458\u804C\u52A1\u3001\u4EA4\u6613\u4EE3\u7801\u3001\u4E70\u5356\u65B9\u5411\u3001\u6570\u91CF\u3001\u4EF7\u683C\u3001\u811A\u6CE8\u548C\u884D\u751F\u54C1\u6807\u5FD7\u3002\u9700SEC_USER_AGENT\u542B\u771F\u5B9E\u8054\u7CFB\u90AE\u7BB1\uFF1Bdays\u6309\u7533\u62A5\u65E5\u671F\u7B5B\u9009\uFF0Ctop\u9650\u5236\u6587\u4EF6\u6570\uFF0C\u4FEE\u8BA2\u52FF\u91CD\u590D\u8BA1\u6570\u3002",
@@ -305,7 +822,7 @@ function apply(ctx, config = {}) {
305
822
  argv: (p) => ["insider_trades", p.symbol, "--days", String(p.days ?? 90), "--top", String(p.top ?? 10)]
306
823
  })
307
824
  );
308
- ctx.tools.register(
825
+ register(
309
826
  pyTool({
310
827
  name: "get_valuation_history",
311
828
  description: "\u67E5\u8BE2A/HK\u80A1\u7968\u5386\u53F2PE-TTM/PB\u3001\u5F53\u524D\u6B63\u503C\u5206\u4F4D\u548C10/25/50/75/90\u5206\u4F4DBand\uFF0C\u8FD4\u56DE\u5B9E\u9645\u91C7\u6837\u533A\u95F4\uFF1B\u4E8F\u635F\u4F30\u503C\u5206\u4F4D\u4E3Anull\u3002years=1..10\uFF0C\u6309\u5929\u7F13\u5B58\u3002HK\u914D\u7F6ELIXINGER_TOKEN\u65F6\u4F18\u5148\u7406\u674F\u4EC1\u975E\u91D1\u878D\u516C\u53F8\u65E5\u5386\u53F2\uFF0C\u5931\u8D25\u964D\u7EA7\u767E\u5EA6\uFF0C\u4E0D\u6DF7\u63A5\u6765\u6E90\u3002",
@@ -324,7 +841,7 @@ function apply(ctx, config = {}) {
324
841
  argv: (p) => ["valuation_history", p.symbol, "--years", String(p.years ?? 5)]
325
842
  })
326
843
  );
327
- ctx.tools.register(
844
+ register(
328
845
  pyTool({
329
846
  name: "get_index_valuation",
330
847
  description: "\u67E5\u8BE2\u4E2D\u56FD\u6307\u6570\u4F30\u503C\u5386\u53F2\u5206\u4F4D\u4E0EBand\uFF1B\u4E50\u5495\u4E50\u80A1PE/PB\u4F18\u5148\uFF0C\u4E2D\u8BC1\u5B98\u65B9\u5386\u53F2\u8865\u5145\u6EDA\u52A8PE\u5E76\u4FDD\u7559\u8FD1\u671FPE1\u53E3\u5F84\u3002\u7F3APB\u65F6\u53EF\u7528LIXINGER_TOKEN\u8865\u5145\u7406\u674F\u4EC1mcw\u5386\u53F2\uFF0C\u6765\u6E90\u4E0E\u7B97\u6CD5\u5206\u522B\u6807\u660E\uFF0C\u4E0D\u6DF7\u63A5\u540C\u4E00\u6307\u6807\u3002",
@@ -343,7 +860,7 @@ function apply(ctx, config = {}) {
343
860
  argv: (p) => ["index_valuation", p.symbol, "--years", String(p.years ?? 5)]
344
861
  })
345
862
  );
346
- ctx.tools.register(
863
+ register(
347
864
  pyTool({
348
865
  name: "get_earnings_calendar",
349
866
  description: "\u67E5\u8BE2\u8D22\u62A5\u65E5\u5386\uFF1AA\u80A1report_date\u5FC5\u586B\u5B63\u5EA6\u671F\u672B\uFF0C\u8FD4\u56DE\u9884\u7EA6/\u4FEE\u8BA2/\u5B9E\u9645\u62AB\u9732\u4E0E\u4E1A\u7EE9\u9884\u544A\uFF1BHK\u9700symbol\uFF0C\u4F18\u5148HKEX\u5DF2\u516C\u544A\u4E1A\u7EE9\u5BA1\u6279\u8463\u4E8B\u4F1A\u6392\u671F\uFF08\u4E0D\u662F\u5B9E\u9645\u62AB\u9732\u65E5\uFF09\uFF0C\u7F3A\u5931\u65F6\u8FD4\u56DE\u4F9B\u5E94\u5546\u65E5\u671F\u3002HK\u53EF\u6309\u5DF2\u77E5\u8D22\u653F\u671F\u672B\u8FC7\u6EE4\uFF0C\u672A\u77E5\u671F\u6B21\u53E6\u5217\u3002",
@@ -365,7 +882,7 @@ function apply(ctx, config = {}) {
365
882
  argv: (p) => ["earnings_calendar", "--report-date", p.report_date ?? "", "--symbol", p.symbol ?? "", "--top", String(p.top ?? 50)]
366
883
  })
367
884
  );
368
- ctx.tools.register(
885
+ register(
369
886
  pyTool({
370
887
  name: "get_shareholder_structure",
371
888
  description: "\u67E5\u8BE2A\u80A1\u80A1\u4E1C\u6237\u6570\u3001\u5341\u5927\u6D41\u901A\u80A1\u4E1C\u53D8\u5316\u53CA\u6CAA\u6DF1\u4EA4\u6613\u6240\u5B63\u5EA6\u5317\u5411\u5408\u8BA1\u6301\u80A1\uFF1B\u5B98\u65B9\u603B\u91CF\u4F18\u5148\uFF0C\u5341\u5927HKSCC\u540D\u4E49\u6301\u80A1\u4EC5\u515C\u5E95\u4E14\u6807\u660E\u53E3\u5F84\u3002HK\u8FD4\u56DE\u6E2F\u4EA4\u6240\u5357\u5411\u8BB0\u5F55\u3002\u7F3A\u5931\u4E0D\u5F53\u96F6\uFF0C\u671F\u672B\u4E0D\u7B49\u4E8E\u5DF2\u516C\u5E03\u3002",
@@ -384,7 +901,7 @@ function apply(ctx, config = {}) {
384
901
  argv: (p) => ["shareholder_structure", p.symbol, "--report-date", p.report_date ?? ""]
385
902
  })
386
903
  );
387
- ctx.tools.register(
904
+ register(
388
905
  pyTool({
389
906
  name: "get_etf_details",
390
907
  description: "\u67E5\u8BE2A\u80A1ETF\u51C0\u503C\u6298\u6EA2\u4EF7\u3001\u89C4\u6A21\u3001\u62AB\u9732\u6301\u4ED3\u53CA\u6CAA\u6DF1\u5B8C\u6574PCF\u7533\u8D4E\u7BEE\u5B50\uFF1B\u7BEE\u5B50\u4E0D\u662F\u5B9E\u9645\u6301\u4ED3\u3002include_full_holdings=true\u53E6\u53D6\u6700\u8FD1\u53EF\u5F97\u534A\u5E74\u5EA6/\u5E74\u5EA6\u62AB\u9732\u80A1\u7968\u8868\uFF0C\u542B\u6570\u91CF/\u5E02\u503C/\u62A5\u544A\u671F\uFF0C\u975E\u5B9E\u65F6\u5168\u8D44\u4EA7\u7EC4\u5408\uFF1Bbenchmark\u7528\u4E8E\u8DDF\u8E2A\u8BEF\u5DEE\u3002",
@@ -408,7 +925,7 @@ function apply(ctx, config = {}) {
408
925
  argv: (p) => ["etf_details", p.symbol, "--benchmark", p.benchmark ?? "", "--days", String(p.days ?? 60), ...p.include_full_holdings ? ["--include-full-holdings"] : []]
409
926
  })
410
927
  );
411
- ctx.tools.register(
928
+ register(
412
929
  pyTool({
413
930
  name: "get_dividends",
414
931
  description: "\u67E5\u8BE2A/HK\u5206\u7EA2\u5386\u53F2\u3001\u9664\u606F\u65E5\u5386\u3001\u5DF2\u5B9E\u65BDTTM\u80A1\u606F\u4E0E\u8FDE\u7EED\u5E74\u6570\u3002mode=ranking\u7701\u7565symbol\uFF0Cmarket=A\u67E5\u62A5\u544A\u671F\u6392\u884C\uFF0Cmarket=HK\u67E5HKEX/LSEG\u5E74\u5EA6\u80A1\u606F\u7387\u6392\u884C\uFF08report_date\u987B\u5E74\u672B\uFF09\uFF1B\u6392\u884C\u5747\u975E\u5F53\u524DTTM\u6536\u76CA\u7387\u3002\u7F3A\u5931\u4E0D\u6309\u96F6\u3002",
@@ -444,7 +961,7 @@ function apply(ctx, config = {}) {
444
961
  argv: (p) => ["dividends", "--market", p.market ?? "A", "--symbol", p.symbol ?? "", "--mode", p.mode ?? "history", "--report-date", p.report_date ?? "", "--years", String(p.years ?? 10), "--top", String(p.top ?? 20)]
445
962
  })
446
963
  );
447
- ctx.tools.register(
964
+ register(
448
965
  pyTool({
449
966
  name: "get_kline",
450
967
  description: "\u83B7\u53D6\u80A1\u7968K\u7EBF\u6570\u636E\uFF08OHLCV\uFF09\u3002\u652F\u6301A\u80A1\uFF08\u5982600519\uFF09\u3001\u6E2F\u80A1\uFF08\u598200700.HK\uFF09\u3001\u7F8E\u80A1\uFF08\u5982AAPL\uFF09\u3001\u65E5\u80A1\uFF08\u59827203.T\uFF09\u3001\u97E9\u80A1\uFF08\u5982005930.KS\uFF09\u3001\u53F0\u80A1\uFF08\u59822330.TW\uFF09\u53CAA\u80A1ETF\u3002A\u80A1\u80A1\u7968/ETF\u8FD4\u56DE\u524D\u590D\u6743\u4EF7\u683C\uFF0C\u6BCF\u6761\u8BB0\u5F55 adjusted=qfq\uFF1Bsh000xxx/sz399xxx \u6307\u6570\u8FD4\u56DE\u539F\u59CB\u70B9\u4F4D\uFF0Cadjusted=none\u3002\u9700\u8981\u5386\u53F2\u4EF7\u683C\u81EA\u884C\u8BA1\u7B97\u6216\u753B\u56FE\u65F6\u7528\uFF1B\u53EA\u95EE\u6307\u6807\u7528 get_technical_analysis\uFF0C\u53EA\u95EE\u73B0\u4EF7\u7528 get_quote\u3002\u6BCF\u6761\u8BB0\u5F55\u9644 source\u3001UTC fetched_at\u3001data_as_of \u548C adjusted\uFF1B\u975EA\u80A1\u590D\u6743\u53E3\u5F84\u53EF\u80FD\u4E3Atotal_return/qfq/unknown\uFF0C\u672A\u77E5\u4E0D\u80FD\u5047\u5B9A\u5DF2\u590D\u6743\u3002\u90E8\u5206\u6765\u6E90\u9644 adjustment_factor\uFF08\u590D\u6743\u4EF7\u683C/\u539F\u59CB\u4EF7\u683C\uFF09\uFF1B\u7F3A\u5931\u4E0D\u80FD\u731C\u6D4B\u6362\u7B97\u7CFB\u6570\u3002",
@@ -472,10 +989,10 @@ function apply(ctx, config = {}) {
472
989
  ]
473
990
  })
474
991
  );
475
- ctx.tools.register(
992
+ register(
476
993
  pyTool({
477
994
  name: "get_quote",
478
- description: "\u83B7\u53D6\u80A1\u7968\u5B9E\u65F6\u884C\u60C5\u62A5\u4EF7\uFF08\u73B0\u4EF7\u3001\u6DA8\u8DCC\u5E45\u3001\u91CF\u6BD4\u7B49\uFF09\u3002\u652F\u6301A\u80A1\u3001\u6E2F\u80A1\u3001\u7F8E\u80A1\u3001\u65E5\u80A1\u3001\u97E9\u80A1\u3001\u53F0\u80A1\uFF1B\u975E\u4EA4\u6613\u65F6\u6BB5\u8FD4\u56DE\u6700\u8FD1\u4EA4\u6613\u65E5\u6536\u76D8\u4EF7\u5E76\u4EE5 as_of/stale \u6807\u6CE8\uFF1BETF \u7684 premium_discount_rate \u4E3A\u6B63=\u6EA2\u4EF7\u3001\u8D1F=\u6298\u4EF7\u3002\u8FD4\u56DE source\u3001UTC fetched_at \u548C\u63D0\u4F9B\u65B9 data_as_of\uFF08\u672A\u77E5\u4E3Anull\uFF09\uFF1Bas_of_basis\u533A\u5206\u63D0\u4F9B\u65B9\u65F6\u95F4\u4E0E\u4EA4\u6613\u65E5\u5386\u63A8\u65AD\uFF0C\u91C7\u96C6\u65F6\u95F4\u4E0D\u7B49\u4E8E\u884C\u60C5\u65F6\u95F4\u3002",
995
+ description: "\u83B7\u53D6\u80A1\u7968\u5B9E\u65F6\u884C\u60C5\u62A5\u4EF7\uFF08\u73B0\u4EF7\u3001\u6DA8\u8DCC\u5E45\u3001\u91CF\u6BD4\u7B49\uFF09\u3002\u652F\u6301A\u80A1\u3001\u6E2F\u80A1\u3001\u7F8E\u80A1\u3001\u65E5\u80A1\u3001\u97E9\u80A1\u3001\u53F0\u80A1\uFF1B\u975E\u4EA4\u6613\u65F6\u6BB5\u8FD4\u56DE\u6700\u8FD1\u4EA4\u6613\u65E5\u6536\u76D8\u4EF7\u5E76\u4EE5 as_of/stale \u6807\u6CE8\uFF1BETF \u7684 premium_discount_rate \u4E3A\u6B63=\u6EA2\u4EF7\u3001\u8D1F=\u6298\u4EF7\u3002\u8FD4\u56DE source\u3001UTC fetched_at \u548C\u63D0\u4F9B\u65B9 data_as_of\uFF08\u672A\u77E5\u4E3Anull\uFF09\uFF1Bas_of_basis\u533A\u5206\u63D0\u4F9B\u65B9\u65F6\u95F4\u4E0E\u4EA4\u6613\u65E5\u5386\u63A8\u65AD\uFF0C\u91C7\u96C6\u65F6\u95F4\u4E0D\u7B49\u4E8E\u884C\u60C5\u65F6\u95F4\u3002\u573A\u5916\u57FA\u91D1\u7528 get_fund_quote\uFF1BTIAAxxxxxx \u8FD4\u56DE\u6295\u987E\u7EC4\u5408\u8BC6\u522B\u3001advisor_org \u4E0E\u65E0\u7EDF\u4E00\u51C0\u503C\u63D0\u793A\uFF1B\u957F\u94B1/\u6D77\u5916\u957F\u94B1/\u7A33\u94B1\u53E6\u6709\u6709\u77E5\u6709\u884C official_disclosures\uFF08partial=true\uFF0C\u975E\u5B9E\u65F6\u5B8C\u6574\u6301\u4ED3\uFF09\uFF1B\u5176\u4ED6\u7EC4\u5408\u641C\u7D22\u53EF\u7528\u65F6\u4E3A search_partial\uFF0C\u5426\u5219 unsupported_provider\u3002",
479
996
  parameters: {
480
997
  symbol: { type: "string", required: true, description: "\u80A1\u7968\u4EE3\u7801\uFF08A\u80A1\u5982600519\uFF0C\u7F8E\u80A1\u5982AAPL\uFF0C\u6E2F\u80A1\u598200700.HK\uFF09" }
481
998
  },
@@ -483,7 +1000,18 @@ function apply(ctx, config = {}) {
483
1000
  argv: (p) => ["quote", p.symbol]
484
1001
  })
485
1002
  );
486
- ctx.tools.register(
1003
+ register(
1004
+ pyTool({
1005
+ name: "get_fund_quote",
1006
+ description: "\u83B7\u53D6\u573A\u5916\u516C\u52DF\u57FA\u91D1\u51C0\u503C\uFF086\u4F4D\u57FA\u91D1\u4EE3\u7801\uFF0C\u5982018147\uFF09\u3002nav \u662F\u5DF2\u62AB\u9732\u65E5\u7EC8\u51C0\u503C\uFF0C\u975E\u5B9E\u65F6\u4EF7\uFF1B\u8FD4\u56DE accumulated_nav\uFF08\u7D2F\u8BA1\u51C0\u503C\uFF09\u3001change_pct\uFF08\u65E5\u6DA8\u8DCC\u5E45\uFF09\u3001nav_date\uFF08\u51C0\u503C\u65E5\u671F\uFF09\u3002estimated_nav \u4E3A\u4F30\u7B97\u51C0\u503C\uFF0C\u53EF\u80FD\u4E3A null\uFF0C\u4E0D\u80FD\u5F53\u4F5C\u5B9E\u65F6\u4EF7\uFF1BQDII \u51C0\u503C\u53EF\u80FD\u6EDE\u540E 1-2 \u4EA4\u6613\u65E5\u3002",
1007
+ parameters: {
1008
+ symbol: { type: "string", required: true, description: "6\u4F4D\u573A\u5916\u516C\u52DF\u57FA\u91D1\u4EE3\u7801\uFF0C\u5982 018147" }
1009
+ },
1010
+ script: "stock_data.py",
1011
+ argv: (p) => ["fund_quote", p.symbol]
1012
+ })
1013
+ );
1014
+ register(
487
1015
  pyTool({
488
1016
  name: "get_capital_flow",
489
1017
  description: "\u83B7\u53D6A\u80A1\u8D44\u91D1\u6D41\u5411\uFF08\u4E3B\u529B/\u8D85\u5927\u5355/\u5927\u5355/\u4E2D\u5355/\u5C0F\u5355\u51C0\u6D41\u5165\uFF09\u3002detail=\u4E2A\u80A1\u6BCF\u65E5\u660E\u7EC6\uFF0Csummary=\u591A\u65E5\u6C47\u603B+\u8D8B\u52BF\uFF0Csector_flow=\u677F\u5757\u8D44\u91D1\u6D41\u6392\u884C\u3002\u53EF\u914D\u5408 get_chip_distribution \u9A8C\u8BC1\u4E3B\u529B\u884C\u4E3A",
@@ -507,7 +1035,7 @@ function apply(ctx, config = {}) {
507
1035
  }
508
1036
  })
509
1037
  );
510
- ctx.tools.register(
1038
+ register(
511
1039
  pyTool({
512
1040
  name: "get_news",
513
1041
  description: "\u83B7\u53D6\u4E2A\u80A1\u6700\u8FD1N\u5929\u8D22\u7ECF\u65B0\u95FB\u5FEB\u8BAF\uFF08\u8F7B\u91CF\u3001\u65E0\u9700\u914D\u7F6E\uFF09\u3002\u9700\u8981\u6DF1\u5EA6\u5168\u7F51\u60C5\u62A5\u7528 search_comprehensive_intel\uFF0C\u6309\u4E3B\u9898\u641C\u7D22\u7528 search_stock_news\uFF0C\u8BFB\u6587\u7AE0\u5168\u6587\u7528 extract_article",
@@ -519,7 +1047,7 @@ function apply(ctx, config = {}) {
519
1047
  argv: (p) => ["news", p.symbol, "--days", String(p.days ?? 3)]
520
1048
  })
521
1049
  );
522
- ctx.tools.register(
1050
+ register(
523
1051
  pyTool({
524
1052
  name: "get_financials",
525
1053
  description: "\u83B7\u53D6\u80A1\u7968\u8D22\u52A1\u6458\u8981\u53CA\u5386\u53F2\u8D8B\u52BF\uFF0C\u6309\u5929\u7F13\u5B58\u3002A\u80A1annual=true\u4E0Eperiods=10\u53D6\u5341\u5E74\u5E74\u62A5\uFF1B\u6E2F\u80A1\u53EF\u914D\u7F6ELIXINGER_TOKEN\u53D6\u975E\u91D1\u878D\u516C\u53F8\u8D22\u52A1\u5E8F\u5217\uFF0C\u4FDD\u7559\u5E01\u79CD/\u62AB\u9732\u65E5/\u5B9E\u9645\u8D22\u5E74\uFF0C\u5386\u53F2\u6BD4\u7387\u5355\u4F4Dpercent\u3002\u6709\u6548Yahoo\u9876\u5C42\u5FEB\u7167\u6309\u6574\u7EC4\u4FDD\u7559\uFF0Ccurrency\u4E3A\u8D22\u62A5\u5E01\u79CD\u3001market_cap_currency\u4E3A\u5E02\u503C\u5E01\u79CD\u3001snapshot_source\u6807\u660E\u6765\u6E90\uFF1B\u7F3A\u5931\u503C\u53CAreport_date\u4E0D\u6DF7\u5165\u5386\u53F2\u6570\u503C/\u65E5\u671F\u3002\u7F3Atoken\u6216\u65E0\u6743\u9650\u964D\u7EA7\u539F\u6709\u6765\u6E90\u5E76\u6807\u6CE8\u4E0D\u8DB3\uFF0C\u4E0D\u8865\u9020\u7F3A\u5931\u3002\u4F30\u503C\u5386\u53F2\u7528get_valuation_history\uFF0C\u62AB\u9732\u6392\u671F\u7528get_earnings_calendar",
@@ -537,7 +1065,7 @@ function apply(ctx, config = {}) {
537
1065
  }
538
1066
  })
539
1067
  );
540
- ctx.tools.register(
1068
+ register(
541
1069
  pyTool({
542
1070
  name: "get_technical_analysis",
543
1071
  description: "\u83B7\u53D6\u80A1\u7968\u6280\u672F\u9762\u5206\u6790\uFF08MA/MACD/RSI/BOLL/KDJ/\u6210\u4EA4\u91CF\u7B49\u6307\u6807 + 100\u5206\u7EFC\u5408\u8BC4\u5206 + 6\u7EA7\u4E70\u5356\u4FE1\u53F7 + \u8D8B\u52BF/\u504F\u79BB\u5EA6/\u652F\u6491\u538B\u529B\u4F4D\uFF1B\u9644 trend_temperature\uFF08\u5B9E\u9A8C\u6027EMA\u5DEE/ATR\u63CF\u8FF0\uFF1Bdirection\u4E3A\u5747\u7EBF\u65B9\u5411\uFF1Bvalidation_status=not_validated\uFF0C\u975E\u661F\u7403\u6307\u6807\uFF0C\u4E03\u6863\u4E0D\u4F5C\u5165\u573A\u4F9D\u636E\uFF1B\u53E6\u9644 trend_horizons\uFF1A21/63/252\u6839\u65E5K\u6708\u5EA6\u52A8\u91CF\uFF0C\u5EFA\u8BAEcount=360\uFF0C\u975E\u6982\u7387\u3001\u672A\u9A8C\u8BC1\uFF09\uFF1B\u591A\u5468\u671F\u5171\u632F\u65F6 resonance.direction \u2208 aligned_bullish/aligned_bearish/divergent\uFF09\u3002\u4E2A\u80A1\u6280\u672F\u9762\u7EFC\u5408\u5224\u65AD\u4E0E\u4E70\u5356\u65F6\u673A\u5206\u6790\u7684\u9996\u9009\uFF1B\u53EA\u8981\u5747\u7EBF\u6570\u503C\u6216\u81EA\u5B9A\u4E49\u5468\u671F\u7528 calculate_ma\uFF0C\u4E13\u95EE\u91CF\u4EF7\u7528 get_volume_analysis\uFF0C\u626B\u5F53\u65E5\u5F02\u52A8\u7528 detect_anomaly",
@@ -569,7 +1097,7 @@ function apply(ctx, config = {}) {
569
1097
  }
570
1098
  })
571
1099
  );
572
- ctx.tools.register(
1100
+ register(
573
1101
  pyTool({
574
1102
  name: "analyze_pattern",
575
1103
  description: "K\u7EBF\u5F62\u6001\u8BC6\u522B \u2014 \u68C0\u6D4B\u5341\u5B57\u661F\u3001\u9524\u5B50\u7EBF\u3001\u541E\u6CA1\u3001\u542F\u660E\u661F\u3001\u9EC4\u660F\u661F\u3001\u53CC\u5E95\u300120\u65E5\u7A81\u7834\u7B4912+\u79CD\u7ECF\u5178\u5F62\u6001\u3002\u7EFC\u5408\u6280\u672F\u9762\u5224\u65AD\u7528 get_technical_analysis",
@@ -593,7 +1121,7 @@ function apply(ctx, config = {}) {
593
1121
  ]
594
1122
  })
595
1123
  );
596
- ctx.tools.register(
1124
+ register(
597
1125
  pyTool({
598
1126
  name: "get_market_indices",
599
1127
  description: "\u83B7\u53D6\u4E3B\u8981\u5E02\u573A\u6307\u6570\u884C\u60C5\u3002CN: \u4E0A\u8BC1/\u6DF1\u8BC1/\u521B\u4E1A\u677F/\u79D1\u521B50/\u6CAA\u6DF1300\uFF1BHK: \u6052\u751F/\u56FD\u4F01/\u79D1\u6280\uFF1BUS: \u9053\u743C\u65AF/\u7EB3\u65AF\u8FBE\u514B/\u6807\u666E500\uFF1BJP: \u65E5\u7ECF225/\u4E1C\u8BC1\uFF1BKR: KOSPI/KOSDAQ\uFF1BTW: \u53F0\u6E7E\u52A0\u6743\u3002\u5927\u76D8\u590D\u76D8\u7528 get_market_review \u4E00\u7AD9\u5F0F\u83B7\u53D6",
@@ -608,7 +1136,7 @@ function apply(ctx, config = {}) {
608
1136
  argv: (p) => ["market_indices", "--region", p.region ?? "cn"]
609
1137
  })
610
1138
  );
611
- ctx.tools.register(
1139
+ register(
612
1140
  pyTool({
613
1141
  name: "get_sector_rankings",
614
1142
  description: "\u83B7\u53D6A\u80A1\u677F\u5757\u6DA8\u8DCC\u5E45\u6392\u884C\uFF08\u542B\u9886\u6DA8\u80A1\u3001\u6DA8\u8DCC\u5BB6\u6570\u7B49\uFF09\u3002board_type=industry\uFF08\u9ED8\u8BA4\uFF09\u4E3A\u884C\u4E1A\u677F\u5757\uFF0Cboard_type=concept \u65F6\u4E3A\u6982\u5FF5\u677F\u5757\u6392\u884C\u3002\u652F\u6301\u67E5\u770B\u6DA8\u5E45\u699C/\u8DCC\u5E45\u699C/\u53CC\u5411",
@@ -637,7 +1165,7 @@ function apply(ctx, config = {}) {
637
1165
  ]
638
1166
  })
639
1167
  );
640
- ctx.tools.register(
1168
+ register(
641
1169
  pyTool({
642
1170
  name: "get_sector_constituents",
643
1171
  description: "\u67E5\u8BE2A\u80A1\u677F\u5757\u6210\u5206\u80A1\uFF08\u6B63\u5411\u6620\u5C04\uFF1A\u677F\u5757\u2192\u80A1\u7968\u5217\u8868\uFF09\u3002\u677F\u5757\u540D\u652F\u6301\u6A21\u7CCA\u5339\u914D\uFF08\u5982\u300C\u521B\u65B0\u836F\u300D\u81EA\u52A8\u89E3\u6790\u5230\u7CBE\u786E\u677F\u5757\u540D\uFF09\uFF0C\u4E1C\u8D22\u884C\u4E1A/\u6982\u5FF5 + \u65B0\u6D6A\u591A\u6E90 failover\uFF0C\u7ED3\u679C\u6309\u7528\u6237\u76EE\u5F55\u7F13\u5B587\u5929\u3002\u4EC5\u652F\u6301A\u80A1\uFF1B\u53CD\u5411\u67E5\u4E2A\u80A1\u6240\u5C5E\u677F\u5757\u7528 resolve_stock_sectors",
@@ -662,7 +1190,7 @@ function apply(ctx, config = {}) {
662
1190
  ]
663
1191
  })
664
1192
  );
665
- ctx.tools.register(
1193
+ register(
666
1194
  pyTool({
667
1195
  name: "resolve_stock_sectors",
668
1196
  description: "\u67E5\u8BE2\u4E2A\u80A1\u6240\u5C5E\u677F\u5757\uFF08\u53CD\u5411\u6620\u5C04\uFF1A\u4E2A\u80A1\u2192\u677F\u5757\uFF09\u3002A\u80A1\u8FD4\u56DE\u4E1C\u8D22\u884C\u4E1A + efinance \u6982\u5FF5/\u677F\u5757\uFF08\u96EA\u7403\u884C\u4E1A\u515C\u5E95\uFF0C\u9700 XUEQIU_TOKEN\uFF09\uFF0C\u6E2F\u80A1\u8FD4\u56DE yfinance GICS \u82F1\u6587 sector/industry \u53E3\u5F84\u3002\u677F\u5757\u7EA7\u60C5\u62A5\uFF08\u5982\u300C\u521B\u65B0\u836F\u56DE\u8C03\u300D\uFF09\u6620\u5C04\u5230\u6C60\u5185\u4E2A\u80A1\u65F6\u8C03\u672C\u5DE5\u5177\uFF1B\u6B63\u5411\u67E5\u677F\u5757\u6210\u5206\u80A1\u7528 get_sector_constituents",
@@ -677,7 +1205,7 @@ function apply(ctx, config = {}) {
677
1205
  argv: (p) => ["resolve_stock_sectors", p.symbol]
678
1206
  })
679
1207
  );
680
- ctx.tools.register(
1208
+ register(
681
1209
  pyTool({
682
1210
  name: "get_stock_info",
683
1211
  description: "\u83B7\u53D6\u80A1\u7968\u57FA\u672C\u4FE1\u606F\uFF08\u884C\u4E1A\u3001\u677F\u5757\u3001\u4E0A\u5E02\u65E5\u671F\u3001\u603B\u80A1\u672C\u7B49\uFF09\u3002A\u80A1\u8FD4\u56DE\u677F\u5757/\u884C\u4E1A\uFF0C\u5176\u4ED6\u5E02\u573A\u8FD4\u56DE\u884C\u4E1A/\u516C\u53F8\u7B80\u4ECB",
@@ -688,7 +1216,7 @@ function apply(ctx, config = {}) {
688
1216
  argv: (p) => ["stock_info", p.symbol]
689
1217
  })
690
1218
  );
691
- ctx.tools.register(
1219
+ register(
692
1220
  pyTool({
693
1221
  name: "get_chip_distribution",
694
1222
  description: "\u83B7\u53D6A\u80A1\u7B79\u7801\u5206\u5E03\u6570\u636E\uFF08\u83B7\u5229\u6BD4\u4F8B\u3001\u5E73\u5747\u6210\u672C\u300190%/70%\u6210\u672C\u96C6\u4E2D\u5EA6\uFF09\u3002\u4EC5\u652F\u6301A\u80A1\u3002\u4E0E get_capital_flow \u914D\u5408\u9A8C\u8BC1\u4E3B\u529B\u884C\u4E3A",
@@ -703,7 +1231,7 @@ function apply(ctx, config = {}) {
703
1231
  argv: (p) => ["chip_distribution", p.symbol]
704
1232
  })
705
1233
  );
706
- ctx.tools.register(
1234
+ register(
707
1235
  pyTool({
708
1236
  name: "get_market_stats",
709
1237
  description: "\u83B7\u53D6A\u80A1\u5E02\u573A\u6574\u4F53\u7EDF\u8BA1\uFF08\u6DA8\u8DCC\u5BB6\u6570\u3001\u6DA8\u505C\u8DCC\u505C\u6570\u3001\u5E73\u5747\u6DA8\u5E45\u3001\u6DA8\u8DCCTop5\u3001\u603B\u6210\u4EA4\u989D\uFF09\u3002\u7528\u4E8E\u8861\u91CF\u5E02\u573A\u6574\u4F53\u60C5\u7EEA\u4E0E\u6E29\u5EA6",
@@ -712,7 +1240,7 @@ function apply(ctx, config = {}) {
712
1240
  argv: () => ["market_stats"]
713
1241
  })
714
1242
  );
715
- ctx.tools.register(
1243
+ register(
716
1244
  pyTool({
717
1245
  name: "get_limit_up_pool",
718
1246
  description: "\u83B7\u53D6A\u80A1\u6DA8\u505C\u6C60/\u6DA8\u505C\u677F\u590D\u76D8\u2014\u2014\u5F53\u65E5\u6DA8\u505C\u4E2A\u80A1\uFF0C\u542B\u8FDE\u677F\u6570\u3001\u5C01\u677F\u8D44\u91D1\u3001\u70B8\u677F\u6B21\u6570\u3001\u9996\u672B\u6B21\u5C01\u677F\u65F6\u95F4\u3001\u6240\u5C5E\u884C\u4E1A\u3002\u77ED\u7EBF\u60C5\u7EEA\u4E0E\u9F99\u5934\u6218\u6CD5\u6838\u5FC3\u6570\u636E",
@@ -727,7 +1255,7 @@ function apply(ctx, config = {}) {
727
1255
  }
728
1256
  })
729
1257
  );
730
- ctx.tools.register(
1258
+ register(
731
1259
  pyTool({
732
1260
  name: "get_dragon_tiger",
733
1261
  description: "\u83B7\u53D6A\u80A1\u9F99\u864E\u699C\u2014\u2014\u4E0A\u699C\u4E2A\u80A1\u51C0\u4E70\u989D/\u4E70\u5165\u989D/\u5356\u51FA\u989D/\u4E0A\u699C\u539F\u56E0/\u89E3\u8BFB\uFF0C\u53EF\u6309\u4E2A\u80A1\u8FC7\u6EE4",
@@ -746,7 +1274,7 @@ function apply(ctx, config = {}) {
746
1274
  }
747
1275
  })
748
1276
  );
749
- ctx.tools.register(
1277
+ register(
750
1278
  pyTool({
751
1279
  name: "get_hot_stocks",
752
1280
  description: "\u83B7\u53D6A\u80A1\u5168\u5E02\u573A\u4EBA\u6C14\u70ED\u641C\u699C\uFF08\u4E1C\u65B9\u8D22\u5BCC\u4EBA\u6C14\u699C\uFF09",
@@ -757,7 +1285,7 @@ function apply(ctx, config = {}) {
757
1285
  argv: (p) => ["hot_stocks", "--top", String(p.top ?? 20)]
758
1286
  })
759
1287
  );
760
- ctx.tools.register(
1288
+ register(
761
1289
  pyTool({
762
1290
  name: "get_margin_trading",
763
1291
  description: "\u83B7\u53D6A\u80A1\u4E2A\u80A1\u878D\u8D44\u878D\u5238\u660E\u7EC6\uFF08\u878D\u8D44\u4F59\u989D/\u878D\u8D44\u4E70\u5165\u989D/\u878D\u5238\u4F59\u91CF\u7B49\uFF0C\u4E0A\u4EA4\u6240/\u6DF1\u4EA4\u6240\u5B98\u65B9\u6570\u636E\u6309\u4EA4\u6613\u6240\u5206\u6D41\uFF09\uFF0C\u8FD4\u56DE\u6700\u8FD1N\u4E2A\u4EA4\u6613\u65E5\u5E8F\u5217\uFF08\u6700\u65B0\u5728\u524D\uFF09\u3002\u91D1\u989D\u5355\u4F4D\u4E3A\u5143\uFF0Cshort_*_shares \u5355\u4F4D\u4E3A\u80A1\u3002include_ratio=true\u8FFD\u52A0\u540C\u65E5\u878D\u8D44\u4E70\u5165/\u6210\u4EA4\u989D\u767E\u5206\u6BD4\uFF08margin_buy_ratio_pct\uFF09\uFF0C\u7F3A\u5C11\u540C\u65E5\u5143\u53E3\u5F84\u6210\u4EA4\u989D\u5219\u4E3Anull\u3002\u4EC5\u4E24\u878D\u6807\u7684\u6709\u6570\u636E\uFF0C\u975E\u4E24\u878D\u6807\u7684\u8FD4\u56DE\u9519\u8BEF",
@@ -770,7 +1298,7 @@ function apply(ctx, config = {}) {
770
1298
  argv: (p) => ["margin_trading", p.symbol, "--days", String(p.days ?? 10), ...p.include_ratio ? ["--include-ratio"] : []]
771
1299
  })
772
1300
  );
773
- ctx.tools.register(
1301
+ register(
774
1302
  pyTool({
775
1303
  name: "get_northbound_flow",
776
1304
  description: "\u83B7\u53D6\u5317\u5411\u8D44\u91D1\u5E02\u573A\u7EA7\u51C0\u4E70\u5165\u5E8F\u5217\uFF08\u6700\u65B0\u5728\u524D\uFF0C\u5355\u4F4D\u4EBF\u5143\uFF09\u3002\u6570\u636E\u53E3\u5F84\uFF1A\u4E1C\u65B9\u8D22\u5BCC\u6CAA\u6DF1\u6E2F\u901A\u5386\u53F2\u6570\u636E\uFF1B2024-08-16 \u8D77\u4EA4\u6613\u6240\u505C\u6B62\u62AB\u9732\u65E5\u5EA6\u51C0\u4E70\u989D\uFF0C\u4EC5 2024-08 \u4E4B\u524D\u5386\u53F2\u6570\u636E\u53EF\u67E5\uFF08\u8FD1\u671F\u5C0F days \u7A97\u53E3\u4F1A\u8FD4\u56DE\u505C\u62AB\u9519\u8BEF\uFF0C\u52A0\u5927 days \u53EF\u53D6\u5386\u53F2\uFF09",
@@ -781,7 +1309,7 @@ function apply(ctx, config = {}) {
781
1309
  argv: (p) => ["northbound_flow", "--days", String(p.days ?? 10)]
782
1310
  })
783
1311
  );
784
- ctx.tools.register(
1312
+ register(
785
1313
  pyTool({
786
1314
  name: "get_fundamental_context",
787
1315
  description: "\u83B7\u53D6A\u80A1\u57FA\u672C\u9762\u4E0A\u4E0B\u6587\uFF08\u4F30\u503C PE/PB/\u5E02\u503C + \u8425\u6536/\u51C0\u5229\u589E\u901F + ROE/\u6BDB\u5229\u7387/\u51C0\u5229\u7387 + \u5206\u7EA2\u5386\u53F2\uFF09\u3002\u7528\u4E8E\u8BC4\u4F30\u516C\u53F8\u8D28\u5730\u4E0E\u957F\u671F\u6301\u6709\u4EF7\u503C",
@@ -796,7 +1324,7 @@ function apply(ctx, config = {}) {
796
1324
  argv: (p) => ["fundamental_context", p.symbol]
797
1325
  })
798
1326
  );
799
- ctx.tools.register(
1327
+ register(
800
1328
  pyTool({
801
1329
  name: "screen_stocks",
802
1330
  description: "\u5168\u5E02\u573A\u80A1\u7968\u7B5B\u9009\uFF08AlphaSift L1 \u591A\u56E0\u5B50\u786C\u7B5B + \u5E02\u573A\u60C5\u7EEA\u8C03\u8282\uFF09\u3002\u6309PE/PB/\u5E02\u503C/\u6362\u624B\u7387/\u6DA8\u8DCC\u5E45/\u91CF\u6BD4\u7B49\u56E0\u5B50\u8FC7\u6EE4\u548C\u8BC4\u5206\uFF0C\u53EF\u7528 l2 \u5F00\u542F\u8D28\u91CF/\u6210\u957F/\u52A8\u91CF/\u6CE2\u52A8\u7387/\u8D44\u91D1\u6D41\u589E\u5F3A\u3002\u663E\u5F0F\u7B5B\u9009\u6761\u4EF6\u7F3A\u5C11\u6570\u636E\u65F6\u62A5error\uFF0Cfilters_applied\u53EA\u5217\u5B9E\u9645\u6267\u884C\u7684\u6761\u4EF6\u3002\u5019\u9009factor_coverage\u5217\u51FA\u53EF\u7528/\u7F3A\u5931\u56E0\u5B50\u3001\u52A0\u6743\u8986\u76D6\u7387\u548Ceffective_weights\uFF1BL1\u4E0EL2\u5747\u6309\u53EF\u7528\u56E0\u5B50\u5F52\u4E00\u5316\u540E\u6392\u5E8F\uFF0C\u7F3A\u5931/\u975E\u6709\u9650\u503C\u4E0D\u6309\u96F6\u5206\u8BA1\uFF1BL2\u53E6\u8FD4\u56DEeffective_scores\u4F9B\u7ED3\u5408\u5E02\u573A\u7CFB\u6570\u590D\u7B97final\uFF0C\u6309\u53EF\u7528\u56E0\u5B50\u91CD\u5F52\u4E00\u5316\uFF0C\u9AD8\u5206\u4E0D\u4EE3\u8868\u6570\u636E\u5B8C\u6574\u3002\u9009\u80A1\u9884\u7B97\u6309\u5019\u9009\u6570\u91CF\u53CA\u91C7\u96C6\u6279\u6B21\u8BA1\u7B97\uFF0Ctop\u987B\u4E3A\u6B63\u6574\u6570\u3002",
@@ -819,7 +1347,7 @@ function apply(ctx, config = {}) {
819
1347
  }
820
1348
  })
821
1349
  );
822
- ctx.tools.register(defineTool2({
1350
+ register(closedTool({
823
1351
  name: "calculate_rotation_metrics",
824
1352
  description: "\u884C\u4E1A\u8F6E\u52A8\u6570\u503C\u590D\u6838\uFF1A\u8F93\u5165\u771F\u5B9EMC-dropout\u6837\u672C\u548C/\u6216\u5386\u53F2\u6210\u4EA4\u8BA1\u6570\uFF0C\u8BA1\u7B97\u96C6\u4E2D\u5EA6\u548C\u539F\u59CB\u914D\u6743\uFF1B\u4E0D\u8BAD\u7EC3\u6A21\u578B\u3001\u4E0D\u751F\u6210\u4E70\u5165\u4FE1\u53F7\uFF0C\u96F6\u5386\u53F2\u4E0D\u8865\u9ED8\u8BA4\u503C\u3002",
825
1353
  parameters: {
@@ -878,12 +1406,11 @@ function apply(ctx, config = {}) {
878
1406
  }
879
1407
  }
880
1408
  },
881
- output: { schema: { type: "string" }, render: (_args, value) => [{ type: "text", text: value }] },
882
1409
  async execute(params) {
883
1410
  return withJsonInput(params, (path) => runPy("sector_rotation.py", ["analyze", "--input", path]));
884
1411
  }
885
1412
  }));
886
- ctx.tools.register(defineTool2({
1413
+ register(closedTool({
887
1414
  name: "backtest_rotation_allocation",
888
1415
  description: "\u884C\u4E1A\u8F6E\u52A8\u914D\u6743\u5206\u9879\u56DE\u6D4B\uFF1A\u4EE3\u7801\u81EA\u52A8\u53D6\u884C\u60C5\uFF0C\u6216\u4F20\u660E\u786E\u5E01\u79CD/\u590D\u6743OHLCV\uFF1B\u76F8\u540C\u6BCF\u5468\u5168\u6C60\u4E70\u5356\u4E0B\u6BD4\u8F83\u7B49\u6743\u4E0E\u5386\u53F2\u914D\u6743\u3002\u6309\u5E02\u573A\u548C\u62A5\u4EF7\u5E01\u79CD\u72EC\u7ACB\u8D44\u91D1\uFF0C\u652F\u6301A/HK/US/JP/KR/TW\uFF1B\u4E0D\u662F\u5B8C\u6574\u8BBA\u6587\u6DF1\u5EA6\u6A21\u578B\u6216\u8DE8\u5E01\u79CD\u5171\u4EAB\u8D44\u91D1\u56DE\u6D4B\u3002",
889
1416
  parameters: {
@@ -1001,12 +1528,11 @@ function apply(ctx, config = {}) {
1001
1528
  "description": "\u6BCF\u8FB9\u6BD4\u4F8B\u6210\u672C0..0.1\uFF0C\u9ED8\u8BA40.001\uFF1B\u4E70\u5165\u9884\u7B97\u542B\u8D39\u7528"
1002
1529
  }
1003
1530
  },
1004
- output: { schema: { type: "string" }, render: (_args, value) => [{ type: "text", text: value }] },
1005
1531
  async execute(params) {
1006
1532
  return withJsonInput(params, (path) => runPy("sector_rotation.py", ["backtest", "--input", path]));
1007
1533
  }
1008
1534
  }));
1009
- ctx.tools.register(defineTool2({
1535
+ register(closedTool({
1010
1536
  name: "analyze_trend_strategy",
1011
1537
  description: "\u6708\u5EA6\u53F3\u4FA7\u8D8B\u52BF\u7B56\u7565\uFF1A\u76F4\u63A5\u4F20\u540C\u5E02\u573AA/HK/US\u80A1\u7968\u4EE3\u7801\uFF0C\u81EA\u52A8\u83B7\u53D6\u65E5K\uFF0C\u8F93\u51FA\u6708\u5EA6\u65B0\u5165/\u6301\u6709/\u9000\u51FA\u4E0E\u9006\u6CE2\u52A8\u9884\u7B97\u3002as_of\u9ED8\u8BA4\u6700\u8FD1\u5DF2\u6536\u76D8\u4EA4\u6613\u65E5\uFF0C\u6301\u4ED3\u53EF\u9009\u4E14\u4E0D\u4FDD\u5B58\uFF0C\u4E0D\u81EA\u52A8\u4E0B\u5355\uFF1B\u8DE8\u6837\u672C\u4ECDnot_validated\u3002",
1012
1538
  parameters: {
@@ -1041,12 +1567,11 @@ function apply(ctx, config = {}) {
1041
1567
  "description": "\u53EF\u9009\u56FA\u5B9A\u5BB9\u91CFK\uFF0C\u9ED8\u8BA4ceil(N/3)\uFF0C\u4E0D\u5F97\u5C0F\u4E8E\u771F\u5B9E\u6301\u80A1\u6570\u91CF"
1042
1568
  }
1043
1569
  },
1044
- output: { schema: { type: "string" }, render: (_args, value) => [{ type: "text", text: value }] },
1045
1570
  async execute(params) {
1046
1571
  return withJsonInput(params, (path) => runPy("trend_strategy.py", ["fetch", "--input", path]));
1047
1572
  }
1048
1573
  }));
1049
- ctx.tools.register(
1574
+ register(
1050
1575
  pyTool({
1051
1576
  name: "run_backtest",
1052
1577
  description: "\u7B56\u7565\u56DE\u6D4B\uFF08AlphaEvo\uFF09\u3002\u8BFB\u53D6YAML\u7B56\u7565\u5B9A\u4E49\uFF0C\u5728\u5386\u53F2\u6570\u636E\u4E0A\u6A21\u62DF\u4EA4\u6613\uFF0C\u8F93\u51FA\u6536\u76CA\u7387/\u56DE\u64A4/\u80DC\u7387\u7B49\u6307\u6807\u3002\u53EA\u60F3\u77E5\u9053\u5355\u4E2A\u6280\u672F\u4FE1\u53F7\u7684\u5386\u53F2\u80DC\u7387\u7528\u66F4\u8F7B\u91CF\u7684 evaluate_signal\u3002period\u4E3A\u5B9E\u9645\u6570\u636E\u671F\u95F4\uFF0Crequested_period\u4FDD\u7559\u8BF7\u6C42\u671F\u95F4\uFF0Cwarnings\u63D0\u793A\u8986\u76D6\u5DEE\u5F02\uFF1B\u5E74\u5316\u6309\u5B9E\u9645\u671F\u95F4\u8BA1\u7B97\u3002\u9ED8\u8BA4\u524D\u65E5\u6536\u76D8\u4FE1\u53F7\u3001\u6B21\u65E5\u5F00\u76D8\u6210\u4EA4\uFF1BYAML simulation.execution=same_close\u53EF\u590D\u73B0\u65E7\u5047\u8BBE\u3002execution\u8FD4\u56DE\u6A21\u578B\u3001\u963B\u6B62\u6210\u4EA4\u6B21\u6570\u548C\u672A\u6A21\u62DF\u7EA6\u675F\uFF1B\u96F6\u6210\u4EA4\u91CF\u53CA\u5E26\u5386\u53F2\u9650\u4EF7\u7684\u4E00\u5B57\u677F\u4E0D\u6210\u4EA4\u3002\u652F\u6301 monthly_momentum\uFF1A\u6708\u521D\u9996\u6839\u6709\u6548\u65E5K\u6536\u76D8\u89C2\u5BDF\u8FC7\u53BBperiod\u6839\u5BF9\u6570\u6536\u76CA\uFF0C\u6B21\u65E5\u5F00\u76D8\uFF1B\u957F\u5468\u671F\u9700\u9884\u70ED\u3002",
@@ -1067,7 +1592,7 @@ function apply(ctx, config = {}) {
1067
1592
  }
1068
1593
  })
1069
1594
  );
1070
- ctx.tools.register(
1595
+ register(
1071
1596
  pyTool({
1072
1597
  name: "evaluate_signal",
1073
1598
  description: "\u6280\u672F\u4FE1\u53F7\u5386\u53F2\u51C6\u786E\u7387\u8BC4\u4F30 \u2014 \u56DE\u6EAF\u5386\u53F2\u6570\u636E\uFF0C\u7EDF\u8BA1\u67D0\u4E2A\u6280\u672F\u4FE1\u53F7\u89E6\u53D1\u540EN\u65E5\u7684\u80DC\u7387\u548C\u5E73\u5747\u6536\u76CA\u3002\u652F\u63019\u79CD\u4FE1\u53F7\uFF1Amacd_golden_cross/macd_death_cross/rsi_oversold/rsi_overbought/breakout_20d/breakdown_20d/volume_surge/ma_golden_cross/ma_death_cross\u3002\u8981\u5B8C\u6574\u6A21\u62DF\u4EA4\u6613\u8FC7\u7A0B\u7528 run_backtest",
@@ -1107,7 +1632,7 @@ function apply(ctx, config = {}) {
1107
1632
  ]
1108
1633
  })
1109
1634
  );
1110
- ctx.tools.register(
1635
+ register(
1111
1636
  pyTool({
1112
1637
  name: "resolve_stock_name",
1113
1638
  description: "\u80A1\u7968\u540D\u79F0\u667A\u80FD\u89E3\u6790 \u2014 \u8F93\u5165\u4E2D\u6587\u540D\uFF08\u8D35\u5DDE\u8305\u53F0\uFF09\u3001\u62FC\u97F3\uFF08guizhou maotai/gzmt\uFF09\u3001\u90E8\u5206\u4EE3\u7801\uFF0C\u8FD4\u56DE\u5339\u914D\u7684\u80A1\u7968\u4EE3\u7801\u3002\u4EC5\u652F\u6301A\u80A1\u3002\u7528\u6237\u7ED9\u51FA\u4E2D\u6587\u540D/\u62FC\u97F3/\u90E8\u5206\u4EE3\u7801\u65F6\u5148\u8C03\u672C\u5DE5\u5177\u6362\u6210\u4EE3\u7801\u518D\u8C03\u5176\u4ED6\u5DE5\u5177",
@@ -1123,7 +1648,7 @@ function apply(ctx, config = {}) {
1123
1648
  argv: (p) => ["resolve", p.query, "--top", String(p.top ?? 5)]
1124
1649
  })
1125
1650
  );
1126
- ctx.tools.register(
1651
+ register(
1127
1652
  pyTool({
1128
1653
  name: "check_trading_day",
1129
1654
  description: "\u67E5\u8BE2\u67D0\u65E5\u662F\u5426\u4E3A\u4EA4\u6613\u65E5\u3002\u652F\u6301CN\uFF08A\u80A1\uFF09\u3001HK\uFF08\u6E2F\u80A1\uFF09\u3001US\uFF08\u7F8E\u80A1\uFF09\u3001JP\uFF08\u65E5\u80A1\uFF09\u3001KR\uFF08\u97E9\u80A1\uFF09\u3001TW\uFF08\u53F0\u80A1\uFF09",
@@ -1144,7 +1669,7 @@ function apply(ctx, config = {}) {
1144
1669
  }
1145
1670
  })
1146
1671
  );
1147
- ctx.tools.register(
1672
+ register(
1148
1673
  pyTool({
1149
1674
  name: "get_trading_days",
1150
1675
  description: "\u83B7\u53D6\u6700\u8FD1/\u672A\u6765N\u4E2A\u4EA4\u6613\u65E5\u5217\u8868\u3002\u652F\u6301CN/HK/US/JP/KR/TW",
@@ -1171,7 +1696,7 @@ function apply(ctx, config = {}) {
1171
1696
  }
1172
1697
  })
1173
1698
  );
1174
- ctx.tools.register(
1699
+ register(
1175
1700
  pyTool({
1176
1701
  name: "get_trading_phase",
1177
1702
  description: "\u67E5\u8BE2\u67D0\u5E02\u573A\u5F53\u524D\u4EA4\u6613\u65F6\u6BB5\uFF08\u76D8\u524D/\u65E9\u76D8/\u5348\u95F4\u4F11\u5E02/\u5348\u76D8/\u4EA4\u6613\u4E2D/\u76D8\u540E/\u4F11\u5E02\uFF09\uFF0C\u7528\u4E8E\u6B63\u786E\u89E3\u8BFB\u5B9E\u65F6\u884C\u60C5\u7684\u76D8\u4E2D\u8BED\u4E49\u3002\u652F\u6301CN/HK/US/JP/KR/TW",
@@ -1187,7 +1712,7 @@ function apply(ctx, config = {}) {
1187
1712
  argv: (p) => ["phase", p.market]
1188
1713
  })
1189
1714
  );
1190
- ctx.tools.register(
1715
+ register(
1191
1716
  pyTool({
1192
1717
  name: "calculate_ma",
1193
1718
  description: "\u72EC\u7ACB\u5747\u7EBF\u8BA1\u7B97\u5668 \u2014 \u652F\u6301\u4EFB\u610F\u5468\u671FMA\uFF085/10/20/30/60/120/250\u6216\u81EA\u5B9A\u4E49\uFF09+ \u504F\u79BB\u5EA6 + \u5747\u7EBF\u6392\u5217 + \u91D1\u53C9\u6B7B\u53C9\u68C0\u6D4B\u3002\u53EA\u8981\u5747\u7EBF\u6570\u503C\u6216\u9700\u898130/120/250\u7B49\u975E\u9ED8\u8BA4\u5468\u671F\u65F6\u7528\u672C\u5DE5\u5177\uFF1B\u7EFC\u5408\u6280\u672F\u9762\u5206\u6790\u7528 get_technical_analysis",
@@ -1216,7 +1741,7 @@ function apply(ctx, config = {}) {
1216
1741
  ]
1217
1742
  })
1218
1743
  );
1219
- ctx.tools.register(
1744
+ register(
1220
1745
  pyTool({
1221
1746
  name: "get_volume_analysis",
1222
1747
  description: "\u72EC\u7ACB\u91CF\u4EF7\u5206\u6790 \u2014 \u91CF\u4EF7\u76F8\u5173\u6027\u3001\u4E0A\u6DA8/\u4E0B\u8DCC\u65E5\u6210\u4EA4\u91CF\u5BF9\u6BD4\u3001\u91CF\u80FD\u8D8B\u52BF\u3001\u91CF\u4EF7\u6A21\u5F0F\u89E3\u8BFB\uFF08\u653E\u91CF\u4E0A\u6DA8/\u7F29\u91CF\u56DE\u8C03\u7B49\uFF09\u3002\u7EFC\u5408\u6280\u672F\u9762\u5224\u65AD\u7528 get_technical_analysis\uFF0C\u626B\u5F53\u65E5\u5F02\u52A8\u7528 detect_anomaly",
@@ -1240,7 +1765,7 @@ function apply(ctx, config = {}) {
1240
1765
  ]
1241
1766
  })
1242
1767
  );
1243
- ctx.tools.register(
1768
+ register(
1244
1769
  pyTool({
1245
1770
  name: "search_stock_news",
1246
1771
  description: "\u591A\u5F15\u64CE\u80A1\u7968\u65B0\u95FB\u641C\u7D22\uFF08Tavily/Brave/SerpAPI/Bocha/SearXNG\uFF09\u3002\u9700\u914D\u7F6E\u81F3\u5C11\u4E00\u4E2A\u641C\u7D22\u6E90\u7684 Key \u6216 SearXNG URL\u3002get_news \u5FEB\u8BAF\u4E0D\u591F\u6216\u8981\u6309\u4E3B\u9898\u641C\u7D22\u65F6\u7528\uFF1B\u6DF1\u5EA66\u7EF4\u60C5\u62A5\u7528 search_comprehensive_intel",
@@ -1252,7 +1777,7 @@ function apply(ctx, config = {}) {
1252
1777
  argv: (p) => ["search", p.query, "--count", String(p.count ?? 10)]
1253
1778
  })
1254
1779
  );
1255
- ctx.tools.register(
1780
+ register(
1256
1781
  pyTool({
1257
1782
  name: "search_comprehensive_intel",
1258
1783
  description: "\u80A1\u7968\u7EFC\u5408\u60C5\u62A5\u641C\u7D22 \u2014 \u4ECE6\u4E2A\u7EF4\u5EA6\uFF08\u65B0\u95FB/\u516C\u544A/\u884C\u60C5\u5206\u6790/\u98CE\u9669/\u4E1A\u7EE9/\u884C\u4E1A\uFF09\u641C\u7D22\u7EFC\u5408\u4FE1\u606F\u3002\u7528\u4E8E\u4E2A\u80A1\u7684\u6DF1\u5165\u7814\u7A76/\u5168\u9762\u8C03\u7814\uFF1B\u5FEB\u901F\u770B\u65B0\u95FB\u7528 get_news",
@@ -1268,7 +1793,7 @@ function apply(ctx, config = {}) {
1268
1793
  }
1269
1794
  })
1270
1795
  );
1271
- ctx.tools.register(
1796
+ register(
1272
1797
  pyTool({
1273
1798
  name: "get_social_sentiment",
1274
1799
  description: "\u83B7\u53D6\u80A1\u7968\u793E\u4EA4\u5A92\u4F53\u60C5\u7EEA\u6570\u636E\u3002A\u80A1\uFF1A\u4E1C\u65B9\u8D22\u5BCC\u80A1\u5427\u70ED\u5EA6+\u96EA\u7403\u8BA8\u8BBA\u70ED\u5EA6\uFF08\u65E0\u9700\u914D\u7F6E\uFF09\uFF1B\u7F8E\u80A1/\u6E2F\u80A1\uFF1AReddit/X/Polymarket\u60C5\u7EEA\uFF08\u9700 SENTIMENT_API_KEY\uFF09\u3002\u81EA\u52A8\u6309\u5E02\u573A\u9009\u6570\u636E\u6E90\u3002\u9762\u5411\u4E2A\u80A1\u7EF4\u5EA6\uFF1B\u5168\u5E02\u573A\u70ED\u95E8\u8BA8\u8BBA\u7528 get_trending_sentiment",
@@ -1279,7 +1804,7 @@ function apply(ctx, config = {}) {
1279
1804
  argv: (p) => ["sentiment", p.symbol]
1280
1805
  })
1281
1806
  );
1282
- ctx.tools.register(
1807
+ register(
1283
1808
  pyTool({
1284
1809
  name: "get_trending_sentiment",
1285
1810
  description: "\u83B7\u53D6\u793E\u4EA4\u5A92\u4F53\u70ED\u95E8\u8D8B\u52BF\uFF08Reddit/X/Polymarket\u70ED\u95E8\u80A1\u7968\u8BA8\u8BBA\uFF09\u3002\u9002\u7528\u4E8E\u53D1\u73B0\u5E02\u573A\u70ED\u70B9\uFF1B\u67E5\u4E2A\u80A1\u60C5\u7EEA\u7528 get_social_sentiment",
@@ -1288,7 +1813,7 @@ function apply(ctx, config = {}) {
1288
1813
  argv: () => ["trending"]
1289
1814
  })
1290
1815
  );
1291
- ctx.tools.register(
1816
+ register(
1292
1817
  pyTool({
1293
1818
  name: "extract_article",
1294
1819
  description: "\u7F51\u9875\u6587\u7AE0\u5168\u6587\u63D0\u53D6 \u2014 \u8F93\u5165URL\uFF0C\u63D0\u53D6\u6587\u7AE0\u6807\u9898\u3001\u6B63\u6587\uFF08\u6700\u591A3000\u5B57\uFF09\u3001\u4F5C\u8005\u3001\u53D1\u5E03\u65E5\u671F\u7B49\u3002\u914D\u5408 get_news/search_stock_news \u7684\u641C\u7D22\u7ED3\u679C\u505A\u6DF1\u5EA6\u9605\u8BFB",
@@ -1299,7 +1824,7 @@ function apply(ctx, config = {}) {
1299
1824
  argv: (p) => ["extract", p.url]
1300
1825
  })
1301
1826
  );
1302
- ctx.tools.register(
1827
+ register(
1303
1828
  pyTool({
1304
1829
  name: "screen_risk",
1305
1830
  description: "A\u80A1\u98CE\u9669\u4E13\u9879\u7B5B\u67E5 \u2014 \u68C0\u67E5\u4F30\u503C\u3001\u6280\u672F\u9884\u8B66\u3001\u89E3\u7981\u3001\u51CF\u6301\u3001\u4E1A\u7EE9\u9884\u8B66\u3001\u76D1\u7BA1\u548C\u884C\u4E1A\u653F\u7B56\uFF0C\u8FD4\u56DE\u98CE\u9669\u8BC4\u7EA7\u548C veto_buy\u3002\u65B0\u95FB\u641C\u7D22\u547D\u4E2D\u662F\u5F85\u6838\u5B9E\u7EBF\u7D22\uFF0C\u4E0D\u662F\u5DF2\u8BC1\u5B9E\u98CE\u9669\u3002data_complete\u548Cwarnings\u6807\u660E\u8986\u76D6\uFF1B\u6570\u636E\u4E0D\u8DB3\u65F6risk_level=unknown\uFF0Crisk_score\u6216veto_buy\u53EF\u4E3Anull\uFF0C\u4E0D\u80FD\u89C6\u4E3A\u4F4E\u98CE\u9669",
@@ -1319,7 +1844,7 @@ function apply(ctx, config = {}) {
1319
1844
  }
1320
1845
  })
1321
1846
  );
1322
- ctx.tools.register(
1847
+ register(
1323
1848
  pyTool({
1324
1849
  name: "detect_market_regime",
1325
1850
  description: "\u5E02\u573A\u72B6\u6001\u68C0\u6D4B \u2014 \u5206\u6790\u5927\u76D8\u6307\u6570\u5224\u65AD\u5F53\u524D\u5E02\u573A\u9636\u6BB5\uFF08\u4E0A\u6DA8\u8D8B\u52BF/\u4E0B\u8DCC\u8D8B\u52BF/\u6A2A\u76D8\u9707\u8361/\u9AD8\u6CE2\u52A8/\u677F\u5757\u70ED\u70B9\uFF09\uFF0C\u5E76\u63A8\u8350\u9002\u5408\u7684\u5206\u6790\u7B56\u7565",
@@ -1334,7 +1859,7 @@ function apply(ctx, config = {}) {
1334
1859
  argv: (p) => ["detect", p.market ?? "A"]
1335
1860
  })
1336
1861
  );
1337
- ctx.tools.register(
1862
+ register(
1338
1863
  pyTool({
1339
1864
  name: "get_market_review",
1340
1865
  description: "\u5927\u76D8\u590D\u76D8 \u2014 \u83B7\u53D6\u5E02\u573A\u65E5\u5EA6\u590D\u76D8\u6570\u636E\uFF0C\u5305\u542B\u6307\u6570\u3001\u6DA8\u8DCC\u7EDF\u8BA1\u3001\u677F\u5757\u6392\u540D\u3001\u65B0\u95FB\u3001\u5E02\u573A\u6E29\u5EA6\u4E0E\u7B56\u7565\u5EFA\u8BAE\u3002\u590D\u76D8\u7C7B\u9700\u6C42\u7684\u9996\u9009\uFF0C\u65E0\u9700\u518D\u5206\u522B\u8C03\u6307\u6570/\u7EDF\u8BA1/\u677F\u5757\u5DE5\u5177\u3002\u6570\u636E\u4E0D\u8DB3\u65F6\u6E29\u5EA6score\u53CAstrategy_stance\u4E3Anull\uFF0C\u4FE1\u53F7unknown\uFF1Bwarnings/data_quality\u8BF4\u660E\u9650\u5236",
@@ -1349,7 +1874,7 @@ function apply(ctx, config = {}) {
1349
1874
  argv: (p) => ["review", "--market", p.market ?? "A"]
1350
1875
  })
1351
1876
  );
1352
- ctx.tools.register(
1877
+ register(
1353
1878
  pyTool({
1354
1879
  name: "run_watchlist_analysis",
1355
1880
  description: "\u6279\u91CF\u81EA\u9009\u80A1\u5206\u6790 \u2014 \u5BF9\u591A\u53EA\u80A1\u7968\u5E76\u884C\u91C7\u96C6\u884C\u60C5/\u6280\u672F/\u8D44\u91D1/\u98CE\u9669\u7B49\u6570\u636E\uFF0C\u8FD4\u56DE\u6C47\u603B\u7ED3\u679C\u3002\u9002\u7528\u4E8E\u6BCF\u65E5\u5B9A\u65F6\u5206\u6790\u81EA\u9009\u80A1\u5217\u8868",
@@ -1368,7 +1893,7 @@ function apply(ctx, config = {}) {
1368
1893
  argv: (p) => ["analyze", p.symbols, "--workers", String(p.workers ?? 3)]
1369
1894
  })
1370
1895
  );
1371
- ctx.tools.register(
1896
+ register(
1372
1897
  pyTool({
1373
1898
  name: "detect_anomaly",
1374
1899
  description: "\u5F02\u5E38/\u4E8B\u4EF6\u68C0\u6D4B \u2014 \u4E00\u952E\u626B\u63CF\u80A1\u7968\u5F53\u524D\u6240\u6709\u5F02\u52A8\u4FE1\u53F7\uFF08MACD\u91D1\u53C9\u6B7B\u53C9\u3001RSI\u8D85\u4E70\u8D85\u5356\u300120\u65E5\u7A81\u7834\u3001\u653E\u91CF\u5F02\u52A8\u3001\u6DA8\u8DCC\u505C\u3001\u5E03\u6797\u7A81\u7834\u3001KDJ\u6781\u503C\u3001\u8D44\u91D1\u5F02\u52A8\u7B49\uFF09\uFF0C\u8FD4\u56DE\u7ED3\u6784\u5316\u5F02\u5E38\u5217\u8868\u3002\u5F53\u65E5\u5F02\u52A8\u5F52\u56E0\u7684\u9996\u9009\uFF1B\u7EFC\u5408\u6280\u672F\u9762\u5224\u65AD\u7528 get_technical_analysis",
@@ -1383,7 +1908,7 @@ function apply(ctx, config = {}) {
1383
1908
  argv: (p) => ["detect", p.symbol]
1384
1909
  })
1385
1910
  );
1386
- ctx.tools.register(
1911
+ register(
1387
1912
  pyTool({
1388
1913
  name: "diagnose_data_sources",
1389
1914
  description: "\u6570\u636E\u6E90\u8BCA\u65AD \u2014 \u68C0\u67E5\u5F53\u524D\u73AF\u5883\u5404\u6570\u636E provider \u7684\u5305\u4E0E\u51ED\u636E\u5C31\u7EEA\u60C5\u51B5\uFF08\u4E0D\u63A2\u6D4B\u7F51\u7EDC\u53EF\u8FBE\u6027\uFF09\uFF0C\u8F93\u51FA\u6BCF\u4E2A\u5E02\u573A\u7684\u53EF\u7528\u94FE\u8DEF\u3001\u7F3A\u5931 env\u3001warnings\u3002\u5DE5\u5177\u62FF\u4E0D\u5230\u6570\u636E\u6216\u62A5\u9519\u65F6\u8C03\u7528\u6392\u67E5",
@@ -1398,7 +1923,7 @@ function apply(ctx, config = {}) {
1398
1923
  argv: (p) => ["check", "--market", p.market ?? "all"]
1399
1924
  })
1400
1925
  );
1401
- ctx.tools.register(
1926
+ register(
1402
1927
  pyTool({
1403
1928
  name: "get_market_capabilities",
1404
1929
  description: "\u5E02\u573A\u80FD\u529B\u8FB9\u754C \u2014 \u8FD4\u56DE\u6307\u5B9A\u5E02\u573A\u652F\u6301/\u4E0D\u652F\u6301\u7684\u5DE5\u5177\u5217\u8868\u3002\u4E0D\u786E\u5B9A\u67D0\u5E02\u573A\u80FD\u5426\u7528\u67D0\u5DE5\u5177\uFF08\u5982\u6E2F\u80A1\u7684\u7B79\u7801\u5206\u5E03\u3001\u7F8E\u80A1\u7684\u8D44\u91D1\u6D41\uFF09\u65F6\u5148\u8C03\u672C\u5DE5\u5177\uFF0C\u907F\u514D\u8C03\u7528\u4E0D\u652F\u6301\u7684\u5DE5\u5177\u540E\u7F16\u9020\u6570\u636E",
@@ -1414,7 +1939,7 @@ function apply(ctx, config = {}) {
1414
1939
  argv: (p) => p.symbol ? ["get", "--symbol", p.symbol] : ["get", "--market", p.market ?? "A"]
1415
1940
  })
1416
1941
  );
1417
- ctx.tools.register(
1942
+ register(
1418
1943
  pyTool({
1419
1944
  name: "render_stock_report",
1420
1945
  description: "\u80A1\u7968\u5206\u6790\u62A5\u544A\u6E32\u67D3 \u2014 \u5C06\u7ED3\u6784\u5316\u62A5\u544A JSON \u901A\u8FC7 j2 \u6A21\u677F\u6E32\u67D3\u4E3A Markdown\u3002report \u5B57\u6BB5\u4EE5 skill \u63D0\u4F9B\u7684 report_schema \u4E3A\u51C6\uFF0C\u4E0D\u8981\u81EA\u9020\u5B57\u6BB5\u3002template: brief|full\u3002\u5168\u90E8\u5206\u6790\u5B8C\u6210\u540E\u7684\u6700\u540E\u4E00\u6B65\u8C03\u7528\u3002\u9ED8\u8BA4\u4EC5\u6E32\u67D3\uFF1Bfinal=true\u8868\u793A\u6700\u7EC8\u56DE\u590D\uFF0C\u652F\u6301\u76F4\u51FA\u7684\u5BBF\u4E3B\u53EF\u539F\u6837\u4EA4\u4ED8\u5E76\u7ED3\u675F\u672C\u8F6E\u3002report\u53EF\u5305\u542Bevidence\uFF08path/label/value/source/as_of\uFF09\u4E0Edata_quality\uFF08flags/limitations\uFF09\uFF0Cbrief/full\u5747\u5C55\u793A\u8BC1\u636E\u548C\u9650\u5236\u3002",
@@ -1439,7 +1964,7 @@ function apply(ctx, config = {}) {
1439
1964
  }
1440
1965
  })
1441
1966
  );
1442
- ctx.tools.register(
1967
+ register(
1443
1968
  pyTool({
1444
1969
  name: "render_market_report",
1445
1970
  description: "\u5927\u76D8\u590D\u76D8\u62A5\u544A\u6E32\u67D3 \u2014 \u5C06\u7ED3\u6784\u5316\u62A5\u544A JSON \u901A\u8FC7 j2 \u6A21\u677F\u6E32\u67D3\u4E3A Markdown\u3002report \u5B57\u6BB5\u4EE5 schemas/market_review_schema.json \u4E3A\u51C6\u3002save=true \u65F6\u628A\u62A5\u544A\u5BF9\u8C61\u8FFD\u52A0\u5F52\u6863\u5230\u672C\u5730 JSONL\uFF08\u9ED8\u8BA4\u4E0D\u4FDD\u5B58\u4E0D\u63A8\u9001\uFF09\uFF0C\u7EB5\u5411\u5BF9\u6BD4\u7528 get_review_history\uFF1Bfinal=true\u4EC5\u7528\u4E8E\u6700\u7EC8\u56DE\u590D\uFF0C\u4FDD\u5B58\u9644\u4EF6\u6216\u7EE7\u7EED\u5206\u6790\u65F6\u4FDD\u6301false",
@@ -1466,7 +1991,7 @@ function apply(ctx, config = {}) {
1466
1991
  }
1467
1992
  })
1468
1993
  );
1469
- ctx.tools.register(
1994
+ register(
1470
1995
  pyTool({
1471
1996
  name: "get_review_history",
1472
1997
  description: "\u590D\u76D8\u5F52\u6863\u5386\u53F2 \u2014 \u8BFB\u53D6\u672C\u5730 JSONL \u5F52\u6863\u7684\u6700\u8FD1 N \u6761\u5E02\u573A\u590D\u76D8\uFF08\u6700\u65B0\u5728\u524D\uFF09\uFF0C\u7528\u4E8E\u7EB5\u5411\u5BF9\u6BD4\uFF08\u6E29\u5EA6/\u59FF\u6001/\u4E3B\u7EBF\u53D8\u5316\uFF09\u3002\u5F52\u6863\u7531 render_market_report \u7684 save=true \u5199\u5165\uFF0C\u7A7A\u5B58\u6863\u8FD4\u56DE\u7A7A\u5217\u8868",
@@ -1477,7 +2002,7 @@ function apply(ctx, config = {}) {
1477
2002
  argv: (p) => ["history", "--limit", String(p.limit ?? 10)]
1478
2003
  })
1479
2004
  );
1480
- ctx.tools.register(
2005
+ register(
1481
2006
  pyTool({
1482
2007
  name: "build_watchlist_context",
1483
2008
  description: "\u81EA\u9009\u80A1\u4E0A\u4E0B\u6587\u5305 \u2014 \u5BF9\u591A\u53EA\u80A1\u7968\u8F93\u51FA\u8BC4\u5206/\u8D8B\u52BF/\u5F02\u5E38/\u98CE\u9669/\u5EFA\u8BAE next_tools \u7684 agent \u53CB\u597D\u6458\u8981\u3002\u5BBF\u4E3B agent \u51B3\u5B9A\u5982\u4F55\u5199\u65E5\u62A5\u6216\u6DF1\u5165\u5206\u6790\u3002\u5F02\u52A8\u68C0\u67E5\u5931\u8D25\u65F6anomaly_status=unavailable\u3001anomaly_count=null\uFF0C\u4FDD\u7559anomaly_error/warnings\uFF1B\u6C47\u603B\u8BA1\u5165partial",
@@ -1497,7 +2022,7 @@ function apply(ctx, config = {}) {
1497
2022
  }
1498
2023
  })
1499
2024
  );
1500
- ctx.tools.register(
2025
+ register(
1501
2026
  pyTool({
1502
2027
  name: "analyze_position_context",
1503
2028
  description: "\u6301\u4ED3\u4E0A\u4E0B\u6587\u5206\u6790 \u2014 \u8F93\u5165\u6210\u672C/\u4ED3\u4F4D/\u6B62\u635F\u6B62\u76C8\uFF0C\u7ED3\u5408\u73B0\u4EF7\u548C\u6280\u672F\u4F4D\u8F93\u51FA\u6D6E\u76C8\u4E8F\u3001\u79BB\u6B62\u635F\u8DDD\u79BB\u3001\u98CE\u9669\u7EA7\u522B\u3001\u64CD\u4F5C\u5EFA\u8BAE\u3002\u65E0\u72B6\u6001\u3001\u4E0D\u5B58\u8D26\u6237",
@@ -1524,7 +2049,7 @@ function apply(ctx, config = {}) {
1524
2049
  }
1525
2050
  })
1526
2051
  );
1527
- ctx.tools.register(
2052
+ register(
1528
2053
  pyTool({
1529
2054
  name: "check_alert_rules",
1530
2055
  description: "\u65E0\u72B6\u6001\u544A\u8B66\u89C4\u5219\u68C0\u67E5 \u2014 \u4F20\u5165\u89C4\u5219\u6570\u7EC4\uFF0C\u8FD4\u56DE\u5F53\u524D\u662F\u5426\u89E6\u53D1\u3002\u89C4\u5219\u7C7B\u578B\uFF1Aprice_below/price_above/change_pct_above/change_pct_below/volume_ratio_above/anomaly/risk_veto/risk_level_at_least\u3002\u4E0D\u505A\u8C03\u5EA6\u4E0D\u5B58\u5386\u53F2\u3002\u4F9D\u8D56\u6570\u636E\u4E0D\u53EF\u7528\u65F6evaluated\u6761\u76EE\u542Berror\uFF0Cmeta.warnings\u63D0\u793A\u7F3A\u5931\uFF0Ctriggered=false\u4E0D\u4EE3\u8868\u68C0\u67E5\u6210\u529F",
@@ -1544,7 +2069,7 @@ function apply(ctx, config = {}) {
1544
2069
  }
1545
2070
  })
1546
2071
  );
1547
- ctx.tools.register(
2072
+ register(
1548
2073
  pyTool({
1549
2074
  name: "record_signal",
1550
2075
  description: "\u8BB0\u5F55\u4E00\u6761 AI \u5206\u6790\u5EFA\u8BAE\u4FE1\u53F7\uFF08\u65B9\u5411/\u5165\u573A\u4EF7/\u76EE\u6807\u4EF7/\u6B62\u635F\u4EF7/\u6301\u6709\u671F\u9650\uFF09\uFF0C\u4F9B\u540E\u7EED\u80DC\u7387\u8BC4\u4F30\u3002\u4FE1\u53F7\u6301\u4E45\u5316\u5728\u672C\u5730 JSONL\uFF08$STOCK_SIGNAL_STORE \u6216 ~/.stock-analysis/signals.jsonl\uFF09\uFF0C\u5BBF\u4E3B Agent \u81EA\u884C\u51B3\u5B9A\u4F55\u65F6 record/evaluate",
@@ -1582,7 +2107,7 @@ function apply(ctx, config = {}) {
1582
2107
  }
1583
2108
  })
1584
2109
  );
1585
- ctx.tools.register(
2110
+ register(
1586
2111
  pyTool({
1587
2112
  name: "evaluate_signals",
1588
2113
  description: "\u8BC4\u4F30\u5230\u671F\u4FE1\u53F7\uFF1A\u62C9\u53D6\u8BB0\u5F55\u65E5\u4E4B\u540E\u7684\u65E5K\uFF0C\u5224\u5B9A target_hit/stop_hit/timeout \u5E76\u8BA1\u7B97\u6536\u76CA\uFF0C\u56DE\u5199\u5B58\u50A8\u3002\u8BB0\u5F55\u5EFA\u8BAE\u7528 record_signal\uFF0C\u80DC\u7387\u590D\u76D8\u7528 get_signal_summary\u3002\u5386\u53F2K\u7EBF\u672A\u8986\u76D6\u8BB0\u5F55\u65E5\u65F6skipped_no_data\u5E76\u4FDD\u6301\u672A\u7ED3\u7B97\uFF0C\u4E0D\u80FD\u7528\u8F83\u65B0\u884C\u60C5\u4EE3\u66FF\u3002\u539F\u59CB\u4FE1\u53F7\u4EF7\u4E0E\u590D\u6743K\u7EBF\u987B\u6709\u53EF\u6838\u5B9E\u7684adjustment_factor\uFF0C\u7F3A\u5931\u5219skipped_price_basis\u4FDD\u6301\u672A\u7ED3\u7B97\u3002CLI\u9884\u7B97300\u79D2\uFF0C\u622A\u6B62\u524D\u8FD4\u56DE\u5E76\u4FDD\u5B58\u5DF2\u5B8C\u6210\u7ED3\u679C\uFF1Bcomplete/deferred/warnings\u8BF4\u660E\u672A\u5904\u7406\u8BB0\u5F55\uFF0C\u4E0B\u6B21\u53EF\u91CD\u8BD5",
@@ -1597,7 +2122,7 @@ function apply(ctx, config = {}) {
1597
2122
  }
1598
2123
  })
1599
2124
  );
1600
- ctx.tools.register(
2125
+ register(
1601
2126
  pyTool({
1602
2127
  name: "get_signal_summary",
1603
2128
  description: "\u4FE1\u53F7\u80DC\u7387\u6C47\u603B\uFF08\u53EF\u6309 source/symbol/status \u8FC7\u6EE4\uFF09\uFF1A\u80DC\u7387\u3001\u5E73\u5747\u6536\u76CA\u3001\u7ED3\u679C\u5206\u5E03\u4E0E\u660E\u7EC6\u3002by_source\u9644avg_return_pct\u3001return_samples\u548Csample_warning\uFF1B\u4EC5\u89C2\u5BDF\u6027\u590D\u76D8\uFF0C\u6837\u672C\u5C11\u4E0D\u80FD\u8BA4\u5B9A\u7B56\u7565\u6709\u6548\u3002",
@@ -1620,7 +2145,7 @@ function apply(ctx, config = {}) {
1620
2145
  }
1621
2146
  })
1622
2147
  );
1623
- ctx.tools.register(
2148
+ register(
1624
2149
  pyTool({
1625
2150
  name: "parse_stock_list",
1626
2151
  description: "\u81EA\u9009\u80A1/\u6587\u672C\u5BFC\u5165\u89E3\u6790 \u2014 \u4ECE\u81EA\u7136\u8BED\u8A00\u3001CSV\u3001Markdown \u8868\u683C\u63D0\u53D6\u80A1\u7968\uFF0C\u81EA\u52A8\u8BC6\u522B A \u80A1 6 \u4F4D\u4EE3\u7801\u3001\u6E2F\u80A1 xxxxx.HK\u3001\u7F8E\u80A1 ticker\u3001\u65E5\u80A1 xxxx.T\u3001\u97E9\u80A1 xxxxxx.KS/KQ\u3001\u53F0\u80A1 xxxx.TW\uFF0C\u5E76\u8C03\u7528 name_resolver \u5904\u7406\u4E2D\u6587\u80A1\u7968\u540D",
@@ -1634,7 +2159,7 @@ function apply(ctx, config = {}) {
1634
2159
  }
1635
2160
  })
1636
2161
  );
1637
- ctx.tools.register(defineTool2({
2162
+ register(closedTool({
1638
2163
  name: "compare_stocks",
1639
2164
  description: "\u65E0\u72B6\u6001\u540C\u884C\u6307\u6807\u6BD4\u8F83\uFF1A\u5148\u7528\u73B0\u6709\u8D22\u52A1/\u884C\u60C5\u5DE5\u5177\u53D6\u6570\uFF0C\u518D\u4F20companies\uFF1B\u4EC5\u76F8\u540Cunit/basis/period\u53EF\u6392\u5E8F\uFF0C\u7F3A\u5931\u4E0D\u586B\u96F6\uFF0C\u4E0D\u751F\u6210\u4E70\u5356\u7EFC\u5408\u5206\u3002",
1640
2165
  parameters: {
@@ -1702,12 +2227,11 @@ function apply(ctx, config = {}) {
1702
2227
  "required": true
1703
2228
  }
1704
2229
  },
1705
- output: { schema: { type: "string" }, render: (_args, value) => [{ type: "text", text: value }] },
1706
2230
  async execute(params) {
1707
2231
  return withJsonInput(params, (path) => runPy("stateless_analysis.py", ["peers", "--input", path]));
1708
2232
  }
1709
2233
  }));
1710
- ctx.tools.register(defineTool2({
2234
+ register(closedTool({
1711
2235
  name: "analyze_disclosure_changes",
1712
2236
  description: "\u65E0\u72B6\u6001\u516C\u544A\u8D22\u62A5\u6BD4\u8F83\uFF1A\u4F20\u65B0\u65E7\u6B63\u6587\u53CA\u6307\u6807\uFF0C\u8FD4\u56DE\u53D8\u66F4\u884C\u53F7\u3001\u6765\u6E90\u4E0E\u8D22\u52A1\u53D8\u5316\uFF1B\u8D1F/\u96F6\u57FA\u6570\u589E\u957F\u7387\u4E3Anull\u3002\u4E0D\u4E0B\u8F7DPDF\u3001\u4E0D\u4EE3\u66FF\u7ECF\u6D4E\u89E3\u8BFB\u3002",
1713
2237
  parameters: {
@@ -1844,14 +2368,13 @@ function apply(ctx, config = {}) {
1844
2368
  "description": "\u53D8\u5316\u4E0A\u96501..100\uFF0C\u9ED8\u8BA430"
1845
2369
  }
1846
2370
  },
1847
- output: { schema: { type: "string" }, render: (_args, value) => [{ type: "text", text: value }] },
1848
2371
  async execute(params) {
1849
2372
  return withJsonInput(params, (path) => runPy("stateless_analysis.py", ["disclosure", "--input", path]));
1850
2373
  }
1851
2374
  }));
1852
- ctx.tools.register(defineTool2({
2375
+ register(closedTool({
1853
2376
  name: "analyze_portfolio_risk",
1854
- description: "\u65E0\u72B6\u6001\u73B0\u8D27\u591A\u5934\u7EC4\u5408\u98CE\u9669\uFF1A\u8F93\u5165\u6301\u4ED3\u3001\u57FA\u51C6\u5E01\u79CD\u73B0\u91D1\u4E0E\u6C47\u7387\uFF0C\u8FD4\u56DE\u96C6\u4E2D\u5EA6\u3001\u5E01\u79CD/\u884C\u4E1A\u655E\u53E3\u3001\u4EF7\u683C\u76C8\u4E8F\u548C\u6B62\u635F\u60C5\u666F\u3002\u7F3A\u6C47\u7387\u62A5\u9519\uFF1B\u4E0D\u4FDD\u5B58\u8D26\u6237\u3002",
2377
+ description: "\u65E0\u72B6\u6001\u73B0\u8D27\u591A\u5934\u7EC4\u5408\u98CE\u9669\u4E0E\u538B\u529B\u6D4B\u8BD5\uFF1A\u8F93\u5165\u6301\u4ED3\u3001\u57FA\u51C6\u5E01\u79CD\u73B0\u91D1\u4E0E\u6C47\u7387\uFF0C\u8FD4\u56DE\u96C6\u4E2D\u5EA6\u3001\u5E01\u79CD/\u884C\u4E1A\u655E\u53E3\u3001\u4EF7\u683C\u76C8\u4E8F\u3001\u6B62\u635F\u60C5\u666F\u53CA\u53EF\u9009\u5E02\u573A/\u884C\u4E1A/\u4E2A\u80A1/\u6C47\u7387\u51B2\u51FB\u635F\u76CA\u3002\u7F3A\u6C47\u7387\u62A5\u9519\uFF1B\u4E0D\u4FDD\u5B58\u8D26\u6237\u3002",
1855
2378
  parameters: {
1856
2379
  "positions": {
1857
2380
  "type": "array",
@@ -1965,14 +2488,231 @@ function apply(ctx, config = {}) {
1965
2488
  "additionalProperties": false
1966
2489
  },
1967
2490
  "description": "\u53EF\u9009\u5386\u53F2\uFF0C\u5171\u540C\u65E5\u671F\u672C\u5E01\u4EF7\u683C\u6536\u76CA\u76F8\u5173\u6027\uFF0C\u4E0D\u8BA1\u6C47\u7387"
2491
+ },
2492
+ "stress_scenarios": {
2493
+ "type": "array",
2494
+ "items": {
2495
+ "type": "object",
2496
+ "properties": {
2497
+ "name": {
2498
+ "type": "string",
2499
+ "description": "\u60C5\u666F\u540D\u79F0",
2500
+ "required": true
2501
+ },
2502
+ "market_shock": {
2503
+ "type": "number",
2504
+ "description": "\u5168\u5E02\u573A\u8D44\u4EA7\u4EF7\u683C\u51B2\u51FB\u6BD4\u4F8B\uFF0C\u5982-0.1"
2505
+ },
2506
+ "sector_shocks": {
2507
+ "type": "array",
2508
+ "items": {
2509
+ "type": "object",
2510
+ "properties": {
2511
+ "sector": {
2512
+ "type": "string",
2513
+ "description": "\u4E0E\u6301\u4ED3\u4E00\u81F4\u7684\u884C\u4E1A\u540D\u79F0",
2514
+ "required": true
2515
+ },
2516
+ "shock": {
2517
+ "type": "number",
2518
+ "description": "\u884C\u4E1A\u4EF7\u683C\u51B2\u51FB\u6BD4\u4F8B",
2519
+ "required": true
2520
+ }
2521
+ },
2522
+ "additionalProperties": false
2523
+ },
2524
+ "description": "\u53EF\u9009\u884C\u4E1A\u51B2\u51FB"
2525
+ },
2526
+ "symbol_shocks": {
2527
+ "type": "array",
2528
+ "items": {
2529
+ "type": "object",
2530
+ "properties": {
2531
+ "symbol": {
2532
+ "type": "string",
2533
+ "description": "\u6301\u4ED3\u6807\u7684\u4EE3\u7801",
2534
+ "required": true
2535
+ },
2536
+ "shock": {
2537
+ "type": "number",
2538
+ "description": "\u6807\u7684\u4EF7\u683C\u51B2\u51FB\u6BD4\u4F8B",
2539
+ "required": true
2540
+ }
2541
+ },
2542
+ "additionalProperties": false
2543
+ },
2544
+ "description": "\u53EF\u9009\u4E2A\u80A1\u51B2\u51FB"
2545
+ },
2546
+ "currency_shocks": {
2547
+ "type": "array",
2548
+ "items": {
2549
+ "type": "object",
2550
+ "properties": {
2551
+ "currency": {
2552
+ "type": "string",
2553
+ "description": "\u6301\u4ED3\u4E2D\u7684\u975E\u57FA\u51C6\u5E01\u79CD\uFF1B\u57FA\u51C6\u5E01\u79CD\u4E0D\u53EF\u76F8\u5BF9\u81EA\u8EAB\u51B2\u51FB",
2554
+ "required": true
2555
+ },
2556
+ "shock": {
2557
+ "type": "number",
2558
+ "description": "\u76F8\u5BF9\u57FA\u51C6\u5E01\u79CD\u7684\u6C47\u7387\u51B2\u51FB\u6BD4\u4F8B",
2559
+ "required": true
2560
+ }
2561
+ },
2562
+ "additionalProperties": false
2563
+ },
2564
+ "description": "\u53EF\u9009\u6C47\u7387\u51B2\u51FB"
2565
+ }
2566
+ },
2567
+ "additionalProperties": false
2568
+ },
2569
+ "description": "\u53EF\u9009\u538B\u529B\u60C5\u666F\uFF1B\u6240\u6709\u51B2\u51FB\u5747\u4E3A\u6BD4\u4F8B\uFF0C\u7531\u5171\u4EAB\u6838\u5FC3\u8BA1\u7B97"
1968
2570
  }
1969
2571
  },
1970
- output: { schema: { type: "string" }, render: (_args, value) => [{ type: "text", text: value }] },
1971
2572
  async execute(params) {
1972
2573
  return withJsonInput(params, (path) => runPy("stateless_analysis.py", ["portfolio", "--input", path]));
1973
2574
  }
1974
2575
  }));
1975
- ctx.tools.register(defineTool2({
2576
+ register(closedTool({
2577
+ name: "plan_portfolio_rebalance",
2578
+ description: "\u65E0\u72B6\u6001\u7EC4\u5408\u8C03\u4ED3\u8BA1\u5212\uFF1A\u6309\u5F53\u524D\u6301\u4ED3\u3001\u76EE\u6807\u6743\u91CD\u3001\u73B0\u91D1\u3001\u6C47\u7387\u3001\u6574\u624B\u3001\u8D39\u7528\u548C\u6362\u624B\u7EA6\u675F\u751F\u6210\u5148\u5356\u540E\u4E70\u6E05\u5355\uFF1B\u4E0D\u4FDD\u5B58\u8D26\u6237\u6216\u63D0\u4EA4\u8BA2\u5355\u3002",
2579
+ parameters: {
2580
+ "base_currency": {
2581
+ "type": "string",
2582
+ "description": "\u57FA\u51C6\u5E01\u79CD",
2583
+ "required": true
2584
+ },
2585
+ "cash": {
2586
+ "type": "number",
2587
+ "description": "\u57FA\u51C6\u5E01\u79CD\u73B0\u91D1\uFF0C\u975E\u8D1F",
2588
+ "required": true
2589
+ },
2590
+ "positions": {
2591
+ "type": "array",
2592
+ "items": {
2593
+ "type": "object",
2594
+ "properties": {
2595
+ "symbol": {
2596
+ "type": "string",
2597
+ "description": "\u552F\u4E00\u4EE3\u7801\uFF0C\u91CD\u590D\u6301\u4ED3\u5148\u6C47\u603B",
2598
+ "required": true
2599
+ },
2600
+ "quantity": {
2601
+ "type": "number",
2602
+ "description": "\u6B63\u6301\u4ED3\u6570\u91CF",
2603
+ "required": true
2604
+ },
2605
+ "price": {
2606
+ "type": "number",
2607
+ "description": "\u6B63\u73B0\u4EF7",
2608
+ "required": true
2609
+ },
2610
+ "currency": {
2611
+ "type": "string",
2612
+ "description": "\u6301\u4ED3\u5E01\u79CD\uFF0C\u5982CNY/USD/HKD",
2613
+ "required": true
2614
+ },
2615
+ "cost": {
2616
+ "type": "number",
2617
+ "description": "\u540C\u5E01\u79CD\u6B63\u6210\u672C\u4EF7\uFF0C\u53EF\u9009\uFF1B\u8C03\u4ED3\u8BA1\u7B97\u4E0D\u4F7F\u7528"
2618
+ },
2619
+ "stop_price": {
2620
+ "type": "number",
2621
+ "description": "\u540C\u5E01\u79CD\u6B63\u6B62\u635F\u4EF7\uFF0C\u53EF\u9009\uFF1B\u8C03\u4ED3\u8BA1\u7B97\u4E0D\u4F7F\u7528"
2622
+ },
2623
+ "sector": {
2624
+ "type": "string",
2625
+ "description": "\u7EDF\u4E00\u884C\u4E1A\u5206\u7C7B\uFF0C\u53EF\u9009"
2626
+ },
2627
+ "as_of": {
2628
+ "type": "string",
2629
+ "description": "\u5B9E\u9645\u4F30\u503C\u65F6\u70B9\uFF0C\u5EFA\u8BAEISO8601"
2630
+ }
2631
+ },
2632
+ "additionalProperties": false
2633
+ },
2634
+ "description": "0..100\u4E2A\u73B0\u8D27\u591A\u5934\u6301\u4ED3\uFF0C\u7A7A\u6570\u7EC4\u8868\u793A\u7EAF\u73B0\u91D1\u5EFA\u4ED3",
2635
+ "required": true
2636
+ },
2637
+ "targets": {
2638
+ "type": "array",
2639
+ "items": {
2640
+ "type": "object",
2641
+ "properties": {
2642
+ "symbol": {
2643
+ "type": "string",
2644
+ "description": "\u76EE\u6807\u6807\u7684\u4EE3\u7801",
2645
+ "required": true
2646
+ },
2647
+ "weight": {
2648
+ "type": "number",
2649
+ "description": "\u76EE\u6807\u6743\u91CD\uFF1B\u5927\u4E8E0\u65F6lot_size\u5FC5\u586B",
2650
+ "required": true
2651
+ },
2652
+ "price": {
2653
+ "type": "number",
2654
+ "description": "\u6B63\u76EE\u6807\u4EF7\u683C\uFF1B\u5F53\u524D\u672A\u6301\u6709\u7684\u65B0\u6807\u7684\u5FC5\u586B"
2655
+ },
2656
+ "currency": {
2657
+ "type": "string",
2658
+ "description": "\u76EE\u6807\u5E01\u79CD\uFF1B\u5F53\u524D\u672A\u6301\u6709\u7684\u65B0\u6807\u7684\u5FC5\u586B"
2659
+ },
2660
+ "sector": {
2661
+ "type": "string",
2662
+ "description": "\u7EDF\u4E00\u884C\u4E1A\u5206\u7C7B\uFF0C\u53EF\u9009"
2663
+ },
2664
+ "as_of": {
2665
+ "type": "string",
2666
+ "description": "\u5B9E\u9645\u4F30\u503C\u65F6\u70B9\uFF0C\u5EFA\u8BAEISO8601"
2667
+ },
2668
+ "lot_size": {
2669
+ "type": "number",
2670
+ "description": "\u6B63\u6574\u6570\u4EA4\u6613\u5355\u4F4D\uFF1Bweight>0\u65F6\u5FC5\u586B"
2671
+ }
2672
+ },
2673
+ "additionalProperties": false
2674
+ },
2675
+ "description": "1..100\u4E2A\u76EE\u6807\uFF1B\u65B0\u6807\u7684price/currency\u5FC5\u586B",
2676
+ "required": true
2677
+ },
2678
+ "fx_rates": {
2679
+ "type": "array",
2680
+ "items": {
2681
+ "type": "object",
2682
+ "properties": {
2683
+ "currency": {
2684
+ "type": "string",
2685
+ "description": "\u552F\u4E00\u975E\u57FA\u51C6\u5E01\u79CD",
2686
+ "required": true
2687
+ },
2688
+ "rate": {
2689
+ "type": "number",
2690
+ "description": "\u4E00\u5355\u4F4D\u8BE5\u5E01\u79CD\u5BF9\u5E94\u591A\u5C11\u57FA\u51C6\u5E01\u79CD\uFF0C\u6B63\u6570",
2691
+ "required": true
2692
+ }
2693
+ },
2694
+ "additionalProperties": false
2695
+ },
2696
+ "description": "\u663E\u5F0F\u73B0\u4EF7\u6C47\u7387\uFF1B\u57FA\u51C6\u5E01\u79CD\u9690\u542B1\uFF0C\u4E0D\u5F97\u91CD\u590D"
2697
+ },
2698
+ "fee_rate": {
2699
+ "type": "number",
2700
+ "description": "\u6BCF\u8FB9\u6BD4\u4F8B\u8D39\u75280..0.1\uFF0C\u9ED8\u8BA40\uFF1B\u4E0D\u542B\u672A\u63D0\u4F9B\u7A0E\u8D39/\u6700\u4F4E\u6536\u8D39"
2701
+ },
2702
+ "slippage_rate": {
2703
+ "type": "number",
2704
+ "description": "\u6BCF\u8FB9\u6ED1\u70B90..0.1\uFF0C\u9ED8\u8BA40"
2705
+ },
2706
+ "max_turnover_fraction": {
2707
+ "type": "number",
2708
+ "description": "\u975E\u8D1F\u6700\u5927\u603B\u6362\u624B\uFF0C\u6309\u4E70\u5356\u53C2\u8003\u91D1\u989D\u5408\u8BA1/\u521D\u59CB\u6743\u76CA\uFF1B\u9ED8\u8BA4\u4E0D\u9650\u5236\uFF0C\u53EF\u5927\u4E8E1"
2709
+ }
2710
+ },
2711
+ async execute(params) {
2712
+ return withJsonInput(params, (path) => runPy("stateless_analysis.py", ["rebalance", "--input", path]));
2713
+ }
2714
+ }));
2715
+ register(closedTool({
1976
2716
  name: "calculate_position_size",
1977
2717
  description: "\u65E0\u72B6\u6001\u591A\u5934\u4ED3\u4F4D\u9884\u7B97\uFF1A\u540C\u5E01\u79CD\u91D1\u989D\uFF0C\u6309\u73B0\u91D1/\u98CE\u9669\u9884\u7B97/\u6700\u5927\u4ED3\u4F4D/\u4EA4\u6613\u5355\u4F4D\u53D6\u6700\u5C0F\u6570\u91CF\uFF0C\u53CC\u8FB9\u8D39\u7528\u548C\u6ED1\u70B9\u53C2\u4E0E\u6B62\u635F\u60C5\u666F\uFF1B\u4E0D\u6267\u884C\u4EA4\u6613\u3002",
1978
2718
  parameters: {
@@ -2019,12 +2759,11 @@ function apply(ctx, config = {}) {
2019
2759
  "description": "\u6BCF\u8FB9\u6ED1\u70B90..0.1\uFF0C\u9ED8\u8BA40"
2020
2760
  }
2021
2761
  },
2022
- output: { schema: { type: "string" }, render: (_args, value) => [{ type: "text", text: value }] },
2023
2762
  async execute(params) {
2024
2763
  return withJsonInput(params, (path) => runPy("stateless_analysis.py", ["position_size", "--input", path]));
2025
2764
  }
2026
2765
  }));
2027
- ctx.tools.register(defineTool2({
2766
+ register(closedTool({
2028
2767
  name: "analyze_event_study",
2029
2768
  description: "\u65E0\u72B6\u6001\u4E8B\u4EF6\u7814\u7A76\uFF1A\u63D0\u4F9B\u540C\u5E02\u573A\u80A1\u7968\u53CA\u57FA\u51C6\u5B8C\u6574\u4EF7\u683C\u3001\u4E8B\u4EF6\u65E5\u671F\uFF1B\u4E8B\u4EF6\u524D\u4E00\u4EA4\u6613\u65E5\u6536\u76D8\u4E3A\u57FA\u70B9\uFF0C\u8BA1\u7B97\u4EA4\u6613\u65E5\u7A97\u53E3\u6536\u76CA\u5DEE\u3002\u7F3A\u7A97\u53E3/\u57FA\u51C6\u4E3Anull\uFF0C\u6807\u6CE8\u91CD\u53E0\uFF0C\u4E0D\u63A8\u65AD\u56E0\u679C\u3002",
2030
2769
  parameters: {
@@ -2106,12 +2845,11 @@ function apply(ctx, config = {}) {
2106
2845
  "description": "\u540C\u5E02\u573A\u57FA\u51C6\u4EE3\u7801\uFF1B\u4E0Esymbol\u4E00\u8D77\u4F7F\u7528"
2107
2846
  }
2108
2847
  },
2109
- output: { schema: { type: "string" }, render: (_args, value) => [{ type: "text", text: value }] },
2110
2848
  async execute(params) {
2111
2849
  return withJsonInput(params, (path) => runPy("stateless_analysis.py", ["event_study", "--input", path]));
2112
2850
  }
2113
2851
  }));
2114
- ctx.tools.register(defineTool2({
2852
+ register(closedTool({
2115
2853
  name: "validate_backtest",
2116
2854
  description: "\u65E0\u72B6\u6001\u56DE\u6D4B\u7A33\u5065\u6027\uFF1A\u8F93\u5165\u5386\u53F2OHLCV\u548C\u5B8C\u6574\u5019\u9009DSL\uFF1B\u6EDA\u52A8\u8BAD\u7EC3\u9009\u53C2\u6570\u3001\u540E\u7EED\u4E0D\u91CD\u53E0\u7A97\u53E3\u9A8C\u8BC1\uFF0C\u5217\u51FA\u5168\u90E8\u6837\u672C\u5185\u654F\u611F\u6027\u53CA\u8DE8\u6807\u7684\u7ED3\u679C\u3002\u4EC5next_open\uFF0C\u4E0D\u81EA\u52A8\u4F18\u5316\u6216\u4FDD\u5B58\u3002",
2117
2855
  parameters: {
@@ -2227,12 +2965,11 @@ function apply(ctx, config = {}) {
2227
2965
  "description": "1..5\u4E2A\u552F\u4E00\u80A1\u7968\u4EE3\u7801\uFF0C\u914D\u5408start_date/end_date\u76F4\u63A5\u53D6\u6570\uFF1B\u548Cdatasets\u4E92\u65A5"
2228
2966
  }
2229
2967
  },
2230
- output: { schema: { type: "string" }, render: (_args, value) => [{ type: "text", text: value }] },
2231
2968
  async execute(params) {
2232
2969
  return withJsonInput(params, (path) => runPy("stateless_analysis.py", ["robustness", "--input", path]));
2233
2970
  }
2234
2971
  }));
2235
- ctx.tools.register(defineTool2({
2972
+ register(closedTool({
2236
2973
  name: "compare_analysis_snapshots",
2237
2974
  description: "\u65E0\u72B6\u6001\u5FEB\u7167\u6BD4\u8F83\uFF1A\u4F20\u65B0\u65E7JSON\uFF0C\u8FD4\u56DEJSON Pointer\u53CA\u65B0\u589E/\u5220\u9664/\u53D8\u5316/\u5931\u6548/\u6062\u590D\uFF1B\u4E0D\u4FDD\u5B58\u5FEB\u7167\u3002\u6570\u7EC4\u6574\u4F53\u6BD4\u8F83\uFF0C\u8C03\u7528\u524D\u6309symbol\u5BF9\u9F50\u3002",
2238
2975
  parameters: {
@@ -2251,15 +2988,12 @@ function apply(ctx, config = {}) {
2251
2988
  "required": true
2252
2989
  }
2253
2990
  },
2254
- output: { schema: { type: "string" }, render: (_args, value) => [{ type: "text", text: value }] },
2255
2991
  async execute(params) {
2256
2992
  return withJsonInput(params, (path) => runPy("stateless_analysis.py", ["snapshot", "--input", path]));
2257
2993
  }
2258
2994
  }));
2995
+ registerDashboard(ctx, runPy);
2259
2996
  registerSkills(ctx);
2260
- if (config.toolDiscovery !== false) {
2261
- registerToolDiscovery(ctx, new Set(ctx.tools.schemas?.().filter((tool) => !previousTools.has(tool.name)).map((tool) => tool.name)));
2262
- }
2263
2997
  }
2264
2998
  export {
2265
2999
  __setExecutor,