@slashfi/agents-sdk 0.77.0 → 0.77.2
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 +2 -2
- package/dist/adk-tools.d.ts.map +1 -1
- package/dist/adk-tools.js +258 -118
- package/dist/adk-tools.js.map +1 -1
- package/dist/adk.js +7 -9
- package/dist/adk.js.map +1 -1
- package/dist/agent-definitions/config.d.ts.map +1 -1
- package/dist/agent-definitions/config.js +12 -14
- package/dist/agent-definitions/config.js.map +1 -1
- package/dist/cjs/adk-tools.js +258 -118
- package/dist/cjs/adk-tools.js.map +1 -1
- package/dist/cjs/agent-definitions/config.js +12 -14
- package/dist/cjs/agent-definitions/config.js.map +1 -1
- package/dist/cjs/config-store.js +34 -17
- package/dist/cjs/config-store.js.map +1 -1
- package/dist/cjs/define-config.js +5 -7
- package/dist/cjs/define-config.js.map +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/materialize.js +1 -1
- package/dist/cjs/materialize.js.map +1 -1
- package/dist/cjs/registry-consumer.js +1 -1
- package/dist/cjs/registry.js +33 -2
- package/dist/cjs/registry.js.map +1 -1
- package/dist/cjs/types.js.map +1 -1
- package/dist/config-store.d.ts +3 -3
- package/dist/config-store.d.ts.map +1 -1
- package/dist/config-store.js +34 -17
- package/dist/config-store.js.map +1 -1
- package/dist/define-config.d.ts +11 -18
- package/dist/define-config.d.ts.map +1 -1
- package/dist/define-config.js +5 -7
- package/dist/define-config.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/materialize.js +1 -1
- package/dist/materialize.js.map +1 -1
- package/dist/registry-consumer.d.ts +1 -1
- package/dist/registry-consumer.js +1 -1
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +33 -2
- package/dist/registry.js.map +1 -1
- package/dist/types.d.ts +5 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/validate.d.ts +8 -8
- package/package.json +1 -1
- package/src/adk-tools.ts +289 -127
- package/src/adk.ts +7 -8
- package/src/agent-definitions/config.ts +15 -16
- package/src/config-store.ts +43 -19
- package/src/consumer.test.ts +7 -7
- package/src/define-config.ts +11 -20
- package/src/index.ts +1 -0
- package/src/materialize.ts +1 -1
- package/src/ref-naming.test.ts +164 -91
- package/src/registry-consumer.ts +1 -1
- package/src/registry.ts +40 -2
- package/src/types.ts +21 -6
package/src/registry.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { dirname, resolve } from "node:path";
|
|
8
|
+
import { AdkError } from "./adk-error.js";
|
|
8
9
|
import type { AgentEvent, BaseEvent, CallAgentToolCallEvent, CustomEventMap, EventCallback, EventType, ListAgentsResult, ListAgentsToolCallEvent } from "./events.js";
|
|
9
10
|
import { createEventBus } from "./events.js";
|
|
10
11
|
import type { Logger } from "./logger.js";
|
|
@@ -39,6 +40,33 @@ const DEFAULT_SUPPORTED_ACTIONS: AgentAction[] = [
|
|
|
39
40
|
"read_resources",
|
|
40
41
|
];
|
|
41
42
|
|
|
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
|
+
|
|
42
70
|
/**
|
|
43
71
|
* Estimate the token count for a tool schema when serialized to JSON.
|
|
44
72
|
* Uses a rough heuristic: ~4 characters per token (conservative estimate
|
|
@@ -760,10 +788,15 @@ export function createAgentRegistry(
|
|
|
760
788
|
})
|
|
761
789
|
.catch(() => {}); // don't let emit error mask tool error
|
|
762
790
|
|
|
791
|
+
const adkErr = adkErrorFields(err);
|
|
763
792
|
return {
|
|
764
793
|
success: false,
|
|
765
794
|
error: err instanceof Error ? err.message : String(err),
|
|
766
|
-
code: "TOOL_EXECUTION_ERROR",
|
|
795
|
+
code: adkErr?.code ?? "TOOL_EXECUTION_ERROR",
|
|
796
|
+
...(adkErr && {
|
|
797
|
+
hint: adkErr.hint,
|
|
798
|
+
details: adkErr.details,
|
|
799
|
+
}),
|
|
767
800
|
} as CallAgentErrorResponse;
|
|
768
801
|
}
|
|
769
802
|
|
|
@@ -784,11 +817,16 @@ export function createAgentRegistry(
|
|
|
784
817
|
} as CallAgentExecuteToolResponse;
|
|
785
818
|
} catch (outerErr) {
|
|
786
819
|
// Catch-all for unexpected errors (e.g., emit failures)
|
|
820
|
+
const adkErr = adkErrorFields(outerErr);
|
|
787
821
|
return {
|
|
788
822
|
success: false,
|
|
789
823
|
error:
|
|
790
824
|
outerErr instanceof Error ? outerErr.message : String(outerErr),
|
|
791
|
-
code: "TOOL_EXECUTION_ERROR",
|
|
825
|
+
code: adkErr?.code ?? "TOOL_EXECUTION_ERROR",
|
|
826
|
+
...(adkErr && {
|
|
827
|
+
hint: adkErr.hint,
|
|
828
|
+
details: adkErr.details,
|
|
829
|
+
}),
|
|
792
830
|
} as CallAgentErrorResponse;
|
|
793
831
|
}
|
|
794
832
|
}
|
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 { EventCallback, EventType } from "./events.js";
|
|
8
7
|
import type { AgentAction, CallerType } from "./call-agent-schema.js";
|
|
8
|
+
import type { EventCallback, EventType } from "./events.js";
|
|
9
9
|
|
|
10
10
|
/** Internal listener entry stored on agents/tools */
|
|
11
11
|
export interface ListenerEntry {
|
|
@@ -22,7 +22,15 @@ export interface ListenerEntry {
|
|
|
22
22
|
* JSON Schema definition for tool input parameters.
|
|
23
23
|
*/
|
|
24
24
|
export type JsonSchema = {
|
|
25
|
-
type:
|
|
25
|
+
type:
|
|
26
|
+
| "object"
|
|
27
|
+
| "array"
|
|
28
|
+
| "string"
|
|
29
|
+
| "number"
|
|
30
|
+
| "integer"
|
|
31
|
+
| "boolean"
|
|
32
|
+
| "null"
|
|
33
|
+
| string[];
|
|
26
34
|
properties?: Record<string, JsonSchema>;
|
|
27
35
|
items?: JsonSchema;
|
|
28
36
|
required?: string[];
|
|
@@ -293,7 +301,7 @@ export type SecurityScheme =
|
|
|
293
301
|
* directory-level overview (e.g., in list_agents responses).
|
|
294
302
|
*/
|
|
295
303
|
export interface SecuritySchemeSummary {
|
|
296
|
-
type: SecurityScheme[
|
|
304
|
+
type: SecurityScheme["type"];
|
|
297
305
|
[key: string]: unknown;
|
|
298
306
|
}
|
|
299
307
|
|
|
@@ -710,7 +718,7 @@ export interface AgentDefinition<TContext extends ToolContext = ToolContext> {
|
|
|
710
718
|
* - 'direct': registry hosts and serves this agent's tools (default)
|
|
711
719
|
* - 'redirect': registry catalogs this agent but clients connect to `upstream` directly
|
|
712
720
|
*/
|
|
713
|
-
mode?:
|
|
721
|
+
mode?: "direct" | "redirect";
|
|
714
722
|
|
|
715
723
|
/**
|
|
716
724
|
* Upstream URL for redirect-mode agents.
|
|
@@ -861,6 +869,8 @@ export interface CallAgentErrorResponse {
|
|
|
861
869
|
success: false;
|
|
862
870
|
error: string;
|
|
863
871
|
code?: string;
|
|
872
|
+
hint?: string;
|
|
873
|
+
details?: Record<string, unknown>;
|
|
864
874
|
}
|
|
865
875
|
|
|
866
876
|
/** Union of all response types */
|
|
@@ -942,5 +952,10 @@ export type ServerSource =
|
|
|
942
952
|
| string
|
|
943
953
|
| { command: string; args?: string[]; env?: Record<string, string> }
|
|
944
954
|
| { url: string; headers?: Record<string, string> }
|
|
945
|
-
| {
|
|
946
|
-
|
|
955
|
+
| {
|
|
956
|
+
spawn: string;
|
|
957
|
+
args?: string[];
|
|
958
|
+
env?: Record<string, string>;
|
|
959
|
+
port?: number;
|
|
960
|
+
endpoint?: string;
|
|
961
|
+
};
|