@hailer/mcp 1.0.28 → 1.1.2

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 (233) hide show
  1. package/.claude/.session-checked +1 -0
  2. package/.claude/agents/agent-ada-skill-builder.md +10 -2
  3. package/.claude/agents/agent-alejandro-function-fields.md +104 -37
  4. package/.claude/agents/agent-bjorn-config-audit.md +41 -21
  5. package/.claude/agents/agent-builder-agent-creator.md +13 -3
  6. package/.claude/agents/agent-code-simplifier.md +53 -0
  7. package/.claude/agents/agent-dmitri-activity-crud.md +126 -11
  8. package/.claude/agents/agent-giuseppe-app-builder.md +212 -22
  9. package/.claude/agents/agent-gunther-mcp-tools.md +7 -36
  10. package/.claude/agents/agent-helga-workflow-config.md +75 -10
  11. package/.claude/agents/agent-igor-activity-mover-automation.md +125 -0
  12. package/.claude/agents/agent-ingrid-doc-templates.md +164 -36
  13. package/.claude/agents/agent-ivan-monolith.md +154 -0
  14. package/.claude/agents/agent-kenji-data-reader.md +15 -8
  15. package/.claude/agents/agent-lars-code-inspector.md +56 -8
  16. package/.claude/agents/agent-marco-mockup-builder.md +110 -0
  17. package/.claude/agents/agent-marcus-api-documenter.md +323 -0
  18. package/.claude/agents/agent-marketplace-publisher.md +232 -72
  19. package/.claude/agents/agent-marketplace-reviewer.md +255 -79
  20. package/.claude/agents/agent-permissions-handler.md +208 -0
  21. package/.claude/agents/agent-simple-writer.md +48 -0
  22. package/.claude/agents/agent-svetlana-code-review.md +127 -14
  23. package/.claude/agents/agent-tanya-test-runner.md +333 -0
  24. package/.claude/agents/agent-ui-designer.md +100 -0
  25. package/.claude/agents/agent-viktor-sql-insights.md +19 -6
  26. package/.claude/agents/agent-web-search.md +55 -0
  27. package/.claude/agents/agent-yevgeni-discussions.md +7 -1
  28. package/.claude/agents/agent-zara-zapier.md +159 -0
  29. package/.claude/commands/app-squad.md +135 -0
  30. package/.claude/commands/audit-squad.md +158 -0
  31. package/.claude/commands/autoplan.md +563 -0
  32. package/.claude/commands/cleanup-squad.md +98 -0
  33. package/.claude/commands/config-squad.md +106 -0
  34. package/.claude/commands/crud-squad.md +87 -0
  35. package/.claude/commands/data-squad.md +97 -0
  36. package/.claude/commands/debug-squad.md +303 -0
  37. package/.claude/commands/doc-squad.md +65 -0
  38. package/.claude/commands/handoff.md +137 -0
  39. package/.claude/commands/health.md +49 -0
  40. package/.claude/commands/help.md +2 -1
  41. package/.claude/commands/help:agents.md +96 -16
  42. package/.claude/commands/help:commands.md +55 -11
  43. package/.claude/commands/help:faq.md +16 -1
  44. package/.claude/commands/help:skills.md +93 -0
  45. package/.claude/commands/hotfix-squad.md +112 -0
  46. package/.claude/commands/integration-squad.md +82 -0
  47. package/.claude/commands/janitor-squad.md +167 -0
  48. package/.claude/commands/learn-auto.md +120 -0
  49. package/.claude/commands/learn.md +120 -0
  50. package/.claude/commands/mcp-list.md +27 -0
  51. package/.claude/commands/onboard-squad.md +140 -0
  52. package/.claude/commands/plan-workspace.md +732 -0
  53. package/.claude/commands/prd.md +131 -0
  54. package/.claude/commands/project-status.md +82 -0
  55. package/.claude/commands/publish.md +138 -0
  56. package/.claude/commands/recap.md +69 -0
  57. package/.claude/commands/restore.md +64 -0
  58. package/.claude/commands/review-squad.md +152 -0
  59. package/.claude/commands/save.md +24 -0
  60. package/.claude/commands/stats.md +19 -0
  61. package/.claude/commands/swarm.md +210 -0
  62. package/.claude/commands/tool-builder.md +3 -1
  63. package/.claude/commands/ws-pull.md +1 -1
  64. package/.claude/commands/yolo-off.md +17 -0
  65. package/.claude/commands/yolo.md +82 -0
  66. package/.claude/hooks/_shared-memory.cjs +305 -0
  67. package/.claude/hooks/_utils.cjs +134 -0
  68. package/.claude/hooks/agent-failure-detector.cjs +164 -79
  69. package/.claude/hooks/agent-usage-logger.cjs +204 -0
  70. package/.claude/hooks/app-edit-guard.cjs +20 -4
  71. package/.claude/hooks/auto-learn.cjs +316 -0
  72. package/.claude/hooks/bash-guard.cjs +282 -0
  73. package/.claude/hooks/builder-mode-manager.cjs +183 -54
  74. package/.claude/hooks/bulk-activity-guard.cjs +283 -0
  75. package/.claude/hooks/context-watchdog.cjs +292 -0
  76. package/.claude/hooks/delegation-reminder.cjs +478 -0
  77. package/.claude/hooks/design-system-lint.cjs +283 -0
  78. package/.claude/hooks/post-scaffold-hook.cjs +16 -3
  79. package/.claude/hooks/prompt-guard.cjs +366 -0
  80. package/.claude/hooks/publish-template-guard.cjs +16 -0
  81. package/.claude/hooks/session-start.cjs +35 -0
  82. package/.claude/hooks/shared-memory-writer.cjs +147 -0
  83. package/.claude/hooks/skill-injector.cjs +140 -0
  84. package/.claude/hooks/skill-usage-logger.cjs +258 -0
  85. package/.claude/hooks/src-edit-guard.cjs +16 -1
  86. package/.claude/hooks/sync-marketplace-agents.cjs +53 -8
  87. package/.claude/scripts/yolo-toggle.cjs +142 -0
  88. package/.claude/settings.json +141 -14
  89. package/.claude/skills/SDK-activity-patterns/SKILL.md +428 -0
  90. package/.claude/skills/SDK-document-templates/SKILL.md +1033 -0
  91. package/.claude/skills/SDK-function-fields/SKILL.md +542 -0
  92. package/.claude/skills/SDK-generate-skill/SKILL.md +92 -0
  93. package/.claude/skills/SDK-init-skill/SKILL.md +127 -0
  94. package/.claude/skills/SDK-insight-queries/SKILL.md +787 -0
  95. package/.claude/skills/SDK-ws-config-skill/SKILL.md +1139 -0
  96. package/.claude/skills/agent-structure/SKILL.md +98 -0
  97. package/.claude/skills/api-documentation-patterns/SKILL.md +474 -0
  98. package/.claude/skills/chrome-mcp-reference/SKILL.md +370 -0
  99. package/.claude/skills/delegation-routing/SKILL.md +202 -0
  100. package/.claude/skills/frontend-design/SKILL.md +254 -0
  101. package/.claude/skills/hailer-activity-mover/SKILL.md +213 -0
  102. package/.claude/skills/hailer-api-client/SKILL.md +518 -0
  103. package/.claude/skills/hailer-app-builder/SKILL.md +939 -11
  104. package/.claude/skills/hailer-apps-pictures/SKILL.md +269 -0
  105. package/.claude/skills/hailer-design-system/SKILL.md +235 -0
  106. package/.claude/skills/hailer-monolith-automations/SKILL.md +686 -0
  107. package/.claude/skills/hailer-permissions-system/SKILL.md +121 -0
  108. package/.claude/skills/hailer-project-protocol/SKILL.md +488 -0
  109. package/.claude/skills/hailer-rest-api/SKILL.md +61 -0
  110. package/.claude/skills/hailer-rest-api/hailer-activities.md +184 -0
  111. package/.claude/skills/hailer-rest-api/hailer-admin.md +473 -0
  112. package/.claude/skills/hailer-rest-api/hailer-calendar.md +256 -0
  113. package/.claude/skills/hailer-rest-api/hailer-feed.md +249 -0
  114. package/.claude/skills/hailer-rest-api/hailer-insights.md +195 -0
  115. package/.claude/skills/hailer-rest-api/hailer-messaging.md +276 -0
  116. package/.claude/skills/hailer-rest-api/hailer-workflows.md +283 -0
  117. package/.claude/skills/insight-join-patterns/SKILL.md +3 -0
  118. package/.claude/skills/integration-patterns/SKILL.md +421 -0
  119. package/.claude/skills/json-only-output/SKILL.md +52 -12
  120. package/.claude/skills/lsp-setup/SKILL.md +160 -0
  121. package/.claude/skills/mcp-direct-tools/SKILL.md +153 -0
  122. package/.claude/skills/optional-parameters/SKILL.md +32 -23
  123. package/.claude/skills/publish-hailer-app/SKILL.md +76 -12
  124. package/.claude/skills/testing-patterns/SKILL.md +630 -0
  125. package/.claude/skills/tool-builder/SKILL.md +250 -0
  126. package/.claude/skills/tool-parameter-usage/SKILL.md +59 -45
  127. package/.claude/skills/tool-response-verification/SKILL.md +82 -48
  128. package/.claude/skills/zapier-hailer-patterns/SKILL.md +581 -0
  129. package/.env.example +26 -7
  130. package/CLAUDE.md +290 -224
  131. package/dist/CLAUDE.md +370 -0
  132. package/dist/app.d.ts +1 -1
  133. package/dist/app.js +101 -101
  134. package/dist/bot/bot-config.d.ts +26 -0
  135. package/dist/bot/bot-config.js +135 -0
  136. package/dist/bot/bot-manager.d.ts +40 -0
  137. package/dist/bot/bot-manager.js +137 -0
  138. package/dist/bot/bot.d.ts +127 -0
  139. package/dist/bot/bot.js +1328 -0
  140. package/dist/bot/operation-logger.d.ts +28 -0
  141. package/dist/bot/operation-logger.js +132 -0
  142. package/dist/bot/services/conversation-manager.d.ts +60 -0
  143. package/dist/bot/services/conversation-manager.js +246 -0
  144. package/dist/bot/services/index.d.ts +9 -0
  145. package/dist/bot/services/index.js +18 -0
  146. package/dist/bot/services/message-classifier.d.ts +42 -0
  147. package/dist/bot/services/message-classifier.js +228 -0
  148. package/dist/bot/services/message-formatter.d.ts +88 -0
  149. package/dist/bot/services/message-formatter.js +411 -0
  150. package/dist/bot/services/session-logger.d.ts +162 -0
  151. package/dist/bot/services/session-logger.js +724 -0
  152. package/dist/bot/services/token-billing.d.ts +78 -0
  153. package/dist/bot/services/token-billing.js +233 -0
  154. package/dist/bot/services/types.d.ts +169 -0
  155. package/dist/bot/services/types.js +12 -0
  156. package/dist/bot/services/typing-indicator.d.ts +23 -0
  157. package/dist/bot/services/typing-indicator.js +60 -0
  158. package/dist/bot/services/workspace-schema-cache.d.ts +122 -0
  159. package/dist/bot/services/workspace-schema-cache.js +506 -0
  160. package/dist/bot/tool-executor.d.ts +28 -0
  161. package/dist/bot/tool-executor.js +48 -0
  162. package/dist/bot/workspace-overview.d.ts +12 -0
  163. package/dist/bot/workspace-overview.js +94 -0
  164. package/dist/cli.d.ts +1 -8
  165. package/dist/cli.js +1 -249
  166. package/dist/config.d.ts +96 -3
  167. package/dist/config.js +148 -37
  168. package/dist/core.d.ts +5 -0
  169. package/dist/core.js +61 -8
  170. package/dist/lib/discussion-lock.d.ts +42 -0
  171. package/dist/lib/discussion-lock.js +110 -0
  172. package/dist/lib/logger.d.ts +0 -1
  173. package/dist/lib/logger.js +39 -23
  174. package/dist/lib/request-logger.d.ts +77 -0
  175. package/dist/lib/request-logger.js +147 -0
  176. package/dist/mcp/UserContextCache.js +16 -13
  177. package/dist/mcp/hailer-clients.js +18 -17
  178. package/dist/mcp/signal-handler.js +29 -13
  179. package/dist/mcp/tool-registry.d.ts +4 -15
  180. package/dist/mcp/tool-registry.js +94 -32
  181. package/dist/mcp/tools/activity.js +28 -69
  182. package/dist/mcp/tools/app-core.js +9 -4
  183. package/dist/mcp/tools/app-marketplace.js +22 -12
  184. package/dist/mcp/tools/app-member.js +5 -2
  185. package/dist/mcp/tools/app-scaffold.js +32 -18
  186. package/dist/mcp/tools/bot-config/constants.d.ts +23 -0
  187. package/dist/mcp/tools/bot-config/constants.js +94 -0
  188. package/dist/mcp/tools/bot-config/core.d.ts +253 -0
  189. package/dist/mcp/tools/bot-config/core.js +2456 -0
  190. package/dist/mcp/tools/bot-config/index.d.ts +10 -0
  191. package/dist/mcp/tools/bot-config/index.js +59 -0
  192. package/dist/mcp/tools/bot-config/tools.d.ts +7 -0
  193. package/dist/mcp/tools/bot-config/tools.js +15 -0
  194. package/dist/mcp/tools/bot-config/types.d.ts +50 -0
  195. package/dist/mcp/tools/bot-config/types.js +6 -0
  196. package/dist/mcp/tools/discussion.js +107 -77
  197. package/dist/mcp/tools/document.d.ts +11 -0
  198. package/dist/mcp/tools/document.js +741 -0
  199. package/dist/mcp/tools/file.js +5 -2
  200. package/dist/mcp/tools/insight.js +36 -12
  201. package/dist/mcp/tools/investigate.d.ts +9 -0
  202. package/dist/mcp/tools/investigate.js +254 -0
  203. package/dist/mcp/tools/user.d.ts +2 -4
  204. package/dist/mcp/tools/user.js +9 -50
  205. package/dist/mcp/tools/workflow.d.ts +1 -0
  206. package/dist/mcp/tools/workflow.js +164 -52
  207. package/dist/mcp/utils/hailer-api-client.js +26 -17
  208. package/dist/mcp/webhook-handler.d.ts +64 -3
  209. package/dist/mcp/webhook-handler.js +219 -9
  210. package/dist/mcp-server.d.ts +4 -0
  211. package/dist/mcp-server.js +237 -25
  212. package/dist/plugins/bug-fixer/index.d.ts +2 -0
  213. package/dist/plugins/bug-fixer/index.js +18 -0
  214. package/dist/plugins/bug-fixer/tools.d.ts +45 -0
  215. package/dist/plugins/bug-fixer/tools.js +1096 -0
  216. package/package.json +10 -10
  217. package/scripts/test-hal-tools.ts +154 -0
  218. package/.claude/agents/agent-nora-name-functions.md +0 -123
  219. package/.claude/assistant-knowledge.md +0 -23
  220. package/.claude/commands/install-plugin.md +0 -261
  221. package/.claude/commands/list-plugins.md +0 -42
  222. package/.claude/commands/marketplace-setup.md +0 -33
  223. package/.claude/commands/publish-plugin.md +0 -55
  224. package/.claude/commands/uninstall-plugin.md +0 -87
  225. package/.claude/hooks/interactive-mode.cjs +0 -87
  226. package/.claude/hooks/mcp-server-guard.cjs +0 -108
  227. package/.claude/skills/marketplace-publishing.md +0 -155
  228. package/dist/bot/chat-bot.d.ts +0 -31
  229. package/dist/bot/chat-bot.js +0 -357
  230. package/dist/mcp/tools/metrics.d.ts +0 -13
  231. package/dist/mcp/tools/metrics.js +0 -546
  232. package/dist/stdio-server.d.ts +0 -14
  233. package/dist/stdio-server.js +0 -114
