@byteplus-iga-pages/agent 0.0.0-stage → 1.0.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/LICENSE +20 -0
- package/README.md +84 -2
- package/dist/cjs/261.js +77 -0
- package/dist/cjs/341.js +43 -0
- package/dist/cjs/401.js +3632 -0
- package/dist/cjs/419.js +854 -0
- package/dist/cjs/504.js +760 -0
- package/dist/cjs/521.js +242 -0
- package/dist/cjs/594.js +79 -0
- package/dist/cjs/647.js +1367 -0
- package/dist/cjs/808.js +322 -0
- package/dist/cjs/82.js +10089 -0
- package/dist/cjs/893.js +17720 -0
- package/dist/cjs/893.js.LICENSE.txt +13 -0
- package/dist/cjs/951.js +59 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/runtime.js +79 -0
- package/dist/cjs/sandbox/host.js +125 -0
- package/dist/cjs/sandbox/index.js +286 -0
- package/dist/cjs/store/claude.js +209 -0
- package/dist/cjs/store/host.js +92 -0
- package/dist/cjs/store/index.js +43 -0
- package/dist/cjs/store/langgraph.js +581 -0
- package/dist/cjs/store/openai.js +118 -0
- package/dist/cjs/tools/claude.js +59 -0
- package/dist/cjs/tools/index.js +37 -0
- package/dist/cjs/tools/langchain.js +52 -0
- package/dist/cjs/tools/openai-agents.js +43 -0
- package/dist/cjs/tools/openai.js +43 -0
- package/dist/esm/128.js +10381 -0
- package/dist/esm/261.js +67 -0
- package/dist/esm/341.js +30 -0
- package/dist/esm/392.js +4453 -0
- package/dist/esm/417.js +704 -0
- package/dist/esm/521.js +230 -0
- package/dist/esm/594.js +67 -0
- package/dist/esm/613.js +19042 -0
- package/dist/esm/613.js.LICENSE.txt +13 -0
- package/dist/esm/951.js +44 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/runtime.js +39 -0
- package/dist/esm/sandbox/host.js +1 -0
- package/dist/esm/sandbox/index.js +183 -0
- package/dist/esm/store/claude.js +172 -0
- package/dist/esm/store/host.js +46 -0
- package/dist/esm/store/index.js +2 -0
- package/dist/esm/store/langgraph.js +542 -0
- package/dist/esm/store/openai.js +81 -0
- package/dist/esm/tools/claude.js +22 -0
- package/dist/esm/tools/index.js +1 -0
- package/dist/esm/tools/langchain.js +16 -0
- package/dist/esm/tools/openai-agents.js +6 -0
- package/dist/esm/tools/openai.js +6 -0
- package/dist/types/_internal/data-plane/control-plane-request.d.ts +12 -0
- package/dist/types/_internal/data-plane/control-plane.d.ts +3 -0
- package/dist/types/_internal/data-plane/credential-provider.d.ts +25 -0
- package/dist/types/_internal/data-plane/errors.d.ts +19 -0
- package/dist/types/_internal/data-plane/index.d.ts +11 -0
- package/dist/types/_internal/data-plane/supabase-client.d.ts +12 -0
- package/dist/types/_internal/data-plane/token-client.d.ts +23 -0
- package/dist/types/sandbox/api-client.d.ts +37 -0
- package/dist/types/sandbox/api-types.d.ts +81 -0
- package/dist/types/sandbox/binding-repository.d.ts +62 -0
- package/dist/types/sandbox/error.d.ts +22 -0
- package/dist/types/sandbox/expiry.d.ts +11 -0
- package/dist/types/sandbox/host.d.ts +6 -0
- package/dist/types/sandbox/iga-sandbox.d.ts +208 -0
- package/dist/types/sandbox/index.d.ts +8 -0
- package/dist/types/sandbox/public-surface.d.ts +19 -0
- package/dist/types/sandbox/runtime-sandbox.d.ts +32 -0
- package/dist/types/sandbox/types.d.ts +238 -0
- package/dist/types/store/append.d.ts +41 -0
- package/dist/types/store/claude-repository.d.ts +36 -0
- package/dist/types/store/claude.d.ts +3 -0
- package/dist/types/store/control-plane-request.d.ts +2 -0
- package/dist/types/store/credential-error.d.ts +2 -0
- package/dist/types/store/credential-provider.d.ts +29 -0
- package/dist/types/store/errors.d.ts +29 -0
- package/dist/types/store/factory.d.ts +31 -0
- package/dist/types/store/host.d.ts +5 -0
- package/dist/types/store/index.d.ts +6 -0
- package/dist/types/store/json.d.ts +7 -0
- package/dist/types/store/langgraph-repository.d.ts +98 -0
- package/dist/types/store/langgraph.d.ts +43 -0
- package/dist/types/store/openai.d.ts +12 -0
- package/dist/types/store/pagination.d.ts +27 -0
- package/dist/types/store/runtime-data-plane.d.ts +8 -0
- package/dist/types/store/runtime-provider.d.ts +1 -0
- package/dist/types/store/runtime-store.d.ts +20 -0
- package/dist/types/store/store.d.ts +240 -0
- package/dist/types/store/supabase-transport.d.ts +43 -0
- package/dist/types/store/token-client.d.ts +7 -0
- package/dist/types/tools/adapters.d.ts +5 -0
- package/dist/types/tools/claude.d.ts +4 -0
- package/dist/types/tools/index.d.ts +2 -0
- package/dist/types/tools/langchain.d.ts +16 -0
- package/dist/types/tools/model-output.d.ts +8 -0
- package/dist/types/tools/openai-agents.d.ts +4 -0
- package/dist/types/tools/openai.d.ts +5 -0
- package/dist/types/tools/registry.d.ts +16 -0
- package/dist/types/tools/result.d.ts +17 -0
- package/dist/types/tools/sandbox-result-mappers.d.ts +10 -0
- package/dist/types/tools/sandbox-tools.d.ts +17 -0
- package/dist/types/tools/types.d.ts +307 -0
- package/package.json +136 -4
package/dist/esm/521.js
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { toOpenAIModelMessages, isScreenshotResult } from "./594.js";
|
|
2
|
+
import { numberType, booleanType, enumType, arrayType, recordType, stringType, unknownType } from "./392.js";
|
|
3
|
+
function toClaudeAgentSdkTool(source) {
|
|
4
|
+
return {
|
|
5
|
+
...toClaudeMcpTool(source),
|
|
6
|
+
execute: source.definition.execute
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function toOpenAISdkTool(source) {
|
|
10
|
+
return {
|
|
11
|
+
type: "function",
|
|
12
|
+
function: {
|
|
13
|
+
name: source.definition.name,
|
|
14
|
+
description: source.definition.description,
|
|
15
|
+
parameters: source.definition.inputSchema
|
|
16
|
+
},
|
|
17
|
+
execute: source.definition.execute,
|
|
18
|
+
toModelMessages: toOpenAIModelMessages
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function toOpenAIAgentsTool(source) {
|
|
22
|
+
const execute = (input, options)=>source.definition.execute(stripNullishObject(input), options);
|
|
23
|
+
return {
|
|
24
|
+
type: "function",
|
|
25
|
+
name: source.definition.name,
|
|
26
|
+
description: source.definition.description,
|
|
27
|
+
strict: true,
|
|
28
|
+
parameters: toOpenAIStrictSchema(source.definition.inputSchema),
|
|
29
|
+
execute,
|
|
30
|
+
invoke: async (contextOrInput, input, details)=>{
|
|
31
|
+
const result = await execute(parseToolInput(void 0 === input ? contextOrInput : input), {
|
|
32
|
+
abortSignal: details?.signal
|
|
33
|
+
});
|
|
34
|
+
if (!isScreenshotResult(result)) return result;
|
|
35
|
+
const { base64Image, mimeType, base64ImageLength } = result.data;
|
|
36
|
+
return [
|
|
37
|
+
{
|
|
38
|
+
type: "text",
|
|
39
|
+
text: JSON.stringify({
|
|
40
|
+
status: "success",
|
|
41
|
+
data: {
|
|
42
|
+
mimeType,
|
|
43
|
+
base64ImageLength
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
type: "image",
|
|
49
|
+
image: `data:${mimeType};base64,${base64Image}`
|
|
50
|
+
}
|
|
51
|
+
];
|
|
52
|
+
},
|
|
53
|
+
needsApproval: async ()=>false,
|
|
54
|
+
isEnabled: async ()=>true
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function toClaudeMcpTool(source, options) {
|
|
58
|
+
const tool = {
|
|
59
|
+
name: source.definition.name,
|
|
60
|
+
description: source.definition.description,
|
|
61
|
+
inputSchema: toClaudeInputShape(source.definition.inputSchema),
|
|
62
|
+
async handler (input, extra) {
|
|
63
|
+
const signal = extra && "object" == typeof extra && "signal" in extra ? extra.signal : void 0;
|
|
64
|
+
const result = await source.definition.execute(input, {
|
|
65
|
+
abortSignal: signal instanceof AbortSignal ? signal : void 0
|
|
66
|
+
});
|
|
67
|
+
if ("error" === result.status) return {
|
|
68
|
+
content: [
|
|
69
|
+
{
|
|
70
|
+
type: "text",
|
|
71
|
+
text: stringify(result)
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
isError: true
|
|
75
|
+
};
|
|
76
|
+
if (isScreenshotResult(result)) {
|
|
77
|
+
const { base64Image, mimeType, base64ImageLength } = result.data;
|
|
78
|
+
return {
|
|
79
|
+
content: [
|
|
80
|
+
{
|
|
81
|
+
type: "text",
|
|
82
|
+
text: JSON.stringify({
|
|
83
|
+
status: "success",
|
|
84
|
+
data: {
|
|
85
|
+
mimeType,
|
|
86
|
+
base64ImageLength
|
|
87
|
+
}
|
|
88
|
+
})
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
type: "image",
|
|
92
|
+
data: base64Image,
|
|
93
|
+
mimeType
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
content: [
|
|
100
|
+
{
|
|
101
|
+
type: "text",
|
|
102
|
+
text: stringify(result)
|
|
103
|
+
}
|
|
104
|
+
]
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
if (options?.alwaysLoad ?? true) return {
|
|
109
|
+
...tool,
|
|
110
|
+
_meta: {
|
|
111
|
+
"anthropic/alwaysLoad": true
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
return tool;
|
|
115
|
+
}
|
|
116
|
+
function toOpenAIStrictSchema(schema) {
|
|
117
|
+
const required = new Set(schema.required ?? []);
|
|
118
|
+
return {
|
|
119
|
+
type: "object",
|
|
120
|
+
properties: Object.fromEntries(Object.entries(schema.properties).map(([name, property])=>[
|
|
121
|
+
name,
|
|
122
|
+
{
|
|
123
|
+
...required.has(name) ? toOpenAIPropertySchema(property) : {
|
|
124
|
+
anyOf: [
|
|
125
|
+
toOpenAIPropertySchema(property),
|
|
126
|
+
{
|
|
127
|
+
type: "null"
|
|
128
|
+
}
|
|
129
|
+
]
|
|
130
|
+
},
|
|
131
|
+
...propertyDescription(property)
|
|
132
|
+
}
|
|
133
|
+
])),
|
|
134
|
+
required: Object.keys(schema.properties),
|
|
135
|
+
additionalProperties: false
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function toOpenAIPropertySchema(property) {
|
|
139
|
+
const schema = property;
|
|
140
|
+
if (Array.isArray(schema.enum) && schema.enum.every((value)=>"string" == typeof value)) return {
|
|
141
|
+
type: "string",
|
|
142
|
+
enum: schema.enum
|
|
143
|
+
};
|
|
144
|
+
switch(schema.type){
|
|
145
|
+
case "number":
|
|
146
|
+
case "integer":
|
|
147
|
+
return {
|
|
148
|
+
type: "number",
|
|
149
|
+
..."number" == typeof schema.minimum ? {
|
|
150
|
+
minimum: schema.minimum
|
|
151
|
+
} : {}
|
|
152
|
+
};
|
|
153
|
+
case "boolean":
|
|
154
|
+
return {
|
|
155
|
+
type: "boolean"
|
|
156
|
+
};
|
|
157
|
+
case "object":
|
|
158
|
+
return {
|
|
159
|
+
type: "object",
|
|
160
|
+
additionalProperties: {}
|
|
161
|
+
};
|
|
162
|
+
case "array":
|
|
163
|
+
return {
|
|
164
|
+
type: "array",
|
|
165
|
+
items: {}
|
|
166
|
+
};
|
|
167
|
+
default:
|
|
168
|
+
return {
|
|
169
|
+
type: "string"
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
function toClaudeInputShape(schema) {
|
|
174
|
+
const required = new Set(schema.required ?? []);
|
|
175
|
+
return Object.fromEntries(Object.entries(schema.properties).map(([name, property])=>{
|
|
176
|
+
const base = toZodSchema(property);
|
|
177
|
+
const field = required.has(name) ? base : base.optional();
|
|
178
|
+
const { description } = propertyDescription(property);
|
|
179
|
+
return [
|
|
180
|
+
name,
|
|
181
|
+
void 0 === description ? field : field.describe(description)
|
|
182
|
+
];
|
|
183
|
+
}));
|
|
184
|
+
}
|
|
185
|
+
function propertyDescription(property) {
|
|
186
|
+
const { description } = property;
|
|
187
|
+
return "string" == typeof description ? {
|
|
188
|
+
description
|
|
189
|
+
} : {};
|
|
190
|
+
}
|
|
191
|
+
function toZodSchema(property) {
|
|
192
|
+
const schema = property;
|
|
193
|
+
if (Array.isArray(schema.enum) && schema.enum.every((value)=>"string" == typeof value)) return enumType(schema.enum);
|
|
194
|
+
switch(schema.type){
|
|
195
|
+
case "number":
|
|
196
|
+
{
|
|
197
|
+
const numberSchema = numberType();
|
|
198
|
+
return "number" == typeof schema.minimum ? numberSchema.min(schema.minimum) : numberSchema;
|
|
199
|
+
}
|
|
200
|
+
case "integer":
|
|
201
|
+
{
|
|
202
|
+
const numberSchema = numberType().int();
|
|
203
|
+
return "number" == typeof schema.minimum ? numberSchema.min(schema.minimum) : numberSchema;
|
|
204
|
+
}
|
|
205
|
+
case "boolean":
|
|
206
|
+
return booleanType();
|
|
207
|
+
case "array":
|
|
208
|
+
return arrayType(unknownType());
|
|
209
|
+
case "object":
|
|
210
|
+
return recordType(unknownType());
|
|
211
|
+
default:
|
|
212
|
+
return stringType();
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
function parseToolInput(input) {
|
|
216
|
+
if ("string" == typeof input) try {
|
|
217
|
+
return stripNullishObject(JSON.parse(input));
|
|
218
|
+
} catch {
|
|
219
|
+
return {};
|
|
220
|
+
}
|
|
221
|
+
return stripNullishObject(input);
|
|
222
|
+
}
|
|
223
|
+
function stripNullishObject(input) {
|
|
224
|
+
if (null === input || "object" != typeof input || Array.isArray(input)) return {};
|
|
225
|
+
return Object.fromEntries(Object.entries(input).filter(([, value])=>null != value));
|
|
226
|
+
}
|
|
227
|
+
function stringify(result) {
|
|
228
|
+
return JSON.stringify(result);
|
|
229
|
+
}
|
|
230
|
+
export { toClaudeAgentSdkTool, toOpenAIAgentsTool, toOpenAISdkTool };
|
package/dist/esm/594.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
function isScreenshotResult(result) {
|
|
2
|
+
if ("error" === result.status || !result.data || "object" != typeof result.data) return false;
|
|
3
|
+
const data = result.data;
|
|
4
|
+
return "string" == typeof data.base64Image && data.base64Image.length > 0 && "string" == typeof data.mimeType && /^image\/(png|jpeg|webp|gif)$/.test(data.mimeType) && "number" == typeof data.base64ImageLength;
|
|
5
|
+
}
|
|
6
|
+
function toImageUrlContent(result) {
|
|
7
|
+
if (!isScreenshotResult(result)) return [
|
|
8
|
+
{
|
|
9
|
+
type: "text",
|
|
10
|
+
text: JSON.stringify(result)
|
|
11
|
+
}
|
|
12
|
+
];
|
|
13
|
+
const { base64Image, mimeType, base64ImageLength } = result.data;
|
|
14
|
+
return [
|
|
15
|
+
{
|
|
16
|
+
type: "text",
|
|
17
|
+
text: JSON.stringify({
|
|
18
|
+
status: "success",
|
|
19
|
+
data: {
|
|
20
|
+
mimeType,
|
|
21
|
+
base64ImageLength
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
type: "image_url",
|
|
27
|
+
image_url: {
|
|
28
|
+
url: `data:${mimeType};base64,${base64Image}`
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
function toOpenAIModelMessages(result, toolCallId) {
|
|
34
|
+
if (!isScreenshotResult(result)) return [
|
|
35
|
+
{
|
|
36
|
+
role: "tool",
|
|
37
|
+
tool_call_id: toolCallId,
|
|
38
|
+
content: JSON.stringify(result)
|
|
39
|
+
}
|
|
40
|
+
];
|
|
41
|
+
const content = toImageUrlContent(result);
|
|
42
|
+
return [
|
|
43
|
+
{
|
|
44
|
+
role: "tool",
|
|
45
|
+
tool_call_id: toolCallId,
|
|
46
|
+
content: JSON.stringify({
|
|
47
|
+
status: "success",
|
|
48
|
+
data: {
|
|
49
|
+
mimeType: result.data.mimeType,
|
|
50
|
+
base64ImageLength: result.data.base64ImageLength
|
|
51
|
+
},
|
|
52
|
+
message: "Screenshot is attached in a following user image message."
|
|
53
|
+
})
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
role: "user",
|
|
57
|
+
content: [
|
|
58
|
+
{
|
|
59
|
+
type: "text",
|
|
60
|
+
text: `Screenshot from tool call ${toolCallId}.`
|
|
61
|
+
},
|
|
62
|
+
...content.filter((part)=>"image_url" === part.type)
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
];
|
|
66
|
+
}
|
|
67
|
+
export { isScreenshotResult, toImageUrlContent, toOpenAIModelMessages };
|