@slashfi/agents-sdk 0.77.2 → 0.78.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/adk-tools.d.ts.map +1 -1
- package/dist/adk-tools.js +104 -253
- package/dist/adk-tools.js.map +1 -1
- package/dist/call-agent-schema.d.ts +12 -12
- package/dist/cjs/adk-tools.js +104 -253
- package/dist/cjs/adk-tools.js.map +1 -1
- package/dist/cjs/config-store.js +333 -94
- package/dist/cjs/config-store.js.map +1 -1
- package/dist/cjs/define-config.js.map +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/registry.js +2 -33
- package/dist/cjs/registry.js.map +1 -1
- package/dist/cjs/types.js.map +1 -1
- package/dist/config-store.d.ts +34 -4
- package/dist/config-store.d.ts.map +1 -1
- package/dist/config-store.js +333 -94
- package/dist/config-store.js.map +1 -1
- package/dist/define-config.d.ts +28 -4
- package/dist/define-config.d.ts.map +1 -1
- package/dist/define-config.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +2 -33
- package/dist/registry.js.map +1 -1
- package/dist/types.d.ts +3 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
- package/src/adk-tools.ts +113 -282
- package/src/config-store.test.ts +345 -28
- package/src/config-store.ts +829 -274
- package/src/define-config.ts +47 -21
- package/src/index.ts +16 -13
- package/src/ref-naming.test.ts +1 -49
- package/src/registry.ts +2 -40
- package/src/types.ts +6 -21
package/src/define-config.ts
CHANGED
|
@@ -53,7 +53,7 @@ export type RegistryAuth =
|
|
|
53
53
|
* local credentials.
|
|
54
54
|
*/
|
|
55
55
|
export interface RegistryProxy {
|
|
56
|
-
mode:
|
|
56
|
+
mode: "required" | "optional";
|
|
57
57
|
/** Agent path to forward to. Defaults to `@config`. */
|
|
58
58
|
agent?: string;
|
|
59
59
|
}
|
|
@@ -119,7 +119,7 @@ export interface RegistryEntry {
|
|
|
119
119
|
publisher?: string;
|
|
120
120
|
|
|
121
121
|
/** Connection status — set by validation/test, used to filter active entries */
|
|
122
|
-
status?:
|
|
122
|
+
status?: "active" | "inactive" | "error";
|
|
123
123
|
|
|
124
124
|
/**
|
|
125
125
|
* If set, ref ops for refs sourced from this registry are forwarded
|
|
@@ -153,31 +153,57 @@ export type RefConfig = Record<string, unknown>;
|
|
|
153
153
|
|
|
154
154
|
/** A ref entry — describes how to connect to an agent */
|
|
155
155
|
export type RefEntry = {
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
/** Canonical agent path on the remote registry (e.g. `notion`, `linear`). */
|
|
157
|
+
ref: string;
|
|
158
158
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
159
|
+
/**
|
|
160
|
+
* Local identifier for this ref. Used by all operations
|
|
161
|
+
* (call/remove/auth/update/…) to look up the entry. Add paths
|
|
162
|
+
* default this to `ref` when omitted.
|
|
163
|
+
*/
|
|
164
|
+
name: string;
|
|
165
165
|
|
|
166
|
-
|
|
167
|
-
|
|
166
|
+
/** Connection scheme */
|
|
167
|
+
scheme?: "mcp" | "https" | "registry";
|
|
168
168
|
|
|
169
|
-
|
|
170
|
-
|
|
169
|
+
/** Direct URL to the agent (e.g. https://mcp.notion.com/mcp) */
|
|
170
|
+
url?: string;
|
|
171
171
|
|
|
172
|
-
|
|
173
|
-
|
|
172
|
+
/** Per-instance config (headers, secrets, etc. — values support {{secret-uri}} templates) */
|
|
173
|
+
config?: RefConfig;
|
|
174
174
|
|
|
175
|
-
|
|
176
|
-
|
|
175
|
+
/** The registry where this ref was discovered */
|
|
176
|
+
sourceRegistry?: { url: string; agentPath: string };
|
|
177
177
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
178
|
+
/** Connection status — set by validation/test, used to filter active entries */
|
|
179
|
+
status?: "active" | "inactive" | "error";
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Human-readable description from the registry.
|
|
183
|
+
*
|
|
184
|
+
* Not stored in `consumer-config.json`. Hydrated into the in-memory
|
|
185
|
+
* `RefEntry` by `ref.list()` / `ref.get()` from `registry-cache.json`,
|
|
186
|
+
* which the adk maintains as a side-effect of `ref.add()` / `ref.inspect()`.
|
|
187
|
+
*
|
|
188
|
+
* `undefined` when the cache has no entry yet (e.g. first session for an
|
|
189
|
+
* existing user, or a freshly cleared cache). Consumers that need a fallback
|
|
190
|
+
* should apply their own (commonly `description ?? name`).
|
|
191
|
+
*/
|
|
192
|
+
description?: string;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Slim tool summaries from the registry. Populated alongside `description`
|
|
196
|
+
* by the same cache lifecycle. Tool input schemas are intentionally
|
|
197
|
+
* omitted — they are too large to cache and callers fetch them on demand
|
|
198
|
+
* via `ref.inspect(name, { full: true })`.
|
|
199
|
+
*
|
|
200
|
+
* `undefined` when the cache has no entry yet.
|
|
201
|
+
*/
|
|
202
|
+
tools?: Array<{
|
|
203
|
+
name: string;
|
|
204
|
+
description?: string;
|
|
205
|
+
}>;
|
|
206
|
+
};
|
|
181
207
|
|
|
182
208
|
/** Input accepted by add paths. `name` defaults to `ref` when omitted. */
|
|
183
209
|
export type RefAddInput = Omit<RefEntry, "name"> & { name?: string };
|
package/src/index.ts
CHANGED
|
@@ -112,7 +112,12 @@ export {
|
|
|
112
112
|
|
|
113
113
|
// Define functions
|
|
114
114
|
export { defineAgent, defineTool } from "./define.js";
|
|
115
|
-
export type {
|
|
115
|
+
export type {
|
|
116
|
+
DefineAgentOptions,
|
|
117
|
+
DefineToolOptions,
|
|
118
|
+
AgentWithHooks,
|
|
119
|
+
ToolWithHooks,
|
|
120
|
+
} from "./define.js";
|
|
116
121
|
|
|
117
122
|
// Registry
|
|
118
123
|
export { createAgentRegistry, agentFromSerialized } from "./registry.js";
|
|
@@ -346,10 +351,7 @@ export {
|
|
|
346
351
|
exchangeCodeForTokens,
|
|
347
352
|
refreshAccessToken as refreshMcpAccessToken,
|
|
348
353
|
} from "./mcp-client.js";
|
|
349
|
-
export type {
|
|
350
|
-
OAuthServerMetadata,
|
|
351
|
-
} from "./mcp-client.js";
|
|
352
|
-
|
|
354
|
+
export type { OAuthServerMetadata } from "./mcp-client.js";
|
|
353
355
|
|
|
354
356
|
// ============================================
|
|
355
357
|
// Serialized Agent Definitions
|
|
@@ -361,10 +363,6 @@ export type {
|
|
|
361
363
|
SerializedTool,
|
|
362
364
|
} from "./serialized.js";
|
|
363
365
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
366
|
// ============================================
|
|
369
367
|
// call_agent Schema (shared source of truth)
|
|
370
368
|
// ============================================
|
|
@@ -405,9 +403,7 @@ export type { ValidationResult } from "./validate.js";
|
|
|
405
403
|
// BM25 Search
|
|
406
404
|
// ============================================
|
|
407
405
|
|
|
408
|
-
export {
|
|
409
|
-
createBM25Index,
|
|
410
|
-
} from "./bm25.js";
|
|
406
|
+
export { createBM25Index } from "./bm25.js";
|
|
411
407
|
|
|
412
408
|
export type {
|
|
413
409
|
BM25Options,
|
|
@@ -438,7 +434,14 @@ export type {
|
|
|
438
434
|
ResolveCredentials,
|
|
439
435
|
ResolveCredentialsContext,
|
|
440
436
|
RegistryTestResult,
|
|
437
|
+
RegistryCache,
|
|
438
|
+
RegistryCacheEntry,
|
|
439
|
+
RegistryCacheToolSummary,
|
|
441
440
|
} from "./config-store.js";
|
|
442
441
|
export { createLocalFsStore, getLocalEncryptionKey } from "./local-fs.js";
|
|
443
442
|
export { AdkError, getError, getRecentErrors } from "./adk-error.js";
|
|
444
|
-
export {
|
|
443
|
+
export {
|
|
444
|
+
createAdkTools,
|
|
445
|
+
type AdkToolsHooks,
|
|
446
|
+
type CreateAdkToolsOptions,
|
|
447
|
+
} from "./adk-tools.js";
|
package/src/ref-naming.test.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import { describe, expect, test } from "bun:test";
|
|
11
11
|
import { createAdkTools } from "./adk-tools";
|
|
12
12
|
import type { FsStore } from "./agent-definitions/config";
|
|
13
|
-
import { createAdk
|
|
13
|
+
import { createAdk } from "./index";
|
|
14
14
|
import type { ToolContext } from "./types";
|
|
15
15
|
|
|
16
16
|
function createMemoryFs(): FsStore {
|
|
@@ -326,54 +326,6 @@ describe("ref tool — add operation defaults ref to name", () => {
|
|
|
326
326
|
const raw = await fs.readFile("consumer-config.json");
|
|
327
327
|
expect(raw).toBeNull();
|
|
328
328
|
});
|
|
329
|
-
|
|
330
|
-
test("invalid add input returns schema details through registry call", async () => {
|
|
331
|
-
const fs = createMemoryFs();
|
|
332
|
-
const adk = createAdk(fs);
|
|
333
|
-
const refTool = makeRefTool(adk);
|
|
334
|
-
const registry = createAgentRegistry();
|
|
335
|
-
registry.register(
|
|
336
|
-
defineAgent({
|
|
337
|
-
path: "@config",
|
|
338
|
-
entrypoint: "Config agent",
|
|
339
|
-
tools: [refTool],
|
|
340
|
-
visibility: "public",
|
|
341
|
-
}),
|
|
342
|
-
);
|
|
343
|
-
|
|
344
|
-
const response = await registry.call({
|
|
345
|
-
action: "execute_tool",
|
|
346
|
-
path: "@config",
|
|
347
|
-
tool: "ref",
|
|
348
|
-
params: {
|
|
349
|
-
operation: "add",
|
|
350
|
-
ref: "google-calendar",
|
|
351
|
-
},
|
|
352
|
-
});
|
|
353
|
-
|
|
354
|
-
expect(response.success).toBe(false);
|
|
355
|
-
if (response.success) throw new Error("expected invalid input error");
|
|
356
|
-
expect(response.code).toBe("TOOL_INPUT_INVALID");
|
|
357
|
-
expect(response.error).toContain("Invalid ref.add input");
|
|
358
|
-
expect(response.details?.issues).toEqual(
|
|
359
|
-
expect.arrayContaining([
|
|
360
|
-
expect.objectContaining({
|
|
361
|
-
path: "sourceRegistry",
|
|
362
|
-
}),
|
|
363
|
-
]),
|
|
364
|
-
);
|
|
365
|
-
expect(response.details?.schema).toMatchObject({
|
|
366
|
-
anyOf: expect.any(Array),
|
|
367
|
-
});
|
|
368
|
-
expect(response.details?.operationSchema).toMatchObject({
|
|
369
|
-
type: "object",
|
|
370
|
-
});
|
|
371
|
-
expect(response.hint).toContain("details.schema");
|
|
372
|
-
expect(response.details).not.toHaveProperty("examples");
|
|
373
|
-
expect(JSON.stringify(response.details?.operationSchema)).toContain(
|
|
374
|
-
"sourceRegistry",
|
|
375
|
-
);
|
|
376
|
-
});
|
|
377
329
|
});
|
|
378
330
|
|
|
379
331
|
describe("ref tool — auth state hook", () => {
|
package/src/registry.ts
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { dirname, resolve } from "node:path";
|
|
8
|
-
import { AdkError } from "./adk-error.js";
|
|
9
8
|
import type { AgentEvent, BaseEvent, CallAgentToolCallEvent, CustomEventMap, EventCallback, EventType, ListAgentsResult, ListAgentsToolCallEvent } from "./events.js";
|
|
10
9
|
import { createEventBus } from "./events.js";
|
|
11
10
|
import type { Logger } from "./logger.js";
|
|
@@ -40,33 +39,6 @@ const DEFAULT_SUPPORTED_ACTIONS: AgentAction[] = [
|
|
|
40
39
|
"read_resources",
|
|
41
40
|
];
|
|
42
41
|
|
|
43
|
-
function adkErrorFields(
|
|
44
|
-
err: unknown,
|
|
45
|
-
): { code: string; hint: string; details: Record<string, unknown> } | null {
|
|
46
|
-
if (err instanceof AdkError) {
|
|
47
|
-
return { code: err.code, hint: err.hint, details: err.details };
|
|
48
|
-
}
|
|
49
|
-
if (!err || typeof err !== "object") return null;
|
|
50
|
-
const candidate = err as {
|
|
51
|
-
name?: unknown;
|
|
52
|
-
code?: unknown;
|
|
53
|
-
hint?: unknown;
|
|
54
|
-
details?: unknown;
|
|
55
|
-
};
|
|
56
|
-
return candidate.name === "AdkError" &&
|
|
57
|
-
typeof candidate.code === "string" &&
|
|
58
|
-
typeof candidate.hint === "string" &&
|
|
59
|
-
!!candidate.details &&
|
|
60
|
-
typeof candidate.details === "object" &&
|
|
61
|
-
!Array.isArray(candidate.details)
|
|
62
|
-
? {
|
|
63
|
-
code: candidate.code,
|
|
64
|
-
hint: candidate.hint,
|
|
65
|
-
details: candidate.details as Record<string, unknown>,
|
|
66
|
-
}
|
|
67
|
-
: null;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
42
|
/**
|
|
71
43
|
* Estimate the token count for a tool schema when serialized to JSON.
|
|
72
44
|
* Uses a rough heuristic: ~4 characters per token (conservative estimate
|
|
@@ -788,15 +760,10 @@ export function createAgentRegistry(
|
|
|
788
760
|
})
|
|
789
761
|
.catch(() => {}); // don't let emit error mask tool error
|
|
790
762
|
|
|
791
|
-
const adkErr = adkErrorFields(err);
|
|
792
763
|
return {
|
|
793
764
|
success: false,
|
|
794
765
|
error: err instanceof Error ? err.message : String(err),
|
|
795
|
-
code:
|
|
796
|
-
...(adkErr && {
|
|
797
|
-
hint: adkErr.hint,
|
|
798
|
-
details: adkErr.details,
|
|
799
|
-
}),
|
|
766
|
+
code: "TOOL_EXECUTION_ERROR",
|
|
800
767
|
} as CallAgentErrorResponse;
|
|
801
768
|
}
|
|
802
769
|
|
|
@@ -817,16 +784,11 @@ export function createAgentRegistry(
|
|
|
817
784
|
} as CallAgentExecuteToolResponse;
|
|
818
785
|
} catch (outerErr) {
|
|
819
786
|
// Catch-all for unexpected errors (e.g., emit failures)
|
|
820
|
-
const adkErr = adkErrorFields(outerErr);
|
|
821
787
|
return {
|
|
822
788
|
success: false,
|
|
823
789
|
error:
|
|
824
790
|
outerErr instanceof Error ? outerErr.message : String(outerErr),
|
|
825
|
-
code:
|
|
826
|
-
...(adkErr && {
|
|
827
|
-
hint: adkErr.hint,
|
|
828
|
-
details: adkErr.details,
|
|
829
|
-
}),
|
|
791
|
+
code: "TOOL_EXECUTION_ERROR",
|
|
830
792
|
} as CallAgentErrorResponse;
|
|
831
793
|
}
|
|
832
794
|
}
|
package/src/types.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* Defines the fundamental types for agent definitions, tools, and contexts.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import type { AgentAction, CallerType } from "./call-agent-schema.js";
|
|
8
7
|
import type { EventCallback, EventType } from "./events.js";
|
|
8
|
+
import type { AgentAction, CallerType } from "./call-agent-schema.js";
|
|
9
9
|
|
|
10
10
|
/** Internal listener entry stored on agents/tools */
|
|
11
11
|
export interface ListenerEntry {
|
|
@@ -22,15 +22,7 @@ export interface ListenerEntry {
|
|
|
22
22
|
* JSON Schema definition for tool input parameters.
|
|
23
23
|
*/
|
|
24
24
|
export type JsonSchema = {
|
|
25
|
-
type:
|
|
26
|
-
| "object"
|
|
27
|
-
| "array"
|
|
28
|
-
| "string"
|
|
29
|
-
| "number"
|
|
30
|
-
| "integer"
|
|
31
|
-
| "boolean"
|
|
32
|
-
| "null"
|
|
33
|
-
| string[];
|
|
25
|
+
type: "object" | "array" | "string" | "number" | "integer" | "boolean" | "null" | string[];
|
|
34
26
|
properties?: Record<string, JsonSchema>;
|
|
35
27
|
items?: JsonSchema;
|
|
36
28
|
required?: string[];
|
|
@@ -301,7 +293,7 @@ export type SecurityScheme =
|
|
|
301
293
|
* directory-level overview (e.g., in list_agents responses).
|
|
302
294
|
*/
|
|
303
295
|
export interface SecuritySchemeSummary {
|
|
304
|
-
type: SecurityScheme[
|
|
296
|
+
type: SecurityScheme['type'];
|
|
305
297
|
[key: string]: unknown;
|
|
306
298
|
}
|
|
307
299
|
|
|
@@ -718,7 +710,7 @@ export interface AgentDefinition<TContext extends ToolContext = ToolContext> {
|
|
|
718
710
|
* - 'direct': registry hosts and serves this agent's tools (default)
|
|
719
711
|
* - 'redirect': registry catalogs this agent but clients connect to `upstream` directly
|
|
720
712
|
*/
|
|
721
|
-
mode?:
|
|
713
|
+
mode?: 'direct' | 'redirect';
|
|
722
714
|
|
|
723
715
|
/**
|
|
724
716
|
* Upstream URL for redirect-mode agents.
|
|
@@ -869,8 +861,6 @@ export interface CallAgentErrorResponse {
|
|
|
869
861
|
success: false;
|
|
870
862
|
error: string;
|
|
871
863
|
code?: string;
|
|
872
|
-
hint?: string;
|
|
873
|
-
details?: Record<string, unknown>;
|
|
874
864
|
}
|
|
875
865
|
|
|
876
866
|
/** Union of all response types */
|
|
@@ -952,10 +942,5 @@ export type ServerSource =
|
|
|
952
942
|
| string
|
|
953
943
|
| { command: string; args?: string[]; env?: Record<string, string> }
|
|
954
944
|
| { url: string; headers?: Record<string, string> }
|
|
955
|
-
| {
|
|
956
|
-
|
|
957
|
-
args?: string[];
|
|
958
|
-
env?: Record<string, string>;
|
|
959
|
-
port?: number;
|
|
960
|
-
endpoint?: string;
|
|
961
|
-
};
|
|
945
|
+
| { spawn: string; args?: string[]; env?: Record<string, string>; port?: number; endpoint?: string };
|
|
946
|
+
|