style: apply oxfmt fixes
This commit is contained in:
@@ -37,6 +37,8 @@ describe("formatAssistantErrorText", () => {
|
|||||||
const msg = makeAssistantError(
|
const msg = makeAssistantError(
|
||||||
'{"type":"error","error":{"message":"Something exploded","type":"server_error"}}',
|
'{"type":"error","error":{"message":"Something exploded","type":"server_error"}}',
|
||||||
);
|
);
|
||||||
expect(formatAssistantErrorText(msg)).toBe("The AI service returned an error. Please try again.");
|
expect(formatAssistantErrorText(msg)).toBe(
|
||||||
|
"The AI service returned an error. Please try again.",
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { buildEmbeddedRunPayloads } from "./payloads.js";
|
|||||||
|
|
||||||
describe("buildEmbeddedRunPayloads", () => {
|
describe("buildEmbeddedRunPayloads", () => {
|
||||||
const errorJson =
|
const errorJson =
|
||||||
'{"type":"error","error":{"details":null,"type":"overloaded_error","message":"Overloaded"},"request_id":"req_011CX7DwS7tSvggaNHmefwWg"}';
|
'{"type":"error","error":{"details":null,"type":"overloaded_error","message":"Overloaded"},"request_id":"req_011CX7DwS7tSvggaNHmefwWg"}';
|
||||||
const errorJsonPretty = `{
|
const errorJsonPretty = `{
|
||||||
"type": "error",
|
"type": "error",
|
||||||
"error": {
|
"error": {
|
||||||
|
|||||||
@@ -60,7 +60,9 @@ export function buildEmbeddedRunPayloads(params: {
|
|||||||
const rawErrorFingerprint = rawErrorMessage
|
const rawErrorFingerprint = rawErrorMessage
|
||||||
? getApiErrorPayloadFingerprint(rawErrorMessage)
|
? getApiErrorPayloadFingerprint(rawErrorMessage)
|
||||||
: null;
|
: null;
|
||||||
const normalizedRawErrorText = rawErrorMessage ? normalizeTextForComparison(rawErrorMessage) : null;
|
const normalizedRawErrorText = rawErrorMessage
|
||||||
|
? normalizeTextForComparison(rawErrorMessage)
|
||||||
|
: null;
|
||||||
if (errorText) replyItems.push({ text: errorText, isError: true });
|
if (errorText) replyItems.push({ text: errorText, isError: true });
|
||||||
|
|
||||||
const inlineToolResults =
|
const inlineToolResults =
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ describe("handleCommands /config configWrites gating", () => {
|
|||||||
commands: { config: true, text: true },
|
commands: { config: true, text: true },
|
||||||
channels: { whatsapp: { allowFrom: ["*"], configWrites: false } },
|
channels: { whatsapp: { allowFrom: ["*"], configWrites: false } },
|
||||||
} as ClawdbotConfig;
|
} as ClawdbotConfig;
|
||||||
const params = buildParams("/config set messages.ackReaction=\":)\"", cfg);
|
const params = buildParams('/config set messages.ackReaction=":)"', cfg);
|
||||||
const result = await handleCommands(params);
|
const result = await handleCommands(params);
|
||||||
expect(result.shouldContinue).toBe(false);
|
expect(result.shouldContinue).toBe(false);
|
||||||
expect(result.reply?.text).toContain("Config writes are disabled");
|
expect(result.reply?.text).toContain("Config writes are disabled");
|
||||||
|
|||||||
@@ -24,9 +24,7 @@ describe("resolveChannelConfigWrites", () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
expect(
|
expect(resolveChannelConfigWrites({ cfg, channelId: "slack", accountId: "work" })).toBe(false);
|
||||||
resolveChannelConfigWrites({ cfg, channelId: "slack", accountId: "work" }),
|
|
||||||
).toBe(false);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("matches account ids case-insensitively", () => {
|
it("matches account ids case-insensitively", () => {
|
||||||
@@ -40,8 +38,6 @@ describe("resolveChannelConfigWrites", () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
expect(
|
expect(resolveChannelConfigWrites({ cfg, channelId: "slack", accountId: "work" })).toBe(false);
|
||||||
resolveChannelConfigWrites({ cfg, channelId: "slack", accountId: "work" }),
|
|
||||||
).toBe(false);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -7,10 +7,7 @@ type ChannelConfigWithAccounts = {
|
|||||||
accounts?: Record<string, { configWrites?: boolean }>;
|
accounts?: Record<string, { configWrites?: boolean }>;
|
||||||
};
|
};
|
||||||
|
|
||||||
function resolveAccountConfig(
|
function resolveAccountConfig(accounts: ChannelConfigWithAccounts["accounts"], accountId: string) {
|
||||||
accounts: ChannelConfigWithAccounts["accounts"],
|
|
||||||
accountId: string,
|
|
||||||
) {
|
|
||||||
if (!accounts || typeof accounts !== "object") return undefined;
|
if (!accounts || typeof accounts !== "object") return undefined;
|
||||||
if (accountId in accounts) return accounts[accountId];
|
if (accountId in accounts) return accounts[accountId];
|
||||||
const matchKey = Object.keys(accounts).find(
|
const matchKey = Object.keys(accounts).find(
|
||||||
|
|||||||
@@ -88,4 +88,3 @@ export function registerSecurityCli(program: Command) {
|
|||||||
defaultRuntime.log(lines.join("\n"));
|
defaultRuntime.log(lines.join("\n"));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -340,8 +340,8 @@ export async function statusAllCommand(
|
|||||||
},
|
},
|
||||||
{ Item: "Security", Value: "Run: clawdbot security audit --deep" },
|
{ Item: "Security", Value: "Run: clawdbot security audit --deep" },
|
||||||
gatewaySelfLine
|
gatewaySelfLine
|
||||||
? { Item: "Gateway self", Value: gatewaySelfLine }
|
? { Item: "Gateway self", Value: gatewaySelfLine }
|
||||||
: { Item: "Gateway self", Value: "unknown" },
|
: { Item: "Gateway self", Value: "unknown" },
|
||||||
daemon
|
daemon
|
||||||
? {
|
? {
|
||||||
Item: "Daemon",
|
Item: "Daemon",
|
||||||
|
|||||||
@@ -77,7 +77,11 @@ function normalizeAllowFromList(list: Array<string | number> | undefined | null)
|
|||||||
|
|
||||||
function classifyChannelWarningSeverity(message: string): SecurityAuditSeverity {
|
function classifyChannelWarningSeverity(message: string): SecurityAuditSeverity {
|
||||||
const s = message.toLowerCase();
|
const s = message.toLowerCase();
|
||||||
if (s.includes('dms: open') || s.includes('grouppolicy="open"') || s.includes('dmpolicy="open"')) {
|
if (
|
||||||
|
s.includes("dms: open") ||
|
||||||
|
s.includes('grouppolicy="open"') ||
|
||||||
|
s.includes('dmpolicy="open"')
|
||||||
|
) {
|
||||||
return "critical";
|
return "critical";
|
||||||
}
|
}
|
||||||
if (s.includes("allows any") || s.includes("anyone can dm") || s.includes("public")) {
|
if (s.includes("allows any") || s.includes("anyone can dm") || s.includes("public")) {
|
||||||
|
|||||||
@@ -95,9 +95,7 @@ export const registerTelegramHandlers = ({
|
|||||||
runtime.log?.(warn(`[telegram] Group migrated: "${chatTitle}" ${oldChatId} → ${newChatId}`));
|
runtime.log?.(warn(`[telegram] Group migrated: "${chatTitle}" ${oldChatId} → ${newChatId}`));
|
||||||
|
|
||||||
if (!resolveChannelConfigWrites({ cfg, channelId: "telegram", accountId })) {
|
if (!resolveChannelConfigWrites({ cfg, channelId: "telegram", accountId })) {
|
||||||
runtime.log?.(
|
runtime.log?.(warn("[telegram] Config writes disabled; skipping group config migration."));
|
||||||
warn("[telegram] Config writes disabled; skipping group config migration."),
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,8 +60,7 @@ async function requireRiskAcknowledgement(params: {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const ok = await params.prompter.confirm({
|
const ok = await params.prompter.confirm({
|
||||||
message:
|
message: "I understand this is powerful and inherently risky. Continue?",
|
||||||
"I understand this is powerful and inherently risky. Continue?",
|
|
||||||
initialValue: false,
|
initialValue: false,
|
||||||
});
|
});
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
|
|||||||
Reference in New Issue
Block a user