Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions docs/agents.html
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,12 @@ <h2>Built-in Tools</h2>
<td>Search the web (requires API key)</td>
</tr>
<tr>
<td><span class="inline-code">run_workflow</span></td>
<td>Execute another Weavr workflow</td>
<td><span class="inline-code">web_fetch</span></td>
<td>Fetch and extract content from a URL</td>
</tr>
<tr>
<td><span class="inline-code">shell_exec</span></td>
<td>Execute local shell commands (use with caution)</td>
</tr>
</tbody>
</table>
Expand Down
96 changes: 89 additions & 7 deletions docs/integrations.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ <h3>Integrations</h3>
<a href="#linear">Linear</a>
<a href="#http">HTTP / Webhooks</a>
<a href="#email">Email</a>
<a href="#calendar">Calendar</a>
<a href="#cron">Cron Schedules</a>
<a href="#mcp">MCP Servers</a>
</aside>
Expand Down Expand Up @@ -350,10 +351,10 @@ <h3>HTTP Request Action</h3>

<div class="section" id="email">
<h2>Email</h2>
<p>Send emails via SMTP.</p>
<p>Send emails via Resend API or SMTP, and receive inbound email webhooks.</p>

<h3>Setup</h3>
<p>Configure SMTP in <span class="inline-code">~/.weavr/config.yaml</span>:</p>
<p>Configure SMTP in <span class="inline-code">~/.weavr/config.yaml</span> or set environment variables:</p>
<div class="code-block">
<div class="code-header">
<div class="code-dot red"></div>
Expand All @@ -364,10 +365,18 @@ <h3>Setup</h3>
<span class="keyword">smtp:</span>
<span class="keyword">host:</span> <span class="string">smtp.example.com</span>
<span class="keyword">port:</span> <span class="number">587</span>
<span class="keyword">secure:</span> <span class="keyword">true</span>
<span class="keyword">auth:</span>
<span class="keyword">user:</span> <span class="string">your-email@example.com</span>
<span class="keyword">pass:</span> <span class="string">your-password</span></code></pre>
<span class="keyword">secure:</span> <span class="keyword">false</span>
<span class="keyword">user:</span> <span class="string">your-email@example.com</span>
<span class="keyword">pass:</span> <span class="string">your-password</span>
<span class="keyword">authMethod:</span> <span class="string">login</span></code></pre>
</div>

<div class="callout">
<strong>Environment variables:</strong>
<span class="inline-code">SMTP_HOST</span>, <span class="inline-code">SMTP_PORT</span>, <span class="inline-code">SMTP_SECURE</span>,
<span class="inline-code">SMTP_USER</span>, <span class="inline-code">SMTP_PASS</span>, <span class="inline-code">SMTP_AUTH_METHOD</span>,
<span class="inline-code">EMAIL_API_KEY</span> or <span class="inline-code">RESEND_API_KEY</span>,
<span class="inline-code">EMAIL_FROM</span>
</div>

<h3>Send Email</h3>
Expand All @@ -382,7 +391,80 @@ <h3>Send Email</h3>
<span class="keyword">with:</span>
<span class="keyword">to:</span> <span class="string">recipient@example.com</span>
<span class="keyword">subject:</span> <span class="string">"Workflow Complete"</span>
<span class="keyword">body:</span> <span class="string">"Your workflow finished successfully."</span></code></pre>
<span class="keyword">text:</span> <span class="string">"Your workflow finished successfully."</span>
<span class="keyword">provider:</span> <span class="string">smtp</span> <span class="comment"># auto | smtp | api</span></code></pre>
</div>

<h3>Inbound Email Webhook</h3>
<p>Configure your email provider to POST inbound email payloads to <span class="inline-code">/webhook/email</span> (or a custom path).</p>
<div class="code-block">
<div class="code-header">
<div class="code-dot red"></div>
<div class="code-dot yellow"></div>
<div class="code-dot green"></div>
</div>
<pre><code><span class="keyword">trigger:</span>
<span class="keyword">type:</span> <span class="string">email.inbound</span>
<span class="keyword">with:</span>
<span class="keyword">path:</span> <span class="string">email</span>
<span class="keyword">provider:</span> <span class="string">generic</span></code></pre>
</div>
</div>

<div class="section" id="calendar">
<h2>Calendar</h2>
<p>Integrate CalDAV calendars (Nextcloud, iCloud, Fastmail, and more).</p>

