@keemakr/agent-sdk 0.3.0 → 0.6.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
@@ -82,15 +82,72 @@ await kee.connections.get("hunter").call("email-finder", { ... }); // equivalent
82
82
  const { access_token } = await kee.connections.hunter.token();
83
83
  ```
84
84
 
85
+ ### Discover connectors + operations
86
+
87
+ `@keemakr/agent-sdk/connectors` ships a generated, typed manifest of every connector keemakr-core exposes — provider slugs, `maturity`, and each operation's name + JSON-Schema arg contract. Use it to discover what's callable (and get autocomplete on provider + op names) **without** scanning a core checkout or hitting a running instance. It's **metadata only** — no credentials.
88
+
89
+ ```ts
90
+ import { connectors, opNames, isReady } from "@keemakr/agent-sdk/connectors";
91
+
92
+ opNames("hunter"); // → ["email-finder"]
93
+ connectors.hunter.ops["email-finder"].inputSchema; // JSON Schema for the args
94
+ isReady("meta"); // false while a connector is coming_soon
95
+ connectors.meta.maturity; // "coming_soon" | "ready"
96
+ ```
97
+
98
+ A `coming_soon` connector is declarable in your `entry.json` `dependencies` today; its operations start callable (and `isReady` flips to `true`) once core ships them — **no change to your agent**.
99
+
100
+ **Refresh the manifest** after core ships new connectors/operations (it's a committed snapshot of `GET /api/connections/catalog`):
101
+
102
+ ```bash
103
+ curl -s "$KEE_CORE_URL/api/connections/catalog" > src/connectors.snapshot.json
104
+ npm run gen:connectors # or: npm run build (runs gen first)
105
+ ```
106
+
107
+ ### Memory (cross-session, tenant-shared)
108
+
109
+ ```ts
110
+ await kee.memory.set("prefs", "tone", { tone: "formal" });
111
+ await kee.memory.get("prefs", "tone"); // → { tone: "formal" }
112
+ await kee.memory.list("prefs"); // → entries in the namespace
113
+ await kee.memory.delete("prefs", "tone");
114
+ // Semantic search by meaning (embeddings):
115
+ const hits = await kee.memory.search("how should I speak to the user?", { limit: 5 });
116
+ // → [{ namespace, key, value, score, … }] (score 0–1, nearest first)
117
+ ```
118
+
119
+ ### Platform tools
120
+
121
+ ```ts
122
+ await kee.tools.list(); // tools this grant is entitled to
123
+ await kee.tools.run("current-time"); // run one in keemakr-core
124
+ ```
125
+
85
126
  A call whose grant lacks the required scope returns a `KeeError` with `status: 403`; an expired/invalid grant returns `status: 401`.
86
127
 
87
- ## Security model
128
+ ## Autonomous / scheduled runs
129
+
130
+ A cron/scheduled turn has no operator session, so it gets no session grant. keemakr-core can mint a **machine grant** for it (gated on the tenant's per-install `unattended_consent`). If your remote runs **outside** an eve channel, verify that grant directly:
88
131
 
89
- - **Tenant always comes from the verified grant**, resolved server-side. Never pass a tenant id from tool input.
90
- - **On the proxy path, credentials never leave keemakr-core.** You send operation args; core runs the third-party request with the tenant's credential and returns only the result.
91
- - **The token path is opt-in and scope-gated** (`conn:<provider>:token`), declared per dependency in your `entry.json` (`"access": "token"`).
132
+ ```ts
133
+ import { verifyGrant } from "@keemakr/agent-sdk";
134
+
135
+ const claims = await verifyGrant(grantToken, { audience: process.env.KEE_AGENT_AUDIENCE });
136
+ if (!claims) throw new Error("invalid or expired grant");
137
+ // claims.tenantId, claims.scopes, claims.aud, claims.exp
138
+ ```
139
+
140
+ Inside an eve channel, `grantAuth()` already accepts machine grants (same token shape) — no extra work.
141
+
142
+ ## Credential & model contract
143
+
144
+ - **Tenant/service credentials live in keemakr-core**, reached only via the proxy — the credential never crosses the wire. Tenant is always the verified grant, resolved server-side; never pass a tenant id from tool input.
145
+ - **The token path is opt-in and scope-gated** (`conn:<provider>:token`), declared per dependency in `entry.json` (`"access": "token"`).
146
+ - **You MAY hold your own model key.** There is no platform model gateway today, so an agent routing its own LLM calls (its own Anthropic/AI-Gateway key) is expected and fine — that is *not* a credential leak. A leak is a *tenant/service* credential read in agent code.
92
147
  - Every capability call re-verifies the grant and enforces scope on the server.
93
148
 
149
+ Full contract: keemakr-core `docs/CONNECTOR-CONTRACT.md`.
150
+
94
151
  ## License
95
152
 
96
153
  MIT
package/dist/client.d.ts CHANGED
@@ -35,6 +35,11 @@ export interface MemoryEntry {
35
35
  * memory use eve's defineState instead — this is for state that must outlive the
36
36
  * session. Requires the `memory:rw` scope.
37
37
  */
38
+ /** A semantic-search hit — a memory entry with its similarity score. */
39
+ export interface MemorySearchHit extends MemoryEntry {
40
+ /** Cosine similarity in [0,1] (1 = identical). */
41
+ score: number;
42
+ }
38
43
  export interface KeeMemory {
39
44
  /** Read a key's value, or null if absent. */
40
45
  get(namespace: string, key: string): Promise<unknown | null>;
@@ -46,6 +51,11 @@ export interface KeeMemory {
46
51
  delete(namespace: string, key: string): Promise<boolean>;
47
52
  /** List every entry in a namespace (tenant-wide). */
48
53
  list(namespace: string): Promise<MemoryEntry[]>;
54
+ /** Semantic search by meaning. Optionally scope to a namespace. */
55
+ search(query: string, opts?: {
56
+ namespace?: string;
57
+ limit?: number;
58
+ }): Promise<MemorySearchHit[]>;
49
59
  }
50
60
  /** Platform registry tools (Shape B) — defined in core, run server-side. */
51
61
  export interface KeeTools {
package/dist/client.js CHANGED
@@ -104,6 +104,14 @@ export function useKee(ctx) {
104
104
  const json = (await capabilityFetch(grant, `memory/${enc(namespace)}`, undefined, 'GET'));
105
105
  return json.entries ?? [];
106
106
  },
107
+ async search(query, opts) {
108
+ const json = (await capabilityFetch(grant, 'memory/search', {
109
+ query,
110
+ namespace: opts?.namespace,
111
+ limit: opts?.limit,
112
+ }));
113
+ return json.hits ?? [];
114
+ },
107
115
  };
108
116
  const tools = {
109
117
  async list() {
@@ -0,0 +1,8 @@
1
+ export { connectors, type ConnectorName, type ConnectorInfo, type ConnectorOp, type ConnectorOps, } from './connectors.generated.js';
2
+ import { type ConnectorName } from './connectors.generated.js';
3
+ /** All provider slugs in the manifest. */
4
+ export declare function providerNames(): ConnectorName[];
5
+ /** The operation names a provider exposes (empty for a coming_soon stub). */
6
+ export declare function opNames(provider: ConnectorName): string[];
7
+ /** True when the provider's connect path is proven and its operations are callable. */
8
+ export declare function isReady(provider: ConnectorName): boolean;
@@ -0,0 +1,276 @@
1
+ export type ConnectorName = "agent-sessions" | "apify" | "apollo" | "cal-com" | "calendly" | "clearbit" | "drip" | "elevenlabs" | "facebook" | "fal" | "hubspot" | "hunter" | "instagram" | "instantly" | "mailchimp" | "meta" | "pagespeed" | "posthog" | "salesforce" | "sendgrid" | "slack" | "stripe" | "twilio" | "whatsapp" | "wordpress";
2
+ /** Per-provider operation names (autocomplete for `.call(op)`). */
3
+ export interface ConnectorOps {
4
+ "agent-sessions": never;
5
+ "apify": never;
6
+ "apollo": never;
7
+ "cal-com": never;
8
+ "calendly": never;
9
+ "clearbit": never;
10
+ "drip": never;
11
+ "elevenlabs": never;
12
+ "facebook": never;
13
+ "fal": never;
14
+ "hubspot": never;
15
+ "hunter": "email-finder";
16
+ "instagram": never;
17
+ "instantly": never;
18
+ "mailchimp": never;
19
+ "meta": never;
20
+ "pagespeed": never;
21
+ "posthog": never;
22
+ "salesforce": never;
23
+ "sendgrid": never;
24
+ "slack": never;
25
+ "stripe": never;
26
+ "twilio": never;
27
+ "whatsapp": never;
28
+ "wordpress": never;
29
+ }
30
+ export interface ConnectorOp {
31
+ description: string | null;
32
+ /** JSON Schema (draft 2020-12) for the operation's arguments. */
33
+ inputSchema: unknown;
34
+ }
35
+ export interface ConnectorInfo {
36
+ displayName: string;
37
+ authKind: string;
38
+ category: string | null;
39
+ /** 'ready' → connectable + operations callable; 'coming_soon' → declared, ops not yet wired. */
40
+ maturity: string;
41
+ docUrl: string | null;
42
+ ops: Record<string, ConnectorOp>;
43
+ }
44
+ /**
45
+ * The connector catalog as of the last snapshot refresh. Metadata only — no
46
+ * credentials. Keyed by provider slug; each entry lists its callable operations
47
+ * and their JSON-Schema arg contracts.
48
+ */
49
+ export declare const connectors: {
50
+ readonly "agent-sessions": {
51
+ readonly displayName: "Agent Session Feed";
52
+ readonly authKind: "api_key";
53
+ readonly category: "voice";
54
+ readonly maturity: "ready";
55
+ readonly docUrl: null;
56
+ readonly ops: {};
57
+ };
58
+ readonly apify: {
59
+ readonly displayName: "Apify";
60
+ readonly authKind: "api_key";
61
+ readonly category: "scraping";
62
+ readonly maturity: "ready";
63
+ readonly docUrl: "https://docs.apify.com/api/v2";
64
+ readonly ops: {};
65
+ };
66
+ readonly apollo: {
67
+ readonly displayName: "Apollo.io";
68
+ readonly authKind: "api_key";
69
+ readonly category: "sales-intelligence";
70
+ readonly maturity: "ready";
71
+ readonly docUrl: "https://docs.apollo.io/reference/introduction";
72
+ readonly ops: {};
73
+ };
74
+ readonly "cal-com": {
75
+ readonly displayName: "Cal.com";
76
+ readonly authKind: "api_key";
77
+ readonly category: "scheduling";
78
+ readonly maturity: "ready";
79
+ readonly docUrl: "https://cal.com/docs/api-reference";
80
+ readonly ops: {};
81
+ };
82
+ readonly calendly: {
83
+ readonly displayName: "Calendly";
84
+ readonly authKind: "api_key";
85
+ readonly category: "scheduling";
86
+ readonly maturity: "coming_soon";
87
+ readonly docUrl: "https://developer.calendly.com/api-docs";
88
+ readonly ops: {};
89
+ };
90
+ readonly clearbit: {
91
+ readonly displayName: "Clearbit";
92
+ readonly authKind: "api_key";
93
+ readonly category: "sales-intelligence";
94
+ readonly maturity: "ready";
95
+ readonly docUrl: "https://dashboard.clearbit.com/docs";
96
+ readonly ops: {};
97
+ };
98
+ readonly drip: {
99
+ readonly displayName: "Drip";
100
+ readonly authKind: "api_key";
101
+ readonly category: "email";
102
+ readonly maturity: "ready";
103
+ readonly docUrl: "https://developer.drip.com/";
104
+ readonly ops: {};
105
+ };
106
+ readonly elevenlabs: {
107
+ readonly displayName: "ElevenLabs";
108
+ readonly authKind: "api_key";
109
+ readonly category: "voice";
110
+ readonly maturity: "ready";
111
+ readonly docUrl: "https://elevenlabs.io/docs/api-reference";
112
+ readonly ops: {};
113
+ };
114
+ readonly facebook: {
115
+ readonly displayName: "Facebook";
116
+ readonly authKind: "oauth2";
117
+ readonly category: "channel";
118
+ readonly maturity: "ready";
119
+ readonly docUrl: "https://developers.facebook.com/docs/pages-api";
120
+ readonly ops: {};
121
+ };
122
+ readonly fal: {
123
+ readonly displayName: "fal.ai";
124
+ readonly authKind: "api_key";
125
+ readonly category: "media";
126
+ readonly maturity: "coming_soon";
127
+ readonly docUrl: "https://fal.ai/docs";
128
+ readonly ops: {};
129
+ };
130
+ readonly hubspot: {
131
+ readonly displayName: "HubSpot";
132
+ readonly authKind: "api_key";
133
+ readonly category: "crm";
134
+ readonly maturity: "ready";
135
+ readonly docUrl: "https://developers.hubspot.com/docs/api/private-apps";
136
+ readonly ops: {};
137
+ };
138
+ readonly hunter: {
139
+ readonly displayName: "Hunter.io";
140
+ readonly authKind: "api_key";
141
+ readonly category: "email";
142
+ readonly maturity: "ready";
143
+ readonly docUrl: "https://hunter.io/api-documentation/v2";
144
+ readonly ops: {
145
+ readonly "email-finder": {
146
+ readonly description: "Find a person's email address at a company domain by their name. Returns the email, a confidence score, and verification status.";
147
+ readonly inputSchema: {
148
+ readonly $schema: "https://json-schema.org/draft/2020-12/schema";
149
+ readonly type: "object";
150
+ readonly properties: {
151
+ readonly domain: {
152
+ readonly type: "string";
153
+ readonly minLength: 1;
154
+ readonly description: "Company domain, e.g. \"stripe.com\".";
155
+ };
156
+ readonly first_name: {
157
+ readonly type: "string";
158
+ readonly minLength: 1;
159
+ readonly description: "The person first name.";
160
+ };
161
+ readonly last_name: {
162
+ readonly type: "string";
163
+ readonly minLength: 1;
164
+ readonly description: "The person last name.";
165
+ };
166
+ };
167
+ readonly required: readonly ["domain", "first_name", "last_name"];
168
+ };
169
+ };
170
+ };
171
+ };
172
+ readonly instagram: {
173
+ readonly displayName: "Instagram";
174
+ readonly authKind: "oauth2";
175
+ readonly category: "channel";
176
+ readonly maturity: "ready";
177
+ readonly docUrl: "https://developers.facebook.com/docs/instagram-platform";
178
+ readonly ops: {};
179
+ };
180
+ readonly instantly: {
181
+ readonly displayName: "Instantly.ai";
182
+ readonly authKind: "api_key";
183
+ readonly category: "email";
184
+ readonly maturity: "ready";
185
+ readonly docUrl: "https://developer.instantly.ai/";
186
+ readonly ops: {};
187
+ };
188
+ readonly mailchimp: {
189
+ readonly displayName: "Mailchimp";
190
+ readonly authKind: "api_key";
191
+ readonly category: "email";
192
+ readonly maturity: "ready";
193
+ readonly docUrl: "https://mailchimp.com/developer/marketing/api/";
194
+ readonly ops: {};
195
+ };
196
+ readonly meta: {
197
+ readonly displayName: "Meta Ads (Marketing API)";
198
+ readonly authKind: "api_key";
199
+ readonly category: "advertising";
200
+ readonly maturity: "coming_soon";
201
+ readonly docUrl: "https://developers.facebook.com/docs/marketing-apis";
202
+ readonly ops: {};
203
+ };
204
+ readonly pagespeed: {
205
+ readonly displayName: "PageSpeed Insights";
206
+ readonly authKind: "api_key";
207
+ readonly category: "analytics";
208
+ readonly maturity: "coming_soon";
209
+ readonly docUrl: "https://developers.google.com/speed/docs/insights/v5/get-started";
210
+ readonly ops: {};
211
+ };
212
+ readonly posthog: {
213
+ readonly displayName: "PostHog";
214
+ readonly authKind: "api_key";
215
+ readonly category: "analytics";
216
+ readonly maturity: "ready";
217
+ readonly docUrl: "https://posthog.com/docs/api";
218
+ readonly ops: {};
219
+ };
220
+ readonly salesforce: {
221
+ readonly displayName: "Salesforce";
222
+ readonly authKind: "api_key";
223
+ readonly category: "crm";
224
+ readonly maturity: "coming_soon";
225
+ readonly docUrl: "https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/";
226
+ readonly ops: {};
227
+ };
228
+ readonly sendgrid: {
229
+ readonly displayName: "SendGrid";
230
+ readonly authKind: "api_key";
231
+ readonly category: "email";
232
+ readonly maturity: "ready";
233
+ readonly docUrl: "https://docs.sendgrid.com/api-reference";
234
+ readonly ops: {};
235
+ };
236
+ readonly slack: {
237
+ readonly displayName: "Slack";
238
+ readonly authKind: "api_key";
239
+ readonly category: "messaging";
240
+ readonly maturity: "coming_soon";
241
+ readonly docUrl: "https://api.slack.com/methods/chat.postMessage";
242
+ readonly ops: {};
243
+ };
244
+ readonly stripe: {
245
+ readonly displayName: "Stripe";
246
+ readonly authKind: "oauth2";
247
+ readonly category: "payments";
248
+ readonly maturity: "coming_soon";
249
+ readonly docUrl: "https://docs.stripe.com/connect/oauth-reference";
250
+ readonly ops: {};
251
+ };
252
+ readonly twilio: {
253
+ readonly displayName: "Twilio";
254
+ readonly authKind: "api_key";
255
+ readonly category: "sms";
256
+ readonly maturity: "ready";
257
+ readonly docUrl: "https://www.twilio.com/docs/usage/api";
258
+ readonly ops: {};
259
+ };
260
+ readonly whatsapp: {
261
+ readonly displayName: "WhatsApp";
262
+ readonly authKind: "oauth2";
263
+ readonly category: "channel";
264
+ readonly maturity: "coming_soon";
265
+ readonly docUrl: "https://developers.facebook.com/docs/whatsapp";
266
+ readonly ops: {};
267
+ };
268
+ readonly wordpress: {
269
+ readonly displayName: "WordPress";
270
+ readonly authKind: "oauth2";
271
+ readonly category: "cms";
272
+ readonly maturity: "ready";
273
+ readonly docUrl: "https://developer.wordpress.com/docs/oauth2/";
274
+ readonly ops: {};
275
+ };
276
+ };
@@ -0,0 +1,240 @@
1
+ // AUTO-GENERATED by scripts/gen-connectors.mjs — DO NOT EDIT BY HAND.
2
+ // Source: src/connectors.snapshot.json (a committed copy of keemakr-core's
3
+ // GET /api/connections/catalog). Refresh: see scripts/gen-connectors.mjs header.
4
+ /**
5
+ * The connector catalog as of the last snapshot refresh. Metadata only — no
6
+ * credentials. Keyed by provider slug; each entry lists its callable operations
7
+ * and their JSON-Schema arg contracts.
8
+ */
9
+ export const connectors = {
10
+ "agent-sessions": {
11
+ "displayName": "Agent Session Feed",
12
+ "authKind": "api_key",
13
+ "category": "voice",
14
+ "maturity": "ready",
15
+ "docUrl": null,
16
+ "ops": {}
17
+ },
18
+ "apify": {
19
+ "displayName": "Apify",
20
+ "authKind": "api_key",
21
+ "category": "scraping",
22
+ "maturity": "ready",
23
+ "docUrl": "https://docs.apify.com/api/v2",
24
+ "ops": {}
25
+ },
26
+ "apollo": {
27
+ "displayName": "Apollo.io",
28
+ "authKind": "api_key",
29
+ "category": "sales-intelligence",
30
+ "maturity": "ready",
31
+ "docUrl": "https://docs.apollo.io/reference/introduction",
32
+ "ops": {}
33
+ },
34
+ "cal-com": {
35
+ "displayName": "Cal.com",
36
+ "authKind": "api_key",
37
+ "category": "scheduling",
38
+ "maturity": "ready",
39
+ "docUrl": "https://cal.com/docs/api-reference",
40
+ "ops": {}
41
+ },
42
+ "calendly": {
43
+ "displayName": "Calendly",
44
+ "authKind": "api_key",
45
+ "category": "scheduling",
46
+ "maturity": "coming_soon",
47
+ "docUrl": "https://developer.calendly.com/api-docs",
48
+ "ops": {}
49
+ },
50
+ "clearbit": {
51
+ "displayName": "Clearbit",
52
+ "authKind": "api_key",
53
+ "category": "sales-intelligence",
54
+ "maturity": "ready",
55
+ "docUrl": "https://dashboard.clearbit.com/docs",
56
+ "ops": {}
57
+ },
58
+ "drip": {
59
+ "displayName": "Drip",
60
+ "authKind": "api_key",
61
+ "category": "email",
62
+ "maturity": "ready",
63
+ "docUrl": "https://developer.drip.com/",
64
+ "ops": {}
65
+ },
66
+ "elevenlabs": {
67
+ "displayName": "ElevenLabs",
68
+ "authKind": "api_key",
69
+ "category": "voice",
70
+ "maturity": "ready",
71
+ "docUrl": "https://elevenlabs.io/docs/api-reference",
72
+ "ops": {}
73
+ },
74
+ "facebook": {
75
+ "displayName": "Facebook",
76
+ "authKind": "oauth2",
77
+ "category": "channel",
78
+ "maturity": "ready",
79
+ "docUrl": "https://developers.facebook.com/docs/pages-api",
80
+ "ops": {}
81
+ },
82
+ "fal": {
83
+ "displayName": "fal.ai",
84
+ "authKind": "api_key",
85
+ "category": "media",
86
+ "maturity": "coming_soon",
87
+ "docUrl": "https://fal.ai/docs",
88
+ "ops": {}
89
+ },
90
+ "hubspot": {
91
+ "displayName": "HubSpot",
92
+ "authKind": "api_key",
93
+ "category": "crm",
94
+ "maturity": "ready",
95
+ "docUrl": "https://developers.hubspot.com/docs/api/private-apps",
96
+ "ops": {}
97
+ },
98
+ "hunter": {
99
+ "displayName": "Hunter.io",
100
+ "authKind": "api_key",
101
+ "category": "email",
102
+ "maturity": "ready",
103
+ "docUrl": "https://hunter.io/api-documentation/v2",
104
+ "ops": {
105
+ "email-finder": {
106
+ "description": "Find a person's email address at a company domain by their name. Returns the email, a confidence score, and verification status.",
107
+ "inputSchema": {
108
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
109
+ "type": "object",
110
+ "properties": {
111
+ "domain": {
112
+ "type": "string",
113
+ "minLength": 1,
114
+ "description": "Company domain, e.g. \"stripe.com\"."
115
+ },
116
+ "first_name": {
117
+ "type": "string",
118
+ "minLength": 1,
119
+ "description": "The person first name."
120
+ },
121
+ "last_name": {
122
+ "type": "string",
123
+ "minLength": 1,
124
+ "description": "The person last name."
125
+ }
126
+ },
127
+ "required": [
128
+ "domain",
129
+ "first_name",
130
+ "last_name"
131
+ ]
132
+ }
133
+ }
134
+ }
135
+ },
136
+ "instagram": {
137
+ "displayName": "Instagram",
138
+ "authKind": "oauth2",
139
+ "category": "channel",
140
+ "maturity": "ready",
141
+ "docUrl": "https://developers.facebook.com/docs/instagram-platform",
142
+ "ops": {}
143
+ },
144
+ "instantly": {
145
+ "displayName": "Instantly.ai",
146
+ "authKind": "api_key",
147
+ "category": "email",
148
+ "maturity": "ready",
149
+ "docUrl": "https://developer.instantly.ai/",
150
+ "ops": {}
151
+ },
152
+ "mailchimp": {
153
+ "displayName": "Mailchimp",
154
+ "authKind": "api_key",
155
+ "category": "email",
156
+ "maturity": "ready",
157
+ "docUrl": "https://mailchimp.com/developer/marketing/api/",
158
+ "ops": {}
159
+ },
160
+ "meta": {
161
+ "displayName": "Meta Ads (Marketing API)",
162
+ "authKind": "api_key",
163
+ "category": "advertising",
164
+ "maturity": "coming_soon",
165
+ "docUrl": "https://developers.facebook.com/docs/marketing-apis",
166
+ "ops": {}
167
+ },
168
+ "pagespeed": {
169
+ "displayName": "PageSpeed Insights",
170
+ "authKind": "api_key",
171
+ "category": "analytics",
172
+ "maturity": "coming_soon",
173
+ "docUrl": "https://developers.google.com/speed/docs/insights/v5/get-started",
174
+ "ops": {}
175
+ },
176
+ "posthog": {
177
+ "displayName": "PostHog",
178
+ "authKind": "api_key",
179
+ "category": "analytics",
180
+ "maturity": "ready",
181
+ "docUrl": "https://posthog.com/docs/api",
182
+ "ops": {}
183
+ },
184
+ "salesforce": {
185
+ "displayName": "Salesforce",
186
+ "authKind": "api_key",
187
+ "category": "crm",
188
+ "maturity": "coming_soon",
189
+ "docUrl": "https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/",
190
+ "ops": {}
191
+ },
192
+ "sendgrid": {
193
+ "displayName": "SendGrid",
194
+ "authKind": "api_key",
195
+ "category": "email",
196
+ "maturity": "ready",
197
+ "docUrl": "https://docs.sendgrid.com/api-reference",
198
+ "ops": {}
199
+ },
200
+ "slack": {
201
+ "displayName": "Slack",
202
+ "authKind": "api_key",
203
+ "category": "messaging",
204
+ "maturity": "coming_soon",
205
+ "docUrl": "https://api.slack.com/methods/chat.postMessage",
206
+ "ops": {}
207
+ },
208
+ "stripe": {
209
+ "displayName": "Stripe",
210
+ "authKind": "oauth2",
211
+ "category": "payments",
212
+ "maturity": "coming_soon",
213
+ "docUrl": "https://docs.stripe.com/connect/oauth-reference",
214
+ "ops": {}
215
+ },
216
+ "twilio": {
217
+ "displayName": "Twilio",
218
+ "authKind": "api_key",
219
+ "category": "sms",
220
+ "maturity": "ready",
221
+ "docUrl": "https://www.twilio.com/docs/usage/api",
222
+ "ops": {}
223
+ },
224
+ "whatsapp": {
225
+ "displayName": "WhatsApp",
226
+ "authKind": "oauth2",
227
+ "category": "channel",
228
+ "maturity": "coming_soon",
229
+ "docUrl": "https://developers.facebook.com/docs/whatsapp",
230
+ "ops": {}
231
+ },
232
+ "wordpress": {
233
+ "displayName": "WordPress",
234
+ "authKind": "oauth2",
235
+ "category": "cms",
236
+ "maturity": "ready",
237
+ "docUrl": "https://developer.wordpress.com/docs/oauth2/",
238
+ "ops": {}
239
+ }
240
+ };
@@ -0,0 +1,28 @@
1
+ // @keemakr/agent-sdk/connectors — the generated connector manifest.
2
+ //
3
+ // A typed, metadata-only view of keemakr-core's connector catalog so an agent
4
+ // author (and the port kit) can discover providers + operation names + their arg
5
+ // schemas WITHOUT scanning a core checkout or hitting a running instance. Credential-
6
+ // free by construction — this is the same data GET /api/connections/catalog serves,
7
+ // committed as a snapshot (src/connectors.snapshot.json) and codegen'd into
8
+ // connectors.generated.ts. Refresh: see scripts/gen-connectors.mjs.
9
+ //
10
+ // Usage:
11
+ // import { connectors, opNames } from '@keemakr/agent-sdk/connectors';
12
+ // connectors.hunter.ops['email-finder'].inputSchema; // JSON Schema for the args
13
+ // opNames('meta'); // string[] of meta's op names
14
+ // isReady('meta'); // false while coming_soon
15
+ export { connectors, } from './connectors.generated.js';
16
+ import { connectors } from './connectors.generated.js';
17
+ /** All provider slugs in the manifest. */
18
+ export function providerNames() {
19
+ return Object.keys(connectors);
20
+ }
21
+ /** The operation names a provider exposes (empty for a coming_soon stub). */
22
+ export function opNames(provider) {
23
+ return Object.keys(connectors[provider]?.ops ?? {});
24
+ }
25
+ /** True when the provider's connect path is proven and its operations are callable. */
26
+ export function isReady(provider) {
27
+ return connectors[provider]?.maturity === 'ready';
28
+ }
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { grantAuth } from './grant-auth.js';
2
- export { useKee, type Kee, type KeeConnection, type KeeContext, type KeeError, type KeeMemory, type KeeTools, type MemoryEntry, } from './client.js';
2
+ export { verifyGrant, type VerifiedGrant } from './verify-grant.js';
3
+ export { useKee, type Kee, type KeeConnection, type KeeContext, type KeeError, type KeeMemory, type KeeTools, type MemoryEntry, type MemorySearchHit, } from './client.js';
3
4
  export { keemakrToolDirectory } from './tool-directory.js';
package/dist/index.js CHANGED
@@ -9,5 +9,6 @@
9
9
  // const kee = useKee(ctx);
10
10
  // const r = await kee.connections.hunter.call('email-finder', { domain, first_name, last_name });
11
11
  export { grantAuth } from './grant-auth.js';
12
+ export { verifyGrant } from './verify-grant.js';
12
13
  export { useKee, } from './client.js';
13
14
  export { keemakrToolDirectory } from './tool-directory.js';
@@ -0,0 +1,20 @@
1
+ /** Trusted claims after verifyGrant() succeeds. */
2
+ export interface VerifiedGrant {
3
+ tenantId: string;
4
+ installedAgent: string | null;
5
+ scopes: string[];
6
+ traceId: string | null;
7
+ aud: string | null;
8
+ exp: number | null;
9
+ }
10
+ /**
11
+ * Verify a capability grant (session OR machine) against keemakr-core's JWKS.
12
+ * Returns the trusted claims, or `null` on any failure (bad signature, wrong
13
+ * issuer/audience, expired). Both `jwksUrl` and `audience` fall back to
14
+ * KEE_CORE_JWKS_URL / KEE_AGENT_AUDIENCE. `audience` is strongly recommended: a
15
+ * grant is only valid for the remote it was minted for.
16
+ */
17
+ export declare function verifyGrant(token: string, opts?: {
18
+ jwksUrl?: string;
19
+ audience?: string;
20
+ }): Promise<VerifiedGrant | null>;
@@ -0,0 +1,52 @@
1
+ // Standalone capability-grant verification — for a scheduled/headless remote.
2
+ //
3
+ // grantAuth() (grant-auth.ts) is the right entry point for an eve CHANNEL: it
4
+ // returns an AuthFn. But an autonomous/machine turn may run OUTSIDE a channel (a
5
+ // cron worker that received a machine grant from core's machine-grant endpoint
6
+ // and wants to verify it before acting). verifyGrant() is that path: give it the
7
+ // token, get back the trusted claims (or null), verifying signature + issuer +
8
+ // audience against core's JWKS.
9
+ //
10
+ // A machine grant is the SAME token shape as a session grant (same issuer, aud,
11
+ // tenant_id, scopes) — only the TTL and the mint path differ — so this one
12
+ // verifier covers both.
13
+ import { createRemoteJWKSet, jwtVerify } from 'jose';
14
+ const GRANT_ISSUER = 'keemakr';
15
+ let jwks = null;
16
+ function jwksFor(url) {
17
+ if (!jwks)
18
+ jwks = createRemoteJWKSet(new URL(url));
19
+ return jwks;
20
+ }
21
+ /**
22
+ * Verify a capability grant (session OR machine) against keemakr-core's JWKS.
23
+ * Returns the trusted claims, or `null` on any failure (bad signature, wrong
24
+ * issuer/audience, expired). Both `jwksUrl` and `audience` fall back to
25
+ * KEE_CORE_JWKS_URL / KEE_AGENT_AUDIENCE. `audience` is strongly recommended: a
26
+ * grant is only valid for the remote it was minted for.
27
+ */
28
+ export async function verifyGrant(token, opts) {
29
+ const jwksUrl = opts?.jwksUrl ?? process.env.KEE_CORE_JWKS_URL;
30
+ if (!jwksUrl)
31
+ return null;
32
+ const expectedAud = opts?.audience ?? process.env.KEE_AGENT_AUDIENCE;
33
+ try {
34
+ const { payload } = await jwtVerify(token, jwksFor(jwksUrl), {
35
+ issuer: GRANT_ISSUER,
36
+ ...(expectedAud ? { audience: expectedAud } : {}),
37
+ });
38
+ if (typeof payload.tenant_id !== 'string' || !Array.isArray(payload.scopes))
39
+ return null;
40
+ return {
41
+ tenantId: payload.tenant_id,
42
+ installedAgent: typeof payload.installed_agent === 'string' ? payload.installed_agent : null,
43
+ scopes: payload.scopes.map(String),
44
+ traceId: typeof payload.trace_id === 'string' ? payload.trace_id : null,
45
+ aud: typeof payload.aud === 'string' ? payload.aud : null,
46
+ exp: typeof payload.exp === 'number' ? payload.exp : null,
47
+ };
48
+ }
49
+ catch {
50
+ return null;
51
+ }
52
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keemakr/agent-sdk",
3
- "version": "0.3.0",
3
+ "version": "0.6.0",
4
4
  "description": "The floor for keemakr marketplace agents: verify the capability grant and reach tenant connections, memory, and shared platform tools through keemakr-core — without holding raw secrets or resolving the tenant yourself.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -14,6 +14,10 @@
14
14
  "./tool-directory": {
15
15
  "types": "./dist/tool-directory.d.ts",
16
16
  "import": "./dist/tool-directory.js"
17
+ },
18
+ "./connectors": {
19
+ "types": "./dist/connectors.d.ts",
20
+ "import": "./dist/connectors.js"
17
21
  }
18
22
  },
19
23
  "files": [
@@ -25,11 +29,13 @@
25
29
  },
26
30
  "repository": {
27
31
  "type": "git",
28
- "url": "git+https://github.com/fsztpartners/keemakr-agent-sdk.git"
32
+ "url": "git+https://github.com/fsztpartners/keemakr.git",
33
+ "directory": "packages/agent-sdk"
29
34
  },
30
35
  "scripts": {
31
- "build": "tsc -p tsconfig.json",
32
- "typecheck": "tsc --noEmit",
36
+ "gen:connectors": "node scripts/gen-connectors.mjs",
37
+ "build": "npm run gen:connectors && tsc -p tsconfig.json",
38
+ "typecheck": "npm run gen:connectors && tsc --noEmit",
33
39
  "prepublishOnly": "npm run build"
34
40
  },
35
41
  "peerDependencies": {