@leadpoet/client 0.0.0-stage → 0.1.2

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/README.md CHANGED
@@ -1,3 +1,161 @@
1
- # Temporary Holding Version
1
+ # Leadpoet API clients
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The shared TypeScript client, CLI, MCP server and skill use `/api/v1`. Each call
4
+ uses the same API-key permissions and saved workflow as the application. The
5
+ package is published to npm as `@leadpoet/client`.
6
+
7
+ ## Request access and install
8
+
9
+ [Request access](https://leadpoet.com/contact) with your intended workflow and
10
+ whether you need the CLI, TypeScript client, MCP or skill. Leadpoet will enable
11
+ API access for your workspace. Once enabled,
12
+ manage your keys in Account → Developer → API keys.
13
+
14
+ Agents can start at [the API guide](https://leadpoet.com/docs/api#agents).
15
+ Request https://leadpoet.com/docs/api with `Accept: text/markdown` for a concise
16
+ machine-readable guide, then use the linked OpenAPI schema for current inputs.
17
+
18
+ With Node.js 22 or later, install the package:
19
+
20
+ ```sh
21
+ npm install -g @leadpoet/client
22
+ ```
23
+
24
+ For the TypeScript client, run `npm install @leadpoet/client` in your project.
25
+
26
+ Set `LEADPOET_API_KEY` through your shell's secret manager and
27
+ `LEADPOET_API_BASE=https://leadpoet.com/api/v1` for the enabled deployment.
28
+ The credential selects the workspace. Use a separate client instance or process
29
+ environment for another workspace. Never put a key in arguments, a checked-in
30
+ config, browser code, or logs. Only HTTPS and localhost HTTP bases are accepted;
31
+ redirects are rejected. Installing a client does not grant API access or change
32
+ your key permissions.
33
+
34
+ ## CLI
35
+
36
+ ```sh
37
+ leadpoet operations
38
+ leadpoet call getCredits
39
+ leadpoet call getContactAllowance
40
+ leadpoet describe createRequest
41
+ leadpoet call createRequest --input request.json --idempotency-key request-0001
42
+ leadpoet wait '<returned-query-uuid>' --timeout 300
43
+ leadpoet call getPipeline --query '{"icp_id":"<returned-icp-uuid>"}'
44
+ leadpoet describe createCampaign
45
+ leadpoet call createCampaign --input campaign.json --idempotency-key campaign-0001
46
+ ```
47
+
48
+ `--input -` reads a bounded JSON body from stdin. `--params` sets UUID path
49
+ parameters and `--query` sets documented query fields. Output is always JSON,
50
+ except help. Options apply only to their documented command; unsupported options
51
+ are rejected before any request. Errors go to stderr and retain safe error codes, correlation IDs
52
+ and Retry-After values, including when a proxy returns a non-JSON error body.
53
+ Non-JSON response bodies are not exposed. Exit codes are 0 success, 1 transport/server failure,
54
+ 2 invalid input, 3 credentials/permissions, 4 conflict, 5 throttled, and
55
+ 6 pending timeout or terminal request failure, and 130 interrupted. Ctrl-C cancels
56
+ discovery, polling, response reads and stdin input; an
57
+ interrupted write may already have committed. Requests finish as `ready` or
58
+ `error`; a successful HTTP response does not imply a successful sourcing result.
59
+ The current workspace flow may stay `pending` until Leadpoet starts fulfillment.
60
+ A polling timeout does not cancel the saved request.
61
+
62
+ Send-authorizing operations require `--allow-send` and all advertised API scopes.
63
+ This includes active-campaign changes and recurring request activation, not
64
+ just immediate sends. `createRequest` with `body.recurrence` also requires
65
+ `outreach:send` and explicit consent (`--allow-send` in the CLI or `allowSend: true`
66
+ in the SDK). MCP additionally requires host send enablement; ordinary one-time
67
+ requests remain available without it. Inspect `describe` before acting; it returns the operation plus referenced
68
+ OpenAPI components. No write is retried
69
+ automatically. Preserve the original key, actor and body after uncertainty.
70
+
71
+ ## TypeScript client
72
+
73
+ ```ts
74
+ import { LeadpoetClient } from '@leadpoet/client';
75
+
76
+ const client = new LeadpoetClient({
77
+ baseUrl: process.env.LEADPOET_API_BASE!,
78
+ apiKey: process.env.LEADPOET_API_KEY!,
79
+ });
80
+ const result = await client.call('getPipeline', { query: { icp_id: savedIcpId } });
81
+ const settled = await client.waitForRequest(savedQueryId, { timeoutMs: 300_000 });
82
+ for await (const page of client.requestPages({ limit: 25, maxPages: 20 })) {
83
+ // Read page.data.queries; preserve IDs and provenance.
84
+ }
85
+ ```
86
+
87
+ Operation names and the transport envelope are typed. Workflow payloads retain
88
+ their native JSON extensions; `describe`/OpenAPI carries the registered input
89
+ schemas and stable response fields. A caller can supply a validated result type
90
+ to `call<T>`. This is not a generated SDK that statically types every workflow
91
+ field. The OpenAPI `x-pagination` extension distinguishes cursor/page lists from
92
+ bounded snapshots. The `x-query-schema` extension preserves conditional query
93
+ requirements (for example, account pipeline configuration requires `icp_id`) for
94
+ MCP validation. Audience contact filters are a JSON-encoded query string.
95
+ Malformed history/status responses, including unknown request statuses, fail with
96
+ `invalid_response` and retain the request ID. Timeouts and polling intervals use bounded integer milliseconds.
97
+ Only request history has a built-in page iterator; other
98
+ cursors must be advanced according to that operation's contract. Preserve
99
+ partial/degraded/limited markers instead of calling a snapshot a complete export.
100
+
101
+ ## MCP
102
+
103
+ Use a local stdio server with an MCP host. `npx` fetches the package, so no
104
+ separate install is needed:
105
+
106
+ ```json
107
+ {
108
+ "mcpServers": {
109
+ "leadpoet": {
110
+ "command": "npx",
111
+ "args": ["-y", "-p", "@leadpoet/client", "leadpoet-mcp"],
112
+ "env": {
113
+ "LEADPOET_API_BASE": "https://leadpoet.com/api/v1",
114
+ "LEADPOET_API_KEY": "<supply-through-your-host-secret-store>"
115
+ }
116
+ }
117
+ }
118
+ }
119
+ ```
120
+
121
+ The adapter uses the [official MCP TypeScript SDK](https://ts.sdk.modelcontextprotocol.io/server).
122
+ It discovers the deployment's OpenAPI schemas, exposes only the compiled
123
+ operation allowlist, validates tool arguments, and calls the shared client.
124
+ It uses no listening HTTP port, OAuth impersonation, provider credentials or
125
+ database access. Stdout is reserved for MCP protocol messages.
126
+
127
+ Send tools are omitted by default. To expose them deliberately, set
128
+ `LEADPOET_MCP_ALLOW_SEND=1`; each send tool also requires `allowSend: true` and
129
+ the server-enforced scopes. Client enablement never widens the key's permissions.
130
+ Errors remain tool errors with actionable status/correlation information.
131
+
132
+ The package includes `skill/SKILL.md`; its source is
133
+ `agent-skills/leadpoet-workspace/SKILL.md`. Install that directory using your
134
+ agent's normal skill installation workflow. It teaches sourcing, saved pipeline
135
+ results, campaign preparation, explicit send authorization and uncertain-outcome
136
+ recovery. Skill installation does not grant API access or authorize sending.
137
+
138
+ ## Verification and boundaries
139
+
140
+ Focused tests execute actual CLI processes and MCP stdio against an isolated
141
+ API HTTP fixture for two workspaces. Native controller tests separately verify
142
+ permissions, paid-request creation/replay and held campaign creation/replay.
143
+ The migration test runs exact SQL in disposable embedded PostgreSQL. These are
144
+ local checks, not evidence that a production deployment has been enabled.
145
+
146
+ Account consent/OAuth, provider migration/connection administration, multipart
147
+ uploads, network prospecting and CRM administration remain in their existing
148
+ application workflows. This package covers the published operation catalog;
149
+ it does not expose arbitrary private application routes.
150
+
151
+ ## Build from source
152
+
153
+ For repository contributors with the locked dependencies installed:
154
+
155
+ ```sh
156
+ npm run build:api-clients
157
+ npm pack ./dist/leadpoet
158
+ ```
159
+
160
+ Releases are published to npm as `@leadpoet/client` from the built
161
+ `dist/leadpoet` directory.