@agent-play/cli 3.1.0 → 3.2.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/README.md +43 -27
- package/dist/README.md +94 -0
- package/dist/cli.js +461 -45
- package/package.json +8 -4
- package/templates/agent-starter/langchain/.env.example +6 -0
- package/templates/agent-starter/langchain/README.md +24 -0
- package/templates/agent-starter/langchain/package.json +25 -0
- package/templates/agent-starter/langchain/src/bare-server.ts +12 -0
- package/templates/agent-starter/langchain/src/builtins/definitions.ts +66 -0
- package/templates/agent-starter/langchain/src/builtins/toolkits/starter-tools.ts +84 -0
- package/templates/agent-starter/langchain/src/express-server.ts +27 -0
- package/templates/agent-starter/langchain/src/index.ts +6 -0
- package/templates/agent-starter/langchain/src/load-env.ts +5 -0
- package/templates/agent-starter/langchain/src/register/register-builtins.ts +62 -0
- package/templates/agent-starter/langchain/src/register-agents.ts +1 -0
- package/templates/agent-starter/langchain/src/tool-handlers/assist-brainstorm.ts +8 -0
- package/templates/agent-starter/langchain/src/tool-handlers/assist-calculate-coefficient.ts +35 -0
- package/templates/agent-starter/langchain/src/tool-handlers/assist-collect-scene-details.ts +32 -0
- package/templates/agent-starter/langchain/src/tool-handlers/chat-tool.ts +6 -0
- package/templates/agent-starter/langchain/src/tool-handlers/execute-tool-capability.ts +12 -0
- package/templates/agent-starter/langchain/src/tool-handlers/tool-capability-registry.ts +49 -0
- package/templates/agent-starter/langchain/tsconfig.json +13 -0
package/README.md
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
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
4
|
|
|
5
|
-
Authentication uses **`x-node-id`** and **`x-node-passw`** on every request **except** main-node creation
|
|
5
|
+
Authentication uses **`x-node-id`** and **`x-node-passw`** (the locally-computed `passwHash`) on every request **except** main-node creation. **`POST /api/nodes`** is unauthenticated and expects a JSON body with **`nodeId`** and **`passwHash`** already derived on the client; the server stores `passwHash` only and never re-hashes anything it receives.
|
|
6
6
|
|
|
7
7
|
## Documentation
|
|
8
8
|
|
|
9
9
|
- **[Repository](https://github.com/wilforlan/agent-play)**
|
|
10
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
|
|
11
|
+
- **[API reference](https://wilforlan.github.io/agent-play/)** — TypeDoc
|
|
12
12
|
|
|
13
13
|
## Install
|
|
14
14
|
|
|
@@ -16,49 +16,52 @@ Authentication uses **`x-node-id`** and **`x-node-passw`** on every request **ex
|
|
|
16
16
|
npm install -g @agent-play/cli
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
Binary name:
|
|
19
|
+
Binary name: `**agent-play**`.
|
|
20
20
|
|
|
21
|
-
Default server URL:
|
|
21
|
+
Default server URL: `**http://127.0.0.1:3000**`, or override with `**AGENT_PLAY_SERVER_URL**`.
|
|
22
22
|
|
|
23
|
-
Root key for derivation:
|
|
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
24
|
|
|
25
25
|
## Node setup
|
|
26
26
|
|
|
27
27
|
1. **Server:** Redis (`REDIS_URL`) and a deployed web UI/API the CLI can reach (`AGENT_PLAY_SERVER_URL`).
|
|
28
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
|
|
30
|
-
4. **`create-agent-node`**: derives an agent node
|
|
31
|
-
5.
|
|
29
|
+
3. **`create-main-node`** (`bootstrap-node`): prompts for server URL, generates a passphrase and **`passwHash`** locally with `createNodeCredentialMaterial`, registers **`POST /api/nodes`** with `{ kind: "main", nodeId, passwHash }`, and writes **`~/.agent-play/credentials.json`** with **`serverUrl`**, **`nodeId`**, and the human passphrase.
|
|
30
|
+
4. **`create-agent-node`**: derives an agent node locally with `createNodeCredentialMaterial`, calls **`POST /api/nodes/agent-node`** with `{ kind: "agent", parentNodeId, agentNodeId, agentNodePasswHash }`, and appends the result 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
32
|
|
|
33
|
-
> **@deprecated**
|
|
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
34
|
|
|
35
35
|
## Node validation
|
|
36
36
|
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
-
|
|
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
40
|
|
|
41
|
-
For Redis-direct checks (ops/CI), use
|
|
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
42
|
|
|
43
43
|
## Commands
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
|
48
|
-
| **`
|
|
49
|
-
|
|
|
50
|
-
|
|
|
51
|
-
|
|
|
52
|
-
|
|
|
53
|
-
|
|
|
54
|
-
|
|
|
55
|
-
|
|
|
45
|
+
|
|
46
|
+
| Command | Aliases | What it does |
|
|
47
|
+
| ---------------------------- | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
48
|
+
| `**create-main-node**` | `bootstrap-node` | Sign up a **main** node: `**POST /api/nodes`** (no node headers), save `**~/.agent-play/credentials.json**`. Optional `**--root-file**`. |
|
|
49
|
+
| `**inspect-node**` | — | **GET /api/nodes** — genesis id, main node, **agent node ids** (`create-agent-node`), and **runtime** agent rows (SDK metadata) if present. |
|
|
50
|
+
| `**create-agent-node`** | `create` | **POST /api/nodes/agent-node** — new agent node under your main node. |
|
|
51
|
+
| `**list-agent-nodes`** | `list` | **GET /api/agents** — lists registered agents. |
|
|
52
|
+
| `**delete-agent-node`** | `delete`, `remove` | **DELETE /api/agents** — optional `**[agent-id]`**; if omitted, prompts. |
|
|
53
|
+
| `**delete-main-node**` | — | **DELETE /api/nodes** — confirm by typing main node id; cascades. |
|
|
54
|
+
| `**validate-main-node`** | — | **POST /api/nodes/validate** for main node id. |
|
|
55
|
+
| `**validate-agent-node`** | — | `**--all**` or `**--agent-node-ids id1,id2,...**` — validate agent node ids. |
|
|
56
|
+
| `**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. |
|
|
57
|
+
| `**clear-node-credentials**` | — | Removes `**~/.agent-play/credentials.json**`. |
|
|
58
|
+
|
|
56
59
|
|
|
57
60
|
## Genesis and main node
|
|
58
61
|
|
|
59
|
-
Every **main node id** is derived from passphrase material and the platform **root key** (the **genesis** identity).
|
|
62
|
+
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.
|
|
60
63
|
|
|
61
|
-
Node kinds:
|
|
64
|
+
Node kinds: `**root` → `main` → `agent**`. Root has no passphrase; main and agent persist hashed material server-side.
|
|
62
65
|
|
|
63
66
|
## Usage examples
|
|
64
67
|
|
|
@@ -68,6 +71,7 @@ npx agent-play validate-main-node
|
|
|
68
71
|
npx agent-play inspect-node
|
|
69
72
|
npx agent-play create-agent-node
|
|
70
73
|
npx agent-play validate-agent-node --all
|
|
74
|
+
npx agent-play initialize
|
|
71
75
|
npx agent-play list-agent-nodes
|
|
72
76
|
npx agent-play delete-agent-node
|
|
73
77
|
npx agent-play delete-agent-node <agent-uuid>
|
|
@@ -75,4 +79,16 @@ npx agent-play delete-main-node
|
|
|
75
79
|
npx agent-play clear-node-credentials
|
|
76
80
|
```
|
|
77
81
|
|
|
78
|
-
For SDK usage after bootstrap, use **`
|
|
82
|
+
For SDK usage after bootstrap, use `**RemotePlayWorld**` and register players with `**mainNodeId**` and `**agentId**` from the CLI output.
|
|
83
|
+
|
|
84
|
+
## Initialize quick start
|
|
85
|
+
|
|
86
|
+
- `npx agent-play initialize` (or `npx agent-play init`) scaffolds starter files.
|
|
87
|
+
- The flow asks whether to create nodes now and how many agent nodes to provision (max `2`).
|
|
88
|
+
- If bootstrap is selected, it writes:
|
|
89
|
+
- `AGENT_PLAY_MAIN_NODE_ID`
|
|
90
|
+
- `AGENT_PLAY_AGENT_NODE_ID_1`
|
|
91
|
+
- `AGENT_PLAY_AGENT_NODE_ID_2` (when requested)
|
|
92
|
+
into generated `.env`.
|
|
93
|
+
- Generated code references these env vars directly (no hardcoded ids).
|
|
94
|
+
|
package/dist/README.md
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
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`** (the locally-computed `passwHash`) on every request **except** main-node creation. **`POST /api/nodes`** is unauthenticated and expects a JSON body with **`nodeId`** and **`passwHash`** already derived on the client; the server stores `passwHash` only and never re-hashes anything it receives.
|
|
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 and **`passwHash`** locally with `createNodeCredentialMaterial`, registers **`POST /api/nodes`** with `{ kind: "main", nodeId, passwHash }`, and writes **`~/.agent-play/credentials.json`** with **`serverUrl`**, **`nodeId`**, and the human passphrase.
|
|
30
|
+
4. **`create-agent-node`**: derives an agent node locally with `createNodeCredentialMaterial`, calls **`POST /api/nodes/agent-node`** with `{ kind: "agent", parentNodeId, agentNodeId, agentNodePasswHash }`, and appends the result 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
|
+
|
|
46
|
+
| Command | Aliases | What it does |
|
|
47
|
+
| ---------------------------- | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
48
|
+
| `**create-main-node**` | `bootstrap-node` | Sign up a **main** node: `**POST /api/nodes`** (no node headers), save `**~/.agent-play/credentials.json**`. Optional `**--root-file**`. |
|
|
49
|
+
| `**inspect-node**` | — | **GET /api/nodes** — genesis id, main node, **agent node ids** (`create-agent-node`), and **runtime** agent rows (SDK metadata) if present. |
|
|
50
|
+
| `**create-agent-node`** | `create` | **POST /api/nodes/agent-node** — new agent node under your main node. |
|
|
51
|
+
| `**list-agent-nodes`** | `list` | **GET /api/agents** — lists registered agents. |
|
|
52
|
+
| `**delete-agent-node`** | `delete`, `remove` | **DELETE /api/agents** — optional `**[agent-id]`**; if omitted, prompts. |
|
|
53
|
+
| `**delete-main-node**` | — | **DELETE /api/nodes** — confirm by typing main node id; cascades. |
|
|
54
|
+
| `**validate-main-node`** | — | **POST /api/nodes/validate** for main node id. |
|
|
55
|
+
| `**validate-agent-node`** | — | `**--all**` or `**--agent-node-ids id1,id2,...**` — validate agent node ids. |
|
|
56
|
+
| `**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. |
|
|
57
|
+
| `**clear-node-credentials**` | — | Removes `**~/.agent-play/credentials.json**`. |
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
## Genesis and main node
|
|
61
|
+
|
|
62
|
+
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.
|
|
63
|
+
|
|
64
|
+
Node kinds: `**root` → `main` → `agent**`. Root has no passphrase; main and agent persist hashed material server-side.
|
|
65
|
+
|
|
66
|
+
## Usage examples
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npx agent-play create-main-node
|
|
70
|
+
npx agent-play validate-main-node
|
|
71
|
+
npx agent-play inspect-node
|
|
72
|
+
npx agent-play create-agent-node
|
|
73
|
+
npx agent-play validate-agent-node --all
|
|
74
|
+
npx agent-play initialize
|
|
75
|
+
npx agent-play list-agent-nodes
|
|
76
|
+
npx agent-play delete-agent-node
|
|
77
|
+
npx agent-play delete-agent-node <agent-uuid>
|
|
78
|
+
npx agent-play delete-main-node
|
|
79
|
+
npx agent-play clear-node-credentials
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
For SDK usage after bootstrap, use `**RemotePlayWorld**` and register players with `**mainNodeId**` and `**agentId**` from the CLI output.
|
|
83
|
+
|
|
84
|
+
## Initialize quick start
|
|
85
|
+
|
|
86
|
+
- `npx agent-play initialize` (or `npx agent-play init`) scaffolds starter files.
|
|
87
|
+
- The flow asks whether to create nodes now and how many agent nodes to provision (max `2`).
|
|
88
|
+
- If bootstrap is selected, it writes:
|
|
89
|
+
- `AGENT_PLAY_MAIN_NODE_ID`
|
|
90
|
+
- `AGENT_PLAY_AGENT_NODE_ID_1`
|
|
91
|
+
- `AGENT_PLAY_AGENT_NODE_ID_2` (when requested)
|
|
92
|
+
into generated `.env`.
|
|
93
|
+
- Generated code references these env vars directly (no hardcoded ids).
|
|
94
|
+
|