@superblocksteam/sdk-api 2.0.175-next.0 → 2.0.176
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/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/integrations/declarations.d.ts +0 -10
- package/dist/integrations/declarations.d.ts.map +1 -1
- package/dist/integrations/declarations.js +0 -9
- package/dist/integrations/declarations.js.map +1 -1
- package/dist/integrations/index.d.ts +1 -3
- package/dist/integrations/index.d.ts.map +1 -1
- package/dist/integrations/index.js +1 -2
- package/dist/integrations/index.js.map +1 -1
- package/dist/integrations/registry.d.ts +0 -1
- package/dist/integrations/registry.d.ts.map +1 -1
- package/dist/integrations/registry.js +0 -4
- package/dist/integrations/registry.js.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +0 -9
- package/src/integrations/declarations.ts +0 -16
- package/src/integrations/index.ts +0 -10
- package/src/integrations/registry.ts +0 -5
- package/dist/integrations/agentcore/client.d.ts +0 -21
- package/dist/integrations/agentcore/client.d.ts.map +0 -1
- package/dist/integrations/agentcore/client.js +0 -109
- package/dist/integrations/agentcore/client.js.map +0 -1
- package/dist/integrations/agentcore/client.test.d.ts +0 -2
- package/dist/integrations/agentcore/client.test.d.ts.map +0 -1
- package/dist/integrations/agentcore/client.test.js +0 -115
- package/dist/integrations/agentcore/client.test.js.map +0 -1
- package/dist/integrations/agentcore/index.d.ts +0 -3
- package/dist/integrations/agentcore/index.d.ts.map +0 -1
- package/dist/integrations/agentcore/index.js +0 -2
- package/dist/integrations/agentcore/index.js.map +0 -1
- package/dist/integrations/agentcore/types.d.ts +0 -43
- package/dist/integrations/agentcore/types.d.ts.map +0 -1
- package/dist/integrations/agentcore/types.js +0 -2
- package/dist/integrations/agentcore/types.js.map +0 -1
- package/src/integrations/agentcore/README.md +0 -49
- package/src/integrations/agentcore/client.test.ts +0 -166
- package/src/integrations/agentcore/client.ts +0 -168
- package/src/integrations/agentcore/docs.manifest.json +0 -5
- package/src/integrations/agentcore/index.ts +0 -8
- package/src/integrations/agentcore/types.ts +0 -56
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Amazon Bedrock AgentCore client.
|
|
3
|
-
*
|
|
4
|
-
* The step fields match the worker plugin. They are declared here because the
|
|
5
|
-
* published types package does not include the plugin yet.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { z } from "zod";
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
RestApiValidationError,
|
|
12
|
-
restApiValidationErrorFromZodError,
|
|
13
|
-
} from "../../errors.js";
|
|
14
|
-
import { IntegrationError } from "../../runtime/errors.js";
|
|
15
|
-
import type { QueryExecutor, TraceMetadata } from "../registry.js";
|
|
16
|
-
import type { IntegrationConfig, IntegrationClientImpl } from "../types.js";
|
|
17
|
-
import type {
|
|
18
|
-
AgentCoreClient,
|
|
19
|
-
AgentCoreInvokeAgentRuntimeOptions,
|
|
20
|
-
AgentCoreInvokeHarnessOptions,
|
|
21
|
-
AgentCoreInvokeHarnessResult,
|
|
22
|
-
} from "./types.js";
|
|
23
|
-
|
|
24
|
-
const HarnessResultSchema = z.object({
|
|
25
|
-
kind: z.literal("harness"),
|
|
26
|
-
text: z.string(),
|
|
27
|
-
toolCalls: z.array(
|
|
28
|
-
z.object({
|
|
29
|
-
name: z.string(),
|
|
30
|
-
toolUseId: z.string().optional(),
|
|
31
|
-
result: z.string(),
|
|
32
|
-
failed: z.boolean(),
|
|
33
|
-
}),
|
|
34
|
-
),
|
|
35
|
-
stopReason: z.string(),
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
const RuntimeResultSchema = z.object({
|
|
39
|
-
kind: z.literal("runtime"),
|
|
40
|
-
response: z.unknown(),
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
function payloadText(payload: unknown): string {
|
|
44
|
-
if (typeof payload === "string") {
|
|
45
|
-
return payload;
|
|
46
|
-
}
|
|
47
|
-
if (payload === undefined) {
|
|
48
|
-
return "";
|
|
49
|
-
}
|
|
50
|
-
try {
|
|
51
|
-
return JSON.stringify(payload) ?? "";
|
|
52
|
-
} catch (error) {
|
|
53
|
-
throw new RestApiValidationError(
|
|
54
|
-
`Payload cannot be sent as JSON: ${error instanceof Error ? error.message : String(error)}`,
|
|
55
|
-
{ data: payload, zodError: new z.ZodError([]) },
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export class AgentCoreClientImpl
|
|
61
|
-
implements AgentCoreClient, IntegrationClientImpl
|
|
62
|
-
{
|
|
63
|
-
readonly config: IntegrationConfig;
|
|
64
|
-
private readonly executeQuery: QueryExecutor;
|
|
65
|
-
|
|
66
|
-
constructor(config: IntegrationConfig, executeQuery: QueryExecutor) {
|
|
67
|
-
this.config = config;
|
|
68
|
-
this.executeQuery = executeQuery;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
get name(): string {
|
|
72
|
-
return this.config.name;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
get pluginId(): string {
|
|
76
|
-
return this.config.pluginId;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
async invokeHarness(
|
|
80
|
-
prompt: string,
|
|
81
|
-
options?: AgentCoreInvokeHarnessOptions,
|
|
82
|
-
): Promise<AgentCoreInvokeHarnessResult> {
|
|
83
|
-
if (prompt.trim() === "") {
|
|
84
|
-
throw new RestApiValidationError("Prompt is required.", {
|
|
85
|
-
data: prompt,
|
|
86
|
-
zodError: new z.ZodError([]),
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
const result = await this.run(
|
|
90
|
-
"invokeHarness",
|
|
91
|
-
{
|
|
92
|
-
prompt,
|
|
93
|
-
...(options?.sessionKey ? { sessionKey: options.sessionKey } : {}),
|
|
94
|
-
},
|
|
95
|
-
options?.label,
|
|
96
|
-
);
|
|
97
|
-
const parsed = HarnessResultSchema.safeParse(result);
|
|
98
|
-
if (!parsed.success) {
|
|
99
|
-
throw restApiValidationErrorFromZodError(
|
|
100
|
-
"AgentCore invokeHarness returned an unexpected result",
|
|
101
|
-
parsed.error,
|
|
102
|
-
result,
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
const { text, toolCalls, stopReason } = parsed.data;
|
|
106
|
-
return { text, toolCalls, stopReason };
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
async invokeAgentRuntime<T>(
|
|
110
|
-
payload: unknown,
|
|
111
|
-
schema: z.ZodType<T>,
|
|
112
|
-
options?: AgentCoreInvokeAgentRuntimeOptions,
|
|
113
|
-
): Promise<T> {
|
|
114
|
-
const body = payloadText(payload);
|
|
115
|
-
if (body.trim() === "") {
|
|
116
|
-
throw new RestApiValidationError("Payload is required.", {
|
|
117
|
-
data: payload,
|
|
118
|
-
zodError: new z.ZodError([]),
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
const result = await this.run(
|
|
122
|
-
"invokeAgentRuntime",
|
|
123
|
-
{
|
|
124
|
-
payload: body,
|
|
125
|
-
...(options?.contentType ? { contentType: options.contentType } : {}),
|
|
126
|
-
...(options?.accept ? { accept: options.accept } : {}),
|
|
127
|
-
...(options?.sessionKey ? { sessionKey: options.sessionKey } : {}),
|
|
128
|
-
},
|
|
129
|
-
options?.label,
|
|
130
|
-
);
|
|
131
|
-
const runtime = RuntimeResultSchema.safeParse(result);
|
|
132
|
-
if (!runtime.success) {
|
|
133
|
-
throw restApiValidationErrorFromZodError(
|
|
134
|
-
"AgentCore invokeAgentRuntime returned an unexpected result",
|
|
135
|
-
runtime.error,
|
|
136
|
-
result,
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
const parsed = schema.safeParse(runtime.data.response);
|
|
140
|
-
if (!parsed.success) {
|
|
141
|
-
throw restApiValidationErrorFromZodError(
|
|
142
|
-
"AgentCore runtime response failed validation",
|
|
143
|
-
parsed.error,
|
|
144
|
-
runtime.data.response,
|
|
145
|
-
);
|
|
146
|
-
}
|
|
147
|
-
return parsed.data;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
private async run(
|
|
151
|
-
operation: string,
|
|
152
|
-
request: Record<string, unknown>,
|
|
153
|
-
label: string | undefined,
|
|
154
|
-
): Promise<unknown> {
|
|
155
|
-
try {
|
|
156
|
-
return await this.executeQuery(request, undefined, trace(label));
|
|
157
|
-
} catch (error) {
|
|
158
|
-
if (error instanceof IntegrationError) {
|
|
159
|
-
throw error;
|
|
160
|
-
}
|
|
161
|
-
throw new IntegrationError(this.config.name, operation, error);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function trace(label: string | undefined): TraceMetadata | undefined {
|
|
167
|
-
return label ? { label } : undefined;
|
|
168
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import type { z } from "zod";
|
|
2
|
-
|
|
3
|
-
import type { BaseIntegrationClient } from "../../types.js";
|
|
4
|
-
|
|
5
|
-
/** One tool the harness ran while answering. */
|
|
6
|
-
export interface AgentCoreToolCall {
|
|
7
|
-
name: string;
|
|
8
|
-
toolUseId?: string;
|
|
9
|
-
result: string;
|
|
10
|
-
failed: boolean;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/** What a harness call returns after the stream finishes. */
|
|
14
|
-
export interface AgentCoreInvokeHarnessResult {
|
|
15
|
-
text: string;
|
|
16
|
-
toolCalls: AgentCoreToolCall[];
|
|
17
|
-
stopReason: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface AgentCoreInvokeHarnessOptions {
|
|
21
|
-
/** Stable key for this conversation. Omitted keys get a new session on each call. */
|
|
22
|
-
sessionKey?: string;
|
|
23
|
-
/** Shown in the Trace View. */
|
|
24
|
-
label?: string;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface AgentCoreInvokeAgentRuntimeOptions {
|
|
28
|
-
sessionKey?: string;
|
|
29
|
-
/** Defaults to application/json on the worker when omitted. */
|
|
30
|
-
contentType?: string;
|
|
31
|
-
/** Response content type to request. Defaults to application/json on the worker. */
|
|
32
|
-
accept?: string;
|
|
33
|
-
label?: string;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface AgentCoreClient extends BaseIntegrationClient {
|
|
37
|
-
/**
|
|
38
|
-
* Call a harness agent with a prompt.
|
|
39
|
-
* The integration's agent ARN must be a harness ARN.
|
|
40
|
-
*/
|
|
41
|
-
invokeHarness(
|
|
42
|
-
prompt: string,
|
|
43
|
-
options?: AgentCoreInvokeHarnessOptions,
|
|
44
|
-
): Promise<AgentCoreInvokeHarnessResult>;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Call a runtime agent with a payload and validate the response.
|
|
48
|
-
* Objects are sent as JSON. A string is sent unchanged.
|
|
49
|
-
* The integration's agent ARN must be a runtime ARN.
|
|
50
|
-
*/
|
|
51
|
-
invokeAgentRuntime<T>(
|
|
52
|
-
payload: unknown,
|
|
53
|
-
schema: z.ZodType<T>,
|
|
54
|
-
options?: AgentCoreInvokeAgentRuntimeOptions,
|
|
55
|
-
): Promise<T>;
|
|
56
|
-
}
|