@clawtopia/werewolf-evolution 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/README.md +68 -0
- package/dist/chunk-3A7SOBN4.js +2180 -0
- package/dist/index.d.ts +207 -0
- package/dist/index.js +1041 -0
- package/dist/setup.d.ts +53 -0
- package/dist/setup.js +638 -0
- package/openclaw.plugin.json +19 -0
- package/package.json +78 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { OpenClawPluginToolContext, OpenClawPluginDefinition, OpenClawPluginApi } from 'openclaw/plugin-sdk/core';
|
|
2
|
+
|
|
3
|
+
type FactVisibility = "PUBLIC" | "WOLF_TEAM" | `SEAT_${number}_ONLY` | "POSTGAME_ONLY";
|
|
4
|
+
interface DebriefFact {
|
|
5
|
+
factId: string;
|
|
6
|
+
anchor: string;
|
|
7
|
+
type: string;
|
|
8
|
+
visibility: FactVisibility;
|
|
9
|
+
availableAt: {
|
|
10
|
+
historyIndex: number;
|
|
11
|
+
round?: number;
|
|
12
|
+
phase?: string;
|
|
13
|
+
};
|
|
14
|
+
actorSeat?: number | null;
|
|
15
|
+
targetSeat?: number | null;
|
|
16
|
+
summary: string;
|
|
17
|
+
}
|
|
18
|
+
interface DecisionWindow {
|
|
19
|
+
decisionWindowId: string;
|
|
20
|
+
anchorFactId: string;
|
|
21
|
+
actorSeat: number;
|
|
22
|
+
actorRole: string;
|
|
23
|
+
phase: string;
|
|
24
|
+
actionType: string;
|
|
25
|
+
allowedDecisionTypes: string[];
|
|
26
|
+
availableActionTypes: string[];
|
|
27
|
+
availableTargetSeats?: number[];
|
|
28
|
+
}
|
|
29
|
+
interface DebriefEnvelope {
|
|
30
|
+
schemaVersion: 2;
|
|
31
|
+
debriefId: string;
|
|
32
|
+
game: {
|
|
33
|
+
gameId: string;
|
|
34
|
+
recipientAgentId: string;
|
|
35
|
+
recipientSeat: number;
|
|
36
|
+
reviewDate: string;
|
|
37
|
+
profile?: string;
|
|
38
|
+
normalEnd: boolean;
|
|
39
|
+
role: string;
|
|
40
|
+
team: string;
|
|
41
|
+
finalState: string;
|
|
42
|
+
result: string;
|
|
43
|
+
players: number;
|
|
44
|
+
systemHealthGate: "PASS" | "SKIP_REQUIRED";
|
|
45
|
+
timelineComplete: boolean;
|
|
46
|
+
voteConsistency: "CONSISTENT" | "INCONSISTENT" | "NOT_APPLICABLE";
|
|
47
|
+
};
|
|
48
|
+
facts: DebriefFact[];
|
|
49
|
+
decisionWindows: DecisionWindow[];
|
|
50
|
+
}
|
|
51
|
+
type ProposalAction = "SKIP" | "SUPPORT" | "COUNTER" | "REFINE" | "NEW";
|
|
52
|
+
type ProposalSource = "SELF" | "OBSERVED" | "EXEMPLAR";
|
|
53
|
+
type ExecutionOperation = "REPORT_DECIDED_ROLE_CLAIM" | "EXPLAIN_DECIDED_VOTE" | "RETRACT_PUBLIC_JUDGMENT" | "AVOID_REPEATING_PRIOR_SPEAKERS" | "EXPLAIN_DECIDED_WOLF_TARGET";
|
|
54
|
+
interface DebriefProposal {
|
|
55
|
+
schemaVersion: 1;
|
|
56
|
+
action: ProposalAction;
|
|
57
|
+
source: ProposalSource;
|
|
58
|
+
topicId?: string | null;
|
|
59
|
+
profile?: string;
|
|
60
|
+
decisionWindowId?: string;
|
|
61
|
+
decisionType?: string;
|
|
62
|
+
executionOperation?: ExecutionOperation;
|
|
63
|
+
alternativeActionType?: string;
|
|
64
|
+
alternativeTargetSeat?: number | null;
|
|
65
|
+
anchorFactId?: string;
|
|
66
|
+
knownFactRefs?: string[];
|
|
67
|
+
outcomeFactRefs?: string[];
|
|
68
|
+
trigger?: string;
|
|
69
|
+
rule?: string;
|
|
70
|
+
boundary?: string;
|
|
71
|
+
behavior?: string;
|
|
72
|
+
alternativeAction?: string;
|
|
73
|
+
expectedLocalEffect?: string;
|
|
74
|
+
observedLocalEffect?: string;
|
|
75
|
+
falsifier?: string;
|
|
76
|
+
alternatives?: string[];
|
|
77
|
+
skipReason?: string;
|
|
78
|
+
}
|
|
79
|
+
interface CapturedBase {
|
|
80
|
+
channelId: string;
|
|
81
|
+
accountId: string;
|
|
82
|
+
from: string;
|
|
83
|
+
sessionKey: string;
|
|
84
|
+
runId?: string;
|
|
85
|
+
conversationId?: string;
|
|
86
|
+
messageId?: string;
|
|
87
|
+
content: string;
|
|
88
|
+
capturedAt: number;
|
|
89
|
+
}
|
|
90
|
+
interface CapturedDebrief extends CapturedBase {
|
|
91
|
+
kind: "debrief";
|
|
92
|
+
bodyHash: string;
|
|
93
|
+
envelope: DebriefEnvelope;
|
|
94
|
+
conflict?: boolean;
|
|
95
|
+
}
|
|
96
|
+
interface CapturedSuggestionCommand extends CapturedBase {
|
|
97
|
+
kind: "suggestion-command";
|
|
98
|
+
suggestionId: string;
|
|
99
|
+
decision: "accept" | "reject";
|
|
100
|
+
}
|
|
101
|
+
type CapturedInbound = CapturedDebrief | CapturedSuggestionCommand;
|
|
102
|
+
interface BoundRun {
|
|
103
|
+
runId: string;
|
|
104
|
+
sessionKey: string;
|
|
105
|
+
agentId: string;
|
|
106
|
+
workspaceDir: string;
|
|
107
|
+
inbound: CapturedInbound;
|
|
108
|
+
senderId?: string;
|
|
109
|
+
senderIsOwner: boolean;
|
|
110
|
+
consumed: boolean;
|
|
111
|
+
boundAt: number;
|
|
112
|
+
expiresAt: number;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
interface MessageReceivedLike {
|
|
116
|
+
from: string;
|
|
117
|
+
content: string;
|
|
118
|
+
messageId?: string;
|
|
119
|
+
runId?: string;
|
|
120
|
+
}
|
|
121
|
+
interface MessageContextLike {
|
|
122
|
+
channelId: string;
|
|
123
|
+
accountId?: string;
|
|
124
|
+
sessionKey?: string;
|
|
125
|
+
runId?: string;
|
|
126
|
+
conversationId?: string;
|
|
127
|
+
}
|
|
128
|
+
interface AgentRunEventLike {
|
|
129
|
+
channelId?: string;
|
|
130
|
+
accountId?: string;
|
|
131
|
+
senderId?: string;
|
|
132
|
+
senderIsOwner?: boolean;
|
|
133
|
+
}
|
|
134
|
+
interface AgentAccountBinding {
|
|
135
|
+
channelId: string;
|
|
136
|
+
accountId: string;
|
|
137
|
+
platformAgentId: string;
|
|
138
|
+
}
|
|
139
|
+
interface AgentRunContextLike {
|
|
140
|
+
runId?: string;
|
|
141
|
+
sessionKey?: string;
|
|
142
|
+
agentId?: string;
|
|
143
|
+
workspaceDir?: string;
|
|
144
|
+
}
|
|
145
|
+
declare class EvolutionContextStore {
|
|
146
|
+
private readonly inboundByRun;
|
|
147
|
+
private readonly boundByRun;
|
|
148
|
+
private readonly hashByDebriefId;
|
|
149
|
+
private readonly toolCalls;
|
|
150
|
+
capture(event: MessageReceivedLike, ctx: MessageContextLike, now?: number): CapturedInbound | undefined;
|
|
151
|
+
bindAgentRun(event: AgentRunEventLike, ctx: AgentRunContextLike, binding: AgentAccountBinding | undefined, now?: number, explicitOwnerAuthorized?: boolean): BoundRun | undefined;
|
|
152
|
+
getBound(runId?: string, sessionKey?: string, now?: number): BoundRun | undefined;
|
|
153
|
+
consume(runId: string, sessionKey: string, now?: number): BoundRun;
|
|
154
|
+
authorizeToolCall(runId: string | undefined, sessionKey: string | undefined, toolCallId: string | undefined, now?: number): BoundRun;
|
|
155
|
+
consumeToolCall(toolCallId: string, sessionKey?: string, now?: number): BoundRun;
|
|
156
|
+
cleanup(now?: number): void;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
interface TransactionHooks {
|
|
160
|
+
afterRename?: (committedCount: number) => void;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
interface CommitInput {
|
|
164
|
+
debriefId: string;
|
|
165
|
+
proposal: DebriefProposal;
|
|
166
|
+
}
|
|
167
|
+
interface SuggestionDecisionInput {
|
|
168
|
+
suggestionId: string;
|
|
169
|
+
decision: "accept" | "reject";
|
|
170
|
+
}
|
|
171
|
+
interface PromptContextLike extends AgentRunContextLike {
|
|
172
|
+
}
|
|
173
|
+
declare class WerewolfEvolutionService {
|
|
174
|
+
readonly contexts: EvolutionContextStore;
|
|
175
|
+
private readonly version;
|
|
176
|
+
private readonly ordinaryDirectMessages;
|
|
177
|
+
private readonly ownerDirectRuns;
|
|
178
|
+
private readonly observedRuns;
|
|
179
|
+
constructor(version?: string);
|
|
180
|
+
captureMessage(event: MessageReceivedLike, ctx: MessageContextLike): void;
|
|
181
|
+
bindAgentRun(event: AgentRunEventLike, ctx: AgentRunContextLike, binding: AgentAccountBinding | undefined, explicitOwnerAuthorized?: boolean): void;
|
|
182
|
+
buildPromptContext(ctx: PromptContextLike): {
|
|
183
|
+
appendContext: string;
|
|
184
|
+
} | undefined;
|
|
185
|
+
beforeToolCall(event: {
|
|
186
|
+
toolName: string;
|
|
187
|
+
params: Record<string, unknown>;
|
|
188
|
+
derivedPaths?: readonly string[];
|
|
189
|
+
toolCallId?: string;
|
|
190
|
+
runId?: string;
|
|
191
|
+
toolKind?: "code_mode_exec";
|
|
192
|
+
}, ctx: {
|
|
193
|
+
sessionKey?: string;
|
|
194
|
+
runId?: string;
|
|
195
|
+
toolCallId?: string;
|
|
196
|
+
}): {
|
|
197
|
+
block?: boolean;
|
|
198
|
+
blockReason?: string;
|
|
199
|
+
} | undefined;
|
|
200
|
+
commit(toolCallId: string, ctx: OpenClawPluginToolContext, input: CommitInput, hooks?: TransactionHooks): Record<string, unknown>;
|
|
201
|
+
decideSuggestion(toolCallId: string, ctx: OpenClawPluginToolContext, input: SuggestionDecisionInput, hooks?: TransactionHooks): Record<string, unknown>;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
declare function registerWerewolfEvolution(api: OpenClawPluginApi, service?: WerewolfEvolutionService): void;
|
|
205
|
+
declare const entry: OpenClawPluginDefinition;
|
|
206
|
+
|
|
207
|
+
export { entry as default, registerWerewolfEvolution };
|