@agent-play/cli 3.0.1 → 3.2.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 (23) hide show
  1. package/README.md +76 -2
  2. package/dist/.root +1 -0
  3. package/dist/README.md +91 -0
  4. package/dist/cli.js +968 -184
  5. package/package.json +11 -5
  6. package/templates/agent-starter/langchain/.env.example +6 -0
  7. package/templates/agent-starter/langchain/README.md +24 -0
  8. package/templates/agent-starter/langchain/package.json +25 -0
  9. package/templates/agent-starter/langchain/src/bare-server.ts +12 -0
  10. package/templates/agent-starter/langchain/src/builtins/definitions.ts +66 -0
  11. package/templates/agent-starter/langchain/src/builtins/toolkits/starter-tools.ts +84 -0
  12. package/templates/agent-starter/langchain/src/express-server.ts +27 -0
  13. package/templates/agent-starter/langchain/src/index.ts +6 -0
  14. package/templates/agent-starter/langchain/src/load-env.ts +5 -0
  15. package/templates/agent-starter/langchain/src/register/register-builtins.ts +62 -0
  16. package/templates/agent-starter/langchain/src/register-agents.ts +1 -0
  17. package/templates/agent-starter/langchain/src/tool-handlers/assist-brainstorm.ts +8 -0
  18. package/templates/agent-starter/langchain/src/tool-handlers/assist-calculate-coefficient.ts +35 -0
  19. package/templates/agent-starter/langchain/src/tool-handlers/assist-collect-scene-details.ts +32 -0
  20. package/templates/agent-starter/langchain/src/tool-handlers/chat-tool.ts +6 -0
  21. package/templates/agent-starter/langchain/src/tool-handlers/execute-tool-capability.ts +12 -0
  22. package/templates/agent-starter/langchain/src/tool-handlers/tool-capability-registry.ts +49 -0
  23. package/templates/agent-starter/langchain/tsconfig.json +13 -0
package/README.md CHANGED
@@ -1,11 +1,13 @@
1
1
  # @agent-play/cli
2
2
 
3
- Command-line tool for **Agent Play**: sign in to the web app, create account API keys, and register agents (up to two per account) when the server uses a Redis-backed repository.
3
+ Command-line tool for **Agent Play**: create a **main developer node** (platform signup), add **agent nodes**, **validate** those identities against the server, and manage agent registrations. The server must use a **Redis**-backed agent repository (`REDIS_URL` on the server).
4
+
5
+ Authentication uses **`x-node-id`** and **`x-node-passw`** on every request **except** main-node creation, which sends hashed passphrase material in the JSON body to **`POST /api/nodes**.
4
6
 
5
7
  ## Documentation
6
8
 
7
9
  - **[Repository](https://github.com/wilforlan/agent-play)**
8
- - **[CLI guide](https://github.com/wilforlan/agent-play/blob/main/docs/cli.md)** — `login`, `create-key`, `create`, `delete`
10
+ - **[CLI guide](https://github.com/wilforlan/agent-play/blob/main/docs/cli.md)** — full **Node setup** and **Node validation** sections
9
11
  - **[API reference](https://wilforlan.github.io/agent-play/)** — TypeDoc
10
12
 
11
13
  ## Install
@@ -15,3 +17,75 @@ npm install -g @agent-play/cli
15
17
  ```
16
18
 
17
19
  Binary name: **`agent-play`**.
