@kenkaiiii/ggcoder 4.3.198 → 4.3.200
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/dist/core/settings-manager.d.ts +0 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +0 -2
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/ui/App.d.ts +0 -1
- package/dist/ui/App.d.ts.map +1 -1
- package/dist/ui/App.js +2 -2
- package/dist/ui/App.js.map +1 -1
- package/dist/ui/components/ActivityIndicator.d.ts +5 -0
- package/dist/ui/components/ActivityIndicator.d.ts.map +1 -1
- package/dist/ui/components/ActivityIndicator.js +23 -13
- package/dist/ui/components/ActivityIndicator.js.map +1 -1
- package/dist/ui/components/ActivityIndicator.test.d.ts +2 -0
- package/dist/ui/components/ActivityIndicator.test.d.ts.map +1 -0
- package/dist/ui/components/ActivityIndicator.test.js +40 -0
- package/dist/ui/components/ActivityIndicator.test.js.map +1 -0
- package/dist/ui/components/AssistantMessage.js +1 -1
- package/dist/ui/components/AssistantMessage.js.map +1 -1
- package/dist/ui/components/StreamingArea.js +1 -1
- package/dist/ui/components/StreamingArea.js.map +1 -1
- package/dist/ui/components/index.d.ts +0 -1
- package/dist/ui/components/index.d.ts.map +1 -1
- package/dist/ui/components/index.js +0 -1
- package/dist/ui/components/index.js.map +1 -1
- package/dist/ui/render.d.ts +0 -1
- package/dist/ui/render.d.ts.map +1 -1
- package/dist/ui/render.js +0 -1
- package/dist/ui/render.js.map +1 -1
- package/package.json +6 -5
- package/dist/core/bridge-client.d.ts +0 -31
- package/dist/core/bridge-client.d.ts.map +0 -1
- package/dist/core/bridge-client.js +0 -124
- package/dist/core/bridge-client.js.map +0 -1
- package/dist/core/bridge-config.d.ts +0 -8
- package/dist/core/bridge-config.d.ts.map +0 -1
- package/dist/core/bridge-config.js +0 -52
- package/dist/core/bridge-config.js.map +0 -1
- package/dist/core/bridge-protocol.d.ts +0 -76
- package/dist/core/bridge-protocol.d.ts.map +0 -1
- package/dist/core/bridge-protocol.js +0 -30
- package/dist/core/bridge-protocol.js.map +0 -1
- package/dist/core/oauth/gemini.d.ts +0 -4
- package/dist/core/oauth/gemini.d.ts.map +0 -1
- package/dist/core/oauth/gemini.js +0 -293
- package/dist/core/oauth/gemini.js.map +0 -1
- package/dist/core/socket-server.d.ts +0 -15
- package/dist/core/socket-server.d.ts.map +0 -1
- package/dist/core/socket-server.js +0 -140
- package/dist/core/socket-server.js.map +0 -1
- package/dist/modes/bridge-mode.d.ts +0 -22
- package/dist/modes/bridge-mode.d.ts.map +0 -1
- package/dist/modes/bridge-mode.js +0 -281
- package/dist/modes/bridge-mode.js.map +0 -1
- package/dist/ui/buddy/Buddy.d.ts +0 -15
- package/dist/ui/buddy/Buddy.d.ts.map +0 -1
- package/dist/ui/buddy/Buddy.js +0 -118
- package/dist/ui/buddy/Buddy.js.map +0 -1
- package/dist/ui/buddy/gacha.d.ts +0 -8
- package/dist/ui/buddy/gacha.d.ts.map +0 -1
- package/dist/ui/buddy/gacha.js +0 -94
- package/dist/ui/buddy/gacha.js.map +0 -1
- package/dist/ui/buddy/species.d.ts +0 -52
- package/dist/ui/buddy/species.d.ts.map +0 -1
- package/dist/ui/buddy/species.js +0 -257
- package/dist/ui/buddy/species.js.map +0 -1
- package/dist/ui/components/ScrollableContent.d.ts +0 -22
- package/dist/ui/components/ScrollableContent.d.ts.map +0 -1
- package/dist/ui/components/ScrollableContent.js +0 -44
- package/dist/ui/components/ScrollableContent.js.map +0 -1
- package/dist/ui/components/ShimmerLine.d.ts +0 -6
- package/dist/ui/components/ShimmerLine.d.ts.map +0 -1
- package/dist/ui/components/ShimmerLine.js +0 -46
- package/dist/ui/components/ShimmerLine.js.map +0 -1
- package/dist/ui/components/SplashScreen.d.ts +0 -7
- package/dist/ui/components/SplashScreen.d.ts.map +0 -1
- package/dist/ui/components/SplashScreen.js +0 -113
- package/dist/ui/components/SplashScreen.js.map +0 -1
- package/dist/ui/components/ThinkingIndicator.d.ts +0 -6
- package/dist/ui/components/ThinkingIndicator.d.ts.map +0 -1
- package/dist/ui/components/ThinkingIndicator.js +0 -145
- package/dist/ui/components/ThinkingIndicator.js.map +0 -1
- package/dist/ui/hooks/useMouseScroll.d.ts.map +0 -1
- package/dist/ui/hooks/useMouseScroll.js.map +0 -1
- package/dist/ui/hooks/useScrollViewport.d.ts +0 -25
- package/dist/ui/hooks/useScrollViewport.d.ts.map +0 -1
- package/dist/ui/hooks/useScrollViewport.js +0 -32
- package/dist/ui/hooks/useScrollViewport.js.map +0 -1
- package/dist/ui/utils/item-heights.d.ts +0 -17
- package/dist/ui/utils/item-heights.d.ts.map +0 -1
- package/dist/ui/utils/item-heights.js +0 -73
- package/dist/ui/utils/item-heights.js.map +0 -1
- package/dist/ui/utils/scroll-pause.d.ts +0 -13
- package/dist/ui/utils/scroll-pause.d.ts.map +0 -1
- package/dist/ui/utils/sync-output.d.ts +0 -16
- package/dist/ui/utils/sync-output.d.ts.map +0 -1
- package/dist/ui/utils/sync-output.js +0 -70
- package/dist/ui/utils/sync-output.js.map +0 -1
- package/dist/utils/markdown.d.ts +0 -6
- package/dist/utils/markdown.d.ts.map +0 -1
- package/dist/utils/markdown.js +0 -25
- package/dist/utils/markdown.js.map +0 -1
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import crypto from "node:crypto";
|
|
3
|
-
import { isAbortError } from "@kenkaiiii/gg-agent";
|
|
4
|
-
import chalk from "chalk";
|
|
5
|
-
import { AgentSession } from "../core/agent-session.js";
|
|
6
|
-
import { BridgeClient } from "../core/bridge-client.js";
|
|
7
|
-
import { MessageType } from "../core/bridge-protocol.js";
|
|
8
|
-
import { formatUserError } from "../utils/error-handler.js";
|
|
9
|
-
import { log, closeLogger } from "../core/logger.js";
|
|
10
|
-
/**
|
|
11
|
-
* Bridge mode: run ggcoder as an Agent Home agent.
|
|
12
|
-
*
|
|
13
|
-
* Connects to the relay server via WebSocket and registers the current
|
|
14
|
-
* project directory as an agent. Messages from the iOS app are forwarded
|
|
15
|
-
* here, processed by AgentSession, and streamed back.
|
|
16
|
-
*/
|
|
17
|
-
export async function runBridgeMode(options) {
|
|
18
|
-
const agentId = crypto.createHash("sha256").update(options.cwd).digest("hex").slice(0, 16);
|
|
19
|
-
const agentName = options.agentName ?? path.basename(options.cwd);
|
|
20
|
-
const client = new BridgeClient(options.bridge.relayUrl, options.bridge.token);
|
|
21
|
-
client.setAgentIds([agentId]);
|
|
22
|
-
let session = null;
|
|
23
|
-
const ac = new AbortController();
|
|
24
|
-
let isProcessing = false;
|
|
25
|
-
let textBuffer = "";
|
|
26
|
-
let currentMessageId = "";
|
|
27
|
-
const activeTools = new Map();
|
|
28
|
-
// ── Session lifecycle ──────────────────────────────────
|
|
29
|
-
async function getOrCreateSession() {
|
|
30
|
-
if (session)
|
|
31
|
-
return session;
|
|
32
|
-
session = new AgentSession({
|
|
33
|
-
provider: options.provider,
|
|
34
|
-
model: options.model,
|
|
35
|
-
cwd: options.cwd,
|
|
36
|
-
thinkingLevel: options.thinkingLevel,
|
|
37
|
-
signal: ac.signal,
|
|
38
|
-
});
|
|
39
|
-
await session.initialize();
|
|
40
|
-
wireSessionEvents();
|
|
41
|
-
log("INFO", "bridge", `Session initialized`, { cwd: options.cwd });
|
|
42
|
-
return session;
|
|
43
|
-
}
|
|
44
|
-
// ── Agent → Relay bridge ───────────────────────────────
|
|
45
|
-
function wireSessionEvents() {
|
|
46
|
-
if (!session)
|
|
47
|
-
return;
|
|
48
|
-
session.eventBus.on("text_delta", ({ text }) => {
|
|
49
|
-
textBuffer += text;
|
|
50
|
-
// Stream tokens to relay
|
|
51
|
-
client.send({
|
|
52
|
-
id: BridgeClient.newId(),
|
|
53
|
-
type: MessageType.CHAT_STREAM,
|
|
54
|
-
timestamp: Date.now(),
|
|
55
|
-
agentId,
|
|
56
|
-
token: text,
|
|
57
|
-
messageId: currentMessageId,
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
session.eventBus.on("tool_call_start", ({ toolCallId, name, args }) => {
|
|
61
|
-
activeTools.set(toolCallId, { name, startTime: Date.now(), args });
|
|
62
|
-
const argsStr = formatArgs(args);
|
|
63
|
-
const token = `\n🔧 \`${name}\` ${argsStr}\n`;
|
|
64
|
-
client.send({
|
|
65
|
-
id: BridgeClient.newId(),
|
|
66
|
-
type: MessageType.CHAT_STREAM,
|
|
67
|
-
timestamp: Date.now(),
|
|
68
|
-
agentId,
|
|
69
|
-
token,
|
|
70
|
-
messageId: currentMessageId,
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
session.eventBus.on("tool_call_end", ({ toolCallId, isError, durationMs }) => {
|
|
74
|
-
const tool = activeTools.get(toolCallId);
|
|
75
|
-
activeTools.delete(toolCallId);
|
|
76
|
-
if (tool) {
|
|
77
|
-
const icon = isError ? "✗" : "✓";
|
|
78
|
-
const token = `${icon} \`${tool.name}\` ${formatDuration(durationMs)}\n`;
|
|
79
|
-
client.send({
|
|
80
|
-
id: BridgeClient.newId(),
|
|
81
|
-
type: MessageType.CHAT_STREAM,
|
|
82
|
-
timestamp: Date.now(),
|
|
83
|
-
agentId,
|
|
84
|
-
token,
|
|
85
|
-
messageId: currentMessageId,
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
session.eventBus.on("agent_done", () => {
|
|
90
|
-
const content = textBuffer.trim();
|
|
91
|
-
client.send({
|
|
92
|
-
id: BridgeClient.newId(),
|
|
93
|
-
type: MessageType.CHAT_STREAM_END,
|
|
94
|
-
timestamp: Date.now(),
|
|
95
|
-
agentId,
|
|
96
|
-
messageId: currentMessageId,
|
|
97
|
-
content,
|
|
98
|
-
});
|
|
99
|
-
textBuffer = "";
|
|
100
|
-
isProcessing = false;
|
|
101
|
-
currentMessageId = "";
|
|
102
|
-
log("INFO", "bridge", `Agent done`);
|
|
103
|
-
});
|
|
104
|
-
session.eventBus.on("error", ({ error }) => {
|
|
105
|
-
const content = textBuffer.trim() + `\n\n✗ Error: ${error.message}`;
|
|
106
|
-
client.send({
|
|
107
|
-
id: BridgeClient.newId(),
|
|
108
|
-
type: MessageType.CHAT_STREAM_END,
|
|
109
|
-
timestamp: Date.now(),
|
|
110
|
-
agentId,
|
|
111
|
-
messageId: currentMessageId,
|
|
112
|
-
content,
|
|
113
|
-
});
|
|
114
|
-
textBuffer = "";
|
|
115
|
-
isProcessing = false;
|
|
116
|
-
currentMessageId = "";
|
|
117
|
-
});
|
|
118
|
-
session.eventBus.on("compaction_end", ({ originalCount, newCount }) => {
|
|
119
|
-
const token = `\n✓ Compacted — ${originalCount} → ${newCount} messages\n`;
|
|
120
|
-
client.send({
|
|
121
|
-
id: BridgeClient.newId(),
|
|
122
|
-
type: MessageType.CHAT_STREAM,
|
|
123
|
-
timestamp: Date.now(),
|
|
124
|
-
agentId,
|
|
125
|
-
token,
|
|
126
|
-
messageId: currentMessageId,
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
// ── Handle incoming messages ───────────────────────────
|
|
131
|
-
client.on(MessageType.CHAT_FORWARD, async (msg) => {
|
|
132
|
-
const forward = msg;
|
|
133
|
-
if (forward.agentId !== agentId)
|
|
134
|
-
return;
|
|
135
|
-
if (isProcessing) {
|
|
136
|
-
client.send({
|
|
137
|
-
id: BridgeClient.newId(),
|
|
138
|
-
type: MessageType.CHAT_STREAM_END,
|
|
139
|
-
timestamp: Date.now(),
|
|
140
|
-
agentId,
|
|
141
|
-
messageId: BridgeClient.newId(),
|
|
142
|
-
content: "Agent is busy processing a previous message. Please wait.",
|
|
143
|
-
});
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
isProcessing = true;
|
|
147
|
-
textBuffer = "";
|
|
148
|
-
activeTools.clear();
|
|
149
|
-
currentMessageId = BridgeClient.newId();
|
|
150
|
-
console.log(chalk.hex("#60a5fa")(` ← ${forward.content.slice(0, 80)}${forward.content.length > 80 ? "..." : ""}`));
|
|
151
|
-
try {
|
|
152
|
-
const s = await getOrCreateSession();
|
|
153
|
-
await s.prompt(forward.content);
|
|
154
|
-
}
|
|
155
|
-
catch (err) {
|
|
156
|
-
if (!isAbortError(err)) {
|
|
157
|
-
const content = `Error: ${formatUserError(err)}`;
|
|
158
|
-
client.send({
|
|
159
|
-
id: BridgeClient.newId(),
|
|
160
|
-
type: MessageType.CHAT_STREAM_END,
|
|
161
|
-
timestamp: Date.now(),
|
|
162
|
-
agentId,
|
|
163
|
-
messageId: currentMessageId,
|
|
164
|
-
content,
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
isProcessing = false;
|
|
168
|
-
currentMessageId = "";
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
// ── Connect and register ───────────────────────────────
|
|
172
|
-
client.onConnect(() => {
|
|
173
|
-
client.send({
|
|
174
|
-
id: BridgeClient.newId(),
|
|
175
|
-
type: MessageType.AGENT_REGISTER,
|
|
176
|
-
timestamp: Date.now(),
|
|
177
|
-
agent: {
|
|
178
|
-
id: agentId,
|
|
179
|
-
name: agentName,
|
|
180
|
-
description: `GG Coder agent — ${options.cwd}`,
|
|
181
|
-
capabilities: ["chat"],
|
|
182
|
-
},
|
|
183
|
-
});
|
|
184
|
-
console.log(chalk.hex("#4ade80")(" Connected to relay"));
|
|
185
|
-
console.log(chalk.hex("#6b7280")(` Agent registered: ${agentName} (${agentId})`));
|
|
186
|
-
});
|
|
187
|
-
client.onDisconnect(() => {
|
|
188
|
-
console.log(chalk.hex("#f59e0b")(" Disconnected from relay — reconnecting..."));
|
|
189
|
-
});
|
|
190
|
-
// ── Display banner ─────────────────────────────────────
|
|
191
|
-
process.stdout.write("\x1b[2J\x1b[3J\x1b[H");
|
|
192
|
-
const LOGO = [
|
|
193
|
-
" \u2584\u2580\u2580\u2580 \u2584\u2580\u2580\u2580",
|
|
194
|
-
" \u2588 \u2580\u2588 \u2588 \u2580\u2588",
|
|
195
|
-
" \u2580\u2584\u2584\u2580 \u2580\u2584\u2584\u2580",
|
|
196
|
-
];
|
|
197
|
-
const GRADIENT = [
|
|
198
|
-
"#60a5fa",
|
|
199
|
-
"#6da1f9",
|
|
200
|
-
"#7a9df7",
|
|
201
|
-
"#8799f5",
|
|
202
|
-
"#9495f3",
|
|
203
|
-
"#a18ff1",
|
|
204
|
-
"#a78bfa",
|
|
205
|
-
"#a18ff1",
|
|
206
|
-
"#9495f3",
|
|
207
|
-
"#8799f5",
|
|
208
|
-
"#7a9df7",
|
|
209
|
-
"#6da1f9",
|
|
210
|
-
];
|
|
211
|
-
function gradientText(text) {
|
|
212
|
-
let colorIdx = 0;
|
|
213
|
-
return text
|
|
214
|
-
.split("")
|
|
215
|
-
.map((ch) => {
|
|
216
|
-
if (ch === " ")
|
|
217
|
-
return ch;
|
|
218
|
-
const color = GRADIENT[colorIdx++ % GRADIENT.length];
|
|
219
|
-
return chalk.hex(color)(ch);
|
|
220
|
-
})
|
|
221
|
-
.join("");
|
|
222
|
-
}
|
|
223
|
-
const home = process.env.HOME ?? "";
|
|
224
|
-
const displayPath = home && options.cwd.startsWith(home) ? "~" + options.cwd.slice(home.length) : options.cwd;
|
|
225
|
-
const GAP = " ";
|
|
226
|
-
console.log();
|
|
227
|
-
console.log(` ${gradientText(LOGO[0])}${GAP}` +
|
|
228
|
-
chalk.hex("#60a5fa").bold("GG Coder") +
|
|
229
|
-
chalk.hex("#6b7280")(` v${options.version}`) +
|
|
230
|
-
chalk.hex("#6b7280")(" · By ") +
|
|
231
|
-
chalk.white.bold("Ken Kai"));
|
|
232
|
-
console.log(` ${gradientText(LOGO[1])}${GAP}` + chalk.hex("#a78bfa")(agentName));
|
|
233
|
-
console.log(` ${gradientText(LOGO[2])}${GAP}` + chalk.hex("#6b7280")(displayPath));
|
|
234
|
-
console.log();
|
|
235
|
-
console.log(chalk.hex("#6b7280")(" Mode ") +
|
|
236
|
-
chalk.hex("#a78bfa")("Agent Home Bridge") +
|
|
237
|
-
chalk.hex("#6b7280")(" · Agent ") +
|
|
238
|
-
chalk.white(agentName));
|
|
239
|
-
console.log();
|
|
240
|
-
console.log(chalk.hex("#6b7280")(" Connecting to relay..."));
|
|
241
|
-
console.log();
|
|
242
|
-
// ── Start connection ───────────────────────────────────
|
|
243
|
-
client.connect();
|
|
244
|
-
// ── Graceful shutdown ──────────────────────────────────
|
|
245
|
-
const shutdown = async () => {
|
|
246
|
-
console.log("\nShutting down...");
|
|
247
|
-
client.send({
|
|
248
|
-
id: BridgeClient.newId(),
|
|
249
|
-
type: MessageType.AGENT_UNREGISTER,
|
|
250
|
-
timestamp: Date.now(),
|
|
251
|
-
agentId,
|
|
252
|
-
});
|
|
253
|
-
client.disconnect();
|
|
254
|
-
if (session) {
|
|
255
|
-
ac.abort();
|
|
256
|
-
await session.dispose();
|
|
257
|
-
}
|
|
258
|
-
closeLogger();
|
|
259
|
-
process.exit(0);
|
|
260
|
-
};
|
|
261
|
-
process.on("SIGINT", shutdown);
|
|
262
|
-
process.on("SIGTERM", shutdown);
|
|
263
|
-
// Keep the process alive
|
|
264
|
-
await new Promise(() => { });
|
|
265
|
-
}
|
|
266
|
-
// ── Helpers ───────────────────────────────────────────────
|
|
267
|
-
function formatArgs(args) {
|
|
268
|
-
const entries = Object.entries(args);
|
|
269
|
-
if (entries.length === 0)
|
|
270
|
-
return "";
|
|
271
|
-
const [_key, value] = entries[0];
|
|
272
|
-
const str = typeof value === "string" ? value : JSON.stringify(value);
|
|
273
|
-
const truncated = str.length > 60 ? str.slice(0, 57) + "..." : str;
|
|
274
|
-
return `\`${truncated}\``;
|
|
275
|
-
}
|
|
276
|
-
function formatDuration(ms) {
|
|
277
|
-
if (ms < 1000)
|
|
278
|
-
return `${ms}ms`;
|
|
279
|
-
return `${(ms / 1000).toFixed(1)}s`;
|
|
280
|
-
}
|
|
281
|
-
//# sourceMappingURL=bridge-mode.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bridge-mode.js","sourceRoot":"","sources":["../../src/modes/bridge-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,cAAc,CAAC,EAAU;IAChC,IAAI,EAAE,GAAG,IAAI;QAAE,OAAO,GAAG,EAAE,IAAI,CAAC;IAChC,OAAO,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;AACtC,CAAC"}
|
package/dist/ui/buddy/Buddy.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { ActivityPhase } from "../hooks/useAgentLoop.js";
|
|
2
|
-
interface BuddyProps {
|
|
3
|
-
phase?: ActivityPhase;
|
|
4
|
-
/** Speech bubble text to display. */
|
|
5
|
-
reaction?: string;
|
|
6
|
-
/** Timestamp of last /buddy pet command. */
|
|
7
|
-
petAt?: number;
|
|
8
|
-
/** Callback to clear reaction after display. */
|
|
9
|
-
onReactionDone?: () => void;
|
|
10
|
-
}
|
|
11
|
-
export declare function Buddy({ phase, reaction, petAt, onReactionDone }: BuddyProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
-
/** How many columns the buddy sprite area reserves. */
|
|
13
|
-
export declare function companionReservedColumns(): number;
|
|
14
|
-
export {};
|
|
15
|
-
//# sourceMappingURL=Buddy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Buddy.d.ts","sourceRoot":"","sources":["../../../src/ui/buddy/Buddy.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAgF9D,UAAU,UAAU;IAClB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,qCAAqC;IACrC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gDAAgD;IAChD,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED,wBAAgB,KAAK,CAAC,EAAE,KAAc,EAAE,QAAQ,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE,UAAU,2CA2GpF;AAED,uDAAuD;AACvD,wBAAgB,wBAAwB,IAAI,MAAM,CAEjD"}
|
package/dist/ui/buddy/Buddy.js
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import React, { useState, useEffect, useMemo, useRef } from "react";
|
|
3
|
-
import { Text, Box } from "ink";
|
|
4
|
-
import { getPlayerBuddy } from "./gacha.js";
|
|
5
|
-
import { renderSprite, renderBlink, renderFace, spriteFrameCount, RARITY_THEME_KEYS, RARITY_STARS, } from "./species.js";
|
|
6
|
-
import { useTheme } from "../theme/theme.js";
|
|
7
|
-
import { useAnimationTick, useAnimationActive, deriveFrame, useReducedMotion, } from "../components/AnimationContext.js";
|
|
8
|
-
import { useTerminalSize } from "../hooks/useTerminalSize.js";
|
|
9
|
-
// ── Constants (matching Claude Code) ─────────────────────────
|
|
10
|
-
const TICK_MS = 500;
|
|
11
|
-
const IDLE_SEQUENCE = [0, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 2, 0, 0, 0];
|
|
12
|
-
const MIN_COLS_FOR_FULL_SPRITE = 100;
|
|
13
|
-
const BUBBLE_SHOW = 20; // ticks (~10s)
|
|
14
|
-
const FADE_WINDOW = 6; // ticks (~3s fade before dismiss)
|
|
15
|
-
const PET_BURST_MS = 2500;
|
|
16
|
-
const PET_HEARTS = [
|
|
17
|
-
" \u2665 \u2665 ",
|
|
18
|
-
" \u2665 \u2665 \u2665 ",
|
|
19
|
-
" \u2665 \u2665 \u2665 ",
|
|
20
|
-
" \u2665 \u2665 \u2665 ",
|
|
21
|
-
" \u2665 \u2665 ",
|
|
22
|
-
];
|
|
23
|
-
// ── Speech Bubble ────────────────────────────────────────────
|
|
24
|
-
function SpeechBubble({ text, color, fading }) {
|
|
25
|
-
// Wrap to 30 chars max
|
|
26
|
-
const maxWidth = 30;
|
|
27
|
-
const words = text.split(" ");
|
|
28
|
-
const lines = [];
|
|
29
|
-
let current = "";
|
|
30
|
-
for (const word of words) {
|
|
31
|
-
if (current.length + word.length + 1 > maxWidth && current.length > 0) {
|
|
32
|
-
lines.push(current);
|
|
33
|
-
current = word;
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
current = current ? `${current} ${word}` : word;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
if (current)
|
|
40
|
-
lines.push(current);
|
|
41
|
-
const width = Math.max(...lines.map((l) => l.length), 1);
|
|
42
|
-
const top = "\u256D" + "\u2500".repeat(width + 2) + "\u256E";
|
|
43
|
-
const bottom = "\u2570" + "\u2500".repeat(width + 2) + "\u256F";
|
|
44
|
-
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { color: color, dimColor: fading, children: top }), lines.map((line, i) => (_jsxs(Text, { color: color, dimColor: fading, children: ["\u2502 ", line.padEnd(width), " \u2502"] }, i))), _jsx(Text, { color: color, dimColor: fading, children: bottom }), _jsx(Text, { color: color, dimColor: fading, children: " \\" })] }));
|
|
45
|
-
}
|
|
46
|
-
// ── Resolve rarity color from theme ──────────────────────────
|
|
47
|
-
function getRarityColor(rarity, theme) {
|
|
48
|
-
const key = RARITY_THEME_KEYS[rarity] ?? "textDim";
|
|
49
|
-
return theme[key] ?? theme.textDim;
|
|
50
|
-
}
|
|
51
|
-
export function Buddy({ phase = "idle", reaction, petAt, onReactionDone }) {
|
|
52
|
-
const theme = useTheme();
|
|
53
|
-
const reducedMotion = useReducedMotion();
|
|
54
|
-
const { columns } = useTerminalSize();
|
|
55
|
-
useAnimationActive();
|
|
56
|
-
const tick = useAnimationTick();
|
|
57
|
-
const buddy = useMemo(() => getPlayerBuddy(), []);
|
|
58
|
-
const color = getRarityColor(buddy.rarity, theme);
|
|
59
|
-
const shinyColor = "#fef08a";
|
|
60
|
-
const displayColor = buddy.isShiny ? shinyColor : color;
|
|
61
|
-
// ── Speech bubble state ──────────────────────────────────
|
|
62
|
-
const [bubbleText, setBubbleText] = useState(null);
|
|
63
|
-
const bubbleTickRef = useRef(0);
|
|
64
|
-
const lastReactionRef = useRef(undefined);
|
|
65
|
-
useEffect(() => {
|
|
66
|
-
if (reaction && reaction !== lastReactionRef.current) {
|
|
67
|
-
lastReactionRef.current = reaction;
|
|
68
|
-
setBubbleText(reaction);
|
|
69
|
-
bubbleTickRef.current = 0;
|
|
70
|
-
}
|
|
71
|
-
}, [reaction]);
|
|
72
|
-
// Advance bubble timer
|
|
73
|
-
useEffect(() => {
|
|
74
|
-
if (!bubbleText)
|
|
75
|
-
return;
|
|
76
|
-
bubbleTickRef.current++;
|
|
77
|
-
if (bubbleTickRef.current >= BUBBLE_SHOW) {
|
|
78
|
-
setBubbleText(null);
|
|
79
|
-
onReactionDone?.();
|
|
80
|
-
}
|
|
81
|
-
}, [tick, bubbleText, onReactionDone]);
|
|
82
|
-
const bubbleFading = bubbleText ? bubbleTickRef.current >= BUBBLE_SHOW - FADE_WINDOW : false;
|
|
83
|
-
// ── Pet hearts state ─────────────────────────────────────
|
|
84
|
-
const showHearts = petAt ? Date.now() - petAt < PET_BURST_MS : false;
|
|
85
|
-
const heartFrame = showHearts ? deriveFrame(tick, TICK_MS, PET_HEARTS.length) : -1;
|
|
86
|
-
// ── Animation ────────────────────────────────────────────
|
|
87
|
-
const seqIdx = deriveFrame(tick, TICK_MS, IDLE_SEQUENCE.length);
|
|
88
|
-
const seqValue = IDLE_SEQUENCE[seqIdx];
|
|
89
|
-
const frameCount = spriteFrameCount(buddy.species);
|
|
90
|
-
const isActive = phase !== "idle";
|
|
91
|
-
let spriteLines;
|
|
92
|
-
if (reducedMotion) {
|
|
93
|
-
spriteLines = renderSprite(buddy, 0);
|
|
94
|
-
}
|
|
95
|
-
else if (showHearts || isActive) {
|
|
96
|
-
// Cycle all frames fast when petting or active
|
|
97
|
-
spriteLines = renderSprite(buddy, tick % frameCount);
|
|
98
|
-
}
|
|
99
|
-
else if (seqValue === -1) {
|
|
100
|
-
spriteLines = renderBlink(buddy);
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
spriteLines = renderSprite(buddy, seqValue);
|
|
104
|
-
}
|
|
105
|
-
// ── Narrow mode ──────────────────────────────────────────
|
|
106
|
-
if (columns < MIN_COLS_FOR_FULL_SPRITE) {
|
|
107
|
-
const face = renderFace(buddy);
|
|
108
|
-
const stars = RARITY_STARS[buddy.rarity];
|
|
109
|
-
return (_jsxs(Box, { children: [_jsxs(Text, { color: displayColor, children: [face, " ", buddy.species] }), _jsxs(Text, { color: displayColor, dimColor: true, children: [" ", stars, buddy.isShiny ? " \u2726" : ""] }), bubbleText && (_jsxs(Text, { color: displayColor, dimColor: bubbleFading, children: [' "', bubbleText.length > 24 ? bubbleText.slice(0, 21) + "..." : bubbleText, '"'] }))] }));
|
|
110
|
-
}
|
|
111
|
-
// ── Wide mode: full sprite ───────────────────────────────
|
|
112
|
-
return (_jsxs(Box, { flexDirection: "row", gap: 1, children: [_jsxs(Box, { flexDirection: "column", children: [showHearts && heartFrame >= 0 && _jsx(Text, { color: "#f87171", children: PET_HEARTS[heartFrame] }), spriteLines.map((line, i) => (_jsx(Text, { color: displayColor, children: line }, i))), _jsxs(Text, { color: displayColor, dimColor: true, children: [buddy.species, buddy.isShiny ? " \u2726" : ""] })] }), bubbleText && (_jsx(Box, { children: _jsx(SpeechBubble, { text: bubbleText, color: displayColor, fading: bubbleFading }) }))] }));
|
|
113
|
-
}
|
|
114
|
-
/** How many columns the buddy sprite area reserves. */
|
|
115
|
-
export function companionReservedColumns() {
|
|
116
|
-
return 14; // 12 char sprite + 2 gap
|
|
117
|
-
}
|
|
118
|
-
//# sourceMappingURL=Buddy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Buddy.js","sourceRoot":"","sources":["../../../src/ui/buddy/Buddy.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACpE,OAAO,EAAE,IAAI,EA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;IAC5D,OAAO,CACL,MAAC,GAAG,IAAC,aAAa,EAAC,KAAK,EAAC,GAAG,EAAE,CAAC,aAC7B,MAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,aACxB,UAAU,IAAI,UAAU,IAAI,CAAC,IAAI,KAAC,IAAI,IAAC,KAAK,EAAC,SAAS,YAAE,UAAU,CAAC,UAAU,CAAC,GAAQ,EACtF,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAC5B,KAAC,IAAI,IAAS,KAAK,EAAE,YAAY,YAC9B,IAAI,IADI,CAAC,CAEL,CACR,CAAC,EACF,MAAC,IAAI,IAAC,KAAK,EAAE,YAAY,EAAE,QAAQ,mBAChC,KAAK,CAAC,OAAO,EACb,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,IAC1B,IACH,EACL,UAAU,IAAI,CACb,KAAC,GAAG,cACF,KAAC,YAAY,IAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,GAAI,GACzE,CACP,IACG,CACP,CAAC;AACJ,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,wBAAwB;IACtC,OAAO,EAAE,CAAC,CAAC,yBAAyB;AACtC,CAAC"}
|
package/dist/ui/buddy/gacha.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type CompanionBones } from "./species.js";
|
|
2
|
-
/**
|
|
3
|
-
* Get the user's deterministic buddy companion.
|
|
4
|
-
* Same machine always gets the same species, eyes, hat, stats.
|
|
5
|
-
* Result is cached for hot paths (500ms sprite tick).
|
|
6
|
-
*/
|
|
7
|
-
export declare function getPlayerBuddy(): CompanionBones;
|
|
8
|
-
//# sourceMappingURL=gacha.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gacha.d.ts","sourceRoot":"","sources":["../../../src/ui/buddy/gacha.ts"],"names":[],"mappings":"AACA,OAAO,EAML,KAAK,cAAc,EAIpB,MAAM,cAAc,CAAC;AAiFtB;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,cAAc,CAoB/C"}
|
package/dist/ui/buddy/gacha.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { hostname, userInfo, homedir } from "node:os";
|
|
2
|
-
import { ALL_SPECIES, SPECIES_RARITY, RARITY_WEIGHTS, RARITY_STAT_FLOORS, EYE_STYLES, } from "./species.js";
|
|
3
|
-
// ── FNV-1a hash ──────────────────────────────────────────────
|
|
4
|
-
function fnv1a(str) {
|
|
5
|
-
let hash = 0x811c9dc5;
|
|
6
|
-
for (let i = 0; i < str.length; i++) {
|
|
7
|
-
hash ^= str.charCodeAt(i);
|
|
8
|
-
hash = Math.imul(hash, 0x01000193);
|
|
9
|
-
}
|
|
10
|
-
return hash >>> 0;
|
|
11
|
-
}
|
|
12
|
-
// ── Mulberry32 PRNG ──────────────────────────────────────────
|
|
13
|
-
function mulberry32(seed) {
|
|
14
|
-
let s = seed | 0;
|
|
15
|
-
return () => {
|
|
16
|
-
s = (s + 0x6d2b79f5) | 0;
|
|
17
|
-
let t = Math.imul(s ^ (s >>> 15), 1 | s);
|
|
18
|
-
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
|
|
19
|
-
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
// ── Seed ─────────────────────────────────────────────────────
|
|
23
|
-
function getUserSeed() {
|
|
24
|
-
const identity = `${hostname()}:${userInfo().username}:${homedir()}:friend-2026-401`;
|
|
25
|
-
return fnv1a(identity);
|
|
26
|
-
}
|
|
27
|
-
// ── Roll helpers ─────────────────────────────────────────────
|
|
28
|
-
function rollRarity(rand) {
|
|
29
|
-
const roll = rand * 100;
|
|
30
|
-
let cumulative = 0;
|
|
31
|
-
for (const [rarity, weight] of RARITY_WEIGHTS) {
|
|
32
|
-
cumulative += weight;
|
|
33
|
-
if (roll < cumulative)
|
|
34
|
-
return rarity;
|
|
35
|
-
}
|
|
36
|
-
return "common";
|
|
37
|
-
}
|
|
38
|
-
function rollStats(rng, rarity) {
|
|
39
|
-
const floor = RARITY_STAT_FLOORS[rarity];
|
|
40
|
-
const keys = ["debugging", "patience", "chaos", "wisdom", "snark"];
|
|
41
|
-
const peakIdx = Math.floor(rng() * keys.length);
|
|
42
|
-
let dumpIdx = Math.floor(rng() * keys.length);
|
|
43
|
-
while (dumpIdx === peakIdx)
|
|
44
|
-
dumpIdx = Math.floor(rng() * keys.length);
|
|
45
|
-
const stats = { debugging: 0, patience: 0, chaos: 0, wisdom: 0, snark: 0 };
|
|
46
|
-
for (let i = 0; i < keys.length; i++) {
|
|
47
|
-
const key = keys[i];
|
|
48
|
-
if (i === peakIdx) {
|
|
49
|
-
stats[key] = Math.min(100, 50 + Math.floor(rng() * 30) + floor);
|
|
50
|
-
}
|
|
51
|
-
else if (i === dumpIdx) {
|
|
52
|
-
stats[key] = Math.max(1, -10 + Math.floor(rng() * 15) + floor);
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
stats[key] = floor + Math.floor(rng() * 40);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return stats;
|
|
59
|
-
}
|
|
60
|
-
// ── Main roll (cached) ───────────────────────────────────────
|
|
61
|
-
const HATS = [
|
|
62
|
-
"none",
|
|
63
|
-
"crown",
|
|
64
|
-
"tophat",
|
|
65
|
-
"propeller",
|
|
66
|
-
"halo",
|
|
67
|
-
"wizard",
|
|
68
|
-
"beanie",
|
|
69
|
-
"tinyduck",
|
|
70
|
-
];
|
|
71
|
-
let rollCache = null;
|
|
72
|
-
/**
|
|
73
|
-
* Get the user's deterministic buddy companion.
|
|
74
|
-
* Same machine always gets the same species, eyes, hat, stats.
|
|
75
|
-
* Result is cached for hot paths (500ms sprite tick).
|
|
76
|
-
*/
|
|
77
|
-
export function getPlayerBuddy() {
|
|
78
|
-
if (rollCache)
|
|
79
|
-
return rollCache;
|
|
80
|
-
const seed = getUserSeed();
|
|
81
|
-
const rng = mulberry32(seed);
|
|
82
|
-
const rarity = rollRarity(rng());
|
|
83
|
-
// Pick species from this rarity tier
|
|
84
|
-
const candidates = ALL_SPECIES.filter((s) => SPECIES_RARITY[s] === rarity);
|
|
85
|
-
const speciesIdx = Math.floor(rng() * candidates.length);
|
|
86
|
-
const species = candidates[speciesIdx];
|
|
87
|
-
const eyes = EYE_STYLES[Math.floor(rng() * EYE_STYLES.length)];
|
|
88
|
-
const hat = rarity === "common" ? "none" : HATS[Math.floor(rng() * HATS.length)];
|
|
89
|
-
const stats = rollStats(rng, rarity);
|
|
90
|
-
const isShiny = rng() < 0.01;
|
|
91
|
-
rollCache = { species, eyes, hat, stats, isShiny, rarity };
|
|
92
|
-
return rollCache;
|
|
93
|
-
}
|
|
94
|
-
//# sourceMappingURL=gacha.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gacha.js","sourceRoot":"","sources":["../../../src/ui/buddy/gacha.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EACL,WAAW,EACX,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,UAAU,GAKX,MAAM,cAAc,CAAC;AAEtB,gEAAgE;AAEhE,SAAS,KAAK,CAAC,GAAW;IACxB,IAAI,IAAI,GAAG,UAAU,CAAC;IACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACpC,IAAI,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAC1B,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,IAAI,KAAK,CAAC,CAAC;AACpB,CAAC;AAED,gEAAg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,CAAC;IAE7B,SAAS,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAC3D,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Buddy companion species definitions.
|
|
3
|
-
*
|
|
4
|
-
* Each species has ASCII art frames (5 lines tall, 12 chars wide),
|
|
5
|
-
* eye placeholder {E} for expression variants, and a rarity tier.
|
|
6
|
-
* Matches Claude Code's buddy system architecture.
|
|
7
|
-
*
|
|
8
|
-
* Line 0 is the hat slot — left blank so hats can overlay it.
|
|
9
|
-
* {E} is replaced with the companion's eye character at render time.
|
|
10
|
-
* Blink replaces {E} with "-" rather than using separate frames.
|
|
11
|
-
*/
|
|
12
|
-
export type Rarity = "common" | "uncommon" | "rare" | "epic" | "legendary";
|
|
13
|
-
export type EyeStyle = "\u00B7" | "\u2726" | "\u00D7" | "\u25C9" | "@" | "\u00B0";
|
|
14
|
-
export type Hat = "none" | "crown" | "tophat" | "propeller" | "halo" | "wizard" | "beanie" | "tinyduck";
|
|
15
|
-
export type Species = "duck" | "goose" | "blob" | "cat" | "dragon" | "octopus" | "owl" | "penguin" | "turtle" | "snail" | "ghost" | "axolotl" | "capybara" | "cactus" | "robot" | "rabbit" | "mushroom" | "chonk" | "phoenix";
|
|
16
|
-
/** Hat art for line 0 (replaces blank first line when hat present). */
|
|
17
|
-
export declare const HAT_LINES: Record<Hat, string>;
|
|
18
|
-
export interface CompanionStats {
|
|
19
|
-
debugging: number;
|
|
20
|
-
patience: number;
|
|
21
|
-
chaos: number;
|
|
22
|
-
wisdom: number;
|
|
23
|
-
snark: number;
|
|
24
|
-
}
|
|
25
|
-
export declare const RARITY_WEIGHTS: [Rarity, number][];
|
|
26
|
-
export declare const RARITY_STAT_FLOORS: Record<Rarity, number>;
|
|
27
|
-
export declare const RARITY_STARS: Record<Rarity, string>;
|
|
28
|
-
export declare const RARITY_THEME_KEYS: Record<Rarity, string>;
|
|
29
|
-
export declare const BODIES: Record<Species, string[][]>;
|
|
30
|
-
/** All species names. */
|
|
31
|
-
export declare const ALL_SPECIES: Species[];
|
|
32
|
-
/** Species rarity mapping. */
|
|
33
|
-
export declare const SPECIES_RARITY: Record<Species, Rarity>;
|
|
34
|
-
/** All available eye styles. */
|
|
35
|
-
export declare const EYE_STYLES: EyeStyle[];
|
|
36
|
-
export interface CompanionBones {
|
|
37
|
-
species: Species;
|
|
38
|
-
eyes: EyeStyle;
|
|
39
|
-
hat: Hat;
|
|
40
|
-
stats: CompanionStats;
|
|
41
|
-
isShiny: boolean;
|
|
42
|
-
rarity: Rarity;
|
|
43
|
-
}
|
|
44
|
-
/** Render sprite lines with eyes and hat applied. */
|
|
45
|
-
export declare function renderSprite(bones: CompanionBones, frame: number): string[];
|
|
46
|
-
/** Render blink frame (eyes replaced with -). */
|
|
47
|
-
export declare function renderBlink(bones: CompanionBones): string[];
|
|
48
|
-
/** Compact one-line face for narrow terminals. */
|
|
49
|
-
export declare function renderFace(bones: CompanionBones): string;
|
|
50
|
-
/** Number of animation frames for a species (always 3). */
|
|
51
|
-
export declare function spriteFrameCount(_species: Species): number;
|
|
52
|
-
//# sourceMappingURL=species.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"species.d.ts","sourceRoot":"","sources":["../../../src/ui/buddy/species.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,MAAM,MAAM,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,WAAW,CAAC;AAE3E,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,GAAG,GAAG,QAAQ,CAAC;AAElF,MAAM,MAAM,GAAG,GACX,MAAM,GACN,OAAO,GACP,QAAQ,GACR,WAAW,GACX,MAAM,GACN,QAAQ,GACR,QAAQ,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