@thecorporation/cli 26.3.21 → 26.3.23
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/README.md +46 -11
- package/dist/index.js +1423 -437
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -90,9 +90,13 @@ function allowUnsafeApiUrl() {
|
|
|
90
90
|
return process.env.CORP_UNSAFE_API_URL === "1";
|
|
91
91
|
}
|
|
92
92
|
function validateApiUrl(value) {
|
|
93
|
+
const trimmed = value.trim();
|
|
94
|
+
if (trimmed.startsWith("process://")) {
|
|
95
|
+
return trimmed;
|
|
96
|
+
}
|
|
93
97
|
let parsed;
|
|
94
98
|
try {
|
|
95
|
-
parsed = new URL(
|
|
99
|
+
parsed = new URL(trimmed);
|
|
96
100
|
} catch {
|
|
97
101
|
throw new Error("api_url must be a valid absolute URL");
|
|
98
102
|
}
|
|
@@ -217,6 +221,7 @@ function normalizeConfig(raw) {
|
|
|
217
221
|
cfg.workspace_id = normalizeString(raw.workspace_id) ?? cfg.workspace_id;
|
|
218
222
|
cfg.hosting_mode = normalizeString(raw.hosting_mode) ?? cfg.hosting_mode;
|
|
219
223
|
cfg.active_entity_id = normalizeString(raw.active_entity_id) ?? cfg.active_entity_id;
|
|
224
|
+
cfg.data_dir = normalizeString(raw.data_dir) ?? cfg.data_dir;
|
|
220
225
|
if (isObject(raw.llm)) {
|
|
221
226
|
cfg.llm.provider = normalizeString(raw.llm.provider) ?? cfg.llm.provider;
|
|
222
227
|
cfg.llm.api_key = normalizeString(raw.llm.api_key) ?? cfg.llm.api_key;
|
|
@@ -263,7 +268,8 @@ function serializeConfig(cfg) {
|
|
|
263
268
|
name: normalized.user.name,
|
|
264
269
|
email: normalized.user.email
|
|
265
270
|
},
|
|
266
|
-
active_entity_id: normalized.active_entity_id
|
|
271
|
+
active_entity_id: normalized.active_entity_id,
|
|
272
|
+
...normalized.data_dir ? { data_dir: normalized.data_dir } : {}
|
|
267
273
|
};
|
|
268
274
|
if (normalized.active_entity_ids && Object.keys(normalized.active_entity_ids).length > 0) {
|
|
269
275
|
serialized.active_entity_ids = normalized.active_entity_ids;
|
|
@@ -283,6 +289,20 @@ function serializeAuth(cfg) {
|
|
|
283
289
|
if (normalized.llm.api_key) {
|
|
284
290
|
serialized.llm = { api_key: normalized.llm.api_key };
|
|
285
291
|
}
|
|
292
|
+
const existingAuth = readJsonFile(AUTH_FILE);
|
|
293
|
+
if (isObject(existingAuth) && isObject(existingAuth.server_secrets)) {
|
|
294
|
+
const ss = existingAuth.server_secrets;
|
|
295
|
+
if (typeof ss.jwt_secret === "string" && typeof ss.secrets_master_key === "string" && typeof ss.internal_worker_token === "string") {
|
|
296
|
+
serialized.server_secrets = {
|
|
297
|
+
jwt_secret: ss.jwt_secret,
|
|
298
|
+
secrets_master_key: ss.secrets_master_key,
|
|
299
|
+
internal_worker_token: ss.internal_worker_token
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
if (cfg._server_secrets) {
|
|
304
|
+
serialized.server_secrets = cfg._server_secrets;
|
|
305
|
+
}
|
|
286
306
|
return JSON.stringify(serialized, null, 2) + "\n";
|
|
287
307
|
}
|
|
288
308
|
function requireSupportedConfigKey(dotPath) {
|
|
@@ -311,6 +331,9 @@ function setKnownConfigValue(cfg, dotPath, value) {
|
|
|
311
331
|
case "hosting_mode":
|
|
312
332
|
cfg.hosting_mode = value.trim();
|
|
313
333
|
return;
|
|
334
|
+
case "data_dir":
|
|
335
|
+
cfg.data_dir = value.trim();
|
|
336
|
+
return;
|
|
314
337
|
case "llm.provider":
|
|
315
338
|
cfg.llm.provider = value.trim();
|
|
316
339
|
return;
|
|
@@ -492,7 +515,8 @@ var init_config = __esm({
|
|
|
492
515
|
"llm.base_url",
|
|
493
516
|
"user.name",
|
|
494
517
|
"user.email",
|
|
495
|
-
"active_entity_id"
|
|
518
|
+
"active_entity_id",
|
|
519
|
+
"data_dir"
|
|
496
520
|
]);
|
|
497
521
|
SENSITIVE_CONFIG_KEYS = /* @__PURE__ */ new Set(["api_url", "api_key", "workspace_id"]);
|
|
498
522
|
DEFAULTS = {
|
|
@@ -507,7 +531,8 @@ var init_config = __esm({
|
|
|
507
531
|
base_url: process.env.CORP_LLM_BASE_URL || void 0
|
|
508
532
|
},
|
|
509
533
|
user: { name: "", email: "" },
|
|
510
|
-
active_entity_id: ""
|
|
534
|
+
active_entity_id: "",
|
|
535
|
+
data_dir: ""
|
|
511
536
|
};
|
|
512
537
|
}
|
|
513
538
|
});
|
|
@@ -658,7 +683,11 @@ function describeReferenceRecord(kind, record) {
|
|
|
658
683
|
idFields: ["share_class_id", "id"],
|
|
659
684
|
labelFields: ["class_code", "name", "share_class"]
|
|
660
685
|
},
|
|
661
|
-
round: { idFields: ["round_id", "equity_round_id", "id"], labelFields: ["name"] }
|
|
686
|
+
round: { idFields: ["round_id", "equity_round_id", "id"], labelFields: ["name"] },
|
|
687
|
+
service_request: {
|
|
688
|
+
idFields: ["request_id", "service_request_id", "id"],
|
|
689
|
+
labelFields: ["service_slug", "status"]
|
|
690
|
+
}
|
|
662
691
|
};
|
|
663
692
|
const spec = specs[kind];
|
|
664
693
|
const id = extractId(record, spec.idFields);
|
|
@@ -726,7 +755,8 @@ var init_references = __esm({
|
|
|
726
755
|
"safe_note",
|
|
727
756
|
"instrument",
|
|
728
757
|
"share_class",
|
|
729
|
-
"round"
|
|
758
|
+
"round",
|
|
759
|
+
"service_request"
|
|
730
760
|
];
|
|
731
761
|
VALID_RESOURCE_KINDS = new Set(RESOURCE_KINDS);
|
|
732
762
|
MAX_REFERENCE_INPUT_LEN = 256;
|
|
@@ -755,6 +785,7 @@ var init_references = __esm({
|
|
|
755
785
|
valuationsCache = /* @__PURE__ */ new Map();
|
|
756
786
|
safeNotesCache = /* @__PURE__ */ new Map();
|
|
757
787
|
roundsCache = /* @__PURE__ */ new Map();
|
|
788
|
+
serviceRequestsCache = /* @__PURE__ */ new Map();
|
|
758
789
|
capTableCache = /* @__PURE__ */ new Map();
|
|
759
790
|
agentsCache;
|
|
760
791
|
constructor(client, cfg) {
|
|
@@ -869,6 +900,9 @@ var init_references = __esm({
|
|
|
869
900
|
async resolveRound(entityId, ref) {
|
|
870
901
|
return this.resolve("round", ref, { entityId });
|
|
871
902
|
}
|
|
903
|
+
async resolveServiceRequest(entityId, ref) {
|
|
904
|
+
return this.resolve("service_request", ref, { entityId });
|
|
905
|
+
}
|
|
872
906
|
async find(kind, query, scope = {}) {
|
|
873
907
|
const trimmedQuery = validateReferenceInput(query, "query", { allowEmpty: true });
|
|
874
908
|
const records = await this.listRecords(kind, scope);
|
|
@@ -1056,6 +1090,8 @@ var init_references = __esm({
|
|
|
1056
1090
|
return this.listShareClasses(scope.entityId);
|
|
1057
1091
|
case "round":
|
|
1058
1092
|
return this.listRounds(scope.entityId);
|
|
1093
|
+
case "service_request":
|
|
1094
|
+
return this.listServiceRequestRecords(scope.entityId);
|
|
1059
1095
|
}
|
|
1060
1096
|
})();
|
|
1061
1097
|
return this.attachStableHandles(kind, records, scope.entityId);
|
|
@@ -1320,6 +1356,14 @@ var init_references = __esm({
|
|
|
1320
1356
|
const capTable = await this.getCapTable(entityId);
|
|
1321
1357
|
return Array.isArray(capTable.share_classes) ? capTable.share_classes : [];
|
|
1322
1358
|
}
|
|
1359
|
+
async listServiceRequestRecords(entityId) {
|
|
1360
|
+
if (!entityId) throw new Error("An entity context is required to resolve service requests.");
|
|
1361
|
+
const cached = this.serviceRequestsCache.get(entityId);
|
|
1362
|
+
if (cached) return cached;
|
|
1363
|
+
const requests = await this.client.listServiceRequests(entityId);
|
|
1364
|
+
this.serviceRequestsCache.set(entityId, requests);
|
|
1365
|
+
return requests;
|
|
1366
|
+
}
|
|
1323
1367
|
};
|
|
1324
1368
|
}
|
|
1325
1369
|
});
|
|
@@ -1327,7 +1371,7 @@ var init_references = __esm({
|
|
|
1327
1371
|
// src/output.ts
|
|
1328
1372
|
import chalk from "chalk";
|
|
1329
1373
|
import Table from "cli-table3";
|
|
1330
|
-
function
|
|
1374
|
+
function printError2(msg) {
|
|
1331
1375
|
console.error(chalk.red("Error:"), msg);
|
|
1332
1376
|
}
|
|
1333
1377
|
function printSuccess(msg) {
|
|
@@ -1346,6 +1390,16 @@ function printDryRun(operation, payload) {
|
|
|
1346
1390
|
payload
|
|
1347
1391
|
});
|
|
1348
1392
|
}
|
|
1393
|
+
function printQuietId(record, ...idFields) {
|
|
1394
|
+
if (typeof record !== "object" || record === null) return;
|
|
1395
|
+
const rec = record;
|
|
1396
|
+
for (const field of idFields) {
|
|
1397
|
+
if (typeof rec[field] === "string" && rec[field]) {
|
|
1398
|
+
console.log(rec[field]);
|
|
1399
|
+
return;
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1349
1403
|
function normalizeWriteResultOptions(options) {
|
|
1350
1404
|
if (typeof options === "boolean") {
|
|
1351
1405
|
return { jsonOnly: options };
|
|
@@ -1375,6 +1429,41 @@ function printWriteResult(result, successMessage, options) {
|
|
|
1375
1429
|
printJson(result);
|
|
1376
1430
|
return;
|
|
1377
1431
|
}
|
|
1432
|
+
if (normalized.quiet) {
|
|
1433
|
+
const defaultIdFields = [
|
|
1434
|
+
"entity_id",
|
|
1435
|
+
"agent_id",
|
|
1436
|
+
"meeting_id",
|
|
1437
|
+
"body_id",
|
|
1438
|
+
"seat_id",
|
|
1439
|
+
"work_item_id",
|
|
1440
|
+
"document_id",
|
|
1441
|
+
"invoice_id",
|
|
1442
|
+
"payment_id",
|
|
1443
|
+
"safe_note_id",
|
|
1444
|
+
"valuation_id",
|
|
1445
|
+
"round_id",
|
|
1446
|
+
"instrument_id",
|
|
1447
|
+
"transfer_workflow_id",
|
|
1448
|
+
"distribution_id",
|
|
1449
|
+
"deadline_id",
|
|
1450
|
+
"filing_id",
|
|
1451
|
+
"bank_account_id",
|
|
1452
|
+
"classification_id",
|
|
1453
|
+
"resolution_id",
|
|
1454
|
+
"agenda_item_id",
|
|
1455
|
+
"contact_id",
|
|
1456
|
+
"request_id",
|
|
1457
|
+
"service_request_id",
|
|
1458
|
+
"key_id",
|
|
1459
|
+
"formation_id",
|
|
1460
|
+
"execution_id",
|
|
1461
|
+
"incident_id",
|
|
1462
|
+
"id"
|
|
1463
|
+
];
|
|
1464
|
+
printQuietId(result, ...normalized.idFields ?? defaultIdFields);
|
|
1465
|
+
return;
|
|
1466
|
+
}
|
|
1378
1467
|
printSuccess(successMessage);
|
|
1379
1468
|
if (normalized.referenceKind && typeof result === "object" && result !== null && !Array.isArray(result)) {
|
|
1380
1469
|
printReferenceSummary(normalized.referenceKind, result, {
|
|
@@ -1382,7 +1471,6 @@ function printWriteResult(result, successMessage, options) {
|
|
|
1382
1471
|
showReuseHint: normalized.showReuseHint
|
|
1383
1472
|
});
|
|
1384
1473
|
}
|
|
1385
|
-
printJson(result);
|
|
1386
1474
|
}
|
|
1387
1475
|
function printStatusPanel(data) {
|
|
1388
1476
|
console.log(chalk.blue("\u2500".repeat(50)));
|
|
@@ -1882,6 +1970,33 @@ function printAgentsTable(agents) {
|
|
|
1882
1970
|
}
|
|
1883
1971
|
console.log(table.toString());
|
|
1884
1972
|
}
|
|
1973
|
+
function printServiceCatalogTable(items) {
|
|
1974
|
+
const table = makeTable("Service Catalog", ["Slug", "Name", "Price", "Type"]);
|
|
1975
|
+
for (const item of items) {
|
|
1976
|
+
table.push([
|
|
1977
|
+
s(item.slug),
|
|
1978
|
+
s(item.name),
|
|
1979
|
+
money(item.amount_cents),
|
|
1980
|
+
s(item.price_type)
|
|
1981
|
+
]);
|
|
1982
|
+
}
|
|
1983
|
+
console.log(table.toString());
|
|
1984
|
+
}
|
|
1985
|
+
function printServiceRequestsTable(requests) {
|
|
1986
|
+
const table = makeTable("Service Requests", ["Ref", "Service", "Amount", "Status", "Created"]);
|
|
1987
|
+
for (const r of requests) {
|
|
1988
|
+
const status = s(r.status);
|
|
1989
|
+
const colored = status === "fulfilled" ? chalk.green(status) : status === "paid" ? chalk.cyan(status) : status === "checkout" ? chalk.yellow(status) : status === "failed" ? chalk.dim(status) : status;
|
|
1990
|
+
table.push([
|
|
1991
|
+
formatReferenceCell("service_request", r),
|
|
1992
|
+
s(r.service_slug),
|
|
1993
|
+
money(r.amount_cents),
|
|
1994
|
+
colored,
|
|
1995
|
+
date(r.created_at)
|
|
1996
|
+
]);
|
|
1997
|
+
}
|
|
1998
|
+
console.log(table.toString());
|
|
1999
|
+
}
|
|
1885
2000
|
function printBillingPanel(status, plans) {
|
|
1886
2001
|
const plan = s(status.plan ?? status.tier) || "free";
|
|
1887
2002
|
const subStatus = s(status.status) || "active";
|
|
@@ -1935,7 +2050,15 @@ var setup_exports = {};
|
|
|
1935
2050
|
__export(setup_exports, {
|
|
1936
2051
|
setupCommand: () => setupCommand
|
|
1937
2052
|
});
|
|
1938
|
-
import { input,
|
|
2053
|
+
import { input, select } from "@inquirer/prompts";
|
|
2054
|
+
import { homedir as homedir2 } from "os";
|
|
2055
|
+
import { join as join2 } from "path";
|
|
2056
|
+
import { existsSync as existsSync2, mkdirSync as mkdirSync2, readdirSync } from "fs";
|
|
2057
|
+
import {
|
|
2058
|
+
generateSecret,
|
|
2059
|
+
generateFernetKey,
|
|
2060
|
+
processRequest
|
|
2061
|
+
} from "@thecorporation/corp-tools";
|
|
1939
2062
|
async function requestMagicLink(apiUrl, email, tosAccepted) {
|
|
1940
2063
|
const resp = await fetch(`${apiUrl}/v1/auth/magic-link`, {
|
|
1941
2064
|
method: "POST",
|
|
@@ -1971,9 +2094,6 @@ async function verifyMagicLinkCode(apiUrl, code) {
|
|
|
1971
2094
|
workspace_id: data.workspace_id
|
|
1972
2095
|
};
|
|
1973
2096
|
}
|
|
1974
|
-
function isCloudApi(url) {
|
|
1975
|
-
return url.replace(/\/+$/, "").includes("thecorporation.ai");
|
|
1976
|
-
}
|
|
1977
2097
|
async function magicLinkAuth(apiUrl, email) {
|
|
1978
2098
|
console.log("\nSending magic link to " + email + "...");
|
|
1979
2099
|
await requestMagicLink(apiUrl, email, true);
|
|
@@ -1989,22 +2109,46 @@ async function magicLinkAuth(apiUrl, email) {
|
|
|
1989
2109
|
console.log("Verifying...");
|
|
1990
2110
|
return verifyMagicLinkCode(apiUrl, trimmed);
|
|
1991
2111
|
}
|
|
2112
|
+
function setupDataDir(dirPath) {
|
|
2113
|
+
if (!existsSync2(dirPath)) {
|
|
2114
|
+
mkdirSync2(dirPath, { recursive: true });
|
|
2115
|
+
return { isNew: true };
|
|
2116
|
+
}
|
|
2117
|
+
try {
|
|
2118
|
+
const entries = readdirSync(dirPath);
|
|
2119
|
+
if (entries.length > 0) {
|
|
2120
|
+
console.log("Found existing data, reusing.");
|
|
2121
|
+
return { isNew: false };
|
|
2122
|
+
}
|
|
2123
|
+
} catch {
|
|
2124
|
+
}
|
|
2125
|
+
return { isNew: true };
|
|
2126
|
+
}
|
|
2127
|
+
async function localProvision(dataDir, name) {
|
|
2128
|
+
const resp = processRequest(
|
|
2129
|
+
"process://",
|
|
2130
|
+
"POST",
|
|
2131
|
+
"/v1/workspaces/provision",
|
|
2132
|
+
{ "Content-Type": "application/json" },
|
|
2133
|
+
JSON.stringify({ name }),
|
|
2134
|
+
{ dataDir }
|
|
2135
|
+
);
|
|
2136
|
+
if (!resp.ok) {
|
|
2137
|
+
const detail = await resp.text();
|
|
2138
|
+
throw new Error(`Provision failed: HTTP ${resp.status} \u2014 ${detail}`);
|
|
2139
|
+
}
|
|
2140
|
+
const body = await resp.json();
|
|
2141
|
+
if (!body.api_key || !body.workspace_id) {
|
|
2142
|
+
throw new Error("Provision response missing api_key or workspace_id");
|
|
2143
|
+
}
|
|
2144
|
+
return {
|
|
2145
|
+
api_key: body.api_key,
|
|
2146
|
+
workspace_id: body.workspace_id
|
|
2147
|
+
};
|
|
2148
|
+
}
|
|
1992
2149
|
async function setupCommand() {
|
|
1993
2150
|
const cfg = loadConfig();
|
|
1994
2151
|
console.log("Welcome to corp \u2014 corporate governance from the terminal.\n");
|
|
1995
|
-
const customUrl = process.env.CORP_API_URL;
|
|
1996
|
-
if (customUrl) {
|
|
1997
|
-
try {
|
|
1998
|
-
cfg.api_url = validateApiUrl(customUrl);
|
|
1999
|
-
} catch (err) {
|
|
2000
|
-
printError(`Invalid CORP_API_URL: ${err}`);
|
|
2001
|
-
process.exit(1);
|
|
2002
|
-
}
|
|
2003
|
-
console.log(`Using API: ${cfg.api_url}
|
|
2004
|
-
`);
|
|
2005
|
-
} else {
|
|
2006
|
-
cfg.api_url = CLOUD_API_URL;
|
|
2007
|
-
}
|
|
2008
2152
|
console.log("--- User Info ---");
|
|
2009
2153
|
const user = cfg.user ?? { name: "", email: "" };
|
|
2010
2154
|
user.name = await input({
|
|
@@ -2016,22 +2160,81 @@ async function setupCommand() {
|
|
|
2016
2160
|
default: user.email || void 0
|
|
2017
2161
|
});
|
|
2018
2162
|
cfg.user = user;
|
|
2019
|
-
|
|
2020
|
-
const
|
|
2021
|
-
|
|
2022
|
-
|
|
2163
|
+
console.log("\n--- Hosting Mode ---");
|
|
2164
|
+
const hostingMode = await select({
|
|
2165
|
+
message: "How would you like to run corp?",
|
|
2166
|
+
choices: [
|
|
2167
|
+
{ value: "local", name: "Local (your machine)" },
|
|
2168
|
+
{ value: "cloud", name: "TheCorporation cloud" },
|
|
2169
|
+
{ value: "self-hosted", name: "Self-hosted server (custom URL)" }
|
|
2170
|
+
],
|
|
2171
|
+
default: cfg.hosting_mode || "local"
|
|
2172
|
+
});
|
|
2173
|
+
cfg.hosting_mode = hostingMode;
|
|
2174
|
+
if (hostingMode === "local") {
|
|
2175
|
+
const dataDir = await input({
|
|
2176
|
+
message: "Data directory",
|
|
2177
|
+
default: cfg.data_dir || DEFAULT_DATA_DIR
|
|
2178
|
+
});
|
|
2179
|
+
cfg.data_dir = dataDir;
|
|
2180
|
+
cfg.api_url = "process://";
|
|
2181
|
+
const { isNew } = setupDataDir(dataDir);
|
|
2182
|
+
const serverSecrets = {
|
|
2183
|
+
jwt_secret: generateSecret(),
|
|
2184
|
+
secrets_master_key: generateFernetKey(),
|
|
2185
|
+
internal_worker_token: generateSecret()
|
|
2186
|
+
};
|
|
2187
|
+
process.env.JWT_SECRET = serverSecrets.jwt_secret;
|
|
2188
|
+
process.env.SECRETS_MASTER_KEY = serverSecrets.secrets_master_key;
|
|
2189
|
+
process.env.INTERNAL_WORKER_TOKEN = serverSecrets.internal_worker_token;
|
|
2190
|
+
cfg._server_secrets = serverSecrets;
|
|
2191
|
+
if (isNew || !cfg.workspace_id) {
|
|
2192
|
+
console.log("\nProvisioning workspace...");
|
|
2193
|
+
try {
|
|
2194
|
+
const result = await localProvision(dataDir, `${user.name}'s workspace`);
|
|
2195
|
+
cfg.api_key = result.api_key;
|
|
2196
|
+
cfg.workspace_id = result.workspace_id;
|
|
2197
|
+
printSuccess(`Local workspace ready: ${result.workspace_id}`);
|
|
2198
|
+
} catch (err) {
|
|
2199
|
+
printError2(`Workspace provisioning failed: ${err}`);
|
|
2200
|
+
console.log("You can retry with 'corp setup'.");
|
|
2201
|
+
}
|
|
2202
|
+
} else {
|
|
2203
|
+
console.log("\nExisting workspace found.");
|
|
2204
|
+
}
|
|
2205
|
+
} else if (hostingMode === "cloud") {
|
|
2206
|
+
cfg.api_url = CLOUD_API_URL;
|
|
2207
|
+
cfg.data_dir = "";
|
|
2208
|
+
const needsAuth = !cfg.api_key || !cfg.workspace_id;
|
|
2209
|
+
if (needsAuth) {
|
|
2023
2210
|
try {
|
|
2024
2211
|
const result = await magicLinkAuth(cfg.api_url, user.email);
|
|
2025
2212
|
cfg.api_key = result.api_key;
|
|
2026
2213
|
cfg.workspace_id = result.workspace_id;
|
|
2027
2214
|
printSuccess(`Authenticated. Workspace: ${result.workspace_id}`);
|
|
2028
2215
|
} catch (err) {
|
|
2029
|
-
|
|
2216
|
+
printError2(`Authentication failed: ${err}`);
|
|
2030
2217
|
console.log(
|
|
2031
2218
|
"You can manually set credentials with: corp config set api_key <key>"
|
|
2032
2219
|
);
|
|
2033
2220
|
}
|
|
2034
2221
|
} else {
|
|
2222
|
+
console.log("\nExisting credentials found. Run 'corp status' to verify.");
|
|
2223
|
+
}
|
|
2224
|
+
} else {
|
|
2225
|
+
const url = await input({
|
|
2226
|
+
message: "Server URL",
|
|
2227
|
+
default: cfg.api_url !== CLOUD_API_URL && !cfg.api_url.startsWith("process://") ? cfg.api_url : void 0
|
|
2228
|
+
});
|
|
2229
|
+
try {
|
|
2230
|
+
cfg.api_url = validateApiUrl(url);
|
|
2231
|
+
} catch (err) {
|
|
2232
|
+
printError2(`Invalid URL: ${err}`);
|
|
2233
|
+
process.exit(1);
|
|
2234
|
+
}
|
|
2235
|
+
cfg.data_dir = "";
|
|
2236
|
+
const needsAuth = !cfg.api_key || !cfg.workspace_id;
|
|
2237
|
+
if (needsAuth) {
|
|
2035
2238
|
console.log("\nProvisioning workspace...");
|
|
2036
2239
|
try {
|
|
2037
2240
|
const result = await provisionWorkspace(
|
|
@@ -2042,63 +2245,19 @@ async function setupCommand() {
|
|
|
2042
2245
|
cfg.workspace_id = result.workspace_id;
|
|
2043
2246
|
console.log(`Workspace provisioned: ${result.workspace_id}`);
|
|
2044
2247
|
} catch (err) {
|
|
2045
|
-
|
|
2248
|
+
printError2(`Auto-provision failed: ${err}`);
|
|
2046
2249
|
console.log(
|
|
2047
2250
|
"You can manually set credentials with: corp config set api_key <key>"
|
|
2048
2251
|
);
|
|
2049
2252
|
}
|
|
2050
2253
|
}
|
|
2051
|
-
} else {
|
|
2052
|
-
console.log("\nVerifying existing credentials...");
|
|
2053
|
-
let keyValid = false;
|
|
2054
|
-
try {
|
|
2055
|
-
const resp = await fetch(
|
|
2056
|
-
`${cfg.api_url.replace(/\/+$/, "")}/v1/workspaces/${cfg.workspace_id}/status`,
|
|
2057
|
-
{ headers: { Authorization: `Bearer ${cfg.api_key}` } }
|
|
2058
|
-
);
|
|
2059
|
-
keyValid = resp.status !== 401;
|
|
2060
|
-
} catch {
|
|
2061
|
-
}
|
|
2062
|
-
if (keyValid) {
|
|
2063
|
-
console.log("Credentials OK.");
|
|
2064
|
-
} else {
|
|
2065
|
-
console.log("API key is no longer valid.");
|
|
2066
|
-
const reauth = await confirm({
|
|
2067
|
-
message: cloud ? "Re-authenticate via magic link?" : "Provision a new workspace? (This will replace your current credentials)",
|
|
2068
|
-
default: true
|
|
2069
|
-
});
|
|
2070
|
-
if (reauth) {
|
|
2071
|
-
try {
|
|
2072
|
-
if (cloud) {
|
|
2073
|
-
const result = await magicLinkAuth(cfg.api_url, user.email);
|
|
2074
|
-
cfg.api_key = result.api_key;
|
|
2075
|
-
cfg.workspace_id = result.workspace_id;
|
|
2076
|
-
printSuccess(`Authenticated. Workspace: ${result.workspace_id}`);
|
|
2077
|
-
} else {
|
|
2078
|
-
const result = await provisionWorkspace(
|
|
2079
|
-
cfg.api_url,
|
|
2080
|
-
`${user.name}'s workspace`
|
|
2081
|
-
);
|
|
2082
|
-
cfg.api_key = result.api_key;
|
|
2083
|
-
cfg.workspace_id = result.workspace_id;
|
|
2084
|
-
console.log(`Workspace provisioned: ${result.workspace_id}`);
|
|
2085
|
-
}
|
|
2086
|
-
} catch (err) {
|
|
2087
|
-
printError(`Authentication failed: ${err}`);
|
|
2088
|
-
}
|
|
2089
|
-
} else {
|
|
2090
|
-
console.log(
|
|
2091
|
-
"Keeping existing credentials. You can manually update with: corp config set api_key <key>"
|
|
2092
|
-
);
|
|
2093
|
-
}
|
|
2094
|
-
}
|
|
2095
2254
|
}
|
|
2096
2255
|
saveConfig(cfg);
|
|
2097
2256
|
console.log("\nSettings saved to ~/.corp/config.json");
|
|
2098
2257
|
console.log("Credentials saved to ~/.corp/auth.json");
|
|
2099
2258
|
console.log("Run 'corp status' to verify your connection.");
|
|
2100
2259
|
}
|
|
2101
|
-
var CLOUD_API_URL;
|
|
2260
|
+
var CLOUD_API_URL, DEFAULT_DATA_DIR;
|
|
2102
2261
|
var init_setup = __esm({
|
|
2103
2262
|
"src/commands/setup.ts"() {
|
|
2104
2263
|
"use strict";
|
|
@@ -2106,6 +2265,7 @@ var init_setup = __esm({
|
|
|
2106
2265
|
init_api_client();
|
|
2107
2266
|
init_output();
|
|
2108
2267
|
CLOUD_API_URL = "https://api.thecorporation.ai";
|
|
2268
|
+
DEFAULT_DATA_DIR = join2(homedir2(), ".corp", "data");
|
|
2109
2269
|
}
|
|
2110
2270
|
});
|
|
2111
2271
|
|
|
@@ -2293,7 +2453,7 @@ async function statusCommand(opts = {}) {
|
|
|
2293
2453
|
printStatusPanel(data);
|
|
2294
2454
|
}
|
|
2295
2455
|
} catch (err) {
|
|
2296
|
-
|
|
2456
|
+
printError2(`Failed to fetch status: ${err}`);
|
|
2297
2457
|
process.exit(1);
|
|
2298
2458
|
}
|
|
2299
2459
|
}
|
|
@@ -2376,7 +2536,7 @@ async function contextCommand(opts) {
|
|
|
2376
2536
|
}
|
|
2377
2537
|
console.log(chalk2.blue("\u2500".repeat(50)));
|
|
2378
2538
|
} catch (err) {
|
|
2379
|
-
|
|
2539
|
+
printError2(`Failed to fetch context: ${err}`);
|
|
2380
2540
|
process.exit(1);
|
|
2381
2541
|
}
|
|
2382
2542
|
}
|
|
@@ -2390,6 +2550,36 @@ var init_context = __esm({
|
|
|
2390
2550
|
}
|
|
2391
2551
|
});
|
|
2392
2552
|
|
|
2553
|
+
// src/commands/use.ts
|
|
2554
|
+
var use_exports = {};
|
|
2555
|
+
__export(use_exports, {
|
|
2556
|
+
useCommand: () => useCommand
|
|
2557
|
+
});
|
|
2558
|
+
async function useCommand(entityRef) {
|
|
2559
|
+
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
2560
|
+
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
2561
|
+
const resolver = new ReferenceResolver(client, cfg);
|
|
2562
|
+
try {
|
|
2563
|
+
const entityId = await resolver.resolveEntity(entityRef);
|
|
2564
|
+
setActiveEntityId(cfg, entityId);
|
|
2565
|
+
saveConfig(cfg);
|
|
2566
|
+
const alias = getReferenceAlias("entity", { entity_id: entityId }) ?? entityId;
|
|
2567
|
+
printSuccess(`Active entity set to ${alias} (${entityId})`);
|
|
2568
|
+
} catch (err) {
|
|
2569
|
+
printError2(`Failed to resolve entity: ${err}`);
|
|
2570
|
+
process.exit(1);
|
|
2571
|
+
}
|
|
2572
|
+
}
|
|
2573
|
+
var init_use = __esm({
|
|
2574
|
+
"src/commands/use.ts"() {
|
|
2575
|
+
"use strict";
|
|
2576
|
+
init_config();
|
|
2577
|
+
init_api_client();
|
|
2578
|
+
init_output();
|
|
2579
|
+
init_references();
|
|
2580
|
+
}
|
|
2581
|
+
});
|
|
2582
|
+
|
|
2393
2583
|
// src/commands/schema.ts
|
|
2394
2584
|
var schema_exports = {};
|
|
2395
2585
|
__export(schema_exports, {
|
|
@@ -2476,7 +2666,7 @@ async function configSetCommand(key, value, options = {}) {
|
|
|
2476
2666
|
});
|
|
2477
2667
|
});
|
|
2478
2668
|
} catch (err) {
|
|
2479
|
-
|
|
2669
|
+
printError2(`Failed to update config: ${err}`);
|
|
2480
2670
|
process.exit(1);
|
|
2481
2671
|
}
|
|
2482
2672
|
if (key === "api_key" || key === "llm.api_key") {
|
|
@@ -2493,7 +2683,7 @@ function configGetCommand(key) {
|
|
|
2493
2683
|
const cfg = loadConfig();
|
|
2494
2684
|
const val = getValue(cfg, key);
|
|
2495
2685
|
if (val === void 0) {
|
|
2496
|
-
|
|
2686
|
+
printError2(`Key not found: ${key}`);
|
|
2497
2687
|
process.exit(1);
|
|
2498
2688
|
}
|
|
2499
2689
|
if (typeof val === "object" && val !== null) {
|
|
@@ -2524,7 +2714,7 @@ __export(resolve_exports, {
|
|
|
2524
2714
|
async function resolveCommand(kind, ref, opts) {
|
|
2525
2715
|
const normalizedKind = kind.trim().toLowerCase();
|
|
2526
2716
|
if (!KINDS.has(normalizedKind)) {
|
|
2527
|
-
|
|
2717
|
+
printError2(`Unsupported resolve kind: ${kind}`);
|
|
2528
2718
|
process.exit(1);
|
|
2529
2719
|
}
|
|
2530
2720
|
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
@@ -2626,7 +2816,7 @@ async function resolveCommand(kind, ref, opts) {
|
|
|
2626
2816
|
...meetingId ? { meeting_id: meetingId } : {}
|
|
2627
2817
|
});
|
|
2628
2818
|
} catch (err) {
|
|
2629
|
-
|
|
2819
|
+
printError2(`Failed to resolve reference: ${err}`);
|
|
2630
2820
|
process.exit(1);
|
|
2631
2821
|
}
|
|
2632
2822
|
}
|
|
@@ -2715,7 +2905,7 @@ import Table2 from "cli-table3";
|
|
|
2715
2905
|
async function findCommand(kind, query, opts) {
|
|
2716
2906
|
const normalizedKind = kind.trim().toLowerCase();
|
|
2717
2907
|
if (!KINDS2.has(normalizedKind)) {
|
|
2718
|
-
|
|
2908
|
+
printError2(`Unsupported find kind: ${kind}`);
|
|
2719
2909
|
process.exit(1);
|
|
2720
2910
|
}
|
|
2721
2911
|
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
@@ -2765,7 +2955,7 @@ async function findCommand(kind, query, opts) {
|
|
|
2765
2955
|
}
|
|
2766
2956
|
console.log(table.toString());
|
|
2767
2957
|
} catch (err) {
|
|
2768
|
-
|
|
2958
|
+
printError2(`Failed to find references: ${err}`);
|
|
2769
2959
|
process.exit(1);
|
|
2770
2960
|
}
|
|
2771
2961
|
}
|
|
@@ -2847,7 +3037,7 @@ async function obligationsCommand(opts) {
|
|
|
2847
3037
|
else if (obligations.length === 0) console.log("No obligations found.");
|
|
2848
3038
|
else printObligationsTable(obligations);
|
|
2849
3039
|
} catch (err) {
|
|
2850
|
-
|
|
3040
|
+
printError2(`Failed to fetch obligations: ${err}`);
|
|
2851
3041
|
process.exit(1);
|
|
2852
3042
|
}
|
|
2853
3043
|
}
|
|
@@ -2891,7 +3081,7 @@ async function digestCommand(opts) {
|
|
|
2891
3081
|
else printJson(digests);
|
|
2892
3082
|
}
|
|
2893
3083
|
} catch (err) {
|
|
2894
|
-
|
|
3084
|
+
printError2(`Failed: ${err}`);
|
|
2895
3085
|
process.exit(1);
|
|
2896
3086
|
}
|
|
2897
3087
|
}
|
|
@@ -2917,7 +3107,7 @@ async function linkCommand(opts) {
|
|
|
2917
3107
|
printSuccess(`Workspace linked to ${opts.provider} (external ID: ${opts.externalId})`);
|
|
2918
3108
|
if (data.workspace_id) console.log(` Workspace: ${data.workspace_id}`);
|
|
2919
3109
|
} catch (err) {
|
|
2920
|
-
|
|
3110
|
+
printError2(`${err}`);
|
|
2921
3111
|
process.exit(1);
|
|
2922
3112
|
}
|
|
2923
3113
|
}
|
|
@@ -2951,7 +3141,7 @@ async function claimCommand(code) {
|
|
|
2951
3141
|
detail = body.detail ?? "";
|
|
2952
3142
|
} catch {
|
|
2953
3143
|
}
|
|
2954
|
-
|
|
3144
|
+
printError2(detail || `${resp.status} ${resp.statusText}`);
|
|
2955
3145
|
process.exit(1);
|
|
2956
3146
|
}
|
|
2957
3147
|
const data = await resp.json();
|
|
@@ -2962,7 +3152,7 @@ async function claimCommand(code) {
|
|
|
2962
3152
|
console.log("Credentials saved to ~/.corp/auth.json");
|
|
2963
3153
|
console.log("Settings remain in ~/.corp/config.json");
|
|
2964
3154
|
} catch (err) {
|
|
2965
|
-
|
|
3155
|
+
printError2(`${err}`);
|
|
2966
3156
|
process.exit(1);
|
|
2967
3157
|
}
|
|
2968
3158
|
}
|
|
@@ -3114,11 +3304,11 @@ import {
|
|
|
3114
3304
|
isWriteTool as _isWriteTool,
|
|
3115
3305
|
executeTool as _executeTool
|
|
3116
3306
|
} from "@thecorporation/corp-tools";
|
|
3117
|
-
import { join as
|
|
3118
|
-
import { homedir as
|
|
3307
|
+
import { join as join3 } from "path";
|
|
3308
|
+
import { homedir as homedir3 } from "os";
|
|
3119
3309
|
async function executeTool(name, args, client) {
|
|
3120
3310
|
return _executeTool(name, args, client, {
|
|
3121
|
-
dataDir:
|
|
3311
|
+
dataDir: join3(homedir3(), ".corp"),
|
|
3122
3312
|
onEntityFormed: (entityId) => {
|
|
3123
3313
|
try {
|
|
3124
3314
|
updateConfig((cfg) => {
|
|
@@ -3159,7 +3349,7 @@ async function chatCommand() {
|
|
|
3159
3349
|
try {
|
|
3160
3350
|
printStatusPanel(await client.getStatus());
|
|
3161
3351
|
} catch (e) {
|
|
3162
|
-
|
|
3352
|
+
printError2(`Status error: ${e}`);
|
|
3163
3353
|
}
|
|
3164
3354
|
},
|
|
3165
3355
|
"/obligations": async () => {
|
|
@@ -3169,7 +3359,7 @@ async function chatCommand() {
|
|
|
3169
3359
|
if (obls.length) printObligationsTable(obls);
|
|
3170
3360
|
else console.log(chalk4.dim("No obligations found."));
|
|
3171
3361
|
} catch (e) {
|
|
3172
|
-
|
|
3362
|
+
printError2(`Obligations error: ${e}`);
|
|
3173
3363
|
}
|
|
3174
3364
|
},
|
|
3175
3365
|
"/digest": async () => {
|
|
@@ -3178,7 +3368,7 @@ async function chatCommand() {
|
|
|
3178
3368
|
if (digests.length) printJson(digests);
|
|
3179
3369
|
else console.log(chalk4.dim("No digest history."));
|
|
3180
3370
|
} catch (e) {
|
|
3181
|
-
|
|
3371
|
+
printError2(`Digest error: ${e}`);
|
|
3182
3372
|
}
|
|
3183
3373
|
},
|
|
3184
3374
|
"/config": () => printJson(configForDisplay(cfg)),
|
|
@@ -3235,7 +3425,7 @@ ${chalk4.bold("Chat Slash Commands")}
|
|
|
3235
3425
|
await handler(args);
|
|
3236
3426
|
continue;
|
|
3237
3427
|
}
|
|
3238
|
-
|
|
3428
|
+
printError2(`Unknown command: ${cmd}. Type /help for available commands.`);
|
|
3239
3429
|
continue;
|
|
3240
3430
|
}
|
|
3241
3431
|
messages.push({ role: "user", content: userInput });
|
|
@@ -3252,7 +3442,7 @@ ${chalk4.bold("Chat Slash Commands")}
|
|
|
3252
3442
|
llmCfg.base_url
|
|
3253
3443
|
);
|
|
3254
3444
|
} catch (err) {
|
|
3255
|
-
|
|
3445
|
+
printError2(`LLM error: ${err}`);
|
|
3256
3446
|
break;
|
|
3257
3447
|
}
|
|
3258
3448
|
totalTokens += response.usage.total_tokens;
|
|
@@ -3310,6 +3500,7 @@ __export(entities_exports, {
|
|
|
3310
3500
|
entitiesDissolveCommand: () => entitiesDissolveCommand,
|
|
3311
3501
|
entitiesShowCommand: () => entitiesShowCommand
|
|
3312
3502
|
});
|
|
3503
|
+
import { confirm as confirm2 } from "@inquirer/prompts";
|
|
3313
3504
|
import chalk5 from "chalk";
|
|
3314
3505
|
async function entitiesCommand(opts) {
|
|
3315
3506
|
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
@@ -3327,7 +3518,7 @@ async function entitiesCommand(opts) {
|
|
|
3327
3518
|
printEntitiesTable(entities);
|
|
3328
3519
|
}
|
|
3329
3520
|
} catch (err) {
|
|
3330
|
-
|
|
3521
|
+
printError2(`Failed to fetch entities: ${err}`);
|
|
3331
3522
|
process.exit(1);
|
|
3332
3523
|
}
|
|
3333
3524
|
}
|
|
@@ -3341,7 +3532,7 @@ async function entitiesShowCommand(entityId, opts) {
|
|
|
3341
3532
|
const entities = await client.listEntities();
|
|
3342
3533
|
const entity = entities.find((e) => e.entity_id === resolvedEntityId);
|
|
3343
3534
|
if (!entity) {
|
|
3344
|
-
|
|
3535
|
+
printError2(`Entity not found: ${entityId}`);
|
|
3345
3536
|
process.exit(1);
|
|
3346
3537
|
}
|
|
3347
3538
|
await resolver.stabilizeRecord("entity", entity);
|
|
@@ -3362,7 +3553,7 @@ async function entitiesShowCommand(entityId, opts) {
|
|
|
3362
3553
|
console.log(chalk5.blue("\u2500".repeat(40)));
|
|
3363
3554
|
}
|
|
3364
3555
|
} catch (err) {
|
|
3365
|
-
|
|
3556
|
+
printError2(`Failed to fetch entities: ${err}`);
|
|
3366
3557
|
process.exit(1);
|
|
3367
3558
|
}
|
|
3368
3559
|
}
|
|
@@ -3378,7 +3569,7 @@ async function entitiesConvertCommand(entityId, opts) {
|
|
|
3378
3569
|
printSuccess(`Entity conversion initiated: ${result.conversion_id ?? "OK"}`);
|
|
3379
3570
|
printJson(result);
|
|
3380
3571
|
} catch (err) {
|
|
3381
|
-
|
|
3572
|
+
printError2(`Failed to convert entity: ${err}`);
|
|
3382
3573
|
process.exit(1);
|
|
3383
3574
|
}
|
|
3384
3575
|
}
|
|
@@ -3388,6 +3579,16 @@ async function entitiesDissolveCommand(entityId, opts) {
|
|
|
3388
3579
|
const resolver = new ReferenceResolver(client, cfg);
|
|
3389
3580
|
try {
|
|
3390
3581
|
const resolvedEntityId = await resolver.resolveEntity(entityId);
|
|
3582
|
+
if (!opts.yes) {
|
|
3583
|
+
const ok = await confirm2({
|
|
3584
|
+
message: `Dissolve entity ${entityId}? This cannot be undone.`,
|
|
3585
|
+
default: false
|
|
3586
|
+
});
|
|
3587
|
+
if (!ok) {
|
|
3588
|
+
console.log("Cancelled.");
|
|
3589
|
+
return;
|
|
3590
|
+
}
|
|
3591
|
+
}
|
|
3391
3592
|
const data = { reason: opts.reason };
|
|
3392
3593
|
if (opts.effectiveDate) data.effective_date = opts.effectiveDate;
|
|
3393
3594
|
const result = await client.dissolveEntity(resolvedEntityId, data);
|
|
@@ -3396,9 +3597,9 @@ async function entitiesDissolveCommand(entityId, opts) {
|
|
|
3396
3597
|
} catch (err) {
|
|
3397
3598
|
const msg = String(err);
|
|
3398
3599
|
if (msg.includes("InvalidTransition") || msg.includes("422")) {
|
|
3399
|
-
|
|
3600
|
+
printError2(`Cannot dissolve entity: only entities with 'active' status can be dissolved. Check the entity's current status with: corp entities show ${entityId}`);
|
|
3400
3601
|
} else {
|
|
3401
|
-
|
|
3602
|
+
printError2(`Failed to dissolve entity: ${err}`);
|
|
3402
3603
|
}
|
|
3403
3604
|
process.exit(1);
|
|
3404
3605
|
}
|
|
@@ -3435,7 +3636,7 @@ async function contactsListCommand(opts) {
|
|
|
3435
3636
|
else if (contacts.length === 0) console.log("No contacts found.");
|
|
3436
3637
|
else printContactsTable(contacts);
|
|
3437
3638
|
} catch (err) {
|
|
3438
|
-
|
|
3639
|
+
printError2(`Failed to fetch contacts: ${err}`);
|
|
3439
3640
|
process.exit(1);
|
|
3440
3641
|
}
|
|
3441
3642
|
}
|
|
@@ -3472,7 +3673,7 @@ async function contactsShowCommand(contactId, opts) {
|
|
|
3472
3673
|
console.log(chalk6.cyan("\u2500".repeat(40)));
|
|
3473
3674
|
}
|
|
3474
3675
|
} catch (err) {
|
|
3475
|
-
|
|
3676
|
+
printError2(`Failed to fetch contact: ${err}`);
|
|
3476
3677
|
process.exit(1);
|
|
3477
3678
|
}
|
|
3478
3679
|
}
|
|
@@ -3502,7 +3703,7 @@ async function contactsAddCommand(opts) {
|
|
|
3502
3703
|
{ jsonOnly: opts.json, referenceKind: "contact", showReuseHint: true }
|
|
3503
3704
|
);
|
|
3504
3705
|
} catch (err) {
|
|
3505
|
-
|
|
3706
|
+
printError2(`Failed to create contact: ${err}`);
|
|
3506
3707
|
process.exit(1);
|
|
3507
3708
|
}
|
|
3508
3709
|
}
|
|
@@ -3551,7 +3752,7 @@ async function contactsEditCommand(contactId, opts) {
|
|
|
3551
3752
|
resolver.remember("contact", resolvedContactId, eid);
|
|
3552
3753
|
printWriteResult(result, "Contact updated.", opts.json);
|
|
3553
3754
|
} catch (err) {
|
|
3554
|
-
|
|
3755
|
+
printError2(`Failed to update contact: ${err}`);
|
|
3555
3756
|
process.exit(1);
|
|
3556
3757
|
}
|
|
3557
3758
|
}
|
|
@@ -3571,14 +3772,18 @@ __export(cap_table_exports, {
|
|
|
3571
3772
|
addSecurityCommand: () => addSecurityCommand,
|
|
3572
3773
|
approveValuationCommand: () => approveValuationCommand,
|
|
3573
3774
|
capTableCommand: () => capTableCommand,
|
|
3775
|
+
controlMapCommand: () => controlMapCommand,
|
|
3574
3776
|
createInstrumentCommand: () => createInstrumentCommand,
|
|
3575
3777
|
createValuationCommand: () => createValuationCommand,
|
|
3778
|
+
dilutionPreviewCommand: () => dilutionPreviewCommand,
|
|
3576
3779
|
distributeCommand: () => distributeCommand,
|
|
3780
|
+
executeConversionCommand: () => executeConversionCommand,
|
|
3577
3781
|
fourOhNineACommand: () => fourOhNineACommand,
|
|
3578
3782
|
instrumentsCommand: () => instrumentsCommand,
|
|
3579
3783
|
issueEquityCommand: () => issueEquityCommand,
|
|
3580
3784
|
issueRoundCommand: () => issueRoundCommand,
|
|
3581
3785
|
issueSafeCommand: () => issueSafeCommand,
|
|
3786
|
+
previewConversionCommand: () => previewConversionCommand,
|
|
3582
3787
|
roundsCommand: () => roundsCommand,
|
|
3583
3788
|
safesCommand: () => safesCommand,
|
|
3584
3789
|
shareClassesCommand: () => shareClassesCommand,
|
|
@@ -3707,7 +3912,7 @@ async function capTableCommand(opts) {
|
|
|
3707
3912
|
return;
|
|
3708
3913
|
}
|
|
3709
3914
|
if (data.access_level === "none") {
|
|
3710
|
-
|
|
3915
|
+
printError2("You do not have access to this entity's cap table.");
|
|
3711
3916
|
process.exit(1);
|
|
3712
3917
|
}
|
|
3713
3918
|
printCapTable(data);
|
|
@@ -3717,7 +3922,7 @@ async function capTableCommand(opts) {
|
|
|
3717
3922
|
} catch {
|
|
3718
3923
|
}
|
|
3719
3924
|
} catch (err) {
|
|
3720
|
-
|
|
3925
|
+
printError2(`Failed to fetch cap table: ${err}`);
|
|
3721
3926
|
process.exit(1);
|
|
3722
3927
|
}
|
|
3723
3928
|
}
|
|
@@ -3733,7 +3938,7 @@ async function safesCommand(opts) {
|
|
|
3733
3938
|
else if (safes.length === 0) console.log("No SAFE notes found.");
|
|
3734
3939
|
else printSafesTable(safes);
|
|
3735
3940
|
} catch (err) {
|
|
3736
|
-
|
|
3941
|
+
printError2(`Failed to fetch SAFE notes: ${err}`);
|
|
3737
3942
|
process.exit(1);
|
|
3738
3943
|
}
|
|
3739
3944
|
}
|
|
@@ -3749,7 +3954,7 @@ async function transfersCommand(opts) {
|
|
|
3749
3954
|
else if (transfers.length === 0) console.log("No share transfers found.");
|
|
3750
3955
|
else printTransfersTable(transfers);
|
|
3751
3956
|
} catch (err) {
|
|
3752
|
-
|
|
3957
|
+
printError2(`Failed to fetch transfers: ${err}`);
|
|
3753
3958
|
process.exit(1);
|
|
3754
3959
|
}
|
|
3755
3960
|
}
|
|
@@ -3766,7 +3971,7 @@ async function instrumentsCommand(opts) {
|
|
|
3766
3971
|
else if (instruments.length === 0) console.log("No instruments found.");
|
|
3767
3972
|
else printInstrumentsTable(instruments);
|
|
3768
3973
|
} catch (err) {
|
|
3769
|
-
|
|
3974
|
+
printError2(`Failed to fetch instruments: ${err}`);
|
|
3770
3975
|
process.exit(1);
|
|
3771
3976
|
}
|
|
3772
3977
|
}
|
|
@@ -3783,7 +3988,7 @@ async function shareClassesCommand(opts) {
|
|
|
3783
3988
|
else if (shareClasses.length === 0) console.log("No share classes found.");
|
|
3784
3989
|
else printShareClassesTable(shareClasses);
|
|
3785
3990
|
} catch (err) {
|
|
3786
|
-
|
|
3991
|
+
printError2(`Failed to fetch share classes: ${err}`);
|
|
3787
3992
|
process.exit(1);
|
|
3788
3993
|
}
|
|
3789
3994
|
}
|
|
@@ -3799,7 +4004,7 @@ async function roundsCommand(opts) {
|
|
|
3799
4004
|
else if (rounds.length === 0) console.log("No rounds found.");
|
|
3800
4005
|
else printRoundsTable(rounds);
|
|
3801
4006
|
} catch (err) {
|
|
3802
|
-
|
|
4007
|
+
printError2(`Failed to fetch rounds: ${err}`);
|
|
3803
4008
|
process.exit(1);
|
|
3804
4009
|
}
|
|
3805
4010
|
}
|
|
@@ -3815,7 +4020,7 @@ async function valuationsCommand(opts) {
|
|
|
3815
4020
|
else if (valuations.length === 0) console.log("No valuations found.");
|
|
3816
4021
|
else printValuationsTable(valuations);
|
|
3817
4022
|
} catch (err) {
|
|
3818
|
-
|
|
4023
|
+
printError2(`Failed to fetch valuations: ${err}`);
|
|
3819
4024
|
process.exit(1);
|
|
3820
4025
|
}
|
|
3821
4026
|
}
|
|
@@ -3854,7 +4059,7 @@ async function fourOhNineACommand(opts) {
|
|
|
3854
4059
|
);
|
|
3855
4060
|
}
|
|
3856
4061
|
} else {
|
|
3857
|
-
|
|
4062
|
+
printError2(`Failed to fetch 409A valuation: ${err}`);
|
|
3858
4063
|
}
|
|
3859
4064
|
process.exit(1);
|
|
3860
4065
|
}
|
|
@@ -3881,12 +4086,12 @@ async function issueEquityCommand(opts) {
|
|
|
3881
4086
|
const capTable = await client.getCapTable(eid);
|
|
3882
4087
|
const issuerLegalEntityId = capTable.issuer_legal_entity_id;
|
|
3883
4088
|
if (!issuerLegalEntityId) {
|
|
3884
|
-
|
|
4089
|
+
printError2("No issuer legal entity found. Has this entity been formed with a cap table?");
|
|
3885
4090
|
process.exit(1);
|
|
3886
4091
|
}
|
|
3887
4092
|
const instruments = capTable.instruments ?? [];
|
|
3888
4093
|
if (!instruments.length) {
|
|
3889
|
-
|
|
4094
|
+
printError2("No instruments found on cap table. Create one with: corp cap-table create-instrument --kind common_equity --symbol COMMON --authorized-units <shares>");
|
|
3890
4095
|
process.exit(1);
|
|
3891
4096
|
}
|
|
3892
4097
|
const explicitInstrumentId = opts.instrumentId ? await resolver.resolveInstrument(eid, opts.instrumentId) : void 0;
|
|
@@ -3932,9 +4137,8 @@ async function issueEquityCommand(opts) {
|
|
|
3932
4137
|
}
|
|
3933
4138
|
printSuccess(`Equity issued: ${opts.shares} shares (${opts.grantType}) to ${opts.recipient}`);
|
|
3934
4139
|
printReferenceSummary("round", round, { label: "Round Ref:", showReuseHint: true });
|
|
3935
|
-
printJson(result);
|
|
3936
4140
|
} catch (err) {
|
|
3937
|
-
|
|
4141
|
+
printError2(`Failed to issue equity: ${err}`);
|
|
3938
4142
|
process.exit(1);
|
|
3939
4143
|
}
|
|
3940
4144
|
}
|
|
@@ -3948,9 +4152,9 @@ async function issueSafeCommand(opts) {
|
|
|
3948
4152
|
printDryRun("cap_table.issue_safe", {
|
|
3949
4153
|
entity_id: eid,
|
|
3950
4154
|
investor: opts.investor,
|
|
3951
|
-
|
|
4155
|
+
amount_cents: opts.amountCents,
|
|
3952
4156
|
safe_type: opts.safeType,
|
|
3953
|
-
|
|
4157
|
+
valuation_cap_cents: opts.valuationCapCents,
|
|
3954
4158
|
email: opts.email,
|
|
3955
4159
|
meeting_id: opts.meetingId,
|
|
3956
4160
|
resolution_id: opts.resolutionId
|
|
@@ -3970,8 +4174,8 @@ async function issueSafeCommand(opts) {
|
|
|
3970
4174
|
const body = {
|
|
3971
4175
|
entity_id: eid,
|
|
3972
4176
|
investor_name: opts.investor,
|
|
3973
|
-
principal_amount_cents: opts.
|
|
3974
|
-
valuation_cap_cents: opts.
|
|
4177
|
+
principal_amount_cents: opts.amountCents,
|
|
4178
|
+
valuation_cap_cents: opts.valuationCapCents,
|
|
3975
4179
|
safe_type: opts.safeType
|
|
3976
4180
|
};
|
|
3977
4181
|
if (opts.email) body.email = opts.email;
|
|
@@ -3984,11 +4188,10 @@ async function issueSafeCommand(opts) {
|
|
|
3984
4188
|
printJson(result);
|
|
3985
4189
|
return;
|
|
3986
4190
|
}
|
|
3987
|
-
printSuccess(`SAFE issued: $${(opts.
|
|
4191
|
+
printSuccess(`SAFE issued: $${(opts.amountCents / 100).toLocaleString()} to ${opts.investor}`);
|
|
3988
4192
|
printReferenceSummary("safe_note", result, { showReuseHint: true });
|
|
3989
|
-
printJson(result);
|
|
3990
4193
|
} catch (err) {
|
|
3991
|
-
|
|
4194
|
+
printError2(`Failed to issue SAFE: ${err}`);
|
|
3992
4195
|
process.exit(1);
|
|
3993
4196
|
}
|
|
3994
4197
|
}
|
|
@@ -4057,7 +4260,7 @@ async function transferSharesCommand(opts) {
|
|
|
4057
4260
|
showReuseHint: true
|
|
4058
4261
|
});
|
|
4059
4262
|
} catch (err) {
|
|
4060
|
-
|
|
4263
|
+
printError2(`Failed to create transfer workflow: ${err}`);
|
|
4061
4264
|
process.exit(1);
|
|
4062
4265
|
}
|
|
4063
4266
|
}
|
|
@@ -4069,7 +4272,7 @@ async function distributeCommand(opts) {
|
|
|
4069
4272
|
const eid = await resolver.resolveEntity(opts.entityId);
|
|
4070
4273
|
const payload = {
|
|
4071
4274
|
entity_id: eid,
|
|
4072
|
-
total_amount_cents: opts.
|
|
4275
|
+
total_amount_cents: opts.amountCents,
|
|
4073
4276
|
distribution_type: opts.type,
|
|
4074
4277
|
description: opts.description
|
|
4075
4278
|
};
|
|
@@ -4086,7 +4289,7 @@ async function distributeCommand(opts) {
|
|
|
4086
4289
|
showReuseHint: true
|
|
4087
4290
|
});
|
|
4088
4291
|
} catch (err) {
|
|
4089
|
-
|
|
4292
|
+
printError2(`Failed to calculate distribution: ${err}`);
|
|
4090
4293
|
process.exit(1);
|
|
4091
4294
|
}
|
|
4092
4295
|
}
|
|
@@ -4115,7 +4318,7 @@ async function startRoundCommand(opts) {
|
|
|
4115
4318
|
showReuseHint: true
|
|
4116
4319
|
});
|
|
4117
4320
|
} catch (err) {
|
|
4118
|
-
|
|
4321
|
+
printError2(`Failed to start round: ${err}`);
|
|
4119
4322
|
process.exit(1);
|
|
4120
4323
|
}
|
|
4121
4324
|
}
|
|
@@ -4157,7 +4360,7 @@ async function createInstrumentCommand(opts) {
|
|
|
4157
4360
|
showReuseHint: true
|
|
4158
4361
|
});
|
|
4159
4362
|
} catch (err) {
|
|
4160
|
-
|
|
4363
|
+
printError2(`Failed to create instrument: ${err}`);
|
|
4161
4364
|
process.exit(1);
|
|
4162
4365
|
}
|
|
4163
4366
|
}
|
|
@@ -4186,7 +4389,7 @@ async function addSecurityCommand(opts) {
|
|
|
4186
4389
|
const result = await client.addRoundSecurity(roundId, body);
|
|
4187
4390
|
printWriteResult(result, `Security added for ${opts.recipientName}`, opts.json);
|
|
4188
4391
|
} catch (err) {
|
|
4189
|
-
|
|
4392
|
+
printError2(`Failed to add security: ${err}`);
|
|
4190
4393
|
process.exit(1);
|
|
4191
4394
|
}
|
|
4192
4395
|
}
|
|
@@ -4227,9 +4430,8 @@ async function issueRoundCommand(opts) {
|
|
|
4227
4430
|
if (roundMatch) {
|
|
4228
4431
|
printReferenceSummary("round", roundMatch.raw, { showReuseHint: true });
|
|
4229
4432
|
}
|
|
4230
|
-
printJson(result);
|
|
4231
4433
|
} catch (err) {
|
|
4232
|
-
|
|
4434
|
+
printError2(`Failed to issue round: ${err}`);
|
|
4233
4435
|
process.exit(1);
|
|
4234
4436
|
}
|
|
4235
4437
|
}
|
|
@@ -4260,7 +4462,7 @@ async function createValuationCommand(opts) {
|
|
|
4260
4462
|
showReuseHint: true
|
|
4261
4463
|
});
|
|
4262
4464
|
} catch (err) {
|
|
4263
|
-
|
|
4465
|
+
printError2(`Failed to create valuation: ${err}`);
|
|
4264
4466
|
process.exit(1);
|
|
4265
4467
|
}
|
|
4266
4468
|
}
|
|
@@ -4305,13 +4507,12 @@ async function submitValuationCommand(opts) {
|
|
|
4305
4507
|
printReferenceSummary("agenda_item", { agenda_item_id: result.agenda_item_id }, { label: "Agenda Ref:" });
|
|
4306
4508
|
}
|
|
4307
4509
|
}
|
|
4308
|
-
printJson(result);
|
|
4309
4510
|
} catch (err) {
|
|
4310
4511
|
const msg = String(err);
|
|
4311
4512
|
if (msg.includes("404")) {
|
|
4312
|
-
|
|
4513
|
+
printError2(`Valuation not found. List valuations with: corp cap-table valuations`);
|
|
4313
4514
|
} else {
|
|
4314
|
-
|
|
4515
|
+
printError2(`Failed to submit valuation: ${err}`);
|
|
4315
4516
|
}
|
|
4316
4517
|
process.exit(1);
|
|
4317
4518
|
}
|
|
@@ -4341,10 +4542,98 @@ async function approveValuationCommand(opts) {
|
|
|
4341
4542
|
} catch (err) {
|
|
4342
4543
|
const msg = String(err);
|
|
4343
4544
|
if (msg.includes("400")) {
|
|
4344
|
-
|
|
4545
|
+
printError2(`Bad request \u2014 a --resolution-id from a board vote may be required. Submit for approval first: corp cap-table submit-valuation <valuation-ref>`);
|
|
4345
4546
|
} else {
|
|
4346
|
-
|
|
4547
|
+
printError2(`Failed to approve valuation: ${err}`);
|
|
4548
|
+
}
|
|
4549
|
+
process.exit(1);
|
|
4550
|
+
}
|
|
4551
|
+
}
|
|
4552
|
+
async function previewConversionCommand(opts) {
|
|
4553
|
+
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
4554
|
+
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
4555
|
+
const resolver = new ReferenceResolver(client, cfg);
|
|
4556
|
+
try {
|
|
4557
|
+
const eid = await resolver.resolveEntity(opts.entityId);
|
|
4558
|
+
const safeId = await resolver.resolveSafeNote(eid, opts.safeId);
|
|
4559
|
+
const result = await client.previewRoundConversion({
|
|
4560
|
+
entity_id: eid,
|
|
4561
|
+
safe_note_id: safeId,
|
|
4562
|
+
price_per_share_cents: opts.pricePerShareCents
|
|
4563
|
+
});
|
|
4564
|
+
if (opts.json) {
|
|
4565
|
+
printJson(result);
|
|
4566
|
+
return;
|
|
4567
|
+
}
|
|
4568
|
+
printSuccess("Conversion Preview:");
|
|
4569
|
+
if (result.shares_issued) console.log(` Shares to issue: ${result.shares_issued}`);
|
|
4570
|
+
if (result.ownership_pct) console.log(` Post-conversion ownership: ${result.ownership_pct}%`);
|
|
4571
|
+
printJson(result);
|
|
4572
|
+
} catch (err) {
|
|
4573
|
+
printError2(`Failed to preview conversion: ${err}`);
|
|
4574
|
+
process.exit(1);
|
|
4575
|
+
}
|
|
4576
|
+
}
|
|
4577
|
+
async function executeConversionCommand(opts) {
|
|
4578
|
+
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
4579
|
+
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
4580
|
+
const resolver = new ReferenceResolver(client, cfg);
|
|
4581
|
+
try {
|
|
4582
|
+
const eid = await resolver.resolveEntity(opts.entityId);
|
|
4583
|
+
const safeId = await resolver.resolveSafeNote(eid, opts.safeId);
|
|
4584
|
+
const payload = {
|
|
4585
|
+
entity_id: eid,
|
|
4586
|
+
safe_note_id: safeId,
|
|
4587
|
+
price_per_share_cents: opts.pricePerShareCents
|
|
4588
|
+
};
|
|
4589
|
+
if (opts.dryRun) {
|
|
4590
|
+
printDryRun("equity.conversion.execute", payload);
|
|
4591
|
+
return;
|
|
4592
|
+
}
|
|
4593
|
+
const result = await client.executeRoundConversion(
|
|
4594
|
+
payload
|
|
4595
|
+
);
|
|
4596
|
+
printWriteResult(result, `Conversion executed for SAFE ${safeId}`, {
|
|
4597
|
+
jsonOnly: opts.json
|
|
4598
|
+
});
|
|
4599
|
+
} catch (err) {
|
|
4600
|
+
printError2(`Failed to execute conversion: ${err}`);
|
|
4601
|
+
process.exit(1);
|
|
4602
|
+
}
|
|
4603
|
+
}
|
|
4604
|
+
async function dilutionPreviewCommand(opts) {
|
|
4605
|
+
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
4606
|
+
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
4607
|
+
const resolver = new ReferenceResolver(client, cfg);
|
|
4608
|
+
try {
|
|
4609
|
+
const eid = await resolver.resolveEntity(opts.entityId);
|
|
4610
|
+
const roundId = await resolver.resolveRound(eid, opts.roundId);
|
|
4611
|
+
const result = await client.getDilutionPreview(eid, roundId);
|
|
4612
|
+
if (opts.json) {
|
|
4613
|
+
printJson(result);
|
|
4614
|
+
return;
|
|
4615
|
+
}
|
|
4616
|
+
printJson(result);
|
|
4617
|
+
} catch (err) {
|
|
4618
|
+
printError2(`Failed to preview dilution: ${err}`);
|
|
4619
|
+
process.exit(1);
|
|
4620
|
+
}
|
|
4621
|
+
}
|
|
4622
|
+
async function controlMapCommand(opts) {
|
|
4623
|
+
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
4624
|
+
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
4625
|
+
const resolver = new ReferenceResolver(client, cfg);
|
|
4626
|
+
try {
|
|
4627
|
+
const eid = await resolver.resolveEntity(opts.entityId);
|
|
4628
|
+
const rootEntityId = opts.rootEntityId ? await resolver.resolveEntity(opts.rootEntityId) : eid;
|
|
4629
|
+
const result = await client.getControlMap(eid, rootEntityId);
|
|
4630
|
+
if (opts.json) {
|
|
4631
|
+
printJson(result);
|
|
4632
|
+
return;
|
|
4347
4633
|
}
|
|
4634
|
+
printJson(result);
|
|
4635
|
+
} catch (err) {
|
|
4636
|
+
printError2(`Failed to fetch control map: ${err}`);
|
|
4348
4637
|
process.exit(1);
|
|
4349
4638
|
}
|
|
4350
4639
|
}
|
|
@@ -4373,6 +4662,7 @@ var init_cap_table = __esm({
|
|
|
4373
4662
|
// src/commands/finance.ts
|
|
4374
4663
|
var finance_exports = {};
|
|
4375
4664
|
__export(finance_exports, {
|
|
4665
|
+
financeActivateAccountCommand: () => financeActivateAccountCommand,
|
|
4376
4666
|
financeBankAccountsCommand: () => financeBankAccountsCommand,
|
|
4377
4667
|
financeClassificationsCommand: () => financeClassificationsCommand,
|
|
4378
4668
|
financeClassifyContractorCommand: () => financeClassifyContractorCommand,
|
|
@@ -4386,6 +4676,7 @@ __export(finance_exports, {
|
|
|
4386
4676
|
financePayrollRunsCommand: () => financePayrollRunsCommand,
|
|
4387
4677
|
financeReconcileCommand: () => financeReconcileCommand,
|
|
4388
4678
|
financeReconciliationsCommand: () => financeReconciliationsCommand,
|
|
4679
|
+
financeStatementsCommand: () => financeStatementsCommand,
|
|
4389
4680
|
financeSummaryCommand: () => financeSummaryCommand
|
|
4390
4681
|
});
|
|
4391
4682
|
function sumAmounts(records, candidates) {
|
|
@@ -4487,7 +4778,7 @@ async function financeSummaryCommand(opts) {
|
|
|
4487
4778
|
}
|
|
4488
4779
|
printFinanceSummaryPanel(summary);
|
|
4489
4780
|
} catch (err) {
|
|
4490
|
-
|
|
4781
|
+
printError2(`Failed to fetch finance summary: ${err}`);
|
|
4491
4782
|
process.exit(1);
|
|
4492
4783
|
}
|
|
4493
4784
|
}
|
|
@@ -4503,7 +4794,7 @@ async function financeInvoicesCommand(opts) {
|
|
|
4503
4794
|
else if (invoices.length === 0) console.log("No invoices found.");
|
|
4504
4795
|
else printInvoicesTable(invoices);
|
|
4505
4796
|
} catch (err) {
|
|
4506
|
-
|
|
4797
|
+
printError2(`Failed to fetch invoices: ${err}`);
|
|
4507
4798
|
process.exit(1);
|
|
4508
4799
|
}
|
|
4509
4800
|
}
|
|
@@ -4519,7 +4810,7 @@ async function financeBankAccountsCommand(opts) {
|
|
|
4519
4810
|
else if (accounts.length === 0) console.log("No bank accounts found.");
|
|
4520
4811
|
else printBankAccountsTable(accounts);
|
|
4521
4812
|
} catch (err) {
|
|
4522
|
-
|
|
4813
|
+
printError2(`Failed to fetch bank accounts: ${err}`);
|
|
4523
4814
|
process.exit(1);
|
|
4524
4815
|
}
|
|
4525
4816
|
}
|
|
@@ -4535,7 +4826,7 @@ async function financePaymentsCommand(opts) {
|
|
|
4535
4826
|
else if (payments.length === 0) console.log("No payments found.");
|
|
4536
4827
|
else printPaymentsTable(payments);
|
|
4537
4828
|
} catch (err) {
|
|
4538
|
-
|
|
4829
|
+
printError2(`Failed to fetch payments: ${err}`);
|
|
4539
4830
|
process.exit(1);
|
|
4540
4831
|
}
|
|
4541
4832
|
}
|
|
@@ -4551,7 +4842,7 @@ async function financePayrollRunsCommand(opts) {
|
|
|
4551
4842
|
else if (runs.length === 0) console.log("No payroll runs found.");
|
|
4552
4843
|
else printPayrollRunsTable(runs);
|
|
4553
4844
|
} catch (err) {
|
|
4554
|
-
|
|
4845
|
+
printError2(`Failed to fetch payroll runs: ${err}`);
|
|
4555
4846
|
process.exit(1);
|
|
4556
4847
|
}
|
|
4557
4848
|
}
|
|
@@ -4567,7 +4858,7 @@ async function financeDistributionsCommand(opts) {
|
|
|
4567
4858
|
else if (distributions.length === 0) console.log("No distributions found.");
|
|
4568
4859
|
else printDistributionsTable(distributions);
|
|
4569
4860
|
} catch (err) {
|
|
4570
|
-
|
|
4861
|
+
printError2(`Failed to fetch distributions: ${err}`);
|
|
4571
4862
|
process.exit(1);
|
|
4572
4863
|
}
|
|
4573
4864
|
}
|
|
@@ -4583,7 +4874,7 @@ async function financeReconciliationsCommand(opts) {
|
|
|
4583
4874
|
else if (reconciliations.length === 0) console.log("No reconciliations found.");
|
|
4584
4875
|
else printReconciliationsTable(reconciliations);
|
|
4585
4876
|
} catch (err) {
|
|
4586
|
-
|
|
4877
|
+
printError2(`Failed to fetch reconciliations: ${err}`);
|
|
4587
4878
|
process.exit(1);
|
|
4588
4879
|
}
|
|
4589
4880
|
}
|
|
@@ -4599,7 +4890,7 @@ async function financeClassificationsCommand(opts) {
|
|
|
4599
4890
|
else if (classifications.length === 0) console.log("No contractor classifications found.");
|
|
4600
4891
|
else printClassificationsTable(classifications);
|
|
4601
4892
|
} catch (err) {
|
|
4602
|
-
|
|
4893
|
+
printError2(`Failed to fetch contractor classifications: ${err}`);
|
|
4603
4894
|
process.exit(1);
|
|
4604
4895
|
}
|
|
4605
4896
|
}
|
|
@@ -4612,7 +4903,7 @@ async function financeInvoiceCommand(opts) {
|
|
|
4612
4903
|
const result = await client.createInvoice({
|
|
4613
4904
|
entity_id: eid,
|
|
4614
4905
|
customer_name: opts.customer,
|
|
4615
|
-
amount_cents: opts.
|
|
4906
|
+
amount_cents: opts.amountCents,
|
|
4616
4907
|
due_date: opts.dueDate,
|
|
4617
4908
|
description: opts.description
|
|
4618
4909
|
});
|
|
@@ -4624,7 +4915,7 @@ async function financeInvoiceCommand(opts) {
|
|
|
4624
4915
|
showReuseHint: true
|
|
4625
4916
|
});
|
|
4626
4917
|
} catch (err) {
|
|
4627
|
-
|
|
4918
|
+
printError2(`Failed to create invoice: ${err}`);
|
|
4628
4919
|
process.exit(1);
|
|
4629
4920
|
}
|
|
4630
4921
|
}
|
|
@@ -4647,7 +4938,7 @@ async function financePayrollCommand(opts) {
|
|
|
4647
4938
|
showReuseHint: true
|
|
4648
4939
|
});
|
|
4649
4940
|
} catch (err) {
|
|
4650
|
-
|
|
4941
|
+
printError2(`Failed to run payroll: ${err}`);
|
|
4651
4942
|
process.exit(1);
|
|
4652
4943
|
}
|
|
4653
4944
|
}
|
|
@@ -4659,7 +4950,7 @@ async function financePayCommand(opts) {
|
|
|
4659
4950
|
const eid = await resolver.resolveEntity(opts.entityId);
|
|
4660
4951
|
const result = await client.submitPayment({
|
|
4661
4952
|
entity_id: eid,
|
|
4662
|
-
amount_cents: opts.
|
|
4953
|
+
amount_cents: opts.amountCents,
|
|
4663
4954
|
recipient: opts.recipient,
|
|
4664
4955
|
payment_method: opts.method,
|
|
4665
4956
|
description: `Payment via ${opts.method}`
|
|
@@ -4672,7 +4963,7 @@ async function financePayCommand(opts) {
|
|
|
4672
4963
|
showReuseHint: true
|
|
4673
4964
|
});
|
|
4674
4965
|
} catch (err) {
|
|
4675
|
-
|
|
4966
|
+
printError2(`Failed to submit payment: ${err}`);
|
|
4676
4967
|
process.exit(1);
|
|
4677
4968
|
}
|
|
4678
4969
|
}
|
|
@@ -4691,7 +4982,27 @@ async function financeOpenAccountCommand(opts) {
|
|
|
4691
4982
|
showReuseHint: true
|
|
4692
4983
|
});
|
|
4693
4984
|
} catch (err) {
|
|
4694
|
-
|
|
4985
|
+
printError2(`Failed to open bank account: ${err}`);
|
|
4986
|
+
process.exit(1);
|
|
4987
|
+
}
|
|
4988
|
+
}
|
|
4989
|
+
async function financeActivateAccountCommand(accountRef, opts) {
|
|
4990
|
+
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
4991
|
+
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
4992
|
+
const resolver = new ReferenceResolver(client, cfg);
|
|
4993
|
+
try {
|
|
4994
|
+
const eid = await resolver.resolveEntity(opts.entityId);
|
|
4995
|
+
const resolvedId = await resolver.resolveBankAccount(eid, accountRef);
|
|
4996
|
+
const result = await client.activateBankAccount(resolvedId, eid);
|
|
4997
|
+
await resolver.stabilizeRecord("bank_account", result, eid);
|
|
4998
|
+
resolver.rememberFromRecord("bank_account", result, eid);
|
|
4999
|
+
printWriteResult(result, `Bank account activated: ${resolvedId}`, {
|
|
5000
|
+
jsonOnly: opts.json,
|
|
5001
|
+
referenceKind: "bank_account",
|
|
5002
|
+
showReuseHint: true
|
|
5003
|
+
});
|
|
5004
|
+
} catch (err) {
|
|
5005
|
+
printError2(`Failed to activate bank account: ${err}`);
|
|
4695
5006
|
process.exit(1);
|
|
4696
5007
|
}
|
|
4697
5008
|
}
|
|
@@ -4718,7 +5029,26 @@ async function financeClassifyContractorCommand(opts) {
|
|
|
4718
5029
|
showReuseHint: true
|
|
4719
5030
|
});
|
|
4720
5031
|
} catch (err) {
|
|
4721
|
-
|
|
5032
|
+
printError2(`Failed to classify contractor: ${err}`);
|
|
5033
|
+
process.exit(1);
|
|
5034
|
+
}
|
|
5035
|
+
}
|
|
5036
|
+
async function financeStatementsCommand(opts) {
|
|
5037
|
+
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
5038
|
+
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
5039
|
+
const resolver = new ReferenceResolver(client, cfg);
|
|
5040
|
+
try {
|
|
5041
|
+
const eid = await resolver.resolveEntity(opts.entityId);
|
|
5042
|
+
const params = {};
|
|
5043
|
+
if (opts.period) params.period = opts.period;
|
|
5044
|
+
const result = await client.getFinancialStatements(eid, params);
|
|
5045
|
+
if (opts.json) {
|
|
5046
|
+
printJson(result);
|
|
5047
|
+
return;
|
|
5048
|
+
}
|
|
5049
|
+
printJson(result);
|
|
5050
|
+
} catch (err) {
|
|
5051
|
+
printError2(`Failed to fetch financial statements: ${err}`);
|
|
4722
5052
|
process.exit(1);
|
|
4723
5053
|
}
|
|
4724
5054
|
}
|
|
@@ -4741,7 +5071,7 @@ async function financeReconcileCommand(opts) {
|
|
|
4741
5071
|
showReuseHint: true
|
|
4742
5072
|
});
|
|
4743
5073
|
} catch (err) {
|
|
4744
|
-
|
|
5074
|
+
printError2(`Failed to reconcile ledger: ${err}`);
|
|
4745
5075
|
process.exit(1);
|
|
4746
5076
|
}
|
|
4747
5077
|
}
|
|
@@ -4765,9 +5095,13 @@ __export(governance_exports, {
|
|
|
4765
5095
|
governanceAddSeatCommand: () => governanceAddSeatCommand,
|
|
4766
5096
|
governanceConveneCommand: () => governanceConveneCommand,
|
|
4767
5097
|
governanceCreateBodyCommand: () => governanceCreateBodyCommand,
|
|
5098
|
+
governanceIncidentsCommand: () => governanceIncidentsCommand,
|
|
4768
5099
|
governanceListCommand: () => governanceListCommand,
|
|
4769
5100
|
governanceMeetingsCommand: () => governanceMeetingsCommand,
|
|
5101
|
+
governanceModeCommand: () => governanceModeCommand,
|
|
4770
5102
|
governanceOpenMeetingCommand: () => governanceOpenMeetingCommand,
|
|
5103
|
+
governanceProfileCommand: () => governanceProfileCommand,
|
|
5104
|
+
governanceResignCommand: () => governanceResignCommand,
|
|
4771
5105
|
governanceResolutionsCommand: () => governanceResolutionsCommand,
|
|
4772
5106
|
governanceSeatsCommand: () => governanceSeatsCommand,
|
|
4773
5107
|
governanceVoteCommand: () => governanceVoteCommand,
|
|
@@ -4776,6 +5110,7 @@ __export(governance_exports, {
|
|
|
4776
5110
|
sendNoticeCommand: () => sendNoticeCommand,
|
|
4777
5111
|
writtenConsentCommand: () => writtenConsentCommand
|
|
4778
5112
|
});
|
|
5113
|
+
import { confirm as confirm3 } from "@inquirer/prompts";
|
|
4779
5114
|
import chalk8 from "chalk";
|
|
4780
5115
|
async function governanceCreateBodyCommand(opts) {
|
|
4781
5116
|
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
@@ -4804,12 +5139,11 @@ async function governanceCreateBodyCommand(opts) {
|
|
|
4804
5139
|
}
|
|
4805
5140
|
printSuccess(`Governance body created: ${bodyId}`);
|
|
4806
5141
|
printReferenceSummary("body", result, { showReuseHint: true });
|
|
4807
|
-
printJson(result);
|
|
4808
5142
|
console.log(chalk8.dim("\n Next steps:"));
|
|
4809
5143
|
console.log(chalk8.dim(` corp governance add-seat @last:body --holder <contact-ref>`));
|
|
4810
5144
|
console.log(chalk8.dim(` corp governance seats @last:body`));
|
|
4811
5145
|
} catch (err) {
|
|
4812
|
-
|
|
5146
|
+
printError2(`Failed to create governance body: ${err}`);
|
|
4813
5147
|
process.exit(1);
|
|
4814
5148
|
}
|
|
4815
5149
|
}
|
|
@@ -4835,9 +5169,8 @@ async function governanceAddSeatCommand(bodyId, opts) {
|
|
|
4835
5169
|
}
|
|
4836
5170
|
printSuccess(`Seat added: ${result.seat_id ?? "OK"}`);
|
|
4837
5171
|
printReferenceSummary("seat", result, { showReuseHint: true });
|
|
4838
|
-
printJson(result);
|
|
4839
5172
|
} catch (err) {
|
|
4840
|
-
|
|
5173
|
+
printError2(`Failed to add seat: ${err}`);
|
|
4841
5174
|
process.exit(1);
|
|
4842
5175
|
}
|
|
4843
5176
|
}
|
|
@@ -4853,7 +5186,7 @@ async function governanceListCommand(opts) {
|
|
|
4853
5186
|
else if (bodies.length === 0) console.log("No governance bodies found.");
|
|
4854
5187
|
else printGovernanceTable(bodies);
|
|
4855
5188
|
} catch (err) {
|
|
4856
|
-
|
|
5189
|
+
printError2(`Failed to fetch governance bodies: ${err}`);
|
|
4857
5190
|
process.exit(1);
|
|
4858
5191
|
}
|
|
4859
5192
|
}
|
|
@@ -4870,7 +5203,7 @@ async function governanceSeatsCommand(bodyId, opts) {
|
|
|
4870
5203
|
else if (seats.length === 0) console.log("No seats found.");
|
|
4871
5204
|
else printSeatsTable(seats);
|
|
4872
5205
|
} catch (err) {
|
|
4873
|
-
|
|
5206
|
+
printError2(`Failed to fetch seats: ${err}`);
|
|
4874
5207
|
process.exit(1);
|
|
4875
5208
|
}
|
|
4876
5209
|
}
|
|
@@ -4887,7 +5220,7 @@ async function governanceMeetingsCommand(bodyId, opts) {
|
|
|
4887
5220
|
else if (meetings.length === 0) console.log("No meetings found.");
|
|
4888
5221
|
else printMeetingsTable(meetings);
|
|
4889
5222
|
} catch (err) {
|
|
4890
|
-
|
|
5223
|
+
printError2(`Failed to fetch meetings: ${err}`);
|
|
4891
5224
|
process.exit(1);
|
|
4892
5225
|
}
|
|
4893
5226
|
}
|
|
@@ -4904,7 +5237,7 @@ async function governanceResolutionsCommand(meetingId, opts) {
|
|
|
4904
5237
|
else if (resolutions.length === 0) console.log("No resolutions found.");
|
|
4905
5238
|
else printResolutionsTable(resolutions);
|
|
4906
5239
|
} catch (err) {
|
|
4907
|
-
|
|
5240
|
+
printError2(`Failed to fetch resolutions: ${err}`);
|
|
4908
5241
|
process.exit(1);
|
|
4909
5242
|
}
|
|
4910
5243
|
}
|
|
@@ -4937,13 +5270,12 @@ async function governanceConveneCommand(opts) {
|
|
|
4937
5270
|
}
|
|
4938
5271
|
printSuccess(`Meeting scheduled: ${meetingId}`);
|
|
4939
5272
|
printReferenceSummary("meeting", result, { showReuseHint: true });
|
|
4940
|
-
printJson(result);
|
|
4941
5273
|
console.log(chalk8.dim("\n Next steps:"));
|
|
4942
5274
|
console.log(chalk8.dim(` corp governance notice @last:meeting`));
|
|
4943
5275
|
console.log(chalk8.dim(` corp governance open @last:meeting --present-seat <seat-ref>`));
|
|
4944
5276
|
console.log(chalk8.dim(` corp governance agenda-items @last:meeting`));
|
|
4945
5277
|
} catch (err) {
|
|
4946
|
-
|
|
5278
|
+
printError2(`Failed to schedule meeting: ${err}`);
|
|
4947
5279
|
process.exit(1);
|
|
4948
5280
|
}
|
|
4949
5281
|
}
|
|
@@ -4968,9 +5300,8 @@ async function governanceOpenMeetingCommand(meetingId, opts) {
|
|
|
4968
5300
|
return;
|
|
4969
5301
|
}
|
|
4970
5302
|
printSuccess(`Meeting opened: ${resolvedMeetingId}`);
|
|
4971
|
-
printJson(result);
|
|
4972
5303
|
} catch (err) {
|
|
4973
|
-
|
|
5304
|
+
printError2(`Failed to open meeting: ${err}`);
|
|
4974
5305
|
process.exit(1);
|
|
4975
5306
|
}
|
|
4976
5307
|
}
|
|
@@ -4998,16 +5329,15 @@ async function governanceVoteCommand(meetingId, itemId, opts) {
|
|
|
4998
5329
|
return;
|
|
4999
5330
|
}
|
|
5000
5331
|
printSuccess(`Vote cast: ${result.vote_id ?? "OK"}`);
|
|
5001
|
-
printJson(result);
|
|
5002
5332
|
} catch (err) {
|
|
5003
5333
|
const message = String(err);
|
|
5004
5334
|
if (message.includes("voting session is not open")) {
|
|
5005
|
-
|
|
5335
|
+
printError2(
|
|
5006
5336
|
`Failed to cast vote: ${err}
|
|
5007
5337
|
Open the meeting first: corp governance open ${meetingId} --present-seat <seat-ref>`
|
|
5008
5338
|
);
|
|
5009
5339
|
} else {
|
|
5010
|
-
|
|
5340
|
+
printError2(`Failed to cast vote: ${err}`);
|
|
5011
5341
|
}
|
|
5012
5342
|
process.exit(1);
|
|
5013
5343
|
}
|
|
@@ -5029,9 +5359,8 @@ async function sendNoticeCommand(meetingId, opts) {
|
|
|
5029
5359
|
return;
|
|
5030
5360
|
}
|
|
5031
5361
|
printSuccess(`Notice sent for meeting ${resolvedMeetingId}`);
|
|
5032
|
-
printJson(result);
|
|
5033
5362
|
} catch (err) {
|
|
5034
|
-
|
|
5363
|
+
printError2(`Failed to send notice: ${err}`);
|
|
5035
5364
|
process.exit(1);
|
|
5036
5365
|
}
|
|
5037
5366
|
}
|
|
@@ -5052,9 +5381,8 @@ async function adjournMeetingCommand(meetingId, opts) {
|
|
|
5052
5381
|
return;
|
|
5053
5382
|
}
|
|
5054
5383
|
printSuccess(`Meeting ${resolvedMeetingId} adjourned`);
|
|
5055
|
-
printJson(result);
|
|
5056
5384
|
} catch (err) {
|
|
5057
|
-
|
|
5385
|
+
printError2(`Failed to adjourn meeting: ${err}`);
|
|
5058
5386
|
process.exit(1);
|
|
5059
5387
|
}
|
|
5060
5388
|
}
|
|
@@ -5069,15 +5397,24 @@ async function cancelMeetingCommand(meetingId, opts) {
|
|
|
5069
5397
|
printDryRun("governance.cancel_meeting", { entity_id: eid, meeting_id: resolvedMeetingId });
|
|
5070
5398
|
return;
|
|
5071
5399
|
}
|
|
5400
|
+
if (!opts.yes) {
|
|
5401
|
+
const ok = await confirm3({
|
|
5402
|
+
message: `Cancel meeting ${resolvedMeetingId}?`,
|
|
5403
|
+
default: false
|
|
5404
|
+
});
|
|
5405
|
+
if (!ok) {
|
|
5406
|
+
console.log("Cancelled.");
|
|
5407
|
+
return;
|
|
5408
|
+
}
|
|
5409
|
+
}
|
|
5072
5410
|
const result = await client.cancelMeeting(resolvedMeetingId, eid);
|
|
5073
5411
|
if (opts.json) {
|
|
5074
5412
|
printJson(result);
|
|
5075
5413
|
return;
|
|
5076
5414
|
}
|
|
5077
5415
|
printSuccess(`Meeting ${resolvedMeetingId} cancelled`);
|
|
5078
|
-
printJson(result);
|
|
5079
5416
|
} catch (err) {
|
|
5080
|
-
|
|
5417
|
+
printError2(`Failed to cancel meeting: ${err}`);
|
|
5081
5418
|
process.exit(1);
|
|
5082
5419
|
}
|
|
5083
5420
|
}
|
|
@@ -5098,9 +5435,8 @@ async function reopenMeetingCommand(meetingId, opts) {
|
|
|
5098
5435
|
return;
|
|
5099
5436
|
}
|
|
5100
5437
|
printSuccess(`Meeting ${resolvedMeetingId} re-opened`);
|
|
5101
|
-
printJson(result);
|
|
5102
5438
|
} catch (err) {
|
|
5103
|
-
|
|
5439
|
+
printError2(`Failed to re-open meeting: ${err}`);
|
|
5104
5440
|
process.exit(1);
|
|
5105
5441
|
}
|
|
5106
5442
|
}
|
|
@@ -5126,9 +5462,8 @@ async function finalizeAgendaItemCommand(meetingId, itemId, opts) {
|
|
|
5126
5462
|
return;
|
|
5127
5463
|
}
|
|
5128
5464
|
printSuccess(`Agenda item ${resolvedItemId} finalized as ${opts.status}`);
|
|
5129
|
-
printJson(result);
|
|
5130
5465
|
} catch (err) {
|
|
5131
|
-
|
|
5466
|
+
printError2(`Failed to finalize agenda item: ${err}`);
|
|
5132
5467
|
process.exit(1);
|
|
5133
5468
|
}
|
|
5134
5469
|
}
|
|
@@ -5161,9 +5496,8 @@ async function computeResolutionCommand(meetingId, itemId, opts) {
|
|
|
5161
5496
|
}
|
|
5162
5497
|
printSuccess(`Resolution computed for agenda item ${itemId}`);
|
|
5163
5498
|
printReferenceSummary("resolution", result, { showReuseHint: true });
|
|
5164
|
-
printJson(result);
|
|
5165
5499
|
} catch (err) {
|
|
5166
|
-
|
|
5500
|
+
printError2(`Failed to compute resolution: ${err}`);
|
|
5167
5501
|
process.exit(1);
|
|
5168
5502
|
}
|
|
5169
5503
|
}
|
|
@@ -5194,43 +5528,137 @@ async function writtenConsentCommand(opts) {
|
|
|
5194
5528
|
}
|
|
5195
5529
|
printSuccess(`Written consent created: ${meetingId}`);
|
|
5196
5530
|
printReferenceSummary("meeting", result, { showReuseHint: true });
|
|
5197
|
-
printJson(result);
|
|
5198
5531
|
console.log(chalk8.dim("\n Next steps:"));
|
|
5199
5532
|
console.log(chalk8.dim(` corp governance agenda-items @last:meeting`));
|
|
5200
5533
|
console.log(chalk8.dim(` corp governance vote @last:meeting <item-ref> --voter <contact-ref> --vote for`));
|
|
5201
5534
|
} catch (err) {
|
|
5202
|
-
|
|
5535
|
+
printError2(`Failed to create written consent: ${err}`);
|
|
5203
5536
|
process.exit(1);
|
|
5204
5537
|
}
|
|
5205
5538
|
}
|
|
5206
|
-
async function
|
|
5539
|
+
async function governanceModeCommand(opts) {
|
|
5207
5540
|
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
5208
5541
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
5209
5542
|
const resolver = new ReferenceResolver(client, cfg);
|
|
5210
5543
|
try {
|
|
5211
5544
|
const eid = await resolver.resolveEntity(opts.entityId);
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
|
|
5217
|
-
|
|
5545
|
+
if (opts.set) {
|
|
5546
|
+
const result = await client.setGovernanceMode({ entity_id: eid, mode: opts.set });
|
|
5547
|
+
if (opts.json) {
|
|
5548
|
+
printJson(result);
|
|
5549
|
+
return;
|
|
5550
|
+
}
|
|
5551
|
+
printSuccess(`Governance mode set to: ${opts.set}`);
|
|
5552
|
+
} else {
|
|
5553
|
+
const result = await client.getGovernanceMode(eid);
|
|
5554
|
+
if (opts.json) {
|
|
5555
|
+
printJson(result);
|
|
5556
|
+
return;
|
|
5557
|
+
}
|
|
5558
|
+
console.log(` ${chalk8.bold("Governance Mode:")} ${result.mode ?? "N/A"}`);
|
|
5559
|
+
if (result.reason) console.log(` ${chalk8.bold("Reason:")} ${result.reason}`);
|
|
5560
|
+
}
|
|
5218
5561
|
} catch (err) {
|
|
5219
|
-
|
|
5562
|
+
printError2(`Failed: ${err}`);
|
|
5220
5563
|
process.exit(1);
|
|
5221
5564
|
}
|
|
5222
5565
|
}
|
|
5223
|
-
|
|
5224
|
-
"
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5566
|
+
async function governanceResignCommand(seatRef, opts) {
|
|
5567
|
+
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
5568
|
+
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
5569
|
+
const resolver = new ReferenceResolver(client, cfg);
|
|
5570
|
+
try {
|
|
5571
|
+
const eid = await resolver.resolveEntity(opts.entityId);
|
|
5572
|
+
const seatId = await resolver.resolveSeat(eid, seatRef, opts.bodyId);
|
|
5573
|
+
const result = await client.resignSeat(seatId, eid);
|
|
5574
|
+
if (opts.json) {
|
|
5575
|
+
printJson(result);
|
|
5576
|
+
return;
|
|
5577
|
+
}
|
|
5578
|
+
printSuccess(`Seat ${seatId} resigned.`);
|
|
5579
|
+
} catch (err) {
|
|
5580
|
+
printError2(`Failed to resign seat: ${err}`);
|
|
5581
|
+
process.exit(1);
|
|
5582
|
+
}
|
|
5583
|
+
}
|
|
5584
|
+
async function governanceIncidentsCommand(opts) {
|
|
5585
|
+
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
5586
|
+
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
5587
|
+
const resolver = new ReferenceResolver(client, cfg);
|
|
5588
|
+
try {
|
|
5589
|
+
const eid = await resolver.resolveEntity(opts.entityId);
|
|
5590
|
+
const incidents = await client.listGovernanceIncidents(eid);
|
|
5591
|
+
if (opts.json) {
|
|
5592
|
+
printJson(incidents);
|
|
5593
|
+
return;
|
|
5594
|
+
}
|
|
5595
|
+
if (incidents.length === 0) {
|
|
5596
|
+
console.log("No governance incidents found.");
|
|
5597
|
+
return;
|
|
5598
|
+
}
|
|
5599
|
+
for (const inc of incidents) {
|
|
5600
|
+
const status = String(inc.status ?? "open");
|
|
5601
|
+
const colored = status === "resolved" ? chalk8.green(status) : chalk8.red(status);
|
|
5602
|
+
console.log(` [${colored}] ${inc.incident_type ?? "unknown"}: ${inc.description ?? inc.id}`);
|
|
5603
|
+
}
|
|
5604
|
+
} catch (err) {
|
|
5605
|
+
printError2(`Failed to list incidents: ${err}`);
|
|
5606
|
+
process.exit(1);
|
|
5607
|
+
}
|
|
5608
|
+
}
|
|
5609
|
+
async function governanceProfileCommand(opts) {
|
|
5610
|
+
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
5611
|
+
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
5612
|
+
const resolver = new ReferenceResolver(client, cfg);
|
|
5613
|
+
try {
|
|
5614
|
+
const eid = await resolver.resolveEntity(opts.entityId);
|
|
5615
|
+
const profile = await client.getGovernanceProfile(eid);
|
|
5616
|
+
if (opts.json) {
|
|
5617
|
+
printJson(profile);
|
|
5618
|
+
return;
|
|
5619
|
+
}
|
|
5620
|
+
console.log(chalk8.blue("\u2500".repeat(40)));
|
|
5621
|
+
console.log(chalk8.blue.bold(" Governance Profile"));
|
|
5622
|
+
console.log(chalk8.blue("\u2500".repeat(40)));
|
|
5623
|
+
for (const [key, value] of Object.entries(profile)) {
|
|
5624
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
5625
|
+
console.log(` ${chalk8.bold(key.replaceAll("_", " ") + ":")} ${value}`);
|
|
5626
|
+
}
|
|
5627
|
+
}
|
|
5628
|
+
console.log(chalk8.blue("\u2500".repeat(40)));
|
|
5629
|
+
} catch (err) {
|
|
5630
|
+
printError2(`Failed to get governance profile: ${err}`);
|
|
5631
|
+
process.exit(1);
|
|
5632
|
+
}
|
|
5633
|
+
}
|
|
5634
|
+
async function listAgendaItemsCommand(meetingId, opts) {
|
|
5635
|
+
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
5636
|
+
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
5637
|
+
const resolver = new ReferenceResolver(client, cfg);
|
|
5638
|
+
try {
|
|
5639
|
+
const eid = await resolver.resolveEntity(opts.entityId);
|
|
5640
|
+
const resolvedMeetingId = await resolver.resolveMeeting(eid, meetingId);
|
|
5641
|
+
const items = await client.listAgendaItems(resolvedMeetingId, eid);
|
|
5642
|
+
await resolver.stabilizeRecords("agenda_item", items, eid);
|
|
5643
|
+
if (opts.json) printJson(items);
|
|
5644
|
+
else if (items.length === 0) console.log("No agenda items found.");
|
|
5645
|
+
else printAgendaItemsTable(items);
|
|
5646
|
+
} catch (err) {
|
|
5647
|
+
printError2(`Failed to list agenda items: ${err}`);
|
|
5648
|
+
process.exit(1);
|
|
5649
|
+
}
|
|
5650
|
+
}
|
|
5651
|
+
var init_governance = __esm({
|
|
5652
|
+
"src/commands/governance.ts"() {
|
|
5653
|
+
"use strict";
|
|
5654
|
+
init_config();
|
|
5655
|
+
init_api_client();
|
|
5656
|
+
init_output();
|
|
5657
|
+
init_references();
|
|
5658
|
+
}
|
|
5659
|
+
});
|
|
5660
|
+
|
|
5661
|
+
// src/formation-automation.ts
|
|
5234
5662
|
function normalizeRole(value) {
|
|
5235
5663
|
return String(value ?? "").trim().toLowerCase();
|
|
5236
5664
|
}
|
|
@@ -5457,7 +5885,7 @@ async function documentsListCommand(opts) {
|
|
|
5457
5885
|
else if (docs.length === 0) console.log("No documents found.");
|
|
5458
5886
|
else printDocumentsTable(docs);
|
|
5459
5887
|
} catch (err) {
|
|
5460
|
-
|
|
5888
|
+
printError2(`Failed to fetch documents: ${err}`);
|
|
5461
5889
|
process.exit(1);
|
|
5462
5890
|
}
|
|
5463
5891
|
}
|
|
@@ -5477,7 +5905,7 @@ async function documentsSigningLinkCommand(docId, opts) {
|
|
|
5477
5905
|
}
|
|
5478
5906
|
console.log(shareUrl);
|
|
5479
5907
|
} catch (err) {
|
|
5480
|
-
|
|
5908
|
+
printError2(`Failed to get signing link: ${err}`);
|
|
5481
5909
|
process.exit(1);
|
|
5482
5910
|
}
|
|
5483
5911
|
}
|
|
@@ -5518,7 +5946,7 @@ async function documentsGenerateCommand(opts) {
|
|
|
5518
5946
|
showReuseHint: true
|
|
5519
5947
|
});
|
|
5520
5948
|
} catch (err) {
|
|
5521
|
-
|
|
5949
|
+
printError2(`Failed to generate contract: ${err}`);
|
|
5522
5950
|
process.exit(1);
|
|
5523
5951
|
}
|
|
5524
5952
|
}
|
|
@@ -5573,7 +6001,7 @@ async function documentsSignCommand(docId, opts) {
|
|
|
5573
6001
|
printReferenceSummary("document", result.document, { showReuseHint: true });
|
|
5574
6002
|
printJson(result.document);
|
|
5575
6003
|
} catch (err) {
|
|
5576
|
-
|
|
6004
|
+
printError2(`Failed to sign document: ${err}`);
|
|
5577
6005
|
process.exit(1);
|
|
5578
6006
|
}
|
|
5579
6007
|
}
|
|
@@ -5598,13 +6026,13 @@ async function documentsSignAllCommand(opts) {
|
|
|
5598
6026
|
signatures: Array.isArray(document.signatures) ? document.signatures.length : document.signatures
|
|
5599
6027
|
})));
|
|
5600
6028
|
} catch (err) {
|
|
5601
|
-
|
|
6029
|
+
printError2(`Failed to sign formation documents: ${err}`);
|
|
5602
6030
|
process.exit(1);
|
|
5603
6031
|
}
|
|
5604
6032
|
}
|
|
5605
6033
|
async function documentsPreviewPdfCommand(opts) {
|
|
5606
6034
|
if (!opts.documentId || opts.documentId.trim().length === 0) {
|
|
5607
|
-
|
|
6035
|
+
printError2("preview-pdf requires --definition-id (or deprecated alias --document-id)");
|
|
5608
6036
|
process.exit(1);
|
|
5609
6037
|
}
|
|
5610
6038
|
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
@@ -5617,7 +6045,7 @@ async function documentsPreviewPdfCommand(opts) {
|
|
|
5617
6045
|
printSuccess(`Preview PDF URL: ${url}`);
|
|
5618
6046
|
console.log("The document definition was validated successfully. Use your API key to download the PDF.");
|
|
5619
6047
|
} catch (err) {
|
|
5620
|
-
|
|
6048
|
+
printError2(`Failed to validate preview PDF: ${err}`);
|
|
5621
6049
|
process.exit(1);
|
|
5622
6050
|
}
|
|
5623
6051
|
}
|
|
@@ -5640,8 +6068,34 @@ __export(tax_exports, {
|
|
|
5640
6068
|
taxDeadlineCommand: () => taxDeadlineCommand,
|
|
5641
6069
|
taxDeadlinesCommand: () => taxDeadlinesCommand,
|
|
5642
6070
|
taxFileCommand: () => taxFileCommand,
|
|
5643
|
-
taxFilingsCommand: () => taxFilingsCommand
|
|
6071
|
+
taxFilingsCommand: () => taxFilingsCommand,
|
|
6072
|
+
taxSummaryCommand: () => taxSummaryCommand
|
|
5644
6073
|
});
|
|
6074
|
+
async function taxSummaryCommand(opts) {
|
|
6075
|
+
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
6076
|
+
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
6077
|
+
const resolver = new ReferenceResolver(client, cfg);
|
|
6078
|
+
try {
|
|
6079
|
+
const eid = await resolver.resolveEntity(opts.entityId);
|
|
6080
|
+
const [filings, deadlines] = await Promise.all([
|
|
6081
|
+
client.listTaxFilings(eid),
|
|
6082
|
+
client.listDeadlines(eid)
|
|
6083
|
+
]);
|
|
6084
|
+
if (opts.json) {
|
|
6085
|
+
printJson({ filings, deadlines });
|
|
6086
|
+
return;
|
|
6087
|
+
}
|
|
6088
|
+
if (filings.length === 0 && deadlines.length === 0) {
|
|
6089
|
+
console.log("No tax filings or deadlines found.");
|
|
6090
|
+
return;
|
|
6091
|
+
}
|
|
6092
|
+
if (filings.length > 0) printTaxFilingsTable(filings);
|
|
6093
|
+
if (deadlines.length > 0) printDeadlinesTable(deadlines);
|
|
6094
|
+
} catch (err) {
|
|
6095
|
+
printError2(`Failed to fetch tax summary: ${err}`);
|
|
6096
|
+
process.exit(1);
|
|
6097
|
+
}
|
|
6098
|
+
}
|
|
5645
6099
|
function normalizeRecurrence(recurrence) {
|
|
5646
6100
|
if (!recurrence) return void 0;
|
|
5647
6101
|
if (recurrence === "yearly") return "annual";
|
|
@@ -5659,7 +6113,7 @@ async function taxFilingsCommand(opts) {
|
|
|
5659
6113
|
else if (filings.length === 0) console.log("No tax filings found.");
|
|
5660
6114
|
else printTaxFilingsTable(filings);
|
|
5661
6115
|
} catch (err) {
|
|
5662
|
-
|
|
6116
|
+
printError2(`Failed to fetch tax filings: ${err}`);
|
|
5663
6117
|
process.exit(1);
|
|
5664
6118
|
}
|
|
5665
6119
|
}
|
|
@@ -5675,7 +6129,7 @@ async function taxDeadlinesCommand(opts) {
|
|
|
5675
6129
|
else if (deadlines.length === 0) console.log("No deadlines found.");
|
|
5676
6130
|
else printDeadlinesTable(deadlines);
|
|
5677
6131
|
} catch (err) {
|
|
5678
|
-
|
|
6132
|
+
printError2(`Failed to fetch deadlines: ${err}`);
|
|
5679
6133
|
process.exit(1);
|
|
5680
6134
|
}
|
|
5681
6135
|
}
|
|
@@ -5684,8 +6138,9 @@ async function taxFileCommand(opts) {
|
|
|
5684
6138
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
5685
6139
|
const resolver = new ReferenceResolver(client, cfg);
|
|
5686
6140
|
try {
|
|
6141
|
+
const docType = TAX_TYPE_ALIASES[opts.type] ?? opts.type;
|
|
5687
6142
|
const eid = await resolver.resolveEntity(opts.entityId);
|
|
5688
|
-
const result = await client.fileTaxDocument({ entity_id: eid, document_type:
|
|
6143
|
+
const result = await client.fileTaxDocument({ entity_id: eid, document_type: docType, tax_year: opts.year });
|
|
5689
6144
|
await resolver.stabilizeRecord("tax_filing", result, eid);
|
|
5690
6145
|
resolver.rememberFromRecord("tax_filing", result, eid);
|
|
5691
6146
|
printWriteResult(result, `Tax document filed: ${result.filing_id ?? "OK"}`, {
|
|
@@ -5694,7 +6149,7 @@ async function taxFileCommand(opts) {
|
|
|
5694
6149
|
showReuseHint: true
|
|
5695
6150
|
});
|
|
5696
6151
|
} catch (err) {
|
|
5697
|
-
|
|
6152
|
+
printError2(`Failed to file tax document: ${err}`);
|
|
5698
6153
|
process.exit(1);
|
|
5699
6154
|
}
|
|
5700
6155
|
}
|
|
@@ -5721,10 +6176,11 @@ async function taxDeadlineCommand(opts) {
|
|
|
5721
6176
|
showReuseHint: true
|
|
5722
6177
|
});
|
|
5723
6178
|
} catch (err) {
|
|
5724
|
-
|
|
6179
|
+
printError2(`Failed to track deadline: ${err}`);
|
|
5725
6180
|
process.exit(1);
|
|
5726
6181
|
}
|
|
5727
6182
|
}
|
|
6183
|
+
var TAX_TYPE_ALIASES;
|
|
5728
6184
|
var init_tax = __esm({
|
|
5729
6185
|
"src/commands/tax.ts"() {
|
|
5730
6186
|
"use strict";
|
|
@@ -5732,6 +6188,15 @@ var init_tax = __esm({
|
|
|
5732
6188
|
init_api_client();
|
|
5733
6189
|
init_output();
|
|
5734
6190
|
init_references();
|
|
6191
|
+
TAX_TYPE_ALIASES = {
|
|
6192
|
+
form_1120: "1120",
|
|
6193
|
+
form_1120s: "1120s",
|
|
6194
|
+
form_1065: "1065",
|
|
6195
|
+
form_1099_nec: "1099_nec",
|
|
6196
|
+
form_k1: "k1",
|
|
6197
|
+
form_941: "941",
|
|
6198
|
+
form_w2: "w2"
|
|
6199
|
+
};
|
|
5735
6200
|
}
|
|
5736
6201
|
});
|
|
5737
6202
|
|
|
@@ -5740,7 +6205,9 @@ var agents_exports = {};
|
|
|
5740
6205
|
__export(agents_exports, {
|
|
5741
6206
|
agentsCreateCommand: () => agentsCreateCommand,
|
|
5742
6207
|
agentsDeleteCommand: () => agentsDeleteCommand,
|
|
5743
|
-
|
|
6208
|
+
agentsExecutionCommand: () => agentsExecutionCommand,
|
|
6209
|
+
agentsExecutionResultCommand: () => agentsExecutionResultCommand,
|
|
6210
|
+
agentsKillCommand: () => agentsKillCommand,
|
|
5744
6211
|
agentsListCommand: () => agentsListCommand,
|
|
5745
6212
|
agentsMessageCommand: () => agentsMessageCommand,
|
|
5746
6213
|
agentsPauseCommand: () => agentsPauseCommand,
|
|
@@ -5748,6 +6215,7 @@ __export(agents_exports, {
|
|
|
5748
6215
|
agentsShowCommand: () => agentsShowCommand,
|
|
5749
6216
|
agentsSkillCommand: () => agentsSkillCommand
|
|
5750
6217
|
});
|
|
6218
|
+
import { confirm as confirm4 } from "@inquirer/prompts";
|
|
5751
6219
|
import chalk9 from "chalk";
|
|
5752
6220
|
import { readFileSync as readFileSync2, realpathSync } from "fs";
|
|
5753
6221
|
import { relative, resolve } from "path";
|
|
@@ -5762,7 +6230,7 @@ async function agentsListCommand(opts) {
|
|
|
5762
6230
|
else if (agents.length === 0) console.log("No agents found.");
|
|
5763
6231
|
else printAgentsTable(agents);
|
|
5764
6232
|
} catch (err) {
|
|
5765
|
-
|
|
6233
|
+
printError2(`Failed to fetch agents: ${err}`);
|
|
5766
6234
|
process.exit(1);
|
|
5767
6235
|
}
|
|
5768
6236
|
}
|
|
@@ -5795,7 +6263,7 @@ async function agentsShowCommand(agentId, opts) {
|
|
|
5795
6263
|
}
|
|
5796
6264
|
console.log(chalk9.magenta("\u2500".repeat(40)));
|
|
5797
6265
|
} catch (err) {
|
|
5798
|
-
|
|
6266
|
+
printError2(`Failed to fetch agent: ${err}`);
|
|
5799
6267
|
process.exit(1);
|
|
5800
6268
|
}
|
|
5801
6269
|
}
|
|
@@ -5815,7 +6283,7 @@ async function agentsCreateCommand(opts) {
|
|
|
5815
6283
|
showReuseHint: true
|
|
5816
6284
|
});
|
|
5817
6285
|
} catch (err) {
|
|
5818
|
-
|
|
6286
|
+
printError2(`Failed to create agent: ${err}`);
|
|
5819
6287
|
process.exit(1);
|
|
5820
6288
|
}
|
|
5821
6289
|
}
|
|
@@ -5828,7 +6296,7 @@ async function agentsPauseCommand(agentId, opts) {
|
|
|
5828
6296
|
const result = await client.updateAgent(resolvedAgentId, { status: "paused" });
|
|
5829
6297
|
printWriteResult(result, `Agent ${resolvedAgentId} paused.`, opts.json);
|
|
5830
6298
|
} catch (err) {
|
|
5831
|
-
|
|
6299
|
+
printError2(`Failed to pause agent: ${err}`);
|
|
5832
6300
|
process.exit(1);
|
|
5833
6301
|
}
|
|
5834
6302
|
}
|
|
@@ -5841,7 +6309,7 @@ async function agentsResumeCommand(agentId, opts) {
|
|
|
5841
6309
|
const result = await client.updateAgent(resolvedAgentId, { status: "active" });
|
|
5842
6310
|
printWriteResult(result, `Agent ${resolvedAgentId} resumed.`, opts.json);
|
|
5843
6311
|
} catch (err) {
|
|
5844
|
-
|
|
6312
|
+
printError2(`Failed to resume agent: ${err}`);
|
|
5845
6313
|
process.exit(1);
|
|
5846
6314
|
}
|
|
5847
6315
|
}
|
|
@@ -5851,10 +6319,20 @@ async function agentsDeleteCommand(agentId, opts) {
|
|
|
5851
6319
|
const resolver = new ReferenceResolver(client, cfg);
|
|
5852
6320
|
try {
|
|
5853
6321
|
const resolvedAgentId = await resolver.resolveAgent(agentId);
|
|
6322
|
+
if (!opts.yes) {
|
|
6323
|
+
const ok = await confirm4({
|
|
6324
|
+
message: `Delete agent ${resolvedAgentId}? This cannot be undone.`,
|
|
6325
|
+
default: false
|
|
6326
|
+
});
|
|
6327
|
+
if (!ok) {
|
|
6328
|
+
console.log("Cancelled.");
|
|
6329
|
+
return;
|
|
6330
|
+
}
|
|
6331
|
+
}
|
|
5854
6332
|
const result = await client.deleteAgent(resolvedAgentId);
|
|
5855
6333
|
printWriteResult(result, `Agent ${resolvedAgentId} deleted.`, opts.json);
|
|
5856
6334
|
} catch (err) {
|
|
5857
|
-
|
|
6335
|
+
printError2(`Failed to delete agent: ${err}`);
|
|
5858
6336
|
process.exit(1);
|
|
5859
6337
|
}
|
|
5860
6338
|
}
|
|
@@ -5894,21 +6372,72 @@ async function agentsMessageCommand(agentId, opts) {
|
|
|
5894
6372
|
const result = await client.sendAgentMessage(resolvedAgentId, body);
|
|
5895
6373
|
printWriteResult(result, `Message sent. Execution: ${result.execution_id ?? "OK"}`, opts.json);
|
|
5896
6374
|
} catch (err) {
|
|
5897
|
-
|
|
6375
|
+
printError2(`Failed to send message: ${err}`);
|
|
5898
6376
|
process.exit(1);
|
|
5899
6377
|
}
|
|
5900
6378
|
}
|
|
5901
|
-
async function
|
|
6379
|
+
async function agentsExecutionCommand(agentId, executionId, opts) {
|
|
5902
6380
|
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
5903
6381
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
5904
6382
|
const resolver = new ReferenceResolver(client, cfg);
|
|
5905
|
-
|
|
5906
|
-
|
|
5907
|
-
|
|
5908
|
-
|
|
5909
|
-
|
|
5910
|
-
|
|
5911
|
-
|
|
6383
|
+
try {
|
|
6384
|
+
const resolvedAgentId = await resolver.resolveAgent(agentId);
|
|
6385
|
+
const result = await client.getAgentExecution(resolvedAgentId, executionId);
|
|
6386
|
+
if (opts.json) {
|
|
6387
|
+
printJson(result);
|
|
6388
|
+
return;
|
|
6389
|
+
}
|
|
6390
|
+
console.log(chalk9.magenta("\u2500".repeat(40)));
|
|
6391
|
+
console.log(chalk9.magenta.bold(" Execution Status"));
|
|
6392
|
+
console.log(chalk9.magenta("\u2500".repeat(40)));
|
|
6393
|
+
console.log(` ${chalk9.bold("Execution:")} ${executionId}`);
|
|
6394
|
+
console.log(` ${chalk9.bold("Agent:")} ${resolvedAgentId}`);
|
|
6395
|
+
console.log(` ${chalk9.bold("Status:")} ${result.status ?? "N/A"}`);
|
|
6396
|
+
if (result.started_at) console.log(` ${chalk9.bold("Started:")} ${result.started_at}`);
|
|
6397
|
+
if (result.completed_at) console.log(` ${chalk9.bold("Completed:")} ${result.completed_at}`);
|
|
6398
|
+
console.log(chalk9.magenta("\u2500".repeat(40)));
|
|
6399
|
+
} catch (err) {
|
|
6400
|
+
printError2(`Failed to get execution: ${err}`);
|
|
6401
|
+
process.exit(1);
|
|
6402
|
+
}
|
|
6403
|
+
}
|
|
6404
|
+
async function agentsExecutionResultCommand(agentId, executionId, opts) {
|
|
6405
|
+
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
6406
|
+
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
6407
|
+
const resolver = new ReferenceResolver(client, cfg);
|
|
6408
|
+
try {
|
|
6409
|
+
const resolvedAgentId = await resolver.resolveAgent(agentId);
|
|
6410
|
+
const result = await client.getAgentExecutionResult(resolvedAgentId, executionId);
|
|
6411
|
+
if (opts.json) {
|
|
6412
|
+
printJson(result);
|
|
6413
|
+
return;
|
|
6414
|
+
}
|
|
6415
|
+
printSuccess(`Result for execution ${executionId}:`);
|
|
6416
|
+
printJson(result);
|
|
6417
|
+
} catch (err) {
|
|
6418
|
+
printError2(`Failed to get execution result: ${err}`);
|
|
6419
|
+
process.exit(1);
|
|
6420
|
+
}
|
|
6421
|
+
}
|
|
6422
|
+
async function agentsKillCommand(agentId, executionId, opts) {
|
|
6423
|
+
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
6424
|
+
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
6425
|
+
const resolver = new ReferenceResolver(client, cfg);
|
|
6426
|
+
try {
|
|
6427
|
+
const resolvedAgentId = await resolver.resolveAgent(agentId);
|
|
6428
|
+
if (!opts.yes) {
|
|
6429
|
+
const ok = await confirm4({ message: `Kill execution ${executionId}?`, default: false });
|
|
6430
|
+
if (!ok) {
|
|
6431
|
+
console.log("Cancelled.");
|
|
6432
|
+
return;
|
|
6433
|
+
}
|
|
6434
|
+
}
|
|
6435
|
+
const result = await client.killAgentExecution(resolvedAgentId, executionId);
|
|
6436
|
+
printWriteResult(result, `Execution ${executionId} killed.`, opts.json);
|
|
6437
|
+
} catch (err) {
|
|
6438
|
+
printError2(`Failed to kill execution: ${err}`);
|
|
6439
|
+
process.exit(1);
|
|
6440
|
+
}
|
|
5912
6441
|
}
|
|
5913
6442
|
async function agentsSkillCommand(agentId, opts) {
|
|
5914
6443
|
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
@@ -5928,7 +6457,7 @@ async function agentsSkillCommand(agentId, opts) {
|
|
|
5928
6457
|
});
|
|
5929
6458
|
printWriteResult(result, `Skill '${opts.name}' added to agent ${resolvedAgentId}.`, opts.json);
|
|
5930
6459
|
} catch (err) {
|
|
5931
|
-
|
|
6460
|
+
printError2(`Failed to add skill: ${err}`);
|
|
5932
6461
|
process.exit(1);
|
|
5933
6462
|
}
|
|
5934
6463
|
}
|
|
@@ -5953,6 +6482,7 @@ __export(work_items_exports, {
|
|
|
5953
6482
|
workItemsReleaseCommand: () => workItemsReleaseCommand,
|
|
5954
6483
|
workItemsShowCommand: () => workItemsShowCommand
|
|
5955
6484
|
});
|
|
6485
|
+
import { confirm as confirm5 } from "@inquirer/prompts";
|
|
5956
6486
|
import chalk10 from "chalk";
|
|
5957
6487
|
function actorLabel2(record, key) {
|
|
5958
6488
|
const actor = record[`${key}_actor`];
|
|
@@ -5981,7 +6511,7 @@ async function workItemsListCommand(opts) {
|
|
|
5981
6511
|
else if (items.length === 0) console.log("No work items found.");
|
|
5982
6512
|
else printWorkItemsTable(items);
|
|
5983
6513
|
} catch (err) {
|
|
5984
|
-
|
|
6514
|
+
printError2(`Failed to fetch work items: ${err}`);
|
|
5985
6515
|
process.exit(1);
|
|
5986
6516
|
}
|
|
5987
6517
|
}
|
|
@@ -6021,7 +6551,7 @@ async function workItemsShowCommand(workItemId, opts) {
|
|
|
6021
6551
|
console.log(` ${chalk10.bold("Created at:")} ${w.created_at ?? "N/A"}`);
|
|
6022
6552
|
console.log(chalk10.cyan("\u2500".repeat(40)));
|
|
6023
6553
|
} catch (err) {
|
|
6024
|
-
|
|
6554
|
+
printError2(`Failed to fetch work item: ${err}`);
|
|
6025
6555
|
process.exit(1);
|
|
6026
6556
|
}
|
|
6027
6557
|
}
|
|
@@ -6031,10 +6561,6 @@ async function workItemsCreateCommand(opts) {
|
|
|
6031
6561
|
const resolver = new ReferenceResolver(client, cfg);
|
|
6032
6562
|
try {
|
|
6033
6563
|
const eid = await resolver.resolveEntity(opts.entityId);
|
|
6034
|
-
if (!opts.category) {
|
|
6035
|
-
printError("Missing required option: --category <category>");
|
|
6036
|
-
process.exit(1);
|
|
6037
|
-
}
|
|
6038
6564
|
const data = { title: opts.title, category: opts.category };
|
|
6039
6565
|
if (opts.description) data.description = opts.description;
|
|
6040
6566
|
if (opts.deadline) data.deadline = opts.deadline;
|
|
@@ -6049,7 +6575,7 @@ async function workItemsCreateCommand(opts) {
|
|
|
6049
6575
|
{ jsonOnly: opts.json, referenceKind: "work_item", showReuseHint: true }
|
|
6050
6576
|
);
|
|
6051
6577
|
} catch (err) {
|
|
6052
|
-
|
|
6578
|
+
printError2(`Failed to create work item: ${err}`);
|
|
6053
6579
|
process.exit(1);
|
|
6054
6580
|
}
|
|
6055
6581
|
}
|
|
@@ -6067,7 +6593,7 @@ async function workItemsClaimCommand(workItemId, opts) {
|
|
|
6067
6593
|
const result = await client.claimWorkItem(eid, resolvedWorkItemId, data);
|
|
6068
6594
|
printWriteResult(result, `Work item ${resolvedWorkItemId} claimed by ${opts.claimedBy}.`, opts.json);
|
|
6069
6595
|
} catch (err) {
|
|
6070
|
-
|
|
6596
|
+
printError2(`Failed to claim work item: ${err}`);
|
|
6071
6597
|
process.exit(1);
|
|
6072
6598
|
}
|
|
6073
6599
|
}
|
|
@@ -6085,7 +6611,7 @@ async function workItemsCompleteCommand(workItemId, opts) {
|
|
|
6085
6611
|
const result = await client.completeWorkItem(eid, resolvedWorkItemId, data);
|
|
6086
6612
|
printWriteResult(result, `Work item ${resolvedWorkItemId} completed.`, opts.json);
|
|
6087
6613
|
} catch (err) {
|
|
6088
|
-
|
|
6614
|
+
printError2(`Failed to complete work item: ${err}`);
|
|
6089
6615
|
process.exit(1);
|
|
6090
6616
|
}
|
|
6091
6617
|
}
|
|
@@ -6099,7 +6625,7 @@ async function workItemsReleaseCommand(workItemId, opts) {
|
|
|
6099
6625
|
const result = await client.releaseWorkItem(eid, resolvedWorkItemId);
|
|
6100
6626
|
printWriteResult(result, `Work item ${resolvedWorkItemId} claim released.`, opts.json);
|
|
6101
6627
|
} catch (err) {
|
|
6102
|
-
|
|
6628
|
+
printError2(`Failed to release work item: ${err}`);
|
|
6103
6629
|
process.exit(1);
|
|
6104
6630
|
}
|
|
6105
6631
|
}
|
|
@@ -6110,10 +6636,20 @@ async function workItemsCancelCommand(workItemId, opts) {
|
|
|
6110
6636
|
try {
|
|
6111
6637
|
const eid = await resolver.resolveEntity(opts.entityId);
|
|
6112
6638
|
const resolvedWorkItemId = await resolver.resolveWorkItem(eid, workItemId);
|
|
6639
|
+
if (!opts.yes) {
|
|
6640
|
+
const ok = await confirm5({
|
|
6641
|
+
message: `Cancel work item ${resolvedWorkItemId}?`,
|
|
6642
|
+
default: false
|
|
6643
|
+
});
|
|
6644
|
+
if (!ok) {
|
|
6645
|
+
console.log("Cancelled.");
|
|
6646
|
+
return;
|
|
6647
|
+
}
|
|
6648
|
+
}
|
|
6113
6649
|
const result = await client.cancelWorkItem(eid, resolvedWorkItemId);
|
|
6114
6650
|
printWriteResult(result, `Work item ${resolvedWorkItemId} cancelled.`, opts.json);
|
|
6115
6651
|
} catch (err) {
|
|
6116
|
-
|
|
6652
|
+
printError2(`Failed to cancel work item: ${err}`);
|
|
6117
6653
|
process.exit(1);
|
|
6118
6654
|
}
|
|
6119
6655
|
}
|
|
@@ -6127,6 +6663,171 @@ var init_work_items = __esm({
|
|
|
6127
6663
|
}
|
|
6128
6664
|
});
|
|
6129
6665
|
|
|
6666
|
+
// src/commands/services.ts
|
|
6667
|
+
var services_exports = {};
|
|
6668
|
+
__export(services_exports, {
|
|
6669
|
+
servicesBuyCommand: () => servicesBuyCommand,
|
|
6670
|
+
servicesCancelCommand: () => servicesCancelCommand,
|
|
6671
|
+
servicesCatalogCommand: () => servicesCatalogCommand,
|
|
6672
|
+
servicesFulfillCommand: () => servicesFulfillCommand,
|
|
6673
|
+
servicesListCommand: () => servicesListCommand,
|
|
6674
|
+
servicesShowCommand: () => servicesShowCommand
|
|
6675
|
+
});
|
|
6676
|
+
import chalk11 from "chalk";
|
|
6677
|
+
async function servicesCatalogCommand(opts) {
|
|
6678
|
+
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
6679
|
+
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
6680
|
+
try {
|
|
6681
|
+
const items = await client.listServiceCatalog();
|
|
6682
|
+
if (opts.json) {
|
|
6683
|
+
printJson(items);
|
|
6684
|
+
return;
|
|
6685
|
+
}
|
|
6686
|
+
printServiceCatalogTable(items);
|
|
6687
|
+
} catch (err) {
|
|
6688
|
+
printError2(`Failed to list service catalog: ${err}`);
|
|
6689
|
+
process.exit(1);
|
|
6690
|
+
}
|
|
6691
|
+
}
|
|
6692
|
+
async function servicesBuyCommand(slug, opts) {
|
|
6693
|
+
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
6694
|
+
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
6695
|
+
const resolver = new ReferenceResolver(client, cfg);
|
|
6696
|
+
try {
|
|
6697
|
+
const eid = await resolver.resolveEntity(opts.entityId);
|
|
6698
|
+
const payload = { entity_id: eid, service_slug: slug };
|
|
6699
|
+
if (opts.dryRun) {
|
|
6700
|
+
printDryRun("services.create_request", payload);
|
|
6701
|
+
return;
|
|
6702
|
+
}
|
|
6703
|
+
const result = await client.createServiceRequest(payload);
|
|
6704
|
+
await resolver.stabilizeRecord("service_request", result, eid);
|
|
6705
|
+
resolver.rememberFromRecord("service_request", result, eid);
|
|
6706
|
+
const requestId = String(result.request_id ?? result.id ?? "");
|
|
6707
|
+
if (requestId) {
|
|
6708
|
+
const checkout = await client.beginServiceCheckout(requestId, { entity_id: eid });
|
|
6709
|
+
if (opts.json) {
|
|
6710
|
+
printJson(checkout);
|
|
6711
|
+
return;
|
|
6712
|
+
}
|
|
6713
|
+
printSuccess(`Service request created: ${requestId}`);
|
|
6714
|
+
printReferenceSummary("service_request", result, { showReuseHint: true });
|
|
6715
|
+
if (checkout.checkout_url) {
|
|
6716
|
+
console.log(`
|
|
6717
|
+
${chalk11.bold("Checkout URL:")} ${checkout.checkout_url}`);
|
|
6718
|
+
}
|
|
6719
|
+
console.log(chalk11.dim("\n Next steps:"));
|
|
6720
|
+
console.log(chalk11.dim(" Complete payment at the checkout URL above"));
|
|
6721
|
+
console.log(chalk11.dim(" corp services list --entity-id <id>"));
|
|
6722
|
+
} else {
|
|
6723
|
+
printWriteResult(result, "Service request created", {
|
|
6724
|
+
referenceKind: "service_request",
|
|
6725
|
+
showReuseHint: true
|
|
6726
|
+
});
|
|
6727
|
+
}
|
|
6728
|
+
} catch (err) {
|
|
6729
|
+
printError2(`Failed to create service request: ${err}`);
|
|
6730
|
+
process.exit(1);
|
|
6731
|
+
}
|
|
6732
|
+
}
|
|
6733
|
+
async function servicesListCommand(opts) {
|
|
6734
|
+
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
6735
|
+
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
6736
|
+
const resolver = new ReferenceResolver(client, cfg);
|
|
6737
|
+
try {
|
|
6738
|
+
const eid = await resolver.resolveEntity(opts.entityId);
|
|
6739
|
+
const requests = await client.listServiceRequests(eid);
|
|
6740
|
+
const stable = await resolver.stabilizeRecords("service_request", requests, eid);
|
|
6741
|
+
if (opts.json) {
|
|
6742
|
+
printJson(stable);
|
|
6743
|
+
return;
|
|
6744
|
+
}
|
|
6745
|
+
printServiceRequestsTable(stable);
|
|
6746
|
+
} catch (err) {
|
|
6747
|
+
printError2(`Failed to list service requests: ${err}`);
|
|
6748
|
+
process.exit(1);
|
|
6749
|
+
}
|
|
6750
|
+
}
|
|
6751
|
+
async function servicesShowCommand(ref_, opts) {
|
|
6752
|
+
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
6753
|
+
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
6754
|
+
const resolver = new ReferenceResolver(client, cfg);
|
|
6755
|
+
try {
|
|
6756
|
+
const eid = await resolver.resolveEntity(opts.entityId);
|
|
6757
|
+
const requestId = await resolver.resolveServiceRequest(eid, ref_);
|
|
6758
|
+
const result = await client.getServiceRequest(requestId, eid);
|
|
6759
|
+
await resolver.stabilizeRecord("service_request", result, eid);
|
|
6760
|
+
resolver.rememberFromRecord("service_request", result, eid);
|
|
6761
|
+
if (opts.json) {
|
|
6762
|
+
printJson(result);
|
|
6763
|
+
return;
|
|
6764
|
+
}
|
|
6765
|
+
printReferenceSummary("service_request", result);
|
|
6766
|
+
printJson(result);
|
|
6767
|
+
} catch (err) {
|
|
6768
|
+
printError2(`Failed to show service request: ${err}`);
|
|
6769
|
+
process.exit(1);
|
|
6770
|
+
}
|
|
6771
|
+
}
|
|
6772
|
+
async function servicesFulfillCommand(ref_, opts) {
|
|
6773
|
+
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
6774
|
+
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
6775
|
+
const resolver = new ReferenceResolver(client, cfg);
|
|
6776
|
+
try {
|
|
6777
|
+
const eid = await resolver.resolveEntity(opts.entityId);
|
|
6778
|
+
const requestId = await resolver.resolveServiceRequest(eid, ref_);
|
|
6779
|
+
const result = await client.fulfillServiceRequest(requestId, {
|
|
6780
|
+
entity_id: eid,
|
|
6781
|
+
note: opts.note
|
|
6782
|
+
});
|
|
6783
|
+
await resolver.stabilizeRecord("service_request", result, eid);
|
|
6784
|
+
resolver.rememberFromRecord("service_request", result, eid);
|
|
6785
|
+
if (opts.json) {
|
|
6786
|
+
printJson(result);
|
|
6787
|
+
return;
|
|
6788
|
+
}
|
|
6789
|
+
printSuccess(`Service request fulfilled: ${requestId}`);
|
|
6790
|
+
printReferenceSummary("service_request", result, { showReuseHint: true });
|
|
6791
|
+
printJson(result);
|
|
6792
|
+
} catch (err) {
|
|
6793
|
+
printError2(`Failed to fulfill service request: ${err}`);
|
|
6794
|
+
process.exit(1);
|
|
6795
|
+
}
|
|
6796
|
+
}
|
|
6797
|
+
async function servicesCancelCommand(ref_, opts) {
|
|
6798
|
+
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
6799
|
+
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
6800
|
+
const resolver = new ReferenceResolver(client, cfg);
|
|
6801
|
+
try {
|
|
6802
|
+
const eid = await resolver.resolveEntity(opts.entityId);
|
|
6803
|
+
const requestId = await resolver.resolveServiceRequest(eid, ref_);
|
|
6804
|
+
const result = await client.cancelServiceRequest(requestId, {
|
|
6805
|
+
entity_id: eid
|
|
6806
|
+
});
|
|
6807
|
+
await resolver.stabilizeRecord("service_request", result, eid);
|
|
6808
|
+
resolver.rememberFromRecord("service_request", result, eid);
|
|
6809
|
+
if (opts.json) {
|
|
6810
|
+
printJson(result);
|
|
6811
|
+
return;
|
|
6812
|
+
}
|
|
6813
|
+
printSuccess(`Service request cancelled: ${requestId}`);
|
|
6814
|
+
printReferenceSummary("service_request", result, { showReuseHint: true });
|
|
6815
|
+
printJson(result);
|
|
6816
|
+
} catch (err) {
|
|
6817
|
+
printError2(`Failed to cancel service request: ${err}`);
|
|
6818
|
+
process.exit(1);
|
|
6819
|
+
}
|
|
6820
|
+
}
|
|
6821
|
+
var init_services = __esm({
|
|
6822
|
+
"src/commands/services.ts"() {
|
|
6823
|
+
"use strict";
|
|
6824
|
+
init_config();
|
|
6825
|
+
init_api_client();
|
|
6826
|
+
init_output();
|
|
6827
|
+
init_references();
|
|
6828
|
+
}
|
|
6829
|
+
});
|
|
6830
|
+
|
|
6130
6831
|
// src/commands/billing.ts
|
|
6131
6832
|
var billing_exports = {};
|
|
6132
6833
|
__export(billing_exports, {
|
|
@@ -6158,7 +6859,7 @@ async function billingCommand(opts) {
|
|
|
6158
6859
|
if (opts.json) printJson({ status: enrichedStatus, plans });
|
|
6159
6860
|
else printBillingPanel(enrichedStatus, plans);
|
|
6160
6861
|
} catch (err) {
|
|
6161
|
-
|
|
6862
|
+
printError2(`Failed to fetch billing info: ${err}`);
|
|
6162
6863
|
process.exit(1);
|
|
6163
6864
|
}
|
|
6164
6865
|
}
|
|
@@ -6168,13 +6869,13 @@ async function billingPortalCommand() {
|
|
|
6168
6869
|
const result = await client.createBillingPortal();
|
|
6169
6870
|
const url = result.portal_url;
|
|
6170
6871
|
if (!url) {
|
|
6171
|
-
|
|
6872
|
+
printError2("No portal URL returned. Ensure you have an active subscription.");
|
|
6172
6873
|
process.exit(1);
|
|
6173
6874
|
}
|
|
6174
6875
|
printSuccess("Stripe Customer Portal URL:");
|
|
6175
6876
|
console.log(url);
|
|
6176
6877
|
} catch (err) {
|
|
6177
|
-
|
|
6878
|
+
printError2(`Failed to create portal session: ${err}`);
|
|
6178
6879
|
process.exit(1);
|
|
6179
6880
|
}
|
|
6180
6881
|
}
|
|
@@ -6184,13 +6885,13 @@ async function billingUpgradeCommand(opts) {
|
|
|
6184
6885
|
const result = await client.createBillingCheckout(opts.plan);
|
|
6185
6886
|
const url = result.checkout_url;
|
|
6186
6887
|
if (!url) {
|
|
6187
|
-
|
|
6888
|
+
printError2("No checkout URL returned.");
|
|
6188
6889
|
process.exit(1);
|
|
6189
6890
|
}
|
|
6190
6891
|
printSuccess(`Stripe Checkout URL for ${opts.plan}:`);
|
|
6191
6892
|
console.log(url);
|
|
6192
6893
|
} catch (err) {
|
|
6193
|
-
|
|
6894
|
+
printError2(`Failed to create checkout session: ${err}`);
|
|
6194
6895
|
process.exit(1);
|
|
6195
6896
|
}
|
|
6196
6897
|
}
|
|
@@ -6209,11 +6910,24 @@ __export(approvals_exports, {
|
|
|
6209
6910
|
approvalsListCommand: () => approvalsListCommand,
|
|
6210
6911
|
approvalsRespondCommand: () => approvalsRespondCommand
|
|
6211
6912
|
});
|
|
6913
|
+
import chalk12 from "chalk";
|
|
6212
6914
|
async function approvalsListCommand(_opts) {
|
|
6213
|
-
|
|
6214
|
-
|
|
6215
|
-
);
|
|
6216
|
-
|
|
6915
|
+
console.log(chalk12.bold("Approvals in TheCorporation"));
|
|
6916
|
+
console.log();
|
|
6917
|
+
console.log("Approvals are handled through governance meetings and execution intents.");
|
|
6918
|
+
console.log("Use these commands to manage approvals:");
|
|
6919
|
+
console.log();
|
|
6920
|
+
console.log(chalk12.dim(" Board approval via meeting vote:"));
|
|
6921
|
+
console.log(` corp governance convene --body <body> --type board_meeting --title "Approve X"`);
|
|
6922
|
+
console.log(` corp governance vote <meeting> <item> --voter <contact> --vote for`);
|
|
6923
|
+
console.log();
|
|
6924
|
+
console.log(chalk12.dim(" Written consent (no meeting needed):"));
|
|
6925
|
+
console.log(` corp governance written-consent --body <body> --title "Approve X" --description "..."`);
|
|
6926
|
+
console.log();
|
|
6927
|
+
console.log(chalk12.dim(" View pending items:"));
|
|
6928
|
+
console.log(` corp governance meetings <body> # see scheduled meetings`);
|
|
6929
|
+
console.log(` corp governance agenda-items <meeting> # see items awaiting votes`);
|
|
6930
|
+
console.log(` corp cap-table valuations # see pending valuations`);
|
|
6217
6931
|
}
|
|
6218
6932
|
async function approvalsRespondCommand(_approvalId, _decision, _opts) {
|
|
6219
6933
|
printError(
|
|
@@ -6224,7 +6938,6 @@ async function approvalsRespondCommand(_approvalId, _decision, _opts) {
|
|
|
6224
6938
|
var init_approvals = __esm({
|
|
6225
6939
|
"src/commands/approvals.ts"() {
|
|
6226
6940
|
"use strict";
|
|
6227
|
-
init_output();
|
|
6228
6941
|
}
|
|
6229
6942
|
});
|
|
6230
6943
|
|
|
@@ -6237,8 +6950,8 @@ __export(form_exports, {
|
|
|
6237
6950
|
formCreateCommand: () => formCreateCommand,
|
|
6238
6951
|
formFinalizeCommand: () => formFinalizeCommand
|
|
6239
6952
|
});
|
|
6240
|
-
import { input as input2, select, confirm as
|
|
6241
|
-
import
|
|
6953
|
+
import { input as input2, select as select2, confirm as confirm6, number } from "@inquirer/prompts";
|
|
6954
|
+
import chalk13 from "chalk";
|
|
6242
6955
|
import Table3 from "cli-table3";
|
|
6243
6956
|
import { readFileSync as readFileSync3, realpathSync as realpathSync2 } from "fs";
|
|
6244
6957
|
import { relative as relative2, resolve as resolve2 } from "path";
|
|
@@ -6248,9 +6961,9 @@ function isCorp(entityType) {
|
|
|
6248
6961
|
}
|
|
6249
6962
|
function sectionHeader(title) {
|
|
6250
6963
|
console.log();
|
|
6251
|
-
console.log(
|
|
6252
|
-
console.log(
|
|
6253
|
-
console.log(
|
|
6964
|
+
console.log(chalk13.blue("\u2500".repeat(50)));
|
|
6965
|
+
console.log(chalk13.blue.bold(` ${title}`));
|
|
6966
|
+
console.log(chalk13.blue("\u2500".repeat(50)));
|
|
6254
6967
|
}
|
|
6255
6968
|
function officerTitleLabel(title) {
|
|
6256
6969
|
switch (title) {
|
|
@@ -6306,7 +7019,7 @@ function normalizeFounderInfo(input3) {
|
|
|
6306
7019
|
throw new Error("Founder JSON requires non-empty name, email, and role.");
|
|
6307
7020
|
}
|
|
6308
7021
|
const founder = { name, email, role };
|
|
6309
|
-
const ownershipPct = input3.ownership_pct ?? input3.pct;
|
|
7022
|
+
const ownershipPct = input3.ownership_pct ?? input3.membership_pct ?? input3.pct;
|
|
6310
7023
|
if (ownershipPct != null) founder.ownership_pct = Number(ownershipPct);
|
|
6311
7024
|
const sharesPurchased = input3.shares_purchased ?? input3.shares;
|
|
6312
7025
|
if (sharesPurchased != null) founder.shares_purchased = Number(sharesPurchased);
|
|
@@ -6410,7 +7123,7 @@ async function phaseEntityDetails(opts, serverCfg, scripted) {
|
|
|
6410
7123
|
if (scripted) {
|
|
6411
7124
|
entityType = "llc";
|
|
6412
7125
|
} else {
|
|
6413
|
-
entityType = await
|
|
7126
|
+
entityType = await select2({
|
|
6414
7127
|
message: "Entity type",
|
|
6415
7128
|
choices: [
|
|
6416
7129
|
{ value: "llc", name: "LLC" },
|
|
@@ -6422,7 +7135,7 @@ async function phaseEntityDetails(opts, serverCfg, scripted) {
|
|
|
6422
7135
|
let name = opts.name;
|
|
6423
7136
|
if (!name) {
|
|
6424
7137
|
if (scripted) {
|
|
6425
|
-
|
|
7138
|
+
printError2("--name is required in scripted mode");
|
|
6426
7139
|
process.exit(1);
|
|
6427
7140
|
}
|
|
6428
7141
|
name = await input2({ message: "Legal name" });
|
|
@@ -6444,7 +7157,7 @@ async function phaseEntityDetails(opts, serverCfg, scripted) {
|
|
|
6444
7157
|
}
|
|
6445
7158
|
}
|
|
6446
7159
|
if (!companyAddress && !scripted) {
|
|
6447
|
-
const wantAddress = await
|
|
7160
|
+
const wantAddress = await confirm6({ message: "Add company address?", default: false });
|
|
6448
7161
|
if (wantAddress) {
|
|
6449
7162
|
companyAddress = await promptAddress();
|
|
6450
7163
|
}
|
|
@@ -6452,7 +7165,7 @@ async function phaseEntityDetails(opts, serverCfg, scripted) {
|
|
|
6452
7165
|
const fiscalYearEnd = opts.fiscalYearEnd ?? "12-31";
|
|
6453
7166
|
let sCorpElection = opts.sCorp ?? false;
|
|
6454
7167
|
if (!scripted && isCorp(entityType) && opts.sCorp === void 0) {
|
|
6455
|
-
sCorpElection = await
|
|
7168
|
+
sCorpElection = await confirm6({ message: "S-Corp election?", default: false });
|
|
6456
7169
|
}
|
|
6457
7170
|
return { entityType, name, jurisdiction, companyAddress, fiscalYearEnd, sCorpElection };
|
|
6458
7171
|
}
|
|
@@ -6463,19 +7176,19 @@ async function phasePeople(opts, entityType, scripted) {
|
|
|
6463
7176
|
try {
|
|
6464
7177
|
return parseScriptedFounders(opts);
|
|
6465
7178
|
} catch (err) {
|
|
6466
|
-
|
|
7179
|
+
printError2(String(err));
|
|
6467
7180
|
process.exit(1);
|
|
6468
7181
|
}
|
|
6469
7182
|
}
|
|
6470
7183
|
const founderCount = await number({ message: "Number of founders (1-6)", default: 1 }) ?? 1;
|
|
6471
7184
|
for (let i = 0; i < founderCount; i++) {
|
|
6472
|
-
console.log(
|
|
7185
|
+
console.log(chalk13.dim(`
|
|
6473
7186
|
Founder ${i + 1} of ${founderCount}:`));
|
|
6474
7187
|
const name = await input2({ message: ` Name` });
|
|
6475
7188
|
const email = await input2({ message: ` Email` });
|
|
6476
7189
|
let role = "member";
|
|
6477
7190
|
if (isCorp(entityType)) {
|
|
6478
|
-
role = await
|
|
7191
|
+
role = await select2({
|
|
6479
7192
|
message: " Role",
|
|
6480
7193
|
choices: [
|
|
6481
7194
|
{ value: "director", name: "Director" },
|
|
@@ -6484,13 +7197,13 @@ async function phasePeople(opts, entityType, scripted) {
|
|
|
6484
7197
|
]
|
|
6485
7198
|
});
|
|
6486
7199
|
}
|
|
6487
|
-
const wantAddress = await
|
|
7200
|
+
const wantAddress = await confirm6({ message: " Add address?", default: false });
|
|
6488
7201
|
const address = wantAddress ? await promptAddress() : void 0;
|
|
6489
7202
|
let officerTitle;
|
|
6490
7203
|
if (isCorp(entityType)) {
|
|
6491
|
-
const wantOfficer = role === "officer" || await
|
|
7204
|
+
const wantOfficer = role === "officer" || await confirm6({ message: " Assign officer title?", default: i === 0 });
|
|
6492
7205
|
if (wantOfficer) {
|
|
6493
|
-
officerTitle = await
|
|
7206
|
+
officerTitle = await select2({
|
|
6494
7207
|
message: " Officer title",
|
|
6495
7208
|
choices: OfficerTitle.map((t) => ({
|
|
6496
7209
|
value: t,
|
|
@@ -6503,7 +7216,7 @@ async function phasePeople(opts, entityType, scripted) {
|
|
|
6503
7216
|
if (isCorp(entityType) && i === 0 && founderCount === 1) {
|
|
6504
7217
|
isIncorporator = true;
|
|
6505
7218
|
} else if (isCorp(entityType)) {
|
|
6506
|
-
isIncorporator = await
|
|
7219
|
+
isIncorporator = await confirm6({ message: " Designate as sole incorporator?", default: i === 0 });
|
|
6507
7220
|
}
|
|
6508
7221
|
founders.push({ name, email, role, address, officer_title: officerTitle, is_incorporator: isIncorporator });
|
|
6509
7222
|
}
|
|
@@ -6511,11 +7224,11 @@ async function phasePeople(opts, entityType, scripted) {
|
|
|
6511
7224
|
}
|
|
6512
7225
|
async function phaseStock(opts, entityType, founders, scripted) {
|
|
6513
7226
|
if (!scripted) sectionHeader("Phase 3: Equity & Finalize");
|
|
6514
|
-
const transferRestrictions = opts.transferRestrictions ?? (!scripted && isCorp(entityType) ? await
|
|
6515
|
-
const rofr = opts.rofr ?? (!scripted && isCorp(entityType) ? await
|
|
7227
|
+
const transferRestrictions = opts.transferRestrictions ?? (!scripted && isCorp(entityType) ? await confirm6({ message: "Transfer restrictions on shares?", default: true }) : isCorp(entityType));
|
|
7228
|
+
const rofr = opts.rofr ?? (!scripted && isCorp(entityType) ? await confirm6({ message: "Right of first refusal?", default: true }) : isCorp(entityType));
|
|
6516
7229
|
if (!scripted) {
|
|
6517
7230
|
for (const f of founders) {
|
|
6518
|
-
console.log(
|
|
7231
|
+
console.log(chalk13.dim(`
|
|
6519
7232
|
Equity for ${f.name}:`));
|
|
6520
7233
|
if (isCorp(entityType)) {
|
|
6521
7234
|
const shares = await number({ message: ` Shares to purchase`, default: 0 });
|
|
@@ -6532,11 +7245,11 @@ async function phaseStock(opts, entityType, founders, scripted) {
|
|
|
6532
7245
|
f.ownership_pct = pct ?? 0;
|
|
6533
7246
|
}
|
|
6534
7247
|
if (isCorp(entityType)) {
|
|
6535
|
-
const wantVesting = await
|
|
7248
|
+
const wantVesting = await confirm6({ message: " Add vesting schedule?", default: false });
|
|
6536
7249
|
if (wantVesting) {
|
|
6537
7250
|
const totalMonths = await number({ message: " Total vesting months", default: 48 }) ?? 48;
|
|
6538
7251
|
const cliffMonths = await number({ message: " Cliff months", default: 12 }) ?? 12;
|
|
6539
|
-
const acceleration = await
|
|
7252
|
+
const acceleration = await select2({
|
|
6540
7253
|
message: " Acceleration",
|
|
6541
7254
|
choices: [
|
|
6542
7255
|
{ value: "none", name: "None" },
|
|
@@ -6551,7 +7264,7 @@ async function phaseStock(opts, entityType, founders, scripted) {
|
|
|
6551
7264
|
};
|
|
6552
7265
|
}
|
|
6553
7266
|
}
|
|
6554
|
-
const wantIp = await
|
|
7267
|
+
const wantIp = await confirm6({ message: " Contributing IP?", default: false });
|
|
6555
7268
|
if (wantIp) {
|
|
6556
7269
|
f.ip_description = await input2({ message: " Describe IP being contributed" });
|
|
6557
7270
|
}
|
|
@@ -6561,17 +7274,17 @@ async function phaseStock(opts, entityType, founders, scripted) {
|
|
|
6561
7274
|
}
|
|
6562
7275
|
function printSummary(entityType, name, jurisdiction, fiscalYearEnd, sCorpElection, founders, transferRestrictions, rofr) {
|
|
6563
7276
|
sectionHeader("Formation Summary");
|
|
6564
|
-
console.log(` ${
|
|
6565
|
-
console.log(` ${
|
|
6566
|
-
console.log(` ${
|
|
6567
|
-
console.log(` ${
|
|
7277
|
+
console.log(` ${chalk13.bold("Entity:")} ${name}`);
|
|
7278
|
+
console.log(` ${chalk13.bold("Type:")} ${entityType}`);
|
|
7279
|
+
console.log(` ${chalk13.bold("Jurisdiction:")} ${jurisdiction}`);
|
|
7280
|
+
console.log(` ${chalk13.bold("Fiscal Year End:")} ${fiscalYearEnd}`);
|
|
6568
7281
|
if (isCorp(entityType)) {
|
|
6569
|
-
console.log(` ${
|
|
6570
|
-
console.log(` ${
|
|
6571
|
-
console.log(` ${
|
|
7282
|
+
console.log(` ${chalk13.bold("S-Corp Election:")} ${sCorpElection ? "Yes" : "No"}`);
|
|
7283
|
+
console.log(` ${chalk13.bold("Transfer Restrictions:")} ${transferRestrictions ? "Yes" : "No"}`);
|
|
7284
|
+
console.log(` ${chalk13.bold("Right of First Refusal:")} ${rofr ? "Yes" : "No"}`);
|
|
6572
7285
|
}
|
|
6573
7286
|
const table = new Table3({
|
|
6574
|
-
head: [
|
|
7287
|
+
head: [chalk13.dim("Name"), chalk13.dim("Email"), chalk13.dim("Role"), chalk13.dim("Equity"), chalk13.dim("Officer")]
|
|
6575
7288
|
});
|
|
6576
7289
|
for (const f of founders) {
|
|
6577
7290
|
const equity = f.shares_purchased ? `${f.shares_purchased.toLocaleString()} shares` : f.ownership_pct ? `${f.ownership_pct}%` : "\u2014";
|
|
@@ -6596,9 +7309,9 @@ async function formCommand(opts) {
|
|
|
6596
7309
|
const founders = await phasePeople(opts, entityType, scripted);
|
|
6597
7310
|
const { transferRestrictions, rofr } = await phaseStock(opts, entityType, founders, scripted);
|
|
6598
7311
|
printSummary(entityType, name, jurisdiction, fiscalYearEnd, sCorpElection, founders, transferRestrictions, rofr);
|
|
6599
|
-
const shouldProceed = scripted ? true : await
|
|
7312
|
+
const shouldProceed = scripted ? true : await confirm6({ message: "Proceed with formation?", default: true });
|
|
6600
7313
|
if (!shouldProceed) {
|
|
6601
|
-
console.log(
|
|
7314
|
+
console.log(chalk13.yellow("Formation cancelled."));
|
|
6602
7315
|
return;
|
|
6603
7316
|
}
|
|
6604
7317
|
const members = founders.map((f) => {
|
|
@@ -6636,6 +7349,11 @@ async function formCommand(opts) {
|
|
|
6636
7349
|
const result = await client.createFormationWithCapTable(payload);
|
|
6637
7350
|
await resolver.stabilizeRecord("entity", result);
|
|
6638
7351
|
resolver.rememberFromRecord("entity", result);
|
|
7352
|
+
if (result.entity_id) {
|
|
7353
|
+
setActiveEntityId(cfg, String(result.entity_id));
|
|
7354
|
+
saveConfig(cfg);
|
|
7355
|
+
console.log(chalk13.dim(` Active entity set to ${result.entity_id}`));
|
|
7356
|
+
}
|
|
6639
7357
|
if (opts.json) {
|
|
6640
7358
|
printJson(result);
|
|
6641
7359
|
return;
|
|
@@ -6654,22 +7372,22 @@ async function formCommand(opts) {
|
|
|
6654
7372
|
if (holders.length > 0) {
|
|
6655
7373
|
console.log();
|
|
6656
7374
|
const table = new Table3({
|
|
6657
|
-
head: [
|
|
7375
|
+
head: [chalk13.dim("Holder"), chalk13.dim("Shares"), chalk13.dim("Ownership %")]
|
|
6658
7376
|
});
|
|
6659
7377
|
for (const h of holders) {
|
|
6660
7378
|
const pct = typeof h.ownership_pct === "number" ? `${h.ownership_pct.toFixed(1)}%` : "\u2014";
|
|
6661
7379
|
table.push([String(h.name ?? "?"), String(h.shares ?? 0), pct]);
|
|
6662
7380
|
}
|
|
6663
|
-
console.log(
|
|
7381
|
+
console.log(chalk13.bold(" Cap Table:"));
|
|
6664
7382
|
console.log(table.toString());
|
|
6665
7383
|
}
|
|
6666
7384
|
if (result.next_action) {
|
|
6667
|
-
console.log(
|
|
7385
|
+
console.log(chalk13.yellow(`
|
|
6668
7386
|
Next: ${result.next_action}`));
|
|
6669
7387
|
}
|
|
6670
7388
|
} catch (err) {
|
|
6671
7389
|
if (err instanceof Error && err.message.includes("exit")) throw err;
|
|
6672
|
-
|
|
7390
|
+
printError2(`Failed to create formation: ${err}`);
|
|
6673
7391
|
process.exit(1);
|
|
6674
7392
|
}
|
|
6675
7393
|
}
|
|
@@ -6725,6 +7443,10 @@ async function formCreateCommand(opts) {
|
|
|
6725
7443
|
const result = await client.createPendingEntity(payload);
|
|
6726
7444
|
await resolver.stabilizeRecord("entity", result);
|
|
6727
7445
|
resolver.rememberFromRecord("entity", result);
|
|
7446
|
+
if (result.entity_id) {
|
|
7447
|
+
setActiveEntityId(cfg, String(result.entity_id));
|
|
7448
|
+
saveConfig(cfg);
|
|
7449
|
+
}
|
|
6728
7450
|
if (opts.json) {
|
|
6729
7451
|
printJson(result);
|
|
6730
7452
|
return;
|
|
@@ -6735,10 +7457,10 @@ async function formCreateCommand(opts) {
|
|
|
6735
7457
|
console.log(` Type: ${result.entity_type}`);
|
|
6736
7458
|
console.log(` Jurisdiction: ${result.jurisdiction}`);
|
|
6737
7459
|
console.log(` Status: ${result.formation_status}`);
|
|
6738
|
-
console.log(
|
|
7460
|
+
console.log(chalk13.yellow(`
|
|
6739
7461
|
Next: corp form add-founder @last:entity --name "..." --email "..." --role member --pct 50`));
|
|
6740
7462
|
} catch (err) {
|
|
6741
|
-
|
|
7463
|
+
printError2(`Failed to create pending entity: ${err}`);
|
|
6742
7464
|
process.exit(1);
|
|
6743
7465
|
}
|
|
6744
7466
|
}
|
|
@@ -6773,10 +7495,10 @@ async function formAddFounderCommand(entityId, opts) {
|
|
|
6773
7495
|
const pct = typeof m.ownership_pct === "number" ? ` (${m.ownership_pct}%)` : "";
|
|
6774
7496
|
console.log(` - ${m.name} <${m.email ?? "no email"}> [${m.role ?? "member"}]${pct}`);
|
|
6775
7497
|
}
|
|
6776
|
-
console.log(
|
|
7498
|
+
console.log(chalk13.yellow(`
|
|
6777
7499
|
Next: add more founders or run: corp form finalize @last:entity`));
|
|
6778
7500
|
} catch (err) {
|
|
6779
|
-
|
|
7501
|
+
printError2(`Failed to add founder: ${err}`);
|
|
6780
7502
|
process.exit(1);
|
|
6781
7503
|
}
|
|
6782
7504
|
}
|
|
@@ -6837,21 +7559,21 @@ async function formFinalizeCommand(entityId, opts) {
|
|
|
6837
7559
|
if (holders.length > 0) {
|
|
6838
7560
|
console.log();
|
|
6839
7561
|
const table = new Table3({
|
|
6840
|
-
head: [
|
|
7562
|
+
head: [chalk13.dim("Holder"), chalk13.dim("Shares"), chalk13.dim("Ownership %")]
|
|
6841
7563
|
});
|
|
6842
7564
|
for (const h of holders) {
|
|
6843
7565
|
const pct = typeof h.ownership_pct === "number" ? `${h.ownership_pct.toFixed(1)}%` : "\u2014";
|
|
6844
7566
|
table.push([String(h.name ?? "?"), String(h.shares ?? 0), pct]);
|
|
6845
7567
|
}
|
|
6846
|
-
console.log(
|
|
7568
|
+
console.log(chalk13.bold(" Cap Table:"));
|
|
6847
7569
|
console.log(table.toString());
|
|
6848
7570
|
}
|
|
6849
7571
|
if (result.next_action) {
|
|
6850
|
-
console.log(
|
|
7572
|
+
console.log(chalk13.yellow(`
|
|
6851
7573
|
Next: ${result.next_action}`));
|
|
6852
7574
|
}
|
|
6853
7575
|
} catch (err) {
|
|
6854
|
-
|
|
7576
|
+
printError2(`Failed to finalize formation: ${err}`);
|
|
6855
7577
|
process.exit(1);
|
|
6856
7578
|
}
|
|
6857
7579
|
}
|
|
@@ -6898,9 +7620,8 @@ async function formActivateCommand(entityId, opts) {
|
|
|
6898
7620
|
}
|
|
6899
7621
|
console.log(` Signatures added: ${result.signatures_added}`);
|
|
6900
7622
|
console.log(` Documents updated: ${result.documents_signed}`);
|
|
6901
|
-
printJson(formation);
|
|
6902
7623
|
} catch (err) {
|
|
6903
|
-
|
|
7624
|
+
printError2(`Failed to activate formation: ${err}`);
|
|
6904
7625
|
process.exit(1);
|
|
6905
7626
|
}
|
|
6906
7627
|
}
|
|
@@ -6918,43 +7639,87 @@ var init_form = __esm({
|
|
|
6918
7639
|
// src/commands/api-keys.ts
|
|
6919
7640
|
var api_keys_exports = {};
|
|
6920
7641
|
__export(api_keys_exports, {
|
|
6921
|
-
|
|
7642
|
+
apiKeysCreateCommand: () => apiKeysCreateCommand,
|
|
7643
|
+
apiKeysListCommand: () => apiKeysListCommand,
|
|
7644
|
+
apiKeysRevokeCommand: () => apiKeysRevokeCommand,
|
|
7645
|
+
apiKeysRotateCommand: () => apiKeysRotateCommand
|
|
6922
7646
|
});
|
|
6923
|
-
import
|
|
6924
|
-
|
|
6925
|
-
async function apiKeysCommand(opts) {
|
|
7647
|
+
import { confirm as confirm7 } from "@inquirer/prompts";
|
|
7648
|
+
async function apiKeysListCommand(opts) {
|
|
6926
7649
|
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
6927
7650
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
6928
7651
|
try {
|
|
6929
7652
|
const keys = await client.listApiKeys();
|
|
6930
7653
|
if (opts.json) {
|
|
6931
|
-
printJson(keys
|
|
6932
|
-
...k,
|
|
6933
|
-
...k.key != null ? { key: maskKey(String(k.key)) } : {},
|
|
6934
|
-
...k.api_key != null ? { api_key: maskKey(String(k.api_key)) } : {}
|
|
6935
|
-
})));
|
|
7654
|
+
printJson(keys);
|
|
6936
7655
|
return;
|
|
6937
7656
|
}
|
|
6938
7657
|
if (keys.length === 0) {
|
|
6939
7658
|
console.log("No API keys found.");
|
|
6940
7659
|
return;
|
|
6941
7660
|
}
|
|
6942
|
-
console.log(`
|
|
6943
|
-
${chalk12.bold("API Keys")}`);
|
|
6944
|
-
const table = new Table4({
|
|
6945
|
-
head: [chalk12.dim("ID"), chalk12.dim("Name"), chalk12.dim("Key"), chalk12.dim("Created")]
|
|
6946
|
-
});
|
|
6947
7661
|
for (const k of keys) {
|
|
6948
|
-
|
|
6949
|
-
|
|
6950
|
-
|
|
6951
|
-
|
|
6952
|
-
|
|
6953
|
-
|
|
7662
|
+
const name = k.name ?? k.label ?? "unnamed";
|
|
7663
|
+
const id = k.key_id ?? k.id;
|
|
7664
|
+
const scopes = Array.isArray(k.scopes) ? k.scopes.join(", ") : "all";
|
|
7665
|
+
console.log(` ${name} [${id}] scopes: ${scopes}`);
|
|
7666
|
+
}
|
|
7667
|
+
} catch (err) {
|
|
7668
|
+
printError2(`Failed to list API keys: ${err}`);
|
|
7669
|
+
process.exit(1);
|
|
7670
|
+
}
|
|
7671
|
+
}
|
|
7672
|
+
async function apiKeysCreateCommand(opts) {
|
|
7673
|
+
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
7674
|
+
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
7675
|
+
try {
|
|
7676
|
+
const data = { name: opts.name };
|
|
7677
|
+
if (opts.scopes) data.scopes = opts.scopes.split(",").map((s2) => s2.trim());
|
|
7678
|
+
const result = await client.createApiKey(data);
|
|
7679
|
+
printWriteResult(result, `API key created: ${result.key_id ?? "OK"}`, opts.json);
|
|
7680
|
+
if (!opts.json && result.api_key) {
|
|
7681
|
+
printSuccess(`Key: ${result.api_key}`);
|
|
7682
|
+
console.log(" Save this key \u2014 it will not be shown again.");
|
|
6954
7683
|
}
|
|
6955
|
-
console.log(table.toString());
|
|
6956
7684
|
} catch (err) {
|
|
6957
|
-
|
|
7685
|
+
printError2(`Failed to create API key: ${err}`);
|
|
7686
|
+
process.exit(1);
|
|
7687
|
+
}
|
|
7688
|
+
}
|
|
7689
|
+
async function apiKeysRevokeCommand(keyId, opts) {
|
|
7690
|
+
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
7691
|
+
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
7692
|
+
try {
|
|
7693
|
+
if (!opts.yes) {
|
|
7694
|
+
const ok = await confirm7({ message: `Revoke API key ${keyId}? This cannot be undone.`, default: false });
|
|
7695
|
+
if (!ok) {
|
|
7696
|
+
console.log("Cancelled.");
|
|
7697
|
+
return;
|
|
7698
|
+
}
|
|
7699
|
+
}
|
|
7700
|
+
await client.revokeApiKey(keyId);
|
|
7701
|
+
if (opts.json) {
|
|
7702
|
+
printJson({ revoked: true, key_id: keyId });
|
|
7703
|
+
return;
|
|
7704
|
+
}
|
|
7705
|
+
printSuccess(`API key ${keyId} revoked.`);
|
|
7706
|
+
} catch (err) {
|
|
7707
|
+
printError2(`Failed to revoke API key: ${err}`);
|
|
7708
|
+
process.exit(1);
|
|
7709
|
+
}
|
|
7710
|
+
}
|
|
7711
|
+
async function apiKeysRotateCommand(keyId, opts) {
|
|
7712
|
+
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
7713
|
+
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
7714
|
+
try {
|
|
7715
|
+
const result = await client.rotateApiKey(keyId);
|
|
7716
|
+
printWriteResult(result, `API key ${keyId} rotated.`, opts.json);
|
|
7717
|
+
if (!opts.json && result.api_key) {
|
|
7718
|
+
printSuccess(`New key: ${result.api_key}`);
|
|
7719
|
+
console.log(" Save this key \u2014 it will not be shown again.");
|
|
7720
|
+
}
|
|
7721
|
+
} catch (err) {
|
|
7722
|
+
printError2(`Failed to rotate API key: ${err}`);
|
|
6958
7723
|
process.exit(1);
|
|
6959
7724
|
}
|
|
6960
7725
|
}
|
|
@@ -7203,7 +7968,7 @@ async function demoCommand(opts) {
|
|
|
7203
7968
|
printReferenceSummary("bank_account", bankAccount, { showReuseHint: true });
|
|
7204
7969
|
printJson(result);
|
|
7205
7970
|
} catch (err) {
|
|
7206
|
-
|
|
7971
|
+
printError2(`Failed to seed demo: ${err}`);
|
|
7207
7972
|
process.exit(1);
|
|
7208
7973
|
}
|
|
7209
7974
|
}
|
|
@@ -7224,14 +7989,14 @@ var feedback_exports = {};
|
|
|
7224
7989
|
__export(feedback_exports, {
|
|
7225
7990
|
feedbackCommand: () => feedbackCommand
|
|
7226
7991
|
});
|
|
7227
|
-
import
|
|
7992
|
+
import chalk14 from "chalk";
|
|
7228
7993
|
async function feedbackCommand(message, opts) {
|
|
7229
7994
|
if (!message || message.trim().length === 0) {
|
|
7230
|
-
|
|
7995
|
+
printError2("Feedback message cannot be empty");
|
|
7231
7996
|
process.exit(1);
|
|
7232
7997
|
}
|
|
7233
7998
|
if (message.length > MAX_FEEDBACK_LENGTH) {
|
|
7234
|
-
|
|
7999
|
+
printError2(`Feedback message must be at most ${MAX_FEEDBACK_LENGTH} characters (got ${message.length})`);
|
|
7235
8000
|
process.exit(1);
|
|
7236
8001
|
}
|
|
7237
8002
|
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
@@ -7243,16 +8008,16 @@ async function feedbackCommand(message, opts) {
|
|
|
7243
8008
|
return;
|
|
7244
8009
|
}
|
|
7245
8010
|
console.log(`
|
|
7246
|
-
${
|
|
8011
|
+
${chalk14.green("\u2713")} Feedback submitted (${chalk14.dim(result.feedback_id)})`);
|
|
7247
8012
|
} catch (err) {
|
|
7248
8013
|
const detail = String(err);
|
|
7249
8014
|
if (detail.includes("404")) {
|
|
7250
|
-
|
|
8015
|
+
printError2(
|
|
7251
8016
|
`Failed to submit feedback: ${detail}
|
|
7252
8017
|
This server does not expose /v1/feedback. Local api-rs dev servers currently do not support feedback submission.`
|
|
7253
8018
|
);
|
|
7254
8019
|
} else {
|
|
7255
|
-
|
|
8020
|
+
printError2(`Failed to submit feedback: ${detail}`);
|
|
7256
8021
|
}
|
|
7257
8022
|
process.exit(1);
|
|
7258
8023
|
}
|
|
@@ -7273,38 +8038,8 @@ var serve_exports = {};
|
|
|
7273
8038
|
__export(serve_exports, {
|
|
7274
8039
|
serveCommand: () => serveCommand
|
|
7275
8040
|
});
|
|
7276
|
-
import { readFileSync as readFileSync4, writeFileSync as writeFileSync2, existsSync as existsSync2 } from "fs";
|
|
7277
8041
|
import { resolve as resolve3 } from "path";
|
|
7278
|
-
import {
|
|
7279
|
-
function generateFernetKey() {
|
|
7280
|
-
return randomBytes(32).toString("base64url") + "=";
|
|
7281
|
-
}
|
|
7282
|
-
function generateSecret(length = 32) {
|
|
7283
|
-
return randomBytes(length).toString("hex");
|
|
7284
|
-
}
|
|
7285
|
-
function loadEnvFile(path) {
|
|
7286
|
-
if (!existsSync2(path)) return;
|
|
7287
|
-
const content = readFileSync4(path, "utf-8");
|
|
7288
|
-
for (const line of content.split("\n")) {
|
|
7289
|
-
const trimmed = line.trim();
|
|
7290
|
-
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
7291
|
-
const eqIdx = trimmed.indexOf("=");
|
|
7292
|
-
if (eqIdx === -1) continue;
|
|
7293
|
-
const key = trimmed.slice(0, eqIdx).trim();
|
|
7294
|
-
const value = trimmed.slice(eqIdx + 1).trim().replace(/^["']|["']$/g, "");
|
|
7295
|
-
if (!process.env[key]) {
|
|
7296
|
-
process.env[key] = value;
|
|
7297
|
-
}
|
|
7298
|
-
}
|
|
7299
|
-
}
|
|
7300
|
-
function ensureEnvFile(envPath) {
|
|
7301
|
-
if (existsSync2(envPath)) return;
|
|
7302
|
-
console.log("No .env file found. Generating one with dev defaults...\n");
|
|
7303
|
-
const content = ENV_TEMPLATE.replace("{{JWT_SECRET}}", generateSecret()).replace("{{SECRETS_MASTER_KEY}}", generateFernetKey()).replace("{{INTERNAL_WORKER_TOKEN}}", generateSecret());
|
|
7304
|
-
writeFileSync2(envPath, content, "utf-8");
|
|
7305
|
-
console.log(` Created ${envPath}
|
|
7306
|
-
`);
|
|
7307
|
-
}
|
|
8042
|
+
import { ensureEnvFile, loadEnvFile } from "@thecorporation/corp-tools";
|
|
7308
8043
|
async function serveCommand(opts) {
|
|
7309
8044
|
let server;
|
|
7310
8045
|
try {
|
|
@@ -7349,40 +8084,9 @@ async function serveCommand(opts) {
|
|
|
7349
8084
|
process.exit(code ?? 0);
|
|
7350
8085
|
});
|
|
7351
8086
|
}
|
|
7352
|
-
var ENV_TEMPLATE;
|
|
7353
8087
|
var init_serve = __esm({
|
|
7354
8088
|
"src/commands/serve.ts"() {
|
|
7355
8089
|
"use strict";
|
|
7356
|
-
ENV_TEMPLATE = `# Corporation API server configuration
|
|
7357
|
-
# Generated by: corp serve
|
|
7358
|
-
|
|
7359
|
-
# Required \u2014 secret for signing JWTs
|
|
7360
|
-
JWT_SECRET={{JWT_SECRET}}
|
|
7361
|
-
|
|
7362
|
-
# Required \u2014 Fernet key for encrypting secrets at rest (base64url, 32 bytes)
|
|
7363
|
-
SECRETS_MASTER_KEY={{SECRETS_MASTER_KEY}}
|
|
7364
|
-
|
|
7365
|
-
# Required \u2014 bearer token for internal worker-to-server auth
|
|
7366
|
-
INTERNAL_WORKER_TOKEN={{INTERNAL_WORKER_TOKEN}}
|
|
7367
|
-
|
|
7368
|
-
# Server port (default: 8000)
|
|
7369
|
-
# PORT=8000
|
|
7370
|
-
|
|
7371
|
-
# Data directory for git repos (default: ./data/repos)
|
|
7372
|
-
# DATA_DIR=./data/repos
|
|
7373
|
-
|
|
7374
|
-
# Redis URL for agent job queue (optional)
|
|
7375
|
-
# REDIS_URL=redis://localhost:6379/0
|
|
7376
|
-
|
|
7377
|
-
# LLM proxy upstream (default: https://openrouter.ai/api/v1)
|
|
7378
|
-
# LLM_UPSTREAM_URL=https://openrouter.ai/api/v1
|
|
7379
|
-
|
|
7380
|
-
# PEM-encoded Ed25519 key for signing git commits (optional)
|
|
7381
|
-
# COMMIT_SIGNING_KEY=
|
|
7382
|
-
|
|
7383
|
-
# Max agent queue depth (default: 1000)
|
|
7384
|
-
# MAX_QUEUE_DEPTH=1000
|
|
7385
|
-
`;
|
|
7386
8090
|
}
|
|
7387
8091
|
});
|
|
7388
8092
|
|
|
@@ -7398,24 +8102,30 @@ function inheritOption(localValue, parentValue) {
|
|
|
7398
8102
|
// src/index.ts
|
|
7399
8103
|
var require2 = createRequire(import.meta.url);
|
|
7400
8104
|
var pkg = require2("../package.json");
|
|
7401
|
-
var
|
|
8105
|
+
var TAX_DOCUMENT_TYPE_DISPLAY = [
|
|
7402
8106
|
"1120",
|
|
7403
8107
|
"1120s",
|
|
7404
8108
|
"1065",
|
|
7405
8109
|
"franchise_tax",
|
|
7406
8110
|
"annual_report",
|
|
7407
8111
|
"83b",
|
|
7408
|
-
"form_1120",
|
|
7409
|
-
"form_1120s",
|
|
7410
|
-
"form_1065",
|
|
7411
8112
|
"1099_nec",
|
|
7412
|
-
"form_1099_nec",
|
|
7413
8113
|
"k1",
|
|
7414
|
-
"form_k1",
|
|
7415
8114
|
"941",
|
|
7416
|
-
"
|
|
7417
|
-
|
|
7418
|
-
|
|
8115
|
+
"w2"
|
|
8116
|
+
];
|
|
8117
|
+
var TAX_DOCUMENT_TYPE_ALIASES = {
|
|
8118
|
+
form_1120: "1120",
|
|
8119
|
+
form_1120s: "1120s",
|
|
8120
|
+
form_1065: "1065",
|
|
8121
|
+
form_1099_nec: "1099_nec",
|
|
8122
|
+
form_k1: "k1",
|
|
8123
|
+
form_941: "941",
|
|
8124
|
+
form_w2: "w2"
|
|
8125
|
+
};
|
|
8126
|
+
var TAX_DOCUMENT_TYPE_CHOICES = [
|
|
8127
|
+
...TAX_DOCUMENT_TYPE_DISPLAY,
|
|
8128
|
+
...Object.keys(TAX_DOCUMENT_TYPE_ALIASES)
|
|
7419
8129
|
];
|
|
7420
8130
|
var FINALIZE_ITEM_STATUS_CHOICES = [
|
|
7421
8131
|
"discussed",
|
|
@@ -7425,6 +8135,7 @@ var FINALIZE_ITEM_STATUS_CHOICES = [
|
|
|
7425
8135
|
];
|
|
7426
8136
|
var program = new Command();
|
|
7427
8137
|
program.name("corp").description("corp \u2014 Corporate governance from the terminal").version(pkg.version);
|
|
8138
|
+
program.option("-q, --quiet", "Only output the resource ID (for scripting)");
|
|
7428
8139
|
program.command("setup").description("Interactive setup wizard").action(async () => {
|
|
7429
8140
|
const { setupCommand: setupCommand2 } = await Promise.resolve().then(() => (init_setup(), setup_exports));
|
|
7430
8141
|
await setupCommand2();
|
|
@@ -7437,6 +8148,10 @@ program.command("context").alias("whoami").description("Show the active workspac
|
|
|
7437
8148
|
const { contextCommand: contextCommand2 } = await Promise.resolve().then(() => (init_context(), context_exports));
|
|
7438
8149
|
await contextCommand2(opts);
|
|
7439
8150
|
});
|
|
8151
|
+
program.command("use <entity-ref>").description("Set the active entity by name, short ID, or reference").action(async (entityRef) => {
|
|
8152
|
+
const { useCommand: useCommand2 } = await Promise.resolve().then(() => (init_use(), use_exports));
|
|
8153
|
+
await useCommand2(entityRef);
|
|
8154
|
+
});
|
|
7440
8155
|
program.command("schema").description("Dump the CLI command catalog as JSON").option("--compact", "Emit compact JSON").action(async (opts) => {
|
|
7441
8156
|
const { schemaCommand: schemaCommand2 } = await Promise.resolve().then(() => (init_schema(), schema_exports));
|
|
7442
8157
|
schemaCommand2(program, opts);
|
|
@@ -7498,7 +8213,7 @@ entitiesCmd.command("convert <entity-ref>").requiredOption("--to <type>", "Targe
|
|
|
7498
8213
|
const { entitiesConvertCommand: entitiesConvertCommand2 } = await Promise.resolve().then(() => (init_entities(), entities_exports));
|
|
7499
8214
|
await entitiesConvertCommand2(entityId, opts);
|
|
7500
8215
|
});
|
|
7501
|
-
entitiesCmd.command("dissolve <entity-ref>").requiredOption("--reason <reason>", "Dissolution reason").option("--effective-date <date>", "Effective date (ISO 8601)").description("Dissolve an entity").action(async (entityId, opts) => {
|
|
8216
|
+
entitiesCmd.command("dissolve <entity-ref>").requiredOption("--reason <reason>", "Dissolution reason").option("--effective-date <date>", "Effective date (ISO 8601)").option("--yes, -y", "Skip confirmation prompt").description("Dissolve an entity").action(async (entityId, opts) => {
|
|
7502
8217
|
const { entitiesDissolveCommand: entitiesDissolveCommand2 } = await Promise.resolve().then(() => (init_entities(), entities_exports));
|
|
7503
8218
|
await entitiesDissolveCommand2(entityId, opts);
|
|
7504
8219
|
});
|
|
@@ -7537,40 +8252,61 @@ var capTableCmd = program.command("cap-table").description("Cap table, equity gr
|
|
|
7537
8252
|
const { capTableCommand: capTableCommand2 } = await Promise.resolve().then(() => (init_cap_table(), cap_table_exports));
|
|
7538
8253
|
await capTableCommand2(opts);
|
|
7539
8254
|
});
|
|
7540
|
-
capTableCmd.command("safes").description("SAFE notes").action(async (
|
|
8255
|
+
capTableCmd.command("safes").option("--entity-id <ref>", "Entity reference").option("--json", "Output as JSON").description("SAFE notes").action(async (opts, cmd) => {
|
|
7541
8256
|
const parent = cmd.parent.opts();
|
|
7542
8257
|
const { safesCommand: safesCommand2 } = await Promise.resolve().then(() => (init_cap_table(), cap_table_exports));
|
|
7543
|
-
await safesCommand2(
|
|
8258
|
+
await safesCommand2({
|
|
8259
|
+
entityId: opts.entityId ?? parent.entityId,
|
|
8260
|
+
json: inheritOption(opts.json, parent.json)
|
|
8261
|
+
});
|
|
7544
8262
|
});
|
|
7545
|
-
capTableCmd.command("transfers").description("Share transfers").action(async (
|
|
8263
|
+
capTableCmd.command("transfers").option("--entity-id <ref>", "Entity reference").option("--json", "Output as JSON").description("Share transfers").action(async (opts, cmd) => {
|
|
7546
8264
|
const parent = cmd.parent.opts();
|
|
7547
8265
|
const { transfersCommand: transfersCommand2 } = await Promise.resolve().then(() => (init_cap_table(), cap_table_exports));
|
|
7548
|
-
await transfersCommand2(
|
|
8266
|
+
await transfersCommand2({
|
|
8267
|
+
entityId: opts.entityId ?? parent.entityId,
|
|
8268
|
+
json: inheritOption(opts.json, parent.json)
|
|
8269
|
+
});
|
|
7549
8270
|
});
|
|
7550
|
-
capTableCmd.command("instruments").description("Cap table instruments").action(async (
|
|
8271
|
+
capTableCmd.command("instruments").option("--entity-id <ref>", "Entity reference").option("--json", "Output as JSON").description("Cap table instruments").action(async (opts, cmd) => {
|
|
7551
8272
|
const parent = cmd.parent.opts();
|
|
7552
8273
|
const { instrumentsCommand: instrumentsCommand2 } = await Promise.resolve().then(() => (init_cap_table(), cap_table_exports));
|
|
7553
|
-
await instrumentsCommand2(
|
|
8274
|
+
await instrumentsCommand2({
|
|
8275
|
+
entityId: opts.entityId ?? parent.entityId,
|
|
8276
|
+
json: inheritOption(opts.json, parent.json)
|
|
8277
|
+
});
|
|
7554
8278
|
});
|
|
7555
|
-
capTableCmd.command("share-classes").description("Share classes").action(async (
|
|
8279
|
+
capTableCmd.command("share-classes").option("--entity-id <ref>", "Entity reference").option("--json", "Output as JSON").description("Share classes").action(async (opts, cmd) => {
|
|
7556
8280
|
const parent = cmd.parent.opts();
|
|
7557
8281
|
const { shareClassesCommand: shareClassesCommand2 } = await Promise.resolve().then(() => (init_cap_table(), cap_table_exports));
|
|
7558
|
-
await shareClassesCommand2(
|
|
8282
|
+
await shareClassesCommand2({
|
|
8283
|
+
entityId: opts.entityId ?? parent.entityId,
|
|
8284
|
+
json: inheritOption(opts.json, parent.json)
|
|
8285
|
+
});
|
|
7559
8286
|
});
|
|
7560
|
-
capTableCmd.command("rounds").description("Staged equity rounds").action(async (
|
|
8287
|
+
capTableCmd.command("rounds").option("--entity-id <ref>", "Entity reference").option("--json", "Output as JSON").description("Staged equity rounds").action(async (opts, cmd) => {
|
|
7561
8288
|
const parent = cmd.parent.opts();
|
|
7562
8289
|
const { roundsCommand: roundsCommand2 } = await Promise.resolve().then(() => (init_cap_table(), cap_table_exports));
|
|
7563
|
-
await roundsCommand2(
|
|
8290
|
+
await roundsCommand2({
|
|
8291
|
+
entityId: opts.entityId ?? parent.entityId,
|
|
8292
|
+
json: inheritOption(opts.json, parent.json)
|
|
8293
|
+
});
|
|
7564
8294
|
});
|
|
7565
|
-
capTableCmd.command("valuations").description("Valuations history").action(async (
|
|
8295
|
+
capTableCmd.command("valuations").option("--entity-id <ref>", "Entity reference").option("--json", "Output as JSON").description("Valuations history").action(async (opts, cmd) => {
|
|
7566
8296
|
const parent = cmd.parent.opts();
|
|
7567
8297
|
const { valuationsCommand: valuationsCommand2 } = await Promise.resolve().then(() => (init_cap_table(), cap_table_exports));
|
|
7568
|
-
await valuationsCommand2(
|
|
8298
|
+
await valuationsCommand2({
|
|
8299
|
+
entityId: opts.entityId ?? parent.entityId,
|
|
8300
|
+
json: inheritOption(opts.json, parent.json)
|
|
8301
|
+
});
|
|
7569
8302
|
});
|
|
7570
|
-
capTableCmd.command("409a").description("Current 409A valuation").action(async (
|
|
8303
|
+
capTableCmd.command("409a").option("--entity-id <ref>", "Entity reference").option("--json", "Output as JSON").description("Current 409A valuation").action(async (opts, cmd) => {
|
|
7571
8304
|
const parent = cmd.parent.opts();
|
|
7572
8305
|
const { fourOhNineACommand: fourOhNineACommand2 } = await Promise.resolve().then(() => (init_cap_table(), cap_table_exports));
|
|
7573
|
-
await fourOhNineACommand2(
|
|
8306
|
+
await fourOhNineACommand2({
|
|
8307
|
+
entityId: opts.entityId ?? parent.entityId,
|
|
8308
|
+
json: inheritOption(opts.json, parent.json)
|
|
8309
|
+
});
|
|
7574
8310
|
});
|
|
7575
8311
|
capTableCmd.command("create-instrument").requiredOption("--kind <kind>", "Instrument kind (common_equity, preferred_equity, membership_unit, option_grant, safe)").requiredOption("--symbol <symbol>", "Instrument symbol").option("--issuer-legal-entity-id <ref>", "Issuer legal entity reference (ID, short ID, @last, or unique name)").option("--authorized-units <n>", "Authorized units", parseInt).option("--issue-price-cents <n>", "Issue price in cents", parseInt).option("--terms-json <json>", "JSON object of instrument terms").option("--json", "Output as JSON").option("--dry-run", "Show the request without creating the instrument").description("Create a cap table instrument").action(async (opts, cmd) => {
|
|
7576
8312
|
const parent = cmd.parent.opts();
|
|
@@ -7590,11 +8326,13 @@ capTableCmd.command("issue-equity").requiredOption("--grant-type <type>", "Grant
|
|
|
7590
8326
|
json: inheritOption(opts.json, parent.json)
|
|
7591
8327
|
});
|
|
7592
8328
|
});
|
|
7593
|
-
capTableCmd.command("issue-safe").requiredOption("--investor <name>", "Investor name").requiredOption("--amount <n>", "Principal amount in cents", parseInt).option("--safe-type <type>", "SAFE type", "post_money").requiredOption("--valuation-cap <n>", "Valuation cap in cents", parseInt).option("--meeting-id <ref>", "Board meeting reference required when issuing under a board-governed entity").option("--resolution-id <ref>", "Board resolution reference required when issuing under a board-governed entity").option("--json", "Output as JSON").option("--dry-run", "Show the request without creating the round").description("Issue a SAFE note").action(async (opts, cmd) => {
|
|
8329
|
+
capTableCmd.command("issue-safe").requiredOption("--investor <name>", "Investor name").requiredOption("--amount-cents <n>", "Principal amount in cents (e.g. 5000000000 = $50M)", parseInt).option("--amount <n>", "", parseInt).option("--safe-type <type>", "SAFE type", "post_money").requiredOption("--valuation-cap-cents <n>", "Valuation cap in cents (e.g. 1000000000 = $10M)", parseInt).option("--valuation-cap <n>", "", parseInt).option("--meeting-id <ref>", "Board meeting reference required when issuing under a board-governed entity").option("--resolution-id <ref>", "Board resolution reference required when issuing under a board-governed entity").option("--json", "Output as JSON").option("--dry-run", "Show the request without creating the round").description("Issue a SAFE note").action(async (opts, cmd) => {
|
|
7594
8330
|
const parent = cmd.parent.opts();
|
|
7595
8331
|
const { issueSafeCommand: issueSafeCommand2 } = await Promise.resolve().then(() => (init_cap_table(), cap_table_exports));
|
|
7596
8332
|
await issueSafeCommand2({
|
|
7597
8333
|
...opts,
|
|
8334
|
+
amountCents: opts.amountCents ?? opts.amount,
|
|
8335
|
+
valuationCapCents: opts.valuationCapCents ?? opts.valuationCap,
|
|
7598
8336
|
entityId: parent.entityId,
|
|
7599
8337
|
json: inheritOption(opts.json, parent.json)
|
|
7600
8338
|
});
|
|
@@ -7608,11 +8346,12 @@ capTableCmd.command("transfer").requiredOption("--from <ref>", "Source contact r
|
|
|
7608
8346
|
json: inheritOption(opts.json, parent.json)
|
|
7609
8347
|
});
|
|
7610
8348
|
});
|
|
7611
|
-
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").option("--json", "Output as JSON").option("--dry-run", "Show the request without calculating the distribution").description("Calculate a distribution").action(async (opts, cmd) => {
|
|
8349
|
+
capTableCmd.command("distribute").requiredOption("--amount-cents <n>", "Total distribution amount in cents (e.g. 100000 = $1,000.00)", parseInt).option("--amount <n>", "", parseInt).option("--type <type>", "Distribution type (dividend, return, liquidation)", "dividend").requiredOption("--description <desc>", "Distribution description").option("--json", "Output as JSON").option("--dry-run", "Show the request without calculating the distribution").description("Calculate a distribution").action(async (opts, cmd) => {
|
|
7612
8350
|
const parent = cmd.parent.opts();
|
|
7613
8351
|
const { distributeCommand: distributeCommand2 } = await Promise.resolve().then(() => (init_cap_table(), cap_table_exports));
|
|
7614
8352
|
await distributeCommand2({
|
|
7615
8353
|
...opts,
|
|
8354
|
+
amountCents: opts.amountCents ?? opts.amount,
|
|
7616
8355
|
entityId: parent.entityId,
|
|
7617
8356
|
json: inheritOption(opts.json, parent.json)
|
|
7618
8357
|
});
|
|
@@ -7673,6 +8412,50 @@ capTableCmd.command("approve-valuation <valuation-ref>").option("--resolution-id
|
|
|
7673
8412
|
json: inheritOption(opts.json, parent.json)
|
|
7674
8413
|
});
|
|
7675
8414
|
});
|
|
8415
|
+
capTableCmd.command("preview-conversion").requiredOption("--safe-id <ref>", "SAFE note reference to convert").requiredOption("--price-per-share-cents <n>", "Conversion price per share in cents", parseInt).option("--json", "Output as JSON").description("Preview SAFE-to-equity conversion").action(async (opts, cmd) => {
|
|
8416
|
+
const parent = cmd.parent.opts();
|
|
8417
|
+
const { previewConversionCommand: previewConversionCommand2 } = await Promise.resolve().then(() => (init_cap_table(), cap_table_exports));
|
|
8418
|
+
await previewConversionCommand2({
|
|
8419
|
+
...opts,
|
|
8420
|
+
entityId: parent.entityId,
|
|
8421
|
+
json: inheritOption(opts.json, parent.json)
|
|
8422
|
+
});
|
|
8423
|
+
});
|
|
8424
|
+
capTableCmd.command("convert").requiredOption("--safe-id <ref>", "SAFE note reference to convert").requiredOption("--price-per-share-cents <n>", "Conversion price per share in cents", parseInt).option("--json", "Output as JSON").option("--dry-run", "Show the request without executing").description("Execute SAFE-to-equity conversion").action(async (opts, cmd) => {
|
|
8425
|
+
const parent = cmd.parent.opts();
|
|
8426
|
+
const { executeConversionCommand: executeConversionCommand2 } = await Promise.resolve().then(() => (init_cap_table(), cap_table_exports));
|
|
8427
|
+
await executeConversionCommand2({
|
|
8428
|
+
...opts,
|
|
8429
|
+
entityId: parent.entityId,
|
|
8430
|
+
json: inheritOption(opts.json, parent.json)
|
|
8431
|
+
});
|
|
8432
|
+
});
|
|
8433
|
+
capTableCmd.command("dilution").requiredOption("--round-id <ref>", "Round reference to model dilution for").option("--json", "Output as JSON").description("Preview dilution impact of a round").action(async (opts, cmd) => {
|
|
8434
|
+
const parent = cmd.parent.opts();
|
|
8435
|
+
const { dilutionPreviewCommand: dilutionPreviewCommand2 } = await Promise.resolve().then(() => (init_cap_table(), cap_table_exports));
|
|
8436
|
+
await dilutionPreviewCommand2({
|
|
8437
|
+
...opts,
|
|
8438
|
+
entityId: parent.entityId,
|
|
8439
|
+
json: inheritOption(opts.json, parent.json)
|
|
8440
|
+
});
|
|
8441
|
+
});
|
|
8442
|
+
capTableCmd.command("control-map").option("--root-entity-id <ref>", "Root entity for ownership tree (defaults to active entity)").option("--json", "Output as JSON").description("View entity control/ownership map").action(async (opts, cmd) => {
|
|
8443
|
+
const parent = cmd.parent.opts();
|
|
8444
|
+
const { controlMapCommand: controlMapCommand2 } = await Promise.resolve().then(() => (init_cap_table(), cap_table_exports));
|
|
8445
|
+
await controlMapCommand2({
|
|
8446
|
+
...opts,
|
|
8447
|
+
entityId: parent.entityId,
|
|
8448
|
+
json: inheritOption(opts.json, parent.json)
|
|
8449
|
+
});
|
|
8450
|
+
});
|
|
8451
|
+
capTableCmd.addHelpText("after", `
|
|
8452
|
+
Examples:
|
|
8453
|
+
$ corp cap-table # view full cap table
|
|
8454
|
+
$ corp cap-table issue-equity --grant-type common --shares 1000000 --recipient "Alice Smith"
|
|
8455
|
+
$ corp cap-table issue-safe --investor "Seed Fund" --amount-cents 50000000 --valuation-cap-cents 1000000000
|
|
8456
|
+
$ corp cap-table create-valuation --type four_oh_nine_a --date 2026-01-01 --methodology market
|
|
8457
|
+
$ corp cap-table transfer --from alice --to bob --shares 1000 --share-class-id COMMON --governing-doc-type bylaws --transferee-rights full_member
|
|
8458
|
+
`);
|
|
7676
8459
|
var financeCmd = program.command("finance").description("Invoicing, payroll, payments, banking").option("--entity-id <ref>", "Entity reference (ID, short ID, @last, or unique name)").option("--json", "Output as JSON").action(async (opts) => {
|
|
7677
8460
|
const { financeSummaryCommand: financeSummaryCommand2 } = await Promise.resolve().then(() => (init_finance(), finance_exports));
|
|
7678
8461
|
await financeSummaryCommand2(opts);
|
|
@@ -7686,11 +8469,12 @@ financeCmd.command("invoices").option("--json", "Output as JSON").description("L
|
|
|
7686
8469
|
json: inheritOption(opts.json, parent.json)
|
|
7687
8470
|
});
|
|
7688
8471
|
});
|
|
7689
|
-
financeCmd.command("invoice").requiredOption("--customer <name>", "Customer name").requiredOption("--amount <n>", "Amount in cents", parseInt).requiredOption("--due-date <date>", "Due date (ISO 8601)").option("--description <desc>", "Description", "Services rendered").option("--json", "Output as JSON").description("Create an invoice").action(async (opts, cmd) => {
|
|
8472
|
+
financeCmd.command("invoice").requiredOption("--customer <name>", "Customer name").requiredOption("--amount-cents <n>", "Amount in cents (e.g. 500000 = $5,000.00)", parseInt).option("--amount <n>", "", parseInt).requiredOption("--due-date <date>", "Due date (ISO 8601)").option("--description <desc>", "Description", "Services rendered").option("--json", "Output as JSON").description("Create an invoice").action(async (opts, cmd) => {
|
|
7690
8473
|
const parent = cmd.parent.opts();
|
|
7691
8474
|
const { financeInvoiceCommand: financeInvoiceCommand2 } = await Promise.resolve().then(() => (init_finance(), finance_exports));
|
|
7692
8475
|
await financeInvoiceCommand2({
|
|
7693
8476
|
...opts,
|
|
8477
|
+
amountCents: opts.amountCents ?? opts.amount,
|
|
7694
8478
|
entityId: parent.entityId,
|
|
7695
8479
|
json: inheritOption(opts.json, parent.json)
|
|
7696
8480
|
});
|
|
@@ -7722,11 +8506,12 @@ financeCmd.command("payments").option("--json", "Output as JSON").description("L
|
|
|
7722
8506
|
json: inheritOption(opts.json, parent.json)
|
|
7723
8507
|
});
|
|
7724
8508
|
});
|
|
7725
|
-
financeCmd.command("pay").requiredOption("--amount <n>", "Amount in cents", parseInt).requiredOption("--recipient <name>", "Recipient name").option("--method <method>", "Payment method", "ach").option("--json", "Output as JSON").description("Submit a payment").action(async (opts, cmd) => {
|
|
8509
|
+
financeCmd.command("pay").requiredOption("--amount-cents <n>", "Amount in cents (e.g. 500000 = $5,000.00)", parseInt).option("--amount <n>", "", parseInt).requiredOption("--recipient <name>", "Recipient name").option("--method <method>", "Payment method", "ach").option("--json", "Output as JSON").description("Submit a payment").action(async (opts, cmd) => {
|
|
7726
8510
|
const parent = cmd.parent.opts();
|
|
7727
8511
|
const { financePayCommand: financePayCommand2 } = await Promise.resolve().then(() => (init_finance(), finance_exports));
|
|
7728
8512
|
await financePayCommand2({
|
|
7729
8513
|
...opts,
|
|
8514
|
+
amountCents: opts.amountCents ?? opts.amount,
|
|
7730
8515
|
entityId: parent.entityId,
|
|
7731
8516
|
json: inheritOption(opts.json, parent.json)
|
|
7732
8517
|
});
|
|
@@ -7749,6 +8534,15 @@ financeCmd.command("open-account").option("--institution <name>", "Banking insti
|
|
|
7749
8534
|
json: inheritOption(opts.json, parent.json)
|
|
7750
8535
|
});
|
|
7751
8536
|
});
|
|
8537
|
+
financeCmd.command("activate-account <account-ref>").option("--json", "Output as JSON").description("Activate a bank account (transitions from pending_review to active)").action(async (accountRef, opts, cmd) => {
|
|
8538
|
+
const parent = cmd.parent.opts();
|
|
8539
|
+
const { financeActivateAccountCommand: financeActivateAccountCommand2 } = await Promise.resolve().then(() => (init_finance(), finance_exports));
|
|
8540
|
+
await financeActivateAccountCommand2(accountRef, {
|
|
8541
|
+
...opts,
|
|
8542
|
+
entityId: parent.entityId,
|
|
8543
|
+
json: inheritOption(opts.json, parent.json)
|
|
8544
|
+
});
|
|
8545
|
+
});
|
|
7752
8546
|
financeCmd.command("classifications").option("--json", "Output as JSON").description("List contractor classifications").action(async (opts, cmd) => {
|
|
7753
8547
|
const parent = cmd.parent.opts();
|
|
7754
8548
|
const { financeClassificationsCommand: financeClassificationsCommand2 } = await Promise.resolve().then(() => (init_finance(), finance_exports));
|
|
@@ -7794,6 +8588,24 @@ financeCmd.command("distributions").option("--json", "Output as JSON").descripti
|
|
|
7794
8588
|
json: inheritOption(opts.json, parent.json)
|
|
7795
8589
|
});
|
|
7796
8590
|
});
|
|
8591
|
+
financeCmd.command("statements").option("--period <period>", "Period (e.g. 2026-Q1, 2025)").option("--json", "Output as JSON").description("View financial statements (P&L, balance sheet)").action(async (opts, cmd) => {
|
|
8592
|
+
const parent = cmd.parent.opts();
|
|
8593
|
+
const { financeStatementsCommand: financeStatementsCommand2 } = await Promise.resolve().then(() => (init_finance(), finance_exports));
|
|
8594
|
+
await financeStatementsCommand2({
|
|
8595
|
+
...opts,
|
|
8596
|
+
entityId: parent.entityId,
|
|
8597
|
+
json: inheritOption(opts.json, parent.json)
|
|
8598
|
+
});
|
|
8599
|
+
});
|
|
8600
|
+
financeCmd.addHelpText("after", `
|
|
8601
|
+
Examples:
|
|
8602
|
+
$ corp finance # financial summary
|
|
8603
|
+
$ corp finance invoice --customer "Client Co" --amount-cents 500000 --due-date 2026-04-01
|
|
8604
|
+
$ corp finance pay --amount-cents 250000 --recipient "Vendor" --method ach
|
|
8605
|
+
$ corp finance payroll --period-start 2026-03-01 --period-end 2026-03-15
|
|
8606
|
+
$ corp finance open-account --institution Mercury
|
|
8607
|
+
$ corp finance statements --period 2026-Q1
|
|
8608
|
+
`);
|
|
7797
8609
|
var governanceCmd = program.command("governance").description("Governance bodies, seats, meetings, resolutions").option("--entity-id <ref>", "Entity reference (overrides active entity)").option("--json", "Output as JSON").action(async (opts) => {
|
|
7798
8610
|
const { governanceListCommand: governanceListCommand2 } = await Promise.resolve().then(() => (init_governance(), governance_exports));
|
|
7799
8611
|
await governanceListCommand2(opts);
|
|
@@ -7886,7 +8698,7 @@ governanceCmd.command("reopen <meeting-ref>").option("--json", "Output as JSON")
|
|
|
7886
8698
|
json: inheritOption(opts.json, parent.json)
|
|
7887
8699
|
});
|
|
7888
8700
|
});
|
|
7889
|
-
governanceCmd.command("cancel <meeting-ref>").option("--json", "Output as JSON").option("--dry-run", "Show the request without cancelling the meeting").description("Cancel a meeting").action(async (meetingId, opts, cmd) => {
|
|
8701
|
+
governanceCmd.command("cancel <meeting-ref>").option("--json", "Output as JSON").option("--dry-run", "Show the request without cancelling the meeting").option("--yes, -y", "Skip confirmation prompt").description("Cancel a meeting").action(async (meetingId, opts, cmd) => {
|
|
7890
8702
|
const parent = cmd.parent.opts();
|
|
7891
8703
|
const { cancelMeetingCommand: cancelMeetingCommand2 } = await Promise.resolve().then(() => (init_governance(), governance_exports));
|
|
7892
8704
|
await cancelMeetingCommand2(meetingId, {
|
|
@@ -7932,6 +8744,56 @@ governanceCmd.command("written-consent").requiredOption("--body <ref>", "Governa
|
|
|
7932
8744
|
json: inheritOption(opts.json, parent.json)
|
|
7933
8745
|
});
|
|
7934
8746
|
});
|
|
8747
|
+
governanceCmd.command("mode").addOption(new Option("--set <mode>", "Set governance mode").choices(["founder", "board", "executive", "normal", "incident_lockdown"])).option("--json", "Output as JSON").description("View or set governance mode").action(async (opts, cmd) => {
|
|
8748
|
+
const parent = cmd.parent.opts();
|
|
8749
|
+
const { governanceModeCommand: governanceModeCommand2 } = await Promise.resolve().then(() => (init_governance(), governance_exports));
|
|
8750
|
+
await governanceModeCommand2({
|
|
8751
|
+
...opts,
|
|
8752
|
+
entityId: parent.entityId,
|
|
8753
|
+
json: inheritOption(opts.json, parent.json)
|
|
8754
|
+
});
|
|
8755
|
+
});
|
|
8756
|
+
governanceCmd.command("resign <seat-ref>").option("--body-id <ref>", "Governance body reference").option("--json", "Output as JSON").description("Resign from a governance seat").action(async (seatRef, opts, cmd) => {
|
|
8757
|
+
const parent = cmd.parent.opts();
|
|
8758
|
+
const { governanceResignCommand: governanceResignCommand2 } = await Promise.resolve().then(() => (init_governance(), governance_exports));
|
|
8759
|
+
await governanceResignCommand2(seatRef, {
|
|
8760
|
+
...opts,
|
|
8761
|
+
entityId: parent.entityId,
|
|
8762
|
+
json: inheritOption(opts.json, parent.json)
|
|
8763
|
+
});
|
|
8764
|
+
});
|
|
8765
|
+
governanceCmd.command("incidents").option("--json", "Output as JSON").description("List governance incidents").action(async (opts, cmd) => {
|
|
8766
|
+
const parent = cmd.parent.opts();
|
|
8767
|
+
const { governanceIncidentsCommand: governanceIncidentsCommand2 } = await Promise.resolve().then(() => (init_governance(), governance_exports));
|
|
8768
|
+
await governanceIncidentsCommand2({
|
|
8769
|
+
...opts,
|
|
8770
|
+
entityId: parent.entityId,
|
|
8771
|
+
json: inheritOption(opts.json, parent.json)
|
|
8772
|
+
});
|
|
8773
|
+
});
|
|
8774
|
+
governanceCmd.command("profile").option("--json", "Output as JSON").description("View governance profile and configuration").action(async (opts, cmd) => {
|
|
8775
|
+
const parent = cmd.parent.opts();
|
|
8776
|
+
const { governanceProfileCommand: governanceProfileCommand2 } = await Promise.resolve().then(() => (init_governance(), governance_exports));
|
|
8777
|
+
await governanceProfileCommand2({
|
|
8778
|
+
...opts,
|
|
8779
|
+
entityId: parent.entityId,
|
|
8780
|
+
json: inheritOption(opts.json, parent.json)
|
|
8781
|
+
});
|
|
8782
|
+
});
|
|
8783
|
+
governanceCmd.addHelpText("after", `
|
|
8784
|
+
Examples:
|
|
8785
|
+
$ corp governance create-body --name "Board of Directors" --body-type board_of_directors
|
|
8786
|
+
$ corp governance add-seat @last:body --holder "alice"
|
|
8787
|
+
$ corp governance convene --body board --type board_meeting --title "Q1 Review" --agenda "Approve budget"
|
|
8788
|
+
$ corp governance open @last:meeting --present-seat alice-seat
|
|
8789
|
+
$ corp governance vote @last:meeting <item-ref> --voter alice --vote for
|
|
8790
|
+
$ corp governance written-consent --body board --title "Approve Option Plan" --description "Board approves 2026 option plan"
|
|
8791
|
+
$ corp governance mode
|
|
8792
|
+
$ corp governance mode --set board
|
|
8793
|
+
$ corp governance resign <seat-ref>
|
|
8794
|
+
$ corp governance incidents
|
|
8795
|
+
$ corp governance profile
|
|
8796
|
+
`);
|
|
7935
8797
|
var documentsCmd = program.command("documents").description("Documents and signing").option("--entity-id <ref>", "Entity reference (ID, short ID, @last, or unique name)").option("--json", "Output as JSON").action(async (opts) => {
|
|
7936
8798
|
const { documentsListCommand: documentsListCommand2 } = await Promise.resolve().then(() => (init_documents(), documents_exports));
|
|
7937
8799
|
await documentsListCommand2(opts);
|
|
@@ -7977,7 +8839,10 @@ documentsCmd.command("preview-pdf").option("--definition-id <id>", "AST document
|
|
|
7977
8839
|
entityId: parent.entityId
|
|
7978
8840
|
});
|
|
7979
8841
|
});
|
|
7980
|
-
var taxCmd = program.command("tax").description("Tax filings and deadline tracking").option("--entity-id <ref>", "Entity reference (ID, short ID, @last, or unique name)").option("--json", "Output as JSON")
|
|
8842
|
+
var taxCmd = program.command("tax").description("Tax filings and deadline tracking").option("--entity-id <ref>", "Entity reference (ID, short ID, @last, or unique name)").option("--json", "Output as JSON").action(async (opts) => {
|
|
8843
|
+
const { taxSummaryCommand: taxSummaryCommand2 } = await Promise.resolve().then(() => (init_tax(), tax_exports));
|
|
8844
|
+
await taxSummaryCommand2(opts);
|
|
8845
|
+
});
|
|
7981
8846
|
taxCmd.command("filings").option("--json", "Output as JSON").description("List tax filings").action(async (opts, cmd) => {
|
|
7982
8847
|
const parent = cmd.parent.opts();
|
|
7983
8848
|
const { taxFilingsCommand: taxFilingsCommand2 } = await Promise.resolve().then(() => (init_tax(), tax_exports));
|
|
@@ -7987,7 +8852,9 @@ taxCmd.command("filings").option("--json", "Output as JSON").description("List t
|
|
|
7987
8852
|
json: inheritOption(opts.json, parent.json)
|
|
7988
8853
|
});
|
|
7989
8854
|
});
|
|
7990
|
-
taxCmd.command("file").addOption(
|
|
8855
|
+
taxCmd.command("file").addOption(
|
|
8856
|
+
new Option("--type <type>", `Document type (${TAX_DOCUMENT_TYPE_DISPLAY.join(", ")})`).choices([...TAX_DOCUMENT_TYPE_CHOICES]).makeOptionMandatory()
|
|
8857
|
+
).requiredOption("--year <year>", "Tax year", parseInt).option("--json", "Output as JSON").description("File a tax document").action(async (opts, cmd) => {
|
|
7991
8858
|
const parent = cmd.parent.opts();
|
|
7992
8859
|
const { taxFileCommand: taxFileCommand2 } = await Promise.resolve().then(() => (init_tax(), tax_exports));
|
|
7993
8860
|
await taxFileCommand2({
|
|
@@ -8048,11 +8915,12 @@ agentsCmd.command("resume <agent-ref>").option("--json", "Output as JSON").descr
|
|
|
8048
8915
|
json: inheritOption(opts.json, parent.json)
|
|
8049
8916
|
});
|
|
8050
8917
|
});
|
|
8051
|
-
agentsCmd.command("delete <agent-ref>").option("--json", "Output as JSON").description("Delete an agent").action(async (agentId, opts, cmd) => {
|
|
8918
|
+
agentsCmd.command("delete <agent-ref>").option("--json", "Output as JSON").option("--yes, -y", "Skip confirmation prompt").description("Delete an agent").action(async (agentId, opts, cmd) => {
|
|
8052
8919
|
const parent = cmd.parent.opts();
|
|
8053
8920
|
const { agentsDeleteCommand: agentsDeleteCommand2 } = await Promise.resolve().then(() => (init_agents(), agents_exports));
|
|
8054
8921
|
await agentsDeleteCommand2(agentId, {
|
|
8055
|
-
json: inheritOption(opts.json, parent.json)
|
|
8922
|
+
json: inheritOption(opts.json, parent.json),
|
|
8923
|
+
yes: opts.yes
|
|
8056
8924
|
});
|
|
8057
8925
|
});
|
|
8058
8926
|
agentsCmd.command("message <agent-ref>").option("--body <text>", "Message text").option("--body-file <path>", "Read the message body from a file").option("--json", "Output as JSON").description("Send a message to an agent").action(async (agentId, opts, cmd) => {
|
|
@@ -8071,6 +8939,37 @@ agentsCmd.command("skill <agent-ref>").requiredOption("--name <name>", "Skill na
|
|
|
8071
8939
|
json: inheritOption(opts.json, parent.json)
|
|
8072
8940
|
});
|
|
8073
8941
|
});
|
|
8942
|
+
agentsCmd.command("execution <agent-ref> <execution-id>").option("--json", "Output as JSON").description("Check execution status").action(async (agentId, executionId, opts, cmd) => {
|
|
8943
|
+
const parent = cmd.parent.opts();
|
|
8944
|
+
const { agentsExecutionCommand: agentsExecutionCommand2 } = await Promise.resolve().then(() => (init_agents(), agents_exports));
|
|
8945
|
+
await agentsExecutionCommand2(agentId, executionId, {
|
|
8946
|
+
json: opts.json ?? parent.json
|
|
8947
|
+
});
|
|
8948
|
+
});
|
|
8949
|
+
agentsCmd.command("execution-result <agent-ref> <execution-id>").option("--json", "Output as JSON").description("Get execution result").action(async (agentId, executionId, opts, cmd) => {
|
|
8950
|
+
const parent = cmd.parent.opts();
|
|
8951
|
+
const { agentsExecutionResultCommand: agentsExecutionResultCommand2 } = await Promise.resolve().then(() => (init_agents(), agents_exports));
|
|
8952
|
+
await agentsExecutionResultCommand2(agentId, executionId, {
|
|
8953
|
+
json: opts.json ?? parent.json
|
|
8954
|
+
});
|
|
8955
|
+
});
|
|
8956
|
+
agentsCmd.command("kill <agent-ref> <execution-id>").option("--yes", "Skip confirmation").option("--json", "Output as JSON").description("Kill a running execution").action(async (agentId, executionId, opts, cmd) => {
|
|
8957
|
+
const parent = cmd.parent.opts();
|
|
8958
|
+
const { agentsKillCommand: agentsKillCommand2 } = await Promise.resolve().then(() => (init_agents(), agents_exports));
|
|
8959
|
+
await agentsKillCommand2(agentId, executionId, {
|
|
8960
|
+
...opts,
|
|
8961
|
+
json: opts.json ?? parent.json
|
|
8962
|
+
});
|
|
8963
|
+
});
|
|
8964
|
+
agentsCmd.addHelpText("after", `
|
|
8965
|
+
Examples:
|
|
8966
|
+
$ corp agents # list all agents
|
|
8967
|
+
$ corp agents create --name "bookkeeper" --prompt "You manage accounts payable"
|
|
8968
|
+
$ corp agents message @last:agent --body "Process this month's invoices"
|
|
8969
|
+
$ corp agents skill @last:agent --name invoice-processing --description "Process AP invoices"
|
|
8970
|
+
$ corp agents execution @last:agent <execution-id> # check execution status
|
|
8971
|
+
$ corp agents kill @last:agent <execution-id> # kill a running execution
|
|
8972
|
+
`);
|
|
8074
8973
|
var workItemsCmd = program.command("work-items").description("Long-term work item coordination").option("--entity-id <ref>", "Entity reference (ID, short ID, @last, or unique name)").option("--json", "Output as JSON").option("--status <status>", "Filter by status (open, claimed, completed, cancelled)").option("--category <category>", "Filter by category").action(async (opts) => {
|
|
8075
8974
|
const { workItemsListCommand: workItemsListCommand2 } = await Promise.resolve().then(() => (init_work_items(), work_items_exports));
|
|
8076
8975
|
await workItemsListCommand2(opts);
|
|
@@ -8084,7 +8983,7 @@ workItemsCmd.command("show <item-ref>").option("--json", "Output as JSON").descr
|
|
|
8084
8983
|
json: inheritOption(opts.json, parent.json)
|
|
8085
8984
|
});
|
|
8086
8985
|
});
|
|
8087
|
-
workItemsCmd.command("create").requiredOption("--title <title>", "Work item title").
|
|
8986
|
+
workItemsCmd.command("create").requiredOption("--title <title>", "Work item title").requiredOption("--category <category>", "Work item category").option("--description <desc>", "Description").option("--deadline <date>", "Deadline (YYYY-MM-DD)").option("--asap", "Mark as ASAP priority").option("--created-by <name>", "Creator identifier").option("--json", "Output as JSON").description("Create a new work item").action(async (opts, cmd) => {
|
|
8088
8987
|
const parent = cmd.parent.opts();
|
|
8089
8988
|
const { workItemsCreateCommand: workItemsCreateCommand2 } = await Promise.resolve().then(() => (init_work_items(), work_items_exports));
|
|
8090
8989
|
await workItemsCreateCommand2({
|
|
@@ -8094,7 +8993,7 @@ workItemsCmd.command("create").requiredOption("--title <title>", "Work item titl
|
|
|
8094
8993
|
json: inheritOption(opts.json, parent.json)
|
|
8095
8994
|
});
|
|
8096
8995
|
});
|
|
8097
|
-
workItemsCmd.command("claim <item-ref>").option("--by <name>", "Agent or user claiming the item").option("--claimer <name>", "Alias for --by").option("--ttl <seconds>", "Auto-release TTL in seconds", parseInt).option("--json", "Output as JSON").description("Claim a work item").action(async (itemId, opts, cmd) => {
|
|
8996
|
+
workItemsCmd.command("claim <item-ref>").option("--by <name>", "Agent or user claiming the item (required)").option("--claimer <name>", "Alias for --by").option("--ttl <seconds>", "Auto-release TTL in seconds", parseInt).option("--json", "Output as JSON").description("Claim a work item").action(async (itemId, opts, cmd) => {
|
|
8098
8997
|
const parent = cmd.parent.opts();
|
|
8099
8998
|
const { workItemsClaimCommand: workItemsClaimCommand2 } = await Promise.resolve().then(() => (init_work_items(), work_items_exports));
|
|
8100
8999
|
const claimedBy = opts.by ?? opts.claimer;
|
|
@@ -8109,7 +9008,7 @@ workItemsCmd.command("claim <item-ref>").option("--by <name>", "Agent or user cl
|
|
|
8109
9008
|
json: inheritOption(opts.json, parent.json)
|
|
8110
9009
|
});
|
|
8111
9010
|
});
|
|
8112
|
-
workItemsCmd.command("complete <item-ref>").option("--by <name>", "Agent or user completing the item").option("--completed-by <name>", "Alias for --by").option("--result <text>", "Completion result or notes").option("--notes <text>", "Alias for --result").option("--json", "Output as JSON").description("Mark a work item as completed").action(async (itemId, opts, cmd) => {
|
|
9011
|
+
workItemsCmd.command("complete <item-ref>").option("--by <name>", "Agent or user completing the item (required)").option("--completed-by <name>", "Alias for --by").option("--result <text>", "Completion result or notes").option("--notes <text>", "Alias for --result").option("--json", "Output as JSON").description("Mark a work item as completed").action(async (itemId, opts, cmd) => {
|
|
8113
9012
|
const parent = cmd.parent.opts();
|
|
8114
9013
|
const { workItemsCompleteCommand: workItemsCompleteCommand2 } = await Promise.resolve().then(() => (init_work_items(), work_items_exports));
|
|
8115
9014
|
const completedBy = opts.by ?? opts.completedBy;
|
|
@@ -8132,10 +9031,74 @@ workItemsCmd.command("release <item-ref>").option("--json", "Output as JSON").de
|
|
|
8132
9031
|
json: inheritOption(opts.json, parent.json)
|
|
8133
9032
|
});
|
|
8134
9033
|
});
|
|
8135
|
-
workItemsCmd.command("cancel <item-ref>").option("--json", "Output as JSON").description("Cancel a work item").action(async (itemId, opts, cmd) => {
|
|
9034
|
+
workItemsCmd.command("cancel <item-ref>").option("--json", "Output as JSON").option("--yes, -y", "Skip confirmation prompt").description("Cancel a work item").action(async (itemId, opts, cmd) => {
|
|
8136
9035
|
const parent = cmd.parent.opts();
|
|
8137
9036
|
const { workItemsCancelCommand: workItemsCancelCommand2 } = await Promise.resolve().then(() => (init_work_items(), work_items_exports));
|
|
8138
9037
|
await workItemsCancelCommand2(itemId, {
|
|
9038
|
+
entityId: parent.entityId,
|
|
9039
|
+
json: inheritOption(opts.json, parent.json),
|
|
9040
|
+
yes: opts.yes
|
|
9041
|
+
});
|
|
9042
|
+
});
|
|
9043
|
+
workItemsCmd.addHelpText("after", `
|
|
9044
|
+
Examples:
|
|
9045
|
+
$ corp work-items # list open work items
|
|
9046
|
+
$ corp work-items create --title "File Q1 taxes" --category compliance --deadline 2026-04-15
|
|
9047
|
+
$ corp work-items claim @last:work_item --by bookkeeper-agent
|
|
9048
|
+
$ corp work-items complete @last:work_item --by bookkeeper-agent --result "Filed 1120 for Q1"
|
|
9049
|
+
`);
|
|
9050
|
+
var servicesCmd = program.command("services").description("Service catalog and fulfillment").option("--entity-id <ref>", "Entity reference (ID, short ID, @last, or unique name)").option("--json", "Output as JSON").action(async (opts) => {
|
|
9051
|
+
const { servicesCatalogCommand: servicesCatalogCommand2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
9052
|
+
await servicesCatalogCommand2({ json: opts.json });
|
|
9053
|
+
});
|
|
9054
|
+
servicesCmd.command("catalog").option("--json", "Output as JSON").description("List the service catalog").action(async (opts, cmd) => {
|
|
9055
|
+
const parent = cmd.parent.opts();
|
|
9056
|
+
const { servicesCatalogCommand: servicesCatalogCommand2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
9057
|
+
await servicesCatalogCommand2({
|
|
9058
|
+
json: inheritOption(opts.json, parent.json)
|
|
9059
|
+
});
|
|
9060
|
+
});
|
|
9061
|
+
servicesCmd.command("buy <slug>").option("--json", "Output as JSON").option("--dry-run", "Show the request without executing").description("Purchase a service from the catalog").action(async (slug, opts, cmd) => {
|
|
9062
|
+
const parent = cmd.parent.opts();
|
|
9063
|
+
const { servicesBuyCommand: servicesBuyCommand2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
9064
|
+
await servicesBuyCommand2(slug, {
|
|
9065
|
+
...opts,
|
|
9066
|
+
entityId: parent.entityId,
|
|
9067
|
+
json: inheritOption(opts.json, parent.json)
|
|
9068
|
+
});
|
|
9069
|
+
});
|
|
9070
|
+
servicesCmd.command("list").option("--json", "Output as JSON").description("List service requests for an entity").action(async (opts, cmd) => {
|
|
9071
|
+
const parent = cmd.parent.opts();
|
|
9072
|
+
const { servicesListCommand: servicesListCommand2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
9073
|
+
await servicesListCommand2({
|
|
9074
|
+
...opts,
|
|
9075
|
+
entityId: parent.entityId,
|
|
9076
|
+
json: inheritOption(opts.json, parent.json)
|
|
9077
|
+
});
|
|
9078
|
+
});
|
|
9079
|
+
servicesCmd.command("show <ref>").option("--json", "Output as JSON").description("Show service request detail").action(async (ref_, opts, cmd) => {
|
|
9080
|
+
const parent = cmd.parent.opts();
|
|
9081
|
+
const { servicesShowCommand: servicesShowCommand2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
9082
|
+
await servicesShowCommand2(ref_, {
|
|
9083
|
+
...opts,
|
|
9084
|
+
entityId: parent.entityId,
|
|
9085
|
+
json: inheritOption(opts.json, parent.json)
|
|
9086
|
+
});
|
|
9087
|
+
});
|
|
9088
|
+
servicesCmd.command("fulfill <ref>").option("--note <note>", "Fulfillment note").option("--json", "Output as JSON").description("Mark a service request as fulfilled (operator)").action(async (ref_, opts, cmd) => {
|
|
9089
|
+
const parent = cmd.parent.opts();
|
|
9090
|
+
const { servicesFulfillCommand: servicesFulfillCommand2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
9091
|
+
await servicesFulfillCommand2(ref_, {
|
|
9092
|
+
...opts,
|
|
9093
|
+
entityId: parent.entityId,
|
|
9094
|
+
json: inheritOption(opts.json, parent.json)
|
|
9095
|
+
});
|
|
9096
|
+
});
|
|
9097
|
+
servicesCmd.command("cancel <ref>").option("--json", "Output as JSON").description("Cancel a service request").action(async (ref_, opts, cmd) => {
|
|
9098
|
+
const parent = cmd.parent.opts();
|
|
9099
|
+
const { servicesCancelCommand: servicesCancelCommand2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
9100
|
+
await servicesCancelCommand2(ref_, {
|
|
9101
|
+
...opts,
|
|
8139
9102
|
entityId: parent.entityId,
|
|
8140
9103
|
json: inheritOption(opts.json, parent.json)
|
|
8141
9104
|
});
|
|
@@ -8156,9 +9119,7 @@ program.command("approvals").description("Approvals are managed through governan
|
|
|
8156
9119
|
const { approvalsListCommand: approvalsListCommand2 } = await Promise.resolve().then(() => (init_approvals(), approvals_exports));
|
|
8157
9120
|
await approvalsListCommand2({});
|
|
8158
9121
|
});
|
|
8159
|
-
var formCmd = program.command("form").description("Form a new entity with founders and cap table").option("--
|
|
8160
|
-
if (opts.entityType && !opts.type) opts.type = opts.entityType;
|
|
8161
|
-
if (opts.legalName && !opts.name) opts.name = opts.legalName;
|
|
9122
|
+
var formCmd = program.command("form").description("Form a new entity with founders and cap table").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>", "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, a) => [...a, v], []).option("--member-json <json>", "Founder JSON object (repeatable)", (v, a) => [...a, v], []).option("--members-file <path>", 'Path to a JSON array of founders or {"members": [...]}').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").option("--json", "Output as JSON").option("--dry-run", "Show the request without creating the entity").action(async (opts) => {
|
|
8162
9123
|
const { formCommand: formCommand2 } = await Promise.resolve().then(() => (init_form(), form_exports));
|
|
8163
9124
|
await formCommand2(opts);
|
|
8164
9125
|
});
|
|
@@ -8168,6 +9129,10 @@ formCmd.command("create").description("Create a pending entity (staged flow step
|
|
|
8168
9129
|
await formCreateCommand2({
|
|
8169
9130
|
...opts,
|
|
8170
9131
|
jurisdiction: inheritOption(opts.jurisdiction, parent.jurisdiction),
|
|
9132
|
+
fiscalYearEnd: inheritOption(opts.fiscalYearEnd, parent.fiscalYearEnd),
|
|
9133
|
+
sCorp: inheritOption(opts.sCorp, parent.sCorp),
|
|
9134
|
+
transferRestrictions: inheritOption(opts.transferRestrictions, parent.transferRestrictions),
|
|
9135
|
+
rofr: inheritOption(opts.rofr, parent.rofr),
|
|
8171
9136
|
json: inheritOption(opts.json, parent.json),
|
|
8172
9137
|
dryRun: inheritOption(opts.dryRun, parent.dryRun)
|
|
8173
9138
|
});
|
|
@@ -8196,9 +9161,30 @@ formCmd.command("activate <entity-ref>").description("Programmatically sign form
|
|
|
8196
9161
|
dryRun: inheritOption(opts.dryRun, cmd.parent.opts().dryRun)
|
|
8197
9162
|
});
|
|
8198
9163
|
});
|
|
8199
|
-
|
|
8200
|
-
|
|
8201
|
-
|
|
9164
|
+
formCmd.addHelpText("after", `
|
|
9165
|
+
Examples:
|
|
9166
|
+
$ corp form --type llc --name "My LLC" --member "Alice,alice@co.com,member,100"
|
|
9167
|
+
$ corp form --type c_corp --name "Acme Inc" --jurisdiction US-DE --member-json '{"name":"Bob","email":"bob@acme.com","role":"director","pct":100}'
|
|
9168
|
+
$ corp form create --type llc --name "My LLC"
|
|
9169
|
+
$ corp form add-founder @last:entity --name "Alice" --email "alice@co.com" --role member --pct 100
|
|
9170
|
+
$ corp form finalize @last:entity
|
|
9171
|
+
$ corp form activate @last:entity
|
|
9172
|
+
`);
|
|
9173
|
+
var apiKeysCmd = program.command("api-keys").description("API key management").option("--json", "Output as JSON").action(async (opts) => {
|
|
9174
|
+
const { apiKeysListCommand: apiKeysListCommand2 } = await Promise.resolve().then(() => (init_api_keys(), api_keys_exports));
|
|
9175
|
+
await apiKeysListCommand2(opts);
|
|
9176
|
+
});
|
|
9177
|
+
apiKeysCmd.command("create").requiredOption("--name <name>", "Key name/label").option("--scopes <scopes>", "Comma-separated scopes").option("--json", "Output as JSON").description("Create a new API key").action(async (opts) => {
|
|
9178
|
+
const { apiKeysCreateCommand: apiKeysCreateCommand2 } = await Promise.resolve().then(() => (init_api_keys(), api_keys_exports));
|
|
9179
|
+
await apiKeysCreateCommand2(opts);
|
|
9180
|
+
});
|
|
9181
|
+
apiKeysCmd.command("revoke <key-id>").option("--yes", "Skip confirmation").option("--json", "Output as JSON").description("Revoke an API key").action(async (keyId, opts) => {
|
|
9182
|
+
const { apiKeysRevokeCommand: apiKeysRevokeCommand2 } = await Promise.resolve().then(() => (init_api_keys(), api_keys_exports));
|
|
9183
|
+
await apiKeysRevokeCommand2(keyId, opts);
|
|
9184
|
+
});
|
|
9185
|
+
apiKeysCmd.command("rotate <key-id>").option("--json", "Output as JSON").description("Rotate an API key (returns new key)").action(async (keyId, opts) => {
|
|
9186
|
+
const { apiKeysRotateCommand: apiKeysRotateCommand2 } = await Promise.resolve().then(() => (init_api_keys(), api_keys_exports));
|
|
9187
|
+
await apiKeysRotateCommand2(keyId, opts);
|
|
8202
9188
|
});
|
|
8203
9189
|
program.command("demo").description("Create a usable demo workspace environment").requiredOption("--name <name>", "Corporation name").option("--scenario <scenario>", "Scenario to create (startup, llc, restaurant)", "startup").option("--minimal", "Use the minimal server-side demo seed instead of the full CLI workflow").option("--json", "Output as JSON").action(async (opts) => {
|
|
8204
9190
|
const { demoCommand: demoCommand2 } = await Promise.resolve().then(() => (init_demo(), demo_exports));
|