@thecorporation/cli 26.3.2 → 26.3.3
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 +316 -166
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -10,6 +10,17 @@ var __export = (target, all) => {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
// src/config.ts
|
|
13
|
+
var config_exports = {};
|
|
14
|
+
__export(config_exports, {
|
|
15
|
+
configForDisplay: () => configForDisplay,
|
|
16
|
+
getValue: () => getValue,
|
|
17
|
+
loadConfig: () => loadConfig,
|
|
18
|
+
maskKey: () => maskKey,
|
|
19
|
+
requireConfig: () => requireConfig,
|
|
20
|
+
resolveEntityId: () => resolveEntityId,
|
|
21
|
+
saveConfig: () => saveConfig,
|
|
22
|
+
setValue: () => setValue
|
|
23
|
+
});
|
|
13
24
|
import { readFileSync, writeFileSync, mkdirSync, existsSync } from "fs";
|
|
14
25
|
import { join } from "path";
|
|
15
26
|
import { homedir } from "os";
|
|
@@ -122,6 +133,29 @@ var init_api_client = __esm({
|
|
|
122
133
|
});
|
|
123
134
|
|
|
124
135
|
// src/output.ts
|
|
136
|
+
var output_exports = {};
|
|
137
|
+
__export(output_exports, {
|
|
138
|
+
printAgentsTable: () => printAgentsTable,
|
|
139
|
+
printApprovalsTable: () => printApprovalsTable,
|
|
140
|
+
printBillingPanel: () => printBillingPanel,
|
|
141
|
+
printCapTable: () => printCapTable,
|
|
142
|
+
printContactsTable: () => printContactsTable,
|
|
143
|
+
printDocumentsTable: () => printDocumentsTable,
|
|
144
|
+
printEntitiesTable: () => printEntitiesTable,
|
|
145
|
+
printError: () => printError,
|
|
146
|
+
printGovernanceTable: () => printGovernanceTable,
|
|
147
|
+
printJson: () => printJson,
|
|
148
|
+
printMeetingsTable: () => printMeetingsTable,
|
|
149
|
+
printObligationsTable: () => printObligationsTable,
|
|
150
|
+
printResolutionsTable: () => printResolutionsTable,
|
|
151
|
+
printSafesTable: () => printSafesTable,
|
|
152
|
+
printSeatsTable: () => printSeatsTable,
|
|
153
|
+
printStatusPanel: () => printStatusPanel,
|
|
154
|
+
printSuccess: () => printSuccess,
|
|
155
|
+
printTransfersTable: () => printTransfersTable,
|
|
156
|
+
printValuationsTable: () => printValuationsTable,
|
|
157
|
+
printWarning: () => printWarning
|
|
158
|
+
});
|
|
125
159
|
import chalk from "chalk";
|
|
126
160
|
import Table from "cli-table3";
|
|
127
161
|
function printError(msg) {
|
|
@@ -130,6 +164,9 @@ function printError(msg) {
|
|
|
130
164
|
function printSuccess(msg) {
|
|
131
165
|
console.log(chalk.green(msg));
|
|
132
166
|
}
|
|
167
|
+
function printWarning(msg) {
|
|
168
|
+
console.log(chalk.yellow(msg));
|
|
169
|
+
}
|
|
133
170
|
function printJson(data) {
|
|
134
171
|
console.log(JSON.stringify(data, null, 2));
|
|
135
172
|
}
|
|
@@ -364,35 +401,30 @@ function printApprovalsTable(approvals) {
|
|
|
364
401
|
console.log(table.toString());
|
|
365
402
|
}
|
|
366
403
|
function printBillingPanel(status, plans) {
|
|
367
|
-
const
|
|
368
|
-
const
|
|
369
|
-
const
|
|
404
|
+
const plan = s(status.plan ?? status.tier) || "free";
|
|
405
|
+
const subStatus = s(status.status) || "active";
|
|
406
|
+
const periodEnd = s(status.current_period_end);
|
|
370
407
|
console.log(chalk.green("\u2500".repeat(50)));
|
|
371
408
|
console.log(chalk.green.bold(" Billing Status"));
|
|
372
409
|
console.log(chalk.green("\u2500".repeat(50)));
|
|
373
|
-
console.log(` ${chalk.bold("
|
|
374
|
-
console.log(` ${chalk.bold("
|
|
375
|
-
|
|
376
|
-
console.log(` - ${sub.tier ?? "N/A"} (${sub.status ?? "N/A"})`);
|
|
377
|
-
}
|
|
378
|
-
console.log(` ${chalk.bold("Tool Calls:")} ${usageCount}`);
|
|
410
|
+
console.log(` ${chalk.bold("Plan:")} ${plan}`);
|
|
411
|
+
console.log(` ${chalk.bold("Status:")} ${subStatus}`);
|
|
412
|
+
if (periodEnd) console.log(` ${chalk.bold("Current Period End:")} ${periodEnd}`);
|
|
379
413
|
console.log(chalk.dim(" Manage: corp billing portal"));
|
|
380
|
-
console.log(chalk.dim(" Upgrade: corp billing upgrade"));
|
|
414
|
+
console.log(chalk.dim(" Upgrade: corp billing upgrade --plan <plan>"));
|
|
381
415
|
console.log(chalk.green("\u2500".repeat(50)));
|
|
382
416
|
if (plans.length > 0) {
|
|
383
|
-
const table = makeTable("Available Plans", ["
|
|
417
|
+
const table = makeTable("Available Plans", ["Plan", "Price", "Features"]);
|
|
384
418
|
for (const p of plans) {
|
|
385
|
-
const amount = p.amount ?? 0;
|
|
419
|
+
const amount = p.price_cents ?? p.amount ?? 0;
|
|
386
420
|
const interval = s(p.interval);
|
|
387
421
|
let priceStr = "Free";
|
|
388
422
|
if (amount > 0) {
|
|
389
|
-
priceStr = interval ? `$${Math.round(amount / 100)}/${interval
|
|
423
|
+
priceStr = interval ? `$${Math.round(amount / 100)}/${interval}` : `$${Math.round(amount / 100)}`;
|
|
390
424
|
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
if (desc.length > 60) desc = desc.slice(0, 57) + "...";
|
|
395
|
-
table.push([name, priceStr, s(p.type), desc]);
|
|
425
|
+
const name = s(p.name ?? p.plan_id ?? p.tier);
|
|
426
|
+
const features = Array.isArray(p.features) ? p.features.join(", ") : s(p.description);
|
|
427
|
+
table.push([name, priceStr, features]);
|
|
396
428
|
}
|
|
397
429
|
console.log(table.toString());
|
|
398
430
|
}
|
|
@@ -682,8 +714,8 @@ var init_status = __esm({
|
|
|
682
714
|
});
|
|
683
715
|
|
|
684
716
|
// src/commands/config.ts
|
|
685
|
-
var
|
|
686
|
-
__export(
|
|
717
|
+
var config_exports2 = {};
|
|
718
|
+
__export(config_exports2, {
|
|
687
719
|
configGetCommand: () => configGetCommand,
|
|
688
720
|
configListCommand: () => configListCommand,
|
|
689
721
|
configSetCommand: () => configSetCommand
|
|
@@ -1035,7 +1067,7 @@ async function chatCommand() {
|
|
|
1035
1067
|
const messages = [{ role: "system", content: SYSTEM_PROMPT }];
|
|
1036
1068
|
let totalTokens = 0;
|
|
1037
1069
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
1038
|
-
const prompt = () => new Promise((
|
|
1070
|
+
const prompt = () => new Promise((resolve2) => rl.question(chalk2.green.bold("> "), resolve2));
|
|
1039
1071
|
console.log(chalk2.blue.bold("corp chat") + " \u2014 type /help for commands, /quit to exit\n");
|
|
1040
1072
|
const slashHandlers = {
|
|
1041
1073
|
"/status": async () => {
|
|
@@ -1245,7 +1277,7 @@ async function entitiesConvertCommand(entityId, opts) {
|
|
|
1245
1277
|
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
1246
1278
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
1247
1279
|
try {
|
|
1248
|
-
const data = {
|
|
1280
|
+
const data = { target_type: opts.to };
|
|
1249
1281
|
if (opts.jurisdiction) data.new_jurisdiction = opts.jurisdiction;
|
|
1250
1282
|
const result = await client.convertEntity(entityId, data);
|
|
1251
1283
|
printSuccess(`Entity conversion initiated: ${result.conversion_id ?? "OK"}`);
|
|
@@ -1290,9 +1322,10 @@ __export(contacts_exports, {
|
|
|
1290
1322
|
import chalk4 from "chalk";
|
|
1291
1323
|
async function contactsListCommand(opts) {
|
|
1292
1324
|
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
1325
|
+
const eid = resolveEntityId(cfg, opts.entityId);
|
|
1293
1326
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
1294
1327
|
try {
|
|
1295
|
-
const contacts = await client.listContacts();
|
|
1328
|
+
const contacts = await client.listContacts(eid);
|
|
1296
1329
|
if (opts.json) printJson(contacts);
|
|
1297
1330
|
else if (contacts.length === 0) console.log("No contacts found.");
|
|
1298
1331
|
else printContactsTable(contacts);
|
|
@@ -1336,10 +1369,16 @@ async function contactsShowCommand(contactId, opts) {
|
|
|
1336
1369
|
}
|
|
1337
1370
|
async function contactsAddCommand(opts) {
|
|
1338
1371
|
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
1372
|
+
const eid = resolveEntityId(cfg, opts.entityId);
|
|
1339
1373
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
1340
1374
|
try {
|
|
1341
|
-
const data = {
|
|
1342
|
-
|
|
1375
|
+
const data = {
|
|
1376
|
+
entity_id: eid,
|
|
1377
|
+
contact_type: opts.type ?? "individual",
|
|
1378
|
+
name: opts.name,
|
|
1379
|
+
email: opts.email,
|
|
1380
|
+
category: opts.category ?? "employee"
|
|
1381
|
+
};
|
|
1343
1382
|
if (opts.phone) data.phone = opts.phone;
|
|
1344
1383
|
if (opts.notes) data.notes = opts.notes;
|
|
1345
1384
|
const result = await client.createContact(data);
|
|
@@ -1485,13 +1524,48 @@ async function issueEquityCommand(opts) {
|
|
|
1485
1524
|
const eid = resolveEntityId(cfg, opts.entityId);
|
|
1486
1525
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
1487
1526
|
try {
|
|
1488
|
-
const
|
|
1527
|
+
const capTable = await client.getCapTable(eid);
|
|
1528
|
+
const issuerLegalEntityId = capTable.issuer_legal_entity_id;
|
|
1529
|
+
if (!issuerLegalEntityId) {
|
|
1530
|
+
printError("No issuer legal entity found. Has this entity been formed with a cap table?");
|
|
1531
|
+
process.exit(1);
|
|
1532
|
+
}
|
|
1533
|
+
let instrumentId = opts.instrumentId;
|
|
1534
|
+
if (!instrumentId) {
|
|
1535
|
+
const instruments = capTable.instruments;
|
|
1536
|
+
if (!instruments?.length) {
|
|
1537
|
+
printError("No instruments found on cap table. Create an instrument first.");
|
|
1538
|
+
process.exit(1);
|
|
1539
|
+
}
|
|
1540
|
+
const grantLower = opts.grantType.toLowerCase();
|
|
1541
|
+
const match = instruments.find(
|
|
1542
|
+
(i) => i.kind.toLowerCase().includes(grantLower) || i.symbol.toLowerCase().includes(grantLower)
|
|
1543
|
+
) ?? instruments.find((i) => i.kind.toLowerCase().includes("common"));
|
|
1544
|
+
if (match) {
|
|
1545
|
+
instrumentId = match.instrument_id;
|
|
1546
|
+
console.log(`Using instrument: ${match.symbol} (${match.kind})`);
|
|
1547
|
+
} else {
|
|
1548
|
+
instrumentId = instruments[0].instrument_id;
|
|
1549
|
+
console.log(`Using first instrument: ${instruments[0].symbol} (${instruments[0].kind})`);
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
const round = await client.startEquityRound({
|
|
1489
1553
|
entity_id: eid,
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
recipient_name: opts.recipient
|
|
1554
|
+
name: `${opts.grantType} grant \u2014 ${opts.recipient}`,
|
|
1555
|
+
issuer_legal_entity_id: issuerLegalEntityId
|
|
1493
1556
|
});
|
|
1494
|
-
|
|
1557
|
+
const roundId = round.round_id ?? round.equity_round_id;
|
|
1558
|
+
const securityData = {
|
|
1559
|
+
entity_id: eid,
|
|
1560
|
+
instrument_id: instrumentId,
|
|
1561
|
+
quantity: opts.shares,
|
|
1562
|
+
recipient_name: opts.recipient,
|
|
1563
|
+
grant_type: opts.grantType
|
|
1564
|
+
};
|
|
1565
|
+
if (opts.email) securityData.email = opts.email;
|
|
1566
|
+
await client.addRoundSecurity(roundId, securityData);
|
|
1567
|
+
const result = await client.issueRound(roundId, { entity_id: eid });
|
|
1568
|
+
printSuccess(`Equity issued: ${opts.shares} shares (${opts.grantType}) to ${opts.recipient}`);
|
|
1495
1569
|
printJson(result);
|
|
1496
1570
|
} catch (err) {
|
|
1497
1571
|
printError(`Failed to issue equity: ${err}`);
|
|
@@ -1503,14 +1577,36 @@ async function issueSafeCommand(opts) {
|
|
|
1503
1577
|
const eid = resolveEntityId(cfg, opts.entityId);
|
|
1504
1578
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
1505
1579
|
try {
|
|
1506
|
-
const
|
|
1580
|
+
const capTable = await client.getCapTable(eid);
|
|
1581
|
+
const issuerLegalEntityId = capTable.issuer_legal_entity_id;
|
|
1582
|
+
if (!issuerLegalEntityId) {
|
|
1583
|
+
printError("No issuer legal entity found. Has this entity been formed with a cap table?");
|
|
1584
|
+
process.exit(1);
|
|
1585
|
+
}
|
|
1586
|
+
const instruments = capTable.instruments;
|
|
1587
|
+
const safeInstrument = instruments?.find((i) => i.kind.toLowerCase() === "safe");
|
|
1588
|
+
if (!safeInstrument) {
|
|
1589
|
+
printError("No SAFE instrument found on cap table. Create a SAFE instrument first.");
|
|
1590
|
+
process.exit(1);
|
|
1591
|
+
}
|
|
1592
|
+
const round = await client.startEquityRound({
|
|
1507
1593
|
entity_id: eid,
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
safe_type: opts.safeType,
|
|
1511
|
-
valuation_cap_cents: opts.valuationCap
|
|
1594
|
+
name: `SAFE \u2014 ${opts.investor}`,
|
|
1595
|
+
issuer_legal_entity_id: issuerLegalEntityId
|
|
1512
1596
|
});
|
|
1513
|
-
|
|
1597
|
+
const roundId = round.round_id ?? round.equity_round_id;
|
|
1598
|
+
const securityData = {
|
|
1599
|
+
entity_id: eid,
|
|
1600
|
+
instrument_id: safeInstrument.instrument_id,
|
|
1601
|
+
quantity: opts.amount,
|
|
1602
|
+
recipient_name: opts.investor,
|
|
1603
|
+
principal_cents: opts.amount,
|
|
1604
|
+
grant_type: opts.safeType
|
|
1605
|
+
};
|
|
1606
|
+
if (opts.email) securityData.email = opts.email;
|
|
1607
|
+
await client.addRoundSecurity(roundId, securityData);
|
|
1608
|
+
const result = await client.issueRound(roundId, { entity_id: eid });
|
|
1609
|
+
printSuccess(`SAFE issued: $${(opts.amount / 100).toLocaleString()} to ${opts.investor}`);
|
|
1514
1610
|
printJson(result);
|
|
1515
1611
|
} catch (err) {
|
|
1516
1612
|
printError(`Failed to issue SAFE: ${err}`);
|
|
@@ -1524,15 +1620,15 @@ async function transferSharesCommand(opts) {
|
|
|
1524
1620
|
try {
|
|
1525
1621
|
const result = await client.transferShares({
|
|
1526
1622
|
entity_id: eid,
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1623
|
+
from_holder_id: opts.fromGrant,
|
|
1624
|
+
to_holder_id: opts.to,
|
|
1625
|
+
quantity: opts.shares,
|
|
1530
1626
|
transfer_type: opts.type
|
|
1531
1627
|
});
|
|
1532
|
-
printSuccess(`Transfer
|
|
1628
|
+
printSuccess(`Transfer workflow created: ${result.workflow_id ?? "OK"}`);
|
|
1533
1629
|
printJson(result);
|
|
1534
1630
|
} catch (err) {
|
|
1535
|
-
printError(`Failed to transfer
|
|
1631
|
+
printError(`Failed to create transfer workflow: ${err}`);
|
|
1536
1632
|
process.exit(1);
|
|
1537
1633
|
}
|
|
1538
1634
|
}
|
|
@@ -1544,7 +1640,8 @@ async function distributeCommand(opts) {
|
|
|
1544
1640
|
const result = await client.calculateDistribution({
|
|
1545
1641
|
entity_id: eid,
|
|
1546
1642
|
total_amount_cents: opts.amount,
|
|
1547
|
-
distribution_type: opts.type
|
|
1643
|
+
distribution_type: opts.type,
|
|
1644
|
+
description: opts.description
|
|
1548
1645
|
});
|
|
1549
1646
|
printSuccess(`Distribution calculated: ${result.distribution_id ?? "OK"}`);
|
|
1550
1647
|
printJson(result);
|
|
@@ -1743,7 +1840,7 @@ async function financeOpenAccountCommand(opts) {
|
|
|
1743
1840
|
const eid = resolveEntityId(cfg, opts.entityId);
|
|
1744
1841
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
1745
1842
|
try {
|
|
1746
|
-
const result = await client.openBankAccount({ entity_id: eid,
|
|
1843
|
+
const result = await client.openBankAccount({ entity_id: eid, bank_name: opts.institution });
|
|
1747
1844
|
printSuccess(`Bank account opened: ${result.account_id ?? "OK"}`);
|
|
1748
1845
|
printJson(result);
|
|
1749
1846
|
} catch (err) {
|
|
@@ -1805,7 +1902,9 @@ __export(governance_exports, {
|
|
|
1805
1902
|
cancelMeetingCommand: () => cancelMeetingCommand,
|
|
1806
1903
|
computeResolutionCommand: () => computeResolutionCommand,
|
|
1807
1904
|
finalizeAgendaItemCommand: () => finalizeAgendaItemCommand,
|
|
1905
|
+
governanceAddSeatCommand: () => governanceAddSeatCommand,
|
|
1808
1906
|
governanceConveneCommand: () => governanceConveneCommand,
|
|
1907
|
+
governanceCreateBodyCommand: () => governanceCreateBodyCommand,
|
|
1809
1908
|
governanceListCommand: () => governanceListCommand,
|
|
1810
1909
|
governanceMeetingsCommand: () => governanceMeetingsCommand,
|
|
1811
1910
|
governanceResolutionsCommand: () => governanceResolutionsCommand,
|
|
@@ -1815,6 +1914,39 @@ __export(governance_exports, {
|
|
|
1815
1914
|
sendNoticeCommand: () => sendNoticeCommand,
|
|
1816
1915
|
writtenConsentCommand: () => writtenConsentCommand
|
|
1817
1916
|
});
|
|
1917
|
+
async function governanceCreateBodyCommand(opts) {
|
|
1918
|
+
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
1919
|
+
const eid = resolveEntityId(cfg, opts.entityId);
|
|
1920
|
+
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
1921
|
+
try {
|
|
1922
|
+
const result = await client.createGovernanceBody({
|
|
1923
|
+
entity_id: eid,
|
|
1924
|
+
body_type: opts.bodyType,
|
|
1925
|
+
name: opts.name,
|
|
1926
|
+
quorum_rule: opts.quorum,
|
|
1927
|
+
voting_method: opts.voting
|
|
1928
|
+
});
|
|
1929
|
+
printSuccess(`Governance body created: ${result.body_id ?? "OK"}`);
|
|
1930
|
+
printJson(result);
|
|
1931
|
+
} catch (err) {
|
|
1932
|
+
printError(`Failed to create governance body: ${err}`);
|
|
1933
|
+
process.exit(1);
|
|
1934
|
+
}
|
|
1935
|
+
}
|
|
1936
|
+
async function governanceAddSeatCommand(bodyId, opts) {
|
|
1937
|
+
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
1938
|
+
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
1939
|
+
try {
|
|
1940
|
+
const data = { holder_id: opts.holder };
|
|
1941
|
+
if (opts.title) data.title = opts.title;
|
|
1942
|
+
const result = await client.createGovernanceSeat(bodyId, data);
|
|
1943
|
+
printSuccess(`Seat added: ${result.seat_id ?? "OK"}`);
|
|
1944
|
+
printJson(result);
|
|
1945
|
+
} catch (err) {
|
|
1946
|
+
printError(`Failed to add seat: ${err}`);
|
|
1947
|
+
process.exit(1);
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1818
1950
|
async function governanceListCommand(opts) {
|
|
1819
1951
|
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
1820
1952
|
const eid = resolveEntityId(cfg, opts.entityId);
|
|
@@ -2057,7 +2189,8 @@ async function documentsGenerateCommand(opts) {
|
|
|
2057
2189
|
const result = await client.generateContract({
|
|
2058
2190
|
entity_id: eid,
|
|
2059
2191
|
template_type: opts.template,
|
|
2060
|
-
|
|
2192
|
+
counterparty_name: opts.counterparty,
|
|
2193
|
+
effective_date: opts.effectiveDate ?? (/* @__PURE__ */ new Date()).toISOString().slice(0, 10)
|
|
2061
2194
|
});
|
|
2062
2195
|
printSuccess(`Contract generated: ${result.contract_id ?? "OK"}`);
|
|
2063
2196
|
printJson(result);
|
|
@@ -2145,7 +2278,6 @@ __export(agents_exports, {
|
|
|
2145
2278
|
agentsSkillCommand: () => agentsSkillCommand
|
|
2146
2279
|
});
|
|
2147
2280
|
import chalk6 from "chalk";
|
|
2148
|
-
import Table2 from "cli-table3";
|
|
2149
2281
|
async function agentsListCommand(opts) {
|
|
2150
2282
|
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
2151
2283
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
@@ -2164,13 +2296,8 @@ async function agentsShowCommand(agentId, opts) {
|
|
|
2164
2296
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
2165
2297
|
try {
|
|
2166
2298
|
const agent = await client.getAgent(agentId);
|
|
2167
|
-
let usage = {};
|
|
2168
|
-
try {
|
|
2169
|
-
usage = await client.getAgentUsage(agentId);
|
|
2170
|
-
} catch {
|
|
2171
|
-
}
|
|
2172
2299
|
if (opts.json) {
|
|
2173
|
-
printJson(
|
|
2300
|
+
printJson(agent);
|
|
2174
2301
|
return;
|
|
2175
2302
|
}
|
|
2176
2303
|
console.log(chalk6.magenta("\u2500".repeat(40)));
|
|
@@ -2185,12 +2312,8 @@ async function agentsShowCommand(agentId, opts) {
|
|
|
2185
2312
|
if (prompt.length > 100) prompt = prompt.slice(0, 97) + "...";
|
|
2186
2313
|
console.log(` ${chalk6.bold("Prompt:")} ${prompt}`);
|
|
2187
2314
|
}
|
|
2188
|
-
if (
|
|
2189
|
-
console.log(`
|
|
2190
|
-
${chalk6.bold("Usage:")}`);
|
|
2191
|
-
for (const [k, v] of Object.entries(usage)) {
|
|
2192
|
-
if (k !== "agent_id") console.log(` ${k}: ${v}`);
|
|
2193
|
-
}
|
|
2315
|
+
if (agent.skills && Array.isArray(agent.skills) && agent.skills.length > 0) {
|
|
2316
|
+
console.log(` ${chalk6.bold("Skills:")} ${agent.skills.map((s2) => s2.name ?? "?").join(", ")}`);
|
|
2194
2317
|
}
|
|
2195
2318
|
console.log(chalk6.magenta("\u2500".repeat(40)));
|
|
2196
2319
|
} catch (err) {
|
|
@@ -2255,44 +2378,22 @@ async function agentsMessageCommand(agentId, opts) {
|
|
|
2255
2378
|
process.exit(1);
|
|
2256
2379
|
}
|
|
2257
2380
|
}
|
|
2258
|
-
async function agentsExecutionsCommand(agentId,
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
return;
|
|
2266
|
-
}
|
|
2267
|
-
if (executions.length === 0) {
|
|
2268
|
-
console.log("No executions found.");
|
|
2269
|
-
return;
|
|
2270
|
-
}
|
|
2271
|
-
console.log(`
|
|
2272
|
-
${chalk6.bold("Agent Executions")}`);
|
|
2273
|
-
const table = new Table2({ head: [chalk6.dim("ID"), chalk6.dim("Status"), chalk6.dim("Started"), chalk6.dim("Duration")] });
|
|
2274
|
-
for (const ex of executions) {
|
|
2275
|
-
table.push([
|
|
2276
|
-
String(ex.execution_id ?? "").slice(0, 12),
|
|
2277
|
-
String(ex.status ?? ""),
|
|
2278
|
-
String(ex.started_at ?? ""),
|
|
2279
|
-
String(ex.duration ?? "")
|
|
2280
|
-
]);
|
|
2281
|
-
}
|
|
2282
|
-
console.log(table.toString());
|
|
2283
|
-
} catch (err) {
|
|
2284
|
-
printError(`Failed to fetch executions: ${err}`);
|
|
2285
|
-
process.exit(1);
|
|
2286
|
-
}
|
|
2381
|
+
async function agentsExecutionsCommand(agentId, _opts) {
|
|
2382
|
+
printError(
|
|
2383
|
+
`Listing executions is not yet supported.
|
|
2384
|
+
To inspect a specific run, use the execution ID returned by "agents message":
|
|
2385
|
+
GET /v1/agents/${agentId}/executions/<execution-id>`
|
|
2386
|
+
);
|
|
2387
|
+
process.exit(1);
|
|
2287
2388
|
}
|
|
2288
2389
|
async function agentsSkillCommand(agentId, opts) {
|
|
2289
2390
|
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
2290
2391
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
2291
2392
|
try {
|
|
2292
2393
|
const result = await client.addAgentSkill(agentId, {
|
|
2293
|
-
|
|
2394
|
+
name: opts.name,
|
|
2294
2395
|
description: opts.description,
|
|
2295
|
-
instructions: opts.instructions
|
|
2396
|
+
parameters: opts.instructions ? { instructions: opts.instructions } : {}
|
|
2296
2397
|
});
|
|
2297
2398
|
printSuccess(`Skill '${opts.name}' added to agent ${agentId}.`);
|
|
2298
2399
|
printJson(result);
|
|
@@ -2361,13 +2462,13 @@ ${url}`);
|
|
|
2361
2462
|
async function billingUpgradeCommand(opts) {
|
|
2362
2463
|
const client = makeClient();
|
|
2363
2464
|
try {
|
|
2364
|
-
const result = await client.createBillingCheckout(opts.
|
|
2465
|
+
const result = await client.createBillingCheckout(opts.plan);
|
|
2365
2466
|
const url = result.checkout_url;
|
|
2366
2467
|
if (!url) {
|
|
2367
2468
|
printError("No checkout URL returned.");
|
|
2368
2469
|
process.exit(1);
|
|
2369
2470
|
}
|
|
2370
|
-
console.log(`Opening Stripe Checkout for ${opts.
|
|
2471
|
+
console.log(`Opening Stripe Checkout for ${opts.plan}...
|
|
2371
2472
|
${url}`);
|
|
2372
2473
|
openUrl(url);
|
|
2373
2474
|
printSuccess("Checkout opened in your browser.");
|
|
@@ -2385,45 +2486,6 @@ var init_billing = __esm({
|
|
|
2385
2486
|
}
|
|
2386
2487
|
});
|
|
2387
2488
|
|
|
2388
|
-
// src/commands/approvals.ts
|
|
2389
|
-
var approvals_exports = {};
|
|
2390
|
-
__export(approvals_exports, {
|
|
2391
|
-
approvalsListCommand: () => approvalsListCommand,
|
|
2392
|
-
approvalsRespondCommand: () => approvalsRespondCommand
|
|
2393
|
-
});
|
|
2394
|
-
async function approvalsListCommand(opts) {
|
|
2395
|
-
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
2396
|
-
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
2397
|
-
try {
|
|
2398
|
-
const approvals = await client.listPendingApprovals();
|
|
2399
|
-
if (opts.json) printJson(approvals);
|
|
2400
|
-
else if (approvals.length === 0) console.log("No pending approvals.");
|
|
2401
|
-
else printApprovalsTable(approvals);
|
|
2402
|
-
} catch (err) {
|
|
2403
|
-
printError(`Failed to fetch approvals: ${err}`);
|
|
2404
|
-
process.exit(1);
|
|
2405
|
-
}
|
|
2406
|
-
}
|
|
2407
|
-
async function approvalsRespondCommand(approvalId, decision, opts) {
|
|
2408
|
-
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
2409
|
-
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
2410
|
-
try {
|
|
2411
|
-
await client.respondApproval(approvalId, decision, opts.message);
|
|
2412
|
-
printSuccess(`Approval ${approvalId} ${decision}d.`);
|
|
2413
|
-
} catch (err) {
|
|
2414
|
-
printError(`Failed to respond to approval: ${err}`);
|
|
2415
|
-
process.exit(1);
|
|
2416
|
-
}
|
|
2417
|
-
}
|
|
2418
|
-
var init_approvals = __esm({
|
|
2419
|
-
"src/commands/approvals.ts"() {
|
|
2420
|
-
"use strict";
|
|
2421
|
-
init_config();
|
|
2422
|
-
init_api_client();
|
|
2423
|
-
init_output();
|
|
2424
|
-
}
|
|
2425
|
-
});
|
|
2426
|
-
|
|
2427
2489
|
// src/commands/form.ts
|
|
2428
2490
|
var form_exports = {};
|
|
2429
2491
|
__export(form_exports, {
|
|
@@ -2434,7 +2496,7 @@ __export(form_exports, {
|
|
|
2434
2496
|
});
|
|
2435
2497
|
import { input as input2, select, confirm as confirm2, number } from "@inquirer/prompts";
|
|
2436
2498
|
import chalk7 from "chalk";
|
|
2437
|
-
import
|
|
2499
|
+
import Table2 from "cli-table3";
|
|
2438
2500
|
function isCorp(entityType) {
|
|
2439
2501
|
return entityType === "c_corp" || entityType === "s_corp" || entityType === "corporation";
|
|
2440
2502
|
}
|
|
@@ -2458,13 +2520,12 @@ async function phaseEntityDetails(opts, serverCfg, scripted) {
|
|
|
2458
2520
|
if (scripted) {
|
|
2459
2521
|
entityType = "llc";
|
|
2460
2522
|
} else {
|
|
2461
|
-
const types = serverCfg.entity_types ?? ["llc", "c_corp"];
|
|
2462
2523
|
entityType = await select({
|
|
2463
2524
|
message: "Entity type",
|
|
2464
|
-
choices:
|
|
2465
|
-
value:
|
|
2466
|
-
|
|
2467
|
-
|
|
2525
|
+
choices: [
|
|
2526
|
+
{ value: "llc", name: "LLC" },
|
|
2527
|
+
{ value: "c_corp", name: "C-Corp" }
|
|
2528
|
+
]
|
|
2468
2529
|
});
|
|
2469
2530
|
}
|
|
2470
2531
|
}
|
|
@@ -2627,7 +2688,7 @@ function printSummary(entityType, name, jurisdiction, fiscalYearEnd, sCorpElecti
|
|
|
2627
2688
|
console.log(` ${chalk7.bold("Transfer Restrictions:")} ${transferRestrictions ? "Yes" : "No"}`);
|
|
2628
2689
|
console.log(` ${chalk7.bold("Right of First Refusal:")} ${rofr ? "Yes" : "No"}`);
|
|
2629
2690
|
}
|
|
2630
|
-
const table = new
|
|
2691
|
+
const table = new Table2({
|
|
2631
2692
|
head: [chalk7.dim("Name"), chalk7.dim("Email"), chalk7.dim("Role"), chalk7.dim("Equity"), chalk7.dim("Officer")]
|
|
2632
2693
|
});
|
|
2633
2694
|
for (const f of founders) {
|
|
@@ -2695,7 +2756,7 @@ async function formCommand(opts) {
|
|
|
2695
2756
|
const holders = result.holders ?? [];
|
|
2696
2757
|
if (holders.length > 0) {
|
|
2697
2758
|
console.log();
|
|
2698
|
-
const table = new
|
|
2759
|
+
const table = new Table2({
|
|
2699
2760
|
head: [chalk7.dim("Holder"), chalk7.dim("Shares"), chalk7.dim("Ownership %")]
|
|
2700
2761
|
});
|
|
2701
2762
|
for (const h of holders) {
|
|
@@ -2719,7 +2780,7 @@ async function formCreateCommand(opts) {
|
|
|
2719
2780
|
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
2720
2781
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
2721
2782
|
try {
|
|
2722
|
-
const entityType = opts.type === "
|
|
2783
|
+
const entityType = opts.type === "corporation" ? "c_corp" : opts.type;
|
|
2723
2784
|
const payload = {
|
|
2724
2785
|
entity_type: entityType,
|
|
2725
2786
|
legal_name: opts.name
|
|
@@ -2779,7 +2840,7 @@ async function formFinalizeCommand(entityId) {
|
|
|
2779
2840
|
const holders = result.holders ?? [];
|
|
2780
2841
|
if (holders.length > 0) {
|
|
2781
2842
|
console.log();
|
|
2782
|
-
const table = new
|
|
2843
|
+
const table = new Table2({
|
|
2783
2844
|
head: [chalk7.dim("Holder"), chalk7.dim("Shares"), chalk7.dim("Ownership %")]
|
|
2784
2845
|
});
|
|
2785
2846
|
for (const h of holders) {
|
|
@@ -2813,7 +2874,7 @@ __export(api_keys_exports, {
|
|
|
2813
2874
|
apiKeysCommand: () => apiKeysCommand
|
|
2814
2875
|
});
|
|
2815
2876
|
import chalk8 from "chalk";
|
|
2816
|
-
import
|
|
2877
|
+
import Table3 from "cli-table3";
|
|
2817
2878
|
async function apiKeysCommand(opts) {
|
|
2818
2879
|
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
2819
2880
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
@@ -2829,7 +2890,7 @@ async function apiKeysCommand(opts) {
|
|
|
2829
2890
|
}
|
|
2830
2891
|
console.log(`
|
|
2831
2892
|
${chalk8.bold("API Keys")}`);
|
|
2832
|
-
const table = new
|
|
2893
|
+
const table = new Table3({
|
|
2833
2894
|
head: [chalk8.dim("ID"), chalk8.dim("Name"), chalk8.dim("Key"), chalk8.dim("Created"), chalk8.dim("Last Used")]
|
|
2834
2895
|
});
|
|
2835
2896
|
for (const k of keys) {
|
|
@@ -2888,6 +2949,38 @@ var serve_exports = {};
|
|
|
2888
2949
|
__export(serve_exports, {
|
|
2889
2950
|
serveCommand: () => serveCommand
|
|
2890
2951
|
});
|
|
2952
|
+
import { readFileSync as readFileSync2, writeFileSync as writeFileSync2, existsSync as existsSync2 } from "fs";
|
|
2953
|
+
import { resolve } from "path";
|
|
2954
|
+
import { randomBytes } from "crypto";
|
|
2955
|
+
function generateFernetKey() {
|
|
2956
|
+
return randomBytes(32).toString("base64url") + "=";
|
|
2957
|
+
}
|
|
2958
|
+
function generateSecret(length = 32) {
|
|
2959
|
+
return randomBytes(length).toString("hex");
|
|
2960
|
+
}
|
|
2961
|
+
function loadEnvFile(path) {
|
|
2962
|
+
if (!existsSync2(path)) return;
|
|
2963
|
+
const content = readFileSync2(path, "utf-8");
|
|
2964
|
+
for (const line of content.split("\n")) {
|
|
2965
|
+
const trimmed = line.trim();
|
|
2966
|
+
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
2967
|
+
const eqIdx = trimmed.indexOf("=");
|
|
2968
|
+
if (eqIdx === -1) continue;
|
|
2969
|
+
const key = trimmed.slice(0, eqIdx).trim();
|
|
2970
|
+
const value = trimmed.slice(eqIdx + 1).trim().replace(/^["']|["']$/g, "");
|
|
2971
|
+
if (!process.env[key]) {
|
|
2972
|
+
process.env[key] = value;
|
|
2973
|
+
}
|
|
2974
|
+
}
|
|
2975
|
+
}
|
|
2976
|
+
function ensureEnvFile(envPath) {
|
|
2977
|
+
if (existsSync2(envPath)) return;
|
|
2978
|
+
console.log("No .env file found. Generating one with dev defaults...\n");
|
|
2979
|
+
const content = ENV_TEMPLATE.replace("{{JWT_SECRET}}", generateSecret()).replace("{{SECRETS_MASTER_KEY}}", generateFernetKey()).replace("{{INTERNAL_WORKER_TOKEN}}", generateSecret());
|
|
2980
|
+
writeFileSync2(envPath, content, "utf-8");
|
|
2981
|
+
console.log(` Created ${envPath}
|
|
2982
|
+
`);
|
|
2983
|
+
}
|
|
2891
2984
|
async function serveCommand(opts) {
|
|
2892
2985
|
let server;
|
|
2893
2986
|
try {
|
|
@@ -2905,10 +2998,25 @@ async function serveCommand(opts) {
|
|
|
2905
2998
|
process.exit(1);
|
|
2906
2999
|
}
|
|
2907
3000
|
const port = parseInt(opts.port, 10);
|
|
2908
|
-
if (isNaN(port) || port
|
|
3001
|
+
if (isNaN(port) || port > 65535) {
|
|
2909
3002
|
console.error(`Error: Invalid port "${opts.port}"`);
|
|
2910
3003
|
process.exit(1);
|
|
2911
3004
|
}
|
|
3005
|
+
const envPath = resolve(process.cwd(), ".env");
|
|
3006
|
+
ensureEnvFile(envPath);
|
|
3007
|
+
loadEnvFile(envPath);
|
|
3008
|
+
const localUrl = `http://localhost:${port}`;
|
|
3009
|
+
const { loadConfig: loadConfig2, saveConfig: saveConfig2 } = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
3010
|
+
const cfg = loadConfig2();
|
|
3011
|
+
const previousUrl = cfg.api_url;
|
|
3012
|
+
if (cfg.api_url !== localUrl) {
|
|
3013
|
+
cfg.api_url = localUrl;
|
|
3014
|
+
saveConfig2(cfg);
|
|
3015
|
+
console.log(`CLI configured to use local server: ${localUrl}`);
|
|
3016
|
+
console.log(` (previous: ${previousUrl})`);
|
|
3017
|
+
console.log(` To revert: corp config set api_url ${previousUrl}
|
|
3018
|
+
`);
|
|
3019
|
+
}
|
|
2912
3020
|
console.log(`Starting server on port ${port}...`);
|
|
2913
3021
|
console.log(`Data directory: ${opts.dataDir}`);
|
|
2914
3022
|
const child = server.startServer({
|
|
@@ -2917,6 +3025,12 @@ async function serveCommand(opts) {
|
|
|
2917
3025
|
});
|
|
2918
3026
|
const shutdown = () => {
|
|
2919
3027
|
console.log("\nShutting down server...");
|
|
3028
|
+
if (previousUrl !== localUrl) {
|
|
3029
|
+
const current = loadConfig2();
|
|
3030
|
+
current.api_url = previousUrl;
|
|
3031
|
+
saveConfig2(current);
|
|
3032
|
+
console.log(`CLI restored to: ${previousUrl}`);
|
|
3033
|
+
}
|
|
2920
3034
|
child.kill("SIGTERM");
|
|
2921
3035
|
};
|
|
2922
3036
|
process.on("SIGINT", shutdown);
|
|
@@ -2925,9 +3039,40 @@ async function serveCommand(opts) {
|
|
|
2925
3039
|
process.exit(code ?? 0);
|
|
2926
3040
|
});
|
|
2927
3041
|
}
|
|
3042
|
+
var ENV_TEMPLATE;
|
|
2928
3043
|
var init_serve = __esm({
|
|
2929
3044
|
"src/commands/serve.ts"() {
|
|
2930
3045
|
"use strict";
|
|
3046
|
+
ENV_TEMPLATE = `# Corporation API server configuration
|
|
3047
|
+
# Generated by: corp serve
|
|
3048
|
+
|
|
3049
|
+
# Required \u2014 secret for signing JWTs
|
|
3050
|
+
JWT_SECRET={{JWT_SECRET}}
|
|
3051
|
+
|
|
3052
|
+
# Required \u2014 Fernet key for encrypting secrets at rest (base64url, 32 bytes)
|
|
3053
|
+
SECRETS_MASTER_KEY={{SECRETS_MASTER_KEY}}
|
|
3054
|
+
|
|
3055
|
+
# Required \u2014 bearer token for internal worker-to-server auth
|
|
3056
|
+
INTERNAL_WORKER_TOKEN={{INTERNAL_WORKER_TOKEN}}
|
|
3057
|
+
|
|
3058
|
+
# Server port (default: 8000)
|
|
3059
|
+
# PORT=8000
|
|
3060
|
+
|
|
3061
|
+
# Data directory for git repos (default: ./data/repos)
|
|
3062
|
+
# DATA_DIR=./data/repos
|
|
3063
|
+
|
|
3064
|
+
# Redis URL for agent job queue (optional)
|
|
3065
|
+
# REDIS_URL=redis://localhost:6379/0
|
|
3066
|
+
|
|
3067
|
+
# LLM proxy upstream (default: https://openrouter.ai/api/v1)
|
|
3068
|
+
# LLM_UPSTREAM_URL=https://openrouter.ai/api/v1
|
|
3069
|
+
|
|
3070
|
+
# PEM-encoded Ed25519 key for signing git commits (optional)
|
|
3071
|
+
# COMMIT_SIGNING_KEY=
|
|
3072
|
+
|
|
3073
|
+
# Max agent queue depth (default: 1000)
|
|
3074
|
+
# MAX_QUEUE_DEPTH=1000
|
|
3075
|
+
`;
|
|
2931
3076
|
}
|
|
2932
3077
|
});
|
|
2933
3078
|
|
|
@@ -2948,15 +3093,15 @@ program.command("status").description("Workspace summary").action(async () => {
|
|
|
2948
3093
|
});
|
|
2949
3094
|
var configCmd = program.command("config").description("Manage configuration");
|
|
2950
3095
|
configCmd.command("set <key> <value>").description("Set a config value (dot-path)").action(async (key, value) => {
|
|
2951
|
-
const { configSetCommand: configSetCommand2 } = await Promise.resolve().then(() => (init_config2(),
|
|
3096
|
+
const { configSetCommand: configSetCommand2 } = await Promise.resolve().then(() => (init_config2(), config_exports2));
|
|
2952
3097
|
configSetCommand2(key, value);
|
|
2953
3098
|
});
|
|
2954
3099
|
configCmd.command("get <key>").description("Get a config value (dot-path)").action(async (key) => {
|
|
2955
|
-
const { configGetCommand: configGetCommand2 } = await Promise.resolve().then(() => (init_config2(),
|
|
3100
|
+
const { configGetCommand: configGetCommand2 } = await Promise.resolve().then(() => (init_config2(), config_exports2));
|
|
2956
3101
|
configGetCommand2(key);
|
|
2957
3102
|
});
|
|
2958
3103
|
configCmd.command("list").description("List all config (API keys masked)").action(async () => {
|
|
2959
|
-
const { configListCommand: configListCommand2 } = await Promise.resolve().then(() => (init_config2(),
|
|
3104
|
+
const { configListCommand: configListCommand2 } = await Promise.resolve().then(() => (init_config2(), config_exports2));
|
|
2960
3105
|
configListCommand2();
|
|
2961
3106
|
});
|
|
2962
3107
|
program.command("obligations").description("List obligations with urgency tiers").option("--tier <tier>", "Filter by urgency tier").option("--json", "Output as JSON").action(async (opts) => {
|
|
@@ -2987,7 +3132,7 @@ entitiesCmd.command("show <entity-id>").option("--json", "Output as JSON").descr
|
|
|
2987
3132
|
const { entitiesShowCommand: entitiesShowCommand2 } = await Promise.resolve().then(() => (init_entities(), entities_exports));
|
|
2988
3133
|
await entitiesShowCommand2(entityId, opts);
|
|
2989
3134
|
});
|
|
2990
|
-
entitiesCmd.command("convert <entity-id>").requiredOption("--to <type>", "Target entity type (llc,
|
|
3135
|
+
entitiesCmd.command("convert <entity-id>").requiredOption("--to <type>", "Target entity type (llc, c_corp)").option("--jurisdiction <jurisdiction>", "New jurisdiction").description("Convert entity to a different type").action(async (entityId, opts) => {
|
|
2991
3136
|
const { entitiesConvertCommand: entitiesConvertCommand2 } = await Promise.resolve().then(() => (init_entities(), entities_exports));
|
|
2992
3137
|
await entitiesConvertCommand2(entityId, opts);
|
|
2993
3138
|
});
|
|
@@ -2995,7 +3140,7 @@ entitiesCmd.command("dissolve <entity-id>").requiredOption("--reason <reason>",
|
|
|
2995
3140
|
const { entitiesDissolveCommand: entitiesDissolveCommand2 } = await Promise.resolve().then(() => (init_entities(), entities_exports));
|
|
2996
3141
|
await entitiesDissolveCommand2(entityId, opts);
|
|
2997
3142
|
});
|
|
2998
|
-
var contactsCmd = program.command("contacts").description("Contact management").option("--json", "Output as JSON").action(async (opts) => {
|
|
3143
|
+
var contactsCmd = program.command("contacts").description("Contact management").option("--entity-id <id>", "Entity ID (overrides active entity)").option("--json", "Output as JSON").action(async (opts) => {
|
|
2999
3144
|
const { contactsListCommand: contactsListCommand2 } = await Promise.resolve().then(() => (init_contacts(), contacts_exports));
|
|
3000
3145
|
await contactsListCommand2(opts);
|
|
3001
3146
|
});
|
|
@@ -3003,15 +3148,16 @@ contactsCmd.command("show <contact-id>").option("--json", "Output as JSON").desc
|
|
|
3003
3148
|
const { contactsShowCommand: contactsShowCommand2 } = await Promise.resolve().then(() => (init_contacts(), contacts_exports));
|
|
3004
3149
|
await contactsShowCommand2(contactId, opts);
|
|
3005
3150
|
});
|
|
3006
|
-
contactsCmd.command("add").requiredOption("--name <name>", "Contact name").requiredOption("--email <email>", "Contact email").option("--
|
|
3151
|
+
contactsCmd.command("add").requiredOption("--name <name>", "Contact name").requiredOption("--email <email>", "Contact email").option("--type <type>", "Contact type (individual, organization)", "individual").option("--category <category>", "Category (employee, contractor, board_member, investor, law_firm, valuation_firm, accounting_firm, officer, advisor)").option("--phone <phone>", "Phone number").option("--notes <notes>", "Notes").description("Add a new contact").action(async (opts, cmd) => {
|
|
3152
|
+
const parent = cmd.parent.opts();
|
|
3007
3153
|
const { contactsAddCommand: contactsAddCommand2 } = await Promise.resolve().then(() => (init_contacts(), contacts_exports));
|
|
3008
|
-
await contactsAddCommand2(opts);
|
|
3154
|
+
await contactsAddCommand2({ ...opts, entityId: parent.entityId });
|
|
3009
3155
|
});
|
|
3010
3156
|
contactsCmd.command("edit <contact-id>").option("--name <name>", "Contact name").option("--email <email>", "Contact email").option("--category <category>", "Contact category").option("--phone <phone>", "Phone number").option("--notes <notes>", "Notes").description("Edit an existing contact").action(async (contactId, opts) => {
|
|
3011
3157
|
const { contactsEditCommand: contactsEditCommand2 } = await Promise.resolve().then(() => (init_contacts(), contacts_exports));
|
|
3012
3158
|
await contactsEditCommand2(contactId, opts);
|
|
3013
3159
|
});
|
|
3014
|
-
var capTableCmd = program.command("cap-table").description("Cap table, SAFEs, transfers, valuations").option("--entity-id <id>", "Entity ID (overrides active entity)").option("--json", "Output as JSON").action(async (opts) => {
|
|
3160
|
+
var capTableCmd = program.command("cap-table").description("Cap table, equity grants, SAFEs, transfers, and valuations").option("--entity-id <id>", "Entity ID (overrides active entity)").option("--json", "Output as JSON").action(async (opts) => {
|
|
3015
3161
|
const { capTableCommand: capTableCommand2 } = await Promise.resolve().then(() => (init_cap_table(), cap_table_exports));
|
|
3016
3162
|
await capTableCommand2(opts);
|
|
3017
3163
|
});
|
|
@@ -3035,7 +3181,7 @@ capTableCmd.command("409a").description("Current 409A valuation").action(async (
|
|
|
3035
3181
|
const { fourOhNineACommand: fourOhNineACommand2 } = await Promise.resolve().then(() => (init_cap_table(), cap_table_exports));
|
|
3036
3182
|
await fourOhNineACommand2(parent);
|
|
3037
3183
|
});
|
|
3038
|
-
capTableCmd.command("issue-equity").requiredOption("--grant-type <type>", "Grant type").requiredOption("--shares <n>", "Number of shares", parseInt).requiredOption("--recipient <name>", "Recipient name").description("Issue an equity grant").action(async (opts, cmd) => {
|
|
3184
|
+
capTableCmd.command("issue-equity").requiredOption("--grant-type <type>", "Grant type (e.g. founder, advisor, employee, investor)").requiredOption("--shares <n>", "Number of shares", parseInt).requiredOption("--recipient <name>", "Recipient name").option("--email <email>", "Recipient email (auto-creates contact if needed)").option("--instrument-id <id>", "Instrument ID (auto-detected from cap table if omitted)").description("Issue an equity grant (creates a round, adds security, and issues it)").action(async (opts, cmd) => {
|
|
3039
3185
|
const parent = cmd.parent.opts();
|
|
3040
3186
|
const { issueEquityCommand: issueEquityCommand2 } = await Promise.resolve().then(() => (init_cap_table(), cap_table_exports));
|
|
3041
3187
|
await issueEquityCommand2({ ...opts, entityId: parent.entityId });
|
|
@@ -3050,7 +3196,7 @@ capTableCmd.command("transfer").requiredOption("--from-grant <id>", "Source gran
|
|
|
3050
3196
|
const { transferSharesCommand: transferSharesCommand2 } = await Promise.resolve().then(() => (init_cap_table(), cap_table_exports));
|
|
3051
3197
|
await transferSharesCommand2({ ...opts, entityId: parent.entityId });
|
|
3052
3198
|
});
|
|
3053
|
-
capTableCmd.command("distribute").requiredOption("--amount <n>", "Total distribution amount in cents", parseInt).option("--type <type>", "Distribution type", "
|
|
3199
|
+
capTableCmd.command("distribute").requiredOption("--amount <n>", "Total distribution amount in cents", parseInt).option("--type <type>", "Distribution type (dividend, return, liquidation)", "dividend").requiredOption("--description <desc>", "Distribution description").description("Calculate a distribution").action(async (opts, cmd) => {
|
|
3054
3200
|
const parent = cmd.parent.opts();
|
|
3055
3201
|
const { distributeCommand: distributeCommand2 } = await Promise.resolve().then(() => (init_cap_table(), cap_table_exports));
|
|
3056
3202
|
await distributeCommand2({ ...opts, entityId: parent.entityId });
|
|
@@ -3120,6 +3266,15 @@ var governanceCmd = program.command("governance").description("Governance bodies
|
|
|
3120
3266
|
const { governanceListCommand: governanceListCommand2 } = await Promise.resolve().then(() => (init_governance(), governance_exports));
|
|
3121
3267
|
await governanceListCommand2(opts);
|
|
3122
3268
|
});
|
|
3269
|
+
governanceCmd.command("create-body").requiredOption("--name <name>", "Body name (e.g. 'Board of Directors')").requiredOption("--body-type <type>", "Body type (board_of_directors, llc_member_vote)").option("--quorum <rule>", "Quorum rule (majority, supermajority, unanimous)", "majority").option("--voting <method>", "Voting method (per_capita, per_unit)", "per_capita").description("Create a governance body").action(async (opts, cmd) => {
|
|
3270
|
+
const parent = cmd.parent.opts();
|
|
3271
|
+
const { governanceCreateBodyCommand: governanceCreateBodyCommand2 } = await Promise.resolve().then(() => (init_governance(), governance_exports));
|
|
3272
|
+
await governanceCreateBodyCommand2({ ...opts, entityId: parent.entityId });
|
|
3273
|
+
});
|
|
3274
|
+
governanceCmd.command("add-seat <body-id>").requiredOption("--holder <contact-id>", "Contact ID for the seat holder").option("--title <title>", "Seat title (e.g. 'Director', 'Member')").description("Add a seat to a governance body").action(async (bodyId, opts) => {
|
|
3275
|
+
const { governanceAddSeatCommand: governanceAddSeatCommand2 } = await Promise.resolve().then(() => (init_governance(), governance_exports));
|
|
3276
|
+
await governanceAddSeatCommand2(bodyId, opts);
|
|
3277
|
+
});
|
|
3123
3278
|
governanceCmd.command("seats <body-id>").description("Seats for a governance body").action(async (bodyId, _opts, cmd) => {
|
|
3124
3279
|
const parent = cmd.parent.opts();
|
|
3125
3280
|
const { governanceSeatsCommand: governanceSeatsCommand2 } = await Promise.resolve().then(() => (init_governance(), governance_exports));
|
|
@@ -3187,7 +3342,7 @@ documentsCmd.command("signing-link <doc-id>").description("Get a signing link fo
|
|
|
3187
3342
|
const { documentsSigningLinkCommand: documentsSigningLinkCommand2 } = await Promise.resolve().then(() => (init_documents(), documents_exports));
|
|
3188
3343
|
await documentsSigningLinkCommand2(docId);
|
|
3189
3344
|
});
|
|
3190
|
-
documentsCmd.command("generate").requiredOption("--template <type>", "Template type").requiredOption("--counterparty <name>", "Counterparty name").option("--effective-date <date>", "Effective date (ISO 8601)").description("Generate a contract from a template").action(async (opts, cmd) => {
|
|
3345
|
+
documentsCmd.command("generate").requiredOption("--template <type>", "Template type (consulting_agreement, employment_offer, contractor_agreement, nda, custom)").requiredOption("--counterparty <name>", "Counterparty name").option("--effective-date <date>", "Effective date (ISO 8601, defaults to today)").description("Generate a contract from a template").action(async (opts, cmd) => {
|
|
3191
3346
|
const parent = cmd.parent.opts();
|
|
3192
3347
|
const { documentsGenerateCommand: documentsGenerateCommand2 } = await Promise.resolve().then(() => (init_documents(), documents_exports));
|
|
3193
3348
|
await documentsGenerateCommand2({ ...opts, entityId: parent.entityId });
|
|
@@ -3252,23 +3407,18 @@ billingCmd.command("portal").description("Open Stripe Customer Portal").action(a
|
|
|
3252
3407
|
const { billingPortalCommand: billingPortalCommand2 } = await Promise.resolve().then(() => (init_billing(), billing_exports));
|
|
3253
3408
|
await billingPortalCommand2();
|
|
3254
3409
|
});
|
|
3255
|
-
billingCmd.command("upgrade").option("--
|
|
3410
|
+
billingCmd.command("upgrade").option("--plan <plan>", "Plan ID to upgrade to (free, pro, enterprise)", "pro").description("Open Stripe Checkout to upgrade your plan").action(async (opts) => {
|
|
3256
3411
|
const { billingUpgradeCommand: billingUpgradeCommand2 } = await Promise.resolve().then(() => (init_billing(), billing_exports));
|
|
3257
3412
|
await billingUpgradeCommand2(opts);
|
|
3258
3413
|
});
|
|
3259
|
-
|
|
3260
|
-
const {
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
const { approvalsRespondCommand: approvalsRespondCommand2 } = await Promise.resolve().then(() => (init_approvals(), approvals_exports));
|
|
3265
|
-
await approvalsRespondCommand2(approvalId, "approve", opts);
|
|
3266
|
-
});
|
|
3267
|
-
approvalsCmd.command("reject <approval-id>").option("--message <msg>", "Optional message").description("Reject a pending approval").action(async (approvalId, opts) => {
|
|
3268
|
-
const { approvalsRespondCommand: approvalsRespondCommand2 } = await Promise.resolve().then(() => (init_approvals(), approvals_exports));
|
|
3269
|
-
await approvalsRespondCommand2(approvalId, "reject", opts);
|
|
3414
|
+
program.command("approvals").description("Approvals are managed through governance meetings and execution intents").action(async () => {
|
|
3415
|
+
const { printError: printError2 } = await Promise.resolve().then(() => (init_output(), output_exports));
|
|
3416
|
+
printError2(
|
|
3417
|
+
"Approvals are managed through governance meetings.\n Use: corp governance convene ... to schedule a board meeting\n Use: corp governance vote <meeting-id> <item-id> ... to cast votes"
|
|
3418
|
+
);
|
|
3270
3419
|
});
|
|
3271
|
-
var formCmd = program.command("form").description("Form a new entity with founders and cap table (Cooley-style)").option("--type <type>", "Entity type (llc, c_corp)").option("--name <name>", "Legal name").option("--jurisdiction <jurisdiction>", "Jurisdiction (e.g. US-DE, US-WY)").option("--member <member>", "Member as 'name,email,role[,pct]' \u2014 role: director|officer|manager|member|chair (repeatable)", (v, a) => [...a, v], []).option("--address <address>", "Company address as 'street,city,state,zip'").option("--fiscal-year-end <date>", "Fiscal year end (MM-DD)", "12-31").option("--s-corp", "Elect S-Corp status").option("--transfer-restrictions", "Enable transfer restrictions").option("--rofr", "Enable right of first refusal").action(async (opts) => {
|
|
3420
|
+
var formCmd = program.command("form").description("Form a new entity with founders and cap table (Cooley-style)").option("--entity-type <type>", "Entity type (llc, c_corp)").option("--name <name>", "Legal name").option("--jurisdiction <jurisdiction>", "Jurisdiction (e.g. US-DE, US-WY)").option("--member <member>", "Member as 'name,email,role[,pct]' \u2014 role: director|officer|manager|member|chair (repeatable)", (v, a) => [...a, v], []).option("--address <address>", "Company address as 'street,city,state,zip'").option("--fiscal-year-end <date>", "Fiscal year end (MM-DD)", "12-31").option("--s-corp", "Elect S-Corp status").option("--transfer-restrictions", "Enable transfer restrictions").option("--rofr", "Enable right of first refusal").action(async (opts) => {
|
|
3421
|
+
if (opts.entityType && !opts.type) opts.type = opts.entityType;
|
|
3272
3422
|
const { formCommand: formCommand2 } = await Promise.resolve().then(() => (init_form(), form_exports));
|
|
3273
3423
|
await formCommand2(opts);
|
|
3274
3424
|
});
|