20
+
21
+ Default server URL: **`http://127.0.0.1:3000`**, or override with **`AGENT_PLAY_SERVER_URL`**.
22
+
23
+ Root key for derivation: **`--root-file`**, **`AGENT_PLAY_ROOT_FILE_PATH`**, or a **`.root`** file under **`~/.agent-play/`** or the current working directory (must match the server’s `.root`).
24
+
25
+ ## Node setup
26
+
27
+ 1. **Server:** Redis (`REDIS_URL`) and a deployed web UI/API the CLI can reach (`AGENT_PLAY_SERVER_URL`).
28
+ 2. **Local `.root`:** Must match the server genesis root key (see resolution order above).
29
+ 3. **`create-main-node`** (`bootstrap-node`): prompts for server URL, generates a passphrase, registers **`POST /api/nodes`**, writes **`~/.agent-play/credentials.json`** with **`serverUrl`**, **`nodeId`**, and the human passphrase.
30
+ 4. **`create-agent-node`**: derives an agent node under your main node, **`POST /api/nodes/agent-node`**, appends to **`credentials.json` → `agentNodes`**.
31
+ 5. **`inspect-node`**, **`list-agent-nodes`**, **`delete-*`**, **`clear-node-credentials`**: inspect or tear down registrations; see **`docs/cli.md`** for the full table.
32
+
33
+ > **@deprecated** **`POST /api/agents`** does not create agent **node** identity. Use **`POST /api/nodes/agent-node`**, then attach runtime data with **`world.addPlayer`**.
34
+
35
+ ## Node validation
36
+
37
+ - **`validate-main-node`** — calls **`POST /api/nodes/validate`** for your main node id (uses **`credentials.json`** + **`.root`**).
38
+ - **`validate-agent-node --all`** — validates every id in **`credentials.json` → `agentNodes`** (includes **`mainNodeId`** in the validate body).
39
+ - **`validate-agent-node --agent-node-ids id1,id2`** — same for explicit ids.
40
+
41
+ For Redis-direct checks (ops/CI), use **`node-tools`** script **`scripts/validate-node-derivative.mjs`**; details in **`docs/cli.md`** and **`docs/notes/node-id-v1-migration.md`**.
42
+
43
+ ## Commands
44
+
45
+ | Command | Aliases | What it does |
46
+ |--------|---------|----------------|
47
+ | **`create-main-node`** | `bootstrap-node` | Sign up a **main** node: **`POST /api/nodes`** (no node headers), save **`~/.agent-play/credentials.json`**. Optional **`--root-file`**. |
48
+ | **`inspect-node`** | — | **GET /api/nodes** — genesis id, main node, **agent node ids** (`create-agent-node`), and **runtime** agent rows (SDK metadata) if present. |
49
+ | **`create-agent-node`** | `create` | **POST /api/nodes/agent-node** — new agent node under your main node. |
50
+ | **`list-agent-nodes`** | `list` | **GET /api/agents** — lists registered agents. |
51
+ | **`delete-agent-node`** | `delete`, `remove` | **DELETE /api/agents** — optional **`[agent-id]`**; if omitted, prompts. |
52
+ | **`delete-main-node`** | — | **DELETE /api/nodes** — confirm by typing main node id; cascades. |
53
+ | **`validate-main-node`** | — | **POST /api/nodes/validate** for main node id. |
54
+ | **`validate-agent-node`** | — | **`--all`** or **`--agent-node-ids id1,id2,...`** — validate agent node ids. |
55
+ | **`initialize`** | `init` | Interactive scaffold for a starter agent codebase, optional node bootstrap, asks for agent count (1-2), and writes env-variable node ids into `.env` when bootstrapped. |
56
+ | **`clear-node-credentials`** | — | Removes **`~/.agent-play/credentials.json`**. |
57
+
58
+ ## Genesis and main node
59
+
60
+ Every **main node id** is derived from passphrase material and the platform **root key** (the **genesis** identity). **`inspect-node`** and **`create-main-node`** output should agree with **`.root`** when both sides use the same key.
61
+
62
+ Node kinds: **`root` → `main` → `agent`**. Root has no passphrase; main and agent persist hashed material server-side.
63
+
64
+ ## Usage examples
65
+
66
+ ```bash
67
+ npx agent-play create-main-node
68
+ npx agent-play validate-main-node
69
+ npx agent-play inspect-node
70
+ npx agent-play create-agent-node
71
+ npx agent-play validate-agent-node --all
72
+ npx agent-play initialize
73
+ npx agent-play list-agent-nodes
74
+ npx agent-play delete-agent-node
75
+ npx agent-play delete-agent-node <agent-uuid>
76
+ npx agent-play delete-main-node
77
+ npx agent-play clear-node-credentials
78
+ ```
79
+
80
+ For SDK usage after bootstrap, use **`RemotePlayWorld`** and register players with **`mainNodeId`** and **`agentId`** from the CLI output.
81
+
82
+ ## Initialize quick start
83
+
84
+ - `npx agent-play initialize` (or `npx agent-play init`) scaffolds starter files.
85
+ - The flow asks whether to create nodes now and how many agent nodes to provision (max `2`).
86
+ - If bootstrap is selected, it writes:
87
+ - `AGENT_PLAY_MAIN_NODE_ID`
88
+ - `AGENT_PLAY_AGENT_NODE_ID_1`
89
+ - `AGENT_PLAY_AGENT_NODE_ID_2` (when requested)
90
+ into generated `.env`.
91
+ - Generated code references these env vars directly (no hardcoded ids).
package/dist/.root ADDED
@@ -0,0 +1 @@
1
+ 87b6637b010478e48a83a8d445041ae4df5d607df7932153cdfee5c601e8e39e
package/dist/README.md ADDED
@@ -0,0 +1,91 @@
1
+ # @agent-play/cli
2
+
3
+ Command-line tool for **Agent Play**: create a **main developer node** (platform signup), add **agent nodes**, **validate** those identities against the server, and manage agent registrations. The server must use a **Redis**-backed agent repository (`REDIS_URL` on the server).
4
+
5
+ Authentication uses **`x-node-id`** and **`x-node-passw`** on every request **except** main-node creation, which sends hashed passphrase material in the JSON body to **`POST /api/nodes**.
6
+
7
+ ## Documentation
8
+
9
+ - **[Repository](https://github.com/wilforlan/agent-play)**
10
+ - **[CLI guide](https://github.com/wilforlan/agent-play/blob/main/docs/cli.md)** — full **Node setup** and **Node validation** sections
11
+ - **[API reference](https://wilforlan.github.io/agent-play/)** — TypeDoc
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ npm install -g @agent-play/cli
17
+ ```
18
+
19
+ Binary name: **`agent-play`**.
20
+
21
+ Default server URL: **`http://127.0.0.1:3000`**, or override with **`AGENT_PLAY_SERVER_URL`**.
22
+
23
+ Root key for derivation: **`--root-file`**, **`AGENT_PLAY_ROOT_FILE_PATH`**, or a **`.root`** file under **`~/.agent-play/`** or the current working directory (must match the server’s `.root`).
24
+
25
+ ## Node setup
26
+
27
+ 1. **Server:** Redis (`REDIS_URL`) and a deployed web UI/API the CLI can reach (`AGENT_PLAY_SERVER_URL`).
28
+ 2. **Local `.root`:** Must match the server genesis root key (see resolution order above).
29
+ 3. **`create-main-node`** (`bootstrap-node`): prompts for server URL, generates a passphrase, registers **`POST /api/nodes`**, writes **`~/.agent-play/credentials.json`** with **`serverUrl`**, **`nodeId`**, and the human passphrase.
30
+ 4. **`create-agent-node`**: derives an agent node under your main node, **`POST /api/nodes/agent-node`**, appends to **`credentials.json` → `agentNodes`**.
31
+ 5. **`inspect-node`**, **`list-agent-nodes`**, **`delete-*`**, **`clear-node-credentials`**: inspect or tear down registrations; see **`docs/cli.md`** for the full table.
32
+
33
+ > **@deprecated** **`POST /api/agents`** does not create agent **node** identity. Use **`POST /api/nodes/agent-node`**, then attach runtime data with **`world.addPlayer`**.
34
+
35
+ ## Node validation
36
+
37
+ - **`validate-main-node`** — calls **`POST /api/nodes/validate`** for your main node id (uses **`credentials.json`** + **`.root`**).
38
+ - **`validate-agent-node --all`** — validates every id in **`credentials.json` → `agentNodes`** (includes **`mainNodeId`** in the validate body).
39
+ - **`validate-agent-node --agent-node-ids id1,id2`** — same for explicit ids.
40
+
41
+ For Redis-direct checks (ops/CI), use **`node-tools`** script **`scripts/validate-node-derivative.mjs`**; details in **`docs/cli.md`** and **`docs/notes/node-id-v1-migration.md`**.
42
+
43
+ ## Commands
44
+
45
+ | Command | Aliases | What it does |
46
+ |--------|---------|----------------|
47
+ | **`create-main-node`** | `bootstrap-node` | Sign up a **main** node: **`POST /api/nodes`** (no node headers), save **`~/.agent-play/credentials.json`**. Optional **`--root-file`**. |
48
+ | **`inspect-node`** | — | **GET /api/nodes** — genesis id, main node, **agent node ids** (`create-agent-node`), and **runtime** agent rows (SDK metadata) if present. |
49
+ | **`create-agent-node`** | `create` | **POST /api/nodes/agent-node** — new agent node under your main node. |
50
+ | **`list-agent-nodes`** | `list` | **GET /api/agents** — lists registered agents. |
51
+ | **`delete-agent-node`** | `delete`, `remove` | **DELETE /api/agents** — optional **`[agent-id]`**; if omitted, prompts. |
52
+ | **`delete-main-node`** | — | **DELETE /api/nodes** — confirm by typing main node id; cascades. |
53
+ | **`validate-main-node`** | — | **POST /api/nodes/validate** for main node id. |
54
+ | **`validate-agent-node`** | — | **`--all`** or **`--agent-node-ids id1,id2,...`** — validate agent node ids. |
55
+ | **`initialize`** | `init` | Interactive scaffold for a starter agent codebase, optional node bootstrap, asks for agent count (1-2), and writes env-variable node ids into `.env` when bootstrapped. |
56
+ | **`clear-node-credentials`** | — | Removes **`~/.agent-play/credentials.json`**. |
57
+
58
+ ## Genesis and main node
59
+
60
+ Every **main node id** is derived from passphrase material and the platform **root key** (the **genesis** identity). **`inspect-node`** and **`create-main-node`** output should agree with **`.root`** when both sides use the same key.
61
+
62
+ Node kinds: **`root` → `main` → `agent`**. Root has no passphrase; main and agent persist hashed material server-side.
63
+
64
+ ## Usage examples
65
+
66
+ ```bash
67
+ npx agent-play create-main-node
68
+ npx agent-play validate-main-node
69
+ npx agent-play inspect-node
70
+ npx agent-play create-agent-node
71
+ npx agent-play validate-agent-node --all
72
+ npx agent-play initialize
73
+ npx agent-play list-agent-nodes
74
+ npx agent-play delete-agent-node
75
+ npx agent-play delete-agent-node <agent-uuid>
76
+ npx agent-play delete-main-node
77
+ npx agent-play clear-node-credentials
78
+ ```
79
+
80
+ For SDK usage after bootstrap, use **`RemotePlayWorld`** and register players with **`mainNodeId`** and **`agentId`** from the CLI output.
81
+
82
+ ## Initialize quick start
83
+
84
+ - `npx agent-play initialize` (or `npx agent-play init`) scaffolds starter files.
85
+ - The flow asks whether to create nodes now and how many agent nodes to provision (max `2`).
86
+ - If bootstrap is selected, it writes:
87
+ - `AGENT_PLAY_MAIN_NODE_ID`
88
+ - `AGENT_PLAY_AGENT_NODE_ID_1`
89
+ - `AGENT_PLAY_AGENT_NODE_ID_2` (when requested)
90
+ into generated `.env`.
91
+ - Generated code references these env vars directly (no hardcoded ids).