import type { CorpConfig } from "../../core/config/types.js"; import type { createSealClient } from "../../core/http/factory.js"; import { runTool } from "../helpers.js"; import { outputOptions } from "../printer.js"; import type { ParsedArgs } from "../types.js"; export async function handleContactsCommand( action: string | undefined, maybeName: string | undefined, client: Awaited>, corp: CorpConfig, args: ParsedArgs ) { if (action === "sync-time" || action === "last-sync-time") { await runTool("seal_contacts_last_sync_time_get", client, corp, {}, outputOptions(args.options)); return; } if (action === "departments" || action === "department") { if (!maybeName) { await runTool("seal_contacts_departments_root_list", client, corp, {}, outputOptions(args.options)); return; } await runTool("seal_contacts_department_get", client, corp, { departmentId: maybeName }, outputOptions(args.options)); return; } if (action === "children" || action === "department-children") { if (!maybeName) throw new Error("Usage: seal-use contacts children "); await runTool("seal_contacts_department_children_list", client, corp, { departmentId: maybeName }, outputOptions(args.options)); return; } if (action === "users" || action === "department-users") { if (!maybeName) throw new Error("Usage: seal-use contacts users "); await runTool("seal_contacts_department_users_list", client, corp, { departmentId: maybeName }, outputOptions(args.options)); return; } throw new Error(`Unknown contacts command: ${action ?? ""}. Run 'seal-use help' for available commands.`); }