@thecorporation/corp-tools 26.3.22 → 26.3.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -3213,7 +3213,7 @@ type DigestTriggerResponse = components["schemas"]["DigestTriggerResponse"];
3213
3213
  type InvoiceResponse = components["schemas"]["InvoiceResponse"];
3214
3214
 
3215
3215
  declare class SessionExpiredError extends Error {
3216
- constructor();
3216
+ constructor(detail?: string);
3217
3217
  }
3218
3218
  declare function provisionWorkspace(apiUrl: string, name?: string): Promise<ApiRecord>;
3219
3219
  declare class CorpAPIClient {
@@ -3289,6 +3289,13 @@ declare class CorpAPIClient {
3289
3289
  computeResolution(meetingId: string, itemId: string, entityId: string, data: ApiRecord): Promise<ResolutionResponse>;
3290
3290
  attachResolutionDocument(meetingId: string, resolutionId: string, data: ApiRecord): Promise<ResolutionResponse>;
3291
3291
  writtenConsent(data: ApiRecord): Promise<WrittenConsentResponse>;
3292
+ getGovernanceMode(entityId: string): Promise<ApiRecord>;
3293
+ setGovernanceMode(data: ApiRecord): Promise<ApiRecord>;
3294
+ resignSeat(seatId: string, entityId: string): Promise<ApiRecord>;
3295
+ createGovernanceIncident(data: ApiRecord): Promise<ApiRecord>;
3296
+ listGovernanceIncidents(entityId: string): Promise<ApiRecord[]>;
3297
+ resolveGovernanceIncident(incidentId: string, data: ApiRecord): Promise<ApiRecord>;
3298
+ getGovernanceProfile(entityId: string): Promise<ApiRecord>;
3292
3299
  listAgendaItems(meetingId: string, entityId: string): Promise<AgendaItemResponse[]>;
3293
3300
  listVotes(meetingId: string, itemId: string, entityId: string): Promise<VoteResponse[]>;
3294
3301
  getEntityDocuments(entityId: string): Promise<DocumentResponse[]>;
@@ -3308,8 +3315,12 @@ declare class CorpAPIClient {
3308
3315
  runPayroll(data: ApiRecord): Promise<ApiRecord>;
3309
3316
  submitPayment(data: ApiRecord): Promise<ApiRecord>;
3310
3317
  openBankAccount(data: ApiRecord): Promise<ApiRecord>;
3318
+ activateBankAccount(bankAccountId: string, entityId: string): Promise<ApiRecord>;
3311
3319
  classifyContractor(data: ApiRecord): Promise<ApiRecord>;
3312
3320
  reconcileLedger(data: ApiRecord): Promise<ApiRecord>;
3321
+ getFinancialStatements(entityId: string, params?: Record<string, string>): Promise<ApiRecord>;
3322
+ getDilutionPreview(entityId: string, roundId: string): Promise<ApiRecord>;
3323
+ getControlMap(entityId: string, rootEntityId: string): Promise<ApiRecord>;
3313
3324
  listTaxFilings(entityId: string): Promise<ApiRecord[]>;
3314
3325
  listDeadlines(entityId: string): Promise<ApiRecord[]>;
3315
3326
  listContractorClassifications(entityId: string): Promise<ApiRecord[]>;
@@ -3347,6 +3358,10 @@ declare class CorpAPIClient {
3347
3358
  sendAgentMessage(id: string, message: string): Promise<ApiRecord>;
3348
3359
  addAgentSkill(id: string, data: ApiRecord): Promise<ApiRecord>;
3349
3360
  listSupportedModels(): Promise<ApiRecord[]>;
3361
+ getAgentExecution(agentId: string, executionId: string): Promise<ApiRecord>;
3362
+ getAgentExecutionResult(agentId: string, executionId: string): Promise<ApiRecord>;
3363
+ getAgentExecutionLogs(agentId: string, executionId: string): Promise<ApiRecord>;
3364
+ killAgentExecution(agentId: string, executionId: string): Promise<ApiRecord>;
3350
3365
  createGovernanceBody(data: ApiRecord): Promise<ApiRecord>;
3351
3366
  createGovernanceSeat(bodyId: string, entityId: string, data: ApiRecord): Promise<ApiRecord>;
3352
3367
  listWorkItems(entityId: string, params?: Record<string, string>): Promise<ApiRecord[]>;
@@ -3357,6 +3372,9 @@ declare class CorpAPIClient {
3357
3372
  releaseWorkItem(entityId: string, workItemId: string): Promise<ApiRecord>;
3358
3373
  cancelWorkItem(entityId: string, workItemId: string): Promise<ApiRecord>;
3359
3374
  listApiKeys(): Promise<ApiRecord[]>;
3375
+ createApiKey(data: ApiRecord): Promise<ApiRecord>;
3376
+ revokeApiKey(keyId: string): Promise<void>;
3377
+ rotateApiKey(keyId: string): Promise<ApiRecord>;
3360
3378
  assignObligation(obligationId: string, contactId: string): Promise<ApiRecord>;
3361
3379
  getConfig(): Promise<ApiRecord>;
3362
3380
  listServiceCatalog(): Promise<ApiRecord[]>;
package/dist/index.js CHANGED
@@ -232,8 +232,8 @@ function resetCache() {
232
232
 
233
233
  // src/api-client.ts
234
234
  var SessionExpiredError = class extends Error {
235
- constructor() {
236
- super("Your API key is no longer valid. Run 'corp setup' to re-authenticate.");
235
+ constructor(detail) {
236
+ super(detail || "Your API key is no longer valid. Run 'corp setup' to re-authenticate.");
237
237
  this.name = "SessionExpiredError";
238
238
  }
239
239
  };
@@ -274,7 +274,8 @@ async function provisionWorkspace(apiUrl, name) {
274
274
  });
275
275
  if (!resp.ok) {
276
276
  const detail = await extractErrorMessage(resp);
277
- throw new Error(`Provision failed: ${resp.status} ${resp.statusText} \u2014 ${detail}`);
277
+ const prefix = resp.status >= 500 ? "Server error" : resp.status === 404 ? "Not found" : resp.status === 422 ? "Validation error" : `HTTP ${resp.status}`;
278
+ throw new Error(`Provision failed (${prefix}): ${detail}`);
278
279
  }
279
280
  return resp.json();
280
281
  }
@@ -311,10 +312,11 @@ var CorpAPIClient = class {
311
312
  return fetch(url, opts);
312
313
  }
313
314
  async throwIfError(resp) {
314
- if (resp.status === 401) throw new SessionExpiredError();
315
315
  if (!resp.ok) {
316
316
  const detail = await extractErrorMessage(resp);
317
- throw new Error(`${resp.status} ${resp.statusText} \u2014 ${detail}`);
317
+ if (resp.status === 401) throw new SessionExpiredError(detail);
318
+ const prefix = resp.status >= 500 ? "Server error" : resp.status === 404 ? "Not found" : resp.status === 422 ? "Validation error" : `HTTP ${resp.status}`;
319
+ throw new Error(`${prefix}: ${detail}`);
318
320
  }
319
321
  }
320
322
  async get(path, params) {
@@ -523,6 +525,27 @@ var CorpAPIClient = class {
523
525
  writtenConsent(data) {
524
526
  return this.post("/v1/meetings/written-consent", data);
525
527
  }
528
+ getGovernanceMode(entityId) {
529
+ return this.get("/v1/governance/mode", { entity_id: entityId });
530
+ }
531
+ setGovernanceMode(data) {
532
+ return this.post("/v1/governance/mode", data);
533
+ }
534
+ resignSeat(seatId, entityId) {
535
+ return this.post(`/v1/governance-seats/${pathSegment(seatId)}/resign`, { entity_id: entityId });
536
+ }
537
+ createGovernanceIncident(data) {
538
+ return this.post("/v1/governance/incidents", data);
539
+ }
540
+ listGovernanceIncidents(entityId) {
541
+ return this.get(`/v1/entities/${pathSegment(entityId)}/governance/incidents`);
542
+ }
543
+ resolveGovernanceIncident(incidentId, data) {
544
+ return this.post(`/v1/governance/incidents/${pathSegment(incidentId)}/resolve`, data);
545
+ }
546
+ getGovernanceProfile(entityId) {
547
+ return this.get(`/v1/entities/${pathSegment(entityId)}/governance/profile`);
548
+ }
526
549
  listAgendaItems(meetingId, entityId) {
527
550
  return this.get(`/v1/meetings/${pathSegment(meetingId)}/agenda-items`, { entity_id: entityId });
528
551
  }
@@ -552,7 +575,9 @@ var CorpAPIClient = class {
552
575
  }
553
576
  getPreviewPdfUrl(entityId, documentId) {
554
577
  if (this.apiUrl.startsWith("process://")) {
555
- throw new Error("getPreviewPdfUrl is not available in process transport mode \u2014 use validatePreviewPdf() and fetch the PDF via the API instead");
578
+ throw new Error(
579
+ "PDF preview is not available in local process transport mode.\n Use cloud mode (npx corp setup) or start a local HTTP server (npx corp serve) instead."
580
+ );
556
581
  }
557
582
  const qs = new URLSearchParams({ entity_id: entityId, document_id: documentId }).toString();
558
583
  return `${this.apiUrl}/v1/documents/preview/pdf?${qs}`;
@@ -588,12 +613,25 @@ var CorpAPIClient = class {
588
613
  openBankAccount(data) {
589
614
  return this.post("/v1/treasury/bank-accounts", data);
590
615
  }
616
+ activateBankAccount(bankAccountId, entityId) {
617
+ return this.postWithParams(`/v1/bank-accounts/${pathSegment(bankAccountId)}/activate`, {}, { entity_id: entityId });
618
+ }
591
619
  classifyContractor(data) {
592
620
  return this.post("/v1/contractors/classify", data);
593
621
  }
594
622
  reconcileLedger(data) {
595
623
  return this.post("/v1/ledger/reconcile", data);
596
624
  }
625
+ getFinancialStatements(entityId, params) {
626
+ return this.get("/v1/treasury/financial-statements", { entity_id: entityId, ...params ?? {} });
627
+ }
628
+ // --- Equity analytics ---
629
+ getDilutionPreview(entityId, roundId) {
630
+ return this.get("/v1/equity/dilution/preview", { entity_id: entityId, round_id: roundId });
631
+ }
632
+ getControlMap(entityId, rootEntityId) {
633
+ return this.get("/v1/equity/control-map", { entity_id: entityId, root_entity_id: rootEntityId });
634
+ }
597
635
  // --- Tax ---
598
636
  listTaxFilings(entityId) {
599
637
  return this.get(`/v1/entities/${pathSegment(entityId)}/tax-filings`);
@@ -724,6 +762,18 @@ var CorpAPIClient = class {
724
762
  listSupportedModels() {
725
763
  return this.get("/v1/models");
726
764
  }
765
+ async getAgentExecution(agentId, executionId) {
766
+ return this.get(`/v1/agents/${pathSegment(agentId)}/executions/${pathSegment(executionId)}`);
767
+ }
768
+ async getAgentExecutionResult(agentId, executionId) {
769
+ return this.get(`/v1/agents/${pathSegment(agentId)}/executions/${pathSegment(executionId)}/result`);
770
+ }
771
+ async getAgentExecutionLogs(agentId, executionId) {
772
+ return this.get(`/v1/agents/${pathSegment(agentId)}/executions/${pathSegment(executionId)}/logs`);
773
+ }
774
+ async killAgentExecution(agentId, executionId) {
775
+ return this.post(`/v1/agents/${pathSegment(agentId)}/executions/${pathSegment(executionId)}/kill`, {});
776
+ }
727
777
  // --- Governance bodies ---
728
778
  createGovernanceBody(data) {
729
779
  return this.post("/v1/governance-bodies", data);
@@ -757,6 +807,15 @@ var CorpAPIClient = class {
757
807
  listApiKeys() {
758
808
  return this.get("/v1/api-keys", { workspace_id: this.workspaceId });
759
809
  }
810
+ async createApiKey(data) {
811
+ return this.post("/v1/api-keys", data);
812
+ }
813
+ async revokeApiKey(keyId) {
814
+ return this.del(`/v1/api-keys/${pathSegment(keyId)}`);
815
+ }
816
+ async rotateApiKey(keyId) {
817
+ return this.post(`/v1/api-keys/${pathSegment(keyId)}/rotate`, {});
818
+ }
760
819
  // --- Obligations ---
761
820
  assignObligation(obligationId, contactId) {
762
821
  return this.patch(`/v1/obligations/${pathSegment(obligationId)}/assign`, { contact_id: contactId });
@@ -796,7 +855,9 @@ var CorpAPIClient = class {
796
855
  const resp = await this.request("POST", "/v1/workspaces/link", { external_id: externalId, provider });
797
856
  if (!resp.ok) {
798
857
  const detail = await extractErrorMessage(resp);
799
- throw new Error(`${resp.status} ${resp.statusText} \u2014 ${detail}`);
858
+ if (resp.status === 401) throw new SessionExpiredError(detail);
859
+ const prefix = resp.status >= 500 ? "Server error" : resp.status === 404 ? "Not found" : resp.status === 422 ? "Validation error" : `HTTP ${resp.status}`;
860
+ throw new Error(`${prefix}: ${detail}`);
800
861
  }
801
862
  return resp.json();
802
863
  }