@zhin.js/plugin-lottery 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -5
- package/lib/agent/agent.d.ts +0 -3
- package/lib/agent/agent.d.ts.map +0 -1
- package/lib/agent/prompts.d.ts +0 -11
- package/lib/agent/prompts.d.ts.map +0 -1
- package/lib/agent/prompts.js +0 -11
- package/lib/agent/prompts.js.map +0 -1
- package/lib/agent/read-skills.d.ts +0 -3
- package/lib/agent/read-skills.d.ts.map +0 -1
- package/lib/agent/read-skills.js +0 -25
- package/lib/agent/read-skills.js.map +0 -1
- package/lib/agent/run-turn.d.ts +0 -14
- package/lib/agent/run-turn.d.ts.map +0 -1
- package/lib/agent/run-turn.js +0 -47
- package/lib/agent/run-turn.js.map +0 -1
- package/lib/agent/schedules/daily_pipeline.d.ts +0 -3
- package/lib/agent/schedules/daily_pipeline.d.ts.map +0 -1
- package/lib/agent/tools/compute_recommend.d.ts +0 -5
- package/lib/agent/tools/compute_recommend.d.ts.map +0 -1
- package/lib/agent/tools/get_model_state.d.ts +0 -5
- package/lib/agent/tools/get_model_state.d.ts.map +0 -1
- package/lib/agent/tools/history.d.ts +0 -6
- package/lib/agent/tools/history.d.ts.map +0 -1
- package/lib/agent/tools/list_pending.d.ts +0 -5
- package/lib/agent/tools/list_pending.d.ts.map +0 -1
- package/lib/agent/tools/save_prediction.d.ts +0 -6
- package/lib/agent/tools/save_prediction.d.ts.map +0 -1
- package/lib/agent/tools/stats_snapshot.d.ts +0 -5
- package/lib/agent/tools/stats_snapshot.d.ts.map +0 -1
- package/lib/agent/tools/sync.d.ts +0 -5
- package/lib/agent/tools/sync.d.ts.map +0 -1
- package/lib/db.d.ts +0 -33
- package/lib/db.d.ts.map +0 -1
- package/lib/db.js +0 -108
- package/lib/db.js.map +0 -1
- package/lib/evals/pipeline_smoke.eval.d.ts +0 -3
- package/lib/evals/pipeline_smoke.eval.d.ts.map +0 -1
- package/lib/evaluate/adaptive-sim.d.ts +0 -31
- package/lib/evaluate/adaptive-sim.d.ts.map +0 -1
- package/lib/evaluate/adaptive-sim.js +0 -155
- package/lib/evaluate/adaptive-sim.js.map +0 -1
- package/lib/evaluate/backtest.d.ts +0 -29
- package/lib/evaluate/backtest.d.ts.map +0 -1
- package/lib/evaluate/backtest.js +0 -87
- package/lib/evaluate/backtest.js.map +0 -1
- package/lib/evaluate/hit-rate.d.ts +0 -8
- package/lib/evaluate/hit-rate.d.ts.map +0 -1
- package/lib/evaluate/hit-rate.js +0 -120
- package/lib/evaluate/hit-rate.js.map +0 -1
- package/lib/evaluate/review-pending.d.ts +0 -13
- package/lib/evaluate/review-pending.d.ts.map +0 -1
- package/lib/evaluate/review-pending.js +0 -89
- package/lib/evaluate/review-pending.js.map +0 -1
- package/lib/evaluate/tracker.d.ts +0 -28
- package/lib/evaluate/tracker.d.ts.map +0 -1
- package/lib/evaluate/tracker.js +0 -265
- package/lib/evaluate/tracker.js.map +0 -1
- package/lib/evaluate/train-weights.d.ts +0 -28
- package/lib/evaluate/train-weights.d.ts.map +0 -1
- package/lib/evaluate/train-weights.js +0 -101
- package/lib/evaluate/train-weights.js.map +0 -1
- package/lib/evaluate/weight-guard.d.ts +0 -15
- package/lib/evaluate/weight-guard.d.ts.map +0 -1
- package/lib/evaluate/weight-guard.js +0 -46
- package/lib/evaluate/weight-guard.js.map +0 -1
- package/lib/games/kl8-groups.d.ts +0 -31
- package/lib/games/kl8-groups.d.ts.map +0 -1
- package/lib/games/kl8-groups.js +0 -62
- package/lib/games/kl8-groups.js.map +0 -1
- package/lib/games/registry.d.ts +0 -13
- package/lib/games/registry.d.ts.map +0 -1
- package/lib/games/registry.js +0 -45
- package/lib/games/registry.js.map +0 -1
- package/lib/index.d.ts +0 -3
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -215
- package/lib/index.js.map +0 -1
- package/lib/pipeline.d.ts +0 -36
- package/lib/pipeline.d.ts.map +0 -1
- package/lib/pipeline.js +0 -130
- package/lib/pipeline.js.map +0 -1
- package/lib/push.d.ts +0 -3
- package/lib/push.d.ts.map +0 -1
- package/lib/push.js +0 -31
- package/lib/push.js.map +0 -1
- package/lib/recommend/game-pick.d.ts +0 -14
- package/lib/recommend/game-pick.d.ts.map +0 -1
- package/lib/recommend/game-pick.js +0 -169
- package/lib/recommend/game-pick.js.map +0 -1
- package/lib/recommend/report.d.ts +0 -22
- package/lib/recommend/report.d.ts.map +0 -1
- package/lib/recommend/report.js +0 -173
- package/lib/recommend/report.js.map +0 -1
- package/lib/src/agent/prompts.d.ts +0 -11
- package/lib/src/agent/prompts.d.ts.map +0 -1
- package/lib/src/agent/read-skills.d.ts +0 -3
- package/lib/src/agent/read-skills.d.ts.map +0 -1
- package/lib/src/agent/run-turn.d.ts +0 -14
- package/lib/src/agent/run-turn.d.ts.map +0 -1
- package/lib/src/db.d.ts +0 -33
- package/lib/src/db.d.ts.map +0 -1
- package/lib/src/evaluate/adaptive-sim.d.ts +0 -31
- package/lib/src/evaluate/adaptive-sim.d.ts.map +0 -1
- package/lib/src/evaluate/backtest.d.ts +0 -29
- package/lib/src/evaluate/backtest.d.ts.map +0 -1
- package/lib/src/evaluate/hit-rate.d.ts +0 -8
- package/lib/src/evaluate/hit-rate.d.ts.map +0 -1
- package/lib/src/evaluate/review-pending.d.ts +0 -13
- package/lib/src/evaluate/review-pending.d.ts.map +0 -1
- package/lib/src/evaluate/tracker.d.ts +0 -28
- package/lib/src/evaluate/tracker.d.ts.map +0 -1
- package/lib/src/evaluate/train-weights.d.ts +0 -28
- package/lib/src/evaluate/train-weights.d.ts.map +0 -1
- package/lib/src/evaluate/weight-guard.d.ts +0 -15
- package/lib/src/evaluate/weight-guard.d.ts.map +0 -1
- package/lib/src/games/kl8-groups.d.ts +0 -31
- package/lib/src/games/kl8-groups.d.ts.map +0 -1
- package/lib/src/games/registry.d.ts +0 -13
- package/lib/src/games/registry.d.ts.map +0 -1
- package/lib/src/index.d.ts +0 -3
- package/lib/src/index.d.ts.map +0 -1
- package/lib/src/lottery-agent-deps.d.ts +0 -24
- package/lib/src/lottery-agent-deps.d.ts.map +0 -1
- package/lib/src/lottery-tool-handlers.d.ts +0 -17
- package/lib/src/lottery-tool-handlers.d.ts.map +0 -1
- package/lib/src/pipeline.d.ts +0 -36
- package/lib/src/pipeline.d.ts.map +0 -1
- package/lib/src/push.d.ts +0 -3
- package/lib/src/push.d.ts.map +0 -1
- package/lib/src/recommend/game-pick.d.ts +0 -14
- package/lib/src/recommend/game-pick.d.ts.map +0 -1
- package/lib/src/recommend/report.d.ts +0 -22
- package/lib/src/recommend/report.d.ts.map +0 -1
- package/lib/src/stats/engine.d.ts +0 -18
- package/lib/src/stats/engine.d.ts.map +0 -1
- package/lib/src/stats/pro-analysis.d.ts +0 -7
- package/lib/src/stats/pro-analysis.d.ts.map +0 -1
- package/lib/src/stats/weights.d.ts +0 -8
- package/lib/src/stats/weights.d.ts.map +0 -1
- package/lib/src/sync/fetch-official.d.ts +0 -4
- package/lib/src/sync/fetch-official.d.ts.map +0 -1
- package/lib/src/sync/run-sync.d.ts +0 -8
- package/lib/src/sync/run-sync.d.ts.map +0 -1
- package/lib/src/tools/agent-tools.d.ts +0 -15
- package/lib/src/tools/agent-tools.d.ts.map +0 -1
- package/lib/src/tools/agent-tools.js +0 -211
- package/lib/src/tools/agent-tools.js.map +0 -1
- package/lib/src/types.d.ts +0 -84
- package/lib/src/types.d.ts.map +0 -1
- package/lib/stats/engine.d.ts +0 -18
- package/lib/stats/engine.d.ts.map +0 -1
- package/lib/stats/engine.js +0 -122
- package/lib/stats/engine.js.map +0 -1
- package/lib/stats/pro-analysis.d.ts +0 -7
- package/lib/stats/pro-analysis.d.ts.map +0 -1
- package/lib/stats/pro-analysis.js +0 -121
- package/lib/stats/pro-analysis.js.map +0 -1
- package/lib/stats/weights.d.ts +0 -8
- package/lib/stats/weights.d.ts.map +0 -1
- package/lib/stats/weights.js +0 -25
- package/lib/stats/weights.js.map +0 -1
- package/lib/sync/fetch-official.d.ts +0 -4
- package/lib/sync/fetch-official.d.ts.map +0 -1
- package/lib/sync/fetch-official.js +0 -160
- package/lib/sync/fetch-official.js.map +0 -1
- package/lib/sync/run-sync.d.ts +0 -8
- package/lib/sync/run-sync.d.ts.map +0 -1
- package/lib/sync/run-sync.js +0 -29
- package/lib/sync/run-sync.js.map +0 -1
- package/lib/tools/agent-tools.d.ts +0 -15
- package/lib/tools/agent-tools.d.ts.map +0 -1
- package/lib/tools/agent-tools.js +0 -211
- package/lib/tools/agent-tools.js.map +0 -1
- package/lib/tsconfig.tsbuildinfo +0 -1
- package/lib/types.d.ts +0 -84
- package/lib/types.d.ts.map +0 -1
- package/lib/types.js +0 -3
- package/lib/types.js.map +0 -1
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.1",
|
|
4
4
|
"description": "Multi-game lottery analysis for Zhin.js — KL8, SSQ, DLT, FC3D, PL3, PL5 with stats, cron sync, and daily recommendations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -40,13 +40,13 @@
|
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"typescript": "^6.0.3",
|
|
42
42
|
"zod": "^4.4.3",
|
|
43
|
-
"zhin.js": "4.1.
|
|
44
|
-
"@zhin.js/agent": "1.0.
|
|
43
|
+
"zhin.js": "4.1.2",
|
|
44
|
+
"@zhin.js/agent": "1.0.3"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"zod": "^4.0.0",
|
|
48
|
-
"zhin.js": "4.1.
|
|
49
|
-
"@zhin.js/agent": "1.0.
|
|
48
|
+
"zhin.js": "4.1.2",
|
|
49
|
+
"@zhin.js/agent": "1.0.3"
|
|
50
50
|
},
|
|
51
51
|
"peerDependenciesMeta": {
|
|
52
52
|
"@zhin.js/agent": {
|
package/lib/agent/agent.d.ts
DELETED
package/lib/agent/agent.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../agent/agent.ts"],"names":[],"mappings":";AAEA,wBAGG"}
|
package/lib/agent/prompts.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { GameId } from '../types.js';
|
|
2
|
-
export type LotteryAgentTask = 'daily_pipeline';
|
|
3
|
-
export interface LotteryAgentContext {
|
|
4
|
-
syncSummary?: string;
|
|
5
|
-
newDrawsSummary?: string;
|
|
6
|
-
games?: GameId[];
|
|
7
|
-
push?: boolean;
|
|
8
|
-
}
|
|
9
|
-
/** Prompt when agent is invoked interactively (cron uses code pipeline). */
|
|
10
|
-
export declare function buildDailyPipelinePrompt(ctx: LotteryAgentContext): string;
|
|
11
|
-
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/agent/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,CAAC;AAEhD,MAAM,WAAW,mBAAmB;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,4EAA4E;AAC5E,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,mBAAmB,GAAG,MAAM,CAQzE"}
|
package/lib/agent/prompts.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/** Prompt when agent is invoked interactively (cron uses code pipeline). */
|
|
2
|
-
export function buildDailyPipelinePrompt(ctx) {
|
|
3
|
-
const games = (ctx.games ?? []).join(', ') || 'kl8, ssq, dlt, fc3d, pl3, pl5';
|
|
4
|
-
return [
|
|
5
|
-
'[lottery daily_pipeline]',
|
|
6
|
-
`games: ${games}`,
|
|
7
|
-
'Steps: lottery_sync → review pending (skip if empty) → lottery_compute_recommend → lottery_publish_report',
|
|
8
|
-
ctx.push ? 'push: true' : 'push: false',
|
|
9
|
-
].join('\n');
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=prompts.js.map
|
package/lib/agent/prompts.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/agent/prompts.ts"],"names":[],"mappings":"AAWA,4EAA4E;AAC5E,MAAM,UAAU,wBAAwB,CAAC,GAAwB;IAC/D,MAAM,KAAK,GAAG,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,+BAA+B,CAAC;IAC9E,OAAO;QACL,0BAA0B;QAC1B,UAAU,KAAK,EAAE;QACjB,2GAA2G;QAC3G,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,aAAa;KACxC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"read-skills.d.ts","sourceRoot":"","sources":["../../src/agent/read-skills.ts"],"names":[],"mappings":"AAMA,wBAAgB,iBAAiB,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAS5D;AAED,wBAAgB,6BAA6B,IAAI,MAAM,CAStD"}
|
package/lib/agent/read-skills.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { fileURLToPath } from 'node:url';
|
|
4
|
-
const PLUGIN_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..');
|
|
5
|
-
export function readSkillMarkdown(...parts) {
|
|
6
|
-
const chunks = [];
|
|
7
|
-
for (const p of parts) {
|
|
8
|
-
const full = path.join(PLUGIN_ROOT, 'skills', p, 'SKILL.md');
|
|
9
|
-
if (fs.existsSync(full)) {
|
|
10
|
-
chunks.push(fs.readFileSync(full, 'utf8'));
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
return chunks.join('\n\n---\n\n');
|
|
14
|
-
}
|
|
15
|
-
export function buildLotteryAgentSystemPrompt() {
|
|
16
|
-
const skills = readSkillMarkdown('lottery');
|
|
17
|
-
return [
|
|
18
|
-
'你是 Zhin 彩票分析 Agent。数据通过 lottery_* 工具查库,算法流程见 skills。',
|
|
19
|
-
'可用 web_search 检索公开分析资料;推荐号码只能来自 lottery_compute_recommend,不得臆造或篡改。',
|
|
20
|
-
'每次任务结束应将洞察写入 lottery_save_memory,形成可累积的专业记忆。',
|
|
21
|
-
'',
|
|
22
|
-
skills || '(skills 未加载,请依赖工具返回的统计数据。)',
|
|
23
|
-
].join('\n');
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=read-skills.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"read-skills.js","sourceRoot":"","sources":["../../src/agent/read-skills.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;AAExF,MAAM,UAAU,iBAAiB,CAAC,GAAG,KAAe;IAClD,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC;QAC7D,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACxB,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,6BAA6B;IAC3C,MAAM,MAAM,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAC;IAC5C,OAAO;QACL,sDAAsD;QACtD,oEAAoE;QACpE,8CAA8C;QAC9C,EAAE;QACF,MAAM,IAAI,4BAA4B;KACvC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
package/lib/agent/run-turn.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Plugin } from 'zhin.js';
|
|
2
|
-
import type { LotteryAgentContext, LotteryAgentTask } from './prompts.js';
|
|
3
|
-
export interface RunLotteryAgentOptions {
|
|
4
|
-
task: LotteryAgentTask;
|
|
5
|
-
context?: LotteryAgentContext;
|
|
6
|
-
gameId?: string;
|
|
7
|
-
maxIterations?: number;
|
|
8
|
-
}
|
|
9
|
-
export declare function runLotteryAgentTurn(root: Plugin, options: RunLotteryAgentOptions): Promise<{
|
|
10
|
-
ok: boolean;
|
|
11
|
-
text: string;
|
|
12
|
-
usedAgent: boolean;
|
|
13
|
-
}>;
|
|
14
|
-
//# sourceMappingURL=run-turn.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run-turn.d.ts","sourceRoot":"","sources":["../../src/agent/run-turn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEtC,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAqB1E,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,gBAAgB,CAAC;IACvB,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAiBD,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC,CA2B5D"}
|
package/lib/agent/run-turn.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { buildDailyPipelinePrompt } from './prompts.js';
|
|
2
|
-
import { buildLotteryAgentSystemPrompt } from './read-skills.js';
|
|
3
|
-
const LOTTERY_TOOL_PREFIX = 'lottery_';
|
|
4
|
-
async function resolveLotteryTools(root) {
|
|
5
|
-
const toolService = root.inject('tool');
|
|
6
|
-
const raw = (toolService?.getAll() ?? []).filter((t) => t.name.startsWith(LOTTERY_TOOL_PREFIX));
|
|
7
|
-
try {
|
|
8
|
-
const agent = await import('zhin.js/agent');
|
|
9
|
-
const normalizeTool = agent.normalizeTool;
|
|
10
|
-
if (typeof normalizeTool === 'function') {
|
|
11
|
-
return raw.map((t) => normalizeTool(t));
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
catch {
|
|
15
|
-
/* agent optional */
|
|
16
|
-
}
|
|
17
|
-
return raw;
|
|
18
|
-
}
|
|
19
|
-
export async function runLotteryAgentTurn(root, options) {
|
|
20
|
-
const ai = root.inject('ai');
|
|
21
|
-
if (!ai?.runAgent)
|
|
22
|
-
return { ok: false, text: '', usedAgent: false };
|
|
23
|
-
const providers = ai.listProviders?.() ?? [];
|
|
24
|
-
if (!providers.length && ai.isReady?.() === false) {
|
|
25
|
-
return { ok: false, text: '', usedAgent: false };
|
|
26
|
-
}
|
|
27
|
-
const userPrompt = buildDailyPipelinePrompt(options.context ?? {});
|
|
28
|
-
const lotteryTools = await resolveLotteryTools(root);
|
|
29
|
-
try {
|
|
30
|
-
const result = await ai.runAgent(userPrompt, {
|
|
31
|
-
systemPrompt: buildLotteryAgentSystemPrompt(),
|
|
32
|
-
tools: lotteryTools,
|
|
33
|
-
useBuiltinTools: true,
|
|
34
|
-
collectExternalTools: false,
|
|
35
|
-
maxIterations: options.maxIterations ?? 14,
|
|
36
|
-
});
|
|
37
|
-
return { ok: true, text: result.content?.trim() ?? '', usedAgent: true };
|
|
38
|
-
}
|
|
39
|
-
catch (e) {
|
|
40
|
-
return {
|
|
41
|
-
ok: false,
|
|
42
|
-
text: e instanceof Error ? e.message : String(e),
|
|
43
|
-
usedAgent: true,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
//# sourceMappingURL=run-turn.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run-turn.js","sourceRoot":"","sources":["../../src/agent/run-turn.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,6BAA6B,EAAE,MAAM,kBAAkB,CAAC;AAEjE,MAAM,mBAAmB,GAAG,UAAU,CAAC;AAwBvC,KAAK,UAAU,mBAAmB,CAAC,IAAY;IAC7C,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAyC,CAAC;IAChF,MAAM,GAAG,GAAG,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,CAAC,CAAC;IAChG,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,CAAC;QAC5C,MAAM,aAAa,GAAI,KAAkD,CAAC,aAAa,CAAC;Q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,EAAE,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAC3E,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO;YACL,EAAE,EAAE,KAAK;YACT,IAAI,EAAE,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;YAChD,SAAS,EAAE,IAAI;SAChB,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"daily_pipeline.d.ts","sourceRoot":"","sources":["../../../agent/schedules/daily_pipeline.ts"],"names":[],"mappings":";AAKA,wBA4BG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compute_recommend.d.ts","sourceRoot":"","sources":["../../../agent/tools/compute_recommend.ts"],"names":[],"mappings":";UAIkC,MAAM;;AAAxC,wBAMG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get_model_state.d.ts","sourceRoot":"","sources":["../../../agent/tools/get_model_state.ts"],"names":[],"mappings":";WAImC,MAAM;;AAAzC,wBAMG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../../agent/tools/history.ts"],"names":[],"mappings":";UAMkC,MAAM;YAAU,MAAM;;AAAxD,wBAeG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"list_pending.d.ts","sourceRoot":"","sources":["../../../agent/tools/list_pending.ts"],"names":[],"mappings":";WAImC,MAAM;;AAAzC,wBAMG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"save_prediction.d.ts","sourceRoot":"","sources":["../../../agent/tools/save_prediction.ts"],"names":[],"mappings":";UAIkC,MAAM;kBAAgB,MAAM;;AAA9D,wBASG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stats_snapshot.d.ts","sourceRoot":"","sources":["../../../agent/tools/stats_snapshot.ts"],"names":[],"mappings":";UAIkC,MAAM;;AAAxC,wBAMG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../agent/tools/sync.ts"],"names":[],"mappings":";WAMmC,MAAM;;AAAzC,wBAWG"}
|
package/lib/db.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { GameId, NormalizedDraw } from './types.js';
|
|
2
|
-
export declare const DRAWS_TABLE = "lottery_draws";
|
|
3
|
-
export declare const REPORTS_TABLE = "lottery_daily_reports";
|
|
4
|
-
export interface LotteryDb {
|
|
5
|
-
models: {
|
|
6
|
-
get: (name: string) => LotteryModel | undefined;
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
export interface LotteryModel {
|
|
10
|
-
select: () => {
|
|
11
|
-
where: (q: Record<string, unknown>) => Promise<unknown[]>;
|
|
12
|
-
};
|
|
13
|
-
insert: (row: Record<string, unknown>) => Promise<unknown>;
|
|
14
|
-
delete: () => {
|
|
15
|
-
where: (q: Record<string, unknown>) => Promise<unknown>;
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
export declare function defineLotteryTables(db: {
|
|
19
|
-
define: (name: string, schema: Record<string, unknown>) => void;
|
|
20
|
-
}): void;
|
|
21
|
-
export declare function upsertDraws(db: LotteryDb, draws: NormalizedDraw[]): Promise<{
|
|
22
|
-
count: number;
|
|
23
|
-
inserted: NormalizedDraw[];
|
|
24
|
-
}>;
|
|
25
|
-
export declare function trimHistory(db: LotteryDb, gameId: GameId, limit: number): Promise<void>;
|
|
26
|
-
export declare function parseStoredJson<T>(value: unknown, fallback: T): T;
|
|
27
|
-
export declare function loadDraws(db: LotteryDb, gameId: GameId, limit: number): Promise<NormalizedDraw[]>;
|
|
28
|
-
export declare function fetchGameDraws(gameId: GameId, count: number): Promise<NormalizedDraw[]>;
|
|
29
|
-
export declare function syncGame(db: LotteryDb, gameId: GameId, historyLimit: number): Promise<{
|
|
30
|
-
count: number;
|
|
31
|
-
inserted: NormalizedDraw[];
|
|
32
|
-
}>;
|
|
33
|
-
//# sourceMappingURL=db.d.ts.map
|
package/lib/db.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../src/db.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,MAAM,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAKtE,eAAO,MAAM,WAAW,kBAAkB,CAAC;AAC3C,eAAO,MAAM,aAAa,0BAA0B,CAAC;AAErD,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE;QACN,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,YAAY,GAAG,SAAS,CAAC;KACjD,CAAC;CACH;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM;QACZ,KAAK,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;KAC3D,CAAC;IACF,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3D,MAAM,EAAE,MAAM;QAAE,KAAK,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;KAAE,CAAC;CAC3E;AAED,wBAAgB,mBAAmB,CAAC,EAAE,EAAE;IAAE,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAA;CAAE,GAAG,IAAI,CAiBjH;AAED,wBAAsB,WAAW,CAAC,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,cAAc,EAAE,CAAA;CAAE,CAAC,CAuBhI;AAED,wBAAsB,WAAW,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAQ7F;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,CAWjE;AAED,wBAAsB,SAAS,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAoBvG;AAED,wBAAsB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAS7F;AAED,wBAAsB,QAAQ,CAC5B,EAAE,EAAE,SAAS,EACb,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,cAAc,EAAE,CAAA;CAAE,CAAC,CAKxD"}
|
package/lib/db.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { getGameMeta } from './games/registry.js';
|
|
2
|
-
import { fetchFucaiDraws, fetchTicaiDraws } from './sync/fetch-official.js';
|
|
3
|
-
import { defineEvalTables } from './evaluate/tracker.js';
|
|
4
|
-
export const DRAWS_TABLE = 'lottery_draws';
|
|
5
|
-
export const REPORTS_TABLE = 'lottery_daily_reports';
|
|
6
|
-
export function defineLotteryTables(db) {
|
|
7
|
-
db.define(DRAWS_TABLE, {
|
|
8
|
-
game_id: { type: 'text', nullable: false },
|
|
9
|
-
issue: { type: 'text', nullable: false },
|
|
10
|
-
draw_time: { type: 'text', default: '' },
|
|
11
|
-
numbers: { type: 'text', default: '{}' },
|
|
12
|
-
source: { type: 'text', default: '' },
|
|
13
|
-
raw_json: { type: 'text', default: '' },
|
|
14
|
-
synced_at: { type: 'text', default: '' },
|
|
15
|
-
});
|
|
16
|
-
db.define(REPORTS_TABLE, {
|
|
17
|
-
date: { type: 'text', nullable: false },
|
|
18
|
-
report_json: { type: 'text', default: '{}' },
|
|
19
|
-
ai_explanation: { type: 'text', default: '' },
|
|
20
|
-
created_at: { type: 'text', default: '' },
|
|
21
|
-
});
|
|
22
|
-
defineEvalTables(db);
|
|
23
|
-
}
|
|
24
|
-
export async function upsertDraws(db, draws) {
|
|
25
|
-
const model = db.models.get(DRAWS_TABLE);
|
|
26
|
-
if (!model)
|
|
27
|
-
return { count: 0, inserted: [] };
|
|
28
|
-
let inserted = 0;
|
|
29
|
-
const insertedDraws = [];
|
|
30
|
-
const now = new Date().toISOString();
|
|
31
|
-
for (const d of draws) {
|
|
32
|
-
if (!d.issue)
|
|
33
|
-
continue;
|
|
34
|
-
const existing = (await model.select().where({ game_id: d.gameId, issue: d.issue }));
|
|
35
|
-
if (existing.length > 0)
|
|
36
|
-
continue;
|
|
37
|
-
await model.insert({
|
|
38
|
-
game_id: d.gameId,
|
|
39
|
-
issue: d.issue,
|
|
40
|
-
draw_time: d.drawTime,
|
|
41
|
-
numbers: JSON.stringify(d.numbers),
|
|
42
|
-
source: d.source,
|
|
43
|
-
raw_json: JSON.stringify(d),
|
|
44
|
-
synced_at: now,
|
|
45
|
-
});
|
|
46
|
-
inserted++;
|
|
47
|
-
insertedDraws.push(d);
|
|
48
|
-
}
|
|
49
|
-
return { count: inserted, inserted: insertedDraws };
|
|
50
|
-
}
|
|
51
|
-
export async function trimHistory(db, gameId, limit) {
|
|
52
|
-
const model = db.models.get(DRAWS_TABLE);
|
|
53
|
-
if (!model || limit <= 0)
|
|
54
|
-
return;
|
|
55
|
-
const rows = (await model.select().where({ game_id: gameId }));
|
|
56
|
-
const sorted = [...rows].sort((a, b) => b.issue.localeCompare(a.issue));
|
|
57
|
-
for (const row of sorted.slice(limit)) {
|
|
58
|
-
await model.delete().where({ game_id: gameId, issue: row.issue });
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
export function parseStoredJson(value, fallback) {
|
|
62
|
-
if (value == null || value === '')
|
|
63
|
-
return fallback;
|
|
64
|
-
if (typeof value === 'object')
|
|
65
|
-
return value;
|
|
66
|
-
if (typeof value === 'string') {
|
|
67
|
-
try {
|
|
68
|
-
return JSON.parse(value);
|
|
69
|
-
}
|
|
70
|
-
catch {
|
|
71
|
-
return fallback;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return fallback;
|
|
75
|
-
}
|
|
76
|
-
export async function loadDraws(db, gameId, limit) {
|
|
77
|
-
const model = db.models.get(DRAWS_TABLE);
|
|
78
|
-
if (!model)
|
|
79
|
-
return [];
|
|
80
|
-
const rows = (await model.select().where({ game_id: gameId }));
|
|
81
|
-
return [...rows]
|
|
82
|
-
.sort((a, b) => b.issue.localeCompare(a.issue))
|
|
83
|
-
.slice(0, limit)
|
|
84
|
-
.map((r) => ({
|
|
85
|
-
gameId: r.game_id,
|
|
86
|
-
issue: r.issue,
|
|
87
|
-
drawTime: r.draw_time,
|
|
88
|
-
numbers: parseStoredJson(r.numbers, {}),
|
|
89
|
-
source: r.source,
|
|
90
|
-
}));
|
|
91
|
-
}
|
|
92
|
-
export async function fetchGameDraws(gameId, count) {
|
|
93
|
-
const meta = getGameMeta(gameId);
|
|
94
|
-
if (meta.source === 'fucai' && meta.fucaiName) {
|
|
95
|
-
return fetchFucaiDraws(meta.fucaiName, count);
|
|
96
|
-
}
|
|
97
|
-
if (meta.source === 'ticai' && meta.ticaiGameNo) {
|
|
98
|
-
return fetchTicaiDraws(meta.ticaiGameNo, count);
|
|
99
|
-
}
|
|
100
|
-
return [];
|
|
101
|
-
}
|
|
102
|
-
export async function syncGame(db, gameId, historyLimit) {
|
|
103
|
-
const draws = await fetchGameDraws(gameId, Math.max(historyLimit, 100));
|
|
104
|
-
const { count, inserted } = await upsertDraws(db, draws);
|
|
105
|
-
await trimHistory(db, gameId, historyLimit);
|
|
106
|
-
return { count, inserted };
|
|
107
|
-
}
|
|
108
|
-
//# sourceMappingURL=db.js.map
|
package/lib/db.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"db.js","sourceRoot":"","sources":["../src/db.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,MAAM,CAAC,MAAM,WAAW,GAAG,eAAe,CAAC;AAC3C,MAAM,CAAC,MAAM,aAAa,GAAG,uBAAuB,CAAC;AAgBrD,MAAM,UAAU,mBAAmB,CAAC,EAAuE;IACzG,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE;QACrB,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE;QAC1C,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE;QACxC,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE;QACxC,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE;QACxC,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE;QACrC,QAAQ,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE;QACvC,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE;KACzC,CAAC,CAAC;IACH,EAAE,CAAC,MAAM,CAAC,aAAa,EAAE;QACvB,IAAI,EAAE,EA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I,CAAC,MAAM,KAAK,OAAO,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;QAC9C,OAAO,eAAe,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAChD,CAAC;IACD,IAAI,IAAI,CAAC,MAAM,KAAK,OAAO,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;QAChD,OAAO,eAAe,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,EAAa,EACb,MAAc,EACd,YAAoB;IAEpB,MAAM,KAAK,GAAG,MAAM,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC,CAAC;IACxE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,MAAM,WAAW,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IACzD,MAAM,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;IAC5C,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AAC7B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline_smoke.eval.d.ts","sourceRoot":"","sources":["../../evals/pipeline_smoke.eval.ts"],"names":[],"mappings":";AAEA,wBAKG"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { DrawNumbers, GameId, NormalizedDraw, ScoreWeights } from '../types.js';
|
|
2
|
-
export interface SimulationOptions {
|
|
3
|
-
pickCount: number;
|
|
4
|
-
minHistory: number;
|
|
5
|
-
randomTrials: number;
|
|
6
|
-
initialWeights?: ScoreWeights;
|
|
7
|
-
adaptive?: boolean;
|
|
8
|
-
/** Score only the last N periods; omit to score every training step. */
|
|
9
|
-
scoreWindow?: number;
|
|
10
|
-
}
|
|
11
|
-
export interface SimulationResult {
|
|
12
|
-
gameId: GameId;
|
|
13
|
-
periods: number;
|
|
14
|
-
warmupPeriods: number;
|
|
15
|
-
adaptiveAvgHitRate: number;
|
|
16
|
-
fixedAvgHitRate: number;
|
|
17
|
-
randomAvgHitRate: number;
|
|
18
|
-
adaptiveVsRandom: number;
|
|
19
|
-
adaptiveVsFixed: number;
|
|
20
|
-
initialWeights: ScoreWeights;
|
|
21
|
-
finalWeights: ScoreWeights;
|
|
22
|
-
firstScoredIssue: string;
|
|
23
|
-
lastScoredIssue: string;
|
|
24
|
-
}
|
|
25
|
-
export declare function randomDrawNumbers(gameId: GameId, pickCount: number, rng: () => number): DrawNumbers;
|
|
26
|
-
/**
|
|
27
|
-
* Walk-forward core: for each issue after minHistory, predict → score → tune weights.
|
|
28
|
-
* Training uses scoreWindow omitted (every step counts); backtest uses scoreWindow.
|
|
29
|
-
*/
|
|
30
|
-
export declare function runAdaptiveSimulation(chronological: NormalizedDraw[], gameId: GameId, options: SimulationOptions): SimulationResult | null;
|
|
31
|
-
//# sourceMappingURL=adaptive-sim.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adaptive-sim.d.ts","sourceRoot":"","sources":["../../src/evaluate/adaptive-sim.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAY,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAK/F,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,wEAAwE;IACxE,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,YAAY,CAAC;IAC7B,YAAY,EAAE,YAAY,CAAC;IAC3B,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;CACzB;AAqCD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,MAAM,GAAG,WAAW,CAgBnG;AAkCD;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,cAAc,EAAE,EAC/B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,iBAAiB,GACzB,gBAAgB,GAAG,IAAI,CAoFzB"}
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_WEIGHTS } from '../types.js';
|
|
2
|
-
import { comparePickToDraw, tuneWeightsFromDraw } from './hit-rate.js';
|
|
3
|
-
import { recommendGame } from '../recommend/game-pick.js';
|
|
4
|
-
const EMPTY_STATS = {
|
|
5
|
-
gameId: 'kl8',
|
|
6
|
-
sampleSize: 0,
|
|
7
|
-
hot: [],
|
|
8
|
-
cold: [],
|
|
9
|
-
detail: '',
|
|
10
|
-
};
|
|
11
|
-
function createRng(seed) {
|
|
12
|
-
let s = seed | 0;
|
|
13
|
-
return () => {
|
|
14
|
-
s = (s + 0x6d2b79f5) | 0;
|
|
15
|
-
let t = Math.imul(s ^ (s >>> 15), 1 | s);
|
|
16
|
-
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
|
|
17
|
-
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
function pickUnique(rng, min, max, count) {
|
|
21
|
-
const pool = [];
|
|
22
|
-
for (let i = min; i <= max; i++)
|
|
23
|
-
pool.push(i);
|
|
24
|
-
const out = [];
|
|
25
|
-
for (let i = 0; i < count && pool.length; i++) {
|
|
26
|
-
const idx = Math.floor(rng() * pool.length);
|
|
27
|
-
out.push(pool.splice(idx, 1)[0]);
|
|
28
|
-
}
|
|
29
|
-
return out.sort((a, b) => a - b);
|
|
30
|
-
}
|
|
31
|
-
function pickDigits(rng, len) {
|
|
32
|
-
const out = [];
|
|
33
|
-
for (let i = 0; i < len; i++)
|
|
34
|
-
out.push(Math.floor(rng() * 10));
|
|
35
|
-
return out;
|
|
36
|
-
}
|
|
37
|
-
export function randomDrawNumbers(gameId, pickCount, rng) {
|
|
38
|
-
switch (gameId) {
|
|
39
|
-
case 'kl8':
|
|
40
|
-
return { main: pickUnique(rng, 1, 80, Math.min(10, Math.max(1, pickCount))) };
|
|
41
|
-
case 'ssq':
|
|
42
|
-
return { red: pickUnique(rng, 1, 33, 6), blue: pickUnique(rng, 1, 16, 1) };
|
|
43
|
-
case 'dlt':
|
|
44
|
-
return { front: pickUnique(rng, 1, 35, 5), back: pickUnique(rng, 1, 12, 2) };
|
|
45
|
-
case 'fc3d':
|
|
46
|
-
case 'pl3':
|
|
47
|
-
return { digits: pickDigits(rng, 3) };
|
|
48
|
-
case 'pl5':
|
|
49
|
-
return { digits: pickDigits(rng, 5) };
|
|
50
|
-
default:
|
|
51
|
-
return {};
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
function asPick(gameId, numbers) {
|
|
55
|
-
return {
|
|
56
|
-
gameId,
|
|
57
|
-
label: gameId,
|
|
58
|
-
numbers,
|
|
59
|
-
weights: DEFAULT_WEIGHTS,
|
|
60
|
-
stats: { ...EMPTY_STATS, gameId },
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
function stableIssueSeed(issue) {
|
|
64
|
-
let h = 0;
|
|
65
|
-
for (let i = 0; i < issue.length; i++)
|
|
66
|
-
h = (h * 31 + issue.charCodeAt(i)) >>> 0;
|
|
67
|
-
return h;
|
|
68
|
-
}
|
|
69
|
-
function randomRateForPeriod(gameId, pickCount, actual, randomTrials) {
|
|
70
|
-
let periodRandom = 0;
|
|
71
|
-
const baseSeed = stableIssueSeed(actual.issue);
|
|
72
|
-
for (let t = 0; t < randomTrials; t++) {
|
|
73
|
-
const rng = createRng(baseSeed + t);
|
|
74
|
-
const rnd = randomDrawNumbers(gameId, pickCount, rng);
|
|
75
|
-
periodRandom += comparePickToDraw(asPick(gameId, rnd), actual).rate;
|
|
76
|
-
}
|
|
77
|
-
return periodRandom / randomTrials;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Walk-forward core: for each issue after minHistory, predict → score → tune weights.
|
|
81
|
-
* Training uses scoreWindow omitted (every step counts); backtest uses scoreWindow.
|
|
82
|
-
*/
|
|
83
|
-
export function runAdaptiveSimulation(chronological, gameId, options) {
|
|
84
|
-
if (chronological.length <= options.minHistory)
|
|
85
|
-
return null;
|
|
86
|
-
const trainable = chronological.length - options.minHistory;
|
|
87
|
-
const testCount = options.scoreWindow
|
|
88
|
-
? Math.min(options.scoreWindow, trainable)
|
|
89
|
-
: trainable;
|
|
90
|
-
if (testCount <= 0)
|
|
91
|
-
return null;
|
|
92
|
-
const testStartIdx = options.scoreWindow
|
|
93
|
-
? chronological.length - testCount
|
|
94
|
-
: options.minHistory;
|
|
95
|
-
const useAdaptive = options.adaptive !== false;
|
|
96
|
-
const initialWeights = options.initialWeights
|
|
97
|
-
? { ...options.initialWeights }
|
|
98
|
-
: { ...DEFAULT_WEIGHTS };
|
|
99
|
-
let adaptiveWeights = { ...initialWeights };
|
|
100
|
-
let adaptiveSum = 0;
|
|
101
|
-
let fixedSum = 0;
|
|
102
|
-
let randomSum = 0;
|
|
103
|
-
let scored = 0;
|
|
104
|
-
let firstScoredIssue = '';
|
|
105
|
-
let lastScoredIssue = '';
|
|
106
|
-
for (let idx = options.minHistory; idx < chronological.length; idx++) {
|
|
107
|
-
const actual = chronological[idx];
|
|
108
|
-
const history = chronological.slice(0, idx).reverse();
|
|
109
|
-
const tieSeed = `sim:${actual.issue}`;
|
|
110
|
-
const fixedPick = recommendGame(gameId, history, {
|
|
111
|
-
pickCount: options.pickCount,
|
|
112
|
-
tieSeed,
|
|
113
|
-
weights: DEFAULT_WEIGHTS,
|
|
114
|
-
});
|
|
115
|
-
const adaptivePick = useAdaptive
|
|
116
|
-
? recommendGame(gameId, history, {
|
|
117
|
-
pickCount: options.pickCount,
|
|
118
|
-
tieSeed,
|
|
119
|
-
weights: adaptiveWeights,
|
|
120
|
-
})
|
|
121
|
-
: fixedPick;
|
|
122
|
-
if (idx >= testStartIdx) {
|
|
123
|
-
if (!firstScoredIssue)
|
|
124
|
-
firstScoredIssue = actual.issue;
|
|
125
|
-
lastScoredIssue = actual.issue;
|
|
126
|
-
fixedSum += comparePickToDraw(fixedPick, actual).rate;
|
|
127
|
-
adaptiveSum += comparePickToDraw(adaptivePick, actual).rate;
|
|
128
|
-
randomSum += randomRateForPeriod(gameId, options.pickCount, actual, options.randomTrials);
|
|
129
|
-
scored++;
|
|
130
|
-
}
|
|
131
|
-
if (useAdaptive) {
|
|
132
|
-
adaptiveWeights = tuneWeightsFromDraw(adaptiveWeights, adaptivePick.numbers, actual.numbers, gameId, history);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
if (!scored)
|
|
136
|
-
return null;
|
|
137
|
-
const adaptiveAvg = adaptiveSum / scored;
|
|
138
|
-
const fixedAvg = fixedSum / scored;
|
|
139
|
-
const randomAvg = randomSum / scored;
|
|
140
|
-
return {
|
|
141
|
-
gameId,
|
|
142
|
-
periods: scored,
|
|
143
|
-
warmupPeriods: testStartIdx - options.minHistory,
|
|
144
|
-
adaptiveAvgHitRate: adaptiveAvg,
|
|
145
|
-
fixedAvgHitRate: fixedAvg,
|
|
146
|
-
randomAvgHitRate: randomAvg,
|
|
147
|
-
adaptiveVsRandom: adaptiveAvg - randomAvg,
|
|
148
|
-
adaptiveVsFixed: adaptiveAvg - fixedAvg,
|
|
149
|
-
initialWeights,
|
|
150
|
-
finalWeights: adaptiveWeights,
|
|
151
|
-
firstScoredIssue,
|
|
152
|
-
lastScoredIssue,
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
//# sourceMappingURL=adaptive-sim.js.map
|