import { Type } from "@sinclair/typebox";
//#region src/agent/tools/session-status-tool.ts
const SessionStatusSchema = Type.Object({ timezone: Type.Optional(Type.String({ description: "Optional IANA timezone for formatting (e.g. Asia/Shanghai). When omitted, uses the host/browser default timezone." })) });
function formatTimestamp(now, timezone) {
	const isoUtc = now.toISOString();
	const fallbackTz = Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC";
	const tz = (timezone ?? "").trim() || fallbackTz;
	try {
		const parts = new Intl.DateTimeFormat("en-GB", {
			timeZone: tz,
			year: "numeric",
			month: "2-digit",
			day: "2-digit",
			hour: "2-digit",
			minute: "2-digit",
			second: "2-digit",
			hour12: false,
			timeZoneName: "short"
		}).formatToParts(now);
		const map = {};
		for (const part of parts) if (part.type !== "literal") map[part.type] = part.value;
		const year = map.year ?? "";
		const month = map.month ?? "";
		const day = map.day ?? "";
		const hour = map.hour ?? "";
		const minute = map.minute ?? "";
		const second = map.second ?? "";
		const tzName = map.timeZoneName ?? "";
		return {
			label: year && month && day && hour && minute && second ? `${year}-${month}-${day} ${hour}:${minute}:${second}${tzName ? ` ${tzName}` : ""}` : `${isoUtc.slice(0, 19).replace("T", " ")} UTC`,
			isoUtc,
			tz
		};
	} catch {
		return {
			label: `${isoUtc.slice(0, 19).replace("T", " ")} UTC`,
			isoUtc,
			tz
		};
	}
}
function createSessionStatusTool() {
	return {
		name: "session_status",
		label: "📊 Session Status",
		description: "Show a compact status card including the current timestamp (UTC + formatted local time). Useful when you need the current date/time without relying on the system prompt.",
		parameters: SessionStatusSchema,
		async execute(_toolCallId, params, _signal) {
			const now = /* @__PURE__ */ new Date();
			const fmt = formatTimestamp(now, params.timezone);
			return {
				content: [{
					type: "text",
					text: [
						"📊 Session status",
						`Time: ${fmt.label}`,
						`Time zone: ${fmt.tz}`,
						`UTC: ${fmt.isoUtc}`,
						`timestampMs: ${now.getTime()}`
					].join("\n")
				}],
				details: {}
			};
		}
	};
}
//#endregion
export { createSessionStatusTool };

//# sourceMappingURL=session-status-tool.js.map