runline 0.1.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 (230) hide show
  1. package/.pi/extensions/runline-context/index.ts +135 -0
  2. package/.pi/extensions/runline-context/package.json +17 -0
  3. package/README.md +273 -0
  4. package/dist/commands/actions.d.ts +3 -0
  5. package/dist/commands/actions.js +43 -0
  6. package/dist/commands/connection.d.ts +11 -0
  7. package/dist/commands/connection.js +56 -0
  8. package/dist/commands/exec.d.ts +5 -0
  9. package/dist/commands/exec.js +46 -0
  10. package/dist/commands/init.d.ts +4 -0
  11. package/dist/commands/init.js +26 -0
  12. package/dist/commands/plugin.d.ts +10 -0
  13. package/dist/commands/plugin.js +57 -0
  14. package/dist/config/index.d.ts +3 -0
  15. package/dist/config/index.js +2 -0
  16. package/dist/config/loader.d.ts +11 -0
  17. package/dist/config/loader.js +82 -0
  18. package/dist/config/types.d.ts +9 -0
  19. package/dist/config/types.js +5 -0
  20. package/dist/core/engine.d.ts +21 -0
  21. package/dist/core/engine.js +280 -0
  22. package/dist/index.d.ts +16 -0
  23. package/dist/index.js +9 -0
  24. package/dist/main.d.ts +2 -0
  25. package/dist/main.js +127 -0
  26. package/dist/plugin/api.d.ts +32 -0
  27. package/dist/plugin/api.js +68 -0
  28. package/dist/plugin/installer.d.ts +27 -0
  29. package/dist/plugin/installer.js +181 -0
  30. package/dist/plugin/loader.d.ts +13 -0
  31. package/dist/plugin/loader.js +164 -0
  32. package/dist/plugin/registry.d.ts +18 -0
  33. package/dist/plugin/registry.js +43 -0
  34. package/dist/plugin/types.d.ts +40 -0
  35. package/dist/plugin/types.js +1 -0
  36. package/dist/plugins/actionNetwork/src/index.js +353 -0
  37. package/dist/plugins/activeCampaign/src/index.js +711 -0
  38. package/dist/plugins/adalo/src/index.js +131 -0
  39. package/dist/plugins/affinity/src/index.js +279 -0
  40. package/dist/plugins/agileCrm/src/index.js +415 -0
  41. package/dist/plugins/airtable/src/index.js +280 -0
  42. package/dist/plugins/airtop/src/index.js +527 -0
  43. package/dist/plugins/apiTemplateIo/src/index.js +86 -0
  44. package/dist/plugins/asana/src/index.js +413 -0
  45. package/dist/plugins/autopilot/src/index.js +203 -0
  46. package/dist/plugins/bambooHr/src/index.js +252 -0
  47. package/dist/plugins/bannerbear/src/index.js +100 -0
  48. package/dist/plugins/baserow/src/index.js +180 -0
  49. package/dist/plugins/beeminder/src/index.js +298 -0
  50. package/dist/plugins/bitly/src/index.js +107 -0
  51. package/dist/plugins/bitwarden/src/index.js +383 -0
  52. package/dist/plugins/box/src/index.js +300 -0
  53. package/dist/plugins/brandfetch/src/index.js +80 -0
  54. package/dist/plugins/brevo/src/index.js +305 -0
  55. package/dist/plugins/bubble/src/index.js +181 -0
  56. package/dist/plugins/chargebee/src/index.js +126 -0
  57. package/dist/plugins/circleci/src/index.js +111 -0
  58. package/dist/plugins/ciscoWebex/src/index.js +245 -0
  59. package/dist/plugins/clearbit/src/index.js +103 -0
  60. package/dist/plugins/clickup/src/index.js +1043 -0
  61. package/dist/plugins/clockify/src/index.js +443 -0
  62. package/dist/plugins/cloudflare/src/index.js +93 -0
  63. package/dist/plugins/cockpit/src/index.js +131 -0
  64. package/dist/plugins/coda/src/index.js +327 -0
  65. package/dist/plugins/coingecko/src/index.js +244 -0
  66. package/dist/plugins/contentful/src/index.js +146 -0
  67. package/dist/plugins/convertkit/src/index.js +270 -0
  68. package/dist/plugins/copper/src/index.js +140 -0
  69. package/dist/plugins/cortex/src/index.js +147 -0
  70. package/dist/plugins/currents/src/index.js +405 -0
  71. package/dist/plugins/customerIo/src/index.js +184 -0
  72. package/dist/plugins/databricks/src/index.js +342 -0
  73. package/dist/plugins/deepl/src/index.js +87 -0
  74. package/dist/plugins/demio/src/index.js +111 -0
  75. package/dist/plugins/dhl/src/index.js +40 -0
  76. package/dist/plugins/discord/src/index.js +275 -0
  77. package/dist/plugins/discourse/src/index.js +273 -0
  78. package/dist/plugins/disqus/src/index.js +145 -0
  79. package/dist/plugins/docker/src/index.js +76 -0
  80. package/dist/plugins/drift/src/index.js +89 -0
  81. package/dist/plugins/dropbox/src/index.js +159 -0
  82. package/dist/plugins/dropcontact/src/index.js +59 -0
  83. package/dist/plugins/egoi/src/index.js +151 -0
  84. package/dist/plugins/elasticsearch/src/index.js +157 -0
  85. package/dist/plugins/emelia/src/index.js +174 -0
  86. package/dist/plugins/erpnext/src/index.js +121 -0
  87. package/dist/plugins/facebookGraph/src/index.js +57 -0
  88. package/dist/plugins/freshdesk/src/index.js +320 -0
  89. package/dist/plugins/freshservice/src/index.js +146 -0
  90. package/dist/plugins/freshworksCrm/src/index.js +149 -0
  91. package/dist/plugins/getresponse/src/index.js +140 -0
  92. package/dist/plugins/ghost/src/index.js +192 -0
  93. package/dist/plugins/github/src/index.js +630 -0
  94. package/dist/plugins/gitlab/src/index.js +358 -0
  95. package/dist/plugins/gong/src/index.js +126 -0
  96. package/dist/plugins/gotify/src/index.js +77 -0
  97. package/dist/plugins/gotowebinar/src/index.js +316 -0
  98. package/dist/plugins/grafana/src/index.js +250 -0
  99. package/dist/plugins/graphql/src/index.js +78 -0
  100. package/dist/plugins/grist/src/index.js +106 -0
  101. package/dist/plugins/hackernews/src/index.js +89 -0
  102. package/dist/plugins/halopsa/src/index.js +79 -0
  103. package/dist/plugins/harvest/src/index.js +163 -0
  104. package/dist/plugins/helpscout/src/index.js +176 -0
  105. package/dist/plugins/highlevel/src/index.js +172 -0
  106. package/dist/plugins/homeAssistant/src/index.js +148 -0
  107. package/dist/plugins/hubspot/src/index.js +176 -0
  108. package/dist/plugins/humanticAi/src/index.js +60 -0
  109. package/dist/plugins/hunter/src/index.js +59 -0
  110. package/dist/plugins/intercom/src/index.js +156 -0
  111. package/dist/plugins/iterable/src/index.js +139 -0
  112. package/dist/plugins/jenkins/src/index.js +132 -0
  113. package/dist/plugins/jira/src/index.js +229 -0
  114. package/dist/plugins/keap/src/index.js +502 -0
  115. package/dist/plugins/kobotoolbox/src/index.js +281 -0
  116. package/dist/plugins/lemlist/src/index.js +231 -0
  117. package/dist/plugins/linear/src/index.js +133 -0
  118. package/dist/plugins/lingvanex/src/index.js +31 -0
  119. package/dist/plugins/linkedin/src/index.js +80 -0
  120. package/dist/plugins/lonescale/src/index.js +119 -0
  121. package/dist/plugins/magento/src/index.js +300 -0
  122. package/dist/plugins/mailcheck/src/index.js +27 -0
  123. package/dist/plugins/mailchimp/src/index.js +321 -0
  124. package/dist/plugins/mailerlite/src/index.js +123 -0
  125. package/dist/plugins/mailgun/src/index.js +48 -0
  126. package/dist/plugins/mailjet/src/index.js +155 -0
  127. package/dist/plugins/mandrill/src/index.js +145 -0
  128. package/dist/plugins/marketstack/src/index.js +97 -0
  129. package/dist/plugins/matrix/src/index.js +194 -0
  130. package/dist/plugins/mattermost/src/index.js +331 -0
  131. package/dist/plugins/mautic/src/index.js +311 -0
  132. package/dist/plugins/medium/src/index.js +77 -0
  133. package/dist/plugins/messagebird/src/index.js +57 -0
  134. package/dist/plugins/metabase/src/index.js +130 -0
  135. package/dist/plugins/misp/src/index.js +476 -0
  136. package/dist/plugins/mocean/src/index.js +67 -0
  137. package/dist/plugins/monday/src/index.js +231 -0
  138. package/dist/plugins/monicaCrm/src/index.js +52 -0
  139. package/dist/plugins/msg91/src/index.js +31 -0
  140. package/dist/plugins/nasa/src/index.js +146 -0
  141. package/dist/plugins/netlify/src/index.js +151 -0
  142. package/dist/plugins/netscalerAdc/src/index.js +131 -0
  143. package/dist/plugins/nextcloud/src/index.js +263 -0
  144. package/dist/plugins/nocodb/src/index.js +130 -0
  145. package/dist/plugins/notion/src/index.js +112 -0
  146. package/dist/plugins/npm/src/index.js +104 -0
  147. package/dist/plugins/odoo/src/index.js +157 -0
  148. package/dist/plugins/okta/src/index.js +141 -0
  149. package/dist/plugins/oneSimpleApi/src/index.js +155 -0
  150. package/dist/plugins/onfleet/src/index.js +254 -0
  151. package/dist/plugins/openThesaurus/src/index.js +32 -0
  152. package/dist/plugins/openweathermap/src/index.js +60 -0
  153. package/dist/plugins/oura/src/index.js +62 -0
  154. package/dist/plugins/paddle/src/index.js +247 -0
  155. package/dist/plugins/pagerduty/src/index.js +201 -0
  156. package/dist/plugins/paypal/src/index.js +106 -0
  157. package/dist/plugins/peekalink/src/index.js +35 -0
  158. package/dist/plugins/phantombuster/src/index.js +94 -0
  159. package/dist/plugins/philipsHue/src/index.js +98 -0
  160. package/dist/plugins/pipedrive/src/index.js +169 -0
  161. package/dist/plugins/plivo/src/index.js +66 -0
  162. package/dist/plugins/postbin/src/index.js +93 -0
  163. package/dist/plugins/posthog/src/index.js +113 -0
  164. package/dist/plugins/profitwell/src/index.js +50 -0
  165. package/dist/plugins/pushbullet/src/index.js +102 -0
  166. package/dist/plugins/pushcut/src/index.js +39 -0
  167. package/dist/plugins/pushover/src/index.js +65 -0
  168. package/dist/plugins/quickbase/src/index.js +153 -0
  169. package/dist/plugins/quickbooks/src/index.js +73 -0
  170. package/dist/plugins/quickchart/src/index.js +36 -0
  171. package/dist/plugins/raindrop/src/index.js +209 -0
  172. package/dist/plugins/reddit/src/index.js +185 -0
  173. package/dist/plugins/rocketchat/src/index.js +53 -0
  174. package/dist/plugins/rundeck/src/index.js +62 -0
  175. package/dist/plugins/salesforce/src/index.js +94 -0
  176. package/dist/plugins/salesmate/src/index.js +83 -0
  177. package/dist/plugins/securityScorecard/src/index.js +200 -0
  178. package/dist/plugins/segment/src/index.js +125 -0
  179. package/dist/plugins/sendgrid/src/index.js +187 -0
  180. package/dist/plugins/sendy/src/index.js +138 -0
  181. package/dist/plugins/sentry/src/index.js +233 -0
  182. package/dist/plugins/servicenow/src/index.js +108 -0
  183. package/dist/plugins/shopify/src/index.js +222 -0
  184. package/dist/plugins/signl4/src/index.js +61 -0
  185. package/dist/plugins/slack/src/index.js +236 -0
  186. package/dist/plugins/sms77/src/index.js +63 -0
  187. package/dist/plugins/splunk/src/index.js +207 -0
  188. package/dist/plugins/spotify/src/index.js +188 -0
  189. package/dist/plugins/stackby/src/index.js +82 -0
  190. package/dist/plugins/storyblok/src/index.js +141 -0
  191. package/dist/plugins/strapi/src/index.js +152 -0
  192. package/dist/plugins/strava/src/index.js +137 -0
  193. package/dist/plugins/stripe/src/index.js +222 -0
  194. package/dist/plugins/supabase/src/index.js +121 -0
  195. package/dist/plugins/syncromsp/src/index.js +255 -0
  196. package/dist/plugins/tapfiliate/src/index.js +125 -0
  197. package/dist/plugins/telegram/src/index.js +233 -0
  198. package/dist/plugins/thehive/src/index.js +142 -0
  199. package/dist/plugins/thehiveProject/src/index.js +194 -0
  200. package/dist/plugins/todoist/src/index.js +244 -0
  201. package/dist/plugins/travisci/src/index.js +71 -0
  202. package/dist/plugins/trello/src/index.js +341 -0
  203. package/dist/plugins/twake/src/index.js +40 -0
  204. package/dist/plugins/twilio/src/index.js +75 -0
  205. package/dist/plugins/twist/src/index.js +90 -0
  206. package/dist/plugins/twitter/src/index.js +123 -0
  207. package/dist/plugins/unleashedSoftware/src/index.js +84 -0
  208. package/dist/plugins/uplead/src/index.js +59 -0
  209. package/dist/plugins/uproc/src/index.js +34 -0
  210. package/dist/plugins/uptimerobot/src/index.js +264 -0
  211. package/dist/plugins/urlscanio/src/index.js +64 -0
  212. package/dist/plugins/vero/src/index.js +80 -0
  213. package/dist/plugins/vonage/src/index.js +42 -0
  214. package/dist/plugins/wekan/src/index.js +91 -0
  215. package/dist/plugins/woocommerce/src/index.js +92 -0
  216. package/dist/plugins/wordpress/src/index.js +121 -0
  217. package/dist/plugins/xero/src/index.js +136 -0
  218. package/dist/plugins/yourls/src/index.js +56 -0
  219. package/dist/plugins/zammad/src/index.js +91 -0
  220. package/dist/plugins/zendesk/src/index.js +137 -0
  221. package/dist/plugins/zoho/src/index.js +85 -0
  222. package/dist/plugins/zoom/src/index.js +122 -0
  223. package/dist/plugins/zulip/src/index.js +170 -0
  224. package/dist/sdk.d.ts +38 -0
  225. package/dist/sdk.js +105 -0
  226. package/dist/utils/cli.d.ts +13 -0
  227. package/dist/utils/cli.js +32 -0
  228. package/dist/utils/output.d.ts +4 -0
  229. package/dist/utils/output.js +13 -0
  230. package/package.json +57 -0
