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.
- package/.pi/extensions/runline-context/index.ts +135 -0
- package/.pi/extensions/runline-context/package.json +17 -0
- package/README.md +273 -0
- package/dist/commands/actions.d.ts +3 -0
- package/dist/commands/actions.js +43 -0
- package/dist/commands/connection.d.ts +11 -0
- package/dist/commands/connection.js +56 -0
- package/dist/commands/exec.d.ts +5 -0
- package/dist/commands/exec.js +46 -0
- package/dist/commands/init.d.ts +4 -0
- package/dist/commands/init.js +26 -0
- package/dist/commands/plugin.d.ts +10 -0
- package/dist/commands/plugin.js +57 -0
- package/dist/config/index.d.ts +3 -0
- package/dist/config/index.js +2 -0
- package/dist/config/loader.d.ts +11 -0
- package/dist/config/loader.js +82 -0
- package/dist/config/types.d.ts +9 -0
- package/dist/config/types.js +5 -0
- package/dist/core/engine.d.ts +21 -0
- package/dist/core/engine.js +280 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +9 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +127 -0
- package/dist/plugin/api.d.ts +32 -0
- package/dist/plugin/api.js +68 -0
- package/dist/plugin/installer.d.ts +27 -0
- package/dist/plugin/installer.js +181 -0
- package/dist/plugin/loader.d.ts +13 -0
- package/dist/plugin/loader.js +164 -0
- package/dist/plugin/registry.d.ts +18 -0
- package/dist/plugin/registry.js +43 -0
- package/dist/plugin/types.d.ts +40 -0
- package/dist/plugin/types.js +1 -0
- package/dist/plugins/actionNetwork/src/index.js +353 -0
- package/dist/plugins/activeCampaign/src/index.js +711 -0
- package/dist/plugins/adalo/src/index.js +131 -0
- package/dist/plugins/affinity/src/index.js +279 -0
- package/dist/plugins/agileCrm/src/index.js +415 -0
- package/dist/plugins/airtable/src/index.js +280 -0
- package/dist/plugins/airtop/src/index.js +527 -0
- package/dist/plugins/apiTemplateIo/src/index.js +86 -0
- package/dist/plugins/asana/src/index.js +413 -0
- package/dist/plugins/autopilot/src/index.js +203 -0
- package/dist/plugins/bambooHr/src/index.js +252 -0
- package/dist/plugins/bannerbear/src/index.js +100 -0
- package/dist/plugins/baserow/src/index.js +180 -0
- package/dist/plugins/beeminder/src/index.js +298 -0
- package/dist/plugins/bitly/src/index.js +107 -0
- package/dist/plugins/bitwarden/src/index.js +383 -0
- package/dist/plugins/box/src/index.js +300 -0
- package/dist/plugins/brandfetch/src/index.js +80 -0
- package/dist/plugins/brevo/src/index.js +305 -0
- package/dist/plugins/bubble/src/index.js +181 -0
- package/dist/plugins/chargebee/src/index.js +126 -0
- package/dist/plugins/circleci/src/index.js +111 -0
- package/dist/plugins/ciscoWebex/src/index.js +245 -0
- package/dist/plugins/clearbit/src/index.js +103 -0
- package/dist/plugins/clickup/src/index.js +1043 -0
- package/dist/plugins/clockify/src/index.js +443 -0
- package/dist/plugins/cloudflare/src/index.js +93 -0
- package/dist/plugins/cockpit/src/index.js +131 -0
- package/dist/plugins/coda/src/index.js +327 -0
- package/dist/plugins/coingecko/src/index.js +244 -0
- package/dist/plugins/contentful/src/index.js +146 -0
- package/dist/plugins/convertkit/src/index.js +270 -0
- package/dist/plugins/copper/src/index.js +140 -0
- package/dist/plugins/cortex/src/index.js +147 -0
- package/dist/plugins/currents/src/index.js +405 -0
- package/dist/plugins/customerIo/src/index.js +184 -0
- package/dist/plugins/databricks/src/index.js +342 -0
- package/dist/plugins/deepl/src/index.js +87 -0
- package/dist/plugins/demio/src/index.js +111 -0
- package/dist/plugins/dhl/src/index.js +40 -0
- package/dist/plugins/discord/src/index.js +275 -0
- package/dist/plugins/discourse/src/index.js +273 -0
- package/dist/plugins/disqus/src/index.js +145 -0
- package/dist/plugins/docker/src/index.js +76 -0
- package/dist/plugins/drift/src/index.js +89 -0
- package/dist/plugins/dropbox/src/index.js +159 -0
- package/dist/plugins/dropcontact/src/index.js +59 -0
- package/dist/plugins/egoi/src/index.js +151 -0
- package/dist/plugins/elasticsearch/src/index.js +157 -0
- package/dist/plugins/emelia/src/index.js +174 -0
- package/dist/plugins/erpnext/src/index.js +121 -0
- package/dist/plugins/facebookGraph/src/index.js +57 -0
- package/dist/plugins/freshdesk/src/index.js +320 -0
- package/dist/plugins/freshservice/src/index.js +146 -0
- package/dist/plugins/freshworksCrm/src/index.js +149 -0
- package/dist/plugins/getresponse/src/index.js +140 -0
- package/dist/plugins/ghost/src/index.js +192 -0
- package/dist/plugins/github/src/index.js +630 -0
- package/dist/plugins/gitlab/src/index.js +358 -0
- package/dist/plugins/gong/src/index.js +126 -0
- package/dist/plugins/gotify/src/index.js +77 -0
- package/dist/plugins/gotowebinar/src/index.js +316 -0
- package/dist/plugins/grafana/src/index.js +250 -0
- package/dist/plugins/graphql/src/index.js +78 -0
- package/dist/plugins/grist/src/index.js +106 -0
- package/dist/plugins/hackernews/src/index.js +89 -0
- package/dist/plugins/halopsa/src/index.js +79 -0
- package/dist/plugins/harvest/src/index.js +163 -0
- package/dist/plugins/helpscout/src/index.js +176 -0
- package/dist/plugins/highlevel/src/index.js +172 -0
- package/dist/plugins/homeAssistant/src/index.js +148 -0
- package/dist/plugins/hubspot/src/index.js +176 -0
- package/dist/plugins/humanticAi/src/index.js +60 -0
- package/dist/plugins/hunter/src/index.js +59 -0
- package/dist/plugins/intercom/src/index.js +156 -0
- package/dist/plugins/iterable/src/index.js +139 -0
- package/dist/plugins/jenkins/src/index.js +132 -0
- package/dist/plugins/jira/src/index.js +229 -0
- package/dist/plugins/keap/src/index.js +502 -0
- package/dist/plugins/kobotoolbox/src/index.js +281 -0
- package/dist/plugins/lemlist/src/index.js +231 -0
- package/dist/plugins/linear/src/index.js +133 -0
- package/dist/plugins/lingvanex/src/index.js +31 -0
- package/dist/plugins/linkedin/src/index.js +80 -0
- package/dist/plugins/lonescale/src/index.js +119 -0
- package/dist/plugins/magento/src/index.js +300 -0
- package/dist/plugins/mailcheck/src/index.js +27 -0
- package/dist/plugins/mailchimp/src/index.js +321 -0
- package/dist/plugins/mailerlite/src/index.js +123 -0
- package/dist/plugins/mailgun/src/index.js +48 -0
- package/dist/plugins/mailjet/src/index.js +155 -0
- package/dist/plugins/mandrill/src/index.js +145 -0
- package/dist/plugins/marketstack/src/index.js +97 -0
- package/dist/plugins/matrix/src/index.js +194 -0
- package/dist/plugins/mattermost/src/index.js +331 -0
- package/dist/plugins/mautic/src/index.js +311 -0
- package/dist/plugins/medium/src/index.js +77 -0
- package/dist/plugins/messagebird/src/index.js +57 -0
- package/dist/plugins/metabase/src/index.js +130 -0
- package/dist/plugins/misp/src/index.js +476 -0
- package/dist/plugins/mocean/src/index.js +67 -0
- package/dist/plugins/monday/src/index.js +231 -0
- package/dist/plugins/monicaCrm/src/index.js +52 -0
- package/dist/plugins/msg91/src/index.js +31 -0
- package/dist/plugins/nasa/src/index.js +146 -0
- package/dist/plugins/netlify/src/index.js +151 -0
- package/dist/plugins/netscalerAdc/src/index.js +131 -0
- package/dist/plugins/nextcloud/src/index.js +263 -0
- package/dist/plugins/nocodb/src/index.js +130 -0
- package/dist/plugins/notion/src/index.js +112 -0
- package/dist/plugins/npm/src/index.js +104 -0
- package/dist/plugins/odoo/src/index.js +157 -0
- package/dist/plugins/okta/src/index.js +141 -0
- package/dist/plugins/oneSimpleApi/src/index.js +155 -0
- package/dist/plugins/onfleet/src/index.js +254 -0
- package/dist/plugins/openThesaurus/src/index.js +32 -0
- package/dist/plugins/openweathermap/src/index.js +60 -0
- package/dist/plugins/oura/src/index.js +62 -0
- package/dist/plugins/paddle/src/index.js +247 -0
- package/dist/plugins/pagerduty/src/index.js +201 -0
- package/dist/plugins/paypal/src/index.js +106 -0
- package/dist/plugins/peekalink/src/index.js +35 -0
- package/dist/plugins/phantombuster/src/index.js +94 -0
- package/dist/plugins/philipsHue/src/index.js +98 -0
- package/dist/plugins/pipedrive/src/index.js +169 -0
- package/dist/plugins/plivo/src/index.js +66 -0
- package/dist/plugins/postbin/src/index.js +93 -0
- package/dist/plugins/posthog/src/index.js +113 -0
- package/dist/plugins/profitwell/src/index.js +50 -0
- package/dist/plugins/pushbullet/src/index.js +102 -0
- package/dist/plugins/pushcut/src/index.js +39 -0
- package/dist/plugins/pushover/src/index.js +65 -0
- package/dist/plugins/quickbase/src/index.js +153 -0
- package/dist/plugins/quickbooks/src/index.js +73 -0
- package/dist/plugins/quickchart/src/index.js +36 -0
- package/dist/plugins/raindrop/src/index.js +209 -0
- package/dist/plugins/reddit/src/index.js +185 -0
- package/dist/plugins/rocketchat/src/index.js +53 -0
- package/dist/plugins/rundeck/src/index.js +62 -0
- package/dist/plugins/salesforce/src/index.js +94 -0
- package/dist/plugins/salesmate/src/index.js +83 -0
- package/dist/plugins/securityScorecard/src/index.js +200 -0
- package/dist/plugins/segment/src/index.js +125 -0
- package/dist/plugins/sendgrid/src/index.js +187 -0
- package/dist/plugins/sendy/src/index.js +138 -0
- package/dist/plugins/sentry/src/index.js +233 -0
- package/dist/plugins/servicenow/src/index.js +108 -0
- package/dist/plugins/shopify/src/index.js +222 -0
- package/dist/plugins/signl4/src/index.js +61 -0
- package/dist/plugins/slack/src/index.js +236 -0
- package/dist/plugins/sms77/src/index.js +63 -0
- package/dist/plugins/splunk/src/index.js +207 -0
- package/dist/plugins/spotify/src/index.js +188 -0
- package/dist/plugins/stackby/src/index.js +82 -0
- package/dist/plugins/storyblok/src/index.js +141 -0
- package/dist/plugins/strapi/src/index.js +152 -0
- package/dist/plugins/strava/src/index.js +137 -0
- package/dist/plugins/stripe/src/index.js +222 -0
- package/dist/plugins/supabase/src/index.js +121 -0
- package/dist/plugins/syncromsp/src/index.js +255 -0
- package/dist/plugins/tapfiliate/src/index.js +125 -0
- package/dist/plugins/telegram/src/index.js +233 -0
- package/dist/plugins/thehive/src/index.js +142 -0
- package/dist/plugins/thehiveProject/src/index.js +194 -0
- package/dist/plugins/todoist/src/index.js +244 -0
- package/dist/plugins/travisci/src/index.js +71 -0
- package/dist/plugins/trello/src/index.js +341 -0
- package/dist/plugins/twake/src/index.js +40 -0
- package/dist/plugins/twilio/src/index.js +75 -0
- package/dist/plugins/twist/src/index.js +90 -0
- package/dist/plugins/twitter/src/index.js +123 -0
- package/dist/plugins/unleashedSoftware/src/index.js +84 -0
- package/dist/plugins/uplead/src/index.js +59 -0
- package/dist/plugins/uproc/src/index.js +34 -0
- package/dist/plugins/uptimerobot/src/index.js +264 -0
- package/dist/plugins/urlscanio/src/index.js +64 -0
- package/dist/plugins/vero/src/index.js +80 -0
- package/dist/plugins/vonage/src/index.js +42 -0
- package/dist/plugins/wekan/src/index.js +91 -0
- package/dist/plugins/woocommerce/src/index.js +92 -0
- package/dist/plugins/wordpress/src/index.js +121 -0
- package/dist/plugins/xero/src/index.js +136 -0
- package/dist/plugins/yourls/src/index.js +56 -0
- package/dist/plugins/zammad/src/index.js +91 -0
- package/dist/plugins/zendesk/src/index.js +137 -0
- package/dist/plugins/zoho/src/index.js +85 -0
- package/dist/plugins/zoom/src/index.js +122 -0
- package/dist/plugins/zulip/src/index.js +170 -0
- package/dist/sdk.d.ts +38 -0
- package/dist/sdk.js +105 -0
- package/dist/utils/cli.d.ts +13 -0
- package/dist/utils/cli.js +32 -0
- package/dist/utils/output.d.ts +4 -0
- package/dist/utils/output.js +13 -0
- package/package.json +57 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
const BASE_URL = "https://mandrillapp.com/api/1.0";
|
|
2
|
+
async function apiRequest(apiKey, endpoint, body = {}) {
|
|
3
|
+
body.key = apiKey;
|
|
4
|
+
const res = await fetch(`${BASE_URL}${endpoint}.json`, {
|
|
5
|
+
method: "POST",
|
|
6
|
+
headers: { "Content-Type": "application/json" },
|
|
7
|
+
body: JSON.stringify(body),
|
|
8
|
+
});
|
|
9
|
+
if (!res.ok)
|
|
10
|
+
throw new Error(`Mandrill API error ${res.status}: ${await res.text()}`);
|
|
11
|
+
return res.json();
|
|
12
|
+
}
|
|
13
|
+
export default function mandrill(rl) {
|
|
14
|
+
rl.setName("mandrill");
|
|
15
|
+
rl.setVersion("0.1.0");
|
|
16
|
+
rl.setConnectionSchema({
|
|
17
|
+
apiKey: { type: "string", required: true, description: "Mandrill API key", env: "MANDRILL_API_KEY" },
|
|
18
|
+
});
|
|
19
|
+
const key = (ctx) => ctx.connection.config.apiKey;
|
|
20
|
+
function buildMessage(p) {
|
|
21
|
+
const message = {
|
|
22
|
+
from_email: p.fromEmail,
|
|
23
|
+
to: p.toEmail.split(",").map((e) => ({ email: e.trim(), type: "to" })),
|
|
24
|
+
};
|
|
25
|
+
if (p.fromName)
|
|
26
|
+
message.from_name = p.fromName;
|
|
27
|
+
if (p.subject)
|
|
28
|
+
message.subject = p.subject;
|
|
29
|
+
if (p.html)
|
|
30
|
+
message.html = p.html;
|
|
31
|
+
if (p.text)
|
|
32
|
+
message.text = p.text;
|
|
33
|
+
if (p.bccAddress)
|
|
34
|
+
message.bcc_address = p.bccAddress;
|
|
35
|
+
if (p.tags)
|
|
36
|
+
message.tags = p.tags.split(",").map((t) => t.trim());
|
|
37
|
+
if (p.subaccount)
|
|
38
|
+
message.subaccount = p.subaccount;
|
|
39
|
+
if (p.trackOpens !== undefined)
|
|
40
|
+
message.track_opens = p.trackOpens;
|
|
41
|
+
if (p.trackClicks !== undefined)
|
|
42
|
+
message.track_clicks = p.trackClicks;
|
|
43
|
+
if (p.autoText !== undefined)
|
|
44
|
+
message.auto_text = p.autoText;
|
|
45
|
+
if (p.autoHtml !== undefined)
|
|
46
|
+
message.auto_html = p.autoHtml;
|
|
47
|
+
if (p.inlineCss !== undefined)
|
|
48
|
+
message.inline_css = p.inlineCss;
|
|
49
|
+
if (p.important !== undefined)
|
|
50
|
+
message.important = p.important;
|
|
51
|
+
if (p.preserveRecipients !== undefined)
|
|
52
|
+
message.preserve_recipients = p.preserveRecipients;
|
|
53
|
+
if (p.urlStripQs !== undefined)
|
|
54
|
+
message.url_strip_qs = p.urlStripQs;
|
|
55
|
+
if (p.viewContentLink !== undefined)
|
|
56
|
+
message.view_content_link = p.viewContentLink;
|
|
57
|
+
if (p.async !== undefined)
|
|
58
|
+
message.async = p.async;
|
|
59
|
+
if (p.ipPool)
|
|
60
|
+
message.ip_pool = p.ipPool;
|
|
61
|
+
if (p.trackingDomain)
|
|
62
|
+
message.tracking_domain = p.trackingDomain;
|
|
63
|
+
if (p.signingDomain)
|
|
64
|
+
message.signing_domain = p.signingDomain;
|
|
65
|
+
if (p.returnPathDomain)
|
|
66
|
+
message.return_path_domain = p.returnPathDomain;
|
|
67
|
+
if (p.googleAnalyticsCampaign)
|
|
68
|
+
message.google_analytics_campaign = p.googleAnalyticsCampaign;
|
|
69
|
+
if (p.googleAnalyticsDomains)
|
|
70
|
+
message.google_analytics_domains = p.googleAnalyticsDomains.split(",").map((d) => d.trim());
|
|
71
|
+
if (p.mergeVars)
|
|
72
|
+
message.global_merge_vars = p.mergeVars;
|
|
73
|
+
if (p.metadata)
|
|
74
|
+
message.metadata = p.metadata;
|
|
75
|
+
if (p.headers)
|
|
76
|
+
message.headers = p.headers;
|
|
77
|
+
if (p.attachments)
|
|
78
|
+
message.attachments = p.attachments;
|
|
79
|
+
return message;
|
|
80
|
+
}
|
|
81
|
+
const messageInputSchema = {
|
|
82
|
+
fromEmail: { type: "string", required: true },
|
|
83
|
+
toEmail: { type: "string", required: true, description: "Comma-separated recipient emails" },
|
|
84
|
+
fromName: { type: "string", required: false },
|
|
85
|
+
subject: { type: "string", required: false },
|
|
86
|
+
html: { type: "string", required: false, description: "HTML body" },
|
|
87
|
+
text: { type: "string", required: false, description: "Plain text body" },
|
|
88
|
+
bccAddress: { type: "string", required: false },
|
|
89
|
+
tags: { type: "string", required: false, description: "Comma-separated tags" },
|
|
90
|
+
subaccount: { type: "string", required: false },
|
|
91
|
+
trackOpens: { type: "boolean", required: false },
|
|
92
|
+
trackClicks: { type: "boolean", required: false },
|
|
93
|
+
autoText: { type: "boolean", required: false },
|
|
94
|
+
autoHtml: { type: "boolean", required: false },
|
|
95
|
+
inlineCss: { type: "boolean", required: false },
|
|
96
|
+
important: { type: "boolean", required: false },
|
|
97
|
+
preserveRecipients: { type: "boolean", required: false },
|
|
98
|
+
urlStripQs: { type: "boolean", required: false },
|
|
99
|
+
viewContentLink: { type: "boolean", required: false },
|
|
100
|
+
async: { type: "boolean", required: false },
|
|
101
|
+
ipPool: { type: "string", required: false },
|
|
102
|
+
trackingDomain: { type: "string", required: false },
|
|
103
|
+
signingDomain: { type: "string", required: false },
|
|
104
|
+
returnPathDomain: { type: "string", required: false },
|
|
105
|
+
googleAnalyticsCampaign: { type: "string", required: false },
|
|
106
|
+
googleAnalyticsDomains: { type: "string", required: false, description: "Comma-separated domains" },
|
|
107
|
+
mergeVars: { type: "array", required: false, description: "Array of {name, content} objects" },
|
|
108
|
+
metadata: { type: "object", required: false, description: "Key-value metadata" },
|
|
109
|
+
headers: { type: "object", required: false, description: "Extra headers" },
|
|
110
|
+
attachments: { type: "array", required: false, description: "Array of {type, name, content} (content is base64)" },
|
|
111
|
+
sendAt: { type: "string", required: false, description: "UTC datetime YYYY-MM-DD HH:mm:ss" },
|
|
112
|
+
};
|
|
113
|
+
rl.registerAction("message.sendHtml", {
|
|
114
|
+
description: "Send an email with HTML/text content via Mandrill",
|
|
115
|
+
inputSchema: messageInputSchema,
|
|
116
|
+
async execute(input, ctx) {
|
|
117
|
+
const p = input;
|
|
118
|
+
const body = {
|
|
119
|
+
message: buildMessage(p),
|
|
120
|
+
template_content: [],
|
|
121
|
+
};
|
|
122
|
+
if (p.sendAt)
|
|
123
|
+
body.send_at = p.sendAt;
|
|
124
|
+
return apiRequest(key(ctx), "/messages/send", body);
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
rl.registerAction("message.sendTemplate", {
|
|
128
|
+
description: "Send an email using a Mandrill template",
|
|
129
|
+
inputSchema: {
|
|
130
|
+
templateName: { type: "string", required: true, description: "Template slug" },
|
|
131
|
+
...messageInputSchema,
|
|
132
|
+
},
|
|
133
|
+
async execute(input, ctx) {
|
|
134
|
+
const p = input;
|
|
135
|
+
const body = {
|
|
136
|
+
template_name: p.templateName,
|
|
137
|
+
template_content: [],
|
|
138
|
+
message: buildMessage(p),
|
|
139
|
+
};
|
|
140
|
+
if (p.sendAt)
|
|
141
|
+
body.send_at = p.sendAt;
|
|
142
|
+
return apiRequest(key(ctx), "/messages/send-template", body);
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
async function apiRequest(apiKey, useHttps, method, endpoint, qs = {}) {
|
|
2
|
+
const protocol = useHttps ? "https" : "http";
|
|
3
|
+
const url = new URL(`${protocol}://api.marketstack.com/v1${endpoint}`);
|
|
4
|
+
url.searchParams.set("access_key", apiKey);
|
|
5
|
+
for (const [k, v] of Object.entries(qs)) {
|
|
6
|
+
if (v !== undefined && v !== null)
|
|
7
|
+
url.searchParams.set(k, String(v));
|
|
8
|
+
}
|
|
9
|
+
const res = await fetch(url.toString(), { method });
|
|
10
|
+
if (!res.ok)
|
|
11
|
+
throw new Error(`Marketstack API error ${res.status}: ${await res.text()}`);
|
|
12
|
+
return res.json();
|
|
13
|
+
}
|
|
14
|
+
async function paginateAll(apiKey, useHttps, endpoint, qs = {}, limit) {
|
|
15
|
+
const all = [];
|
|
16
|
+
qs.offset = 0;
|
|
17
|
+
let resp;
|
|
18
|
+
do {
|
|
19
|
+
resp = (await apiRequest(apiKey, useHttps, "GET", endpoint, qs));
|
|
20
|
+
const data = resp.data;
|
|
21
|
+
if (data)
|
|
22
|
+
all.push(...data);
|
|
23
|
+
if (limit && all.length >= limit)
|
|
24
|
+
return all.slice(0, limit);
|
|
25
|
+
qs.offset += resp.count ?? 0;
|
|
26
|
+
} while (resp.total > all.length);
|
|
27
|
+
return all;
|
|
28
|
+
}
|
|
29
|
+
export default function marketstack(rl) {
|
|
30
|
+
rl.setName("marketstack");
|
|
31
|
+
rl.setVersion("0.1.0");
|
|
32
|
+
rl.setConnectionSchema({
|
|
33
|
+
apiKey: { type: "string", required: true, description: "Marketstack API access key", env: "MARKETSTACK_API_KEY" },
|
|
34
|
+
useHttps: { type: "boolean", required: false, description: "Use HTTPS (requires paid plan). Default: false", default: false },
|
|
35
|
+
});
|
|
36
|
+
const conn = (ctx) => ({
|
|
37
|
+
apiKey: ctx.connection.config.apiKey,
|
|
38
|
+
useHttps: ctx.connection.config.useHttps ?? false,
|
|
39
|
+
});
|
|
40
|
+
// ── End-of-Day Data ─────────────────────────────────
|
|
41
|
+
rl.registerAction("endOfDayData.list", {
|
|
42
|
+
description: "Get end-of-day stock market closing data. Must specify exactly one of: latest, specificDate, or dateFrom+dateTo.",
|
|
43
|
+
inputSchema: {
|
|
44
|
+
symbols: { type: "string", required: true, description: "Comma-separated stock symbols (e.g. AAPL,MSFT)" },
|
|
45
|
+
latest: { type: "boolean", required: false, description: "Get latest EOD data" },
|
|
46
|
+
specificDate: { type: "string", required: false, description: "Specific date (YYYY-MM-DD)" },
|
|
47
|
+
dateFrom: { type: "string", required: false, description: "Start date (YYYY-MM-DD)" },
|
|
48
|
+
dateTo: { type: "string", required: false, description: "End date (YYYY-MM-DD)" },
|
|
49
|
+
sort: { type: "string", required: false, description: "ASC or DESC" },
|
|
50
|
+
exchange: { type: "string", required: false, description: "Filter by exchange MIC" },
|
|
51
|
+
limit: { type: "number", required: false, description: "Max results" },
|
|
52
|
+
},
|
|
53
|
+
async execute(input, ctx) {
|
|
54
|
+
const p = input;
|
|
55
|
+
const { apiKey, useHttps } = conn(ctx);
|
|
56
|
+
const qs = { symbols: p.symbols };
|
|
57
|
+
if (p.sort)
|
|
58
|
+
qs.sort = p.sort;
|
|
59
|
+
if (p.exchange)
|
|
60
|
+
qs.exchange = p.exchange;
|
|
61
|
+
let endpoint;
|
|
62
|
+
if (p.latest) {
|
|
63
|
+
endpoint = "/eod/latest";
|
|
64
|
+
}
|
|
65
|
+
else if (p.specificDate) {
|
|
66
|
+
endpoint = `/eod/${p.specificDate.split("T")[0]}`;
|
|
67
|
+
}
|
|
68
|
+
else if (p.dateFrom && p.dateTo) {
|
|
69
|
+
endpoint = "/eod";
|
|
70
|
+
qs.date_from = p.dateFrom.split("T")[0];
|
|
71
|
+
qs.date_to = p.dateTo.split("T")[0];
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
throw new Error("Specify one of: latest (true), specificDate, or dateFrom+dateTo");
|
|
75
|
+
}
|
|
76
|
+
return paginateAll(apiKey, useHttps, endpoint, qs, p.limit);
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
// ── Exchange ────────────────────────────────────────
|
|
80
|
+
rl.registerAction("exchange.get", {
|
|
81
|
+
description: "Get details about a stock exchange",
|
|
82
|
+
inputSchema: { exchange: { type: "string", required: true, description: "Exchange MIC code (e.g. XNAS)" } },
|
|
83
|
+
async execute(input, ctx) {
|
|
84
|
+
const { apiKey, useHttps } = conn(ctx);
|
|
85
|
+
return apiRequest(apiKey, useHttps, "GET", `/exchanges/${input.exchange}`);
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
// ── Ticker ──────────────────────────────────────────
|
|
89
|
+
rl.registerAction("ticker.get", {
|
|
90
|
+
description: "Get details about a stock ticker symbol",
|
|
91
|
+
inputSchema: { symbol: { type: "string", required: true, description: "Ticker symbol (e.g. AAPL)" } },
|
|
92
|
+
async execute(input, ctx) {
|
|
93
|
+
const { apiKey, useHttps } = conn(ctx);
|
|
94
|
+
return apiRequest(apiKey, useHttps, "GET", `/tickers/${input.symbol}`);
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
async function apiRequest(homeserver, token, method, endpoint, body, qs) {
|
|
2
|
+
const url = new URL(`${homeserver}/_matrix/client/r0${endpoint}`);
|
|
3
|
+
if (qs) {
|
|
4
|
+
for (const [k, v] of Object.entries(qs)) {
|
|
5
|
+
if (v !== undefined && v !== null && v !== "")
|
|
6
|
+
url.searchParams.set(k, String(v));
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
const opts = {
|
|
10
|
+
method,
|
|
11
|
+
headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json; charset=utf-8" },
|
|
12
|
+
};
|
|
13
|
+
if (body && Object.keys(body).length > 0 && method !== "GET" && method !== "DELETE")
|
|
14
|
+
opts.body = JSON.stringify(body);
|
|
15
|
+
const res = await fetch(url.toString(), opts);
|
|
16
|
+
if (!res.ok)
|
|
17
|
+
throw new Error(`Matrix API error ${res.status}: ${await res.text()}`);
|
|
18
|
+
return res.json();
|
|
19
|
+
}
|
|
20
|
+
function generateTxnId() {
|
|
21
|
+
return crypto.randomUUID();
|
|
22
|
+
}
|
|
23
|
+
export default function matrix(rl) {
|
|
24
|
+
rl.setName("matrix");
|
|
25
|
+
rl.setVersion("0.1.0");
|
|
26
|
+
rl.setConnectionSchema({
|
|
27
|
+
homeserverUrl: { type: "string", required: true, description: "Matrix homeserver URL (e.g. https://matrix.org)", env: "MATRIX_HOMESERVER_URL" },
|
|
28
|
+
accessToken: { type: "string", required: true, description: "Matrix access token", env: "MATRIX_ACCESS_TOKEN" },
|
|
29
|
+
});
|
|
30
|
+
const conn = (ctx) => ({
|
|
31
|
+
homeserver: ctx.connection.config.homeserverUrl.replace(/\/$/, ""),
|
|
32
|
+
token: ctx.connection.config.accessToken,
|
|
33
|
+
});
|
|
34
|
+
// ── Account ─────────────────────────────────────────
|
|
35
|
+
rl.registerAction("account.me", {
|
|
36
|
+
description: "Get info about the authenticated user",
|
|
37
|
+
async execute(_input, ctx) {
|
|
38
|
+
const { homeserver, token } = conn(ctx);
|
|
39
|
+
return apiRequest(homeserver, token, "GET", "/account/whoami");
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
// ── Room ────────────────────────────────────────────
|
|
43
|
+
rl.registerAction("room.create", {
|
|
44
|
+
description: "Create a new room",
|
|
45
|
+
inputSchema: {
|
|
46
|
+
name: { type: "string", required: true, description: "Room name" },
|
|
47
|
+
preset: { type: "string", required: true, description: "private_chat, public_chat, or trusted_private_chat" },
|
|
48
|
+
roomAlias: { type: "string", required: false, description: "Local part of room alias (without # or :server)" },
|
|
49
|
+
},
|
|
50
|
+
async execute(input, ctx) {
|
|
51
|
+
const { name, preset, roomAlias } = input;
|
|
52
|
+
const { homeserver, token } = conn(ctx);
|
|
53
|
+
const body = { name, preset };
|
|
54
|
+
if (roomAlias)
|
|
55
|
+
body.room_alias_name = roomAlias;
|
|
56
|
+
return apiRequest(homeserver, token, "POST", "/createRoom", body);
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
rl.registerAction("room.join", {
|
|
60
|
+
description: "Join a room",
|
|
61
|
+
inputSchema: { roomIdOrAlias: { type: "string", required: true, description: "Room ID (!xxx:server) or alias (#xxx:server)" } },
|
|
62
|
+
async execute(input, ctx) {
|
|
63
|
+
const { homeserver, token } = conn(ctx);
|
|
64
|
+
return apiRequest(homeserver, token, "POST", `/rooms/${encodeURIComponent(input.roomIdOrAlias)}/join`);
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
rl.registerAction("room.leave", {
|
|
68
|
+
description: "Leave a room",
|
|
69
|
+
inputSchema: { roomId: { type: "string", required: true } },
|
|
70
|
+
async execute(input, ctx) {
|
|
71
|
+
const { homeserver, token } = conn(ctx);
|
|
72
|
+
return apiRequest(homeserver, token, "POST", `/rooms/${encodeURIComponent(input.roomId)}/leave`);
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
rl.registerAction("room.invite", {
|
|
76
|
+
description: "Invite a user to a room",
|
|
77
|
+
inputSchema: {
|
|
78
|
+
roomId: { type: "string", required: true },
|
|
79
|
+
userId: { type: "string", required: true, description: "Matrix user ID (@user:server)" },
|
|
80
|
+
},
|
|
81
|
+
async execute(input, ctx) {
|
|
82
|
+
const { roomId, userId } = input;
|
|
83
|
+
const { homeserver, token } = conn(ctx);
|
|
84
|
+
return apiRequest(homeserver, token, "POST", `/rooms/${encodeURIComponent(roomId)}/invite`, { user_id: userId });
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
rl.registerAction("room.kick", {
|
|
88
|
+
description: "Kick a user from a room",
|
|
89
|
+
inputSchema: {
|
|
90
|
+
roomId: { type: "string", required: true },
|
|
91
|
+
userId: { type: "string", required: true },
|
|
92
|
+
reason: { type: "string", required: false, description: "Reason for kicking" },
|
|
93
|
+
},
|
|
94
|
+
async execute(input, ctx) {
|
|
95
|
+
const { roomId, userId, reason } = input;
|
|
96
|
+
const { homeserver, token } = conn(ctx);
|
|
97
|
+
const body = { user_id: userId };
|
|
98
|
+
if (reason)
|
|
99
|
+
body.reason = reason;
|
|
100
|
+
return apiRequest(homeserver, token, "POST", `/rooms/${encodeURIComponent(roomId)}/kick`, body);
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
// ── Message ─────────────────────────────────────────
|
|
104
|
+
rl.registerAction("message.create", {
|
|
105
|
+
description: "Send a message to a room",
|
|
106
|
+
inputSchema: {
|
|
107
|
+
roomId: { type: "string", required: true },
|
|
108
|
+
text: { type: "string", required: true, description: "Message text (or HTML if format is org.matrix.custom.html)" },
|
|
109
|
+
messageType: { type: "string", required: false, description: "m.text (default), m.notice, m.emote" },
|
|
110
|
+
messageFormat: { type: "string", required: false, description: "org.matrix.custom.html for HTML messages" },
|
|
111
|
+
fallbackText: { type: "string", required: false, description: "Plain text fallback for HTML messages" },
|
|
112
|
+
},
|
|
113
|
+
async execute(input, ctx) {
|
|
114
|
+
const { roomId, text, messageType = "m.text", messageFormat, fallbackText } = input;
|
|
115
|
+
const { homeserver, token } = conn(ctx);
|
|
116
|
+
const body = { msgtype: messageType, body: text };
|
|
117
|
+
if (messageFormat === "org.matrix.custom.html") {
|
|
118
|
+
body.format = messageFormat;
|
|
119
|
+
body.formatted_body = text;
|
|
120
|
+
body.body = fallbackText || text;
|
|
121
|
+
}
|
|
122
|
+
const txnId = generateTxnId();
|
|
123
|
+
return apiRequest(homeserver, token, "PUT", `/rooms/${encodeURIComponent(roomId)}/send/m.room.message/${txnId}`, body);
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
rl.registerAction("message.list", {
|
|
127
|
+
description: "Get messages from a room (newest first)",
|
|
128
|
+
inputSchema: {
|
|
129
|
+
roomId: { type: "string", required: true },
|
|
130
|
+
limit: { type: "number", required: false, description: "Max messages to return" },
|
|
131
|
+
filter: { type: "string", required: false, description: "JSON filter string" },
|
|
132
|
+
},
|
|
133
|
+
async execute(input, ctx) {
|
|
134
|
+
const { roomId, limit, filter } = (input ?? {});
|
|
135
|
+
const { homeserver, token } = conn(ctx);
|
|
136
|
+
if (limit) {
|
|
137
|
+
const qs = { dir: "b", limit };
|
|
138
|
+
if (filter)
|
|
139
|
+
qs.filter = filter;
|
|
140
|
+
const data = (await apiRequest(homeserver, token, "GET", `/rooms/${encodeURIComponent(roomId)}/messages`, undefined, qs));
|
|
141
|
+
return data.chunk;
|
|
142
|
+
}
|
|
143
|
+
// Paginate all
|
|
144
|
+
const all = [];
|
|
145
|
+
let from;
|
|
146
|
+
let chunk;
|
|
147
|
+
do {
|
|
148
|
+
const qs = { dir: "b" };
|
|
149
|
+
if (from)
|
|
150
|
+
qs.from = from;
|
|
151
|
+
if (filter)
|
|
152
|
+
qs.filter = filter;
|
|
153
|
+
const data = (await apiRequest(homeserver, token, "GET", `/rooms/${encodeURIComponent(roomId)}/messages`, undefined, qs));
|
|
154
|
+
chunk = data.chunk;
|
|
155
|
+
all.push(...chunk);
|
|
156
|
+
from = data.end;
|
|
157
|
+
} while (chunk.length > 0);
|
|
158
|
+
return all;
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
// ── Event ───────────────────────────────────────────
|
|
162
|
+
rl.registerAction("event.get", {
|
|
163
|
+
description: "Get a single event from a room",
|
|
164
|
+
inputSchema: {
|
|
165
|
+
roomId: { type: "string", required: true },
|
|
166
|
+
eventId: { type: "string", required: true, description: "Event ID ($xxx)" },
|
|
167
|
+
},
|
|
168
|
+
async execute(input, ctx) {
|
|
169
|
+
const { roomId, eventId } = input;
|
|
170
|
+
const { homeserver, token } = conn(ctx);
|
|
171
|
+
return apiRequest(homeserver, token, "GET", `/rooms/${encodeURIComponent(roomId)}/event/${encodeURIComponent(eventId)}`);
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
// ── Room Member ─────────────────────────────────────
|
|
175
|
+
rl.registerAction("roomMember.list", {
|
|
176
|
+
description: "List members of a room",
|
|
177
|
+
inputSchema: {
|
|
178
|
+
roomId: { type: "string", required: true },
|
|
179
|
+
membership: { type: "string", required: false, description: "Filter: join, invite, leave, ban, knock" },
|
|
180
|
+
notMembership: { type: "string", required: false, description: "Exclude membership type" },
|
|
181
|
+
},
|
|
182
|
+
async execute(input, ctx) {
|
|
183
|
+
const { roomId, membership, notMembership } = (input ?? {});
|
|
184
|
+
const { homeserver, token } = conn(ctx);
|
|
185
|
+
const qs = {};
|
|
186
|
+
if (membership)
|
|
187
|
+
qs.membership = membership;
|
|
188
|
+
if (notMembership)
|
|
189
|
+
qs.not_membership = notMembership;
|
|
190
|
+
const data = (await apiRequest(homeserver, token, "GET", `/rooms/${encodeURIComponent(roomId)}/members`, undefined, qs));
|
|
191
|
+
return data.chunk;
|
|
192
|
+
},
|
|
193
|
+
});
|
|
194
|
+
}
|