<h3>List Events</h3>
<div class="code-block">
<div class="code-header">
<div class="code-dot red"></div>
<div class="code-dot yellow"></div>
<div class="code-dot green"></div>
</div>
<pre><code>- <span class="keyword">id:</span> <span class="string">list-events</span>
<span class="keyword">action:</span> <span class="string">calendar.list_events</span>
<span class="keyword">with:</span>
<span class="keyword">calendarUrl:</span> <span class="string">"https://cal.example.com/dav/calendars/user/default/"</span>
<span class="keyword">username:</span> <span class="string">"user@example.com"</span>
<span class="keyword">password:</span> <span class="string">"app-password"</span>
<span class="keyword">from:</span> <span class="string">"2026-02-07T00:00:00Z"</span>
<span class="keyword">to:</span> <span class="string">"2026-02-14T00:00:00Z"</span></code></pre>
</div>

<h3>Create Event</h3>
<div class="code-block">
<div class="code-header">
<div class="code-dot red"></div>
<div class="code-dot yellow"></div>
<div class="code-dot green"></div>
</div>
<pre><code>- <span class="keyword">id:</span> <span class="string">create-event</span>
<span class="keyword">action:</span> <span class="string">calendar.create_event</span>
<span class="keyword">with:</span>
<span class="keyword">calendarUrl:</span> <span class="string">"https://cal.example.com/dav/calendars/user/default/"</span>
<span class="keyword">username:</span> <span class="string">"user@example.com"</span>
<span class="keyword">password:</span> <span class="string">"app-password"</span>
<span class="keyword">summary:</span> <span class="string">"Weekly Sync"</span>
<span class="keyword">start:</span> <span class="string">"2026-02-10T15:00:00Z"</span>
<span class="keyword">end:</span> <span class="string">"2026-02-10T15:30:00Z"</span></code></pre>
</div>

<h3>Upcoming Event Trigger</h3>
<div class="code-block">
<div class="code-header">
<div class="code-dot red"></div>
<div class="code-dot yellow"></div>
<div class="code-dot green"></div>
</div>
<pre><code><span class="keyword">trigger:</span>
<span class="keyword">type:</span> <span class="string">calendar.event_upcoming</span>
<span class="keyword">with:</span>
<span class="keyword">calendarUrl:</span> <span class="string">"https://cal.example.com/dav/calendars/user/default/"</span>
<span class="keyword">username:</span> <span class="string">"user@example.com"</span>
<span class="keyword">password:</span> <span class="string">"app-password"</span>
<span class="keyword">windowMinutes:</span> <span class="number">60</span>
<span class="keyword">pollIntervalSeconds:</span> <span class="number">60</span></code></pre>
</div>
</div>

Expand Down
22 changes: 17 additions & 5 deletions src/engine/scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { parse as parseYaml } from 'yaml';
import { randomUUID } from 'node:crypto';
import type { Workflow, WorkflowRun, WeavrConfig } from '../types/index.js';
import { parser } from './parser.js';

