@waifucave/discord-waifus 1.5.154
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 +230 -0
- package/THIRD_PARTY_NOTICES.md +26 -0
- package/assets/ocr/eng.traineddata +0 -0
- 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 +1290 -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 +521 -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 +30 -0
- package/dist/backend/runtime.js +49 -0
- package/dist/backend/runtime.js.map +1 -0
- package/dist/backend/server.d.ts +18 -0
- package/dist/backend/server.js +581 -0
- package/dist/backend/server.js.map +1 -0
- package/dist/cli/commands.d.ts +35 -0
- package/dist/cli/commands.js +510 -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 +173 -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 +106 -0
- package/dist/config/prebuiltWaifus.js.map +1 -0
- package/dist/discord/client.d.ts +394 -0
- package/dist/discord/client.js +1196 -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 +34 -0
- package/dist/discord/normalization.js +330 -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 +85 -0
- package/dist/orchestration/context.js +200 -0
- package/dist/orchestration/context.js.map +1 -0
- package/dist/orchestration/decisions.d.ts +52 -0
- package/dist/orchestration/decisions.js +61 -0
- package/dist/orchestration/decisions.js.map +1 -0
- package/dist/orchestration/messageSplit.d.ts +6 -0
- package/dist/orchestration/messageSplit.js +118 -0
- package/dist/orchestration/messageSplit.js.map +1 -0
- package/dist/orchestration/ocr.d.ts +43 -0
- package/dist/orchestration/ocr.js +504 -0
- package/dist/orchestration/ocr.js.map +1 -0
- package/dist/orchestration/ocrPackages.d.ts +24 -0
- package/dist/orchestration/ocrPackages.js +85 -0
- package/dist/orchestration/ocrPackages.js.map +1 -0
- package/dist/orchestration/promptBlocks.d.ts +28 -0
- package/dist/orchestration/promptBlocks.js +232 -0
- package/dist/orchestration/promptBlocks.js.map +1 -0
- package/dist/orchestration/replyQuote.d.ts +7 -0
- package/dist/orchestration/replyQuote.js +198 -0
- package/dist/orchestration/replyQuote.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 +152 -0
- package/dist/orchestration/runtime.js +3535 -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 +42 -0
- package/dist/orchestration/stageManager.js +50 -0
- package/dist/orchestration/stageManager.js.map +1 -0
- package/dist/providers/catalog.d.ts +6 -0
- package/dist/providers/catalog.js +212 -0
- package/dist/providers/catalog.js.map +1 -0
- package/dist/providers/pipelines.d.ts +13 -0
- package/dist/providers/pipelines.js +2388 -0
- package/dist/providers/pipelines.js.map +1 -0
- package/dist/providers/types.d.ts +91 -0
- package/dist/providers/types.js +2 -0
- package/dist/providers/types.js.map +1 -0
- package/dist/shared/queryLog.d.ts +39 -0
- package/dist/shared/queryLog.js +80 -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 +57 -0
- package/dist/shared/schemas/config.js +49 -0
- package/dist/shared/schemas/config.js.map +1 -0
- package/dist/shared/schemas/domain.d.ts +825 -0
- package/dist/shared/schemas/domain.js +444 -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-B2bB3_2r.js +39 -0
- package/dist-frontend/assets/index-B2bB3_2r.js.map +1 -0
- package/dist-frontend/assets/index-Dj1L8Px-.css +1 -0
- package/dist-frontend/index.html +14 -0
- package/docs/api.md +162 -0
- package/docs/old-orchestrator-prompt.md +123 -0
- package/package.json +81 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { Logger } from "../backend/logger.js";
|
|
2
|
+
import { DiscordGatewayFacade, DiscordMessageEvent } from "../discord/client.js";
|
|
3
|
+
import { PipelineCredentials } from "../providers/pipelines.js";
|
|
4
|
+
import { ModelPipeline } from "../providers/types.js";
|
|
5
|
+
import { WaifuConfig } from "../shared/schemas/domain.js";
|
|
6
|
+
import { StorageService } from "../storage/storageService.js";
|
|
7
|
+
import { ContextMessage } from "./context.js";
|
|
8
|
+
export type RuntimeOrchestratorOptions = {
|
|
9
|
+
storage: StorageService;
|
|
10
|
+
discord: DiscordGatewayFacade;
|
|
11
|
+
logger: Logger;
|
|
12
|
+
maxAutomaticTurns?: number;
|
|
13
|
+
isPaused?: () => boolean;
|
|
14
|
+
onActiveRunsChange?: (activeRuns: number) => void;
|
|
15
|
+
createPipeline?: (modelId: string, credentials: PipelineCredentials) => ModelPipeline;
|
|
16
|
+
ocr?: {
|
|
17
|
+
enrichMessages(messages: ContextMessage[], options?: {
|
|
18
|
+
signal?: AbortSignal;
|
|
19
|
+
}): Promise<ContextMessage[]>;
|
|
20
|
+
dispose?(): Promise<void>;
|
|
21
|
+
};
|
|
22
|
+
sleep?: (ms: number, signal?: AbortSignal) => Promise<void>;
|
|
23
|
+
stageManagerIdleDelayMs?: number;
|
|
24
|
+
};
|
|
25
|
+
export type StageManagerRunResult = {
|
|
26
|
+
status: "updated" | "no_change" | "already_running" | "disabled" | "failed";
|
|
27
|
+
message?: string;
|
|
28
|
+
};
|
|
29
|
+
export declare class RuntimeOrchestrator {
|
|
30
|
+
private readonly options;
|
|
31
|
+
private readonly activeRuns;
|
|
32
|
+
private readonly retriggerTimers;
|
|
33
|
+
private readonly stageManagerSchedules;
|
|
34
|
+
private readonly activeStageManagerRuns;
|
|
35
|
+
private readonly maxAutomaticTurns;
|
|
36
|
+
private readonly createPipeline;
|
|
37
|
+
private readonly sleep;
|
|
38
|
+
private readonly stageManagerIdleDelayMs;
|
|
39
|
+
private readonly recentSelfSentIds;
|
|
40
|
+
private readonly activeWaifuSendChannels;
|
|
41
|
+
private readonly activeWaifuQueries;
|
|
42
|
+
private readonly activeReviewerRuns;
|
|
43
|
+
private readonly channelRunVersions;
|
|
44
|
+
private readonly suppressMemoryToolOnce;
|
|
45
|
+
private static readonly SELF_SENT_TTL_MS;
|
|
46
|
+
private static readonly STAGE_MANAGER_IDLE_DELAY_MS;
|
|
47
|
+
private static readonly ACTIVE_CHAT_PARTICIPANT_TTL_MS;
|
|
48
|
+
private unsubscribes;
|
|
49
|
+
constructor(options: RuntimeOrchestratorOptions);
|
|
50
|
+
start(): Promise<void>;
|
|
51
|
+
stop(): Promise<void>;
|
|
52
|
+
pause(): Promise<void>;
|
|
53
|
+
private runBackground;
|
|
54
|
+
private startChannelRunBackground;
|
|
55
|
+
private markSessionIdleBackground;
|
|
56
|
+
handleDiscordMessage(event: DiscordMessageEvent): Promise<void>;
|
|
57
|
+
triggerChannel(guildId: string, channelId: string, reason?: string): Promise<void>;
|
|
58
|
+
stopChannel(guildId: string, channelId: string, reason?: string): Promise<{
|
|
59
|
+
stoppedRun: boolean;
|
|
60
|
+
clearedRetrigger: boolean;
|
|
61
|
+
activeInAnotherChannel: boolean;
|
|
62
|
+
}>;
|
|
63
|
+
triggerStageManager(guildId: string, channelId: string): Promise<StageManagerRunResult>;
|
|
64
|
+
triggerReviewer(guildId: string, channelId: string, userId?: string): Promise<{
|
|
65
|
+
hallucination: boolean;
|
|
66
|
+
deleted: boolean;
|
|
67
|
+
messageIds: string[];
|
|
68
|
+
}>;
|
|
69
|
+
private handleReviewCommand;
|
|
70
|
+
private handleClearCommand;
|
|
71
|
+
private handleRunCommand;
|
|
72
|
+
private handleRunWaifuAutocomplete;
|
|
73
|
+
private handleStopCommand;
|
|
74
|
+
private handlePrintWaifuAutocomplete;
|
|
75
|
+
private handleMemoriesCommand;
|
|
76
|
+
private handlePrintCommand;
|
|
77
|
+
private formatPrintCommandMessages;
|
|
78
|
+
private modelVisibleMemoryBlockForPrint;
|
|
79
|
+
private handleDebugCommand;
|
|
80
|
+
private runtimeBusyReason;
|
|
81
|
+
private startChannelRun;
|
|
82
|
+
private runChannelLoop;
|
|
83
|
+
private recordOrchestratorDecision;
|
|
84
|
+
private executeResponderDecision;
|
|
85
|
+
private noteStageManagerActivity;
|
|
86
|
+
private runStageManager;
|
|
87
|
+
private startStageManagerRun;
|
|
88
|
+
private runReviewer;
|
|
89
|
+
private runReviewerInternal;
|
|
90
|
+
private clearLatestMessages;
|
|
91
|
+
private clearAllChannelMessages;
|
|
92
|
+
private applyStageManagerCalls;
|
|
93
|
+
private scheduleRetrigger;
|
|
94
|
+
private clearRetriggerTimer;
|
|
95
|
+
private clearStageManagerTimers;
|
|
96
|
+
private clearAllStageManagerTimers;
|
|
97
|
+
private clearScheduledRetrigger;
|
|
98
|
+
private sendWaifuChunks;
|
|
99
|
+
private setActivePipeline;
|
|
100
|
+
private rememberSelfSent;
|
|
101
|
+
private wasSelfSent;
|
|
102
|
+
private markSessionIdle;
|
|
103
|
+
private pipelineFor;
|
|
104
|
+
private messagesForModel;
|
|
105
|
+
private readProviderCredentials;
|
|
106
|
+
private readAgentConfig;
|
|
107
|
+
private readWaifu;
|
|
108
|
+
private resolveRunWaifu;
|
|
109
|
+
private validateRunWaifuTarget;
|
|
110
|
+
private resolvePrintWaifu;
|
|
111
|
+
private listWaifus;
|
|
112
|
+
private listAvailableWaifusForChannel;
|
|
113
|
+
private listAvailableWaifusForGuild;
|
|
114
|
+
private readMemoryStore;
|
|
115
|
+
private readShortTermMemoryStore;
|
|
116
|
+
private noteActiveChatParticipant;
|
|
117
|
+
private noteActiveChatParticipantsFromContext;
|
|
118
|
+
private noteActiveChatParticipants;
|
|
119
|
+
private readActiveChatParticipants;
|
|
120
|
+
private recordShortTermMemoryEntries;
|
|
121
|
+
private buildWaifuPromptParts;
|
|
122
|
+
private buildOrchestratorSystemPrompt;
|
|
123
|
+
private buildOrchestratorTrailingPrompt;
|
|
124
|
+
private ensureServer;
|
|
125
|
+
private ensureChannelConfig;
|
|
126
|
+
private channelHasWaifus;
|
|
127
|
+
private ensureChannelSession;
|
|
128
|
+
private readChannelSession;
|
|
129
|
+
private updateSession;
|
|
130
|
+
private readCompletedOrchestratorDecisionsForChannel;
|
|
131
|
+
private readRecentNoReplyMarkers;
|
|
132
|
+
private appendOrchestratorHistory;
|
|
133
|
+
private setDebugRoute;
|
|
134
|
+
private unsetDebugRoute;
|
|
135
|
+
private readDebugRoute;
|
|
136
|
+
private sendOrchestratorDebugLog;
|
|
137
|
+
private sendStageManagerDebugLog;
|
|
138
|
+
private sendDebugLogForChannel;
|
|
139
|
+
private updateOrchestratorDecisionStatus;
|
|
140
|
+
private insertOrchestratorResponderOutcomeAfter;
|
|
141
|
+
private moveOrchestratorResponderOutcomeAfter;
|
|
142
|
+
private updateOrchestratorResponderOutcome;
|
|
143
|
+
private finalizeOrchestratorDecisionAfterError;
|
|
144
|
+
private recordOrchestratorDecisionWaifuMessage;
|
|
145
|
+
private healPendingOrchestratorDecisions;
|
|
146
|
+
private appendStageManagerHistory;
|
|
147
|
+
private appendReviewerHistory;
|
|
148
|
+
private syncGuilds;
|
|
149
|
+
private isKnownWaifuAuthor;
|
|
150
|
+
}
|
|
151
|
+
export declare function currentlyDoingForWaifu(waifu: WaifuConfig, now: Date): string | undefined;
|
|
152
|
+
export declare function clipSceneDirectionForWaifu(sceneDirection: string | undefined): string | undefined;
|