poke 0.1.2 → 0.2.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.
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # poke
2
2
 
3
- CLI for [Poke](https://poke.com) — manage authentication and MCP server connections.
3
+ The official [Poke](https://poke.com) developer toolkit a CLI and Node.js SDK for managing authentication, MCP server connections, and programmatic access to your Poke agent.
4
+
5
+ Built by [Interaction Company](https://poke.com) in California.
4
6
 
5
7
  ## Installation
6
8
 
@@ -10,7 +12,107 @@ npm install -g poke
10
12
 
11
13
  Requires Node.js >= 18.
12
14
 
13
- ## Commands
15
+ ## SDK
16
+
17
+ Use the SDK to interact with your Poke agent programmatically.
18
+
19
+ ```bash
20
+ npm install poke
21
+ ```
22
+
23
+ ### Quick start
24
+
25
+ ```typescript
26
+ import { Poke } from "poke";
27
+
28
+ const poke = new Poke({ apiKey: "pk_..." });
29
+
30
+ // Send a message to your agent
31
+ await poke.sendMessage("Summarize my unread emails");
32
+
33
+ // Create a webhook trigger
34
+ const webhook = await poke.createWebhook({
35
+ condition: "When a deploy fails",
36
+ action: "Send me a summary of the error",
37
+ });
38
+
39
+ // Fire the webhook with data
40
+ await poke.sendWebhook({
41
+ webhookUrl: webhook.webhookUrl,
42
+ webhookToken: webhook.webhookToken,
43
+ data: { event: "deploy_failed", repo: "my-app", error: "OOM killed" },
44
+ });
45
+ ```
46
+
47
+ ### Authentication
48
+
49
+ The SDK resolves credentials in this order:
50
+
51
+ 1. `apiKey` passed to the constructor
52
+ 2. `POKE_API_KEY` environment variable
53
+ 3. Credentials from `poke login` (`~/.config/poke/credentials.json`)
54
+
55
+ ```typescript
56
+ // Option 1: Pass directly
57
+ const poke = new Poke({ apiKey: "pk_..." });
58
+
59
+ // Option 2: Set POKE_API_KEY in your environment
60
+ const poke = new Poke();
61
+
62
+ // Option 3: Run `poke login` first, then
63
+ const poke = new Poke();
64
+ ```
65
+
66
+ Get your API key at [poke.com/kitchen/api-keys](https://poke.com/kitchen/api-keys).
67
+
68
+ ### Methods
69
+
70
+ #### `poke.sendMessage(text)`
71
+
72
+ Send a text message to your Poke agent.
73
+
74
+ ```typescript
75
+ const response = await poke.sendMessage("What meetings do I have today?");
76
+ // { success: true, message: "..." }
77
+ ```
78
+
79
+ #### `poke.createWebhook({ condition, action })`
80
+
81
+ Create a webhook trigger. Returns a `webhookUrl` and `webhookToken` that you use with `sendWebhook`.
82
+
83
+ ```typescript
84
+ const webhook = await poke.createWebhook({
85
+ condition: "When a new user signs up",
86
+ action: "Send me a welcome summary in Slack",
87
+ });
88
+ // {
89
+ // triggerId: "...",
90
+ // webhookUrl: "https://poke.com/api/v1/inbound/webhook",
91
+ // webhookToken: "eyJhbG..."
92
+ // }
93
+ ```
94
+
95
+ #### `poke.sendWebhook({ webhookUrl, webhookToken, data })`
96
+
97
+ Fire a webhook trigger with data. Use the `webhookUrl` and `webhookToken` returned by `createWebhook`.
98
+
99
+ ```typescript
100
+ await poke.sendWebhook({
101
+ webhookUrl: webhook.webhookUrl,
102
+ webhookToken: webhook.webhookToken,
103
+ data: { event: "new_signup", email: "user@example.com", plan: "pro" },
104
+ });
105
+ // { success: true }
106
+ ```
107
+
108
+ ### Configuration
109
+
110
+ | Option | Environment Variable | Default |
111
+ |--------|---------------------|---------|
112
+ | `apiKey` | `POKE_API_KEY` | — |
113
+ | `baseUrl` | `POKE_API` | `https://poke.com/api/v1` |
114
+
115
+ ## CLI
14
116
 
15
117
  ### `poke login`
16
118
 
@@ -61,14 +163,33 @@ poke tunnel http://localhost:3000/mcp --name "Local Dev"
61
163
  | Option | Description |
62
164
  |--------|-------------|
63
165
  | `-n, --name <name>` | Display name for the connection (required) |
166
+ | `--share` | Create a shareable recipe with QR code |
64
167
 
65
168
  The tunnel stays active until you press Ctrl+C. Tools are synced automatically every 5 minutes.
66
169
 
170
+ ### `poke wrap`
171
+
172
+ Analyze your project with AI and generate an MCP server that exposes its capabilities, then tunnel it to Poke.
173
+
174
+ ```bash
175
+ poke wrap
176
+ poke wrap --name "My Project" --share
177
+ ```
178
+
179
+ | Option | Description |
180
+ |--------|-------------|
181
+ | `--port <port>` | Port for the generated MCP server (default: `8765`) |
182
+ | `-n, --name <name>` | Display name for the connection |
183
+ | `--share` | Create a shareable recipe with QR code |
184
+
185
+ Requires [uv](https://docs.astral.sh/uv/) to be installed.
186
+
67
187
  ## Configuration
68
188
 
69
189
  Credentials are stored in `~/.config/poke/credentials.json` (respects `$XDG_CONFIG_HOME`).
70
190
 
71
191
  | Environment Variable | Description | Default |
72
192
  |---------------------|-------------|---------|
193
+ | `POKE_API_KEY` | API key for SDK usage | &mdash; |
73
194
  | `POKE_API` | API base URL | `https://poke.com/api/v1` |
74
- | `POKE_FRONTEND` | Frontend URL | `https://poke.com` |
195
+ | `POKE_FRONTEND` | Frontend URL | `https://poke.com` |
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/index.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";var u=Object.create;var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,P=Object.prototype.hasOwnProperty;var f=(s,e)=>{for(var o in e)a(s,o,{get:e[o],enumerable:!0})},d=(s,e,o,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of m(e))!P.call(s,r)&&r!==o&&a(s,r,{get:()=>e[r],enumerable:!(t=b(e,r))||t.enumerable});return s};var h=(s,e,o)=>(o=s!=null?u(w(s)):{},d(e||!s||!s.__esModule?a(o,"default",{value:s,enumerable:!0}):o,s)),l=s=>d(a({},"__esModule",{value:!0}),s);var S={};f(S,{Poke:()=>c});module.exports=l(S);var y=h(require("fs"),1),g=h(require("os"),1),p=h(require("path"),1);function O(){try{let s=process.env.XDG_CONFIG_HOME?p.default.join(process.env.XDG_CONFIG_HOME,"poke"):p.default.join(g.default.homedir(),".config","poke"),e=y.default.readFileSync(p.default.join(s,"credentials.json"),"utf-8");return JSON.parse(e).token??void 0}catch{return}}var c=class{apiKey;baseUrl;constructor(e){let o=e?.apiKey??process.env.POKE_API_KEY??O();if(!o)throw new Error(["Missing API key. Find yours at https://poke.com/kitchen/api-keys","","Provide it in one of three ways:",' 1. new Poke({ apiKey: "pk_..." })'," 2. Set the POKE_API_KEY environment variable"," 3. Run `poke login` in your terminal"].join(`
2
+ `));this.apiKey=o,this.baseUrl=e?.baseUrl??process.env.POKE_API??"https://poke.com/api/v1"}async request({path:e,body:o}){let t=await fetch(`${this.baseUrl}${e}`,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"},body:JSON.stringify(o)});if(!t.ok){let r=await t.text(),i="";try{let n=JSON.parse(r);i=n.error??n.message??""}catch{}throw t.status===401?new Error("Poke: Invalid API key. Get a new one at https://poke.com/kitchen/api-keys"):t.status===403?new Error("Poke: API key doesn't have permission for this action. Check your key scopes at https://poke.com/kitchen/api-keys"):t.status===429?new Error("Poke: Rate limited. Please slow down and retry."):new Error(`Poke API error (${t.status}): ${i||t.statusText}`)}return t.json()}async sendMessage(e){return this.request({path:"/inbound/api-message",body:{message:e}})}async sendWebhook({webhookUrl:e,webhookToken:o,data:t}){let r=await fetch(e,{method:"POST",headers:{Authorization:`Bearer ${o}`,"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){let i=await r.text(),n="";try{let k=JSON.parse(i);n=k.error??k.message??""}catch{}throw new Error(`Poke webhook error (${r.status}): ${n||r.statusText}`)}return r.json()}async createWebhook({condition:e,action:o}){return this.request({path:"/api-keys/webhook",body:{condition:e,action:o}})}};0&&(module.exports={Poke});
@@ -0,0 +1 @@
1
+ export { Poke, type PokeOptions, type SendMessageResponse, type SendWebhookResponse, type CreateWebhookResponse, } from "./sdk.js";
package/dist/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import h from"fs";import k from"os";import i from"path";function d(){try{let p=process.env.XDG_CONFIG_HOME?i.join(process.env.XDG_CONFIG_HOME,"poke"):i.join(k.homedir(),".config","poke"),e=h.readFileSync(i.join(p,"credentials.json"),"utf-8");return JSON.parse(e).token??void 0}catch{return}}var a=class{apiKey;baseUrl;constructor(e){let s=e?.apiKey??process.env.POKE_API_KEY??d();if(!s)throw new Error(["Missing API key. Find yours at https://poke.com/kitchen/api-keys","","Provide it in one of three ways:",' 1. new Poke({ apiKey: "pk_..." })'," 2. Set the POKE_API_KEY environment variable"," 3. Run `poke login` in your terminal"].join(`
2
+ `));this.apiKey=s,this.baseUrl=e?.baseUrl??process.env.POKE_API??"https://poke.com/api/v1"}async request({path:e,body:s}){let o=await fetch(`${this.baseUrl}${e}`,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"},body:JSON.stringify(s)});if(!o.ok){let t=await o.text(),n="";try{let r=JSON.parse(t);n=r.error??r.message??""}catch{}throw o.status===401?new Error("Poke: Invalid API key. Get a new one at https://poke.com/kitchen/api-keys"):o.status===403?new Error("Poke: API key doesn't have permission for this action. Check your key scopes at https://poke.com/kitchen/api-keys"):o.status===429?new Error("Poke: Rate limited. Please slow down and retry."):new Error(`Poke API error (${o.status}): ${n||o.statusText}`)}return o.json()}async sendMessage(e){return this.request({path:"/inbound/api-message",body:{message:e}})}async sendWebhook({webhookUrl:e,webhookToken:s,data:o}){let t=await fetch(e,{method:"POST",headers:{Authorization:`Bearer ${s}`,"Content-Type":"application/json"},body:JSON.stringify(o)});if(!t.ok){let n=await t.text(),r="";try{let c=JSON.parse(n);r=c.error??c.message??""}catch{}throw new Error(`Poke webhook error (${t.status}): ${r||t.statusText}`)}return t.json()}async createWebhook({condition:e,action:s}){return this.request({path:"/api-keys/webhook",body:{condition:e,action:s}})}};export{a as Poke};
package/dist/sdk.d.ts ADDED
@@ -0,0 +1,32 @@
1
+ export interface PokeOptions {
2
+ apiKey?: string;
3
+ baseUrl?: string;
4
+ }
5
+ export interface SendMessageResponse {
6
+ success: boolean;
7
+ message: string;
8
+ }
9
+ export interface SendWebhookResponse {
10
+ success: boolean;
11
+ }
12
+ export interface CreateWebhookResponse {
13
+ triggerId: string;
14
+ webhookUrl: string;
15
+ webhookToken: string;
16
+ }
17
+ export declare class Poke {
18
+ private apiKey;
19
+ private baseUrl;
20
+ constructor(options?: PokeOptions);
21
+ private request;
22
+ sendMessage(text: string): Promise<SendMessageResponse>;
23
+ sendWebhook({ webhookUrl, webhookToken, data, }: {
24
+ webhookUrl: string;
25
+ webhookToken: string;
26
+ data: Record<string, unknown>;
27
+ }): Promise<SendWebhookResponse>;
28
+ createWebhook({ condition, action, }: {
29
+ condition: string;
30
+ action: string;
31
+ }): Promise<CreateWebhookResponse>;
32
+ }
package/package.json CHANGED
@@ -1,8 +1,18 @@
1
1
  {
2
2
  "name": "poke",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "description": "Poke.com Developer SDK",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.mjs",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.mjs",
13
+ "require": "./dist/index.cjs"
14
+ }
15
+ },
6
16
  "bin": {
7
17
  "poke": "./dist/cli.cjs"
8
18
  },
@@ -10,7 +20,7 @@
10
20
  "dist"
11
21
  ],
12
22
  "scripts": {
13
- "build": "tsc --noEmit && node esbuild.config.js",
23
+ "build": "tsc --noEmit && tsc --emitDeclarationOnly --outDir dist && node esbuild.config.js",
14
24
  "dev": "tsx src/cli.ts"
15
25
  },
16
26
  "dependencies": {