mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-04 23:44:41 +00:00
* Add metrics collection and terminal performance tests * feat: add loop, schedule, and chat commands with slash-namespaced RPC Introduce three new server-side features with CLI command groups: - `paseo loop` — iterative agent execution with verify-check/verify-prompt - `paseo schedule` — recurring tasks on interval or cron cadence - `paseo chat` — chat rooms for agent-to-agent coordination All features use new slash-namespaced RPC methods (e.g. `loop/run`, `schedule/create`, `chat/post`) instead of flat message types, backed by file-based persistence and wired through the existing WebSocket session dispatch. * test: stabilize loop schedule chat rollout
56 lines
1.4 KiB
TypeScript
56 lines
1.4 KiB
TypeScript
import type { Command } from "commander";
|
|
import type { ListResult } from "../../output/index.js";
|
|
import {
|
|
connectChatClient,
|
|
parseSinceValue,
|
|
toChatCommandError,
|
|
type ChatCommandOptions,
|
|
} from "./shared.js";
|
|
import { chatMessageSchema, type ChatMessageRow, toChatMessageRow } from "./schema.js";
|
|
|
|
export interface ChatReadOptions extends ChatCommandOptions {
|
|
limit?: string;
|
|
since?: string;
|
|
agent?: string;
|
|
}
|
|
|
|
function parseLimit(value?: string): number | undefined {
|
|
if (!value) {
|
|
return undefined;
|
|
}
|
|
const parsed = Number.parseInt(value, 10);
|
|
if (!Number.isInteger(parsed) || parsed < 0) {
|
|
throw {
|
|
code: "INVALID_LIMIT",
|
|
message: "Invalid --limit value",
|
|
details: "Use a non-negative integer.",
|
|
};
|
|
}
|
|
return parsed;
|
|
}
|
|
|
|
export async function runReadCommand(
|
|
room: string,
|
|
options: ChatReadOptions,
|
|
_command: Command,
|
|
): Promise<ListResult<ChatMessageRow>> {
|
|
const { client } = await connectChatClient(options.host);
|
|
try {
|
|
const payload = await client.readChatMessages({
|
|
room,
|
|
limit: parseLimit(options.limit),
|
|
since: parseSinceValue(options.since),
|
|
authorAgentId: options.agent,
|
|
});
|
|
return {
|
|
type: "list",
|
|
data: payload.messages.map(toChatMessageRow),
|
|
schema: chatMessageSchema,
|
|
};
|
|
} catch (err) {
|
|
throw toChatCommandError("CHAT_READ_FAILED", "read chat messages", err);
|
|
} finally {
|
|
await client.close().catch(() => {});
|
|
}
|
|
}
|