@slashfi/agents-sdk 0.38.0 → 0.40.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/src/events.ts CHANGED
@@ -171,7 +171,7 @@ export interface ListAgentsResult {
171
171
  integration?: unknown;
172
172
  security?: { type: string };
173
173
  resources?: Array<{ uri: string; name?: string; mimeType?: string }>;
174
- tools: string[];
174
+ toolCount: number;
175
175
  }>;
176
176
  }
177
177
 
package/src/hooks.test.ts CHANGED
@@ -330,7 +330,7 @@ describe("tools/call/list_agents hook", () => {
330
330
  path: "@custom-only",
331
331
  name: "Custom",
332
332
  description: "Only this one",
333
- tools: ["do_stuff"],
333
+ toolCount: 1,
334
334
  },
335
335
  ],
336
336
  });
package/src/index.ts CHANGED
@@ -447,3 +447,17 @@ export type {
447
447
  ConfigAgentOptions,
448
448
  FsStore,
449
449
  } from "./agent-definitions/config.js";
450
+
451
+ // ADK Config Store
452
+ export { createAdk } from "./config-store.js";
453
+ export type {
454
+ Adk,
455
+ AdkOptions,
456
+ AdkRegistryApi,
457
+ AdkRefApi,
458
+ RefAuthStatus,
459
+ AuthStartResult,
460
+ OAuthResult,
461
+ RegistryTestResult,
462
+ } from "./config-store.js";
463
+ export { createLocalFsStore, getLocalEncryptionKey } from "./local-fs.js";
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Local filesystem FsStore for ADK CLI.
3
+ *
4
+ * Reads/writes files under ~/.adk/ (or $ADK_CONFIG_DIR).
5
+ * Creates the directory on first write.
6
+ *
7
+ * Also manages the local encryption key at .encryption-key
8
+ * (auto-generated on first use, never read by FsStore itself).
9
+ */
10
+
11
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
12
+ import { randomBytes } from "node:crypto";
13
+ import { dirname, join } from "node:path";
14
+ import { homedir } from "node:os";
15
+ import type { FsStore } from "./agent-definitions/config.js";
16
+
17
+ const ENCRYPTION_KEY_FILE = ".encryption-key";
18
+
19
+ function defaultDir(): string {
20
+ return process.env.ADK_CONFIG_DIR ?? join(homedir(), ".adk");
21
+ }
22
+
23
+ export function createLocalFsStore(dir?: string): FsStore {
24
+ const base = dir ?? defaultDir();
25
+
26
+ return {
27
+ async readFile(path: string): Promise<string | null> {
28
+ const full = join(base, path);
29
+ if (!existsSync(full)) return null;
30
+ return readFileSync(full, "utf-8");
31
+ },
32
+
33
+ async writeFile(path: string, content: string): Promise<void> {
34
+ const full = join(base, path);
35
+ const parent = dirname(full);
36
+ if (!existsSync(parent)) {
37
+ mkdirSync(parent, { recursive: true });
38
+ }
39
+ writeFileSync(full, content, "utf-8");
40
+ },
41
+ };
42
+ }
43
+
44
+ /**
45
+ * Read the local encryption key from ~/.adk/.encryption-key.
46
+ * Generates a random 32-byte hex key on first use.
47
+ * Pass the env var ADK_ENCRYPTION_KEY to override.
48
+ */
49
+ export function getLocalEncryptionKey(dir?: string): string {
50
+ if (process.env.ADK_ENCRYPTION_KEY) {
51
+ return process.env.ADK_ENCRYPTION_KEY;
52
+ }
53
+
54
+ const base = dir ?? defaultDir();
55
+ const keyPath = join(base, ENCRYPTION_KEY_FILE);
56
+
57
+ if (existsSync(keyPath)) {
58
+ return readFileSync(keyPath, "utf-8").trim();
59
+ }
60
+
61
+ // Generate and persist
62
+ if (!existsSync(base)) {
63
+ mkdirSync(base, { recursive: true });
64
+ }
65
+ const key = randomBytes(32).toString("hex");
66
+ writeFileSync(keyPath, key, { encoding: "utf-8", mode: 0o600 });
67
+ return key;
68
+ }
package/src/server.ts CHANGED
@@ -764,9 +764,9 @@ export function createAgentServer(
764
764
  name: r.name,
765
765
  mimeType: r.mimeType,
766
766
  })),
767
- tools: agent.tools
767
+ toolCount: agent.tools
768
768
  .filter((t) => canSeeTool(t, auth, (agent.visibility ?? agent.config?.visibility ?? 'internal') as Visibility))
769
- .map((t) => t.name),
769
+ .length,
770
770
  })),
771
771
  };
772
772
  },