style: normalize indentation to 2 spaces
This commit is contained in:
@@ -10,17 +10,17 @@ export type ClaudeOutputFormat = "text" | "json" | "stream-json";
|
|||||||
export type SessionScope = "per-sender" | "global";
|
export type SessionScope = "per-sender" | "global";
|
||||||
|
|
||||||
export type SessionConfig = {
|
export type SessionConfig = {
|
||||||
scope?: SessionScope;
|
scope?: SessionScope;
|
||||||
resetTriggers?: string[];
|
resetTriggers?: string[];
|
||||||
idleMinutes?: number;
|
idleMinutes?: number;
|
||||||
store?: string;
|
store?: string;
|
||||||
sessionArgNew?: string[];
|
sessionArgNew?: string[];
|
||||||
sessionArgResume?: string[];
|
sessionArgResume?: string[];
|
||||||
sessionArgBeforeBody?: boolean;
|
sessionArgBeforeBody?: boolean;
|
||||||
sendSystemOnce?: boolean;
|
sendSystemOnce?: boolean;
|
||||||
sessionIntro?: string;
|
sessionIntro?: string;
|
||||||
typingIntervalSeconds?: number;
|
typingIntervalSeconds?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type LoggingConfig = {
|
export type LoggingConfig = {
|
||||||
level?: "silent" | "fatal" | "error" | "warn" | "info" | "debug" | "trace";
|
level?: "silent" | "fatal" | "error" | "warn" | "info" | "debug" | "trace";
|
||||||
@@ -28,29 +28,29 @@ export type LoggingConfig = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type WarelayConfig = {
|
export type WarelayConfig = {
|
||||||
logging?: LoggingConfig;
|
logging?: LoggingConfig;
|
||||||
inbound?: {
|
inbound?: {
|
||||||
allowFrom?: string[]; // E.164 numbers allowed to trigger auto-reply (without whatsapp:)
|
allowFrom?: string[]; // E.164 numbers allowed to trigger auto-reply (without whatsapp:)
|
||||||
transcribeAudio?: {
|
transcribeAudio?: {
|
||||||
// Optional CLI to turn inbound audio into text; templated args, must output transcript to stdout.
|
// Optional CLI to turn inbound audio into text; templated args, must output transcript to stdout.
|
||||||
command: string[];
|
command: string[];
|
||||||
timeoutSeconds?: number;
|
timeoutSeconds?: number;
|
||||||
};
|
};
|
||||||
reply?: {
|
reply?: {
|
||||||
mode: ReplyMode;
|
mode: ReplyMode;
|
||||||
text?: string; // for mode=text, can contain {{Body}}
|
text?: string; // for mode=text, can contain {{Body}}
|
||||||
command?: string[]; // for mode=command, argv with templates
|
command?: string[]; // for mode=command, argv with templates
|
||||||
cwd?: string; // working directory for command execution
|
cwd?: string; // working directory for command execution
|
||||||
template?: string; // prepend template string when building command/prompt
|
template?: string; // prepend template string when building command/prompt
|
||||||
timeoutSeconds?: number; // optional command timeout; defaults to 600s
|
timeoutSeconds?: number; // optional command timeout; defaults to 600s
|
||||||
bodyPrefix?: string; // optional string prepended to Body before templating
|
bodyPrefix?: string; // optional string prepended to Body before templating
|
||||||
mediaUrl?: string; // optional media attachment (path or URL)
|
mediaUrl?: string; // optional media attachment (path or URL)
|
||||||
session?: SessionConfig;
|
session?: SessionConfig;
|
||||||
claudeOutputFormat?: ClaudeOutputFormat; // when command starts with `claude`, force an output format
|
claudeOutputFormat?: ClaudeOutputFormat; // when command starts with `claude`, force an output format
|
||||||
mediaMaxMb?: number; // optional cap for outbound media (default 5MB)
|
mediaMaxMb?: number; // optional cap for outbound media (default 5MB)
|
||||||
typingIntervalSeconds?: number; // how often to refresh typing indicator while command runs
|
typingIntervalSeconds?: number; // how often to refresh typing indicator while command runs
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const CONFIG_PATH = path.join(os.homedir(), ".warelay", "warelay.json");
|
export const CONFIG_PATH = path.join(os.homedir(), ".warelay", "warelay.json");
|
||||||
|
|||||||
@@ -640,44 +640,44 @@ describe("config and templating", () => {
|
|||||||
expect(onReplyStart.mock.calls.length).toBeGreaterThanOrEqual(3);
|
expect(onReplyStart.mock.calls.length).toBeGreaterThanOrEqual(3);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("uses session typing interval override", async () => {
|
it("uses session typing interval override", async () => {
|
||||||
const onReplyStart = vi.fn();
|
const onReplyStart = vi.fn();
|
||||||
const runSpy = vi.spyOn(index, "runCommandWithTimeout").mockImplementation(
|
const runSpy = vi.spyOn(index, "runCommandWithTimeout").mockImplementation(
|
||||||
() =>
|
() =>
|
||||||
new Promise((resolve) =>
|
new Promise((resolve) =>
|
||||||
setTimeout(
|
setTimeout(
|
||||||
() =>
|
() =>
|
||||||
resolve({
|
resolve({
|
||||||
stdout: "done\n",
|
stdout: "done\n",
|
||||||
stderr: "",
|
stderr: "",
|
||||||
code: 0,
|
code: 0,
|
||||||
signal: null,
|
signal: null,
|
||||||
killed: false,
|
killed: false,
|
||||||
}),
|
}),
|
||||||
120,
|
120,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
const cfg = {
|
const cfg = {
|
||||||
inbound: {
|
inbound: {
|
||||||
reply: {
|
reply: {
|
||||||
mode: "command" as const,
|
mode: "command" as const,
|
||||||
command: ["echo", "{{Body}}"],
|
command: ["echo", "{{Body}}"],
|
||||||
session: { typingIntervalSeconds: 0.02 },
|
session: { typingIntervalSeconds: 0.02 },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const promise = index.getReplyFromConfig(
|
const promise = index.getReplyFromConfig(
|
||||||
{ Body: "hi", From: "+1", To: "+2" },
|
{ Body: "hi", From: "+1", To: "+2" },
|
||||||
{ onReplyStart },
|
{ onReplyStart },
|
||||||
cfg,
|
cfg,
|
||||||
runSpy,
|
runSpy,
|
||||||
);
|
);
|
||||||
await new Promise((r) => setTimeout(r, 200));
|
await new Promise((r) => setTimeout(r, 200));
|
||||||
await promise;
|
await promise;
|
||||||
expect(onReplyStart.mock.calls.length).toBeGreaterThanOrEqual(3);
|
expect(onReplyStart.mock.calls.length).toBeGreaterThanOrEqual(3);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("injects Claude output format + print flag when configured", async () => {
|
it("injects Claude output format + print flag when configured", async () => {
|
||||||
const runSpy = vi.spyOn(index, "runCommandWithTimeout").mockResolvedValue({
|
const runSpy = vi.spyOn(index, "runCommandWithTimeout").mockResolvedValue({
|
||||||
|
|||||||
Reference in New Issue
Block a user