@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.
Files changed (126) hide show
  1. package/README.md +90 -36
  2. package/bin/waifus.mjs +36 -0
  3. package/dist/api/errors.d.ts +9 -0
  4. package/dist/api/errors.js +23 -0
  5. package/dist/api/errors.js.map +1 -0
  6. package/dist/api/server.d.ts +19 -0
  7. package/dist/api/server.js +1176 -0
  8. package/dist/api/server.js.map +1 -0
  9. package/dist/backend/logger.d.ts +20 -0
  10. package/dist/backend/logger.js +65 -0
  11. package/dist/backend/logger.js.map +1 -0
  12. package/dist/backend/migrations.d.ts +4 -0
  13. package/dist/backend/migrations.js +8 -0
  14. package/dist/backend/migrations.js.map +1 -0
  15. package/dist/backend/redaction.d.ts +1 -0
  16. package/dist/backend/redaction.js +22 -0
  17. package/dist/backend/redaction.js.map +1 -0
  18. package/dist/backend/runtime.d.ts +24 -0
  19. package/dist/backend/runtime.js +43 -0
  20. package/dist/backend/runtime.js.map +1 -0
  21. package/dist/backend/server.d.ts +15 -0
  22. package/dist/backend/server.js +295 -0
  23. package/dist/backend/server.js.map +1 -0
  24. package/dist/cli/commands.d.ts +2 -0
  25. package/dist/cli/commands.js +286 -0
  26. package/dist/cli/commands.js.map +1 -0
  27. package/dist/cli/main.d.ts +1 -0
  28. package/dist/cli/main.js +12 -0
  29. package/dist/cli/main.js.map +1 -0
  30. package/dist/cli/parser.d.ts +10 -0
  31. package/dist/cli/parser.js +64 -0
  32. package/dist/cli/parser.js.map +1 -0
  33. package/dist/config/appConfig.d.ts +3 -0
  34. package/dist/config/appConfig.js +27 -0
  35. package/dist/config/appConfig.js.map +1 -0
  36. package/dist/config/layout.d.ts +13 -0
  37. package/dist/config/layout.js +160 -0
  38. package/dist/config/layout.js.map +1 -0
  39. package/dist/config/paths.d.ts +5 -0
  40. package/dist/config/paths.js +20 -0
  41. package/dist/config/paths.js.map +1 -0
  42. package/dist/config/prebuiltWaifus.d.ts +3 -0
  43. package/dist/config/prebuiltWaifus.js +67 -0
  44. package/dist/config/prebuiltWaifus.js.map +1 -0
  45. package/dist/discord/client.d.ts +143 -0
  46. package/dist/discord/client.js +438 -0
  47. package/dist/discord/client.js.map +1 -0
  48. package/dist/discord/contextBuilder.d.ts +15 -0
  49. package/dist/discord/contextBuilder.js +18 -0
  50. package/dist/discord/contextBuilder.js.map +1 -0
  51. package/dist/discord/intents.d.ts +5 -0
  52. package/dist/discord/intents.js +21 -0
  53. package/dist/discord/intents.js.map +1 -0
  54. package/dist/discord/memberCache.d.ts +12 -0
  55. package/dist/discord/memberCache.js +55 -0
  56. package/dist/discord/memberCache.js.map +1 -0
  57. package/dist/discord/normalization.d.ts +32 -0
  58. package/dist/discord/normalization.js +176 -0
  59. package/dist/discord/normalization.js.map +1 -0
  60. package/dist/discord/rateLimit.d.ts +9 -0
  61. package/dist/discord/rateLimit.js +11 -0
  62. package/dist/discord/rateLimit.js.map +1 -0
  63. package/dist/orchestration/context.d.ts +61 -0
  64. package/dist/orchestration/context.js +97 -0
  65. package/dist/orchestration/context.js.map +1 -0
  66. package/dist/orchestration/decisions.d.ts +27 -0
  67. package/dist/orchestration/decisions.js +28 -0
  68. package/dist/orchestration/decisions.js.map +1 -0
  69. package/dist/orchestration/messageSplit.d.ts +2 -0
  70. package/dist/orchestration/messageSplit.js +16 -0
  71. package/dist/orchestration/messageSplit.js.map +1 -0
  72. package/dist/orchestration/reviewer.d.ts +5 -0
  73. package/dist/orchestration/reviewer.js +5 -0
  74. package/dist/orchestration/reviewer.js.map +1 -0
  75. package/dist/orchestration/runtime.d.ts +71 -0
  76. package/dist/orchestration/runtime.js +1043 -0
  77. package/dist/orchestration/runtime.js.map +1 -0
  78. package/dist/orchestration/session.d.ts +30 -0
  79. package/dist/orchestration/session.js +41 -0
  80. package/dist/orchestration/session.js.map +1 -0
  81. package/dist/orchestration/stageManager.d.ts +52 -0
  82. package/dist/orchestration/stageManager.js +27 -0
  83. package/dist/orchestration/stageManager.js.map +1 -0
  84. package/dist/providers/catalog.d.ts +6 -0
  85. package/dist/providers/catalog.js +173 -0
  86. package/dist/providers/catalog.js.map +1 -0
  87. package/dist/providers/pipelines.d.ts +110 -0
  88. package/dist/providers/pipelines.js +1056 -0
  89. package/dist/providers/pipelines.js.map +1 -0
  90. package/dist/providers/types.d.ts +64 -0
  91. package/dist/providers/types.js +2 -0
  92. package/dist/providers/types.js.map +1 -0
  93. package/dist/shared/queryLog.d.ts +19 -0
  94. package/dist/shared/queryLog.js +38 -0
  95. package/dist/shared/queryLog.js.map +1 -0
  96. package/dist/shared/schemas/common.d.ts +21 -0
  97. package/dist/shared/schemas/common.js +27 -0
  98. package/dist/shared/schemas/common.js.map +1 -0
  99. package/dist/shared/schemas/config.d.ts +28 -0
  100. package/dist/shared/schemas/config.js +27 -0
  101. package/dist/shared/schemas/config.js.map +1 -0
  102. package/dist/shared/schemas/domain.d.ts +396 -0
  103. package/dist/shared/schemas/domain.js +184 -0
  104. package/dist/shared/schemas/domain.js.map +1 -0
  105. package/dist/storage/atomic.d.ts +6 -0
  106. package/dist/storage/atomic.js +60 -0
  107. package/dist/storage/atomic.js.map +1 -0
  108. package/dist/storage/errors.d.ts +12 -0
  109. package/dist/storage/errors.js +23 -0
  110. package/dist/storage/errors.js.map +1 -0
  111. package/dist/storage/locks.d.ts +9 -0
  112. package/dist/storage/locks.js +42 -0
  113. package/dist/storage/locks.js.map +1 -0
  114. package/dist/storage/storageService.d.ts +25 -0
  115. package/dist/storage/storageService.js +66 -0
  116. package/dist/storage/storageService.js.map +1 -0
  117. package/dist-frontend/assets/index-BV8l-6Yl.js +67 -0
  118. package/dist-frontend/assets/index-BV8l-6Yl.js.map +1 -0
  119. package/dist-frontend/assets/index-BZ0CmOEI.css +1 -0
  120. package/dist-frontend/index.html +14 -0
  121. package/docs/api.md +148 -0
  122. package/docs/old-orchestrator-prompt.md +123 -0
  123. package/package.json +49 -24
  124. package/dist/index.d.ts +0 -1
  125. package/dist/index.js +0 -2062
  126. package/dist/index.js.map +0 -1