@@ -0,0 +1,581 @@
1
+ ---
2
+ name: zapier-hailer-patterns
3
+ description: Patterns for building Zapier integrations with Hailer REST API
4
+ version: 1.0.1
5
+ triggers: When building Zapier automations, webhook triggers, or API integrations
6
+ ---
7
+
8
+ # Zapier-Hailer Integration Patterns
9
+
10
+ Use this skill when building Zapier automations that integrate with Hailer.
11
+
12
+ ## Key Insight: Zapier + Any REST API
13
+
14
+ Zapier doesn't have a native Hailer integration, but **Webhooks by Zapier** can connect to ANY REST API. This means:
15
+ - Hailer's full REST API is available via Zapier
16
+ - Same pattern works for any external system with REST API
17
+
18
+ ---
19
+
20
+ ## CRITICAL: Custom Request Configuration
21
+
22
+ **#1 Zapier mistake: Not setting `return_raw_response`**
23
+
24
+ Every Custom Request step MUST set `return_raw_response: true` (or `"yes"` in JSON).
25
+
26
+ Without this parameter:
27
+ - Zapier returns only HTTP status (200 OK), not the response body
28
+ - You can't get created activity IDs
29
+ - You can't parse API responses in Code steps
30
+ - You can't chain API calls using returned data
31
+
32
+ **Always include this:**
33
+ ```json
34
+ {
35
+ "method": "POST",
36
+ "url": "https://api.hailer.com/api/v3/activity/create",
37
+ "return_raw_response": "yes" // ← ESSENTIAL - Enables access to response body
38
+ }
39
+ ```
40
+
41
+ This single parameter fixes 90% of "Zap runs but I can't access the data" issues.
42
+
43
+ ---
44
+
45
+ ## Knowledge Sources
46
+
47
+ **Always query NotebookLM first** for detailed patterns and examples:
48
+
49
+ ```
50
+ Notebook: "Zapier-opas Haileriin: Automaatio, AI-orkestointi ja yritysratkaisut"
51
+ ID: 2d93afb6-6378-45e7-b380-3ee3c235244f
52
+ ```
53
+
54
+ This notebook contains:
55
+ - Hailer REST API documentation
56
+ - Authentication patterns
57
+ - Field type formats
58
+ - Example zaps with annotations
59
+ - Webhook configuration guides
60
+
61
+ **Also check:** "Hailer REST-api" notebook (ID: `68e4e3fd-6ed6-4e0b-b624-672773ba4142`) for API endpoint details.
62
+
63
+ ## Quick Reference
64
+
65
+ ### Authentication
66
+ ```
67
+ POST https://api.hailer.com/api/login
68
+ Body: {"0": "email", "1": "password"}
69
+ Returns: Session key → use as "hlrkey" header
70
+ ```
71
+
72
+ ### Webhook Triggers
73
+ - Configured per-phase in Hailer (not per-workflow)
74
+ - Set `webhooksEnabled: true` and `webhookUrl` on phase
75
+
76
+ **CRITICAL: Webhook Payload Structure**
77
+ ```typescript
78
+ {
79
+ _id: string; // Activity ID (MongoDB ObjectId)
80
+ name: string; // Activity name
81
+ currentPhase: string; // Phase ID (MongoDB ObjectId)
82
+ process: string; // Workflow ID (MongoDB ObjectId)
83
+ fields: Array<{
84
+ id: string; // Field ID (MongoDB ObjectId)
85
+ type: string; // Field type
86
+ value: any; // Field value
87
+ key?: string; // Optional field key (human-readable)
88
+ }>;
89
+ }
90
+ ```
91
+
92
+ **Finding field values - two methods:**
93
+ ```javascript
94
+ // Method 1: By key (if field has key property - preferred when available)
95
+ const tagValue = fields.find(f => f.key === 'tag')?.value;
96
+
97
+ // Method 2: By fieldId (always works - use real MongoDB IDs)
98
+ const tagValue = fields.find(f => f.id === '507f1f77bcf86cd799439011')?.value;
99
+ ```
100
+
101
+ **⚠️ NEVER use SDK enums in automations.** Webhooks receive raw MongoDB ObjectIds, not SDK enum names. Use real IDs from the workspace or extract from payload.
102
+
103
+ ### Activity Creation
104
+ ```
105
+ POST https://api.hailer.com/api/v3/activity/create
106
+ Headers: Content-Type: application/json, hlrkey: <session_key>
107
+ Body: {
108
+ "0": "workflowId",
109
+ "1": {
110
+ "name": "Activity name",
111
+ "phaseId": "phaseId",
112
+ "teamId": "teamId",
113
+ "fields": { "fieldId": "value" }
114
+ }
115
+ }
116
+ ```
117
+
118
+ ### Field Types
119
+ | Type | Format |
120
+ |------|--------|
121
+ | text/textarea | String |
122
+ | date | Timestamp in milliseconds |
123
+ | users | 24-char userId |
124
+ | activitylink | 24-char activityId |
125
+ | textpredefinedoptions | Exact option string |
126
+
127
+ ### Zapier Tips
128
+ - **Always set `return_raw_response: true`** in Custom Request steps - this gives you the full JSON response for parsing in subsequent code steps
129
+ - Webhook payloads use `id` (not `_id`) for field identifiers
130
+ - Use Code steps to parse and transform data between API calls
131
+ - Search fields by `key` property when available (e.g., `f.key === 'user'`) for more readable code
132
+ - **For Dataset workflows:** `phaseId` must be in the OPTIONS object (third parameter "2"), not in the activity object
133
+
134
+ ### Zapier Import/Export JSON Format
135
+
136
+ Zaps can be exported and imported as JSON files. This is useful for:
137
+ - Version controlling automations in git
138
+ - Sharing zap templates between projects
139
+ - Backing up zap configurations
140
+
141
+ **Top-level structure:**
142
+ ```json
143
+ {
144
+ "metadata": { "version": 2 },
145
+ "zaps": [{
146
+ "id": 1,
147
+ "title": "Zap name",
148
+ "nodes": {
149
+ "1": { /* trigger */ },
150
+ "2": { /* action 1 */ },
151
+ "3": { /* action 2 */ }
152
+ }
153
+ }]
154
+ }
155
+ ```
156
+
157
+ **Node structure:**
158
+ ```json
159
+ {
160
+ "id": 1,
161
+ "paused": false,
162
+ "type_of": "read", // "read" = trigger, "write" = action
163
+ "params": {}, // Step-specific parameters
164
+ "meta": { "$editor": { "has_automatic_issues": false }, "timezone": "Europe/Helsinki" },
165
+ "triple_stores": { "copied_from": null, "created_by": null, "polling_interval_override": 0, "block_and_release_limit_override": 0, "spread_tasks": 1 },
166
+ "parent_id": null, // null for trigger, previous node id for actions
167
+ "root_id": null, // null for trigger, 1 for all actions
168
+ "action": "hook_raw", // Action type (see below)
169
+ "selected_api": "WebHookCLIAPI@1.0.29",
170
+ "title": "Step title",
171
+ "authentication_id": null
172
+ }
173
+ ```
174
+
175
+ **Action types:**
176
+ | action | selected_api | Purpose |
177
+ |--------|--------------|---------|
178
+ | `hook_raw` | WebHookCLIAPI@1.0.29 | Catch Webhook trigger |
179
+ | `post` | WebHookCLIAPI@1.0.29 | POST request |
180
+ | `custom` | WebHookCLIAPI@1.0.29 | Custom Request (GET/POST/PUT) |
181
+ | `01929fad-d3dd-...` | CodeCLIAPI@1.0.1 | Run JavaScript code |
182
+
183
+ **Data references between steps:**
184
+ Use `{{node_id__field}}` syntax:
185
+ - `{{1__raw_body}}` - Raw body from trigger
186
+ - `{{2__results}}` - Results from node 2 (e.g., session key from login)
187
+ - `{{3__payload}}` - Output field from code step
188
+
189
+ **Example: Webhook → Login → Code → Create Activity**
190
+ ```json
191
+ {
192
+ "metadata": { "version": 2 },
193
+ "zaps": [{
194
+ "id": 1,
195
+ "title": "Phase webhook → Create task",
196
+ "nodes": {
197
+ "1": {
198
+ "id": 1, "type_of": "read", "action": "hook_raw",
199
+ "selected_api": "WebHookCLIAPI@1.0.29",
200
+ "title": "Catch webhook", "parent_id": null, "root_id": null,
201
+ "params": {}, "paused": false, "authentication_id": null,
202
+ "meta": { "$editor": { "has_automatic_issues": false }, "timezone": "Europe/Helsinki" },
203
+ "triple_stores": { "copied_from": null, "created_by": null, "polling_interval_override": 0, "block_and_release_limit_override": 0, "spread_tasks": 1 }
204
+ },
205
+ "2": {
206
+ "id": 2, "type_of": "write", "action": "post",
207
+ "selected_api": "WebHookCLIAPI@1.0.29",
208
+ "title": "Login to Hailer", "parent_id": 1, "root_id": 1,
209
+ "params": {
210
+ "payload_type": "json", "wrap_in_array": "no", "unflatten": "yes",
211
+ "url": "https://api.hailer.com/api/login",
212
+ "data": { "0": "user@example.com", "1": "PASSWORD" },
213
+ "headers": { "Content-Type": "application/json" }
214
+ },
215
+ "paused": false, "authentication_id": null,
216
+ "meta": { "$editor": { "has_automatic_issues": false }, "parammap": {} },
217
+ "triple_stores": { "copied_from": null, "created_by": null, "polling_interval_override": 0, "block_and_release_limit_override": 0, "spread_tasks": 1 }
218
+ },
219
+ "3": {
220
+ "id": 3, "type_of": "write", "action": "01929fad-d3dd-62c2-52ed-7868d5fcc691",
221
+ "selected_api": "CodeCLIAPI@1.0.1",
222
+ "title": "Build payload", "parent_id": 2, "root_id": 1,
223
+ "params": {
224
+ "code": "const body = JSON.parse(inputData.rawBody);\\nconst payload = { \"0\": \"workflowId\", \"1\": { ... } };\\nreturn { payload: JSON.stringify(payload) };",
225
+ "input": { "rawBody": "{{1__raw_body}}" }
226
+ },
227
+ "paused": false, "authentication_id": null,
228
+ "meta": { "$editor": { "has_automatic_issues": false }, "parammap": {} },
229
+ "triple_stores": { "copied_from": null, "created_by": null, "polling_interval_override": 0, "block_and_release_limit_override": 0, "spread_tasks": 1 }
230
+ },
231
+ "4": {
232
+ "id": 4, "type_of": "write", "action": "custom",
233
+ "selected_api": "WebHookCLIAPI@1.0.29",
234
+ "title": "Create activity", "parent_id": 3, "root_id": 1,
235
+ "params": {
236
+ "method": "POST", "unflatten": "yes", "return_raw_response": "no",
237
+ "url": "https://api.hailer.com/api/v3/activity/create",
238
+ "headers": { "Content-Type": "application/json", "hlrkey": "{{2__results}}" },
239
+ "data": "{{3__payload}}"
240
+ },
241
+ "paused": false, "authentication_id": null,
242
+ "meta": { "$editor": { "has_automatic_issues": false }, "parammap": {} },
243
+ "triple_stores": { "copied_from": null, "created_by": null, "polling_interval_override": 0, "block_and_release_limit_override": 0, "spread_tasks": 1 }
244
+ }
245
+ }
246
+ }]
247
+ }
248
+ ```
249
+
250
+ **See also:** `sdk-projects/pohjaset/automations/` for real-world examples with annotations
251
+
252
+ ---
253
+
254
+ ## Zapier Built-in Tools Reference
255
+
256
+ These are Zapier's native apps - no external service needed. Essential for Hailer integrations.
257
+
258
+ ### Webhooks by Zapier
259
+ **API:** `WebHookCLIAPI@1.0.29`
260
+
261
+ | Trigger/Action | Purpose | Key Params |
262
+ |----------------|---------|------------|
263
+ | **Catch Hook** (trigger) | Receive webhook from Hailer phase | `action: "hook_raw"` |
264
+ | **Catch Raw Hook** (trigger) | Same, preserves raw body | `action: "hook_raw"` |
265
+ | **Custom Request** (action) | Any HTTP request | `action: "custom"`, `method`, `url`, `headers`, `data` |
266
+ | **POST** (action) | Simple POST | `action: "post"`, `url`, `data` |
267
+ | **GET** (action) | Simple GET | `action: "get"`, `url` |
268
+ | **PUT** (action) | Simple PUT | `action: "put"`, `url`, `data` |
269
+
270
+ **Custom Request params:**
271
+ ```json
272
+ {
273
+ "method": "POST",
274
+ "url": "https://api.hailer.com/api/v3/activity/create",
275
+ "headers": { "Content-Type": "application/json", "hlrkey": "{{2__results}}" },
276
+ "data": "{{3__payload}}",
277
+ "unflatten": "yes",
278
+ "return_raw_response": "yes"
279
+ }
280
+ ```
281
+
282
+ ### Code by Zapier
283
+ **API:** `CodeCLIAPI@1.0.1`
284
+
285
+ | Action | Purpose | Key Params |
286
+ |--------|---------|------------|
287
+ | **Run JavaScript** | Transform data, build payloads | `action: "01929fad-d3dd-62c2-52ed-7868d5fcc691"` |
288
+ | **Run Python** | Same, Python syntax | Different action UUID |
289
+
290
+ **JavaScript params:**
291
+ ```json
292
+ {
293
+ "code": "const data = JSON.parse(inputData.rawBody);\\nreturn { result: data.field };",
294
+ "input": { "rawBody": "{{1__raw_body}}", "sessionKey": "{{2__results}}" }
295
+ }
296
+ ```
297
+
298
+ **Code tips:**
299
+ - Access inputs via `inputData.variableName`
300
+ - Return object with named outputs: `return { payload, email, id };`
301
+ - Can use `fetch` for additional API calls (async supported)
302
+ - Output fields available as `{{node__fieldname}}`
303
+
304
+ ### Filter by Zapier
305
+ **API:** `FilterAPI` (legacy, still works)
306
+
307
+ Conditionally continue or stop the Zap. Note: `type_of` is `"filter"` (not "write").
308
+
309
+ | Action | Purpose |
310
+ |--------|---------|
311
+ | `filter` | Only continue if conditions match |
312
+
313
+ **Params:**
314
+ ```json
315
+ {
316
+ "selected_api": "FilterAPI",
317
+ "action": "filter",
318
+ "type_of": "filter",
319
+ "params": {
320
+ "filter_criteria": [
321
+ {
322
+ "id": 4699009700892223,
323
+ "group": 4153161264351725,
324
+ "key": "{{1__status}}",
325
+ "value": "approved",
326
+ "match": "icontains",
327
+ "action": "continue"
328
+ }
329
+ ]
330
+ }
331
+ }
332
+ ```
333
+
334
+ **Match types:** `icontains`, `inot_contains`, `iexact`, `inot_exact`, `is_set`, `not_set`, `greater_than`, `less_than`
335
+
336
+ ### Paths by Zapier
337
+ **API:** `BranchingAPI` (419 uses found)
338
+
339
+ Conditional branching - different actions based on conditions. Note: Uses `BranchingAPI` not `PathsCLIAPI`.
340
+
341
+ ```json
342
+ {
343
+ "selected_api": "BranchingAPI",
344
+ "action": "branch",
345
+ "type_of": "branching",
346
+ "params": {
347
+ "branches": [
348
+ {
349
+ "name": "Path A - Approved",
350
+ "filter_criteria": [
351
+ { "key": "{{1__status}}", "value": "approved", "match": "iexact" }
352
+ ]
353
+ },
354
+ {
355
+ "name": "Path B - Rejected",
356
+ "filter_criteria": [
357
+ { "key": "{{1__status}}", "value": "rejected", "match": "iexact" }
358
+ ]
359
+ }
360
+ ]
361
+ }
362
+ }
363
+ ```
364
+
365
+ ### Formatter by Zapier
366
+ **API:** `ZapierFormatterCLIAPI@1.0.7`
367
+
368
+ Transform text, dates, numbers without code.
369
+
370
+ | Action | Purpose |
371
+ |--------|---------|
372
+ | `datetime_line_item` | Format dates |
373
+ | `text_line_item` | Manipulate strings |
374
+ | `util_line_item` | Utilities (lookup, pick) |
375
+
376
+ **Date format (useful for Hailer timestamps):**
377
+ ```json
378
+ {
379
+ "selected_api": "ZapierFormatterCLIAPI@1.0.7",
380
+ "action": "datetime_line_item",
381
+ "type_of": "write",
382
+ "params": {
383
+ "transform": "date.formatting",
384
+ "to_timezone": "UTC",
385
+ "from_timezone": "UTC",
386
+ "inputs": "{{1__timestamp}}",
387
+ "to_format": "YYYY-MM-DD"
388
+ }
389
+ }
390
+ ```
391
+
392
+ **Text transform:**
393
+ ```json
394
+ {
395
+ "selected_api": "ZapierFormatterCLIAPI@1.0.7",
396
+ "action": "text_line_item",
397
+ "type_of": "write",
398
+ "params": {
399
+ "transform": "text.replace",
400
+ "inputs": "{{1__email}}",
401
+ "find": "@old-domain.com",
402
+ "replace": "@new-domain.com"
403
+ }
404
+ }
405
+ ```
406
+ Note: Hailer uses milliseconds, Zapier's `X` is seconds - divide by 1000 in Code step or use date formatting.
407
+
408
+ ### Delay by Zapier
409
+ **API:** `DelayCLIAPI@1.1.1`
410
+
411
+ Pause execution.
412
+
413
+ | Action | Purpose |
414
+ |--------|---------|
415
+ | `delay_for` | Wait specific duration |
416
+
417
+ ```json
418
+ {
419
+ "selected_api": "DelayCLIAPI@1.1.1",
420
+ "action": "delay_for",
421
+ "type_of": "write",
422
+ "params": {
423
+ "delay_for_value": "5",
424
+ "delay_for_unit": "minutes"
425
+ }
426
+ }
427
+ ```
428
+
429
+ ### Looping by Zapier
430
+ **API:** `ZapierLoopingCLIAPI@1.2.6`
431
+
432
+ Iterate over arrays (e.g., process multiple activities).
433
+
434
+ | Action | Purpose |
435
+ |--------|---------|
436
+ | `loop_values_line_items` | Loop over line items (objects) |
437
+ | `loop_values_numbers` | Loop over number range |
438
+ | `loop_values_text` | Loop over text items |
439
+
440
+ ```json
441
+ {
442
+ "selected_api": "ZapierLoopingCLIAPI@1.2.6",
443
+ "action": "loop_values_line_items",
444
+ "type_of": "write",
445
+ "params": {
446
+ "trim_whitespace": "True",
447
+ "iteration_start": "1",
448
+ "iteration_limit": "500",
449
+ "loop_values": {
450
+ "activityId": "{{1__activities[]_id}}",
451
+ "name": "{{1__activities[]name}}",
452
+ "status": "{{1__activities[]currentPhase}}"
453
+ }
454
+ }
455
+ }
456
+ ```
457
+
458
+ Access loop outputs: `{{node__activityId}}`, `{{node__name}}`, etc.
459
+
460
+ ### Sub-Zap by Zapier
461
+ **API:** `SubZapCLIAPI@0.11.2`
462
+
463
+ Call another Zap as a subroutine.
464
+
465
+ | Action | Purpose |
466
+ |--------|---------|
467
+ | `start_subzap` | Trigger (receives call from parent) |
468
+ | `call_subzap` | Call another Zap, wait for response |
469
+ | `return_subzap` | Return data to caller |
470
+
471
+ **Trigger (in sub-zap):**
472
+ ```json
473
+ {
474
+ "selected_api": "SubZapCLIAPI@0.11.2",
475
+ "action": "start_subzap",
476
+ "type_of": "read",
477
+ "params": {
478
+ "input_list": ["activityId", "sessionKey", "workflowId"]
479
+ }
480
+ }
481
+ ```
482
+
483
+ **Call (from parent zap):**
484
+ ```json
485
+ {
486
+ "selected_api": "SubZapCLIAPI@0.11.2",
487
+ "action": "call_subzap",
488
+ "type_of": "write",
489
+ "params": {
490
+ "account_id": "5024683",
491
+ "zap_id": "202514585",
492
+ "activityId": "{{1__activityId}}",
493
+ "sessionKey": "{{2__results}}",
494
+ "workflowId": "{{3__workflowId}}"
495
+ }
496
+ }
497
+ ```
498
+
499
+ Useful for reusable logic (e.g., "Login to Hailer" sub-zap).
500
+
501
+ ### Storage by Zapier
502
+ **API:** `StorageCLIAPI@1.2.1`
503
+
504
+ Store and retrieve values across Zap runs.
505
+
506
+ | Action | Purpose |
507
+ |--------|---------|
508
+ | `get_multiple_values` | Retrieve stored values |
509
+ | `list_push` | Add to list |
510
+ | `set_value` | Store key-value pair |
511
+
512
+ **Get values:**
513
+ ```json
514
+ {
515
+ "selected_api": "StorageCLIAPI@1.2.1",
516
+ "action": "get_multiple_values",
517
+ "type_of": "search",
518
+ "params": {
519
+ "_zap_search_success_on_miss": true,
520
+ "keys": ["{{1__activityId}}", "lastSyncTimestamp"]
521
+ }
522
+ }
523
+ ```
524
+
525
+ **Push to list:**
526
+ ```json
527
+ {
528
+ "selected_api": "StorageCLIAPI@1.2.1",
529
+ "action": "list_push",
530
+ "type_of": "write",
531
+ "params": {
532
+ "key": "processedIds",
533
+ "value": "{{1__activityId}}",
534
+ "location": "tail"
535
+ }
536
+ }
537
+ ```
538
+
539
+ Useful for: tracking last sync timestamp, deduplication, counters.
540
+
541
+ ---
542
+
543
+ ## Common Tool Combinations for Hailer
544
+
545
+ | Pattern | Tools Used |
546
+ |---------|------------|
547
+ | **Webhook → Create Activity** | Catch Hook → Code → Custom Request |
548
+ | **Conditional Processing** | Catch Hook → Filter → Code → Custom Request |
549
+ | **Branching Logic** | Catch Hook → Paths → (different actions per path) |
550
+ | **Batch Processing** | Catch Hook → Looping → Custom Request |
551
+ | **Scheduled Sync** | Schedule trigger → Custom Request (list) → Looping → Custom Request (update) |
552
+ | **Date Formatting** | Catch Hook → Formatter (date) → Code → Custom Request |
553
+ | **Reusable Auth** | Sub-Zap for login → Return session key |
554
+
555
+ ---
556
+
557
+ ## Workflow for Building Zaps
558
+
559
+ 1. **Query NotebookLM** for API patterns and field formats
560
+ 2. **Get workspace IDs** using Kenji agent (workflow, phase, field, team IDs)
561
+ 3. **Design the zap flow**: Trigger → (optional code step) → API action
562
+ 4. **Create annotated documentation** for future reference
563
+ 5. **Store zap JSON** in project's `automations/` folder
564
+
565
+ ## Common Zap Patterns
566
+
567
+ ### Hailer Webhook → Hailer Action
568
+ 1. Catch Hook (webhook from Hailer phase)
569
+ 2. Login to get session key
570
+ 3. Code step to build payload
571
+ 4. Custom Request to Hailer API
572
+
573
+ ### External Trigger → Hailer
574
+ 1. Trigger from external app (Gmail, Slack, etc.)
575
+ 2. Login to Hailer
576
+ 3. Create/Update activity via API
577
+
578
+ ### Hailer → External Action
579
+ 1. Catch Hook from Hailer
580
+ 2. Transform data if needed
581
+ 3. Send to external API (Slack, Email, etc.)
package/.env.example CHANGED
@@ -62,13 +62,32 @@
62
62
  # Default: false (nuclear tools completely hidden)
