@trikhub/server 0.10.0 → 0.12.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @trikhub/server
2
2
 
3
- HTTP server for TrikHub - remote gateway for AI agents.
3
+ HTTP server for TrikHub - remote gateway for AI agent handoff routing.
4
4
 
5
5
  ## Installation
6
6
 
@@ -35,19 +35,20 @@ docker-compose up
35
35
  trik-server
36
36
  ```
37
37
 
38
- 1. Install a trik via API:
38
+ 2. Check available endpoints:
39
+ - Health: http://localhost:3000/api/v1/health
40
+ - API Docs: http://localhost:3000/docs
41
+ - Handoff Tools: http://localhost:3000/api/v1/tools
42
+ - Loaded Triks: http://localhost:3000/api/v1/triks
43
+
44
+ 3. Send a message through the gateway:
39
45
 
40
46
  ```bash
41
- curl -X POST http://localhost:3000/api/v1/triks/install \
47
+ curl -X POST http://localhost:3000/api/v1/message \
42
48
  -H "Content-Type: application/json" \
43
- -d '{"package": "@molefas/article-search"}'
49
+ -d '{"message": "Hello", "sessionId": "session-1"}'
44
50
  ```
45
51
 
46
- 1. Access the API:
47
- - Health: http://localhost:3000/api/v1/health
48
- - API Docs: http://localhost:3000/docs
49
- - Tools: http://localhost:3000/api/v1/tools
50
-
51
52
  ## Configuration
52
53
 
53
54
  All configuration is done via environment variables:
@@ -56,73 +57,153 @@ All configuration is done via environment variables:
56
57
  |----------|---------|-------------|
57
58
  | `PORT` | `3000` | Server port |
58
59
  | `HOST` | `0.0.0.0` | Server host |
59
- | `SKILLS_DIR` | `./skills` | Directory containing local skills |
60
- | `CONFIG_PATH` | - | Path to `.trikhub/config.json` for npm-installed skills |
60
+ | `SKILLS_DIR` | - | Directory containing local triks (optional) |
61
+ | `CONFIG_PATH` | - | Path to `.trikhub/config.json` for npm-installed triks |
61
62
  | `AUTH_TOKEN` | - | Bearer token for authentication (optional) |
62
63
  | `LOG_LEVEL` | `info` | Log level: `debug`, `info`, `warn`, `error` |
63
- | `LINT_ON_LOAD` | `true` | Validate skills before loading |
64
- | `LINT_WARNINGS_AS_ERRORS` | `false` | Treat lint warnings as errors |
65
- | `ALLOWED_SKILLS` | - | Comma-separated allowlist of skill IDs |
64
+ | `ALLOWED_SKILLS` | - | Comma-separated allowlist of trik IDs |
66
65
 
67
66
  ## API Endpoints
68
67
 
69
- ### Core Endpoints
68
+ ### Message Routing
70
69
 
71
70
  | Endpoint | Method | Description |
72
71
  |----------|--------|-------------|
73
- | `/api/v1/health` | GET | Health check |
74
- | `/api/v1/tools` | GET | List available tools |
75
- | `/api/v1/execute` | POST | Execute a skill action |
76
- | `/api/v1/content/:ref` | GET | Retrieve passthrough content |
77
- | `/docs` | GET | Swagger UI documentation |
72
+ | `/api/v1/message` | POST | Route a user message through the handoff gateway |
73
+ | `/api/v1/back` | POST | Force transfer-back from current handoff |
74
+ | `/api/v1/session` | GET | Get current handoff state |
78
75
 
79
- ### Trik Management Endpoints
76
+ ### Tools & Triks
80
77
 
81
78
  | Endpoint | Method | Description |
82
79
  |----------|--------|-------------|
83
- | `/api/v1/triks` | GET | List installed triks |
80
+ | `/api/v1/tools` | GET | List handoff tool definitions |
81
+ | `/api/v1/triks` | GET | List loaded triks with v2 info |
84
82
  | `/api/v1/triks/install` | POST | Install a trik package |
85
83
  | `/api/v1/triks/:name` | DELETE | Uninstall a trik |
86
- | `/api/v1/triks/reload` | POST | Hot-reload all skills |
84
+ | `/api/v1/triks/reload` | POST | Hot-reload all triks |
87
85
 
88
- ### Execute a Skill
86
+ ### System
87
+
88
+ | Endpoint | Method | Description |
89
+ |----------|--------|-------------|
90
+ | `/api/v1/health` | GET | Health check |
91
+ | `/docs` | GET | Swagger UI documentation |
92
+
93
+ ### Send a Message
89
94
 
90
95
  ```bash
