@slashfi/agents-sdk 0.39.0 → 0.40.1
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/adk.d.ts +13 -21
- package/dist/adk.d.ts.map +1 -1
- package/dist/adk.js +354 -51
- package/dist/adk.js.map +1 -1
- package/dist/cjs/codegen.js +1 -1
- package/dist/cjs/codegen.js.map +1 -1
- package/dist/cjs/config-store.js +727 -0
- package/dist/cjs/config-store.js.map +1 -0
- package/dist/cjs/index.js +7 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/local-fs.js +63 -0
- package/dist/cjs/local-fs.js.map +1 -0
- package/dist/cjs/registry.js +3 -0
- package/dist/cjs/registry.js.map +1 -1
- package/dist/codegen.d.ts +1 -0
- package/dist/codegen.d.ts.map +1 -1
- package/dist/codegen.js +1 -1
- package/dist/codegen.js.map +1 -1
- package/dist/config-store.d.ts +137 -0
- package/dist/config-store.d.ts.map +1 -0
- package/dist/config-store.js +691 -0
- package/dist/config-store.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/local-fs.d.ts +18 -0
- package/dist/local-fs.d.ts.map +1 -0
- package/dist/local-fs.js +59 -0
- package/dist/local-fs.js.map +1 -0
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +3 -0
- package/dist/registry.js.map +1 -1
- package/dist/validate.d.ts +4 -4
- package/package.json +1 -1
- package/src/adk.ts +313 -53
- package/src/codegen.ts +2 -2
- package/src/config-store.ts +910 -0
- package/src/index.ts +14 -0
- package/src/local-fs.ts +68 -0
- package/src/registry.ts +3 -0
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";
|
package/src/local-fs.ts
ADDED
|
@@ -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/registry.ts
CHANGED
|
@@ -789,6 +789,7 @@ export function createAgentRegistry(
|
|
|
789
789
|
}
|
|
790
790
|
|
|
791
791
|
case "describe_tools": {
|
|
792
|
+
const configUpstream = (agent.config as Record<string, unknown> | undefined)?.upstream as string | undefined;
|
|
792
793
|
const toolSchemas: ToolSchema[] = agent.tools
|
|
793
794
|
.filter((t: ToolDefinition) =>
|
|
794
795
|
checkToolAccess(
|
|
@@ -817,6 +818,7 @@ export function createAgentRegistry(
|
|
|
817
818
|
tools: toolSchemas,
|
|
818
819
|
description: agent.config?.description,
|
|
819
820
|
security: agent.config?.security,
|
|
821
|
+
...(configUpstream ? { upstream: configUpstream } : {}),
|
|
820
822
|
resources: agent.config?.resources?.map((r) => ({
|
|
821
823
|
uri: r.uri,
|
|
822
824
|
name: r.name,
|
|
@@ -843,6 +845,7 @@ export function createAgentRegistry(
|
|
|
843
845
|
toolSummaries,
|
|
844
846
|
description: agent.config?.description,
|
|
845
847
|
security: agent.config?.security,
|
|
848
|
+
...(configUpstream ? { upstream: configUpstream } : {}),
|
|
846
849
|
resources: agent.config?.resources?.map((r) => ({
|
|
847
850
|
uri: r.uri,
|
|
848
851
|
name: r.name,
|