@thecorporation/cli 26.3.44 → 26.3.46
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 +65 -28
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -190,8 +190,10 @@ import {
|
|
|
190
190
|
} from "fs";
|
|
191
191
|
import { homedir } from "os";
|
|
192
192
|
import { join } from "path";
|
|
193
|
-
function
|
|
194
|
-
|
|
193
|
+
function spinWaitMs(ms) {
|
|
194
|
+
const end = Date.now() + ms;
|
|
195
|
+
while (Date.now() < end) {
|
|
196
|
+
}
|
|
195
197
|
}
|
|
196
198
|
function withConfigLock(fn) {
|
|
197
199
|
mkdirSync(CONFIG_DIR, { recursive: true, mode: 448 });
|
|
@@ -215,7 +217,7 @@ function withConfigLock(fn) {
|
|
|
215
217
|
if (Date.now() - startedAt >= CONFIG_LOCK_TIMEOUT_MS) {
|
|
216
218
|
throw new Error("timed out waiting for the corp config lock");
|
|
217
219
|
}
|
|
218
|
-
|
|
220
|
+
spinWaitMs(CONFIG_LOCK_RETRY_MS);
|
|
219
221
|
}
|
|
220
222
|
}
|
|
221
223
|
try {
|
|
@@ -667,7 +669,7 @@ function resolveEntityId(cfg, explicitId) {
|
|
|
667
669
|
}
|
|
668
670
|
return eid;
|
|
669
671
|
}
|
|
670
|
-
var CONFIG_DIR, CONFIG_FILE, AUTH_FILE, CONFIG_LOCK_DIR, CONFIG_LOCK_TIMEOUT_MS, CONFIG_LOCK_RETRY_MS, CONFIG_STALE_LOCK_MS, MAX_LAST_REFERENCES, TRUSTED_API_HOST_SUFFIXES,
|
|
672
|
+
var CONFIG_DIR, CONFIG_FILE, AUTH_FILE, CONFIG_LOCK_DIR, CONFIG_LOCK_TIMEOUT_MS, CONFIG_LOCK_RETRY_MS, CONFIG_STALE_LOCK_MS, MAX_LAST_REFERENCES, TRUSTED_API_HOST_SUFFIXES, ALLOWED_CONFIG_KEYS, SENSITIVE_CONFIG_KEYS, DEFAULTS;
|
|
671
673
|
var init_config = __esm({
|
|
672
674
|
"src/config.ts"() {
|
|
673
675
|
"use strict";
|
|
@@ -680,8 +682,6 @@ var init_config = __esm({
|
|
|
680
682
|
CONFIG_STALE_LOCK_MS = 6e4;
|
|
681
683
|
MAX_LAST_REFERENCES = 4096;
|
|
682
684
|
TRUSTED_API_HOST_SUFFIXES = ["thecorporation.ai"];
|
|
683
|
-
CONFIG_WAIT_BUFFER = new SharedArrayBuffer(4);
|
|
684
|
-
CONFIG_WAIT_SIGNAL = new Int32Array(CONFIG_WAIT_BUFFER);
|
|
685
685
|
ALLOWED_CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
686
686
|
"api_url",
|
|
687
687
|
"api_key",
|
|
@@ -792,6 +792,14 @@ var init_references = __esm({
|
|
|
792
792
|
this.cfg = cfg;
|
|
793
793
|
this.tracker = new ReferenceTracker(new NodeReferenceStorage(cfg));
|
|
794
794
|
}
|
|
795
|
+
/**
|
|
796
|
+
* Public generic resolver for any resource kind.
|
|
797
|
+
* Used by the generic executor when a positional arg declares `posKind`.
|
|
798
|
+
* Entity-scoped kinds require an entityId in the scope.
|
|
799
|
+
*/
|
|
800
|
+
async resolveByKind(kind, ref, entityId) {
|
|
801
|
+
return this.resolve(kind, ref, { entityId });
|
|
802
|
+
}
|
|
795
803
|
async resolveEntity(ref) {
|
|
796
804
|
if (ref !== void 0 && ref !== null && !ref.trim()) {
|
|
797
805
|
throw new Error(
|
|
@@ -2877,7 +2885,7 @@ var init_entities = __esm({
|
|
|
2877
2885
|
name: "contacts notification-prefs",
|
|
2878
2886
|
description: "View notification preferences for a contact",
|
|
2879
2887
|
route: { method: "GET", path: "/v1/contacts/{pos}/notification-prefs" },
|
|
2880
|
-
args: [{ name: "contact-id", required: true, description: "Contact ID" }],
|
|
2888
|
+
args: [{ name: "contact-id", required: true, description: "Contact ID", posKind: "contact" }],
|
|
2881
2889
|
display: { title: "Contacts Notification Prefs", cols: ["#contact_id>ID", "email_enabled>Email Enabled", "sms_enabled>Sms Enabled", "@updated_at>Updated At", "webhook_enabled>Webhook Enabled"] },
|
|
2882
2890
|
examples: ["corp contacts notification-prefs"]
|
|
2883
2891
|
},
|
|
@@ -2885,7 +2893,7 @@ var init_entities = __esm({
|
|
|
2885
2893
|
name: "contacts update-notification-prefs",
|
|
2886
2894
|
description: "View notification preferences for a contact",
|
|
2887
2895
|
route: { method: "PATCH", path: "/v1/contacts/{pos}/notification-prefs" },
|
|
2888
|
-
args: [{ name: "contact-id", required: true, description: "Contact ID" }],
|
|
2896
|
+
args: [{ name: "contact-id", required: true, description: "Contact ID", posKind: "contact" }],
|
|
2889
2897
|
options: [
|
|
2890
2898
|
{ flags: "--email-enabled <email-enabled>", description: "Email Enabled" },
|
|
2891
2899
|
{ flags: "--sms-enabled <sms-enabled>", description: "Sms Enabled" },
|
|
@@ -4374,7 +4382,7 @@ var init_formation = __esm({
|
|
|
4374
4382
|
description: "View a document by ID",
|
|
4375
4383
|
route: { method: "GET", path: "/v1/documents/{pos}" },
|
|
4376
4384
|
entity: true,
|
|
4377
|
-
args: [{ name: "document-id", required: true, description: "Document ID" }],
|
|
4385
|
+
args: [{ name: "document-id", required: true, description: "Document ID", posKind: "document" }],
|
|
4378
4386
|
display: { title: "Document", cols: ["document_type>Type", "status>Status", "title>Title", "signature_count>Signatures", "@created_at>Created", "#document_id>ID"] },
|
|
4379
4387
|
examples: ["corp documents show <document-id>", "corp documents show <document-id> --json"]
|
|
4380
4388
|
},
|
|
@@ -4383,7 +4391,7 @@ var init_formation = __esm({
|
|
|
4383
4391
|
description: "View amendment history for a document",
|
|
4384
4392
|
route: { method: "GET", path: "/v1/documents/{pos}/amendment-history" },
|
|
4385
4393
|
entity: true,
|
|
4386
|
-
args: [{ name: "document-id", required: true, description: "Document ID" }],
|
|
4394
|
+
args: [{ name: "document-id", required: true, description: "Document ID", posKind: "document" }],
|
|
4387
4395
|
display: { title: "Documents Amendment History", cols: ["amended_at>Amended At", "description>Description", "version>Version"] },
|
|
4388
4396
|
examples: ["corp documents amendment-history", "corp documents amendment-history --json"]
|
|
4389
4397
|
},
|
|
@@ -4392,14 +4400,14 @@ var init_formation = __esm({
|
|
|
4392
4400
|
description: "Download a document as PDF",
|
|
4393
4401
|
route: { method: "GET", path: "/v1/documents/{pos}/pdf" },
|
|
4394
4402
|
entity: true,
|
|
4395
|
-
args: [{ name: "document-id", required: true, description: "Document ID" }],
|
|
4403
|
+
args: [{ name: "document-id", required: true, description: "Document ID", posKind: "document" }],
|
|
4396
4404
|
examples: ["corp documents pdf", "corp documents pdf --json"]
|
|
4397
4405
|
},
|
|
4398
4406
|
{
|
|
4399
4407
|
name: "documents request-copy",
|
|
4400
4408
|
description: "Request a certified copy of a document",
|
|
4401
4409
|
route: { method: "POST", path: "/v1/documents/{pos}/request-copy" },
|
|
4402
|
-
args: [{ name: "document-id", required: true, description: "Document ID" }],
|
|
4410
|
+
args: [{ name: "document-id", required: true, description: "Document ID", posKind: "document" }],
|
|
4403
4411
|
options: [
|
|
4404
4412
|
{ flags: "--recipient-email <recipient-email>", description: "Recipient Email" }
|
|
4405
4413
|
],
|
|
@@ -8983,7 +8991,7 @@ var init_agents = __esm({
|
|
|
8983
8991
|
name: "agents executions-logs",
|
|
8984
8992
|
description: "View execution logs for an agent run",
|
|
8985
8993
|
route: { method: "GET", path: "/v1/agents/{pos}/executions/{pos2}/logs" },
|
|
8986
|
-
args: [{ name: "agent-id", required: true, description: "Agent ID" }, { name: "execution-id", required: true, description: "Agent execution ID" }],
|
|
8994
|
+
args: [{ name: "agent-id", required: true, description: "Agent ID", posKind: "agent" }, { name: "execution-id", required: true, description: "Agent execution ID" }],
|
|
8987
8995
|
display: { title: "Execution Logs", cols: ["@timestamp>Time", "level>Level", "message>Message"] },
|
|
8988
8996
|
examples: ["corp agents executions-logs"]
|
|
8989
8997
|
},
|
|
@@ -8992,7 +9000,7 @@ var init_agents = __esm({
|
|
|
8992
9000
|
name: "agents messages",
|
|
8993
9001
|
description: "View a specific agent message",
|
|
8994
9002
|
route: { method: "GET", path: "/v1/agents/{pos}/messages/{pos2}" },
|
|
8995
|
-
args: [{ name: "agent-id", required: true, description: "Agent ID" }, { name: "message-id", required: true, description: "Message Id" }],
|
|
9003
|
+
args: [{ name: "agent-id", required: true, description: "Agent ID", posKind: "agent" }, { name: "message-id", required: true, description: "Message Id" }],
|
|
8996
9004
|
display: { title: "Agent Message" },
|
|
8997
9005
|
examples: ["corp agents messages"]
|
|
8998
9006
|
}
|
|
@@ -9465,7 +9473,7 @@ var init_services = __esm({
|
|
|
9465
9473
|
description: "Submit a new service request",
|
|
9466
9474
|
route: { method: "GET", path: "/v1/services/requests/{pos}" },
|
|
9467
9475
|
entity: true,
|
|
9468
|
-
args: [{ name: "request-id", required: true, description: "Document request ID" }],
|
|
9476
|
+
args: [{ name: "request-id", required: true, description: "Document request ID", posKind: "service_request" }],
|
|
9469
9477
|
display: { title: "Services Requests", cols: ["amount_cents>Amount Cents", "checkout_url>Checkout Url", "failed_at>Failed At", "fulfilled_at>Fulfilled At", "@created_at>Created At", "#entity_id>ID"] },
|
|
9470
9478
|
examples: ["corp services requests", "corp services requests --json"]
|
|
9471
9479
|
},
|
|
@@ -9473,7 +9481,7 @@ var init_services = __esm({
|
|
|
9473
9481
|
name: "services requests-cancel",
|
|
9474
9482
|
description: "Cancel a service request",
|
|
9475
9483
|
route: { method: "POST", path: "/v1/services/requests/{pos}/cancel" },
|
|
9476
|
-
args: [{ name: "request-id", required: true, description: "Document request ID" }],
|
|
9484
|
+
args: [{ name: "request-id", required: true, description: "Document request ID", posKind: "service_request" }],
|
|
9477
9485
|
examples: ["corp services requests-cancel <request-id>"],
|
|
9478
9486
|
successTemplate: "Requests Cancel created"
|
|
9479
9487
|
},
|
|
@@ -9481,7 +9489,7 @@ var init_services = __esm({
|
|
|
9481
9489
|
name: "services requests-checkout",
|
|
9482
9490
|
description: "Start checkout for a service request",
|
|
9483
9491
|
route: { method: "POST", path: "/v1/services/requests/{pos}/checkout" },
|
|
9484
|
-
args: [{ name: "request-id", required: true, description: "Document request ID" }],
|
|
9492
|
+
args: [{ name: "request-id", required: true, description: "Document request ID", posKind: "service_request" }],
|
|
9485
9493
|
examples: ["corp services requests-checkout <request-id>"],
|
|
9486
9494
|
successTemplate: "Requests Checkout created"
|
|
9487
9495
|
},
|
|
@@ -9489,7 +9497,7 @@ var init_services = __esm({
|
|
|
9489
9497
|
name: "services requests-fulfill",
|
|
9490
9498
|
description: "Fulfill a service request",
|
|
9491
9499
|
route: { method: "POST", path: "/v1/services/requests/{pos}/fulfill" },
|
|
9492
|
-
args: [{ name: "request-id", required: true, description: "Document request ID" }],
|
|
9500
|
+
args: [{ name: "request-id", required: true, description: "Document request ID", posKind: "service_request" }],
|
|
9493
9501
|
options: [
|
|
9494
9502
|
{ flags: "--note <note>", description: "Note" }
|
|
9495
9503
|
],
|
|
@@ -10137,7 +10145,12 @@ var init_demo = __esm({
|
|
|
10137
10145
|
|
|
10138
10146
|
// src/llm.ts
|
|
10139
10147
|
async function chat(messages, tools, provider = "openrouter", apiKey = "", model = "", baseUrl) {
|
|
10140
|
-
const effectiveUrl = baseUrl ?? PROVIDER_BASE_URLS[provider]
|
|
10148
|
+
const effectiveUrl = baseUrl ?? PROVIDER_BASE_URLS[provider];
|
|
10149
|
+
if (!effectiveUrl) {
|
|
10150
|
+
throw new Error(
|
|
10151
|
+
`Unknown LLM provider "${provider}". Supported providers: ${Object.keys(PROVIDER_BASE_URLS).join(", ")}. Set llm.base_url in your config to use a custom provider.`
|
|
10152
|
+
);
|
|
10153
|
+
}
|
|
10141
10154
|
const { default: OpenAIClient } = await import("openai");
|
|
10142
10155
|
const client = new OpenAIClient({ apiKey, baseURL: effectiveUrl });
|
|
10143
10156
|
const params = {
|
|
@@ -10180,6 +10193,8 @@ var init_llm = __esm({
|
|
|
10180
10193
|
"src/llm.ts"() {
|
|
10181
10194
|
"use strict";
|
|
10182
10195
|
PROVIDER_BASE_URLS = {
|
|
10196
|
+
anthropic: "https://api.anthropic.com/v1",
|
|
10197
|
+
openai: "https://api.openai.com/v1",
|
|
10183
10198
|
openrouter: "https://openrouter.ai/api/v1"
|
|
10184
10199
|
};
|
|
10185
10200
|
}
|
|
@@ -11847,7 +11862,7 @@ var init_treasury = __esm({
|
|
|
11847
11862
|
description: "Close a bank account",
|
|
11848
11863
|
route: { method: "POST", path: "/v1/bank-accounts/{pos}/close" },
|
|
11849
11864
|
entity: true,
|
|
11850
|
-
args: [{ name: "bank-account-id", required: true, description: "Bank account ID" }],
|
|
11865
|
+
args: [{ name: "bank-account-id", required: true, description: "Bank account ID", posKind: "bank_account" }],
|
|
11851
11866
|
examples: ["corp bank-accounts close <bank-account-id>"],
|
|
11852
11867
|
successTemplate: "Close created"
|
|
11853
11868
|
},
|
|
@@ -11914,7 +11929,7 @@ var init_treasury = __esm({
|
|
|
11914
11929
|
description: "Create a new invoice",
|
|
11915
11930
|
route: { method: "GET", path: "/v1/invoices/{pos}" },
|
|
11916
11931
|
entity: true,
|
|
11917
|
-
args: [{ name: "invoice-id", required: true, description: "Invoice ID" }],
|
|
11932
|
+
args: [{ name: "invoice-id", required: true, description: "Invoice ID", posKind: "invoice" }],
|
|
11918
11933
|
display: { title: "Invoices", cols: ["amount_cents>Amount Cents", "customer_name>Customer Name", "description>Description", "status>Status", "@created_at>Created At", "#entity_id>ID"] },
|
|
11919
11934
|
examples: ["corp invoices", "corp invoices --json"]
|
|
11920
11935
|
},
|
|
@@ -11923,7 +11938,7 @@ var init_treasury = __esm({
|
|
|
11923
11938
|
description: "Mark an invoice as paid",
|
|
11924
11939
|
route: { method: "POST", path: "/v1/invoices/{pos}/mark-paid" },
|
|
11925
11940
|
entity: true,
|
|
11926
|
-
args: [{ name: "invoice-id", required: true, description: "Invoice ID" }],
|
|
11941
|
+
args: [{ name: "invoice-id", required: true, description: "Invoice ID", posKind: "invoice" }],
|
|
11927
11942
|
examples: ["corp invoices mark-paid <invoice-id>"],
|
|
11928
11943
|
successTemplate: "Mark Paid created"
|
|
11929
11944
|
},
|
|
@@ -11932,7 +11947,7 @@ var init_treasury = __esm({
|
|
|
11932
11947
|
description: "Get payment instructions for an invoice",
|
|
11933
11948
|
route: { method: "GET", path: "/v1/invoices/{pos}/pay-instructions" },
|
|
11934
11949
|
entity: true,
|
|
11935
|
-
args: [{ name: "invoice-id", required: true, description: "Invoice ID" }],
|
|
11950
|
+
args: [{ name: "invoice-id", required: true, description: "Invoice ID", posKind: "invoice" }],
|
|
11936
11951
|
display: { title: "Invoices Pay Instructions", cols: ["amount_cents>Amount Cents", "currency>Currency", "instructions>Instructions", "#invoice_id>ID", "payment_method>Payment Method"] },
|
|
11937
11952
|
examples: ["corp invoices pay-instructions", "corp invoices pay-instructions --json"]
|
|
11938
11953
|
},
|
|
@@ -11941,7 +11956,7 @@ var init_treasury = __esm({
|
|
|
11941
11956
|
description: "Send an invoice to the recipient",
|
|
11942
11957
|
route: { method: "POST", path: "/v1/invoices/{pos}/send" },
|
|
11943
11958
|
entity: true,
|
|
11944
|
-
args: [{ name: "invoice-id", required: true, description: "Invoice ID" }],
|
|
11959
|
+
args: [{ name: "invoice-id", required: true, description: "Invoice ID", posKind: "invoice" }],
|
|
11945
11960
|
examples: ["corp invoices send <invoice-id>"],
|
|
11946
11961
|
successTemplate: "Send created"
|
|
11947
11962
|
},
|
|
@@ -11950,7 +11965,7 @@ var init_treasury = __esm({
|
|
|
11950
11965
|
description: "Check invoice payment status",
|
|
11951
11966
|
route: { method: "GET", path: "/v1/invoices/{pos}/status" },
|
|
11952
11967
|
entity: true,
|
|
11953
|
-
args: [{ name: "invoice-id", required: true, description: "Invoice ID" }],
|
|
11968
|
+
args: [{ name: "invoice-id", required: true, description: "Invoice ID", posKind: "invoice" }],
|
|
11954
11969
|
display: { title: "Invoices Status", cols: ["amount_cents>Amount Cents", "customer_name>Customer Name", "description>Description", "status>Status", "@created_at>Created At", "#entity_id>ID"] },
|
|
11955
11970
|
examples: ["corp invoices status", "corp invoices status --json"]
|
|
11956
11971
|
},
|
|
@@ -12497,6 +12512,22 @@ function displayPanel(data, title, ctx) {
|
|
|
12497
12512
|
});
|
|
12498
12513
|
ctx.writer.panel(title, "blue", lines);
|
|
12499
12514
|
}
|
|
12515
|
+
function getPosKind(def, posIndex) {
|
|
12516
|
+
if (!def.args) return void 0;
|
|
12517
|
+
let argIdx = 0;
|
|
12518
|
+
for (const arg of def.args) {
|
|
12519
|
+
if (argIdx === posIndex) {
|
|
12520
|
+
return arg.posKind;
|
|
12521
|
+
}
|
|
12522
|
+
argIdx++;
|
|
12523
|
+
}
|
|
12524
|
+
return void 0;
|
|
12525
|
+
}
|
|
12526
|
+
async function resolvePositional(def, posIndex, rawValue, ctx) {
|
|
12527
|
+
const kind = getPosKind(def, posIndex);
|
|
12528
|
+
if (!kind) return rawValue;
|
|
12529
|
+
return ctx.resolver.resolveByKind(kind, rawValue, ctx.entityId);
|
|
12530
|
+
}
|
|
12500
12531
|
async function executeGenericRead(def, ctx) {
|
|
12501
12532
|
if (!def.route?.path) {
|
|
12502
12533
|
ctx.writer.error("No route defined for this command");
|
|
@@ -12528,7 +12559,9 @@ async function executeGenericRead(def, ctx) {
|
|
|
12528
12559
|
ctx.writer.error("Missing required argument (ID or reference).");
|
|
12529
12560
|
return;
|
|
12530
12561
|
}
|
|
12531
|
-
|
|
12562
|
+
const resolved = await resolvePositional(def, posIdx, ctx.positional[posIdx], ctx);
|
|
12563
|
+
posIdx++;
|
|
12564
|
+
path = path.replace("{pos}", encodeURIComponent(resolved));
|
|
12532
12565
|
}
|
|
12533
12566
|
path = path.replace("{wid}", encodeURIComponent(ctx.client.workspaceId));
|
|
12534
12567
|
path = path.replace("{workspace_id}", encodeURIComponent(ctx.client.workspaceId));
|
|
@@ -12598,14 +12631,18 @@ async function executeGenericWrite(def, ctx) {
|
|
|
12598
12631
|
ctx.writer.error("Missing required argument (ID or reference).");
|
|
12599
12632
|
return;
|
|
12600
12633
|
}
|
|
12601
|
-
|
|
12634
|
+
const resolved = await resolvePositional(def, posIdx, ctx.positional[posIdx], ctx);
|
|
12635
|
+
posIdx++;
|
|
12636
|
+
path = path.replace("{pos}", encodeURIComponent(resolved));
|
|
12602
12637
|
}
|
|
12603
12638
|
if (path.includes("{pos2}")) {
|
|
12604
12639
|
if (!ctx.positional[posIdx]) {
|
|
12605
12640
|
ctx.writer.error("Missing required second argument (ID or reference).");
|
|
12606
12641
|
return;
|
|
12607
12642
|
}
|
|
12608
|
-
|
|
12643
|
+
const resolved = await resolvePositional(def, posIdx, ctx.positional[posIdx], ctx);
|
|
12644
|
+
posIdx++;
|
|
12645
|
+
path = path.replace("{pos2}", encodeURIComponent(resolved));
|
|
12609
12646
|
}
|
|
12610
12647
|
path = path.replace("{wid}", encodeURIComponent(ctx.client.workspaceId));
|
|
12611
12648
|
path = path.replace("{workspace_id}", encodeURIComponent(ctx.client.workspaceId));
|