@zhin.js/plugin-lottery 1.0.2 → 1.0.3
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/agent/runtime-tools.ts +53 -0
- package/package.json +5 -5
- package/plugin.ts +10 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridge agent/tools/* authoring definitions into the Plugin Runtime Agent Host.
|
|
3
|
+
* Loaded lazily from plugin.ts only when agentToolsHostToken is present, so
|
|
4
|
+
* IM-only installs never pull @zhin.js/agent into the module graph.
|
|
5
|
+
* Lives outside src/ (like the other agent/ authoring files) and is therefore
|
|
6
|
+
* not part of the tsc build — the Plugin Runtime loads it from source.
|
|
7
|
+
*/
|
|
8
|
+
import type { AgentToolsHost } from '@zhin.js/plugin-runtime';
|
|
9
|
+
import syncTool from './tools/sync.js';
|
|
10
|
+
import computeRecommendTool from './tools/compute_recommend.js';
|
|
11
|
+
import historyTool from './tools/history.js';
|
|
12
|
+
import getModelStateTool from './tools/get_model_state.js';
|
|
13
|
+
import listPendingTool from './tools/list_pending.js';
|
|
14
|
+
import savePredictionTool from './tools/save_prediction.js';
|
|
15
|
+
import statsSnapshotTool from './tools/stats_snapshot.js';
|
|
16
|
+
|
|
17
|
+
interface AuthoringToolLike {
|
|
18
|
+
readonly description: string;
|
|
19
|
+
readonly inputSchema?: unknown;
|
|
20
|
+
readonly keywords?: readonly string[];
|
|
21
|
+
readonly tags?: readonly string[];
|
|
22
|
+
readonly permissions?: readonly string[];
|
|
23
|
+
readonly hidden?: boolean;
|
|
24
|
+
execute(input: never, ctx?: unknown): unknown | Promise<unknown>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const TOOLS: ReadonlyArray<readonly [string, AuthoringToolLike]> = [
|
|
28
|
+
['lottery_sync', syncTool as AuthoringToolLike],
|
|
29
|
+
['lottery_compute_recommend', computeRecommendTool as AuthoringToolLike],
|
|
30
|
+
['lottery_history', historyTool as AuthoringToolLike],
|
|
31
|
+
['lottery_get_model_state', getModelStateTool as AuthoringToolLike],
|
|
32
|
+
['lottery_list_pending', listPendingTool as AuthoringToolLike],
|
|
33
|
+
['lottery_save_prediction', savePredictionTool as AuthoringToolLike],
|
|
34
|
+
['lottery_stats_snapshot', statsSnapshotTool as AuthoringToolLike],
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
/** Register every lottery agent tool for this generation; returns disposal. */
|
|
38
|
+
export function registerLotteryAgentTools(host: AgentToolsHost): () => void {
|
|
39
|
+
const disposers = TOOLS.map(([name, tool]) => host.register({
|
|
40
|
+
name,
|
|
41
|
+
description: tool.description,
|
|
42
|
+
inputSchema: tool.inputSchema,
|
|
43
|
+
source: 'lottery',
|
|
44
|
+
...(tool.keywords ? { keywords: tool.keywords } : {}),
|
|
45
|
+
...(tool.tags ? { tags: tool.tags } : {}),
|
|
46
|
+
...(tool.permissions ? { permissions: tool.permissions } : {}),
|
|
47
|
+
...(tool.hidden !== undefined ? { hidden: tool.hidden } : {}),
|
|
48
|
+
execute: (input) => tool.execute(input as never, { pluginName: 'lottery', runtimeName: name }),
|
|
49
|
+
}));
|
|
50
|
+
return () => {
|
|
51
|
+
for (const dispose of disposers.splice(0)) dispose();
|
|
52
|
+
};
|
|
53
|
+
}
|
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.3",
|
|
4
4
|
"description": "Multi-game lottery analysis for Zhin.js (Plugin Runtime)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -41,18 +41,18 @@
|
|
|
41
41
|
},
|
|
42
42
|
"license": "MIT",
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@zhin.js/
|
|
45
|
-
"@zhin.js/
|
|
44
|
+
"@zhin.js/command": "1.0.2",
|
|
45
|
+
"@zhin.js/plugin-runtime": "1.1.0"
|
|
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.5"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"zod": "^4.0.0",
|
|
55
|
-
"@zhin.js/agent": "1.0.
|
|
55
|
+
"@zhin.js/agent": "1.0.5"
|
|
56
56
|
},
|
|
57
57
|
"peerDependenciesMeta": {
|
|
58
58
|
"@zhin.js/agent": {
|
package/plugin.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
definePlugin,
|
|
3
|
+
agentToolsHostToken,
|
|
3
4
|
databaseHostToken,
|
|
4
5
|
outboundHostToken,
|
|
5
6
|
scheduleHostToken,
|
|
@@ -29,7 +30,7 @@ export default definePlugin<LotteryConfig>({
|
|
|
29
30
|
metadata: {
|
|
30
31
|
displayName: 'Lottery',
|
|
31
32
|
},
|
|
32
|
-
setup(context) {
|
|
33
|
+
async setup(context) {
|
|
33
34
|
const config = resolveLotteryConfig(context.config.get());
|
|
34
35
|
const db = context.resources.has(databaseHostToken)
|
|
35
36
|
? context.resources.use(databaseHostToken)
|
|
@@ -74,6 +75,14 @@ export default definePlugin<LotteryConfig>({
|
|
|
74
75
|
pipelinePush: config.pushTargets.length > 0,
|
|
75
76
|
}));
|
|
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
|
+
|
|
77
86
|
if (!context.resources.has(scheduleHostToken) || !config.scheduleEnabled) {
|
|
78
87
|
return;
|
|
79
88
|
}
|