Chore: format + lint fixes
This commit is contained in:
@@ -76,7 +76,11 @@ function parsePiJson(raw: string): AgentParseResult {
|
|||||||
}
|
}
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
return { texts, toolResults: toolResults.length ? toolResults : undefined, meta };
|
return {
|
||||||
|
texts,
|
||||||
|
toolResults: toolResults.length ? toolResults : undefined,
|
||||||
|
meta,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export const piSpec: AgentSpec = {
|
export const piSpec: AgentSpec = {
|
||||||
|
|||||||
@@ -45,7 +45,17 @@ function normalizeThinkLevel(raw?: string | null): ThinkLevel | undefined {
|
|||||||
return "low";
|
return "low";
|
||||||
if (["med", "medium", "thinkharder", "think-harder", "harder"].includes(key))
|
if (["med", "medium", "thinkharder", "think-harder", "harder"].includes(key))
|
||||||
return "medium";
|
return "medium";
|
||||||
if (["high", "ultra", "ultrathink", "think-hard", "thinkhardest", "highest", "max"].includes(key))
|
if (
|
||||||
|
[
|
||||||
|
"high",
|
||||||
|
"ultra",
|
||||||
|
"ultrathink",
|
||||||
|
"think-hard",
|
||||||
|
"thinkhardest",
|
||||||
|
"highest",
|
||||||
|
"max",
|
||||||
|
].includes(key)
|
||||||
|
)
|
||||||
return "high";
|
return "high";
|
||||||
if (["think"].includes(key)) return "minimal";
|
if (["think"].includes(key)) return "minimal";
|
||||||
return undefined;
|
return undefined;
|
||||||
@@ -67,9 +77,7 @@ function extractThinkDirective(body?: string): {
|
|||||||
} {
|
} {
|
||||||
if (!body) return { cleaned: "", hasDirective: false };
|
if (!body) return { cleaned: "", hasDirective: false };
|
||||||
// Match the longest keyword first to avoid partial captures (e.g. "/think:high")
|
// Match the longest keyword first to avoid partial captures (e.g. "/think:high")
|
||||||
const match = body.match(
|
const match = body.match(/\/(?:thinking|think|t)\s*:?\s*([a-zA-Z-]+)\b/i);
|
||||||
/\/(?:thinking|think|t)\s*:?\s*([a-zA-Z-]+)\b/i,
|
|
||||||
);
|
|
||||||
const thinkLevel = normalizeThinkLevel(match?.[1]);
|
const thinkLevel = normalizeThinkLevel(match?.[1]);
|
||||||
const cleaned = match
|
const cleaned = match
|
||||||
? body.replace(match[0], "").replace(/\s+/g, " ").trim()
|
? body.replace(match[0], "").replace(/\s+/g, " ").trim()
|
||||||
@@ -262,7 +270,7 @@ export async function getReplyFromConfig(
|
|||||||
(sessionEntry?.thinkingLevel as ThinkLevel | undefined) ??
|
(sessionEntry?.thinkingLevel as ThinkLevel | undefined) ??
|
||||||
(reply?.thinkingDefault as ThinkLevel | undefined);
|
(reply?.thinkingDefault as ThinkLevel | undefined);
|
||||||
|
|
||||||
let resolvedVerboseLevel =
|
const resolvedVerboseLevel =
|
||||||
inlineVerbose ??
|
inlineVerbose ??
|
||||||
(sessionEntry?.verboseLevel as VerboseLevel | undefined) ??
|
(sessionEntry?.verboseLevel as VerboseLevel | undefined) ??
|
||||||
(reply?.verboseDefault as VerboseLevel | undefined);
|
(reply?.verboseDefault as VerboseLevel | undefined);
|
||||||
@@ -559,10 +567,10 @@ export async function getReplyFromConfig(
|
|||||||
// If verbose is enabled and this is a new session, prepend a session hint.
|
// If verbose is enabled and this is a new session, prepend a session hint.
|
||||||
const sessionIdHint =
|
const sessionIdHint =
|
||||||
resolvedVerboseLevel === "on" && isNewSession
|
resolvedVerboseLevel === "on" && isNewSession
|
||||||
? sessionId ??
|
? (sessionId ??
|
||||||
meta.agentMeta?.sessionId ??
|
meta.agentMeta?.sessionId ??
|
||||||
templatingCtx.SessionId ??
|
templatingCtx.SessionId ??
|
||||||
"unknown"
|
"unknown")
|
||||||
: undefined;
|
: undefined;
|
||||||
if (sessionIdHint) {
|
if (sessionIdHint) {
|
||||||
finalPayloads = [
|
finalPayloads = [
|
||||||
|
|||||||
@@ -810,7 +810,11 @@ describe("config and templating", () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const ack = await index.getReplyFromConfig(
|
const ack = await index.getReplyFromConfig(
|
||||||
{ Body: "[Dec 1 00:00] [🦞 same-phone] /think:high", From: "+1", To: "+2" },
|
{
|
||||||
|
Body: "[Dec 1 00:00] [🦞 same-phone] /think:high",
|
||||||
|
From: "+1",
|
||||||
|
To: "+2",
|
||||||
|
},
|
||||||
undefined,
|
undefined,
|
||||||
cfg,
|
cfg,
|
||||||
runSpy,
|
runSpy,
|
||||||
@@ -863,7 +867,7 @@ describe("config and templating", () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
expect(runSpy).not.toHaveBeenCalled();
|
expect(runSpy).not.toHaveBeenCalled();
|
||||||
expect(ack?.text).toContain("Unrecognized thinking level \"big\"");
|
expect(ack?.text).toContain('Unrecognized thinking level "big"');
|
||||||
|
|
||||||
// Send another message; state should not carry any level.
|
// Send another message; state should not carry any level.
|
||||||
const second = await index.getReplyFromConfig(
|
const second = await index.getReplyFromConfig(
|
||||||
|
|||||||
Reference in New Issue
Block a user