@slashfi/agents-sdk 0.77.2 → 0.77.3
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/cjs/adk-tools.js +104 -253
- package/dist/cjs/adk-tools.js.map +1 -1
- package/dist/cjs/config-store.js +68 -26
- package/dist/cjs/config-store.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.map +1 -1
- package/dist/config-store.js +68 -26
- package/dist/config-store.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.ts +97 -27
- package/src/ref-naming.test.ts +1 -49
- package/src/registry.ts +2 -40
- package/src/types.ts +6 -21
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
|
+
|