v0.0.61 - feat: add webhook cron and chain trigger types

This commit is contained in:
Your Name
2026-03-09 20:58:52 -04:00
parent 421e1abb15
commit 6c78f6e79f
12 changed files with 1807 additions and 34 deletions

View File

@@ -190,6 +190,45 @@ Returns the context broken into labeled, individually-sized parts. Useful for un
---
### POST /api/trigger/:d_tag
Fires a webhook-triggered skill by `d_tag`.
**Path params:**
| Param | Required | Description |
|---|---|---|
| `d_tag` | yes | Skill `d` tag of a skill configured with `trigger=webhook` |
**Request body:**
Optional JSON payload; if present it is passed into the synthetic trigger event as `payload`.
```json
{
"source": "external-cron",
"note": "run maintenance sweep"
}
```
**Response:**
```json
{
"success": true,
"d_tag": "maintenance-sweep",
"fired": true
}
```
**Notes:**
- Returns `404` if no skill exists for `d_tag` or no active trigger is registered.
- Returns `400` if the matched skill is not a `webhook` trigger or is disabled.
- Trigger execution uses the same trigger cooldown policy as other trigger types.
---
### POST /api/prompt/run-simple
Submit a system prompt and user message for a simple LLM call with no tools. Useful for quick prompt iteration.

View File

@@ -204,14 +204,14 @@ sequenceDiagram
## Triggered Skills
A triggered skill has a Nostr subscription filter attached. When matching events arrive, the skill executes automatically.
A triggered skill has a trigger source attached. Didactyl supports `nostr-subscription`, `webhook`, `cron`, and `chain` trigger types.
### Trigger Tags
| Tag | Required | Description |
|---|---|---|
| `trigger` | Yes | Trigger type: `nostr-subscription` |
| `filter` | Yes | JSON-encoded Nostr subscription filter |
| `trigger` | Yes | Trigger type: `nostr-subscription`, `webhook`, `cron`, or `chain` |
| `filter` | Yes | Type-specific filter (Nostr JSON filter, webhook placeholder payload, cron expression, or source skill `d` tag) |
| `action` | No | `template` or `llm` (default: `llm`) |
| `enabled` | No | Whether active (default: `true`) |
@@ -251,6 +251,44 @@ The skill content defines the execution context. The triggering event is availab
}
```
### Trigger Types
#### `nostr-subscription`
`filter` is a JSON-encoded Nostr subscription filter.
```json
["trigger", "nostr-subscription"],
["filter", "{\"#p\":[\"<admin_pubkey>\"],\"kinds\":[1]}"]
```
#### `webhook`
`filter` is required for schema compatibility and can be a simple placeholder like `{}`; webhook firing happens via HTTP.
```json
["trigger", "webhook"],
["filter", "{}"]
```
#### `cron`
`filter` is a standard 5-field cron expression: `minute hour day-of-month month day-of-week`.
```json
["trigger", "cron"],
["filter", "0 * * * *"]
```
#### `chain`
`filter` is the source skill `d` tag to chain from.
```json
["trigger", "chain"],
["filter", "source-skill-d-tag"]
```
### Trigger Lifecycle
```mermaid
@@ -264,14 +302,23 @@ flowchart TD
subgraph Activation
STARTUP[Didactyl starts up] --> LOAD_SKILLS[Load adopted skills from kind 10123]
LOAD_SKILLS --> FIND_TRIGGERS[Find skills with trigger tags]
FIND_TRIGGERS --> SUBSCRIBE[Create Nostr subscriptions for each filter]
FIND_TRIGGERS --> REGISTER[Register trigger by type]
REGISTER --> NOSTR_SUB[nostr-subscription: create Nostr subscriptions]
REGISTER --> CRON_REG[cron: keep expression for poll loop]
REGISTER --> WEBHOOK_REG[webhook: route via /api/trigger/:d_tag]
REGISTER --> CHAIN_REG[chain: wait for source skill completion]
end
subgraph Execution
EVENT_IN[Matching event arrives] --> LOOKUP[Find associated skill]
EVENT_IN[Matching Nostr event] --> LOOKUP[Find associated skill]
WEBHOOK_IN[POST /api/trigger/:d_tag] --> LOOKUP
CRON_TICK[cron poll match] --> LOOKUP
LOOKUP --> CHECK_TYPE{Action type?}
CHECK_TYPE -->|template| INTERPOLATE[Interpolate + execute prefix]
CHECK_TYPE -->|llm| RESOLVE[Resolve LLM + assemble context + run]
RESOLVE --> CHAIN_CHECK[Check chain triggers]
INTERPOLATE --> CHAIN_CHECK
CHAIN_CHECK --> CHAIN_FIRE[Fire matching chain triggers]
end
PUBLISHED --> LOAD_SKILLS
@@ -351,9 +398,6 @@ A spelling checker runs with no soul — purely functional, minimal context, che
| Extension | Description |
|---|---|
| `cron` triggers | Time-based triggers |
| `webhook` triggers | HTTP webhook triggers |
| `chain` triggers | Output of one skill triggers another |
| Skill composition | Pipeline multiple skills |
| Agent-to-agent sharing | Discover and adopt skills across agents |
| Trigger marketplace | Popular triggers rise via adoption count |