63
63
  # ENABLE_NUCLEAR_TOOLS=true
64
64
 
65
+
65
66
  # ==============================================
66
- # METRICS ADMIN API
67
+ # OPTIONAL: MCP CLIENT CONFIGURATION (automated agent)
67
68
  # ==============================================
68
69
 
69
- # Metrics Admin API (for workspace/user search - requires whitelisted Hailer user)
70
- # These credentials are used for privileged metrics operations like searching all workspaces
71
- # Only whitelisted users can make these API calls
72
- # METRICS_ADMIN_EMAIL=admin@example.com
73
- # METRICS_ADMIN_PASSWORD=your-password
74
- # METRICS_ADMIN_API_URL=https://api.hailer.com
70
+ # Enable the MCP Client (enabled by default)
71
+ MCP_CLIENT_ENABLED=false
72
+
73
+ # LLM Provider API Keys (add at least one)
74
+ # ANTHROPIC_API_KEY=sk-ant-your-key-here
75
+ # OPENAI_API_KEY=sk-your-openai-key-here
76
+
77
+ # MCP Server URL (for client to call our own tools)
78
+ MCP_SERVER_URL=http://localhost:3030/api/mcp
79
+ #MCP_CLIENT_API_KEY=your-api-key
80
+
81
+ # MCP Agent User IDs (required for agent tagging - get these from Hailer)
82
+ MCP_CLIENT_AGENT_IDS='[]'
83
+
84
+ # Bot Features (optional, defaults to true)
85
+ TOKEN_USAGE_BOT_ENABLED=false
86
+ AGENT_ACTIVITY_BOT_ENABLED=false
87
+
88
+ # Adaptive Documentation Bot (automatically improves tool descriptions based on errors)
89
+ ADAPTIVE_DOCUMENTATION_BOT_ENABLED=false
90
+ ADAPTIVE_AUTO_UPDATE=false
91
+ ADAPTIVE_UPDATE_INTERVAL=60000
92
+ ADAPTIVE_MIN_ERROR_COUNT=3
93
+ ADAPTIVE_SKILL_GENERATION=false