package/README.md CHANGED
@@ -1,66 +1,120 @@
1
- # @starlight-ai/discord-waifus
1
+ # Discord Waifus
2
2
 
3
- `@starlight-ai/discord-waifus` provides the global `waifus` command for the local Discord Waifus stack.
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
- ## Install
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
- ```bash
8
- npm install -g @starlight-ai/discord-waifus
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
- From a clone:
16
+ Open the web UI:
12
17
 
13
- ```bash
14
- pnpm --filter @starlight-ai/discord-waifus build
15
- pnpm --filter @starlight-ai/discord-waifus link --global
18
+ ```text
19
+ http://127.0.0.1:3888
16
20
  ```
17
21
 
18
- ## Typical Flow
22
+ ## Install From a GitHub Release
19
23
 
20
- ### Existing clone
24
+ Download the `.tgz` release asset, then install it globally:
21
25
 
22
- ```bash
23
- waifus use /path/to/Discord-Waifus
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
- ### First run with no existing project
31
+ ## Build From Source
31
32
 
32
- ```bash
33
- waifus
34
- waifus open
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
- On first run, `waifus` downloads the latest GitHub Release bundle into `~/Discord-Waifus`, verifies the checksum when available, saves that directory as the default project root, runs `pnpm install --prod --frozen-lockfile` with the bundled pnpm, initializes local runtime files, and starts the local stack.
41
+ For local development:
42
+
43
+ ```sh
44
+ npm run waifus -- dev
45
+ npm run dev:frontend
46
+ ```
38
47
 
39
- ### Refresh an existing release-bundle install
48
+ ## CLI
40
49
 
41
- ```bash
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
- `waifus update` downloads the latest GitHub Release bundle into the existing project root, preserves local runtime data such as `.waifus/`, reinstalls runtime dependencies, and restarts the stack if it was already running. It prints progress while resolving the release, downloading, verifying, extracting, applying files, and installing dependencies.
61
+ `DC_WAIFUS_HOME=PATH` overrides the default `~/.dc-waifus` data root.
46
62
 
47
- ### Download from GitHub into a custom directory
63
+ ## Discord Setup
48
64
 
49
- ```bash
50
- waifus init ~/Discord-Waifus --repo https://github.com/HeavenllyDemon/Discord-Waifus
51
- waifus start
52
- waifus open
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
- You can also pin a specific GitHub Release:
104
+ Important folders:
56
105
 
57
- ```bash
58
- waifus init ~/Discord-Waifus --release app-v0.3.0
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
- ## Runtime Model
116
+ Use `waifus clean` only when you intentionally want to delete saved user data.
62
117
 
63
- - committed defaults live in `defaults/`
64
- - local runtime state lives in `.waifus/`
118
+ ## Release Notes
65
119
 
66
- This CLI is for local-machine usage. The dashboard runs on `http://localhost:3000` and the backend API runs on `http://127.0.0.1:4000`.
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>;