//#region src/agent/ipc/types.ts
function isValidIPCMessage(msg) {
	if (typeof msg !== "object" || msg === null) return false;
	const m = msg;
	return typeof m.id === "string" && typeof m.version === "number" && typeof m.from === "string" && typeof m.to === "string" && typeof m.type === "string" && [
		"task",
		"query",
		"response",
		"event",
		"signal"
	].includes(m.type) && typeof m.createdAt === "number";
}
function createTaskMessage(from, to, task, options = {}) {
	return {
		id: generateMessageId(),
		version: 1,
		from,
		to,
		type: "task",
		payload: {
			task,
			context: options.context,
			priority: options.priority || "normal",
			sessionKey: options.sessionKey,
			callbackAgentId: options.callbackAgentId
		},
		timeoutMs: options.timeoutMs,
		createdAt: Date.now()
	};
}
function createResponseMessage(from, to, requestId, success, data, error) {
	return {
		id: generateMessageId(),
		version: 1,
		from,
		to,
		type: "response",
		payload: {
			success,
			data,
			error,
			requestId
		},
		replyTo: requestId,
		createdAt: Date.now()
	};
}
function createSignalMessage(from, to, signal, data) {
	return {
		id: generateMessageId(),
		version: 1,
		from,
		to,
		type: "signal",
		payload: {
			signal,
			data
		},
		createdAt: Date.now()
	};
}
function generateMessageId() {
	return `${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;
}
//#endregion
export { createResponseMessage, createSignalMessage, createTaskMessage, isValidIPCMessage };

//# sourceMappingURL=types.js.map