@colin999n9/gworld-agent 0.1.0-alpha.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.
Files changed (86) hide show
  1. package/README.md +127 -0
  2. package/dist/cli.d.ts +12 -0
  3. package/dist/cli.js +256 -0
  4. package/dist/cli.js.map +1 -0
  5. package/dist/client-installer.d.ts +20 -0
  6. package/dist/client-installer.js +48 -0
  7. package/dist/client-installer.js.map +1 -0
  8. package/dist/config.d.ts +37 -0
  9. package/dist/config.js +184 -0
  10. package/dist/config.js.map +1 -0
  11. package/dist/data/indexer-client.d.ts +34 -0
  12. package/dist/data/indexer-client.js +172 -0
  13. package/dist/data/indexer-client.js.map +1 -0
  14. package/dist/data/rpc-reader.d.ts +69 -0
  15. package/dist/data/rpc-reader.js +163 -0
  16. package/dist/data/rpc-reader.js.map +1 -0
  17. package/dist/domain.d.ts +204 -0
  18. package/dist/domain.js +2 -0
  19. package/dist/domain.js.map +1 -0
  20. package/dist/errors.d.ts +10 -0
  21. package/dist/errors.js +16 -0
  22. package/dist/errors.js.map +1 -0
  23. package/dist/factory.d.ts +4 -0
  24. package/dist/factory.js +25 -0
  25. package/dist/factory.js.map +1 -0
  26. package/dist/fs.d.ts +3 -0
  27. package/dist/fs.js +35 -0
  28. package/dist/fs.js.map +1 -0
  29. package/dist/generated/abis.d.ts +7446 -0
  30. package/dist/generated/abis.js +4861 -0
  31. package/dist/generated/abis.js.map +1 -0
  32. package/dist/generated/deployments.d.ts +145 -0
  33. package/dist/generated/deployments.js +150 -0
  34. package/dist/generated/deployments.js.map +1 -0
  35. package/dist/generated/protocol.d.ts +165 -0
  36. package/dist/generated/protocol.js +132 -0
  37. package/dist/generated/protocol.js.map +1 -0
  38. package/dist/geometry.d.ts +24 -0
  39. package/dist/geometry.js +31 -0
  40. package/dist/geometry.js.map +1 -0
  41. package/dist/json.d.ts +3 -0
  42. package/dist/json.js +14 -0
  43. package/dist/json.js.map +1 -0
  44. package/dist/mcp/server.d.ts +4 -0
  45. package/dist/mcp/server.js +134 -0
  46. package/dist/mcp/server.js.map +1 -0
  47. package/dist/mcp/stdio.d.ts +2 -0
  48. package/dist/mcp/stdio.js +23 -0
  49. package/dist/mcp/stdio.js.map +1 -0
  50. package/dist/runner/audit-store.d.ts +27 -0
  51. package/dist/runner/audit-store.js +61 -0
  52. package/dist/runner/audit-store.js.map +1 -0
  53. package/dist/runner/file-state.d.ts +7 -0
  54. package/dist/runner/file-state.js +23 -0
  55. package/dist/runner/file-state.js.map +1 -0
  56. package/dist/runner/legal-actions.d.ts +22 -0
  57. package/dist/runner/legal-actions.js +171 -0
  58. package/dist/runner/legal-actions.js.map +1 -0
  59. package/dist/runner/observation.d.ts +12 -0
  60. package/dist/runner/observation.js +47 -0
  61. package/dist/runner/observation.js.map +1 -0
  62. package/dist/runner/policy.d.ts +10 -0
  63. package/dist/runner/policy.js +68 -0
  64. package/dist/runner/policy.js.map +1 -0
  65. package/dist/runner/runtime.d.ts +73 -0
  66. package/dist/runner/runtime.js +236 -0
  67. package/dist/runner/runtime.js.map +1 -0
  68. package/dist/runner/strategy.d.ts +2 -0
  69. package/dist/runner/strategy.js +19 -0
  70. package/dist/runner/strategy.js.map +1 -0
  71. package/dist/runner/transaction-executor.d.ts +58 -0
  72. package/dist/runner/transaction-executor.js +114 -0
  73. package/dist/runner/transaction-executor.js.map +1 -0
  74. package/dist/runner/writer-lock.d.ts +14 -0
  75. package/dist/runner/writer-lock.js +81 -0
  76. package/dist/runner/writer-lock.js.map +1 -0
  77. package/dist/wallet/keystore.d.ts +18 -0
  78. package/dist/wallet/keystore.js +111 -0
  79. package/dist/wallet/keystore.js.map +1 -0
  80. package/dist/wallet/password-store.d.ts +27 -0
  81. package/dist/wallet/password-store.js +118 -0
  82. package/dist/wallet/password-store.js.map +1 -0
  83. package/package.json +41 -0
  84. package/skill/gworld/SKILL.md +58 -0
  85. package/skill/gworld/references/rules.md +33 -0
  86. package/skill/gworld/references/troubleshooting.md +22 -0
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@colin999n9/gworld-agent",
3
+ "version": "0.1.0-alpha.0",
4
+ "description": "Local-first GWorld Agent runner, MCP server, and Agent Skill",
5
+ "type": "module",
6
+ "license": "UNLICENSED",
7
+ "engines": {
8
+ "node": ">=22.13.0 <23 || >=24.0.0 <25"
9
+ },
10
+ "bin": {
11
+ "gworld-agent": "dist/cli.js",
12
+ "gworld-mcp": "dist/mcp/stdio.js"
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "skill",
17
+ "README.md"
18
+ ],
19
+ "scripts": {
20
+ "generate:contracts": "node ../scripts/generate-web-contracts.mjs",
21
+ "check:generated": "node ../scripts/generate-web-contracts.mjs --check",
22
+ "typecheck": "tsc --noEmit",
23
+ "build": "tsc -p tsconfig.build.json",
24
+ "test": "vitest run",
25
+ "test:watch": "vitest",
26
+ "test:e2e": "bash scripts/anvil-e2e.sh"
27
+ },
28
+ "dependencies": {
29
+ "@modelcontextprotocol/sdk": "1.29.0",
30
+ "viem": "2.55.2",
31
+ "zod": "4.4.3"
32
+ },
33
+ "devDependencies": {
34
+ "@types/node": "26.1.1",
35
+ "typescript": "7.0.2",
36
+ "vitest": "4.1.10"
37
+ },
38
+ "publishConfig": {
39
+ "access": "public"
40
+ }
41
+ }
@@ -0,0 +1,58 @@
1
+ ---
2
+ name: gworld
3
+ description: Operates a GWorld game Agent through the local policy-controlled Runner and MCP tools. Use when the user asks to join GWorld, inspect an Agent, play a turn, choose or execute game actions, manage the Runner, or review GWorld activity.
4
+ ---
5
+
6
+ # GWorld
7
+
8
+ Use the installed `gworld_*` MCP tools. The local Runner owns the wallet, validates policy, simulates transactions, signs, waits for receipts, and waits for the Indexer.
9
+
10
+ ## Non-negotiable safety
11
+
12
+ - Never ask for, read, paste, log, or return a private key, seed phrase, keystore password, raw transaction, or calldata.
13
+ - Wallet import/export is a user-only local CLI recovery operation. Never invoke it, request its output, or ask the user to paste exported material into chat.
14
+ - Never propose shell, wallet, or contract workarounds around Runner policy.
15
+ - Execute only an `actionId` returned by `gworld_get_legal_actions` in this session.
16
+ - Treat every `actionId` as short-lived and single-state. After any transaction or stale/expired error, discard it and observe again.
17
+ - Do not enable betting or raise spending/risk limits unless the user explicitly asks and understands the change.
18
+
19
+ ## Start or inspect
20
+
21
+ 1. Call `gworld_status`.
22
+ 2. If state is `not_joined`, explain that joining creates on-chain transactions, then call `gworld_join` when the user asked to join or play.
23
+ 3. If state is `pending`, call `gworld_join` to resume the spawn lifecycle.
24
+ 4. Call `gworld_get_policy`, then `gworld_observe` before recommending actions.
25
+ 5. If the Indexer is `lagging` or `rebuilding`, report it and avoid writes until a fresh observation is available.
26
+
27
+ ## Play one turn
28
+
29
+ 1. Call `gworld_get_legal_actions`.
30
+ 2. Choose only from the returned actions. Prefer actions that preserve AP, avoid G spending, and match the user's goal.
31
+ 3. Explain the chosen action, reason, maximum AP/G exposure, and risk.
32
+ 4. Call `gworld_simulate_action` before a manual action when consequences are material or the user asked for a preview.
33
+ 5. Call `gworld_execute_action` with only the selected `actionId`.
34
+ 6. Report the transaction hash, indexed block, and resulting state from a fresh `gworld_observe`.
35
+
36
+ For exact rules and action meanings, read [references/rules.md](references/rules.md).
37
+
38
+ ## Autonomous play
39
+
40
+ - Before `gworld_start`, show the effective policy and summarize its action, Agent, AP, G, transaction, and risk limits.
41
+ - Start only when the user asks for continuous/autonomous play.
42
+ - Use `gworld_pause` immediately when the user asks to stop, when repeated failures occur, or when the observed chain/Agent differs from the user's intent.
43
+ - Use `gworld_get_activity` to explain decisions and failures; do not infer transactions from chat history.
44
+
45
+ ## Policy changes
46
+
47
+ - Read the current policy first.
48
+ - Change only fields required by the user's stated intent; preserve all others.
49
+ - Decimal G values are base-unit strings, not human-formatted decimals.
50
+ - After `gworld_set_policy`, read the policy again and state the exact effective limits.
51
+
52
+ ## Recovery
53
+
54
+ - `action_stale`, `action_expired`, or `action_not_found`: observe, list legal actions again, and choose a new ID.
55
+ - `indexer_lagging`: wait for sync; do not resubmit a transaction merely because the Indexer has not caught up.
56
+ - `policy_denied`: explain the exact active limit; never bypass it.
57
+ - `wallet_locked`: tell the user to unlock/configure the local Runner outside chat. Never ask them to send credentials.
58
+ - For other failures, inspect `gworld_status` and `gworld_get_activity`, then follow [references/troubleshooting.md](references/troubleshooting.md).
@@ -0,0 +1,33 @@
1
+ # GWorld action guide
2
+
3
+ The Runner is the authority for whether an action is currently legal and what it costs. Never reconstruct contract calls from this document.
4
+
5
+ ## Agent lifecycle
6
+
7
+ - `gworld_join` creates an Agent when the wallet has none, waits for block-based randomness, spawns it, and persists the selected Agent ID.
8
+ - Re-running join resumes an incomplete lifecycle. Do not create a second Agent as a recovery step.
9
+
10
+ ## AP and world actions
11
+
12
+ - `checkin`: replenishes AP when the cooldown and faucet conditions permit it.
13
+ - `claim`: takes an activated, neutral, adjacent tile.
14
+ - `move`: follows a planned path from the expected current position and nonce. Owned/enemy tiles may add a toll.
15
+ - `attack`: challenges an adjacent enemy tile and is high risk by default.
16
+ - `reinforce`: spends AP to add defense to an owned tile.
17
+ - `continueFragmentResolution`: completes a pending world-fragment job that blocks other world actions.
18
+
19
+ AP costs returned by the Runner are capped base units. Compare them to both available AP and policy limits; do not convert them into a different unit unless the observation supplies that conversion.
20
+
21
+ ## Markets
22
+
23
+ - `requestMarket`, `finalizeMarket`, `settleMarket`, and `claimMarket` are permissionless maintenance actions when returned as legal.
24
+ - `bet` spends G and is disabled by the default policy. It requires explicit allowed actions and non-zero per-action and daily G limits.
25
+ - An execute result may contain an ERC-20 approval followed by a market transaction. The Runner restricts approval to the protocol escrow and exact required amount.
26
+
27
+ ## Risk selection
28
+
29
+ - Low: maintenance, check-in, claim, safe move, reinforce, fragment continuation.
30
+ - Medium: hostile/tolled move or G bet, depending on the returned ticket.
31
+ - High: attack.
32
+
33
+ Risk labels are inputs to policy, not guarantees of outcome. A simulation can validate execution conditions but cannot promise a strategic result when other transactions may change state first.
@@ -0,0 +1,22 @@
1
+ # GWorld troubleshooting
2
+
3
+ ## Safe diagnostic order
4
+
5
+ 1. Call `gworld_status` and confirm chain ID, wallet address, Agent ID, state, and sync.
6
+ 2. Call `gworld_get_activity` and locate the latest simulation, transaction, or error.
7
+ 3. Call `gworld_observe` only when status shows a usable Agent and Indexer.
8
+ 4. Re-plan with `gworld_get_legal_actions`; never retry an old action ID.
9
+
10
+ ## Common states
11
+
12
+ - `not_joined`: use `gworld_join` only when joining is intended.
13
+ - `pending`: call `gworld_join` to continue randomness/spawn processing.
14
+ - `paused`: manual observe and action execution remain available; call `gworld_start` only for autonomous play.
15
+ - `lagging` or `rebuilding`: wait for Indexer recovery. A confirmed receipt must not be blindly resubmitted.
16
+
17
+ ## Errors
18
+
19
+ - Wallet errors are resolved in the user's local terminal or system keychain. Do not request the secret in chat.
20
+ - Network/chain mismatch requires correcting the local profile. Do not suggest switching contract addresses through MCP.
21
+ - Ownership errors usually mean the profile wallet does not own the selected Agent. Confirm status and local profile rather than attempting another signer.
22
+ - Repeated loop failures: pause, inspect activity, fix the underlying sync/policy/network issue, then resume explicitly.