wolli 0.0.1 → 0.0.3
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/LICENSE +182 -0
- package/README.md +136 -2
- package/built-in/plugins/discord/README.md +156 -0
- package/built-in/plugins/discord/discord-chat.ts +87 -0
- package/built-in/plugins/discord/index.ts +192 -0
- package/built-in/plugins/discord/package.json +16 -0
- package/built-in/plugins/scheduler/index.ts +244 -0
- package/built-in/plugins/scheduler/package.json +16 -0
- package/built-in/plugins/scheduler/scheduler-chat.ts +164 -0
- package/built-in/plugins/telegram/README.md +153 -0
- package/built-in/plugins/telegram/index.ts +311 -0
- package/built-in/plugins/telegram/package.json +17 -0
- package/built-in/plugins/telegram/telegram-chat.ts +169 -0
- package/built-in/skills/.gitkeep +0 -0
- package/dist/cli.js +325758 -0
- package/dist/photon_rs_bg.wasm +0 -0
- package/dist/theme/dark.json +86 -0
- package/dist/theme/light.json +85 -0
- package/dist/theme/theme-schema.json +335 -0
- package/dist/theme/theme.ts +1237 -0
- package/docs/extensions.md +2331 -0
- package/docs/index.md +36 -0
- package/docs/integrations.md +715 -0
- package/docs/plugins.md +299 -0
- package/docs/prompt-templates.md +92 -0
- package/docs/sdk.md +760 -0
- package/docs/skills.md +220 -0
- package/docs/themes.md +274 -0
- package/native/darwin/prebuilds/darwin-arm64/darwin-modifiers.node +0 -0
- package/native/darwin/prebuilds/darwin-x64/darwin-modifiers.node +0 -0
- package/native/win32/prebuilds/win32-arm64/win32-console-mode.node +0 -0
- package/native/win32/prebuilds/win32-x64/win32-console-mode.node +0 -0
- package/package.json +40 -9
- package/index.js +0 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction, and
|
|
10
|
+
distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by the
|
|
13
|
+
copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities
|
|
16
|
+
that control, are controlled by, or are under common control with that entity.
|
|
17
|
+
For the purposes of this definition, "control" means (i) the power, direct or
|
|
18
|
+
indirect, to cause the direction or management of such entity, whether by
|
|
19
|
+
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
20
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
21
|
+
|
|
22
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
|
23
|
+
permissions granted by this License.
|
|
24
|
+
|
|
25
|
+
"Source" form shall mean the preferred form for making modifications, including
|
|
26
|
+
but not limited to software source code, documentation source, and configuration
|
|
27
|
+
files.
|
|
28
|
+
|
|
29
|
+
"Object" form shall mean any form resulting from mechanical transformation or
|
|
30
|
+
translation of a Source form, including but not limited to compiled object code,
|
|
31
|
+
generated documentation, and conversions to other media types.
|
|
32
|
+
|
|
33
|
+
"Work" shall mean the work of authorship, whether in Source or Object form,
|
|
34
|
+
made available under the License, as indicated by a copyright notice that is
|
|
35
|
+
included in or attached to the work (an example is provided in the Appendix
|
|
36
|
+
below).
|
|
37
|
+
|
|
38
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that
|
|
39
|
+
is based on (or derived from) the Work and for which the editorial revisions,
|
|
40
|
+
annotations, elaborations, or other modifications represent, as a whole, an
|
|
41
|
+
original work of authorship. For the purposes of this License, Derivative Works
|
|
42
|
+
shall not include works that remain separable from, or merely link (or bind by
|
|
43
|
+
name) to the interfaces of, the Work and Derivative Works thereof.
|
|
44
|
+
|
|
45
|
+
"Contribution" shall mean any work of authorship, including the original
|
|
46
|
+
version of the Work and any modifications or additions to that Work or
|
|
47
|
+
Derivative Works thereof, that is intentionally submitted to Licensor for
|
|
48
|
+
inclusion in the Work by the copyright owner or by an individual or Legal Entity
|
|
49
|
+
authorized to submit on behalf of the copyright owner. For the purposes of this
|
|
50
|
+
definition, "submitted" means any form of electronic, verbal, or written
|
|
51
|
+
communication sent to the Licensor or its representatives, including but not
|
|
52
|
+
limited to communication on electronic mailing lists, source code control
|
|
53
|
+
systems, and issue tracking systems that are managed by, or on behalf of, the
|
|
54
|
+
Licensor for the purpose of discussing and improving the Work, but excluding
|
|
55
|
+
communication that is conspicuously marked or otherwise designated in writing by
|
|
56
|
+
the copyright owner as "Not a Contribution."
|
|
57
|
+
|
|
58
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
|
|
59
|
+
of whom a Contribution has been received by Licensor and subsequently
|
|
60
|
+
incorporated within the Work.
|
|
61
|
+
|
|
62
|
+
2. Grant of Copyright License. Subject to the terms and conditions of this
|
|
63
|
+
License, each Contributor hereby grants to You a perpetual, worldwide,
|
|
64
|
+
non-exclusive, no-charge, royalty-free, irrevocable copyright license to
|
|
65
|
+
reproduce, prepare Derivative Works of, publicly display, publicly perform,
|
|
66
|
+
sublicense, and distribute the Work and such Derivative Works in Source or
|
|
67
|
+
Object form.
|
|
68
|
+
|
|
69
|
+
3. Grant of Patent License. Subject to the terms and conditions of this License,
|
|
70
|
+
each Contributor hereby grants to You a perpetual, worldwide, non-exclusive,
|
|
71
|
+
no-charge, royalty-free, irrevocable (except as stated in this section) patent
|
|
72
|
+
license to make, have made, use, offer to sell, sell, import, and otherwise
|
|
73
|
+
transfer the Work, where such license applies only to those patent claims
|
|
74
|
+
licensable by such Contributor that are necessarily infringed by their
|
|
75
|
+
Contribution(s) alone or by combination of their Contribution(s) with the Work
|
|
76
|
+
to which such Contribution(s) was submitted. If You institute patent litigation
|
|
77
|
+
against any entity (including a cross-claim or counterclaim in a lawsuit)
|
|
78
|
+
alleging that the Work or a Contribution incorporated within the Work
|
|
79
|
+
constitutes direct or contributory patent infringement, then any patent licenses
|
|
80
|
+
granted to You under this License for that Work shall terminate as of the date
|
|
81
|
+
such litigation is filed.
|
|
82
|
+
|
|
83
|
+
4. Redistribution. You may reproduce and distribute copies of the Work or
|
|
84
|
+
Derivative Works thereof in any medium, with or without modifications, and in
|
|
85
|
+
Source or Object form, provided that You meet the following conditions:
|
|
86
|
+
|
|
87
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy of
|
|
88
|
+
this License; and
|
|
89
|
+
|
|
90
|
+
(b) You must cause any modified files to carry prominent notices stating that
|
|
91
|
+
You changed the files; and
|
|
92
|
+
|
|
93
|
+
(c) You must retain, in the Source form of any Derivative Works that You
|
|
94
|
+
distribute, all copyright, patent, trademark, and attribution notices from the
|
|
95
|
+
Source form of the Work, excluding those notices that do not pertain to any part
|
|
96
|
+
of the Derivative Works; and
|
|
97
|
+
|
|
98
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then
|
|
99
|
+
any Derivative Works that You distribute must include a readable copy of the
|
|
100
|
+
attribution notices contained within such NOTICE file, excluding those notices
|
|
101
|
+
that do not pertain to any part of the Derivative Works, in at least one of the
|
|
102
|
+
following places: within a NOTICE text file distributed as part of the Derivative
|
|
103
|
+
Works; within the Source form or documentation, if provided along with the
|
|
104
|
+
Derivative Works; or, within a display generated by the Derivative Works, if and
|
|
105
|
+
wherever such third-party notices normally appear. The contents of the NOTICE
|
|
106
|
+
file are for informational purposes only and do not modify the License. You may
|
|
107
|
+
add Your own attribution notices within Derivative Works that You distribute,
|
|
108
|
+
alongside or as an addendum to the NOTICE text from the Work, provided that such
|
|
109
|
+
additional attribution notices cannot be construed as modifying the License.
|
|
110
|
+
|
|
111
|
+
You may add Your own copyright statement to Your modifications and may provide
|
|
112
|
+
additional or different license terms and conditions for use, reproduction, or
|
|
113
|
+
distribution of Your modifications, or for any such Derivative Works as a whole,
|
|
114
|
+
provided Your use, reproduction, and distribution of the Work otherwise complies
|
|
115
|
+
with the conditions stated in this License.
|
|
116
|
+
|
|
117
|
+
5. Submission of Contributions. Unless You explicitly state otherwise, any
|
|
118
|
+
Contribution intentionally submitted for inclusion in the Work by You to the
|
|
119
|
+
Licensor shall be under the terms and conditions of this License, without any
|
|
120
|
+
additional terms or conditions. Notwithstanding the above, nothing herein shall
|
|
121
|
+
supersede or modify the terms of any separate license agreement you may have
|
|
122
|
+
executed with Licensor regarding such Contributions.
|
|
123
|
+
|
|
124
|
+
6. Trademarks. This License does not grant permission to use the trade names,
|
|
125
|
+
trademarks, service marks, or product names of the Licensor, except as required
|
|
126
|
+
for reasonable and customary use in describing the origin of the Work and
|
|
127
|
+
reproducing the content of the NOTICE file.
|
|
128
|
+
|
|
129
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
|
|
130
|
+
writing, Licensor provides the Work (and each Contributor provides its
|
|
131
|
+
Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
132
|
+
KIND, either express or implied, including, without limitation, any warranties or
|
|
133
|
+
conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
134
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
135
|
+
appropriateness of using or redistributing the Work and assume any risks
|
|
136
|
+
associated with Your exercise of permissions under this License.
|
|
137
|
+
|
|
138
|
+
8. Limitation of Liability. In no event and under no legal theory, whether in
|
|
139
|
+
tort (including negligence), contract, or otherwise, unless required by
|
|
140
|
+
applicable law (such as deliberate and grossly negligent acts) or agreed to in
|
|
141
|
+
writing, shall any Contributor be liable to You for damages, including any
|
|
142
|
+
direct, indirect, special, incidental, or consequential damages of any character
|
|
143
|
+
arising as a result of this License or out of the use or inability to use the
|
|
144
|
+
Work (including but not limited to damages for loss of goodwill, work stoppage,
|
|
145
|
+
computer failure or malfunction, or any and all other commercial damages or
|
|
146
|
+
losses), even if such Contributor has been advised of the possibility of such
|
|
147
|
+
damages.
|
|
148
|
+
|
|
149
|
+
9. Accepting Warranty or Additional Liability. While redistributing the Work or
|
|
150
|
+
Derivative Works thereof, You may choose to offer, and charge a fee for,
|
|
151
|
+
acceptance of support, warranty, indemnity, or other liability obligations
|
|
152
|
+
and/or rights consistent with this License. However, in accepting such
|
|
153
|
+
obligations, You may act only on Your own behalf and on Your sole
|
|
154
|
+
responsibility, not on behalf of any other Contributor, and only if You agree to
|
|
155
|
+
indemnify, defend, and hold each Contributor harmless for any liability incurred
|
|
156
|
+
by, or claims asserted against, such Contributor by reason of your accepting any
|
|
157
|
+
such warranty or additional liability.
|
|
158
|
+
|
|
159
|
+
END OF TERMS AND CONDITIONS
|
|
160
|
+
|
|
161
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
162
|
+
|
|
163
|
+
To apply the Apache License to your work, attach the following boilerplate
|
|
164
|
+
notice, with the fields enclosed by brackets "[]" replaced with your own
|
|
165
|
+
identifying information. (Don't include the brackets!) The text should be
|
|
166
|
+
enclosed in the appropriate comment syntax for the file format. We also
|
|
167
|
+
recommend that a file or class name and description of purpose be included on
|
|
168
|
+
the same "printed page" as the copyright notice for easier identification
|
|
169
|
+
within third-party archives.
|
|
170
|
+
|
|
171
|
+
Copyright [yyyy] [name of copyright owner]
|
|
172
|
+
|
|
173
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
174
|
+
this file except in compliance with the License. You may obtain a copy of the
|
|
175
|
+
License at
|
|
176
|
+
|
|
177
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
178
|
+
|
|
179
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
180
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
181
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
182
|
+
specific language governing permissions and limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,137 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# Wolli
|
|
4
|
+
|
|
5
|
+
**Create purposeful, self-extending AI agents.**
|
|
6
|
+
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
[](https://www.npmjs.com/package/wolli)
|
|
9
|
+
[](https://github.com/opsyhq/wolli/actions/workflows/ci.yml)
|
|
10
|
+
|
|
11
|
+
[Install](#install) · [How it works](#how-it-works) · [Roadmap](ROADMAP.md)
|
|
12
|
+
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
> **What is my purpose?**
|
|
18
|
+
|
|
19
|
+
Wolli lets you create purposeful agents. That purpose becomes the organizing
|
|
20
|
+
principle of an agent's life: it remembers across sessions, runs on a schedule,
|
|
21
|
+
acts on events, and extends itself to do its job better over time, writing its
|
|
22
|
+
own skills, integrations, and extensions as the work demands.
|
|
23
|
+
|
|
24
|
+
## Install
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
npm install -g wolli
|
|
28
|
+
wolli
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The first run sets up your provider and creates your first agent. A new agent
|
|
32
|
+
starts in a **forming** state: it interviews you to work out its purpose and
|
|
33
|
+
records what it learns, and does not act unattended until you deploy it. Agents and
|
|
34
|
+
state live under `~/.wolli`. `●` deployed and `○` forming.
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
Agents
|
|
38
|
+
|
|
39
|
+
→ ● inbox Triage my email each morning, draft replies to the routine ones, flag what needs me.
|
|
40
|
+
● scout Watch the repos and deps we ship; when a release or CVE needs action, open an issue and ping me.
|
|
41
|
+
● ledger Track project spend across providers, reconcile invoices weekly, warn me before a budget tips over.
|
|
42
|
+
○ sprout Still working out my purpose.
|
|
43
|
+
|
|
44
|
+
↑/↓ browse · enter chat · tab details · type to search commands · ctrl+c quit
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## How it works
|
|
48
|
+
|
|
49
|
+
- **Purpose-built.** You state the agent's purpose at birth. It decides what the
|
|
50
|
+
agent stores, when it speaks up, and what it does unattended.
|
|
51
|
+
- **Self-extending.** The agent builds itself out for its purpose. It curates its
|
|
52
|
+
own memory and authors and installs its own skills, tools, extensions and integrations; they
|
|
53
|
+
live in its home and load on reload. The agent grows more capable at its job
|
|
54
|
+
instead of staying a fixed tool.
|
|
55
|
+
- **Persistent.** Sessions are an append-only JSONL tree, the agent's lifetime
|
|
56
|
+
memory. Nothing is rewritten; context is reconstructed deterministically and the
|
|
57
|
+
latest leaf resumes by default.
|
|
58
|
+
- **Curated memory.** Three files are read once and frozen into the system prompt
|
|
59
|
+
per session, and the agent maintains them through a memory tool:
|
|
60
|
+
|
|
61
|
+
| File | Holds |
|
|
62
|
+
| --- | --- |
|
|
63
|
+
| `SOUL.md` | Identity, authored at deploy. |
|
|
64
|
+
| `MEMORY.md` | Durable notes the agent keeps. |
|
|
65
|
+
| `USER.md` | Facts about its human. |
|
|
66
|
+
|
|
67
|
+
- **Always on, locally.** A per-agent daemon supervised by launchd (macOS) or
|
|
68
|
+
systemd (Linux) runs the agent on schedules and events while your machine is on.
|
|
69
|
+
- **Sandboxed.** The agent runs in a sandbox by default: `srt` (Apple Seatbelt /
|
|
70
|
+
bubblewrap), or optional Docker. Reaching your real machine is an explicit,
|
|
71
|
+
approval-gated escalation.
|
|
72
|
+
- **Any model.** Multi-provider via OAuth `/login` (Anthropic, OpenAI, and others).
|
|
73
|
+
|
|
74
|
+
## Lifecycle
|
|
75
|
+
|
|
76
|
+
| State | What happens |
|
|
77
|
+
| --- | --- |
|
|
78
|
+
| **forming** | Interviews its human and records memory. Does not act unattended. |
|
|
79
|
+
| **deployed** | The agent has authored its purpose and `SOUL.md`, and you confirmed `/deploy`, the single human-held latch. It now runs on schedules and events. |
|
|
80
|
+
|
|
81
|
+
`wolli delete <name>` removes an agent and its state.
|
|
82
|
+
|
|
83
|
+
## Extending an agent
|
|
84
|
+
|
|
85
|
+
An agent's capabilities are plugins under its own home, so deleting the agent
|
|
86
|
+
removes them with it:
|
|
87
|
+
|
|
88
|
+
| Type | What it adds |
|
|
89
|
+
| --- | --- |
|
|
90
|
+
| **Integrations** | TypeScript modules: tools, commands, events, UI. |
|
|
91
|
+
| **Extensions** | TypeScript modules: tools, commands, events, UI. |
|
|
92
|
+
| **Skills** | The Agent Skills standard. |
|
|
93
|
+
| **Prompt templates** | `/name` slash commands. |
|
|
94
|
+
| **Themes** | TUI appearance. |
|
|
95
|
+
|
|
96
|
+
Two integrations ship bundled: **Telegram** (bidirectional chat) and a
|
|
97
|
+
**scheduler** (cron). Manage plugins with `wolli <agent> plugins ...`.
|
|
98
|
+
|
|
99
|
+
## CLI
|
|
100
|
+
|
|
101
|
+
| Command | Action |
|
|
102
|
+
| --- | --- |
|
|
103
|
+
| `wolli` | Set up on first run; otherwise pick an agent and open it |
|
|
104
|
+
| `wolli new <name>` | Create and birth a new agent |
|
|
105
|
+
| `wolli <agent>` | Open a specific agent interactively |
|
|
106
|
+
| `wolli <agent> "msg" --print` | One-shot, non-interactive reply |
|
|
107
|
+
| `wolli list` | List agents |
|
|
108
|
+
| `wolli restart <name>` | Restart an agent's daemon |
|
|
109
|
+
| `wolli delete <name>` | Remove an agent and its state |
|
|
110
|
+
| `wolli <agent> plugins ...` | Manage an agent's plugins |
|
|
111
|
+
|
|
112
|
+
## Documentation
|
|
113
|
+
|
|
114
|
+
Full documentation is in [`packages/wolli/docs`](packages/wolli/docs/index.md):
|
|
115
|
+
extensions, skills, prompt templates, themes, integrations, plugins, and the SDK.
|
|
116
|
+
|
|
117
|
+
## Roadmap
|
|
118
|
+
|
|
119
|
+
Cloud sync, hosted email identity, agent-to-agent messaging, durable runtimes, and
|
|
120
|
+
more inbound integrations are not built yet. Shipped versus planned is tracked in
|
|
121
|
+
[ROADMAP.md](ROADMAP.md).
|
|
122
|
+
|
|
123
|
+
## Contributing
|
|
124
|
+
|
|
125
|
+
Wolli is a pnpm + TypeScript monorepo (Node >= 22.19).
|
|
126
|
+
|
|
127
|
+
```sh
|
|
128
|
+
pnpm install
|
|
129
|
+
pnpm build
|
|
130
|
+
pnpm test
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
See [AGENTS.md](AGENTS.md) for development rules before opening a pull request.
|
|
134
|
+
|
|
135
|
+
## License
|
|
136
|
+
|
|
137
|
+
[Apache-2.0](LICENSE)
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# Discord
|
|
2
|
+
|
|
3
|
+
Connect a wolli agent to Discord. The bot runs over Discord's gateway WebSocket,
|
|
4
|
+
gives each channel and DM its own wolli session, and replies in place. Setup is a
|
|
5
|
+
few clicks in the Discord Developer Portal plus a single token prompt.
|
|
6
|
+
|
|
7
|
+
## How the bot behaves
|
|
8
|
+
|
|
9
|
+
Before setup, here's the part most people want to know: this bot answers
|
|
10
|
+
**everything it can read**. There is no `@mention` gate.
|
|
11
|
+
|
|
12
|
+
| Context | Behavior |
|
|
13
|
+
|---------|----------|
|
|
14
|
+
| **DMs** | Responds to every non-empty message. |
|
|
15
|
+
| **Server channels** | Responds to every non-empty message in any channel it can read. No `@mention` required — unlike some Discord agents, the bot replies to plain messages. Scope where it listens with `allowedChannelIds`. |
|
|
16
|
+
| **Other bots / itself** | Ignored. The bot skips its own messages and messages from any other bot, so it can't loop. |
|
|
17
|
+
| **Empty / media-only messages** | Skipped (there is no inbound media handling). |
|
|
18
|
+
|
|
19
|
+
While a turn runs, the bot shows Discord's **typing…** indicator in the channel and
|
|
20
|
+
keeps it alive until the reply lands. Replies are chunked at **2000 characters**
|
|
21
|
+
(Discord's per-message limit); Discord renders markdown natively, so formatting in
|
|
22
|
+
the agent's output comes through as-is.
|
|
23
|
+
|
|
24
|
+
If a new message arrives while the agent is mid-reply, it is **queued as a
|
|
25
|
+
follow-up** and answered after the current turn finishes — it does not interrupt the
|
|
26
|
+
in-flight response.
|
|
27
|
+
|
|
28
|
+
## Session model
|
|
29
|
+
|
|
30
|
+
Each channel and DM gets its **own wolli session**, bound by a `discord:channel`
|
|
31
|
+
tag:
|
|
32
|
+
|
|
33
|
+
- **Inbound** — an incoming message is routed to the session tagged for its channel.
|
|
34
|
+
If none exists yet, one is created and tagged on the spot. Histories never bleed
|
|
35
|
+
across channels, and two channels can run in parallel.
|
|
36
|
+
- **Outbound** — the reply rides the producing session's tag, so the answer always
|
|
37
|
+
returns to the channel that started the turn — not to whoever messaged most
|
|
38
|
+
recently.
|
|
39
|
+
|
|
40
|
+
## Setup
|
|
41
|
+
|
|
42
|
+
### 1. Create a Discord application
|
|
43
|
+
|
|
44
|
+
Open the [Discord Developer Portal](https://discord.com/developers/applications) and
|
|
45
|
+
click **New Application**. Name it (e.g. "Wolli") and accept the terms.
|
|
46
|
+
|
|
47
|
+
### 2. Enable the Message Content Intent
|
|
48
|
+
|
|
49
|
+
This is the critical step. Open **Bot** in the sidebar, scroll to **Privileged
|
|
50
|
+
Gateway Intents**, toggle **Message Content Intent** to **ON**, and **Save Changes**.
|
|
51
|
+
|
|
52
|
+
Without it, the bot still receives message events but the message text arrives
|
|
53
|
+
**empty**, so it can never reply. This is the single privileged intent the bot
|
|
54
|
+
needs — you do **not** need Server Members or Presence.
|
|
55
|
+
|
|
56
|
+
### 3. Reset and copy the bot token
|
|
57
|
+
|
|
58
|
+
On the same **Bot** page, click **Reset Token**, complete 2FA if prompted, and copy
|
|
59
|
+
the token. It is shown only once — if you lose it, reset and generate a new one. Keep
|
|
60
|
+
it secret.
|
|
61
|
+
|
|
62
|
+
### 4. Invite the bot
|
|
63
|
+
|
|
64
|
+
Open **OAuth2 → URL Generator** and select:
|
|
65
|
+
|
|
66
|
+
- **Scopes:** `bot`
|
|
67
|
+
- **Bot Permissions:** **View Channels**, **Send Messages**, **Read Message History**
|
|
68
|
+
|
|
69
|
+
Copy the generated URL at the bottom, open it, pick a server you administer, and
|
|
70
|
+
authorize. Only the `bot` scope is required — the `applications.commands` scope is
|
|
71
|
+
not needed.
|
|
72
|
+
|
|
73
|
+
### 5. Install and onboard in wolli
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
wolli <agent> plugins install ./built-in/plugins/discord
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
In an interactive terminal this runs onboarding immediately: it prints the connect
|
|
80
|
+
guide, then prompts you to **paste the bot token**. Paste the token from step 3.
|
|
81
|
+
Wolli verifies it with a live `GET /users/@me` call and stores it. That single token
|
|
82
|
+
is the only value you enter.
|
|
83
|
+
|
|
84
|
+
If you installed non-interactively, onboard later with:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
wolli <agent> plugins configure discord
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 6. Restart the agent
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
wolli restart <agent>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
This starts the gateway producer that connects to Discord. After onboarding a fresh
|
|
97
|
+
integration, restart the agent once so the bot comes online and begins responding.
|
|
98
|
+
|
|
99
|
+
## Configuration reference
|
|
100
|
+
|
|
101
|
+
Configuration lives per agent in `~/.wolli/agents/<name>/integrations.json` under
|
|
102
|
+
`discord.default`:
|
|
103
|
+
|
|
104
|
+
```json
|
|
105
|
+
{
|
|
106
|
+
"discord": {
|
|
107
|
+
"default": {
|
|
108
|
+
"botToken": "...",
|
|
109
|
+
"allowedChannelIds": ["123456789012345678"]
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
| Field | Required | Default | Purpose |
|
|
116
|
+
|-------|----------|---------|---------|
|
|
117
|
+
| `botToken` | Yes | — | The bot token. Onboarding stores it raw; a `$ENV` / `!cmd` reference placed here by hand also resolves on read. |
|
|
118
|
+
| `allowedChannelIds` | No | *(any channel)* | Allowlist of channel IDs the bot will respond in. Empty or absent accepts **any** channel the bot can read (logged as a warning at startup). |
|
|
119
|
+
|
|
120
|
+
Discord IDs are snowflakes — keep them as **quoted strings** in JSON, never numbers,
|
|
121
|
+
since a 64-bit snowflake exceeds JavaScript's safe-integer range. To grab a channel
|
|
122
|
+
ID, enable **Developer Mode** in Discord (Settings → Advanced), then right-click a
|
|
123
|
+
channel and **Copy Channel ID**.
|
|
124
|
+
|
|
125
|
+
`allowedChannelIds` is not asked during onboarding — edit `integrations.json` to set
|
|
126
|
+
it.
|
|
127
|
+
|
|
128
|
+
## Not supported
|
|
129
|
+
|
|
130
|
+
The bot is deliberately focused on text chat. It does not provide:
|
|
131
|
+
|
|
132
|
+
- Mention-gating — it answers every readable message, not only `@mentions`.
|
|
133
|
+
- User, role, or guild allowlists — channel-level `allowedChannelIds` is the only
|
|
134
|
+
scope control.
|
|
135
|
+
- Threads or auto-threading.
|
|
136
|
+
- Reactions.
|
|
137
|
+
- Native Discord slash commands.
|
|
138
|
+
- Inbound or outbound media, attachments, or voice.
|
|
139
|
+
|
|
140
|
+
## Troubleshooting
|
|
141
|
+
|
|
142
|
+
| Symptom | Fix |
|
|
143
|
+
|---------|-----|
|
|
144
|
+
| Bot is online but never replies | Enable the **Message Content Intent** (step 2). Without it the message text arrives empty and there is nothing to answer. |
|
|
145
|
+
| `Disallowed intents` on connect | Same cause: the Message Content Intent is not enabled in the Developer Portal. |
|
|
146
|
+
| No reply right after the first install/onboard | Restart the agent (`wolli restart <agent>`) so the gateway producer starts. |
|
|
147
|
+
| Silence in one specific channel | The bot is missing **View Channels** / **Send Messages** there, or the channel isn't in `allowedChannelIds`. Try a DM to isolate. |
|
|
148
|
+
|
|
149
|
+
## Security
|
|
150
|
+
|
|
151
|
+
- `allowedChannelIds` is the only access gate today. With it empty, **any** channel
|
|
152
|
+
the bot can read is accepted — set it to lock the bot to known channels.
|
|
153
|
+
- There is no per-user or per-role gate. Anyone who can post in an allowed channel
|
|
154
|
+
can drive the agent, so keep the bot in trusted channels.
|
|
155
|
+
- The bot token grants full control of the bot account — never commit it or share
|
|
156
|
+
it. Wolli writes `integrations.json` with mode `0600`.
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Discord chat extension — maps the transport's `message` events onto wolli sessions:
|
|
3
|
+
* each channel/DM gets its own session (bound by a `discord:channel` tag), inbound text
|
|
4
|
+
* is queued as a followUp, and the final assistant text is sent back on `agent_end`.
|
|
5
|
+
* Paired with `index.ts`.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { AgentMessage } from "@opsyhq/agent";
|
|
9
|
+
import type { ExtensionAPI } from "@opsyhq/wolli";
|
|
10
|
+
|
|
11
|
+
// Discord's typing state lasts ~10s; refresh a little ahead of that.
|
|
12
|
+
const TYPING_INTERVAL_MS = 8000;
|
|
13
|
+
|
|
14
|
+
interface DiscordMessage {
|
|
15
|
+
channelId: string;
|
|
16
|
+
messageId: string;
|
|
17
|
+
text: string;
|
|
18
|
+
author: { id: string; name?: string };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Text of the last assistant message; "" for a pure tool-call turn. */
|
|
22
|
+
function finalAssistantText(messages: AgentMessage[]): string {
|
|
23
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
24
|
+
const m = messages[i];
|
|
25
|
+
if (m.role !== "assistant") continue;
|
|
26
|
+
return m.content
|
|
27
|
+
.filter((c): c is { type: "text"; text: string } => c.type === "text")
|
|
28
|
+
.map((c) => c.text)
|
|
29
|
+
.join("")
|
|
30
|
+
.trim();
|
|
31
|
+
}
|
|
32
|
+
return "";
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default function (wolli: ExtensionAPI) {
|
|
36
|
+
const discord = wolli.getIntegration("discord", "default");
|
|
37
|
+
|
|
38
|
+
let typingTimer: ReturnType<typeof setInterval> | undefined;
|
|
39
|
+
|
|
40
|
+
discord.on("message", async (data) => {
|
|
41
|
+
const m = data as DiscordMessage;
|
|
42
|
+
|
|
43
|
+
// Reuse this channel's session, or create + tag a fresh one.
|
|
44
|
+
const channelTag = { "discord:channel": m.channelId };
|
|
45
|
+
const [match] = await wolli.findSessions(channelTag);
|
|
46
|
+
const session = match
|
|
47
|
+
? await wolli.openSession(match.id)
|
|
48
|
+
: await wolli.createSession({
|
|
49
|
+
setup: async (sessionManager) => {
|
|
50
|
+
await sessionManager.appendTags(channelTag);
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// followUp: a message arriving mid-turn queues instead of interrupting.
|
|
55
|
+
void session.sendUserMessage(m.text, { deliverAs: "followUp" });
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const stopTyping = (): void => {
|
|
59
|
+
if (typingTimer) {
|
|
60
|
+
clearInterval(typingTimer);
|
|
61
|
+
typingTimer = undefined;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
wolli.on("agent_start", async (_event, ctx) => {
|
|
66
|
+
const channelId = ctx.session.getTags()["discord:channel"];
|
|
67
|
+
if (!channelId) return; // not a discord-bound session
|
|
68
|
+
const sendTyping = () => {
|
|
69
|
+
void discord.call("sendTyping", { channelId }).catch(() => {});
|
|
70
|
+
};
|
|
71
|
+
sendTyping();
|
|
72
|
+
stopTyping();
|
|
73
|
+
typingTimer = setInterval(sendTyping, TYPING_INTERVAL_MS);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
wolli.on("agent_end", async ({ messages }, ctx) => {
|
|
77
|
+
stopTyping();
|
|
78
|
+
|
|
79
|
+
// Reply goes to the channel that started this turn (the producing session's tag).
|
|
80
|
+
const channelId = ctx.session.getTags()["discord:channel"];
|
|
81
|
+
if (!channelId) return; // not a discord-bound session
|
|
82
|
+
|
|
83
|
+
const text = finalAssistantText(messages as AgentMessage[]);
|
|
84
|
+
if (!text) return; // pure tool-call turn — nothing to send
|
|
85
|
+
await discord.call("sendMessage", { channelId, text });
|
|
86
|
+
});
|
|
87
|
+
}
|