wolli 0.0.3 → 0.0.4
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/README.md +23 -24
- package/built-in/plugins/discord/discord-chat.ts +47 -84
- package/built-in/plugins/discord/index.ts +139 -97
- package/built-in/plugins/discord/package.json +2 -2
- package/built-in/plugins/scheduler/cron.ts +131 -0
- package/built-in/plugins/scheduler/index.ts +147 -151
- package/built-in/plugins/scheduler/package.json +3 -2
- package/built-in/plugins/scheduler/scheduler-due.ts +22 -0
- package/built-in/plugins/telegram/README.md +3 -3
- package/built-in/plugins/telegram/index.ts +177 -139
- package/built-in/plugins/telegram/package.json +2 -2
- package/built-in/plugins/telegram/telegram-chat.ts +79 -155
- package/dist/cli.js +5696 -5841
- package/docs/hooks.md +103 -0
- package/docs/index.md +10 -8
- package/docs/integrations.md +78 -663
- package/docs/introduction.md +95 -0
- package/docs/plugins.md +43 -36
- package/docs/providers.md +63 -0
- package/docs/sdk.md +42 -47
- package/docs/tools.md +81 -0
- package/docs/workflows.md +170 -0
- package/package.json +1 -1
- package/built-in/plugins/scheduler/scheduler-chat.ts +0 -164
- package/docs/extensions.md +0 -2331
package/docs/hooks.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# Hooks
|
|
2
|
+
|
|
3
|
+
Intercept engine events and decide what happens next from `hooks/`.
|
|
4
|
+
|
|
5
|
+
A hook is the one place agent-home code alters engine behavior. Where a [workflow](./workflows.md) observes a lifecycle event and reacts alongside the turn, a hook sits in the turn's path and decides: block a tool call, rewrite input, replace the messages headed to the model. Each hook is one file under `~/.wolli/agents/<name>/hooks/`; the filename is the name, the default export the definition. A hook runs inline in the turn that fires it, so it stays fast and does no durable work.
|
|
6
|
+
|
|
7
|
+
The simplest hook guards a tool before it runs:
|
|
8
|
+
|
|
9
|
+
`~/.wolli/agents/assistant/hooks/guard-bash.ts`
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { defineHook, isToolCallEventType } from "wolli";
|
|
13
|
+
|
|
14
|
+
export default defineHook({
|
|
15
|
+
before: "tool_call",
|
|
16
|
+
run(event) {
|
|
17
|
+
if (isToolCallEventType("bash", event) && event.input.command.includes("rm -rf")) {
|
|
18
|
+
return { block: true, reason: "destructive command blocked" };
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
`before:` names the event. The handler receives that event and a `ctx`, and returns a decision or nothing. Returning nothing lets the event through untouched, so a hook only acts on the cases it cares about. Add the file and wolli discovers it; run `/reload` to apply a change without restarting the daemon.
|
|
25
|
+
|
|
26
|
+
## Events
|
|
27
|
+
|
|
28
|
+
A hook binds exactly one of eight `before:` events. Each one hands the handler the value about to take effect and takes a typed decision back.
|
|
29
|
+
|
|
30
|
+
| `before:` | The handler sees | Returning |
|
|
31
|
+
| --- | --- | --- |
|
|
32
|
+
| `tool_call` | the tool about to run (`toolName`, `input`) | mutate `event.input` in place to patch arguments; `{ block, reason }` to stop the call |
|
|
33
|
+
| `tool_result` | a finished tool's `content`, `details`, `isError` | any of those keys to rewrite the result |
|
|
34
|
+
| `input` | user input before the turn (`text`, `images`, `source`) | `{ action: "transform", text }` to rewrite it, `{ action: "handled" }` to consume it |
|
|
35
|
+
| `context` | the `messages` array bound for the model | `{ messages }` to replace it |
|
|
36
|
+
| `provider_request` | the raw provider `payload` | a new payload to send instead |
|
|
37
|
+
| `agent_start` | the assembled `prompt` and `systemPrompt` | `{ message }` to inject a message, `{ systemPrompt }` to replace the prompt for this turn |
|
|
38
|
+
| `compact` | a pending compaction (`preparation`, `branchEntries`) | `{ cancel: true }` to stop it |
|
|
39
|
+
| `message_end` | a finalized `message` | `{ message }` to replace it, keeping the same role |
|
|
40
|
+
|
|
41
|
+
These are the interception counterpart to a workflow's observe-only lifecycle events. A hook cannot bind `on:`, is not callable, and has no input or output schema.
|
|
42
|
+
|
|
43
|
+
## Chains and short-circuits
|
|
44
|
+
|
|
45
|
+
Hooks bound to the same event run as a chain in load order: the agent's own `hooks/` files by filename, then any from installed plugins. Each hook sees the event as earlier hooks left it, so patches accumulate down the chain. An `input` hook that rewrites text hands the next hook the rewritten text:
|
|
46
|
+
|
|
47
|
+
`~/.wolli/agents/assistant/hooks/redact-input.ts`
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
import { defineHook } from "wolli";
|
|
51
|
+
|
|
52
|
+
export default defineHook({
|
|
53
|
+
before: "input",
|
|
54
|
+
run(event) {
|
|
55
|
+
const redacted = event.text.replace(/sk-[a-z0-9]+/gi, "[redacted]");
|
|
56
|
+
if (redacted === event.text) return;
|
|
57
|
+
return { action: "transform", text: redacted };
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
A terminal decision short-circuits the rest of the chain: a `tool_call` `{ block }`, a `compact` `{ cancel }`, or an `input` `{ action: "handled" }` stops there and no later hook runs. `tool_call` is the exception that patches by mutation: change `event.input` in place and later hooks and the executor see the change. `agent_start` accumulates every injected message and chains `systemPrompt` replacements, so the last hook to set one wins. A `message_end` replacement must keep the original message role; a role change is rejected and the chain moves on.
|
|
63
|
+
|
|
64
|
+
## ctx
|
|
65
|
+
|
|
66
|
+
Every hook event belongs to the session that produced it, so `ctx.session` and `ctx.ui` are always present. `ctx.session` is that session's surface: `prompt`, `sendUserMessage`, `getTags`, `setTags`, and its `id`. `ctx.ui` is the four dialog primitives routed to the session's clients: `select`, `confirm`, `input`, `notify`. A hook can ask before it lets the engine proceed:
|
|
67
|
+
|
|
68
|
+
`~/.wolli/agents/assistant/hooks/confirm-compact.ts`
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
import { defineHook } from "wolli";
|
|
72
|
+
|
|
73
|
+
export default defineHook({
|
|
74
|
+
before: "compact",
|
|
75
|
+
async run(event, ctx) {
|
|
76
|
+
const ok = await ctx.ui.confirm("Compact now?", "Older messages will be summarized.");
|
|
77
|
+
if (!ok) return { cancel: true };
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Because the dialog rides the producing session's clients, the prompt reaches whoever is attached to that session. A hook on a headless session still runs; its `ctx.ui` calls resolve without a user in front of them.
|
|
83
|
+
|
|
84
|
+
## Failure
|
|
85
|
+
|
|
86
|
+
A hook that throws fails open: wolli reports the error and the chain continues with the event as the throwing hook left it. A broken hook cannot break the turn.
|
|
87
|
+
|
|
88
|
+
## Hooks vs workflows
|
|
89
|
+
|
|
90
|
+
Both react to engine events, but they answer different questions.
|
|
91
|
+
|
|
92
|
+
| Need | Use |
|
|
93
|
+
| --- | --- |
|
|
94
|
+
| Alter an event before it takes effect: block, rewrite, replace | a hook |
|
|
95
|
+
| React to an event, or route it into a session | a workflow |
|
|
96
|
+
|
|
97
|
+
Put the decision in a hook and the reaction in a workflow. A hook blocks a tool call in the live turn; a workflow watching `tool_execution_end` records that the call happened.
|
|
98
|
+
|
|
99
|
+
## What to read next
|
|
100
|
+
|
|
101
|
+
- [Workflows](./workflows.md): triggers, routing, and the run and step record.
|
|
102
|
+
- [Tools](./tools.md): the typed actions a `tool_call` hook guards.
|
|
103
|
+
- [Plugins](./plugins.md): package and install hooks alongside other resources.
|
package/docs/index.md
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Getting Started
|
|
2
2
|
|
|
3
|
-
Wolli is a persistent, purposeful agent that runs in your terminal. It stays small at the core while
|
|
3
|
+
Wolli is a persistent, purposeful agent that runs in your terminal. It stays small at the core while growing through integrations, workflows, tools, providers, skills, prompt templates, themes, and plugins. Start with the [Introduction](introduction.md) for how those fit together.
|
|
4
4
|
|
|
5
5
|
## Quick start
|
|
6
6
|
|
|
7
7
|
Install Wolli with npm:
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
npm install -g
|
|
10
|
+
npm install -g wolli
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Then
|
|
13
|
+
Then create a new agent and start its first conversation:
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
16
|
wolli new <name>
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
The agent opens by asking what it is for. Answer conversationally; it interviews you, distills its purpose, and when you both agree it understands its job,
|
|
19
|
+
The agent opens by asking what it is for. Answer conversationally; it interviews you, distills its purpose, and when you both agree it understands its job, it writes its own SOUL.md. Reconnect any time with `wolli <name>`.
|
|
20
20
|
|
|
21
21
|
Authenticate with `/login` for subscription/OAuth providers (Claude and others), or set an API key such as `ANTHROPIC_API_KEY` before starting wolli. Credentials persist to the shared `~/.wolli/agent/auth.json` and are reused by every agent.
|
|
22
22
|
|
|
@@ -24,12 +24,14 @@ For the full first-run flow, CLI reference, sessions, and the agent-home layout,
|
|
|
24
24
|
|
|
25
25
|
## Customization
|
|
26
26
|
|
|
27
|
-
- [
|
|
27
|
+
- [Integrations](integrations.md) - transports that connect external services and message channels to the agent.
|
|
28
|
+
- [Workflows](workflows.md) - route events into sessions and automate the agent.
|
|
29
|
+
- [Tools](tools.md) - typed actions the model calls during a turn.
|
|
30
|
+
- [Providers](providers.md) - model providers beyond the built-in catalog.
|
|
28
31
|
- [Skills](skills.md) - Agent Skills for reusable on-demand capabilities.
|
|
29
32
|
- [Prompt templates](prompt-templates.md) - reusable prompts that expand from slash commands.
|
|
30
33
|
- [Themes](themes.md) - built-in and custom terminal themes.
|
|
31
|
-
- [
|
|
32
|
-
- [Plugins](plugins.md) - bundle, publish, and install extensions, integrations, skills, prompts, and themes.
|
|
34
|
+
- [Plugins](plugins.md) - bundle, publish, and install any mix of those resources.
|
|
33
35
|
|
|
34
36
|
## Programmatic usage
|
|
35
37
|
|