@keemakr/agent-sdk 0.2.0 → 0.3.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/dist/client.d.ts CHANGED
@@ -47,6 +47,17 @@ export interface KeeMemory {
47
47
  /** List every entry in a namespace (tenant-wide). */
48
48
  list(namespace: string): Promise<MemoryEntry[]>;
49
49
  }
50
+ /** Platform registry tools (Shape B) — defined in core, run server-side. */
51
+ export interface KeeTools {
52
+ /** List the registry tools this grant is entitled to. */
53
+ list(): Promise<Array<{
54
+ name: string;
55
+ description: string;
56
+ requiredScope?: string;
57
+ }>>;
58
+ /** Run a registry tool by name and return its result. Requires `tools:run`. */
59
+ run(name: string, args?: Record<string, unknown>): Promise<unknown>;
60
+ }
50
61
  export interface Kee {
51
62
  tenantId: string;
52
63
  scopes: string[];
@@ -55,6 +66,7 @@ export interface Kee {
55
66
  get(provider: string): KeeConnection;
56
67
  };
57
68
  memory: KeeMemory;
69
+ tools: KeeTools;
58
70
  }
59
71
  /**
60
72
  * Build a tenant-scoped capability client from a tool's context. Call inside a
package/dist/client.js CHANGED
@@ -105,5 +105,17 @@ export function useKee(ctx) {
105
105
  return json.entries ?? [];
106
106
  },
107
107
  };
108
- return { tenantId: grant.tenantId, scopes: grant.scopes, connections, memory };
108
+ const tools = {
109
+ async list() {
110
+ const json = (await capabilityFetch(grant, 'tools', undefined, 'GET'));
111
+ return json.tools ?? [];
112
+ },
113
+ async run(name, args) {
114
+ const json = (await capabilityFetch(grant, `tools/${encodeURIComponent(name)}`, {
115
+ args: args ?? {},
116
+ }));
117
+ return json.result;
118
+ },
119
+ };
120
+ return { tenantId: grant.tenantId, scopes: grant.scopes, connections, memory, tools };
109
121
  }
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export { grantAuth } from './grant-auth.js';
2
- export { useKee, type Kee, type KeeConnection, type KeeContext, type KeeError, type KeeMemory, type MemoryEntry, } from './client.js';
2
+ export { useKee, type Kee, type KeeConnection, type KeeContext, type KeeError, type KeeMemory, type KeeTools, type MemoryEntry, } from './client.js';
3
+ export { keemakrToolDirectory } from './tool-directory.js';
package/dist/index.js CHANGED
@@ -10,3 +10,4 @@
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
12
  export { useKee, } from './client.js';
13
+ export { keemakrToolDirectory } from './tool-directory.js';
@@ -0,0 +1 @@
1
+ export declare const keemakrToolDirectory: import("eve/tools").DynamicSentinel;
@@ -0,0 +1,61 @@
1
+ // keemakrToolDirectory — a defineDynamic file that surfaces the platform's
2
+ // registry tools (Shape B) to an agent at session start, with NO redeploy.
3
+ //
4
+ // Drop it into your agent in one line:
5
+ // // agent/tools/keemakr-directory.ts
6
+ // export { keemakrToolDirectory as default } from '@keemakr/agent-sdk/tool-directory';
7
+ //
8
+ // On session.started it reads the verified grant off the session, asks
9
+ // keemakr-core which registry tools this install is entitled to, and synthesizes
10
+ // one delegation tool per entry. Each synthesized tool's execute calls
11
+ // useKee(ctx).tools.run(name, args) — so the tool runs IN CORE, governed
12
+ // centrally: a fix or a new tool in core's registry reaches every agent next
13
+ // session, no redeploy here. Mirrors keemakr-core's marketplace-dispatch.ts.
14
+ import { defineDynamic, defineTool } from 'eve/tools';
15
+ import { z } from 'zod';
16
+ import { useKee } from './client.js';
17
+ export const keemakrToolDirectory = defineDynamic({
18
+ events: {
19
+ 'session.started': async (_event, ctx) => {
20
+ // No grant on the session (e.g. local dev without grantAuth) → no tools.
21
+ let kee;
22
+ try {
23
+ kee = useKee(ctx);
24
+ }
25
+ catch {
26
+ return null;
27
+ }
28
+ let entries;
29
+ try {
30
+ entries = await kee.tools.list();
31
+ }
32
+ catch {
33
+ return null;
34
+ }
35
+ if (!entries.length)
36
+ return null;
37
+ // One delegation tool per entitled registry tool. The args are passed
38
+ // through as a generic object; core validates them against the tool's real
39
+ // schema and returns a typed error if they don't fit. (Names are namespaced
40
+ // `kee__<name>` to avoid colliding with the agent's own tools.)
41
+ const pairs = entries.map((t) => {
42
+ const name = t.name;
43
+ const tool = defineTool({
44
+ description: `${t.description} (keemakr platform tool, runs server-side)`,
45
+ inputSchema: z.object({
46
+ args: z
47
+ .record(z.string(), z.unknown())
48
+ .optional()
49
+ .describe('Arguments for the tool, per its description.'),
50
+ }),
51
+ execute: async ({ args }) => {
52
+ const result = await useKee(ctx).tools.run(name, args ?? {});
53
+ return { ok: true, tool: name, result };
54
+ },
55
+ });
56
+ return [`kee__${name.replace(/[^a-z0-9]+/gi, '_')}`, tool];
57
+ });
58
+ return Object.fromEntries(pairs);
59
+ },
60
+ },
61
+ });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@keemakr/agent-sdk",
3
- "version": "0.2.0",
4
- "description": "The floor for keemakr marketplace agents: verify the capability grant and reach tenant connections (and, soon, memory and shared tools) through keemakr-core — without holding raw secrets or resolving the tenant yourself.",
3
+ "version": "0.3.0",
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",
7
7
  "main": "./dist/index.js",
@@ -10,6 +10,10 @@
10
10
  ".": {
11
11
  "types": "./dist/index.d.ts",
12
12
  "import": "./dist/index.js"
13
+ },
14
+ "./tool-directory": {
15
+ "types": "./dist/tool-directory.d.ts",
16
+ "import": "./dist/tool-directory.js"
13
17
  }
14
18
  },
15
19
  "files": [