import { b as danger, j as theme } from "./registry-Sbac4a4z.js";
import "./paths-By0XjHBk.js";
import "./utils-CTPsqyE_.js";
import { f as defaultRuntime } from "./subsystem-CHbO_DkH.js";
import "./exec-DuYbft0z.js";
import "./agent-scope-Bnsyyeci.js";
import "./model-selection-CCTzD29o.js";
import "./config-BngIfn5l.js";
import "./boolean-CbZoNRMn.js";
import "./env-BRnPI9sO.js";
import "./shell-env-Dc3iU7HK.js";
import "./manifest-registry-D1MLZEjS.js";
import "./message-channel-DgjXWzf-.js";
import "./client-CTrfpKT3.js";
import "./call-Bpjj5p7I.js";
import "./pairing-token-B703A1U3.js";
import { t as formatDocsLink } from "./links-Bqr0FxXx.js";
import "./progress-swt2y17x.js";
import { n as callGatewayFromCli, t as addGatewayClientOptions } from "./gateway-rpc-gaoD882s.js";
import fsPromises from "node:fs/promises";

//#region src/cli/symframe-cli.ts
function registerSymframeCli(program) {
	addGatewayClientOptions(program.command("symframe").description("Push cards to the Glass UI symframe (right-column dynamic display)").addHelpText("after", () => `\n${theme.muted("Docs:")} ${formatDocsLink("/cli/symframe", "docs.symi.ai/cli/symframe")}\n`).command("push").description("Push (add/update/remove) a card to the symframe").option("--action <add|update|remove|dwell|release|recall|pin|unpin>", "Action (default: add). Stage-C verbs (dwell|release|recall|pin|unpin) are id-only — no card body.", "add").option("--id <id>", "Card id (required for update/remove; auto-generated for add)").option("--type <type>", "Renderer type — text | markdown | code | email-draft | pdf | audio | video", "text").option("--intent <intent>", "Card intent (mental-state slot) — holding | weighing | producing | awaiting | drafted | reference").option("--title <title>", "Card title (header text)").option("--body <body>", "Card body text (code source if --type=code)").option("--file <path>", "Read body from file (overrides --body)").option("--language <lang>", "Language hint for --type=code (e.g. ts, py, sh)").option("--url <url>", "Media URL for --type=pdf|audio|video").option("--mime <type>", "MIME type for --type=audio|video (e.g. audio/mpeg)").option("--data <json>", "Extra structured fields merged into the card (e.g. email-draft uses { email: { from, to, subject, body } })").option("--sticky", "Anchor at the bottom of the stack (no dismiss button)", false).option("--force", "Required to update or remove a sticky card (use sparingly)", false).option("--json", "Output JSON", false)).action(async (opts) => {
		try {
			const action = (opts.action ?? "add").trim();
			if (!new Set([
				"add",
				"update",
				"remove",
				"dwell",
				"release",
				"recall",
				"pin",
				"unpin"
			]).has(action)) throw new Error(`--action must be one of: add | update | remove | dwell | release | recall | pin | unpin (got '${action}')`);
			let bodyText = opts.body;
			if (opts.file) bodyText = await fsPromises.readFile(opts.file, "utf8");
			const params = { action };
			if (opts.id) params.id = opts.id;
			if (opts.force) params.force = true;
			const ID_ONLY_VERBS = new Set([
				"remove",
				"dwell",
				"release",
				"recall",
				"pin",
				"unpin"
			]);
			const REQUIRES_ID = new Set([
				"remove",
				"dwell",
				"release",
				"pin",
				"unpin"
			]);
			if (ID_ONLY_VERBS.has(action)) {
				if (REQUIRES_ID.has(action) && !opts.id) throw new Error(`--id is required for ${action}`);
			} else {
				const card = {};
				if (opts.id) card.id = opts.id;
				if (opts.type) card.type = opts.type;
				if (opts.intent) card.intent = opts.intent;
				if (opts.title) card.title = opts.title;
				if (bodyText !== void 0) card.body = bodyText;
				if (opts.language) card.language = opts.language;
				if (opts.url) card.url = opts.url;
				if (opts.mime) card.mimeType = opts.mime;
				if (opts.data) {
					let parsed;
					try {
						parsed = JSON.parse(opts.data);
					} catch (err) {
						throw new Error(`--data must be valid JSON: ${String(err)}`, { cause: err });
					}
					if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) Object.assign(card, parsed);
					else throw new Error("--data must be a JSON object");
				}
				if (opts.sticky) card.sticky = true;
				const hasContent = opts.title || bodyText !== void 0 || opts.url || opts.data && card.email;
				if (action === "add" && !hasContent) throw new Error("add requires at least --title, --body/--file, --url, or --data with structured content");
				if (action === "update" && !opts.id) throw new Error("--id is required for update");
				if (Object.keys(card).length > 0) params.card = card;
			}
			const result = await callGatewayFromCli("chat.symframe.push", opts, params, { expectFinal: false });
			if (opts.json) defaultRuntime.log(JSON.stringify(result ?? { ok: true }, null, 2));
			else defaultRuntime.log("ok");
		} catch (err) {
			defaultRuntime.error(danger(String(err)));
			defaultRuntime.exit(1);
		}
	});
}

//#endregion
export { registerSymframeCli };