Skip to content

Commit 232c512

Browse files
grp06steipete
authored andcommitted
Format: apply oxfmt fixes
1 parent 8c1e6a8 commit 232c512

File tree

14 files changed

+200
-232
lines changed

14 files changed

+200
-232
lines changed

src/agents/google-gemini-switch.live.test.ts

Lines changed: 59 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -2,82 +2,77 @@ import { completeSimple, getModel } from "@mariozechner/pi-ai";
22
import { describe, expect, it } from "vitest";
33

44
const GEMINI_KEY = process.env.GEMINI_API_KEY ?? "";
5-
const LIVE =
6-
process.env.GEMINI_LIVE_TEST === "1" || process.env.LIVE === "1";
5+
const LIVE = process.env.GEMINI_LIVE_TEST === "1" || process.env.LIVE === "1";
76

87
const describeLive = LIVE && GEMINI_KEY ? describe : describe.skip;
98

109
describeLive("gemini live switch", () => {
11-
it(
12-
"handles unsigned tool calls from Antigravity when switching to Gemini 3",
13-
async () => {
14-
const now = Date.now();
15-
const model = getModel("google", "gemini-3-pro-preview");
10+
it("handles unsigned tool calls from Antigravity when switching to Gemini 3", async () => {
11+
const now = Date.now();
12+
const model = getModel("google", "gemini-3-pro-preview");
1613

17-
const res = await completeSimple(
18-
model,
19-
{
20-
messages: [
21-
{
22-
role: "user",
23-
content: "Reply with ok.",
24-
timestamp: now,
25-
},
26-
{
27-
role: "assistant",
28-
content: [
29-
{
30-
type: "toolCall",
31-
id: "call_1",
32-
name: "bash",
33-
arguments: { command: "ls -la" },
34-
// No thoughtSignature: simulates Claude via Antigravity.
35-
},
36-
],
37-
api: "google-gemini-cli",
38-
provider: "google-antigravity",
39-
model: "claude-sonnet-4-20250514",
40-
usage: {
14+
const res = await completeSimple(
15+
model,
16+
{
17+
messages: [
18+
{
19+
role: "user",
20+
content: "Reply with ok.",
21+
timestamp: now,
22+
},
23+
{
24+
role: "assistant",
25+
content: [
26+
{
27+
type: "toolCall",
28+
id: "call_1",
29+
name: "bash",
30+
arguments: { command: "ls -la" },
31+
// No thoughtSignature: simulates Claude via Antigravity.
32+
},
33+
],
34+
api: "google-gemini-cli",
35+
provider: "google-antigravity",
36+
model: "claude-sonnet-4-20250514",
37+
usage: {
38+
input: 0,
39+
output: 0,
40+
cacheRead: 0,
41+
cacheWrite: 0,
42+
totalTokens: 0,
43+
cost: {
4144
input: 0,
4245
output: 0,
4346
cacheRead: 0,
4447
cacheWrite: 0,
45-
totalTokens: 0,
46-
cost: {
47-
input: 0,
48-
output: 0,
49-
cacheRead: 0,
50-
cacheWrite: 0,
51-
total: 0,
52-
},
48+
total: 0,
5349
},
54-
stopReason: "stop",
55-
timestamp: now,
5650
},
57-
],
58-
tools: [
59-
{
60-
name: "bash",
61-
description: "Run shell command",
62-
parameters: {
63-
type: "object",
64-
properties: {
65-
command: { type: "string" },
66-
},
67-
required: ["command"],
51+
stopReason: "stop",
52+
timestamp: now,
53+
},
54+
],
55+
tools: [
56+
{
57+
name: "bash",
58+
description: "Run shell command",
59+
parameters: {
60+
type: "object",
61+
properties: {
62+
command: { type: "string" },
6863
},
64+
required: ["command"],
6965
},
70-
],
71-
},
72-
{
73-
apiKey: GEMINI_KEY,
74-
reasoning: "low",
75-
maxTokens: 128,
76-
},
77-
);
66+
},
67+
],
68+
},
69+
{
70+
apiKey: GEMINI_KEY,
71+
reasoning: "low",
72+
maxTokens: 128,
73+
},
74+
);
7875

79-
expect(res.stopReason).not.toBe("error");
80-
},
81-
20000,
82-
);
76+
expect(res.stopReason).not.toBe("error");
77+
}, 20000);
8378
});

src/auto-reply/command-auth.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,12 @@ export function resolveCommandAuthorization(params: {
116116

117117
const ownerCandidates = allowAll ? [] : allowFromList.filter((entry) => entry !== "*");
118118
if (!allowAll && ownerCandidates.length === 0 && to) {
119-
const normalizedTo = normalizeAllowFromEntry({ dock, cfg, accountId: ctx.AccountId, value: to });
119+
const normalizedTo = normalizeAllowFromEntry({
120+
dock,
121+
cfg,
122+
accountId: ctx.AccountId,
123+
value: to,
124+
});
120125
if (normalizedTo) ownerCandidates.push(normalizedTo);
121126
}
122127
const ownerList = ownerCandidates;

src/auto-reply/reply/agent-runner-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export function buildThreadingToolContext(params: {
2626
const dock = getChannelDock(provider);
2727
if (!dock?.threading?.buildToolContext) return {};
2828
// WhatsApp context isolation keys off conversation id, not the bot's own number.
29-
const threadingTo = provider === "whatsapp" ? sessionCtx.From ?? sessionCtx.To : sessionCtx.To;
29+
const threadingTo = provider === "whatsapp" ? (sessionCtx.From ?? sessionCtx.To) : sessionCtx.To;
3030
return (
3131
dock.threading.buildToolContext({
3232
cfg: config,

src/auto-reply/reply/session-reset-group.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ import { initSessionState } from "./session.js";
99

1010
describe("initSessionState reset triggers in WhatsApp groups", () => {
1111
async function createStorePath(prefix: string): Promise<string> {
12-
const root = await fs.mkdtemp(
13-
path.join(os.tmpdir(), prefix),
14-
);
12+
const root = await fs.mkdtemp(path.join(os.tmpdir(), prefix));
1513
return path.join(root, "sessions.json");
1614
}
1715

src/discord/monitor/message-handler.process.ts

Lines changed: 83 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ import {
2424
} from "./message-utils.js";
2525
import { buildDirectLabel, buildGuildLabel, resolveReplyContext } from "./reply-context.js";
2626
import { deliverDiscordReply } from "./reply-delivery.js";
27-
import {
28-
resolveDiscordAutoThreadReplyPlan,
29-
resolveDiscordThreadStarter,
30-
} from "./threading.js";
27+
import { resolveDiscordAutoThreadReplyPlan, resolveDiscordThreadStarter } from "./threading.js";
3128
import { sendTyping } from "./typing.js";
3229

3330
export async function processDiscordMessage(ctx: DiscordMessagePreflightContext) {
@@ -191,72 +188,72 @@ export async function processDiscordMessage(ctx: DiscordMessagePreflightContext)
191188
peer: { kind: "channel", id: threadParentId },
192189
});
193190
}
194-
}
195-
const mediaPayload = buildDiscordMediaPayload(mediaList);
196-
const threadKeys = resolveThreadSessionKeys({
197-
baseSessionKey,
198-
threadId: threadChannel ? message.channelId : undefined,
199-
parentSessionKey,
200-
useSuffix: false,
201-
});
202-
const replyPlan = await resolveDiscordAutoThreadReplyPlan({
203-
client,
204-
message,
205-
isGuildMessage,
206-
channelConfig,
207-
threadChannel,
208-
baseText: baseText ?? "",
209-
combinedBody,
210-
replyToMode,
211-
agentId: route.agentId,
212-
channel: route.channel,
213-
});
214-
const deliverTarget = replyPlan.deliverTarget;
215-
const replyTarget = replyPlan.replyTarget;
216-
const replyReference = replyPlan.replyReference;
217-
const autoThreadContext = replyPlan.autoThreadContext;
191+
}
192+
const mediaPayload = buildDiscordMediaPayload(mediaList);
193+
const threadKeys = resolveThreadSessionKeys({
194+
baseSessionKey,
195+
threadId: threadChannel ? message.channelId : undefined,
196+
parentSessionKey,
197+
useSuffix: false,
198+
});
199+
const replyPlan = await resolveDiscordAutoThreadReplyPlan({
200+
client,
201+
message,
202+
isGuildMessage,
203+
channelConfig,
204+
threadChannel,
205+
baseText: baseText ?? "",
206+
combinedBody,
207+
replyToMode,
208+
agentId: route.agentId,
209+
channel: route.channel,
210+
});
211+
const deliverTarget = replyPlan.deliverTarget;
212+
const replyTarget = replyPlan.replyTarget;
213+
const replyReference = replyPlan.replyReference;
214+
const autoThreadContext = replyPlan.autoThreadContext;
218215

219-
const effectiveFrom = isDirectMessage
220-
? `discord:${author.id}`
221-
: (autoThreadContext?.From ?? `group:${message.channelId}`);
222-
const effectiveTo = autoThreadContext?.To ?? replyTarget;
223-
if (!effectiveTo) {
224-
runtime.error?.(danger("discord: missing reply target"));
225-
return;
226-
}
216+
const effectiveFrom = isDirectMessage
217+
? `discord:${author.id}`
218+
: (autoThreadContext?.From ?? `group:${message.channelId}`);
219+
const effectiveTo = autoThreadContext?.To ?? replyTarget;
220+
if (!effectiveTo) {
221+
runtime.error?.(danger("discord: missing reply target"));
222+
return;
223+
}
227224

228-
const ctxPayload = {
229-
Body: combinedBody,
230-
RawBody: baseText,
231-
CommandBody: baseText,
232-
From: effectiveFrom,
233-
To: effectiveTo,
234-
SessionKey: autoThreadContext?.SessionKey ?? threadKeys.sessionKey,
235-
AccountId: route.accountId,
236-
ChatType: isDirectMessage ? "direct" : "group",
237-
SenderName: data.member?.nickname ?? author.globalName ?? author.username,
238-
SenderId: author.id,
239-
SenderUsername: author.username,
240-
SenderTag: formatDiscordUserTag(author),
241-
GroupSubject: groupSubject,
242-
GroupRoom: groupRoom,
243-
GroupSystemPrompt: isGuildMessage ? groupSystemPrompt : undefined,
244-
GroupSpace: isGuildMessage ? (guildInfo?.id ?? guildSlug) || undefined : undefined,
245-
Provider: "discord" as const,
246-
Surface: "discord" as const,
247-
WasMentioned: effectiveWasMentioned,
248-
MessageSid: message.id,
249-
ParentSessionKey: autoThreadContext?.ParentSessionKey ?? threadKeys.parentSessionKey,
250-
ThreadStarterBody: threadStarterBody,
251-
ThreadLabel: threadLabel,
252-
Timestamp: resolveTimestampMs(message.timestamp),
253-
...mediaPayload,
254-
CommandAuthorized: commandAuthorized,
255-
CommandSource: "text" as const,
256-
// Originating channel for reply routing.
257-
OriginatingChannel: "discord" as const,
258-
OriginatingTo: autoThreadContext?.OriginatingTo ?? replyTarget,
259-
};
225+
const ctxPayload = {
226+
Body: combinedBody,
227+
RawBody: baseText,
228+
CommandBody: baseText,
229+
From: effectiveFrom,
230+
To: effectiveTo,
231+
SessionKey: autoThreadContext?.SessionKey ?? threadKeys.sessionKey,
232+
AccountId: route.accountId,
233+
ChatType: isDirectMessage ? "direct" : "group",
234+
SenderName: data.member?.nickname ?? author.globalName ?? author.username,
235+
SenderId: author.id,
236+
SenderUsername: author.username,
237+
SenderTag: formatDiscordUserTag(author),
238+
GroupSubject: groupSubject,
239+
GroupRoom: groupRoom,
240+
GroupSystemPrompt: isGuildMessage ? groupSystemPrompt : undefined,
241+
GroupSpace: isGuildMessage ? (guildInfo?.id ?? guildSlug) || undefined : undefined,
242+
Provider: "discord" as const,
243+
Surface: "discord" as const,
244+
WasMentioned: effectiveWasMentioned,
245+
MessageSid: message.id,
246+
ParentSessionKey: autoThreadContext?.ParentSessionKey ?? threadKeys.parentSessionKey,
247+
ThreadStarterBody: threadStarterBody,
248+
ThreadLabel: threadLabel,
249+
Timestamp: resolveTimestampMs(message.timestamp),
250+
...mediaPayload,
251+
CommandAuthorized: commandAuthorized,
252+
CommandSource: "text" as const,
253+
// Originating channel for reply routing.
254+
OriginatingChannel: "discord" as const,
255+
OriginatingTo: autoThreadContext?.OriginatingTo ?? replyTarget,
256+
};
260257

261258
if (isDirectMessage) {
262259
const sessionCfg = cfg.session;
@@ -272,20 +269,20 @@ export async function processDiscordMessage(ctx: DiscordMessagePreflightContext)
272269
});
273270
}
274271

275-
if (shouldLogVerbose()) {
276-
const preview = truncateUtf16Safe(combinedBody, 200).replace(/\n/g, "\\n");
277-
logVerbose(
278-
`discord inbound: channel=${message.channelId} deliver=${deliverTarget} from=${ctxPayload.From} preview="${preview}"`,
279-
);
280-
}
272+
if (shouldLogVerbose()) {
273+
const preview = truncateUtf16Safe(combinedBody, 200).replace(/\n/g, "\\n");
274+
logVerbose(
275+
`discord inbound: channel=${message.channelId} deliver=${deliverTarget} from=${ctxPayload.From} preview="${preview}"`,
276+
);
277+
}
281278

282-
let didSendReply = false;
283-
const typingChannelId = deliverTarget.startsWith("channel:")
284-
? deliverTarget.slice("channel:".length)
285-
: message.channelId;
286-
const { dispatcher, replyOptions, markDispatchIdle } = createReplyDispatcherWithTyping({
287-
responsePrefix: resolveEffectiveMessagesConfig(cfg, route.agentId).responsePrefix,
288-
humanDelay: resolveHumanDelayConfig(cfg, route.agentId),
279+
let didSendReply = false;
280+
const typingChannelId = deliverTarget.startsWith("channel:")
281+
? deliverTarget.slice("channel:".length)
282+
: message.channelId;
283+
const { dispatcher, replyOptions, markDispatchIdle } = createReplyDispatcherWithTyping({
284+
responsePrefix: resolveEffectiveMessagesConfig(cfg, route.agentId).responsePrefix,
285+
humanDelay: resolveHumanDelayConfig(cfg, route.agentId),
289286
deliver: async (payload: ReplyPayload) => {
290287
const replyToId = replyReference.use();
291288
await deliverDiscordReply({
@@ -302,11 +299,11 @@ export async function processDiscordMessage(ctx: DiscordMessagePreflightContext)
302299
didSendReply = true;
303300
replyReference.markSent();
304301
},
305-
onError: (err, info) => {
306-
runtime.error?.(danger(`discord ${info.kind} reply failed: ${String(err)}`));
307-
},
308-
onReplyStart: () => sendTyping({ client, channelId: typingChannelId }),
309-
});
302+
onError: (err, info) => {
303+
runtime.error?.(danger(`discord ${info.kind} reply failed: ${String(err)}`));
304+
},
305+
onReplyStart: () => sendTyping({ client, channelId: typingChannelId }),
306+
});
310307

311308
const { queuedFinal, counts } = await dispatchReplyFromConfig({
312309
ctx: ctxPayload,

0 commit comments

Comments
 (0)