91
- curl -X POST http://localhost:3000/api/v1/execute \
96
+ curl -X POST http://localhost:3000/api/v1/message \
92
97
  -H "Content-Type: application/json" \
93
- -d '{"tool": "my-skill:action", "input": {"param": "value"}}'
98
+ -d '{"message": "Search for articles about AI", "sessionId": "s1"}'
94
99
  ```
95
100
 
96
- ### Install a Trik
101
+ **Response (no active handoff):**
102
+
103
+ ```json
104
+ {
105
+ "target": "main",
106
+ "handoffTools": [
107
+ {
108
+ "name": "talk_to_content-hoarder",
109
+ "description": "Search, create, and manage articles...",
110
+ "inputSchema": { "type": "object", "properties": { "context": { "type": "string" } } }
111
+ }
112
+ ]
113
+ }
114
+ ```
115
+
116
+ **Response (active handoff):**
117
+
118
+ ```json
119
+ {
120
+ "target": "trik",
121
+ "trikId": "content-hoarder",
122
+ "response": {
123
+ "message": "I found 3 articles about AI.",
124
+ "transferBack": false
125
+ },
126
+ "sessionId": "hs-abc123"
127
+ }
128
+ ```
129
+
130
+ ### Force Transfer Back
97
131
 
98
132
  ```bash
99
- curl -X POST http://localhost:3000/api/v1/triks/install \
133
+ curl -X POST http://localhost:3000/api/v1/back \
100
134
  -H "Content-Type: application/json" \
101
- -d '{"package": "@molefas/article-search"}'
135
+ -d '{"sessionId": "s1"}'
102
136
  ```
103
137
 
104
- ### List Installed Triks
138
+ ### Get Session State
105
139
 
106
140
  ```bash
107
- curl http://localhost:3000/api/v1/triks
141
+ curl http://localhost:3000/api/v1/session
108
142
  ```
109
143
 
110
- ## Docker Usage
144
+ ```json
145
+ {
146
+ "activeHandoff": {
147
+ "trikId": "content-hoarder",
148
+ "sessionId": "hs-abc123",
149
+ "turnCount": 3
150
+ }
151
+ }
152
+ ```
111
153
 
112
- The Docker image includes the `trik` CLI for runtime package management.
154
+ ### List Handoff Tools
113
155
 
114
- ### Basic Usage
156
+ ```bash
157
+ curl http://localhost:3000/api/v1/tools
158
+ ```
159
+
160
+ ```json
161
+ {
162
+ "handoffTools": [
163
+ {
164
+ "name": "talk_to_content-hoarder",
165
+ "description": "Search, create, revise, and publish articles...",
166
+ "inputSchema": { ... }
167
+ }
168
+ ]
169
+ }
170
+ ```
171
+
172
+ ### List Loaded Triks
115
173
 
116
174
  ```bash
117
- docker run -p 3000:3000 -v trik-data:/data trikhub/server
175
+ curl http://localhost:3000/api/v1/triks
118
176
  ```
119
177
 
120
- ### With Local Skills (Read-Only)
178
+ ```json
179
+ {
180
+ "triks": [
181
+ {
182
+ "name": "content-hoarder",
183
+ "version": "0.1.0",
184
+ "description": "Article curation and publishing agent",
185
+ "mode": "conversational",
186
+ "domain": ["content curation", "article writing"],
187
+ "tools": ["searchArticles", "createArticle", "reviseArticle"]
188
+ }
189
+ ]
190
+ }
191
+ ```
192
+
193
+ ### Install a Trik
121
194
 
122
195
  ```bash
