@troyaagent/game-plugin 0.0.0-stage → 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Troya Agent contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,55 @@
1
- # Temporary Holding Version
1
+ # @troyaagent/game-plugin
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [Troya](https://troya.codes) for Virtuals GAME agents (`@virtuals-protocol/game`, game-node): a worker with read-only
4
+ safety functions on **Robinhood Chain (chain 4663)**, in the same shape as the official game-node plugins. Tested on
5
+ `@virtuals-protocol/game` 0.1.14.
6
+
7
+ ```bash
8
+ npm i @troyaagent/game-plugin @virtuals-protocol/game
9
+ ```
10
+
11
+ ```js
12
+ import { GameAgent } from "@virtuals-protocol/game";
13
+ import TroyaPlugin from "@troyaagent/game-plugin";
14
+
15
+ const troya = new TroyaPlugin(); // { clientOptions: { apiKey?, baseUrl?, timeoutMs? } }
16
+ const agent = new GameAgent(process.env.GAME_API_KEY, {
17
+ name: "Robinhood Scout",
18
+ goal: "Find Robinhood Chain coins worth a look and never act on one that fails Troya Gate.",
19
+ description: "A careful on-chain scout.",
20
+ workers: [troya.getWorker()], // or getWorker({ functions: [troya.gateCheckFunction] })
21
+ });
22
+ await agent.init();
23
+ await agent.run(60, { verbose: true });
24
+ ```
25
+
26
+ ## Functions
27
+
28
+ GAME passes every argument as a string; numbers and booleans are read back. Each function finishes `done` with a
29
+ one-line summary plus `result: {…}` JSON as feedback, or `failed` with the reason (`BAD_INPUT`, `PAYMENT_REQUIRED`,
30
+ `RATE_LIMITED`, `TIMEOUT`, …).
31
+
32
+ | Function | Args | Feedback `result` |
33
+ |---|---|---|
34
+ | `troya_gate_check` | `token`, `amountEth?`, `from?`, `signed?` | `verdict` passed / caution / failed / untested, `reason`, `checks[]`, `quote`; signed adds the attestor signature and The Assay's flags |
35
+ | `troya_trident_check` | `to?`, `data?`, `value?`, `from?`, `typedData?` (JSON) | `verdict` allow / warn / block, `reasons[]`, `coins[]` |
36
+ | `troya_bridge_safety` | `from?`, `to?`, `amount?`, `token?`, `address?` | `routes[]` with score 0-100, band, red lines; `gate`; `storm` |
37
+ | `troya_agent_passport` | `address?` or `agentId?` | `standing`, `summary`, `stamps[]` with evidence, `warnings` |
38
+ | `troya_weak_spot` | `address` | `heel`, `severity`, `confidence`, `facts[]` |
39
+ | `troya_real_depth` | `token` | `depth` per venue at $100 / $1k / $10k, `volume` raw vs honest, `family` |
40
+
41
+ Getters: `gateCheckFunction`, `tridentCheckFunction`, `bridgeSafetyFunction`, `agentPassportFunction`,
42
+ `weakSpotFunction`, `realDepthFunction`, `functions` (all six).
43
+
44
+ ## Honest limits
45
+
46
+ - **Read only.** No function trades, bridges, signs or sends, and none needs a private key. Pair it with your own trading
47
+ worker and let that worker act only after `troya_gate_check` is not `failed`.
48
+ - **A verdict is a snapshot, not a safe stamp.** Check again right before acting; a bridge score explains a risk; a
49
+ passport says what a wallet did, never who runs it.
50
+ - Robinhood Chain (4663) only, except the other side of a bridge route.
51
+ - The GAME planner needs your own GAME API key; Troya needs none. Signed Gate checks without a Troya API key are limited
52
+ to a few a day per IP; paying for more (USDG credit or x402) happens outside this plugin.
53
+ - Feedback is cut at 3,500 characters so the planner stays focused.
54
+
55
+ MIT · https://troya.codes
package/package.json CHANGED
@@ -1,6 +1,25 @@
1
1
  {
2
2
  "name": "@troyaagent/game-plugin",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Virtuals GAME (game-node) plugin for Troya: a worker with read-only Robinhood Chain safety functions (Gate pre-trade check, Trident firewall, Scylla bridge safety, Bow agent passport, Heel weak spot, Sirens real depth). Never trades or signs.",
5
+ "type": "module",
6
+ "main": "./src/index.js",
7
+ "types": "./src/index.d.ts",
8
+ "exports": {
9
+ ".": { "types": "./src/index.d.ts", "import": "./src/index.js", "default": "./src/index.js" }
10
+ },
11
+ "files": ["src", "README.md", "LICENSE"],
12
+ "sideEffects": false,
13
+ "engines": { "node": ">=18" },
14
+ "dependencies": {
15
+ "@troyaagent/sdk": "^0.1.0"
16
+ },
17
+ "peerDependencies": {
18
+ "@virtuals-protocol/game": ">=0.1.14 <1"
19
+ },
20
+ "keywords": ["virtuals", "game", "game-node", "virtuals-protocol", "plugin", "troya", "robinhood-chain", "ai-agent", "token-safety"],
21
+ "homepage": "https://troya.codes",
22
+ "repository": { "type": "git", "url": "https://troya.codes" },
23
+ "bugs": { "url": "https://troya.codes" },
24
+ "license": "MIT"
25
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,32 @@
1
+ import { GameWorker, GameFunction } from "@virtuals-protocol/game";
2
+ import type { TroyaClient, TroyaClientOptions, TroyaToolKey } from "@troyaagent/sdk";
3
+
4
+ export interface TroyaPluginOptions {
5
+ id?: string;
6
+ name?: string;
7
+ description?: string;
8
+ client?: TroyaClient;
9
+ clientOptions?: TroyaClientOptions;
10
+ }
11
+
12
+ export declare class TroyaPlugin {
13
+ constructor(options?: TroyaPluginOptions);
14
+ readonly id: string;
15
+ readonly name: string;
16
+ readonly description: string;
17
+ readonly client: TroyaClient;
18
+ makeFunction(key: TroyaToolKey): GameFunction<any>;
19
+ get gateCheckFunction(): GameFunction<any>;
20
+ get tridentCheckFunction(): GameFunction<any>;
21
+ get bridgeSafetyFunction(): GameFunction<any>;
22
+ get agentPassportFunction(): GameFunction<any>;
23
+ get weakSpotFunction(): GameFunction<any>;
24
+ get realDepthFunction(): GameFunction<any>;
25
+ get functions(): GameFunction<any>[];
26
+ getWorker(data?: { functions?: GameFunction<any>[]; getEnvironment?: () => Promise<Record<string, any>> }): GameWorker;
27
+ }
28
+
29
+ export declare const FUNCTION_NAMES: readonly (
30
+ | "troya_gate_check" | "troya_trident_check" | "troya_bridge_safety" | "troya_agent_passport" | "troya_weak_spot" | "troya_real_depth"
31
+ )[];
32
+ export default TroyaPlugin;
package/src/index.js ADDED
@@ -0,0 +1,72 @@
1
+ // @troyaagent/game-plugin: Troya's read-only checks for Robinhood Chain (4663) as Virtuals GAME functions and a worker,
2
+ // in the shape of the official game-node plugins (a class with one getter per GameFunction and getWorker()).
3
+ // GAME hands every argument over as a string; the shared tool layer turns numbers and booleans back.
4
+ // Read only: no function trades, signs or sends anything, and none needs a private key.
5
+ import { GameWorker, GameFunction, ExecutableGameFunctionResponse, ExecutableGameFunctionStatus } from "@virtuals-protocol/game";
6
+ import { createTroyaClient, runTool, TOOLS, toolByKey } from "@troyaagent/sdk";
7
+
8
+ const MAX_FEEDBACK = 3500; // keep the feedback the GAME planner reads short enough to stay useful
9
+
10
+ const HINTS = {
11
+ gate_check: "Call before buying or recommending any Robinhood Chain coin. Use the coin's 0x address, not its ticker.",
12
+ trident_check: "Call before signing any Robinhood Chain transaction or EIP-712 signature request.",
13
+ bridge_safety: "Call before moving ETH between Robinhood Chain and Base, Arbitrum or Ethereum.",
14
+ agent_passport: "Call before trusting another agent's calls or paying it.",
15
+ weak_spot: "Call to learn the single biggest risk of a coin, dev wallet or agent.",
16
+ real_depth: "Call to learn whether a coin's liquidity and volume are real before sizing a trade.",
17
+ };
18
+
19
+ export class TroyaPlugin {
20
+ /**
21
+ * options: id, name, description (of the worker), client (a ready @troyaagent/sdk client) or clientOptions
22
+ * (apiKey, baseUrl, timeoutMs, fetch).
23
+ */
24
+ constructor(options = {}) {
25
+ this.id = options.id || "troya_worker";
26
+ this.name = options.name || "Troya Worker";
27
+ this.description = options.description || "Checks Robinhood Chain (chain 4663) coins, transactions, bridge routes and other agents with Troya (https://troya.codes) before the agent acts: Gate pre-trade check, Trident transaction firewall, Scylla bridge safety, Bow agent passport, Heel weak spot and Sirens real depth. Read only: it never trades or signs.";
28
+ this.client = options.client || createTroyaClient(options.clientOptions || {});
29
+ }
30
+
31
+ /** Build one GameFunction for a Troya tool key. */
32
+ makeFunction(key) {
33
+ const tool = toolByKey(key);
34
+ if (!tool) throw new Error(`Unknown Troya tool ${key}`);
35
+ return new GameFunction({
36
+ name: `troya_${tool.key}`,
37
+ description: tool.description,
38
+ hint: HINTS[tool.key],
39
+ args: Object.entries(tool.params).map(([name, p]) => ({ name, description: p.description, type: p.type, optional: !p.required })),
40
+ executable: async (args, logger) => {
41
+ logger?.(`${tool.title}: ${JSON.stringify(args).slice(0, 200)}`);
42
+ const r = await runTool(this.client, tool.key, args || {});
43
+ let feedback = r.ok ? `${r.text}\nresult: ${JSON.stringify(r.data)}` : r.text;
44
+ if (feedback.length > MAX_FEEDBACK) feedback = feedback.slice(0, MAX_FEEDBACK) + "… (cut)";
45
+ return new ExecutableGameFunctionResponse(r.ok ? ExecutableGameFunctionStatus.Done : ExecutableGameFunctionStatus.Failed, feedback);
46
+ },
47
+ });
48
+ }
49
+
50
+ get gateCheckFunction() { return this.makeFunction("gate_check"); }
51
+ get tridentCheckFunction() { return this.makeFunction("trident_check"); }
52
+ get bridgeSafetyFunction() { return this.makeFunction("bridge_safety"); }
53
+ get agentPassportFunction() { return this.makeFunction("agent_passport"); }
54
+ get weakSpotFunction() { return this.makeFunction("weak_spot"); }
55
+ get realDepthFunction() { return this.makeFunction("real_depth"); }
56
+ /** Every Troya function. */
57
+ get functions() { return TOOLS.map((t) => this.makeFunction(t.key)); }
58
+
59
+ /** A GameWorker with every Troya function (or the ones you pass) for a GameAgent's workers list. */
60
+ getWorker(data = {}) {
61
+ return new GameWorker({
62
+ id: this.id,
63
+ name: this.name,
64
+ description: this.description,
65
+ functions: data.functions || this.functions,
66
+ getEnvironment: data.getEnvironment || (async () => ({ troya: this.client.baseUrl, chain: "Robinhood Chain (4663)", readOnly: true })),
67
+ });
68
+ }
69
+ }
70
+
71
+ export const FUNCTION_NAMES = TOOLS.map((t) => `troya_${t.key}`);
72
+ export default TroyaPlugin;