const WEBHOOK_TRIGGER_TYPES = new Set(['http.webhook', 'email.inbound']);
import { WorkflowExecutor } from './executor.js';
import type { PluginRegistry } from '../plugins/sdk/registry.js';
import { TriggerManager } from './trigger-manager.js';
Expand Down Expand Up @@ -280,20 +282,30 @@ export class TriggerScheduler {

for (const scheduled of this.scheduledWorkflows.values()) {
if (scheduled.status !== 'active') continue;
if (scheduled.triggerType !== 'http.webhook') continue;
if (!WEBHOOK_TRIGGER_TYPES.has(scheduled.triggerType)) continue;

const webhookPath = scheduled.triggerConfig.path as string;
const defaultPath = scheduled.triggerType === 'email.inbound' ? 'email' : undefined;
const webhookPath = (scheduled.triggerConfig.path as string | undefined) ?? defaultPath;
if (!webhookPath) continue;
if (webhookPath === path || webhookPath === `/${path}` || `/${webhookPath}` === path) {
try {
const runId = randomUUID();
triggered.push(scheduled.name);
runIds.push(runId);

this.events.onWorkflowTriggered?.(scheduled.name, runId);
const triggerPayload = scheduled.triggerType === 'email.inbound'
? {
type: 'email',
path,
provider: scheduled.triggerConfig.provider as string | undefined,
data,
}
: { type: 'webhook', path, data };
this.enqueueRun(
scheduled.name,
'http.webhook',
{ type: 'webhook', path, data },
scheduled.triggerType,
triggerPayload,
scheduled.workflowContent,
runId
);
Expand Down Expand Up @@ -459,7 +471,7 @@ export class TriggerScheduler {
console.error(`[scheduler] Invalid cron schedule for ${name}:`, err);
}
}
} else if (triggerType !== 'http.webhook') {
} else if (!WEBHOOK_TRIGGER_TYPES.has(triggerType)) {
const success = await this.triggerManager.setupTrigger(name, triggerType, triggerConfig, yamlContent, id);
if (success) {
console.log(`[scheduler] Custom trigger set up: ${name} (${triggerType})`);
Expand Down
60 changes: 60 additions & 0 deletions src/gateway/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,22 @@ export function createGatewayServer(config: WeavrConfig): GatewayServer {
apiKey: config.webSearch.apiKey ? '••••••••' : undefined,
hasApiKey: Boolean(config.webSearch.apiKey),
} : undefined,
email: config.email ? {
smtp: config.email.smtp ? {
...config.email.smtp,
pass: config.email.smtp.pass ? '••••••••' : undefined,
hasPass: Boolean(config.email.smtp.pass),
} : undefined,
} : undefined,
calendar: config.calendar ? {
caldav: config.calendar.caldav ? {
...config.calendar.caldav,
password: config.calendar.caldav.password ? '••••••••' : undefined,
bearerToken: config.calendar.caldav.bearerToken ? '••••••••' : undefined,
hasPassword: Boolean(config.calendar.caldav.password),
hasBearerToken: Boolean(config.calendar.caldav.bearerToken),
} : undefined,
} : undefined,
// Messaging: hide tokens but indicate if configured
messaging: config.messaging ? {
telegram: config.messaging.telegram ? {
Expand Down Expand Up @@ -893,6 +909,50 @@ export function createGatewayServer(config: WeavrConfig): GatewayServer {
}
}

// Handle email config - preserve SMTP password if masked value is sent
if (newConfig.email) {
mergedConfig.email = {
...existingConfig.email,
...newConfig.email,
};
if (newConfig.email.smtp) {
mergedConfig.email.smtp = {
...existingConfig.email?.smtp,
...newConfig.email.smtp,
};
if (newConfig.email.smtp.pass && newConfig.email.smtp.pass !== '••••••••') {
mergedConfig.email.smtp.pass = newConfig.email.smtp.pass;
} else if (existingConfig.email?.smtp?.pass) {
mergedConfig.email.smtp.pass = existingConfig.email.smtp.pass;
}
}
}

// Handle calendar config - preserve secrets if masked values are sent
if (newConfig.calendar) {
mergedConfig.calendar = {
...existingConfig.calendar,
...newConfig.calendar,
};
if (newConfig.calendar.caldav) {
mergedConfig.calendar.caldav = {
...existingConfig.calendar?.caldav,
...newConfig.calendar.caldav,
};
if (newConfig.calendar.caldav.password && newConfig.calendar.caldav.password !== '••••••••') {
mergedConfig.calendar.caldav.password = newConfig.calendar.caldav.password;
} else if (existingConfig.calendar?.caldav?.password) {
mergedConfig.calendar.caldav.password = existingConfig.calendar.caldav.password;
}

if (newConfig.calendar.caldav.bearerToken && newConfig.calendar.caldav.bearerToken !== '••••••••') {
mergedConfig.calendar.caldav.bearerToken = newConfig.calendar.caldav.bearerToken;
} else if (existingConfig.calendar?.caldav?.bearerToken) {
mergedConfig.calendar.caldav.bearerToken = existingConfig.calendar.caldav.bearerToken;
}
}
}

// Ensure directories exist
await mkdir(weavrDir, { recursive: true });
await mkdir(join(weavrDir, 'workflows'), { recursive: true });
Expand Down
18 changes: 18 additions & 0 deletions src/mcp/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,24 @@ export interface WeavrConfig {
scheduler?: {
dbPath?: string;
};
email?: {
smtp?: {
host: string;
port?: number;
secure?: boolean;
user?: string;
pass?: string;
authMethod?: 'login' | 'plain';
};
};
calendar?: {
caldav?: {
calendarUrl: string;
username?: string;
password?: string;
bearerToken?: string;
};
};
mcp?: {
servers?: Record<string, MCPServerConfig>;
};
Expand Down
Loading