123
- docker run -p 3000:3000 \
124
- -v ./skills:/data/skills:ro \
125
- trikhub/server
196
+ curl -X POST http://localhost:3000/api/v1/triks/install \
197
+ -H "Content-Type: application/json" \
198
+ -d '{"package": "@molefas/content-hoarder"}'
199
+ ```
200
+
201
+ ## Docker Usage
202
+
203
+ ### Basic Usage
204
+
205
+ ```bash
206
+ docker run -p 3000:3000 -v trik-data:/data trikhub/server
126
207
  ```
127
208
 
128
209
  ### With Authentication
@@ -136,18 +217,14 @@ docker run -p 3000:3000 \
136
217
 
137
218
  ### Runtime Trik Installation
138
219
 
139
- Install triks at runtime via CLI:
140
-
141
220
  ```bash
142
- docker exec trik-server trik install @molefas/article-search
143
- ```
221
+ # Via CLI
222
+ docker exec trik-server trik install @molefas/content-hoarder
144
223
 
145
- Or via API:
146
-
147
- ```bash
224
+ # Via API
148
225
  curl -X POST http://localhost:3000/api/v1/triks/install \
149
226
  -H "Content-Type: application/json" \
150
- -d '{"package": "@molefas/article-search"}'
227
+ -d '{"package": "@molefas/content-hoarder"}'
151
228
  ```
152
229
 
153
230
  ### Using docker-compose
@@ -167,42 +244,35 @@ volumes:
167
244
  trik-data:
168
245
  ```
169
246
 
170
- ### Building from Source
171
-
172
- ```bash
173
- # From monorepo root
174
- docker build -f packages/trik-server/Dockerfile -t trikhub/server .
175
- ```
176
-
177
- ## Skill Loading
247
+ ## Trik Loading
178
248
 
179
- The server loads skills from two sources:
249
+ The server loads triks from two sources:
180
250
 
181
251
  ### 1. Local Directory (`SKILLS_DIR`)
182
252
 
183
- Skills are directories containing a `manifest.json` and implementation:
253
+ Triks are directories containing a `manifest.json` and implementation:
184
254
 
185
255
  ```
186
256
  skills/
187
- ├── my-skill/
257
+ ├── my-trik/
188
258
  │ ├── manifest.json
189
- │ └── graph.js
190
- └── @scope/another-skill/
259
+ │ └── dist/agent.js
260
+ └── @scope/another-trik/
191
261
  ├── manifest.json
192
- └── graph.js
262
+ └── dist/agent.js
193
263
  ```
194
264
 
195
265
  ### 2. npm Packages (`CONFIG_PATH`)
196
266
 
197
- Skills installed via `trik install` or the API are tracked in a config file:
267
+ Triks installed via `trik install` or the API are tracked in a config file:
198
268
 
199
269
  ```json
200
270
  {
201
- "triks": ["@molefas/article-search", "my-other-skill"]
271
+ "triks": ["@molefas/content-hoarder", "@acme/web-scraper"]
202
272
  }
203
273
  ```
204
274
 
205
- Set `CONFIG_PATH` to enable npm-based skill loading:
275
+ Set `CONFIG_PATH` to enable npm-based trik loading:
206
276
 
207
277
  ```bash
208
278
  CONFIG_PATH=./.trikhub/config.json trik-server
@@ -210,9 +280,10 @@ CONFIG_PATH=./.trikhub/config.json trik-server
210
280
 
211
281
  ## See Also
212
282
 
213
- - [@trikhub/manifest](../trik-manifest) - Manifest schema documentation
214
- - [@trikhub/gateway](../trik-gateway) - Core gateway library
215
- - [@trikhub/cli](../trik-cli) - CLI for installing triks
283
+ - [@trikhub/gateway](../gateway) - Core gateway library with handoff routing
284
+ - [@trikhub/manifest](../manifest) - Manifest types and validation
285
+ - [@trikhub/cli](../cli) - CLI for installing and managing triks
286
+ - [@trikhub/sdk](../sdk) - SDK for building triks
216
287
 
217
288
  ## License
218
289