@thecorporation/cli 26.3.14 → 26.3.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1757 -444
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -10,40 +10,239 @@ var __export = (target, all) => {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
// src/config.ts
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
setValue: () => setValue
|
|
23
|
-
});
|
|
24
|
-
import { readFileSync, writeFileSync, mkdirSync, existsSync } from "fs";
|
|
25
|
-
import { join } from "path";
|
|
13
|
+
import {
|
|
14
|
+
chmodSync,
|
|
15
|
+
existsSync,
|
|
16
|
+
mkdirSync,
|
|
17
|
+
readFileSync,
|
|
18
|
+
renameSync,
|
|
19
|
+
rmSync,
|
|
20
|
+
writeFileSync
|
|
21
|
+
} from "fs";
|
|
26
22
|
import { homedir } from "os";
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
import { join } from "path";
|
|
24
|
+
function sleepSync(ms) {
|
|
25
|
+
Atomics.wait(CONFIG_WAIT_SIGNAL, 0, 0, ms);
|
|
26
|
+
}
|
|
27
|
+
function withConfigLock(fn) {
|
|
28
|
+
mkdirSync(CONFIG_DIR, { recursive: true, mode: 448 });
|
|
29
|
+
const startedAt = Date.now();
|
|
30
|
+
while (true) {
|
|
31
|
+
try {
|
|
32
|
+
mkdirSync(CONFIG_LOCK_DIR, { mode: 448 });
|
|
33
|
+
break;
|
|
34
|
+
} catch (err) {
|
|
35
|
+
if (err.code !== "EEXIST") {
|
|
36
|
+
throw err;
|
|
37
|
+
}
|
|
38
|
+
if (Date.now() - startedAt >= CONFIG_LOCK_TIMEOUT_MS) {
|
|
39
|
+
throw new Error("timed out waiting for the corp config lock");
|
|
40
|
+
}
|
|
41
|
+
sleepSync(CONFIG_LOCK_RETRY_MS);
|
|
33
42
|
}
|
|
34
43
|
}
|
|
44
|
+
try {
|
|
45
|
+
return fn();
|
|
46
|
+
} finally {
|
|
47
|
+
rmSync(CONFIG_LOCK_DIR, { recursive: true, force: true });
|
|
48
|
+
}
|
|
35
49
|
}
|
|
36
|
-
function
|
|
37
|
-
|
|
50
|
+
function ensureSecurePermissions() {
|
|
51
|
+
mkdirSync(CONFIG_DIR, { recursive: true, mode: 448 });
|
|
52
|
+
try {
|
|
53
|
+
chmodSync(CONFIG_DIR, 448);
|
|
54
|
+
} catch {
|
|
55
|
+
}
|
|
38
56
|
if (existsSync(CONFIG_FILE)) {
|
|
39
|
-
|
|
40
|
-
|
|
57
|
+
try {
|
|
58
|
+
chmodSync(CONFIG_FILE, 384);
|
|
59
|
+
} catch {
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function isObject(value) {
|
|
64
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
65
|
+
}
|
|
66
|
+
function isLoopbackHost(hostname) {
|
|
67
|
+
return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1";
|
|
68
|
+
}
|
|
69
|
+
function validateApiUrl(value) {
|
|
70
|
+
let parsed;
|
|
71
|
+
try {
|
|
72
|
+
parsed = new URL(value.trim());
|
|
73
|
+
} catch {
|
|
74
|
+
throw new Error("api_url must be a valid absolute URL");
|
|
75
|
+
}
|
|
76
|
+
if (parsed.username || parsed.password) {
|
|
77
|
+
throw new Error("api_url must not include embedded credentials");
|
|
78
|
+
}
|
|
79
|
+
const protocol = parsed.protocol.toLowerCase();
|
|
80
|
+
const hostname = parsed.hostname.toLowerCase();
|
|
81
|
+
if (protocol !== "https:" && !(protocol === "http:" && isLoopbackHost(hostname))) {
|
|
82
|
+
throw new Error("api_url must use https, or http only for localhost/loopback development");
|
|
83
|
+
}
|
|
84
|
+
parsed.hash = "";
|
|
85
|
+
return parsed.toString().replace(/\/+$/, "");
|
|
86
|
+
}
|
|
87
|
+
function normalizeString(value) {
|
|
88
|
+
return typeof value === "string" ? value : void 0;
|
|
89
|
+
}
|
|
90
|
+
function normalizeActiveEntityMap(value) {
|
|
91
|
+
if (!isObject(value)) {
|
|
92
|
+
return void 0;
|
|
93
|
+
}
|
|
94
|
+
const entries = Object.entries(value).filter(
|
|
95
|
+
([workspaceId, entityId]) => typeof workspaceId === "string" && typeof entityId === "string" && entityId.length > 0
|
|
96
|
+
);
|
|
97
|
+
if (entries.length === 0) {
|
|
98
|
+
return void 0;
|
|
99
|
+
}
|
|
100
|
+
return Object.fromEntries(entries);
|
|
101
|
+
}
|
|
102
|
+
function normalizeConfig(raw) {
|
|
103
|
+
const cfg = structuredClone(DEFAULTS);
|
|
104
|
+
if (!isObject(raw)) {
|
|
105
|
+
return cfg;
|
|
106
|
+
}
|
|
107
|
+
const savedApiUrl = normalizeString(raw.api_url);
|
|
108
|
+
if (savedApiUrl) {
|
|
109
|
+
try {
|
|
110
|
+
cfg.api_url = validateApiUrl(savedApiUrl);
|
|
111
|
+
} catch {
|
|
112
|
+
cfg.api_url = DEFAULTS.api_url;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
cfg.api_key = normalizeString(raw.api_key) ?? cfg.api_key;
|
|
116
|
+
cfg.workspace_id = normalizeString(raw.workspace_id) ?? cfg.workspace_id;
|
|
117
|
+
cfg.hosting_mode = normalizeString(raw.hosting_mode) ?? cfg.hosting_mode;
|
|
118
|
+
cfg.active_entity_id = normalizeString(raw.active_entity_id) ?? cfg.active_entity_id;
|
|
119
|
+
if (isObject(raw.llm)) {
|
|
120
|
+
cfg.llm.provider = normalizeString(raw.llm.provider) ?? cfg.llm.provider;
|
|
121
|
+
cfg.llm.api_key = normalizeString(raw.llm.api_key) ?? cfg.llm.api_key;
|
|
122
|
+
cfg.llm.model = normalizeString(raw.llm.model) ?? cfg.llm.model;
|
|
123
|
+
const baseUrl = normalizeString(raw.llm.base_url);
|
|
124
|
+
if (baseUrl && baseUrl.trim()) {
|
|
125
|
+
cfg.llm.base_url = baseUrl.trim();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (isObject(raw.user)) {
|
|
129
|
+
cfg.user.name = normalizeString(raw.user.name) ?? cfg.user.name;
|
|
130
|
+
cfg.user.email = normalizeString(raw.user.email) ?? cfg.user.email;
|
|
131
|
+
}
|
|
132
|
+
const activeEntityIds = normalizeActiveEntityMap(raw.active_entity_ids);
|
|
133
|
+
if (activeEntityIds) {
|
|
134
|
+
cfg.active_entity_ids = activeEntityIds;
|
|
135
|
+
}
|
|
136
|
+
if (cfg.workspace_id && cfg.active_entity_id) {
|
|
137
|
+
cfg.active_entity_ids = {
|
|
138
|
+
...cfg.active_entity_ids ?? {},
|
|
139
|
+
[cfg.workspace_id]: cfg.active_entity_id
|
|
140
|
+
};
|
|
41
141
|
}
|
|
42
142
|
return cfg;
|
|
43
143
|
}
|
|
144
|
+
function serializeConfig(cfg) {
|
|
145
|
+
const normalized = normalizeConfig(cfg);
|
|
146
|
+
const serialized = {
|
|
147
|
+
api_url: normalized.api_url,
|
|
148
|
+
api_key: normalized.api_key,
|
|
149
|
+
workspace_id: normalized.workspace_id,
|
|
150
|
+
hosting_mode: normalized.hosting_mode,
|
|
151
|
+
llm: {
|
|
152
|
+
provider: normalized.llm.provider,
|
|
153
|
+
api_key: normalized.llm.api_key,
|
|
154
|
+
model: normalized.llm.model,
|
|
155
|
+
...normalized.llm.base_url ? { base_url: normalized.llm.base_url } : {}
|
|
156
|
+
},
|
|
157
|
+
user: {
|
|
158
|
+
name: normalized.user.name,
|
|
159
|
+
email: normalized.user.email
|
|
160
|
+
},
|
|
161
|
+
active_entity_id: normalized.active_entity_id
|
|
162
|
+
};
|
|
163
|
+
if (normalized.active_entity_ids && Object.keys(normalized.active_entity_ids).length > 0) {
|
|
164
|
+
serialized.active_entity_ids = normalized.active_entity_ids;
|
|
165
|
+
}
|
|
166
|
+
return JSON.stringify(serialized, null, 2) + "\n";
|
|
167
|
+
}
|
|
168
|
+
function requireSupportedConfigKey(dotPath) {
|
|
169
|
+
if (!ALLOWED_CONFIG_KEYS.has(dotPath)) {
|
|
170
|
+
throw new Error(`unsupported config key: ${dotPath}`);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
function validateSensitiveConfigUpdate(dotPath, forceSensitive = false) {
|
|
174
|
+
if (SENSITIVE_CONFIG_KEYS.has(dotPath) && !forceSensitive) {
|
|
175
|
+
throw new Error(`refusing to update security-sensitive key '${dotPath}' without --force`);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
function setKnownConfigValue(cfg, dotPath, value) {
|
|
179
|
+
switch (dotPath) {
|
|
180
|
+
case "api_url":
|
|
181
|
+
cfg.api_url = validateApiUrl(value);
|
|
182
|
+
return;
|
|
183
|
+
case "api_key":
|
|
184
|
+
cfg.api_key = value.trim();
|
|
185
|
+
return;
|
|
186
|
+
case "workspace_id":
|
|
187
|
+
cfg.workspace_id = value.trim();
|
|
188
|
+
return;
|
|
189
|
+
case "hosting_mode":
|
|
190
|
+
cfg.hosting_mode = value.trim();
|
|
191
|
+
return;
|
|
192
|
+
case "llm.provider":
|
|
193
|
+
cfg.llm.provider = value.trim();
|
|
194
|
+
return;
|
|
195
|
+
case "llm.api_key":
|
|
196
|
+
cfg.llm.api_key = value.trim();
|
|
197
|
+
return;
|
|
198
|
+
case "llm.model":
|
|
199
|
+
cfg.llm.model = value.trim();
|
|
200
|
+
return;
|
|
201
|
+
case "llm.base_url":
|
|
202
|
+
cfg.llm.base_url = value.trim() || void 0;
|
|
203
|
+
return;
|
|
204
|
+
case "user.name":
|
|
205
|
+
cfg.user.name = value.trim();
|
|
206
|
+
return;
|
|
207
|
+
case "user.email":
|
|
208
|
+
cfg.user.email = value.trim();
|
|
209
|
+
return;
|
|
210
|
+
case "active_entity_id":
|
|
211
|
+
setActiveEntityId(cfg, value.trim());
|
|
212
|
+
return;
|
|
213
|
+
default:
|
|
214
|
+
throw new Error(`unsupported config key: ${dotPath}`);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
function readConfigUnlocked() {
|
|
218
|
+
ensureSecurePermissions();
|
|
219
|
+
if (!existsSync(CONFIG_FILE)) {
|
|
220
|
+
return normalizeConfig(DEFAULTS);
|
|
221
|
+
}
|
|
222
|
+
return normalizeConfig(JSON.parse(readFileSync(CONFIG_FILE, "utf-8")));
|
|
223
|
+
}
|
|
224
|
+
function loadConfig() {
|
|
225
|
+
return readConfigUnlocked();
|
|
226
|
+
}
|
|
44
227
|
function saveConfig(cfg) {
|
|
45
|
-
|
|
46
|
-
|
|
228
|
+
withConfigLock(() => {
|
|
229
|
+
ensureSecurePermissions();
|
|
230
|
+
const tempFile = `${CONFIG_FILE}.${process.pid}.tmp`;
|
|
231
|
+
writeFileSync(tempFile, serializeConfig(cfg), { mode: 384 });
|
|
232
|
+
renameSync(tempFile, CONFIG_FILE);
|
|
233
|
+
ensureSecurePermissions();
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
function updateConfig(mutator) {
|
|
237
|
+
return withConfigLock(() => {
|
|
238
|
+
const cfg = readConfigUnlocked();
|
|
239
|
+
mutator(cfg);
|
|
240
|
+
const tempFile = `${CONFIG_FILE}.${process.pid}.tmp`;
|
|
241
|
+
writeFileSync(tempFile, serializeConfig(cfg), { mode: 384 });
|
|
242
|
+
renameSync(tempFile, CONFIG_FILE);
|
|
243
|
+
ensureSecurePermissions();
|
|
244
|
+
return cfg;
|
|
245
|
+
});
|
|
47
246
|
}
|
|
48
247
|
function getValue(cfg, dotPath) {
|
|
49
248
|
const keys = dotPath.split(".");
|
|
@@ -57,16 +256,10 @@ function getValue(cfg, dotPath) {
|
|
|
57
256
|
}
|
|
58
257
|
return current;
|
|
59
258
|
}
|
|
60
|
-
function setValue(cfg, dotPath, value) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (!(key in current) || typeof current[key] !== "object" || current[key] === null) {
|
|
65
|
-
current[key] = {};
|
|
66
|
-
}
|
|
67
|
-
current = current[key];
|
|
68
|
-
}
|
|
69
|
-
current[keys[keys.length - 1]] = value;
|
|
259
|
+
function setValue(cfg, dotPath, value, options = {}) {
|
|
260
|
+
requireSupportedConfigKey(dotPath);
|
|
261
|
+
validateSensitiveConfigUpdate(dotPath, options.forceSensitive);
|
|
262
|
+
setKnownConfigValue(cfg, dotPath, value);
|
|
70
263
|
}
|
|
71
264
|
function requireConfig(...fields) {
|
|
72
265
|
const cfg = loadConfig();
|
|
@@ -92,8 +285,24 @@ function configForDisplay(cfg) {
|
|
|
92
285
|
}
|
|
93
286
|
return display;
|
|
94
287
|
}
|
|
288
|
+
function getActiveEntityId(cfg) {
|
|
289
|
+
if (cfg.workspace_id && cfg.active_entity_ids?.[cfg.workspace_id]) {
|
|
290
|
+
return cfg.active_entity_ids[cfg.workspace_id];
|
|
291
|
+
}
|
|
292
|
+
return cfg.active_entity_id;
|
|
293
|
+
}
|
|
294
|
+
function setActiveEntityId(cfg, entityId) {
|
|
295
|
+
cfg.active_entity_id = entityId;
|
|
296
|
+
if (!cfg.workspace_id) {
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
cfg.active_entity_ids = {
|
|
300
|
+
...cfg.active_entity_ids ?? {},
|
|
301
|
+
[cfg.workspace_id]: entityId
|
|
302
|
+
};
|
|
303
|
+
}
|
|
95
304
|
function resolveEntityId(cfg, explicitId) {
|
|
96
|
-
const eid = explicitId || cfg
|
|
305
|
+
const eid = explicitId || getActiveEntityId(cfg);
|
|
97
306
|
if (!eid) {
|
|
98
307
|
console.error(
|
|
99
308
|
"No entity specified. Use --entity-id or set active_entity_id via 'corp config set active_entity_id <id>'."
|
|
@@ -102,21 +311,41 @@ function resolveEntityId(cfg, explicitId) {
|
|
|
102
311
|
}
|
|
103
312
|
return eid;
|
|
104
313
|
}
|
|
105
|
-
var CONFIG_DIR, CONFIG_FILE, DEFAULTS;
|
|
314
|
+
var CONFIG_DIR, CONFIG_FILE, CONFIG_LOCK_DIR, CONFIG_LOCK_TIMEOUT_MS, CONFIG_LOCK_RETRY_MS, CONFIG_WAIT_BUFFER, CONFIG_WAIT_SIGNAL, ALLOWED_CONFIG_KEYS, SENSITIVE_CONFIG_KEYS, DEFAULTS;
|
|
106
315
|
var init_config = __esm({
|
|
107
316
|
"src/config.ts"() {
|
|
108
317
|
"use strict";
|
|
109
318
|
CONFIG_DIR = process.env.CORP_CONFIG_DIR || join(homedir(), ".corp");
|
|
110
319
|
CONFIG_FILE = join(CONFIG_DIR, "config.json");
|
|
320
|
+
CONFIG_LOCK_DIR = join(CONFIG_DIR, "config.lock");
|
|
321
|
+
CONFIG_LOCK_TIMEOUT_MS = 5e3;
|
|
322
|
+
CONFIG_LOCK_RETRY_MS = 25;
|
|
323
|
+
CONFIG_WAIT_BUFFER = new SharedArrayBuffer(4);
|
|
324
|
+
CONFIG_WAIT_SIGNAL = new Int32Array(CONFIG_WAIT_BUFFER);
|
|
325
|
+
ALLOWED_CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
326
|
+
"api_url",
|
|
327
|
+
"api_key",
|
|
328
|
+
"workspace_id",
|
|
329
|
+
"hosting_mode",
|
|
330
|
+
"llm.provider",
|
|
331
|
+
"llm.api_key",
|
|
332
|
+
"llm.model",
|
|
333
|
+
"llm.base_url",
|
|
334
|
+
"user.name",
|
|
335
|
+
"user.email",
|
|
336
|
+
"active_entity_id"
|
|
337
|
+
]);
|
|
338
|
+
SENSITIVE_CONFIG_KEYS = /* @__PURE__ */ new Set(["api_url", "api_key", "workspace_id"]);
|
|
111
339
|
DEFAULTS = {
|
|
112
340
|
api_url: process.env.CORP_API_URL || "https://api.thecorporation.ai",
|
|
113
|
-
api_key: "",
|
|
114
|
-
workspace_id: "",
|
|
341
|
+
api_key: process.env.CORP_API_KEY || "",
|
|
342
|
+
workspace_id: process.env.CORP_WORKSPACE_ID || "",
|
|
115
343
|
hosting_mode: "",
|
|
116
344
|
llm: {
|
|
117
345
|
provider: "anthropic",
|
|
118
|
-
api_key: "",
|
|
119
|
-
model: "claude-sonnet-4-6"
|
|
346
|
+
api_key: process.env.CORP_LLM_API_KEY || "",
|
|
347
|
+
model: "claude-sonnet-4-6",
|
|
348
|
+
base_url: process.env.CORP_LLM_BASE_URL || void 0
|
|
120
349
|
},
|
|
121
350
|
user: { name: "", email: "" },
|
|
122
351
|
active_entity_id: ""
|
|
@@ -141,6 +370,7 @@ __export(output_exports, {
|
|
|
141
370
|
printCapTable: () => printCapTable,
|
|
142
371
|
printContactsTable: () => printContactsTable,
|
|
143
372
|
printDocumentsTable: () => printDocumentsTable,
|
|
373
|
+
printDryRun: () => printDryRun,
|
|
144
374
|
printEntitiesTable: () => printEntitiesTable,
|
|
145
375
|
printError: () => printError,
|
|
146
376
|
printGovernanceTable: () => printGovernanceTable,
|
|
@@ -155,7 +385,8 @@ __export(output_exports, {
|
|
|
155
385
|
printTransfersTable: () => printTransfersTable,
|
|
156
386
|
printValuationsTable: () => printValuationsTable,
|
|
157
387
|
printWarning: () => printWarning,
|
|
158
|
-
printWorkItemsTable: () => printWorkItemsTable
|
|
388
|
+
printWorkItemsTable: () => printWorkItemsTable,
|
|
389
|
+
printWriteResult: () => printWriteResult
|
|
159
390
|
});
|
|
160
391
|
import chalk from "chalk";
|
|
161
392
|
import Table from "cli-table3";
|
|
@@ -171,6 +402,21 @@ function printWarning(msg) {
|
|
|
171
402
|
function printJson(data) {
|
|
172
403
|
console.log(JSON.stringify(data, null, 2));
|
|
173
404
|
}
|
|
405
|
+
function printDryRun(operation, payload) {
|
|
406
|
+
printJson({
|
|
407
|
+
dry_run: true,
|
|
408
|
+
operation,
|
|
409
|
+
payload
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
function printWriteResult(result, successMessage, jsonOnly) {
|
|
413
|
+
if (jsonOnly) {
|
|
414
|
+
printJson(result);
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
printSuccess(successMessage);
|
|
418
|
+
printJson(result);
|
|
419
|
+
}
|
|
174
420
|
function printStatusPanel(data) {
|
|
175
421
|
console.log(chalk.blue("\u2500".repeat(50)));
|
|
176
422
|
console.log(chalk.blue.bold(" Corp Status"));
|
|
@@ -246,6 +492,38 @@ function printContactsTable(contacts) {
|
|
|
246
492
|
}
|
|
247
493
|
function printCapTable(data) {
|
|
248
494
|
const accessLevel = s(data.access_level) || "admin";
|
|
495
|
+
const instruments = data.instruments ?? [];
|
|
496
|
+
if (instruments.length > 0) {
|
|
497
|
+
const table = makeTable("Cap Table \u2014 Instruments", ["Symbol", "Kind", "Authorized", "Issued", "Diluted"]);
|
|
498
|
+
for (const instrument of instruments) {
|
|
499
|
+
table.push([
|
|
500
|
+
s(instrument.symbol),
|
|
501
|
+
s(instrument.kind),
|
|
502
|
+
s(instrument.authorized_units ?? "unlimited"),
|
|
503
|
+
s(instrument.issued_units),
|
|
504
|
+
s(instrument.diluted_units)
|
|
505
|
+
]);
|
|
506
|
+
}
|
|
507
|
+
console.log(table.toString());
|
|
508
|
+
}
|
|
509
|
+
const holders = data.holders ?? [];
|
|
510
|
+
if (holders.length > 0 && accessLevel !== "summary") {
|
|
511
|
+
const table = makeTable(
|
|
512
|
+
"Ownership Breakdown",
|
|
513
|
+
["Holder", "Outstanding", "As Converted", "Fully Diluted", "Fully Diluted %"]
|
|
514
|
+
);
|
|
515
|
+
for (const holder of holders) {
|
|
516
|
+
const dilutedBps = typeof holder.fully_diluted_bps === "number" ? `${(holder.fully_diluted_bps / 100).toFixed(2)}%` : "";
|
|
517
|
+
table.push([
|
|
518
|
+
s(holder.name),
|
|
519
|
+
s(holder.outstanding_units),
|
|
520
|
+
s(holder.as_converted_units),
|
|
521
|
+
s(holder.fully_diluted_units),
|
|
522
|
+
dilutedBps
|
|
523
|
+
]);
|
|
524
|
+
}
|
|
525
|
+
console.log(table.toString());
|
|
526
|
+
}
|
|
249
527
|
const shareClasses = data.share_classes ?? [];
|
|
250
528
|
if (shareClasses.length > 0) {
|
|
251
529
|
const cols = ["Class", "Authorized", "Outstanding"];
|
|
@@ -254,8 +532,8 @@ function printCapTable(data) {
|
|
|
254
532
|
for (const sc of shareClasses) {
|
|
255
533
|
const row = [s(sc.class_code ?? sc.name), s(sc.authorized), s(sc.outstanding)];
|
|
256
534
|
if (accessLevel !== "summary") {
|
|
257
|
-
const
|
|
258
|
-
row.push(
|
|
535
|
+
const holders2 = sc.holders ?? [];
|
|
536
|
+
row.push(holders2.map((h) => `${h.name ?? "?"}(${h.percentage ?? "?"}%)`).join(", "));
|
|
259
537
|
}
|
|
260
538
|
table.push(row);
|
|
261
539
|
}
|
|
@@ -282,17 +560,22 @@ function printCapTable(data) {
|
|
|
282
560
|
console.log(`
|
|
283
561
|
${chalk.bold("Fully Diluted Shares:")} ${typeof fd === "number" ? fd.toLocaleString() : fd}`);
|
|
284
562
|
}
|
|
563
|
+
if (data.total_units != null) {
|
|
564
|
+
console.log(`
|
|
565
|
+
${chalk.bold("Cap Table Basis:")} ${s(data.basis) || "outstanding"}`);
|
|
566
|
+
console.log(`${chalk.bold("Total Units:")} ${typeof data.total_units === "number" ? data.total_units.toLocaleString() : data.total_units}`);
|
|
567
|
+
}
|
|
285
568
|
}
|
|
286
569
|
function printSafesTable(safes) {
|
|
287
570
|
const table = makeTable("SAFE Notes", ["ID", "Investor", "Amount", "Cap", "Discount", "Date"]);
|
|
288
571
|
for (const s_ of safes) {
|
|
289
572
|
table.push([
|
|
290
|
-
s(s_.safe_id ?? s_.id, 12),
|
|
573
|
+
s(s_.safe_note_id ?? s_.safe_id ?? s_.id, 12),
|
|
291
574
|
s(s_.investor_name ?? s_.investor),
|
|
292
|
-
money(s_.investment_amount ?? s_.amount, false),
|
|
293
|
-
|
|
575
|
+
money(s_.principal_amount_cents ?? s_.investment_amount ?? s_.amount, false),
|
|
576
|
+
money(s_.valuation_cap_cents ?? s_.valuation_cap ?? s_.cap, false),
|
|
294
577
|
s(s_.discount_rate ?? s_.discount),
|
|
295
|
-
s(s_.date ?? s_.created_at)
|
|
578
|
+
s(s_.issued_at ?? s_.date ?? s_.created_at)
|
|
296
579
|
]);
|
|
297
580
|
}
|
|
298
581
|
console.log(table.toString());
|
|
@@ -819,12 +1102,16 @@ var status_exports = {};
|
|
|
819
1102
|
__export(status_exports, {
|
|
820
1103
|
statusCommand: () => statusCommand
|
|
821
1104
|
});
|
|
822
|
-
async function statusCommand() {
|
|
1105
|
+
async function statusCommand(opts = {}) {
|
|
823
1106
|
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
824
1107
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
825
1108
|
try {
|
|
826
1109
|
const data = await withSpinner("Loading", () => client.getStatus());
|
|
827
|
-
|
|
1110
|
+
if (opts.json) {
|
|
1111
|
+
printJson(data);
|
|
1112
|
+
} else {
|
|
1113
|
+
printStatusPanel(data);
|
|
1114
|
+
}
|
|
828
1115
|
} catch (err) {
|
|
829
1116
|
printError(`Failed to fetch status: ${err}`);
|
|
830
1117
|
process.exit(1);
|
|
@@ -840,18 +1127,169 @@ var init_status = __esm({
|
|
|
840
1127
|
}
|
|
841
1128
|
});
|
|
842
1129
|
|
|
1130
|
+
// src/commands/context.ts
|
|
1131
|
+
var context_exports = {};
|
|
1132
|
+
__export(context_exports, {
|
|
1133
|
+
contextCommand: () => contextCommand
|
|
1134
|
+
});
|
|
1135
|
+
import chalk2 from "chalk";
|
|
1136
|
+
async function contextCommand(opts) {
|
|
1137
|
+
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
1138
|
+
const rawCfg = loadConfig();
|
|
1139
|
+
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
1140
|
+
try {
|
|
1141
|
+
const [status, entities] = await Promise.all([
|
|
1142
|
+
client.getStatus(),
|
|
1143
|
+
client.listEntities()
|
|
1144
|
+
]);
|
|
1145
|
+
const activeEntityId = getActiveEntityId(rawCfg);
|
|
1146
|
+
const activeEntity = activeEntityId ? entities.find((entity) => entity.entity_id === activeEntityId) ?? null : null;
|
|
1147
|
+
const [contactsResult, documentsResult, workItemsResult] = activeEntity ? await Promise.allSettled([
|
|
1148
|
+
client.listContacts(String(activeEntity.entity_id)),
|
|
1149
|
+
client.getEntityDocuments(String(activeEntity.entity_id)),
|
|
1150
|
+
client.listWorkItems(String(activeEntity.entity_id))
|
|
1151
|
+
]) : [null, null, null];
|
|
1152
|
+
const payload = {
|
|
1153
|
+
user: {
|
|
1154
|
+
name: rawCfg.user?.name ?? "",
|
|
1155
|
+
email: rawCfg.user?.email ?? ""
|
|
1156
|
+
},
|
|
1157
|
+
workspace: {
|
|
1158
|
+
workspace_id: rawCfg.workspace_id,
|
|
1159
|
+
api_url: rawCfg.api_url,
|
|
1160
|
+
status
|
|
1161
|
+
},
|
|
1162
|
+
active_entity: activeEntity ? {
|
|
1163
|
+
entity: activeEntity,
|
|
1164
|
+
summary: {
|
|
1165
|
+
contact_count: contactsResult && contactsResult.status === "fulfilled" ? contactsResult.value.length : null,
|
|
1166
|
+
document_count: documentsResult && documentsResult.status === "fulfilled" ? documentsResult.value.length : null,
|
|
1167
|
+
work_item_count: workItemsResult && workItemsResult.status === "fulfilled" ? workItemsResult.value.length : null
|
|
1168
|
+
}
|
|
1169
|
+
} : null,
|
|
1170
|
+
entity_count: entities.length
|
|
1171
|
+
};
|
|
1172
|
+
if (opts.json) {
|
|
1173
|
+
printJson(payload);
|
|
1174
|
+
return;
|
|
1175
|
+
}
|
|
1176
|
+
console.log(chalk2.blue("\u2500".repeat(50)));
|
|
1177
|
+
console.log(chalk2.blue.bold(" Corp Context"));
|
|
1178
|
+
console.log(chalk2.blue("\u2500".repeat(50)));
|
|
1179
|
+
console.log(` ${chalk2.bold("User:")} ${payload.user.name || "N/A"} <${payload.user.email || "N/A"}>`);
|
|
1180
|
+
console.log(` ${chalk2.bold("Workspace:")} ${rawCfg.workspace_id}`);
|
|
1181
|
+
console.log(` ${chalk2.bold("API URL:")} ${rawCfg.api_url}`);
|
|
1182
|
+
console.log(` ${chalk2.bold("Entities:")} ${entities.length}`);
|
|
1183
|
+
if (payload.active_entity) {
|
|
1184
|
+
console.log(` ${chalk2.bold("Active Entity:")} ${payload.active_entity.entity.legal_name ?? payload.active_entity.entity.entity_id}`);
|
|
1185
|
+
console.log(` ${chalk2.bold("Active Entity ID:")} ${payload.active_entity.entity.entity_id}`);
|
|
1186
|
+
console.log(` ${chalk2.bold("Contacts:")} ${payload.active_entity.summary.contact_count ?? "N/A"}`);
|
|
1187
|
+
console.log(` ${chalk2.bold("Documents:")} ${payload.active_entity.summary.document_count ?? "N/A"}`);
|
|
1188
|
+
console.log(` ${chalk2.bold("Work Items:")} ${payload.active_entity.summary.work_item_count ?? "N/A"}`);
|
|
1189
|
+
} else {
|
|
1190
|
+
console.log(` ${chalk2.bold("Active Entity:")} none`);
|
|
1191
|
+
}
|
|
1192
|
+
if (status.next_deadline) {
|
|
1193
|
+
console.log(` ${chalk2.bold("Next Deadline:")} ${status.next_deadline}`);
|
|
1194
|
+
}
|
|
1195
|
+
console.log(chalk2.blue("\u2500".repeat(50)));
|
|
1196
|
+
} catch (err) {
|
|
1197
|
+
printError(`Failed to fetch context: ${err}`);
|
|
1198
|
+
process.exit(1);
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
var init_context = __esm({
|
|
1202
|
+
"src/commands/context.ts"() {
|
|
1203
|
+
"use strict";
|
|
1204
|
+
init_config();
|
|
1205
|
+
init_api_client();
|
|
1206
|
+
init_output();
|
|
1207
|
+
}
|
|
1208
|
+
});
|
|
1209
|
+
|
|
1210
|
+
// src/commands/schema.ts
|
|
1211
|
+
var schema_exports = {};
|
|
1212
|
+
__export(schema_exports, {
|
|
1213
|
+
schemaCommand: () => schemaCommand
|
|
1214
|
+
});
|
|
1215
|
+
function readChoices(value) {
|
|
1216
|
+
if (Array.isArray(value) && value.every((entry) => typeof entry === "string")) {
|
|
1217
|
+
return value;
|
|
1218
|
+
}
|
|
1219
|
+
return void 0;
|
|
1220
|
+
}
|
|
1221
|
+
function commandToSchema(command, parentPath = "") {
|
|
1222
|
+
const cmd = command;
|
|
1223
|
+
const path = parentPath ? `${parentPath} ${command.name()}` : command.name();
|
|
1224
|
+
return {
|
|
1225
|
+
path,
|
|
1226
|
+
name: command.name(),
|
|
1227
|
+
description: command.description(),
|
|
1228
|
+
aliases: command.aliases(),
|
|
1229
|
+
arguments: (cmd.registeredArguments ?? []).map((arg) => ({
|
|
1230
|
+
name: arg.name(),
|
|
1231
|
+
required: Boolean(arg.required),
|
|
1232
|
+
variadic: Boolean(arg.variadic),
|
|
1233
|
+
defaultValue: arg.defaultValue,
|
|
1234
|
+
choices: readChoices(arg.argChoices)
|
|
1235
|
+
})),
|
|
1236
|
+
options: command.options.map((option) => ({
|
|
1237
|
+
flags: option.flags,
|
|
1238
|
+
name: option.attributeName(),
|
|
1239
|
+
description: option.description ?? "",
|
|
1240
|
+
required: option.required,
|
|
1241
|
+
mandatory: option.mandatory,
|
|
1242
|
+
variadic: option.variadic,
|
|
1243
|
+
defaultValue: option.defaultValue,
|
|
1244
|
+
choices: readChoices(option.argChoices)
|
|
1245
|
+
})),
|
|
1246
|
+
subcommands: command.commands.map((child) => commandToSchema(child, path))
|
|
1247
|
+
};
|
|
1248
|
+
}
|
|
1249
|
+
function schemaCommand(program2, opts) {
|
|
1250
|
+
const manifest = {
|
|
1251
|
+
name: program2.name(),
|
|
1252
|
+
version: program2.version(),
|
|
1253
|
+
description: program2.description(),
|
|
1254
|
+
generated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1255
|
+
commands: program2.commands.map((command) => commandToSchema(command, program2.name()))
|
|
1256
|
+
};
|
|
1257
|
+
if (opts.compact) {
|
|
1258
|
+
console.log(JSON.stringify(manifest));
|
|
1259
|
+
return;
|
|
1260
|
+
}
|
|
1261
|
+
printJson(manifest);
|
|
1262
|
+
}
|
|
1263
|
+
var init_schema = __esm({
|
|
1264
|
+
"src/commands/schema.ts"() {
|
|
1265
|
+
"use strict";
|
|
1266
|
+
init_output();
|
|
1267
|
+
}
|
|
1268
|
+
});
|
|
1269
|
+
|
|
843
1270
|
// src/commands/config.ts
|
|
844
|
-
var
|
|
845
|
-
__export(
|
|
1271
|
+
var config_exports = {};
|
|
1272
|
+
__export(config_exports, {
|
|
846
1273
|
configGetCommand: () => configGetCommand,
|
|
847
1274
|
configListCommand: () => configListCommand,
|
|
848
1275
|
configSetCommand: () => configSetCommand
|
|
849
1276
|
});
|
|
850
|
-
function configSetCommand(key, value) {
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
1277
|
+
function configSetCommand(key, value, options = {}) {
|
|
1278
|
+
try {
|
|
1279
|
+
updateConfig((cfg) => {
|
|
1280
|
+
setValue(cfg, key, value, {
|
|
1281
|
+
forceSensitive: options.force
|
|
1282
|
+
});
|
|
1283
|
+
});
|
|
1284
|
+
} catch (err) {
|
|
1285
|
+
printError(`Failed to update config: ${err}`);
|
|
1286
|
+
process.exit(1);
|
|
1287
|
+
}
|
|
1288
|
+
if (key === "api_key" || key === "llm.api_key") {
|
|
1289
|
+
console.log(`${key} updated.`);
|
|
1290
|
+
return;
|
|
1291
|
+
}
|
|
1292
|
+
console.log(`${key} updated.`);
|
|
855
1293
|
}
|
|
856
1294
|
function configGetCommand(key) {
|
|
857
1295
|
const cfg = loadConfig();
|
|
@@ -921,8 +1359,10 @@ async function digestCommand(opts) {
|
|
|
921
1359
|
const value = result.message;
|
|
922
1360
|
return typeof value === "string" && value.trim() ? value : null;
|
|
923
1361
|
})();
|
|
924
|
-
|
|
925
|
-
|
|
1362
|
+
if (!opts.json) {
|
|
1363
|
+
printSuccess(result.digest_count > 0 ? "Digest triggered." : "Digest trigger accepted.");
|
|
1364
|
+
}
|
|
1365
|
+
if (message && !opts.json) {
|
|
926
1366
|
printWarning(message);
|
|
927
1367
|
}
|
|
928
1368
|
printJson(result);
|
|
@@ -1164,9 +1604,9 @@ async function executeTool(name, args, client) {
|
|
|
1164
1604
|
dataDir: join2(homedir2(), ".corp"),
|
|
1165
1605
|
onEntityFormed: (entityId) => {
|
|
1166
1606
|
try {
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1607
|
+
updateConfig((cfg) => {
|
|
1608
|
+
setActiveEntityId(cfg, entityId);
|
|
1609
|
+
});
|
|
1170
1610
|
} catch {
|
|
1171
1611
|
}
|
|
1172
1612
|
}
|
|
@@ -1188,15 +1628,15 @@ __export(chat_exports, {
|
|
|
1188
1628
|
chatCommand: () => chatCommand
|
|
1189
1629
|
});
|
|
1190
1630
|
import { createInterface } from "readline";
|
|
1191
|
-
import
|
|
1631
|
+
import chalk3 from "chalk";
|
|
1192
1632
|
async function chatCommand() {
|
|
1193
1633
|
const cfg = requireConfig("api_url", "api_key", "workspace_id", "llm.api_key");
|
|
1194
1634
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
1195
1635
|
const messages = [{ role: "system", content: SYSTEM_PROMPT }];
|
|
1196
1636
|
let totalTokens = 0;
|
|
1197
1637
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
1198
|
-
const prompt = () => new Promise((
|
|
1199
|
-
console.log(
|
|
1638
|
+
const prompt = () => new Promise((resolve3) => rl.question(chalk3.green.bold("> "), resolve3));
|
|
1639
|
+
console.log(chalk3.blue.bold("corp chat") + " \u2014 type /help for commands, /quit to exit\n");
|
|
1200
1640
|
const slashHandlers = {
|
|
1201
1641
|
"/status": async () => {
|
|
1202
1642
|
try {
|
|
@@ -1210,7 +1650,7 @@ async function chatCommand() {
|
|
|
1210
1650
|
const data = await client.getObligations();
|
|
1211
1651
|
const obls = data.obligations ?? [];
|
|
1212
1652
|
if (obls.length) printObligationsTable(obls);
|
|
1213
|
-
else console.log(
|
|
1653
|
+
else console.log(chalk3.dim("No obligations found."));
|
|
1214
1654
|
} catch (e) {
|
|
1215
1655
|
printError(`Obligations error: ${e}`);
|
|
1216
1656
|
}
|
|
@@ -1219,7 +1659,7 @@ async function chatCommand() {
|
|
|
1219
1659
|
try {
|
|
1220
1660
|
const digests = await client.listDigests();
|
|
1221
1661
|
if (digests.length) printJson(digests);
|
|
1222
|
-
else console.log(
|
|
1662
|
+
else console.log(chalk3.dim("No digest history."));
|
|
1223
1663
|
} catch (e) {
|
|
1224
1664
|
printError(`Digest error: ${e}`);
|
|
1225
1665
|
}
|
|
@@ -1240,11 +1680,11 @@ async function chatCommand() {
|
|
|
1240
1680
|
messages.length = 0;
|
|
1241
1681
|
messages.push({ role: "system", content: SYSTEM_PROMPT });
|
|
1242
1682
|
totalTokens = 0;
|
|
1243
|
-
console.log(
|
|
1683
|
+
console.log(chalk3.dim("Conversation cleared."));
|
|
1244
1684
|
},
|
|
1245
1685
|
"/help": () => {
|
|
1246
1686
|
console.log(`
|
|
1247
|
-
${
|
|
1687
|
+
${chalk3.bold("Chat Slash Commands")}
|
|
1248
1688
|
/status Show workspace status
|
|
1249
1689
|
/obligations List obligations
|
|
1250
1690
|
/digest Show digest history
|
|
@@ -1262,7 +1702,7 @@ ${chalk2.bold("Chat Slash Commands")}
|
|
|
1262
1702
|
try {
|
|
1263
1703
|
userInput = (await prompt()).trim();
|
|
1264
1704
|
} catch {
|
|
1265
|
-
console.log("\n" +
|
|
1705
|
+
console.log("\n" + chalk3.dim("Goodbye."));
|
|
1266
1706
|
break;
|
|
1267
1707
|
}
|
|
1268
1708
|
if (!userInput) continue;
|
|
@@ -1270,7 +1710,7 @@ ${chalk2.bold("Chat Slash Commands")}
|
|
|
1270
1710
|
const [cmd, ...rest] = userInput.split(/\s+/);
|
|
1271
1711
|
const args = rest.join(" ");
|
|
1272
1712
|
if (cmd === "/quit" || cmd === "/exit") {
|
|
1273
|
-
console.log(
|
|
1713
|
+
console.log(chalk3.dim("Goodbye."));
|
|
1274
1714
|
break;
|
|
1275
1715
|
}
|
|
1276
1716
|
const handler = slashHandlers[cmd.toLowerCase()];
|
|
@@ -1314,10 +1754,10 @@ ${chalk2.bold("Chat Slash Commands")}
|
|
|
1314
1754
|
break;
|
|
1315
1755
|
}
|
|
1316
1756
|
for (const tc of response.tool_calls) {
|
|
1317
|
-
console.log(
|
|
1757
|
+
console.log(chalk3.dim(` ${isWriteTool(tc.name, tc.arguments) ? "\u2699" : "\u2139"} ${tc.name}(${JSON.stringify(tc.arguments).slice(0, 80)})`));
|
|
1318
1758
|
const result = await executeTool(tc.name, tc.arguments, client);
|
|
1319
1759
|
const short = result.length > 200 ? result.slice(0, 197) + "..." : result;
|
|
1320
|
-
console.log(
|
|
1760
|
+
console.log(chalk3.dim(` => ${short}`));
|
|
1321
1761
|
messages.push({ role: "tool", tool_call_id: tc.id, content: result });
|
|
1322
1762
|
}
|
|
1323
1763
|
}
|
|
@@ -1353,7 +1793,7 @@ __export(entities_exports, {
|
|
|
1353
1793
|
entitiesDissolveCommand: () => entitiesDissolveCommand,
|
|
1354
1794
|
entitiesShowCommand: () => entitiesShowCommand
|
|
1355
1795
|
});
|
|
1356
|
-
import
|
|
1796
|
+
import chalk4 from "chalk";
|
|
1357
1797
|
async function entitiesCommand(opts) {
|
|
1358
1798
|
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
1359
1799
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
@@ -1386,18 +1826,18 @@ async function entitiesShowCommand(entityId, opts) {
|
|
|
1386
1826
|
if (jsonOutput) {
|
|
1387
1827
|
printJson(entity);
|
|
1388
1828
|
} else {
|
|
1389
|
-
console.log(
|
|
1390
|
-
console.log(
|
|
1391
|
-
console.log(
|
|
1392
|
-
console.log(` ${
|
|
1393
|
-
console.log(` ${
|
|
1394
|
-
console.log(` ${
|
|
1395
|
-
console.log(` ${
|
|
1396
|
-
console.log(` ${
|
|
1397
|
-
console.log(` ${
|
|
1398
|
-
if (entity.formation_date) console.log(` ${
|
|
1399
|
-
if (entity.ein) console.log(` ${
|
|
1400
|
-
console.log(
|
|
1829
|
+
console.log(chalk4.blue("\u2500".repeat(40)));
|
|
1830
|
+
console.log(chalk4.blue.bold(" Entity Detail"));
|
|
1831
|
+
console.log(chalk4.blue("\u2500".repeat(40)));
|
|
1832
|
+
console.log(` ${chalk4.bold("Name:")} ${entity.legal_name ?? entity.name ?? "N/A"}`);
|
|
1833
|
+
console.log(` ${chalk4.bold("Type:")} ${entity.entity_type ?? "N/A"}`);
|
|
1834
|
+
console.log(` ${chalk4.bold("Jurisdiction:")} ${entity.jurisdiction ?? "N/A"}`);
|
|
1835
|
+
console.log(` ${chalk4.bold("Status:")} ${entity.formation_status ?? entity.status ?? "N/A"}`);
|
|
1836
|
+
console.log(` ${chalk4.bold("State:")} ${entity.formation_state ?? "N/A"}`);
|
|
1837
|
+
console.log(` ${chalk4.bold("ID:")} ${entity.entity_id ?? "N/A"}`);
|
|
1838
|
+
if (entity.formation_date) console.log(` ${chalk4.bold("Formation Date:")} ${entity.formation_date}`);
|
|
1839
|
+
if (entity.ein) console.log(` ${chalk4.bold("EIN:")} ${entity.ein}`);
|
|
1840
|
+
console.log(chalk4.blue("\u2500".repeat(40)));
|
|
1401
1841
|
}
|
|
1402
1842
|
} catch (err) {
|
|
1403
1843
|
printError(`Failed to fetch entities: ${err}`);
|
|
@@ -1455,7 +1895,7 @@ __export(contacts_exports, {
|
|
|
1455
1895
|
contactsListCommand: () => contactsListCommand,
|
|
1456
1896
|
contactsShowCommand: () => contactsShowCommand
|
|
1457
1897
|
});
|
|
1458
|
-
import
|
|
1898
|
+
import chalk5 from "chalk";
|
|
1459
1899
|
async function contactsListCommand(opts) {
|
|
1460
1900
|
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
1461
1901
|
const eid = resolveEntityId(cfg, opts.entityId);
|
|
@@ -1480,24 +1920,24 @@ async function contactsShowCommand(contactId, opts) {
|
|
|
1480
1920
|
printJson(profile);
|
|
1481
1921
|
} else {
|
|
1482
1922
|
const contact = profile.contact ?? profile;
|
|
1483
|
-
console.log(
|
|
1484
|
-
console.log(
|
|
1485
|
-
console.log(
|
|
1486
|
-
console.log(` ${
|
|
1487
|
-
console.log(` ${
|
|
1488
|
-
console.log(` ${
|
|
1489
|
-
if (contact.phone) console.log(` ${
|
|
1490
|
-
if (contact.notes) console.log(` ${
|
|
1923
|
+
console.log(chalk5.cyan("\u2500".repeat(40)));
|
|
1924
|
+
console.log(chalk5.cyan.bold(" Contact Profile"));
|
|
1925
|
+
console.log(chalk5.cyan("\u2500".repeat(40)));
|
|
1926
|
+
console.log(` ${chalk5.bold("Name:")} ${contact.name ?? "N/A"}`);
|
|
1927
|
+
console.log(` ${chalk5.bold("Email:")} ${contact.email ?? "N/A"}`);
|
|
1928
|
+
console.log(` ${chalk5.bold("Category:")} ${contact.category ?? "N/A"}`);
|
|
1929
|
+
if (contact.phone) console.log(` ${chalk5.bold("Phone:")} ${contact.phone}`);
|
|
1930
|
+
if (contact.notes) console.log(` ${chalk5.bold("Notes:")} ${contact.notes}`);
|
|
1491
1931
|
const holdings = profile.equity_holdings;
|
|
1492
1932
|
if (holdings?.length) {
|
|
1493
1933
|
console.log(`
|
|
1494
|
-
${
|
|
1934
|
+
${chalk5.bold("Equity Holdings:")}`);
|
|
1495
1935
|
for (const h of holdings) console.log(` ${h.share_class ?? "?"}: ${h.shares ?? "?"} shares`);
|
|
1496
1936
|
}
|
|
1497
1937
|
const obls = profile.obligations;
|
|
1498
1938
|
if (obls?.length) console.log(`
|
|
1499
|
-
${
|
|
1500
|
-
console.log(
|
|
1939
|
+
${chalk5.bold("Obligations:")} ${obls.length}`);
|
|
1940
|
+
console.log(chalk5.cyan("\u2500".repeat(40)));
|
|
1501
1941
|
}
|
|
1502
1942
|
} catch (err) {
|
|
1503
1943
|
printError(`Failed to fetch contact: ${err}`);
|
|
@@ -1518,8 +1958,14 @@ async function contactsAddCommand(opts) {
|
|
|
1518
1958
|
};
|
|
1519
1959
|
if (opts.phone) data.phone = opts.phone;
|
|
1520
1960
|
if (opts.notes) data.notes = opts.notes;
|
|
1961
|
+
if (opts.mailingAddress ?? opts.address) data.mailing_address = opts.mailingAddress ?? opts.address;
|
|
1962
|
+
if (opts.capTableAccess) data.cap_table_access = opts.capTableAccess;
|
|
1521
1963
|
const result = await client.createContact(data);
|
|
1522
|
-
|
|
1964
|
+
printWriteResult(
|
|
1965
|
+
result,
|
|
1966
|
+
`Contact created: ${result.contact_id ?? result.id ?? "OK"}`,
|
|
1967
|
+
opts.json
|
|
1968
|
+
);
|
|
1523
1969
|
} catch (err) {
|
|
1524
1970
|
printError(`Failed to create contact: ${err}`);
|
|
1525
1971
|
process.exit(1);
|
|
@@ -1531,17 +1977,41 @@ async function contactsEditCommand(contactId, opts) {
|
|
|
1531
1977
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
1532
1978
|
try {
|
|
1533
1979
|
const data = { entity_id: eid };
|
|
1534
|
-
|
|
1535
|
-
if (opts.
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
if (
|
|
1980
|
+
let hasUpdates = false;
|
|
1981
|
+
if (opts.name != null) {
|
|
1982
|
+
data.name = opts.name;
|
|
1983
|
+
hasUpdates = true;
|
|
1984
|
+
}
|
|
1985
|
+
if (opts.email != null) {
|
|
1986
|
+
data.email = opts.email;
|
|
1987
|
+
hasUpdates = true;
|
|
1988
|
+
}
|
|
1989
|
+
if (opts.category != null) {
|
|
1990
|
+
data.category = opts.category;
|
|
1991
|
+
hasUpdates = true;
|
|
1992
|
+
}
|
|
1993
|
+
if (opts.phone != null) {
|
|
1994
|
+
data.phone = opts.phone;
|
|
1995
|
+
hasUpdates = true;
|
|
1996
|
+
}
|
|
1997
|
+
if (opts.notes != null) {
|
|
1998
|
+
data.notes = opts.notes;
|
|
1999
|
+
hasUpdates = true;
|
|
2000
|
+
}
|
|
2001
|
+
if (opts.capTableAccess != null) {
|
|
2002
|
+
data.cap_table_access = opts.capTableAccess;
|
|
2003
|
+
hasUpdates = true;
|
|
2004
|
+
}
|
|
2005
|
+
if (opts.mailingAddress != null || opts.address != null) {
|
|
2006
|
+
data.mailing_address = opts.mailingAddress ?? opts.address;
|
|
2007
|
+
hasUpdates = true;
|
|
2008
|
+
}
|
|
2009
|
+
if (!hasUpdates) {
|
|
1540
2010
|
console.log("No fields to update.");
|
|
1541
2011
|
return;
|
|
1542
2012
|
}
|
|
1543
|
-
await client.updateContact(contactId, data);
|
|
1544
|
-
|
|
2013
|
+
const result = await client.updateContact(contactId, data);
|
|
2014
|
+
printWriteResult(result, "Contact updated.", opts.json);
|
|
1545
2015
|
} catch (err) {
|
|
1546
2016
|
printError(`Failed to update contact: ${err}`);
|
|
1547
2017
|
process.exit(1);
|
|
@@ -1562,6 +2032,7 @@ __export(cap_table_exports, {
|
|
|
1562
2032
|
addSecurityCommand: () => addSecurityCommand,
|
|
1563
2033
|
approveValuationCommand: () => approveValuationCommand,
|
|
1564
2034
|
capTableCommand: () => capTableCommand,
|
|
2035
|
+
createInstrumentCommand: () => createInstrumentCommand,
|
|
1565
2036
|
createValuationCommand: () => createValuationCommand,
|
|
1566
2037
|
distributeCommand: () => distributeCommand,
|
|
1567
2038
|
fourOhNineACommand: () => fourOhNineACommand,
|
|
@@ -1575,7 +2046,109 @@ __export(cap_table_exports, {
|
|
|
1575
2046
|
transfersCommand: () => transfersCommand,
|
|
1576
2047
|
valuationsCommand: () => valuationsCommand
|
|
1577
2048
|
});
|
|
1578
|
-
import
|
|
2049
|
+
import chalk6 from "chalk";
|
|
2050
|
+
function normalizedGrantType(grantType) {
|
|
2051
|
+
return grantType.trim().toLowerCase().replaceAll("-", "_").replaceAll(" ", "_");
|
|
2052
|
+
}
|
|
2053
|
+
function expectedInstrumentKinds(grantType) {
|
|
2054
|
+
switch (normalizedGrantType(grantType)) {
|
|
2055
|
+
case "common":
|
|
2056
|
+
case "common_stock":
|
|
2057
|
+
return ["common_equity"];
|
|
2058
|
+
case "preferred":
|
|
2059
|
+
case "preferred_stock":
|
|
2060
|
+
return ["preferred_equity"];
|
|
2061
|
+
case "unit":
|
|
2062
|
+
case "membership_unit":
|
|
2063
|
+
return ["membership_unit"];
|
|
2064
|
+
case "option":
|
|
2065
|
+
case "options":
|
|
2066
|
+
case "stock_option":
|
|
2067
|
+
case "iso":
|
|
2068
|
+
case "nso":
|
|
2069
|
+
return ["option_grant"];
|
|
2070
|
+
case "rsa":
|
|
2071
|
+
return ["common_equity", "preferred_equity"];
|
|
2072
|
+
default:
|
|
2073
|
+
return [];
|
|
2074
|
+
}
|
|
2075
|
+
}
|
|
2076
|
+
function grantRequiresCurrent409a(grantType, instrumentKind) {
|
|
2077
|
+
return instrumentKind?.toLowerCase() === "option_grant" || expectedInstrumentKinds(grantType).includes("option_grant");
|
|
2078
|
+
}
|
|
2079
|
+
function buildInstrumentCreationHint(grantType) {
|
|
2080
|
+
const normalized = normalizedGrantType(grantType);
|
|
2081
|
+
switch (normalized) {
|
|
2082
|
+
case "preferred":
|
|
2083
|
+
case "preferred_stock":
|
|
2084
|
+
return "Create one with: corp cap-table create-instrument --kind preferred_equity --symbol SERIES-A --authorized-units <shares>";
|
|
2085
|
+
case "option":
|
|
2086
|
+
case "options":
|
|
2087
|
+
case "stock_option":
|
|
2088
|
+
case "iso":
|
|
2089
|
+
case "nso":
|
|
2090
|
+
return "Create one with: corp cap-table create-instrument --kind option_grant --symbol OPTION-PLAN --authorized-units <shares>";
|
|
2091
|
+
case "membership_unit":
|
|
2092
|
+
case "unit":
|
|
2093
|
+
return "Create one with: corp cap-table create-instrument --kind membership_unit --symbol UNIT --authorized-units <units>";
|
|
2094
|
+
case "common":
|
|
2095
|
+
case "common_stock":
|
|
2096
|
+
return "Create one with: corp cap-table create-instrument --kind common_equity --symbol COMMON --authorized-units <shares>";
|
|
2097
|
+
default:
|
|
2098
|
+
return "Create a matching instrument first, then pass --instrument-id explicitly.";
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
2101
|
+
function resolveInstrumentForGrant(instruments, grantType, explicitInstrumentId) {
|
|
2102
|
+
if (explicitInstrumentId) {
|
|
2103
|
+
const explicit = instruments.find((instrument) => instrument.instrument_id === explicitInstrumentId);
|
|
2104
|
+
if (!explicit) {
|
|
2105
|
+
throw new Error(`Instrument ${explicitInstrumentId} was not found on the cap table.`);
|
|
2106
|
+
}
|
|
2107
|
+
return explicit;
|
|
2108
|
+
}
|
|
2109
|
+
const expectedKinds = expectedInstrumentKinds(grantType);
|
|
2110
|
+
if (expectedKinds.length === 0) {
|
|
2111
|
+
throw new Error(
|
|
2112
|
+
`No default instrument mapping exists for grant type "${grantType}". ${buildInstrumentCreationHint(grantType)}`
|
|
2113
|
+
);
|
|
2114
|
+
}
|
|
2115
|
+
const match = instruments.find((instrument) => expectedKinds.includes(String(instrument.kind).toLowerCase()));
|
|
2116
|
+
if (!match) {
|
|
2117
|
+
throw new Error(
|
|
2118
|
+
`No instrument found for grant type "${grantType}". Expected one of: ${expectedKinds.join(", ")}. ${buildInstrumentCreationHint(grantType)}`
|
|
2119
|
+
);
|
|
2120
|
+
}
|
|
2121
|
+
return match;
|
|
2122
|
+
}
|
|
2123
|
+
async function entityHasActiveBoard(client, entityId) {
|
|
2124
|
+
const bodies = await client.listGovernanceBodies(entityId);
|
|
2125
|
+
return bodies.some(
|
|
2126
|
+
(body) => String(body.body_type ?? "").toLowerCase() === "board_of_directors" && String(body.status ?? "active").toLowerCase() === "active"
|
|
2127
|
+
);
|
|
2128
|
+
}
|
|
2129
|
+
async function ensureIssuancePreflight(client, entityId, grantType, instrument, meetingId, resolutionId) {
|
|
2130
|
+
if (!meetingId || !resolutionId) {
|
|
2131
|
+
if (await entityHasActiveBoard(client, entityId)) {
|
|
2132
|
+
throw new Error(
|
|
2133
|
+
"Board approval is required before issuing this round. Pass --meeting-id and --resolution-id from a passed board vote."
|
|
2134
|
+
);
|
|
2135
|
+
}
|
|
2136
|
+
}
|
|
2137
|
+
if (!grantRequiresCurrent409a(grantType, instrument?.kind)) {
|
|
2138
|
+
return;
|
|
2139
|
+
}
|
|
2140
|
+
try {
|
|
2141
|
+
await client.getCurrent409a(entityId);
|
|
2142
|
+
} catch (err) {
|
|
2143
|
+
const msg = String(err);
|
|
2144
|
+
if (msg.includes("404")) {
|
|
2145
|
+
throw new Error(
|
|
2146
|
+
"Stock option issuances require a current approved 409A valuation. Create and approve one first with: corp cap-table create-valuation --type four_oh_nine_a --date YYYY-MM-DD --methodology <method>; corp cap-table submit-valuation <id>; corp cap-table approve-valuation <id> --resolution-id <resolution-id>"
|
|
2147
|
+
);
|
|
2148
|
+
}
|
|
2149
|
+
throw err;
|
|
2150
|
+
}
|
|
2151
|
+
}
|
|
1579
2152
|
async function capTableCommand(opts) {
|
|
1580
2153
|
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
1581
2154
|
const eid = resolveEntityId(cfg, opts.entityId);
|
|
@@ -1667,31 +2240,43 @@ async function issueEquityCommand(opts) {
|
|
|
1667
2240
|
const eid = resolveEntityId(cfg, opts.entityId);
|
|
1668
2241
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
1669
2242
|
try {
|
|
2243
|
+
if (opts.dryRun) {
|
|
2244
|
+
printDryRun("cap_table.issue_equity", {
|
|
2245
|
+
entity_id: eid,
|
|
2246
|
+
grant_type: opts.grantType,
|
|
2247
|
+
shares: opts.shares,
|
|
2248
|
+
recipient: opts.recipient,
|
|
2249
|
+
email: opts.email,
|
|
2250
|
+
instrument_id: opts.instrumentId,
|
|
2251
|
+
meeting_id: opts.meetingId,
|
|
2252
|
+
resolution_id: opts.resolutionId
|
|
2253
|
+
});
|
|
2254
|
+
return;
|
|
2255
|
+
}
|
|
1670
2256
|
const capTable = await client.getCapTable(eid);
|
|
1671
2257
|
const issuerLegalEntityId = capTable.issuer_legal_entity_id;
|
|
1672
2258
|
if (!issuerLegalEntityId) {
|
|
1673
2259
|
printError("No issuer legal entity found. Has this entity been formed with a cap table?");
|
|
1674
2260
|
process.exit(1);
|
|
1675
2261
|
}
|
|
1676
|
-
|
|
1677
|
-
if (!
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
printError("No instruments found on cap table. Create an instrument first.");
|
|
1681
|
-
process.exit(1);
|
|
1682
|
-
}
|
|
1683
|
-
const grantLower = opts.grantType.toLowerCase();
|
|
1684
|
-
const match = instruments.find(
|
|
1685
|
-
(i) => i.kind.toLowerCase().includes(grantLower) || i.symbol.toLowerCase().includes(grantLower)
|
|
1686
|
-
) ?? instruments.find((i) => i.kind.toLowerCase().includes("common"));
|
|
1687
|
-
if (match) {
|
|
1688
|
-
instrumentId = match.instrument_id;
|
|
1689
|
-
console.log(`Using instrument: ${match.symbol} (${match.kind})`);
|
|
1690
|
-
} else {
|
|
1691
|
-
instrumentId = instruments[0].instrument_id;
|
|
1692
|
-
console.log(`Using first instrument: ${instruments[0].symbol} (${instruments[0].kind})`);
|
|
1693
|
-
}
|
|
2262
|
+
const instruments = capTable.instruments ?? [];
|
|
2263
|
+
if (!instruments.length) {
|
|
2264
|
+
printError("No instruments found on cap table. Create one with: corp cap-table create-instrument --kind common_equity --symbol COMMON --authorized-units <shares>");
|
|
2265
|
+
process.exit(1);
|
|
1694
2266
|
}
|
|
2267
|
+
const instrument = resolveInstrumentForGrant(instruments, opts.grantType, opts.instrumentId);
|
|
2268
|
+
const instrumentId = instrument.instrument_id;
|
|
2269
|
+
if (!opts.instrumentId) {
|
|
2270
|
+
console.log(`Using instrument: ${instrument.symbol} (${instrument.kind})`);
|
|
2271
|
+
}
|
|
2272
|
+
await ensureIssuancePreflight(
|
|
2273
|
+
client,
|
|
2274
|
+
eid,
|
|
2275
|
+
opts.grantType,
|
|
2276
|
+
instrument,
|
|
2277
|
+
opts.meetingId,
|
|
2278
|
+
opts.resolutionId
|
|
2279
|
+
);
|
|
1695
2280
|
const round = await client.startEquityRound({
|
|
1696
2281
|
entity_id: eid,
|
|
1697
2282
|
name: `${opts.grantType} grant \u2014 ${opts.recipient}`,
|
|
@@ -1707,7 +2292,14 @@ async function issueEquityCommand(opts) {
|
|
|
1707
2292
|
};
|
|
1708
2293
|
if (opts.email) securityData.email = opts.email;
|
|
1709
2294
|
await client.addRoundSecurity(roundId, securityData);
|
|
1710
|
-
const
|
|
2295
|
+
const issuePayload = { entity_id: eid };
|
|
2296
|
+
if (opts.meetingId) issuePayload.meeting_id = opts.meetingId;
|
|
2297
|
+
if (opts.resolutionId) issuePayload.resolution_id = opts.resolutionId;
|
|
2298
|
+
const result = await client.issueRound(roundId, issuePayload);
|
|
2299
|
+
if (opts.json) {
|
|
2300
|
+
printJson(result);
|
|
2301
|
+
return;
|
|
2302
|
+
}
|
|
1711
2303
|
printSuccess(`Equity issued: ${opts.shares} shares (${opts.grantType}) to ${opts.recipient}`);
|
|
1712
2304
|
printJson(result);
|
|
1713
2305
|
} catch (err) {
|
|
@@ -1720,35 +2312,42 @@ async function issueSafeCommand(opts) {
|
|
|
1720
2312
|
const eid = resolveEntityId(cfg, opts.entityId);
|
|
1721
2313
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
1722
2314
|
try {
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
2315
|
+
if (opts.dryRun) {
|
|
2316
|
+
printDryRun("cap_table.issue_safe", {
|
|
2317
|
+
entity_id: eid,
|
|
2318
|
+
investor: opts.investor,
|
|
2319
|
+
amount: opts.amount,
|
|
2320
|
+
safe_type: opts.safeType,
|
|
2321
|
+
valuation_cap: opts.valuationCap,
|
|
2322
|
+
email: opts.email,
|
|
2323
|
+
meeting_id: opts.meetingId,
|
|
2324
|
+
resolution_id: opts.resolutionId
|
|
2325
|
+
});
|
|
2326
|
+
return;
|
|
1734
2327
|
}
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
2328
|
+
await ensureIssuancePreflight(
|
|
2329
|
+
client,
|
|
2330
|
+
eid,
|
|
2331
|
+
opts.safeType,
|
|
2332
|
+
void 0,
|
|
2333
|
+
opts.meetingId,
|
|
2334
|
+
opts.resolutionId
|
|
2335
|
+
);
|
|
2336
|
+
const body = {
|
|
1742
2337
|
entity_id: eid,
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
grant_type: opts.safeType
|
|
2338
|
+
investor_name: opts.investor,
|
|
2339
|
+
principal_amount_cents: opts.amount,
|
|
2340
|
+
valuation_cap_cents: opts.valuationCap,
|
|
2341
|
+
safe_type: opts.safeType
|
|
1748
2342
|
};
|
|
1749
|
-
if (opts.email)
|
|
1750
|
-
|
|
1751
|
-
|
|
2343
|
+
if (opts.email) body.email = opts.email;
|
|
2344
|
+
if (opts.meetingId) body.meeting_id = opts.meetingId;
|
|
2345
|
+
if (opts.resolutionId) body.resolution_id = opts.resolutionId;
|
|
2346
|
+
const result = await client.createSafeNote(body);
|
|
2347
|
+
if (opts.json) {
|
|
2348
|
+
printJson(result);
|
|
2349
|
+
return;
|
|
2350
|
+
}
|
|
1752
2351
|
printSuccess(`SAFE issued: $${(opts.amount / 100).toLocaleString()} to ${opts.investor}`);
|
|
1753
2352
|
printJson(result);
|
|
1754
2353
|
} catch (err) {
|
|
@@ -1761,6 +2360,28 @@ async function transferSharesCommand(opts) {
|
|
|
1761
2360
|
const eid = resolveEntityId(cfg, opts.entityId);
|
|
1762
2361
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
1763
2362
|
try {
|
|
2363
|
+
if (opts.pricePerShareCents != null && opts.pricePerShareCents < 0) {
|
|
2364
|
+
throw new Error("price-per-share-cents cannot be negative");
|
|
2365
|
+
}
|
|
2366
|
+
if (opts.from === opts.to) {
|
|
2367
|
+
throw new Error("--from and --to must be different contacts");
|
|
2368
|
+
}
|
|
2369
|
+
if (opts.dryRun) {
|
|
2370
|
+
printDryRun("cap_table.transfer_shares", {
|
|
2371
|
+
entity_id: eid,
|
|
2372
|
+
from_contact_id: opts.from,
|
|
2373
|
+
to_contact_id: opts.to,
|
|
2374
|
+
share_count: opts.shares,
|
|
2375
|
+
transfer_type: opts.type,
|
|
2376
|
+
share_class_id: opts.shareClassId,
|
|
2377
|
+
governing_doc_type: opts.governingDocType,
|
|
2378
|
+
transferee_rights: opts.transfereeRights,
|
|
2379
|
+
prepare_intent_id: opts.prepareIntentId,
|
|
2380
|
+
price_per_share_cents: opts.pricePerShareCents,
|
|
2381
|
+
relationship_to_holder: opts.relationship
|
|
2382
|
+
});
|
|
2383
|
+
return;
|
|
2384
|
+
}
|
|
1764
2385
|
let intentId = opts.prepareIntentId;
|
|
1765
2386
|
if (!intentId) {
|
|
1766
2387
|
const intent = await client.createExecutionIntent({
|
|
@@ -1786,8 +2407,7 @@ async function transferSharesCommand(opts) {
|
|
|
1786
2407
|
if (opts.pricePerShareCents != null) body.price_per_share_cents = opts.pricePerShareCents;
|
|
1787
2408
|
if (opts.relationship) body.relationship_to_holder = opts.relationship;
|
|
1788
2409
|
const result = await client.transferShares(body);
|
|
1789
|
-
|
|
1790
|
-
printJson(result);
|
|
2410
|
+
printWriteResult(result, `Transfer workflow created: ${result.workflow_id ?? "OK"}`, opts.json);
|
|
1791
2411
|
} catch (err) {
|
|
1792
2412
|
printError(`Failed to create transfer workflow: ${err}`);
|
|
1793
2413
|
process.exit(1);
|
|
@@ -1798,15 +2418,19 @@ async function distributeCommand(opts) {
|
|
|
1798
2418
|
const eid = resolveEntityId(cfg, opts.entityId);
|
|
1799
2419
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
1800
2420
|
try {
|
|
1801
|
-
const
|
|
2421
|
+
const payload = {
|
|
1802
2422
|
entity_id: eid,
|
|
1803
2423
|
total_amount_cents: opts.amount,
|
|
1804
2424
|
distribution_type: opts.type,
|
|
1805
2425
|
description: opts.description
|
|
1806
|
-
}
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
2426
|
+
};
|
|
2427
|
+
if (opts.dryRun) {
|
|
2428
|
+
printDryRun("cap_table.distribute", payload);
|
|
2429
|
+
return;
|
|
2430
|
+
}
|
|
2431
|
+
const result = await client.calculateDistribution(payload);
|
|
2432
|
+
printWriteResult(result, `Distribution calculated: ${result.distribution_id ?? "OK"}`, opts.json);
|
|
2433
|
+
} catch (err) {
|
|
1810
2434
|
printError(`Failed to calculate distribution: ${err}`);
|
|
1811
2435
|
process.exit(1);
|
|
1812
2436
|
}
|
|
@@ -1816,18 +2440,56 @@ async function startRoundCommand(opts) {
|
|
|
1816
2440
|
const eid = resolveEntityId(cfg, opts.entityId);
|
|
1817
2441
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
1818
2442
|
try {
|
|
1819
|
-
const
|
|
2443
|
+
const payload = {
|
|
1820
2444
|
entity_id: eid,
|
|
1821
2445
|
name: opts.name,
|
|
1822
2446
|
issuer_legal_entity_id: opts.issuerLegalEntityId
|
|
1823
|
-
}
|
|
1824
|
-
|
|
1825
|
-
|
|
2447
|
+
};
|
|
2448
|
+
if (opts.dryRun) {
|
|
2449
|
+
printDryRun("cap_table.start_round", payload);
|
|
2450
|
+
return;
|
|
2451
|
+
}
|
|
2452
|
+
const result = await client.startEquityRound(payload);
|
|
2453
|
+
printWriteResult(result, `Round started: ${result.round_id ?? "OK"}`, opts.json);
|
|
1826
2454
|
} catch (err) {
|
|
1827
2455
|
printError(`Failed to start round: ${err}`);
|
|
1828
2456
|
process.exit(1);
|
|
1829
2457
|
}
|
|
1830
2458
|
}
|
|
2459
|
+
async function createInstrumentCommand(opts) {
|
|
2460
|
+
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
2461
|
+
const eid = resolveEntityId(cfg, opts.entityId);
|
|
2462
|
+
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
2463
|
+
try {
|
|
2464
|
+
let issuerLegalEntityId = opts.issuerLegalEntityId;
|
|
2465
|
+
if (!issuerLegalEntityId) {
|
|
2466
|
+
const capTable = await client.getCapTable(eid);
|
|
2467
|
+
issuerLegalEntityId = capTable.issuer_legal_entity_id;
|
|
2468
|
+
}
|
|
2469
|
+
if (!issuerLegalEntityId) {
|
|
2470
|
+
throw new Error("No issuer legal entity found. Has this entity been formed with a cap table?");
|
|
2471
|
+
}
|
|
2472
|
+
const terms = opts.termsJson ? JSON.parse(opts.termsJson) : {};
|
|
2473
|
+
const payload = {
|
|
2474
|
+
entity_id: eid,
|
|
2475
|
+
issuer_legal_entity_id: issuerLegalEntityId,
|
|
2476
|
+
kind: opts.kind,
|
|
2477
|
+
symbol: opts.symbol,
|
|
2478
|
+
terms
|
|
2479
|
+
};
|
|
2480
|
+
if (opts.authorizedUnits != null) payload.authorized_units = opts.authorizedUnits;
|
|
2481
|
+
if (opts.issuePriceCents != null) payload.issue_price_cents = opts.issuePriceCents;
|
|
2482
|
+
if (opts.dryRun) {
|
|
2483
|
+
printDryRun("cap_table.create_instrument", payload);
|
|
2484
|
+
return;
|
|
2485
|
+
}
|
|
2486
|
+
const result = await client.createInstrument(payload);
|
|
2487
|
+
printWriteResult(result, `Instrument created: ${result.instrument_id ?? "OK"}`, opts.json);
|
|
2488
|
+
} catch (err) {
|
|
2489
|
+
printError(`Failed to create instrument: ${err}`);
|
|
2490
|
+
process.exit(1);
|
|
2491
|
+
}
|
|
2492
|
+
}
|
|
1831
2493
|
async function addSecurityCommand(opts) {
|
|
1832
2494
|
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
1833
2495
|
const eid = resolveEntityId(cfg, opts.entityId);
|
|
@@ -1843,9 +2505,12 @@ async function addSecurityCommand(opts) {
|
|
|
1843
2505
|
if (opts.email) body.email = opts.email;
|
|
1844
2506
|
if (opts.principalCents) body.principal_cents = opts.principalCents;
|
|
1845
2507
|
if (opts.grantType) body.grant_type = opts.grantType;
|
|
2508
|
+
if (opts.dryRun) {
|
|
2509
|
+
printDryRun("cap_table.add_security", { round_id: opts.roundId, ...body });
|
|
2510
|
+
return;
|
|
2511
|
+
}
|
|
1846
2512
|
const result = await client.addRoundSecurity(opts.roundId, body);
|
|
1847
|
-
|
|
1848
|
-
printJson(result);
|
|
2513
|
+
printWriteResult(result, `Security added for ${opts.recipientName}`, opts.json);
|
|
1849
2514
|
} catch (err) {
|
|
1850
2515
|
printError(`Failed to add security: ${err}`);
|
|
1851
2516
|
process.exit(1);
|
|
@@ -1856,9 +2521,25 @@ async function issueRoundCommand(opts) {
|
|
|
1856
2521
|
const eid = resolveEntityId(cfg, opts.entityId);
|
|
1857
2522
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
1858
2523
|
try {
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
2524
|
+
if (opts.dryRun) {
|
|
2525
|
+
printDryRun("cap_table.issue_round", {
|
|
2526
|
+
entity_id: eid,
|
|
2527
|
+
round_id: opts.roundId,
|
|
2528
|
+
meeting_id: opts.meetingId,
|
|
2529
|
+
resolution_id: opts.resolutionId
|
|
2530
|
+
});
|
|
2531
|
+
return;
|
|
2532
|
+
}
|
|
2533
|
+
if ((!opts.meetingId || !opts.resolutionId) && await entityHasActiveBoard(client, eid)) {
|
|
2534
|
+
throw new Error(
|
|
2535
|
+
"Board approval is required before issuing this round. Pass --meeting-id and --resolution-id from a passed board vote."
|
|
2536
|
+
);
|
|
2537
|
+
}
|
|
2538
|
+
const body = { entity_id: eid };
|
|
2539
|
+
if (opts.meetingId) body.meeting_id = opts.meetingId;
|
|
2540
|
+
if (opts.resolutionId) body.resolution_id = opts.resolutionId;
|
|
2541
|
+
const result = await client.issueRound(opts.roundId, body);
|
|
2542
|
+
printWriteResult(result, "Round issued and closed", opts.json);
|
|
1862
2543
|
} catch (err) {
|
|
1863
2544
|
printError(`Failed to issue round: ${err}`);
|
|
1864
2545
|
process.exit(1);
|
|
@@ -1877,9 +2558,12 @@ async function createValuationCommand(opts) {
|
|
|
1877
2558
|
};
|
|
1878
2559
|
if (opts.fmv != null) body.fmv_per_share_cents = opts.fmv;
|
|
1879
2560
|
if (opts.enterpriseValue != null) body.enterprise_value_cents = opts.enterpriseValue;
|
|
2561
|
+
if (opts.dryRun) {
|
|
2562
|
+
printDryRun("cap_table.create_valuation", body);
|
|
2563
|
+
return;
|
|
2564
|
+
}
|
|
1880
2565
|
const result = await client.createValuation(body);
|
|
1881
|
-
|
|
1882
|
-
printJson(result);
|
|
2566
|
+
printWriteResult(result, `Valuation created: ${result.valuation_id ?? "OK"}`, opts.json);
|
|
1883
2567
|
} catch (err) {
|
|
1884
2568
|
printError(`Failed to create valuation: ${err}`);
|
|
1885
2569
|
process.exit(1);
|
|
@@ -1890,7 +2574,15 @@ async function submitValuationCommand(opts) {
|
|
|
1890
2574
|
const eid = resolveEntityId(cfg, opts.entityId);
|
|
1891
2575
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
1892
2576
|
try {
|
|
2577
|
+
if (opts.dryRun) {
|
|
2578
|
+
printDryRun("cap_table.submit_valuation", { entity_id: eid, valuation_id: opts.valuationId });
|
|
2579
|
+
return;
|
|
2580
|
+
}
|
|
1893
2581
|
const result = await client.submitValuationForApproval(opts.valuationId, eid);
|
|
2582
|
+
if (opts.json) {
|
|
2583
|
+
printJson(result);
|
|
2584
|
+
return;
|
|
2585
|
+
}
|
|
1894
2586
|
printSuccess(`Valuation submitted for approval: ${result.valuation_id ?? "OK"}`);
|
|
1895
2587
|
if (result.meeting_id) console.log(` Meeting: ${result.meeting_id}`);
|
|
1896
2588
|
if (result.agenda_item_id) console.log(` Agenda Item: ${result.agenda_item_id}`);
|
|
@@ -1910,9 +2602,16 @@ async function approveValuationCommand(opts) {
|
|
|
1910
2602
|
const eid = resolveEntityId(cfg, opts.entityId);
|
|
1911
2603
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
1912
2604
|
try {
|
|
2605
|
+
if (opts.dryRun) {
|
|
2606
|
+
printDryRun("cap_table.approve_valuation", {
|
|
2607
|
+
entity_id: eid,
|
|
2608
|
+
valuation_id: opts.valuationId,
|
|
2609
|
+
resolution_id: opts.resolutionId
|
|
2610
|
+
});
|
|
2611
|
+
return;
|
|
2612
|
+
}
|
|
1913
2613
|
const result = await client.approveValuation(opts.valuationId, eid, opts.resolutionId);
|
|
1914
|
-
|
|
1915
|
-
printJson(result);
|
|
2614
|
+
printWriteResult(result, `Valuation approved: ${result.valuation_id ?? "OK"}`, opts.json);
|
|
1916
2615
|
} catch (err) {
|
|
1917
2616
|
const msg = String(err);
|
|
1918
2617
|
if (msg.includes("400")) {
|
|
@@ -1924,16 +2623,16 @@ async function approveValuationCommand(opts) {
|
|
|
1924
2623
|
}
|
|
1925
2624
|
}
|
|
1926
2625
|
function print409a(data) {
|
|
1927
|
-
console.log(
|
|
1928
|
-
console.log(
|
|
1929
|
-
console.log(
|
|
2626
|
+
console.log(chalk6.green("\u2500".repeat(40)));
|
|
2627
|
+
console.log(chalk6.green.bold(" 409A Valuation"));
|
|
2628
|
+
console.log(chalk6.green("\u2500".repeat(40)));
|
|
1930
2629
|
const fmv = typeof data.fmv_per_share_cents === "number" ? data.fmv_per_share_cents / 100 : data.fmv_per_share;
|
|
1931
2630
|
const enterpriseValue = typeof data.enterprise_value_cents === "number" ? data.enterprise_value_cents / 100 : data.enterprise_value;
|
|
1932
|
-
console.log(` ${
|
|
1933
|
-
console.log(` ${
|
|
1934
|
-
console.log(` ${
|
|
1935
|
-
if (data.provider) console.log(` ${
|
|
1936
|
-
console.log(
|
|
2631
|
+
console.log(` ${chalk6.bold("FMV/Share:")} $${fmv ?? "N/A"}`);
|
|
2632
|
+
console.log(` ${chalk6.bold("Enterprise Value:")} $${enterpriseValue ?? "N/A"}`);
|
|
2633
|
+
console.log(` ${chalk6.bold("Valuation Date:")} ${data.effective_date ?? data.valuation_date ?? "N/A"}`);
|
|
2634
|
+
if (data.provider) console.log(` ${chalk6.bold("Provider:")} ${data.provider}`);
|
|
2635
|
+
console.log(chalk6.green("\u2500".repeat(40)));
|
|
1937
2636
|
}
|
|
1938
2637
|
var init_cap_table = __esm({
|
|
1939
2638
|
"src/commands/cap-table.ts"() {
|
|
@@ -1966,8 +2665,7 @@ async function financeInvoiceCommand(opts) {
|
|
|
1966
2665
|
due_date: opts.dueDate,
|
|
1967
2666
|
description: opts.description
|
|
1968
2667
|
});
|
|
1969
|
-
|
|
1970
|
-
printJson(result);
|
|
2668
|
+
printWriteResult(result, `Invoice created: ${result.invoice_id ?? "OK"}`, opts.json);
|
|
1971
2669
|
} catch (err) {
|
|
1972
2670
|
printError(`Failed to create invoice: ${err}`);
|
|
1973
2671
|
process.exit(1);
|
|
@@ -1983,8 +2681,7 @@ async function financePayrollCommand(opts) {
|
|
|
1983
2681
|
pay_period_start: opts.periodStart,
|
|
1984
2682
|
pay_period_end: opts.periodEnd
|
|
1985
2683
|
});
|
|
1986
|
-
|
|
1987
|
-
printJson(result);
|
|
2684
|
+
printWriteResult(result, `Payroll run created: ${result.payroll_run_id ?? "OK"}`, opts.json);
|
|
1988
2685
|
} catch (err) {
|
|
1989
2686
|
printError(`Failed to run payroll: ${err}`);
|
|
1990
2687
|
process.exit(1);
|
|
@@ -2002,8 +2699,7 @@ async function financePayCommand(opts) {
|
|
|
2002
2699
|
payment_method: opts.method,
|
|
2003
2700
|
description: `Payment via ${opts.method}`
|
|
2004
2701
|
});
|
|
2005
|
-
|
|
2006
|
-
printJson(result);
|
|
2702
|
+
printWriteResult(result, `Payment submitted: ${result.payment_id ?? "OK"}`, opts.json);
|
|
2007
2703
|
} catch (err) {
|
|
2008
2704
|
printError(`Failed to submit payment: ${err}`);
|
|
2009
2705
|
process.exit(1);
|
|
@@ -2015,8 +2711,7 @@ async function financeOpenAccountCommand(opts) {
|
|
|
2015
2711
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
2016
2712
|
try {
|
|
2017
2713
|
const result = await client.openBankAccount({ entity_id: eid, bank_name: opts.institution });
|
|
2018
|
-
|
|
2019
|
-
printJson(result);
|
|
2714
|
+
printWriteResult(result, `Bank account opened: ${result.account_id ?? "OK"}`, opts.json);
|
|
2020
2715
|
} catch (err) {
|
|
2021
2716
|
printError(`Failed to open bank account: ${err}`);
|
|
2022
2717
|
process.exit(1);
|
|
@@ -2036,8 +2731,7 @@ async function financeClassifyContractorCommand(opts) {
|
|
|
2036
2731
|
duration_months: opts.duration,
|
|
2037
2732
|
provides_tools: opts.providesTools
|
|
2038
2733
|
});
|
|
2039
|
-
|
|
2040
|
-
printJson(result);
|
|
2734
|
+
printWriteResult(result, `Classification: ${result.risk_level ?? "OK"}`, opts.json);
|
|
2041
2735
|
} catch (err) {
|
|
2042
2736
|
printError(`Failed to classify contractor: ${err}`);
|
|
2043
2737
|
process.exit(1);
|
|
@@ -2053,8 +2747,7 @@ async function financeReconcileCommand(opts) {
|
|
|
2053
2747
|
start_date: opts.startDate,
|
|
2054
2748
|
end_date: opts.endDate
|
|
2055
2749
|
});
|
|
2056
|
-
|
|
2057
|
-
printJson(result);
|
|
2750
|
+
printWriteResult(result, `Ledger reconciled: ${result.reconciliation_id ?? "OK"}`, opts.json);
|
|
2058
2751
|
} catch (err) {
|
|
2059
2752
|
printError(`Failed to reconcile ledger: ${err}`);
|
|
2060
2753
|
process.exit(1);
|
|
@@ -2081,6 +2774,7 @@ __export(governance_exports, {
|
|
|
2081
2774
|
governanceCreateBodyCommand: () => governanceCreateBodyCommand,
|
|
2082
2775
|
governanceListCommand: () => governanceListCommand,
|
|
2083
2776
|
governanceMeetingsCommand: () => governanceMeetingsCommand,
|
|
2777
|
+
governanceOpenMeetingCommand: () => governanceOpenMeetingCommand,
|
|
2084
2778
|
governanceResolutionsCommand: () => governanceResolutionsCommand,
|
|
2085
2779
|
governanceSeatsCommand: () => governanceSeatsCommand,
|
|
2086
2780
|
governanceVoteCommand: () => governanceVoteCommand,
|
|
@@ -2088,25 +2782,34 @@ __export(governance_exports, {
|
|
|
2088
2782
|
sendNoticeCommand: () => sendNoticeCommand,
|
|
2089
2783
|
writtenConsentCommand: () => writtenConsentCommand
|
|
2090
2784
|
});
|
|
2091
|
-
import
|
|
2785
|
+
import chalk7 from "chalk";
|
|
2092
2786
|
async function governanceCreateBodyCommand(opts) {
|
|
2093
2787
|
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
2094
2788
|
const eid = resolveEntityId(cfg, opts.entityId);
|
|
2095
2789
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
2096
2790
|
try {
|
|
2097
|
-
const
|
|
2791
|
+
const payload = {
|
|
2098
2792
|
entity_id: eid,
|
|
2099
2793
|
body_type: opts.bodyType,
|
|
2100
2794
|
name: opts.name,
|
|
2101
2795
|
quorum_rule: opts.quorum,
|
|
2102
2796
|
voting_method: opts.voting
|
|
2103
|
-
}
|
|
2797
|
+
};
|
|
2798
|
+
if (opts.dryRun) {
|
|
2799
|
+
printDryRun("governance.create_body", payload);
|
|
2800
|
+
return;
|
|
2801
|
+
}
|
|
2802
|
+
const result = await client.createGovernanceBody(payload);
|
|
2104
2803
|
const bodyId = result.body_id ?? "OK";
|
|
2804
|
+
if (opts.json) {
|
|
2805
|
+
printJson(result);
|
|
2806
|
+
return;
|
|
2807
|
+
}
|
|
2105
2808
|
printSuccess(`Governance body created: ${bodyId}`);
|
|
2106
2809
|
printJson(result);
|
|
2107
|
-
console.log(
|
|
2108
|
-
console.log(
|
|
2109
|
-
console.log(
|
|
2810
|
+
console.log(chalk7.dim("\n Next steps:"));
|
|
2811
|
+
console.log(chalk7.dim(` corp governance add-seat ${bodyId} --holder <contact-id>`));
|
|
2812
|
+
console.log(chalk7.dim(` corp governance seats ${bodyId}`));
|
|
2110
2813
|
} catch (err) {
|
|
2111
2814
|
printError(`Failed to create governance body: ${err}`);
|
|
2112
2815
|
process.exit(1);
|
|
@@ -2118,7 +2821,15 @@ async function governanceAddSeatCommand(bodyId, opts) {
|
|
|
2118
2821
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
2119
2822
|
try {
|
|
2120
2823
|
const data = { holder_id: opts.holder, role: opts.role ?? "member" };
|
|
2824
|
+
if (opts.dryRun) {
|
|
2825
|
+
printDryRun("governance.add_seat", { entity_id: eid, body_id: bodyId, ...data });
|
|
2826
|
+
return;
|
|
2827
|
+
}
|
|
2121
2828
|
const result = await client.createGovernanceSeat(bodyId, eid, data);
|
|
2829
|
+
if (opts.json) {
|
|
2830
|
+
printJson(result);
|
|
2831
|
+
return;
|
|
2832
|
+
}
|
|
2122
2833
|
printSuccess(`Seat added: ${result.seat_id ?? "OK"}`);
|
|
2123
2834
|
printJson(result);
|
|
2124
2835
|
} catch (err) {
|
|
@@ -2187,38 +2898,87 @@ async function governanceConveneCommand(opts) {
|
|
|
2187
2898
|
const eid = resolveEntityId(cfg, opts.entityId);
|
|
2188
2899
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
2189
2900
|
try {
|
|
2190
|
-
const
|
|
2901
|
+
const payload = {
|
|
2191
2902
|
entity_id: eid,
|
|
2192
2903
|
body_id: opts.body,
|
|
2193
2904
|
meeting_type: opts.meetingType,
|
|
2194
2905
|
title: opts.title,
|
|
2195
|
-
scheduled_date: opts.date,
|
|
2196
2906
|
agenda_item_titles: opts.agenda
|
|
2197
|
-
}
|
|
2907
|
+
};
|
|
2908
|
+
if (opts.date) payload.scheduled_date = opts.date;
|
|
2909
|
+
if (opts.dryRun) {
|
|
2910
|
+
printDryRun("governance.schedule_meeting", payload);
|
|
2911
|
+
return;
|
|
2912
|
+
}
|
|
2913
|
+
const result = await client.scheduleMeeting(payload);
|
|
2198
2914
|
const meetingId = result.meeting_id ?? "OK";
|
|
2915
|
+
if (opts.json) {
|
|
2916
|
+
printJson(result);
|
|
2917
|
+
return;
|
|
2918
|
+
}
|
|
2199
2919
|
printSuccess(`Meeting scheduled: ${meetingId}`);
|
|
2200
2920
|
printJson(result);
|
|
2201
|
-
console.log(
|
|
2202
|
-
console.log(
|
|
2203
|
-
console.log(
|
|
2921
|
+
console.log(chalk7.dim("\n Next steps:"));
|
|
2922
|
+
console.log(chalk7.dim(` corp governance notice ${meetingId}`));
|
|
2923
|
+
console.log(chalk7.dim(` corp governance open ${meetingId} --present-seat <seat-id>`));
|
|
2924
|
+
console.log(chalk7.dim(` corp governance agenda-items ${meetingId}`));
|
|
2204
2925
|
} catch (err) {
|
|
2205
2926
|
printError(`Failed to schedule meeting: ${err}`);
|
|
2206
2927
|
process.exit(1);
|
|
2207
2928
|
}
|
|
2208
2929
|
}
|
|
2930
|
+
async function governanceOpenMeetingCommand(meetingId, opts) {
|
|
2931
|
+
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
2932
|
+
const eid = resolveEntityId(cfg, opts.entityId);
|
|
2933
|
+
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
2934
|
+
try {
|
|
2935
|
+
const payload = { present_seat_ids: opts.presentSeat };
|
|
2936
|
+
if (opts.dryRun) {
|
|
2937
|
+
printDryRun("governance.open_meeting", { entity_id: eid, meeting_id: meetingId, ...payload });
|
|
2938
|
+
return;
|
|
2939
|
+
}
|
|
2940
|
+
const result = await client.conveneMeeting(meetingId, eid, payload);
|
|
2941
|
+
if (opts.json) {
|
|
2942
|
+
printJson(result);
|
|
2943
|
+
return;
|
|
2944
|
+
}
|
|
2945
|
+
printSuccess(`Meeting opened: ${meetingId}`);
|
|
2946
|
+
printJson(result);
|
|
2947
|
+
} catch (err) {
|
|
2948
|
+
printError(`Failed to open meeting: ${err}`);
|
|
2949
|
+
process.exit(1);
|
|
2950
|
+
}
|
|
2951
|
+
}
|
|
2209
2952
|
async function governanceVoteCommand(meetingId, itemId, opts) {
|
|
2210
2953
|
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
2211
2954
|
const eid = resolveEntityId(cfg, opts.entityId);
|
|
2212
2955
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
2213
2956
|
try {
|
|
2214
|
-
const
|
|
2957
|
+
const payload = {
|
|
2215
2958
|
voter_id: opts.voter,
|
|
2216
2959
|
vote_value: opts.vote
|
|
2217
|
-
}
|
|
2960
|
+
};
|
|
2961
|
+
if (opts.dryRun) {
|
|
2962
|
+
printDryRun("governance.cast_vote", { entity_id: eid, meeting_id: meetingId, agenda_item_id: itemId, ...payload });
|
|
2963
|
+
return;
|
|
2964
|
+
}
|
|
2965
|
+
const result = await client.castVote(eid, meetingId, itemId, payload);
|
|
2966
|
+
if (opts.json) {
|
|
2967
|
+
printJson(result);
|
|
2968
|
+
return;
|
|
2969
|
+
}
|
|
2218
2970
|
printSuccess(`Vote cast: ${result.vote_id ?? "OK"}`);
|
|
2219
2971
|
printJson(result);
|
|
2220
2972
|
} catch (err) {
|
|
2221
|
-
|
|
2973
|
+
const message = String(err);
|
|
2974
|
+
if (message.includes("voting session is not open")) {
|
|
2975
|
+
printError(
|
|
2976
|
+
`Failed to cast vote: ${err}
|
|
2977
|
+
Open the meeting first: corp governance open ${meetingId} --present-seat <seat-id>`
|
|
2978
|
+
);
|
|
2979
|
+
} else {
|
|
2980
|
+
printError(`Failed to cast vote: ${err}`);
|
|
2981
|
+
}
|
|
2222
2982
|
process.exit(1);
|
|
2223
2983
|
}
|
|
2224
2984
|
}
|
|
@@ -2227,7 +2987,15 @@ async function sendNoticeCommand(meetingId, opts) {
|
|
|
2227
2987
|
const eid = resolveEntityId(cfg, opts.entityId);
|
|
2228
2988
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
2229
2989
|
try {
|
|
2990
|
+
if (opts.dryRun) {
|
|
2991
|
+
printDryRun("governance.send_notice", { entity_id: eid, meeting_id: meetingId });
|
|
2992
|
+
return;
|
|
2993
|
+
}
|
|
2230
2994
|
const result = await client.sendNotice(meetingId, eid);
|
|
2995
|
+
if (opts.json) {
|
|
2996
|
+
printJson(result);
|
|
2997
|
+
return;
|
|
2998
|
+
}
|
|
2231
2999
|
printSuccess(`Notice sent for meeting ${meetingId}`);
|
|
2232
3000
|
printJson(result);
|
|
2233
3001
|
} catch (err) {
|
|
@@ -2240,7 +3008,15 @@ async function adjournMeetingCommand(meetingId, opts) {
|
|
|
2240
3008
|
const eid = resolveEntityId(cfg, opts.entityId);
|
|
2241
3009
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
2242
3010
|
try {
|
|
3011
|
+
if (opts.dryRun) {
|
|
3012
|
+
printDryRun("governance.adjourn_meeting", { entity_id: eid, meeting_id: meetingId });
|
|
3013
|
+
return;
|
|
3014
|
+
}
|
|
2243
3015
|
const result = await client.adjournMeeting(meetingId, eid);
|
|
3016
|
+
if (opts.json) {
|
|
3017
|
+
printJson(result);
|
|
3018
|
+
return;
|
|
3019
|
+
}
|
|
2244
3020
|
printSuccess(`Meeting ${meetingId} adjourned`);
|
|
2245
3021
|
printJson(result);
|
|
2246
3022
|
} catch (err) {
|
|
@@ -2253,7 +3029,15 @@ async function cancelMeetingCommand(meetingId, opts) {
|
|
|
2253
3029
|
const eid = resolveEntityId(cfg, opts.entityId);
|
|
2254
3030
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
2255
3031
|
try {
|
|
3032
|
+
if (opts.dryRun) {
|
|
3033
|
+
printDryRun("governance.cancel_meeting", { entity_id: eid, meeting_id: meetingId });
|
|
3034
|
+
return;
|
|
3035
|
+
}
|
|
2256
3036
|
const result = await client.cancelMeeting(meetingId, eid);
|
|
3037
|
+
if (opts.json) {
|
|
3038
|
+
printJson(result);
|
|
3039
|
+
return;
|
|
3040
|
+
}
|
|
2257
3041
|
printSuccess(`Meeting ${meetingId} cancelled`);
|
|
2258
3042
|
printJson(result);
|
|
2259
3043
|
} catch (err) {
|
|
@@ -2266,10 +3050,19 @@ async function finalizeAgendaItemCommand(meetingId, itemId, opts) {
|
|
|
2266
3050
|
const eid = resolveEntityId(cfg, opts.entityId);
|
|
2267
3051
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
2268
3052
|
try {
|
|
2269
|
-
const
|
|
3053
|
+
const payload = {
|
|
2270
3054
|
entity_id: eid,
|
|
2271
3055
|
status: opts.status
|
|
2272
|
-
}
|
|
3056
|
+
};
|
|
3057
|
+
if (opts.dryRun) {
|
|
3058
|
+
printDryRun("governance.finalize_agenda_item", { meeting_id: meetingId, agenda_item_id: itemId, ...payload });
|
|
3059
|
+
return;
|
|
3060
|
+
}
|
|
3061
|
+
const result = await client.finalizeAgendaItem(meetingId, itemId, payload);
|
|
3062
|
+
if (opts.json) {
|
|
3063
|
+
printJson(result);
|
|
3064
|
+
return;
|
|
3065
|
+
}
|
|
2273
3066
|
printSuccess(`Agenda item ${itemId} finalized as ${opts.status}`);
|
|
2274
3067
|
printJson(result);
|
|
2275
3068
|
} catch (err) {
|
|
@@ -2282,9 +3075,23 @@ async function computeResolutionCommand(meetingId, itemId, opts) {
|
|
|
2282
3075
|
const eid = resolveEntityId(cfg, opts.entityId);
|
|
2283
3076
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
2284
3077
|
try {
|
|
2285
|
-
const
|
|
3078
|
+
const payload = {
|
|
2286
3079
|
resolution_text: opts.text
|
|
2287
|
-
}
|
|
3080
|
+
};
|
|
3081
|
+
if (opts.dryRun) {
|
|
3082
|
+
printDryRun("governance.compute_resolution", {
|
|
3083
|
+
entity_id: eid,
|
|
3084
|
+
meeting_id: meetingId,
|
|
3085
|
+
agenda_item_id: itemId,
|
|
3086
|
+
...payload
|
|
3087
|
+
});
|
|
3088
|
+
return;
|
|
3089
|
+
}
|
|
3090
|
+
const result = await client.computeResolution(meetingId, itemId, eid, payload);
|
|
3091
|
+
if (opts.json) {
|
|
3092
|
+
printJson(result);
|
|
3093
|
+
return;
|
|
3094
|
+
}
|
|
2288
3095
|
printSuccess(`Resolution computed for agenda item ${itemId}`);
|
|
2289
3096
|
printJson(result);
|
|
2290
3097
|
} catch (err) {
|
|
@@ -2297,18 +3104,27 @@ async function writtenConsentCommand(opts) {
|
|
|
2297
3104
|
const eid = resolveEntityId(cfg, opts.entityId);
|
|
2298
3105
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
2299
3106
|
try {
|
|
2300
|
-
const
|
|
3107
|
+
const payload = {
|
|
2301
3108
|
entity_id: eid,
|
|
2302
3109
|
body_id: opts.body,
|
|
2303
3110
|
title: opts.title,
|
|
2304
3111
|
description: opts.description
|
|
2305
|
-
}
|
|
3112
|
+
};
|
|
3113
|
+
if (opts.dryRun) {
|
|
3114
|
+
printDryRun("governance.written_consent", payload);
|
|
3115
|
+
return;
|
|
3116
|
+
}
|
|
3117
|
+
const result = await client.writtenConsent(payload);
|
|
2306
3118
|
const meetingId = result.meeting_id ?? "OK";
|
|
3119
|
+
if (opts.json) {
|
|
3120
|
+
printJson(result);
|
|
3121
|
+
return;
|
|
3122
|
+
}
|
|
2307
3123
|
printSuccess(`Written consent created: ${meetingId}`);
|
|
2308
3124
|
printJson(result);
|
|
2309
|
-
console.log(
|
|
2310
|
-
console.log(
|
|
2311
|
-
console.log(
|
|
3125
|
+
console.log(chalk7.dim("\n Next steps:"));
|
|
3126
|
+
console.log(chalk7.dim(` corp governance agenda-items ${meetingId}`));
|
|
3127
|
+
console.log(chalk7.dim(` corp governance vote ${meetingId} <item-id> --voter <contact-uuid> --vote for`));
|
|
2312
3128
|
} catch (err) {
|
|
2313
3129
|
printError(`Failed to create written consent: ${err}`);
|
|
2314
3130
|
process.exit(1);
|
|
@@ -2324,10 +3140,10 @@ async function listAgendaItemsCommand(meetingId, opts) {
|
|
|
2324
3140
|
else if (items.length === 0) console.log("No agenda items found.");
|
|
2325
3141
|
else {
|
|
2326
3142
|
const Table4 = (await import("cli-table3")).default;
|
|
2327
|
-
const
|
|
3143
|
+
const chalk13 = (await import("chalk")).default;
|
|
2328
3144
|
console.log(`
|
|
2329
|
-
${
|
|
2330
|
-
const table = new Table4({ head: [
|
|
3145
|
+
${chalk13.bold("Agenda Items")}`);
|
|
3146
|
+
const table = new Table4({ head: [chalk13.dim("ID"), chalk13.dim("Title"), chalk13.dim("Status"), chalk13.dim("Type")] });
|
|
2331
3147
|
for (const item of items) {
|
|
2332
3148
|
table.push([
|
|
2333
3149
|
String(item.item_id ?? item.agenda_item_id ?? item.id ?? "").slice(0, 12),
|
|
@@ -2408,19 +3224,48 @@ async function documentsGenerateCommand(opts) {
|
|
|
2408
3224
|
const eid = resolveEntityId(cfg, opts.entityId);
|
|
2409
3225
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
2410
3226
|
try {
|
|
3227
|
+
const parameters = {};
|
|
3228
|
+
if (opts.baseSalary) {
|
|
3229
|
+
parameters.base_salary = opts.baseSalary;
|
|
3230
|
+
}
|
|
3231
|
+
for (const raw of opts.param ?? []) {
|
|
3232
|
+
const idx = raw.indexOf("=");
|
|
3233
|
+
if (idx <= 0) {
|
|
3234
|
+
throw new Error(`Invalid --param value: ${raw}. Expected key=value.`);
|
|
3235
|
+
}
|
|
3236
|
+
const key = raw.slice(0, idx).trim();
|
|
3237
|
+
const value = raw.slice(idx + 1).trim();
|
|
3238
|
+
if (!key) {
|
|
3239
|
+
throw new Error(`Invalid --param value: ${raw}. Expected key=value.`);
|
|
3240
|
+
}
|
|
3241
|
+
parameters[key] = coerceParamValue(value);
|
|
3242
|
+
}
|
|
2411
3243
|
const result = await client.generateContract({
|
|
2412
3244
|
entity_id: eid,
|
|
2413
3245
|
template_type: opts.template,
|
|
2414
3246
|
counterparty_name: opts.counterparty,
|
|
2415
|
-
effective_date: opts.effectiveDate ?? (/* @__PURE__ */ new Date()).toISOString().slice(0, 10)
|
|
3247
|
+
effective_date: opts.effectiveDate ?? (/* @__PURE__ */ new Date()).toISOString().slice(0, 10),
|
|
3248
|
+
parameters
|
|
2416
3249
|
});
|
|
2417
|
-
|
|
2418
|
-
printJson(result);
|
|
3250
|
+
printWriteResult(result, `Contract generated: ${result.contract_id ?? "OK"}`, opts.json);
|
|
2419
3251
|
} catch (err) {
|
|
2420
3252
|
printError(`Failed to generate contract: ${err}`);
|
|
2421
3253
|
process.exit(1);
|
|
2422
3254
|
}
|
|
2423
3255
|
}
|
|
3256
|
+
function coerceParamValue(raw) {
|
|
3257
|
+
if (raw === "true") return true;
|
|
3258
|
+
if (raw === "false") return false;
|
|
3259
|
+
if (/^-?\d+(\.\d+)?$/.test(raw)) return Number(raw);
|
|
3260
|
+
if (raw.startsWith("{") && raw.endsWith("}") || raw.startsWith("[") && raw.endsWith("]")) {
|
|
3261
|
+
try {
|
|
3262
|
+
return JSON.parse(raw);
|
|
3263
|
+
} catch {
|
|
3264
|
+
return raw;
|
|
3265
|
+
}
|
|
3266
|
+
}
|
|
3267
|
+
return raw;
|
|
3268
|
+
}
|
|
2424
3269
|
async function documentsPreviewPdfCommand(opts) {
|
|
2425
3270
|
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
2426
3271
|
const eid = resolveEntityId(cfg, opts.entityId);
|
|
@@ -2463,8 +3308,7 @@ async function taxFileCommand(opts) {
|
|
|
2463
3308
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
2464
3309
|
try {
|
|
2465
3310
|
const result = await client.fileTaxDocument({ entity_id: eid, document_type: opts.type, tax_year: opts.year });
|
|
2466
|
-
|
|
2467
|
-
printJson(result);
|
|
3311
|
+
printWriteResult(result, `Tax document filed: ${result.filing_id ?? "OK"}`, opts.json);
|
|
2468
3312
|
} catch (err) {
|
|
2469
3313
|
printError(`Failed to file tax document: ${err}`);
|
|
2470
3314
|
process.exit(1);
|
|
@@ -2484,8 +3328,7 @@ async function taxDeadlineCommand(opts) {
|
|
|
2484
3328
|
const recurrence = normalizeRecurrence(opts.recurrence);
|
|
2485
3329
|
if (recurrence) payload.recurrence = recurrence;
|
|
2486
3330
|
const result = await client.trackDeadline(payload);
|
|
2487
|
-
|
|
2488
|
-
printJson(result);
|
|
3331
|
+
printWriteResult(result, `Deadline tracked: ${result.deadline_id ?? "OK"}`, opts.json);
|
|
2489
3332
|
} catch (err) {
|
|
2490
3333
|
printError(`Failed to track deadline: ${err}`);
|
|
2491
3334
|
process.exit(1);
|
|
@@ -2513,7 +3356,9 @@ __export(agents_exports, {
|
|
|
2513
3356
|
agentsShowCommand: () => agentsShowCommand,
|
|
2514
3357
|
agentsSkillCommand: () => agentsSkillCommand
|
|
2515
3358
|
});
|
|
2516
|
-
import
|
|
3359
|
+
import chalk8 from "chalk";
|
|
3360
|
+
import { readFileSync as readFileSync2, realpathSync } from "fs";
|
|
3361
|
+
import { relative, resolve } from "path";
|
|
2517
3362
|
async function agentsListCommand(opts) {
|
|
2518
3363
|
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
2519
3364
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
@@ -2536,22 +3381,22 @@ async function agentsShowCommand(agentId, opts) {
|
|
|
2536
3381
|
printJson(agent);
|
|
2537
3382
|
return;
|
|
2538
3383
|
}
|
|
2539
|
-
console.log(
|
|
2540
|
-
console.log(
|
|
2541
|
-
console.log(
|
|
2542
|
-
console.log(` ${
|
|
2543
|
-
console.log(` ${
|
|
2544
|
-
console.log(` ${
|
|
2545
|
-
console.log(` ${
|
|
3384
|
+
console.log(chalk8.magenta("\u2500".repeat(40)));
|
|
3385
|
+
console.log(chalk8.magenta.bold(" Agent Detail"));
|
|
3386
|
+
console.log(chalk8.magenta("\u2500".repeat(40)));
|
|
3387
|
+
console.log(` ${chalk8.bold("Name:")} ${agent.name ?? "N/A"}`);
|
|
3388
|
+
console.log(` ${chalk8.bold("Status:")} ${agent.status ?? "N/A"}`);
|
|
3389
|
+
console.log(` ${chalk8.bold("Model:")} ${agent.model ?? "N/A"}`);
|
|
3390
|
+
console.log(` ${chalk8.bold("ID:")} ${agent.agent_id ?? "N/A"}`);
|
|
2546
3391
|
if (agent.system_prompt) {
|
|
2547
3392
|
let prompt = String(agent.system_prompt);
|
|
2548
3393
|
if (prompt.length > 100) prompt = prompt.slice(0, 97) + "...";
|
|
2549
|
-
console.log(` ${
|
|
3394
|
+
console.log(` ${chalk8.bold("Prompt:")} ${prompt}`);
|
|
2550
3395
|
}
|
|
2551
3396
|
if (agent.skills && Array.isArray(agent.skills) && agent.skills.length > 0) {
|
|
2552
|
-
console.log(` ${
|
|
3397
|
+
console.log(` ${chalk8.bold("Skills:")} ${agent.skills.map((s2) => s2.name ?? "?").join(", ")}`);
|
|
2553
3398
|
}
|
|
2554
|
-
console.log(
|
|
3399
|
+
console.log(chalk8.magenta("\u2500".repeat(40)));
|
|
2555
3400
|
} catch (err) {
|
|
2556
3401
|
printError(`Failed to fetch agent: ${err}`);
|
|
2557
3402
|
process.exit(1);
|
|
@@ -2564,52 +3409,78 @@ async function agentsCreateCommand(opts) {
|
|
|
2564
3409
|
const data = { name: opts.name, system_prompt: opts.prompt };
|
|
2565
3410
|
if (opts.model) data.model = opts.model;
|
|
2566
3411
|
const result = await client.createAgent(data);
|
|
2567
|
-
|
|
2568
|
-
printJson(result);
|
|
3412
|
+
printWriteResult(result, `Agent created: ${result.agent_id ?? result.id ?? "OK"}`, opts.json);
|
|
2569
3413
|
} catch (err) {
|
|
2570
3414
|
printError(`Failed to create agent: ${err}`);
|
|
2571
3415
|
process.exit(1);
|
|
2572
3416
|
}
|
|
2573
3417
|
}
|
|
2574
|
-
async function agentsPauseCommand(agentId) {
|
|
3418
|
+
async function agentsPauseCommand(agentId, opts) {
|
|
2575
3419
|
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
2576
3420
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
2577
3421
|
try {
|
|
2578
|
-
await client.updateAgent(agentId, { status: "paused" });
|
|
2579
|
-
|
|
3422
|
+
const result = await client.updateAgent(agentId, { status: "paused" });
|
|
3423
|
+
printWriteResult(result, `Agent ${agentId} paused.`, opts.json);
|
|
2580
3424
|
} catch (err) {
|
|
2581
3425
|
printError(`Failed to pause agent: ${err}`);
|
|
2582
3426
|
process.exit(1);
|
|
2583
3427
|
}
|
|
2584
3428
|
}
|
|
2585
|
-
async function agentsResumeCommand(agentId) {
|
|
3429
|
+
async function agentsResumeCommand(agentId, opts) {
|
|
2586
3430
|
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
2587
3431
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
2588
3432
|
try {
|
|
2589
|
-
await client.updateAgent(agentId, { status: "active" });
|
|
2590
|
-
|
|
3433
|
+
const result = await client.updateAgent(agentId, { status: "active" });
|
|
3434
|
+
printWriteResult(result, `Agent ${agentId} resumed.`, opts.json);
|
|
2591
3435
|
} catch (err) {
|
|
2592
3436
|
printError(`Failed to resume agent: ${err}`);
|
|
2593
3437
|
process.exit(1);
|
|
2594
3438
|
}
|
|
2595
3439
|
}
|
|
2596
|
-
async function agentsDeleteCommand(agentId) {
|
|
3440
|
+
async function agentsDeleteCommand(agentId, opts) {
|
|
2597
3441
|
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
2598
3442
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
2599
3443
|
try {
|
|
2600
|
-
await client.deleteAgent(agentId);
|
|
2601
|
-
|
|
3444
|
+
const result = await client.deleteAgent(agentId);
|
|
3445
|
+
printWriteResult(result, `Agent ${agentId} deleted.`, opts.json);
|
|
2602
3446
|
} catch (err) {
|
|
2603
3447
|
printError(`Failed to delete agent: ${err}`);
|
|
2604
3448
|
process.exit(1);
|
|
2605
3449
|
}
|
|
2606
3450
|
}
|
|
3451
|
+
function resolveTextInput(inlineText, filePath, label, required = false) {
|
|
3452
|
+
if (inlineText && filePath) {
|
|
3453
|
+
throw new Error(`Pass either --${label} or --${label}-file, not both.`);
|
|
3454
|
+
}
|
|
3455
|
+
if (filePath) {
|
|
3456
|
+
if (process.env.CORP_ALLOW_UNSAFE_FILE_INPUT === "1") {
|
|
3457
|
+
return readFileSync2(filePath, "utf8");
|
|
3458
|
+
}
|
|
3459
|
+
const resolvedFile = realpathSync(resolve(filePath));
|
|
3460
|
+
const workingTreeRoot = realpathSync(process.cwd());
|
|
3461
|
+
const rel = relative(workingTreeRoot, resolvedFile);
|
|
3462
|
+
if (rel === "" || !rel.startsWith("..") && !rel.startsWith("/")) {
|
|
3463
|
+
return readFileSync2(resolvedFile, "utf8");
|
|
3464
|
+
}
|
|
3465
|
+
throw new Error(
|
|
3466
|
+
`--${label}-file must stay inside the current working directory unless CORP_ALLOW_UNSAFE_FILE_INPUT=1 is set.`
|
|
3467
|
+
);
|
|
3468
|
+
}
|
|
3469
|
+
if (inlineText) {
|
|
3470
|
+
return inlineText;
|
|
3471
|
+
}
|
|
3472
|
+
if (required) {
|
|
3473
|
+
throw new Error(`Provide --${label} or --${label}-file.`);
|
|
3474
|
+
}
|
|
3475
|
+
return void 0;
|
|
3476
|
+
}
|
|
2607
3477
|
async function agentsMessageCommand(agentId, opts) {
|
|
2608
3478
|
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
2609
3479
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
2610
3480
|
try {
|
|
2611
|
-
const
|
|
2612
|
-
|
|
3481
|
+
const body = resolveTextInput(opts.body, opts.bodyFile, "body", true);
|
|
3482
|
+
const result = await client.sendAgentMessage(agentId, body);
|
|
3483
|
+
printWriteResult(result, `Message sent. Execution: ${result.execution_id ?? "OK"}`, opts.json);
|
|
2613
3484
|
} catch (err) {
|
|
2614
3485
|
printError(`Failed to send message: ${err}`);
|
|
2615
3486
|
process.exit(1);
|
|
@@ -2627,13 +3498,17 @@ async function agentsSkillCommand(agentId, opts) {
|
|
|
2627
3498
|
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
2628
3499
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
2629
3500
|
try {
|
|
3501
|
+
const instructions = resolveTextInput(
|
|
3502
|
+
opts.instructions,
|
|
3503
|
+
opts.instructionsFile,
|
|
3504
|
+
"instructions"
|
|
3505
|
+
);
|
|
2630
3506
|
const result = await client.addAgentSkill(agentId, {
|
|
2631
3507
|
name: opts.name,
|
|
2632
3508
|
description: opts.description,
|
|
2633
|
-
parameters:
|
|
3509
|
+
parameters: instructions ? { instructions } : {}
|
|
2634
3510
|
});
|
|
2635
|
-
|
|
2636
|
-
printJson(result);
|
|
3511
|
+
printWriteResult(result, `Skill '${opts.name}' added to agent ${agentId}.`, opts.json);
|
|
2637
3512
|
} catch (err) {
|
|
2638
3513
|
printError(`Failed to add skill: ${err}`);
|
|
2639
3514
|
process.exit(1);
|
|
@@ -2659,7 +3534,7 @@ __export(work_items_exports, {
|
|
|
2659
3534
|
workItemsReleaseCommand: () => workItemsReleaseCommand,
|
|
2660
3535
|
workItemsShowCommand: () => workItemsShowCommand
|
|
2661
3536
|
});
|
|
2662
|
-
import
|
|
3537
|
+
import chalk9 from "chalk";
|
|
2663
3538
|
async function workItemsListCommand(opts) {
|
|
2664
3539
|
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
2665
3540
|
const eid = resolveEntityId(cfg, opts.entityId);
|
|
@@ -2687,24 +3562,24 @@ async function workItemsShowCommand(workItemId, opts) {
|
|
|
2687
3562
|
printJson(w);
|
|
2688
3563
|
return;
|
|
2689
3564
|
}
|
|
2690
|
-
console.log(
|
|
2691
|
-
console.log(
|
|
2692
|
-
console.log(
|
|
2693
|
-
console.log(` ${
|
|
2694
|
-
console.log(` ${
|
|
2695
|
-
console.log(` ${
|
|
2696
|
-
if (w.description) console.log(` ${
|
|
2697
|
-
if (w.deadline) console.log(` ${
|
|
2698
|
-
if (w.asap) console.log(` ${
|
|
2699
|
-
if (w.claimed_by) console.log(` ${
|
|
2700
|
-
if (w.claimed_at) console.log(` ${
|
|
2701
|
-
if (w.claim_ttl_seconds) console.log(` ${
|
|
2702
|
-
if (w.completed_by) console.log(` ${
|
|
2703
|
-
if (w.completed_at) console.log(` ${
|
|
2704
|
-
if (w.result) console.log(` ${
|
|
2705
|
-
if (w.created_by) console.log(` ${
|
|
2706
|
-
console.log(` ${
|
|
2707
|
-
console.log(
|
|
3565
|
+
console.log(chalk9.cyan("\u2500".repeat(40)));
|
|
3566
|
+
console.log(chalk9.cyan.bold(" Work Item Detail"));
|
|
3567
|
+
console.log(chalk9.cyan("\u2500".repeat(40)));
|
|
3568
|
+
console.log(` ${chalk9.bold("Title:")} ${w.title ?? "N/A"}`);
|
|
3569
|
+
console.log(` ${chalk9.bold("Category:")} ${w.category ?? "N/A"}`);
|
|
3570
|
+
console.log(` ${chalk9.bold("Status:")} ${w.effective_status ?? w.status ?? "N/A"}`);
|
|
3571
|
+
if (w.description) console.log(` ${chalk9.bold("Description:")} ${w.description}`);
|
|
3572
|
+
if (w.deadline) console.log(` ${chalk9.bold("Deadline:")} ${w.deadline}`);
|
|
3573
|
+
if (w.asap) console.log(` ${chalk9.bold("Priority:")} ${chalk9.red.bold("ASAP")}`);
|
|
3574
|
+
if (w.claimed_by) console.log(` ${chalk9.bold("Claimed by:")} ${w.claimed_by}`);
|
|
3575
|
+
if (w.claimed_at) console.log(` ${chalk9.bold("Claimed at:")} ${w.claimed_at}`);
|
|
3576
|
+
if (w.claim_ttl_seconds) console.log(` ${chalk9.bold("Claim TTL:")} ${w.claim_ttl_seconds}s`);
|
|
3577
|
+
if (w.completed_by) console.log(` ${chalk9.bold("Completed by:")} ${w.completed_by}`);
|
|
3578
|
+
if (w.completed_at) console.log(` ${chalk9.bold("Completed at:")} ${w.completed_at}`);
|
|
3579
|
+
if (w.result) console.log(` ${chalk9.bold("Result:")} ${w.result}`);
|
|
3580
|
+
if (w.created_by) console.log(` ${chalk9.bold("Created by:")} ${w.created_by}`);
|
|
3581
|
+
console.log(` ${chalk9.bold("Created at:")} ${w.created_at ?? "N/A"}`);
|
|
3582
|
+
console.log(chalk9.cyan("\u2500".repeat(40)));
|
|
2708
3583
|
} catch (err) {
|
|
2709
3584
|
printError(`Failed to fetch work item: ${err}`);
|
|
2710
3585
|
process.exit(1);
|
|
@@ -2725,7 +3600,11 @@ async function workItemsCreateCommand(opts) {
|
|
|
2725
3600
|
if (opts.asap) data.asap = true;
|
|
2726
3601
|
if (opts.createdBy) data.created_by = opts.createdBy;
|
|
2727
3602
|
const result = await client.createWorkItem(eid, data);
|
|
2728
|
-
|
|
3603
|
+
printWriteResult(
|
|
3604
|
+
result,
|
|
3605
|
+
`Work item created: ${result.work_item_id ?? result.id ?? "OK"}`,
|
|
3606
|
+
opts.json
|
|
3607
|
+
);
|
|
2729
3608
|
} catch (err) {
|
|
2730
3609
|
printError(`Failed to create work item: ${err}`);
|
|
2731
3610
|
process.exit(1);
|
|
@@ -2738,8 +3617,8 @@ async function workItemsClaimCommand(workItemId, opts) {
|
|
|
2738
3617
|
try {
|
|
2739
3618
|
const data = { claimed_by: opts.claimedBy };
|
|
2740
3619
|
if (opts.ttl != null) data.ttl_seconds = opts.ttl;
|
|
2741
|
-
await client.claimWorkItem(eid, workItemId, data);
|
|
2742
|
-
|
|
3620
|
+
const result = await client.claimWorkItem(eid, workItemId, data);
|
|
3621
|
+
printWriteResult(result, `Work item ${workItemId} claimed by ${opts.claimedBy}.`, opts.json);
|
|
2743
3622
|
} catch (err) {
|
|
2744
3623
|
printError(`Failed to claim work item: ${err}`);
|
|
2745
3624
|
process.exit(1);
|
|
@@ -2752,8 +3631,8 @@ async function workItemsCompleteCommand(workItemId, opts) {
|
|
|
2752
3631
|
try {
|
|
2753
3632
|
const data = { completed_by: opts.completedBy };
|
|
2754
3633
|
if (opts.result) data.result = opts.result;
|
|
2755
|
-
await client.completeWorkItem(eid, workItemId, data);
|
|
2756
|
-
|
|
3634
|
+
const result = await client.completeWorkItem(eid, workItemId, data);
|
|
3635
|
+
printWriteResult(result, `Work item ${workItemId} completed.`, opts.json);
|
|
2757
3636
|
} catch (err) {
|
|
2758
3637
|
printError(`Failed to complete work item: ${err}`);
|
|
2759
3638
|
process.exit(1);
|
|
@@ -2764,8 +3643,8 @@ async function workItemsReleaseCommand(workItemId, opts) {
|
|
|
2764
3643
|
const eid = resolveEntityId(cfg, opts.entityId);
|
|
2765
3644
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
2766
3645
|
try {
|
|
2767
|
-
await client.releaseWorkItem(eid, workItemId);
|
|
2768
|
-
|
|
3646
|
+
const result = await client.releaseWorkItem(eid, workItemId);
|
|
3647
|
+
printWriteResult(result, `Work item ${workItemId} claim released.`, opts.json);
|
|
2769
3648
|
} catch (err) {
|
|
2770
3649
|
printError(`Failed to release work item: ${err}`);
|
|
2771
3650
|
process.exit(1);
|
|
@@ -2776,8 +3655,8 @@ async function workItemsCancelCommand(workItemId, opts) {
|
|
|
2776
3655
|
const eid = resolveEntityId(cfg, opts.entityId);
|
|
2777
3656
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
2778
3657
|
try {
|
|
2779
|
-
await client.cancelWorkItem(eid, workItemId);
|
|
2780
|
-
|
|
3658
|
+
const result = await client.cancelWorkItem(eid, workItemId);
|
|
3659
|
+
printWriteResult(result, `Work item ${workItemId} cancelled.`, opts.json);
|
|
2781
3660
|
} catch (err) {
|
|
2782
3661
|
printError(`Failed to cancel work item: ${err}`);
|
|
2783
3662
|
process.exit(1);
|
|
@@ -2877,17 +3756,148 @@ __export(form_exports, {
|
|
|
2877
3756
|
formFinalizeCommand: () => formFinalizeCommand
|
|
2878
3757
|
});
|
|
2879
3758
|
import { input as input2, select, confirm as confirm2, number } from "@inquirer/prompts";
|
|
2880
|
-
import
|
|
3759
|
+
import chalk10 from "chalk";
|
|
2881
3760
|
import Table2 from "cli-table3";
|
|
3761
|
+
import { readFileSync as readFileSync3 } from "fs";
|
|
2882
3762
|
import { OfficerTitle } from "@thecorporation/corp-tools";
|
|
2883
3763
|
function isCorp(entityType) {
|
|
2884
3764
|
return entityType === "c_corp" || entityType === "s_corp" || entityType === "corporation";
|
|
2885
3765
|
}
|
|
2886
3766
|
function sectionHeader(title) {
|
|
2887
3767
|
console.log();
|
|
2888
|
-
console.log(
|
|
2889
|
-
console.log(
|
|
2890
|
-
console.log(
|
|
3768
|
+
console.log(chalk10.blue("\u2500".repeat(50)));
|
|
3769
|
+
console.log(chalk10.blue.bold(` ${title}`));
|
|
3770
|
+
console.log(chalk10.blue("\u2500".repeat(50)));
|
|
3771
|
+
}
|
|
3772
|
+
function officerTitleLabel(title) {
|
|
3773
|
+
switch (title) {
|
|
3774
|
+
case "ceo":
|
|
3775
|
+
return "CEO";
|
|
3776
|
+
case "cfo":
|
|
3777
|
+
return "CFO";
|
|
3778
|
+
case "cto":
|
|
3779
|
+
return "CTO";
|
|
3780
|
+
case "coo":
|
|
3781
|
+
return "COO";
|
|
3782
|
+
case "vp":
|
|
3783
|
+
return "VP";
|
|
3784
|
+
default:
|
|
3785
|
+
return title.charAt(0).toUpperCase() + title.slice(1);
|
|
3786
|
+
}
|
|
3787
|
+
}
|
|
3788
|
+
function parseBoolean(value) {
|
|
3789
|
+
if (typeof value === "boolean") return value;
|
|
3790
|
+
if (typeof value !== "string") return void 0;
|
|
3791
|
+
if (value === "true") return true;
|
|
3792
|
+
if (value === "false") return false;
|
|
3793
|
+
return void 0;
|
|
3794
|
+
}
|
|
3795
|
+
function parseAddressValue(raw) {
|
|
3796
|
+
if (!raw) return void 0;
|
|
3797
|
+
if (typeof raw === "string") {
|
|
3798
|
+
const parts = raw.split("|").map((part) => part.trim());
|
|
3799
|
+
if (parts.length === 4) {
|
|
3800
|
+
return { street: parts[0], city: parts[1], state: parts[2], zip: parts[3] };
|
|
3801
|
+
}
|
|
3802
|
+
throw new Error(`Invalid founder address: ${raw}. Expected street|city|state|zip.`);
|
|
3803
|
+
}
|
|
3804
|
+
if (typeof raw === "object" && raw !== null) {
|
|
3805
|
+
const value = raw;
|
|
3806
|
+
if (typeof value.street === "string" && typeof value.city === "string" && typeof value.state === "string" && typeof value.zip === "string") {
|
|
3807
|
+
return {
|
|
3808
|
+
street: value.street,
|
|
3809
|
+
street2: typeof value.street2 === "string" ? value.street2 : void 0,
|
|
3810
|
+
city: value.city,
|
|
3811
|
+
state: value.state,
|
|
3812
|
+
zip: value.zip
|
|
3813
|
+
};
|
|
3814
|
+
}
|
|
3815
|
+
}
|
|
3816
|
+
throw new Error("Founder address must be an object or street|city|state|zip string.");
|
|
3817
|
+
}
|
|
3818
|
+
function normalizeFounderInfo(input3) {
|
|
3819
|
+
const name = typeof input3.name === "string" ? input3.name.trim() : "";
|
|
3820
|
+
const email = typeof input3.email === "string" ? input3.email.trim() : "";
|
|
3821
|
+
const role = typeof input3.role === "string" ? input3.role.trim() : "";
|
|
3822
|
+
if (!name || !email || !role) {
|
|
3823
|
+
throw new Error("Founder JSON requires non-empty name, email, and role.");
|
|
3824
|
+
}
|
|
3825
|
+
const founder = { name, email, role };
|
|
3826
|
+
const ownershipPct = input3.ownership_pct ?? input3.pct;
|
|
3827
|
+
if (ownershipPct != null) founder.ownership_pct = Number(ownershipPct);
|
|
3828
|
+
const sharesPurchased = input3.shares_purchased ?? input3.shares;
|
|
3829
|
+
if (sharesPurchased != null) founder.shares_purchased = Number(sharesPurchased);
|
|
3830
|
+
if (typeof input3.officer_title === "string") founder.officer_title = input3.officer_title;
|
|
3831
|
+
const incorporator = parseBoolean(input3.is_incorporator ?? input3.incorporator);
|
|
3832
|
+
if (incorporator !== void 0) founder.is_incorporator = incorporator;
|
|
3833
|
+
if (input3.address != null) founder.address = parseAddressValue(input3.address);
|
|
3834
|
+
if (typeof input3.ip_description === "string") founder.ip_description = input3.ip_description;
|
|
3835
|
+
if (input3.vesting && typeof input3.vesting === "object") {
|
|
3836
|
+
const vesting = input3.vesting;
|
|
3837
|
+
if (vesting.total_months != null && vesting.cliff_months != null) {
|
|
3838
|
+
founder.vesting = {
|
|
3839
|
+
total_months: Number(vesting.total_months),
|
|
3840
|
+
cliff_months: Number(vesting.cliff_months),
|
|
3841
|
+
acceleration: typeof vesting.acceleration === "string" ? vesting.acceleration : void 0
|
|
3842
|
+
};
|
|
3843
|
+
}
|
|
3844
|
+
}
|
|
3845
|
+
return founder;
|
|
3846
|
+
}
|
|
3847
|
+
function parseLegacyMemberSpec(raw) {
|
|
3848
|
+
const parts = raw.split(",").map((p) => p.trim());
|
|
3849
|
+
if (parts.length < 3) {
|
|
3850
|
+
throw new Error(
|
|
3851
|
+
`Invalid member format: ${raw}. Expected: name,email,role[,pct[,address[,officer_title[,is_incorporator]]]]`
|
|
3852
|
+
);
|
|
3853
|
+
}
|
|
3854
|
+
const founder = { name: parts[0], email: parts[1], role: parts[2] };
|
|
3855
|
+
if (parts.length >= 4) founder.ownership_pct = parseFloat(parts[3]);
|
|
3856
|
+
if (parts.length >= 5 && parts[4]) founder.address = parseAddressValue(parts[4]);
|
|
3857
|
+
if (parts.length >= 6 && parts[5]) founder.officer_title = parts[5];
|
|
3858
|
+
if (parts.length >= 7) {
|
|
3859
|
+
const incorporator = parseBoolean(parts[6]);
|
|
3860
|
+
if (incorporator !== void 0) founder.is_incorporator = incorporator;
|
|
3861
|
+
}
|
|
3862
|
+
return founder;
|
|
3863
|
+
}
|
|
3864
|
+
function parseKeyValueMemberSpec(raw) {
|
|
3865
|
+
const parsed = {};
|
|
3866
|
+
for (const segment of raw.split(",")) {
|
|
3867
|
+
const [key, ...rest] = segment.split("=");
|
|
3868
|
+
if (!key || rest.length === 0) {
|
|
3869
|
+
throw new Error(`Invalid member format: ${raw}. Expected key=value pairs.`);
|
|
3870
|
+
}
|
|
3871
|
+
parsed[key.trim()] = rest.join("=").trim();
|
|
3872
|
+
}
|
|
3873
|
+
return normalizeFounderInfo(parsed);
|
|
3874
|
+
}
|
|
3875
|
+
function parseScriptedFounders(opts) {
|
|
3876
|
+
const founders = [];
|
|
3877
|
+
for (const raw of opts.member ?? []) {
|
|
3878
|
+
founders.push(raw.includes("=") ? parseKeyValueMemberSpec(raw) : parseLegacyMemberSpec(raw));
|
|
3879
|
+
}
|
|
3880
|
+
for (const raw of opts.memberJson ?? []) {
|
|
3881
|
+
founders.push(normalizeFounderInfo(JSON.parse(raw)));
|
|
3882
|
+
}
|
|
3883
|
+
if (opts.membersFile) {
|
|
3884
|
+
const parsed = JSON.parse(readFileSync3(opts.membersFile, "utf8"));
|
|
3885
|
+
let entries;
|
|
3886
|
+
if (Array.isArray(parsed)) {
|
|
3887
|
+
entries = parsed;
|
|
3888
|
+
} else if (typeof parsed === "object" && parsed !== null && "members" in parsed && Array.isArray(parsed.members)) {
|
|
3889
|
+
entries = parsed.members;
|
|
3890
|
+
} else {
|
|
3891
|
+
throw new Error('members file must be a JSON array or {"members": [...]}');
|
|
3892
|
+
}
|
|
3893
|
+
for (const entry of entries) {
|
|
3894
|
+
if (typeof entry !== "object" || entry === null || Array.isArray(entry)) {
|
|
3895
|
+
throw new Error("each founder entry must be a JSON object");
|
|
3896
|
+
}
|
|
3897
|
+
founders.push(normalizeFounderInfo(entry));
|
|
3898
|
+
}
|
|
3899
|
+
}
|
|
3900
|
+
return founders;
|
|
2891
3901
|
}
|
|
2892
3902
|
async function promptAddress() {
|
|
2893
3903
|
const street = await input2({ message: " Street address" });
|
|
@@ -2953,21 +3963,16 @@ async function phasePeople(opts, entityType, scripted) {
|
|
|
2953
3963
|
if (!scripted) sectionHeader("Phase 2: Founders & Officers");
|
|
2954
3964
|
const founders = [];
|
|
2955
3965
|
if (scripted) {
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
}
|
|
2962
|
-
const f = { name: parts[0], email: parts[1], role: parts[2] };
|
|
2963
|
-
if (parts.length >= 4) f.ownership_pct = parseFloat(parts[3]);
|
|
2964
|
-
founders.push(f);
|
|
3966
|
+
try {
|
|
3967
|
+
return parseScriptedFounders(opts);
|
|
3968
|
+
} catch (err) {
|
|
3969
|
+
printError(String(err));
|
|
3970
|
+
process.exit(1);
|
|
2965
3971
|
}
|
|
2966
|
-
return founders;
|
|
2967
3972
|
}
|
|
2968
3973
|
const founderCount = await number({ message: "Number of founders (1-6)", default: 1 }) ?? 1;
|
|
2969
3974
|
for (let i = 0; i < founderCount; i++) {
|
|
2970
|
-
console.log(
|
|
3975
|
+
console.log(chalk10.dim(`
|
|
2971
3976
|
Founder ${i + 1} of ${founderCount}:`));
|
|
2972
3977
|
const name = await input2({ message: ` Name` });
|
|
2973
3978
|
const email = await input2({ message: ` Email` });
|
|
@@ -2992,7 +3997,7 @@ async function phasePeople(opts, entityType, scripted) {
|
|
|
2992
3997
|
message: " Officer title",
|
|
2993
3998
|
choices: OfficerTitle.map((t) => ({
|
|
2994
3999
|
value: t,
|
|
2995
|
-
name:
|
|
4000
|
+
name: officerTitleLabel(t)
|
|
2996
4001
|
}))
|
|
2997
4002
|
});
|
|
2998
4003
|
}
|
|
@@ -3013,7 +4018,7 @@ async function phaseStock(opts, entityType, founders, scripted) {
|
|
|
3013
4018
|
const rofr = opts.rofr ?? (!scripted && isCorp(entityType) ? await confirm2({ message: "Right of first refusal?", default: true }) : isCorp(entityType));
|
|
3014
4019
|
if (!scripted) {
|
|
3015
4020
|
for (const f of founders) {
|
|
3016
|
-
console.log(
|
|
4021
|
+
console.log(chalk10.dim(`
|
|
3017
4022
|
Equity for ${f.name}:`));
|
|
3018
4023
|
if (isCorp(entityType)) {
|
|
3019
4024
|
const shares = await number({ message: ` Shares to purchase`, default: 0 });
|
|
@@ -3059,17 +4064,17 @@ async function phaseStock(opts, entityType, founders, scripted) {
|
|
|
3059
4064
|
}
|
|
3060
4065
|
function printSummary(entityType, name, jurisdiction, fiscalYearEnd, sCorpElection, founders, transferRestrictions, rofr) {
|
|
3061
4066
|
sectionHeader("Formation Summary");
|
|
3062
|
-
console.log(` ${
|
|
3063
|
-
console.log(` ${
|
|
3064
|
-
console.log(` ${
|
|
3065
|
-
console.log(` ${
|
|
4067
|
+
console.log(` ${chalk10.bold("Entity:")} ${name}`);
|
|
4068
|
+
console.log(` ${chalk10.bold("Type:")} ${entityType}`);
|
|
4069
|
+
console.log(` ${chalk10.bold("Jurisdiction:")} ${jurisdiction}`);
|
|
4070
|
+
console.log(` ${chalk10.bold("Fiscal Year End:")} ${fiscalYearEnd}`);
|
|
3066
4071
|
if (isCorp(entityType)) {
|
|
3067
|
-
console.log(` ${
|
|
3068
|
-
console.log(` ${
|
|
3069
|
-
console.log(` ${
|
|
4072
|
+
console.log(` ${chalk10.bold("S-Corp Election:")} ${sCorpElection ? "Yes" : "No"}`);
|
|
4073
|
+
console.log(` ${chalk10.bold("Transfer Restrictions:")} ${transferRestrictions ? "Yes" : "No"}`);
|
|
4074
|
+
console.log(` ${chalk10.bold("Right of First Refusal:")} ${rofr ? "Yes" : "No"}`);
|
|
3070
4075
|
}
|
|
3071
4076
|
const table = new Table2({
|
|
3072
|
-
head: [
|
|
4077
|
+
head: [chalk10.dim("Name"), chalk10.dim("Email"), chalk10.dim("Role"), chalk10.dim("Equity"), chalk10.dim("Officer")]
|
|
3073
4078
|
});
|
|
3074
4079
|
for (const f of founders) {
|
|
3075
4080
|
const equity = f.shares_purchased ? `${f.shares_purchased.toLocaleString()} shares` : f.ownership_pct ? `${f.ownership_pct}%` : "\u2014";
|
|
@@ -3086,14 +4091,16 @@ async function formCommand(opts) {
|
|
|
3086
4091
|
serverCfg = await client.getConfig();
|
|
3087
4092
|
} catch {
|
|
3088
4093
|
}
|
|
3089
|
-
const scripted =
|
|
4094
|
+
const scripted = Boolean(
|
|
4095
|
+
opts.member && opts.member.length > 0 || opts.memberJson && opts.memberJson.length > 0 || opts.membersFile
|
|
4096
|
+
);
|
|
3090
4097
|
const { entityType, name, jurisdiction, companyAddress, fiscalYearEnd, sCorpElection } = await phaseEntityDetails(opts, serverCfg, scripted);
|
|
3091
4098
|
const founders = await phasePeople(opts, entityType, scripted);
|
|
3092
4099
|
const { transferRestrictions, rofr } = await phaseStock(opts, entityType, founders, scripted);
|
|
3093
4100
|
printSummary(entityType, name, jurisdiction, fiscalYearEnd, sCorpElection, founders, transferRestrictions, rofr);
|
|
3094
4101
|
const shouldProceed = scripted ? true : await confirm2({ message: "Proceed with formation?", default: true });
|
|
3095
4102
|
if (!shouldProceed) {
|
|
3096
|
-
console.log(
|
|
4103
|
+
console.log(chalk10.yellow("Formation cancelled."));
|
|
3097
4104
|
return;
|
|
3098
4105
|
}
|
|
3099
4106
|
const members = founders.map((f) => {
|
|
@@ -3124,7 +4131,15 @@ async function formCommand(opts) {
|
|
|
3124
4131
|
right_of_first_refusal: rofr
|
|
3125
4132
|
};
|
|
3126
4133
|
if (companyAddress) payload.company_address = companyAddress;
|
|
4134
|
+
if (opts.dryRun) {
|
|
4135
|
+
printDryRun("formation.create_with_cap_table", payload);
|
|
4136
|
+
return;
|
|
4137
|
+
}
|
|
3127
4138
|
const result = await client.createFormationWithCapTable(payload);
|
|
4139
|
+
if (opts.json) {
|
|
4140
|
+
printJson(result);
|
|
4141
|
+
return;
|
|
4142
|
+
}
|
|
3128
4143
|
printSuccess(`Formation created: ${result.formation_id ?? "OK"}`);
|
|
3129
4144
|
if (result.entity_id) console.log(` Entity ID: ${result.entity_id}`);
|
|
3130
4145
|
if (result.legal_entity_id) console.log(` Legal Entity ID: ${result.legal_entity_id}`);
|
|
@@ -3137,17 +4152,17 @@ async function formCommand(opts) {
|
|
|
3137
4152
|
if (holders.length > 0) {
|
|
3138
4153
|
console.log();
|
|
3139
4154
|
const table = new Table2({
|
|
3140
|
-
head: [
|
|
4155
|
+
head: [chalk10.dim("Holder"), chalk10.dim("Shares"), chalk10.dim("Ownership %")]
|
|
3141
4156
|
});
|
|
3142
4157
|
for (const h of holders) {
|
|
3143
4158
|
const pct = typeof h.ownership_pct === "number" ? `${h.ownership_pct.toFixed(1)}%` : "\u2014";
|
|
3144
4159
|
table.push([String(h.name ?? "?"), String(h.shares ?? 0), pct]);
|
|
3145
4160
|
}
|
|
3146
|
-
console.log(
|
|
4161
|
+
console.log(chalk10.bold(" Cap Table:"));
|
|
3147
4162
|
console.log(table.toString());
|
|
3148
4163
|
}
|
|
3149
4164
|
if (result.next_action) {
|
|
3150
|
-
console.log(
|
|
4165
|
+
console.log(chalk10.yellow(`
|
|
3151
4166
|
Next: ${result.next_action}`));
|
|
3152
4167
|
}
|
|
3153
4168
|
} catch (err) {
|
|
@@ -3183,13 +4198,21 @@ async function formCreateCommand(opts) {
|
|
|
3183
4198
|
if (opts.rofr !== void 0) payload.right_of_first_refusal = opts.rofr;
|
|
3184
4199
|
const companyAddress = parseCsvAddress(opts.companyAddress);
|
|
3185
4200
|
if (companyAddress) payload.company_address = companyAddress;
|
|
4201
|
+
if (opts.dryRun) {
|
|
4202
|
+
printDryRun("formation.create_pending", payload);
|
|
4203
|
+
return;
|
|
4204
|
+
}
|
|
3186
4205
|
const result = await client.createPendingEntity(payload);
|
|
4206
|
+
if (opts.json) {
|
|
4207
|
+
printJson(result);
|
|
4208
|
+
return;
|
|
4209
|
+
}
|
|
3187
4210
|
printSuccess(`Pending entity created: ${result.entity_id}`);
|
|
3188
4211
|
console.log(` Name: ${result.legal_name}`);
|
|
3189
4212
|
console.log(` Type: ${result.entity_type}`);
|
|
3190
4213
|
console.log(` Jurisdiction: ${result.jurisdiction}`);
|
|
3191
4214
|
console.log(` Status: ${result.formation_status}`);
|
|
3192
|
-
console.log(
|
|
4215
|
+
console.log(chalk10.yellow(`
|
|
3193
4216
|
Next: corp form add-founder ${result.entity_id} --name "..." --email "..." --role member --pct 50`));
|
|
3194
4217
|
} catch (err) {
|
|
3195
4218
|
printError(`Failed to create pending entity: ${err}`);
|
|
@@ -3210,14 +4233,22 @@ async function formAddFounderCommand(entityId, opts) {
|
|
|
3210
4233
|
if (opts.incorporator) payload.is_incorporator = true;
|
|
3211
4234
|
const address = parseCsvAddress(opts.address);
|
|
3212
4235
|
if (address) payload.address = address;
|
|
4236
|
+
if (opts.dryRun) {
|
|
4237
|
+
printDryRun("formation.add_founder", { entity_id: entityId, ...payload });
|
|
4238
|
+
return;
|
|
4239
|
+
}
|
|
3213
4240
|
const result = await client.addFounder(entityId, payload);
|
|
4241
|
+
if (opts.json) {
|
|
4242
|
+
printJson(result);
|
|
4243
|
+
return;
|
|
4244
|
+
}
|
|
3214
4245
|
printSuccess(`Founder added (${result.member_count} total)`);
|
|
3215
4246
|
const members = result.members ?? [];
|
|
3216
4247
|
for (const m of members) {
|
|
3217
4248
|
const pct = typeof m.ownership_pct === "number" ? ` (${m.ownership_pct}%)` : "";
|
|
3218
4249
|
console.log(` - ${m.name} <${m.email ?? "no email"}> [${m.role ?? "member"}]${pct}`);
|
|
3219
4250
|
}
|
|
3220
|
-
console.log(
|
|
4251
|
+
console.log(chalk10.yellow(`
|
|
3221
4252
|
Next: add more founders or run: corp form finalize ${entityId}`));
|
|
3222
4253
|
} catch (err) {
|
|
3223
4254
|
printError(`Failed to add founder: ${err}`);
|
|
@@ -3237,6 +4268,14 @@ async function formFinalizeCommand(entityId, opts) {
|
|
|
3237
4268
|
payload.authorized_shares = authorizedShares;
|
|
3238
4269
|
}
|
|
3239
4270
|
if (opts.parValue) payload.par_value = opts.parValue;
|
|
4271
|
+
if (opts.boardSize) {
|
|
4272
|
+
const boardSize = parseInt(opts.boardSize, 10);
|
|
4273
|
+
if (!Number.isFinite(boardSize) || boardSize <= 0) {
|
|
4274
|
+
throw new Error(`Invalid board size: ${opts.boardSize}`);
|
|
4275
|
+
}
|
|
4276
|
+
payload.board_size = boardSize;
|
|
4277
|
+
}
|
|
4278
|
+
if (opts.principalName) payload.principal_name = opts.principalName;
|
|
3240
4279
|
if (opts.registeredAgentName) payload.registered_agent_name = opts.registeredAgentName;
|
|
3241
4280
|
if (opts.registeredAgentAddress) payload.registered_agent_address = opts.registeredAgentAddress;
|
|
3242
4281
|
if (opts.formationDate) payload.formation_date = opts.formationDate;
|
|
@@ -3246,7 +4285,17 @@ async function formFinalizeCommand(entityId, opts) {
|
|
|
3246
4285
|
if (opts.rofr !== void 0) payload.right_of_first_refusal = opts.rofr;
|
|
3247
4286
|
const companyAddress = parseCsvAddress(opts.companyAddress);
|
|
3248
4287
|
if (companyAddress) payload.company_address = companyAddress;
|
|
4288
|
+
if (opts.incorporatorName) payload.incorporator_name = opts.incorporatorName;
|
|
4289
|
+
if (opts.incorporatorAddress) payload.incorporator_address = opts.incorporatorAddress;
|
|
4290
|
+
if (opts.dryRun) {
|
|
4291
|
+
printDryRun("formation.finalize", { entity_id: entityId, ...payload });
|
|
4292
|
+
return;
|
|
4293
|
+
}
|
|
3249
4294
|
const result = await client.finalizeFormation(entityId, payload);
|
|
4295
|
+
if (opts.json) {
|
|
4296
|
+
printJson(result);
|
|
4297
|
+
return;
|
|
4298
|
+
}
|
|
3250
4299
|
printSuccess(`Formation finalized: ${result.entity_id}`);
|
|
3251
4300
|
if (result.legal_entity_id) console.log(` Legal Entity ID: ${result.legal_entity_id}`);
|
|
3252
4301
|
if (result.instrument_id) console.log(` Instrument ID: ${result.instrument_id}`);
|
|
@@ -3258,17 +4307,17 @@ async function formFinalizeCommand(entityId, opts) {
|
|
|
3258
4307
|
if (holders.length > 0) {
|
|
3259
4308
|
console.log();
|
|
3260
4309
|
const table = new Table2({
|
|
3261
|
-
head: [
|
|
4310
|
+
head: [chalk10.dim("Holder"), chalk10.dim("Shares"), chalk10.dim("Ownership %")]
|
|
3262
4311
|
});
|
|
3263
4312
|
for (const h of holders) {
|
|
3264
4313
|
const pct = typeof h.ownership_pct === "number" ? `${h.ownership_pct.toFixed(1)}%` : "\u2014";
|
|
3265
4314
|
table.push([String(h.name ?? "?"), String(h.shares ?? 0), pct]);
|
|
3266
4315
|
}
|
|
3267
|
-
console.log(
|
|
4316
|
+
console.log(chalk10.bold(" Cap Table:"));
|
|
3268
4317
|
console.log(table.toString());
|
|
3269
4318
|
}
|
|
3270
4319
|
if (result.next_action) {
|
|
3271
|
-
console.log(
|
|
4320
|
+
console.log(chalk10.yellow(`
|
|
3272
4321
|
Next: ${result.next_action}`));
|
|
3273
4322
|
}
|
|
3274
4323
|
} catch (err) {
|
|
@@ -3290,7 +4339,7 @@ var api_keys_exports = {};
|
|
|
3290
4339
|
__export(api_keys_exports, {
|
|
3291
4340
|
apiKeysCommand: () => apiKeysCommand
|
|
3292
4341
|
});
|
|
3293
|
-
import
|
|
4342
|
+
import chalk11 from "chalk";
|
|
3294
4343
|
import Table3 from "cli-table3";
|
|
3295
4344
|
async function apiKeysCommand(opts) {
|
|
3296
4345
|
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
@@ -3310,9 +4359,9 @@ async function apiKeysCommand(opts) {
|
|
|
3310
4359
|
return;
|
|
3311
4360
|
}
|
|
3312
4361
|
console.log(`
|
|
3313
|
-
${
|
|
4362
|
+
${chalk11.bold("API Keys")}`);
|
|
3314
4363
|
const table = new Table3({
|
|
3315
|
-
head: [
|
|
4364
|
+
head: [chalk11.dim("ID"), chalk11.dim("Name"), chalk11.dim("Key"), chalk11.dim("Created")]
|
|
3316
4365
|
});
|
|
3317
4366
|
for (const k of keys) {
|
|
3318
4367
|
table.push([
|
|
@@ -3364,13 +4413,54 @@ var init_demo = __esm({
|
|
|
3364
4413
|
}
|
|
3365
4414
|
});
|
|
3366
4415
|
|
|
4416
|
+
// src/commands/feedback.ts
|
|
4417
|
+
var feedback_exports = {};
|
|
4418
|
+
__export(feedback_exports, {
|
|
4419
|
+
feedbackCommand: () => feedbackCommand
|
|
4420
|
+
});
|
|
4421
|
+
import chalk12 from "chalk";
|
|
4422
|
+
async function feedbackCommand(message, opts) {
|
|
4423
|
+
if (!message || message.trim().length === 0) {
|
|
4424
|
+
printError("Feedback message cannot be empty");
|
|
4425
|
+
process.exit(1);
|
|
4426
|
+
}
|
|
4427
|
+
if (message.length > MAX_FEEDBACK_LENGTH) {
|
|
4428
|
+
printError(`Feedback message must be at most ${MAX_FEEDBACK_LENGTH} characters (got ${message.length})`);
|
|
4429
|
+
process.exit(1);
|
|
4430
|
+
}
|
|
4431
|
+
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
4432
|
+
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
4433
|
+
try {
|
|
4434
|
+
const result = await client.submitFeedback(message, opts.category, opts.email);
|
|
4435
|
+
if (opts.json) {
|
|
4436
|
+
printJson(result);
|
|
4437
|
+
return;
|
|
4438
|
+
}
|
|
4439
|
+
console.log(`
|
|
4440
|
+
${chalk12.green("\u2713")} Feedback submitted (${chalk12.dim(result.feedback_id)})`);
|
|
4441
|
+
} catch (err) {
|
|
4442
|
+
printError("Failed to submit feedback", err);
|
|
4443
|
+
process.exit(1);
|
|
4444
|
+
}
|
|
4445
|
+
}
|
|
4446
|
+
var MAX_FEEDBACK_LENGTH;
|
|
4447
|
+
var init_feedback = __esm({
|
|
4448
|
+
"src/commands/feedback.ts"() {
|
|
4449
|
+
"use strict";
|
|
4450
|
+
init_config();
|
|
4451
|
+
init_api_client();
|
|
4452
|
+
init_output();
|
|
4453
|
+
MAX_FEEDBACK_LENGTH = 1e4;
|
|
4454
|
+
}
|
|
4455
|
+
});
|
|
4456
|
+
|
|
3367
4457
|
// src/commands/serve.ts
|
|
3368
4458
|
var serve_exports = {};
|
|
3369
4459
|
__export(serve_exports, {
|
|
3370
4460
|
serveCommand: () => serveCommand
|
|
3371
4461
|
});
|
|
3372
|
-
import { readFileSync as
|
|
3373
|
-
import { resolve } from "path";
|
|
4462
|
+
import { readFileSync as readFileSync4, writeFileSync as writeFileSync2, existsSync as existsSync2 } from "fs";
|
|
4463
|
+
import { resolve as resolve2 } from "path";
|
|
3374
4464
|
import { randomBytes } from "crypto";
|
|
3375
4465
|
function generateFernetKey() {
|
|
3376
4466
|
return randomBytes(32).toString("base64url") + "=";
|
|
@@ -3380,7 +4470,7 @@ function generateSecret(length = 32) {
|
|
|
3380
4470
|
}
|
|
3381
4471
|
function loadEnvFile(path) {
|
|
3382
4472
|
if (!existsSync2(path)) return;
|
|
3383
|
-
const content =
|
|
4473
|
+
const content = readFileSync4(path, "utf-8");
|
|
3384
4474
|
for (const line of content.split("\n")) {
|
|
3385
4475
|
const trimmed = line.trim();
|
|
3386
4476
|
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
@@ -3422,35 +4512,21 @@ async function serveCommand(opts) {
|
|
|
3422
4512
|
console.error(`Error: Invalid port "${opts.port}"`);
|
|
3423
4513
|
process.exit(1);
|
|
3424
4514
|
}
|
|
3425
|
-
const envPath =
|
|
4515
|
+
const envPath = resolve2(process.cwd(), ".env");
|
|
3426
4516
|
ensureEnvFile(envPath);
|
|
3427
4517
|
loadEnvFile(envPath);
|
|
3428
4518
|
const localUrl = `http://localhost:${port}`;
|
|
3429
|
-
const { loadConfig: loadConfig2, saveConfig: saveConfig2 } = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
3430
|
-
const cfg = loadConfig2();
|
|
3431
|
-
const previousUrl = cfg.api_url;
|
|
3432
|
-
if (cfg.api_url !== localUrl) {
|
|
3433
|
-
cfg.api_url = localUrl;
|
|
3434
|
-
saveConfig2(cfg);
|
|
3435
|
-
console.log(`CLI configured to use local server: ${localUrl}`);
|
|
3436
|
-
console.log(` (previous: ${previousUrl})`);
|
|
3437
|
-
console.log(` To revert: corp config set api_url ${previousUrl}
|
|
3438
|
-
`);
|
|
3439
|
-
}
|
|
3440
4519
|
console.log(`Starting server on port ${port}...`);
|
|
3441
4520
|
console.log(`Data directory: ${opts.dataDir}`);
|
|
4521
|
+
console.log(`CLI API URL remains unchanged.`);
|
|
4522
|
+
console.log(` Use CORP_API_URL=${localUrl} for commands against this local server.
|
|
4523
|
+
`);
|
|
3442
4524
|
const child = server.startServer({
|
|
3443
4525
|
port,
|
|
3444
4526
|
dataDir: opts.dataDir
|
|
3445
4527
|
});
|
|
3446
4528
|
const shutdown = () => {
|
|
3447
4529
|
console.log("\nShutting down server...");
|
|
3448
|
-
if (previousUrl !== localUrl) {
|
|
3449
|
-
const current = loadConfig2();
|
|
3450
|
-
current.api_url = previousUrl;
|
|
3451
|
-
saveConfig2(current);
|
|
3452
|
-
console.log(`CLI restored to: ${previousUrl}`);
|
|
3453
|
-
}
|
|
3454
4530
|
child.kill("SIGTERM");
|
|
3455
4531
|
};
|
|
3456
4532
|
process.on("SIGINT", shutdown);
|
|
@@ -3508,34 +4584,61 @@ function inheritOption(localValue, parentValue) {
|
|
|
3508
4584
|
// src/index.ts
|
|
3509
4585
|
var require2 = createRequire(import.meta.url);
|
|
3510
4586
|
var pkg = require2("../package.json");
|
|
4587
|
+
var TAX_DOCUMENT_TYPE_CHOICES = [
|
|
4588
|
+
"1120",
|
|
4589
|
+
"1120s",
|
|
4590
|
+
"1065",
|
|
4591
|
+
"franchise_tax",
|
|
4592
|
+
"annual_report",
|
|
4593
|
+
"83b",
|
|
4594
|
+
"form_1120",
|
|
4595
|
+
"form_1120s",
|
|
4596
|
+
"form_1065",
|
|
4597
|
+
"1099_nec",
|
|
4598
|
+
"form_1099_nec",
|
|
4599
|
+
"k1",
|
|
4600
|
+
"form_k1",
|
|
4601
|
+
"941",
|
|
4602
|
+
"form_941",
|
|
4603
|
+
"w2",
|
|
4604
|
+
"form_w2"
|
|
4605
|
+
];
|
|
3511
4606
|
var program = new Command();
|
|
3512
4607
|
program.name("corp").description("corp \u2014 Corporate governance from the terminal").version(pkg.version);
|
|
3513
4608
|
program.command("setup").description("Interactive setup wizard").action(async () => {
|
|
3514
4609
|
const { setupCommand: setupCommand2 } = await Promise.resolve().then(() => (init_setup(), setup_exports));
|
|
3515
4610
|
await setupCommand2();
|
|
3516
4611
|
});
|
|
3517
|
-
program.command("status").description("Workspace summary").action(async () => {
|
|
4612
|
+
program.command("status").description("Workspace summary").option("--json", "Output as JSON").action(async (opts) => {
|
|
3518
4613
|
const { statusCommand: statusCommand2 } = await Promise.resolve().then(() => (init_status(), status_exports));
|
|
3519
|
-
await statusCommand2();
|
|
4614
|
+
await statusCommand2(opts);
|
|
4615
|
+
});
|
|
4616
|
+
program.command("context").alias("whoami").description("Show the active workspace, user, and entity context").option("--json", "Output as JSON").action(async (opts) => {
|
|
4617
|
+
const { contextCommand: contextCommand2 } = await Promise.resolve().then(() => (init_context(), context_exports));
|
|
4618
|
+
await contextCommand2(opts);
|
|
4619
|
+
});
|
|
4620
|
+
program.command("schema").description("Dump the CLI command catalog as JSON").option("--compact", "Emit compact JSON").action(async (opts) => {
|
|
4621
|
+
const { schemaCommand: schemaCommand2 } = await Promise.resolve().then(() => (init_schema(), schema_exports));
|
|
4622
|
+
schemaCommand2(program, opts);
|
|
3520
4623
|
});
|
|
3521
4624
|
var configCmd = program.command("config").description("Manage configuration");
|
|
3522
|
-
configCmd.command("set <key> <value>").description("Set a config value (dot-path)").action(async (key, value) => {
|
|
3523
|
-
const { configSetCommand: configSetCommand2 } = await Promise.resolve().then(() => (init_config2(),
|
|
3524
|
-
configSetCommand2(key, value);
|
|
4625
|
+
configCmd.command("set <key> <value>").description("Set a config value (dot-path)").option("--force", "Allow updating a security-sensitive config key").action(async (key, value, opts) => {
|
|
4626
|
+
const { configSetCommand: configSetCommand2 } = await Promise.resolve().then(() => (init_config2(), config_exports));
|
|
4627
|
+
configSetCommand2(key, value, opts);
|
|
3525
4628
|
});
|
|
3526
4629
|
configCmd.command("get <key>").description("Get a config value (dot-path)").action(async (key) => {
|
|
3527
|
-
const { configGetCommand: configGetCommand2 } = await Promise.resolve().then(() => (init_config2(),
|
|
4630
|
+
const { configGetCommand: configGetCommand2 } = await Promise.resolve().then(() => (init_config2(), config_exports));
|
|
3528
4631
|
configGetCommand2(key);
|
|
3529
4632
|
});
|
|
3530
4633
|
configCmd.command("list").description("List all config (API keys masked)").action(async () => {
|
|
3531
|
-
const { configListCommand: configListCommand2 } = await Promise.resolve().then(() => (init_config2(),
|
|
4634
|
+
const { configListCommand: configListCommand2 } = await Promise.resolve().then(() => (init_config2(), config_exports));
|
|
3532
4635
|
configListCommand2();
|
|
3533
4636
|
});
|
|
3534
4637
|
program.command("obligations").description("List obligations with urgency tiers").option("--tier <tier>", "Filter by urgency tier").option("--json", "Output as JSON").action(async (opts) => {
|
|
3535
4638
|
const { obligationsCommand: obligationsCommand2 } = await Promise.resolve().then(() => (init_obligations(), obligations_exports));
|
|
3536
4639
|
await obligationsCommand2(opts);
|
|
3537
4640
|
});
|
|
3538
|
-
program.command("digest").description("View or trigger daily digests").option("--trigger", "Trigger digest now").option("--key <key>", "Get specific digest by key").action(async (opts) => {
|
|
4641
|
+
program.command("digest").description("View or trigger daily digests").option("--trigger", "Trigger digest now").option("--key <key>", "Get specific digest by key").option("--json", "Output as JSON").action(async (opts) => {
|
|
3539
4642
|
const { digestCommand: digestCommand2 } = await Promise.resolve().then(() => (init_digest(), digest_exports));
|
|
3540
4643
|
await digestCommand2(opts);
|
|
3541
4644
|
});
|
|
@@ -3584,15 +4687,23 @@ contactsCmd.command("show <contact-id>").option("--json", "Output as JSON").desc
|
|
|
3584
4687
|
json: inheritOption(opts.json, parent.json)
|
|
3585
4688
|
});
|
|
3586
4689
|
});
|
|
3587
|
-
contactsCmd.command("add").requiredOption("--name <name>", "Contact name").requiredOption("--email <email>", "Contact email").option("--type <type>", "Contact type (individual, organization)", "individual").option("--category <category>", "Category (employee, contractor, board_member, investor, law_firm, valuation_firm, accounting_firm, officer, founder, member, other)").option("--phone <phone>", "Phone number").option("--notes <notes>", "Notes").description("Add a new contact").action(async (opts, cmd) => {
|
|
4690
|
+
contactsCmd.command("add").requiredOption("--name <name>", "Contact name").requiredOption("--email <email>", "Contact email").option("--type <type>", "Contact type (individual, organization)", "individual").option("--category <category>", "Category (employee, contractor, board_member, investor, law_firm, valuation_firm, accounting_firm, officer, founder, member, other)").option("--cap-table-access <level>", "Cap table access (none, summary, detailed)").option("--address <address>", "Mailing address").option("--mailing-address <address>", "Alias for --address").option("--phone <phone>", "Phone number").option("--notes <notes>", "Notes").option("--json", "Output as JSON").description("Add a new contact").action(async (opts, cmd) => {
|
|
3588
4691
|
const parent = cmd.parent.opts();
|
|
3589
4692
|
const { contactsAddCommand: contactsAddCommand2 } = await Promise.resolve().then(() => (init_contacts(), contacts_exports));
|
|
3590
|
-
await contactsAddCommand2({
|
|
4693
|
+
await contactsAddCommand2({
|
|
4694
|
+
...opts,
|
|
4695
|
+
entityId: parent.entityId,
|
|
4696
|
+
json: inheritOption(opts.json, parent.json)
|
|
4697
|
+
});
|
|
3591
4698
|
});
|
|
3592
|
-
contactsCmd.command("edit <contact-id>").option("--name <name>", "Contact name").option("--email <email>", "Contact email").option("--category <category>", "Contact category").option("--phone <phone>", "Phone number").option("--notes <notes>", "Notes").description("Edit an existing contact").action(async (contactId, opts, cmd) => {
|
|
4699
|
+
contactsCmd.command("edit <contact-id>").option("--name <name>", "Contact name").option("--email <email>", "Contact email").option("--category <category>", "Contact category").option("--cap-table-access <level>", "Cap table access (none, summary, detailed)").option("--address <address>", "Mailing address").option("--mailing-address <address>", "Alias for --address").option("--phone <phone>", "Phone number").option("--notes <notes>", "Notes").option("--json", "Output as JSON").description("Edit an existing contact").action(async (contactId, opts, cmd) => {
|
|
3593
4700
|
const parent = cmd.parent.opts();
|
|
3594
4701
|
const { contactsEditCommand: contactsEditCommand2 } = await Promise.resolve().then(() => (init_contacts(), contacts_exports));
|
|
3595
|
-
await contactsEditCommand2(contactId, {
|
|
4702
|
+
await contactsEditCommand2(contactId, {
|
|
4703
|
+
...opts,
|
|
4704
|
+
entityId: parent.entityId,
|
|
4705
|
+
json: inheritOption(opts.json, parent.json)
|
|
4706
|
+
});
|
|
3596
4707
|
});
|
|
3597
4708
|
var capTableCmd = program.command("cap-table").description("Cap table, equity grants, SAFEs, transfers, and valuations").option("--entity-id <id>", "Entity ID (overrides active entity)").option("--json", "Output as JSON").action(async (opts) => {
|
|
3598
4709
|
const { capTableCommand: capTableCommand2 } = await Promise.resolve().then(() => (init_cap_table(), cap_table_exports));
|
|
@@ -3618,100 +4729,183 @@ capTableCmd.command("409a").description("Current 409A valuation").action(async (
|
|
|
3618
4729
|
const { fourOhNineACommand: fourOhNineACommand2 } = await Promise.resolve().then(() => (init_cap_table(), cap_table_exports));
|
|
3619
4730
|
await fourOhNineACommand2(parent);
|
|
3620
4731
|
});
|
|
3621
|
-
capTableCmd.command("
|
|
4732
|
+
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 <id>", "Issuer legal entity ID (auto-detected from the cap table if omitted)").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) => {
|
|
4733
|
+
const parent = cmd.parent.opts();
|
|
4734
|
+
const { createInstrumentCommand: createInstrumentCommand2 } = await Promise.resolve().then(() => (init_cap_table(), cap_table_exports));
|
|
4735
|
+
await createInstrumentCommand2({
|
|
4736
|
+
...opts,
|
|
4737
|
+
entityId: parent.entityId,
|
|
4738
|
+
json: inheritOption(opts.json, parent.json)
|
|
4739
|
+
});
|
|
4740
|
+
});
|
|
4741
|
+
capTableCmd.command("issue-equity").requiredOption("--grant-type <type>", "Grant type (common, preferred, membership_unit, stock_option, iso, nso, rsa)").requiredOption("--shares <n>", "Number of shares", parseInt).requiredOption("--recipient <name>", "Recipient name").option("--email <email>", "Recipient email (auto-creates contact if needed)").option("--instrument-id <id>", "Instrument ID (auto-detected from cap table if omitted)").option("--meeting-id <id>", "Board meeting ID required when a board approval already exists or is being recorded").option("--resolution-id <id>", "Board resolution ID 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 an equity grant (creates a round, adds security, and issues it)").action(async (opts, cmd) => {
|
|
3622
4742
|
const parent = cmd.parent.opts();
|
|
3623
4743
|
const { issueEquityCommand: issueEquityCommand2 } = await Promise.resolve().then(() => (init_cap_table(), cap_table_exports));
|
|
3624
|
-
await issueEquityCommand2({
|
|
4744
|
+
await issueEquityCommand2({
|
|
4745
|
+
...opts,
|
|
4746
|
+
entityId: parent.entityId,
|
|
4747
|
+
json: inheritOption(opts.json, parent.json)
|
|
4748
|
+
});
|
|
3625
4749
|
});
|
|
3626
|
-
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).description("Issue a SAFE note").action(async (opts, cmd) => {
|
|
4750
|
+
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 <id>", "Board meeting ID required when issuing under a board-governed entity").option("--resolution-id <id>", "Board resolution ID 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) => {
|
|
3627
4751
|
const parent = cmd.parent.opts();
|
|
3628
4752
|
const { issueSafeCommand: issueSafeCommand2 } = await Promise.resolve().then(() => (init_cap_table(), cap_table_exports));
|
|
3629
|
-
await issueSafeCommand2({
|
|
4753
|
+
await issueSafeCommand2({
|
|
4754
|
+
...opts,
|
|
4755
|
+
entityId: parent.entityId,
|
|
4756
|
+
json: inheritOption(opts.json, parent.json)
|
|
4757
|
+
});
|
|
3630
4758
|
});
|
|
3631
|
-
capTableCmd.command("transfer").requiredOption("--from <id>", "Source contact ID (from_contact_id)").requiredOption("--to <id>", "Destination contact ID (to_contact_id)").requiredOption("--shares <n>", "Number of shares to transfer", parseInt).requiredOption("--share-class-id <id>", "Share class ID").requiredOption("--governing-doc-type <type>", "Governing doc type (bylaws, operating_agreement, shareholder_agreement, other)").requiredOption("--transferee-rights <rights>", "Transferee rights (full_member, economic_only, limited)").option("--prepare-intent-id <id>", "Prepare intent ID (auto-created if omitted)").option("--type <type>", "Transfer type (gift, trust_transfer, secondary_sale, estate, other)", "secondary_sale").option("--price-per-share-cents <n>", "Price per share in cents", parseInt).option("--relationship <rel>", "Relationship to holder").description("Create a share transfer workflow").action(async (opts, cmd) => {
|
|
4759
|
+
capTableCmd.command("transfer").requiredOption("--from <id>", "Source contact ID (from_contact_id)").requiredOption("--to <id>", "Destination contact ID (to_contact_id)").requiredOption("--shares <n>", "Number of shares to transfer", parseInt).requiredOption("--share-class-id <id>", "Share class ID").requiredOption("--governing-doc-type <type>", "Governing doc type (bylaws, operating_agreement, shareholder_agreement, other)").requiredOption("--transferee-rights <rights>", "Transferee rights (full_member, economic_only, limited)").option("--prepare-intent-id <id>", "Prepare intent ID (auto-created if omitted)").option("--type <type>", "Transfer type (gift, trust_transfer, secondary_sale, estate, other)", "secondary_sale").option("--price-per-share-cents <n>", "Price per share in cents", parseInt).option("--relationship <rel>", "Relationship to holder").option("--json", "Output as JSON").option("--dry-run", "Show the request without creating the workflow").description("Create a share transfer workflow").action(async (opts, cmd) => {
|
|
3632
4760
|
const parent = cmd.parent.opts();
|
|
3633
4761
|
const { transferSharesCommand: transferSharesCommand2 } = await Promise.resolve().then(() => (init_cap_table(), cap_table_exports));
|
|
3634
|
-
await transferSharesCommand2({
|
|
4762
|
+
await transferSharesCommand2({
|
|
4763
|
+
...opts,
|
|
4764
|
+
entityId: parent.entityId,
|
|
4765
|
+
json: inheritOption(opts.json, parent.json)
|
|
4766
|
+
});
|
|
3635
4767
|
});
|
|
3636
|
-
capTableCmd.command("distribute").requiredOption("--amount <n>", "Total distribution amount in cents", parseInt).option("--type <type>", "Distribution type (dividend, return, liquidation)", "dividend").requiredOption("--description <desc>", "Distribution description").description("Calculate a distribution").action(async (opts, cmd) => {
|
|
4768
|
+
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) => {
|
|
3637
4769
|
const parent = cmd.parent.opts();
|
|
3638
4770
|
const { distributeCommand: distributeCommand2 } = await Promise.resolve().then(() => (init_cap_table(), cap_table_exports));
|
|
3639
|
-
await distributeCommand2({
|
|
4771
|
+
await distributeCommand2({
|
|
4772
|
+
...opts,
|
|
4773
|
+
entityId: parent.entityId,
|
|
4774
|
+
json: inheritOption(opts.json, parent.json)
|
|
4775
|
+
});
|
|
3640
4776
|
});
|
|
3641
|
-
capTableCmd.command("start-round").requiredOption("--name <name>", "Round name").requiredOption("--issuer-legal-entity-id <id>", "Issuer legal entity ID").description("Start a staged equity round").action(async (opts, cmd) => {
|
|
4777
|
+
capTableCmd.command("start-round").requiredOption("--name <name>", "Round name").requiredOption("--issuer-legal-entity-id <id>", "Issuer legal entity ID").option("--json", "Output as JSON").option("--dry-run", "Show the request without creating the round").description("Start a staged equity round").action(async (opts, cmd) => {
|
|
3642
4778
|
const parent = cmd.parent.opts();
|
|
3643
4779
|
const { startRoundCommand: startRoundCommand2 } = await Promise.resolve().then(() => (init_cap_table(), cap_table_exports));
|
|
3644
|
-
await startRoundCommand2({
|
|
4780
|
+
await startRoundCommand2({
|
|
4781
|
+
...opts,
|
|
4782
|
+
entityId: parent.entityId,
|
|
4783
|
+
json: inheritOption(opts.json, parent.json)
|
|
4784
|
+
});
|
|
3645
4785
|
});
|
|
3646
|
-
capTableCmd.command("add-security").requiredOption("--round-id <id>", "Round ID").requiredOption("--instrument-id <id>", "Instrument ID").requiredOption("--quantity <n>", "Number of shares/units", parseInt).requiredOption("--recipient-name <name>", "Recipient display name").option("--holder-id <id>", "Existing holder ID").option("--email <email>", "Recipient email (to find or create holder)").option("--principal-cents <n>", "Principal amount in cents", parseInt).option("--grant-type <type>", "Grant type").description("Add a security to a staged equity round").action(async (opts, cmd) => {
|
|
4786
|
+
capTableCmd.command("add-security").requiredOption("--round-id <id>", "Round ID").requiredOption("--instrument-id <id>", "Instrument ID").requiredOption("--quantity <n>", "Number of shares/units", parseInt).requiredOption("--recipient-name <name>", "Recipient display name").option("--holder-id <id>", "Existing holder ID").option("--email <email>", "Recipient email (to find or create holder)").option("--principal-cents <n>", "Principal amount in cents", parseInt).option("--grant-type <type>", "Grant type").option("--json", "Output as JSON").option("--dry-run", "Show the request without adding the security").description("Add a security to a staged equity round").action(async (opts, cmd) => {
|
|
3647
4787
|
const parent = cmd.parent.opts();
|
|
3648
4788
|
const { addSecurityCommand: addSecurityCommand2 } = await Promise.resolve().then(() => (init_cap_table(), cap_table_exports));
|
|
3649
|
-
await addSecurityCommand2({
|
|
4789
|
+
await addSecurityCommand2({
|
|
4790
|
+
...opts,
|
|
4791
|
+
entityId: parent.entityId,
|
|
4792
|
+
json: inheritOption(opts.json, parent.json)
|
|
4793
|
+
});
|
|
3650
4794
|
});
|
|
3651
|
-
capTableCmd.command("issue-round").requiredOption("--round-id <id>", "Round ID").description("Issue all securities and close a staged round").action(async (opts, cmd) => {
|
|
4795
|
+
capTableCmd.command("issue-round").option("--meeting-id <id>", "Board meeting ID required when issuing under a board-governed entity").option("--resolution-id <id>", "Board resolution ID required when issuing under a board-governed entity").option("--json", "Output as JSON").option("--dry-run", "Show the request without issuing the round").requiredOption("--round-id <id>", "Round ID").description("Issue all securities and close a staged round").action(async (opts, cmd) => {
|
|
3652
4796
|
const parent = cmd.parent.opts();
|
|
3653
4797
|
const { issueRoundCommand: issueRoundCommand2 } = await Promise.resolve().then(() => (init_cap_table(), cap_table_exports));
|
|
3654
|
-
await issueRoundCommand2({
|
|
4798
|
+
await issueRoundCommand2({
|
|
4799
|
+
...opts,
|
|
4800
|
+
entityId: parent.entityId,
|
|
4801
|
+
json: inheritOption(opts.json, parent.json)
|
|
4802
|
+
});
|
|
3655
4803
|
});
|
|
3656
|
-
capTableCmd.command("create-valuation").requiredOption("--type <type>", "Valuation type (four_oh_nine_a, fair_market_value, etc.)").requiredOption("--date <date>", "Effective date (ISO 8601)").requiredOption("--methodology <method>", "Methodology (income, market, asset, backsolve, hybrid)").option("--fmv <cents>", "FMV per share in cents", parseInt).option("--enterprise-value <cents>", "Enterprise value in cents", parseInt).description("Create a valuation").action(async (opts, cmd) => {
|
|
4804
|
+
capTableCmd.command("create-valuation").requiredOption("--type <type>", "Valuation type (four_oh_nine_a, fair_market_value, etc.)").requiredOption("--date <date>", "Effective date (ISO 8601)").requiredOption("--methodology <method>", "Methodology (income, market, asset, backsolve, hybrid)").option("--fmv <cents>", "FMV per share in cents", parseInt).option("--enterprise-value <cents>", "Enterprise value in cents", parseInt).option("--json", "Output as JSON").option("--dry-run", "Show the request without creating the valuation").description("Create a valuation").action(async (opts, cmd) => {
|
|
3657
4805
|
const parent = cmd.parent.opts();
|
|
3658
4806
|
const { createValuationCommand: createValuationCommand2 } = await Promise.resolve().then(() => (init_cap_table(), cap_table_exports));
|
|
3659
|
-
await createValuationCommand2({
|
|
4807
|
+
await createValuationCommand2({
|
|
4808
|
+
...opts,
|
|
4809
|
+
entityId: parent.entityId,
|
|
4810
|
+
json: inheritOption(opts.json, parent.json)
|
|
4811
|
+
});
|
|
3660
4812
|
});
|
|
3661
|
-
capTableCmd.command("submit-valuation <valuation-id>").description("Submit a valuation for board approval").action(async (valuationId,
|
|
4813
|
+
capTableCmd.command("submit-valuation <valuation-id>").option("--json", "Output as JSON").option("--dry-run", "Show the request without submitting the valuation").description("Submit a valuation for board approval").action(async (valuationId, opts, cmd) => {
|
|
3662
4814
|
const parent = cmd.parent.opts();
|
|
3663
4815
|
const { submitValuationCommand: submitValuationCommand2 } = await Promise.resolve().then(() => (init_cap_table(), cap_table_exports));
|
|
3664
|
-
await submitValuationCommand2({
|
|
4816
|
+
await submitValuationCommand2({
|
|
4817
|
+
...opts,
|
|
4818
|
+
valuationId,
|
|
4819
|
+
entityId: parent.entityId,
|
|
4820
|
+
json: inheritOption(opts.json, parent.json)
|
|
4821
|
+
});
|
|
3665
4822
|
});
|
|
3666
|
-
capTableCmd.command("approve-valuation <valuation-id>").option("--resolution-id <id>", "Resolution ID from the board vote").description("Approve a valuation").action(async (valuationId, opts, cmd) => {
|
|
4823
|
+
capTableCmd.command("approve-valuation <valuation-id>").option("--resolution-id <id>", "Resolution ID from the board vote").option("--json", "Output as JSON").option("--dry-run", "Show the request without approving the valuation").description("Approve a valuation").action(async (valuationId, opts, cmd) => {
|
|
3667
4824
|
const parent = cmd.parent.opts();
|
|
3668
4825
|
const { approveValuationCommand: approveValuationCommand2 } = await Promise.resolve().then(() => (init_cap_table(), cap_table_exports));
|
|
3669
|
-
await approveValuationCommand2({
|
|
4826
|
+
await approveValuationCommand2({
|
|
4827
|
+
...opts,
|
|
4828
|
+
valuationId,
|
|
4829
|
+
entityId: parent.entityId,
|
|
4830
|
+
json: inheritOption(opts.json, parent.json)
|
|
4831
|
+
});
|
|
3670
4832
|
});
|
|
3671
|
-
var financeCmd = program.command("finance").description("Invoicing, payroll, payments, banking").option("--entity-id <id>", "Entity ID (overrides active entity)");
|
|
3672
|
-
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").description("Create an invoice").action(async (opts, cmd) => {
|
|
4833
|
+
var financeCmd = program.command("finance").description("Invoicing, payroll, payments, banking").option("--entity-id <id>", "Entity ID (overrides active entity)").option("--json", "Output as JSON");
|
|
4834
|
+
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) => {
|
|
3673
4835
|
const parent = cmd.parent.opts();
|
|
3674
4836
|
const { financeInvoiceCommand: financeInvoiceCommand2 } = await Promise.resolve().then(() => (init_finance(), finance_exports));
|
|
3675
|
-
await financeInvoiceCommand2({
|
|
4837
|
+
await financeInvoiceCommand2({
|
|
4838
|
+
...opts,
|
|
4839
|
+
entityId: parent.entityId,
|
|
4840
|
+
json: inheritOption(opts.json, parent.json)
|
|
4841
|
+
});
|
|
3676
4842
|
});
|
|
3677
|
-
financeCmd.command("payroll").requiredOption("--period-start <date>", "Pay period start").requiredOption("--period-end <date>", "Pay period end").description("Run payroll").action(async (opts, cmd) => {
|
|
4843
|
+
financeCmd.command("payroll").requiredOption("--period-start <date>", "Pay period start").requiredOption("--period-end <date>", "Pay period end").option("--json", "Output as JSON").description("Run payroll").action(async (opts, cmd) => {
|
|
3678
4844
|
const parent = cmd.parent.opts();
|
|
3679
4845
|
const { financePayrollCommand: financePayrollCommand2 } = await Promise.resolve().then(() => (init_finance(), finance_exports));
|
|
3680
|
-
await financePayrollCommand2({
|
|
4846
|
+
await financePayrollCommand2({
|
|
4847
|
+
...opts,
|
|
4848
|
+
entityId: parent.entityId,
|
|
4849
|
+
json: inheritOption(opts.json, parent.json)
|
|
4850
|
+
});
|
|
3681
4851
|
});
|
|
3682
|
-
financeCmd.command("pay").requiredOption("--amount <n>", "Amount in cents", parseInt).requiredOption("--recipient <name>", "Recipient name").option("--method <method>", "Payment method", "ach").description("Submit a payment").action(async (opts, cmd) => {
|
|
4852
|
+
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) => {
|
|
3683
4853
|
const parent = cmd.parent.opts();
|
|
3684
4854
|
const { financePayCommand: financePayCommand2 } = await Promise.resolve().then(() => (init_finance(), finance_exports));
|
|
3685
|
-
await financePayCommand2({
|
|
4855
|
+
await financePayCommand2({
|
|
4856
|
+
...opts,
|
|
4857
|
+
entityId: parent.entityId,
|
|
4858
|
+
json: inheritOption(opts.json, parent.json)
|
|
4859
|
+
});
|
|
3686
4860
|
});
|
|
3687
|
-
financeCmd.command("open-account").option("--institution <name>", "Banking institution", "Mercury").description("Open a business bank account").action(async (opts, cmd) => {
|
|
4861
|
+
financeCmd.command("open-account").option("--institution <name>", "Banking institution", "Mercury").option("--json", "Output as JSON").description("Open a business bank account").action(async (opts, cmd) => {
|
|
3688
4862
|
const parent = cmd.parent.opts();
|
|
3689
4863
|
const { financeOpenAccountCommand: financeOpenAccountCommand2 } = await Promise.resolve().then(() => (init_finance(), finance_exports));
|
|
3690
|
-
await financeOpenAccountCommand2({
|
|
4864
|
+
await financeOpenAccountCommand2({
|
|
4865
|
+
...opts,
|
|
4866
|
+
entityId: parent.entityId,
|
|
4867
|
+
json: inheritOption(opts.json, parent.json)
|
|
4868
|
+
});
|
|
3691
4869
|
});
|
|
3692
|
-
financeCmd.command("classify-contractor").requiredOption("--name <name>", "Contractor name").requiredOption("--state <code>", "US state code").requiredOption("--hours <n>", "Hours per week", parseInt).option("--exclusive", "Exclusive client", false).requiredOption("--duration <n>", "Duration in months", parseInt).option("--provides-tools", "Company provides tools", false).description("Analyze contractor classification risk").action(async (opts, cmd) => {
|
|
4870
|
+
financeCmd.command("classify-contractor").requiredOption("--name <name>", "Contractor name").requiredOption("--state <code>", "US state code").requiredOption("--hours <n>", "Hours per week", parseInt).option("--exclusive", "Exclusive client", false).requiredOption("--duration <n>", "Duration in months", parseInt).option("--provides-tools", "Company provides tools", false).option("--json", "Output as JSON").description("Analyze contractor classification risk").action(async (opts, cmd) => {
|
|
3693
4871
|
const parent = cmd.parent.opts();
|
|
3694
4872
|
const { financeClassifyContractorCommand: financeClassifyContractorCommand2 } = await Promise.resolve().then(() => (init_finance(), finance_exports));
|
|
3695
|
-
await financeClassifyContractorCommand2({
|
|
4873
|
+
await financeClassifyContractorCommand2({
|
|
4874
|
+
...opts,
|
|
4875
|
+
entityId: parent.entityId,
|
|
4876
|
+
json: inheritOption(opts.json, parent.json)
|
|
4877
|
+
});
|
|
3696
4878
|
});
|
|
3697
|
-
financeCmd.command("reconcile").requiredOption("--start-date <date>", "Period start").requiredOption("--end-date <date>", "Period end").description("Reconcile ledger").action(async (opts, cmd) => {
|
|
4879
|
+
financeCmd.command("reconcile").requiredOption("--start-date <date>", "Period start").requiredOption("--end-date <date>", "Period end").option("--json", "Output as JSON").description("Reconcile ledger").action(async (opts, cmd) => {
|
|
3698
4880
|
const parent = cmd.parent.opts();
|
|
3699
4881
|
const { financeReconcileCommand: financeReconcileCommand2 } = await Promise.resolve().then(() => (init_finance(), finance_exports));
|
|
3700
|
-
await financeReconcileCommand2({
|
|
4882
|
+
await financeReconcileCommand2({
|
|
4883
|
+
...opts,
|
|
4884
|
+
entityId: parent.entityId,
|
|
4885
|
+
json: inheritOption(opts.json, parent.json)
|
|
4886
|
+
});
|
|
3701
4887
|
});
|
|
3702
4888
|
var governanceCmd = program.command("governance").description("Governance bodies, seats, meetings, resolutions").option("--entity-id <id>", "Entity ID (overrides active entity)").option("--json", "Output as JSON").action(async (opts) => {
|
|
3703
4889
|
const { governanceListCommand: governanceListCommand2 } = await Promise.resolve().then(() => (init_governance(), governance_exports));
|
|
3704
4890
|
await governanceListCommand2(opts);
|
|
3705
4891
|
});
|
|
3706
|
-
governanceCmd.command("create-body").requiredOption("--name <name>", "Body name (e.g. 'Board of Directors')").requiredOption("--body-type <type>", "Body type (board_of_directors, llc_member_vote)").option("--quorum <rule>", "Quorum rule (majority, supermajority, unanimous)", "majority").option("--voting <method>", "Voting method (per_capita, per_unit)", "per_capita").description("Create a governance body").action(async (opts, cmd) => {
|
|
4892
|
+
governanceCmd.command("create-body").requiredOption("--name <name>", "Body name (e.g. 'Board of Directors')").requiredOption("--body-type <type>", "Body type (board_of_directors, llc_member_vote)").option("--quorum <rule>", "Quorum rule (majority, supermajority, unanimous)", "majority").option("--voting <method>", "Voting method (per_capita, per_unit)", "per_capita").option("--json", "Output as JSON").option("--dry-run", "Show the request without creating the governance body").description("Create a governance body").action(async (opts, cmd) => {
|
|
3707
4893
|
const parent = cmd.parent.opts();
|
|
3708
4894
|
const { governanceCreateBodyCommand: governanceCreateBodyCommand2 } = await Promise.resolve().then(() => (init_governance(), governance_exports));
|
|
3709
|
-
await governanceCreateBodyCommand2({
|
|
4895
|
+
await governanceCreateBodyCommand2({
|
|
4896
|
+
...opts,
|
|
4897
|
+
entityId: parent.entityId,
|
|
4898
|
+
json: inheritOption(opts.json, parent.json)
|
|
4899
|
+
});
|
|
3710
4900
|
});
|
|
3711
|
-
governanceCmd.command("add-seat <body-id>").requiredOption("--holder <contact-id>", "Contact ID for the seat holder").option("--role <role>", "Seat role (chair, member, officer, observer)", "member").description("Add a seat to a governance body").action(async (bodyId, opts, cmd) => {
|
|
4901
|
+
governanceCmd.command("add-seat <body-id>").requiredOption("--holder <contact-id>", "Contact ID for the seat holder").option("--role <role>", "Seat role (chair, member, officer, observer)", "member").option("--json", "Output as JSON").option("--dry-run", "Show the request without adding the seat").description("Add a seat to a governance body").action(async (bodyId, opts, cmd) => {
|
|
3712
4902
|
const parent = cmd.parent.opts();
|
|
3713
4903
|
const { governanceAddSeatCommand: governanceAddSeatCommand2 } = await Promise.resolve().then(() => (init_governance(), governance_exports));
|
|
3714
|
-
await governanceAddSeatCommand2(bodyId, {
|
|
4904
|
+
await governanceAddSeatCommand2(bodyId, {
|
|
4905
|
+
...opts,
|
|
4906
|
+
entityId: parent.entityId,
|
|
4907
|
+
json: inheritOption(opts.json, parent.json)
|
|
4908
|
+
});
|
|
3715
4909
|
});
|
|
3716
4910
|
governanceCmd.command("seats <body-id>").description("Seats for a governance body").action(async (bodyId, _opts, cmd) => {
|
|
3717
4911
|
const parent = cmd.parent.opts();
|
|
@@ -3728,53 +4922,92 @@ governanceCmd.command("resolutions <meeting-id>").description("Resolutions for a
|
|
|
3728
4922
|
const { governanceResolutionsCommand: governanceResolutionsCommand2 } = await Promise.resolve().then(() => (init_governance(), governance_exports));
|
|
3729
4923
|
await governanceResolutionsCommand2(meetingId, parent);
|
|
3730
4924
|
});
|
|
3731
|
-
governanceCmd.command("convene").requiredOption("--body <id>", "Governance body ID").requiredOption("--type <type>", "Meeting type (board_meeting, shareholder_meeting, member_meeting, written_consent)").requiredOption("--title <title>", "Meeting title").
|
|
4925
|
+
governanceCmd.command("convene").requiredOption("--body <id>", "Governance body ID").requiredOption("--type <type>", "Meeting type (board_meeting, shareholder_meeting, member_meeting, written_consent)").requiredOption("--title <title>", "Meeting title").option("--date <date>", "Meeting date (ISO 8601)").option("--agenda <item>", "Agenda item (repeatable)", (v, a) => [...a, v], []).option("--json", "Output as JSON").option("--dry-run", "Show the request without scheduling the meeting").description("Convene a governance meeting").action(async (opts, cmd) => {
|
|
3732
4926
|
const parent = cmd.parent.opts();
|
|
3733
4927
|
const { governanceConveneCommand: governanceConveneCommand2 } = await Promise.resolve().then(() => (init_governance(), governance_exports));
|
|
3734
|
-
await governanceConveneCommand2({
|
|
4928
|
+
await governanceConveneCommand2({
|
|
4929
|
+
...opts,
|
|
4930
|
+
meetingType: opts.type,
|
|
4931
|
+
entityId: parent.entityId,
|
|
4932
|
+
json: inheritOption(opts.json, parent.json)
|
|
4933
|
+
});
|
|
3735
4934
|
});
|
|
3736
|
-
governanceCmd.command("
|
|
4935
|
+
governanceCmd.command("open <meeting-id>").requiredOption("--present-seat <id>", "Seat ID present at the meeting (repeatable)", (v, a) => [...a ?? [], v]).option("--json", "Output as JSON").option("--dry-run", "Show the request without opening the meeting").description("Open a scheduled meeting for voting").action(async (meetingId, opts, cmd) => {
|
|
4936
|
+
const parent = cmd.parent.opts();
|
|
4937
|
+
const { governanceOpenMeetingCommand: governanceOpenMeetingCommand2 } = await Promise.resolve().then(() => (init_governance(), governance_exports));
|
|
4938
|
+
await governanceOpenMeetingCommand2(meetingId, {
|
|
4939
|
+
...opts,
|
|
4940
|
+
entityId: parent.entityId,
|
|
4941
|
+
json: inheritOption(opts.json, parent.json)
|
|
4942
|
+
});
|
|
4943
|
+
});
|
|
4944
|
+
governanceCmd.command("vote <meeting-id> <item-id>").requiredOption("--voter <id>", "Voter contact UUID").addOption(new Option("--vote <value>", "Vote (for, against, abstain, recusal)").choices(["for", "against", "abstain", "recusal"]).makeOptionMandatory()).option("--json", "Output as JSON").option("--dry-run", "Show the request without casting the vote").description("Cast a vote on an agenda item").action(async (meetingId, itemId, opts, cmd) => {
|
|
3737
4945
|
const parent = cmd.parent.opts();
|
|
3738
4946
|
const { governanceVoteCommand: governanceVoteCommand2 } = await Promise.resolve().then(() => (init_governance(), governance_exports));
|
|
3739
4947
|
await governanceVoteCommand2(meetingId, itemId, {
|
|
3740
4948
|
...opts,
|
|
3741
|
-
entityId: parent.entityId
|
|
4949
|
+
entityId: parent.entityId,
|
|
4950
|
+
json: inheritOption(opts.json, parent.json)
|
|
3742
4951
|
});
|
|
3743
4952
|
});
|
|
3744
|
-
governanceCmd.command("notice <meeting-id>").description("Send meeting notice").action(async (meetingId,
|
|
4953
|
+
governanceCmd.command("notice <meeting-id>").option("--json", "Output as JSON").option("--dry-run", "Show the request without sending notices").description("Send meeting notice").action(async (meetingId, opts, cmd) => {
|
|
3745
4954
|
const parent = cmd.parent.opts();
|
|
3746
4955
|
const { sendNoticeCommand: sendNoticeCommand2 } = await Promise.resolve().then(() => (init_governance(), governance_exports));
|
|
3747
|
-
await sendNoticeCommand2(meetingId, {
|
|
4956
|
+
await sendNoticeCommand2(meetingId, {
|
|
4957
|
+
...opts,
|
|
4958
|
+
entityId: parent.entityId,
|
|
4959
|
+
json: inheritOption(opts.json, parent.json)
|
|
4960
|
+
});
|
|
3748
4961
|
});
|
|
3749
|
-
governanceCmd.command("adjourn <meeting-id>").description("Adjourn a meeting").action(async (meetingId,
|
|
4962
|
+
governanceCmd.command("adjourn <meeting-id>").option("--json", "Output as JSON").option("--dry-run", "Show the request without adjourning the meeting").description("Adjourn a meeting").action(async (meetingId, opts, cmd) => {
|
|
3750
4963
|
const parent = cmd.parent.opts();
|
|
3751
4964
|
const { adjournMeetingCommand: adjournMeetingCommand2 } = await Promise.resolve().then(() => (init_governance(), governance_exports));
|
|
3752
|
-
await adjournMeetingCommand2(meetingId, {
|
|
4965
|
+
await adjournMeetingCommand2(meetingId, {
|
|
4966
|
+
...opts,
|
|
4967
|
+
entityId: parent.entityId,
|
|
4968
|
+
json: inheritOption(opts.json, parent.json)
|
|
4969
|
+
});
|
|
3753
4970
|
});
|
|
3754
|
-
governanceCmd.command("cancel <meeting-id>").description("Cancel a meeting").action(async (meetingId,
|
|
4971
|
+
governanceCmd.command("cancel <meeting-id>").option("--json", "Output as JSON").option("--dry-run", "Show the request without cancelling the meeting").description("Cancel a meeting").action(async (meetingId, opts, cmd) => {
|
|
3755
4972
|
const parent = cmd.parent.opts();
|
|
3756
4973
|
const { cancelMeetingCommand: cancelMeetingCommand2 } = await Promise.resolve().then(() => (init_governance(), governance_exports));
|
|
3757
|
-
await cancelMeetingCommand2(meetingId, {
|
|
4974
|
+
await cancelMeetingCommand2(meetingId, {
|
|
4975
|
+
...opts,
|
|
4976
|
+
entityId: parent.entityId,
|
|
4977
|
+
json: inheritOption(opts.json, parent.json)
|
|
4978
|
+
});
|
|
3758
4979
|
});
|
|
3759
4980
|
governanceCmd.command("agenda-items <meeting-id>").description("List agenda items for a meeting").action(async (meetingId, _opts, cmd) => {
|
|
3760
4981
|
const parent = cmd.parent.opts();
|
|
3761
4982
|
const { listAgendaItemsCommand: listAgendaItemsCommand2 } = await Promise.resolve().then(() => (init_governance(), governance_exports));
|
|
3762
4983
|
await listAgendaItemsCommand2(meetingId, { entityId: parent.entityId, json: parent.json });
|
|
3763
4984
|
});
|
|
3764
|
-
governanceCmd.command("finalize-item <meeting-id> <item-id>").requiredOption("--status <status>", "Status: voted, discussed, tabled, withdrawn").description("Finalize an agenda item").action(async (meetingId, itemId, opts, cmd) => {
|
|
4985
|
+
governanceCmd.command("finalize-item <meeting-id> <item-id>").requiredOption("--status <status>", "Status: voted, discussed, tabled, withdrawn").option("--json", "Output as JSON").option("--dry-run", "Show the request without finalizing the item").description("Finalize an agenda item").action(async (meetingId, itemId, opts, cmd) => {
|
|
3765
4986
|
const parent = cmd.parent.opts();
|
|
3766
4987
|
const { finalizeAgendaItemCommand: finalizeAgendaItemCommand2 } = await Promise.resolve().then(() => (init_governance(), governance_exports));
|
|
3767
|
-
await finalizeAgendaItemCommand2(meetingId, itemId, {
|
|
4988
|
+
await finalizeAgendaItemCommand2(meetingId, itemId, {
|
|
4989
|
+
...opts,
|
|
4990
|
+
entityId: parent.entityId,
|
|
4991
|
+
json: inheritOption(opts.json, parent.json)
|
|
4992
|
+
});
|
|
3768
4993
|
});
|
|
3769
|
-
governanceCmd.command("resolve <meeting-id> <item-id>").requiredOption("--text <resolution_text>", "Resolution text").description("Compute a resolution for an agenda item").action(async (meetingId, itemId, opts, cmd) => {
|
|
4994
|
+
governanceCmd.command("resolve <meeting-id> <item-id>").requiredOption("--text <resolution_text>", "Resolution text").option("--json", "Output as JSON").option("--dry-run", "Show the request without computing the resolution").description("Compute a resolution for an agenda item").action(async (meetingId, itemId, opts, cmd) => {
|
|
3770
4995
|
const parent = cmd.parent.opts();
|
|
3771
4996
|
const { computeResolutionCommand: computeResolutionCommand2 } = await Promise.resolve().then(() => (init_governance(), governance_exports));
|
|
3772
|
-
await computeResolutionCommand2(meetingId, itemId, {
|
|
4997
|
+
await computeResolutionCommand2(meetingId, itemId, {
|
|
4998
|
+
...opts,
|
|
4999
|
+
entityId: parent.entityId,
|
|
5000
|
+
json: inheritOption(opts.json, parent.json)
|
|
5001
|
+
});
|
|
3773
5002
|
});
|
|
3774
|
-
governanceCmd.command("written-consent").requiredOption("--body <id>", "Governance body ID").requiredOption("--title <title>", "Title").requiredOption("--description <desc>", "Description").description("Create a written consent action").action(async (opts, cmd) => {
|
|
5003
|
+
governanceCmd.command("written-consent").requiredOption("--body <id>", "Governance body ID").requiredOption("--title <title>", "Title").requiredOption("--description <desc>", "Description").option("--json", "Output as JSON").option("--dry-run", "Show the request without creating the written consent").description("Create a written consent action").action(async (opts, cmd) => {
|
|
3775
5004
|
const parent = cmd.parent.opts();
|
|
3776
5005
|
const { writtenConsentCommand: writtenConsentCommand2 } = await Promise.resolve().then(() => (init_governance(), governance_exports));
|
|
3777
|
-
await writtenConsentCommand2({
|
|
5006
|
+
await writtenConsentCommand2({
|
|
5007
|
+
...opts,
|
|
5008
|
+
entityId: parent.entityId,
|
|
5009
|
+
json: inheritOption(opts.json, parent.json)
|
|
5010
|
+
});
|
|
3778
5011
|
});
|
|
3779
5012
|
var documentsCmd = program.command("documents").description("Documents and signing").option("--entity-id <id>", "Entity ID (overrides active entity)").option("--json", "Output as JSON").action(async (opts) => {
|
|
3780
5013
|
const { documentsListCommand: documentsListCommand2 } = await Promise.resolve().then(() => (init_documents(), documents_exports));
|
|
@@ -3785,26 +5018,42 @@ documentsCmd.command("signing-link <doc-id>").option("--entity-id <id>", "Entity
|
|
|
3785
5018
|
const { documentsSigningLinkCommand: documentsSigningLinkCommand2 } = await Promise.resolve().then(() => (init_documents(), documents_exports));
|
|
3786
5019
|
await documentsSigningLinkCommand2(docId, { entityId: opts.entityId ?? parent.entityId });
|
|
3787
5020
|
});
|
|
3788
|
-
documentsCmd.command("generate").requiredOption("--template <type>", "Template type (consulting_agreement, employment_offer, contractor_agreement, nda, custom)").requiredOption("--counterparty <name>", "Counterparty name").option("--effective-date <date>", "Effective date (ISO 8601, defaults to today)").description("Generate a contract from a template").action(async (opts, cmd) => {
|
|
5021
|
+
documentsCmd.command("generate").requiredOption("--template <type>", "Template type (consulting_agreement, employment_offer, contractor_agreement, nda, custom)").requiredOption("--counterparty <name>", "Counterparty name").option("--effective-date <date>", "Effective date (ISO 8601, defaults to today)").option("--base-salary <amount>", "Employment offer base salary (for employment_offer)").option("--param <key=value>", "Additional template parameter (repeatable)", (value, values) => [...values, value], []).option("--json", "Output as JSON").description("Generate a contract from a template").action(async (opts, cmd) => {
|
|
3789
5022
|
const parent = cmd.parent.opts();
|
|
3790
5023
|
const { documentsGenerateCommand: documentsGenerateCommand2 } = await Promise.resolve().then(() => (init_documents(), documents_exports));
|
|
3791
|
-
await documentsGenerateCommand2({
|
|
5024
|
+
await documentsGenerateCommand2({
|
|
5025
|
+
...opts,
|
|
5026
|
+
entityId: parent.entityId,
|
|
5027
|
+
json: inheritOption(opts.json, parent.json)
|
|
5028
|
+
});
|
|
3792
5029
|
});
|
|
3793
|
-
documentsCmd.command("preview-pdf").requiredOption("--
|
|
5030
|
+
documentsCmd.command("preview-pdf").requiredOption("--definition-id <id>", "AST document definition ID (e.g. 'bylaws')").option("--document-id <id>", "Deprecated alias for --definition-id").description("Validate and print the authenticated PDF preview URL for a governance document").action(async (opts, cmd) => {
|
|
3794
5031
|
const parent = cmd.parent.opts();
|
|
3795
5032
|
const { documentsPreviewPdfCommand: documentsPreviewPdfCommand2 } = await Promise.resolve().then(() => (init_documents(), documents_exports));
|
|
3796
|
-
await documentsPreviewPdfCommand2({
|
|
5033
|
+
await documentsPreviewPdfCommand2({
|
|
5034
|
+
...opts,
|
|
5035
|
+
documentId: opts.definitionId ?? opts.documentId,
|
|
5036
|
+
entityId: parent.entityId
|
|
5037
|
+
});
|
|
3797
5038
|
});
|
|
3798
5039
|
var taxCmd = program.command("tax").description("Tax filings and deadline tracking").option("--entity-id <id>", "Entity ID (overrides active entity)");
|
|
3799
|
-
taxCmd.command("file").
|
|
5040
|
+
taxCmd.command("file").addOption(new Option("--type <type>", `Document type (${TAX_DOCUMENT_TYPE_CHOICES.join(", ")})`).choices([...TAX_DOCUMENT_TYPE_CHOICES]).makeOptionMandatory()).requiredOption("--year <year>", "Tax year", parseInt).option("--json", "Output as JSON").description("File a tax document").action(async (opts, cmd) => {
|
|
3800
5041
|
const parent = cmd.parent.opts();
|
|
3801
5042
|
const { taxFileCommand: taxFileCommand2 } = await Promise.resolve().then(() => (init_tax(), tax_exports));
|
|
3802
|
-
await taxFileCommand2({
|
|
5043
|
+
await taxFileCommand2({
|
|
5044
|
+
...opts,
|
|
5045
|
+
entityId: parent.entityId,
|
|
5046
|
+
json: inheritOption(opts.json, parent.json)
|
|
5047
|
+
});
|
|
3803
5048
|
});
|
|
3804
|
-
taxCmd.command("deadline").requiredOption("--type <type>", "Deadline type").requiredOption("--due-date <date>", "Due date (ISO 8601)").requiredOption("--description <desc>", "Description").option("--recurrence <recurrence>", "Recurrence (e.g. annual; 'yearly' is normalized)").description("Track a compliance deadline").action(async (opts, cmd) => {
|
|
5049
|
+
taxCmd.command("deadline").requiredOption("--type <type>", "Deadline type").requiredOption("--due-date <date>", "Due date (ISO 8601)").requiredOption("--description <desc>", "Description").option("--recurrence <recurrence>", "Recurrence (e.g. annual; 'yearly' is normalized)").option("--json", "Output as JSON").description("Track a compliance deadline").action(async (opts, cmd) => {
|
|
3805
5050
|
const parent = cmd.parent.opts();
|
|
3806
5051
|
const { taxDeadlineCommand: taxDeadlineCommand2 } = await Promise.resolve().then(() => (init_tax(), tax_exports));
|
|
3807
|
-
await taxDeadlineCommand2({
|
|
5052
|
+
await taxDeadlineCommand2({
|
|
5053
|
+
...opts,
|
|
5054
|
+
entityId: parent.entityId,
|
|
5055
|
+
json: inheritOption(opts.json, parent.json)
|
|
5056
|
+
});
|
|
3808
5057
|
});
|
|
3809
5058
|
var agentsCmd = program.command("agents").description("Agent management").option("--json", "Output as JSON").action(async (opts) => {
|
|
3810
5059
|
const { agentsListCommand: agentsListCommand2 } = await Promise.resolve().then(() => (init_agents(), agents_exports));
|
|
@@ -3818,29 +5067,50 @@ agentsCmd.command("show <agent-id>").option("--json", "Output as JSON").descript
|
|
|
3818
5067
|
json: inheritOption(opts.json, parent.json)
|
|
3819
5068
|
});
|
|
3820
5069
|
});
|
|
3821
|
-
agentsCmd.command("create").requiredOption("--name <name>", "Agent name").requiredOption("--prompt <prompt>", "System prompt").option("--model <model>", "Model").description("Create a new agent").action(async (opts) => {
|
|
5070
|
+
agentsCmd.command("create").requiredOption("--name <name>", "Agent name").requiredOption("--prompt <prompt>", "System prompt").option("--model <model>", "Model").option("--json", "Output as JSON").description("Create a new agent").action(async (opts, cmd) => {
|
|
5071
|
+
const parent = cmd.parent.opts();
|
|
3822
5072
|
const { agentsCreateCommand: agentsCreateCommand2 } = await Promise.resolve().then(() => (init_agents(), agents_exports));
|
|
3823
|
-
await agentsCreateCommand2(
|
|
5073
|
+
await agentsCreateCommand2({
|
|
5074
|
+
...opts,
|
|
5075
|
+
json: inheritOption(opts.json, parent.json)
|
|
5076
|
+
});
|
|
3824
5077
|
});
|
|
3825
|
-
agentsCmd.command("pause <agent-id>").description("Pause an agent").action(async (agentId) => {
|
|
5078
|
+
agentsCmd.command("pause <agent-id>").option("--json", "Output as JSON").description("Pause an agent").action(async (agentId, opts, cmd) => {
|
|
5079
|
+
const parent = cmd.parent.opts();
|
|
3826
5080
|
const { agentsPauseCommand: agentsPauseCommand2 } = await Promise.resolve().then(() => (init_agents(), agents_exports));
|
|
3827
|
-
await agentsPauseCommand2(agentId
|
|
5081
|
+
await agentsPauseCommand2(agentId, {
|
|
5082
|
+
json: inheritOption(opts.json, parent.json)
|
|
5083
|
+
});
|
|
3828
5084
|
});
|
|
3829
|
-
agentsCmd.command("resume <agent-id>").description("Resume a paused agent").action(async (agentId) => {
|
|
5085
|
+
agentsCmd.command("resume <agent-id>").option("--json", "Output as JSON").description("Resume a paused agent").action(async (agentId, opts, cmd) => {
|
|
5086
|
+
const parent = cmd.parent.opts();
|
|
3830
5087
|
const { agentsResumeCommand: agentsResumeCommand2 } = await Promise.resolve().then(() => (init_agents(), agents_exports));
|
|
3831
|
-
await agentsResumeCommand2(agentId
|
|
5088
|
+
await agentsResumeCommand2(agentId, {
|
|
5089
|
+
json: inheritOption(opts.json, parent.json)
|
|
5090
|
+
});
|
|
3832
5091
|
});
|
|
3833
|
-
agentsCmd.command("delete <agent-id>").description("Delete an agent").action(async (agentId) => {
|
|
5092
|
+
agentsCmd.command("delete <agent-id>").option("--json", "Output as JSON").description("Delete an agent").action(async (agentId, opts, cmd) => {
|
|
5093
|
+
const parent = cmd.parent.opts();
|
|
3834
5094
|
const { agentsDeleteCommand: agentsDeleteCommand2 } = await Promise.resolve().then(() => (init_agents(), agents_exports));
|
|
3835
|
-
await agentsDeleteCommand2(agentId
|
|
5095
|
+
await agentsDeleteCommand2(agentId, {
|
|
5096
|
+
json: inheritOption(opts.json, parent.json)
|
|
5097
|
+
});
|
|
3836
5098
|
});
|
|
3837
|
-
agentsCmd.command("message <agent-id>").
|
|
5099
|
+
agentsCmd.command("message <agent-id>").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) => {
|
|
5100
|
+
const parent = cmd.parent.opts();
|
|
3838
5101
|
const { agentsMessageCommand: agentsMessageCommand2 } = await Promise.resolve().then(() => (init_agents(), agents_exports));
|
|
3839
|
-
await agentsMessageCommand2(agentId,
|
|
5102
|
+
await agentsMessageCommand2(agentId, {
|
|
5103
|
+
...opts,
|
|
5104
|
+
json: inheritOption(opts.json, parent.json)
|
|
5105
|
+
});
|
|
3840
5106
|
});
|
|
3841
|
-
agentsCmd.command("skill <agent-id>").requiredOption("--name <name>", "Skill name").requiredOption("--description <desc>", "Skill description").option("--instructions <text>", "Instructions").description("Add a skill to an agent").action(async (agentId, opts) => {
|
|
5107
|
+
agentsCmd.command("skill <agent-id>").requiredOption("--name <name>", "Skill name").requiredOption("--description <desc>", "Skill description").option("--instructions <text>", "Instructions").option("--instructions-file <path>", "Read skill instructions from a file").option("--json", "Output as JSON").description("Add a skill to an agent").action(async (agentId, opts, cmd) => {
|
|
5108
|
+
const parent = cmd.parent.opts();
|
|
3842
5109
|
const { agentsSkillCommand: agentsSkillCommand2 } = await Promise.resolve().then(() => (init_agents(), agents_exports));
|
|
3843
|
-
await agentsSkillCommand2(agentId,
|
|
5110
|
+
await agentsSkillCommand2(agentId, {
|
|
5111
|
+
...opts,
|
|
5112
|
+
json: inheritOption(opts.json, parent.json)
|
|
5113
|
+
});
|
|
3844
5114
|
});
|
|
3845
5115
|
var workItemsCmd = program.command("work-items").description("Long-term work item coordination").option("--entity-id <id>", "Entity ID (overrides active entity)").option("--json", "Output as JSON").option("--status <status>", "Filter by status (open, claimed, completed, cancelled)").option("--category <category>", "Filter by category").action(async (opts) => {
|
|
3846
5116
|
const { workItemsListCommand: workItemsListCommand2 } = await Promise.resolve().then(() => (init_work_items(), work_items_exports));
|
|
@@ -3855,34 +5125,61 @@ workItemsCmd.command("show <item-id>").option("--json", "Output as JSON").descri
|
|
|
3855
5125
|
json: inheritOption(opts.json, parent.json)
|
|
3856
5126
|
});
|
|
3857
5127
|
});
|
|
3858
|
-
workItemsCmd.command("create").requiredOption("--title <title>", "Work item title").option("--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").description("Create a new work item").action(async (opts, cmd) => {
|
|
5128
|
+
workItemsCmd.command("create").requiredOption("--title <title>", "Work item title").option("--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) => {
|
|
3859
5129
|
const parent = cmd.parent.opts();
|
|
3860
5130
|
const { workItemsCreateCommand: workItemsCreateCommand2 } = await Promise.resolve().then(() => (init_work_items(), work_items_exports));
|
|
3861
5131
|
await workItemsCreateCommand2({
|
|
3862
5132
|
...opts,
|
|
3863
5133
|
category: inheritOption(opts.category, parent.category),
|
|
3864
|
-
entityId: parent.entityId
|
|
5134
|
+
entityId: parent.entityId,
|
|
5135
|
+
json: inheritOption(opts.json, parent.json)
|
|
3865
5136
|
});
|
|
3866
5137
|
});
|
|
3867
|
-
workItemsCmd.command("claim <item-id>").
|
|
5138
|
+
workItemsCmd.command("claim <item-id>").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) => {
|
|
3868
5139
|
const parent = cmd.parent.opts();
|
|
3869
5140
|
const { workItemsClaimCommand: workItemsClaimCommand2 } = await Promise.resolve().then(() => (init_work_items(), work_items_exports));
|
|
3870
|
-
|
|
5141
|
+
const claimedBy = opts.by ?? opts.claimer;
|
|
5142
|
+
if (!claimedBy) {
|
|
5143
|
+
cmd.error("required option '--by <name>' not specified");
|
|
5144
|
+
return;
|
|
5145
|
+
}
|
|
5146
|
+
await workItemsClaimCommand2(itemId, {
|
|
5147
|
+
claimedBy,
|
|
5148
|
+
ttl: opts.ttl,
|
|
5149
|
+
entityId: parent.entityId,
|
|
5150
|
+
json: inheritOption(opts.json, parent.json)
|
|
5151
|
+
});
|
|
3871
5152
|
});
|
|
3872
|
-
workItemsCmd.command("complete <item-id>").
|
|
5153
|
+
workItemsCmd.command("complete <item-id>").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) => {
|
|
3873
5154
|
const parent = cmd.parent.opts();
|
|
3874
5155
|
const { workItemsCompleteCommand: workItemsCompleteCommand2 } = await Promise.resolve().then(() => (init_work_items(), work_items_exports));
|
|
3875
|
-
|
|
5156
|
+
const completedBy = opts.by ?? opts.completedBy;
|
|
5157
|
+
if (!completedBy) {
|
|
5158
|
+
cmd.error("required option '--by <name>' not specified");
|
|
5159
|
+
return;
|
|
5160
|
+
}
|
|
5161
|
+
await workItemsCompleteCommand2(itemId, {
|
|
5162
|
+
completedBy,
|
|
5163
|
+
result: opts.result ?? opts.notes,
|
|
5164
|
+
entityId: parent.entityId,
|
|
5165
|
+
json: inheritOption(opts.json, parent.json)
|
|
5166
|
+
});
|
|
3876
5167
|
});
|
|
3877
|
-
workItemsCmd.command("release <item-id>").description("Release a claimed work item").action(async (itemId,
|
|
5168
|
+
workItemsCmd.command("release <item-id>").option("--json", "Output as JSON").description("Release a claimed work item").action(async (itemId, opts, cmd) => {
|
|
3878
5169
|
const parent = cmd.parent.opts();
|
|
3879
5170
|
const { workItemsReleaseCommand: workItemsReleaseCommand2 } = await Promise.resolve().then(() => (init_work_items(), work_items_exports));
|
|
3880
|
-
await workItemsReleaseCommand2(itemId, {
|
|
5171
|
+
await workItemsReleaseCommand2(itemId, {
|
|
5172
|
+
entityId: parent.entityId,
|
|
5173
|
+
json: inheritOption(opts.json, parent.json)
|
|
5174
|
+
});
|
|
3881
5175
|
});
|
|
3882
|
-
workItemsCmd.command("cancel <item-id>").description("Cancel a work item").action(async (itemId,
|
|
5176
|
+
workItemsCmd.command("cancel <item-id>").option("--json", "Output as JSON").description("Cancel a work item").action(async (itemId, opts, cmd) => {
|
|
3883
5177
|
const parent = cmd.parent.opts();
|
|
3884
5178
|
const { workItemsCancelCommand: workItemsCancelCommand2 } = await Promise.resolve().then(() => (init_work_items(), work_items_exports));
|
|
3885
|
-
await workItemsCancelCommand2(itemId, {
|
|
5179
|
+
await workItemsCancelCommand2(itemId, {
|
|
5180
|
+
entityId: parent.entityId,
|
|
5181
|
+
json: inheritOption(opts.json, parent.json)
|
|
5182
|
+
});
|
|
3886
5183
|
});
|
|
3887
5184
|
var billingCmd = program.command("billing").description("Billing status, plans, and subscription management").option("--json", "Output as JSON").action(async (opts) => {
|
|
3888
5185
|
const { billingCommand: billingCommand2 } = await Promise.resolve().then(() => (init_billing(), billing_exports));
|
|
@@ -3902,23 +5199,35 @@ program.command("approvals").description("Approvals are managed through governan
|
|
|
3902
5199
|
"Approvals are managed through governance meetings.\n Use: corp governance convene ... to schedule a board meeting\n Use: corp governance vote <meeting-id> <item-id> ... to cast votes"
|
|
3903
5200
|
);
|
|
3904
5201
|
});
|
|
3905
|
-
var formCmd = program.command("form").description("Form a new entity with founders and cap table").option("--entity-type <type>", "Entity type (llc, c_corp)").option("--legal-name <name>", "Legal name").option("--jurisdiction <jurisdiction>", "Jurisdiction (e.g. US-DE, US-WY)").option("--member <member>", "
|
|
5202
|
+
var formCmd = program.command("form").description("Form a new entity with founders and cap table").option("--entity-type <type>", "Entity type (llc, c_corp)").option("--legal-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) => {
|
|
3906
5203
|
if (opts.entityType && !opts.type) opts.type = opts.entityType;
|
|
3907
5204
|
if (opts.legalName && !opts.name) opts.name = opts.legalName;
|
|
3908
5205
|
const { formCommand: formCommand2 } = await Promise.resolve().then(() => (init_form(), form_exports));
|
|
3909
5206
|
await formCommand2(opts);
|
|
3910
5207
|
});
|
|
3911
|
-
formCmd.command("create").description("Create a pending entity (staged flow step 1)").requiredOption("--type <type>", "Entity type (llc, c_corp)").requiredOption("--name <name>", "Legal name").option("--jurisdiction <jurisdiction>", "Jurisdiction (e.g. US-DE, US-WY)").option("--registered-agent-name <name>", "Registered agent legal name").option("--registered-agent-address <address>", "Registered agent address line").option("--formation-date <date>", "Formation date (RFC3339 or YYYY-MM-DD)").option("--fiscal-year-end <date>", "Fiscal year end (MM-DD)").option("--s-corp", "Elect S-Corp status").option("--transfer-restrictions", "Enable transfer restrictions").option("--rofr", "Enable right of first refusal").option("--company-address <address>", "Company address as 'street,city,state,zip'").action(async (opts) => {
|
|
5208
|
+
formCmd.command("create").description("Create a pending entity (staged flow step 1)").requiredOption("--type <type>", "Entity type (llc, c_corp)").requiredOption("--name <name>", "Legal name").option("--jurisdiction <jurisdiction>", "Jurisdiction (e.g. US-DE, US-WY)").option("--registered-agent-name <name>", "Registered agent legal name").option("--registered-agent-address <address>", "Registered agent address line").option("--formation-date <date>", "Formation date (RFC3339 or YYYY-MM-DD)").option("--fiscal-year-end <date>", "Fiscal year end (MM-DD)").option("--s-corp", "Elect S-Corp status").option("--transfer-restrictions", "Enable transfer restrictions").option("--rofr", "Enable right of first refusal").option("--company-address <address>", "Company address as 'street,city,state,zip'").option("--json", "Output as JSON").option("--dry-run", "Show the request without creating the pending entity").action(async (opts, cmd) => {
|
|
3912
5209
|
const { formCreateCommand: formCreateCommand2 } = await Promise.resolve().then(() => (init_form(), form_exports));
|
|
3913
|
-
await formCreateCommand2(
|
|
5210
|
+
await formCreateCommand2({
|
|
5211
|
+
...opts,
|
|
5212
|
+
json: inheritOption(opts.json, cmd.parent.opts().json),
|
|
5213
|
+
dryRun: inheritOption(opts.dryRun, cmd.parent.opts().dryRun)
|
|
5214
|
+
});
|
|
3914
5215
|
});
|
|
3915
|
-
formCmd.command("add-founder <entity-id>").description("Add a founder to a pending entity (staged flow step 2)").requiredOption("--name <name>", "Founder name").requiredOption("--email <email>", "Founder email").requiredOption("--role <role>", "Role: director|officer|manager|member|chair").requiredOption("--pct <pct>", "Ownership percentage").
|
|
5216
|
+
formCmd.command("add-founder <entity-id>").description("Add a founder to a pending entity (staged flow step 2)").requiredOption("--name <name>", "Founder name").requiredOption("--email <email>", "Founder email").requiredOption("--role <role>", "Role: director|officer|manager|member|chair").requiredOption("--pct <pct>", "Ownership percentage").addOption(new Option("--officer-title <title>", "Officer title (corporations only)").choices(["ceo", "cfo", "cto", "coo", "secretary", "treasurer", "president", "vp", "other"])).option("--incorporator", "Mark as sole incorporator (corporations only)").option("--address <address>", "Founder address as 'street,city,state,zip'").option("--json", "Output as JSON").option("--dry-run", "Show the request without adding the founder").action(async (entityId, opts, cmd) => {
|
|
3916
5217
|
const { formAddFounderCommand: formAddFounderCommand2 } = await Promise.resolve().then(() => (init_form(), form_exports));
|
|
3917
|
-
await formAddFounderCommand2(entityId,
|
|
5218
|
+
await formAddFounderCommand2(entityId, {
|
|
5219
|
+
...opts,
|
|
5220
|
+
json: inheritOption(opts.json, cmd.parent.opts().json),
|
|
5221
|
+
dryRun: inheritOption(opts.dryRun, cmd.parent.opts().dryRun)
|
|
5222
|
+
});
|
|
3918
5223
|
});
|
|
3919
|
-
formCmd.command("finalize <entity-id>").description("Finalize formation and generate documents + cap table (staged flow step 3)").option("--authorized-shares <count>", "Authorized shares for corporations").option("--par-value <value>", "Par value per share, e.g. 0.0001").option("--registered-agent-name <name>", "Registered agent legal name").option("--registered-agent-address <address>", "Registered agent address line").option("--formation-date <date>", "Formation date (RFC3339 or YYYY-MM-DD)").option("--fiscal-year-end <date>", "Fiscal year end (MM-DD)").option("--s-corp", "Elect S-Corp status").option("--transfer-restrictions", "Enable transfer restrictions").option("--rofr", "Enable right of first refusal").option("--company-address <address>", "Company address as 'street,city,state,zip'").action(async (entityId, opts) => {
|
|
5224
|
+
formCmd.command("finalize <entity-id>").description("Finalize formation and generate documents + cap table (staged flow step 3)").option("--authorized-shares <count>", "Authorized shares for corporations").option("--par-value <value>", "Par value per share, e.g. 0.0001").option("--board-size <count>", "Board size for corporations").option("--principal-name <name>", "Principal or manager name for LLCs").option("--registered-agent-name <name>", "Registered agent legal name").option("--registered-agent-address <address>", "Registered agent address line").option("--formation-date <date>", "Formation date (RFC3339 or YYYY-MM-DD)").option("--fiscal-year-end <date>", "Fiscal year end (MM-DD)").option("--s-corp", "Elect S-Corp status").option("--transfer-restrictions", "Enable transfer restrictions").option("--rofr", "Enable right of first refusal").option("--company-address <address>", "Company address as 'street,city,state,zip'").option("--incorporator-name <name>", "Incorporator legal name (overrides founder)").option("--incorporator-address <address>", "Incorporator mailing address (overrides founder)").option("--json", "Output as JSON").option("--dry-run", "Show the request without finalizing formation").action(async (entityId, opts, cmd) => {
|
|
3920
5225
|
const { formFinalizeCommand: formFinalizeCommand2 } = await Promise.resolve().then(() => (init_form(), form_exports));
|
|
3921
|
-
await formFinalizeCommand2(entityId,
|
|
5226
|
+
await formFinalizeCommand2(entityId, {
|
|
5227
|
+
...opts,
|
|
5228
|
+
json: inheritOption(opts.json, cmd.parent.opts().json),
|
|
5229
|
+
dryRun: inheritOption(opts.dryRun, cmd.parent.opts().dryRun)
|
|
5230
|
+
});
|
|
3922
5231
|
});
|
|
3923
5232
|
program.command("api-keys").description("List API keys").option("--json", "Output as JSON").action(async (opts) => {
|
|
3924
5233
|
const { apiKeysCommand: apiKeysCommand2 } = await Promise.resolve().then(() => (init_api_keys(), api_keys_exports));
|
|
@@ -3928,9 +5237,13 @@ program.command("demo").description("Seed a fully-populated demo corporation").r
|
|
|
3928
5237
|
const { demoCommand: demoCommand2 } = await Promise.resolve().then(() => (init_demo(), demo_exports));
|
|
3929
5238
|
await demoCommand2(opts);
|
|
3930
5239
|
});
|
|
5240
|
+
program.command("feedback").description("Submit feedback to TheCorporation").argument("<message>", "Feedback message").option("--category <category>", "Category (e.g. bug, feature, general)", "general").option("--email <email>", "Your email address (to receive a copy)").action(async (message, opts) => {
|
|
5241
|
+
const { feedbackCommand: feedbackCommand2 } = await Promise.resolve().then(() => (init_feedback(), feedback_exports));
|
|
5242
|
+
await feedbackCommand2(message, opts);
|
|
5243
|
+
});
|
|
3931
5244
|
program.command("serve").description("Start the API server locally").option("--port <port>", "Port to listen on", "8000").option("--data-dir <path>", "Data directory", "./data/repos").action(async (opts) => {
|
|
3932
5245
|
const { serveCommand: serveCommand2 } = await Promise.resolve().then(() => (init_serve(), serve_exports));
|
|
3933
5246
|
await serveCommand2(opts);
|
|
3934
5247
|
});
|
|
3935
|
-
program.
|
|
5248
|
+
await program.parseAsync(process.argv);
|
|
3936
5249
|
//# sourceMappingURL=index.js.map
|