@thecorporation/corp-tools 26.3.6 → 26.3.9

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 CHANGED
@@ -10,7 +10,9 @@ async function extractErrorMessage(resp) {
10
10
  const text = await resp.text();
11
11
  try {
12
12
  const json = JSON.parse(text);
13
- return json.error || json.message || json.detail || text;
13
+ const val = json.error || json.message || json.detail;
14
+ if (val == null) return text;
15
+ return typeof val === "string" ? val : JSON.stringify(val);
14
16
  } catch {
15
17
  return text;
16
18
  }
@@ -112,7 +114,7 @@ var CorpAPIClient = class {
112
114
  }
113
115
  // --- Entities ---
114
116
  listEntities() {
115
- return this.get(`/v1/workspaces/${this.workspaceId}/entities`);
117
+ return this.get("/v1/entities");
116
118
  }
117
119
  // --- Contacts ---
118
120
  listContacts(entityId) {
@@ -274,6 +276,15 @@ var CorpAPIClient = class {
274
276
  getSigningLink(documentId, entityId) {
275
277
  return this.get(`/v1/sign/${documentId}`, { entity_id: entityId });
276
278
  }
279
+ async validatePreviewPdf(entityId, documentId) {
280
+ const resp = await this.request("GET", "/v1/documents/preview/pdf", void 0, { entity_id: entityId, document_id: documentId });
281
+ await this.throwIfError(resp);
282
+ return { entity_id: entityId, document_id: documentId };
283
+ }
284
+ getPreviewPdfUrl(entityId, documentId) {
285
+ const qs = new URLSearchParams({ entity_id: entityId, document_id: documentId }).toString();
286
+ return `${this.apiUrl}/v1/documents/preview/pdf?${qs}`;
287
+ }
277
288
  // --- Finance ---
278
289
  createInvoice(data) {
279
290
  return this.post("/v1/treasury/invoices", data);
@@ -355,7 +366,12 @@ var CorpAPIClient = class {
355
366
  }
356
367
  // --- Entities writes ---
357
368
  convertEntity(entityId, data) {
358
- return this.post(`/v1/entities/${entityId}/convert`, data);
369
+ const body = {
370
+ target_type: data.target_type ?? data.new_entity_type
371
+ };
372
+ const jurisdiction = data.jurisdiction ?? data.new_jurisdiction;
373
+ if (jurisdiction) body.jurisdiction = jurisdiction;
374
+ return this.post(`/v1/entities/${entityId}/convert`, body);
359
375
  }
360
376
  dissolveEntity(entityId, data) {
361
377
  return this.post(`/v1/entities/${entityId}/dissolve`, data);
@@ -392,6 +408,28 @@ var CorpAPIClient = class {
392
408
  createGovernanceSeat(bodyId, entityId, data) {
393
409
  return this.postWithParams(`/v1/governance-bodies/${bodyId}/seats`, data, { entity_id: entityId });
394
410
  }
411
+ // --- Work Items ---
412
+ listWorkItems(entityId, params) {
413
+ return this.get(`/v1/entities/${entityId}/work-items`, params);
414
+ }
415
+ getWorkItem(entityId, workItemId) {
416
+ return this.get(`/v1/entities/${entityId}/work-items/${workItemId}`);
417
+ }
418
+ createWorkItem(entityId, data) {
419
+ return this.post(`/v1/entities/${entityId}/work-items`, data);
420
+ }
421
+ claimWorkItem(entityId, workItemId, data) {
422
+ return this.post(`/v1/entities/${entityId}/work-items/${workItemId}/claim`, data);
423
+ }
424
+ completeWorkItem(entityId, workItemId, data) {
425
+ return this.post(`/v1/entities/${entityId}/work-items/${workItemId}/complete`, data);
426
+ }
427
+ releaseWorkItem(entityId, workItemId) {
428
+ return this.post(`/v1/entities/${entityId}/work-items/${workItemId}/release`, {});
429
+ }
430
+ cancelWorkItem(entityId, workItemId) {
431
+ return this.post(`/v1/entities/${entityId}/work-items/${workItemId}/cancel`, {});
432
+ }
395
433
  // --- API Keys ---
396
434
  listApiKeys() {
397
435
  return this.get("/v1/api-keys", { workspace_id: this.workspaceId });
@@ -425,17 +463,21 @@ var GENERATED_TOOL_DEFINITIONS = [
425
463
  "type": "function",
426
464
  "function": {
427
465
  "name": "workspace",
428
- "description": "Workspace-level queries. Actions: status (get workspace summary), list_entities (list all entities), obligations (list obligations, optional tier filter), billing (get billing status and plans).",
466
+ "description": "Workspace-level queries. Actions: status (get workspace summary), list_entities (list all entities), obligations (list obligations, optional tier filter), billing (get billing status and plans), checkout (create Stripe checkout URL \u2014 requires plan_id), portal (get Stripe billing portal URL for managing subscription).",
429
467
  "parameters": {
430
468
  "type": "object",
431
469
  "properties": {
432
470
  "action": {
433
471
  "type": "string",
434
- "enum": ["status", "list_entities", "obligations", "billing"]
472
+ "enum": ["status", "list_entities", "obligations", "billing", "checkout", "portal"]
435
473
  },
436
474
  "tier": {
437
475
  "type": "string",
438
476
  "description": "obligations: filter by urgency tier"
477
+ },
478
+ "plan_id": {
479
+ "type": "string",
480
+ "description": "checkout: plan to subscribe to (pro, enterprise)"
439
481
  }
440
482
  },
441
483
  "required": ["action"]
@@ -745,6 +787,37 @@ var GENERATED_TOOL_DEFINITIONS = [
745
787
  }
746
788
  }
747
789
  },
790
+ {
791
+ "type": "function",
792
+ "function": {
793
+ "name": "work_item",
794
+ "description": "Long-term work item coordination stored in entity repos. Agents claim items with TTL, complete them, or release/cancel. Actions: list (entity_id, optional status filter), get (entity_id + work_item_id), create (entity_id + title + category + optional deadline/asap/description/metadata/created_by), claim (entity_id + work_item_id + claimed_by + optional ttl_seconds), complete (entity_id + work_item_id + completed_by + optional result), release (entity_id + work_item_id \u2014 release a claim), cancel (entity_id + work_item_id).",
795
+ "parameters": {
796
+ "type": "object",
797
+ "properties": {
798
+ "action": {
799
+ "type": "string",
800
+ "enum": ["list", "get", "create", "claim", "complete", "release", "cancel"]
801
+ },
802
+ "entity_id": { "type": "string", "description": "All actions: entity ID" },
803
+ "work_item_id": { "type": "string", "description": "get/claim/complete/release/cancel: work item ID" },
804
+ "title": { "type": "string", "description": "create: work item title" },
805
+ "category": { "type": "string", "description": "create/list: work item category" },
806
+ "description": { "type": "string", "description": "create: work item description" },
807
+ "deadline": { "type": "string", "description": "create: deadline date (YYYY-MM-DD)" },
808
+ "asap": { "type": "boolean", "description": "create: mark as ASAP priority" },
809
+ "metadata": { "type": "object", "description": "create: arbitrary metadata" },
810
+ "created_by": { "type": "string", "description": "create: creator identifier" },
811
+ "claimed_by": { "type": "string", "description": "claim: agent or user identifier" },
812
+ "ttl_seconds": { "type": "integer", "description": "claim: auto-release TTL in seconds" },
813
+ "completed_by": { "type": "string", "description": "complete: agent or user identifier" },
814
+ "result": { "type": "string", "description": "complete: completion result/notes" },
815
+ "status": { "type": "string", "enum": ["open", "claimed", "completed", "cancelled"], "description": "list: filter by effective status" }
816
+ },
817
+ "required": ["action"]
818
+ }
819
+ }
820
+ },
748
821
  {
749
822
  "type": "function",
750
823
  "function": {
@@ -787,6 +860,13 @@ var workspaceActions = {
787
860
  billing: async (_args, client) => {
788
861
  const [status, plans] = await Promise.all([client.getBillingStatus(), client.getBillingPlans()]);
789
862
  return { status, plans };
863
+ },
864
+ checkout: async (args, client) => {
865
+ const planId = requiredString(args, "plan_id");
866
+ return client.createBillingCheckout(planId);
867
+ },
868
+ portal: async (_args, client) => {
869
+ return client.createBillingPortal();
790
870
  }
791
871
  };
792
872
  var entityActions = {
@@ -1142,6 +1222,46 @@ var checklistActions = {
1142
1222
  return { status: "updated", checklist: args.checklist };
1143
1223
  }
1144
1224
  };
1225
+ var workItemActions = {
1226
+ list: async (args, client) => client.listWorkItems(requiredString(args, "entity_id"), args.status ? { status: args.status } : void 0),
1227
+ get: async (args, client) => client.getWorkItem(requiredString(args, "entity_id"), requiredString(args, "work_item_id")),
1228
+ create: async (args, client) => {
1229
+ const data = {
1230
+ title: requiredString(args, "title"),
1231
+ category: requiredString(args, "category")
1232
+ };
1233
+ if (args.description) data.description = args.description;
1234
+ if (args.deadline) data.deadline = args.deadline;
1235
+ if (args.asap != null) data.asap = args.asap;
1236
+ if (args.metadata) data.metadata = args.metadata;
1237
+ if (args.created_by) data.created_by = args.created_by;
1238
+ return client.createWorkItem(requiredString(args, "entity_id"), data);
1239
+ },
1240
+ claim: async (args, client) => {
1241
+ const data = {
1242
+ claimed_by: requiredString(args, "claimed_by")
1243
+ };
1244
+ if (args.ttl_seconds != null) data.ttl_seconds = args.ttl_seconds;
1245
+ return client.claimWorkItem(
1246
+ requiredString(args, "entity_id"),
1247
+ requiredString(args, "work_item_id"),
1248
+ data
1249
+ );
1250
+ },
1251
+ complete: async (args, client) => {
1252
+ const data = {
1253
+ completed_by: requiredString(args, "completed_by")
1254
+ };
1255
+ if (args.result) data.result = args.result;
1256
+ return client.completeWorkItem(
1257
+ requiredString(args, "entity_id"),
1258
+ requiredString(args, "work_item_id"),
1259
+ data
1260
+ );
1261
+ },
1262
+ release: async (args, client) => client.releaseWorkItem(requiredString(args, "entity_id"), requiredString(args, "work_item_id")),
1263
+ cancel: async (args, client) => client.cancelWorkItem(requiredString(args, "entity_id"), requiredString(args, "work_item_id"))
1264
+ };
1145
1265
  var agentActions = {
1146
1266
  list: async (_args, client) => client.listAgents(),
1147
1267
  create: async (args, client) => client.createAgent(args),
@@ -1159,6 +1279,7 @@ var TOOL_DISPATCH = {
1159
1279
  compliance: complianceActions,
1160
1280
  document: documentActions,
1161
1281
  checklist: checklistActions,
1282
+ work_item: workItemActions,
1162
1283
  agent: agentActions
1163
1284
  };
1164
1285
  var TOOL_DEFINITIONS = GENERATED_TOOL_DEFINITIONS;
@@ -1177,6 +1298,8 @@ var READ_ONLY_ACTIONS = /* @__PURE__ */ new Set([
1177
1298
  "checklist:get",
1178
1299
  "meeting:list_items",
1179
1300
  "meeting:list_votes",
1301
+ "work_item:list",
1302
+ "work_item:get",
1180
1303
  "agent:list"
1181
1304
  ]);
1182
1305
  function isWriteTool(name, args) {
@@ -1486,14 +1609,184 @@ var READ_ONLY_TOOLS = /* @__PURE__ */ new Set([
1486
1609
  "workspace",
1487
1610
  "checklist"
1488
1611
  ]);
1612
+
1613
+ // src/api-enums.generated.ts
1614
+ var AccountType = ["asset", "liability", "equity", "revenue", "expense"];
1615
+ var AgendaItemStatus = ["pending", "discussed", "voted", "tabled", "withdrawn"];
1616
+ var AgendaItemType = ["resolution", "discussion", "report", "election"];
1617
+ var AgentStatus = ["active", "paused", "disabled"];
1618
+ var AntiDilutionMethod = ["none", "broad_based_weighted_average", "narrow_based_weighted_average", "full_ratchet"];
1619
+ var AssigneeType = ["internal", "third_party", "human"];
1620
+ var AuthoritySource = ["law", "charter", "governance_docs", "resolution", "directive", "standing_instruction", "delegation_schedule", "heuristic"];
1621
+ var AuthorityTier = ["tier_1", "tier_2", "tier_3"];
1622
+ var BankAccountStatus = ["pending_review", "active", "closed"];
1623
+ var BankAccountType = ["checking", "savings"];
1624
+ var BodyStatus = ["active", "inactive"];
1625
+ var BodyType = ["board_of_directors", "llc_member_vote"];
1626
+ var CapTableAccess = ["none", "summary", "detailed"];
1627
+ var CapTableBasis = ["outstanding", "as_converted", "fully_diluted"];
1628
+ var ClassificationResult = ["independent", "employee", "uncertain"];
1629
+ var ContactCategory = ["employee", "contractor", "board_member", "law_firm", "valuation_firm", "accounting_firm", "investor", "officer", "founder", "member", "other"];
1630
+ var ContactStatus = ["active", "inactive"];
1631
+ var ContactType = ["individual", "organization"];
1632
+ var ContractStatus = ["draft", "active", "expired", "terminated"];
1633
+ var ContractTemplateType = ["consulting_agreement", "employment_offer", "contractor_agreement", "nda", "custom"];
1634
+ var ControlType = ["voting", "board", "economic", "contractual"];
1635
+ var Currency = ["usd"];
1636
+ var DeadlineSeverity = ["low", "medium", "high", "critical"];
1637
+ var DeadlineStatus = ["upcoming", "due", "completed", "overdue"];
1638
+ var DistributionStatus = ["pending", "approved", "distributed"];
1639
+ var DistributionType = ["dividend", "return", "liquidation"];
1640
+ var DocumentRequestStatus = ["requested", "provided", "not_applicable", "waived"];
1641
+ var DocumentStatus = ["draft", "signed", "amended", "filed"];
1642
+ var DocumentType = ["articles_of_incorporation", "articles_of_organization", "bylaws", "operating_agreement", "ss4_application", "meeting_notice", "resolution", "safe_agreement"];
1643
+ var EntityType = ["corporation", "llc"];
1644
+ var EquityRoundStatus = ["draft", "open", "board_approved", "accepted", "closed", "cancelled"];
1645
+ var EscalationStatus = ["open", "resolved"];
1646
+ var FormationState = ["forming", "active"];
1647
+ var FormationStatus = ["pending", "documents_generated", "documents_signed", "filing_submitted", "filed", "ein_applied", "active", "rejected", "dissolved"];
1648
+ var GlAccountCode = ["Cash", "AccountsReceivable", "AccountsPayable", "AccruedExpenses", "FounderCapital", "Revenue", "OperatingExpenses", "Cogs"];
1649
+ var GovernanceAuditEventType = ["mode_changed", "lockdown_trigger_applied", "manual_event", "checkpoint_written", "chain_verified", "chain_verification_failed"];
1650
+ var GovernanceMode = ["normal", "principal_unavailable", "incident_lockdown"];
1651
+ var GovernanceTriggerSource = ["compliance_scanner", "execution_gate", "external_ingestion"];
1652
+ var GovernanceTriggerType = ["external_signal", "policy_evidence_mismatch", "compliance_deadline_missed_d_plus_1", "audit_chain_verification_failed"];
1653
+ var GoverningDocType = ["bylaws", "operating_agreement", "shareholder_agreement", "other"];
1654
+ var HolderType = ["individual", "organization", "fund", "nonprofit", "trust", "other"];
1655
+ var HttpMethod = ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"];
1656
+ var IncidentSeverity = ["low", "medium", "high", "critical"];
1657
+ var IncidentStatus = ["open", "resolved"];
1658
+ var InstrumentKind = ["common_equity", "preferred_equity", "membership_unit", "option_grant", "safe", "convertible_note", "warrant"];
1659
+ var InstrumentStatus = ["active", "closed", "cancelled"];
1660
+ var IntentStatus = ["pending", "evaluated", "authorized", "executed", "failed", "cancelled"];
1661
+ var InvestorType = ["natural_person", "agent", "entity"];
1662
+ var InvoiceStatus = ["draft", "sent", "paid", "voided"];
1663
+ var JournalEntryStatus = ["draft", "posted", "voided"];
1664
+ var LegalEntityRole = ["operating", "control", "investment", "nonprofit", "spv", "other"];
1665
+ var MeetingStatus = ["draft", "noticed", "convened", "adjourned", "cancelled"];
1666
+ var MeetingType = ["board_meeting", "shareholder_meeting", "written_consent", "member_meeting"];
1667
+ var MemberRole = ["director", "officer", "manager", "member", "chair"];
1668
+ var NetworkEgress = ["restricted", "open"];
1669
+ var ObligationStatus = ["required", "in_progress", "fulfilled", "waived", "expired"];
1670
+ var OfficerTitle = ["ceo", "cfo", "secretary", "president", "vp", "other"];
1671
+ var PaymentMethod = ["bank_transfer", "card", "check", "wire", "ach"];
1672
+ var PaymentStatus = ["submitted", "processing", "completed", "failed"];
1673
+ var PayrollStatus = ["pending", "processing", "completed"];
1674
+ var PositionStatus = ["active", "closed"];
1675
+ var QuorumStatus = ["unknown", "met", "not_met"];
1676
+ var QuorumThreshold = ["majority", "supermajority", "unanimous"];
1677
+ var ReceiptStatus = ["pending", "executed", "failed"];
1678
+ var ReconciliationStatus = ["balanced", "discrepancy"];
1679
+ var Recurrence = ["one_time", "monthly", "quarterly", "annual"];
1680
+ var ResolutionType = ["ordinary", "special", "unanimous_written_consent"];
1681
+ var RiskLevel = ["low", "medium", "high"];
1682
+ var Scope = ["formation_create", "formation_read", "formation_sign", "equity_read", "equity_write", "equity_transfer", "governance_read", "governance_write", "governance_vote", "treasury_read", "treasury_write", "treasury_approve", "contacts_read", "contacts_write", "execution_read", "execution_write", "branch_create", "branch_merge", "branch_delete", "admin", "internal_worker_read", "internal_worker_write", "secrets_manage", "all"];
1683
+ var SeatRole = ["chair", "member", "officer", "observer"];
1684
+ var SeatStatus = ["active", "resigned", "expired"];
1685
+ var Side = ["debit", "credit"];
1686
+ var TaxFilingStatus = ["pending", "filed", "accepted", "rejected"];
1687
+ var TransactionPacketStatus = ["drafted", "ready_for_signature", "fully_signed", "executable", "executed", "failed"];
1688
+ var TransferStatus = ["draft", "pending_bylaws_review", "pending_rofr", "pending_board_approval", "approved", "executed", "denied", "cancelled"];
1689
+ var TransferType = ["gift", "trust_transfer", "secondary_sale", "estate", "other"];
1690
+ var TransfereeRights = ["full_member", "economic_only", "limited"];
1691
+ var Transport = ["stdio", "http"];
1692
+ var ValuationMethodology = ["income", "market", "asset", "backsolve", "hybrid", "other"];
1693
+ var ValuationStatus = ["draft", "pending_approval", "approved", "expired", "superseded"];
1694
+ var ValuationType = ["four_oh_nine_a", "llc_profits_interest", "fair_market_value", "gift", "estate", "other"];
1695
+ var VoteValue = ["for", "against", "abstain", "recusal"];
1696
+ var VotingMethod = ["per_capita", "per_unit"];
1697
+ var WorkflowType = ["transfer", "fundraising"];
1489
1698
  export {
1699
+ AccountType,
1700
+ AgendaItemStatus,
1701
+ AgendaItemType,
1702
+ AgentStatus,
1703
+ AntiDilutionMethod,
1704
+ AssigneeType,
1705
+ AuthoritySource,
1706
+ AuthorityTier,
1707
+ BankAccountStatus,
1708
+ BankAccountType,
1709
+ BodyStatus,
1710
+ BodyType,
1711
+ CapTableAccess,
1712
+ CapTableBasis,
1713
+ ClassificationResult,
1714
+ ContactCategory,
1715
+ ContactStatus,
1716
+ ContactType,
1717
+ ContractStatus,
1718
+ ContractTemplateType,
1719
+ ControlType,
1490
1720
  CorpAPIClient,
1721
+ Currency,
1722
+ DeadlineSeverity,
1723
+ DeadlineStatus,
1724
+ DistributionStatus,
1725
+ DistributionType,
1726
+ DocumentRequestStatus,
1727
+ DocumentStatus,
1728
+ DocumentType,
1729
+ EntityType,
1730
+ EquityRoundStatus,
1731
+ EscalationStatus,
1732
+ FormationState,
1733
+ FormationStatus,
1491
1734
  GENERATED_TOOL_DEFINITIONS,
1735
+ GlAccountCode,
1736
+ GovernanceAuditEventType,
1737
+ GovernanceMode,
1738
+ GovernanceTriggerSource,
1739
+ GovernanceTriggerType,
1740
+ GoverningDocType,
1741
+ HolderType,
1742
+ HttpMethod,
1743
+ IncidentSeverity,
1744
+ IncidentStatus,
1745
+ InstrumentKind,
1746
+ InstrumentStatus,
1747
+ IntentStatus,
1748
+ InvestorType,
1749
+ InvoiceStatus,
1750
+ JournalEntryStatus,
1751
+ LegalEntityRole,
1752
+ MeetingStatus,
1753
+ MeetingType,
1754
+ MemberRole,
1755
+ NetworkEgress,
1756
+ ObligationStatus,
1757
+ OfficerTitle,
1758
+ PaymentMethod,
1759
+ PaymentStatus,
1760
+ PayrollStatus,
1761
+ PositionStatus,
1762
+ QuorumStatus,
1763
+ QuorumThreshold,
1492
1764
  READ_ONLY_TOOLS,
1765
+ ReceiptStatus,
1766
+ ReconciliationStatus,
1767
+ Recurrence,
1768
+ ResolutionType,
1769
+ RiskLevel,
1493
1770
  SYSTEM_PROMPT_BASE,
1771
+ Scope,
1772
+ SeatRole,
1773
+ SeatStatus,
1494
1774
  SessionExpiredError,
1775
+ Side,
1495
1776
  TOOL_DEFINITIONS,
1496
1777
  TOOL_REGISTRY,
1778
+ TaxFilingStatus,
1779
+ TransactionPacketStatus,
1780
+ TransferStatus,
1781
+ TransferType,
1782
+ TransfereeRights,
1783
+ Transport,
1784
+ ValuationMethodology,
1785
+ ValuationStatus,
1786
+ ValuationType,
1787
+ VoteValue,
1788
+ VotingMethod,
1789
+ WorkflowType,
1497
1790
  describeToolCall,
1498
1791
  executeTool,
1499
1792
  formatConfigSection,