@hailer/mcp 0.0.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/.claude/commands/tool-builder.md +37 -0
- package/.claude/commands/ws-pull.md +44 -0
- package/.claude/settings.json +8 -0
- package/.claude/settings.local.json +49 -0
- package/.claude/skills/activity-api/SKILL.md +96 -0
- package/.claude/skills/activity-api/references/activity-endpoints.md +845 -0
- package/.claude/skills/add-app-member-skill/SKILL.md +977 -0
- package/.claude/skills/agent-building/SKILL.md +243 -0
- package/.claude/skills/agent-building/references/architecture-patterns.md +446 -0
- package/.claude/skills/agent-building/references/code-examples.md +587 -0
- package/.claude/skills/agent-building/references/implementation-guide.md +619 -0
- package/.claude/skills/app-api/SKILL.md +219 -0
- package/.claude/skills/app-api/references/app-endpoints.md +759 -0
- package/.claude/skills/building-hailer-apps-skill/SKILL.md +548 -0
- package/.claude/skills/create-app-skill/SKILL.md +1101 -0
- package/.claude/skills/create-insight-skill/SKILL.md +1317 -0
- package/.claude/skills/get-insight-data-skill/SKILL.md +1053 -0
- package/.claude/skills/hailer-api/SKILL.md +283 -0
- package/.claude/skills/hailer-api/references/activities.md +620 -0
- package/.claude/skills/hailer-api/references/authentication.md +216 -0
- package/.claude/skills/hailer-api/references/datasets.md +437 -0
- package/.claude/skills/hailer-api/references/files.md +301 -0
- package/.claude/skills/hailer-api/references/insights.md +469 -0
- package/.claude/skills/hailer-api/references/workflows.md +720 -0
- package/.claude/skills/hailer-api/references/workspaces-users.md +445 -0
- package/.claude/skills/insight-api/SKILL.md +185 -0
- package/.claude/skills/insight-api/references/insight-endpoints.md +514 -0
- package/.claude/skills/install-workflow-skill/SKILL.md +1056 -0
- package/.claude/skills/list-apps-skill/SKILL.md +1010 -0
- package/.claude/skills/list-workflows-minimal-skill/SKILL.md +992 -0
- package/.claude/skills/local-first-skill/SKILL.md +570 -0
- package/.claude/skills/mcp-tools/SKILL.md +419 -0
- package/.claude/skills/mcp-tools/references/api-endpoints.md +499 -0
- package/.claude/skills/mcp-tools/references/data-structures.md +554 -0
- package/.claude/skills/mcp-tools/references/implementation-patterns.md +717 -0
- package/.claude/skills/preview-insight-skill/SKILL.md +1290 -0
- package/.claude/skills/publish-hailer-app-skill/SKILL.md +453 -0
- package/.claude/skills/remove-app-member-skill/SKILL.md +671 -0
- package/.claude/skills/remove-app-skill/SKILL.md +985 -0
- package/.claude/skills/remove-insight-skill/SKILL.md +1011 -0
- package/.claude/skills/remove-workflow-skill/SKILL.md +920 -0
- package/.claude/skills/scaffold-hailer-app-skill/SKILL.md +1034 -0
- package/.claude/skills/skill-testing/README.md +137 -0
- package/.claude/skills/skill-testing/SKILL.md +348 -0
- package/.claude/skills/skill-testing/references/test-patterns.md +705 -0
- package/.claude/skills/skill-testing/references/testing-guide.md +603 -0
- package/.claude/skills/skill-testing/references/validation-checklist.md +537 -0
- package/.claude/skills/tool-builder/SKILL.md +328 -0
- package/.claude/skills/update-app-skill/SKILL.md +970 -0
- package/.claude/skills/update-workflow-field-skill/SKILL.md +1098 -0
- package/.env.example +81 -0
- package/.mcp.json +13 -0
- package/README.md +297 -0
- package/dist/app.d.ts +4 -0
- package/dist/app.js +74 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +5 -0
- package/dist/client/adaptive-documentation-bot.d.ts +108 -0
- package/dist/client/adaptive-documentation-bot.js +475 -0
- package/dist/client/adaptive-documentation-types.d.ts +66 -0
- package/dist/client/adaptive-documentation-types.js +9 -0
- package/dist/client/agent-activity-bot.d.ts +51 -0
- package/dist/client/agent-activity-bot.js +166 -0
- package/dist/client/agent-tracker.d.ts +499 -0
- package/dist/client/agent-tracker.js +659 -0
- package/dist/client/description-updater.d.ts +56 -0
- package/dist/client/description-updater.js +259 -0
- package/dist/client/log-parser.d.ts +72 -0
- package/dist/client/log-parser.js +387 -0
- package/dist/client/mcp-client.d.ts +50 -0
- package/dist/client/mcp-client.js +532 -0
- package/dist/client/message-processor.d.ts +35 -0
- package/dist/client/message-processor.js +352 -0
- package/dist/client/multi-bot-manager.d.ts +24 -0
- package/dist/client/multi-bot-manager.js +74 -0
- package/dist/client/providers/anthropic-provider.d.ts +19 -0
- package/dist/client/providers/anthropic-provider.js +631 -0
- package/dist/client/providers/llm-provider.d.ts +47 -0
- package/dist/client/providers/llm-provider.js +367 -0
- package/dist/client/providers/openai-provider.d.ts +23 -0
- package/dist/client/providers/openai-provider.js +621 -0
- package/dist/client/simple-llm-caller.d.ts +19 -0
- package/dist/client/simple-llm-caller.js +100 -0
- package/dist/client/skill-generator.d.ts +81 -0
- package/dist/client/skill-generator.js +386 -0
- package/dist/client/test-adaptive-bot.d.ts +9 -0
- package/dist/client/test-adaptive-bot.js +82 -0
- package/dist/client/token-pricing.d.ts +38 -0
- package/dist/client/token-pricing.js +127 -0
- package/dist/client/token-tracker.d.ts +232 -0
- package/dist/client/token-tracker.js +457 -0
- package/dist/client/token-usage-bot.d.ts +53 -0
- package/dist/client/token-usage-bot.js +153 -0
- package/dist/client/tool-executor.d.ts +69 -0
- package/dist/client/tool-executor.js +159 -0
- package/dist/client/tool-schema-loader.d.ts +60 -0
- package/dist/client/tool-schema-loader.js +178 -0
- package/dist/client/types.d.ts +69 -0
- package/dist/client/types.js +7 -0
- package/dist/config.d.ts +162 -0
- package/dist/config.js +296 -0
- package/dist/core.d.ts +26 -0
- package/dist/core.js +147 -0
- package/dist/lib/context-manager.d.ts +111 -0
- package/dist/lib/context-manager.js +431 -0
- package/dist/lib/logger.d.ts +74 -0
- package/dist/lib/logger.js +277 -0
- package/dist/lib/materialize.d.ts +3 -0
- package/dist/lib/materialize.js +101 -0
- package/dist/lib/normalizedName.d.ts +7 -0
- package/dist/lib/normalizedName.js +48 -0
- package/dist/lib/prompt-length-manager.d.ts +81 -0
- package/dist/lib/prompt-length-manager.js +457 -0
- package/dist/lib/terminal-prompt.d.ts +9 -0
- package/dist/lib/terminal-prompt.js +108 -0
- package/dist/mcp/UserContextCache.d.ts +56 -0
- package/dist/mcp/UserContextCache.js +163 -0
- package/dist/mcp/auth.d.ts +2 -0
- package/dist/mcp/auth.js +29 -0
- package/dist/mcp/hailer-clients.d.ts +42 -0
- package/dist/mcp/hailer-clients.js +246 -0
- package/dist/mcp/signal-handler.d.ts +45 -0
- package/dist/mcp/signal-handler.js +317 -0
- package/dist/mcp/tool-registry.d.ts +100 -0
- package/dist/mcp/tool-registry.js +306 -0
- package/dist/mcp/tools/activity.d.ts +15 -0
- package/dist/mcp/tools/activity.js +955 -0
- package/dist/mcp/tools/app.d.ts +20 -0
- package/dist/mcp/tools/app.js +1488 -0
- package/dist/mcp/tools/discussion.d.ts +19 -0
- package/dist/mcp/tools/discussion.js +950 -0
- package/dist/mcp/tools/file.d.ts +15 -0
- package/dist/mcp/tools/file.js +119 -0
- package/dist/mcp/tools/insight.d.ts +17 -0
- package/dist/mcp/tools/insight.js +806 -0
- package/dist/mcp/tools/skill.d.ts +10 -0
- package/dist/mcp/tools/skill.js +279 -0
- package/dist/mcp/tools/user.d.ts +10 -0
- package/dist/mcp/tools/user.js +108 -0
- package/dist/mcp/tools/workflow-template.d.ts +19 -0
- package/dist/mcp/tools/workflow-template.js +822 -0
- package/dist/mcp/tools/workflow.d.ts +18 -0
- package/dist/mcp/tools/workflow.js +1362 -0
- package/dist/mcp/utils/api-errors.d.ts +45 -0
- package/dist/mcp/utils/api-errors.js +160 -0
- package/dist/mcp/utils/data-transformers.d.ts +102 -0
- package/dist/mcp/utils/data-transformers.js +194 -0
- package/dist/mcp/utils/file-upload.d.ts +33 -0
- package/dist/mcp/utils/file-upload.js +148 -0
- package/dist/mcp/utils/hailer-api-client.d.ts +120 -0
- package/dist/mcp/utils/hailer-api-client.js +323 -0
- package/dist/mcp/utils/index.d.ts +13 -0
- package/dist/mcp/utils/index.js +39 -0
- package/dist/mcp/utils/logger.d.ts +42 -0
- package/dist/mcp/utils/logger.js +103 -0
- package/dist/mcp/utils/types.d.ts +286 -0
- package/dist/mcp/utils/types.js +7 -0
- package/dist/mcp/workspace-cache.d.ts +42 -0
- package/dist/mcp/workspace-cache.js +97 -0
- package/dist/mcp-server.d.ts +42 -0
- package/dist/mcp-server.js +280 -0
- package/package.json +56 -0
- package/tsconfig.json +23 -0
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+
# API Endpoints Reference
|
|
2
|
+
|
|
3
|
+
Complete reference for all working Hailer API endpoints with exact request/response formats.
|
|
4
|
+
|
|
5
|
+
## Authentication
|
|
6
|
+
|
|
7
|
+
**All requests require**:
|
|
8
|
+
- Header: `hlrkey: {auth_token}`
|
|
9
|
+
- Content-Type: `application/json`
|
|
10
|
+
|
|
11
|
+
## Request Format Convention
|
|
12
|
+
|
|
13
|
+
Most endpoints expect a **JSON array** as the request body:
|
|
14
|
+
|
|
15
|
+
```javascript
|
|
16
|
+
body: JSON.stringify([arg1, arg2, arg3])
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
This is **NOT standard REST** - always use array format unless specified otherwise.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Activity Endpoints
|
|
24
|
+
|
|
25
|
+
### 1. List Activities (`POST /v3/activity/list`)
|
|
26
|
+
|
|
27
|
+
List and filter activities in a workflow/phase with advanced query capabilities.
|
|
28
|
+
|
|
29
|
+
**Request Format**:
|
|
30
|
+
```javascript
|
|
31
|
+
POST /v3/activity/list
|
|
32
|
+
body: JSON.stringify([workflowFilter, requestOptions])
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**Example Request**:
|
|
36
|
+
```javascript
|
|
37
|
+
[
|
|
38
|
+
{
|
|
39
|
+
processId: "68446dc05b30685f67c6fcd4", // workflow ID
|
|
40
|
+
phaseId: "6901ebb64fd57ff171f43338" // optional phase ID
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
limit: 50, // max results (default: 50)
|
|
44
|
+
page: 1, // 1-based pagination (NOT 0-based!)
|
|
45
|
+
sortBy: "updated", // updated | created | name | priority
|
|
46
|
+
sortOrder: "desc", // asc | desc
|
|
47
|
+
returnFlat: true, // use field.key instead of field._id
|
|
48
|
+
filters: { // optional advanced filters
|
|
49
|
+
and: [
|
|
50
|
+
{ "field-id-company": { equalTo: "company-id" } },
|
|
51
|
+
{ "field-id-created": { between: ["1717200000000", "1719791999000"] } }
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**Filter Operators**:
|
|
59
|
+
- `textSearch` - Partial text search in field
|
|
60
|
+
- `equalTo` / `notEqualTo` - Exact matching
|
|
61
|
+
- `contains` - Partial text matching
|
|
62
|
+
- `greaterThan` / `lessThan` / `greaterThanOrEqual` / `lessThanOrEqual` - Numeric comparisons
|
|
63
|
+
- `between` - Range filter: `[start, end]` for dates/numbers
|
|
64
|
+
|
|
65
|
+
**Combining Filters**:
|
|
66
|
+
```javascript
|
|
67
|
+
filters: {
|
|
68
|
+
and: [
|
|
69
|
+
{ "field-id-1": { equalTo: "value" } },
|
|
70
|
+
{ "field-id-2": { greaterThan: 100 } }
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Or use 'or':
|
|
75
|
+
filters: {
|
|
76
|
+
or: [
|
|
77
|
+
{ "field-id-status": { equalTo: "active" } },
|
|
78
|
+
{ "field-id-status": { equalTo: "pending" } }
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**Response**:
|
|
84
|
+
```javascript
|
|
85
|
+
{
|
|
86
|
+
data: [
|
|
87
|
+
{
|
|
88
|
+
_id: "activity-id",
|
|
89
|
+
name: "Activity Title",
|
|
90
|
+
// With returnFlat: true
|
|
91
|
+
relatedTo: "other-activity-id", // Uses field.key
|
|
92
|
+
company: "company-id",
|
|
93
|
+
// Without returnFlat
|
|
94
|
+
fields: {
|
|
95
|
+
"field-id": { value: "value" }
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
totalCount: 123,
|
|
100
|
+
page: 1,
|
|
101
|
+
totalPages: 3
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
### 2. Create Activities (`POST /v3/activity/createMany`)
|
|
108
|
+
|
|
109
|
+
Create one or more activities in a workflow.
|
|
110
|
+
|
|
111
|
+
**Request Format**:
|
|
112
|
+
```javascript
|
|
113
|
+
POST /v3/activity/createMany
|
|
114
|
+
body: JSON.stringify([workflowId, activityDataArray, options])
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**Example Request**:
|
|
118
|
+
```javascript
|
|
119
|
+
[
|
|
120
|
+
"68446dc05b30685f67c6fcd4", // workflowId
|
|
121
|
+
[
|
|
122
|
+
{
|
|
123
|
+
name: "New Task",
|
|
124
|
+
fields: {
|
|
125
|
+
relatedTo: "topic-activity-id", // ActivityLink field
|
|
126
|
+
priority: "high",
|
|
127
|
+
dueDate: "2025-11-15"
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
name: "Another Task",
|
|
132
|
+
fields: { relatedTo: "topic-activity-id" }
|
|
133
|
+
}
|
|
134
|
+
],
|
|
135
|
+
{
|
|
136
|
+
returnDocument: true, // Return created activities
|
|
137
|
+
phaseId: "initial-phase-id" // Optional: specific phase
|
|
138
|
+
}
|
|
139
|
+
]
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Response**:
|
|
143
|
+
```javascript
|
|
144
|
+
{
|
|
145
|
+
success: true,
|
|
146
|
+
activities: [
|
|
147
|
+
{
|
|
148
|
+
_id: "new-activity-id",
|
|
149
|
+
name: "New Task",
|
|
150
|
+
fields: { ... }
|
|
151
|
+
}
|
|
152
|
+
]
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
### 3. Update Activities (`POST /v3/activity/updateMany`)
|
|
159
|
+
|
|
160
|
+
Update one or more existing activities.
|
|
161
|
+
|
|
162
|
+
**Request Format**:
|
|
163
|
+
```javascript
|
|
164
|
+
POST /v3/activity/updateMany
|
|
165
|
+
body: JSON.stringify([updatesArray, options])
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
**Example Request**:
|
|
169
|
+
```javascript
|
|
170
|
+
[
|
|
171
|
+
[
|
|
172
|
+
{
|
|
173
|
+
_id: "activity-id-1",
|
|
174
|
+
name: "Updated Title", // Update name
|
|
175
|
+
fields: {
|
|
176
|
+
priority: "urgent",
|
|
177
|
+
relatedTo: "new-topic-id"
|
|
178
|
+
},
|
|
179
|
+
phaseId: "new-phase-id" // Move to different phase
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
_id: "activity-id-2",
|
|
183
|
+
fields: { status: "completed" }
|
|
184
|
+
}
|
|
185
|
+
],
|
|
186
|
+
{
|
|
187
|
+
// Optional batch options
|
|
188
|
+
phaseId: "batch-phase-id" // Apply to all activities
|
|
189
|
+
}
|
|
190
|
+
]
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
**Response**:
|
|
194
|
+
```javascript
|
|
195
|
+
{
|
|
196
|
+
success: true,
|
|
197
|
+
updated: 2
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## Discussion Endpoints
|
|
204
|
+
|
|
205
|
+
### 4. Fetch Latest Messages (`POST /v3/discussion/message/latest`)
|
|
206
|
+
|
|
207
|
+
Fetch the most recent messages from a discussion (up to 50 messages - API limit).
|
|
208
|
+
|
|
209
|
+
**Request Format**:
|
|
210
|
+
```javascript
|
|
211
|
+
POST /v3/discussion/message/latest
|
|
212
|
+
body: JSON.stringify([discussionId, limit])
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
**Example Request**:
|
|
216
|
+
```javascript
|
|
217
|
+
[
|
|
218
|
+
"684be83f68e9345040ad02a3", // discussionId
|
|
219
|
+
50 // optional limit (default: 50, max: 50)
|
|
220
|
+
]
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
**Response**:
|
|
224
|
+
```javascript
|
|
225
|
+
{
|
|
226
|
+
messages: [
|
|
227
|
+
{
|
|
228
|
+
_id: "message-id",
|
|
229
|
+
msg: "Message content",
|
|
230
|
+
user: {
|
|
231
|
+
_id: "user-id",
|
|
232
|
+
name: "User Name"
|
|
233
|
+
},
|
|
234
|
+
created: "2025-10-30T10:00:00Z"
|
|
235
|
+
}
|
|
236
|
+
]
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
### 5. Fetch Previous Messages (`POST /v3/discussion/message/previous`)
|
|
243
|
+
|
|
244
|
+
Paginate through older messages using the oldest message ID.
|
|
245
|
+
|
|
246
|
+
**Request Format**:
|
|
247
|
+
```javascript
|
|
248
|
+
POST /v3/discussion/message/previous
|
|
249
|
+
body: JSON.stringify([oldestMessageId, limit])
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
**Example Request**:
|
|
253
|
+
```javascript
|
|
254
|
+
[
|
|
255
|
+
"message-id-from-previous-fetch", // Use _id from last message
|
|
256
|
+
50 // optional limit
|
|
257
|
+
]
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
**Pagination Pattern**:
|
|
261
|
+
```javascript
|
|
262
|
+
// 1. Fetch latest 50 messages
|
|
263
|
+
const latest = await fetchLatest(discussionId);
|
|
264
|
+
const oldestId = latest.messages[latest.messages.length - 1]._id;
|
|
265
|
+
|
|
266
|
+
// 2. Fetch next 50 older messages
|
|
267
|
+
const previous = await fetchPrevious(oldestId);
|
|
268
|
+
const nextOldestId = previous.messages[previous.messages.length - 1]._id;
|
|
269
|
+
|
|
270
|
+
// 3. Continue...
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
### 6. Send Message (`POST /api/messenger/send`)
|
|
276
|
+
|
|
277
|
+
Post a message to a discussion.
|
|
278
|
+
|
|
279
|
+
**Request Format**:
|
|
280
|
+
```javascript
|
|
281
|
+
POST /api/messenger/send
|
|
282
|
+
body: JSON.stringify([messageData, discussionId])
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
**Example Request**:
|
|
286
|
+
```javascript
|
|
287
|
+
[
|
|
288
|
+
{
|
|
289
|
+
msg: "Hello world!", // Message text
|
|
290
|
+
// Optional fields:
|
|
291
|
+
replyTo: "message-id", // Reply to specific message
|
|
292
|
+
mentions: ["user-id-1", "user-id-2"] // @mention users
|
|
293
|
+
},
|
|
294
|
+
"684be83f68e9345040ad02a3" // discussionId
|
|
295
|
+
]
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
**Response**:
|
|
299
|
+
```javascript
|
|
300
|
+
{
|
|
301
|
+
success: true,
|
|
302
|
+
message: {
|
|
303
|
+
_id: "new-message-id",
|
|
304
|
+
msg: "Hello world!",
|
|
305
|
+
created: "2025-10-30T10:00:00Z"
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
---
|
|
311
|
+
|
|
312
|
+
## Workspace & Search Endpoints
|
|
313
|
+
|
|
314
|
+
### 7. Workspace Initialization (`POST /v2/core/init`)
|
|
315
|
+
|
|
316
|
+
Initialize workspace and fetch all initial data (networks, users, workflows, etc.).
|
|
317
|
+
|
|
318
|
+
**Request Format**:
|
|
319
|
+
```javascript
|
|
320
|
+
POST /v2/core/init
|
|
321
|
+
body: JSON.stringify([workspaceId])
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
**Example Request**:
|
|
325
|
+
```javascript
|
|
326
|
+
["68446c045b30685f67c6fc8c"]
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
**Response**:
|
|
330
|
+
```javascript
|
|
331
|
+
{
|
|
332
|
+
workspace: { ... },
|
|
333
|
+
networks: [{ processes: [...], users: [...] }],
|
|
334
|
+
user: { ... }
|
|
335
|
+
}
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
---
|
|
339
|
+
|
|
340
|
+
### 8. Global Search (`POST /v2/search/global`)
|
|
341
|
+
|
|
342
|
+
Search across activities, users, and other entities.
|
|
343
|
+
|
|
344
|
+
**Request Format**:
|
|
345
|
+
```javascript
|
|
346
|
+
POST /v2/search/global
|
|
347
|
+
body: JSON.stringify([searchOptions])
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
**Example Request**:
|
|
351
|
+
```javascript
|
|
352
|
+
[
|
|
353
|
+
{
|
|
354
|
+
search: "query string",
|
|
355
|
+
sections: ["activities", "users"], // What to search
|
|
356
|
+
limit: 20
|
|
357
|
+
}
|
|
358
|
+
]
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
**Response**:
|
|
362
|
+
```javascript
|
|
363
|
+
{
|
|
364
|
+
activities: [...],
|
|
365
|
+
users: [...]
|
|
366
|
+
}
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
---
|
|
370
|
+
|
|
371
|
+
## Socket.io Methods
|
|
372
|
+
|
|
373
|
+
These use socket.io via `@hailer/cli`, not HTTP requests.
|
|
374
|
+
|
|
375
|
+
### 9. Follow/Unfollow Activity (`activities.follow`)
|
|
376
|
+
|
|
377
|
+
Join or leave an activity's discussion by following/unfollowing it.
|
|
378
|
+
|
|
379
|
+
**Usage**:
|
|
380
|
+
```typescript
|
|
381
|
+
await client.socket.call('activities.follow', {
|
|
382
|
+
activityId: "activity-id",
|
|
383
|
+
follow: true // true to join, false to leave
|
|
384
|
+
});
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
**Behavior**:
|
|
388
|
+
- Following an activity automatically joins its discussion
|
|
389
|
+
- Unfollowing leaves the discussion
|
|
390
|
+
- Toggles follow state
|
|
391
|
+
|
|
392
|
+
---
|
|
393
|
+
|
|
394
|
+
### 10. Leave Discussion (`messenger.leave_discussion`)
|
|
395
|
+
|
|
396
|
+
Leave any discussion directly (not activity-specific).
|
|
397
|
+
|
|
398
|
+
**Usage**:
|
|
399
|
+
```typescript
|
|
400
|
+
await client.socket.call('messenger.leave_discussion', {
|
|
401
|
+
discussionId: "discussion-id"
|
|
402
|
+
});
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
---
|
|
406
|
+
|
|
407
|
+
## Implementation Pattern
|
|
408
|
+
|
|
409
|
+
When adding a new API endpoint:
|
|
410
|
+
|
|
411
|
+
1. **Add function to `hailer-api.ts`**:
|
|
412
|
+
```typescript
|
|
413
|
+
export async function myNewEndpoint(
|
|
414
|
+
client: HailerClient,
|
|
415
|
+
arg1: string,
|
|
416
|
+
options: any = {}
|
|
417
|
+
): Promise<any> {
|
|
418
|
+
const response = await fetch(
|
|
419
|
+
`${client.baseUrl}/v3/my/endpoint`,
|
|
420
|
+
{
|
|
421
|
+
method: 'POST',
|
|
422
|
+
headers: {
|
|
423
|
+
'Content-Type': 'application/json',
|
|
424
|
+
'hlrkey': client.authToken
|
|
425
|
+
},
|
|
426
|
+
body: JSON.stringify([arg1, options])
|
|
427
|
+
}
|
|
428
|
+
);
|
|
429
|
+
|
|
430
|
+
if (!response.ok) {
|
|
431
|
+
throw new Error(`API error: ${response.statusText}`);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
return response.json();
|
|
435
|
+
}
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
2. **Add tool to static tool class** (ReadTools, WriteTools, etc.)
|
|
439
|
+
|
|
440
|
+
3. **Register in GlobalToolRegistry**
|
|
441
|
+
|
|
442
|
+
4. **Test with debug endpoint** or Claude Code
|
|
443
|
+
|
|
444
|
+
5. **Update tool description** with ✅ status
|
|
445
|
+
|
|
446
|
+
---
|
|
447
|
+
|
|
448
|
+
## Error Handling
|
|
449
|
+
|
|
450
|
+
**Common HTTP Status Codes**:
|
|
451
|
+
- `401` - Invalid or missing authentication
|
|
452
|
+
- `403` - Insufficient permissions
|
|
453
|
+
- `404` - Endpoint or resource not found
|
|
454
|
+
- `422` - Validation error (check request format)
|
|
455
|
+
- `500` - Server error
|
|
456
|
+
|
|
457
|
+
**Error Response Format**:
|
|
458
|
+
```javascript
|
|
459
|
+
{
|
|
460
|
+
error: "Error message",
|
|
461
|
+
details: { ... }
|
|
462
|
+
}
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
**Always wrap API calls in try/catch**:
|
|
466
|
+
```typescript
|
|
467
|
+
try {
|
|
468
|
+
const result = await apiFunction();
|
|
469
|
+
return formatSuccess(result);
|
|
470
|
+
} catch (error) {
|
|
471
|
+
console.error('API error:', error);
|
|
472
|
+
return `Error: ${error.message}`;
|
|
473
|
+
}
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
---
|
|
477
|
+
|
|
478
|
+
## Testing Endpoints
|
|
479
|
+
|
|
480
|
+
Use the MCP server's debug endpoint:
|
|
481
|
+
|
|
482
|
+
```bash
|
|
483
|
+
curl -X POST http://localhost:3030/api/debug/execute-tool \
|
|
484
|
+
-H "Content-Type: application/json" \
|
|
485
|
+
-d '{
|
|
486
|
+
"apiKey": "test-key",
|
|
487
|
+
"toolName": "list_activities",
|
|
488
|
+
"args": {
|
|
489
|
+
"workflowId": "68446dc05b30685f67c6fcd4",
|
|
490
|
+
"limit": 10
|
|
491
|
+
}
|
|
492
|
+
}'
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
Or use Claude Code with the MCP connection:
|
|
496
|
+
```
|
|
497
|
+
claude mcp
|
|
498
|
+
# Then: list activities in workflow X
|
|
499
|
+
```
|