Add oxlint-tsgolint and configure typescript/no-unnecessary-type-assertion to flag redundant `!` and `as Foo` casts. Type-aware mode is left off by default to keep `npm run lint` fast; the rule sits configured for when we turn type-aware on intentionally. Auto-fix removed ~283 redundant casts; two manual touch-ups: a real tsgolint false positive in split-container.tsx and a stale ChildProcess import after a double-cast collapsed.
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import type { Command } from "commander";
|
|
import type { SingleResult } from "../../output/index.js";
|
|
import {
|
|
attachAgentNamesToMessages,
|
|
connectChatClient,
|
|
resolveChatAuthorAgentId,
|
|
toChatCommandError,
|
|
type ChatCommandOptions,
|
|
} from "./shared.js";
|
|
import { chatMessageSchema, type ChatMessageRow, toChatMessageRow } from "./schema.js";
|
|
|
|
export interface ChatPostOptions extends ChatCommandOptions {
|
|
replyTo?: string;
|
|
}
|
|
|
|
export async function runPostCommand(
|
|
room: string,
|
|
body: string,
|
|
options: ChatPostOptions,
|
|
_command: Command,
|
|
): Promise<SingleResult<ChatMessageRow>> {
|
|
const { client } = await connectChatClient(options.host);
|
|
try {
|
|
const payload = await client.postChatMessage({
|
|
room,
|
|
body,
|
|
authorAgentId: resolveChatAuthorAgentId(),
|
|
replyToMessageId: options.replyTo,
|
|
});
|
|
const [message] = await attachAgentNamesToMessages(client, [
|
|
toChatMessageRow(payload.message!),
|
|
]);
|
|
return {
|
|
type: "single",
|
|
data: message,
|
|
schema: chatMessageSchema,
|
|
};
|
|
} catch (err) {
|
|
throw toChatCommandError("CHAT_POST_FAILED", "post chat message", err);
|
|
} finally {
|
|
await client.close().catch(() => {});
|
|
}
|
|
}
|