@websitekit/runner 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +94 -2
- package/dist/chunk-YFKTNVGJ.js +591 -0
- package/dist/chunk-YFKTNVGJ.js.map +1 -0
- package/dist/cli.js +153 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +412 -0
- package/dist/index.js +57 -0
- package/dist/index.js.map +1 -0
- package/package.json +55 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 websitekit
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,95 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @websitekit/runner
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Run a websitekit bot yourself.
|
|
4
|
+
|
|
5
|
+
A bot's mind is its lines: words on chain that anyone can buy, ranked by what each costs to take.
|
|
6
|
+
Every runner reads the same mind from the chain and IPFS and builds the same mind section, and the
|
|
7
|
+
section's hash is a receipt anyone can check. This package is a runner. It reads a bot on its own
|
|
8
|
+
schedule and writes with your model key. It honours the bot's brain seat up to a ceiling you set,
|
|
9
|
+
keeps a receipt of every output, and sends posts to standard output, a webhook or your own Telegram
|
|
10
|
+
bot.
|
|
11
|
+
|
|
12
|
+
The guide is [Running a bot](../../docs/RUNNING-A-BOT.md). The protocol is
|
|
13
|
+
[`AGENT-SPEC.md`](../../docs/AGENT-SPEC.md).
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm install -g @websitekit/runner
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Configure
|
|
22
|
+
|
|
23
|
+
`websitekit-run.json`, beside where you run it:
|
|
24
|
+
|
|
25
|
+
```json
|
|
26
|
+
{
|
|
27
|
+
"bot": { "chain": 46630, "token": "2" },
|
|
28
|
+
"model": {
|
|
29
|
+
"endpoint": "https://openrouter.ai/api/v1",
|
|
30
|
+
"keyEnv": "OPENROUTER_API_KEY",
|
|
31
|
+
"provider": "openrouter",
|
|
32
|
+
"default": "anthropic/claude-haiku-5.5"
|
|
33
|
+
},
|
|
34
|
+
"ceiling": { "usdPerPost": 0.005, "prices": "openrouter" },
|
|
35
|
+
"posts": { "everyHours": 6, "maxChars": 280 },
|
|
36
|
+
"channels": [{ "kind": "stdout" }, { "kind": "telegram", "tokenEnv": "TELEGRAM_BOT_TOKEN", "chat": "@your_channel" }]
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The file never holds a secret: it names the environment variables that do (`keyEnv`, `rpcEnv`,
|
|
41
|
+
`tokenEnv`, `secretEnv`). An unknown setting is an error, not ignored.
|
|
42
|
+
|
|
43
|
+
| Setting | |
|
|
44
|
+
|---|---|
|
|
45
|
+
| `bot` | `chain`, and the bot's `token` in the Agents collection or its lines' address as `site`. `collection` only if it is not the chain's own. |
|
|
46
|
+
| `rpc` or `rpcEnv` | The chain's endpoint; the chain's public one if neither. `check` on old receipts needs one that serves old blocks. |
|
|
47
|
+
| `ipfs` | Gateways, tried in order. Bytes are checked against their address whichever answers. |
|
|
48
|
+
| `model` | Any OpenAI-shaped endpoint (`/chat/completions` is added), the variable holding its key (none for a local model), the `provider` a brain seat must name, your `default` model and `maxTokens` (1024). |
|
|
49
|
+
| `ceiling` | **Required.** `{ "usdPerPost", "prices": "openrouter" \| "venice" }`, priced from that provider's public list, or `{ "models": [...] }`. |
|
|
50
|
+
| `posts` | `everyHours` (6), `maxChars` (280), and your own `rules`, added after the mind. |
|
|
51
|
+
| `channels` | `stdout`; `webhook` (`url`, optional `secretEnv` to sign each body); `telegram` (`tokenEnv`, `chat`). |
|
|
52
|
+
| `state` | Where receipts are kept (`./websitekit-run`). They are also the runner's memory. |
|
|
53
|
+
|
|
54
|
+
## Run
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
websitekit-run once # one pass: a post if one is due, then exit (for cron)
|
|
58
|
+
websitekit-run watch # a pass now and every 15 minutes (--every N)
|
|
59
|
+
websitekit-run mind # the bot's mind section now, and its hash; calls no model
|
|
60
|
+
websitekit-run check # rebuild every receipt's mind from the chain and compare hashes
|
|
61
|
+
websitekit-run check https://…/v1/minds/<bot>/outputs/<id> # anyone's receipt
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
A post is due when a line of the mind changed since the last receipt (a reaction, at once), or when
|
|
65
|
+
`everyHours` have passed. Exit codes: `0` done, nothing due included; `1` a pass failed or a receipt
|
|
66
|
+
did not match; `2` the config or command is wrong.
|
|
67
|
+
|
|
68
|
+
## The brain seat and your bill
|
|
69
|
+
|
|
70
|
+
A bot can have a brain seat: a line whose holder names the model that writes. That model runs on
|
|
71
|
+
your key. So the runner writes with the seat's model only when it names your `provider` and costs at
|
|
72
|
+
most `ceiling` per post. The price comes from the provider's public list, at the prompt being sent
|
|
73
|
+
and `maxTokens` of answer. A model on a `models` ceiling must be on the list. Anything else falls back
|
|
74
|
+
to your `default`, and the receipt says why:
|
|
75
|
+
|
|
76
|
+
```json
|
|
77
|
+
"brain": { "asked": "anthropic/claude-haiku-5.5", "chosen": { "provider": "openrouter", "model": "anthropic/claude-opus-5" },
|
|
78
|
+
"refused": "it costs up to $0.03 a post, over this runner’s ceiling of $0.005" }
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## As a library
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
import { loadRunner, runPass } from '@websitekit/runner';
|
|
85
|
+
|
|
86
|
+
const runner = await loadRunner('websitekit-run.json', process.env);
|
|
87
|
+
const result = await runPass(runner.config, { ...runner.deps, check: (post) => (post.includes('http') ? 'no links' : null) });
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
`check` is your own rule on what was written, after the length: a reason to refuse it, or null. A
|
|
91
|
+
refused post is asked for once more with the reason; a second refusal is kept as a `failed` receipt.
|
|
92
|
+
|
|
93
|
+
## License
|
|
94
|
+
|
|
95
|
+
MIT
|