@thecorporation/cli 26.3.14 → 26.3.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1757 -444
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/config.ts","../src/api-client.ts","../src/output.ts","../src/commands/setup.ts","../src/animation.ts","../src/spinner.ts","../src/commands/status.ts","../src/commands/config.ts","../src/commands/obligations.ts","../src/commands/digest.ts","../src/commands/link.ts","../src/commands/claim.ts","../src/llm.ts","../src/tools.ts","../src/chat.ts","../src/commands/entities.ts","../src/commands/contacts.ts","../src/commands/cap-table.ts","../src/commands/finance.ts","../src/commands/governance.ts","../src/commands/documents.ts","../src/commands/tax.ts","../src/commands/agents.ts","../src/commands/work-items.ts","../src/commands/billing.ts","../src/commands/form.ts","../src/commands/api-keys.ts","../src/commands/demo.ts","../src/commands/serve.ts","../src/index.ts","../src/command-options.ts"],"sourcesContent":["import { readFileSync, writeFileSync, mkdirSync, chmodSync, existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { homedir } from \"node:os\";\nimport type { CorpConfig } from \"./types.js\";\n\nconst CONFIG_DIR = process.env.CORP_CONFIG_DIR || join(homedir(), \".corp\");\nconst CONFIG_FILE = join(CONFIG_DIR, \"config.json\");\n\nconst DEFAULTS: CorpConfig = {\n api_url: process.env.CORP_API_URL || \"https://api.thecorporation.ai\",\n api_key: \"\",\n workspace_id: \"\",\n hosting_mode: \"\",\n llm: {\n provider: \"anthropic\",\n api_key: \"\",\n model: \"claude-sonnet-4-6\",\n },\n user: { name: \"\", email: \"\" },\n active_entity_id: \"\",\n};\n\nfunction deepMerge(base: Record<string, unknown>, override: Record<string, unknown>): void {\n for (const [key, value] of Object.entries(override)) {\n if (\n key in base &&\n typeof base[key] === \"object\" &&\n base[key] !== null &&\n !Array.isArray(base[key]) &&\n typeof value === \"object\" &&\n value !== null &&\n !Array.isArray(value)\n ) {\n deepMerge(base[key] as Record<string, unknown>, value as Record<string, unknown>);\n } else {\n base[key] = value;\n }\n }\n}\n\nexport function loadConfig(): CorpConfig {\n const cfg = structuredClone(DEFAULTS);\n if (existsSync(CONFIG_FILE)) {\n const saved = JSON.parse(readFileSync(CONFIG_FILE, \"utf-8\"));\n deepMerge(cfg as unknown as Record<string, unknown>, saved);\n }\n return cfg;\n}\n\nexport function saveConfig(cfg: CorpConfig): void {\n mkdirSync(CONFIG_DIR, { recursive: true, mode: 0o700 });\n writeFileSync(CONFIG_FILE, JSON.stringify(cfg, null, 2) + \"\\n\", { mode: 0o600 });\n}\n\nexport function getValue(cfg: Record<string, unknown>, dotPath: string): unknown {\n const keys = dotPath.split(\".\");\n let current: unknown = cfg;\n for (const key of keys) {\n if (typeof current === \"object\" && current !== null && key in current) {\n current = (current as Record<string, unknown>)[key];\n } else {\n return undefined;\n }\n }\n return current;\n}\n\nexport function setValue(cfg: Record<string, unknown>, dotPath: string, value: string): void {\n const keys = dotPath.split(\".\");\n let current = cfg;\n for (const key of keys.slice(0, -1)) {\n if (!(key in current) || typeof current[key] !== \"object\" || current[key] === null) {\n current[key] = {};\n }\n current = current[key] as Record<string, unknown>;\n }\n current[keys[keys.length - 1]] = value;\n}\n\nexport function requireConfig(...fields: string[]): CorpConfig {\n const cfg = loadConfig();\n const missing = fields.filter((f) => !getValue(cfg as unknown as Record<string, unknown>, f));\n if (missing.length > 0) {\n console.error(`Missing config: ${missing.join(\", \")}`);\n console.error(\"Run 'corp setup' to configure.\");\n process.exit(1);\n }\n return cfg;\n}\n\nexport function maskKey(value: string): string {\n if (!value || value.length < 8) return \"***\";\n return \"***\" + value.slice(-4);\n}\n\nexport function configForDisplay(cfg: CorpConfig): Record<string, unknown> {\n const display = { ...cfg } as Record<string, unknown>;\n if (display.api_key) display.api_key = maskKey(display.api_key as string);\n if (typeof display.llm === \"object\" && display.llm !== null) {\n const llm = { ...(display.llm as Record<string, unknown>) };\n if (llm.api_key) llm.api_key = maskKey(llm.api_key as string);\n display.llm = llm;\n }\n return display;\n}\n\nexport function resolveEntityId(cfg: CorpConfig, explicitId?: string): string {\n const eid = explicitId || cfg.active_entity_id;\n if (!eid) {\n console.error(\n \"No entity specified. Use --entity-id or set active_entity_id via 'corp config set active_entity_id <id>'.\"\n );\n process.exit(1);\n }\n return eid;\n}\n","export { CorpAPIClient, SessionExpiredError, provisionWorkspace } from \"@thecorporation/corp-tools\";\n","import chalk from \"chalk\";\nimport Table from \"cli-table3\";\nimport type { ApiRecord } from \"./types.js\";\n\nconst URGENCY_COLORS: Record<string, (s: string) => string> = {\n overdue: chalk.red.bold,\n due_today: chalk.yellow.bold,\n d1: chalk.yellow,\n d7: chalk.cyan,\n d14: chalk.blue,\n d30: chalk.dim,\n upcoming: chalk.dim,\n};\n\nexport function printError(msg: string): void {\n console.error(chalk.red(\"Error:\"), msg);\n}\n\nexport function printSuccess(msg: string): void {\n console.log(chalk.green(msg));\n}\n\nexport function printWarning(msg: string): void {\n console.log(chalk.yellow(msg));\n}\n\nexport function printJson(data: unknown): void {\n console.log(JSON.stringify(data, null, 2));\n}\n\n// --- Status Panel ---\n\nexport function printStatusPanel(data: ApiRecord): void {\n console.log(chalk.blue(\"─\".repeat(50)));\n console.log(chalk.blue.bold(\" Corp Status\"));\n console.log(chalk.blue(\"─\".repeat(50)));\n console.log(` ${chalk.bold(\"Workspace:\")} ${data.workspace_id ?? \"N/A\"}`);\n console.log(` ${chalk.bold(\"Entities:\")} ${data.entity_count ?? 0}`);\n\n const urgency = (data.urgency_counts ?? {}) as Record<string, number>;\n if (Object.keys(urgency).length > 0) {\n console.log(`\\n ${chalk.bold(\"Obligations:\")}`);\n for (const [tier, count] of Object.entries(urgency)) {\n const colorFn = URGENCY_COLORS[tier] ?? ((s: string) => s);\n console.log(` ${colorFn(`${tier}:`)} ${count}`);\n }\n }\n\n if (data.next_deadline) {\n console.log(`\\n ${chalk.bold(\"Next deadline:\")} ${data.next_deadline}`);\n }\n console.log(chalk.blue(\"─\".repeat(50)));\n}\n\n// --- Generic table helper ---\n\nfunction makeTable(title: string, columns: string[]): Table.Table {\n console.log(`\\n${chalk.bold(title)}`);\n return new Table({ head: columns.map((c) => chalk.dim(c)) });\n}\n\nfunction s(val: unknown, maxLen?: number): string {\n const str = val == null ? \"\" : String(val);\n if (maxLen && str.length > maxLen) return str.slice(0, maxLen);\n return str;\n}\n\nfunction money(val: unknown, cents = true): string {\n if (typeof val === \"number\") {\n const dollars = cents ? val / 100 : val;\n return `$${dollars.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;\n }\n return String(val ?? \"\");\n}\n\nfunction date(val: unknown): string {\n const str = s(val);\n if (!str) return \"\";\n const parsed = new Date(str);\n return Number.isNaN(parsed.getTime()) ? str : parsed.toISOString().slice(0, 10);\n}\n\n// --- Domain tables ---\n\nexport function printEntitiesTable(entities: ApiRecord[]): void {\n const table = makeTable(\"Entities\", [\"ID\", \"Name\", \"Type\", \"Jurisdiction\", \"Status\"]);\n for (const e of entities) {\n table.push([s(e.entity_id, 12), s(e.legal_name ?? e.name), s(e.entity_type), s(e.jurisdiction), s(e.formation_status ?? e.status)]);\n }\n console.log(table.toString());\n}\n\nexport function printObligationsTable(obligations: ApiRecord[]): void {\n const table = makeTable(\"Obligations\", [\"ID\", \"Type\", \"Urgency\", \"Due\", \"Status\"]);\n for (const o of obligations) {\n const urg = s(o.urgency) || \"upcoming\";\n const colorFn = URGENCY_COLORS[urg] ?? ((x: string) => x);\n table.push([s(o.obligation_id, 12), s(o.obligation_type), colorFn(urg), s(o.due_at), s(o.status)]);\n }\n console.log(table.toString());\n}\n\nexport function printContactsTable(contacts: ApiRecord[]): void {\n const table = makeTable(\"Contacts\", [\"ID\", \"Name\", \"Email\", \"Category\", \"Entity\"]);\n for (const c of contacts) {\n table.push([\n s(c.contact_id ?? c.id, 12),\n s(c.name),\n s(c.email),\n s(c.category),\n s(c.entity_name ?? c.entity_id),\n ]);\n }\n console.log(table.toString());\n}\n\nexport function printCapTable(data: ApiRecord): void {\n const accessLevel = s(data.access_level) || \"admin\";\n const shareClasses = (data.share_classes ?? []) as ApiRecord[];\n if (shareClasses.length > 0) {\n const cols = [\"Class\", \"Authorized\", \"Outstanding\"];\n if (accessLevel !== \"summary\") cols.push(\"Holders\");\n const table = makeTable(\"Cap Table — Share Classes\", cols);\n for (const sc of shareClasses) {\n const row = [s(sc.class_code ?? sc.name), s(sc.authorized), s(sc.outstanding)];\n if (accessLevel !== \"summary\") {\n const holders = (sc.holders ?? []) as ApiRecord[];\n row.push(holders.map((h) => `${h.name ?? \"?\"}(${h.percentage ?? \"?\"}%)`).join(\", \"));\n }\n table.push(row);\n }\n console.log(table.toString());\n }\n\n const ownership = (data.ownership ?? []) as ApiRecord[];\n if (ownership.length > 0 && accessLevel !== \"summary\") {\n const table = makeTable(\"Ownership Breakdown\", [\"Holder\", \"Shares\", \"Percentage\", \"Class\"]);\n for (const o of ownership) {\n table.push([s(o.holder_name ?? o.name), s(o.shares), `${o.percentage ?? \"\"}%`, s(o.share_class)]);\n }\n console.log(table.toString());\n }\n\n const pools = (data.option_pools ?? []) as ApiRecord[];\n if (pools.length > 0) {\n const table = makeTable(\"Option Pools\", [\"Name\", \"Authorized\", \"Granted\", \"Available\"]);\n for (const p of pools) {\n table.push([s(p.name), s(p.authorized), s(p.granted), s(p.available)]);\n }\n console.log(table.toString());\n }\n\n if (data.fully_diluted_shares != null) {\n const fd = data.fully_diluted_shares;\n console.log(`\\n${chalk.bold(\"Fully Diluted Shares:\")} ${typeof fd === \"number\" ? fd.toLocaleString() : fd}`);\n }\n}\n\nexport function printSafesTable(safes: ApiRecord[]): void {\n const table = makeTable(\"SAFE Notes\", [\"ID\", \"Investor\", \"Amount\", \"Cap\", \"Discount\", \"Date\"]);\n for (const s_ of safes) {\n table.push([\n s(s_.safe_id ?? s_.id, 12),\n s(s_.investor_name ?? s_.investor),\n money(s_.investment_amount ?? s_.amount, false),\n s(s_.valuation_cap ?? s_.cap),\n s(s_.discount_rate ?? s_.discount),\n s(s_.date ?? s_.created_at),\n ]);\n }\n console.log(table.toString());\n}\n\nexport function printTransfersTable(transfers: ApiRecord[]): void {\n const table = makeTable(\"Share Transfers\", [\"ID\", \"From\", \"To\", \"Shares\", \"Class\", \"Date\"]);\n for (const t of transfers) {\n table.push([\n s(t.transfer_id ?? t.id, 12),\n s(t.from_holder ?? t.from),\n s(t.to_holder ?? t.to),\n s(t.shares),\n s(t.share_class),\n s(t.date ?? t.transfer_date),\n ]);\n }\n console.log(table.toString());\n}\n\nexport function printValuationsTable(valuations: ApiRecord[]): void {\n const table = makeTable(\"Valuations\", [\"Date\", \"Type\", \"Valuation\", \"PPS\"]);\n for (const v of valuations) {\n table.push([\n date(v.effective_date ?? v.valuation_date ?? v.date),\n s(v.valuation_type ?? v.type),\n money(v.enterprise_value_cents ?? v.enterprise_value ?? v.valuation),\n money(v.fmv_per_share_cents ?? v.price_per_share ?? v.pps ?? v.fmv_per_share),\n ]);\n }\n console.log(table.toString());\n}\n\nexport function printGovernanceTable(bodies: ApiRecord[]): void {\n const table = makeTable(\"Governance Bodies\", [\"ID\", \"Body\", \"Type\", \"Seats\", \"Meetings\"]);\n for (const b of bodies) {\n table.push([\n s(b.body_id ?? b.id, 12),\n s(b.name),\n s(b.body_type ?? b.type),\n s(b.seat_count ?? b.seats),\n s(b.meeting_count ?? b.meetings),\n ]);\n }\n console.log(table.toString());\n}\n\nexport function printSeatsTable(seats: ApiRecord[]): void {\n const table = makeTable(\"Seats\", [\"Seat\", \"Holder\", \"Role\", \"Status\"]);\n for (const st of seats) {\n table.push([s(st.seat_name ?? st.title), s(st.holder_name ?? st.holder), s(st.role), s(st.status)]);\n }\n console.log(table.toString());\n}\n\nexport function printMeetingsTable(meetings: ApiRecord[]): void {\n const table = makeTable(\"Meetings\", [\"ID\", \"Title\", \"Date\", \"Status\", \"Resolutions\"]);\n for (const m of meetings) {\n table.push([\n s(m.meeting_id ?? m.id, 12),\n s(m.title ?? m.name),\n s(m.scheduled_date ?? m.meeting_date ?? m.date),\n s(m.status),\n s(m.resolution_count ?? m.resolutions),\n ]);\n }\n console.log(table.toString());\n}\n\nexport function printResolutionsTable(resolutions: ApiRecord[]): void {\n const table = makeTable(\"Resolutions\", [\"ID\", \"Title\", \"Type\", \"Status\", \"For\", \"Against\"]);\n for (const r of resolutions) {\n table.push([\n s(r.resolution_id ?? r.id, 12),\n s(r.title),\n s(r.resolution_type ?? r.type),\n s(r.status),\n s(r.votes_for),\n s(r.votes_against),\n ]);\n }\n console.log(table.toString());\n}\n\nexport function printDocumentsTable(docs: ApiRecord[]): void {\n const table = makeTable(\"Documents\", [\"ID\", \"Title\", \"Type\", \"Date\", \"Status\", \"Signatures\"]);\n for (const d of docs) {\n const sigs = d.signatures;\n const sigStr = Array.isArray(sigs) ? `${sigs.length} signed` : s(sigs);\n table.push([\n s(d.document_id ?? d.id, 12),\n s(d.title ?? d.name),\n s(d.document_type ?? d.type),\n s(d.date ?? d.created_at),\n s(d.status),\n sigStr,\n ]);\n }\n console.log(table.toString());\n}\n\nexport function printWorkItemsTable(items: ApiRecord[]): void {\n const table = makeTable(\"Work Items\", [\"ID\", \"Title\", \"Category\", \"Status\", \"Deadline\", \"Claimed By\"]);\n for (const w of items) {\n const status = s(w.effective_status ?? w.status);\n const colored =\n status === \"completed\" ? chalk.green(status) :\n status === \"claimed\" ? chalk.yellow(status) :\n status === \"cancelled\" ? chalk.dim(status) :\n status;\n table.push([\n s(w.work_item_id ?? w.id, 12),\n s(w.title),\n s(w.category),\n colored,\n w.asap ? chalk.red.bold(\"ASAP\") : s(w.deadline ?? \"\"),\n s(w.claimed_by ?? \"\"),\n ]);\n }\n console.log(table.toString());\n}\n\nexport function printAgentsTable(agents: ApiRecord[]): void {\n const table = makeTable(\"Agents\", [\"ID\", \"Name\", \"Status\", \"Model\"]);\n for (const a of agents) {\n const status = s(a.status);\n const colored =\n status === \"active\" ? chalk.green(status) : status === \"paused\" ? chalk.yellow(status) : status;\n table.push([s(a.agent_id ?? a.id, 12), s(a.name), colored, s(a.model)]);\n }\n console.log(table.toString());\n}\n\nexport function printApprovalsTable(approvals: ApiRecord[]): void {\n const table = makeTable(\"Pending Approvals\", [\"ID\", \"Type\", \"Requested By\", \"Description\", \"Created\"]);\n for (const a of approvals) {\n let desc = s(a.description ?? a.summary);\n if (desc.length > 60) desc = desc.slice(0, 57) + \"...\";\n table.push([\n s(a.approval_id ?? a.id, 12),\n s(a.approval_type ?? a.type),\n s(a.requested_by ?? a.requester),\n desc,\n s(a.created_at),\n ]);\n }\n console.log(table.toString());\n}\n\nexport function printBillingPanel(status: ApiRecord, plans: ApiRecord[]): void {\n const plan = s(status.plan ?? status.tier) || \"free\";\n const subStatus = s(status.status) || \"active\";\n const periodEnd = s(status.current_period_end);\n const explanation = s(status.status_explanation);\n\n console.log(chalk.green(\"─\".repeat(50)));\n console.log(chalk.green.bold(\" Billing Status\"));\n console.log(chalk.green(\"─\".repeat(50)));\n console.log(` ${chalk.bold(\"Plan:\")} ${plan}`);\n console.log(` ${chalk.bold(\"Status:\")} ${subStatus}`);\n if (periodEnd) console.log(` ${chalk.bold(\"Current Period End:\")} ${periodEnd}`);\n if (explanation) console.log(` ${chalk.bold(\"Explanation:\")} ${explanation}`);\n console.log(chalk.dim(\" Manage: corp billing portal\"));\n console.log(chalk.dim(\" Upgrade: corp billing upgrade --plan <plan>\"));\n console.log(chalk.green(\"─\".repeat(50)));\n\n if (plans.length > 0) {\n const table = makeTable(\"Available Plans\", [\"Plan\", \"Price\", \"Features\"]);\n for (const p of plans) {\n const amount = (p.price_cents ?? p.amount ?? 0) as number;\n const interval = s(p.interval);\n let priceStr = \"Free\";\n if (amount > 0) {\n priceStr = interval ? `$${Math.round(amount / 100)}/${interval}` : `$${Math.round(amount / 100)}`;\n }\n const name = s(p.name ?? p.plan_id ?? p.tier);\n const features = Array.isArray(p.features) ? (p.features as string[]).join(\", \") : s(p.description);\n table.push([name, priceStr, features]);\n }\n console.log(table.toString());\n }\n}\n","import { input, confirm } from \"@inquirer/prompts\";\nimport { loadConfig, saveConfig } from \"../config.js\";\nimport { provisionWorkspace } from \"../api-client.js\";\nimport { printSuccess, printError } from \"../output.js\";\n\nconst CLOUD_API_URL = \"https://api.thecorporation.ai\";\n\nasync function requestMagicLink(\n apiUrl: string,\n email: string,\n tosAccepted: boolean\n): Promise<void> {\n const resp = await fetch(`${apiUrl}/v1/auth/magic-link`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ email, tos_accepted: tosAccepted }),\n });\n if (!resp.ok) {\n const data = await resp.json().catch(() => ({}));\n const detail =\n (data as Record<string, unknown>)?.error ??\n (data as Record<string, unknown>)?.message ??\n resp.statusText;\n throw new Error(\n typeof detail === \"string\" ? detail : JSON.stringify(detail)\n );\n }\n}\n\nasync function verifyMagicLinkCode(\n apiUrl: string,\n code: string\n): Promise<{ api_key: string; workspace_id: string }> {\n const resp = await fetch(`${apiUrl}/v1/auth/magic-link/verify`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ code, client: \"cli\" }),\n });\n const data = (await resp.json().catch(() => ({}))) as Record<string, unknown>;\n if (!resp.ok) {\n const detail = data?.error ?? data?.message ?? resp.statusText;\n throw new Error(\n typeof detail === \"string\" ? detail : JSON.stringify(detail)\n );\n }\n if (!data.api_key || !data.workspace_id) {\n throw new Error(\"Unexpected response — missing api_key or workspace_id\");\n }\n return {\n api_key: data.api_key as string,\n workspace_id: data.workspace_id as string,\n };\n}\n\nfunction isCloudApi(url: string): boolean {\n return url.replace(/\\/+$/, \"\").includes(\"thecorporation.ai\");\n}\n\nasync function magicLinkAuth(\n apiUrl: string,\n email: string\n): Promise<{ api_key: string; workspace_id: string }> {\n console.log(\"\\nSending magic link to \" + email + \"...\");\n await requestMagicLink(apiUrl, email, true);\n console.log(\"Check your email for a sign-in link from TheCorporation.\");\n console.log(\n \"Copy the code from the URL (the ?code=... part) and paste it below.\\n\"\n );\n\n const code = await input({ message: \"Paste your magic link code\" });\n const trimmed = code.trim().replace(/^.*[?&]code=/, \"\");\n if (!trimmed) {\n throw new Error(\"No code provided\");\n }\n\n console.log(\"Verifying...\");\n return verifyMagicLinkCode(apiUrl, trimmed);\n}\n\nexport async function setupCommand(): Promise<void> {\n const cfg = loadConfig();\n console.log(\"Welcome to corp — corporate governance from the terminal.\\n\");\n\n // Determine API URL\n const customUrl = process.env.CORP_API_URL;\n if (customUrl) {\n cfg.api_url = customUrl.replace(/\\/+$/, \"\");\n console.log(`Using API: ${cfg.api_url}\\n`);\n } else {\n cfg.api_url = CLOUD_API_URL;\n }\n\n console.log(\"--- User Info ---\");\n const user = cfg.user ?? { name: \"\", email: \"\" };\n user.name = await input({\n message: \"Your name\",\n default: user.name || undefined,\n });\n user.email = await input({\n message: \"Your email\",\n default: user.email || undefined,\n });\n cfg.user = user;\n\n const needsAuth = !cfg.api_key || !cfg.workspace_id;\n const cloud = isCloudApi(cfg.api_url);\n\n if (needsAuth) {\n if (cloud) {\n // Cloud API — authenticate via magic link\n try {\n const result = await magicLinkAuth(cfg.api_url, user.email);\n cfg.api_key = result.api_key;\n cfg.workspace_id = result.workspace_id;\n printSuccess(`Authenticated. Workspace: ${result.workspace_id}`);\n } catch (err) {\n printError(`Authentication failed: ${err}`);\n console.log(\n \"You can manually set credentials with: corp config set api_key <key>\"\n );\n }\n } else {\n // Self-hosted — provision directly (no auth required)\n console.log(\"\\nProvisioning workspace...\");\n try {\n const result = await provisionWorkspace(\n cfg.api_url,\n `${user.name}'s workspace`\n );\n cfg.api_key = result.api_key as string;\n cfg.workspace_id = result.workspace_id as string;\n console.log(`Workspace provisioned: ${result.workspace_id}`);\n } catch (err) {\n printError(`Auto-provision failed: ${err}`);\n console.log(\n \"You can manually set credentials with: corp config set api_key <key>\"\n );\n }\n }\n } else {\n console.log(\"\\nVerifying existing credentials...\");\n let keyValid = false;\n try {\n const resp = await fetch(\n `${cfg.api_url.replace(/\\/+$/, \"\")}/v1/workspaces/${cfg.workspace_id}/status`,\n { headers: { Authorization: `Bearer ${cfg.api_key}` } }\n );\n keyValid = resp.status !== 401;\n } catch {\n // network error — treat as potentially valid\n }\n\n if (keyValid) {\n console.log(\"Credentials OK.\");\n } else {\n console.log(\"API key is no longer valid.\");\n const reauth = await confirm({\n message: cloud\n ? \"Re-authenticate via magic link?\"\n : \"Provision a new workspace? (This will replace your current credentials)\",\n default: true,\n });\n if (reauth) {\n try {\n if (cloud) {\n const result = await magicLinkAuth(cfg.api_url, user.email);\n cfg.api_key = result.api_key;\n cfg.workspace_id = result.workspace_id;\n printSuccess(`Authenticated. Workspace: ${result.workspace_id}`);\n } else {\n const result = await provisionWorkspace(\n cfg.api_url,\n `${user.name}'s workspace`\n );\n cfg.api_key = result.api_key as string;\n cfg.workspace_id = result.workspace_id as string;\n console.log(`Workspace provisioned: ${result.workspace_id}`);\n }\n } catch (err) {\n printError(`Authentication failed: ${err}`);\n }\n } else {\n console.log(\n \"Keeping existing credentials. You can manually update with: corp config set api_key <key>\"\n );\n }\n }\n }\n\n saveConfig(cfg);\n console.log(\"\\nConfig saved to ~/.corp/config.json\");\n console.log(\"Run 'corp status' to verify your connection.\");\n}\n","/**\n * Rising cityscape boot animation — ported from packages/cli/corp/tui/widgets/mascot.py\n */\n\n// prettier-ignore\nconst BUILDINGS: string[][] = [\n [\n \" ┌┐ \",\n \" ││ \",\n \" ││ \",\n \" ┌┤├┐ \",\n \" │││││\",\n \" │││││\",\n ],\n [\n \" ╔══╗ \",\n \" ║▪▪║ \",\n \" ║▪▪║ \",\n \" ║▪▪║ \",\n \" ║▪▪║ \",\n \" ║▪▪║ \",\n \" ║▪▪║ \",\n \" ║▪▪║ \",\n ],\n [\n \" /\\\\ \",\n \" / \\\\ \",\n \" │▪▪│ \",\n \" │▪▪│ \",\n \" │▪▪│ \",\n ],\n [\n \" ┌──┐ \",\n \" │≋≋│ \",\n \" │▪▪│ \",\n \" │▪▪│ \",\n \" │▪▪│ \",\n \" │▪▪│ \",\n \" │▪▪│ \",\n \" │▪▪│ \",\n \" │▪▪│ \",\n ],\n [\n \" ╻ \",\n \" ┃ \",\n \" ┌┤┐ \",\n \" │▪│ \",\n \" │▪│ \",\n \" │▪│ \",\n \" │▪│ \",\n \" │▪│ \",\n \" │▪│ \",\n \" │▪│ \",\n \" │▪│ \",\n ],\n [\n \" ┌┐ \",\n \" ├┤ \",\n \" │▪│ \",\n \" │▪│ \",\n \" │▪│ \",\n \" │▪│ \",\n ],\n [\n \" ╔═══╗\",\n \" ║▪ ▪║\",\n \" ║▪ ▪║\",\n \" ║▪ ▪║\",\n \" ║▪ ▪║\",\n \" ║▪ ▪║\",\n \" ║▪ ▪║\",\n \" ║▪ ▪║\",\n \" ║▪ ▪║\",\n \" ║▪ ▪║\",\n ],\n [\n \" ┬─┬ \",\n \" │~│ \",\n \" │▪│ \",\n \" │▪│ \",\n \" │▪│ \",\n \" │▪│ \",\n \" │▪│ \",\n ],\n];\n\nconst MAX_HEIGHT = Math.max(...BUILDINGS.map((b) => b.length));\nconst TOTAL_FRAMES = MAX_HEIGHT + 4; // 15 frames, ~1.5s at 100ms\n\nconst GOLD = \"\\x1b[38;2;212;160;23m\";\nconst RESET = \"\\x1b[0m\";\n\nexport function renderFrame(frame: number): string {\n const cols: string[][] = [];\n for (let i = 0; i < BUILDINGS.length; i++) {\n const building = BUILDINGS[i];\n const h = building.length;\n const visible = Math.max(0, Math.min(h, frame - i));\n const width = building[0]?.length ?? 6;\n const blank = \" \".repeat(width);\n const col: string[] = Array(MAX_HEIGHT - visible).fill(blank);\n col.push(...building.slice(h - visible));\n cols.push(col);\n }\n\n const lines: string[] = [];\n for (let row = 0; row < MAX_HEIGHT; row++) {\n lines.push(cols.map((col) => col[row]).join(\"\"));\n }\n return lines.join(\"\\n\");\n}\n\n/**\n * Run an async function while displaying the rising cityscape animation.\n * No-ops when stdout is not a TTY (piped, CI, etc.).\n */\nexport async function withAnimation<T>(fn: () => Promise<T>): Promise<T> {\n if (!process.stdout.isTTY) {\n return fn();\n }\n\n let frame = 0;\n let animDone = false;\n const spinChars = [\"⠋\", \"⠙\", \"⠹\", \"⠸\", \"⠼\", \"⠴\", \"⠦\", \"⠧\", \"⠇\", \"⠏\"];\n let spinIdx = 0;\n let lastLineCount = 0;\n\n const clearPrev = () => {\n if (lastLineCount > 0) {\n process.stdout.write(`\\x1b[${lastLineCount}A\\x1b[0J`);\n }\n };\n\n const drawFrame = () => {\n clearPrev();\n if (!animDone) {\n const art = renderFrame(frame);\n const output = `${GOLD}${art}${RESET}\\n`;\n process.stdout.write(output);\n lastLineCount = MAX_HEIGHT + 1;\n frame++;\n if (frame >= TOTAL_FRAMES) {\n animDone = true;\n }\n } else {\n // Dot spinner fallback after animation finishes\n const line = `${GOLD}${spinChars[spinIdx % spinChars.length]} Loading...${RESET}\\n`;\n process.stdout.write(line);\n lastLineCount = 1;\n spinIdx++;\n }\n };\n\n drawFrame();\n const timer = setInterval(drawFrame, 100);\n\n try {\n const result = await fn();\n return result;\n } finally {\n clearInterval(timer);\n clearPrev();\n }\n}\n","import { withAnimation } from \"./animation.js\";\n\n/**\n * Run an async function with a loading animation.\n * Silently skipped when `json` is truthy (pure JSON output) or non-TTY.\n */\nexport async function withSpinner<T>(\n _label: string,\n fn: () => Promise<T>,\n json?: boolean,\n): Promise<T> {\n if (json) {\n return fn();\n }\n return withAnimation(fn);\n}\n","import { requireConfig } from \"../config.js\";\nimport { CorpAPIClient } from \"../api-client.js\";\nimport { printError, printStatusPanel } from \"../output.js\";\nimport { withSpinner } from \"../spinner.js\";\n\nexport async function statusCommand(): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const data = await withSpinner(\"Loading\", () => client.getStatus());\n printStatusPanel(data);\n } catch (err) {\n printError(`Failed to fetch status: ${err}`);\n process.exit(1);\n }\n}\n","import { configForDisplay, getValue, loadConfig, saveConfig, setValue } from \"../config.js\";\nimport { printError, printJson } from \"../output.js\";\n\nexport function configSetCommand(key: string, value: string): void {\n const cfg = loadConfig();\n setValue(cfg as unknown as Record<string, unknown>, key, value);\n saveConfig(cfg);\n console.log(`${key} = ${value}`);\n}\n\nexport function configGetCommand(key: string): void {\n const cfg = loadConfig();\n const val = getValue(cfg as unknown as Record<string, unknown>, key);\n if (val === undefined) {\n printError(`Key not found: ${key}`);\n process.exit(1);\n }\n if (typeof val === \"object\" && val !== null) {\n printJson(val);\n } else {\n console.log(String(val));\n }\n}\n\nexport function configListCommand(): void {\n const cfg = loadConfig();\n printJson(configForDisplay(cfg));\n}\n","import { requireConfig } from \"../config.js\";\nimport { CorpAPIClient } from \"../api-client.js\";\nimport { printObligationsTable, printError, printJson } from \"../output.js\";\n\nexport async function obligationsCommand(opts: { tier?: string; json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const data = await client.getObligations(opts.tier);\n const obligations = (data.obligations ?? []) as Record<string, unknown>[];\n if (opts.json) printJson(obligations);\n else if (obligations.length === 0) console.log(\"No obligations found.\");\n else printObligationsTable(obligations);\n } catch (err) { printError(`Failed to fetch obligations: ${err}`); process.exit(1); }\n}\n","import { requireConfig } from \"../config.js\";\nimport { CorpAPIClient } from \"../api-client.js\";\nimport { printError, printSuccess, printJson, printWarning } from \"../output.js\";\n\nexport async function digestCommand(opts: { trigger?: boolean; key?: string }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n if (opts.trigger) {\n const result = await client.triggerDigest();\n const message = (() => {\n const value = (result as Record<string, unknown>).message;\n return typeof value === \"string\" && value.trim() ? value : null;\n })();\n printSuccess(result.digest_count > 0 ? \"Digest triggered.\" : \"Digest trigger accepted.\");\n if (message) {\n printWarning(message);\n }\n printJson(result);\n } else if (opts.key) {\n const result = await client.getDigest(opts.key);\n printJson(result);\n } else {\n const digests = await client.listDigests();\n if (digests.length === 0) console.log(\"No digest history found.\");\n else printJson(digests);\n }\n } catch (err) { printError(`Failed: ${err}`); process.exit(1); }\n}\n","import { requireConfig } from \"../config.js\";\nimport { CorpAPIClient } from \"../api-client.js\";\nimport { printError, printSuccess } from \"../output.js\";\n\nexport async function linkCommand(opts: { externalId: string; provider: string }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const data = await client.createLink(opts.externalId, opts.provider);\n printSuccess(`Workspace linked to ${opts.provider} (external ID: ${opts.externalId})`);\n if (data.workspace_id) console.log(` Workspace: ${data.workspace_id}`);\n } catch (err) {\n printError(`${err}`);\n process.exit(1);\n }\n}\n","import { loadConfig, saveConfig } from \"../config.js\";\nimport { printError } from \"../output.js\";\n\nexport async function claimCommand(code: string): Promise<void> {\n const cfg = loadConfig();\n const apiUrl = (cfg.api_url || \"https://api.thecorporation.ai\").replace(/\\/+$/, \"\");\n try {\n const resp = await fetch(`${apiUrl}/v1/workspaces/claim`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ code }),\n });\n if (!resp.ok) {\n let detail = \"\";\n try { const body = await resp.json() as Record<string, string>; detail = body.detail ?? \"\"; } catch { /* ignore */ }\n printError(detail || `${resp.status} ${resp.statusText}`);\n process.exit(1);\n }\n const data = await resp.json() as Record<string, string>;\n cfg.api_key = data.api_key;\n cfg.workspace_id = data.workspace_id;\n saveConfig(cfg);\n console.log(`Workspace joined: ${data.workspace_id}`);\n console.log(\"Credentials saved to ~/.corp/config.json\");\n } catch (err) {\n printError(`${err}`);\n process.exit(1);\n }\n}\n","import type { ToolCall, LLMResponse } from \"./types.js\";\n\nconst PROVIDER_BASE_URLS: Record<string, string> = {\n openrouter: \"https://openrouter.ai/api/v1\",\n};\n\nexport async function chat(\n messages: Record<string, unknown>[],\n tools?: Record<string, unknown>[],\n provider = \"anthropic\",\n apiKey = \"\",\n model = \"\",\n baseUrl?: string,\n): Promise<LLMResponse> {\n if (provider === \"anthropic\") {\n return chatAnthropic(messages, tools, apiKey, model);\n } else if (provider === \"openai\" || provider === \"openrouter\") {\n const effectiveUrl = baseUrl ?? PROVIDER_BASE_URLS[provider];\n return chatOpenAI(messages, tools, apiKey, model, effectiveUrl);\n }\n throw new Error(`Unknown LLM provider: ${provider}`);\n}\n\nasync function chatAnthropic(\n messages: Record<string, unknown>[],\n tools?: Record<string, unknown>[],\n apiKey = \"\",\n model = \"\",\n): Promise<LLMResponse> {\n const { default: Anthropic } = await import(\"@anthropic-ai/sdk\");\n const client = new Anthropic({ apiKey });\n\n let systemText = \"\";\n const convMessages: Record<string, unknown>[] = [];\n\n for (const msg of messages) {\n if (msg.role === \"system\") {\n systemText = msg.content as string;\n } else if (msg.role === \"tool\") {\n convMessages.push({\n role: \"user\",\n content: [{\n type: \"tool_result\",\n tool_use_id: msg.tool_call_id,\n content: msg.content,\n }],\n });\n } else if (msg.role === \"assistant\" && msg.tool_calls) {\n const contentBlocks: Record<string, unknown>[] = [];\n if (msg.content) contentBlocks.push({ type: \"text\", text: msg.content });\n for (const tc of msg.tool_calls as Record<string, unknown>[]) {\n const fn = tc.function as Record<string, unknown>;\n let args = fn.arguments;\n if (typeof args === \"string\") args = JSON.parse(args);\n contentBlocks.push({ type: \"tool_use\", id: tc.id, name: fn.name, input: args });\n }\n convMessages.push({ role: \"assistant\", content: contentBlocks });\n } else {\n convMessages.push({ role: msg.role, content: msg.content ?? \"\" });\n }\n }\n\n let anthropicTools: Record<string, unknown>[] | undefined;\n if (tools?.length) {\n anthropicTools = tools.map((t) => {\n const fn = (t as Record<string, unknown>).function as Record<string, unknown>;\n return {\n name: fn.name,\n description: fn.description ?? \"\",\n input_schema: fn.parameters ?? { type: \"object\", properties: {} },\n };\n });\n }\n\n const kwargs: Record<string, unknown> = {\n model: model || \"claude-sonnet-4-20250514\",\n max_tokens: 4096,\n messages: convMessages,\n };\n if (systemText) kwargs.system = systemText;\n if (anthropicTools) kwargs.tools = anthropicTools;\n\n const response = await client.messages.create(kwargs as Parameters<typeof client.messages.create>[0]);\n\n let content: string | null = null;\n const toolCallsOut: ToolCall[] = [];\n for (const block of response.content) {\n if (block.type === \"text\") {\n content = block.text;\n } else if (block.type === \"tool_use\") {\n toolCallsOut.push({\n id: block.id,\n name: block.name,\n arguments: typeof block.input === \"object\" ? (block.input as Record<string, unknown>) : {},\n });\n }\n }\n\n return {\n content,\n tool_calls: toolCallsOut,\n usage: {\n prompt_tokens: response.usage.input_tokens,\n completion_tokens: response.usage.output_tokens,\n total_tokens: response.usage.input_tokens + response.usage.output_tokens,\n },\n finish_reason: response.stop_reason ?? null,\n };\n}\n\nasync function chatOpenAI(\n messages: Record<string, unknown>[],\n tools?: Record<string, unknown>[],\n apiKey = \"\",\n model = \"\",\n baseUrl?: string,\n): Promise<LLMResponse> {\n const { default: OpenAI } = await import(\"openai\");\n const clientOpts: Record<string, unknown> = { apiKey };\n if (baseUrl) clientOpts.baseURL = baseUrl;\n const client = new OpenAI(clientOpts as ConstructorParameters<typeof OpenAI>[0]);\n\n const kwargs: Record<string, unknown> = {\n model: model || \"gpt-4o\",\n messages,\n max_tokens: 4096,\n };\n if (tools?.length) {\n kwargs.tools = tools;\n kwargs.tool_choice = \"auto\";\n }\n\n const response = await client.chat.completions.create(kwargs as Parameters<typeof client.chat.completions.create>[0]);\n const choice = response.choices[0];\n const message = choice.message;\n\n const toolCallsOut: ToolCall[] = [];\n if (message.tool_calls) {\n for (const tc of message.tool_calls) {\n let args: Record<string, unknown>;\n try {\n args = JSON.parse(tc.function.arguments);\n } catch {\n args = { _raw: tc.function.arguments };\n }\n toolCallsOut.push({ id: tc.id, name: tc.function.name, arguments: args });\n }\n }\n\n return {\n content: message.content,\n tool_calls: toolCallsOut,\n usage: {\n prompt_tokens: response.usage?.prompt_tokens ?? 0,\n completion_tokens: response.usage?.completion_tokens ?? 0,\n total_tokens: response.usage?.total_tokens ?? 0,\n },\n finish_reason: choice.finish_reason ?? null,\n };\n}\n","import {\n TOOL_DEFINITIONS as _TOOL_DEFINITIONS,\n isWriteTool as _isWriteTool,\n executeTool as _executeTool,\n} from \"@thecorporation/corp-tools\";\nimport type { CorpAPIClient } from \"@thecorporation/corp-tools\";\nimport { loadConfig, saveConfig } from \"./config.js\";\nimport { join } from \"node:path\";\nimport { homedir } from \"node:os\";\n\nexport const TOOL_DEFINITIONS = _TOOL_DEFINITIONS;\nexport const isWriteTool: (name: string, args?: Record<string, unknown>) => boolean = _isWriteTool;\n\nexport async function executeTool(\n name: string,\n args: Record<string, unknown>,\n client: CorpAPIClient,\n): Promise<string> {\n return _executeTool(name, args, client, {\n dataDir: join(homedir(), \".corp\"),\n onEntityFormed: (entityId) => {\n try {\n const cfg = loadConfig();\n cfg.active_entity_id = entityId;\n saveConfig(cfg);\n } catch { /* ignore */ }\n },\n });\n}\n","import { createInterface } from \"node:readline\";\nimport chalk from \"chalk\";\nimport { requireConfig, configForDisplay, getValue, setValue, saveConfig } from \"./config.js\";\nimport { CorpAPIClient } from \"./api-client.js\";\nimport { chat as llmChat } from \"./llm.js\";\nimport { TOOL_DEFINITIONS, executeTool, isWriteTool } from \"./tools.js\";\nimport { printError, printStatusPanel, printObligationsTable, printJson } from \"./output.js\";\nimport type { CorpConfig, LLMResponse, ToolCall } from \"./types.js\";\n\nconst SYSTEM_PROMPT = `You are **corp**, an AI assistant for corporate governance.\nYou help users manage their companies — entities, cap tables, compliance, governance, finances, and more.\nYou have tools to read and write corporate data. Use them to fulfill user requests.\nFor write operations, confirm with the user before proceeding.\nMonetary values are in cents (e.g. 100000 = $1,000.00).\nDocuments must be signed by the human — you cannot sign on their behalf.\nAfter completing actions, suggest logical next steps.`;\n\nexport async function chatCommand(): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\", \"llm.api_key\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n\n const messages: Record<string, unknown>[] = [{ role: \"system\", content: SYSTEM_PROMPT }];\n let totalTokens = 0;\n\n const rl = createInterface({ input: process.stdin, output: process.stdout });\n const prompt = () => new Promise<string>((resolve) => rl.question(chalk.green.bold(\"> \"), resolve));\n\n console.log(chalk.blue.bold(\"corp chat\") + \" — type /help for commands, /quit to exit\\n\");\n\n const slashHandlers: Record<string, (args: string) => void> = {\n \"/status\": async () => {\n try { printStatusPanel(await client.getStatus()); } catch (e) { printError(`Status error: ${e}`); }\n },\n \"/obligations\": async () => {\n try {\n const data = await client.getObligations();\n const obls = (data.obligations ?? []) as Record<string, unknown>[];\n if (obls.length) printObligationsTable(obls);\n else console.log(chalk.dim(\"No obligations found.\"));\n } catch (e) { printError(`Obligations error: ${e}`); }\n },\n \"/digest\": async () => {\n try {\n const digests = await client.listDigests();\n if (digests.length) printJson(digests);\n else console.log(chalk.dim(\"No digest history.\"));\n } catch (e) { printError(`Digest error: ${e}`); }\n },\n \"/config\": () => printJson(configForDisplay(cfg)),\n \"/model\": (args: string) => {\n const model = args.trim();\n if (!model) { console.log(`Current model: ${getValue(cfg as unknown as Record<string, unknown>, \"llm.model\")}`); return; }\n setValue(cfg as unknown as Record<string, unknown>, \"llm.model\", model);\n saveConfig(cfg);\n console.log(`Model switched to: ${model}`);\n },\n \"/cost\": () => console.log(`Session tokens used: ${totalTokens.toLocaleString()}`),\n \"/clear\": () => {\n messages.length = 0;\n messages.push({ role: \"system\", content: SYSTEM_PROMPT });\n totalTokens = 0;\n console.log(chalk.dim(\"Conversation cleared.\"));\n },\n \"/help\": () => {\n console.log(`\n${chalk.bold(\"Chat Slash Commands\")}\n /status Show workspace status\n /obligations List obligations\n /digest Show digest history\n /config Show current config (masked keys)\n /model <name> Switch LLM model\n /cost Show token usage\n /clear Clear conversation\n /help Show this help\n /quit Exit chat`);\n },\n };\n\n try {\n while (true) {\n let userInput: string;\n try {\n userInput = (await prompt()).trim();\n } catch {\n console.log(\"\\n\" + chalk.dim(\"Goodbye.\"));\n break;\n }\n\n if (!userInput) continue;\n\n if (userInput.startsWith(\"/\")) {\n const [cmd, ...rest] = userInput.split(/\\s+/);\n const args = rest.join(\" \");\n if (cmd === \"/quit\" || cmd === \"/exit\") {\n console.log(chalk.dim(\"Goodbye.\"));\n break;\n }\n const handler = slashHandlers[cmd.toLowerCase()];\n if (handler) { await handler(args); continue; }\n printError(`Unknown command: ${cmd}. Type /help for available commands.`);\n continue;\n }\n\n messages.push({ role: \"user\", content: userInput });\n\n const llmCfg = cfg.llm;\n while (true) {\n let response: LLMResponse;\n try {\n response = await llmChat(\n messages, TOOL_DEFINITIONS, llmCfg.provider, llmCfg.api_key, llmCfg.model, llmCfg.base_url,\n );\n } catch (err) {\n printError(`LLM error: ${err}`);\n break;\n }\n\n totalTokens += response.usage.total_tokens;\n\n const assistantMsg: Record<string, unknown> = { role: \"assistant\", content: response.content };\n if (response.tool_calls.length > 0) {\n assistantMsg.tool_calls = response.tool_calls.map((tc) => ({\n id: tc.id, type: \"function\",\n function: { name: tc.name, arguments: JSON.stringify(tc.arguments) },\n }));\n if (!response.content) assistantMsg.content = null;\n }\n messages.push(assistantMsg);\n\n if (response.tool_calls.length === 0) {\n if (response.content) console.log(\"\\n\" + response.content + \"\\n\");\n break;\n }\n\n for (const tc of response.tool_calls) {\n console.log(chalk.dim(` ${isWriteTool(tc.name, tc.arguments) ? \"\\u2699\" : \"\\u2139\"} ${tc.name}(${JSON.stringify(tc.arguments).slice(0, 80)})`));\n const result = await executeTool(tc.name, tc.arguments, client);\n const short = result.length > 200 ? result.slice(0, 197) + \"...\" : result;\n console.log(chalk.dim(` => ${short}`));\n messages.push({ role: \"tool\", tool_call_id: tc.id, content: result });\n }\n }\n }\n } finally {\n rl.close();\n }\n}\n","import { requireConfig } from \"../config.js\";\nimport { CorpAPIClient } from \"../api-client.js\";\nimport { printEntitiesTable, printError, printSuccess, printJson } from \"../output.js\";\nimport { withSpinner } from \"../spinner.js\";\nimport chalk from \"chalk\";\n\nexport async function entitiesCommand(opts: { json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n const jsonOutput = Boolean(opts.json);\n try {\n const entities = await withSpinner(\"Loading\", () => client.listEntities(), jsonOutput);\n if (jsonOutput) {\n printJson(entities);\n } else if (entities.length === 0) {\n console.log(\"No entities found.\");\n } else {\n printEntitiesTable(entities);\n }\n } catch (err) {\n printError(`Failed to fetch entities: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function entitiesShowCommand(entityId: string, opts: { json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n const jsonOutput = Boolean(opts.json);\n try {\n const entities = await client.listEntities();\n const entity = entities.find((e) => e.entity_id === entityId);\n if (!entity) {\n printError(`Entity not found: ${entityId}`);\n process.exit(1);\n }\n if (jsonOutput) {\n printJson(entity);\n } else {\n console.log(chalk.blue(\"─\".repeat(40)));\n console.log(chalk.blue.bold(\" Entity Detail\"));\n console.log(chalk.blue(\"─\".repeat(40)));\n console.log(` ${chalk.bold(\"Name:\")} ${entity.legal_name ?? entity.name ?? \"N/A\"}`);\n console.log(` ${chalk.bold(\"Type:\")} ${entity.entity_type ?? \"N/A\"}`);\n console.log(` ${chalk.bold(\"Jurisdiction:\")} ${entity.jurisdiction ?? \"N/A\"}`);\n console.log(` ${chalk.bold(\"Status:\")} ${entity.formation_status ?? entity.status ?? \"N/A\"}`);\n console.log(` ${chalk.bold(\"State:\")} ${entity.formation_state ?? \"N/A\"}`);\n console.log(` ${chalk.bold(\"ID:\")} ${entity.entity_id ?? \"N/A\"}`);\n if (entity.formation_date) console.log(` ${chalk.bold(\"Formation Date:\")} ${entity.formation_date}`);\n if (entity.ein) console.log(` ${chalk.bold(\"EIN:\")} ${entity.ein}`);\n console.log(chalk.blue(\"─\".repeat(40)));\n }\n } catch (err) {\n printError(`Failed to fetch entities: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function entitiesConvertCommand(\n entityId: string,\n opts: { to: string; jurisdiction?: string }\n): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const data: Record<string, string> = { target_type: opts.to };\n if (opts.jurisdiction) data.new_jurisdiction = opts.jurisdiction;\n const result = await client.convertEntity(entityId, data);\n printSuccess(`Entity conversion initiated: ${result.conversion_id ?? \"OK\"}`);\n printJson(result);\n } catch (err) {\n printError(`Failed to convert entity: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function entitiesDissolveCommand(\n entityId: string,\n opts: { reason: string; effectiveDate?: string }\n): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const data: Record<string, string> = { reason: opts.reason };\n if (opts.effectiveDate) data.effective_date = opts.effectiveDate;\n const result = await client.dissolveEntity(entityId, data);\n printSuccess(`Dissolution initiated: ${result.dissolution_id ?? \"OK\"}`);\n printJson(result);\n } catch (err) {\n const msg = String(err);\n if (msg.includes(\"InvalidTransition\") || msg.includes(\"422\")) {\n printError(`Cannot dissolve entity: only entities with 'active' status can be dissolved. Check the entity's current status with: corp entities show ${entityId}`);\n } else {\n printError(`Failed to dissolve entity: ${err}`);\n }\n process.exit(1);\n }\n}\n","import { requireConfig, resolveEntityId } from \"../config.js\";\nimport { CorpAPIClient } from \"../api-client.js\";\nimport { printContactsTable, printError, printSuccess, printJson } from \"../output.js\";\nimport chalk from \"chalk\";\nimport type { ApiRecord } from \"../types.js\";\n\nexport async function contactsListCommand(opts: { entityId?: string; json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const contacts = await client.listContacts(eid);\n if (opts.json) printJson(contacts);\n else if (contacts.length === 0) console.log(\"No contacts found.\");\n else printContactsTable(contacts);\n } catch (err) {\n printError(`Failed to fetch contacts: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function contactsShowCommand(contactId: string, opts: { entityId?: string; json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const profile = await client.getContactProfile(contactId, eid);\n if (opts.json) {\n printJson(profile);\n } else {\n const contact = (profile.contact ?? profile) as ApiRecord;\n console.log(chalk.cyan(\"─\".repeat(40)));\n console.log(chalk.cyan.bold(\" Contact Profile\"));\n console.log(chalk.cyan(\"─\".repeat(40)));\n console.log(` ${chalk.bold(\"Name:\")} ${contact.name ?? \"N/A\"}`);\n console.log(` ${chalk.bold(\"Email:\")} ${contact.email ?? \"N/A\"}`);\n console.log(` ${chalk.bold(\"Category:\")} ${contact.category ?? \"N/A\"}`);\n if (contact.phone) console.log(` ${chalk.bold(\"Phone:\")} ${contact.phone}`);\n if (contact.notes) console.log(` ${chalk.bold(\"Notes:\")} ${contact.notes}`);\n const holdings = profile.equity_holdings as ApiRecord[] | undefined;\n if (holdings?.length) {\n console.log(`\\n ${chalk.bold(\"Equity Holdings:\")}`);\n for (const h of holdings) console.log(` ${h.share_class ?? \"?\"}: ${h.shares ?? \"?\"} shares`);\n }\n const obls = profile.obligations as unknown[];\n if (obls?.length) console.log(`\\n ${chalk.bold(\"Obligations:\")} ${obls.length}`);\n console.log(chalk.cyan(\"─\".repeat(40)));\n }\n } catch (err) {\n printError(`Failed to fetch contact: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function contactsAddCommand(opts: {\n entityId?: string;\n name: string;\n email: string;\n type?: string;\n category?: string;\n phone?: string;\n notes?: string;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const data: ApiRecord = {\n entity_id: eid,\n contact_type: opts.type ?? \"individual\",\n name: opts.name,\n email: opts.email,\n category: opts.category ?? \"employee\",\n };\n if (opts.phone) data.phone = opts.phone;\n if (opts.notes) data.notes = opts.notes;\n const result = await client.createContact(data);\n printSuccess(`Contact created: ${result.contact_id ?? result.id ?? \"OK\"}`);\n } catch (err) {\n printError(`Failed to create contact: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function contactsEditCommand(\n contactId: string,\n opts: { entityId?: string; name?: string; email?: string; category?: string; phone?: string; notes?: string }\n): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const data: ApiRecord = { entity_id: eid };\n if (opts.name != null) data.name = opts.name;\n if (opts.email != null) data.email = opts.email;\n if (opts.category != null) data.category = opts.category;\n if (opts.phone != null) data.phone = opts.phone;\n if (opts.notes != null) data.notes = opts.notes;\n if (Object.keys(data).length === 0) {\n console.log(\"No fields to update.\");\n return;\n }\n await client.updateContact(contactId, data);\n printSuccess(\"Contact updated.\");\n } catch (err) {\n printError(`Failed to update contact: ${err}`);\n process.exit(1);\n }\n}\n","import { requireConfig, resolveEntityId } from \"../config.js\";\nimport { CorpAPIClient } from \"../api-client.js\";\nimport {\n printCapTable, printSafesTable, printTransfersTable,\n printValuationsTable, printError, printSuccess, printJson,\n} from \"../output.js\";\nimport chalk from \"chalk\";\n\nexport async function capTableCommand(opts: { entityId?: string; json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const data = await client.getCapTable(eid);\n if (opts.json) { printJson(data); return; }\n if ((data.access_level as string) === \"none\") {\n printError(\"You do not have access to this entity's cap table.\");\n process.exit(1);\n }\n printCapTable(data);\n try {\n const val = await client.getCurrent409a(eid);\n if (val) print409a(val);\n } catch { /* ignore */ }\n } catch (err) {\n printError(`Failed to fetch cap table: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function safesCommand(opts: { entityId?: string; json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const safes = await client.getSafeNotes(eid);\n if (opts.json) printJson(safes);\n else if (safes.length === 0) console.log(\"No SAFE notes found.\");\n else printSafesTable(safes);\n } catch (err) {\n printError(`Failed to fetch SAFE notes: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function transfersCommand(opts: { entityId?: string; json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const transfers = await client.getShareTransfers(eid);\n if (opts.json) printJson(transfers);\n else if (transfers.length === 0) console.log(\"No share transfers found.\");\n else printTransfersTable(transfers);\n } catch (err) {\n printError(`Failed to fetch transfers: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function valuationsCommand(opts: { entityId?: string; json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const valuations = await client.getValuations(eid);\n if (opts.json) printJson(valuations);\n else if (valuations.length === 0) console.log(\"No valuations found.\");\n else printValuationsTable(valuations);\n } catch (err) {\n printError(`Failed to fetch valuations: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function fourOhNineACommand(opts: { entityId?: string; json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const data = await client.getCurrent409a(eid);\n if (opts.json) printJson(data);\n else if (!data || Object.keys(data).length === 0) console.log(\"No 409A valuation found.\");\n else print409a(data);\n } catch (err) {\n const msg = String(err);\n if (msg.includes(\"404\")) {\n console.log(\"No 409A valuation found for this entity. Create one with:\\n corp cap-table create-valuation --type four_oh_nine_a --date YYYY-MM-DD --methodology <method>\");\n } else {\n printError(`Failed to fetch 409A valuation: ${err}`);\n }\n process.exit(1);\n }\n}\n\nexport async function issueEquityCommand(opts: {\n entityId?: string;\n grantType: string;\n shares: number;\n recipient: string;\n email?: string;\n instrumentId?: string;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n // Fetch cap table to get issuer and instrument info\n const capTable = await client.getCapTable(eid);\n const issuerLegalEntityId = capTable.issuer_legal_entity_id as string;\n if (!issuerLegalEntityId) {\n printError(\"No issuer legal entity found. Has this entity been formed with a cap table?\");\n process.exit(1);\n }\n\n // Resolve instrument ID — use provided, or match by grant type, or use first common stock\n let instrumentId = opts.instrumentId;\n if (!instrumentId) {\n const instruments = capTable.instruments as Array<{ instrument_id: string; kind: string; symbol: string }>;\n if (!instruments?.length) {\n printError(\"No instruments found on cap table. Create an instrument first.\");\n process.exit(1);\n }\n const grantLower = opts.grantType.toLowerCase();\n const match = instruments.find(\n (i) => i.kind.toLowerCase().includes(grantLower) || i.symbol.toLowerCase().includes(grantLower),\n ) ?? instruments.find((i) => i.kind.toLowerCase().includes(\"common\"));\n if (match) {\n instrumentId = match.instrument_id;\n console.log(`Using instrument: ${match.symbol} (${match.kind})`);\n } else {\n instrumentId = instruments[0].instrument_id;\n console.log(`Using first instrument: ${instruments[0].symbol} (${instruments[0].kind})`);\n }\n }\n\n // 1. Start a staged round\n const round = await client.startEquityRound({\n entity_id: eid,\n name: `${opts.grantType} grant — ${opts.recipient}`,\n issuer_legal_entity_id: issuerLegalEntityId,\n });\n const roundId = (round.round_id ?? round.equity_round_id) as string;\n\n // 2. Add the security\n const securityData: Record<string, unknown> = {\n entity_id: eid,\n instrument_id: instrumentId,\n quantity: opts.shares,\n recipient_name: opts.recipient,\n grant_type: opts.grantType,\n };\n if (opts.email) securityData.email = opts.email;\n await client.addRoundSecurity(roundId, securityData);\n\n // 3. Issue the round\n const result = await client.issueRound(roundId, { entity_id: eid });\n\n printSuccess(`Equity issued: ${opts.shares} shares (${opts.grantType}) to ${opts.recipient}`);\n printJson(result);\n } catch (err) {\n printError(`Failed to issue equity: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function issueSafeCommand(opts: {\n entityId?: string;\n investor: string;\n amount: number;\n safeType: string;\n valuationCap: number;\n email?: string;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n // Fetch cap table for issuer and SAFE instrument\n const capTable = await client.getCapTable(eid);\n const issuerLegalEntityId = capTable.issuer_legal_entity_id as string;\n if (!issuerLegalEntityId) {\n printError(\"No issuer legal entity found. Has this entity been formed with a cap table?\");\n process.exit(1);\n }\n\n const instruments = capTable.instruments as Array<{ instrument_id: string; kind: string; symbol: string }>;\n const safeInstrument = instruments?.find((i) => i.kind.toLowerCase() === \"safe\");\n if (!safeInstrument) {\n printError(\"No SAFE instrument found on cap table. Create a SAFE instrument first.\");\n process.exit(1);\n }\n\n // Start a staged round for the SAFE\n const round = await client.startEquityRound({\n entity_id: eid,\n name: `SAFE — ${opts.investor}`,\n issuer_legal_entity_id: issuerLegalEntityId,\n });\n const roundId = (round.round_id ?? round.equity_round_id) as string;\n\n // Add the SAFE security — use principal_cents as quantity since quantity must be > 0\n const securityData: Record<string, unknown> = {\n entity_id: eid,\n instrument_id: safeInstrument.instrument_id,\n quantity: opts.amount,\n recipient_name: opts.investor,\n principal_cents: opts.amount,\n grant_type: opts.safeType,\n };\n if (opts.email) securityData.email = opts.email;\n await client.addRoundSecurity(roundId, securityData);\n\n // Issue the round\n const result = await client.issueRound(roundId, { entity_id: eid });\n printSuccess(`SAFE issued: $${(opts.amount / 100).toLocaleString()} to ${opts.investor}`);\n printJson(result);\n } catch (err) {\n printError(`Failed to issue SAFE: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function transferSharesCommand(opts: {\n entityId?: string;\n from: string;\n to: string;\n shares: number;\n type: string;\n shareClassId: string;\n governingDocType: string;\n transfereeRights: string;\n prepareIntentId?: string;\n pricePerShareCents?: number;\n relationship?: string;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n let intentId = opts.prepareIntentId;\n if (!intentId) {\n const intent = await client.createExecutionIntent({\n entity_id: eid,\n intent_type: \"equity.transfer.prepare\",\n description: `Transfer ${opts.shares} shares from ${opts.from} to ${opts.to}`,\n });\n intentId = (intent.intent_id ?? intent.id) as string;\n await client.evaluateIntent(intentId, eid);\n await client.authorizeIntent(intentId, eid);\n }\n const body: Record<string, unknown> = {\n entity_id: eid,\n share_class_id: opts.shareClassId,\n from_contact_id: opts.from,\n to_contact_id: opts.to,\n transfer_type: opts.type,\n share_count: opts.shares,\n governing_doc_type: opts.governingDocType,\n transferee_rights: opts.transfereeRights,\n prepare_intent_id: intentId,\n };\n if (opts.pricePerShareCents != null) body.price_per_share_cents = opts.pricePerShareCents;\n if (opts.relationship) body.relationship_to_holder = opts.relationship;\n const result = await client.transferShares(body);\n printSuccess(`Transfer workflow created: ${result.workflow_id ?? \"OK\"}`);\n printJson(result);\n } catch (err) {\n printError(`Failed to create transfer workflow: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function distributeCommand(opts: {\n entityId?: string;\n amount: number;\n type: string;\n description: string;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.calculateDistribution({\n entity_id: eid, total_amount_cents: opts.amount, distribution_type: opts.type,\n description: opts.description,\n });\n printSuccess(`Distribution calculated: ${result.distribution_id ?? \"OK\"}`);\n printJson(result);\n } catch (err) {\n printError(`Failed to calculate distribution: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function startRoundCommand(opts: {\n entityId?: string;\n name: string;\n issuerLegalEntityId: string;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.startEquityRound({\n entity_id: eid,\n name: opts.name,\n issuer_legal_entity_id: opts.issuerLegalEntityId,\n });\n printSuccess(`Round started: ${result.round_id ?? \"OK\"}`);\n printJson(result);\n } catch (err) {\n printError(`Failed to start round: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function addSecurityCommand(opts: {\n entityId?: string;\n roundId: string;\n holderId?: string;\n email?: string;\n instrumentId: string;\n quantity: number;\n recipientName: string;\n principalCents?: number;\n grantType?: string;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const body: Record<string, unknown> = {\n entity_id: eid,\n instrument_id: opts.instrumentId,\n quantity: opts.quantity,\n recipient_name: opts.recipientName,\n };\n if (opts.holderId) body.holder_id = opts.holderId;\n if (opts.email) body.email = opts.email;\n if (opts.principalCents) body.principal_cents = opts.principalCents;\n if (opts.grantType) body.grant_type = opts.grantType;\n const result = await client.addRoundSecurity(opts.roundId, body);\n printSuccess(`Security added for ${opts.recipientName}`);\n printJson(result);\n } catch (err) {\n printError(`Failed to add security: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function issueRoundCommand(opts: {\n entityId?: string;\n roundId: string;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.issueRound(opts.roundId, { entity_id: eid });\n printSuccess(\"Round issued and closed\");\n printJson(result);\n } catch (err) {\n printError(`Failed to issue round: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function createValuationCommand(opts: {\n entityId?: string;\n type: string;\n date: string;\n methodology: string;\n fmv?: number;\n enterpriseValue?: number;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const body: Record<string, unknown> = {\n entity_id: eid,\n valuation_type: opts.type,\n effective_date: opts.date,\n methodology: opts.methodology,\n };\n if (opts.fmv != null) body.fmv_per_share_cents = opts.fmv;\n if (opts.enterpriseValue != null) body.enterprise_value_cents = opts.enterpriseValue;\n const result = await client.createValuation(body);\n printSuccess(`Valuation created: ${result.valuation_id ?? \"OK\"}`);\n printJson(result);\n } catch (err) {\n printError(`Failed to create valuation: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function submitValuationCommand(opts: {\n entityId?: string;\n valuationId: string;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.submitValuationForApproval(opts.valuationId, eid);\n printSuccess(`Valuation submitted for approval: ${result.valuation_id ?? \"OK\"}`);\n if (result.meeting_id) console.log(` Meeting: ${result.meeting_id}`);\n if (result.agenda_item_id) console.log(` Agenda Item: ${result.agenda_item_id}`);\n printJson(result);\n } catch (err) {\n const msg = String(err);\n if (msg.includes(\"404\")) {\n printError(`Valuation not found. List valuations with: corp cap-table valuations`);\n } else {\n printError(`Failed to submit valuation: ${err}`);\n }\n process.exit(1);\n }\n}\n\nexport async function approveValuationCommand(opts: {\n entityId?: string;\n valuationId: string;\n resolutionId?: string;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.approveValuation(opts.valuationId, eid, opts.resolutionId);\n printSuccess(`Valuation approved: ${result.valuation_id ?? \"OK\"}`);\n printJson(result);\n } catch (err) {\n const msg = String(err);\n if (msg.includes(\"400\")) {\n printError(`Bad request — a --resolution-id from a board vote may be required. Submit for approval first: corp cap-table submit-valuation <id>`);\n } else {\n printError(`Failed to approve valuation: ${err}`);\n }\n process.exit(1);\n }\n}\n\nfunction print409a(data: Record<string, unknown>): void {\n console.log(chalk.green(\"─\".repeat(40)));\n console.log(chalk.green.bold(\" 409A Valuation\"));\n console.log(chalk.green(\"─\".repeat(40)));\n const fmv = typeof data.fmv_per_share_cents === \"number\" ? (data.fmv_per_share_cents as number) / 100 : data.fmv_per_share;\n const enterpriseValue = typeof data.enterprise_value_cents === \"number\"\n ? (data.enterprise_value_cents as number) / 100\n : data.enterprise_value;\n console.log(` ${chalk.bold(\"FMV/Share:\")} $${fmv ?? \"N/A\"}`);\n console.log(` ${chalk.bold(\"Enterprise Value:\")} $${enterpriseValue ?? \"N/A\"}`);\n console.log(` ${chalk.bold(\"Valuation Date:\")} ${data.effective_date ?? data.valuation_date ?? \"N/A\"}`);\n if (data.provider) console.log(` ${chalk.bold(\"Provider:\")} ${data.provider}`);\n console.log(chalk.green(\"─\".repeat(40)));\n}\n","import { requireConfig, resolveEntityId } from \"../config.js\";\nimport { CorpAPIClient } from \"../api-client.js\";\nimport { printError, printSuccess, printJson } from \"../output.js\";\n\nexport async function financeInvoiceCommand(opts: {\n entityId?: string; customer: string; amount: number; dueDate: string; description: string;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.createInvoice({\n entity_id: eid, customer_name: opts.customer, amount_cents: opts.amount,\n due_date: opts.dueDate, description: opts.description,\n });\n printSuccess(`Invoice created: ${result.invoice_id ?? \"OK\"}`);\n printJson(result);\n } catch (err) { printError(`Failed to create invoice: ${err}`); process.exit(1); }\n}\n\nexport async function financePayrollCommand(opts: {\n entityId?: string; periodStart: string; periodEnd: string;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.runPayroll({\n entity_id: eid, pay_period_start: opts.periodStart, pay_period_end: opts.periodEnd,\n });\n printSuccess(`Payroll run created: ${result.payroll_run_id ?? \"OK\"}`);\n printJson(result);\n } catch (err) { printError(`Failed to run payroll: ${err}`); process.exit(1); }\n}\n\nexport async function financePayCommand(opts: {\n entityId?: string; amount: number; recipient: string; method: string;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.submitPayment({\n entity_id: eid, amount_cents: opts.amount, recipient: opts.recipient,\n payment_method: opts.method,\n description: `Payment via ${opts.method}`,\n });\n printSuccess(`Payment submitted: ${result.payment_id ?? \"OK\"}`);\n printJson(result);\n } catch (err) { printError(`Failed to submit payment: ${err}`); process.exit(1); }\n}\n\nexport async function financeOpenAccountCommand(opts: {\n entityId?: string; institution: string;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.openBankAccount({ entity_id: eid, bank_name: opts.institution });\n printSuccess(`Bank account opened: ${result.account_id ?? \"OK\"}`);\n printJson(result);\n } catch (err) { printError(`Failed to open bank account: ${err}`); process.exit(1); }\n}\n\nexport async function financeClassifyContractorCommand(opts: {\n entityId?: string; name: string; state: string; hours: number;\n exclusive: boolean; duration: number; providesTools: boolean;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.classifyContractor({\n entity_id: eid, contractor_name: opts.name, state: opts.state, hours_per_week: opts.hours,\n exclusive_client: opts.exclusive, duration_months: opts.duration, provides_tools: opts.providesTools,\n });\n printSuccess(`Classification: ${result.risk_level ?? \"OK\"}`);\n printJson(result);\n } catch (err) { printError(`Failed to classify contractor: ${err}`); process.exit(1); }\n}\n\nexport async function financeReconcileCommand(opts: {\n entityId?: string; startDate: string; endDate: string;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.reconcileLedger({\n entity_id: eid, start_date: opts.startDate, end_date: opts.endDate,\n });\n printSuccess(`Ledger reconciled: ${result.reconciliation_id ?? \"OK\"}`);\n printJson(result);\n } catch (err) { printError(`Failed to reconcile ledger: ${err}`); process.exit(1); }\n}\n","import { requireConfig, resolveEntityId } from \"../config.js\";\nimport { CorpAPIClient } from \"../api-client.js\";\nimport {\n printGovernanceTable, printSeatsTable, printMeetingsTable,\n printResolutionsTable, printError, printSuccess, printJson, printWarning,\n} from \"../output.js\";\nimport chalk from \"chalk\";\n\nexport async function governanceCreateBodyCommand(opts: {\n entityId?: string; name: string; bodyType: string; quorum: string; voting: string;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.createGovernanceBody({\n entity_id: eid,\n body_type: opts.bodyType,\n name: opts.name,\n quorum_rule: opts.quorum,\n voting_method: opts.voting,\n });\n const bodyId = result.body_id ?? \"OK\";\n printSuccess(`Governance body created: ${bodyId}`);\n printJson(result);\n console.log(chalk.dim(\"\\n Next steps:\"));\n console.log(chalk.dim(` corp governance add-seat ${bodyId} --holder <contact-id>`));\n console.log(chalk.dim(` corp governance seats ${bodyId}`));\n } catch (err) { printError(`Failed to create governance body: ${err}`); process.exit(1); }\n}\n\nexport async function governanceAddSeatCommand(bodyId: string, opts: {\n holder: string; role?: string; entityId?: string;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const data: Record<string, unknown> = { holder_id: opts.holder, role: opts.role ?? \"member\" };\n const result = await client.createGovernanceSeat(bodyId, eid, data);\n printSuccess(`Seat added: ${result.seat_id ?? \"OK\"}`);\n printJson(result);\n } catch (err) { printError(`Failed to add seat: ${err}`); process.exit(1); }\n}\n\nexport async function governanceListCommand(opts: { entityId?: string; json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const bodies = await client.listGovernanceBodies(eid);\n if (opts.json) printJson(bodies);\n else if (bodies.length === 0) console.log(\"No governance bodies found.\");\n else printGovernanceTable(bodies);\n } catch (err) { printError(`Failed to fetch governance bodies: ${err}`); process.exit(1); }\n}\n\nexport async function governanceSeatsCommand(bodyId: string, opts: { entityId?: string; json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const seats = await client.getGovernanceSeats(bodyId, eid);\n if (opts.json) printJson(seats);\n else if (seats.length === 0) console.log(\"No seats found.\");\n else printSeatsTable(seats);\n } catch (err) { printError(`Failed to fetch seats: ${err}`); process.exit(1); }\n}\n\nexport async function governanceMeetingsCommand(bodyId: string, opts: { entityId?: string; json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const meetings = await client.listMeetings(bodyId, eid);\n if (opts.json) printJson(meetings);\n else if (meetings.length === 0) console.log(\"No meetings found.\");\n else printMeetingsTable(meetings);\n } catch (err) { printError(`Failed to fetch meetings: ${err}`); process.exit(1); }\n}\n\nexport async function governanceResolutionsCommand(meetingId: string, opts: { entityId?: string; json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const resolutions = await client.getMeetingResolutions(meetingId, eid);\n if (opts.json) printJson(resolutions);\n else if (resolutions.length === 0) console.log(\"No resolutions found.\");\n else printResolutionsTable(resolutions);\n } catch (err) { printError(`Failed to fetch resolutions: ${err}`); process.exit(1); }\n}\n\nexport async function governanceConveneCommand(opts: {\n entityId?: string; body: string; meetingType: string; title: string; date: string; agenda: string[];\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.scheduleMeeting({\n entity_id: eid, body_id: opts.body, meeting_type: opts.meetingType,\n title: opts.title, scheduled_date: opts.date,\n agenda_item_titles: opts.agenda,\n });\n const meetingId = result.meeting_id ?? \"OK\";\n printSuccess(`Meeting scheduled: ${meetingId}`);\n printJson(result);\n console.log(chalk.dim(\"\\n Next steps:\"));\n console.log(chalk.dim(` corp governance notice ${meetingId}`));\n console.log(chalk.dim(` corp governance agenda-items ${meetingId}`));\n } catch (err) { printError(`Failed to schedule meeting: ${err}`); process.exit(1); }\n}\n\nexport async function governanceVoteCommand(\n meetingId: string,\n itemId: string,\n opts: { voter: string; vote: string; entityId?: string }\n): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.castVote(eid, meetingId, itemId, {\n voter_id: opts.voter, vote_value: opts.vote,\n });\n printSuccess(`Vote cast: ${result.vote_id ?? \"OK\"}`);\n printJson(result);\n } catch (err) { printError(`Failed to cast vote: ${err}`); process.exit(1); }\n}\n\nexport async function sendNoticeCommand(meetingId: string, opts: { entityId?: string }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.sendNotice(meetingId, eid);\n printSuccess(`Notice sent for meeting ${meetingId}`);\n printJson(result);\n } catch (err) { printError(`Failed to send notice: ${err}`); process.exit(1); }\n}\n\nexport async function adjournMeetingCommand(meetingId: string, opts: { entityId?: string }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.adjournMeeting(meetingId, eid);\n printSuccess(`Meeting ${meetingId} adjourned`);\n printJson(result);\n } catch (err) { printError(`Failed to adjourn meeting: ${err}`); process.exit(1); }\n}\n\nexport async function cancelMeetingCommand(meetingId: string, opts: { entityId?: string }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.cancelMeeting(meetingId, eid);\n printSuccess(`Meeting ${meetingId} cancelled`);\n printJson(result);\n } catch (err) { printError(`Failed to cancel meeting: ${err}`); process.exit(1); }\n}\n\nexport async function finalizeAgendaItemCommand(\n meetingId: string, itemId: string, opts: { status: string; entityId?: string }\n): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.finalizeAgendaItem(meetingId, itemId, {\n entity_id: eid, status: opts.status,\n });\n printSuccess(`Agenda item ${itemId} finalized as ${opts.status}`);\n printJson(result);\n } catch (err) { printError(`Failed to finalize agenda item: ${err}`); process.exit(1); }\n}\n\nexport async function computeResolutionCommand(\n meetingId: string, itemId: string, opts: { text: string; entityId?: string }\n): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.computeResolution(meetingId, itemId, eid, {\n resolution_text: opts.text,\n });\n printSuccess(`Resolution computed for agenda item ${itemId}`);\n printJson(result);\n } catch (err) { printError(`Failed to compute resolution: ${err}`); process.exit(1); }\n}\n\nexport async function writtenConsentCommand(opts: {\n body: string; title: string; description: string; entityId?: string;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.writtenConsent({\n entity_id: eid, body_id: opts.body, title: opts.title, description: opts.description,\n });\n const meetingId = result.meeting_id ?? \"OK\";\n printSuccess(`Written consent created: ${meetingId}`);\n printJson(result);\n console.log(chalk.dim(\"\\n Next steps:\"));\n console.log(chalk.dim(` corp governance agenda-items ${meetingId}`));\n console.log(chalk.dim(` corp governance vote ${meetingId} <item-id> --voter <contact-uuid> --vote for`));\n } catch (err) { printError(`Failed to create written consent: ${err}`); process.exit(1); }\n}\n\nexport async function listAgendaItemsCommand(meetingId: string, opts: { entityId?: string; json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const items = await client.listAgendaItems(meetingId, eid);\n if (opts.json) printJson(items);\n else if (items.length === 0) console.log(\"No agenda items found.\");\n else {\n const Table = (await import(\"cli-table3\")).default;\n const chalk = (await import(\"chalk\")).default;\n console.log(`\\n${chalk.bold(\"Agenda Items\")}`);\n const table = new Table({ head: [chalk.dim(\"ID\"), chalk.dim(\"Title\"), chalk.dim(\"Status\"), chalk.dim(\"Type\")] });\n for (const item of items) {\n table.push([\n String(item.item_id ?? item.agenda_item_id ?? item.id ?? \"\").slice(0, 12),\n String(item.title ?? \"\"),\n String(item.status ?? \"\"),\n String(item.item_type ?? item.type ?? \"\"),\n ]);\n }\n console.log(table.toString());\n }\n } catch (err) { printError(`Failed to list agenda items: ${err}`); process.exit(1); }\n}\n","import { requireConfig, resolveEntityId } from \"../config.js\";\nimport { CorpAPIClient } from \"../api-client.js\";\nimport { printDocumentsTable, printError, printSuccess, printJson } from \"../output.js\";\n\nconst HUMANS_APP_ORIGIN = \"https://humans.thecorporation.ai\";\n\nfunction formatSigningLink(docId: string, result: { token?: unknown; signing_url?: unknown }): string {\n if (typeof result.token === \"string\" && result.token.length > 0) {\n return `${HUMANS_APP_ORIGIN}/sign/${docId}?token=${encodeURIComponent(result.token)}`;\n }\n if (typeof result.signing_url === \"string\" && result.signing_url.length > 0) {\n if (/^https?:\\/\\//.test(result.signing_url)) {\n return result.signing_url;\n }\n const normalizedPath = result.signing_url.startsWith(\"/human/sign/\")\n ? result.signing_url.replace(\"/human/sign/\", \"/sign/\")\n : result.signing_url;\n return `${HUMANS_APP_ORIGIN}${normalizedPath.startsWith(\"/\") ? normalizedPath : `/${normalizedPath}`}`;\n }\n return `${HUMANS_APP_ORIGIN}/sign/${docId}`;\n}\n\nexport async function documentsListCommand(opts: { entityId?: string; json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const docs = await client.getEntityDocuments(eid);\n if (opts.json) printJson(docs);\n else if (docs.length === 0) console.log(\"No documents found.\");\n else printDocumentsTable(docs);\n } catch (err) { printError(`Failed to fetch documents: ${err}`); process.exit(1); }\n}\n\nexport async function documentsSigningLinkCommand(docId: string, opts: { entityId?: string }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.getSigningLink(docId, eid);\n const shareUrl = formatSigningLink(docId, result);\n if (process.stdout.isTTY) {\n printSuccess(\"Signing link generated.\");\n }\n console.log(shareUrl);\n } catch (err) { printError(`Failed to get signing link: ${err}`); process.exit(1); }\n}\n\nexport async function documentsGenerateCommand(opts: {\n entityId?: string; template: string; counterparty: string; effectiveDate?: string;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.generateContract({\n entity_id: eid,\n template_type: opts.template,\n counterparty_name: opts.counterparty,\n effective_date: opts.effectiveDate ?? new Date().toISOString().slice(0, 10),\n });\n printSuccess(`Contract generated: ${result.contract_id ?? \"OK\"}`);\n printJson(result);\n } catch (err) { printError(`Failed to generate contract: ${err}`); process.exit(1); }\n}\n\nexport async function documentsPreviewPdfCommand(opts: {\n entityId?: string; documentId: string;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n await client.validatePreviewPdf(eid, opts.documentId);\n const url = client.getPreviewPdfUrl(eid, opts.documentId);\n printSuccess(`Preview PDF URL: ${url}`);\n console.log(\"The document definition was validated successfully. Use your API key to download the PDF.\");\n } catch (err) {\n printError(`Failed to validate preview PDF: ${err}`);\n process.exit(1);\n }\n}\n","import { requireConfig, resolveEntityId } from \"../config.js\";\nimport { CorpAPIClient } from \"../api-client.js\";\nimport { printError, printSuccess, printJson } from \"../output.js\";\n\nfunction normalizeRecurrence(recurrence?: string): string | undefined {\n if (!recurrence) return undefined;\n if (recurrence === \"yearly\") return \"annual\";\n return recurrence;\n}\n\nexport async function taxFileCommand(opts: { entityId?: string; type: string; year: number }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.fileTaxDocument({ entity_id: eid, document_type: opts.type, tax_year: opts.year });\n printSuccess(`Tax document filed: ${result.filing_id ?? \"OK\"}`);\n printJson(result);\n } catch (err) { printError(`Failed to file tax document: ${err}`); process.exit(1); }\n}\n\nexport async function taxDeadlineCommand(opts: {\n entityId?: string; type: string; dueDate: string; description: string; recurrence?: string;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const payload: Record<string, unknown> = {\n entity_id: eid, deadline_type: opts.type, due_date: opts.dueDate,\n description: opts.description,\n };\n const recurrence = normalizeRecurrence(opts.recurrence);\n if (recurrence) payload.recurrence = recurrence;\n const result = await client.trackDeadline(payload);\n printSuccess(`Deadline tracked: ${result.deadline_id ?? \"OK\"}`);\n printJson(result);\n } catch (err) { printError(`Failed to track deadline: ${err}`); process.exit(1); }\n}\n","import { requireConfig } from \"../config.js\";\nimport { CorpAPIClient } from \"../api-client.js\";\nimport { printAgentsTable, printError, printSuccess, printJson } from \"../output.js\";\nimport chalk from \"chalk\";\nimport type { ApiRecord } from \"../types.js\";\n\nexport async function agentsListCommand(opts: { json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const agents = await client.listAgents();\n if (opts.json) printJson(agents);\n else if (agents.length === 0) console.log(\"No agents found.\");\n else printAgentsTable(agents);\n } catch (err) { printError(`Failed to fetch agents: ${err}`); process.exit(1); }\n}\n\nexport async function agentsShowCommand(agentId: string, opts: { json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const agent = await client.getAgent(agentId);\n if (opts.json) { printJson(agent); return; }\n console.log(chalk.magenta(\"─\".repeat(40)));\n console.log(chalk.magenta.bold(\" Agent Detail\"));\n console.log(chalk.magenta(\"─\".repeat(40)));\n console.log(` ${chalk.bold(\"Name:\")} ${agent.name ?? \"N/A\"}`);\n console.log(` ${chalk.bold(\"Status:\")} ${agent.status ?? \"N/A\"}`);\n console.log(` ${chalk.bold(\"Model:\")} ${agent.model ?? \"N/A\"}`);\n console.log(` ${chalk.bold(\"ID:\")} ${agent.agent_id ?? \"N/A\"}`);\n if (agent.system_prompt) {\n let prompt = String(agent.system_prompt);\n if (prompt.length > 100) prompt = prompt.slice(0, 97) + \"...\";\n console.log(` ${chalk.bold(\"Prompt:\")} ${prompt}`);\n }\n if (agent.skills && Array.isArray(agent.skills) && agent.skills.length > 0) {\n console.log(` ${chalk.bold(\"Skills:\")} ${(agent.skills as Array<{name?: string}>).map((s) => s.name ?? \"?\").join(\", \")}`);\n }\n console.log(chalk.magenta(\"─\".repeat(40)));\n } catch (err) { printError(`Failed to fetch agent: ${err}`); process.exit(1); }\n}\n\nexport async function agentsCreateCommand(opts: { name: string; prompt: string; model?: string }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const data: ApiRecord = { name: opts.name, system_prompt: opts.prompt };\n if (opts.model) data.model = opts.model;\n const result = await client.createAgent(data);\n printSuccess(`Agent created: ${result.agent_id ?? result.id ?? \"OK\"}`);\n printJson(result);\n } catch (err) { printError(`Failed to create agent: ${err}`); process.exit(1); }\n}\n\nexport async function agentsPauseCommand(agentId: string): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n await client.updateAgent(agentId, { status: \"paused\" });\n printSuccess(`Agent ${agentId} paused.`);\n } catch (err) { printError(`Failed to pause agent: ${err}`); process.exit(1); }\n}\n\nexport async function agentsResumeCommand(agentId: string): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n await client.updateAgent(agentId, { status: \"active\" });\n printSuccess(`Agent ${agentId} resumed.`);\n } catch (err) { printError(`Failed to resume agent: ${err}`); process.exit(1); }\n}\n\nexport async function agentsDeleteCommand(agentId: string): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n await client.deleteAgent(agentId);\n printSuccess(`Agent ${agentId} deleted.`);\n } catch (err) { printError(`Failed to delete agent: ${err}`); process.exit(1); }\n}\n\nexport async function agentsMessageCommand(agentId: string, opts: { body: string }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.sendAgentMessage(agentId, opts.body);\n printSuccess(`Message sent. Execution: ${result.execution_id ?? \"OK\"}`);\n } catch (err) { printError(`Failed to send message: ${err}`); process.exit(1); }\n}\n\nexport async function agentsExecutionsCommand(agentId: string, _opts: { json?: boolean }): Promise<void> {\n // No list-executions endpoint exists yet; individual executions can be\n // queried via GET /v1/agents/{agent_id}/executions/{execution_id}.\n printError(\n `Listing executions is not yet supported.\\n` +\n ` To inspect a specific run, use the execution ID returned by \"agents message\":\\n` +\n ` GET /v1/agents/${agentId}/executions/<execution-id>`,\n );\n process.exit(1);\n}\n\n\nexport async function agentsSkillCommand(agentId: string, opts: {\n name: string; description: string; instructions?: string;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.addAgentSkill(agentId, {\n name: opts.name, description: opts.description, parameters: opts.instructions ? { instructions: opts.instructions } : {},\n });\n printSuccess(`Skill '${opts.name}' added to agent ${agentId}.`);\n printJson(result);\n } catch (err) { printError(`Failed to add skill: ${err}`); process.exit(1); }\n}\n","import { requireConfig, resolveEntityId } from \"../config.js\";\nimport { CorpAPIClient } from \"../api-client.js\";\nimport { printWorkItemsTable, printError, printSuccess, printJson } from \"../output.js\";\nimport chalk from \"chalk\";\n\nexport async function workItemsListCommand(opts: { entityId?: string; json?: boolean; status?: string; category?: string }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const params: Record<string, string> = {};\n if (opts.status) params.status = opts.status;\n if (opts.category) params.category = opts.category;\n const items = await client.listWorkItems(eid, Object.keys(params).length > 0 ? params : undefined);\n if (opts.json) printJson(items);\n else if (items.length === 0) console.log(\"No work items found.\");\n else printWorkItemsTable(items);\n } catch (err) { printError(`Failed to fetch work items: ${err}`); process.exit(1); }\n}\n\nexport async function workItemsShowCommand(workItemId: string, opts: { entityId?: string; json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const w = await client.getWorkItem(eid, workItemId);\n if (opts.json) { printJson(w); return; }\n console.log(chalk.cyan(\"─\".repeat(40)));\n console.log(chalk.cyan.bold(\" Work Item Detail\"));\n console.log(chalk.cyan(\"─\".repeat(40)));\n console.log(` ${chalk.bold(\"Title:\")} ${w.title ?? \"N/A\"}`);\n console.log(` ${chalk.bold(\"Category:\")} ${w.category ?? \"N/A\"}`);\n console.log(` ${chalk.bold(\"Status:\")} ${w.effective_status ?? w.status ?? \"N/A\"}`);\n if (w.description) console.log(` ${chalk.bold(\"Description:\")} ${w.description}`);\n if (w.deadline) console.log(` ${chalk.bold(\"Deadline:\")} ${w.deadline}`);\n if (w.asap) console.log(` ${chalk.bold(\"Priority:\")} ${chalk.red.bold(\"ASAP\")}`);\n if (w.claimed_by) console.log(` ${chalk.bold(\"Claimed by:\")} ${w.claimed_by}`);\n if (w.claimed_at) console.log(` ${chalk.bold(\"Claimed at:\")} ${w.claimed_at}`);\n if (w.claim_ttl_seconds) console.log(` ${chalk.bold(\"Claim TTL:\")} ${w.claim_ttl_seconds}s`);\n if (w.completed_by) console.log(` ${chalk.bold(\"Completed by:\")} ${w.completed_by}`);\n if (w.completed_at) console.log(` ${chalk.bold(\"Completed at:\")} ${w.completed_at}`);\n if (w.result) console.log(` ${chalk.bold(\"Result:\")} ${w.result}`);\n if (w.created_by) console.log(` ${chalk.bold(\"Created by:\")} ${w.created_by}`);\n console.log(` ${chalk.bold(\"Created at:\")} ${w.created_at ?? \"N/A\"}`);\n console.log(chalk.cyan(\"─\".repeat(40)));\n } catch (err) { printError(`Failed to fetch work item: ${err}`); process.exit(1); }\n}\n\nexport async function workItemsCreateCommand(opts: {\n entityId?: string; title: string; category?: string;\n description?: string; deadline?: string; asap?: boolean; createdBy?: string;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n if (!opts.category) {\n printError(\"Missing required option: --category <category>\");\n process.exit(1);\n }\n const data: Record<string, unknown> = { title: opts.title, category: opts.category };\n if (opts.description) data.description = opts.description;\n if (opts.deadline) data.deadline = opts.deadline;\n if (opts.asap) data.asap = true;\n if (opts.createdBy) data.created_by = opts.createdBy;\n const result = await client.createWorkItem(eid, data);\n printSuccess(`Work item created: ${result.work_item_id ?? result.id ?? \"OK\"}`);\n } catch (err) { printError(`Failed to create work item: ${err}`); process.exit(1); }\n}\n\nexport async function workItemsClaimCommand(workItemId: string, opts: {\n entityId?: string; claimedBy: string; ttl?: number;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const data: Record<string, unknown> = { claimed_by: opts.claimedBy };\n if (opts.ttl != null) data.ttl_seconds = opts.ttl;\n await client.claimWorkItem(eid, workItemId, data);\n printSuccess(`Work item ${workItemId} claimed by ${opts.claimedBy}.`);\n } catch (err) { printError(`Failed to claim work item: ${err}`); process.exit(1); }\n}\n\nexport async function workItemsCompleteCommand(workItemId: string, opts: {\n entityId?: string; completedBy: string; result?: string;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const data: Record<string, unknown> = { completed_by: opts.completedBy };\n if (opts.result) data.result = opts.result;\n await client.completeWorkItem(eid, workItemId, data);\n printSuccess(`Work item ${workItemId} completed.`);\n } catch (err) { printError(`Failed to complete work item: ${err}`); process.exit(1); }\n}\n\nexport async function workItemsReleaseCommand(workItemId: string, opts: { entityId?: string }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n await client.releaseWorkItem(eid, workItemId);\n printSuccess(`Work item ${workItemId} claim released.`);\n } catch (err) { printError(`Failed to release work item: ${err}`); process.exit(1); }\n}\n\nexport async function workItemsCancelCommand(workItemId: string, opts: { entityId?: string }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n await client.cancelWorkItem(eid, workItemId);\n printSuccess(`Work item ${workItemId} cancelled.`);\n } catch (err) { printError(`Failed to cancel work item: ${err}`); process.exit(1); }\n}\n","import { requireConfig } from \"../config.js\";\nimport { CorpAPIClient } from \"../api-client.js\";\nimport { printBillingPanel, printError, printSuccess, printJson } from \"../output.js\";\nimport type { ApiRecord } from \"../types.js\";\n\nfunction makeClient() {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n return new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n}\n\nfunction enrichBillingStatus(status: ApiRecord): ApiRecord {\n if (typeof status.status_explanation === \"string\" && status.status_explanation.trim()) {\n return status;\n }\n\n const plan = String(status.plan ?? status.tier ?? \"\").trim();\n const subStatus = String(status.status ?? \"\").trim();\n if (subStatus !== \"pending_checkout\") {\n return status;\n }\n\n const statusExplanation = plan\n ? `Checkout for the ${plan} plan has started, but billing will not become active until Stripe checkout is completed.`\n : \"Checkout has started, but billing will not become active until Stripe checkout is completed.\";\n\n return { ...status, status_explanation: statusExplanation };\n}\n\nexport async function billingCommand(opts: { json?: boolean }): Promise<void> {\n const client = makeClient();\n try {\n const [status, plans] = await Promise.all([client.getBillingStatus(), client.getBillingPlans()]);\n const enrichedStatus = enrichBillingStatus(status);\n if (opts.json) printJson({ status: enrichedStatus, plans });\n else printBillingPanel(enrichedStatus, plans);\n } catch (err) { printError(`Failed to fetch billing info: ${err}`); process.exit(1); }\n}\n\nexport async function billingPortalCommand(): Promise<void> {\n const client = makeClient();\n try {\n const result = await client.createBillingPortal();\n const url = result.portal_url as string;\n if (!url) { printError(\"No portal URL returned. Ensure you have an active subscription.\"); process.exit(1); }\n printSuccess(\"Stripe Customer Portal URL:\");\n console.log(url);\n } catch (err) { printError(`Failed to create portal session: ${err}`); process.exit(1); }\n}\n\nexport async function billingUpgradeCommand(opts: { plan: string }): Promise<void> {\n const client = makeClient();\n try {\n const result = await client.createBillingCheckout(opts.plan);\n const url = result.checkout_url as string;\n if (!url) { printError(\"No checkout URL returned.\"); process.exit(1); }\n printSuccess(`Stripe Checkout URL for ${opts.plan}:`);\n console.log(url);\n } catch (err) { printError(`Failed to create checkout session: ${err}`); process.exit(1); }\n}\n","import { input, select, confirm, number } from \"@inquirer/prompts\";\nimport chalk from \"chalk\";\nimport Table from \"cli-table3\";\nimport { requireConfig } from \"../config.js\";\nimport { CorpAPIClient } from \"../api-client.js\";\nimport { printError, printSuccess } from \"../output.js\";\nimport type { ApiRecord } from \"../types.js\";\nimport { EntityType, OfficerTitle } from \"@thecorporation/corp-tools\";\n\n// ── Types ──────────────────────────────────────────────────────\n\ninterface FounderInfo {\n name: string;\n email: string;\n role: string;\n address?: { street: string; city: string; state: string; zip: string };\n officer_title?: string;\n is_incorporator?: boolean;\n shares_purchased?: number;\n ownership_pct?: number;\n vesting?: { total_months: number; cliff_months: number; acceleration?: string };\n ip_description?: string;\n}\n\ninterface FormOptions {\n type?: string;\n name?: string;\n jurisdiction?: string;\n member?: string[];\n fiscalYearEnd?: string;\n sCorp?: boolean;\n transferRestrictions?: boolean;\n rofr?: boolean;\n address?: string;\n}\n\n// ── Helpers ────────────────────────────────────────────────────\n\nfunction isCorp(entityType: string): boolean {\n return entityType === \"c_corp\" || entityType === \"s_corp\" || entityType === \"corporation\";\n}\n\nfunction sectionHeader(title: string): void {\n console.log();\n console.log(chalk.blue(\"─\".repeat(50)));\n console.log(chalk.blue.bold(` ${title}`));\n console.log(chalk.blue(\"─\".repeat(50)));\n}\n\nasync function promptAddress(): Promise<{ street: string; city: string; state: string; zip: string }> {\n const street = await input({ message: \" Street address\" });\n const city = await input({ message: \" City\" });\n const state = await input({ message: \" State (2-letter)\", default: \"DE\" });\n const zip = await input({ message: \" ZIP code\" });\n return { street, city, state, zip };\n}\n\n// ── Phase 1: Entity Details ────────────────────────────────────\n\nasync function phaseEntityDetails(opts: FormOptions, serverCfg: ApiRecord, scripted: boolean) {\n if (!scripted) sectionHeader(\"Phase 1: Entity Details\");\n\n let entityType = opts.type;\n if (!entityType) {\n if (scripted) { entityType = \"llc\"; }\n else {\n entityType = await select({\n message: \"Entity type\",\n choices: [\n { value: \"llc\", name: \"LLC\" },\n { value: \"c_corp\", name: \"C-Corp\" },\n ],\n });\n }\n }\n\n let name = opts.name;\n if (!name) {\n if (scripted) { printError(\"--name is required in scripted mode\"); process.exit(1); }\n name = await input({ message: \"Legal name\" });\n }\n\n let jurisdiction = opts.jurisdiction;\n if (!jurisdiction) {\n const defaultJ = entityType === \"llc\" ? \"US-WY\" : \"US-DE\";\n if (scripted) { jurisdiction = defaultJ; }\n else { jurisdiction = await input({ message: \"Jurisdiction\", default: defaultJ }); }\n }\n\n let companyAddress: { street: string; city: string; state: string; zip: string } | undefined;\n if (opts.address) {\n const parts = opts.address.split(\",\").map((p) => p.trim());\n if (parts.length === 4) {\n companyAddress = { street: parts[0], city: parts[1], state: parts[2], zip: parts[3] };\n }\n }\n if (!companyAddress && !scripted) {\n const wantAddress = await confirm({ message: \"Add company address?\", default: false });\n if (wantAddress) {\n companyAddress = await promptAddress();\n }\n }\n\n const fiscalYearEnd = opts.fiscalYearEnd ?? \"12-31\";\n\n let sCorpElection = opts.sCorp ?? false;\n if (!scripted && isCorp(entityType) && opts.sCorp === undefined) {\n sCorpElection = await confirm({ message: \"S-Corp election?\", default: false });\n }\n\n return { entityType, name, jurisdiction, companyAddress, fiscalYearEnd, sCorpElection };\n}\n\n// ── Phase 2: People ────────────────────────────────────────────\n\nasync function phasePeople(\n opts: FormOptions,\n entityType: string,\n scripted: boolean,\n): Promise<FounderInfo[]> {\n if (!scripted) sectionHeader(\"Phase 2: Founders & Officers\");\n\n const founders: FounderInfo[] = [];\n\n // CLI-provided members (scripted mode)\n if (scripted) {\n for (const m of opts.member!) {\n const parts = m.split(\",\").map((p) => p.trim());\n if (parts.length < 3) {\n printError(`Invalid member format: ${m}. Expected: name,email,role[,pct]`);\n process.exit(1);\n }\n const f: FounderInfo = { name: parts[0], email: parts[1], role: parts[2] };\n if (parts.length >= 4) f.ownership_pct = parseFloat(parts[3]);\n founders.push(f);\n }\n return founders;\n }\n\n // Interactive mode\n const founderCount = (await number({ message: \"Number of founders (1-6)\", default: 1 })) ?? 1;\n\n for (let i = 0; i < founderCount; i++) {\n console.log(chalk.dim(`\\n Founder ${i + 1} of ${founderCount}:`));\n const name = await input({ message: ` Name` });\n const email = await input({ message: ` Email` });\n\n let role = \"member\";\n if (isCorp(entityType)) {\n role = await select({\n message: \" Role\",\n choices: [\n { value: \"director\", name: \"Director\" },\n { value: \"officer\", name: \"Officer\" },\n { value: \"member\", name: \"Shareholder only\" },\n ],\n });\n }\n\n const wantAddress = await confirm({ message: \" Add address?\", default: false });\n const address = wantAddress ? await promptAddress() : undefined;\n\n let officerTitle: string | undefined;\n if (isCorp(entityType)) {\n const wantOfficer = role === \"officer\" || await confirm({ message: \" Assign officer title?\", default: i === 0 });\n if (wantOfficer) {\n officerTitle = await select({\n message: \" Officer title\",\n choices: OfficerTitle.map((t) => ({\n value: t,\n name: t === \"ceo\" ? \"CEO\" : t === \"cfo\" ? \"CFO\" : t === \"vp\" ? \"VP\" : t.charAt(0).toUpperCase() + t.slice(1),\n })),\n });\n }\n }\n\n let isIncorporator = false;\n if (isCorp(entityType) && i === 0 && founderCount === 1) {\n isIncorporator = true;\n } else if (isCorp(entityType)) {\n isIncorporator = await confirm({ message: \" Designate as sole incorporator?\", default: i === 0 });\n }\n\n founders.push({ name, email, role, address, officer_title: officerTitle, is_incorporator: isIncorporator });\n }\n\n return founders;\n}\n\n// ── Phase 3: Stock & Finalize ──────────────────────────────────\n\nasync function phaseStock(\n opts: FormOptions,\n entityType: string,\n founders: FounderInfo[],\n scripted: boolean,\n): Promise<{ founders: FounderInfo[]; transferRestrictions: boolean; rofr: boolean }> {\n if (!scripted) sectionHeader(\"Phase 3: Equity & Finalize\");\n\n const transferRestrictions = opts.transferRestrictions ?? (\n !scripted && isCorp(entityType)\n ? await confirm({ message: \"Transfer restrictions on shares?\", default: true })\n : isCorp(entityType)\n );\n\n const rofr = opts.rofr ?? (\n !scripted && isCorp(entityType)\n ? await confirm({ message: \"Right of first refusal?\", default: true })\n : isCorp(entityType)\n );\n\n if (!scripted) {\n for (const f of founders) {\n console.log(chalk.dim(`\\n Equity for ${f.name}:`));\n\n if (isCorp(entityType)) {\n const shares = await number({ message: ` Shares to purchase`, default: 0 });\n f.shares_purchased = shares ?? 0;\n if (f.shares_purchased === 0) {\n const pct = await number({ message: ` Ownership % (1-100)`, default: founders.length === 1 ? 100 : 0 });\n f.ownership_pct = pct ?? 0;\n }\n } else {\n const pct = await number({\n message: ` Ownership % (1-100)`,\n default: founders.length === 1 ? 100 : 0,\n });\n f.ownership_pct = pct ?? 0;\n }\n\n if (isCorp(entityType)) {\n const wantVesting = await confirm({ message: \" Add vesting schedule?\", default: false });\n if (wantVesting) {\n const totalMonths = (await number({ message: \" Total vesting months\", default: 48 })) ?? 48;\n const cliffMonths = (await number({ message: \" Cliff months\", default: 12 })) ?? 12;\n const acceleration = await select({\n message: \" Acceleration\",\n choices: [\n { value: \"none\", name: \"None\" },\n { value: \"single_trigger\", name: \"Single trigger\" },\n { value: \"double_trigger\", name: \"Double trigger\" },\n ],\n });\n f.vesting = {\n total_months: totalMonths,\n cliff_months: cliffMonths,\n acceleration: acceleration === \"none\" ? undefined : acceleration,\n };\n }\n }\n\n const wantIp = await confirm({ message: \" Contributing IP?\", default: false });\n if (wantIp) {\n f.ip_description = await input({ message: \" Describe IP being contributed\" });\n }\n }\n }\n\n return { founders, transferRestrictions, rofr };\n}\n\n// ── Summary Table ──────────────────────────────────────────────\n\nfunction printSummary(\n entityType: string,\n name: string,\n jurisdiction: string,\n fiscalYearEnd: string,\n sCorpElection: boolean,\n founders: FounderInfo[],\n transferRestrictions: boolean,\n rofr: boolean,\n): void {\n sectionHeader(\"Formation Summary\");\n\n console.log(` ${chalk.bold(\"Entity:\")} ${name}`);\n console.log(` ${chalk.bold(\"Type:\")} ${entityType}`);\n console.log(` ${chalk.bold(\"Jurisdiction:\")} ${jurisdiction}`);\n console.log(` ${chalk.bold(\"Fiscal Year End:\")} ${fiscalYearEnd}`);\n if (isCorp(entityType)) {\n console.log(` ${chalk.bold(\"S-Corp Election:\")} ${sCorpElection ? \"Yes\" : \"No\"}`);\n console.log(` ${chalk.bold(\"Transfer Restrictions:\")} ${transferRestrictions ? \"Yes\" : \"No\"}`);\n console.log(` ${chalk.bold(\"Right of First Refusal:\")} ${rofr ? \"Yes\" : \"No\"}`);\n }\n\n const table = new Table({\n head: [chalk.dim(\"Name\"), chalk.dim(\"Email\"), chalk.dim(\"Role\"), chalk.dim(\"Equity\"), chalk.dim(\"Officer\")],\n });\n for (const f of founders) {\n const equity = f.shares_purchased\n ? `${f.shares_purchased.toLocaleString()} shares`\n : f.ownership_pct\n ? `${f.ownership_pct}%`\n : \"—\";\n table.push([f.name, f.email, f.role, equity, f.officer_title ?? \"—\"]);\n }\n console.log(table.toString());\n}\n\n// ── Main Command ───────────────────────────────────────────────\n\nexport async function formCommand(opts: FormOptions): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n\n try {\n let serverCfg: ApiRecord = {};\n try { serverCfg = await client.getConfig(); } catch { /* ignore */ }\n\n const scripted = !!(opts.member && opts.member.length > 0);\n\n // Phase 1: Entity Details\n const { entityType, name, jurisdiction, companyAddress, fiscalYearEnd, sCorpElection } =\n await phaseEntityDetails(opts, serverCfg, scripted);\n\n // Phase 2: People\n const founders = await phasePeople(opts, entityType, scripted);\n\n // Phase 3: Stock & Finalize\n const { transferRestrictions, rofr } = await phaseStock(opts, entityType, founders, scripted);\n\n // Summary & Confirm\n printSummary(entityType, name, jurisdiction, fiscalYearEnd, sCorpElection, founders, transferRestrictions, rofr);\n\n const shouldProceed = scripted\n ? true\n : await confirm({ message: \"Proceed with formation?\", default: true });\n\n if (!shouldProceed) {\n console.log(chalk.yellow(\"Formation cancelled.\"));\n return;\n }\n\n // Build members payload\n const members: ApiRecord[] = founders.map((f) => {\n const m: ApiRecord = {\n name: f.name,\n email: f.email,\n role: f.role,\n investor_type: \"natural_person\",\n };\n if (f.ownership_pct) m.ownership_pct = f.ownership_pct;\n if (f.shares_purchased) m.shares_purchased = f.shares_purchased;\n if (f.address) m.address = f.address;\n if (f.officer_title) m.officer_title = f.officer_title;\n if (f.is_incorporator) m.is_incorporator = true;\n if (f.vesting) m.vesting = f.vesting;\n if (f.ip_description) m.ip_description = f.ip_description;\n return m;\n });\n\n const payload: ApiRecord = {\n entity_type: entityType,\n legal_name: name,\n jurisdiction,\n members,\n workspace_id: cfg.workspace_id,\n fiscal_year_end: fiscalYearEnd,\n s_corp_election: sCorpElection,\n transfer_restrictions: transferRestrictions,\n right_of_first_refusal: rofr,\n };\n if (companyAddress) payload.company_address = companyAddress;\n\n const result = await client.createFormationWithCapTable(payload);\n\n // Output results\n printSuccess(`Formation created: ${result.formation_id ?? \"OK\"}`);\n if (result.entity_id) console.log(` Entity ID: ${result.entity_id}`);\n if (result.legal_entity_id) console.log(` Legal Entity ID: ${result.legal_entity_id}`);\n if (result.instrument_id) console.log(` Instrument ID: ${result.instrument_id}`);\n\n const docIds = (result.document_ids ?? []) as string[];\n if (docIds.length > 0) {\n console.log(` Documents: ${docIds.length} generated`);\n }\n\n const holders = (result.holders ?? []) as ApiRecord[];\n if (holders.length > 0) {\n console.log();\n const table = new Table({\n head: [chalk.dim(\"Holder\"), chalk.dim(\"Shares\"), chalk.dim(\"Ownership %\")],\n });\n for (const h of holders) {\n const pct = typeof h.ownership_pct === \"number\" ? `${h.ownership_pct.toFixed(1)}%` : \"—\";\n table.push([String(h.name ?? \"?\"), String(h.shares ?? 0), pct]);\n }\n console.log(chalk.bold(\" Cap Table:\"));\n console.log(table.toString());\n }\n\n if (result.next_action) {\n console.log(chalk.yellow(`\\n Next: ${result.next_action}`));\n }\n } catch (err) {\n if (err instanceof Error && err.message.includes(\"exit\")) throw err;\n printError(`Failed to create formation: ${err}`);\n process.exit(1);\n }\n}\n\n// ── Staged Formation Subcommands ─────────────────────────────\n\ninterface FormCreateOptions {\n type: string;\n name: string;\n jurisdiction?: string;\n registeredAgentName?: string;\n registeredAgentAddress?: string;\n formationDate?: string;\n fiscalYearEnd?: string;\n sCorp?: boolean;\n transferRestrictions?: boolean;\n rofr?: boolean;\n companyAddress?: string;\n}\n\nfunction parseCsvAddress(raw?: string): { street: string; city: string; state: string; zip: string } | undefined {\n if (!raw) return undefined;\n const parts = raw.split(\",\").map((p) => p.trim()).filter(Boolean);\n if (parts.length !== 4) {\n throw new Error(`Invalid address format: ${raw}. Expected 'street,city,state,zip'`);\n }\n return { street: parts[0], city: parts[1], state: parts[2], zip: parts[3] };\n}\n\nexport async function formCreateCommand(opts: FormCreateOptions): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n\n try {\n const entityType = opts.type === \"corporation\" ? \"c_corp\" : opts.type;\n const payload: ApiRecord = {\n entity_type: entityType,\n legal_name: opts.name,\n };\n if (opts.jurisdiction) payload.jurisdiction = opts.jurisdiction;\n if (opts.registeredAgentName) payload.registered_agent_name = opts.registeredAgentName;\n if (opts.registeredAgentAddress) payload.registered_agent_address = opts.registeredAgentAddress;\n if (opts.formationDate) payload.formation_date = opts.formationDate;\n if (opts.fiscalYearEnd) payload.fiscal_year_end = opts.fiscalYearEnd;\n if (opts.sCorp !== undefined) payload.s_corp_election = opts.sCorp;\n if (opts.transferRestrictions !== undefined) payload.transfer_restrictions = opts.transferRestrictions;\n if (opts.rofr !== undefined) payload.right_of_first_refusal = opts.rofr;\n const companyAddress = parseCsvAddress(opts.companyAddress);\n if (companyAddress) payload.company_address = companyAddress;\n\n const result = await client.createPendingEntity(payload);\n printSuccess(`Pending entity created: ${result.entity_id}`);\n console.log(` Name: ${result.legal_name}`);\n console.log(` Type: ${result.entity_type}`);\n console.log(` Jurisdiction: ${result.jurisdiction}`);\n console.log(` Status: ${result.formation_status}`);\n console.log(chalk.yellow(`\\n Next: corp form add-founder ${result.entity_id} --name \"...\" --email \"...\" --role member --pct 50`));\n } catch (err) {\n printError(`Failed to create pending entity: ${err}`);\n process.exit(1);\n }\n}\n\ninterface FormAddFounderOptions {\n name: string;\n email: string;\n role: string;\n pct: string;\n officerTitle?: string;\n incorporator?: boolean;\n address?: string;\n}\n\ninterface FormFinalizeOptions {\n authorizedShares?: string;\n parValue?: string;\n registeredAgentName?: string;\n registeredAgentAddress?: string;\n formationDate?: string;\n fiscalYearEnd?: string;\n sCorp?: boolean;\n transferRestrictions?: boolean;\n rofr?: boolean;\n companyAddress?: string;\n}\n\nexport async function formAddFounderCommand(entityId: string, opts: FormAddFounderOptions): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n\n try {\n const payload: ApiRecord = {\n name: opts.name,\n email: opts.email,\n role: opts.role,\n ownership_pct: parseFloat(opts.pct),\n };\n if (opts.officerTitle) payload.officer_title = opts.officerTitle.toLowerCase();\n if (opts.incorporator) payload.is_incorporator = true;\n const address = parseCsvAddress(opts.address);\n if (address) payload.address = address;\n\n const result = await client.addFounder(entityId, payload);\n printSuccess(`Founder added (${result.member_count} total)`);\n const members = (result.members ?? []) as ApiRecord[];\n for (const m of members) {\n const pct = typeof m.ownership_pct === \"number\" ? ` (${m.ownership_pct}%)` : \"\";\n console.log(` - ${m.name} <${m.email ?? \"no email\"}> [${m.role ?? \"member\"}]${pct}`);\n }\n console.log(chalk.yellow(`\\n Next: add more founders or run: corp form finalize ${entityId}`));\n } catch (err) {\n printError(`Failed to add founder: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function formFinalizeCommand(entityId: string, opts: FormFinalizeOptions): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n\n try {\n const payload: ApiRecord = {};\n if (opts.authorizedShares) {\n const authorizedShares = parseInt(opts.authorizedShares, 10);\n if (!Number.isFinite(authorizedShares)) {\n throw new Error(`Invalid authorized shares: ${opts.authorizedShares}`);\n }\n payload.authorized_shares = authorizedShares;\n }\n if (opts.parValue) payload.par_value = opts.parValue;\n if (opts.registeredAgentName) payload.registered_agent_name = opts.registeredAgentName;\n if (opts.registeredAgentAddress) payload.registered_agent_address = opts.registeredAgentAddress;\n if (opts.formationDate) payload.formation_date = opts.formationDate;\n if (opts.fiscalYearEnd) payload.fiscal_year_end = opts.fiscalYearEnd;\n if (opts.sCorp !== undefined) payload.s_corp_election = opts.sCorp;\n if (opts.transferRestrictions !== undefined) payload.transfer_restrictions = opts.transferRestrictions;\n if (opts.rofr !== undefined) payload.right_of_first_refusal = opts.rofr;\n const companyAddress = parseCsvAddress(opts.companyAddress);\n if (companyAddress) payload.company_address = companyAddress;\n\n const result = await client.finalizeFormation(entityId, payload);\n printSuccess(`Formation finalized: ${result.entity_id}`);\n if (result.legal_entity_id) console.log(` Legal Entity ID: ${result.legal_entity_id}`);\n if (result.instrument_id) console.log(` Instrument ID: ${result.instrument_id}`);\n\n const docIds = (result.document_ids ?? []) as string[];\n if (docIds.length > 0) {\n console.log(` Documents: ${docIds.length} generated`);\n }\n\n const holders = (result.holders ?? []) as ApiRecord[];\n if (holders.length > 0) {\n console.log();\n const table = new Table({\n head: [chalk.dim(\"Holder\"), chalk.dim(\"Shares\"), chalk.dim(\"Ownership %\")],\n });\n for (const h of holders) {\n const pct = typeof h.ownership_pct === \"number\" ? `${h.ownership_pct.toFixed(1)}%` : \"—\";\n table.push([String(h.name ?? \"?\"), String(h.shares ?? 0), pct]);\n }\n console.log(chalk.bold(\" Cap Table:\"));\n console.log(table.toString());\n }\n\n if (result.next_action) {\n console.log(chalk.yellow(`\\n Next: ${result.next_action}`));\n }\n } catch (err) {\n printError(`Failed to finalize formation: ${err}`);\n process.exit(1);\n }\n}\n","import { requireConfig, maskKey } from \"../config.js\";\nimport { CorpAPIClient } from \"../api-client.js\";\nimport { printError, printJson } from \"../output.js\";\nimport chalk from \"chalk\";\nimport Table from \"cli-table3\";\n\nexport async function apiKeysCommand(opts: { json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const keys = await client.listApiKeys();\n if (opts.json) {\n printJson(keys.map((k: any) => ({\n ...k,\n ...(k.key != null ? { key: maskKey(String(k.key)) } : {}),\n ...(k.api_key != null ? { api_key: maskKey(String(k.api_key)) } : {}),\n })));\n return;\n }\n if (keys.length === 0) { console.log(\"No API keys found.\"); return; }\n console.log(`\\n${chalk.bold(\"API Keys\")}`);\n const table = new Table({\n head: [chalk.dim(\"ID\"), chalk.dim(\"Name\"), chalk.dim(\"Key\"), chalk.dim(\"Created\")],\n });\n for (const k of keys) {\n table.push([\n String(k.key_id ?? k.id ?? k.api_key_id ?? \"\").slice(0, 12),\n String(k.name ?? \"\"),\n maskKey(String(k.key ?? k.api_key ?? \"\")),\n String(k.created_at ?? \"\"),\n ]);\n }\n console.log(table.toString());\n } catch (err) { printError(`Failed to fetch API keys: ${err}`); process.exit(1); }\n}\n","import { requireConfig } from \"../config.js\";\nimport { CorpAPIClient } from \"../api-client.js\";\nimport { printError, printSuccess, printJson } from \"../output.js\";\nimport { withSpinner } from \"../spinner.js\";\n\nexport async function demoCommand(opts: { name: string }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await withSpinner(\"Loading\", () => client.seedDemo(opts.name));\n printSuccess(`Demo seeded: ${result.entity_id ?? \"OK\"}`);\n printJson(result);\n } catch (err) { printError(`Failed to seed demo: ${err}`); process.exit(1); }\n}\n","import { readFileSync, writeFileSync, existsSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { randomBytes } from \"node:crypto\";\nimport type { ChildProcess } from \"node:child_process\";\n\ninterface ServeOptions {\n port: string;\n dataDir: string;\n}\n\nconst ENV_TEMPLATE = `# Corporation API server configuration\n# Generated by: corp serve\n\n# Required — secret for signing JWTs\nJWT_SECRET={{JWT_SECRET}}\n\n# Required — Fernet key for encrypting secrets at rest (base64url, 32 bytes)\nSECRETS_MASTER_KEY={{SECRETS_MASTER_KEY}}\n\n# Required — bearer token for internal worker-to-server auth\nINTERNAL_WORKER_TOKEN={{INTERNAL_WORKER_TOKEN}}\n\n# Server port (default: 8000)\n# PORT=8000\n\n# Data directory for git repos (default: ./data/repos)\n# DATA_DIR=./data/repos\n\n# Redis URL for agent job queue (optional)\n# REDIS_URL=redis://localhost:6379/0\n\n# LLM proxy upstream (default: https://openrouter.ai/api/v1)\n# LLM_UPSTREAM_URL=https://openrouter.ai/api/v1\n\n# PEM-encoded Ed25519 key for signing git commits (optional)\n# COMMIT_SIGNING_KEY=\n\n# Max agent queue depth (default: 1000)\n# MAX_QUEUE_DEPTH=1000\n`;\n\nfunction generateFernetKey(): string {\n // Fernet key = url-safe base64 of 32 random bytes\n return randomBytes(32).toString(\"base64url\") + \"=\";\n}\n\nfunction generateSecret(length = 32): string {\n return randomBytes(length).toString(\"hex\");\n}\n\nfunction loadEnvFile(path: string): void {\n if (!existsSync(path)) return;\n\n const content = readFileSync(path, \"utf-8\");\n for (const line of content.split(\"\\n\")) {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith(\"#\")) continue;\n\n const eqIdx = trimmed.indexOf(\"=\");\n if (eqIdx === -1) continue;\n\n const key = trimmed.slice(0, eqIdx).trim();\n const value = trimmed.slice(eqIdx + 1).trim().replace(/^[\"']|[\"']$/g, \"\");\n\n // Don't override vars already set in the environment\n if (!process.env[key]) {\n process.env[key] = value;\n }\n }\n}\n\nfunction ensureEnvFile(envPath: string): void {\n if (existsSync(envPath)) return;\n\n console.log(\"No .env file found. Generating one with dev defaults...\\n\");\n\n const content = ENV_TEMPLATE\n .replace(\"{{JWT_SECRET}}\", generateSecret())\n .replace(\"{{SECRETS_MASTER_KEY}}\", generateFernetKey())\n .replace(\"{{INTERNAL_WORKER_TOKEN}}\", generateSecret());\n\n writeFileSync(envPath, content, \"utf-8\");\n console.log(` Created ${envPath}\\n`);\n}\n\nexport async function serveCommand(opts: ServeOptions): Promise<void> {\n let server: { getBinaryPath: () => string | null; isAvailable: () => boolean; startServer: (options: Record<string, unknown>) => ChildProcess };\n try {\n server = await import(\"@thecorporation/server\");\n } catch {\n console.error(\n \"Error: @thecorporation/server is not installed.\\n\\n\" +\n \"Install it with:\\n\" +\n \" npm install @thecorporation/server\\n\\n\" +\n \"Or run the Rust binary directly:\\n\" +\n \" cd services/api-rs && cargo run\"\n );\n process.exit(1);\n }\n\n if (!server.isAvailable()) {\n console.error(\n \"Error: No server binary available for this platform.\\n\\n\" +\n \"Pre-built binaries are available for:\\n\" +\n \" - linux-x64, linux-arm64\\n\" +\n \" - darwin-x64, darwin-arm64\\n\" +\n \" - win32-x64\\n\\n\" +\n \"You can build from source:\\n\" +\n \" cd services/api-rs && cargo build --release\"\n );\n process.exit(1);\n }\n\n const port = parseInt(opts.port, 10);\n if (isNaN(port) || port > 65535) {\n console.error(`Error: Invalid port \"${opts.port}\"`);\n process.exit(1);\n }\n\n // Load .env file, generating one if it doesn't exist\n const envPath = resolve(process.cwd(), \".env\");\n ensureEnvFile(envPath);\n loadEnvFile(envPath);\n\n // Auto-configure CLI to point at the local server\n const localUrl = `http://localhost:${port}`;\n const { loadConfig, saveConfig } = await import(\"../config.js\");\n const cfg = loadConfig();\n const previousUrl = cfg.api_url;\n if (cfg.api_url !== localUrl) {\n cfg.api_url = localUrl;\n saveConfig(cfg);\n console.log(`CLI configured to use local server: ${localUrl}`);\n console.log(` (previous: ${previousUrl})`);\n console.log(` To revert: corp config set api_url ${previousUrl}\\n`);\n }\n\n console.log(`Starting server on port ${port}...`);\n console.log(`Data directory: ${opts.dataDir}`);\n\n const child = server.startServer({\n port,\n dataDir: opts.dataDir,\n });\n\n const shutdown = () => {\n console.log(\"\\nShutting down server...\");\n // Restore previous API URL\n if (previousUrl !== localUrl) {\n const current = loadConfig();\n current.api_url = previousUrl;\n saveConfig(current);\n console.log(`CLI restored to: ${previousUrl}`);\n }\n child.kill(\"SIGTERM\");\n };\n\n process.on(\"SIGINT\", shutdown);\n process.on(\"SIGTERM\", shutdown);\n\n child.on(\"exit\", (code) => {\n process.exit(code ?? 0);\n });\n}\n","import { Command, Option } from \"commander\";\nimport { createRequire } from \"node:module\";\nimport { inheritOption } from \"./command-options.js\";\n\nconst require = createRequire(import.meta.url);\nconst pkg = require(\"../package.json\");\n\nconst program = new Command();\nprogram\n .name(\"corp\")\n .description(\"corp — Corporate governance from the terminal\")\n .version(pkg.version);\n\n// --- setup ---\nprogram\n .command(\"setup\")\n .description(\"Interactive setup wizard\")\n .action(async () => {\n const { setupCommand } = await import(\"./commands/setup.js\");\n await setupCommand();\n });\n\n// --- status ---\nprogram\n .command(\"status\")\n .description(\"Workspace summary\")\n .action(async () => {\n const { statusCommand } = await import(\"./commands/status.js\");\n await statusCommand();\n });\n\n// --- config ---\nconst configCmd = program.command(\"config\").description(\"Manage configuration\");\nconfigCmd\n .command(\"set <key> <value>\")\n .description(\"Set a config value (dot-path)\")\n .action(async (key: string, value: string) => {\n const { configSetCommand } = await import(\"./commands/config.js\");\n configSetCommand(key, value);\n });\nconfigCmd\n .command(\"get <key>\")\n .description(\"Get a config value (dot-path)\")\n .action(async (key: string) => {\n const { configGetCommand } = await import(\"./commands/config.js\");\n configGetCommand(key);\n });\nconfigCmd\n .command(\"list\")\n .description(\"List all config (API keys masked)\")\n .action(async () => {\n const { configListCommand } = await import(\"./commands/config.js\");\n configListCommand();\n });\n\n// --- obligations ---\nprogram\n .command(\"obligations\")\n .description(\"List obligations with urgency tiers\")\n .option(\"--tier <tier>\", \"Filter by urgency tier\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (opts) => {\n const { obligationsCommand } = await import(\"./commands/obligations.js\");\n await obligationsCommand(opts);\n });\n\n// --- digest ---\nprogram\n .command(\"digest\")\n .description(\"View or trigger daily digests\")\n .option(\"--trigger\", \"Trigger digest now\")\n .option(\"--key <key>\", \"Get specific digest by key\")\n .action(async (opts) => {\n const { digestCommand } = await import(\"./commands/digest.js\");\n await digestCommand(opts);\n });\n\n// --- link ---\nprogram\n .command(\"link\")\n .description(\"Link workspace to an external provider\")\n .requiredOption(\"--external-id <id>\", \"External ID to link\")\n .requiredOption(\"--provider <provider>\", \"Provider name (e.g. stripe, github)\")\n .action(async (opts) => {\n const { linkCommand } = await import(\"./commands/link.js\");\n await linkCommand(opts);\n });\n\n// --- claim ---\nprogram\n .command(\"claim <code>\")\n .description(\"Redeem a claim code to join a workspace\")\n .action(async (code: string) => {\n const { claimCommand } = await import(\"./commands/claim.js\");\n await claimCommand(code);\n });\n\n// --- chat ---\nprogram\n .command(\"chat\")\n .description(\"Interactive LLM chat session\")\n .action(async () => {\n const { chatCommand } = await import(\"./chat.js\");\n await chatCommand();\n });\n\n// --- entities ---\nconst entitiesCmd = program\n .command(\"entities\")\n .description(\"List entities, show detail, convert, or dissolve\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (opts) => {\n const { entitiesCommand } = await import(\"./commands/entities.js\");\n await entitiesCommand(opts);\n });\nentitiesCmd\n .command(\"show <entity-id>\")\n .option(\"--json\", \"Output as JSON\")\n .description(\"Show entity detail\")\n .action(async (entityId: string, opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { entitiesShowCommand } = await import(\"./commands/entities.js\");\n await entitiesShowCommand(entityId, {\n ...opts,\n json: inheritOption(opts.json, parent.json),\n });\n });\nentitiesCmd\n .command(\"convert <entity-id>\")\n .requiredOption(\"--to <type>\", \"Target entity type (llc, c_corp)\")\n .option(\"--jurisdiction <jurisdiction>\", \"New jurisdiction\")\n .description(\"Convert entity to a different type\")\n .action(async (entityId: string, opts) => {\n const { entitiesConvertCommand } = await import(\"./commands/entities.js\");\n await entitiesConvertCommand(entityId, opts);\n });\nentitiesCmd\n .command(\"dissolve <entity-id>\")\n .requiredOption(\"--reason <reason>\", \"Dissolution reason\")\n .option(\"--effective-date <date>\", \"Effective date (ISO 8601)\")\n .description(\"Dissolve an entity\")\n .action(async (entityId: string, opts) => {\n const { entitiesDissolveCommand } = await import(\"./commands/entities.js\");\n await entitiesDissolveCommand(entityId, opts);\n });\n\n// --- contacts ---\nconst contactsCmd = program\n .command(\"contacts\")\n .description(\"Contact management\")\n .option(\"--entity-id <id>\", \"Entity ID (overrides active entity)\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (opts) => {\n const { contactsListCommand } = await import(\"./commands/contacts.js\");\n await contactsListCommand(opts);\n });\ncontactsCmd\n .command(\"show <contact-id>\")\n .option(\"--json\", \"Output as JSON\")\n .description(\"Show contact detail/profile\")\n .action(async (contactId: string, opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { contactsShowCommand } = await import(\"./commands/contacts.js\");\n await contactsShowCommand(contactId, {\n ...opts,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\ncontactsCmd\n .command(\"add\")\n .requiredOption(\"--name <name>\", \"Contact name\")\n .requiredOption(\"--email <email>\", \"Contact email\")\n .option(\"--type <type>\", \"Contact type (individual, organization)\", \"individual\")\n .option(\"--category <category>\", \"Category (employee, contractor, board_member, investor, law_firm, valuation_firm, accounting_firm, officer, founder, member, other)\")\n .option(\"--phone <phone>\", \"Phone number\")\n .option(\"--notes <notes>\", \"Notes\")\n .description(\"Add a new contact\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { contactsAddCommand } = await import(\"./commands/contacts.js\");\n await contactsAddCommand({ ...opts, entityId: parent.entityId });\n });\ncontactsCmd\n .command(\"edit <contact-id>\")\n .option(\"--name <name>\", \"Contact name\")\n .option(\"--email <email>\", \"Contact email\")\n .option(\"--category <category>\", \"Contact category\")\n .option(\"--phone <phone>\", \"Phone number\")\n .option(\"--notes <notes>\", \"Notes\")\n .description(\"Edit an existing contact\")\n .action(async (contactId: string, opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { contactsEditCommand } = await import(\"./commands/contacts.js\");\n await contactsEditCommand(contactId, { ...opts, entityId: parent.entityId });\n });\n\n// --- cap-table ---\nconst capTableCmd = program\n .command(\"cap-table\")\n .description(\"Cap table, equity grants, SAFEs, transfers, and valuations\")\n .option(\"--entity-id <id>\", \"Entity ID (overrides active entity)\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (opts) => {\n const { capTableCommand } = await import(\"./commands/cap-table.js\");\n await capTableCommand(opts);\n });\ncapTableCmd.command(\"safes\").description(\"SAFE notes\").action(async (_opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { safesCommand } = await import(\"./commands/cap-table.js\");\n await safesCommand(parent);\n});\ncapTableCmd.command(\"transfers\").description(\"Share transfers\").action(async (_opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { transfersCommand } = await import(\"./commands/cap-table.js\");\n await transfersCommand(parent);\n});\ncapTableCmd.command(\"valuations\").description(\"Valuations history\").action(async (_opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { valuationsCommand } = await import(\"./commands/cap-table.js\");\n await valuationsCommand(parent);\n});\ncapTableCmd.command(\"409a\").description(\"Current 409A valuation\").action(async (_opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { fourOhNineACommand } = await import(\"./commands/cap-table.js\");\n await fourOhNineACommand(parent);\n});\ncapTableCmd\n .command(\"issue-equity\")\n .requiredOption(\"--grant-type <type>\", \"Grant type (common, preferred, membership_unit, stock_option, iso, nso, rsa)\")\n .requiredOption(\"--shares <n>\", \"Number of shares\", parseInt)\n .requiredOption(\"--recipient <name>\", \"Recipient name\")\n .option(\"--email <email>\", \"Recipient email (auto-creates contact if needed)\")\n .option(\"--instrument-id <id>\", \"Instrument ID (auto-detected from cap table if omitted)\")\n .description(\"Issue an equity grant (creates a round, adds security, and issues it)\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { issueEquityCommand } = await import(\"./commands/cap-table.js\");\n await issueEquityCommand({ ...opts, entityId: parent.entityId });\n });\ncapTableCmd\n .command(\"issue-safe\")\n .requiredOption(\"--investor <name>\", \"Investor name\")\n .requiredOption(\"--amount <n>\", \"Principal amount in cents\", parseInt)\n .option(\"--safe-type <type>\", \"SAFE type\", \"post_money\")\n .requiredOption(\"--valuation-cap <n>\", \"Valuation cap in cents\", parseInt)\n .description(\"Issue a SAFE note\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { issueSafeCommand } = await import(\"./commands/cap-table.js\");\n await issueSafeCommand({ ...opts, entityId: parent.entityId });\n });\ncapTableCmd\n .command(\"transfer\")\n .requiredOption(\"--from <id>\", \"Source contact ID (from_contact_id)\")\n .requiredOption(\"--to <id>\", \"Destination contact ID (to_contact_id)\")\n .requiredOption(\"--shares <n>\", \"Number of shares to transfer\", parseInt)\n .requiredOption(\"--share-class-id <id>\", \"Share class ID\")\n .requiredOption(\"--governing-doc-type <type>\", \"Governing doc type (bylaws, operating_agreement, shareholder_agreement, other)\")\n .requiredOption(\"--transferee-rights <rights>\", \"Transferee rights (full_member, economic_only, limited)\")\n .option(\"--prepare-intent-id <id>\", \"Prepare intent ID (auto-created if omitted)\")\n .option(\"--type <type>\", \"Transfer type (gift, trust_transfer, secondary_sale, estate, other)\", \"secondary_sale\")\n .option(\"--price-per-share-cents <n>\", \"Price per share in cents\", parseInt)\n .option(\"--relationship <rel>\", \"Relationship to holder\")\n .description(\"Create a share transfer workflow\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { transferSharesCommand } = await import(\"./commands/cap-table.js\");\n await transferSharesCommand({ ...opts, entityId: parent.entityId });\n });\ncapTableCmd\n .command(\"distribute\")\n .requiredOption(\"--amount <n>\", \"Total distribution amount in cents\", parseInt)\n .option(\"--type <type>\", \"Distribution type (dividend, return, liquidation)\", \"dividend\")\n .requiredOption(\"--description <desc>\", \"Distribution description\")\n .description(\"Calculate a distribution\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { distributeCommand } = await import(\"./commands/cap-table.js\");\n await distributeCommand({ ...opts, entityId: parent.entityId });\n });\n\ncapTableCmd\n .command(\"start-round\")\n .requiredOption(\"--name <name>\", \"Round name\")\n .requiredOption(\"--issuer-legal-entity-id <id>\", \"Issuer legal entity ID\")\n .description(\"Start a staged equity round\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { startRoundCommand } = await import(\"./commands/cap-table.js\");\n await startRoundCommand({ ...opts, entityId: parent.entityId });\n });\ncapTableCmd\n .command(\"add-security\")\n .requiredOption(\"--round-id <id>\", \"Round ID\")\n .requiredOption(\"--instrument-id <id>\", \"Instrument ID\")\n .requiredOption(\"--quantity <n>\", \"Number of shares/units\", parseInt)\n .requiredOption(\"--recipient-name <name>\", \"Recipient display name\")\n .option(\"--holder-id <id>\", \"Existing holder ID\")\n .option(\"--email <email>\", \"Recipient email (to find or create holder)\")\n .option(\"--principal-cents <n>\", \"Principal amount in cents\", parseInt)\n .option(\"--grant-type <type>\", \"Grant type\")\n .description(\"Add a security to a staged equity round\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { addSecurityCommand } = await import(\"./commands/cap-table.js\");\n await addSecurityCommand({ ...opts, entityId: parent.entityId });\n });\ncapTableCmd\n .command(\"issue-round\")\n .requiredOption(\"--round-id <id>\", \"Round ID\")\n .description(\"Issue all securities and close a staged round\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { issueRoundCommand } = await import(\"./commands/cap-table.js\");\n await issueRoundCommand({ ...opts, entityId: parent.entityId });\n });\ncapTableCmd\n .command(\"create-valuation\")\n .requiredOption(\"--type <type>\", \"Valuation type (four_oh_nine_a, fair_market_value, etc.)\")\n .requiredOption(\"--date <date>\", \"Effective date (ISO 8601)\")\n .requiredOption(\"--methodology <method>\", \"Methodology (income, market, asset, backsolve, hybrid)\")\n .option(\"--fmv <cents>\", \"FMV per share in cents\", parseInt)\n .option(\"--enterprise-value <cents>\", \"Enterprise value in cents\", parseInt)\n .description(\"Create a valuation\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { createValuationCommand } = await import(\"./commands/cap-table.js\");\n await createValuationCommand({ ...opts, entityId: parent.entityId });\n });\ncapTableCmd\n .command(\"submit-valuation <valuation-id>\")\n .description(\"Submit a valuation for board approval\")\n .action(async (valuationId: string, _opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { submitValuationCommand } = await import(\"./commands/cap-table.js\");\n await submitValuationCommand({ valuationId, entityId: parent.entityId });\n });\ncapTableCmd\n .command(\"approve-valuation <valuation-id>\")\n .option(\"--resolution-id <id>\", \"Resolution ID from the board vote\")\n .description(\"Approve a valuation\")\n .action(async (valuationId: string, opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { approveValuationCommand } = await import(\"./commands/cap-table.js\");\n await approveValuationCommand({ ...opts, valuationId, entityId: parent.entityId });\n });\n\n// --- finance ---\nconst financeCmd = program\n .command(\"finance\")\n .description(\"Invoicing, payroll, payments, banking\")\n .option(\"--entity-id <id>\", \"Entity ID (overrides active entity)\");\nfinanceCmd\n .command(\"invoice\")\n .requiredOption(\"--customer <name>\", \"Customer name\")\n .requiredOption(\"--amount <n>\", \"Amount in cents\", parseInt)\n .requiredOption(\"--due-date <date>\", \"Due date (ISO 8601)\")\n .option(\"--description <desc>\", \"Description\", \"Services rendered\")\n .description(\"Create an invoice\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { financeInvoiceCommand } = await import(\"./commands/finance.js\");\n await financeInvoiceCommand({ ...opts, entityId: parent.entityId });\n });\nfinanceCmd\n .command(\"payroll\")\n .requiredOption(\"--period-start <date>\", \"Pay period start\")\n .requiredOption(\"--period-end <date>\", \"Pay period end\")\n .description(\"Run payroll\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { financePayrollCommand } = await import(\"./commands/finance.js\");\n await financePayrollCommand({ ...opts, entityId: parent.entityId });\n });\nfinanceCmd\n .command(\"pay\")\n .requiredOption(\"--amount <n>\", \"Amount in cents\", parseInt)\n .requiredOption(\"--recipient <name>\", \"Recipient name\")\n .option(\"--method <method>\", \"Payment method\", \"ach\")\n .description(\"Submit a payment\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { financePayCommand } = await import(\"./commands/finance.js\");\n await financePayCommand({ ...opts, entityId: parent.entityId });\n });\nfinanceCmd\n .command(\"open-account\")\n .option(\"--institution <name>\", \"Banking institution\", \"Mercury\")\n .description(\"Open a business bank account\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { financeOpenAccountCommand } = await import(\"./commands/finance.js\");\n await financeOpenAccountCommand({ ...opts, entityId: parent.entityId });\n });\nfinanceCmd\n .command(\"classify-contractor\")\n .requiredOption(\"--name <name>\", \"Contractor name\")\n .requiredOption(\"--state <code>\", \"US state code\")\n .requiredOption(\"--hours <n>\", \"Hours per week\", parseInt)\n .option(\"--exclusive\", \"Exclusive client\", false)\n .requiredOption(\"--duration <n>\", \"Duration in months\", parseInt)\n .option(\"--provides-tools\", \"Company provides tools\", false)\n .description(\"Analyze contractor classification risk\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { financeClassifyContractorCommand } = await import(\"./commands/finance.js\");\n await financeClassifyContractorCommand({ ...opts, entityId: parent.entityId });\n });\nfinanceCmd\n .command(\"reconcile\")\n .requiredOption(\"--start-date <date>\", \"Period start\")\n .requiredOption(\"--end-date <date>\", \"Period end\")\n .description(\"Reconcile ledger\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { financeReconcileCommand } = await import(\"./commands/finance.js\");\n await financeReconcileCommand({ ...opts, entityId: parent.entityId });\n });\n\n// --- governance ---\nconst governanceCmd = program\n .command(\"governance\")\n .description(\"Governance bodies, seats, meetings, resolutions\")\n .option(\"--entity-id <id>\", \"Entity ID (overrides active entity)\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (opts) => {\n const { governanceListCommand } = await import(\"./commands/governance.js\");\n await governanceListCommand(opts);\n });\ngovernanceCmd\n .command(\"create-body\")\n .requiredOption(\"--name <name>\", \"Body name (e.g. 'Board of Directors')\")\n .requiredOption(\"--body-type <type>\", \"Body type (board_of_directors, llc_member_vote)\")\n .option(\"--quorum <rule>\", \"Quorum rule (majority, supermajority, unanimous)\", \"majority\")\n .option(\"--voting <method>\", \"Voting method (per_capita, per_unit)\", \"per_capita\")\n .description(\"Create a governance body\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { governanceCreateBodyCommand } = await import(\"./commands/governance.js\");\n await governanceCreateBodyCommand({ ...opts, entityId: parent.entityId });\n });\ngovernanceCmd\n .command(\"add-seat <body-id>\")\n .requiredOption(\"--holder <contact-id>\", \"Contact ID for the seat holder\")\n .option(\"--role <role>\", \"Seat role (chair, member, officer, observer)\", \"member\")\n .description(\"Add a seat to a governance body\")\n .action(async (bodyId: string, opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { governanceAddSeatCommand } = await import(\"./commands/governance.js\");\n await governanceAddSeatCommand(bodyId, { ...opts, entityId: parent.entityId });\n });\ngovernanceCmd\n .command(\"seats <body-id>\")\n .description(\"Seats for a governance body\")\n .action(async (bodyId: string, _opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { governanceSeatsCommand } = await import(\"./commands/governance.js\");\n await governanceSeatsCommand(bodyId, parent);\n });\ngovernanceCmd\n .command(\"meetings <body-id>\")\n .description(\"Meetings for a governance body\")\n .action(async (bodyId: string, _opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { governanceMeetingsCommand } = await import(\"./commands/governance.js\");\n await governanceMeetingsCommand(bodyId, parent);\n });\ngovernanceCmd\n .command(\"resolutions <meeting-id>\")\n .description(\"Resolutions for a meeting\")\n .action(async (meetingId: string, _opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { governanceResolutionsCommand } = await import(\"./commands/governance.js\");\n await governanceResolutionsCommand(meetingId, parent);\n });\ngovernanceCmd\n .command(\"convene\")\n .requiredOption(\"--body <id>\", \"Governance body ID\")\n .requiredOption(\"--type <type>\", \"Meeting type (board_meeting, shareholder_meeting, member_meeting, written_consent)\")\n .requiredOption(\"--title <title>\", \"Meeting title\")\n .requiredOption(\"--date <date>\", \"Meeting date (ISO 8601)\")\n .option(\"--agenda <item>\", \"Agenda item (repeatable)\", (v: string, a: string[]) => [...a, v], [] as string[])\n .description(\"Convene a governance meeting\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { governanceConveneCommand } = await import(\"./commands/governance.js\");\n await governanceConveneCommand({ ...opts, meetingType: opts.type, entityId: parent.entityId });\n });\ngovernanceCmd\n .command(\"vote <meeting-id> <item-id>\")\n .requiredOption(\"--voter <id>\", \"Voter contact UUID\")\n .addOption(new Option(\"--vote <value>\", \"Vote (for, against, abstain, recusal)\").choices([\"for\", \"against\", \"abstain\", \"recusal\"]).makeOptionMandatory())\n .description(\"Cast a vote on an agenda item\")\n .action(async (meetingId: string, itemId: string, opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { governanceVoteCommand } = await import(\"./commands/governance.js\");\n await governanceVoteCommand(meetingId, itemId, {\n ...opts,\n entityId: parent.entityId,\n });\n });\ngovernanceCmd\n .command(\"notice <meeting-id>\")\n .description(\"Send meeting notice\")\n .action(async (meetingId: string, _opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { sendNoticeCommand } = await import(\"./commands/governance.js\");\n await sendNoticeCommand(meetingId, { entityId: parent.entityId });\n });\ngovernanceCmd\n .command(\"adjourn <meeting-id>\")\n .description(\"Adjourn a meeting\")\n .action(async (meetingId: string, _opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { adjournMeetingCommand } = await import(\"./commands/governance.js\");\n await adjournMeetingCommand(meetingId, { entityId: parent.entityId });\n });\ngovernanceCmd\n .command(\"cancel <meeting-id>\")\n .description(\"Cancel a meeting\")\n .action(async (meetingId: string, _opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { cancelMeetingCommand } = await import(\"./commands/governance.js\");\n await cancelMeetingCommand(meetingId, { entityId: parent.entityId });\n });\ngovernanceCmd\n .command(\"agenda-items <meeting-id>\")\n .description(\"List agenda items for a meeting\")\n .action(async (meetingId: string, _opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { listAgendaItemsCommand } = await import(\"./commands/governance.js\");\n await listAgendaItemsCommand(meetingId, { entityId: parent.entityId, json: parent.json });\n });\ngovernanceCmd\n .command(\"finalize-item <meeting-id> <item-id>\")\n .requiredOption(\"--status <status>\", \"Status: voted, discussed, tabled, withdrawn\")\n .description(\"Finalize an agenda item\")\n .action(async (meetingId: string, itemId: string, opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { finalizeAgendaItemCommand } = await import(\"./commands/governance.js\");\n await finalizeAgendaItemCommand(meetingId, itemId, { ...opts, entityId: parent.entityId });\n });\ngovernanceCmd\n .command(\"resolve <meeting-id> <item-id>\")\n .requiredOption(\"--text <resolution_text>\", \"Resolution text\")\n .description(\"Compute a resolution for an agenda item\")\n .action(async (meetingId: string, itemId: string, opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { computeResolutionCommand } = await import(\"./commands/governance.js\");\n await computeResolutionCommand(meetingId, itemId, { ...opts, entityId: parent.entityId });\n });\ngovernanceCmd\n .command(\"written-consent\")\n .requiredOption(\"--body <id>\", \"Governance body ID\")\n .requiredOption(\"--title <title>\", \"Title\")\n .requiredOption(\"--description <desc>\", \"Description\")\n .description(\"Create a written consent action\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { writtenConsentCommand } = await import(\"./commands/governance.js\");\n await writtenConsentCommand({ ...opts, entityId: parent.entityId });\n });\n\n// --- documents ---\nconst documentsCmd = program\n .command(\"documents\")\n .description(\"Documents and signing\")\n .option(\"--entity-id <id>\", \"Entity ID (overrides active entity)\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (opts) => {\n const { documentsListCommand } = await import(\"./commands/documents.js\");\n await documentsListCommand(opts);\n });\ndocumentsCmd\n .command(\"signing-link <doc-id>\")\n .option(\"--entity-id <id>\", \"Entity ID (overrides active entity and parent command)\")\n .description(\"Get a signing link for a document\")\n .action(async (docId: string, opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { documentsSigningLinkCommand } = await import(\"./commands/documents.js\");\n await documentsSigningLinkCommand(docId, { entityId: opts.entityId ?? parent.entityId });\n });\ndocumentsCmd\n .command(\"generate\")\n .requiredOption(\"--template <type>\", \"Template type (consulting_agreement, employment_offer, contractor_agreement, nda, custom)\")\n .requiredOption(\"--counterparty <name>\", \"Counterparty name\")\n .option(\"--effective-date <date>\", \"Effective date (ISO 8601, defaults to today)\")\n .description(\"Generate a contract from a template\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { documentsGenerateCommand } = await import(\"./commands/documents.js\");\n await documentsGenerateCommand({ ...opts, entityId: parent.entityId });\n });\ndocumentsCmd\n .command(\"preview-pdf\")\n .requiredOption(\"--document-id <id>\", \"AST document definition ID (e.g. 'bylaws')\")\n .description(\"Validate and print the authenticated PDF preview URL for a governance document\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { documentsPreviewPdfCommand } = await import(\"./commands/documents.js\");\n await documentsPreviewPdfCommand({ ...opts, entityId: parent.entityId });\n });\n\n// --- tax ---\nconst taxCmd = program\n .command(\"tax\")\n .description(\"Tax filings and deadline tracking\")\n .option(\"--entity-id <id>\", \"Entity ID (overrides active entity)\");\ntaxCmd\n .command(\"file\")\n .requiredOption(\"--type <type>\", \"Document type\")\n .requiredOption(\"--year <year>\", \"Tax year\", parseInt)\n .description(\"File a tax document\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { taxFileCommand } = await import(\"./commands/tax.js\");\n await taxFileCommand({ ...opts, entityId: parent.entityId });\n });\ntaxCmd\n .command(\"deadline\")\n .requiredOption(\"--type <type>\", \"Deadline type\")\n .requiredOption(\"--due-date <date>\", \"Due date (ISO 8601)\")\n .requiredOption(\"--description <desc>\", \"Description\")\n .option(\"--recurrence <recurrence>\", \"Recurrence (e.g. annual; 'yearly' is normalized)\")\n .description(\"Track a compliance deadline\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { taxDeadlineCommand } = await import(\"./commands/tax.js\");\n await taxDeadlineCommand({ ...opts, entityId: parent.entityId });\n });\n\n// --- agents ---\nconst agentsCmd = program\n .command(\"agents\")\n .description(\"Agent management\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (opts) => {\n const { agentsListCommand } = await import(\"./commands/agents.js\");\n await agentsListCommand(opts);\n });\nagentsCmd.command(\"show <agent-id>\").option(\"--json\", \"Output as JSON\").description(\"Show agent detail\")\n .action(async (agentId: string, opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { agentsShowCommand } = await import(\"./commands/agents.js\");\n await agentsShowCommand(agentId, {\n ...opts,\n json: inheritOption(opts.json, parent.json),\n });\n });\nagentsCmd.command(\"create\").requiredOption(\"--name <name>\", \"Agent name\")\n .requiredOption(\"--prompt <prompt>\", \"System prompt\").option(\"--model <model>\", \"Model\")\n .description(\"Create a new agent\")\n .action(async (opts) => {\n const { agentsCreateCommand } = await import(\"./commands/agents.js\");\n await agentsCreateCommand(opts);\n });\nagentsCmd.command(\"pause <agent-id>\").description(\"Pause an agent\")\n .action(async (agentId: string) => {\n const { agentsPauseCommand } = await import(\"./commands/agents.js\");\n await agentsPauseCommand(agentId);\n });\nagentsCmd.command(\"resume <agent-id>\").description(\"Resume a paused agent\")\n .action(async (agentId: string) => {\n const { agentsResumeCommand } = await import(\"./commands/agents.js\");\n await agentsResumeCommand(agentId);\n });\nagentsCmd.command(\"delete <agent-id>\").description(\"Delete an agent\")\n .action(async (agentId: string) => {\n const { agentsDeleteCommand } = await import(\"./commands/agents.js\");\n await agentsDeleteCommand(agentId);\n });\nagentsCmd.command(\"message <agent-id>\").requiredOption(\"--body <text>\", \"Message text\")\n .description(\"Send a message to an agent\")\n .action(async (agentId: string, opts) => {\n const { agentsMessageCommand } = await import(\"./commands/agents.js\");\n await agentsMessageCommand(agentId, opts);\n });\nagentsCmd.command(\"skill <agent-id>\").requiredOption(\"--name <name>\", \"Skill name\")\n .requiredOption(\"--description <desc>\", \"Skill description\").option(\"--instructions <text>\", \"Instructions\")\n .description(\"Add a skill to an agent\")\n .action(async (agentId: string, opts) => {\n const { agentsSkillCommand } = await import(\"./commands/agents.js\");\n await agentsSkillCommand(agentId, opts);\n });\n\n// --- work-items ---\nconst workItemsCmd = program\n .command(\"work-items\")\n .description(\"Long-term work item coordination\")\n .option(\"--entity-id <id>\", \"Entity ID (overrides active entity)\")\n .option(\"--json\", \"Output as JSON\")\n .option(\"--status <status>\", \"Filter by status (open, claimed, completed, cancelled)\")\n .option(\"--category <category>\", \"Filter by category\")\n .action(async (opts) => {\n const { workItemsListCommand } = await import(\"./commands/work-items.js\");\n await workItemsListCommand(opts);\n });\nworkItemsCmd\n .command(\"show <item-id>\")\n .option(\"--json\", \"Output as JSON\")\n .description(\"Show work item detail\")\n .action(async (itemId: string, opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { workItemsShowCommand } = await import(\"./commands/work-items.js\");\n await workItemsShowCommand(itemId, {\n ...opts,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\nworkItemsCmd\n .command(\"create\")\n .requiredOption(\"--title <title>\", \"Work item title\")\n .option(\"--category <category>\", \"Work item category\")\n .option(\"--description <desc>\", \"Description\")\n .option(\"--deadline <date>\", \"Deadline (YYYY-MM-DD)\")\n .option(\"--asap\", \"Mark as ASAP priority\")\n .option(\"--created-by <name>\", \"Creator identifier\")\n .description(\"Create a new work item\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { workItemsCreateCommand } = await import(\"./commands/work-items.js\");\n await workItemsCreateCommand({\n ...opts,\n category: inheritOption(opts.category, parent.category),\n entityId: parent.entityId,\n });\n });\nworkItemsCmd\n .command(\"claim <item-id>\")\n .requiredOption(\"--by <name>\", \"Agent or user claiming the item\")\n .option(\"--ttl <seconds>\", \"Auto-release TTL in seconds\", parseInt)\n .description(\"Claim a work item\")\n .action(async (itemId: string, opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { workItemsClaimCommand } = await import(\"./commands/work-items.js\");\n await workItemsClaimCommand(itemId, { claimedBy: opts.by, ttl: opts.ttl, entityId: parent.entityId });\n });\nworkItemsCmd\n .command(\"complete <item-id>\")\n .requiredOption(\"--by <name>\", \"Agent or user completing the item\")\n .option(\"--result <text>\", \"Completion result or notes\")\n .description(\"Mark a work item as completed\")\n .action(async (itemId: string, opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { workItemsCompleteCommand } = await import(\"./commands/work-items.js\");\n await workItemsCompleteCommand(itemId, { completedBy: opts.by, result: opts.result, entityId: parent.entityId });\n });\nworkItemsCmd\n .command(\"release <item-id>\")\n .description(\"Release a claimed work item\")\n .action(async (itemId: string, _opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { workItemsReleaseCommand } = await import(\"./commands/work-items.js\");\n await workItemsReleaseCommand(itemId, { entityId: parent.entityId });\n });\nworkItemsCmd\n .command(\"cancel <item-id>\")\n .description(\"Cancel a work item\")\n .action(async (itemId: string, _opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { workItemsCancelCommand } = await import(\"./commands/work-items.js\");\n await workItemsCancelCommand(itemId, { entityId: parent.entityId });\n });\n\n// --- billing ---\nconst billingCmd = program\n .command(\"billing\")\n .description(\"Billing status, plans, and subscription management\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (opts) => {\n const { billingCommand } = await import(\"./commands/billing.js\");\n await billingCommand(opts);\n });\nbillingCmd.command(\"portal\").description(\"Open Stripe Customer Portal\")\n .action(async () => {\n const { billingPortalCommand } = await import(\"./commands/billing.js\");\n await billingPortalCommand();\n });\nbillingCmd.command(\"upgrade\").option(\"--plan <plan>\", \"Plan ID to upgrade to (free, pro, enterprise)\", \"pro\")\n .description(\"Open Stripe Checkout to upgrade your plan\")\n .action(async (opts) => {\n const { billingUpgradeCommand } = await import(\"./commands/billing.js\");\n await billingUpgradeCommand(opts);\n });\n\n// --- approvals ---\n// The approval system is integrated into governance meetings (vote on agenda items)\n// and execution intents. There is no standalone /v1/approvals endpoint.\nprogram\n .command(\"approvals\")\n .description(\"Approvals are managed through governance meetings and execution intents\")\n .action(async () => {\n const { printError } = await import(\"./output.js\");\n printError(\n \"Approvals are managed through governance meetings.\\n\" +\n \" Use: corp governance convene ... to schedule a board meeting\\n\" +\n \" Use: corp governance vote <meeting-id> <item-id> ... to cast votes\"\n );\n });\n\n// --- form ---\nconst formCmd = program\n .command(\"form\")\n .description(\"Form a new entity with founders and cap table\")\n .option(\"--entity-type <type>\", \"Entity type (llc, c_corp)\")\n .option(\"--legal-name <name>\", \"Legal name\")\n .option(\"--jurisdiction <jurisdiction>\", \"Jurisdiction (e.g. US-DE, US-WY)\")\n .option(\"--member <member>\", \"Member as 'name,email,role[,pct]' — role: director|officer|manager|member|chair (repeatable)\", (v: string, a: string[]) => [...a, v], [] as string[])\n .option(\"--address <address>\", \"Company address as 'street,city,state,zip'\")\n .option(\"--fiscal-year-end <date>\", \"Fiscal year end (MM-DD)\", \"12-31\")\n .option(\"--s-corp\", \"Elect S-Corp status\")\n .option(\"--transfer-restrictions\", \"Enable transfer restrictions\")\n .option(\"--rofr\", \"Enable right of first refusal\")\n .action(async (opts) => {\n // Map --entity-type and --legal-name to the internal keys expected by formCommand\n if (opts.entityType && !opts.type) opts.type = opts.entityType;\n if (opts.legalName && !opts.name) opts.name = opts.legalName;\n const { formCommand } = await import(\"./commands/form.js\");\n await formCommand(opts);\n });\nformCmd.command(\"create\")\n .description(\"Create a pending entity (staged flow step 1)\")\n .requiredOption(\"--type <type>\", \"Entity type (llc, c_corp)\")\n .requiredOption(\"--name <name>\", \"Legal name\")\n .option(\"--jurisdiction <jurisdiction>\", \"Jurisdiction (e.g. US-DE, US-WY)\")\n .option(\"--registered-agent-name <name>\", \"Registered agent legal name\")\n .option(\"--registered-agent-address <address>\", \"Registered agent address line\")\n .option(\"--formation-date <date>\", \"Formation date (RFC3339 or YYYY-MM-DD)\")\n .option(\"--fiscal-year-end <date>\", \"Fiscal year end (MM-DD)\")\n .option(\"--s-corp\", \"Elect S-Corp status\")\n .option(\"--transfer-restrictions\", \"Enable transfer restrictions\")\n .option(\"--rofr\", \"Enable right of first refusal\")\n .option(\"--company-address <address>\", \"Company address as 'street,city,state,zip'\")\n .action(async (opts) => {\n const { formCreateCommand } = await import(\"./commands/form.js\");\n await formCreateCommand(opts);\n });\nformCmd.command(\"add-founder <entity-id>\")\n .description(\"Add a founder to a pending entity (staged flow step 2)\")\n .requiredOption(\"--name <name>\", \"Founder name\")\n .requiredOption(\"--email <email>\", \"Founder email\")\n .requiredOption(\"--role <role>\", \"Role: director|officer|manager|member|chair\")\n .requiredOption(\"--pct <pct>\", \"Ownership percentage\")\n .option(\"--officer-title <title>\", \"Officer title (corporations only)\")\n .option(\"--incorporator\", \"Mark as sole incorporator (corporations only)\")\n .option(\"--address <address>\", \"Founder address as 'street,city,state,zip'\")\n .action(async (entityId: string, opts) => {\n const { formAddFounderCommand } = await import(\"./commands/form.js\");\n await formAddFounderCommand(entityId, opts);\n });\nformCmd.command(\"finalize <entity-id>\")\n .description(\"Finalize formation and generate documents + cap table (staged flow step 3)\")\n .option(\"--authorized-shares <count>\", \"Authorized shares for corporations\")\n .option(\"--par-value <value>\", \"Par value per share, e.g. 0.0001\")\n .option(\"--registered-agent-name <name>\", \"Registered agent legal name\")\n .option(\"--registered-agent-address <address>\", \"Registered agent address line\")\n .option(\"--formation-date <date>\", \"Formation date (RFC3339 or YYYY-MM-DD)\")\n .option(\"--fiscal-year-end <date>\", \"Fiscal year end (MM-DD)\")\n .option(\"--s-corp\", \"Elect S-Corp status\")\n .option(\"--transfer-restrictions\", \"Enable transfer restrictions\")\n .option(\"--rofr\", \"Enable right of first refusal\")\n .option(\"--company-address <address>\", \"Company address as 'street,city,state,zip'\")\n .action(async (entityId: string, opts) => {\n const { formFinalizeCommand } = await import(\"./commands/form.js\");\n await formFinalizeCommand(entityId, opts);\n });\n\n// --- api-keys ---\nprogram\n .command(\"api-keys\")\n .description(\"List API keys\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (opts) => {\n const { apiKeysCommand } = await import(\"./commands/api-keys.js\");\n await apiKeysCommand(opts);\n });\n\n// --- demo ---\nprogram\n .command(\"demo\")\n .description(\"Seed a fully-populated demo corporation\")\n .requiredOption(\"--name <name>\", \"Corporation name\")\n .action(async (opts) => {\n const { demoCommand } = await import(\"./commands/demo.js\");\n await demoCommand(opts);\n });\n\n// --- serve ---\nprogram\n .command(\"serve\")\n .description(\"Start the API server locally\")\n .option(\"--port <port>\", \"Port to listen on\", \"8000\")\n .option(\"--data-dir <path>\", \"Data directory\", \"./data/repos\")\n .action(async (opts) => {\n const { serveCommand } = await import(\"./commands/serve.js\");\n await serveCommand(opts);\n });\n\nprogram.parse();\n","export function inheritOption<T>(localValue: T | undefined, parentValue: T | undefined): T | undefined {\n return localValue ?? parentValue;\n}\n"],"mappings":";;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,cAAc,eAAe,WAAsB,kBAAkB;AAC9E,SAAS,YAAY;AACrB,SAAS,eAAe;AAoBxB,SAAS,UAAU,MAA+B,UAAyC;AACzF,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,QAAQ,GAAG;AACnD,QACE,OAAO,QACP,OAAO,KAAK,GAAG,MAAM,YACrB,KAAK,GAAG,MAAM,QACd,CAAC,MAAM,QAAQ,KAAK,GAAG,CAAC,KACxB,OAAO,UAAU,YACjB,UAAU,QACV,CAAC,MAAM,QAAQ,KAAK,GACpB;AACA,gBAAU,KAAK,GAAG,GAA8B,KAAgC;AAAA,IAClF,OAAO;AACL,WAAK,GAAG,IAAI;AAAA,IACd;AAAA,EACF;AACF;AAEO,SAAS,aAAyB;AACvC,QA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AAI,MAAM;AACxC,QAAMA,uBAAsB,UAAU,IAAI;AAC5C,CAAC;AACH,QAAQ,QAAQ,sBAAsB,EACnC,YAAY,4EAA4E,EACxF,OAAO,+BAA+B,oCAAoC,EAC1E,OAAO,uBAAuB,kCAAkC,EAChE,OAAO,kCAAkC,6BAA6B,EACtE,OAAO,wCAAwC,+BAA+B,EAC9E,OAAO,2BAA2B,wCAAwC,EAC1E,OAAO,4BAA4B,yBAAyB,EAC5D,OAAO,YAAY,qBAAqB,EACxC,OAAO,2BAA2B,8BAA8B,EAChE,OAAO,UAAU,+BAA+B,EAChD,OAAO,+BAA+B,4CAA4C,EAClF,OAAO,OAAO,UAAkB,SAAS;AACxC,QAAM,EAAE,qBAAAC,qBAAoB,IAAI,MAAM;AACtC,QAAMA,qBAAoB,UAAU,IAAI;AAC1C,CAAC;AAGH,QACG,QAAQ,UAAU,EAClB,YAAY,eAAe,EAC3B,OAAO,UAAU,gBAAgB,EACjC,OAAO,OAAO,SAAS;AACtB,QAAM,EAAE,gBAAAC,gBAAe,IAAI,MAAM;AACjC,QAAMA,gBAAe,IAAI;AAC3B,CAAC;AAGH,QACG,QAAQ,MAAM,EACd,YAAY,yCAAyC,EACrD,eAAe,iBAAiB,kBAAkB,EAClD,OAAO,OAAO,SAAS;AACtB,QAAM,EAAE,aAAAC,aAAY,IAAI,MAAM;AAC9B,QAAMA,aAAY,IAAI;AACxB,CAAC;AAGH,QACG,QAAQ,OAAO,EACf,YAAY,8BAA8B,EAC1C,OAAO,iBAAiB,qBAAqB,MAAM,EACnD,OAAO,qBAAqB,kBAAkB,cAAc,EAC5D,OAAO,OAAO,SAAS;AACtB,QAAM,EAAE,cAAAC,cAAa,IAAI,MAAM;AAC/B,QAAMA,cAAa,IAAI;AACzB,CAAC;AAEH,QAAQ,MAAM;","names":["s","config_exports","init_config","join","homedir","chalk","resolve","chalk","chalk","chalk","chalk","Table","chalk","s","chalk","input","confirm","chalk","Table","chalk","Table","readFileSync","writeFileSync","existsSync","loadConfig","saveConfig","require","setupCommand","statusCommand","configSetCommand","configGetCommand","configListCommand","obligationsCommand","digestCommand","linkCommand","claimCommand","chatCommand","entitiesCommand","entitiesShowCommand","entitiesConvertCommand","entitiesDissolveCommand","contactsListCommand","contactsShowCommand","contactsAddCommand","contactsEditCommand","capTableCommand","safesCommand","transfersCommand","valuationsCommand","fourOhNineACommand","issueEquityCommand","issueSafeCommand","transferSharesCommand","distributeCommand","startRoundCommand","addSecurityCommand","issueRoundCommand","createValuationCommand","submitValuationCommand","approveValuationCommand","financeInvoiceCommand","financePayrollCommand","financePayCommand","financeOpenAccountCommand","financeClassifyContractorCommand","financeReconcileCommand","governanceListCommand","governanceCreateBodyCommand","governanceAddSeatCommand","governanceSeatsCommand","governanceMeetingsCommand","governanceResolutionsCommand","governanceConveneCommand","governanceVoteCommand","sendNoticeCommand","adjournMeetingCommand","cancelMeetingCommand","listAgendaItemsCommand","finalizeAgendaItemCommand","computeResolutionCommand","writtenConsentCommand","documentsListCommand","documentsSigningLinkCommand","documentsGenerateCommand","documentsPreviewPdfCommand","taxFileCommand","taxDeadlineCommand","agentsListCommand","agentsShowCommand","agentsCreateCommand","agentsPauseCommand","agentsResumeCommand","agentsDeleteCommand","agentsMessageCommand","agentsSkillCommand","workItemsListCommand","workItemsShowCommand","workItemsCreateCommand","workItemsClaimCommand","workItemsCompleteCommand","workItemsReleaseCommand","workItemsCancelCommand","billingCommand","billingPortalCommand","billingUpgradeCommand","printError","formCommand","formCreateCommand","formAddFounderCommand","formFinalizeCommand","apiKeysCommand","demoCommand","serveCommand"]}
|
|
1
|
+
{"version":3,"sources":["../src/config.ts","../src/api-client.ts","../src/output.ts","../src/commands/setup.ts","../src/animation.ts","../src/spinner.ts","../src/commands/status.ts","../src/commands/context.ts","../src/commands/schema.ts","../src/commands/config.ts","../src/commands/obligations.ts","../src/commands/digest.ts","../src/commands/link.ts","../src/commands/claim.ts","../src/llm.ts","../src/tools.ts","../src/chat.ts","../src/commands/entities.ts","../src/commands/contacts.ts","../src/commands/cap-table.ts","../src/commands/finance.ts","../src/commands/governance.ts","../src/commands/documents.ts","../src/commands/tax.ts","../src/commands/agents.ts","../src/commands/work-items.ts","../src/commands/billing.ts","../src/commands/form.ts","../src/commands/api-keys.ts","../src/commands/demo.ts","../src/commands/feedback.ts","../src/commands/serve.ts","../src/index.ts","../src/command-options.ts"],"sourcesContent":["import {\n chmodSync,\n existsSync,\n mkdirSync,\n readFileSync,\n renameSync,\n rmSync,\n writeFileSync,\n} from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport type { CorpConfig } from \"./types.js\";\n\nconst CONFIG_DIR = process.env.CORP_CONFIG_DIR || join(homedir(), \".corp\");\nconst CONFIG_FILE = join(CONFIG_DIR, \"config.json\");\nconst CONFIG_LOCK_DIR = join(CONFIG_DIR, \"config.lock\");\nconst CONFIG_LOCK_TIMEOUT_MS = 5000;\nconst CONFIG_LOCK_RETRY_MS = 25;\n\nconst CONFIG_WAIT_BUFFER = new SharedArrayBuffer(4);\nconst CONFIG_WAIT_SIGNAL = new Int32Array(CONFIG_WAIT_BUFFER);\n\nconst ALLOWED_CONFIG_KEYS = new Set([\n \"api_url\",\n \"api_key\",\n \"workspace_id\",\n \"hosting_mode\",\n \"llm.provider\",\n \"llm.api_key\",\n \"llm.model\",\n \"llm.base_url\",\n \"user.name\",\n \"user.email\",\n \"active_entity_id\",\n]);\n\nconst SENSITIVE_CONFIG_KEYS = new Set([\"api_url\", \"api_key\", \"workspace_id\"]);\n\nconst DEFAULTS: CorpConfig = {\n api_url: process.env.CORP_API_URL || \"https://api.thecorporation.ai\",\n api_key: process.env.CORP_API_KEY || \"\",\n workspace_id: process.env.CORP_WORKSPACE_ID || \"\",\n hosting_mode: \"\",\n llm: {\n provider: \"anthropic\",\n api_key: process.env.CORP_LLM_API_KEY || \"\",\n model: \"claude-sonnet-4-6\",\n base_url: process.env.CORP_LLM_BASE_URL || undefined,\n },\n user: { name: \"\", email: \"\" },\n active_entity_id: \"\",\n};\n\nfunction sleepSync(ms: number): void {\n Atomics.wait(CONFIG_WAIT_SIGNAL, 0, 0, ms);\n}\n\nfunction withConfigLock<T>(fn: () => T): T {\n mkdirSync(CONFIG_DIR, { recursive: true, mode: 0o700 });\n const startedAt = Date.now();\n while (true) {\n try {\n mkdirSync(CONFIG_LOCK_DIR, { mode: 0o700 });\n break;\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code !== \"EEXIST\") {\n throw err;\n }\n if (Date.now() - startedAt >= CONFIG_LOCK_TIMEOUT_MS) {\n throw new Error(\"timed out waiting for the corp config lock\");\n }\n sleepSync(CONFIG_LOCK_RETRY_MS);\n }\n }\n\n try {\n return fn();\n } finally {\n rmSync(CONFIG_LOCK_DIR, { recursive: true, force: true });\n }\n}\n\nfunction ensureSecurePermissions(): void {\n mkdirSync(CONFIG_DIR, { recursive: true, mode: 0o700 });\n try {\n chmodSync(CONFIG_DIR, 0o700);\n } catch {\n // Ignore chmod failures on filesystems without POSIX permission support.\n }\n if (existsSync(CONFIG_FILE)) {\n try {\n chmodSync(CONFIG_FILE, 0o600);\n } catch {\n // Ignore chmod failures on filesystems without POSIX permission support.\n }\n }\n}\n\nfunction isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction isLoopbackHost(hostname: string): boolean {\n return hostname === \"localhost\" || hostname === \"127.0.0.1\" || hostname === \"::1\";\n}\n\nfunction validateApiUrl(value: string): string {\n let parsed: URL;\n try {\n parsed = new URL(value.trim());\n } catch {\n throw new Error(\"api_url must be a valid absolute URL\");\n }\n\n if (parsed.username || parsed.password) {\n throw new Error(\"api_url must not include embedded credentials\");\n }\n\n const protocol = parsed.protocol.toLowerCase();\n const hostname = parsed.hostname.toLowerCase();\n if (protocol !== \"https:\" && !(protocol === \"http:\" && isLoopbackHost(hostname))) {\n throw new Error(\"api_url must use https, or http only for localhost/loopback development\");\n }\n\n parsed.hash = \"\";\n return parsed.toString().replace(/\\/+$/, \"\");\n}\n\nfunction normalizeString(value: unknown): string | undefined {\n return typeof value === \"string\" ? value : undefined;\n}\n\nfunction normalizeActiveEntityMap(value: unknown): Record<string, string> | undefined {\n if (!isObject(value)) {\n return undefined;\n }\n const entries = Object.entries(value).filter(\n ([workspaceId, entityId]) =>\n typeof workspaceId === \"string\" && typeof entityId === \"string\" && entityId.length > 0,\n );\n if (entries.length === 0) {\n return undefined;\n }\n return Object.fromEntries(entries);\n}\n\nfunction normalizeConfig(raw: unknown): CorpConfig {\n const cfg = structuredClone(DEFAULTS) as CorpConfig;\n if (!isObject(raw)) {\n return cfg;\n }\n\n const savedApiUrl = normalizeString(raw.api_url);\n if (savedApiUrl) {\n try {\n cfg.api_url = validateApiUrl(savedApiUrl);\n } catch {\n cfg.api_url = DEFAULTS.api_url;\n }\n }\n cfg.api_key = normalizeString(raw.api_key) ?? cfg.api_key;\n cfg.workspace_id = normalizeString(raw.workspace_id) ?? cfg.workspace_id;\n cfg.hosting_mode = normalizeString(raw.hosting_mode) ?? cfg.hosting_mode;\n cfg.active_entity_id = normalizeString(raw.active_entity_id) ?? cfg.active_entity_id;\n\n if (isObject(raw.llm)) {\n cfg.llm.provider = normalizeString(raw.llm.provider) ?? cfg.llm.provider;\n cfg.llm.api_key = normalizeString(raw.llm.api_key) ?? cfg.llm.api_key;\n cfg.llm.model = normalizeString(raw.llm.model) ?? cfg.llm.model;\n const baseUrl = normalizeString(raw.llm.base_url);\n if (baseUrl && baseUrl.trim()) {\n cfg.llm.base_url = baseUrl.trim();\n }\n }\n\n if (isObject(raw.user)) {\n cfg.user.name = normalizeString(raw.user.name) ?? cfg.user.name;\n cfg.user.email = normalizeString(raw.user.email) ?? cfg.user.email;\n }\n\n const activeEntityIds = normalizeActiveEntityMap(raw.active_entity_ids);\n if (activeEntityIds) {\n cfg.active_entity_ids = activeEntityIds;\n }\n if (cfg.workspace_id && cfg.active_entity_id) {\n cfg.active_entity_ids = {\n ...(cfg.active_entity_ids ?? {}),\n [cfg.workspace_id]: cfg.active_entity_id,\n };\n }\n\n return cfg;\n}\n\nfunction serializeConfig(cfg: CorpConfig): string {\n const normalized = normalizeConfig(cfg);\n const serialized: Record<string, unknown> = {\n api_url: normalized.api_url,\n api_key: normalized.api_key,\n workspace_id: normalized.workspace_id,\n hosting_mode: normalized.hosting_mode,\n llm: {\n provider: normalized.llm.provider,\n api_key: normalized.llm.api_key,\n model: normalized.llm.model,\n ...(normalized.llm.base_url ? { base_url: normalized.llm.base_url } : {}),\n },\n user: {\n name: normalized.user.name,\n email: normalized.user.email,\n },\n active_entity_id: normalized.active_entity_id,\n };\n if (normalized.active_entity_ids && Object.keys(normalized.active_entity_ids).length > 0) {\n serialized.active_entity_ids = normalized.active_entity_ids;\n }\n return JSON.stringify(serialized, null, 2) + \"\\n\";\n}\n\nfunction requireSupportedConfigKey(dotPath: string): void {\n if (!ALLOWED_CONFIG_KEYS.has(dotPath)) {\n throw new Error(`unsupported config key: ${dotPath}`);\n }\n}\n\nfunction validateSensitiveConfigUpdate(dotPath: string, forceSensitive = false): void {\n if (SENSITIVE_CONFIG_KEYS.has(dotPath) && !forceSensitive) {\n throw new Error(`refusing to update security-sensitive key '${dotPath}' without --force`);\n }\n}\n\nfunction setKnownConfigValue(cfg: CorpConfig, dotPath: string, value: string): void {\n switch (dotPath) {\n case \"api_url\":\n cfg.api_url = validateApiUrl(value);\n return;\n case \"api_key\":\n cfg.api_key = value.trim();\n return;\n case \"workspace_id\":\n cfg.workspace_id = value.trim();\n return;\n case \"hosting_mode\":\n cfg.hosting_mode = value.trim();\n return;\n case \"llm.provider\":\n cfg.llm.provider = value.trim();\n return;\n case \"llm.api_key\":\n cfg.llm.api_key = value.trim();\n return;\n case \"llm.model\":\n cfg.llm.model = value.trim();\n return;\n case \"llm.base_url\":\n cfg.llm.base_url = value.trim() || undefined;\n return;\n case \"user.name\":\n cfg.user.name = value.trim();\n return;\n case \"user.email\":\n cfg.user.email = value.trim();\n return;\n case \"active_entity_id\":\n setActiveEntityId(cfg, value.trim());\n return;\n default:\n throw new Error(`unsupported config key: ${dotPath}`);\n }\n}\n\nfunction readConfigUnlocked(): CorpConfig {\n ensureSecurePermissions();\n if (!existsSync(CONFIG_FILE)) {\n return normalizeConfig(DEFAULTS);\n }\n return normalizeConfig(JSON.parse(readFileSync(CONFIG_FILE, \"utf-8\")) as unknown);\n}\n\nexport function loadConfig(): CorpConfig {\n return readConfigUnlocked();\n}\n\nexport function saveConfig(cfg: CorpConfig): void {\n withConfigLock(() => {\n ensureSecurePermissions();\n const tempFile = `${CONFIG_FILE}.${process.pid}.tmp`;\n writeFileSync(tempFile, serializeConfig(cfg), { mode: 0o600 });\n renameSync(tempFile, CONFIG_FILE);\n ensureSecurePermissions();\n });\n}\n\nexport function updateConfig(mutator: (cfg: CorpConfig) => void): CorpConfig {\n return withConfigLock(() => {\n const cfg = readConfigUnlocked();\n mutator(cfg);\n const tempFile = `${CONFIG_FILE}.${process.pid}.tmp`;\n writeFileSync(tempFile, serializeConfig(cfg), { mode: 0o600 });\n renameSync(tempFile, CONFIG_FILE);\n ensureSecurePermissions();\n return cfg;\n });\n}\n\nexport function getValue(cfg: Record<string, unknown>, dotPath: string): unknown {\n const keys = dotPath.split(\".\");\n let current: unknown = cfg;\n for (const key of keys) {\n if (typeof current === \"object\" && current !== null && key in current) {\n current = (current as Record<string, unknown>)[key];\n } else {\n return undefined;\n }\n }\n return current;\n}\n\nexport function setValue(\n cfg: Record<string, unknown>,\n dotPath: string,\n value: string,\n options: { forceSensitive?: boolean } = {},\n): void {\n requireSupportedConfigKey(dotPath);\n validateSensitiveConfigUpdate(dotPath, options.forceSensitive);\n setKnownConfigValue(cfg as CorpConfig, dotPath, value);\n}\n\nexport function requireConfig(...fields: string[]): CorpConfig {\n const cfg = loadConfig();\n const missing = fields.filter((f) => !getValue(cfg as unknown as Record<string, unknown>, f));\n if (missing.length > 0) {\n console.error(`Missing config: ${missing.join(\", \")}`);\n console.error(\"Run 'corp setup' to configure.\");\n process.exit(1);\n }\n return cfg;\n}\n\nexport function maskKey(value: string): string {\n if (!value || value.length < 8) return \"***\";\n return \"***\" + value.slice(-4);\n}\n\nexport function configForDisplay(cfg: CorpConfig): Record<string, unknown> {\n const display = { ...cfg } as Record<string, unknown>;\n if (display.api_key) display.api_key = maskKey(display.api_key as string);\n if (typeof display.llm === \"object\" && display.llm !== null) {\n const llm = { ...(display.llm as Record<string, unknown>) };\n if (llm.api_key) llm.api_key = maskKey(llm.api_key as string);\n display.llm = llm;\n }\n return display;\n}\n\nexport function getActiveEntityId(cfg: CorpConfig): string {\n if (cfg.workspace_id && cfg.active_entity_ids?.[cfg.workspace_id]) {\n return cfg.active_entity_ids[cfg.workspace_id];\n }\n return cfg.active_entity_id;\n}\n\nexport function setActiveEntityId(cfg: CorpConfig, entityId: string): void {\n cfg.active_entity_id = entityId;\n if (!cfg.workspace_id) {\n return;\n }\n cfg.active_entity_ids = {\n ...(cfg.active_entity_ids ?? {}),\n [cfg.workspace_id]: entityId,\n };\n}\n\nexport function resolveEntityId(cfg: CorpConfig, explicitId?: string): string {\n const eid = explicitId || getActiveEntityId(cfg);\n if (!eid) {\n console.error(\n \"No entity specified. Use --entity-id or set active_entity_id via 'corp config set active_entity_id <id>'.\"\n );\n process.exit(1);\n }\n return eid;\n}\n","export { CorpAPIClient, SessionExpiredError, provisionWorkspace } from \"@thecorporation/corp-tools\";\n","import chalk from \"chalk\";\nimport Table from \"cli-table3\";\nimport type { ApiRecord } from \"./types.js\";\n\nconst URGENCY_COLORS: Record<string, (s: string) => string> = {\n overdue: chalk.red.bold,\n due_today: chalk.yellow.bold,\n d1: chalk.yellow,\n d7: chalk.cyan,\n d14: chalk.blue,\n d30: chalk.dim,\n upcoming: chalk.dim,\n};\n\nexport function printError(msg: string): void {\n console.error(chalk.red(\"Error:\"), msg);\n}\n\nexport function printSuccess(msg: string): void {\n console.log(chalk.green(msg));\n}\n\nexport function printWarning(msg: string): void {\n console.log(chalk.yellow(msg));\n}\n\nexport function printJson(data: unknown): void {\n console.log(JSON.stringify(data, null, 2));\n}\n\nexport function printDryRun(operation: string, payload: unknown): void {\n printJson({\n dry_run: true,\n operation,\n payload,\n });\n}\n\nexport function printWriteResult(\n result: unknown,\n successMessage: string,\n jsonOnly?: boolean,\n): void {\n if (jsonOnly) {\n printJson(result);\n return;\n }\n printSuccess(successMessage);\n printJson(result);\n}\n\n// --- Status Panel ---\n\nexport function printStatusPanel(data: ApiRecord): void {\n console.log(chalk.blue(\"─\".repeat(50)));\n console.log(chalk.blue.bold(\" Corp Status\"));\n console.log(chalk.blue(\"─\".repeat(50)));\n console.log(` ${chalk.bold(\"Workspace:\")} ${data.workspace_id ?? \"N/A\"}`);\n console.log(` ${chalk.bold(\"Entities:\")} ${data.entity_count ?? 0}`);\n\n const urgency = (data.urgency_counts ?? {}) as Record<string, number>;\n if (Object.keys(urgency).length > 0) {\n console.log(`\\n ${chalk.bold(\"Obligations:\")}`);\n for (const [tier, count] of Object.entries(urgency)) {\n const colorFn = URGENCY_COLORS[tier] ?? ((s: string) => s);\n console.log(` ${colorFn(`${tier}:`)} ${count}`);\n }\n }\n\n if (data.next_deadline) {\n console.log(`\\n ${chalk.bold(\"Next deadline:\")} ${data.next_deadline}`);\n }\n console.log(chalk.blue(\"─\".repeat(50)));\n}\n\n// --- Generic table helper ---\n\nfunction makeTable(title: string, columns: string[]): Table.Table {\n console.log(`\\n${chalk.bold(title)}`);\n return new Table({ head: columns.map((c) => chalk.dim(c)) });\n}\n\nfunction s(val: unknown, maxLen?: number): string {\n const str = val == null ? \"\" : String(val);\n if (maxLen && str.length > maxLen) return str.slice(0, maxLen);\n return str;\n}\n\nfunction money(val: unknown, cents = true): string {\n if (typeof val === \"number\") {\n const dollars = cents ? val / 100 : val;\n return `$${dollars.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;\n }\n return String(val ?? \"\");\n}\n\nfunction date(val: unknown): string {\n const str = s(val);\n if (!str) return \"\";\n const parsed = new Date(str);\n return Number.isNaN(parsed.getTime()) ? str : parsed.toISOString().slice(0, 10);\n}\n\n// --- Domain tables ---\n\nexport function printEntitiesTable(entities: ApiRecord[]): void {\n const table = makeTable(\"Entities\", [\"ID\", \"Name\", \"Type\", \"Jurisdiction\", \"Status\"]);\n for (const e of entities) {\n table.push([s(e.entity_id, 12), s(e.legal_name ?? e.name), s(e.entity_type), s(e.jurisdiction), s(e.formation_status ?? e.status)]);\n }\n console.log(table.toString());\n}\n\nexport function printObligationsTable(obligations: ApiRecord[]): void {\n const table = makeTable(\"Obligations\", [\"ID\", \"Type\", \"Urgency\", \"Due\", \"Status\"]);\n for (const o of obligations) {\n const urg = s(o.urgency) || \"upcoming\";\n const colorFn = URGENCY_COLORS[urg] ?? ((x: string) => x);\n table.push([s(o.obligation_id, 12), s(o.obligation_type), colorFn(urg), s(o.due_at), s(o.status)]);\n }\n console.log(table.toString());\n}\n\nexport function printContactsTable(contacts: ApiRecord[]): void {\n const table = makeTable(\"Contacts\", [\"ID\", \"Name\", \"Email\", \"Category\", \"Entity\"]);\n for (const c of contacts) {\n table.push([\n s(c.contact_id ?? c.id, 12),\n s(c.name),\n s(c.email),\n s(c.category),\n s(c.entity_name ?? c.entity_id),\n ]);\n }\n console.log(table.toString());\n}\n\nexport function printCapTable(data: ApiRecord): void {\n const accessLevel = s(data.access_level) || \"admin\";\n const instruments = (data.instruments ?? []) as ApiRecord[];\n if (instruments.length > 0) {\n const table = makeTable(\"Cap Table — Instruments\", [\"Symbol\", \"Kind\", \"Authorized\", \"Issued\", \"Diluted\"]);\n for (const instrument of instruments) {\n table.push([\n s(instrument.symbol),\n s(instrument.kind),\n s(instrument.authorized_units ?? \"unlimited\"),\n s(instrument.issued_units),\n s(instrument.diluted_units),\n ]);\n }\n console.log(table.toString());\n }\n\n const holders = (data.holders ?? []) as ApiRecord[];\n if (holders.length > 0 && accessLevel !== \"summary\") {\n const table = makeTable(\n \"Ownership Breakdown\",\n [\"Holder\", \"Outstanding\", \"As Converted\", \"Fully Diluted\", \"Fully Diluted %\"],\n );\n for (const holder of holders) {\n const dilutedBps = typeof holder.fully_diluted_bps === \"number\"\n ? `${(holder.fully_diluted_bps / 100).toFixed(2)}%`\n : \"\";\n table.push([\n s(holder.name),\n s(holder.outstanding_units),\n s(holder.as_converted_units),\n s(holder.fully_diluted_units),\n dilutedBps,\n ]);\n }\n console.log(table.toString());\n }\n\n const shareClasses = (data.share_classes ?? []) as ApiRecord[];\n if (shareClasses.length > 0) {\n const cols = [\"Class\", \"Authorized\", \"Outstanding\"];\n if (accessLevel !== \"summary\") cols.push(\"Holders\");\n const table = makeTable(\"Cap Table — Share Classes\", cols);\n for (const sc of shareClasses) {\n const row = [s(sc.class_code ?? sc.name), s(sc.authorized), s(sc.outstanding)];\n if (accessLevel !== \"summary\") {\n const holders = (sc.holders ?? []) as ApiRecord[];\n row.push(holders.map((h) => `${h.name ?? \"?\"}(${h.percentage ?? \"?\"}%)`).join(\", \"));\n }\n table.push(row);\n }\n console.log(table.toString());\n }\n\n const ownership = (data.ownership ?? []) as ApiRecord[];\n if (ownership.length > 0 && accessLevel !== \"summary\") {\n const table = makeTable(\"Ownership Breakdown\", [\"Holder\", \"Shares\", \"Percentage\", \"Class\"]);\n for (const o of ownership) {\n table.push([s(o.holder_name ?? o.name), s(o.shares), `${o.percentage ?? \"\"}%`, s(o.share_class)]);\n }\n console.log(table.toString());\n }\n\n const pools = (data.option_pools ?? []) as ApiRecord[];\n if (pools.length > 0) {\n const table = makeTable(\"Option Pools\", [\"Name\", \"Authorized\", \"Granted\", \"Available\"]);\n for (const p of pools) {\n table.push([s(p.name), s(p.authorized), s(p.granted), s(p.available)]);\n }\n console.log(table.toString());\n }\n\n if (data.fully_diluted_shares != null) {\n const fd = data.fully_diluted_shares;\n console.log(`\\n${chalk.bold(\"Fully Diluted Shares:\")} ${typeof fd === \"number\" ? fd.toLocaleString() : fd}`);\n }\n if (data.total_units != null) {\n console.log(`\\n${chalk.bold(\"Cap Table Basis:\")} ${s(data.basis) || \"outstanding\"}`);\n console.log(`${chalk.bold(\"Total Units:\")} ${typeof data.total_units === \"number\" ? data.total_units.toLocaleString() : data.total_units}`);\n }\n}\n\nexport function printSafesTable(safes: ApiRecord[]): void {\n const table = makeTable(\"SAFE Notes\", [\"ID\", \"Investor\", \"Amount\", \"Cap\", \"Discount\", \"Date\"]);\n for (const s_ of safes) {\n table.push([\n s(s_.safe_note_id ?? s_.safe_id ?? s_.id, 12),\n s(s_.investor_name ?? s_.investor),\n money(s_.principal_amount_cents ?? s_.investment_amount ?? s_.amount, false),\n money(s_.valuation_cap_cents ?? s_.valuation_cap ?? s_.cap, false),\n s(s_.discount_rate ?? s_.discount),\n s(s_.issued_at ?? s_.date ?? s_.created_at),\n ]);\n }\n console.log(table.toString());\n}\n\nexport function printTransfersTable(transfers: ApiRecord[]): void {\n const table = makeTable(\"Share Transfers\", [\"ID\", \"From\", \"To\", \"Shares\", \"Class\", \"Date\"]);\n for (const t of transfers) {\n table.push([\n s(t.transfer_id ?? t.id, 12),\n s(t.from_holder ?? t.from),\n s(t.to_holder ?? t.to),\n s(t.shares),\n s(t.share_class),\n s(t.date ?? t.transfer_date),\n ]);\n }\n console.log(table.toString());\n}\n\nexport function printValuationsTable(valuations: ApiRecord[]): void {\n const table = makeTable(\"Valuations\", [\"Date\", \"Type\", \"Valuation\", \"PPS\"]);\n for (const v of valuations) {\n table.push([\n date(v.effective_date ?? v.valuation_date ?? v.date),\n s(v.valuation_type ?? v.type),\n money(v.enterprise_value_cents ?? v.enterprise_value ?? v.valuation),\n money(v.fmv_per_share_cents ?? v.price_per_share ?? v.pps ?? v.fmv_per_share),\n ]);\n }\n console.log(table.toString());\n}\n\nexport function printGovernanceTable(bodies: ApiRecord[]): void {\n const table = makeTable(\"Governance Bodies\", [\"ID\", \"Body\", \"Type\", \"Seats\", \"Meetings\"]);\n for (const b of bodies) {\n table.push([\n s(b.body_id ?? b.id, 12),\n s(b.name),\n s(b.body_type ?? b.type),\n s(b.seat_count ?? b.seats),\n s(b.meeting_count ?? b.meetings),\n ]);\n }\n console.log(table.toString());\n}\n\nexport function printSeatsTable(seats: ApiRecord[]): void {\n const table = makeTable(\"Seats\", [\"Seat\", \"Holder\", \"Role\", \"Status\"]);\n for (const st of seats) {\n table.push([s(st.seat_name ?? st.title), s(st.holder_name ?? st.holder), s(st.role), s(st.status)]);\n }\n console.log(table.toString());\n}\n\nexport function printMeetingsTable(meetings: ApiRecord[]): void {\n const table = makeTable(\"Meetings\", [\"ID\", \"Title\", \"Date\", \"Status\", \"Resolutions\"]);\n for (const m of meetings) {\n table.push([\n s(m.meeting_id ?? m.id, 12),\n s(m.title ?? m.name),\n s(m.scheduled_date ?? m.meeting_date ?? m.date),\n s(m.status),\n s(m.resolution_count ?? m.resolutions),\n ]);\n }\n console.log(table.toString());\n}\n\nexport function printResolutionsTable(resolutions: ApiRecord[]): void {\n const table = makeTable(\"Resolutions\", [\"ID\", \"Title\", \"Type\", \"Status\", \"For\", \"Against\"]);\n for (const r of resolutions) {\n table.push([\n s(r.resolution_id ?? r.id, 12),\n s(r.title),\n s(r.resolution_type ?? r.type),\n s(r.status),\n s(r.votes_for),\n s(r.votes_against),\n ]);\n }\n console.log(table.toString());\n}\n\nexport function printDocumentsTable(docs: ApiRecord[]): void {\n const table = makeTable(\"Documents\", [\"ID\", \"Title\", \"Type\", \"Date\", \"Status\", \"Signatures\"]);\n for (const d of docs) {\n const sigs = d.signatures;\n const sigStr = Array.isArray(sigs) ? `${sigs.length} signed` : s(sigs);\n table.push([\n s(d.document_id ?? d.id, 12),\n s(d.title ?? d.name),\n s(d.document_type ?? d.type),\n s(d.date ?? d.created_at),\n s(d.status),\n sigStr,\n ]);\n }\n console.log(table.toString());\n}\n\nexport function printWorkItemsTable(items: ApiRecord[]): void {\n const table = makeTable(\"Work Items\", [\"ID\", \"Title\", \"Category\", \"Status\", \"Deadline\", \"Claimed By\"]);\n for (const w of items) {\n const status = s(w.effective_status ?? w.status);\n const colored =\n status === \"completed\" ? chalk.green(status) :\n status === \"claimed\" ? chalk.yellow(status) :\n status === \"cancelled\" ? chalk.dim(status) :\n status;\n table.push([\n s(w.work_item_id ?? w.id, 12),\n s(w.title),\n s(w.category),\n colored,\n w.asap ? chalk.red.bold(\"ASAP\") : s(w.deadline ?? \"\"),\n s(w.claimed_by ?? \"\"),\n ]);\n }\n console.log(table.toString());\n}\n\nexport function printAgentsTable(agents: ApiRecord[]): void {\n const table = makeTable(\"Agents\", [\"ID\", \"Name\", \"Status\", \"Model\"]);\n for (const a of agents) {\n const status = s(a.status);\n const colored =\n status === \"active\" ? chalk.green(status) : status === \"paused\" ? chalk.yellow(status) : status;\n table.push([s(a.agent_id ?? a.id, 12), s(a.name), colored, s(a.model)]);\n }\n console.log(table.toString());\n}\n\nexport function printApprovalsTable(approvals: ApiRecord[]): void {\n const table = makeTable(\"Pending Approvals\", [\"ID\", \"Type\", \"Requested By\", \"Description\", \"Created\"]);\n for (const a of approvals) {\n let desc = s(a.description ?? a.summary);\n if (desc.length > 60) desc = desc.slice(0, 57) + \"...\";\n table.push([\n s(a.approval_id ?? a.id, 12),\n s(a.approval_type ?? a.type),\n s(a.requested_by ?? a.requester),\n desc,\n s(a.created_at),\n ]);\n }\n console.log(table.toString());\n}\n\nexport function printBillingPanel(status: ApiRecord, plans: ApiRecord[]): void {\n const plan = s(status.plan ?? status.tier) || \"free\";\n const subStatus = s(status.status) || \"active\";\n const periodEnd = s(status.current_period_end);\n const explanation = s(status.status_explanation);\n\n console.log(chalk.green(\"─\".repeat(50)));\n console.log(chalk.green.bold(\" Billing Status\"));\n console.log(chalk.green(\"─\".repeat(50)));\n console.log(` ${chalk.bold(\"Plan:\")} ${plan}`);\n console.log(` ${chalk.bold(\"Status:\")} ${subStatus}`);\n if (periodEnd) console.log(` ${chalk.bold(\"Current Period End:\")} ${periodEnd}`);\n if (explanation) console.log(` ${chalk.bold(\"Explanation:\")} ${explanation}`);\n console.log(chalk.dim(\" Manage: corp billing portal\"));\n console.log(chalk.dim(\" Upgrade: corp billing upgrade --plan <plan>\"));\n console.log(chalk.green(\"─\".repeat(50)));\n\n if (plans.length > 0) {\n const table = makeTable(\"Available Plans\", [\"Plan\", \"Price\", \"Features\"]);\n for (const p of plans) {\n const amount = (p.price_cents ?? p.amount ?? 0) as number;\n const interval = s(p.interval);\n let priceStr = \"Free\";\n if (amount > 0) {\n priceStr = interval ? `$${Math.round(amount / 100)}/${interval}` : `$${Math.round(amount / 100)}`;\n }\n const name = s(p.name ?? p.plan_id ?? p.tier);\n const features = Array.isArray(p.features) ? (p.features as string[]).join(\", \") : s(p.description);\n table.push([name, priceStr, features]);\n }\n console.log(table.toString());\n }\n}\n","import { input, confirm } from \"@inquirer/prompts\";\nimport { loadConfig, saveConfig } from \"../config.js\";\nimport { provisionWorkspace } from \"../api-client.js\";\nimport { printSuccess, printError } from \"../output.js\";\n\nconst CLOUD_API_URL = \"https://api.thecorporation.ai\";\n\nasync function requestMagicLink(\n apiUrl: string,\n email: string,\n tosAccepted: boolean\n): Promise<void> {\n const resp = await fetch(`${apiUrl}/v1/auth/magic-link`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ email, tos_accepted: tosAccepted }),\n });\n if (!resp.ok) {\n const data = await resp.json().catch(() => ({}));\n const detail =\n (data as Record<string, unknown>)?.error ??\n (data as Record<string, unknown>)?.message ??\n resp.statusText;\n throw new Error(\n typeof detail === \"string\" ? detail : JSON.stringify(detail)\n );\n }\n}\n\nasync function verifyMagicLinkCode(\n apiUrl: string,\n code: string\n): Promise<{ api_key: string; workspace_id: string }> {\n const resp = await fetch(`${apiUrl}/v1/auth/magic-link/verify`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ code, client: \"cli\" }),\n });\n const data = (await resp.json().catch(() => ({}))) as Record<string, unknown>;\n if (!resp.ok) {\n const detail = data?.error ?? data?.message ?? resp.statusText;\n throw new Error(\n typeof detail === \"string\" ? detail : JSON.stringify(detail)\n );\n }\n if (!data.api_key || !data.workspace_id) {\n throw new Error(\"Unexpected response — missing api_key or workspace_id\");\n }\n return {\n api_key: data.api_key as string,\n workspace_id: data.workspace_id as string,\n };\n}\n\nfunction isCloudApi(url: string): boolean {\n return url.replace(/\\/+$/, \"\").includes(\"thecorporation.ai\");\n}\n\nasync function magicLinkAuth(\n apiUrl: string,\n email: string\n): Promise<{ api_key: string; workspace_id: string }> {\n console.log(\"\\nSending magic link to \" + email + \"...\");\n await requestMagicLink(apiUrl, email, true);\n console.log(\"Check your email for a sign-in link from TheCorporation.\");\n console.log(\n \"Copy the code from the URL (the ?code=... part) and paste it below.\\n\"\n );\n\n const code = await input({ message: \"Paste your magic link code\" });\n const trimmed = code.trim().replace(/^.*[?&]code=/, \"\");\n if (!trimmed) {\n throw new Error(\"No code provided\");\n }\n\n console.log(\"Verifying...\");\n return verifyMagicLinkCode(apiUrl, trimmed);\n}\n\nexport async function setupCommand(): Promise<void> {\n const cfg = loadConfig();\n console.log(\"Welcome to corp — corporate governance from the terminal.\\n\");\n\n // Determine API URL\n const customUrl = process.env.CORP_API_URL;\n if (customUrl) {\n cfg.api_url = customUrl.replace(/\\/+$/, \"\");\n console.log(`Using API: ${cfg.api_url}\\n`);\n } else {\n cfg.api_url = CLOUD_API_URL;\n }\n\n console.log(\"--- User Info ---\");\n const user = cfg.user ?? { name: \"\", email: \"\" };\n user.name = await input({\n message: \"Your name\",\n default: user.name || undefined,\n });\n user.email = await input({\n message: \"Your email\",\n default: user.email || undefined,\n });\n cfg.user = user;\n\n const needsAuth = !cfg.api_key || !cfg.workspace_id;\n const cloud = isCloudApi(cfg.api_url);\n\n if (needsAuth) {\n if (cloud) {\n // Cloud API — authenticate via magic link\n try {\n const result = await magicLinkAuth(cfg.api_url, user.email);\n cfg.api_key = result.api_key;\n cfg.workspace_id = result.workspace_id;\n printSuccess(`Authenticated. Workspace: ${result.workspace_id}`);\n } catch (err) {\n printError(`Authentication failed: ${err}`);\n console.log(\n \"You can manually set credentials with: corp config set api_key <key>\"\n );\n }\n } else {\n // Self-hosted — provision directly (no auth required)\n console.log(\"\\nProvisioning workspace...\");\n try {\n const result = await provisionWorkspace(\n cfg.api_url,\n `${user.name}'s workspace`\n );\n cfg.api_key = result.api_key as string;\n cfg.workspace_id = result.workspace_id as string;\n console.log(`Workspace provisioned: ${result.workspace_id}`);\n } catch (err) {\n printError(`Auto-provision failed: ${err}`);\n console.log(\n \"You can manually set credentials with: corp config set api_key <key>\"\n );\n }\n }\n } else {\n console.log(\"\\nVerifying existing credentials...\");\n let keyValid = false;\n try {\n const resp = await fetch(\n `${cfg.api_url.replace(/\\/+$/, \"\")}/v1/workspaces/${cfg.workspace_id}/status`,\n { headers: { Authorization: `Bearer ${cfg.api_key}` } }\n );\n keyValid = resp.status !== 401;\n } catch {\n // network error — treat as potentially valid\n }\n\n if (keyValid) {\n console.log(\"Credentials OK.\");\n } else {\n console.log(\"API key is no longer valid.\");\n const reauth = await confirm({\n message: cloud\n ? \"Re-authenticate via magic link?\"\n : \"Provision a new workspace? (This will replace your current credentials)\",\n default: true,\n });\n if (reauth) {\n try {\n if (cloud) {\n const result = await magicLinkAuth(cfg.api_url, user.email);\n cfg.api_key = result.api_key;\n cfg.workspace_id = result.workspace_id;\n printSuccess(`Authenticated. Workspace: ${result.workspace_id}`);\n } else {\n const result = await provisionWorkspace(\n cfg.api_url,\n `${user.name}'s workspace`\n );\n cfg.api_key = result.api_key as string;\n cfg.workspace_id = result.workspace_id as string;\n console.log(`Workspace provisioned: ${result.workspace_id}`);\n }\n } catch (err) {\n printError(`Authentication failed: ${err}`);\n }\n } else {\n console.log(\n \"Keeping existing credentials. You can manually update with: corp config set api_key <key>\"\n );\n }\n }\n }\n\n saveConfig(cfg);\n console.log(\"\\nConfig saved to ~/.corp/config.json\");\n console.log(\"Run 'corp status' to verify your connection.\");\n}\n","/**\n * Rising cityscape boot animation — ported from packages/cli/corp/tui/widgets/mascot.py\n */\n\n// prettier-ignore\nconst BUILDINGS: string[][] = [\n [\n \" ┌┐ \",\n \" ││ \",\n \" ││ \",\n \" ┌┤├┐ \",\n \" │││││\",\n \" │││││\",\n ],\n [\n \" ╔══╗ \",\n \" ║▪▪║ \",\n \" ║▪▪║ \",\n \" ║▪▪║ \",\n \" ║▪▪║ \",\n \" ║▪▪║ \",\n \" ║▪▪║ \",\n \" ║▪▪║ \",\n ],\n [\n \" /\\\\ \",\n \" / \\\\ \",\n \" │▪▪│ \",\n \" │▪▪│ \",\n \" │▪▪│ \",\n ],\n [\n \" ┌──┐ \",\n \" │≋≋│ \",\n \" │▪▪│ \",\n \" │▪▪│ \",\n \" │▪▪│ \",\n \" │▪▪│ \",\n \" │▪▪│ \",\n \" │▪▪│ \",\n \" │▪▪│ \",\n ],\n [\n \" ╻ \",\n \" ┃ \",\n \" ┌┤┐ \",\n \" │▪│ \",\n \" │▪│ \",\n \" │▪│ \",\n \" │▪│ \",\n \" │▪│ \",\n \" │▪│ \",\n \" │▪│ \",\n \" │▪│ \",\n ],\n [\n \" ┌┐ \",\n \" ├┤ \",\n \" │▪│ \",\n \" │▪│ \",\n \" │▪│ \",\n \" │▪│ \",\n ],\n [\n \" ╔═══╗\",\n \" ║▪ ▪║\",\n \" ║▪ ▪║\",\n \" ║▪ ▪║\",\n \" ║▪ ▪║\",\n \" ║▪ ▪║\",\n \" ║▪ ▪║\",\n \" ║▪ ▪║\",\n \" ║▪ ▪║\",\n \" ║▪ ▪║\",\n ],\n [\n \" ┬─┬ \",\n \" │~│ \",\n \" │▪│ \",\n \" │▪│ \",\n \" │▪│ \",\n \" │▪│ \",\n \" │▪│ \",\n ],\n];\n\nconst MAX_HEIGHT = Math.max(...BUILDINGS.map((b) => b.length));\nconst TOTAL_FRAMES = MAX_HEIGHT + 4; // 15 frames, ~1.5s at 100ms\n\nconst GOLD = \"\\x1b[38;2;212;160;23m\";\nconst RESET = \"\\x1b[0m\";\n\nexport function renderFrame(frame: number): string {\n const cols: string[][] = [];\n for (let i = 0; i < BUILDINGS.length; i++) {\n const building = BUILDINGS[i];\n const h = building.length;\n const visible = Math.max(0, Math.min(h, frame - i));\n const width = building[0]?.length ?? 6;\n const blank = \" \".repeat(width);\n const col: string[] = Array(MAX_HEIGHT - visible).fill(blank);\n col.push(...building.slice(h - visible));\n cols.push(col);\n }\n\n const lines: string[] = [];\n for (let row = 0; row < MAX_HEIGHT; row++) {\n lines.push(cols.map((col) => col[row]).join(\"\"));\n }\n return lines.join(\"\\n\");\n}\n\n/**\n * Run an async function while displaying the rising cityscape animation.\n * No-ops when stdout is not a TTY (piped, CI, etc.).\n */\nexport async function withAnimation<T>(fn: () => Promise<T>): Promise<T> {\n if (!process.stdout.isTTY) {\n return fn();\n }\n\n let frame = 0;\n let animDone = false;\n const spinChars = [\"⠋\", \"⠙\", \"⠹\", \"⠸\", \"⠼\", \"⠴\", \"⠦\", \"⠧\", \"⠇\", \"⠏\"];\n let spinIdx = 0;\n let lastLineCount = 0;\n\n const clearPrev = () => {\n if (lastLineCount > 0) {\n process.stdout.write(`\\x1b[${lastLineCount}A\\x1b[0J`);\n }\n };\n\n const drawFrame = () => {\n clearPrev();\n if (!animDone) {\n const art = renderFrame(frame);\n const output = `${GOLD}${art}${RESET}\\n`;\n process.stdout.write(output);\n lastLineCount = MAX_HEIGHT + 1;\n frame++;\n if (frame >= TOTAL_FRAMES) {\n animDone = true;\n }\n } else {\n // Dot spinner fallback after animation finishes\n const line = `${GOLD}${spinChars[spinIdx % spinChars.length]} Loading...${RESET}\\n`;\n process.stdout.write(line);\n lastLineCount = 1;\n spinIdx++;\n }\n };\n\n drawFrame();\n const timer = setInterval(drawFrame, 100);\n\n try {\n const result = await fn();\n return result;\n } finally {\n clearInterval(timer);\n clearPrev();\n }\n}\n","import { withAnimation } from \"./animation.js\";\n\n/**\n * Run an async function with a loading animation.\n * Silently skipped when `json` is truthy (pure JSON output) or non-TTY.\n */\nexport async function withSpinner<T>(\n _label: string,\n fn: () => Promise<T>,\n json?: boolean,\n): Promise<T> {\n if (json) {\n return fn();\n }\n return withAnimation(fn);\n}\n","import { requireConfig } from \"../config.js\";\nimport { CorpAPIClient } from \"../api-client.js\";\nimport { printError, printJson, printStatusPanel } from \"../output.js\";\nimport { withSpinner } from \"../spinner.js\";\n\nexport async function statusCommand(opts: { json?: boolean } = {}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const data = await withSpinner(\"Loading\", () => client.getStatus());\n if (opts.json) {\n printJson(data);\n } else {\n printStatusPanel(data);\n }\n } catch (err) {\n printError(`Failed to fetch status: ${err}`);\n process.exit(1);\n }\n}\n","import chalk from \"chalk\";\nimport { getActiveEntityId, loadConfig, requireConfig } from \"../config.js\";\nimport { CorpAPIClient } from \"../api-client.js\";\nimport { printError, printJson } from \"../output.js\";\n\nexport async function contextCommand(opts: { json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const rawCfg = loadConfig();\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n\n try {\n const [status, entities] = await Promise.all([\n client.getStatus(),\n client.listEntities(),\n ]);\n\n const activeEntityId = getActiveEntityId(rawCfg);\n const activeEntity = activeEntityId\n ? entities.find((entity) => entity.entity_id === activeEntityId) ?? null\n : null;\n\n const [contactsResult, documentsResult, workItemsResult] = activeEntity\n ? await Promise.allSettled([\n client.listContacts(String(activeEntity.entity_id)),\n client.getEntityDocuments(String(activeEntity.entity_id)),\n client.listWorkItems(String(activeEntity.entity_id)),\n ])\n : [null, null, null];\n\n const payload = {\n user: {\n name: rawCfg.user?.name ?? \"\",\n email: rawCfg.user?.email ?? \"\",\n },\n workspace: {\n workspace_id: rawCfg.workspace_id,\n api_url: rawCfg.api_url,\n status,\n },\n active_entity: activeEntity\n ? {\n entity: activeEntity,\n summary: {\n contact_count:\n contactsResult && contactsResult.status === \"fulfilled\"\n ? contactsResult.value.length\n : null,\n document_count:\n documentsResult && documentsResult.status === \"fulfilled\"\n ? documentsResult.value.length\n : null,\n work_item_count:\n workItemsResult && workItemsResult.status === \"fulfilled\"\n ? workItemsResult.value.length\n : null,\n },\n }\n : null,\n entity_count: entities.length,\n };\n\n if (opts.json) {\n printJson(payload);\n return;\n }\n\n console.log(chalk.blue(\"─\".repeat(50)));\n console.log(chalk.blue.bold(\" Corp Context\"));\n console.log(chalk.blue(\"─\".repeat(50)));\n console.log(` ${chalk.bold(\"User:\")} ${payload.user.name || \"N/A\"} <${payload.user.email || \"N/A\"}>`);\n console.log(` ${chalk.bold(\"Workspace:\")} ${rawCfg.workspace_id}`);\n console.log(` ${chalk.bold(\"API URL:\")} ${rawCfg.api_url}`);\n console.log(` ${chalk.bold(\"Entities:\")} ${entities.length}`);\n if (payload.active_entity) {\n console.log(` ${chalk.bold(\"Active Entity:\")} ${payload.active_entity.entity.legal_name ?? payload.active_entity.entity.entity_id}`);\n console.log(` ${chalk.bold(\"Active Entity ID:\")} ${payload.active_entity.entity.entity_id}`);\n console.log(` ${chalk.bold(\"Contacts:\")} ${payload.active_entity.summary.contact_count ?? \"N/A\"}`);\n console.log(` ${chalk.bold(\"Documents:\")} ${payload.active_entity.summary.document_count ?? \"N/A\"}`);\n console.log(` ${chalk.bold(\"Work Items:\")} ${payload.active_entity.summary.work_item_count ?? \"N/A\"}`);\n } else {\n console.log(` ${chalk.bold(\"Active Entity:\")} none`);\n }\n if (status.next_deadline) {\n console.log(` ${chalk.bold(\"Next Deadline:\")} ${status.next_deadline}`);\n }\n console.log(chalk.blue(\"─\".repeat(50)));\n } catch (err) {\n printError(`Failed to fetch context: ${err}`);\n process.exit(1);\n }\n}\n","import type { Command } from \"commander\";\nimport { printJson } from \"../output.js\";\n\ntype SchemaArgument = {\n name: string;\n required: boolean;\n variadic: boolean;\n defaultValue?: unknown;\n choices?: string[];\n};\n\ntype SchemaOption = {\n flags: string;\n name: string;\n description: string;\n required: boolean;\n mandatory: boolean;\n variadic: boolean;\n defaultValue?: unknown;\n choices?: string[];\n};\n\ntype SchemaCommand = {\n path: string;\n name: string;\n description: string;\n aliases: string[];\n arguments: SchemaArgument[];\n options: SchemaOption[];\n subcommands: SchemaCommand[];\n};\n\nfunction readChoices(value: unknown): string[] | undefined {\n if (Array.isArray(value) && value.every((entry) => typeof entry === \"string\")) {\n return value;\n }\n return undefined;\n}\n\nfunction commandToSchema(command: Command, parentPath = \"\"): SchemaCommand {\n const cmd = command as Command & {\n registeredArguments?: Array<{\n name: () => string;\n required?: boolean;\n variadic?: boolean;\n defaultValue?: unknown;\n argChoices?: unknown;\n }>;\n };\n\n const path = parentPath ? `${parentPath} ${command.name()}` : command.name();\n return {\n path,\n name: command.name(),\n description: command.description(),\n aliases: command.aliases(),\n arguments: (cmd.registeredArguments ?? []).map((arg) => ({\n name: arg.name(),\n required: Boolean(arg.required),\n variadic: Boolean(arg.variadic),\n defaultValue: arg.defaultValue,\n choices: readChoices(arg.argChoices),\n })),\n options: command.options.map((option) => ({\n flags: option.flags,\n name: option.attributeName(),\n description: option.description ?? \"\",\n required: option.required,\n mandatory: option.mandatory,\n variadic: option.variadic,\n defaultValue: option.defaultValue,\n choices: readChoices(option.argChoices),\n })),\n subcommands: command.commands.map((child) => commandToSchema(child, path)),\n };\n}\n\nexport function schemaCommand(program: Command, opts: { compact?: boolean }): void {\n const manifest = {\n name: program.name(),\n version: program.version(),\n description: program.description(),\n generated_at: new Date().toISOString(),\n commands: program.commands.map((command) => commandToSchema(command, program.name())),\n };\n if (opts.compact) {\n console.log(JSON.stringify(manifest));\n return;\n }\n printJson(manifest);\n}\n","import { configForDisplay, getValue, loadConfig, setValue, updateConfig } from \"../config.js\";\nimport { printError, printJson } from \"../output.js\";\n\nexport function configSetCommand(\n key: string,\n value: string,\n options: { force?: boolean } = {},\n): void {\n try {\n updateConfig((cfg) => {\n setValue(cfg as unknown as Record<string, unknown>, key, value, {\n forceSensitive: options.force,\n });\n });\n } catch (err) {\n printError(`Failed to update config: ${err}`);\n process.exit(1);\n }\n\n if (key === \"api_key\" || key === \"llm.api_key\") {\n console.log(`${key} updated.`);\n return;\n }\n console.log(`${key} updated.`);\n}\n\nexport function configGetCommand(key: string): void {\n const cfg = loadConfig();\n const val = getValue(cfg as unknown as Record<string, unknown>, key);\n if (val === undefined) {\n printError(`Key not found: ${key}`);\n process.exit(1);\n }\n if (typeof val === \"object\" && val !== null) {\n printJson(val);\n } else {\n console.log(String(val));\n }\n}\n\nexport function configListCommand(): void {\n const cfg = loadConfig();\n printJson(configForDisplay(cfg));\n}\n","import { requireConfig } from \"../config.js\";\nimport { CorpAPIClient } from \"../api-client.js\";\nimport { printObligationsTable, printError, printJson } from \"../output.js\";\n\nexport async function obligationsCommand(opts: { tier?: string; json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const data = await client.getObligations(opts.tier);\n const obligations = (data.obligations ?? []) as Record<string, unknown>[];\n if (opts.json) printJson(obligations);\n else if (obligations.length === 0) console.log(\"No obligations found.\");\n else printObligationsTable(obligations);\n } catch (err) { printError(`Failed to fetch obligations: ${err}`); process.exit(1); }\n}\n","import { requireConfig } from \"../config.js\";\nimport { CorpAPIClient } from \"../api-client.js\";\nimport { printError, printSuccess, printJson, printWarning } from \"../output.js\";\n\nexport async function digestCommand(opts: { trigger?: boolean; key?: string; json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n if (opts.trigger) {\n const result = await client.triggerDigest();\n const message = (() => {\n const value = (result as Record<string, unknown>).message;\n return typeof value === \"string\" && value.trim() ? value : null;\n })();\n if (!opts.json) {\n printSuccess(result.digest_count > 0 ? \"Digest triggered.\" : \"Digest trigger accepted.\");\n }\n if (message && !opts.json) {\n printWarning(message);\n }\n printJson(result);\n } else if (opts.key) {\n const result = await client.getDigest(opts.key);\n printJson(result);\n } else {\n const digests = await client.listDigests();\n if (digests.length === 0) console.log(\"No digest history found.\");\n else printJson(digests);\n }\n } catch (err) { printError(`Failed: ${err}`); process.exit(1); }\n}\n","import { requireConfig } from \"../config.js\";\nimport { CorpAPIClient } from \"../api-client.js\";\nimport { printError, printSuccess } from \"../output.js\";\n\nexport async function linkCommand(opts: { externalId: string; provider: string }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const data = await client.createLink(opts.externalId, opts.provider);\n printSuccess(`Workspace linked to ${opts.provider} (external ID: ${opts.externalId})`);\n if (data.workspace_id) console.log(` Workspace: ${data.workspace_id}`);\n } catch (err) {\n printError(`${err}`);\n process.exit(1);\n }\n}\n","import { loadConfig, saveConfig } from \"../config.js\";\nimport { printError } from \"../output.js\";\n\nexport async function claimCommand(code: string): Promise<void> {\n const cfg = loadConfig();\n const apiUrl = (cfg.api_url || \"https://api.thecorporation.ai\").replace(/\\/+$/, \"\");\n try {\n const resp = await fetch(`${apiUrl}/v1/workspaces/claim`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ code }),\n });\n if (!resp.ok) {\n let detail = \"\";\n try { const body = await resp.json() as Record<string, string>; detail = body.detail ?? \"\"; } catch { /* ignore */ }\n printError(detail || `${resp.status} ${resp.statusText}`);\n process.exit(1);\n }\n const data = await resp.json() as Record<string, string>;\n cfg.api_key = data.api_key;\n cfg.workspace_id = data.workspace_id;\n saveConfig(cfg);\n console.log(`Workspace joined: ${data.workspace_id}`);\n console.log(\"Credentials saved to ~/.corp/config.json\");\n } catch (err) {\n printError(`${err}`);\n process.exit(1);\n }\n}\n","import type { ToolCall, LLMResponse } from \"./types.js\";\n\nconst PROVIDER_BASE_URLS: Record<string, string> = {\n openrouter: \"https://openrouter.ai/api/v1\",\n};\n\nexport async function chat(\n messages: Record<string, unknown>[],\n tools?: Record<string, unknown>[],\n provider = \"anthropic\",\n apiKey = \"\",\n model = \"\",\n baseUrl?: string,\n): Promise<LLMResponse> {\n if (provider === \"anthropic\") {\n return chatAnthropic(messages, tools, apiKey, model);\n } else if (provider === \"openai\" || provider === \"openrouter\") {\n const effectiveUrl = baseUrl ?? PROVIDER_BASE_URLS[provider];\n return chatOpenAI(messages, tools, apiKey, model, effectiveUrl);\n }\n throw new Error(`Unknown LLM provider: ${provider}`);\n}\n\nasync function chatAnthropic(\n messages: Record<string, unknown>[],\n tools?: Record<string, unknown>[],\n apiKey = \"\",\n model = \"\",\n): Promise<LLMResponse> {\n const { default: Anthropic } = await import(\"@anthropic-ai/sdk\");\n const client = new Anthropic({ apiKey });\n\n let systemText = \"\";\n const convMessages: Record<string, unknown>[] = [];\n\n for (const msg of messages) {\n if (msg.role === \"system\") {\n systemText = msg.content as string;\n } else if (msg.role === \"tool\") {\n convMessages.push({\n role: \"user\",\n content: [{\n type: \"tool_result\",\n tool_use_id: msg.tool_call_id,\n content: msg.content,\n }],\n });\n } else if (msg.role === \"assistant\" && msg.tool_calls) {\n const contentBlocks: Record<string, unknown>[] = [];\n if (msg.content) contentBlocks.push({ type: \"text\", text: msg.content });\n for (const tc of msg.tool_calls as Record<string, unknown>[]) {\n const fn = tc.function as Record<string, unknown>;\n let args = fn.arguments;\n if (typeof args === \"string\") args = JSON.parse(args);\n contentBlocks.push({ type: \"tool_use\", id: tc.id, name: fn.name, input: args });\n }\n convMessages.push({ role: \"assistant\", content: contentBlocks });\n } else {\n convMessages.push({ role: msg.role, content: msg.content ?? \"\" });\n }\n }\n\n let anthropicTools: Record<string, unknown>[] | undefined;\n if (tools?.length) {\n anthropicTools = tools.map((t) => {\n const fn = (t as Record<string, unknown>).function as Record<string, unknown>;\n return {\n name: fn.name,\n description: fn.description ?? \"\",\n input_schema: fn.parameters ?? { type: \"object\", properties: {} },\n };\n });\n }\n\n const kwargs: Record<string, unknown> = {\n model: model || \"claude-sonnet-4-20250514\",\n max_tokens: 4096,\n messages: convMessages,\n };\n if (systemText) kwargs.system = systemText;\n if (anthropicTools) kwargs.tools = anthropicTools;\n\n const response = await client.messages.create(kwargs as Parameters<typeof client.messages.create>[0]);\n\n let content: string | null = null;\n const toolCallsOut: ToolCall[] = [];\n for (const block of response.content) {\n if (block.type === \"text\") {\n content = block.text;\n } else if (block.type === \"tool_use\") {\n toolCallsOut.push({\n id: block.id,\n name: block.name,\n arguments: typeof block.input === \"object\" ? (block.input as Record<string, unknown>) : {},\n });\n }\n }\n\n return {\n content,\n tool_calls: toolCallsOut,\n usage: {\n prompt_tokens: response.usage.input_tokens,\n completion_tokens: response.usage.output_tokens,\n total_tokens: response.usage.input_tokens + response.usage.output_tokens,\n },\n finish_reason: response.stop_reason ?? null,\n };\n}\n\nasync function chatOpenAI(\n messages: Record<string, unknown>[],\n tools?: Record<string, unknown>[],\n apiKey = \"\",\n model = \"\",\n baseUrl?: string,\n): Promise<LLMResponse> {\n const { default: OpenAI } = await import(\"openai\");\n const clientOpts: Record<string, unknown> = { apiKey };\n if (baseUrl) clientOpts.baseURL = baseUrl;\n const client = new OpenAI(clientOpts as ConstructorParameters<typeof OpenAI>[0]);\n\n const kwargs: Record<string, unknown> = {\n model: model || \"gpt-4o\",\n messages,\n max_tokens: 4096,\n };\n if (tools?.length) {\n kwargs.tools = tools;\n kwargs.tool_choice = \"auto\";\n }\n\n const response = await client.chat.completions.create(kwargs as Parameters<typeof client.chat.completions.create>[0]);\n const choice = response.choices[0];\n const message = choice.message;\n\n const toolCallsOut: ToolCall[] = [];\n if (message.tool_calls) {\n for (const tc of message.tool_calls) {\n let args: Record<string, unknown>;\n try {\n args = JSON.parse(tc.function.arguments);\n } catch {\n args = { _raw: tc.function.arguments };\n }\n toolCallsOut.push({ id: tc.id, name: tc.function.name, arguments: args });\n }\n }\n\n return {\n content: message.content,\n tool_calls: toolCallsOut,\n usage: {\n prompt_tokens: response.usage?.prompt_tokens ?? 0,\n completion_tokens: response.usage?.completion_tokens ?? 0,\n total_tokens: response.usage?.total_tokens ?? 0,\n },\n finish_reason: choice.finish_reason ?? null,\n };\n}\n","import {\n TOOL_DEFINITIONS as _TOOL_DEFINITIONS,\n isWriteTool as _isWriteTool,\n executeTool as _executeTool,\n} from \"@thecorporation/corp-tools\";\nimport type { CorpAPIClient } from \"@thecorporation/corp-tools\";\nimport { setActiveEntityId, updateConfig } from \"./config.js\";\nimport { join } from \"node:path\";\nimport { homedir } from \"node:os\";\n\nexport const TOOL_DEFINITIONS = _TOOL_DEFINITIONS;\nexport const isWriteTool: (name: string, args?: Record<string, unknown>) => boolean = _isWriteTool;\n\nexport async function executeTool(\n name: string,\n args: Record<string, unknown>,\n client: CorpAPIClient,\n): Promise<string> {\n return _executeTool(name, args, client, {\n dataDir: join(homedir(), \".corp\"),\n onEntityFormed: (entityId) => {\n try {\n updateConfig((cfg) => {\n setActiveEntityId(cfg, entityId);\n });\n } catch { /* ignore */ }\n },\n });\n}\n","import { createInterface } from \"node:readline\";\nimport chalk from \"chalk\";\nimport { requireConfig, configForDisplay, getValue, setValue, saveConfig } from \"./config.js\";\nimport { CorpAPIClient } from \"./api-client.js\";\nimport { chat as llmChat } from \"./llm.js\";\nimport { TOOL_DEFINITIONS, executeTool, isWriteTool } from \"./tools.js\";\nimport { printError, printStatusPanel, printObligationsTable, printJson } from \"./output.js\";\nimport type { CorpConfig, LLMResponse, ToolCall } from \"./types.js\";\n\nconst SYSTEM_PROMPT = `You are **corp**, an AI assistant for corporate governance.\nYou help users manage their companies — entities, cap tables, compliance, governance, finances, and more.\nYou have tools to read and write corporate data. Use them to fulfill user requests.\nFor write operations, confirm with the user before proceeding.\nMonetary values are in cents (e.g. 100000 = $1,000.00).\nDocuments must be signed by the human — you cannot sign on their behalf.\nAfter completing actions, suggest logical next steps.`;\n\nexport async function chatCommand(): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\", \"llm.api_key\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n\n const messages: Record<string, unknown>[] = [{ role: \"system\", content: SYSTEM_PROMPT }];\n let totalTokens = 0;\n\n const rl = createInterface({ input: process.stdin, output: process.stdout });\n const prompt = () => new Promise<string>((resolve) => rl.question(chalk.green.bold(\"> \"), resolve));\n\n console.log(chalk.blue.bold(\"corp chat\") + \" — type /help for commands, /quit to exit\\n\");\n\n const slashHandlers: Record<string, (args: string) => void> = {\n \"/status\": async () => {\n try { printStatusPanel(await client.getStatus()); } catch (e) { printError(`Status error: ${e}`); }\n },\n \"/obligations\": async () => {\n try {\n const data = await client.getObligations();\n const obls = (data.obligations ?? []) as Record<string, unknown>[];\n if (obls.length) printObligationsTable(obls);\n else console.log(chalk.dim(\"No obligations found.\"));\n } catch (e) { printError(`Obligations error: ${e}`); }\n },\n \"/digest\": async () => {\n try {\n const digests = await client.listDigests();\n if (digests.length) printJson(digests);\n else console.log(chalk.dim(\"No digest history.\"));\n } catch (e) { printError(`Digest error: ${e}`); }\n },\n \"/config\": () => printJson(configForDisplay(cfg)),\n \"/model\": (args: string) => {\n const model = args.trim();\n if (!model) { console.log(`Current model: ${getValue(cfg as unknown as Record<string, unknown>, \"llm.model\")}`); return; }\n setValue(cfg as unknown as Record<string, unknown>, \"llm.model\", model);\n saveConfig(cfg);\n console.log(`Model switched to: ${model}`);\n },\n \"/cost\": () => console.log(`Session tokens used: ${totalTokens.toLocaleString()}`),\n \"/clear\": () => {\n messages.length = 0;\n messages.push({ role: \"system\", content: SYSTEM_PROMPT });\n totalTokens = 0;\n console.log(chalk.dim(\"Conversation cleared.\"));\n },\n \"/help\": () => {\n console.log(`\n${chalk.bold(\"Chat Slash Commands\")}\n /status Show workspace status\n /obligations List obligations\n /digest Show digest history\n /config Show current config (masked keys)\n /model <name> Switch LLM model\n /cost Show token usage\n /clear Clear conversation\n /help Show this help\n /quit Exit chat`);\n },\n };\n\n try {\n while (true) {\n let userInput: string;\n try {\n userInput = (await prompt()).trim();\n } catch {\n console.log(\"\\n\" + chalk.dim(\"Goodbye.\"));\n break;\n }\n\n if (!userInput) continue;\n\n if (userInput.startsWith(\"/\")) {\n const [cmd, ...rest] = userInput.split(/\\s+/);\n const args = rest.join(\" \");\n if (cmd === \"/quit\" || cmd === \"/exit\") {\n console.log(chalk.dim(\"Goodbye.\"));\n break;\n }\n const handler = slashHandlers[cmd.toLowerCase()];\n if (handler) { await handler(args); continue; }\n printError(`Unknown command: ${cmd}. Type /help for available commands.`);\n continue;\n }\n\n messages.push({ role: \"user\", content: userInput });\n\n const llmCfg = cfg.llm;\n while (true) {\n let response: LLMResponse;\n try {\n response = await llmChat(\n messages, TOOL_DEFINITIONS, llmCfg.provider, llmCfg.api_key, llmCfg.model, llmCfg.base_url,\n );\n } catch (err) {\n printError(`LLM error: ${err}`);\n break;\n }\n\n totalTokens += response.usage.total_tokens;\n\n const assistantMsg: Record<string, unknown> = { role: \"assistant\", content: response.content };\n if (response.tool_calls.length > 0) {\n assistantMsg.tool_calls = response.tool_calls.map((tc) => ({\n id: tc.id, type: \"function\",\n function: { name: tc.name, arguments: JSON.stringify(tc.arguments) },\n }));\n if (!response.content) assistantMsg.content = null;\n }\n messages.push(assistantMsg);\n\n if (response.tool_calls.length === 0) {\n if (response.content) console.log(\"\\n\" + response.content + \"\\n\");\n break;\n }\n\n for (const tc of response.tool_calls) {\n console.log(chalk.dim(` ${isWriteTool(tc.name, tc.arguments) ? \"\\u2699\" : \"\\u2139\"} ${tc.name}(${JSON.stringify(tc.arguments).slice(0, 80)})`));\n const result = await executeTool(tc.name, tc.arguments, client);\n const short = result.length > 200 ? result.slice(0, 197) + \"...\" : result;\n console.log(chalk.dim(` => ${short}`));\n messages.push({ role: \"tool\", tool_call_id: tc.id, content: result });\n }\n }\n }\n } finally {\n rl.close();\n }\n}\n","import { requireConfig } from \"../config.js\";\nimport { CorpAPIClient } from \"../api-client.js\";\nimport { printEntitiesTable, printError, printSuccess, printJson } from \"../output.js\";\nimport { withSpinner } from \"../spinner.js\";\nimport chalk from \"chalk\";\n\nexport async function entitiesCommand(opts: { json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n const jsonOutput = Boolean(opts.json);\n try {\n const entities = await withSpinner(\"Loading\", () => client.listEntities(), jsonOutput);\n if (jsonOutput) {\n printJson(entities);\n } else if (entities.length === 0) {\n console.log(\"No entities found.\");\n } else {\n printEntitiesTable(entities);\n }\n } catch (err) {\n printError(`Failed to fetch entities: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function entitiesShowCommand(entityId: string, opts: { json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n const jsonOutput = Boolean(opts.json);\n try {\n const entities = await client.listEntities();\n const entity = entities.find((e) => e.entity_id === entityId);\n if (!entity) {\n printError(`Entity not found: ${entityId}`);\n process.exit(1);\n }\n if (jsonOutput) {\n printJson(entity);\n } else {\n console.log(chalk.blue(\"─\".repeat(40)));\n console.log(chalk.blue.bold(\" Entity Detail\"));\n console.log(chalk.blue(\"─\".repeat(40)));\n console.log(` ${chalk.bold(\"Name:\")} ${entity.legal_name ?? entity.name ?? \"N/A\"}`);\n console.log(` ${chalk.bold(\"Type:\")} ${entity.entity_type ?? \"N/A\"}`);\n console.log(` ${chalk.bold(\"Jurisdiction:\")} ${entity.jurisdiction ?? \"N/A\"}`);\n console.log(` ${chalk.bold(\"Status:\")} ${entity.formation_status ?? entity.status ?? \"N/A\"}`);\n console.log(` ${chalk.bold(\"State:\")} ${entity.formation_state ?? \"N/A\"}`);\n console.log(` ${chalk.bold(\"ID:\")} ${entity.entity_id ?? \"N/A\"}`);\n if (entity.formation_date) console.log(` ${chalk.bold(\"Formation Date:\")} ${entity.formation_date}`);\n if (entity.ein) console.log(` ${chalk.bold(\"EIN:\")} ${entity.ein}`);\n console.log(chalk.blue(\"─\".repeat(40)));\n }\n } catch (err) {\n printError(`Failed to fetch entities: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function entitiesConvertCommand(\n entityId: string,\n opts: { to: string; jurisdiction?: string }\n): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const data: Record<string, string> = { target_type: opts.to };\n if (opts.jurisdiction) data.new_jurisdiction = opts.jurisdiction;\n const result = await client.convertEntity(entityId, data);\n printSuccess(`Entity conversion initiated: ${result.conversion_id ?? \"OK\"}`);\n printJson(result);\n } catch (err) {\n printError(`Failed to convert entity: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function entitiesDissolveCommand(\n entityId: string,\n opts: { reason: string; effectiveDate?: string }\n): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const data: Record<string, string> = { reason: opts.reason };\n if (opts.effectiveDate) data.effective_date = opts.effectiveDate;\n const result = await client.dissolveEntity(entityId, data);\n printSuccess(`Dissolution initiated: ${result.dissolution_id ?? \"OK\"}`);\n printJson(result);\n } catch (err) {\n const msg = String(err);\n if (msg.includes(\"InvalidTransition\") || msg.includes(\"422\")) {\n printError(`Cannot dissolve entity: only entities with 'active' status can be dissolved. Check the entity's current status with: corp entities show ${entityId}`);\n } else {\n printError(`Failed to dissolve entity: ${err}`);\n }\n process.exit(1);\n }\n}\n","import { requireConfig, resolveEntityId } from \"../config.js\";\nimport { CorpAPIClient } from \"../api-client.js\";\nimport { printContactsTable, printError, printJson, printWriteResult } from \"../output.js\";\nimport chalk from \"chalk\";\nimport type { ApiRecord } from \"../types.js\";\n\nexport async function contactsListCommand(opts: { entityId?: string; json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const contacts = await client.listContacts(eid);\n if (opts.json) printJson(contacts);\n else if (contacts.length === 0) console.log(\"No contacts found.\");\n else printContactsTable(contacts);\n } catch (err) {\n printError(`Failed to fetch contacts: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function contactsShowCommand(contactId: string, opts: { entityId?: string; json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const profile = await client.getContactProfile(contactId, eid);\n if (opts.json) {\n printJson(profile);\n } else {\n const contact = (profile.contact ?? profile) as ApiRecord;\n console.log(chalk.cyan(\"─\".repeat(40)));\n console.log(chalk.cyan.bold(\" Contact Profile\"));\n console.log(chalk.cyan(\"─\".repeat(40)));\n console.log(` ${chalk.bold(\"Name:\")} ${contact.name ?? \"N/A\"}`);\n console.log(` ${chalk.bold(\"Email:\")} ${contact.email ?? \"N/A\"}`);\n console.log(` ${chalk.bold(\"Category:\")} ${contact.category ?? \"N/A\"}`);\n if (contact.phone) console.log(` ${chalk.bold(\"Phone:\")} ${contact.phone}`);\n if (contact.notes) console.log(` ${chalk.bold(\"Notes:\")} ${contact.notes}`);\n const holdings = profile.equity_holdings as ApiRecord[] | undefined;\n if (holdings?.length) {\n console.log(`\\n ${chalk.bold(\"Equity Holdings:\")}`);\n for (const h of holdings) console.log(` ${h.share_class ?? \"?\"}: ${h.shares ?? \"?\"} shares`);\n }\n const obls = profile.obligations as unknown[];\n if (obls?.length) console.log(`\\n ${chalk.bold(\"Obligations:\")} ${obls.length}`);\n console.log(chalk.cyan(\"─\".repeat(40)));\n }\n } catch (err) {\n printError(`Failed to fetch contact: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function contactsAddCommand(opts: {\n entityId?: string;\n name: string;\n email: string;\n type?: string;\n category?: string;\n capTableAccess?: string;\n phone?: string;\n notes?: string;\n mailingAddress?: string;\n address?: string;\n json?: boolean;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const data: ApiRecord = {\n entity_id: eid,\n contact_type: opts.type ?? \"individual\",\n name: opts.name,\n email: opts.email,\n category: opts.category ?? \"employee\",\n };\n if (opts.phone) data.phone = opts.phone;\n if (opts.notes) data.notes = opts.notes;\n if (opts.mailingAddress ?? opts.address) data.mailing_address = opts.mailingAddress ?? opts.address;\n if (opts.capTableAccess) data.cap_table_access = opts.capTableAccess;\n const result = await client.createContact(data);\n printWriteResult(\n result,\n `Contact created: ${result.contact_id ?? result.id ?? \"OK\"}`,\n opts.json,\n );\n } catch (err) {\n printError(`Failed to create contact: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function contactsEditCommand(\n contactId: string,\n opts: {\n entityId?: string;\n name?: string;\n email?: string;\n category?: string;\n capTableAccess?: string;\n phone?: string;\n notes?: string;\n mailingAddress?: string;\n address?: string;\n json?: boolean;\n }\n): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const data: ApiRecord = { entity_id: eid };\n let hasUpdates = false;\n if (opts.name != null) {\n data.name = opts.name;\n hasUpdates = true;\n }\n if (opts.email != null) {\n data.email = opts.email;\n hasUpdates = true;\n }\n if (opts.category != null) {\n data.category = opts.category;\n hasUpdates = true;\n }\n if (opts.phone != null) {\n data.phone = opts.phone;\n hasUpdates = true;\n }\n if (opts.notes != null) {\n data.notes = opts.notes;\n hasUpdates = true;\n }\n if (opts.capTableAccess != null) {\n data.cap_table_access = opts.capTableAccess;\n hasUpdates = true;\n }\n if (opts.mailingAddress != null || opts.address != null) {\n data.mailing_address = opts.mailingAddress ?? opts.address;\n hasUpdates = true;\n }\n if (!hasUpdates) {\n console.log(\"No fields to update.\");\n return;\n }\n const result = await client.updateContact(contactId, data);\n printWriteResult(result, \"Contact updated.\", opts.json);\n } catch (err) {\n printError(`Failed to update contact: ${err}`);\n process.exit(1);\n }\n}\n","import { requireConfig, resolveEntityId } from \"../config.js\";\nimport { CorpAPIClient } from \"../api-client.js\";\nimport {\n printCapTable, printSafesTable, printTransfersTable,\n printValuationsTable, printDryRun, printError, printSuccess, printJson, printWriteResult,\n} from \"../output.js\";\nimport chalk from \"chalk\";\n\ntype CapTableInstrument = {\n instrument_id: string;\n kind: string;\n symbol: string;\n status?: string;\n};\n\nfunction normalizedGrantType(grantType: string): string {\n return grantType.trim().toLowerCase().replaceAll(\"-\", \"_\").replaceAll(\" \", \"_\");\n}\n\nfunction expectedInstrumentKinds(grantType: string): string[] {\n switch (normalizedGrantType(grantType)) {\n case \"common\":\n case \"common_stock\":\n return [\"common_equity\"];\n case \"preferred\":\n case \"preferred_stock\":\n return [\"preferred_equity\"];\n case \"unit\":\n case \"membership_unit\":\n return [\"membership_unit\"];\n case \"option\":\n case \"options\":\n case \"stock_option\":\n case \"iso\":\n case \"nso\":\n return [\"option_grant\"];\n case \"rsa\":\n return [\"common_equity\", \"preferred_equity\"];\n default:\n return [];\n }\n}\n\nfunction grantRequiresCurrent409a(grantType: string, instrumentKind?: string): boolean {\n return instrumentKind?.toLowerCase() === \"option_grant\" || expectedInstrumentKinds(grantType).includes(\"option_grant\");\n}\n\nfunction buildInstrumentCreationHint(grantType: string): string {\n const normalized = normalizedGrantType(grantType);\n switch (normalized) {\n case \"preferred\":\n case \"preferred_stock\":\n return \"Create one with: corp cap-table create-instrument --kind preferred_equity --symbol SERIES-A --authorized-units <shares>\";\n case \"option\":\n case \"options\":\n case \"stock_option\":\n case \"iso\":\n case \"nso\":\n return \"Create one with: corp cap-table create-instrument --kind option_grant --symbol OPTION-PLAN --authorized-units <shares>\";\n case \"membership_unit\":\n case \"unit\":\n return \"Create one with: corp cap-table create-instrument --kind membership_unit --symbol UNIT --authorized-units <units>\";\n case \"common\":\n case \"common_stock\":\n return \"Create one with: corp cap-table create-instrument --kind common_equity --symbol COMMON --authorized-units <shares>\";\n default:\n return \"Create a matching instrument first, then pass --instrument-id explicitly.\";\n }\n}\n\nfunction resolveInstrumentForGrant(\n instruments: CapTableInstrument[],\n grantType: string,\n explicitInstrumentId?: string,\n): CapTableInstrument {\n if (explicitInstrumentId) {\n const explicit = instruments.find((instrument) => instrument.instrument_id === explicitInstrumentId);\n if (!explicit) {\n throw new Error(`Instrument ${explicitInstrumentId} was not found on the cap table.`);\n }\n return explicit;\n }\n\n const expectedKinds = expectedInstrumentKinds(grantType);\n if (expectedKinds.length === 0) {\n throw new Error(\n `No default instrument mapping exists for grant type \"${grantType}\". ${buildInstrumentCreationHint(grantType)}`,\n );\n }\n const match = instruments.find((instrument) => expectedKinds.includes(String(instrument.kind).toLowerCase()));\n if (!match) {\n throw new Error(\n `No instrument found for grant type \"${grantType}\". Expected one of: ${expectedKinds.join(\", \")}. ${buildInstrumentCreationHint(grantType)}`,\n );\n }\n return match;\n}\n\nasync function entityHasActiveBoard(client: CorpAPIClient, entityId: string): Promise<boolean> {\n const bodies = await client.listGovernanceBodies(entityId);\n return bodies.some((body) =>\n String(body.body_type ?? \"\").toLowerCase() === \"board_of_directors\"\n && String(body.status ?? \"active\").toLowerCase() === \"active\"\n );\n}\n\nasync function ensureIssuancePreflight(\n client: CorpAPIClient,\n entityId: string,\n grantType: string,\n instrument?: CapTableInstrument,\n meetingId?: string,\n resolutionId?: string,\n): Promise<void> {\n if (!meetingId || !resolutionId) {\n if (await entityHasActiveBoard(client, entityId)) {\n throw new Error(\n \"Board approval is required before issuing this round. Pass --meeting-id and --resolution-id from a passed board vote.\",\n );\n }\n }\n\n if (!grantRequiresCurrent409a(grantType, instrument?.kind)) {\n return;\n }\n\n try {\n await client.getCurrent409a(entityId);\n } catch (err) {\n const msg = String(err);\n if (msg.includes(\"404\")) {\n throw new Error(\n \"Stock option issuances require a current approved 409A valuation. Create and approve one first with: corp cap-table create-valuation --type four_oh_nine_a --date YYYY-MM-DD --methodology <method>; corp cap-table submit-valuation <id>; corp cap-table approve-valuation <id> --resolution-id <resolution-id>\",\n );\n }\n throw err;\n }\n}\n\nexport async function capTableCommand(opts: { entityId?: string; json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const data = await client.getCapTable(eid);\n if (opts.json) { printJson(data); return; }\n if ((data.access_level as string) === \"none\") {\n printError(\"You do not have access to this entity's cap table.\");\n process.exit(1);\n }\n printCapTable(data);\n try {\n const val = await client.getCurrent409a(eid);\n if (val) print409a(val);\n } catch { /* ignore */ }\n } catch (err) {\n printError(`Failed to fetch cap table: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function safesCommand(opts: { entityId?: string; json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const safes = await client.getSafeNotes(eid);\n if (opts.json) printJson(safes);\n else if (safes.length === 0) console.log(\"No SAFE notes found.\");\n else printSafesTable(safes);\n } catch (err) {\n printError(`Failed to fetch SAFE notes: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function transfersCommand(opts: { entityId?: string; json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const transfers = await client.getShareTransfers(eid);\n if (opts.json) printJson(transfers);\n else if (transfers.length === 0) console.log(\"No share transfers found.\");\n else printTransfersTable(transfers);\n } catch (err) {\n printError(`Failed to fetch transfers: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function valuationsCommand(opts: { entityId?: string; json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const valuations = await client.getValuations(eid);\n if (opts.json) printJson(valuations);\n else if (valuations.length === 0) console.log(\"No valuations found.\");\n else printValuationsTable(valuations);\n } catch (err) {\n printError(`Failed to fetch valuations: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function fourOhNineACommand(opts: { entityId?: string; json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const data = await client.getCurrent409a(eid);\n if (opts.json) printJson(data);\n else if (!data || Object.keys(data).length === 0) console.log(\"No 409A valuation found.\");\n else print409a(data);\n } catch (err) {\n const msg = String(err);\n if (msg.includes(\"404\")) {\n console.log(\"No 409A valuation found for this entity. Create one with:\\n corp cap-table create-valuation --type four_oh_nine_a --date YYYY-MM-DD --methodology <method>\");\n } else {\n printError(`Failed to fetch 409A valuation: ${err}`);\n }\n process.exit(1);\n }\n}\n\nexport async function issueEquityCommand(opts: {\n entityId?: string;\n grantType: string;\n shares: number;\n recipient: string;\n email?: string;\n instrumentId?: string;\n meetingId?: string;\n resolutionId?: string;\n json?: boolean;\n dryRun?: boolean;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n if (opts.dryRun) {\n printDryRun(\"cap_table.issue_equity\", {\n entity_id: eid,\n grant_type: opts.grantType,\n shares: opts.shares,\n recipient: opts.recipient,\n email: opts.email,\n instrument_id: opts.instrumentId,\n meeting_id: opts.meetingId,\n resolution_id: opts.resolutionId,\n });\n return;\n }\n\n // Fetch cap table to get issuer and instrument info\n const capTable = await client.getCapTable(eid);\n const issuerLegalEntityId = capTable.issuer_legal_entity_id as string;\n if (!issuerLegalEntityId) {\n printError(\"No issuer legal entity found. Has this entity been formed with a cap table?\");\n process.exit(1);\n }\n\n // Resolve instrument ID — use provided, or match by grant type, or use first common stock\n const instruments = (capTable.instruments ?? []) as CapTableInstrument[];\n if (!instruments.length) {\n printError(\"No instruments found on cap table. Create one with: corp cap-table create-instrument --kind common_equity --symbol COMMON --authorized-units <shares>\");\n process.exit(1);\n }\n const instrument = resolveInstrumentForGrant(instruments, opts.grantType, opts.instrumentId);\n const instrumentId = instrument.instrument_id;\n if (!opts.instrumentId) {\n console.log(`Using instrument: ${instrument.symbol} (${instrument.kind})`);\n }\n await ensureIssuancePreflight(\n client,\n eid,\n opts.grantType,\n instrument,\n opts.meetingId,\n opts.resolutionId,\n );\n\n // 1. Start a staged round\n const round = await client.startEquityRound({\n entity_id: eid,\n name: `${opts.grantType} grant — ${opts.recipient}`,\n issuer_legal_entity_id: issuerLegalEntityId,\n });\n const roundId = (round.round_id ?? round.equity_round_id) as string;\n\n // 2. Add the security\n const securityData: Record<string, unknown> = {\n entity_id: eid,\n instrument_id: instrumentId,\n quantity: opts.shares,\n recipient_name: opts.recipient,\n grant_type: opts.grantType,\n };\n if (opts.email) securityData.email = opts.email;\n await client.addRoundSecurity(roundId, securityData);\n\n // 3. Issue the round\n const issuePayload: Record<string, unknown> = { entity_id: eid };\n if (opts.meetingId) issuePayload.meeting_id = opts.meetingId;\n if (opts.resolutionId) issuePayload.resolution_id = opts.resolutionId;\n const result = await client.issueRound(roundId, issuePayload);\n\n if (opts.json) {\n printJson(result);\n return;\n }\n printSuccess(`Equity issued: ${opts.shares} shares (${opts.grantType}) to ${opts.recipient}`);\n printJson(result);\n } catch (err) {\n printError(`Failed to issue equity: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function issueSafeCommand(opts: {\n entityId?: string;\n investor: string;\n amount: number;\n safeType: string;\n valuationCap: number;\n email?: string;\n meetingId?: string;\n resolutionId?: string;\n json?: boolean;\n dryRun?: boolean;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n if (opts.dryRun) {\n printDryRun(\"cap_table.issue_safe\", {\n entity_id: eid,\n investor: opts.investor,\n amount: opts.amount,\n safe_type: opts.safeType,\n valuation_cap: opts.valuationCap,\n email: opts.email,\n meeting_id: opts.meetingId,\n resolution_id: opts.resolutionId,\n });\n return;\n }\n\n await ensureIssuancePreflight(\n client,\n eid,\n opts.safeType,\n undefined,\n opts.meetingId,\n opts.resolutionId,\n );\n\n const body: Record<string, unknown> = {\n entity_id: eid,\n investor_name: opts.investor,\n principal_amount_cents: opts.amount,\n valuation_cap_cents: opts.valuationCap,\n safe_type: opts.safeType,\n };\n if (opts.email) body.email = opts.email;\n if (opts.meetingId) body.meeting_id = opts.meetingId;\n if (opts.resolutionId) body.resolution_id = opts.resolutionId;\n const result = await client.createSafeNote(body);\n if (opts.json) {\n printJson(result);\n return;\n }\n printSuccess(`SAFE issued: $${(opts.amount / 100).toLocaleString()} to ${opts.investor}`);\n printJson(result);\n } catch (err) {\n printError(`Failed to issue SAFE: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function transferSharesCommand(opts: {\n entityId?: string;\n from: string;\n to: string;\n shares: number;\n type: string;\n shareClassId: string;\n governingDocType: string;\n transfereeRights: string;\n prepareIntentId?: string;\n pricePerShareCents?: number;\n relationship?: string;\n json?: boolean;\n dryRun?: boolean;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n if (opts.pricePerShareCents != null && opts.pricePerShareCents < 0) {\n throw new Error(\"price-per-share-cents cannot be negative\");\n }\n if (opts.from === opts.to) {\n throw new Error(\"--from and --to must be different contacts\");\n }\n if (opts.dryRun) {\n printDryRun(\"cap_table.transfer_shares\", {\n entity_id: eid,\n from_contact_id: opts.from,\n to_contact_id: opts.to,\n share_count: opts.shares,\n transfer_type: opts.type,\n share_class_id: opts.shareClassId,\n governing_doc_type: opts.governingDocType,\n transferee_rights: opts.transfereeRights,\n prepare_intent_id: opts.prepareIntentId,\n price_per_share_cents: opts.pricePerShareCents,\n relationship_to_holder: opts.relationship,\n });\n return;\n }\n\n let intentId = opts.prepareIntentId;\n if (!intentId) {\n const intent = await client.createExecutionIntent({\n entity_id: eid,\n intent_type: \"equity.transfer.prepare\",\n description: `Transfer ${opts.shares} shares from ${opts.from} to ${opts.to}`,\n });\n intentId = (intent.intent_id ?? intent.id) as string;\n await client.evaluateIntent(intentId, eid);\n await client.authorizeIntent(intentId, eid);\n }\n const body: Record<string, unknown> = {\n entity_id: eid,\n share_class_id: opts.shareClassId,\n from_contact_id: opts.from,\n to_contact_id: opts.to,\n transfer_type: opts.type,\n share_count: opts.shares,\n governing_doc_type: opts.governingDocType,\n transferee_rights: opts.transfereeRights,\n prepare_intent_id: intentId,\n };\n if (opts.pricePerShareCents != null) body.price_per_share_cents = opts.pricePerShareCents;\n if (opts.relationship) body.relationship_to_holder = opts.relationship;\n const result = await client.transferShares(body);\n printWriteResult(result, `Transfer workflow created: ${result.workflow_id ?? \"OK\"}`, opts.json);\n } catch (err) {\n printError(`Failed to create transfer workflow: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function distributeCommand(opts: {\n entityId?: string;\n amount: number;\n type: string;\n description: string;\n json?: boolean;\n dryRun?: boolean;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const payload = {\n entity_id: eid, total_amount_cents: opts.amount, distribution_type: opts.type,\n description: opts.description,\n };\n if (opts.dryRun) {\n printDryRun(\"cap_table.distribute\", payload);\n return;\n }\n const result = await client.calculateDistribution(payload);\n printWriteResult(result, `Distribution calculated: ${result.distribution_id ?? \"OK\"}`, opts.json);\n } catch (err) {\n printError(`Failed to calculate distribution: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function startRoundCommand(opts: {\n entityId?: string;\n name: string;\n issuerLegalEntityId: string;\n json?: boolean;\n dryRun?: boolean;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const payload = {\n entity_id: eid,\n name: opts.name,\n issuer_legal_entity_id: opts.issuerLegalEntityId,\n };\n if (opts.dryRun) {\n printDryRun(\"cap_table.start_round\", payload);\n return;\n }\n const result = await client.startEquityRound(payload);\n printWriteResult(result, `Round started: ${result.round_id ?? \"OK\"}`, opts.json);\n } catch (err) {\n printError(`Failed to start round: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function createInstrumentCommand(opts: {\n entityId?: string;\n issuerLegalEntityId?: string;\n kind: string;\n symbol: string;\n authorizedUnits?: number;\n issuePriceCents?: number;\n termsJson?: string;\n json?: boolean;\n dryRun?: boolean;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n let issuerLegalEntityId = opts.issuerLegalEntityId;\n if (!issuerLegalEntityId) {\n const capTable = await client.getCapTable(eid);\n issuerLegalEntityId = capTable.issuer_legal_entity_id as string | undefined;\n }\n if (!issuerLegalEntityId) {\n throw new Error(\"No issuer legal entity found. Has this entity been formed with a cap table?\");\n }\n\n const terms = opts.termsJson ? JSON.parse(opts.termsJson) as Record<string, unknown> : {};\n const payload: Record<string, unknown> = {\n entity_id: eid,\n issuer_legal_entity_id: issuerLegalEntityId,\n kind: opts.kind,\n symbol: opts.symbol,\n terms,\n };\n if (opts.authorizedUnits != null) payload.authorized_units = opts.authorizedUnits;\n if (opts.issuePriceCents != null) payload.issue_price_cents = opts.issuePriceCents;\n if (opts.dryRun) {\n printDryRun(\"cap_table.create_instrument\", payload);\n return;\n }\n const result = await client.createInstrument(payload);\n printWriteResult(result, `Instrument created: ${result.instrument_id ?? \"OK\"}`, opts.json);\n } catch (err) {\n printError(`Failed to create instrument: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function addSecurityCommand(opts: {\n entityId?: string;\n roundId: string;\n holderId?: string;\n email?: string;\n instrumentId: string;\n quantity: number;\n recipientName: string;\n principalCents?: number;\n grantType?: string;\n json?: boolean;\n dryRun?: boolean;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const body: Record<string, unknown> = {\n entity_id: eid,\n instrument_id: opts.instrumentId,\n quantity: opts.quantity,\n recipient_name: opts.recipientName,\n };\n if (opts.holderId) body.holder_id = opts.holderId;\n if (opts.email) body.email = opts.email;\n if (opts.principalCents) body.principal_cents = opts.principalCents;\n if (opts.grantType) body.grant_type = opts.grantType;\n if (opts.dryRun) {\n printDryRun(\"cap_table.add_security\", { round_id: opts.roundId, ...body });\n return;\n }\n const result = await client.addRoundSecurity(opts.roundId, body);\n printWriteResult(result, `Security added for ${opts.recipientName}`, opts.json);\n } catch (err) {\n printError(`Failed to add security: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function issueRoundCommand(opts: {\n entityId?: string;\n roundId: string;\n meetingId?: string;\n resolutionId?: string;\n json?: boolean;\n dryRun?: boolean;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n if (opts.dryRun) {\n printDryRun(\"cap_table.issue_round\", {\n entity_id: eid,\n round_id: opts.roundId,\n meeting_id: opts.meetingId,\n resolution_id: opts.resolutionId,\n });\n return;\n }\n if ((!opts.meetingId || !opts.resolutionId) && await entityHasActiveBoard(client, eid)) {\n throw new Error(\n \"Board approval is required before issuing this round. Pass --meeting-id and --resolution-id from a passed board vote.\",\n );\n }\n const body: Record<string, unknown> = { entity_id: eid };\n if (opts.meetingId) body.meeting_id = opts.meetingId;\n if (opts.resolutionId) body.resolution_id = opts.resolutionId;\n const result = await client.issueRound(opts.roundId, body);\n printWriteResult(result, \"Round issued and closed\", opts.json);\n } catch (err) {\n printError(`Failed to issue round: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function createValuationCommand(opts: {\n entityId?: string;\n type: string;\n date: string;\n methodology: string;\n fmv?: number;\n enterpriseValue?: number;\n json?: boolean;\n dryRun?: boolean;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const body: Record<string, unknown> = {\n entity_id: eid,\n valuation_type: opts.type,\n effective_date: opts.date,\n methodology: opts.methodology,\n };\n if (opts.fmv != null) body.fmv_per_share_cents = opts.fmv;\n if (opts.enterpriseValue != null) body.enterprise_value_cents = opts.enterpriseValue;\n if (opts.dryRun) {\n printDryRun(\"cap_table.create_valuation\", body);\n return;\n }\n const result = await client.createValuation(body);\n printWriteResult(result, `Valuation created: ${result.valuation_id ?? \"OK\"}`, opts.json);\n } catch (err) {\n printError(`Failed to create valuation: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function submitValuationCommand(opts: {\n entityId?: string;\n valuationId: string;\n json?: boolean;\n dryRun?: boolean;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n if (opts.dryRun) {\n printDryRun(\"cap_table.submit_valuation\", { entity_id: eid, valuation_id: opts.valuationId });\n return;\n }\n const result = await client.submitValuationForApproval(opts.valuationId, eid);\n if (opts.json) {\n printJson(result);\n return;\n }\n printSuccess(`Valuation submitted for approval: ${result.valuation_id ?? \"OK\"}`);\n if (result.meeting_id) console.log(` Meeting: ${result.meeting_id}`);\n if (result.agenda_item_id) console.log(` Agenda Item: ${result.agenda_item_id}`);\n printJson(result);\n } catch (err) {\n const msg = String(err);\n if (msg.includes(\"404\")) {\n printError(`Valuation not found. List valuations with: corp cap-table valuations`);\n } else {\n printError(`Failed to submit valuation: ${err}`);\n }\n process.exit(1);\n }\n}\n\nexport async function approveValuationCommand(opts: {\n entityId?: string;\n valuationId: string;\n resolutionId?: string;\n json?: boolean;\n dryRun?: boolean;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n if (opts.dryRun) {\n printDryRun(\"cap_table.approve_valuation\", {\n entity_id: eid,\n valuation_id: opts.valuationId,\n resolution_id: opts.resolutionId,\n });\n return;\n }\n const result = await client.approveValuation(opts.valuationId, eid, opts.resolutionId);\n printWriteResult(result, `Valuation approved: ${result.valuation_id ?? \"OK\"}`, opts.json);\n } catch (err) {\n const msg = String(err);\n if (msg.includes(\"400\")) {\n printError(`Bad request — a --resolution-id from a board vote may be required. Submit for approval first: corp cap-table submit-valuation <id>`);\n } else {\n printError(`Failed to approve valuation: ${err}`);\n }\n process.exit(1);\n }\n}\n\nfunction print409a(data: Record<string, unknown>): void {\n console.log(chalk.green(\"─\".repeat(40)));\n console.log(chalk.green.bold(\" 409A Valuation\"));\n console.log(chalk.green(\"─\".repeat(40)));\n const fmv = typeof data.fmv_per_share_cents === \"number\" ? (data.fmv_per_share_cents as number) / 100 : data.fmv_per_share;\n const enterpriseValue = typeof data.enterprise_value_cents === \"number\"\n ? (data.enterprise_value_cents as number) / 100\n : data.enterprise_value;\n console.log(` ${chalk.bold(\"FMV/Share:\")} $${fmv ?? \"N/A\"}`);\n console.log(` ${chalk.bold(\"Enterprise Value:\")} $${enterpriseValue ?? \"N/A\"}`);\n console.log(` ${chalk.bold(\"Valuation Date:\")} ${data.effective_date ?? data.valuation_date ?? \"N/A\"}`);\n if (data.provider) console.log(` ${chalk.bold(\"Provider:\")} ${data.provider}`);\n console.log(chalk.green(\"─\".repeat(40)));\n}\n","import { requireConfig, resolveEntityId } from \"../config.js\";\nimport { CorpAPIClient } from \"../api-client.js\";\nimport { printError, printWriteResult } from \"../output.js\";\n\nexport async function financeInvoiceCommand(opts: {\n entityId?: string; customer: string; amount: number; dueDate: string; description: string; json?: boolean;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.createInvoice({\n entity_id: eid, customer_name: opts.customer, amount_cents: opts.amount,\n due_date: opts.dueDate, description: opts.description,\n });\n printWriteResult(result, `Invoice created: ${result.invoice_id ?? \"OK\"}`, opts.json);\n } catch (err) { printError(`Failed to create invoice: ${err}`); process.exit(1); }\n}\n\nexport async function financePayrollCommand(opts: {\n entityId?: string; periodStart: string; periodEnd: string; json?: boolean;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.runPayroll({\n entity_id: eid, pay_period_start: opts.periodStart, pay_period_end: opts.periodEnd,\n });\n printWriteResult(result, `Payroll run created: ${result.payroll_run_id ?? \"OK\"}`, opts.json);\n } catch (err) { printError(`Failed to run payroll: ${err}`); process.exit(1); }\n}\n\nexport async function financePayCommand(opts: {\n entityId?: string; amount: number; recipient: string; method: string; json?: boolean;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.submitPayment({\n entity_id: eid, amount_cents: opts.amount, recipient: opts.recipient,\n payment_method: opts.method,\n description: `Payment via ${opts.method}`,\n });\n printWriteResult(result, `Payment submitted: ${result.payment_id ?? \"OK\"}`, opts.json);\n } catch (err) { printError(`Failed to submit payment: ${err}`); process.exit(1); }\n}\n\nexport async function financeOpenAccountCommand(opts: {\n entityId?: string; institution: string; json?: boolean;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.openBankAccount({ entity_id: eid, bank_name: opts.institution });\n printWriteResult(result, `Bank account opened: ${result.account_id ?? \"OK\"}`, opts.json);\n } catch (err) { printError(`Failed to open bank account: ${err}`); process.exit(1); }\n}\n\nexport async function financeClassifyContractorCommand(opts: {\n entityId?: string; name: string; state: string; hours: number;\n exclusive: boolean; duration: number; providesTools: boolean; json?: boolean;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.classifyContractor({\n entity_id: eid, contractor_name: opts.name, state: opts.state, hours_per_week: opts.hours,\n exclusive_client: opts.exclusive, duration_months: opts.duration, provides_tools: opts.providesTools,\n });\n printWriteResult(result, `Classification: ${result.risk_level ?? \"OK\"}`, opts.json);\n } catch (err) { printError(`Failed to classify contractor: ${err}`); process.exit(1); }\n}\n\nexport async function financeReconcileCommand(opts: {\n entityId?: string; startDate: string; endDate: string; json?: boolean;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.reconcileLedger({\n entity_id: eid, start_date: opts.startDate, end_date: opts.endDate,\n });\n printWriteResult(result, `Ledger reconciled: ${result.reconciliation_id ?? \"OK\"}`, opts.json);\n } catch (err) { printError(`Failed to reconcile ledger: ${err}`); process.exit(1); }\n}\n","import { requireConfig, resolveEntityId } from \"../config.js\";\nimport { CorpAPIClient } from \"../api-client.js\";\nimport {\n printGovernanceTable, printSeatsTable, printMeetingsTable,\n printResolutionsTable, printDryRun, printError, printSuccess, printJson,\n} from \"../output.js\";\nimport chalk from \"chalk\";\n\nexport async function governanceCreateBodyCommand(opts: {\n entityId?: string; name: string; bodyType: string; quorum: string; voting: string;\n json?: boolean; dryRun?: boolean;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const payload = {\n entity_id: eid,\n body_type: opts.bodyType,\n name: opts.name,\n quorum_rule: opts.quorum,\n voting_method: opts.voting,\n };\n if (opts.dryRun) {\n printDryRun(\"governance.create_body\", payload);\n return;\n }\n const result = await client.createGovernanceBody(payload);\n const bodyId = result.body_id ?? \"OK\";\n if (opts.json) {\n printJson(result);\n return;\n }\n printSuccess(`Governance body created: ${bodyId}`);\n printJson(result);\n console.log(chalk.dim(\"\\n Next steps:\"));\n console.log(chalk.dim(` corp governance add-seat ${bodyId} --holder <contact-id>`));\n console.log(chalk.dim(` corp governance seats ${bodyId}`));\n } catch (err) { printError(`Failed to create governance body: ${err}`); process.exit(1); }\n}\n\nexport async function governanceAddSeatCommand(bodyId: string, opts: {\n holder: string; role?: string; entityId?: string; json?: boolean; dryRun?: boolean;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const data: Record<string, unknown> = { holder_id: opts.holder, role: opts.role ?? \"member\" };\n if (opts.dryRun) {\n printDryRun(\"governance.add_seat\", { entity_id: eid, body_id: bodyId, ...data });\n return;\n }\n const result = await client.createGovernanceSeat(bodyId, eid, data);\n if (opts.json) {\n printJson(result);\n return;\n }\n printSuccess(`Seat added: ${result.seat_id ?? \"OK\"}`);\n printJson(result);\n } catch (err) { printError(`Failed to add seat: ${err}`); process.exit(1); }\n}\n\nexport async function governanceListCommand(opts: { entityId?: string; json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const bodies = await client.listGovernanceBodies(eid);\n if (opts.json) printJson(bodies);\n else if (bodies.length === 0) console.log(\"No governance bodies found.\");\n else printGovernanceTable(bodies);\n } catch (err) { printError(`Failed to fetch governance bodies: ${err}`); process.exit(1); }\n}\n\nexport async function governanceSeatsCommand(bodyId: string, opts: { entityId?: string; json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const seats = await client.getGovernanceSeats(bodyId, eid);\n if (opts.json) printJson(seats);\n else if (seats.length === 0) console.log(\"No seats found.\");\n else printSeatsTable(seats);\n } catch (err) { printError(`Failed to fetch seats: ${err}`); process.exit(1); }\n}\n\nexport async function governanceMeetingsCommand(bodyId: string, opts: { entityId?: string; json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const meetings = await client.listMeetings(bodyId, eid);\n if (opts.json) printJson(meetings);\n else if (meetings.length === 0) console.log(\"No meetings found.\");\n else printMeetingsTable(meetings);\n } catch (err) { printError(`Failed to fetch meetings: ${err}`); process.exit(1); }\n}\n\nexport async function governanceResolutionsCommand(meetingId: string, opts: { entityId?: string; json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const resolutions = await client.getMeetingResolutions(meetingId, eid);\n if (opts.json) printJson(resolutions);\n else if (resolutions.length === 0) console.log(\"No resolutions found.\");\n else printResolutionsTable(resolutions);\n } catch (err) { printError(`Failed to fetch resolutions: ${err}`); process.exit(1); }\n}\n\nexport async function governanceConveneCommand(opts: {\n entityId?: string; body: string; meetingType: string; title: string; date?: string; agenda: string[];\n json?: boolean; dryRun?: boolean;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const payload: Record<string, unknown> = {\n entity_id: eid, body_id: opts.body, meeting_type: opts.meetingType,\n title: opts.title,\n agenda_item_titles: opts.agenda,\n };\n if (opts.date) payload.scheduled_date = opts.date;\n if (opts.dryRun) {\n printDryRun(\"governance.schedule_meeting\", payload);\n return;\n }\n const result = await client.scheduleMeeting(payload);\n const meetingId = result.meeting_id ?? \"OK\";\n if (opts.json) {\n printJson(result);\n return;\n }\n printSuccess(`Meeting scheduled: ${meetingId}`);\n printJson(result);\n console.log(chalk.dim(\"\\n Next steps:\"));\n console.log(chalk.dim(` corp governance notice ${meetingId}`));\n console.log(chalk.dim(` corp governance open ${meetingId} --present-seat <seat-id>`));\n console.log(chalk.dim(` corp governance agenda-items ${meetingId}`));\n } catch (err) { printError(`Failed to schedule meeting: ${err}`); process.exit(1); }\n}\n\nexport async function governanceOpenMeetingCommand(\n meetingId: string,\n opts: { entityId?: string; presentSeat: string[]; json?: boolean; dryRun?: boolean },\n): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const payload = { present_seat_ids: opts.presentSeat };\n if (opts.dryRun) {\n printDryRun(\"governance.open_meeting\", { entity_id: eid, meeting_id: meetingId, ...payload });\n return;\n }\n const result = await client.conveneMeeting(meetingId, eid, payload);\n if (opts.json) {\n printJson(result);\n return;\n }\n printSuccess(`Meeting opened: ${meetingId}`);\n printJson(result);\n } catch (err) { printError(`Failed to open meeting: ${err}`); process.exit(1); }\n}\n\nexport async function governanceVoteCommand(\n meetingId: string,\n itemId: string,\n opts: { voter: string; vote: string; entityId?: string; json?: boolean; dryRun?: boolean }\n): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const payload = {\n voter_id: opts.voter, vote_value: opts.vote,\n };\n if (opts.dryRun) {\n printDryRun(\"governance.cast_vote\", { entity_id: eid, meeting_id: meetingId, agenda_item_id: itemId, ...payload });\n return;\n }\n const result = await client.castVote(eid, meetingId, itemId, payload);\n if (opts.json) {\n printJson(result);\n return;\n }\n printSuccess(`Vote cast: ${result.vote_id ?? \"OK\"}`);\n printJson(result);\n } catch (err) {\n const message = String(err);\n if (message.includes(\"voting session is not open\")) {\n printError(\n `Failed to cast vote: ${err}\\n` +\n ` Open the meeting first: corp governance open ${meetingId} --present-seat <seat-id>`,\n );\n } else {\n printError(`Failed to cast vote: ${err}`);\n }\n process.exit(1);\n }\n}\n\nexport async function sendNoticeCommand(\n meetingId: string,\n opts: { entityId?: string; json?: boolean; dryRun?: boolean },\n): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n if (opts.dryRun) {\n printDryRun(\"governance.send_notice\", { entity_id: eid, meeting_id: meetingId });\n return;\n }\n const result = await client.sendNotice(meetingId, eid);\n if (opts.json) {\n printJson(result);\n return;\n }\n printSuccess(`Notice sent for meeting ${meetingId}`);\n printJson(result);\n } catch (err) { printError(`Failed to send notice: ${err}`); process.exit(1); }\n}\n\nexport async function adjournMeetingCommand(\n meetingId: string,\n opts: { entityId?: string; json?: boolean; dryRun?: boolean },\n): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n if (opts.dryRun) {\n printDryRun(\"governance.adjourn_meeting\", { entity_id: eid, meeting_id: meetingId });\n return;\n }\n const result = await client.adjournMeeting(meetingId, eid);\n if (opts.json) {\n printJson(result);\n return;\n }\n printSuccess(`Meeting ${meetingId} adjourned`);\n printJson(result);\n } catch (err) { printError(`Failed to adjourn meeting: ${err}`); process.exit(1); }\n}\n\nexport async function cancelMeetingCommand(\n meetingId: string,\n opts: { entityId?: string; json?: boolean; dryRun?: boolean },\n): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n if (opts.dryRun) {\n printDryRun(\"governance.cancel_meeting\", { entity_id: eid, meeting_id: meetingId });\n return;\n }\n const result = await client.cancelMeeting(meetingId, eid);\n if (opts.json) {\n printJson(result);\n return;\n }\n printSuccess(`Meeting ${meetingId} cancelled`);\n printJson(result);\n } catch (err) { printError(`Failed to cancel meeting: ${err}`); process.exit(1); }\n}\n\nexport async function finalizeAgendaItemCommand(\n meetingId: string,\n itemId: string,\n opts: { status: string; entityId?: string; json?: boolean; dryRun?: boolean },\n): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const payload = {\n entity_id: eid, status: opts.status,\n };\n if (opts.dryRun) {\n printDryRun(\"governance.finalize_agenda_item\", { meeting_id: meetingId, agenda_item_id: itemId, ...payload });\n return;\n }\n const result = await client.finalizeAgendaItem(meetingId, itemId, payload);\n if (opts.json) {\n printJson(result);\n return;\n }\n printSuccess(`Agenda item ${itemId} finalized as ${opts.status}`);\n printJson(result);\n } catch (err) { printError(`Failed to finalize agenda item: ${err}`); process.exit(1); }\n}\n\nexport async function computeResolutionCommand(\n meetingId: string,\n itemId: string,\n opts: { text: string; entityId?: string; json?: boolean; dryRun?: boolean },\n): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const payload = {\n resolution_text: opts.text,\n };\n if (opts.dryRun) {\n printDryRun(\"governance.compute_resolution\", {\n entity_id: eid,\n meeting_id: meetingId,\n agenda_item_id: itemId,\n ...payload,\n });\n return;\n }\n const result = await client.computeResolution(meetingId, itemId, eid, payload);\n if (opts.json) {\n printJson(result);\n return;\n }\n printSuccess(`Resolution computed for agenda item ${itemId}`);\n printJson(result);\n } catch (err) { printError(`Failed to compute resolution: ${err}`); process.exit(1); }\n}\n\nexport async function writtenConsentCommand(opts: {\n body: string; title: string; description: string; entityId?: string; json?: boolean; dryRun?: boolean;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const payload = {\n entity_id: eid, body_id: opts.body, title: opts.title, description: opts.description,\n };\n if (opts.dryRun) {\n printDryRun(\"governance.written_consent\", payload);\n return;\n }\n const result = await client.writtenConsent(payload);\n const meetingId = result.meeting_id ?? \"OK\";\n if (opts.json) {\n printJson(result);\n return;\n }\n printSuccess(`Written consent created: ${meetingId}`);\n printJson(result);\n console.log(chalk.dim(\"\\n Next steps:\"));\n console.log(chalk.dim(` corp governance agenda-items ${meetingId}`));\n console.log(chalk.dim(` corp governance vote ${meetingId} <item-id> --voter <contact-uuid> --vote for`));\n } catch (err) { printError(`Failed to create written consent: ${err}`); process.exit(1); }\n}\n\nexport async function listAgendaItemsCommand(meetingId: string, opts: { entityId?: string; json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const items = await client.listAgendaItems(meetingId, eid);\n if (opts.json) printJson(items);\n else if (items.length === 0) console.log(\"No agenda items found.\");\n else {\n const Table = (await import(\"cli-table3\")).default;\n const chalk = (await import(\"chalk\")).default;\n console.log(`\\n${chalk.bold(\"Agenda Items\")}`);\n const table = new Table({ head: [chalk.dim(\"ID\"), chalk.dim(\"Title\"), chalk.dim(\"Status\"), chalk.dim(\"Type\")] });\n for (const item of items) {\n table.push([\n String(item.item_id ?? item.agenda_item_id ?? item.id ?? \"\").slice(0, 12),\n String(item.title ?? \"\"),\n String(item.status ?? \"\"),\n String(item.item_type ?? item.type ?? \"\"),\n ]);\n }\n console.log(table.toString());\n }\n } catch (err) { printError(`Failed to list agenda items: ${err}`); process.exit(1); }\n}\n","import { requireConfig, resolveEntityId } from \"../config.js\";\nimport { CorpAPIClient } from \"../api-client.js\";\nimport { printDocumentsTable, printError, printSuccess, printJson, printWriteResult } from \"../output.js\";\n\nconst HUMANS_APP_ORIGIN = \"https://humans.thecorporation.ai\";\n\nfunction formatSigningLink(docId: string, result: { token?: unknown; signing_url?: unknown }): string {\n if (typeof result.token === \"string\" && result.token.length > 0) {\n return `${HUMANS_APP_ORIGIN}/sign/${docId}?token=${encodeURIComponent(result.token)}`;\n }\n if (typeof result.signing_url === \"string\" && result.signing_url.length > 0) {\n if (/^https?:\\/\\//.test(result.signing_url)) {\n return result.signing_url;\n }\n const normalizedPath = result.signing_url.startsWith(\"/human/sign/\")\n ? result.signing_url.replace(\"/human/sign/\", \"/sign/\")\n : result.signing_url;\n return `${HUMANS_APP_ORIGIN}${normalizedPath.startsWith(\"/\") ? normalizedPath : `/${normalizedPath}`}`;\n }\n return `${HUMANS_APP_ORIGIN}/sign/${docId}`;\n}\n\nexport async function documentsListCommand(opts: { entityId?: string; json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const docs = await client.getEntityDocuments(eid);\n if (opts.json) printJson(docs);\n else if (docs.length === 0) console.log(\"No documents found.\");\n else printDocumentsTable(docs);\n } catch (err) { printError(`Failed to fetch documents: ${err}`); process.exit(1); }\n}\n\nexport async function documentsSigningLinkCommand(docId: string, opts: { entityId?: string }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.getSigningLink(docId, eid);\n const shareUrl = formatSigningLink(docId, result);\n if (process.stdout.isTTY) {\n printSuccess(\"Signing link generated.\");\n }\n console.log(shareUrl);\n } catch (err) { printError(`Failed to get signing link: ${err}`); process.exit(1); }\n}\n\nexport async function documentsGenerateCommand(opts: {\n entityId?: string;\n template: string;\n counterparty: string;\n effectiveDate?: string;\n baseSalary?: string;\n param?: string[];\n json?: boolean;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const parameters: Record<string, unknown> = {};\n if (opts.baseSalary) {\n parameters.base_salary = opts.baseSalary;\n }\n for (const raw of opts.param ?? []) {\n const idx = raw.indexOf(\"=\");\n if (idx <= 0) {\n throw new Error(`Invalid --param value: ${raw}. Expected key=value.`);\n }\n const key = raw.slice(0, idx).trim();\n const value = raw.slice(idx + 1).trim();\n if (!key) {\n throw new Error(`Invalid --param value: ${raw}. Expected key=value.`);\n }\n parameters[key] = coerceParamValue(value);\n }\n\n const result = await client.generateContract({\n entity_id: eid,\n template_type: opts.template,\n counterparty_name: opts.counterparty,\n effective_date: opts.effectiveDate ?? new Date().toISOString().slice(0, 10),\n parameters,\n });\n printWriteResult(result, `Contract generated: ${result.contract_id ?? \"OK\"}`, opts.json);\n } catch (err) { printError(`Failed to generate contract: ${err}`); process.exit(1); }\n}\n\nfunction coerceParamValue(raw: string): unknown {\n if (raw === \"true\") return true;\n if (raw === \"false\") return false;\n if (/^-?\\d+(\\.\\d+)?$/.test(raw)) return Number(raw);\n if ((raw.startsWith(\"{\") && raw.endsWith(\"}\")) || (raw.startsWith(\"[\") && raw.endsWith(\"]\"))) {\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n return raw;\n}\n\nexport async function documentsPreviewPdfCommand(opts: {\n entityId?: string; documentId: string;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n await client.validatePreviewPdf(eid, opts.documentId);\n const url = client.getPreviewPdfUrl(eid, opts.documentId);\n printSuccess(`Preview PDF URL: ${url}`);\n console.log(\"The document definition was validated successfully. Use your API key to download the PDF.\");\n } catch (err) {\n printError(`Failed to validate preview PDF: ${err}`);\n process.exit(1);\n }\n}\n","import { requireConfig, resolveEntityId } from \"../config.js\";\nimport { CorpAPIClient } from \"../api-client.js\";\nimport { printError, printWriteResult } from \"../output.js\";\n\nfunction normalizeRecurrence(recurrence?: string): string | undefined {\n if (!recurrence) return undefined;\n if (recurrence === \"yearly\") return \"annual\";\n return recurrence;\n}\n\nexport async function taxFileCommand(opts: {\n entityId?: string;\n type: string;\n year: number;\n json?: boolean;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.fileTaxDocument({ entity_id: eid, document_type: opts.type, tax_year: opts.year });\n printWriteResult(result, `Tax document filed: ${result.filing_id ?? \"OK\"}`, opts.json);\n } catch (err) { printError(`Failed to file tax document: ${err}`); process.exit(1); }\n}\n\nexport async function taxDeadlineCommand(opts: {\n entityId?: string;\n type: string;\n dueDate: string;\n description: string;\n recurrence?: string;\n json?: boolean;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const payload: Record<string, unknown> = {\n entity_id: eid, deadline_type: opts.type, due_date: opts.dueDate,\n description: opts.description,\n };\n const recurrence = normalizeRecurrence(opts.recurrence);\n if (recurrence) payload.recurrence = recurrence;\n const result = await client.trackDeadline(payload);\n printWriteResult(result, `Deadline tracked: ${result.deadline_id ?? \"OK\"}`, opts.json);\n } catch (err) { printError(`Failed to track deadline: ${err}`); process.exit(1); }\n}\n","import { requireConfig } from \"../config.js\";\nimport { CorpAPIClient } from \"../api-client.js\";\nimport { printAgentsTable, printError, printJson, printWriteResult } from \"../output.js\";\nimport chalk from \"chalk\";\nimport type { ApiRecord } from \"../types.js\";\nimport { readFileSync, realpathSync } from \"node:fs\";\nimport { relative, resolve } from \"node:path\";\n\nexport async function agentsListCommand(opts: { json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const agents = await client.listAgents();\n if (opts.json) printJson(agents);\n else if (agents.length === 0) console.log(\"No agents found.\");\n else printAgentsTable(agents);\n } catch (err) { printError(`Failed to fetch agents: ${err}`); process.exit(1); }\n}\n\nexport async function agentsShowCommand(agentId: string, opts: { json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const agent = await client.getAgent(agentId);\n if (opts.json) { printJson(agent); return; }\n console.log(chalk.magenta(\"─\".repeat(40)));\n console.log(chalk.magenta.bold(\" Agent Detail\"));\n console.log(chalk.magenta(\"─\".repeat(40)));\n console.log(` ${chalk.bold(\"Name:\")} ${agent.name ?? \"N/A\"}`);\n console.log(` ${chalk.bold(\"Status:\")} ${agent.status ?? \"N/A\"}`);\n console.log(` ${chalk.bold(\"Model:\")} ${agent.model ?? \"N/A\"}`);\n console.log(` ${chalk.bold(\"ID:\")} ${agent.agent_id ?? \"N/A\"}`);\n if (agent.system_prompt) {\n let prompt = String(agent.system_prompt);\n if (prompt.length > 100) prompt = prompt.slice(0, 97) + \"...\";\n console.log(` ${chalk.bold(\"Prompt:\")} ${prompt}`);\n }\n if (agent.skills && Array.isArray(agent.skills) && agent.skills.length > 0) {\n console.log(` ${chalk.bold(\"Skills:\")} ${(agent.skills as Array<{name?: string}>).map((s) => s.name ?? \"?\").join(\", \")}`);\n }\n console.log(chalk.magenta(\"─\".repeat(40)));\n } catch (err) { printError(`Failed to fetch agent: ${err}`); process.exit(1); }\n}\n\nexport async function agentsCreateCommand(opts: {\n name: string;\n prompt: string;\n model?: string;\n json?: boolean;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const data: ApiRecord = { name: opts.name, system_prompt: opts.prompt };\n if (opts.model) data.model = opts.model;\n const result = await client.createAgent(data);\n printWriteResult(result, `Agent created: ${result.agent_id ?? result.id ?? \"OK\"}`, opts.json);\n } catch (err) { printError(`Failed to create agent: ${err}`); process.exit(1); }\n}\n\nexport async function agentsPauseCommand(agentId: string, opts: { json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.updateAgent(agentId, { status: \"paused\" });\n printWriteResult(result, `Agent ${agentId} paused.`, opts.json);\n } catch (err) { printError(`Failed to pause agent: ${err}`); process.exit(1); }\n}\n\nexport async function agentsResumeCommand(agentId: string, opts: { json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.updateAgent(agentId, { status: \"active\" });\n printWriteResult(result, `Agent ${agentId} resumed.`, opts.json);\n } catch (err) { printError(`Failed to resume agent: ${err}`); process.exit(1); }\n}\n\nexport async function agentsDeleteCommand(agentId: string, opts: { json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.deleteAgent(agentId);\n printWriteResult(result, `Agent ${agentId} deleted.`, opts.json);\n } catch (err) { printError(`Failed to delete agent: ${err}`); process.exit(1); }\n}\n\nfunction resolveTextInput(\n inlineText: string | undefined,\n filePath: string | undefined,\n label: string,\n required = false,\n): string | undefined {\n if (inlineText && filePath) {\n throw new Error(`Pass either --${label} or --${label}-file, not both.`);\n }\n if (filePath) {\n if (process.env.CORP_ALLOW_UNSAFE_FILE_INPUT === \"1\") {\n return readFileSync(filePath, \"utf8\");\n }\n const resolvedFile = realpathSync(resolve(filePath));\n const workingTreeRoot = realpathSync(process.cwd());\n const rel = relative(workingTreeRoot, resolvedFile);\n if (rel === \"\" || (!rel.startsWith(\"..\") && !rel.startsWith(\"/\"))) {\n return readFileSync(resolvedFile, \"utf8\");\n }\n throw new Error(\n `--${label}-file must stay inside the current working directory unless CORP_ALLOW_UNSAFE_FILE_INPUT=1 is set.`,\n );\n }\n if (inlineText) {\n return inlineText;\n }\n if (required) {\n throw new Error(`Provide --${label} or --${label}-file.`);\n }\n return undefined;\n}\n\nexport async function agentsMessageCommand(\n agentId: string,\n opts: { body?: string; bodyFile?: string; json?: boolean },\n): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const body = resolveTextInput(opts.body, opts.bodyFile, \"body\", true);\n const result = await client.sendAgentMessage(agentId, body!);\n printWriteResult(result, `Message sent. Execution: ${result.execution_id ?? \"OK\"}`, opts.json);\n } catch (err) { printError(`Failed to send message: ${err}`); process.exit(1); }\n}\n\nexport async function agentsExecutionsCommand(agentId: string, _opts: { json?: boolean }): Promise<void> {\n // No list-executions endpoint exists yet; individual executions can be\n // queried via GET /v1/agents/{agent_id}/executions/{execution_id}.\n printError(\n `Listing executions is not yet supported.\\n` +\n ` To inspect a specific run, use the execution ID returned by \"agents message\":\\n` +\n ` GET /v1/agents/${agentId}/executions/<execution-id>`,\n );\n process.exit(1);\n}\n\n\nexport async function agentsSkillCommand(agentId: string, opts: {\n name: string;\n description: string;\n instructions?: string;\n instructionsFile?: string;\n json?: boolean;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const instructions = resolveTextInput(\n opts.instructions,\n opts.instructionsFile,\n \"instructions\",\n );\n const result = await client.addAgentSkill(agentId, {\n name: opts.name,\n description: opts.description,\n parameters: instructions ? { instructions } : {},\n });\n printWriteResult(result, `Skill '${opts.name}' added to agent ${agentId}.`, opts.json);\n } catch (err) { printError(`Failed to add skill: ${err}`); process.exit(1); }\n}\n","import { requireConfig, resolveEntityId } from \"../config.js\";\nimport { CorpAPIClient } from \"../api-client.js\";\nimport { printWorkItemsTable, printError, printJson, printWriteResult } from \"../output.js\";\nimport chalk from \"chalk\";\n\nexport async function workItemsListCommand(opts: { entityId?: string; json?: boolean; status?: string; category?: string }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const params: Record<string, string> = {};\n if (opts.status) params.status = opts.status;\n if (opts.category) params.category = opts.category;\n const items = await client.listWorkItems(eid, Object.keys(params).length > 0 ? params : undefined);\n if (opts.json) printJson(items);\n else if (items.length === 0) console.log(\"No work items found.\");\n else printWorkItemsTable(items);\n } catch (err) { printError(`Failed to fetch work items: ${err}`); process.exit(1); }\n}\n\nexport async function workItemsShowCommand(workItemId: string, opts: { entityId?: string; json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const w = await client.getWorkItem(eid, workItemId);\n if (opts.json) { printJson(w); return; }\n console.log(chalk.cyan(\"─\".repeat(40)));\n console.log(chalk.cyan.bold(\" Work Item Detail\"));\n console.log(chalk.cyan(\"─\".repeat(40)));\n console.log(` ${chalk.bold(\"Title:\")} ${w.title ?? \"N/A\"}`);\n console.log(` ${chalk.bold(\"Category:\")} ${w.category ?? \"N/A\"}`);\n console.log(` ${chalk.bold(\"Status:\")} ${w.effective_status ?? w.status ?? \"N/A\"}`);\n if (w.description) console.log(` ${chalk.bold(\"Description:\")} ${w.description}`);\n if (w.deadline) console.log(` ${chalk.bold(\"Deadline:\")} ${w.deadline}`);\n if (w.asap) console.log(` ${chalk.bold(\"Priority:\")} ${chalk.red.bold(\"ASAP\")}`);\n if (w.claimed_by) console.log(` ${chalk.bold(\"Claimed by:\")} ${w.claimed_by}`);\n if (w.claimed_at) console.log(` ${chalk.bold(\"Claimed at:\")} ${w.claimed_at}`);\n if (w.claim_ttl_seconds) console.log(` ${chalk.bold(\"Claim TTL:\")} ${w.claim_ttl_seconds}s`);\n if (w.completed_by) console.log(` ${chalk.bold(\"Completed by:\")} ${w.completed_by}`);\n if (w.completed_at) console.log(` ${chalk.bold(\"Completed at:\")} ${w.completed_at}`);\n if (w.result) console.log(` ${chalk.bold(\"Result:\")} ${w.result}`);\n if (w.created_by) console.log(` ${chalk.bold(\"Created by:\")} ${w.created_by}`);\n console.log(` ${chalk.bold(\"Created at:\")} ${w.created_at ?? \"N/A\"}`);\n console.log(chalk.cyan(\"─\".repeat(40)));\n } catch (err) { printError(`Failed to fetch work item: ${err}`); process.exit(1); }\n}\n\nexport async function workItemsCreateCommand(opts: {\n entityId?: string; title: string; category?: string;\n description?: string; deadline?: string; asap?: boolean; createdBy?: string; json?: boolean;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n if (!opts.category) {\n printError(\"Missing required option: --category <category>\");\n process.exit(1);\n }\n const data: Record<string, unknown> = { title: opts.title, category: opts.category };\n if (opts.description) data.description = opts.description;\n if (opts.deadline) data.deadline = opts.deadline;\n if (opts.asap) data.asap = true;\n if (opts.createdBy) data.created_by = opts.createdBy;\n const result = await client.createWorkItem(eid, data);\n printWriteResult(\n result,\n `Work item created: ${result.work_item_id ?? result.id ?? \"OK\"}`,\n opts.json,\n );\n } catch (err) { printError(`Failed to create work item: ${err}`); process.exit(1); }\n}\n\nexport async function workItemsClaimCommand(workItemId: string, opts: {\n entityId?: string; claimedBy: string; ttl?: number; json?: boolean;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const data: Record<string, unknown> = { claimed_by: opts.claimedBy };\n if (opts.ttl != null) data.ttl_seconds = opts.ttl;\n const result = await client.claimWorkItem(eid, workItemId, data);\n printWriteResult(result, `Work item ${workItemId} claimed by ${opts.claimedBy}.`, opts.json);\n } catch (err) { printError(`Failed to claim work item: ${err}`); process.exit(1); }\n}\n\nexport async function workItemsCompleteCommand(workItemId: string, opts: {\n entityId?: string; completedBy: string; result?: string; json?: boolean;\n}): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const data: Record<string, unknown> = { completed_by: opts.completedBy };\n if (opts.result) data.result = opts.result;\n const result = await client.completeWorkItem(eid, workItemId, data);\n printWriteResult(result, `Work item ${workItemId} completed.`, opts.json);\n } catch (err) { printError(`Failed to complete work item: ${err}`); process.exit(1); }\n}\n\nexport async function workItemsReleaseCommand(workItemId: string, opts: { entityId?: string; json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.releaseWorkItem(eid, workItemId);\n printWriteResult(result, `Work item ${workItemId} claim released.`, opts.json);\n } catch (err) { printError(`Failed to release work item: ${err}`); process.exit(1); }\n}\n\nexport async function workItemsCancelCommand(workItemId: string, opts: { entityId?: string; json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const eid = resolveEntityId(cfg, opts.entityId);\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.cancelWorkItem(eid, workItemId);\n printWriteResult(result, `Work item ${workItemId} cancelled.`, opts.json);\n } catch (err) { printError(`Failed to cancel work item: ${err}`); process.exit(1); }\n}\n","import { requireConfig } from \"../config.js\";\nimport { CorpAPIClient } from \"../api-client.js\";\nimport { printBillingPanel, printError, printSuccess, printJson } from \"../output.js\";\nimport type { ApiRecord } from \"../types.js\";\n\nfunction makeClient() {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n return new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n}\n\nfunction enrichBillingStatus(status: ApiRecord): ApiRecord {\n if (typeof status.status_explanation === \"string\" && status.status_explanation.trim()) {\n return status;\n }\n\n const plan = String(status.plan ?? status.tier ?? \"\").trim();\n const subStatus = String(status.status ?? \"\").trim();\n if (subStatus !== \"pending_checkout\") {\n return status;\n }\n\n const statusExplanation = plan\n ? `Checkout for the ${plan} plan has started, but billing will not become active until Stripe checkout is completed.`\n : \"Checkout has started, but billing will not become active until Stripe checkout is completed.\";\n\n return { ...status, status_explanation: statusExplanation };\n}\n\nexport async function billingCommand(opts: { json?: boolean }): Promise<void> {\n const client = makeClient();\n try {\n const [status, plans] = await Promise.all([client.getBillingStatus(), client.getBillingPlans()]);\n const enrichedStatus = enrichBillingStatus(status);\n if (opts.json) printJson({ status: enrichedStatus, plans });\n else printBillingPanel(enrichedStatus, plans);\n } catch (err) { printError(`Failed to fetch billing info: ${err}`); process.exit(1); }\n}\n\nexport async function billingPortalCommand(): Promise<void> {\n const client = makeClient();\n try {\n const result = await client.createBillingPortal();\n const url = result.portal_url as string;\n if (!url) { printError(\"No portal URL returned. Ensure you have an active subscription.\"); process.exit(1); }\n printSuccess(\"Stripe Customer Portal URL:\");\n console.log(url);\n } catch (err) { printError(`Failed to create portal session: ${err}`); process.exit(1); }\n}\n\nexport async function billingUpgradeCommand(opts: { plan: string }): Promise<void> {\n const client = makeClient();\n try {\n const result = await client.createBillingCheckout(opts.plan);\n const url = result.checkout_url as string;\n if (!url) { printError(\"No checkout URL returned.\"); process.exit(1); }\n printSuccess(`Stripe Checkout URL for ${opts.plan}:`);\n console.log(url);\n } catch (err) { printError(`Failed to create checkout session: ${err}`); process.exit(1); }\n}\n","import { input, select, confirm, number } from \"@inquirer/prompts\";\nimport chalk from \"chalk\";\nimport Table from \"cli-table3\";\nimport { readFileSync } from \"node:fs\";\nimport { requireConfig } from \"../config.js\";\nimport { CorpAPIClient } from \"../api-client.js\";\nimport { printDryRun, printError, printJson, printSuccess } from \"../output.js\";\nimport type { ApiRecord } from \"../types.js\";\nimport { EntityType, OfficerTitle } from \"@thecorporation/corp-tools\";\n\n// ── Types ──────────────────────────────────────────────────────\n\ninterface FounderInfo {\n name: string;\n email: string;\n role: string;\n address?: { street: string; street2?: string; city: string; state: string; zip: string };\n officer_title?: string;\n is_incorporator?: boolean;\n shares_purchased?: number;\n ownership_pct?: number;\n vesting?: { total_months: number; cliff_months: number; acceleration?: string };\n ip_description?: string;\n}\n\ninterface FormOptions {\n type?: string;\n name?: string;\n jurisdiction?: string;\n member?: string[];\n memberJson?: string[];\n membersFile?: string;\n fiscalYearEnd?: string;\n sCorp?: boolean;\n transferRestrictions?: boolean;\n rofr?: boolean;\n address?: string;\n json?: boolean;\n dryRun?: boolean;\n}\n\n// ── Helpers ────────────────────────────────────────────────────\n\nfunction isCorp(entityType: string): boolean {\n return entityType === \"c_corp\" || entityType === \"s_corp\" || entityType === \"corporation\";\n}\n\nfunction sectionHeader(title: string): void {\n console.log();\n console.log(chalk.blue(\"─\".repeat(50)));\n console.log(chalk.blue.bold(` ${title}`));\n console.log(chalk.blue(\"─\".repeat(50)));\n}\n\nfunction officerTitleLabel(title: string): string {\n switch (title) {\n case \"ceo\":\n return \"CEO\";\n case \"cfo\":\n return \"CFO\";\n case \"cto\":\n return \"CTO\";\n case \"coo\":\n return \"COO\";\n case \"vp\":\n return \"VP\";\n default:\n return title.charAt(0).toUpperCase() + title.slice(1);\n }\n}\n\nfunction parseBoolean(value: unknown): boolean | undefined {\n if (typeof value === \"boolean\") return value;\n if (typeof value !== \"string\") return undefined;\n if (value === \"true\") return true;\n if (value === \"false\") return false;\n return undefined;\n}\n\nfunction parseAddressValue(raw: unknown): FounderInfo[\"address\"] {\n if (!raw) return undefined;\n if (typeof raw === \"string\") {\n const parts = raw.split(\"|\").map((part) => part.trim());\n if (parts.length === 4) {\n return { street: parts[0], city: parts[1], state: parts[2], zip: parts[3] };\n }\n throw new Error(`Invalid founder address: ${raw}. Expected street|city|state|zip.`);\n }\n if (typeof raw === \"object\" && raw !== null) {\n const value = raw as Record<string, unknown>;\n if (\n typeof value.street === \"string\" &&\n typeof value.city === \"string\" &&\n typeof value.state === \"string\" &&\n typeof value.zip === \"string\"\n ) {\n return {\n street: value.street,\n street2: typeof value.street2 === \"string\" ? value.street2 : undefined,\n city: value.city,\n state: value.state,\n zip: value.zip,\n };\n }\n }\n throw new Error(\"Founder address must be an object or street|city|state|zip string.\");\n}\n\nfunction normalizeFounderInfo(input: Record<string, unknown>): FounderInfo {\n const name = typeof input.name === \"string\" ? input.name.trim() : \"\";\n const email = typeof input.email === \"string\" ? input.email.trim() : \"\";\n const role = typeof input.role === \"string\" ? input.role.trim() : \"\";\n if (!name || !email || !role) {\n throw new Error(\"Founder JSON requires non-empty name, email, and role.\");\n }\n\n const founder: FounderInfo = { name, email, role };\n const ownershipPct = input.ownership_pct ?? input.pct;\n if (ownershipPct != null) founder.ownership_pct = Number(ownershipPct);\n const sharesPurchased = input.shares_purchased ?? input.shares;\n if (sharesPurchased != null) founder.shares_purchased = Number(sharesPurchased);\n if (typeof input.officer_title === \"string\") founder.officer_title = input.officer_title;\n const incorporator = parseBoolean(input.is_incorporator ?? input.incorporator);\n if (incorporator !== undefined) founder.is_incorporator = incorporator;\n if (input.address != null) founder.address = parseAddressValue(input.address);\n if (typeof input.ip_description === \"string\") founder.ip_description = input.ip_description;\n if (input.vesting && typeof input.vesting === \"object\") {\n const vesting = input.vesting as Record<string, unknown>;\n if (vesting.total_months != null && vesting.cliff_months != null) {\n founder.vesting = {\n total_months: Number(vesting.total_months),\n cliff_months: Number(vesting.cliff_months),\n acceleration:\n typeof vesting.acceleration === \"string\" ? vesting.acceleration : undefined,\n };\n }\n }\n return founder;\n}\n\nfunction parseLegacyMemberSpec(raw: string): FounderInfo {\n const parts = raw.split(\",\").map((p) => p.trim());\n if (parts.length < 3) {\n throw new Error(\n `Invalid member format: ${raw}. Expected: name,email,role[,pct[,address[,officer_title[,is_incorporator]]]]`,\n );\n }\n const founder: FounderInfo = { name: parts[0], email: parts[1], role: parts[2] };\n if (parts.length >= 4) founder.ownership_pct = parseFloat(parts[3]);\n if (parts.length >= 5 && parts[4]) founder.address = parseAddressValue(parts[4]);\n if (parts.length >= 6 && parts[5]) founder.officer_title = parts[5];\n if (parts.length >= 7) {\n const incorporator = parseBoolean(parts[6]);\n if (incorporator !== undefined) founder.is_incorporator = incorporator;\n }\n return founder;\n}\n\nfunction parseKeyValueMemberSpec(raw: string): FounderInfo {\n const parsed: Record<string, unknown> = {};\n for (const segment of raw.split(\",\")) {\n const [key, ...rest] = segment.split(\"=\");\n if (!key || rest.length === 0) {\n throw new Error(`Invalid member format: ${raw}. Expected key=value pairs.`);\n }\n parsed[key.trim()] = rest.join(\"=\").trim();\n }\n return normalizeFounderInfo(parsed);\n}\n\nfunction parseScriptedFounders(opts: FormOptions): FounderInfo[] {\n const founders: FounderInfo[] = [];\n for (const raw of opts.member ?? []) {\n founders.push(raw.includes(\"=\") ? parseKeyValueMemberSpec(raw) : parseLegacyMemberSpec(raw));\n }\n for (const raw of opts.memberJson ?? []) {\n founders.push(normalizeFounderInfo(JSON.parse(raw) as Record<string, unknown>));\n }\n if (opts.membersFile) {\n const parsed = JSON.parse(readFileSync(opts.membersFile, \"utf8\")) as unknown;\n let entries: unknown[];\n if (Array.isArray(parsed)) {\n entries = parsed;\n } else if (\n typeof parsed === \"object\" &&\n parsed !== null &&\n \"members\" in parsed &&\n Array.isArray((parsed as { members?: unknown }).members)\n ) {\n entries = (parsed as { members: unknown[] }).members;\n } else {\n throw new Error(\"members file must be a JSON array or {\\\"members\\\": [...]}\");\n }\n for (const entry of entries) {\n if (typeof entry !== \"object\" || entry === null || Array.isArray(entry)) {\n throw new Error(\"each founder entry must be a JSON object\");\n }\n founders.push(normalizeFounderInfo(entry as Record<string, unknown>));\n }\n }\n return founders;\n}\n\nasync function promptAddress(): Promise<{ street: string; city: string; state: string; zip: string }> {\n const street = await input({ message: \" Street address\" });\n const city = await input({ message: \" City\" });\n const state = await input({ message: \" State (2-letter)\", default: \"DE\" });\n const zip = await input({ message: \" ZIP code\" });\n return { street, city, state, zip };\n}\n\n// ── Phase 1: Entity Details ────────────────────────────────────\n\nasync function phaseEntityDetails(opts: FormOptions, serverCfg: ApiRecord, scripted: boolean) {\n if (!scripted) sectionHeader(\"Phase 1: Entity Details\");\n\n let entityType = opts.type;\n if (!entityType) {\n if (scripted) { entityType = \"llc\"; }\n else {\n entityType = await select({\n message: \"Entity type\",\n choices: [\n { value: \"llc\", name: \"LLC\" },\n { value: \"c_corp\", name: \"C-Corp\" },\n ],\n });\n }\n }\n\n let name = opts.name;\n if (!name) {\n if (scripted) { printError(\"--name is required in scripted mode\"); process.exit(1); }\n name = await input({ message: \"Legal name\" });\n }\n\n let jurisdiction = opts.jurisdiction;\n if (!jurisdiction) {\n const defaultJ = entityType === \"llc\" ? \"US-WY\" : \"US-DE\";\n if (scripted) { jurisdiction = defaultJ; }\n else { jurisdiction = await input({ message: \"Jurisdiction\", default: defaultJ }); }\n }\n\n let companyAddress: { street: string; city: string; state: string; zip: string } | undefined;\n if (opts.address) {\n const parts = opts.address.split(\",\").map((p) => p.trim());\n if (parts.length === 4) {\n companyAddress = { street: parts[0], city: parts[1], state: parts[2], zip: parts[3] };\n }\n }\n if (!companyAddress && !scripted) {\n const wantAddress = await confirm({ message: \"Add company address?\", default: false });\n if (wantAddress) {\n companyAddress = await promptAddress();\n }\n }\n\n const fiscalYearEnd = opts.fiscalYearEnd ?? \"12-31\";\n\n let sCorpElection = opts.sCorp ?? false;\n if (!scripted && isCorp(entityType) && opts.sCorp === undefined) {\n sCorpElection = await confirm({ message: \"S-Corp election?\", default: false });\n }\n\n return { entityType, name, jurisdiction, companyAddress, fiscalYearEnd, sCorpElection };\n}\n\n// ── Phase 2: People ────────────────────────────────────────────\n\nasync function phasePeople(\n opts: FormOptions,\n entityType: string,\n scripted: boolean,\n): Promise<FounderInfo[]> {\n if (!scripted) sectionHeader(\"Phase 2: Founders & Officers\");\n\n const founders: FounderInfo[] = [];\n\n // CLI-provided members (scripted mode)\n if (scripted) {\n try {\n return parseScriptedFounders(opts);\n } catch (err) {\n printError(String(err));\n process.exit(1);\n }\n }\n\n // Interactive mode\n const founderCount = (await number({ message: \"Number of founders (1-6)\", default: 1 })) ?? 1;\n\n for (let i = 0; i < founderCount; i++) {\n console.log(chalk.dim(`\\n Founder ${i + 1} of ${founderCount}:`));\n const name = await input({ message: ` Name` });\n const email = await input({ message: ` Email` });\n\n let role = \"member\";\n if (isCorp(entityType)) {\n role = await select({\n message: \" Role\",\n choices: [\n { value: \"director\", name: \"Director\" },\n { value: \"officer\", name: \"Officer\" },\n { value: \"member\", name: \"Shareholder only\" },\n ],\n });\n }\n\n const wantAddress = await confirm({ message: \" Add address?\", default: false });\n const address = wantAddress ? await promptAddress() : undefined;\n\n let officerTitle: string | undefined;\n if (isCorp(entityType)) {\n const wantOfficer = role === \"officer\" || await confirm({ message: \" Assign officer title?\", default: i === 0 });\n if (wantOfficer) {\n officerTitle = await select({\n message: \" Officer title\",\n choices: OfficerTitle.map((t) => ({\n value: t,\n name: officerTitleLabel(t),\n })),\n });\n }\n }\n\n let isIncorporator = false;\n if (isCorp(entityType) && i === 0 && founderCount === 1) {\n isIncorporator = true;\n } else if (isCorp(entityType)) {\n isIncorporator = await confirm({ message: \" Designate as sole incorporator?\", default: i === 0 });\n }\n\n founders.push({ name, email, role, address, officer_title: officerTitle, is_incorporator: isIncorporator });\n }\n\n return founders;\n}\n\n// ── Phase 3: Stock & Finalize ──────────────────────────────────\n\nasync function phaseStock(\n opts: FormOptions,\n entityType: string,\n founders: FounderInfo[],\n scripted: boolean,\n): Promise<{ founders: FounderInfo[]; transferRestrictions: boolean; rofr: boolean }> {\n if (!scripted) sectionHeader(\"Phase 3: Equity & Finalize\");\n\n const transferRestrictions = opts.transferRestrictions ?? (\n !scripted && isCorp(entityType)\n ? await confirm({ message: \"Transfer restrictions on shares?\", default: true })\n : isCorp(entityType)\n );\n\n const rofr = opts.rofr ?? (\n !scripted && isCorp(entityType)\n ? await confirm({ message: \"Right of first refusal?\", default: true })\n : isCorp(entityType)\n );\n\n if (!scripted) {\n for (const f of founders) {\n console.log(chalk.dim(`\\n Equity for ${f.name}:`));\n\n if (isCorp(entityType)) {\n const shares = await number({ message: ` Shares to purchase`, default: 0 });\n f.shares_purchased = shares ?? 0;\n if (f.shares_purchased === 0) {\n const pct = await number({ message: ` Ownership % (1-100)`, default: founders.length === 1 ? 100 : 0 });\n f.ownership_pct = pct ?? 0;\n }\n } else {\n const pct = await number({\n message: ` Ownership % (1-100)`,\n default: founders.length === 1 ? 100 : 0,\n });\n f.ownership_pct = pct ?? 0;\n }\n\n if (isCorp(entityType)) {\n const wantVesting = await confirm({ message: \" Add vesting schedule?\", default: false });\n if (wantVesting) {\n const totalMonths = (await number({ message: \" Total vesting months\", default: 48 })) ?? 48;\n const cliffMonths = (await number({ message: \" Cliff months\", default: 12 })) ?? 12;\n const acceleration = await select({\n message: \" Acceleration\",\n choices: [\n { value: \"none\", name: \"None\" },\n { value: \"single_trigger\", name: \"Single trigger\" },\n { value: \"double_trigger\", name: \"Double trigger\" },\n ],\n });\n f.vesting = {\n total_months: totalMonths,\n cliff_months: cliffMonths,\n acceleration: acceleration === \"none\" ? undefined : acceleration,\n };\n }\n }\n\n const wantIp = await confirm({ message: \" Contributing IP?\", default: false });\n if (wantIp) {\n f.ip_description = await input({ message: \" Describe IP being contributed\" });\n }\n }\n }\n\n return { founders, transferRestrictions, rofr };\n}\n\n// ── Summary Table ──────────────────────────────────────────────\n\nfunction printSummary(\n entityType: string,\n name: string,\n jurisdiction: string,\n fiscalYearEnd: string,\n sCorpElection: boolean,\n founders: FounderInfo[],\n transferRestrictions: boolean,\n rofr: boolean,\n): void {\n sectionHeader(\"Formation Summary\");\n\n console.log(` ${chalk.bold(\"Entity:\")} ${name}`);\n console.log(` ${chalk.bold(\"Type:\")} ${entityType}`);\n console.log(` ${chalk.bold(\"Jurisdiction:\")} ${jurisdiction}`);\n console.log(` ${chalk.bold(\"Fiscal Year End:\")} ${fiscalYearEnd}`);\n if (isCorp(entityType)) {\n console.log(` ${chalk.bold(\"S-Corp Election:\")} ${sCorpElection ? \"Yes\" : \"No\"}`);\n console.log(` ${chalk.bold(\"Transfer Restrictions:\")} ${transferRestrictions ? \"Yes\" : \"No\"}`);\n console.log(` ${chalk.bold(\"Right of First Refusal:\")} ${rofr ? \"Yes\" : \"No\"}`);\n }\n\n const table = new Table({\n head: [chalk.dim(\"Name\"), chalk.dim(\"Email\"), chalk.dim(\"Role\"), chalk.dim(\"Equity\"), chalk.dim(\"Officer\")],\n });\n for (const f of founders) {\n const equity = f.shares_purchased\n ? `${f.shares_purchased.toLocaleString()} shares`\n : f.ownership_pct\n ? `${f.ownership_pct}%`\n : \"—\";\n table.push([f.name, f.email, f.role, equity, f.officer_title ?? \"—\"]);\n }\n console.log(table.toString());\n}\n\n// ── Main Command ───────────────────────────────────────────────\n\nexport async function formCommand(opts: FormOptions): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n\n try {\n let serverCfg: ApiRecord = {};\n try { serverCfg = await client.getConfig(); } catch { /* ignore */ }\n\n const scripted = Boolean(\n (opts.member && opts.member.length > 0) ||\n (opts.memberJson && opts.memberJson.length > 0) ||\n opts.membersFile,\n );\n\n // Phase 1: Entity Details\n const { entityType, name, jurisdiction, companyAddress, fiscalYearEnd, sCorpElection } =\n await phaseEntityDetails(opts, serverCfg, scripted);\n\n // Phase 2: People\n const founders = await phasePeople(opts, entityType, scripted);\n\n // Phase 3: Stock & Finalize\n const { transferRestrictions, rofr } = await phaseStock(opts, entityType, founders, scripted);\n\n // Summary & Confirm\n printSummary(entityType, name, jurisdiction, fiscalYearEnd, sCorpElection, founders, transferRestrictions, rofr);\n\n const shouldProceed = scripted\n ? true\n : await confirm({ message: \"Proceed with formation?\", default: true });\n\n if (!shouldProceed) {\n console.log(chalk.yellow(\"Formation cancelled.\"));\n return;\n }\n\n // Build members payload\n const members: ApiRecord[] = founders.map((f) => {\n const m: ApiRecord = {\n name: f.name,\n email: f.email,\n role: f.role,\n investor_type: \"natural_person\",\n };\n if (f.ownership_pct) m.ownership_pct = f.ownership_pct;\n if (f.shares_purchased) m.shares_purchased = f.shares_purchased;\n if (f.address) m.address = f.address;\n if (f.officer_title) m.officer_title = f.officer_title;\n if (f.is_incorporator) m.is_incorporator = true;\n if (f.vesting) m.vesting = f.vesting;\n if (f.ip_description) m.ip_description = f.ip_description;\n return m;\n });\n\n const payload: ApiRecord = {\n entity_type: entityType,\n legal_name: name,\n jurisdiction,\n members,\n workspace_id: cfg.workspace_id,\n fiscal_year_end: fiscalYearEnd,\n s_corp_election: sCorpElection,\n transfer_restrictions: transferRestrictions,\n right_of_first_refusal: rofr,\n };\n if (companyAddress) payload.company_address = companyAddress;\n\n if (opts.dryRun) {\n printDryRun(\"formation.create_with_cap_table\", payload);\n return;\n }\n\n const result = await client.createFormationWithCapTable(payload);\n\n if (opts.json) {\n printJson(result);\n return;\n }\n\n // Output results\n printSuccess(`Formation created: ${result.formation_id ?? \"OK\"}`);\n if (result.entity_id) console.log(` Entity ID: ${result.entity_id}`);\n if (result.legal_entity_id) console.log(` Legal Entity ID: ${result.legal_entity_id}`);\n if (result.instrument_id) console.log(` Instrument ID: ${result.instrument_id}`);\n\n const docIds = (result.document_ids ?? []) as string[];\n if (docIds.length > 0) {\n console.log(` Documents: ${docIds.length} generated`);\n }\n\n const holders = (result.holders ?? []) as ApiRecord[];\n if (holders.length > 0) {\n console.log();\n const table = new Table({\n head: [chalk.dim(\"Holder\"), chalk.dim(\"Shares\"), chalk.dim(\"Ownership %\")],\n });\n for (const h of holders) {\n const pct = typeof h.ownership_pct === \"number\" ? `${h.ownership_pct.toFixed(1)}%` : \"—\";\n table.push([String(h.name ?? \"?\"), String(h.shares ?? 0), pct]);\n }\n console.log(chalk.bold(\" Cap Table:\"));\n console.log(table.toString());\n }\n\n if (result.next_action) {\n console.log(chalk.yellow(`\\n Next: ${result.next_action}`));\n }\n } catch (err) {\n if (err instanceof Error && err.message.includes(\"exit\")) throw err;\n printError(`Failed to create formation: ${err}`);\n process.exit(1);\n }\n}\n\n// ── Staged Formation Subcommands ─────────────────────────────\n\ninterface FormCreateOptions {\n type: string;\n name: string;\n jurisdiction?: string;\n registeredAgentName?: string;\n registeredAgentAddress?: string;\n formationDate?: string;\n fiscalYearEnd?: string;\n sCorp?: boolean;\n transferRestrictions?: boolean;\n rofr?: boolean;\n companyAddress?: string;\n dryRun?: boolean;\n json?: boolean;\n}\n\nfunction parseCsvAddress(raw?: string): { street: string; city: string; state: string; zip: string } | undefined {\n if (!raw) return undefined;\n const parts = raw.split(\",\").map((p) => p.trim()).filter(Boolean);\n if (parts.length !== 4) {\n throw new Error(`Invalid address format: ${raw}. Expected 'street,city,state,zip'`);\n }\n return { street: parts[0], city: parts[1], state: parts[2], zip: parts[3] };\n}\n\nexport async function formCreateCommand(opts: FormCreateOptions): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n\n try {\n const entityType = opts.type === \"corporation\" ? \"c_corp\" : opts.type;\n const payload: ApiRecord = {\n entity_type: entityType,\n legal_name: opts.name,\n };\n if (opts.jurisdiction) payload.jurisdiction = opts.jurisdiction;\n if (opts.registeredAgentName) payload.registered_agent_name = opts.registeredAgentName;\n if (opts.registeredAgentAddress) payload.registered_agent_address = opts.registeredAgentAddress;\n if (opts.formationDate) payload.formation_date = opts.formationDate;\n if (opts.fiscalYearEnd) payload.fiscal_year_end = opts.fiscalYearEnd;\n if (opts.sCorp !== undefined) payload.s_corp_election = opts.sCorp;\n if (opts.transferRestrictions !== undefined) payload.transfer_restrictions = opts.transferRestrictions;\n if (opts.rofr !== undefined) payload.right_of_first_refusal = opts.rofr;\n const companyAddress = parseCsvAddress(opts.companyAddress);\n if (companyAddress) payload.company_address = companyAddress;\n\n if (opts.dryRun) {\n printDryRun(\"formation.create_pending\", payload);\n return;\n }\n\n const result = await client.createPendingEntity(payload);\n if (opts.json) {\n printJson(result);\n return;\n }\n printSuccess(`Pending entity created: ${result.entity_id}`);\n console.log(` Name: ${result.legal_name}`);\n console.log(` Type: ${result.entity_type}`);\n console.log(` Jurisdiction: ${result.jurisdiction}`);\n console.log(` Status: ${result.formation_status}`);\n console.log(chalk.yellow(`\\n Next: corp form add-founder ${result.entity_id} --name \"...\" --email \"...\" --role member --pct 50`));\n } catch (err) {\n printError(`Failed to create pending entity: ${err}`);\n process.exit(1);\n }\n}\n\ninterface FormAddFounderOptions {\n name: string;\n email: string;\n role: string;\n pct: string;\n officerTitle?: string;\n incorporator?: boolean;\n address?: string;\n dryRun?: boolean;\n json?: boolean;\n}\n\ninterface FormFinalizeOptions {\n authorizedShares?: string;\n parValue?: string;\n boardSize?: string;\n principalName?: string;\n registeredAgentName?: string;\n registeredAgentAddress?: string;\n formationDate?: string;\n fiscalYearEnd?: string;\n sCorp?: boolean;\n transferRestrictions?: boolean;\n rofr?: boolean;\n companyAddress?: string;\n incorporatorName?: string;\n incorporatorAddress?: string;\n dryRun?: boolean;\n json?: boolean;\n}\n\nexport async function formAddFounderCommand(entityId: string, opts: FormAddFounderOptions): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n\n try {\n const payload: ApiRecord = {\n name: opts.name,\n email: opts.email,\n role: opts.role,\n ownership_pct: parseFloat(opts.pct),\n };\n if (opts.officerTitle) payload.officer_title = opts.officerTitle.toLowerCase();\n if (opts.incorporator) payload.is_incorporator = true;\n const address = parseCsvAddress(opts.address);\n if (address) payload.address = address;\n\n if (opts.dryRun) {\n printDryRun(\"formation.add_founder\", { entity_id: entityId, ...payload });\n return;\n }\n\n const result = await client.addFounder(entityId, payload);\n if (opts.json) {\n printJson(result);\n return;\n }\n printSuccess(`Founder added (${result.member_count} total)`);\n const members = (result.members ?? []) as ApiRecord[];\n for (const m of members) {\n const pct = typeof m.ownership_pct === \"number\" ? ` (${m.ownership_pct}%)` : \"\";\n console.log(` - ${m.name} <${m.email ?? \"no email\"}> [${m.role ?? \"member\"}]${pct}`);\n }\n console.log(chalk.yellow(`\\n Next: add more founders or run: corp form finalize ${entityId}`));\n } catch (err) {\n printError(`Failed to add founder: ${err}`);\n process.exit(1);\n }\n}\n\nexport async function formFinalizeCommand(entityId: string, opts: FormFinalizeOptions): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n\n try {\n const payload: ApiRecord = {};\n if (opts.authorizedShares) {\n const authorizedShares = parseInt(opts.authorizedShares, 10);\n if (!Number.isFinite(authorizedShares)) {\n throw new Error(`Invalid authorized shares: ${opts.authorizedShares}`);\n }\n payload.authorized_shares = authorizedShares;\n }\n if (opts.parValue) payload.par_value = opts.parValue;\n if (opts.boardSize) {\n const boardSize = parseInt(opts.boardSize, 10);\n if (!Number.isFinite(boardSize) || boardSize <= 0) {\n throw new Error(`Invalid board size: ${opts.boardSize}`);\n }\n payload.board_size = boardSize;\n }\n if (opts.principalName) payload.principal_name = opts.principalName;\n if (opts.registeredAgentName) payload.registered_agent_name = opts.registeredAgentName;\n if (opts.registeredAgentAddress) payload.registered_agent_address = opts.registeredAgentAddress;\n if (opts.formationDate) payload.formation_date = opts.formationDate;\n if (opts.fiscalYearEnd) payload.fiscal_year_end = opts.fiscalYearEnd;\n if (opts.sCorp !== undefined) payload.s_corp_election = opts.sCorp;\n if (opts.transferRestrictions !== undefined) payload.transfer_restrictions = opts.transferRestrictions;\n if (opts.rofr !== undefined) payload.right_of_first_refusal = opts.rofr;\n const companyAddress = parseCsvAddress(opts.companyAddress);\n if (companyAddress) payload.company_address = companyAddress;\n if (opts.incorporatorName) payload.incorporator_name = opts.incorporatorName;\n if (opts.incorporatorAddress) payload.incorporator_address = opts.incorporatorAddress;\n\n if (opts.dryRun) {\n printDryRun(\"formation.finalize\", { entity_id: entityId, ...payload });\n return;\n }\n\n const result = await client.finalizeFormation(entityId, payload);\n if (opts.json) {\n printJson(result);\n return;\n }\n printSuccess(`Formation finalized: ${result.entity_id}`);\n if (result.legal_entity_id) console.log(` Legal Entity ID: ${result.legal_entity_id}`);\n if (result.instrument_id) console.log(` Instrument ID: ${result.instrument_id}`);\n\n const docIds = (result.document_ids ?? []) as string[];\n if (docIds.length > 0) {\n console.log(` Documents: ${docIds.length} generated`);\n }\n\n const holders = (result.holders ?? []) as ApiRecord[];\n if (holders.length > 0) {\n console.log();\n const table = new Table({\n head: [chalk.dim(\"Holder\"), chalk.dim(\"Shares\"), chalk.dim(\"Ownership %\")],\n });\n for (const h of holders) {\n const pct = typeof h.ownership_pct === \"number\" ? `${h.ownership_pct.toFixed(1)}%` : \"—\";\n table.push([String(h.name ?? \"?\"), String(h.shares ?? 0), pct]);\n }\n console.log(chalk.bold(\" Cap Table:\"));\n console.log(table.toString());\n }\n\n if (result.next_action) {\n console.log(chalk.yellow(`\\n Next: ${result.next_action}`));\n }\n } catch (err) {\n printError(`Failed to finalize formation: ${err}`);\n process.exit(1);\n }\n}\n","import { requireConfig, maskKey } from \"../config.js\";\nimport { CorpAPIClient } from \"../api-client.js\";\nimport { printError, printJson } from \"../output.js\";\nimport chalk from \"chalk\";\nimport Table from \"cli-table3\";\n\nexport async function apiKeysCommand(opts: { json?: boolean }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const keys = await client.listApiKeys();\n if (opts.json) {\n printJson(keys.map((k: any) => ({\n ...k,\n ...(k.key != null ? { key: maskKey(String(k.key)) } : {}),\n ...(k.api_key != null ? { api_key: maskKey(String(k.api_key)) } : {}),\n })));\n return;\n }\n if (keys.length === 0) { console.log(\"No API keys found.\"); return; }\n console.log(`\\n${chalk.bold(\"API Keys\")}`);\n const table = new Table({\n head: [chalk.dim(\"ID\"), chalk.dim(\"Name\"), chalk.dim(\"Key\"), chalk.dim(\"Created\")],\n });\n for (const k of keys) {\n table.push([\n String(k.key_id ?? k.id ?? k.api_key_id ?? \"\").slice(0, 12),\n String(k.name ?? \"\"),\n maskKey(String(k.key ?? k.api_key ?? \"\")),\n String(k.created_at ?? \"\"),\n ]);\n }\n console.log(table.toString());\n } catch (err) { printError(`Failed to fetch API keys: ${err}`); process.exit(1); }\n}\n","import { requireConfig } from \"../config.js\";\nimport { CorpAPIClient } from \"../api-client.js\";\nimport { printError, printSuccess, printJson } from \"../output.js\";\nimport { withSpinner } from \"../spinner.js\";\n\nexport async function demoCommand(opts: { name: string }): Promise<void> {\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await withSpinner(\"Loading\", () => client.seedDemo(opts.name));\n printSuccess(`Demo seeded: ${result.entity_id ?? \"OK\"}`);\n printJson(result);\n } catch (err) { printError(`Failed to seed demo: ${err}`); process.exit(1); }\n}\n","import { requireConfig } from \"../config.js\";\nimport { CorpAPIClient } from \"../api-client.js\";\nimport { printError, printJson } from \"../output.js\";\nimport chalk from \"chalk\";\n\ninterface FeedbackOptions {\n category?: string;\n email?: string;\n json?: boolean;\n}\n\nconst MAX_FEEDBACK_LENGTH = 10_000;\n\nexport async function feedbackCommand(message: string, opts: FeedbackOptions): Promise<void> {\n if (!message || message.trim().length === 0) {\n printError(\"Feedback message cannot be empty\");\n process.exit(1);\n }\n if (message.length > MAX_FEEDBACK_LENGTH) {\n printError(`Feedback message must be at most ${MAX_FEEDBACK_LENGTH} characters (got ${message.length})`);\n process.exit(1);\n }\n const cfg = requireConfig(\"api_url\", \"api_key\", \"workspace_id\");\n const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);\n try {\n const result = await client.submitFeedback(message, opts.category, opts.email);\n if (opts.json) {\n printJson(result);\n return;\n }\n console.log(`\\n${chalk.green(\"✓\")} Feedback submitted (${chalk.dim(result.feedback_id)})`);\n } catch (err: any) {\n printError(\"Failed to submit feedback\", err);\n process.exit(1);\n }\n}\n","import { readFileSync, writeFileSync, existsSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { randomBytes } from \"node:crypto\";\nimport type { ChildProcess } from \"node:child_process\";\n\ninterface ServeOptions {\n port: string;\n dataDir: string;\n}\n\nconst ENV_TEMPLATE = `# Corporation API server configuration\n# Generated by: corp serve\n\n# Required — secret for signing JWTs\nJWT_SECRET={{JWT_SECRET}}\n\n# Required — Fernet key for encrypting secrets at rest (base64url, 32 bytes)\nSECRETS_MASTER_KEY={{SECRETS_MASTER_KEY}}\n\n# Required — bearer token for internal worker-to-server auth\nINTERNAL_WORKER_TOKEN={{INTERNAL_WORKER_TOKEN}}\n\n# Server port (default: 8000)\n# PORT=8000\n\n# Data directory for git repos (default: ./data/repos)\n# DATA_DIR=./data/repos\n\n# Redis URL for agent job queue (optional)\n# REDIS_URL=redis://localhost:6379/0\n\n# LLM proxy upstream (default: https://openrouter.ai/api/v1)\n# LLM_UPSTREAM_URL=https://openrouter.ai/api/v1\n\n# PEM-encoded Ed25519 key for signing git commits (optional)\n# COMMIT_SIGNING_KEY=\n\n# Max agent queue depth (default: 1000)\n# MAX_QUEUE_DEPTH=1000\n`;\n\nfunction generateFernetKey(): string {\n // Fernet key = url-safe base64 of 32 random bytes\n return randomBytes(32).toString(\"base64url\") + \"=\";\n}\n\nfunction generateSecret(length = 32): string {\n return randomBytes(length).toString(\"hex\");\n}\n\nfunction loadEnvFile(path: string): void {\n if (!existsSync(path)) return;\n\n const content = readFileSync(path, \"utf-8\");\n for (const line of content.split(\"\\n\")) {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith(\"#\")) continue;\n\n const eqIdx = trimmed.indexOf(\"=\");\n if (eqIdx === -1) continue;\n\n const key = trimmed.slice(0, eqIdx).trim();\n const value = trimmed.slice(eqIdx + 1).trim().replace(/^[\"']|[\"']$/g, \"\");\n\n // Don't override vars already set in the environment\n if (!process.env[key]) {\n process.env[key] = value;\n }\n }\n}\n\nfunction ensureEnvFile(envPath: string): void {\n if (existsSync(envPath)) return;\n\n console.log(\"No .env file found. Generating one with dev defaults...\\n\");\n\n const content = ENV_TEMPLATE\n .replace(\"{{JWT_SECRET}}\", generateSecret())\n .replace(\"{{SECRETS_MASTER_KEY}}\", generateFernetKey())\n .replace(\"{{INTERNAL_WORKER_TOKEN}}\", generateSecret());\n\n writeFileSync(envPath, content, \"utf-8\");\n console.log(` Created ${envPath}\\n`);\n}\n\nexport async function serveCommand(opts: ServeOptions): Promise<void> {\n let server: { getBinaryPath: () => string | null; isAvailable: () => boolean; startServer: (options: Record<string, unknown>) => ChildProcess };\n try {\n server = await import(\"@thecorporation/server\");\n } catch {\n console.error(\n \"Error: @thecorporation/server is not installed.\\n\\n\" +\n \"Install it with:\\n\" +\n \" npm install @thecorporation/server\\n\\n\" +\n \"Or run the Rust binary directly:\\n\" +\n \" cd services/api-rs && cargo run\"\n );\n process.exit(1);\n }\n\n if (!server.isAvailable()) {\n console.error(\n \"Error: No server binary available for this platform.\\n\\n\" +\n \"Pre-built binaries are available for:\\n\" +\n \" - linux-x64, linux-arm64\\n\" +\n \" - darwin-x64, darwin-arm64\\n\" +\n \" - win32-x64\\n\\n\" +\n \"You can build from source:\\n\" +\n \" cd services/api-rs && cargo build --release\"\n );\n process.exit(1);\n }\n\n const port = parseInt(opts.port, 10);\n if (isNaN(port) || port > 65535) {\n console.error(`Error: Invalid port \"${opts.port}\"`);\n process.exit(1);\n }\n\n // Load .env file, generating one if it doesn't exist\n const envPath = resolve(process.cwd(), \".env\");\n ensureEnvFile(envPath);\n loadEnvFile(envPath);\n\n const localUrl = `http://localhost:${port}`;\n console.log(`Starting server on port ${port}...`);\n console.log(`Data directory: ${opts.dataDir}`);\n console.log(`CLI API URL remains unchanged.`);\n console.log(` Use CORP_API_URL=${localUrl} for commands against this local server.\\n`);\n\n const child = server.startServer({\n port,\n dataDir: opts.dataDir,\n });\n\n const shutdown = () => {\n console.log(\"\\nShutting down server...\");\n child.kill(\"SIGTERM\");\n };\n\n process.on(\"SIGINT\", shutdown);\n process.on(\"SIGTERM\", shutdown);\n\n child.on(\"exit\", (code) => {\n process.exit(code ?? 0);\n });\n}\n","import { Command, Option } from \"commander\";\nimport { createRequire } from \"node:module\";\nimport { inheritOption } from \"./command-options.js\";\n\nconst require = createRequire(import.meta.url);\nconst pkg = require(\"../package.json\");\nconst TAX_DOCUMENT_TYPE_CHOICES = [\n \"1120\",\n \"1120s\",\n \"1065\",\n \"franchise_tax\",\n \"annual_report\",\n \"83b\",\n \"form_1120\",\n \"form_1120s\",\n \"form_1065\",\n \"1099_nec\",\n \"form_1099_nec\",\n \"k1\",\n \"form_k1\",\n \"941\",\n \"form_941\",\n \"w2\",\n \"form_w2\",\n] as const;\n\nconst program = new Command();\nprogram\n .name(\"corp\")\n .description(\"corp — Corporate governance from the terminal\")\n .version(pkg.version);\n\n// --- setup ---\nprogram\n .command(\"setup\")\n .description(\"Interactive setup wizard\")\n .action(async () => {\n const { setupCommand } = await import(\"./commands/setup.js\");\n await setupCommand();\n });\n\n// --- status ---\nprogram\n .command(\"status\")\n .description(\"Workspace summary\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (opts) => {\n const { statusCommand } = await import(\"./commands/status.js\");\n await statusCommand(opts);\n });\n\nprogram\n .command(\"context\")\n .alias(\"whoami\")\n .description(\"Show the active workspace, user, and entity context\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (opts) => {\n const { contextCommand } = await import(\"./commands/context.js\");\n await contextCommand(opts);\n });\n\nprogram\n .command(\"schema\")\n .description(\"Dump the CLI command catalog as JSON\")\n .option(\"--compact\", \"Emit compact JSON\")\n .action(async (opts) => {\n const { schemaCommand } = await import(\"./commands/schema.js\");\n schemaCommand(program, opts);\n });\n\n// --- config ---\nconst configCmd = program.command(\"config\").description(\"Manage configuration\");\nconfigCmd\n .command(\"set <key> <value>\")\n .description(\"Set a config value (dot-path)\")\n .option(\"--force\", \"Allow updating a security-sensitive config key\")\n .action(async (key: string, value: string, opts: { force?: boolean }) => {\n const { configSetCommand } = await import(\"./commands/config.js\");\n configSetCommand(key, value, opts);\n });\nconfigCmd\n .command(\"get <key>\")\n .description(\"Get a config value (dot-path)\")\n .action(async (key: string) => {\n const { configGetCommand } = await import(\"./commands/config.js\");\n configGetCommand(key);\n });\nconfigCmd\n .command(\"list\")\n .description(\"List all config (API keys masked)\")\n .action(async () => {\n const { configListCommand } = await import(\"./commands/config.js\");\n configListCommand();\n });\n\n// --- obligations ---\nprogram\n .command(\"obligations\")\n .description(\"List obligations with urgency tiers\")\n .option(\"--tier <tier>\", \"Filter by urgency tier\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (opts) => {\n const { obligationsCommand } = await import(\"./commands/obligations.js\");\n await obligationsCommand(opts);\n });\n\n// --- digest ---\nprogram\n .command(\"digest\")\n .description(\"View or trigger daily digests\")\n .option(\"--trigger\", \"Trigger digest now\")\n .option(\"--key <key>\", \"Get specific digest by key\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (opts) => {\n const { digestCommand } = await import(\"./commands/digest.js\");\n await digestCommand(opts);\n });\n\n// --- link ---\nprogram\n .command(\"link\")\n .description(\"Link workspace to an external provider\")\n .requiredOption(\"--external-id <id>\", \"External ID to link\")\n .requiredOption(\"--provider <provider>\", \"Provider name (e.g. stripe, github)\")\n .action(async (opts) => {\n const { linkCommand } = await import(\"./commands/link.js\");\n await linkCommand(opts);\n });\n\n// --- claim ---\nprogram\n .command(\"claim <code>\")\n .description(\"Redeem a claim code to join a workspace\")\n .action(async (code: string) => {\n const { claimCommand } = await import(\"./commands/claim.js\");\n await claimCommand(code);\n });\n\n// --- chat ---\nprogram\n .command(\"chat\")\n .description(\"Interactive LLM chat session\")\n .action(async () => {\n const { chatCommand } = await import(\"./chat.js\");\n await chatCommand();\n });\n\n// --- entities ---\nconst entitiesCmd = program\n .command(\"entities\")\n .description(\"List entities, show detail, convert, or dissolve\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (opts) => {\n const { entitiesCommand } = await import(\"./commands/entities.js\");\n await entitiesCommand(opts);\n });\nentitiesCmd\n .command(\"show <entity-id>\")\n .option(\"--json\", \"Output as JSON\")\n .description(\"Show entity detail\")\n .action(async (entityId: string, opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { entitiesShowCommand } = await import(\"./commands/entities.js\");\n await entitiesShowCommand(entityId, {\n ...opts,\n json: inheritOption(opts.json, parent.json),\n });\n });\nentitiesCmd\n .command(\"convert <entity-id>\")\n .requiredOption(\"--to <type>\", \"Target entity type (llc, c_corp)\")\n .option(\"--jurisdiction <jurisdiction>\", \"New jurisdiction\")\n .description(\"Convert entity to a different type\")\n .action(async (entityId: string, opts) => {\n const { entitiesConvertCommand } = await import(\"./commands/entities.js\");\n await entitiesConvertCommand(entityId, opts);\n });\nentitiesCmd\n .command(\"dissolve <entity-id>\")\n .requiredOption(\"--reason <reason>\", \"Dissolution reason\")\n .option(\"--effective-date <date>\", \"Effective date (ISO 8601)\")\n .description(\"Dissolve an entity\")\n .action(async (entityId: string, opts) => {\n const { entitiesDissolveCommand } = await import(\"./commands/entities.js\");\n await entitiesDissolveCommand(entityId, opts);\n });\n\n// --- contacts ---\nconst contactsCmd = program\n .command(\"contacts\")\n .description(\"Contact management\")\n .option(\"--entity-id <id>\", \"Entity ID (overrides active entity)\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (opts) => {\n const { contactsListCommand } = await import(\"./commands/contacts.js\");\n await contactsListCommand(opts);\n });\ncontactsCmd\n .command(\"show <contact-id>\")\n .option(\"--json\", \"Output as JSON\")\n .description(\"Show contact detail/profile\")\n .action(async (contactId: string, opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { contactsShowCommand } = await import(\"./commands/contacts.js\");\n await contactsShowCommand(contactId, {\n ...opts,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\ncontactsCmd\n .command(\"add\")\n .requiredOption(\"--name <name>\", \"Contact name\")\n .requiredOption(\"--email <email>\", \"Contact email\")\n .option(\"--type <type>\", \"Contact type (individual, organization)\", \"individual\")\n .option(\"--category <category>\", \"Category (employee, contractor, board_member, investor, law_firm, valuation_firm, accounting_firm, officer, founder, member, other)\")\n .option(\"--cap-table-access <level>\", \"Cap table access (none, summary, detailed)\")\n .option(\"--address <address>\", \"Mailing address\")\n .option(\"--mailing-address <address>\", \"Alias for --address\")\n .option(\"--phone <phone>\", \"Phone number\")\n .option(\"--notes <notes>\", \"Notes\")\n .option(\"--json\", \"Output as JSON\")\n .description(\"Add a new contact\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { contactsAddCommand } = await import(\"./commands/contacts.js\");\n await contactsAddCommand({\n ...opts,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\ncontactsCmd\n .command(\"edit <contact-id>\")\n .option(\"--name <name>\", \"Contact name\")\n .option(\"--email <email>\", \"Contact email\")\n .option(\"--category <category>\", \"Contact category\")\n .option(\"--cap-table-access <level>\", \"Cap table access (none, summary, detailed)\")\n .option(\"--address <address>\", \"Mailing address\")\n .option(\"--mailing-address <address>\", \"Alias for --address\")\n .option(\"--phone <phone>\", \"Phone number\")\n .option(\"--notes <notes>\", \"Notes\")\n .option(\"--json\", \"Output as JSON\")\n .description(\"Edit an existing contact\")\n .action(async (contactId: string, opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { contactsEditCommand } = await import(\"./commands/contacts.js\");\n await contactsEditCommand(contactId, {\n ...opts,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\n\n// --- cap-table ---\nconst capTableCmd = program\n .command(\"cap-table\")\n .description(\"Cap table, equity grants, SAFEs, transfers, and valuations\")\n .option(\"--entity-id <id>\", \"Entity ID (overrides active entity)\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (opts) => {\n const { capTableCommand } = await import(\"./commands/cap-table.js\");\n await capTableCommand(opts);\n });\ncapTableCmd.command(\"safes\").description(\"SAFE notes\").action(async (_opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { safesCommand } = await import(\"./commands/cap-table.js\");\n await safesCommand(parent);\n});\ncapTableCmd.command(\"transfers\").description(\"Share transfers\").action(async (_opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { transfersCommand } = await import(\"./commands/cap-table.js\");\n await transfersCommand(parent);\n});\ncapTableCmd.command(\"valuations\").description(\"Valuations history\").action(async (_opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { valuationsCommand } = await import(\"./commands/cap-table.js\");\n await valuationsCommand(parent);\n});\ncapTableCmd.command(\"409a\").description(\"Current 409A valuation\").action(async (_opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { fourOhNineACommand } = await import(\"./commands/cap-table.js\");\n await fourOhNineACommand(parent);\n});\ncapTableCmd\n .command(\"create-instrument\")\n .requiredOption(\"--kind <kind>\", \"Instrument kind (common_equity, preferred_equity, membership_unit, option_grant, safe)\")\n .requiredOption(\"--symbol <symbol>\", \"Instrument symbol\")\n .option(\"--issuer-legal-entity-id <id>\", \"Issuer legal entity ID (auto-detected from the cap table if omitted)\")\n .option(\"--authorized-units <n>\", \"Authorized units\", parseInt)\n .option(\"--issue-price-cents <n>\", \"Issue price in cents\", parseInt)\n .option(\"--terms-json <json>\", \"JSON object of instrument terms\")\n .option(\"--json\", \"Output as JSON\")\n .option(\"--dry-run\", \"Show the request without creating the instrument\")\n .description(\"Create a cap table instrument\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { createInstrumentCommand } = await import(\"./commands/cap-table.js\");\n await createInstrumentCommand({\n ...opts,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\ncapTableCmd\n .command(\"issue-equity\")\n .requiredOption(\"--grant-type <type>\", \"Grant type (common, preferred, membership_unit, stock_option, iso, nso, rsa)\")\n .requiredOption(\"--shares <n>\", \"Number of shares\", parseInt)\n .requiredOption(\"--recipient <name>\", \"Recipient name\")\n .option(\"--email <email>\", \"Recipient email (auto-creates contact if needed)\")\n .option(\"--instrument-id <id>\", \"Instrument ID (auto-detected from cap table if omitted)\")\n .option(\"--meeting-id <id>\", \"Board meeting ID required when a board approval already exists or is being recorded\")\n .option(\"--resolution-id <id>\", \"Board resolution ID required when issuing under a board-governed entity\")\n .option(\"--json\", \"Output as JSON\")\n .option(\"--dry-run\", \"Show the request without creating the round\")\n .description(\"Issue an equity grant (creates a round, adds security, and issues it)\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { issueEquityCommand } = await import(\"./commands/cap-table.js\");\n await issueEquityCommand({\n ...opts,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\ncapTableCmd\n .command(\"issue-safe\")\n .requiredOption(\"--investor <name>\", \"Investor name\")\n .requiredOption(\"--amount <n>\", \"Principal amount in cents\", parseInt)\n .option(\"--safe-type <type>\", \"SAFE type\", \"post_money\")\n .requiredOption(\"--valuation-cap <n>\", \"Valuation cap in cents\", parseInt)\n .option(\"--meeting-id <id>\", \"Board meeting ID required when issuing under a board-governed entity\")\n .option(\"--resolution-id <id>\", \"Board resolution ID required when issuing under a board-governed entity\")\n .option(\"--json\", \"Output as JSON\")\n .option(\"--dry-run\", \"Show the request without creating the round\")\n .description(\"Issue a SAFE note\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { issueSafeCommand } = await import(\"./commands/cap-table.js\");\n await issueSafeCommand({\n ...opts,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\ncapTableCmd\n .command(\"transfer\")\n .requiredOption(\"--from <id>\", \"Source contact ID (from_contact_id)\")\n .requiredOption(\"--to <id>\", \"Destination contact ID (to_contact_id)\")\n .requiredOption(\"--shares <n>\", \"Number of shares to transfer\", parseInt)\n .requiredOption(\"--share-class-id <id>\", \"Share class ID\")\n .requiredOption(\"--governing-doc-type <type>\", \"Governing doc type (bylaws, operating_agreement, shareholder_agreement, other)\")\n .requiredOption(\"--transferee-rights <rights>\", \"Transferee rights (full_member, economic_only, limited)\")\n .option(\"--prepare-intent-id <id>\", \"Prepare intent ID (auto-created if omitted)\")\n .option(\"--type <type>\", \"Transfer type (gift, trust_transfer, secondary_sale, estate, other)\", \"secondary_sale\")\n .option(\"--price-per-share-cents <n>\", \"Price per share in cents\", parseInt)\n .option(\"--relationship <rel>\", \"Relationship to holder\")\n .option(\"--json\", \"Output as JSON\")\n .option(\"--dry-run\", \"Show the request without creating the workflow\")\n .description(\"Create a share transfer workflow\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { transferSharesCommand } = await import(\"./commands/cap-table.js\");\n await transferSharesCommand({\n ...opts,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\ncapTableCmd\n .command(\"distribute\")\n .requiredOption(\"--amount <n>\", \"Total distribution amount in cents\", parseInt)\n .option(\"--type <type>\", \"Distribution type (dividend, return, liquidation)\", \"dividend\")\n .requiredOption(\"--description <desc>\", \"Distribution description\")\n .option(\"--json\", \"Output as JSON\")\n .option(\"--dry-run\", \"Show the request without calculating the distribution\")\n .description(\"Calculate a distribution\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { distributeCommand } = await import(\"./commands/cap-table.js\");\n await distributeCommand({\n ...opts,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\n\ncapTableCmd\n .command(\"start-round\")\n .requiredOption(\"--name <name>\", \"Round name\")\n .requiredOption(\"--issuer-legal-entity-id <id>\", \"Issuer legal entity ID\")\n .option(\"--json\", \"Output as JSON\")\n .option(\"--dry-run\", \"Show the request without creating the round\")\n .description(\"Start a staged equity round\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { startRoundCommand } = await import(\"./commands/cap-table.js\");\n await startRoundCommand({\n ...opts,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\ncapTableCmd\n .command(\"add-security\")\n .requiredOption(\"--round-id <id>\", \"Round ID\")\n .requiredOption(\"--instrument-id <id>\", \"Instrument ID\")\n .requiredOption(\"--quantity <n>\", \"Number of shares/units\", parseInt)\n .requiredOption(\"--recipient-name <name>\", \"Recipient display name\")\n .option(\"--holder-id <id>\", \"Existing holder ID\")\n .option(\"--email <email>\", \"Recipient email (to find or create holder)\")\n .option(\"--principal-cents <n>\", \"Principal amount in cents\", parseInt)\n .option(\"--grant-type <type>\", \"Grant type\")\n .option(\"--json\", \"Output as JSON\")\n .option(\"--dry-run\", \"Show the request without adding the security\")\n .description(\"Add a security to a staged equity round\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { addSecurityCommand } = await import(\"./commands/cap-table.js\");\n await addSecurityCommand({\n ...opts,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\ncapTableCmd\n .command(\"issue-round\")\n .option(\"--meeting-id <id>\", \"Board meeting ID required when issuing under a board-governed entity\")\n .option(\"--resolution-id <id>\", \"Board resolution ID required when issuing under a board-governed entity\")\n .option(\"--json\", \"Output as JSON\")\n .option(\"--dry-run\", \"Show the request without issuing the round\")\n .requiredOption(\"--round-id <id>\", \"Round ID\")\n .description(\"Issue all securities and close a staged round\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { issueRoundCommand } = await import(\"./commands/cap-table.js\");\n await issueRoundCommand({\n ...opts,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\ncapTableCmd\n .command(\"create-valuation\")\n .requiredOption(\"--type <type>\", \"Valuation type (four_oh_nine_a, fair_market_value, etc.)\")\n .requiredOption(\"--date <date>\", \"Effective date (ISO 8601)\")\n .requiredOption(\"--methodology <method>\", \"Methodology (income, market, asset, backsolve, hybrid)\")\n .option(\"--fmv <cents>\", \"FMV per share in cents\", parseInt)\n .option(\"--enterprise-value <cents>\", \"Enterprise value in cents\", parseInt)\n .option(\"--json\", \"Output as JSON\")\n .option(\"--dry-run\", \"Show the request without creating the valuation\")\n .description(\"Create a valuation\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { createValuationCommand } = await import(\"./commands/cap-table.js\");\n await createValuationCommand({\n ...opts,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\ncapTableCmd\n .command(\"submit-valuation <valuation-id>\")\n .option(\"--json\", \"Output as JSON\")\n .option(\"--dry-run\", \"Show the request without submitting the valuation\")\n .description(\"Submit a valuation for board approval\")\n .action(async (valuationId: string, opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { submitValuationCommand } = await import(\"./commands/cap-table.js\");\n await submitValuationCommand({\n ...opts,\n valuationId,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\ncapTableCmd\n .command(\"approve-valuation <valuation-id>\")\n .option(\"--resolution-id <id>\", \"Resolution ID from the board vote\")\n .option(\"--json\", \"Output as JSON\")\n .option(\"--dry-run\", \"Show the request without approving the valuation\")\n .description(\"Approve a valuation\")\n .action(async (valuationId: string, opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { approveValuationCommand } = await import(\"./commands/cap-table.js\");\n await approveValuationCommand({\n ...opts,\n valuationId,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\n\n// --- finance ---\nconst financeCmd = program\n .command(\"finance\")\n .description(\"Invoicing, payroll, payments, banking\")\n .option(\"--entity-id <id>\", \"Entity ID (overrides active entity)\")\n .option(\"--json\", \"Output as JSON\");\nfinanceCmd\n .command(\"invoice\")\n .requiredOption(\"--customer <name>\", \"Customer name\")\n .requiredOption(\"--amount <n>\", \"Amount in cents\", parseInt)\n .requiredOption(\"--due-date <date>\", \"Due date (ISO 8601)\")\n .option(\"--description <desc>\", \"Description\", \"Services rendered\")\n .option(\"--json\", \"Output as JSON\")\n .description(\"Create an invoice\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { financeInvoiceCommand } = await import(\"./commands/finance.js\");\n await financeInvoiceCommand({\n ...opts,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\nfinanceCmd\n .command(\"payroll\")\n .requiredOption(\"--period-start <date>\", \"Pay period start\")\n .requiredOption(\"--period-end <date>\", \"Pay period end\")\n .option(\"--json\", \"Output as JSON\")\n .description(\"Run payroll\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { financePayrollCommand } = await import(\"./commands/finance.js\");\n await financePayrollCommand({\n ...opts,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\nfinanceCmd\n .command(\"pay\")\n .requiredOption(\"--amount <n>\", \"Amount in cents\", parseInt)\n .requiredOption(\"--recipient <name>\", \"Recipient name\")\n .option(\"--method <method>\", \"Payment method\", \"ach\")\n .option(\"--json\", \"Output as JSON\")\n .description(\"Submit a payment\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { financePayCommand } = await import(\"./commands/finance.js\");\n await financePayCommand({\n ...opts,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\nfinanceCmd\n .command(\"open-account\")\n .option(\"--institution <name>\", \"Banking institution\", \"Mercury\")\n .option(\"--json\", \"Output as JSON\")\n .description(\"Open a business bank account\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { financeOpenAccountCommand } = await import(\"./commands/finance.js\");\n await financeOpenAccountCommand({\n ...opts,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\nfinanceCmd\n .command(\"classify-contractor\")\n .requiredOption(\"--name <name>\", \"Contractor name\")\n .requiredOption(\"--state <code>\", \"US state code\")\n .requiredOption(\"--hours <n>\", \"Hours per week\", parseInt)\n .option(\"--exclusive\", \"Exclusive client\", false)\n .requiredOption(\"--duration <n>\", \"Duration in months\", parseInt)\n .option(\"--provides-tools\", \"Company provides tools\", false)\n .option(\"--json\", \"Output as JSON\")\n .description(\"Analyze contractor classification risk\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { financeClassifyContractorCommand } = await import(\"./commands/finance.js\");\n await financeClassifyContractorCommand({\n ...opts,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\nfinanceCmd\n .command(\"reconcile\")\n .requiredOption(\"--start-date <date>\", \"Period start\")\n .requiredOption(\"--end-date <date>\", \"Period end\")\n .option(\"--json\", \"Output as JSON\")\n .description(\"Reconcile ledger\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { financeReconcileCommand } = await import(\"./commands/finance.js\");\n await financeReconcileCommand({\n ...opts,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\n\n// --- governance ---\nconst governanceCmd = program\n .command(\"governance\")\n .description(\"Governance bodies, seats, meetings, resolutions\")\n .option(\"--entity-id <id>\", \"Entity ID (overrides active entity)\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (opts) => {\n const { governanceListCommand } = await import(\"./commands/governance.js\");\n await governanceListCommand(opts);\n });\ngovernanceCmd\n .command(\"create-body\")\n .requiredOption(\"--name <name>\", \"Body name (e.g. 'Board of Directors')\")\n .requiredOption(\"--body-type <type>\", \"Body type (board_of_directors, llc_member_vote)\")\n .option(\"--quorum <rule>\", \"Quorum rule (majority, supermajority, unanimous)\", \"majority\")\n .option(\"--voting <method>\", \"Voting method (per_capita, per_unit)\", \"per_capita\")\n .option(\"--json\", \"Output as JSON\")\n .option(\"--dry-run\", \"Show the request without creating the governance body\")\n .description(\"Create a governance body\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { governanceCreateBodyCommand } = await import(\"./commands/governance.js\");\n await governanceCreateBodyCommand({\n ...opts,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\ngovernanceCmd\n .command(\"add-seat <body-id>\")\n .requiredOption(\"--holder <contact-id>\", \"Contact ID for the seat holder\")\n .option(\"--role <role>\", \"Seat role (chair, member, officer, observer)\", \"member\")\n .option(\"--json\", \"Output as JSON\")\n .option(\"--dry-run\", \"Show the request without adding the seat\")\n .description(\"Add a seat to a governance body\")\n .action(async (bodyId: string, opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { governanceAddSeatCommand } = await import(\"./commands/governance.js\");\n await governanceAddSeatCommand(bodyId, {\n ...opts,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\ngovernanceCmd\n .command(\"seats <body-id>\")\n .description(\"Seats for a governance body\")\n .action(async (bodyId: string, _opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { governanceSeatsCommand } = await import(\"./commands/governance.js\");\n await governanceSeatsCommand(bodyId, parent);\n });\ngovernanceCmd\n .command(\"meetings <body-id>\")\n .description(\"Meetings for a governance body\")\n .action(async (bodyId: string, _opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { governanceMeetingsCommand } = await import(\"./commands/governance.js\");\n await governanceMeetingsCommand(bodyId, parent);\n });\ngovernanceCmd\n .command(\"resolutions <meeting-id>\")\n .description(\"Resolutions for a meeting\")\n .action(async (meetingId: string, _opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { governanceResolutionsCommand } = await import(\"./commands/governance.js\");\n await governanceResolutionsCommand(meetingId, parent);\n });\ngovernanceCmd\n .command(\"convene\")\n .requiredOption(\"--body <id>\", \"Governance body ID\")\n .requiredOption(\"--type <type>\", \"Meeting type (board_meeting, shareholder_meeting, member_meeting, written_consent)\")\n .requiredOption(\"--title <title>\", \"Meeting title\")\n .option(\"--date <date>\", \"Meeting date (ISO 8601)\")\n .option(\"--agenda <item>\", \"Agenda item (repeatable)\", (v: string, a: string[]) => [...a, v], [] as string[])\n .option(\"--json\", \"Output as JSON\")\n .option(\"--dry-run\", \"Show the request without scheduling the meeting\")\n .description(\"Convene a governance meeting\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { governanceConveneCommand } = await import(\"./commands/governance.js\");\n await governanceConveneCommand({\n ...opts,\n meetingType: opts.type,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\ngovernanceCmd\n .command(\"open <meeting-id>\")\n .requiredOption(\"--present-seat <id>\", \"Seat ID present at the meeting (repeatable)\", (v: string, a?: string[]) => [...(a ?? []), v])\n .option(\"--json\", \"Output as JSON\")\n .option(\"--dry-run\", \"Show the request without opening the meeting\")\n .description(\"Open a scheduled meeting for voting\")\n .action(async (meetingId: string, opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { governanceOpenMeetingCommand } = await import(\"./commands/governance.js\");\n await governanceOpenMeetingCommand(meetingId, {\n ...opts,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\ngovernanceCmd\n .command(\"vote <meeting-id> <item-id>\")\n .requiredOption(\"--voter <id>\", \"Voter contact UUID\")\n .addOption(new Option(\"--vote <value>\", \"Vote (for, against, abstain, recusal)\").choices([\"for\", \"against\", \"abstain\", \"recusal\"]).makeOptionMandatory())\n .option(\"--json\", \"Output as JSON\")\n .option(\"--dry-run\", \"Show the request without casting the vote\")\n .description(\"Cast a vote on an agenda item\")\n .action(async (meetingId: string, itemId: string, opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { governanceVoteCommand } = await import(\"./commands/governance.js\");\n await governanceVoteCommand(meetingId, itemId, {\n ...opts,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\ngovernanceCmd\n .command(\"notice <meeting-id>\")\n .option(\"--json\", \"Output as JSON\")\n .option(\"--dry-run\", \"Show the request without sending notices\")\n .description(\"Send meeting notice\")\n .action(async (meetingId: string, opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { sendNoticeCommand } = await import(\"./commands/governance.js\");\n await sendNoticeCommand(meetingId, {\n ...opts,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\ngovernanceCmd\n .command(\"adjourn <meeting-id>\")\n .option(\"--json\", \"Output as JSON\")\n .option(\"--dry-run\", \"Show the request without adjourning the meeting\")\n .description(\"Adjourn a meeting\")\n .action(async (meetingId: string, opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { adjournMeetingCommand } = await import(\"./commands/governance.js\");\n await adjournMeetingCommand(meetingId, {\n ...opts,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\ngovernanceCmd\n .command(\"cancel <meeting-id>\")\n .option(\"--json\", \"Output as JSON\")\n .option(\"--dry-run\", \"Show the request without cancelling the meeting\")\n .description(\"Cancel a meeting\")\n .action(async (meetingId: string, opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { cancelMeetingCommand } = await import(\"./commands/governance.js\");\n await cancelMeetingCommand(meetingId, {\n ...opts,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\ngovernanceCmd\n .command(\"agenda-items <meeting-id>\")\n .description(\"List agenda items for a meeting\")\n .action(async (meetingId: string, _opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { listAgendaItemsCommand } = await import(\"./commands/governance.js\");\n await listAgendaItemsCommand(meetingId, { entityId: parent.entityId, json: parent.json });\n });\ngovernanceCmd\n .command(\"finalize-item <meeting-id> <item-id>\")\n .requiredOption(\"--status <status>\", \"Status: voted, discussed, tabled, withdrawn\")\n .option(\"--json\", \"Output as JSON\")\n .option(\"--dry-run\", \"Show the request without finalizing the item\")\n .description(\"Finalize an agenda item\")\n .action(async (meetingId: string, itemId: string, opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { finalizeAgendaItemCommand } = await import(\"./commands/governance.js\");\n await finalizeAgendaItemCommand(meetingId, itemId, {\n ...opts,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\ngovernanceCmd\n .command(\"resolve <meeting-id> <item-id>\")\n .requiredOption(\"--text <resolution_text>\", \"Resolution text\")\n .option(\"--json\", \"Output as JSON\")\n .option(\"--dry-run\", \"Show the request without computing the resolution\")\n .description(\"Compute a resolution for an agenda item\")\n .action(async (meetingId: string, itemId: string, opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { computeResolutionCommand } = await import(\"./commands/governance.js\");\n await computeResolutionCommand(meetingId, itemId, {\n ...opts,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\ngovernanceCmd\n .command(\"written-consent\")\n .requiredOption(\"--body <id>\", \"Governance body ID\")\n .requiredOption(\"--title <title>\", \"Title\")\n .requiredOption(\"--description <desc>\", \"Description\")\n .option(\"--json\", \"Output as JSON\")\n .option(\"--dry-run\", \"Show the request without creating the written consent\")\n .description(\"Create a written consent action\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { writtenConsentCommand } = await import(\"./commands/governance.js\");\n await writtenConsentCommand({\n ...opts,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\n\n// --- documents ---\nconst documentsCmd = program\n .command(\"documents\")\n .description(\"Documents and signing\")\n .option(\"--entity-id <id>\", \"Entity ID (overrides active entity)\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (opts) => {\n const { documentsListCommand } = await import(\"./commands/documents.js\");\n await documentsListCommand(opts);\n });\ndocumentsCmd\n .command(\"signing-link <doc-id>\")\n .option(\"--entity-id <id>\", \"Entity ID (overrides active entity and parent command)\")\n .description(\"Get a signing link for a document\")\n .action(async (docId: string, opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { documentsSigningLinkCommand } = await import(\"./commands/documents.js\");\n await documentsSigningLinkCommand(docId, { entityId: opts.entityId ?? parent.entityId });\n });\ndocumentsCmd\n .command(\"generate\")\n .requiredOption(\"--template <type>\", \"Template type (consulting_agreement, employment_offer, contractor_agreement, nda, custom)\")\n .requiredOption(\"--counterparty <name>\", \"Counterparty name\")\n .option(\"--effective-date <date>\", \"Effective date (ISO 8601, defaults to today)\")\n .option(\"--base-salary <amount>\", \"Employment offer base salary (for employment_offer)\")\n .option(\"--param <key=value>\", \"Additional template parameter (repeatable)\", (value: string, values: string[]) => [...values, value], [] as string[])\n .option(\"--json\", \"Output as JSON\")\n .description(\"Generate a contract from a template\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { documentsGenerateCommand } = await import(\"./commands/documents.js\");\n await documentsGenerateCommand({\n ...opts,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\ndocumentsCmd\n .command(\"preview-pdf\")\n .requiredOption(\"--definition-id <id>\", \"AST document definition ID (e.g. 'bylaws')\")\n .option(\"--document-id <id>\", \"Deprecated alias for --definition-id\")\n .description(\"Validate and print the authenticated PDF preview URL for a governance document\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { documentsPreviewPdfCommand } = await import(\"./commands/documents.js\");\n await documentsPreviewPdfCommand({\n ...opts,\n documentId: opts.definitionId ?? opts.documentId,\n entityId: parent.entityId,\n });\n });\n\n// --- tax ---\nconst taxCmd = program\n .command(\"tax\")\n .description(\"Tax filings and deadline tracking\")\n .option(\"--entity-id <id>\", \"Entity ID (overrides active entity)\");\ntaxCmd\n .command(\"file\")\n .addOption(new Option(\"--type <type>\", `Document type (${TAX_DOCUMENT_TYPE_CHOICES.join(\", \")})`).choices([...TAX_DOCUMENT_TYPE_CHOICES]).makeOptionMandatory())\n .requiredOption(\"--year <year>\", \"Tax year\", parseInt)\n .option(\"--json\", \"Output as JSON\")\n .description(\"File a tax document\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { taxFileCommand } = await import(\"./commands/tax.js\");\n await taxFileCommand({\n ...opts,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\ntaxCmd\n .command(\"deadline\")\n .requiredOption(\"--type <type>\", \"Deadline type\")\n .requiredOption(\"--due-date <date>\", \"Due date (ISO 8601)\")\n .requiredOption(\"--description <desc>\", \"Description\")\n .option(\"--recurrence <recurrence>\", \"Recurrence (e.g. annual; 'yearly' is normalized)\")\n .option(\"--json\", \"Output as JSON\")\n .description(\"Track a compliance deadline\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { taxDeadlineCommand } = await import(\"./commands/tax.js\");\n await taxDeadlineCommand({\n ...opts,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\n\n// --- agents ---\nconst agentsCmd = program\n .command(\"agents\")\n .description(\"Agent management\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (opts) => {\n const { agentsListCommand } = await import(\"./commands/agents.js\");\n await agentsListCommand(opts);\n });\nagentsCmd.command(\"show <agent-id>\").option(\"--json\", \"Output as JSON\").description(\"Show agent detail\")\n .action(async (agentId: string, opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { agentsShowCommand } = await import(\"./commands/agents.js\");\n await agentsShowCommand(agentId, {\n ...opts,\n json: inheritOption(opts.json, parent.json),\n });\n });\nagentsCmd.command(\"create\").requiredOption(\"--name <name>\", \"Agent name\")\n .requiredOption(\"--prompt <prompt>\", \"System prompt\").option(\"--model <model>\", \"Model\")\n .option(\"--json\", \"Output as JSON\")\n .description(\"Create a new agent\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { agentsCreateCommand } = await import(\"./commands/agents.js\");\n await agentsCreateCommand({\n ...opts,\n json: inheritOption(opts.json, parent.json),\n });\n });\nagentsCmd.command(\"pause <agent-id>\").option(\"--json\", \"Output as JSON\").description(\"Pause an agent\")\n .action(async (agentId: string, opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { agentsPauseCommand } = await import(\"./commands/agents.js\");\n await agentsPauseCommand(agentId, {\n json: inheritOption(opts.json, parent.json),\n });\n });\nagentsCmd.command(\"resume <agent-id>\").option(\"--json\", \"Output as JSON\").description(\"Resume a paused agent\")\n .action(async (agentId: string, opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { agentsResumeCommand } = await import(\"./commands/agents.js\");\n await agentsResumeCommand(agentId, {\n json: inheritOption(opts.json, parent.json),\n });\n });\nagentsCmd.command(\"delete <agent-id>\").option(\"--json\", \"Output as JSON\").description(\"Delete an agent\")\n .action(async (agentId: string, opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { agentsDeleteCommand } = await import(\"./commands/agents.js\");\n await agentsDeleteCommand(agentId, {\n json: inheritOption(opts.json, parent.json),\n });\n });\nagentsCmd.command(\"message <agent-id>\").option(\"--body <text>\", \"Message text\")\n .option(\"--body-file <path>\", \"Read the message body from a file\")\n .option(\"--json\", \"Output as JSON\")\n .description(\"Send a message to an agent\")\n .action(async (agentId: string, opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { agentsMessageCommand } = await import(\"./commands/agents.js\");\n await agentsMessageCommand(agentId, {\n ...opts,\n json: inheritOption(opts.json, parent.json),\n });\n });\nagentsCmd.command(\"skill <agent-id>\").requiredOption(\"--name <name>\", \"Skill name\")\n .requiredOption(\"--description <desc>\", \"Skill description\").option(\"--instructions <text>\", \"Instructions\")\n .option(\"--instructions-file <path>\", \"Read skill instructions from a file\")\n .option(\"--json\", \"Output as JSON\")\n .description(\"Add a skill to an agent\")\n .action(async (agentId: string, opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { agentsSkillCommand } = await import(\"./commands/agents.js\");\n await agentsSkillCommand(agentId, {\n ...opts,\n json: inheritOption(opts.json, parent.json),\n });\n });\n\n// --- work-items ---\nconst workItemsCmd = program\n .command(\"work-items\")\n .description(\"Long-term work item coordination\")\n .option(\"--entity-id <id>\", \"Entity ID (overrides active entity)\")\n .option(\"--json\", \"Output as JSON\")\n .option(\"--status <status>\", \"Filter by status (open, claimed, completed, cancelled)\")\n .option(\"--category <category>\", \"Filter by category\")\n .action(async (opts) => {\n const { workItemsListCommand } = await import(\"./commands/work-items.js\");\n await workItemsListCommand(opts);\n });\nworkItemsCmd\n .command(\"show <item-id>\")\n .option(\"--json\", \"Output as JSON\")\n .description(\"Show work item detail\")\n .action(async (itemId: string, opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { workItemsShowCommand } = await import(\"./commands/work-items.js\");\n await workItemsShowCommand(itemId, {\n ...opts,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\nworkItemsCmd\n .command(\"create\")\n .requiredOption(\"--title <title>\", \"Work item title\")\n .option(\"--category <category>\", \"Work item category\")\n .option(\"--description <desc>\", \"Description\")\n .option(\"--deadline <date>\", \"Deadline (YYYY-MM-DD)\")\n .option(\"--asap\", \"Mark as ASAP priority\")\n .option(\"--created-by <name>\", \"Creator identifier\")\n .option(\"--json\", \"Output as JSON\")\n .description(\"Create a new work item\")\n .action(async (opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { workItemsCreateCommand } = await import(\"./commands/work-items.js\");\n await workItemsCreateCommand({\n ...opts,\n category: inheritOption(opts.category, parent.category),\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\nworkItemsCmd\n .command(\"claim <item-id>\")\n .option(\"--by <name>\", \"Agent or user claiming the item\")\n .option(\"--claimer <name>\", \"Alias for --by\")\n .option(\"--ttl <seconds>\", \"Auto-release TTL in seconds\", parseInt)\n .option(\"--json\", \"Output as JSON\")\n .description(\"Claim a work item\")\n .action(async (itemId: string, opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { workItemsClaimCommand } = await import(\"./commands/work-items.js\");\n const claimedBy = opts.by ?? opts.claimer;\n if (!claimedBy) {\n cmd.error(\"required option '--by <name>' not specified\");\n return;\n }\n await workItemsClaimCommand(itemId, {\n claimedBy,\n ttl: opts.ttl,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\nworkItemsCmd\n .command(\"complete <item-id>\")\n .option(\"--by <name>\", \"Agent or user completing the item\")\n .option(\"--completed-by <name>\", \"Alias for --by\")\n .option(\"--result <text>\", \"Completion result or notes\")\n .option(\"--notes <text>\", \"Alias for --result\")\n .option(\"--json\", \"Output as JSON\")\n .description(\"Mark a work item as completed\")\n .action(async (itemId: string, opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { workItemsCompleteCommand } = await import(\"./commands/work-items.js\");\n const completedBy = opts.by ?? opts.completedBy;\n if (!completedBy) {\n cmd.error(\"required option '--by <name>' not specified\");\n return;\n }\n await workItemsCompleteCommand(itemId, {\n completedBy,\n result: opts.result ?? opts.notes,\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\nworkItemsCmd\n .command(\"release <item-id>\")\n .option(\"--json\", \"Output as JSON\")\n .description(\"Release a claimed work item\")\n .action(async (itemId: string, opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { workItemsReleaseCommand } = await import(\"./commands/work-items.js\");\n await workItemsReleaseCommand(itemId, {\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\nworkItemsCmd\n .command(\"cancel <item-id>\")\n .option(\"--json\", \"Output as JSON\")\n .description(\"Cancel a work item\")\n .action(async (itemId: string, opts, cmd) => {\n const parent = cmd.parent!.opts();\n const { workItemsCancelCommand } = await import(\"./commands/work-items.js\");\n await workItemsCancelCommand(itemId, {\n entityId: parent.entityId,\n json: inheritOption(opts.json, parent.json),\n });\n });\n\n// --- billing ---\nconst billingCmd = program\n .command(\"billing\")\n .description(\"Billing status, plans, and subscription management\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (opts) => {\n const { billingCommand } = await import(\"./commands/billing.js\");\n await billingCommand(opts);\n });\nbillingCmd.command(\"portal\").description(\"Open Stripe Customer Portal\")\n .action(async () => {\n const { billingPortalCommand } = await import(\"./commands/billing.js\");\n await billingPortalCommand();\n });\nbillingCmd.command(\"upgrade\").option(\"--plan <plan>\", \"Plan ID to upgrade to (free, pro, enterprise)\", \"pro\")\n .description(\"Open Stripe Checkout to upgrade your plan\")\n .action(async (opts) => {\n const { billingUpgradeCommand } = await import(\"./commands/billing.js\");\n await billingUpgradeCommand(opts);\n });\n\n// --- approvals ---\n// The approval system is integrated into governance meetings (vote on agenda items)\n// and execution intents. There is no standalone /v1/approvals endpoint.\nprogram\n .command(\"approvals\")\n .description(\"Approvals are managed through governance meetings and execution intents\")\n .action(async () => {\n const { printError } = await import(\"./output.js\");\n printError(\n \"Approvals are managed through governance meetings.\\n\" +\n \" Use: corp governance convene ... to schedule a board meeting\\n\" +\n \" Use: corp governance vote <meeting-id> <item-id> ... to cast votes\"\n );\n });\n\n// --- form ---\nconst formCmd = program\n .command(\"form\")\n .description(\"Form a new entity with founders and cap table\")\n .option(\"--entity-type <type>\", \"Entity type (llc, c_corp)\")\n .option(\"--legal-name <name>\", \"Legal name\")\n .option(\"--jurisdiction <jurisdiction>\", \"Jurisdiction (e.g. US-DE, US-WY)\")\n .option(\"--member <member>\", \"Founder as 'name,email,role[,pct[,address[,officer_title[,is_incorporator]]]]' with address as street|city|state|zip, or key=value pairs like 'name=...,email=...,role=...,officer_title=cto,is_incorporator=true,address=street|city|state|zip' (repeatable)\", (v: string, a: string[]) => [...a, v], [] as string[])\n .option(\"--member-json <json>\", \"Founder JSON object (repeatable)\", (v: string, a: string[]) => [...a, v], [] as string[])\n .option(\"--members-file <path>\", \"Path to a JSON array of founders or {\\\"members\\\": [...]}\")\n .option(\"--address <address>\", \"Company address as 'street,city,state,zip'\")\n .option(\"--fiscal-year-end <date>\", \"Fiscal year end (MM-DD)\", \"12-31\")\n .option(\"--s-corp\", \"Elect S-Corp status\")\n .option(\"--transfer-restrictions\", \"Enable transfer restrictions\")\n .option(\"--rofr\", \"Enable right of first refusal\")\n .option(\"--json\", \"Output as JSON\")\n .option(\"--dry-run\", \"Show the request without creating the entity\")\n .action(async (opts) => {\n // Map --entity-type and --legal-name to the internal keys expected by formCommand\n if (opts.entityType && !opts.type) opts.type = opts.entityType;\n if (opts.legalName && !opts.name) opts.name = opts.legalName;\n const { formCommand } = await import(\"./commands/form.js\");\n await formCommand(opts);\n });\nformCmd.command(\"create\")\n .description(\"Create a pending entity (staged flow step 1)\")\n .requiredOption(\"--type <type>\", \"Entity type (llc, c_corp)\")\n .requiredOption(\"--name <name>\", \"Legal name\")\n .option(\"--jurisdiction <jurisdiction>\", \"Jurisdiction (e.g. US-DE, US-WY)\")\n .option(\"--registered-agent-name <name>\", \"Registered agent legal name\")\n .option(\"--registered-agent-address <address>\", \"Registered agent address line\")\n .option(\"--formation-date <date>\", \"Formation date (RFC3339 or YYYY-MM-DD)\")\n .option(\"--fiscal-year-end <date>\", \"Fiscal year end (MM-DD)\")\n .option(\"--s-corp\", \"Elect S-Corp status\")\n .option(\"--transfer-restrictions\", \"Enable transfer restrictions\")\n .option(\"--rofr\", \"Enable right of first refusal\")\n .option(\"--company-address <address>\", \"Company address as 'street,city,state,zip'\")\n .option(\"--json\", \"Output as JSON\")\n .option(\"--dry-run\", \"Show the request without creating the pending entity\")\n .action(async (opts, cmd) => {\n const { formCreateCommand } = await import(\"./commands/form.js\");\n await formCreateCommand({\n ...opts,\n json: inheritOption(opts.json, cmd.parent!.opts().json),\n dryRun: inheritOption(opts.dryRun, cmd.parent!.opts().dryRun),\n });\n });\nformCmd.command(\"add-founder <entity-id>\")\n .description(\"Add a founder to a pending entity (staged flow step 2)\")\n .requiredOption(\"--name <name>\", \"Founder name\")\n .requiredOption(\"--email <email>\", \"Founder email\")\n .requiredOption(\"--role <role>\", \"Role: director|officer|manager|member|chair\")\n .requiredOption(\"--pct <pct>\", \"Ownership percentage\")\n .addOption(new Option(\"--officer-title <title>\", \"Officer title (corporations only)\").choices([\"ceo\", \"cfo\", \"cto\", \"coo\", \"secretary\", \"treasurer\", \"president\", \"vp\", \"other\"]))\n .option(\"--incorporator\", \"Mark as sole incorporator (corporations only)\")\n .option(\"--address <address>\", \"Founder address as 'street,city,state,zip'\")\n .option(\"--json\", \"Output as JSON\")\n .option(\"--dry-run\", \"Show the request without adding the founder\")\n .action(async (entityId: string, opts, cmd) => {\n const { formAddFounderCommand } = await import(\"./commands/form.js\");\n await formAddFounderCommand(entityId, {\n ...opts,\n json: inheritOption(opts.json, cmd.parent!.opts().json),\n dryRun: inheritOption(opts.dryRun, cmd.parent!.opts().dryRun),\n });\n });\nformCmd.command(\"finalize <entity-id>\")\n .description(\"Finalize formation and generate documents + cap table (staged flow step 3)\")\n .option(\"--authorized-shares <count>\", \"Authorized shares for corporations\")\n .option(\"--par-value <value>\", \"Par value per share, e.g. 0.0001\")\n .option(\"--board-size <count>\", \"Board size for corporations\")\n .option(\"--principal-name <name>\", \"Principal or manager name for LLCs\")\n .option(\"--registered-agent-name <name>\", \"Registered agent legal name\")\n .option(\"--registered-agent-address <address>\", \"Registered agent address line\")\n .option(\"--formation-date <date>\", \"Formation date (RFC3339 or YYYY-MM-DD)\")\n .option(\"--fiscal-year-end <date>\", \"Fiscal year end (MM-DD)\")\n .option(\"--s-corp\", \"Elect S-Corp status\")\n .option(\"--transfer-restrictions\", \"Enable transfer restrictions\")\n .option(\"--rofr\", \"Enable right of first refusal\")\n .option(\"--company-address <address>\", \"Company address as 'street,city,state,zip'\")\n .option(\"--incorporator-name <name>\", \"Incorporator legal name (overrides founder)\")\n .option(\"--incorporator-address <address>\", \"Incorporator mailing address (overrides founder)\")\n .option(\"--json\", \"Output as JSON\")\n .option(\"--dry-run\", \"Show the request without finalizing formation\")\n .action(async (entityId: string, opts, cmd) => {\n const { formFinalizeCommand } = await import(\"./commands/form.js\");\n await formFinalizeCommand(entityId, {\n ...opts,\n json: inheritOption(opts.json, cmd.parent!.opts().json),\n dryRun: inheritOption(opts.dryRun, cmd.parent!.opts().dryRun),\n });\n });\n\n// --- api-keys ---\nprogram\n .command(\"api-keys\")\n .description(\"List API keys\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (opts) => {\n const { apiKeysCommand } = await import(\"./commands/api-keys.js\");\n await apiKeysCommand(opts);\n });\n\n// --- demo ---\nprogram\n .command(\"demo\")\n .description(\"Seed a fully-populated demo corporation\")\n .requiredOption(\"--name <name>\", \"Corporation name\")\n .action(async (opts) => {\n const { demoCommand } = await import(\"./commands/demo.js\");\n await demoCommand(opts);\n });\n\n// --- feedback ---\nprogram\n .command(\"feedback\")\n .description(\"Submit feedback to TheCorporation\")\n .argument(\"<message>\", \"Feedback message\")\n .option(\"--category <category>\", \"Category (e.g. bug, feature, general)\", \"general\")\n .option(\"--email <email>\", \"Your email address (to receive a copy)\")\n .action(async (message, opts) => {\n const { feedbackCommand } = await import(\"./commands/feedback.js\");\n await feedbackCommand(message, opts);\n });\n\n// --- serve ---\nprogram\n .command(\"serve\")\n .description(\"Start the API server locally\")\n .option(\"--port <port>\", \"Port to listen on\", \"8000\")\n .option(\"--data-dir <path>\", \"Data directory\", \"./data/repos\")\n .action(async (opts) => {\n const { serveCommand } = await import(\"./commands/serve.js\");\n await serveCommand(opts);\n });\n\nawait program.parseAsync(process.argv);\n","export function inheritOption<T>(localValue: T | undefined, parentValue: T | undefined): T | undefined {\n return localValue ?? parentValue;\n}\n"],"mappings":";;;;;;;;;;;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,eAAe;AACxB,SAAS,YAAY;AA2CrB,SAAS,UAAU,IAAkB;AACnC,UAAQ,KAAK,oBAAoB,GAAG,GAAG,EAAE;AAC3C;AAEA,SAAS,eAAkB,I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S;AACtB,QAAM,EAAE,gBAAAC,gBAAe,IAAI,MAAM;AACjC,QAAMA,gBAAe,IAAI;AAC3B,CAAC;AAGH,QACG,QAAQ,MAAM,EACd,YAAY,yCAAyC,EACrD,eAAe,iBAAiB,kBAAkB,EAClD,OAAO,OAAO,SAAS;AACtB,QAAM,EAAE,aAAAC,aAAY,IAAI,MAAM;AAC9B,QAAMA,aAAY,IAAI;AACxB,CAAC;AAGH,QACG,QAAQ,UAAU,EAClB,YAAY,mCAAmC,EAC/C,SAAS,aAAa,kBAAkB,EACxC,OAAO,yBAAyB,yCAAyC,SAAS,EAClF,OAAO,mBAAmB,wCAAwC,EAClE,OAAO,OAAO,SAAS,SAAS;AAC/B,QAAM,EAAE,iBAAAC,iBAAgB,IAAI,MAAM;AAClC,QAAMA,iBAAgB,SAAS,IAAI;AACrC,CAAC;AAGH,QACG,QAAQ,OAAO,EACf,YAAY,8BAA8B,EAC1C,OAAO,iBAAiB,qBAAqB,MAAM,EACnD,OAAO,qBAAqB,kBAAkB,cAAc,EAC5D,OAAO,OAAO,SAAS;AACtB,QAAM,EAAE,cAAAC,cAAa,IAAI,MAAM;AAC/B,QAAMA,cAAa,IAAI;AACzB,CAAC;AAEH,MAAM,QAAQ,WAAW,QAAQ,IAAI;","names":["s","holders","chalk","program","init_config","join","homedir","chalk","resolve","chalk","chalk","chalk","chalk","Table","chalk","readFileSync","s","chalk","input","confirm","chalk","Table","readFileSync","chalk","Table","chalk","readFileSync","writeFileSync","existsSync","resolve","require","setupCommand","statusCommand","contextCommand","schemaCommand","configSetCommand","configGetCommand","configListCommand","obligationsCommand","digestCommand","linkCommand","claimCommand","chatCommand","entitiesCommand","entitiesShowCommand","entitiesConvertCommand","entitiesDissolveCommand","contactsListCommand","contactsShowCommand","contactsAddCommand","contactsEditCommand","capTableCommand","safesCommand","transfersCommand","valuationsCommand","fourOhNineACommand","createInstrumentCommand","issueEquityCommand","issueSafeCommand","transferSharesCommand","distributeCommand","startRoundCommand","addSecurityCommand","issueRoundCommand","createValuationCommand","submitValuationCommand","approveValuationCommand","financeInvoiceCommand","financePayrollCommand","financePayCommand","financeOpenAccountCommand","financeClassifyContractorCommand","financeReconcileCommand","governanceListCommand","governanceCreateBodyCommand","governanceAddSeatCommand","governanceSeatsCommand","governanceMeetingsCommand","governanceResolutionsCommand","governanceConveneCommand","governanceOpenMeetingCommand","governanceVoteCommand","sendNoticeCommand","adjournMeetingCommand","cancelMeetingCommand","listAgendaItemsCommand","finalizeAgendaItemCommand","computeResolutionCommand","writtenConsentCommand","documentsListCommand","documentsSigningLinkCommand","documentsGenerateCommand","documentsPreviewPdfCommand","taxFileCommand","taxDeadlineCommand","agentsListCommand","agentsShowCommand","agentsCreateCommand","agentsPauseCommand","agentsResumeCommand","agentsDeleteCommand","agentsMessageCommand","agentsSkillCommand","workItemsListCommand","workItemsShowCommand","workItemsCreateCommand","workItemsClaimCommand","workItemsCompleteCommand","workItemsReleaseCommand","workItemsCancelCommand","billingCommand","billingPortalCommand","billingUpgradeCommand","printError","formCommand","formCreateCommand","formAddFounderCommand","formFinalizeCommand","apiKeysCommand","demoCommand","feedbackCommand","serveCommand"]}
|