@starlight-ai/discord-waifus 0.3.3 → 1.0.1
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 +90 -36
- package/bin/waifus.mjs +36 -0
- package/dist/api/errors.d.ts +9 -0
- package/dist/api/errors.js +23 -0
- package/dist/api/errors.js.map +1 -0
- package/dist/api/server.d.ts +19 -0
- package/dist/api/server.js +1176 -0
- package/dist/api/server.js.map +1 -0
- package/dist/backend/logger.d.ts +20 -0
- package/dist/backend/logger.js +65 -0
- package/dist/backend/logger.js.map +1 -0
- package/dist/backend/migrations.d.ts +4 -0
- package/dist/backend/migrations.js +8 -0
- package/dist/backend/migrations.js.map +1 -0
- package/dist/backend/redaction.d.ts +1 -0
- package/dist/backend/redaction.js +22 -0
- package/dist/backend/redaction.js.map +1 -0
- package/dist/backend/runtime.d.ts +24 -0
- package/dist/backend/runtime.js +43 -0
- package/dist/backend/runtime.js.map +1 -0
- package/dist/backend/server.d.ts +15 -0
- package/dist/backend/server.js +295 -0
- package/dist/backend/server.js.map +1 -0
- package/dist/cli/commands.d.ts +2 -0
- package/dist/cli/commands.js +286 -0
- package/dist/cli/commands.js.map +1 -0
- package/dist/cli/main.d.ts +1 -0
- package/dist/cli/main.js +12 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/cli/parser.d.ts +10 -0
- package/dist/cli/parser.js +64 -0
- package/dist/cli/parser.js.map +1 -0
- package/dist/config/appConfig.d.ts +3 -0
- package/dist/config/appConfig.js +27 -0
- package/dist/config/appConfig.js.map +1 -0
- package/dist/config/layout.d.ts +13 -0
- package/dist/config/layout.js +160 -0
- package/dist/config/layout.js.map +1 -0
- package/dist/config/paths.d.ts +5 -0
- package/dist/config/paths.js +20 -0
- package/dist/config/paths.js.map +1 -0
- package/dist/config/prebuiltWaifus.d.ts +3 -0
- package/dist/config/prebuiltWaifus.js +67 -0
- package/dist/config/prebuiltWaifus.js.map +1 -0
- package/dist/discord/client.d.ts +143 -0
- package/dist/discord/client.js +438 -0
- package/dist/discord/client.js.map +1 -0
- package/dist/discord/contextBuilder.d.ts +15 -0
- package/dist/discord/contextBuilder.js +18 -0
- package/dist/discord/contextBuilder.js.map +1 -0
- package/dist/discord/intents.d.ts +5 -0
- package/dist/discord/intents.js +21 -0
- package/dist/discord/intents.js.map +1 -0
- package/dist/discord/memberCache.d.ts +12 -0
- package/dist/discord/memberCache.js +55 -0
- package/dist/discord/memberCache.js.map +1 -0
- package/dist/discord/normalization.d.ts +32 -0
- package/dist/discord/normalization.js +176 -0
- package/dist/discord/normalization.js.map +1 -0
- package/dist/discord/rateLimit.d.ts +9 -0
- package/dist/discord/rateLimit.js +11 -0
- package/dist/discord/rateLimit.js.map +1 -0
- package/dist/orchestration/context.d.ts +61 -0
- package/dist/orchestration/context.js +97 -0
- package/dist/orchestration/context.js.map +1 -0
- package/dist/orchestration/decisions.d.ts +27 -0
- package/dist/orchestration/decisions.js +28 -0
- package/dist/orchestration/decisions.js.map +1 -0
- package/dist/orchestration/messageSplit.d.ts +2 -0
- package/dist/orchestration/messageSplit.js +16 -0
- package/dist/orchestration/messageSplit.js.map +1 -0
- package/dist/orchestration/reviewer.d.ts +5 -0
- package/dist/orchestration/reviewer.js +5 -0
- package/dist/orchestration/reviewer.js.map +1 -0
- package/dist/orchestration/runtime.d.ts +71 -0
- package/dist/orchestration/runtime.js +1043 -0
- package/dist/orchestration/runtime.js.map +1 -0
- package/dist/orchestration/session.d.ts +30 -0
- package/dist/orchestration/session.js +41 -0
- package/dist/orchestration/session.js.map +1 -0
- package/dist/orchestration/stageManager.d.ts +52 -0
- package/dist/orchestration/stageManager.js +27 -0
- package/dist/orchestration/stageManager.js.map +1 -0
- package/dist/providers/catalog.d.ts +6 -0
- package/dist/providers/catalog.js +173 -0
- package/dist/providers/catalog.js.map +1 -0
- package/dist/providers/pipelines.d.ts +110 -0
- package/dist/providers/pipelines.js +1056 -0
- package/dist/providers/pipelines.js.map +1 -0
- package/dist/providers/types.d.ts +64 -0
- package/dist/providers/types.js +2 -0
- package/dist/providers/types.js.map +1 -0
- package/dist/shared/queryLog.d.ts +19 -0
- package/dist/shared/queryLog.js +38 -0
- package/dist/shared/queryLog.js.map +1 -0
- package/dist/shared/schemas/common.d.ts +21 -0
- package/dist/shared/schemas/common.js +27 -0
- package/dist/shared/schemas/common.js.map +1 -0
- package/dist/shared/schemas/config.d.ts +28 -0
- package/dist/shared/schemas/config.js +27 -0
- package/dist/shared/schemas/config.js.map +1 -0
- package/dist/shared/schemas/domain.d.ts +396 -0
- package/dist/shared/schemas/domain.js +184 -0
- package/dist/shared/schemas/domain.js.map +1 -0
- package/dist/storage/atomic.d.ts +6 -0
- package/dist/storage/atomic.js +60 -0
- package/dist/storage/atomic.js.map +1 -0
- package/dist/storage/errors.d.ts +12 -0
- package/dist/storage/errors.js +23 -0
- package/dist/storage/errors.js.map +1 -0
- package/dist/storage/locks.d.ts +9 -0
- package/dist/storage/locks.js +42 -0
- package/dist/storage/locks.js.map +1 -0
- package/dist/storage/storageService.d.ts +25 -0
- package/dist/storage/storageService.js +66 -0
- package/dist/storage/storageService.js.map +1 -0
- package/dist-frontend/assets/index-BV8l-6Yl.js +67 -0
- package/dist-frontend/assets/index-BV8l-6Yl.js.map +1 -0
- package/dist-frontend/assets/index-BZ0CmOEI.css +1 -0
- package/dist-frontend/index.html +14 -0
- package/docs/api.md +148 -0
- package/docs/old-orchestrator-prompt.md +123 -0
- package/package.json +49 -24
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -2062
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,66 +1,120 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Discord Waifus
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Local Discord waifu orchestrator with a backend, web UI, Discord gateway clients, provider-specific AI model pipelines, and a global `waifus` CLI.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The app runs on your machine, stores its user data under `~/.dc-waifus`, and lets one orchestrator bot decide which configured waifu bot should answer in each Discord channel.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
## Install From npm
|
|
8
|
+
|
|
9
|
+
Requires Node.js 20 or newer.
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install -g @starlight-ai/discord-waifus@latest
|
|
13
|
+
waifus start
|
|
9
14
|
```
|
|
10
15
|
|
|
11
|
-
|
|
16
|
+
Open the web UI:
|
|
12
17
|
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
pnpm --filter @starlight-ai/discord-waifus link --global
|
|
18
|
+
```text
|
|
19
|
+
http://127.0.0.1:3888
|
|
16
20
|
```
|
|
17
21
|
|
|
18
|
-
##
|
|
22
|
+
## Install From a GitHub Release
|
|
19
23
|
|
|
20
|
-
|
|
24
|
+
Download the `.tgz` release asset, then install it globally:
|
|
21
25
|
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
waifus init-config
|
|
25
|
-
waifus build
|
|
26
|
+
```sh
|
|
27
|
+
npm install -g ./starlight-ai-discord-waifus-1.0.0.tgz
|
|
26
28
|
waifus start
|
|
27
|
-
waifus open
|
|
28
29
|
```
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
## Build From Source
|
|
31
32
|
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
```sh
|
|
34
|
+
git clone https://github.com/HeavenllyDemon/Discord-Waifus.git
|
|
35
|
+
cd Discord-Waifus
|
|
36
|
+
npm install
|
|
37
|
+
npm run build
|
|
38
|
+
npm run waifus -- start
|
|
35
39
|
```
|
|
36
40
|
|
|
37
|
-
|
|
41
|
+
For local development:
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
npm run waifus -- dev
|
|
45
|
+
npm run dev:frontend
|
|
46
|
+
```
|
|
38
47
|
|
|
39
|
-
|
|
48
|
+
## CLI
|
|
40
49
|
|
|
41
|
-
```
|
|
50
|
+
```text
|
|
51
|
+
waifus help
|
|
52
|
+
waifus start [--host 127.0.0.1] [--port 3888] [--data-root PATH]
|
|
53
|
+
waifus stop [--data-root PATH]
|
|
54
|
+
waifus restart [--host 127.0.0.1] [--port 3888] [--data-root PATH]
|
|
55
|
+
waifus status [--data-root PATH]
|
|
56
|
+
waifus doctor [--data-root PATH]
|
|
57
|
+
waifus clean [--force] [--include-logs] [--data-root PATH]
|
|
42
58
|
waifus update
|
|
43
59
|
```
|
|
44
60
|
|
|
45
|
-
`
|
|
61
|
+
`DC_WAIFUS_HOME=PATH` overrides the default `~/.dc-waifus` data root.
|
|
46
62
|
|
|
47
|
-
|
|
63
|
+
## Discord Setup
|
|
48
64
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
65
|
+
Create one Discord application for the orchestrator and one application for each waifu bot. In the web UI:
|
|
66
|
+
|
|
67
|
+
1. Configure the orchestrator bot token and Application ID in **Orchestrator**.
|
|
68
|
+
2. Configure provider API keys in **Providers**.
|
|
69
|
+
3. Configure each waifu model, persona, and bot token in **Waifus**.
|
|
70
|
+
4. Invite the bots to your Discord server from **Servers**.
|
|
71
|
+
5. Select at least one waifu for each channel where the system should run.
|
|
72
|
+
|
|
73
|
+
Required gateway intents:
|
|
74
|
+
|
|
75
|
+
```text
|
|
76
|
+
GUILDS
|
|
77
|
+
GUILD_MESSAGES
|
|
78
|
+
GUILD_MESSAGE_REACTIONS
|
|
79
|
+
MESSAGE_CONTENT
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
`MESSAGE_CONTENT` must be enabled in the Discord Developer Portal for complete channel context.
|
|
83
|
+
|
|
84
|
+
## AI Providers
|
|
85
|
+
|
|
86
|
+
The app groups supported models under:
|
|
87
|
+
|
|
88
|
+
- x.ai
|
|
89
|
+
- DeepSeek
|
|
90
|
+
- Anthropic
|
|
91
|
+
- OpenAI
|
|
92
|
+
- Z.AI
|
|
93
|
+
|
|
94
|
+
Each model has its own backend pipeline so provider-specific options can be exposed without flattening everything into one generic request shape.
|
|
95
|
+
|
|
96
|
+
## Data Layout
|
|
97
|
+
|
|
98
|
+
By default, runtime and user configuration lives in:
|
|
99
|
+
|
|
100
|
+
```text
|
|
101
|
+
~/.dc-waifus
|
|
53
102
|
```
|
|
54
103
|
|
|
55
|
-
|
|
104
|
+
Important folders:
|
|
56
105
|
|
|
57
|
-
```
|
|
58
|
-
waifus
|
|
106
|
+
```text
|
|
107
|
+
~/.dc-waifus/config.toml
|
|
108
|
+
~/.dc-waifus/user/providers.json
|
|
109
|
+
~/.dc-waifus/user/discord-bots.json
|
|
110
|
+
~/.dc-waifus/user/waifus/
|
|
111
|
+
~/.dc-waifus/user/servers/
|
|
112
|
+
~/.dc-waifus/user/memories.json
|
|
113
|
+
~/.dc-waifus/app/logs/
|
|
59
114
|
```
|
|
60
115
|
|
|
61
|
-
|
|
116
|
+
Use `waifus clean` only when you intentionally want to delete saved user data.
|
|
62
117
|
|
|
63
|
-
|
|
64
|
-
- local runtime state lives in `.waifus/`
|
|
118
|
+
## Release Notes
|
|
65
119
|
|
|
66
|
-
|
|
120
|
+
Version `1.0.0` is the first stable release for the local backend, web UI, Discord runtime, npm CLI, and prebuilt waifu configuration flow.
|
package/bin/waifus.mjs
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawnSync } from "node:child_process";
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { pathToFileURL, fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
8
|
+
const compiled = path.join(root, "dist", "cli", "main.js");
|
|
9
|
+
const source = path.join(root, "src", "cli", "main.ts");
|
|
10
|
+
|
|
11
|
+
if (existsSync(compiled)) {
|
|
12
|
+
await import(pathToFileURL(compiled).href);
|
|
13
|
+
} else if (existsSync(source)) {
|
|
14
|
+
const tsxBin = path.join(
|
|
15
|
+
root,
|
|
16
|
+
"node_modules",
|
|
17
|
+
".bin",
|
|
18
|
+
process.platform === "win32" ? "tsx.cmd" : "tsx"
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
if (!existsSync(tsxBin)) {
|
|
22
|
+
console.error(
|
|
23
|
+
"waifus is not built yet and local tsx is missing. Run `npm install`, then `npm run build` or retry the command."
|
|
24
|
+
);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const result = spawnSync(tsxBin, [source, ...process.argv.slice(2)], {
|
|
29
|
+
cwd: root,
|
|
30
|
+
stdio: "inherit"
|
|
31
|
+
});
|
|
32
|
+
process.exit(result.status ?? 1);
|
|
33
|
+
} else {
|
|
34
|
+
console.error("waifus CLI entrypoint is missing. Reinstall @starlight-ai/discord-waifus.");
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare class ApiError extends Error {
|
|
2
|
+
readonly statusCode: number;
|
|
3
|
+
readonly details?: unknown | undefined;
|
|
4
|
+
constructor(statusCode: number, message: string, details?: unknown | undefined);
|
|
5
|
+
}
|
|
6
|
+
export declare function badRequest(message: string, details?: unknown): ApiError;
|
|
7
|
+
export declare function notFound(message: string): ApiError;
|
|
8
|
+
export declare function conflict(message: string, details?: unknown): ApiError;
|
|
9
|
+
export declare function preconditionRequired(message: string): ApiError;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export class ApiError extends Error {
|
|
2
|
+
statusCode;
|
|
3
|
+
details;
|
|
4
|
+
constructor(statusCode, message, details) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.statusCode = statusCode;
|
|
7
|
+
this.details = details;
|
|
8
|
+
this.name = "ApiError";
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export function badRequest(message, details) {
|
|
12
|
+
return new ApiError(400, message, details);
|
|
13
|
+
}
|
|
14
|
+
export function notFound(message) {
|
|
15
|
+
return new ApiError(404, message);
|
|
16
|
+
}
|
|
17
|
+
export function conflict(message, details) {
|
|
18
|
+
return new ApiError(409, message, details);
|
|
19
|
+
}
|
|
20
|
+
export function preconditionRequired(message) {
|
|
21
|
+
return new ApiError(428, message);
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/api/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,QAAS,SAAQ,KAAK;IAEtB;IAEA;IAHX,YACW,UAAkB,EAC3B,OAAe,EACN,OAAiB;QAE1B,KAAK,CAAC,OAAO,CAAC,CAAC;QAJN,eAAU,GAAV,UAAU,CAAQ;QAElB,YAAO,GAAP,OAAO,CAAU;QAG1B,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACzB,CAAC;CACF;AAED,MAAM,UAAU,UAAU,CAAC,OAAe,EAAE,OAAiB;IAC3D,OAAO,IAAI,QAAQ,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,OAAe;IACtC,OAAO,IAAI,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,OAAe,EAAE,OAAiB;IACzD,OAAO,IAAI,QAAQ,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,OAAe;IAClD,OAAO,IAAI,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FastifyInstance } from "fastify";
|
|
2
|
+
import { Logger } from "../backend/logger.js";
|
|
3
|
+
import { RuntimeState } from "../backend/runtime.js";
|
|
4
|
+
import { RuntimeOrchestrator } from "../orchestration/runtime.js";
|
|
5
|
+
import { StorageService } from "../storage/storageService.js";
|
|
6
|
+
export type ApiServerOptions = {
|
|
7
|
+
dataRoot: string;
|
|
8
|
+
storage?: StorageService;
|
|
9
|
+
runtime: RuntimeState;
|
|
10
|
+
runtimeOrchestrator?: RuntimeOrchestrator;
|
|
11
|
+
runtimeControl?: {
|
|
12
|
+
getOrchestrator: () => RuntimeOrchestrator | undefined;
|
|
13
|
+
pause: () => Promise<void>;
|
|
14
|
+
resume: () => Promise<void>;
|
|
15
|
+
reload: (reason: string) => Promise<void>;
|
|
16
|
+
};
|
|
17
|
+
logger?: Logger;
|
|
18
|
+
};
|
|
19
|
+
export declare function createApiServer(options: ApiServerOptions): Promise<FastifyInstance>;
|