@zhin.js/plugin-lottery 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/commands/lottery/[game:string=].js +18 -0
- package/commands/lottery-backtest/[game:string=].js +28 -0
- package/commands/lottery-history/[game:string].js +23 -0
- package/commands/lottery-stats/[game:string].js +33 -0
- package/commands/lottery-today.js +17 -0
- package/commands/lottery-train/[game:string=].js +28 -0
- package/package.json +6 -6
- package/plugin.js +101 -0
- package/plugin.ts +0 -115
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { defineCommand } from '@zhin.js/command';
|
|
3
|
+
import { parseGameId } from "../../lib/games/registry.js";
|
|
4
|
+
import { buildPipelineDeps, formatPipelineReply, getLotteryDb, runLotteryPipeline, resolveLotteryConfig, } from "../../lib/command-helpers.js";
|
|
5
|
+
import { resolveLotteryRuntime } from "../../lib/runtime-state.js";
|
|
6
|
+
export default defineCommand({
|
|
7
|
+
description: 'Run full pipeline: sync → review → recommend (manual, no push)',
|
|
8
|
+
async execute({ params, config, owner, use }) {
|
|
9
|
+
const cfg = resolveLotteryConfig(config);
|
|
10
|
+
const gid = parseGameId(String(params.game ?? ''));
|
|
11
|
+
const db = resolveLotteryRuntime({ owner, use })?.db ?? getLotteryDb();
|
|
12
|
+
const out = await runLotteryPipeline(buildPipelineDeps(cfg, db), {
|
|
13
|
+
gameId: gid ?? undefined,
|
|
14
|
+
push: false,
|
|
15
|
+
});
|
|
16
|
+
return formatPipelineReply(out);
|
|
17
|
+
},
|
|
18
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { defineCommand } from '@zhin.js/command';
|
|
3
|
+
import { parseGameId } from "../../lib/games/registry.js";
|
|
4
|
+
import { formatBacktestSection, runBacktestForGames, } from "../../lib/evaluate/backtest.js";
|
|
5
|
+
import { getLotteryDb, resolveLotteryConfig, } from "../../lib/command-helpers.js";
|
|
6
|
+
import { lotteryEnabledGames } from "../../lib/config.js";
|
|
7
|
+
import { resolveLotteryRuntime } from "../../lib/runtime-state.js";
|
|
8
|
+
export default defineCommand({
|
|
9
|
+
description: 'Walk-forward backtest vs random baseline',
|
|
10
|
+
async execute({ params, config, owner, use }) {
|
|
11
|
+
const db = resolveLotteryRuntime({ owner, use })?.db ?? getLotteryDb();
|
|
12
|
+
if (!db)
|
|
13
|
+
return '数据库未就绪';
|
|
14
|
+
const cfg = resolveLotteryConfig(config);
|
|
15
|
+
const gid = parseGameId(String(params.game ?? ''));
|
|
16
|
+
const gameIds = gid ? [gid] : lotteryEnabledGames(cfg);
|
|
17
|
+
const summaries = await runBacktestForGames(db, gameIds, {
|
|
18
|
+
pickCount: cfg.pickCount,
|
|
19
|
+
window: cfg.backtestWindow,
|
|
20
|
+
randomTrials: cfg.backtestRandomTrials,
|
|
21
|
+
minHistory: cfg.backtestMinHistory,
|
|
22
|
+
historyLimit: cfg.historyLimit,
|
|
23
|
+
adaptive: cfg.backtestAdaptive,
|
|
24
|
+
});
|
|
25
|
+
const text = formatBacktestSection(summaries);
|
|
26
|
+
return text || '历史数据不足,请先执行 lottery 同步开奖';
|
|
27
|
+
},
|
|
28
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { defineCommand } from '@zhin.js/command';
|
|
3
|
+
import { parseGameId } from "../../lib/games/registry.js";
|
|
4
|
+
import { loadDraws } from "../../lib/db.js";
|
|
5
|
+
import { getLotteryDb } from "../../lib/command-helpers.js";
|
|
6
|
+
import { resolveLotteryRuntime } from "../../lib/runtime-state.js";
|
|
7
|
+
export default defineCommand({
|
|
8
|
+
description: 'List historical draw results',
|
|
9
|
+
async execute({ params, args, owner, use }) {
|
|
10
|
+
const gid = parseGameId(String(params.game ?? ''));
|
|
11
|
+
if (!gid)
|
|
12
|
+
return '请指定玩法';
|
|
13
|
+
const db = resolveLotteryRuntime({ owner, use })?.db ?? getLotteryDb();
|
|
14
|
+
if (!db)
|
|
15
|
+
return '数据库未就绪';
|
|
16
|
+
// count 原来是第二动态段,约定式命令只支持单动态文件参数,改从 args 取
|
|
17
|
+
const count = Math.min(50, Math.max(1, Number(args[0]) || 10));
|
|
18
|
+
const draws = await loadDraws(db, gid, count);
|
|
19
|
+
if (!draws.length)
|
|
20
|
+
return '暂无数据';
|
|
21
|
+
return draws.map((d) => `${d.issue} ${d.drawTime} ${JSON.stringify(d.numbers)}`).join('\n');
|
|
22
|
+
},
|
|
23
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { defineCommand } from '@zhin.js/command';
|
|
3
|
+
import { parseGameId } from "../../lib/games/registry.js";
|
|
4
|
+
import { loadDraws } from "../../lib/db.js";
|
|
5
|
+
import { recommendGame, formatPickLine, formatPickStats } from "../../lib/recommend/game-pick.js";
|
|
6
|
+
import { loadAccuracySnapshot, loadGameWeights } from "../../lib/evaluate/tracker.js";
|
|
7
|
+
import { getLotteryDb, resolveLotteryConfig, } from "../../lib/command-helpers.js";
|
|
8
|
+
import { lotteryKl8 } from "../../lib/config.js";
|
|
9
|
+
import { resolveLotteryRuntime } from "../../lib/runtime-state.js";
|
|
10
|
+
export default defineCommand({
|
|
11
|
+
description: 'Single-game stats snapshot',
|
|
12
|
+
async execute({ params, config, owner, use }) {
|
|
13
|
+
const gid = parseGameId(String(params.game ?? ''));
|
|
14
|
+
if (!gid)
|
|
15
|
+
return '请指定玩法';
|
|
16
|
+
const db = resolveLotteryRuntime({ owner, use })?.db ?? getLotteryDb();
|
|
17
|
+
if (!db)
|
|
18
|
+
return '数据库未就绪';
|
|
19
|
+
const cfg = resolveLotteryConfig(config);
|
|
20
|
+
const draws = await loadDraws(db, gid, cfg.historyLimit);
|
|
21
|
+
if (!draws.length)
|
|
22
|
+
return '暂无数据,请先 lottery';
|
|
23
|
+
const kl8 = lotteryKl8(cfg);
|
|
24
|
+
const pick = recommendGame(gid, draws, {
|
|
25
|
+
pickCount: gid === 'kl8' ? kl8.pickCount : cfg.pickCount,
|
|
26
|
+
tieSeed: 'stats',
|
|
27
|
+
weights: await loadGameWeights(db, gid),
|
|
28
|
+
accuracy: await loadAccuracySnapshot(db, gid),
|
|
29
|
+
kl8: gid === 'kl8' ? kl8 : undefined,
|
|
30
|
+
});
|
|
31
|
+
return [formatPickLine(pick), formatPickStats(pick), `样本 ${draws.length} 期`].join('\n');
|
|
32
|
+
},
|
|
33
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { defineCommand } from '@zhin.js/command';
|
|
3
|
+
import { formatDailyReportText, loadTodayReport } from "../lib/recommend/report.js";
|
|
4
|
+
import { getLotteryDb } from "../lib/command-helpers.js";
|
|
5
|
+
import { resolveLotteryRuntime } from "../lib/runtime-state.js";
|
|
6
|
+
export default defineCommand({
|
|
7
|
+
description: 'Show today published recommendation report',
|
|
8
|
+
async execute({ owner, use }) {
|
|
9
|
+
const db = resolveLotteryRuntime({ owner, use })?.db ?? getLotteryDb();
|
|
10
|
+
if (!db)
|
|
11
|
+
return '数据库未就绪';
|
|
12
|
+
const report = await loadTodayReport(db);
|
|
13
|
+
if (!report)
|
|
14
|
+
return '今日尚无推荐,可执行 lottery 或等待定时任务';
|
|
15
|
+
return formatDailyReportText(report, '');
|
|
16
|
+
},
|
|
17
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { defineCommand } from '@zhin.js/command';
|
|
3
|
+
import { parseGameId } from "../../lib/games/registry.js";
|
|
4
|
+
import { formatTrainReport, trainAllGameWeights, } from "../../lib/evaluate/backtest.js";
|
|
5
|
+
import { getLotteryDb, resolveLotteryConfig, } from "../../lib/command-helpers.js";
|
|
6
|
+
import { lotteryEnabledGames } from "../../lib/config.js";
|
|
7
|
+
import { resolveLotteryRuntime } from "../../lib/runtime-state.js";
|
|
8
|
+
export default defineCommand({
|
|
9
|
+
description: 'Full-history weight training',
|
|
10
|
+
async execute({ params, config, owner, use }) {
|
|
11
|
+
const db = resolveLotteryRuntime({ owner, use })?.db ?? getLotteryDb();
|
|
12
|
+
if (!db)
|
|
13
|
+
return '数据库未就绪';
|
|
14
|
+
const cfg = resolveLotteryConfig(config);
|
|
15
|
+
const gid = parseGameId(String(params.game ?? ''));
|
|
16
|
+
const gameIds = gid ? [gid] : lotteryEnabledGames(cfg);
|
|
17
|
+
const results = await trainAllGameWeights(db, gameIds, {
|
|
18
|
+
pickCount: cfg.pickCount,
|
|
19
|
+
minHistory: cfg.backtestMinHistory,
|
|
20
|
+
historyLimit: cfg.historyLimit,
|
|
21
|
+
randomTrials: cfg.backtestRandomTrials,
|
|
22
|
+
holdoutWindow: cfg.backtestWindow,
|
|
23
|
+
holdoutFallback: cfg.weightHoldoutFallback,
|
|
24
|
+
persist: true,
|
|
25
|
+
});
|
|
26
|
+
return formatTrainReport(results);
|
|
27
|
+
},
|
|
28
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhin.js/plugin-lottery",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "Multi-game lottery analysis for Zhin.js (Plugin Runtime)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"./package.json": "./package.json"
|
|
15
15
|
},
|
|
16
16
|
"files": [
|
|
17
|
-
"plugin.
|
|
17
|
+
"plugin.js",
|
|
18
18
|
"schema.json",
|
|
19
19
|
"commands",
|
|
20
20
|
"src",
|
|
@@ -41,18 +41,18 @@
|
|
|
41
41
|
},
|
|
42
42
|
"license": "MIT",
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@zhin.js/command": "1.0.
|
|
44
|
+
"@zhin.js/command": "1.0.4",
|
|
45
45
|
"@zhin.js/plugin-runtime": "1.1.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"typescript": "^6.0.3",
|
|
49
49
|
"vitest": "^4.1.10",
|
|
50
50
|
"zod": "^4.4.3",
|
|
51
|
-
"@zhin.js/agent": "1.0.
|
|
51
|
+
"@zhin.js/agent": "1.0.8"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"zod": "^4.0.0",
|
|
55
|
-
"@zhin.js/agent": "1.0.
|
|
55
|
+
"@zhin.js/agent": "1.0.8"
|
|
56
56
|
},
|
|
57
57
|
"peerDependenciesMeta": {
|
|
58
58
|
"@zhin.js/agent": {
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"zhin": {
|
|
78
78
|
"protocol": 1,
|
|
79
79
|
"type": "plugin",
|
|
80
|
-
"entry": "./plugin.
|
|
80
|
+
"entry": "./plugin.js",
|
|
81
81
|
"engine": "^1.0.0",
|
|
82
82
|
"runtime": "trusted",
|
|
83
83
|
"features": [
|
package/plugin.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { definePlugin, agentToolsHostToken, databaseHostToken, outboundHostToken, scheduleHostToken, } from '@zhin.js/plugin-runtime';
|
|
3
|
+
import { lotteryEnabledGames, lotteryKl8, resolveLotteryConfig, } from "./lib/config.js";
|
|
4
|
+
import { defineLotteryTables } from "./lib/db.js";
|
|
5
|
+
import { registerLotteryDb } from "./lib/db-store.js";
|
|
6
|
+
import { registerLotteryAgentDeps } from "./lib/lottery-agent-deps.js";
|
|
7
|
+
import { createInMemoryLotteryDb } from "./lib/memory-db.js";
|
|
8
|
+
import { lotteryRuntimeToken } from "./lib/runtime-state.js";
|
|
9
|
+
import { runLotteryPipeline } from "./lib/pipeline.js";
|
|
10
|
+
import { registerLotteryOutboundPush } from "./lib/push.js";
|
|
11
|
+
/**
|
|
12
|
+
* Plugin Runtime:
|
|
13
|
+
* - DB: prefer databaseHostToken; else memory.
|
|
14
|
+
* - Push: OutboundHost + config.pushTargets (cron / publish).
|
|
15
|
+
* - Cron: scheduleHostToken daily pipeline.
|
|
16
|
+
*/
|
|
17
|
+
export default definePlugin({
|
|
18
|
+
name: 'lottery',
|
|
19
|
+
metadata: {
|
|
20
|
+
displayName: 'Lottery',
|
|
21
|
+
},
|
|
22
|
+
async setup(context) {
|
|
23
|
+
const config = resolveLotteryConfig(context.config.get());
|
|
24
|
+
const db = context.resources.has(databaseHostToken)
|
|
25
|
+
? context.resources.use(databaseHostToken)
|
|
26
|
+
: createInMemoryLotteryDb();
|
|
27
|
+
if (context.resources.has(databaseHostToken)) {
|
|
28
|
+
defineLotteryTables(db);
|
|
29
|
+
}
|
|
30
|
+
context.resources.provide(lotteryRuntimeToken, { db });
|
|
31
|
+
context.lifecycle.add(registerLotteryDb(db));
|
|
32
|
+
let outboundPush = null;
|
|
33
|
+
if (context.resources.has(outboundHostToken) && config.pushTargets.length > 0) {
|
|
34
|
+
const outbound = context.resources.use(outboundHostToken);
|
|
35
|
+
outboundPush = async (text) => {
|
|
36
|
+
for (const target of config.pushTargets) {
|
|
37
|
+
try {
|
|
38
|
+
await outbound.send({
|
|
39
|
+
adapter: target.adapter,
|
|
40
|
+
endpointId: target.endpointId || target.adapter,
|
|
41
|
+
channelType: target.channelType || 'private',
|
|
42
|
+
channelId: target.channelId,
|
|
43
|
+
content: text,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
// OutboundHost logs; continue remaining targets.
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
context.lifecycle.add(registerLotteryOutboundPush(outboundPush));
|
|
53
|
+
context.lifecycle.add(registerLotteryAgentDeps({
|
|
54
|
+
getDb: () => db,
|
|
55
|
+
getConfig: () => ({
|
|
56
|
+
pickCount: config.pickCount,
|
|
57
|
+
historyLimit: config.historyLimit,
|
|
58
|
+
kl8: lotteryKl8(config),
|
|
59
|
+
}),
|
|
60
|
+
enabledGames: () => lotteryEnabledGames(config),
|
|
61
|
+
scheduleCron: () => config.scheduleCron,
|
|
62
|
+
scheduleEnabled: () => config.scheduleEnabled,
|
|
63
|
+
pipelinePush: config.pushTargets.length > 0,
|
|
64
|
+
}));
|
|
65
|
+
// Agent tools (agent/tools/*): register into the Runtime Agent Host when AI
|
|
66
|
+
// is installed. Lazy import keeps @zhin.js/agent out of IM-only installs.
|
|
67
|
+
if (context.resources.has(agentToolsHostToken)) {
|
|
68
|
+
const agentTools = context.resources.use(agentToolsHostToken);
|
|
69
|
+
const { registerLotteryAgentTools } = await import('./agent/runtime-tools.js');
|
|
70
|
+
context.lifecycle.add(registerLotteryAgentTools(agentTools));
|
|
71
|
+
}
|
|
72
|
+
if (!context.resources.has(scheduleHostToken) || !config.scheduleEnabled) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const schedule = context.resources.use(scheduleHostToken);
|
|
76
|
+
const dispose = schedule.register({
|
|
77
|
+
id: 'lottery/daily_pipeline',
|
|
78
|
+
cron: config.scheduleCron || '0 0 18 * * *',
|
|
79
|
+
description: 'Daily lottery pipeline',
|
|
80
|
+
async execute() {
|
|
81
|
+
await runLotteryPipeline({
|
|
82
|
+
getDb: () => db,
|
|
83
|
+
enabledGames: () => lotteryEnabledGames(config),
|
|
84
|
+
historyLimit: config.historyLimit,
|
|
85
|
+
pickCount: config.pickCount,
|
|
86
|
+
kl8: lotteryKl8(config),
|
|
87
|
+
backtest: {
|
|
88
|
+
enabled: config.backtestEnabled,
|
|
89
|
+
window: config.backtestWindow,
|
|
90
|
+
randomTrials: config.backtestRandomTrials,
|
|
91
|
+
minHistory: config.backtestMinHistory,
|
|
92
|
+
adaptive: config.backtestAdaptive,
|
|
93
|
+
},
|
|
94
|
+
weightPersist: config.weightPersistEnabled,
|
|
95
|
+
weightHoldoutFallback: config.weightHoldoutFallback,
|
|
96
|
+
}, { push: config.pushTargets.length > 0 });
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
context.lifecycle.add(dispose);
|
|
100
|
+
},
|
|
101
|
+
});
|
package/plugin.ts
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
definePlugin,
|
|
3
|
-
agentToolsHostToken,
|
|
4
|
-
databaseHostToken,
|
|
5
|
-
outboundHostToken,
|
|
6
|
-
scheduleHostToken,
|
|
7
|
-
} from '@zhin.js/plugin-runtime';
|
|
8
|
-
import {
|
|
9
|
-
lotteryEnabledGames,
|
|
10
|
-
lotteryKl8,
|
|
11
|
-
resolveLotteryConfig,
|
|
12
|
-
type LotteryConfig,
|
|
13
|
-
} from './src/config.js';
|
|
14
|
-
import { defineLotteryTables } from './src/db.js';
|
|
15
|
-
import { registerLotteryDb } from './src/db-store.js';
|
|
16
|
-
import { registerLotteryAgentDeps } from './src/lottery-agent-deps.js';
|
|
17
|
-
import { createInMemoryLotteryDb } from './src/memory-db.js';
|
|
18
|
-
import { lotteryRuntimeToken } from './src/runtime-state.js';
|
|
19
|
-
import { runLotteryPipeline } from './src/pipeline.js';
|
|
20
|
-
import { registerLotteryOutboundPush } from './src/push.js';
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Plugin Runtime:
|
|
24
|
-
* - DB: prefer databaseHostToken; else memory.
|
|
25
|
-
* - Push: OutboundHost + config.pushTargets (cron / publish).
|
|
26
|
-
* - Cron: scheduleHostToken daily pipeline.
|
|
27
|
-
*/
|
|
28
|
-
export default definePlugin<LotteryConfig>({
|
|
29
|
-
name: 'lottery',
|
|
30
|
-
metadata: {
|
|
31
|
-
displayName: 'Lottery',
|
|
32
|
-
},
|
|
33
|
-
async setup(context) {
|
|
34
|
-
const config = resolveLotteryConfig(context.config.get());
|
|
35
|
-
const db = context.resources.has(databaseHostToken)
|
|
36
|
-
? context.resources.use(databaseHostToken)
|
|
37
|
-
: createInMemoryLotteryDb();
|
|
38
|
-
if (context.resources.has(databaseHostToken)) {
|
|
39
|
-
defineLotteryTables(db);
|
|
40
|
-
}
|
|
41
|
-
context.resources.provide(lotteryRuntimeToken, { db });
|
|
42
|
-
context.lifecycle.add(registerLotteryDb(db));
|
|
43
|
-
|
|
44
|
-
let outboundPush: ((text: string) => Promise<void>) | null = null;
|
|
45
|
-
if (context.resources.has(outboundHostToken) && config.pushTargets.length > 0) {
|
|
46
|
-
const outbound = context.resources.use(outboundHostToken);
|
|
47
|
-
outboundPush = async (text) => {
|
|
48
|
-
for (const target of config.pushTargets) {
|
|
49
|
-
try {
|
|
50
|
-
await outbound.send({
|
|
51
|
-
adapter: target.adapter,
|
|
52
|
-
endpointId: target.endpointId || target.adapter,
|
|
53
|
-
channelType: target.channelType || 'private',
|
|
54
|
-
channelId: target.channelId,
|
|
55
|
-
content: text,
|
|
56
|
-
});
|
|
57
|
-
} catch {
|
|
58
|
-
// OutboundHost logs; continue remaining targets.
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
context.lifecycle.add(registerLotteryOutboundPush(outboundPush));
|
|
64
|
-
|
|
65
|
-
context.lifecycle.add(registerLotteryAgentDeps({
|
|
66
|
-
getDb: () => db,
|
|
67
|
-
getConfig: () => ({
|
|
68
|
-
pickCount: config.pickCount,
|
|
69
|
-
historyLimit: config.historyLimit,
|
|
70
|
-
kl8: lotteryKl8(config),
|
|
71
|
-
}),
|
|
72
|
-
enabledGames: () => lotteryEnabledGames(config),
|
|
73
|
-
scheduleCron: () => config.scheduleCron,
|
|
74
|
-
scheduleEnabled: () => config.scheduleEnabled,
|
|
75
|
-
pipelinePush: config.pushTargets.length > 0,
|
|
76
|
-
}));
|
|
77
|
-
|
|
78
|
-
// Agent tools (agent/tools/*): register into the Runtime Agent Host when AI
|
|
79
|
-
// is installed. Lazy import keeps @zhin.js/agent out of IM-only installs.
|
|
80
|
-
if (context.resources.has(agentToolsHostToken)) {
|
|
81
|
-
const agentTools = context.resources.use(agentToolsHostToken);
|
|
82
|
-
const { registerLotteryAgentTools } = await import('./agent/runtime-tools.js');
|
|
83
|
-
context.lifecycle.add(registerLotteryAgentTools(agentTools));
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (!context.resources.has(scheduleHostToken) || !config.scheduleEnabled) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
const schedule = context.resources.use(scheduleHostToken);
|
|
90
|
-
const dispose = schedule.register({
|
|
91
|
-
id: 'lottery/daily_pipeline',
|
|
92
|
-
cron: config.scheduleCron || '0 0 18 * * *',
|
|
93
|
-
description: 'Daily lottery pipeline',
|
|
94
|
-
async execute() {
|
|
95
|
-
await runLotteryPipeline({
|
|
96
|
-
getDb: () => db,
|
|
97
|
-
enabledGames: () => lotteryEnabledGames(config),
|
|
98
|
-
historyLimit: config.historyLimit,
|
|
99
|
-
pickCount: config.pickCount,
|
|
100
|
-
kl8: lotteryKl8(config),
|
|
101
|
-
backtest: {
|
|
102
|
-
enabled: config.backtestEnabled,
|
|
103
|
-
window: config.backtestWindow,
|
|
104
|
-
randomTrials: config.backtestRandomTrials,
|
|
105
|
-
minHistory: config.backtestMinHistory,
|
|
106
|
-
adaptive: config.backtestAdaptive,
|
|
107
|
-
},
|
|
108
|
-
weightPersist: config.weightPersistEnabled,
|
|
109
|
-
weightHoldoutFallback: config.weightHoldoutFallback,
|
|
110
|
-
}, { push: config.pushTargets.length > 0 });
|
|
111
|
-
},
|
|
112
|
-
});
|
|
113
|
-
context.lifecycle.add(dispose);
|
|
114
|
-
},
|
|
115
|
-
});
|