@@ -0,0 +1,142 @@
1
+ function getConn(ctx) {
2
+ const c = ctx.connection.config;
3
+ return { url: c.url.replace(/\/$/, ""), apiKey: c.apiKey };
4
+ }
5
+ async function api(conn, method, endpoint, body, qs) {
6
+ const url = new URL(`${conn.url}/api${endpoint}`);
7
+ if (qs) {
8
+ for (const [k, v] of Object.entries(qs)) {
9
+ if (v !== undefined && v !== null)
10
+ url.searchParams.set(k, String(v));
11
+ }
12
+ }
13
+ const init = { method, headers: { Authorization: `Bearer ${conn.apiKey}`, "Content-Type": "application/json" } };
14
+ if (body && Object.keys(body).length > 0)
15
+ init.body = JSON.stringify(body);
16
+ const res = await fetch(url.toString(), init);
17
+ if (!res.ok)
18
+ throw new Error(`TheHive error ${res.status}: ${await res.text()}`);
19
+ return res.json();
20
+ }
21
+ export default function thehive(rl) {
22
+ rl.setName("thehive");
23
+ rl.setVersion("0.1.0");
24
+ rl.setConnectionSchema({
25
+ url: { type: "string", required: true, description: "TheHive instance URL", env: "THEHIVE_URL" },
26
+ apiKey: { type: "string", required: true, description: "TheHive API key", env: "THEHIVE_API_KEY" },
27
+ });
28
+ // ── Alert ───────────────────────────────────────────
29
+ rl.registerAction("alert.create", { description: "Create an alert",
30
+ inputSchema: { title: { type: "string", required: true }, description: { type: "string", required: true }, severity: { type: "number", required: true, description: "1-4" }, type: { type: "string", required: true }, source: { type: "string", required: true }, sourceRef: { type: "string", required: true }, tlp: { type: "number", required: false }, tags: { type: "string", required: false, description: "Comma-separated" } },
31
+ async execute(input, ctx) {
32
+ const p = input;
33
+ const body = { ...p, date: Date.now() };
34
+ if (p.tags)
35
+ body.tags = p.tags.split(",").map(t => t.trim());
36
+ return api(getConn(ctx), "POST", "/alert", body);
37
+ } });
38
+ rl.registerAction("alert.get", { description: "Get an alert by ID", inputSchema: { id: { type: "string", required: true } },
39
+ async execute(input, ctx) { return api(getConn(ctx), "GET", `/alert/${input.id}`); } });
40
+ rl.registerAction("alert.list", { description: "List alerts", inputSchema: { limit: { type: "number", required: false } },
41
+ async execute(input, ctx) {
42
+ const p = (input ?? {});
43
+ const body = { query: [{ _name: "listAlert" }] };
44
+ if (p.limit)
45
+ body.query.push({ _name: "page", from: 0, to: p.limit });
46
+ return api(getConn(ctx), "POST", "/v1/query", body, { name: "alerts" });
47
+ } });
48
+ rl.registerAction("alert.update", { description: "Update an alert", inputSchema: { id: { type: "string", required: true }, data: { type: "object", required: true } },
49
+ async execute(input, ctx) { const p = input; return api(getConn(ctx), "PATCH", `/alert/${p.id}`, p.data); } });
50
+ rl.registerAction("alert.markAsRead", { description: "Mark an alert as read", inputSchema: { id: { type: "string", required: true } },
51
+ async execute(input, ctx) { return api(getConn(ctx), "POST", `/alert/${input.id}/markAsRead`); } });
52
+ rl.registerAction("alert.markAsUnread", { description: "Mark an alert as unread", inputSchema: { id: { type: "string", required: true } },
53
+ async execute(input, ctx) { return api(getConn(ctx), "POST", `/alert/${input.id}/markAsUnread`); } });
54
+ rl.registerAction("alert.promote", { description: "Promote an alert to a case", inputSchema: { id: { type: "string", required: true } },
55
+ async execute(input, ctx) { return api(getConn(ctx), "POST", `/alert/${input.id}/createCase`); } });
56
+ rl.registerAction("alert.merge", { description: "Merge an alert into an existing case", inputSchema: { alertId: { type: "string", required: true }, caseId: { type: "string", required: true } },
57
+ async execute(input, ctx) { const p = input; return api(getConn(ctx), "POST", `/alert/${p.alertId}/merge/${p.caseId}`); } });
58
+ // ── Case ────────────────────────────────────────────
59
+ rl.registerAction("case.create", { description: "Create a case",
60
+ inputSchema: { title: { type: "string", required: true }, description: { type: "string", required: true }, severity: { type: "number", required: true }, tlp: { type: "number", required: false }, tags: { type: "string", required: false, description: "Comma-separated" }, owner: { type: "string", required: false } },
61
+ async execute(input, ctx) {
62
+ const p = input;
63
+ const body = { ...p, startDate: Date.now() };
64
+ if (p.tags)
65
+ body.tags = p.tags.split(",").map(t => t.trim());
66
+ return api(getConn(ctx), "POST", "/case", body);
67
+ } });
68
+ rl.registerAction("case.get", { description: "Get a case", inputSchema: { id: { type: "string", required: true } },
69
+ async execute(input, ctx) { return api(getConn(ctx), "GET", `/case/${input.id}`); } });
70
+ rl.registerAction("case.list", { description: "List cases", inputSchema: { limit: { type: "number", required: false } },
71
+ async execute(input, ctx) {
72
+ const p = (input ?? {});
73
+ const body = { query: [{ _name: "listCase" }] };
74
+ if (p.limit)
75
+ body.query.push({ _name: "page", from: 0, to: p.limit });
76
+ return api(getConn(ctx), "POST", "/v1/query", body, { name: "cases" });
77
+ } });
78
+ rl.registerAction("case.update", { description: "Update a case", inputSchema: { id: { type: "string", required: true }, data: { type: "object", required: true } },
79
+ async execute(input, ctx) { const p = input; return api(getConn(ctx), "PATCH", `/case/${p.id}`, p.data); } });
80
+ // ── Observable ──────────────────────────────────────
81
+ rl.registerAction("observable.create", { description: "Create an observable on a case",
82
+ inputSchema: { caseId: { type: "string", required: true }, dataType: { type: "string", required: true }, data: { type: "string", required: true }, message: { type: "string", required: false }, tlp: { type: "number", required: false }, ioc: { type: "boolean", required: false }, sighted: { type: "boolean", required: false } },
83
+ async execute(input, ctx) {
84
+ const { caseId, ...body } = input;
85
+ return api(getConn(ctx), "POST", `/case/${caseId}/artifact`, body);
86
+ } });
87
+ rl.registerAction("observable.get", { description: "Get an observable", inputSchema: { id: { type: "string", required: true } },
88
+ async execute(input, ctx) {
89
+ return api(getConn(ctx), "POST", "/v1/query", { query: [{ _name: "getObservable", idOrName: input.id }] }, { name: "get-observable" });
90
+ } });
91
+ rl.registerAction("observable.list", { description: "List observables for a case", inputSchema: { caseId: { type: "string", required: true }, limit: { type: "number", required: false } },
92
+ async execute(input, ctx) {
93
+ const p = input;
94
+ const body = { query: [{ _name: "getCase", idOrName: p.caseId }, { _name: "observables" }] };
95
+ if (p.limit)
96
+ body.query.push({ _name: "page", from: 0, to: p.limit });
97
+ return api(getConn(ctx), "POST", "/v1/query", body, { name: "observables" });
98
+ } });
99
+ rl.registerAction("observable.update", { description: "Update an observable", inputSchema: { id: { type: "string", required: true }, data: { type: "object", required: true } },
100
+ async execute(input, ctx) { const p = input; return api(getConn(ctx), "PATCH", `/case/artifact/${p.id}`, p.data); } });
101
+ // ── Task ────────────────────────────────────────────
102
+ rl.registerAction("task.create", { description: "Create a task on a case",
103
+ inputSchema: { caseId: { type: "string", required: true }, title: { type: "string", required: true }, status: { type: "string", required: false, description: "Waiting, InProgress, Completed, Cancel" }, flag: { type: "boolean", required: false } },
104
+ async execute(input, ctx) {
105
+ const { caseId, ...body } = input;
106
+ return api(getConn(ctx), "POST", `/case/${caseId}/task`, body);
107
+ } });
108
+ rl.registerAction("task.get", { description: "Get a task", inputSchema: { id: { type: "string", required: true } },
109
+ async execute(input, ctx) {
110
+ return api(getConn(ctx), "POST", "/v1/query", { query: [{ _name: "getTask", idOrName: input.id }] }, { name: "get-task" });
111
+ } });
112
+ rl.registerAction("task.list", { description: "List tasks for a case", inputSchema: { caseId: { type: "string", required: true }, limit: { type: "number", required: false } },
113
+ async execute(input, ctx) {
114
+ const p = input;
115
+ const body = { query: [{ _name: "getCase", idOrName: p.caseId }, { _name: "tasks" }] };
116
+ if (p.limit)
117
+ body.query.push({ _name: "page", from: 0, to: p.limit });
118
+ return api(getConn(ctx), "POST", "/v1/query", body, { name: "case-tasks" });
119
+ } });
120
+ rl.registerAction("task.update", { description: "Update a task", inputSchema: { id: { type: "string", required: true }, data: { type: "object", required: true } },
121
+ async execute(input, ctx) { const p = input; return api(getConn(ctx), "PATCH", `/case/task/${p.id}`, p.data); } });
122
+ // ── Log ─────────────────────────────────────────────
123
+ rl.registerAction("log.create", { description: "Create a log entry on a task",
124
+ inputSchema: { taskId: { type: "string", required: true }, message: { type: "string", required: true }, status: { type: "string", required: false, description: "Ok, Deleted" } },
125
+ async execute(input, ctx) {
126
+ const { taskId, ...body } = input;
127
+ body.startDate = Date.now();
128
+ return api(getConn(ctx), "POST", `/case/task/${taskId}/log`, body);
129
+ } });
130
+ rl.registerAction("log.get", { description: "Get a log entry", inputSchema: { id: { type: "string", required: true } },
131
+ async execute(input, ctx) {
132
+ return api(getConn(ctx), "POST", "/v1/query", { query: [{ _name: "getLog", idOrName: input.id }] }, { name: "get-log" });
133
+ } });
134
+ rl.registerAction("log.list", { description: "List logs for a task", inputSchema: { taskId: { type: "string", required: true }, limit: { type: "number", required: false } },
135
+ async execute(input, ctx) {
136
+ const p = input;
137
+ const body = { query: [{ _name: "getTask", idOrName: p.taskId }, { _name: "logs" }] };
138
+ if (p.limit)
139
+ body.query.push({ _name: "page", from: 0, to: p.limit });
140
+ return api(getConn(ctx), "POST", "/v1/query", body, { name: "case-task-logs" });
141
+ } });
142
+ }
@@ -0,0 +1,194 @@
1
+ function getConn(ctx) {
2
+ const url = ctx.connection.config.url.replace(/\/$/, "");
3
+ const apiKey = ctx.connection.config.apiKey;
4
+ return { url, apiKey };
5
+ }
6
+ async function api(url, apiKey, method, path, body, qs) {
7
+ const u = new URL(`${url}/api${path}`);
8
+ if (qs) {
9
+ for (const [k, v] of Object.entries(qs)) {
10
+ if (v !== undefined)
11
+ u.searchParams.set(k, String(v));
12
+ }
13
+ }
14
+ const init = { method, headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" } };
15
+ if (body && Object.keys(body).length > 0)
16
+ init.body = JSON.stringify(body);
17
+ const res = await fetch(u.toString(), init);
18
+ if (res.status === 204)
19
+ return { success: true };
20
+ if (!res.ok)
21
+ throw new Error(`TheHive error ${res.status}: ${await res.text()}`);
22
+ const text = await res.text();
23
+ return text ? JSON.parse(text) : { success: true };
24
+ }
25
+ // TheHive v1 query API — paginated search
26
+ async function query(url, apiKey, scope, filters, sortFields, limit) {
27
+ const q = [];
28
+ if (scope.id)
29
+ q.push({ _name: scope.query, idOrName: scope.id });
30
+ else
31
+ q.push({ _name: scope.query });
32
+ if (scope.restrictTo)
33
+ q.push({ _name: scope.restrictTo });
34
+ if (filters && filters.length)
35
+ q.push({ _name: "filter", _and: filters });
36
+ if (sortFields && sortFields.length)
37
+ q.push({ _name: "sort", _fields: sortFields });
38
+ if (limit) {
39
+ q.push({ _name: "page", from: 0, to: limit });
40
+ return api(url, apiKey, "POST", "/v1/query", { query: q });
41
+ }
42
+ // Paginate in batches of 500
43
+ const results = [];
44
+ let from = 0;
45
+ let batch;
46
+ do {
47
+ batch = (await api(url, apiKey, "POST", "/v1/query", { query: [...q, { _name: "page", from, to: from + 500 }] }) ?? []);
48
+ results.push(...batch);
49
+ from += 500;
50
+ } while (batch.length > 0);
51
+ return results;
52
+ }
53
+ function searchAction(rl, name, scope, description, extraInputs) {
54
+ rl.registerAction(name, { description,
55
+ inputSchema: { limit: { type: "number", required: false }, filters: { type: "object", required: false, description: "Array of filter objects" }, sort: { type: "object", required: false, description: "Array of sort field objects" }, ...extraInputs },
56
+ async execute(input, ctx) {
57
+ const { url, apiKey } = getConn(ctx);
58
+ const p = (input ?? {});
59
+ let s;
60
+ if (typeof scope === "string") {
61
+ s = { query: scope };
62
+ }
63
+ else {
64
+ s = scope;
65
+ }
66
+ // If there's scope customization via input (e.g. caseId for tasks)
67
+ if (p.caseId && typeof scope === "object" && scope.restrictTo) {
68
+ s = { query: "getCase", id: p.caseId, restrictTo: scope.restrictTo };
69
+ }
70
+ return query(url, apiKey, s, p.filters, p.sort, p.limit);
71
+ } });
72
+ }
73
+ export default function theHiveProject(rl) {
74
+ rl.setName("thehiveProject");
75
+ rl.setVersion("0.1.0");
76
+ rl.setConnectionSchema({
77
+ url: { type: "string", required: true, description: "TheHive instance URL", env: "THEHIVE_URL" },
78
+ apiKey: { type: "string", required: true, description: "API key", env: "THEHIVE_API_KEY" },
79
+ });
80
+ // ── Alert ───────────────────────────────────────────
81
+ rl.registerAction("alert.create", { description: "Create an alert",
82
+ inputSchema: { type: { type: "string", required: true }, source: { type: "string", required: true }, sourceRef: { type: "string", required: true }, title: { type: "string", required: true }, description: { type: "string", required: false }, severity: { type: "number", required: false }, tlp: { type: "number", required: false }, tags: { type: "object", required: false }, customFields: { type: "object", required: false } },
83
+ async execute(input, ctx) { const { url, apiKey } = getConn(ctx); return api(url, apiKey, "POST", "/v1/alert", input); } });
84
+ rl.registerAction("alert.get", { description: "Get an alert by ID", inputSchema: { id: { type: "string", required: true } },
85
+ async execute(input, ctx) { const { url, apiKey } = getConn(ctx); return api(url, apiKey, "GET", `/v1/alert/${input.id}`); } });
86
+ rl.registerAction("alert.update", { description: "Update an alert by ID",
87
+ inputSchema: { id: { type: "string", required: true }, title: { type: "string", required: false }, description: { type: "string", required: false }, severity: { type: "number", required: false }, tlp: { type: "number", required: false }, tags: { type: "object", required: false }, status: { type: "string", required: false }, customFields: { type: "object", required: false } },
88
+ async execute(input, ctx) { const { url, apiKey } = getConn(ctx); const { id, ...body } = input; await api(url, apiKey, "PATCH", `/v1/alert/${id}`, body); return { success: true }; } });
89
+ rl.registerAction("alert.delete", { description: "Delete an alert", inputSchema: { id: { type: "string", required: true } },
90
+ async execute(input, ctx) { const { url, apiKey } = getConn(ctx); await api(url, apiKey, "DELETE", `/v1/alert/${input.id}`); return { success: true }; } });
91
+ searchAction(rl, "alert.search", "listAlert", "Search alerts");
92
+ rl.registerAction("alert.merge", { description: "Merge an alert into a case",
93
+ inputSchema: { alertId: { type: "string", required: true }, caseId: { type: "string", required: true } },
94
+ async execute(input, ctx) { const { url, apiKey } = getConn(ctx); const p = input; return api(url, apiKey, "POST", `/alert/${p.alertId}/merge/${p.caseId}`); } });
95
+ rl.registerAction("alert.promote", { description: "Promote an alert to a case",
96
+ inputSchema: { id: { type: "string", required: true }, caseTemplate: { type: "string", required: false } },
97
+ async execute(input, ctx) { const { url, apiKey } = getConn(ctx); const p = input; const body = {}; if (p.caseTemplate)
98
+ body.caseTemplate = p.caseTemplate; return api(url, apiKey, "POST", `/v1/alert/${p.id}/case`, body); } });
99
+ rl.registerAction("alert.setStatus", { description: "Set alert status",
100
+ inputSchema: { id: { type: "string", required: true }, status: { type: "string", required: true } },
101
+ async execute(input, ctx) { const { url, apiKey } = getConn(ctx); const p = input; await api(url, apiKey, "PATCH", `/v1/alert/${p.id}`, { status: p.status }); return { success: true }; } });
102
+ // ── Case ────────────────────────────────────────────
103
+ rl.registerAction("case.create", { description: "Create a case",
104
+ inputSchema: { title: { type: "string", required: true }, description: { type: "string", required: false }, severity: { type: "number", required: false }, tlp: { type: "number", required: false }, tags: { type: "object", required: false }, assignee: { type: "string", required: false }, customFields: { type: "object", required: false } },
105
+ async execute(input, ctx) { const { url, apiKey } = getConn(ctx); return api(url, apiKey, "POST", "/v1/case", input); } });
106
+ rl.registerAction("case.get", { description: "Get a case by ID", inputSchema: { id: { type: "string", required: true } },
107
+ async execute(input, ctx) { const { url, apiKey } = getConn(ctx); return api(url, apiKey, "POST", "/v1/query", { query: [{ _name: "getCase", idOrName: input.id }, { _name: "page", from: 0, to: 10, extraData: ["attachmentCount"] }] }); } });
108
+ rl.registerAction("case.update", { description: "Update a case by ID",
109
+ inputSchema: { id: { type: "string", required: true }, title: { type: "string", required: false }, description: { type: "string", required: false }, severity: { type: "number", required: false }, tlp: { type: "number", required: false }, tags: { type: "object", required: false }, status: { type: "string", required: false }, assignee: { type: "string", required: false }, customFields: { type: "object", required: false } },
110
+ async execute(input, ctx) { const { url, apiKey } = getConn(ctx); const { id, ...body } = input; await api(url, apiKey, "PATCH", `/v1/case/${id}`, body); return { success: true }; } });
111
+ rl.registerAction("case.delete", { description: "Delete a case", inputSchema: { id: { type: "string", required: true } },
112
+ async execute(input, ctx) { const { url, apiKey } = getConn(ctx); await api(url, apiKey, "DELETE", `/v1/case/${input.id}`); return { success: true }; } });
113
+ searchAction(rl, "case.search", "listCase", "Search cases");
114
+ rl.registerAction("case.getTimeline", { description: "Get case timeline", inputSchema: { id: { type: "string", required: true } },
115
+ async execute(input, ctx) { const { url, apiKey } = getConn(ctx); return api(url, apiKey, "GET", `/v1/case/${input.id}/timeline`); } });
116
+ // ── Task ────────────────────────────────────────────
117
+ rl.registerAction("task.create", { description: "Create a task in a case",
118
+ inputSchema: { caseId: { type: "string", required: true }, title: { type: "string", required: true }, description: { type: "string", required: false }, status: { type: "string", required: false }, flag: { type: "boolean", required: false }, assignee: { type: "string", required: false } },
119
+ async execute(input, ctx) { const { url, apiKey } = getConn(ctx); const { caseId, ...body } = input; return api(url, apiKey, "POST", `/v1/case/${caseId}/task`, body); } });
120
+ rl.registerAction("task.get", { description: "Get a task by ID", inputSchema: { id: { type: "string", required: true } },
121
+ async execute(input, ctx) { const { url, apiKey } = getConn(ctx); return api(url, apiKey, "POST", "/v1/query", { query: [{ _name: "getTask", idOrName: input.id }] }); } });
122
+ rl.registerAction("task.update", { description: "Update a task by ID",
123
+ inputSchema: { id: { type: "string", required: true }, title: { type: "string", required: false }, description: { type: "string", required: false }, status: { type: "string", required: false }, flag: { type: "boolean", required: false }, assignee: { type: "string", required: false } },
124
+ async execute(input, ctx) { const { url, apiKey } = getConn(ctx); const { id, ...body } = input; await api(url, apiKey, "PATCH", `/v1/task/${id}`, body); return { success: true }; } });
125
+ rl.registerAction("task.delete", { description: "Delete a task", inputSchema: { id: { type: "string", required: true } },
126
+ async execute(input, ctx) { const { url, apiKey } = getConn(ctx); await api(url, apiKey, "DELETE", `/v1/task/${input.id}`); return { success: true }; } });
127
+ searchAction(rl, "task.search", "listTask", "Search tasks");
128
+ // ── Observable ──────────────────────────────────────
129
+ rl.registerAction("observable.create", { description: "Create an observable in a case or alert",
130
+ inputSchema: { createIn: { type: "string", required: true, description: "case or alert" }, parentId: { type: "string", required: true, description: "Case or alert ID" }, dataType: { type: "string", required: true }, data: { type: "string", required: false, description: "Value (for non-file types)" }, message: { type: "string", required: false }, tlp: { type: "number", required: false }, tags: { type: "object", required: false }, ioc: { type: "boolean", required: false } },
131
+ async execute(input, ctx) {
132
+ const { url, apiKey } = getConn(ctx);
133
+ const { createIn, parentId, ...body } = input;
134
+ return api(url, apiKey, "POST", `/v1/${createIn}/${parentId}/observable`, body);
135
+ } });
136
+ rl.registerAction("observable.get", { description: "Get an observable by ID", inputSchema: { id: { type: "string", required: true } },
137
+ async execute(input, ctx) { const { url, apiKey } = getConn(ctx); return api(url, apiKey, "POST", "/v1/query", { query: [{ _name: "getObservable", idOrName: input.id }] }); } });
138
+ rl.registerAction("observable.update", { description: "Update an observable by ID",
139
+ inputSchema: { id: { type: "string", required: true }, message: { type: "string", required: false }, tlp: { type: "number", required: false }, tags: { type: "object", required: false }, ioc: { type: "boolean", required: false }, sighted: { type: "boolean", required: false } },
140
+ async execute(input, ctx) { const { url, apiKey } = getConn(ctx); const { id, ...body } = input; await api(url, apiKey, "PATCH", `/v1/observable/${id}`, body); return { success: true }; } });
141
+ rl.registerAction("observable.delete", { description: "Delete an observable", inputSchema: { id: { type: "string", required: true } },
142
+ async execute(input, ctx) { const { url, apiKey } = getConn(ctx); await api(url, apiKey, "DELETE", `/v1/observable/${input.id}`); return { success: true }; } });
143
+ searchAction(rl, "observable.search", "listObservable", "Search observables");
144
+ // ── Comment ─────────────────────────────────────────
145
+ rl.registerAction("comment.add", { description: "Add a comment to a case or alert",
146
+ inputSchema: { addTo: { type: "string", required: true, description: "case or alert" }, parentId: { type: "string", required: true }, message: { type: "string", required: true } },
147
+ async execute(input, ctx) { const { url, apiKey } = getConn(ctx); const p = input; return api(url, apiKey, "POST", `/v1/${p.addTo}/${p.parentId}/comment`, { message: p.message }); } });
148
+ rl.registerAction("comment.update", { description: "Update a comment",
149
+ inputSchema: { id: { type: "string", required: true }, message: { type: "string", required: true } },
150
+ async execute(input, ctx) { const { url, apiKey } = getConn(ctx); const p = input; return api(url, apiKey, "PATCH", `/v1/comment/${p.id}`, { message: p.message }); } });
151
+ rl.registerAction("comment.delete", { description: "Delete a comment", inputSchema: { id: { type: "string", required: true } },
152
+ async execute(input, ctx) { const { url, apiKey } = getConn(ctx); await api(url, apiKey, "DELETE", `/v1/comment/${input.id}`); return { success: true }; } });
153
+ searchAction(rl, "comment.search", "listComment", "Search comments");
154
+ // ── Task Log ────────────────────────────────────────
155
+ rl.registerAction("log.create", { description: "Create a task log entry",
156
+ inputSchema: { taskId: { type: "string", required: true }, message: { type: "string", required: true }, startDate: { type: "string", required: false }, includeInTimeline: { type: "string", required: false } },
157
+ async execute(input, ctx) { const { url, apiKey } = getConn(ctx); const { taskId, ...body } = input; return api(url, apiKey, "POST", `/v1/task/${taskId}/log`, body); } });
158
+ rl.registerAction("log.get", { description: "Get a log entry by ID", inputSchema: { id: { type: "string", required: true } },
159
+ async execute(input, ctx) { const { url, apiKey } = getConn(ctx); return api(url, apiKey, "POST", "/v1/query", { query: [{ _name: "getLog", idOrName: input.id }] }); } });
160
+ rl.registerAction("log.delete", { description: "Delete a log entry", inputSchema: { id: { type: "string", required: true } },
161
+ async execute(input, ctx) { const { url, apiKey } = getConn(ctx); await api(url, apiKey, "DELETE", `/v1/log/${input.id}`); return { success: true }; } });
162
+ searchAction(rl, "log.search", "listLog", "Search task logs");
163
+ // ── Page ────────────────────────────────────────────
164
+ rl.registerAction("page.create", { description: "Create a page (case page or knowledge base)",
165
+ inputSchema: { caseId: { type: "string", required: false, description: "If omitted, creates in knowledge base" }, title: { type: "string", required: true }, category: { type: "string", required: true }, content: { type: "string", required: true } },
166
+ async execute(input, ctx) {
167
+ const { url, apiKey } = getConn(ctx);
168
+ const { caseId, ...body } = input;
169
+ const endpoint = caseId ? `/v1/case/${caseId}/page` : "/v1/page";
170
+ return api(url, apiKey, "POST", endpoint, body);
171
+ } });
172
+ rl.registerAction("page.update", { description: "Update a page",
173
+ inputSchema: { pageId: { type: "string", required: true }, caseId: { type: "string", required: false }, content: { type: "string", required: false }, title: { type: "string", required: false }, category: { type: "string", required: false }, order: { type: "number", required: false } },
174
+ async execute(input, ctx) {
175
+ const { url, apiKey } = getConn(ctx);
176
+ const { pageId, caseId, ...body } = input;
177
+ const endpoint = caseId ? `/v1/case/${caseId}/page/${pageId}` : `/v1/page/${pageId}`;
178
+ return api(url, apiKey, "PATCH", endpoint, body);
179
+ } });
180
+ rl.registerAction("page.delete", { description: "Delete a page",
181
+ inputSchema: { pageId: { type: "string", required: true }, caseId: { type: "string", required: false } },
182
+ async execute(input, ctx) {
183
+ const { url, apiKey } = getConn(ctx);
184
+ const p = input;
185
+ const endpoint = p.caseId ? `/v1/case/${p.caseId}/page/${p.pageId}` : `/v1/page/${p.pageId}`;
186
+ await api(url, apiKey, "DELETE", endpoint);
187
+ return { success: true };
188
+ } });
189
+ searchAction(rl, "page.search", "listOrganisationPage", "Search pages");
190
+ // ── Query ───────────────────────────────────────────
191
+ rl.registerAction("query.execute", { description: "Execute a raw TheHive Query API request",
192
+ inputSchema: { query: { type: "object", required: true, description: "Array of query operations" } },
193
+ async execute(input, ctx) { const { url, apiKey } = getConn(ctx); return api(url, apiKey, "POST", "/v1/query", { query: input.query }); } });
194
+ }
@@ -0,0 +1,244 @@
1
+ const BASE = "https://api.todoist.com/rest/v2";
2
+ const SYNC_BASE = "https://api.todoist.com/sync/v9";
3
+ async function api(token, method, endpoint, body, qs) {
4
+ const url = new URL(`${BASE}${endpoint}`);
5
+ if (qs) {
6
+ for (const [k, v] of Object.entries(qs)) {
7
+ if (v !== undefined && v !== null)
8
+ url.searchParams.set(k, String(v));
9
+ }
10
+ }
11
+ const init = { method, headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" } };
12
+ if (body && Object.keys(body).length > 0)
13
+ init.body = JSON.stringify(body);
14
+ const res = await fetch(url.toString(), init);
15
+ if (res.status === 204)
16
+ return { success: true };
17
+ if (!res.ok)
18
+ throw new Error(`Todoist error ${res.status}: ${await res.text()}`);
19
+ const text = await res.text();
20
+ return text ? JSON.parse(text) : { success: true };
21
+ }
22
+ async function syncApi(token, body) {
23
+ const res = await fetch(`${SYNC_BASE}/sync`, {
24
+ method: "POST", headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" },
25
+ body: JSON.stringify(body),
26
+ });
27
+ if (!res.ok)
28
+ throw new Error(`Todoist Sync error ${res.status}: ${await res.text()}`);
29
+ return res.json();
30
+ }
31
+ async function quickAdd(token, body) {
32
+ const res = await fetch(`${SYNC_BASE}/quick/add`, {
33
+ method: "POST", headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" },
34
+ body: JSON.stringify(body),
35
+ });
36
+ if (!res.ok)
37
+ throw new Error(`Todoist error ${res.status}: ${await res.text()}`);
38
+ return res.json();
39
+ }
40
+ export default function todoist(rl) {
41
+ rl.setName("todoist");
42
+ rl.setVersion("0.1.0");
43
+ rl.setConnectionSchema({ apiToken: { type: "string", required: true, description: "Todoist API token", env: "TODOIST_API_TOKEN" } });
44
+ const t = (ctx) => ctx.connection.config.apiToken;
45
+ // ── Task ────────────────────────────────────────────
46
+ rl.registerAction("task.create", { description: "Create a task",
47
+ inputSchema: { content: { type: "string", required: true }, projectId: { type: "string", required: false }, description: { type: "string", required: false }, priority: { type: "number", required: false, description: "1 (normal) to 4 (urgent)" }, dueString: { type: "string", required: false }, dueDate: { type: "string", required: false, description: "YYYY-MM-DD" }, labels: { type: "object", required: false, description: "Array of label names" }, sectionId: { type: "string", required: false }, parentId: { type: "string", required: false }, assigneeId: { type: "string", required: false } },
48
+ async execute(input, ctx) {
49
+ const p = input;
50
+ const body = { content: p.content };
51
+ if (p.projectId)
52
+ body.project_id = p.projectId;
53
+ if (p.description)
54
+ body.description = p.description;
55
+ if (p.priority)
56
+ body.priority = p.priority;
57
+ if (p.dueString)
58
+ body.due_string = p.dueString;
59
+ if (p.dueDate)
60
+ body.due_date = p.dueDate;
61
+ if (p.labels)
62
+ body.labels = p.labels;
63
+ if (p.sectionId)
64
+ body.section_id = p.sectionId;
65
+ if (p.parentId)
66
+ body.parent_id = p.parentId;
67
+ if (p.assigneeId)
68
+ body.assignee_id = p.assigneeId;
69
+ return api(t(ctx), "POST", "/tasks", body);
70
+ } });
71
+ rl.registerAction("task.get", { description: "Get a task by ID", inputSchema: { id: { type: "string", required: true } },
72
+ async execute(input, ctx) { return api(t(ctx), "GET", `/tasks/${input.id}`); } });
73
+ rl.registerAction("task.list", { description: "List tasks",
74
+ inputSchema: { projectId: { type: "string", required: false }, sectionId: { type: "string", required: false }, label: { type: "string", required: false }, filter: { type: "string", required: false }, limit: { type: "number", required: false } },
75
+ async execute(input, ctx) {
76
+ const p = (input ?? {});
77
+ const qs = {};
78
+ if (p.projectId)
79
+ qs.project_id = p.projectId;
80
+ if (p.sectionId)
81
+ qs.section_id = p.sectionId;
82
+ if (p.label)
83
+ qs.label = p.label;
84
+ if (p.filter)
85
+ qs.filter = p.filter;
86
+ const data = (await api(t(ctx), "GET", "/tasks", undefined, qs));
87
+ return p.limit ? data.slice(0, p.limit) : data;
88
+ } });
89
+ rl.registerAction("task.update", { description: "Update a task",
90
+ inputSchema: { id: { type: "string", required: true }, content: { type: "string", required: false }, description: { type: "string", required: false }, priority: { type: "number", required: false }, dueString: { type: "string", required: false }, dueDate: { type: "string", required: false }, labels: { type: "object", required: false }, assigneeId: { type: "string", required: false } },
91
+ async execute(input, ctx) {
92
+ const { id, ...fields } = input;
93
+ const body = {};
94
+ if (fields.content)
95
+ body.content = fields.content;
96
+ if (fields.description)
97
+ body.description = fields.description;
98
+ if (fields.priority)
99
+ body.priority = fields.priority;
100
+ if (fields.dueString)
101
+ body.due_string = fields.dueString;
102
+ if (fields.dueDate)
103
+ body.due_date = fields.dueDate;
104
+ if (fields.labels)
105
+ body.labels = fields.labels;
106
+ if (fields.assigneeId)
107
+ body.assignee_id = fields.assigneeId;
108
+ return api(t(ctx), "POST", `/tasks/${id}`, body);
109
+ } });
110
+ rl.registerAction("task.close", { description: "Close (complete) a task", inputSchema: { id: { type: "string", required: true } },
111
+ async execute(input, ctx) { await api(t(ctx), "POST", `/tasks/${input.id}/close`); return { success: true }; } });
112
+ rl.registerAction("task.reopen", { description: "Reopen a task", inputSchema: { id: { type: "string", required: true } },
113
+ async execute(input, ctx) { await api(t(ctx), "POST", `/tasks/${input.id}/reopen`); return { success: true }; } });
114
+ rl.registerAction("task.delete", { description: "Delete a task", inputSchema: { id: { type: "string", required: true } },
115
+ async execute(input, ctx) { await api(t(ctx), "DELETE", `/tasks/${input.id}`); return { success: true }; } });
116
+ rl.registerAction("task.quickAdd", { description: "Quick add a task using natural language",
117
+ inputSchema: { text: { type: "string", required: true, description: 'e.g. "Buy milk @Grocery #shopping tomorrow"' }, note: { type: "string", required: false }, reminder: { type: "string", required: false } },
118
+ async execute(input, ctx) {
119
+ const p = input;
120
+ const body = { text: p.text };
121
+ if (p.note)
122
+ body.note = p.note;
123
+ if (p.reminder)
124
+ body.reminder = p.reminder;
125
+ return quickAdd(t(ctx), body);
126
+ } });
127
+ // ── Project ─────────────────────────────────────────
128
+ rl.registerAction("project.create", { description: "Create a project",
129
+ inputSchema: { name: { type: "string", required: true }, color: { type: "string", required: false }, isFavorite: { type: "boolean", required: false }, parentId: { type: "string", required: false }, viewStyle: { type: "string", required: false, description: "list or board" } },
130
+ async execute(input, ctx) {
131
+ const p = input;
132
+ const body = { name: p.name };
133
+ if (p.color)
134
+ body.color = p.color;
135
+ if (p.isFavorite)
136
+ body.is_favorite = true;
137
+ if (p.parentId)
138
+ body.parent_id = p.parentId;
139
+ if (p.viewStyle)
140
+ body.view_style = p.viewStyle;
141
+ return api(t(ctx), "POST", "/projects", body);
142
+ } });
143
+ rl.registerAction("project.get", { description: "Get a project", inputSchema: { id: { type: "string", required: true } },
144
+ async execute(input, ctx) { return api(t(ctx), "GET", `/projects/${input.id}`); } });
145
+ rl.registerAction("project.list", { description: "List all projects", inputSchema: {},
146
+ async execute(_input, ctx) { return api(t(ctx), "GET", "/projects"); } });
147
+ rl.registerAction("project.update", { description: "Update a project",
148
+ inputSchema: { id: { type: "string", required: true }, name: { type: "string", required: false }, color: { type: "string", required: false }, isFavorite: { type: "boolean", required: false }, viewStyle: { type: "string", required: false } },
149
+ async execute(input, ctx) {
150
+ const { id, ...fields } = input;
151
+ const body = {};
152
+ if (fields.name)
153
+ body.name = fields.name;
154
+ if (fields.color)
155
+ body.color = fields.color;
156
+ if (fields.isFavorite !== undefined)
157
+ body.is_favorite = fields.isFavorite;
158
+ if (fields.viewStyle)
159
+ body.view_style = fields.viewStyle;
160
+ return api(t(ctx), "POST", `/projects/${id}`, body);
161
+ } });
162
+ rl.registerAction("project.delete", { description: "Delete a project", inputSchema: { id: { type: "string", required: true } },
163
+ async execute(input, ctx) { await api(t(ctx), "DELETE", `/projects/${input.id}`); return { success: true }; } });
164
+ rl.registerAction("project.archive", { description: "Archive a project", inputSchema: { id: { type: "string", required: true } },
165
+ async execute(input, ctx) { await api(t(ctx), "POST", `/projects/${input.id}/archive`); return { success: true }; } });
166
+ rl.registerAction("project.unarchive", { description: "Unarchive a project", inputSchema: { id: { type: "string", required: true } },
167
+ async execute(input, ctx) { await api(t(ctx), "POST", `/projects/${input.id}/unarchive`); return { success: true }; } });
168
+ rl.registerAction("project.getCollaborators", { description: "Get project collaborators", inputSchema: { id: { type: "string", required: true } },
169
+ async execute(input, ctx) { return api(t(ctx), "GET", `/projects/${input.id}/collaborators`); } });
170
+ // ── Section ─────────────────────────────────────────
171
+ rl.registerAction("section.create", { description: "Create a section",
172
+ inputSchema: { projectId: { type: "string", required: true }, name: { type: "string", required: true }, order: { type: "number", required: false } },
173
+ async execute(input, ctx) { const p = input; return api(t(ctx), "POST", "/sections", { project_id: p.projectId, name: p.name, ...(p.order ? { order: p.order } : {}) }); } });
174
+ rl.registerAction("section.get", { description: "Get a section", inputSchema: { id: { type: "string", required: true } },
175
+ async execute(input, ctx) { return api(t(ctx), "GET", `/sections/${input.id}`); } });
176
+ rl.registerAction("section.list", { description: "List sections",
177
+ inputSchema: { projectId: { type: "string", required: false } },
178
+ async execute(input, ctx) {
179
+ const qs = {};
180
+ if (input?.projectId)
181
+ qs.project_id = input.projectId;
182
+ return api(t(ctx), "GET", "/sections", undefined, qs);
183
+ } });
184
+ rl.registerAction("section.update", { description: "Update a section", inputSchema: { id: { type: "string", required: true }, name: { type: "string", required: true } },
185
+ async execute(input, ctx) { const p = input; return api(t(ctx), "POST", `/sections/${p.id}`, { name: p.name }); } });
186
+ rl.registerAction("section.delete", { description: "Delete a section", inputSchema: { id: { type: "string", required: true } },
187
+ async execute(input, ctx) { await api(t(ctx), "DELETE", `/sections/${input.id}`); return { success: true }; } });
188
+ // ── Comment ─────────────────────────────────────────
189
+ rl.registerAction("comment.create", { description: "Create a comment on a task",
190
+ inputSchema: { taskId: { type: "string", required: true }, content: { type: "string", required: true } },
191
+ async execute(input, ctx) { const p = input; return api(t(ctx), "POST", "/comments", { task_id: p.taskId, content: p.content }); } });
192
+ rl.registerAction("comment.get", { description: "Get a comment", inputSchema: { id: { type: "string", required: true } },
193
+ async execute(input, ctx) { return api(t(ctx), "GET", `/comments/${input.id}`); } });
194
+ rl.registerAction("comment.list", { description: "List comments",
195
+ inputSchema: { taskId: { type: "string", required: false }, projectId: { type: "string", required: false } },
196
+ async execute(input, ctx) {
197
+ const p = (input ?? {});
198
+ const qs = {};
199
+ if (p.taskId)
200
+ qs.task_id = p.taskId;
201
+ if (p.projectId)
202
+ qs.project_id = p.projectId;
203
+ return api(t(ctx), "GET", "/comments", undefined, qs);
204
+ } });
205
+ rl.registerAction("comment.update", { description: "Update a comment", inputSchema: { id: { type: "string", required: true }, content: { type: "string", required: true } },
206
+ async execute(input, ctx) { const p = input; return api(t(ctx), "POST", `/comments/${p.id}`, { content: p.content }); } });
207
+ rl.registerAction("comment.delete", { description: "Delete a comment", inputSchema: { id: { type: "string", required: true } },
208
+ async execute(input, ctx) { await api(t(ctx), "DELETE", `/comments/${input.id}`); return { success: true }; } });
209
+ // ── Label ───────────────────────────────────────────
210
+ rl.registerAction("label.create", { description: "Create a label",
211
+ inputSchema: { name: { type: "string", required: true }, color: { type: "string", required: false }, order: { type: "number", required: false }, isFavorite: { type: "boolean", required: false } },
212
+ async execute(input, ctx) {
213
+ const p = input;
214
+ const body = { name: p.name };
215
+ if (p.color)
216
+ body.color = p.color;
217
+ if (p.order)
218
+ body.order = p.order;
219
+ if (p.isFavorite)
220
+ body.is_favorite = true;
221
+ return api(t(ctx), "POST", "/labels", body);
222
+ } });
223
+ rl.registerAction("label.get", { description: "Get a label", inputSchema: { id: { type: "string", required: true } },
224
+ async execute(input, ctx) { return api(t(ctx), "GET", `/labels/${input.id}`); } });
225
+ rl.registerAction("label.list", { description: "List all labels", inputSchema: {},
226
+ async execute(_input, ctx) { return api(t(ctx), "GET", "/labels"); } });
227
+ rl.registerAction("label.update", { description: "Update a label",
228
+ inputSchema: { id: { type: "string", required: true }, name: { type: "string", required: false }, color: { type: "string", required: false }, order: { type: "number", required: false }, isFavorite: { type: "boolean", required: false } },
229
+ async execute(input, ctx) {
230
+ const { id, ...fields } = input;
231
+ const body = {};
232
+ if (fields.name)
233
+ body.name = fields.name;
234
+ if (fields.color)
235
+ body.color = fields.color;
236
+ if (fields.order)
237
+ body.order = fields.order;
238
+ if (fields.isFavorite !== undefined)
239
+ body.is_favorite = fields.isFavorite;
240
+ return api(t(ctx), "POST", `/labels/${id}`, body);
241
+ } });
242
+ rl.registerAction("label.delete", { description: "Delete a label", inputSchema: { id: { type: "string", required: true } },
243
+ async execute(input, ctx) { await api(t(ctx), "DELETE", `/labels/${input.id}`); return { success: true }; } });
244
+ }