@thecorporation/corp-tools 0.1.0

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.
@@ -0,0 +1,152 @@
1
+ interface CorpConfig {
2
+ api_url: string;
3
+ api_key: string;
4
+ workspace_id: string;
5
+ hosting_mode: string;
6
+ llm: {
7
+ provider: string;
8
+ api_key: string;
9
+ model: string;
10
+ base_url?: string;
11
+ };
12
+ user: {
13
+ name: string;
14
+ email: string;
15
+ };
16
+ active_entity_id: string;
17
+ [key: string]: unknown;
18
+ }
19
+ interface ToolCall {
20
+ id: string;
21
+ name: string;
22
+ arguments: Record<string, unknown>;
23
+ }
24
+ interface LLMResponse {
25
+ content: string | null;
26
+ tool_calls: ToolCall[];
27
+ usage: {
28
+ prompt_tokens: number;
29
+ completion_tokens: number;
30
+ total_tokens: number;
31
+ };
32
+ finish_reason: string | null;
33
+ }
34
+ type ApiRecord = Record<string, unknown>;
35
+
36
+ declare class SessionExpiredError extends Error {
37
+ constructor();
38
+ }
39
+ declare function provisionWorkspace(apiUrl: string, name?: string): Promise<ApiRecord>;
40
+ declare class CorpAPIClient {
41
+ readonly apiUrl: string;
42
+ readonly apiKey: string;
43
+ readonly workspaceId: string;
44
+ constructor(apiUrl: string, apiKey: string, workspaceId: string);
45
+ private headers;
46
+ private request;
47
+ private get;
48
+ private post;
49
+ private patch;
50
+ private del;
51
+ getStatus(): Promise<ApiRecord>;
52
+ getObligations(tier?: string): Promise<ApiRecord>;
53
+ listDigests(): Promise<ApiRecord[]>;
54
+ triggerDigest(): Promise<ApiRecord>;
55
+ getDigest(key: string): Promise<ApiRecord>;
56
+ listEntities(): Promise<ApiRecord[]>;
57
+ listContacts(): Promise<ApiRecord[]>;
58
+ getContact(id: string): Promise<ApiRecord>;
59
+ getContactProfile(id: string): Promise<ApiRecord>;
60
+ createContact(data: ApiRecord): Promise<ApiRecord>;
61
+ updateContact(id: string, data: ApiRecord): Promise<ApiRecord>;
62
+ getNotificationPrefs(contactId: string): Promise<ApiRecord>;
63
+ updateNotificationPrefs(contactId: string, prefs: ApiRecord): Promise<ApiRecord>;
64
+ getCapTable(entityId: string): Promise<ApiRecord>;
65
+ getSafeNotes(entityId: string): Promise<ApiRecord[]>;
66
+ getShareTransfers(entityId: string): Promise<ApiRecord[]>;
67
+ getValuations(entityId: string): Promise<ApiRecord[]>;
68
+ getCurrent409a(entityId: string): Promise<ApiRecord>;
69
+ issueEquity(data: ApiRecord): Promise<ApiRecord>;
70
+ issueSafe(data: ApiRecord): Promise<ApiRecord>;
71
+ transferShares(data: ApiRecord): Promise<ApiRecord>;
72
+ calculateDistribution(data: ApiRecord): Promise<ApiRecord>;
73
+ listGovernanceBodies(entityId: string): Promise<ApiRecord[]>;
74
+ getGovernanceSeats(bodyId: string): Promise<ApiRecord[]>;
75
+ listMeetings(bodyId: string): Promise<ApiRecord[]>;
76
+ getMeetingResolutions(meetingId: string): Promise<ApiRecord[]>;
77
+ conveneMeeting(data: ApiRecord): Promise<ApiRecord>;
78
+ castVote(meetingId: string, itemId: string, data: ApiRecord): Promise<ApiRecord>;
79
+ getEntityDocuments(entityId: string): Promise<ApiRecord[]>;
80
+ generateContract(data: ApiRecord): Promise<ApiRecord>;
81
+ getSigningLink(documentId: string): ApiRecord;
82
+ createInvoice(data: ApiRecord): Promise<ApiRecord>;
83
+ runPayroll(data: ApiRecord): Promise<ApiRecord>;
84
+ submitPayment(data: ApiRecord): Promise<ApiRecord>;
85
+ openBankAccount(data: ApiRecord): Promise<ApiRecord>;
86
+ classifyContractor(data: ApiRecord): Promise<ApiRecord>;
87
+ reconcileLedger(data: ApiRecord): Promise<ApiRecord>;
88
+ fileTaxDocument(data: ApiRecord): Promise<ApiRecord>;
89
+ trackDeadline(data: ApiRecord): Promise<ApiRecord>;
90
+ getBillingStatus(): Promise<ApiRecord>;
91
+ getBillingPlans(): Promise<ApiRecord[]>;
92
+ createBillingPortal(): Promise<ApiRecord>;
93
+ createBillingCheckout(tier: string, entityId?: string): Promise<ApiRecord>;
94
+ getFormation(id: string): Promise<ApiRecord>;
95
+ getFormationDocuments(id: string): Promise<ApiRecord[]>;
96
+ createFormation(data: ApiRecord): Promise<ApiRecord>;
97
+ getHumanObligations(): Promise<ApiRecord[]>;
98
+ getSignerToken(obligationId: string): Promise<ApiRecord>;
99
+ seedDemo(name: string): Promise<ApiRecord>;
100
+ convertEntity(entityId: string, data: ApiRecord): Promise<ApiRecord>;
101
+ dissolveEntity(entityId: string, data: ApiRecord): Promise<ApiRecord>;
102
+ listAgents(): Promise<ApiRecord[]>;
103
+ getAgent(id: string): Promise<ApiRecord>;
104
+ createAgent(data: ApiRecord): Promise<ApiRecord>;
105
+ updateAgent(id: string, data: ApiRecord): Promise<ApiRecord>;
106
+ deleteAgent(id: string): Promise<void>;
107
+ sendAgentMessage(id: string, body: string): Promise<ApiRecord>;
108
+ listAgentExecutions(id: string): Promise<ApiRecord[]>;
109
+ getAgentUsage(id: string): Promise<ApiRecord>;
110
+ addAgentSkill(id: string, data: ApiRecord): Promise<ApiRecord>;
111
+ listSupportedModels(): Promise<ApiRecord[]>;
112
+ listPendingApprovals(): Promise<ApiRecord[]>;
113
+ respondApproval(id: string, decision: string, message?: string): Promise<ApiRecord>;
114
+ listApiKeys(): Promise<ApiRecord[]>;
115
+ assignObligation(obligationId: string, contactId: string): Promise<ApiRecord>;
116
+ getConfig(): Promise<ApiRecord>;
117
+ createLink(): Promise<ApiRecord>;
118
+ }
119
+
120
+ interface ToolContext {
121
+ dataDir: string;
122
+ onEntityFormed?: (entityId: string) => void;
123
+ }
124
+ declare const TOOL_DEFINITIONS: Record<string, unknown>[];
125
+ declare function isWriteTool(name: string): boolean;
126
+ declare function executeTool(name: string, args: Record<string, unknown>, client: CorpAPIClient, ctx: ToolContext): Promise<string>;
127
+
128
+ declare function describeToolCall(name: string, args: Record<string, unknown>): string;
129
+
130
+ /**
131
+ * System prompt base and config formatter.
132
+ */
133
+ declare const SYSTEM_PROMPT_BASE = "You are a corporate governance assistant for TheCorporation, an agentic corporate governance platform.\n\n## Context\n{context}\n\n## Capabilities\nYou can perform the full range of corporate operations:\n\n**Read operations:**\n- View workspace status, entities, cap tables, documents\n- List SAFE notes, equity grants, agents\n- Check deadlines and compliance status\n\n**Write operations:**\n- Form new LLCs and corporations in any US jurisdiction\n- Issue equity (common, preferred, options, units)\n- Issue SAFE notes to investors\n- Transfer shares between holders\n- Convert entities (LLC <> Corporation)\n- Create invoices, run payroll, submit payments\n- Open bank accounts, reconcile ledgers\n- Generate contracts (NDAs, employment offers, consulting agreements)\n- File tax documents (1099-NEC, K-1, 941, W-2, estimated tax)\n- Generate signing links for documents (human-only signing)\n- Track compliance deadlines\n- Classify contractor risk (employee vs 1099)\n- Convene governance meetings and cast votes\n- Dissolve entities with full wind-down workflow\n\n## Rules\n- All monetary values are in integer cents ($1,000 = 100000).\n- Be concise and helpful.\n- **You MUST confirm with the user before calling ANY write tool.** Describe what you are about to do and wait for explicit approval. Never execute tools speculatively or \"on behalf of\" the user without their go-ahead.\n- Don't ask for info available in platform config \u2014 use the correct values automatically.\n- If only one option exists for a field, use it without asking.\n- Don't make up data \u2014 only present what the tools return.\n- If a tool returns an error, explain it simply without exposing raw error details.\n- NEVER create an agent to answer a question you can answer yourself. You are the assistant \u2014 answer questions directly using your knowledge and the read tools.\n\n## Agent Rules\n- Agents are for **delegating recurring corporate operations tasks** that the user explicitly requests \u2014 e.g. \"process incoming invoices\", \"monitor compliance deadlines\", \"handle payroll every two weeks\".\n- Agents are NOT for research, answering questions, or one-off lookups. If the user asks a question, YOU answer it.\n- NEVER proactively suggest or create an agent unless the user specifically asks for one.\n- Agent tools require a paid plan.\n\n## Entity Formation Rules\n- When forming an entity, you MUST ask about all founding members and their ownership allocations BEFORE calling the form_entity tool.\n- For LLCs, ownership percentages must total 100%.\n\n## Document Signing Rules\n- You CANNOT sign documents on behalf of users. Signing is a human action.\n- Use `get_signing_link` to generate a signing URL for a document.\n- Present the signing link so users can open it and sign themselves.\n- NEVER attempt to sign, execute, or complete signature actions automatically.\n- The `get_signing_link` tool does NOT sign anything \u2014 it only returns a URL.\n\n## User Journey\nAfter completing any action, ALWAYS present the logical next step(s) as a\nnumbered list. The user should never wonder \"what now?\" \u2014 guide them forward.\n\nAfter entity formation:\n1. The `form_entity` response includes a `documents` array with document IDs. These documents are created immediately \u2014 they are NEVER \"still being generated\" or delayed.\n2. Immediately call `get_signing_link` for each document ID in the response to get signing URLs.\n3. Present the signing links to the user right away. Do NOT tell the user to \"check back later\" or that documents are \"being prepared\" \u2014 they already exist.\n4. Then: \"Documents signed! Next: apply for an EIN, open a bank account, or issue equity.\"\n\nAfter document generation:\n1. Present signing links immediately \u2014 don't wait for the user to ask.\n2. Use the document IDs from the tool response \u2014 do NOT call `list_documents` to re-fetch them.\n\nAfter signing:\n1. \"Documents are signed! Next: file for EIN, open a bank account, or add team members.\"\n\nAfter equity issuance:\n1. \"Equity issued! Next: generate the stock certificate for signing, or issue more grants.\"\n\nGeneral pattern:\n- Always end with 1-2 concrete next actions the user can take.\n- Phrase them as questions or suggestions: \"Would you like to [next step]?\"\n- If there are signing obligations, proactively generate and present the signing links.\n- Never just say \"done\" \u2014 always show what comes next.\n\nAfter major actions, use update_checklist to track progress. Use markdown checkbox\nformat (- [x] / - [ ]). Call get_checklist first to see current state, then\nupdate_checklist with checked-off items. This helps users see where they are.\n\n{extra_sections}";
134
+ declare function formatConfigSection(cfgData: Record<string, unknown>): string;
135
+
136
+ declare const GENERATED_TOOL_DEFINITIONS: Record<string, unknown>[];
137
+
138
+ /**
139
+ * Tool registry and classification helpers.
140
+ * Re-exports from existing modules + builds a registry from generated defs.
141
+ */
142
+
143
+ interface ToolFunction {
144
+ name: string;
145
+ description: string;
146
+ parameters: Record<string, unknown>;
147
+ }
148
+ /** Registry: tool name → function metadata (description + parameters). */
149
+ declare const TOOL_REGISTRY: Record<string, ToolFunction>;
150
+ declare const READ_ONLY_TOOLS: Set<string>;
151
+
152
+ export { type ApiRecord, CorpAPIClient, type CorpConfig, GENERATED_TOOL_DEFINITIONS, type LLMResponse, READ_ONLY_TOOLS, SYSTEM_PROMPT_BASE, SessionExpiredError, TOOL_DEFINITIONS, TOOL_REGISTRY, type ToolCall, type ToolContext, describeToolCall, executeTool, formatConfigSection, isWriteTool, provisionWorkspace };