@standardagents/builder 0.10.0 → 0.10.1-dev.114898
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.txt +48 -0
- package/dist/built-in-routes.js +75 -25
- package/dist/built-in-routes.js.map +1 -1
- package/dist/client/assets/index.css +1 -1
- package/dist/client/index.js +11 -11
- package/dist/image-processing.d.ts +7 -4
- package/dist/image-processing.js +103 -127
- package/dist/image-processing.js.map +1 -1
- package/dist/index.d.ts +32 -0
- package/dist/index.js +280 -10
- package/dist/index.js.map +1 -1
- package/dist/plugin.js +41 -6
- package/dist/plugin.js.map +1 -1
- package/package.json +18 -18
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
PROPRIETARY SOFTWARE LICENSE
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2025 FormKit Inc. All Rights Reserved.
|
|
4
|
+
|
|
5
|
+
UNLICENSED - DO NOT USE
|
|
6
|
+
|
|
7
|
+
This software and associated documentation files (the "Software") are the sole
|
|
8
|
+
and exclusive property of FormKit Inc. ("FormKit").
|
|
9
|
+
|
|
10
|
+
USE RESTRICTIONS
|
|
11
|
+
|
|
12
|
+
The Software is UNLICENSED and proprietary. NO PERMISSION is granted to use,
|
|
13
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
14
|
+
the Software, or to permit persons to whom the Software is furnished to do so,
|
|
15
|
+
under any circumstances, without prior written authorization from FormKit Inc.
|
|
16
|
+
|
|
17
|
+
UNAUTHORIZED USE PROHIBITED
|
|
18
|
+
|
|
19
|
+
Any use of this Software without a valid, written license agreement signed by
|
|
20
|
+
authorized officers of FormKit Inc. is strictly prohibited and constitutes
|
|
21
|
+
unauthorized use and infringement of FormKit's intellectual property rights.
|
|
22
|
+
|
|
23
|
+
LICENSING INQUIRIES
|
|
24
|
+
|
|
25
|
+
Organizations interested in licensing this Software should contact:
|
|
26
|
+
enterprise@formkit.com
|
|
27
|
+
|
|
28
|
+
A written license agreement must be executed before any use of this Software
|
|
29
|
+
is authorized.
|
|
30
|
+
|
|
31
|
+
NO WARRANTY
|
|
32
|
+
|
|
33
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
34
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
35
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
36
|
+
FORMKIT INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|
37
|
+
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
38
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
39
|
+
|
|
40
|
+
GOVERNING LAW
|
|
41
|
+
|
|
42
|
+
This license shall be governed by and construed in accordance with the laws
|
|
43
|
+
of the jurisdiction in which FormKit Inc. is incorporated, without regard to
|
|
44
|
+
its conflict of law provisions.
|
|
45
|
+
|
|
46
|
+
FormKit Inc.
|
|
47
|
+
https://formkit.com
|
|
48
|
+
enterprise@formkit.com
|
package/dist/built-in-routes.js
CHANGED
|
@@ -848,12 +848,23 @@ var index_post_default3 = defineController(async ({ req, env }) => {
|
|
|
848
848
|
});
|
|
849
849
|
|
|
850
850
|
// src/api/threads/index.ts
|
|
851
|
+
function resolveIconUrl(icon, origin) {
|
|
852
|
+
if (!icon) return void 0;
|
|
853
|
+
if (icon.startsWith("http://") || icon.startsWith("https://")) {
|
|
854
|
+
return icon;
|
|
855
|
+
}
|
|
856
|
+
if (icon.startsWith("/")) {
|
|
857
|
+
return `${origin}${icon}`;
|
|
858
|
+
}
|
|
859
|
+
return icon;
|
|
860
|
+
}
|
|
851
861
|
var threads_default = defineController(async ({ req, env }) => {
|
|
852
862
|
if (req.method !== "GET") {
|
|
853
863
|
return new Response("Method Not Allowed", { status: 405 });
|
|
854
864
|
}
|
|
855
865
|
try {
|
|
856
866
|
const url = new URL(req.url);
|
|
867
|
+
const origin = url.origin;
|
|
857
868
|
const limit = parseInt(url.searchParams.get("limit") || "50", 10);
|
|
858
869
|
const offset = parseInt(url.searchParams.get("offset") || "0", 10);
|
|
859
870
|
const agentName = url.searchParams.get("agent_id");
|
|
@@ -872,11 +883,14 @@ var threads_default = defineController(async ({ req, env }) => {
|
|
|
872
883
|
try {
|
|
873
884
|
const agentDef = await agentBuilder.loadAgent(thread.agent_name);
|
|
874
885
|
agentDetails = {
|
|
875
|
-
|
|
876
|
-
|
|
886
|
+
name: thread.agent_name,
|
|
887
|
+
title: agentDef.title || thread.agent_name,
|
|
888
|
+
type: agentDef.type || "ai_human",
|
|
889
|
+
description: agentDef.description,
|
|
890
|
+
icon: resolveIconUrl(agentDef.icon, origin)
|
|
877
891
|
};
|
|
878
892
|
} catch {
|
|
879
|
-
agentDetails = { title: thread.agent_name, type: "unknown" };
|
|
893
|
+
agentDetails = { name: thread.agent_name, title: thread.agent_name, type: "unknown" };
|
|
880
894
|
}
|
|
881
895
|
return {
|
|
882
896
|
id: thread.id,
|
|
@@ -1447,6 +1461,16 @@ var id_patch_default = defineController(async ({ req, env, params }) => {
|
|
|
1447
1461
|
});
|
|
1448
1462
|
|
|
1449
1463
|
// src/api/threads/[id].ts
|
|
1464
|
+
function resolveIconUrl2(icon, origin) {
|
|
1465
|
+
if (!icon) return void 0;
|
|
1466
|
+
if (icon.startsWith("http://") || icon.startsWith("https://")) {
|
|
1467
|
+
return icon;
|
|
1468
|
+
}
|
|
1469
|
+
if (icon.startsWith("/")) {
|
|
1470
|
+
return `${origin}${icon}`;
|
|
1471
|
+
}
|
|
1472
|
+
return icon;
|
|
1473
|
+
}
|
|
1450
1474
|
var id_default = defineController(async ({ req, params, env }) => {
|
|
1451
1475
|
const threadId = params.id;
|
|
1452
1476
|
if (!threadId) {
|
|
@@ -1462,6 +1486,10 @@ var id_default = defineController(async ({ req, params, env }) => {
|
|
|
1462
1486
|
{ status: 404 }
|
|
1463
1487
|
);
|
|
1464
1488
|
}
|
|
1489
|
+
if (doData.agent?.icon) {
|
|
1490
|
+
const origin = new URL(req.url).origin;
|
|
1491
|
+
doData.agent.icon = resolveIconUrl2(doData.agent.icon, origin);
|
|
1492
|
+
}
|
|
1465
1493
|
return Response.json(doData);
|
|
1466
1494
|
} catch (error) {
|
|
1467
1495
|
console.error(`Error fetching thread ${threadId}:`, error);
|
|
@@ -2077,15 +2105,19 @@ var logs_get_default = defineController(async ({ req, params, env }) => {
|
|
|
2077
2105
|
}
|
|
2078
2106
|
});
|
|
2079
2107
|
|
|
2080
|
-
// src/api/threads/[id]/
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2108
|
+
// src/api/threads/[id]/messages.post.ts
|
|
2109
|
+
function needsProcessing(base64Data, mimeType) {
|
|
2110
|
+
const binarySize = Math.ceil(base64Data.length * 3 / 4);
|
|
2111
|
+
const MAX_SIZE = 2 * 1024 * 1024;
|
|
2112
|
+
if (binarySize > MAX_SIZE) {
|
|
2113
|
+
return true;
|
|
2114
|
+
}
|
|
2115
|
+
if (mimeType !== "image/jpeg" && mimeType !== "image/png") {
|
|
2116
|
+
return true;
|
|
2085
2117
|
}
|
|
2086
|
-
return
|
|
2118
|
+
return false;
|
|
2087
2119
|
}
|
|
2088
|
-
var
|
|
2120
|
+
var messages_post_default = defineController(async ({ req, params, env }) => {
|
|
2089
2121
|
const threadId = params.id;
|
|
2090
2122
|
if (!threadId) {
|
|
2091
2123
|
return Response.json({ error: "Thread ID required" }, { status: 400 });
|
|
@@ -2122,18 +2154,22 @@ var message_post_default = defineController(async ({ req, params, env }) => {
|
|
|
2122
2154
|
let mimeType = attachment.mimeType;
|
|
2123
2155
|
let width = attachment.width;
|
|
2124
2156
|
let height = attachment.height;
|
|
2125
|
-
|
|
2126
|
-
if (mimeType.startsWith("image/") && imgProc.needsProcessing(fileData, mimeType)) {
|
|
2157
|
+
if (mimeType.startsWith("image/") && needsProcessing(fileData, mimeType)) {
|
|
2127
2158
|
try {
|
|
2128
|
-
const
|
|
2129
|
-
const processed = await
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2159
|
+
const originalSize = Math.ceil(fileData.length * 3 / 4);
|
|
2160
|
+
const processed = await stub.processImage(fileData, mimeType);
|
|
2161
|
+
if (processed.success && processed.data) {
|
|
2162
|
+
fileData = processed.data;
|
|
2163
|
+
mimeType = processed.mimeType;
|
|
2164
|
+
width = processed.width;
|
|
2165
|
+
height = processed.height;
|
|
2166
|
+
const newSize = Math.ceil(fileData.length * 3 / 4);
|
|
2167
|
+
console.log(
|
|
2168
|
+
`[image-processing] Processed ${attachment.name}: ${(originalSize / 1024 / 1024).toFixed(2)}MB \u2192 ${(newSize / 1024 / 1024).toFixed(2)}MB, ${processed.width}x${processed.height}, ${processed.mimeType}`
|
|
2169
|
+
);
|
|
2170
|
+
} else {
|
|
2171
|
+
console.error(`[image-processing] Failed to process ${attachment.name}:`, processed.error);
|
|
2172
|
+
}
|
|
2137
2173
|
} catch (err) {
|
|
2138
2174
|
console.error(`[image-processing] Failed to process ${attachment.name}:`, err);
|
|
2139
2175
|
}
|
|
@@ -2315,6 +2351,20 @@ var stream_default = defineController(async ({ req, params, env }) => {
|
|
|
2315
2351
|
});
|
|
2316
2352
|
|
|
2317
2353
|
// src/api/threads/[id]/fs/[...path].ts
|
|
2354
|
+
function toAttachmentRef(file) {
|
|
2355
|
+
const metadata = file.metadata;
|
|
2356
|
+
return {
|
|
2357
|
+
id: file.path,
|
|
2358
|
+
// Use path as unique ID
|
|
2359
|
+
type: "file",
|
|
2360
|
+
path: file.path,
|
|
2361
|
+
name: file.name,
|
|
2362
|
+
mimeType: file.mimeType,
|
|
2363
|
+
size: file.size,
|
|
2364
|
+
...metadata?.width && { width: metadata.width },
|
|
2365
|
+
...metadata?.height && { height: metadata.height }
|
|
2366
|
+
};
|
|
2367
|
+
}
|
|
2318
2368
|
var path_default = defineController(async ({ req, params, env }) => {
|
|
2319
2369
|
console.log("[fs] params received:", JSON.stringify(params));
|
|
2320
2370
|
const threadId = params.id;
|
|
@@ -2436,7 +2486,7 @@ async function handlePut(stub, path, req) {
|
|
|
2436
2486
|
if (!result2.success) {
|
|
2437
2487
|
return Response.json({ error: result2.error }, { status: 400 });
|
|
2438
2488
|
}
|
|
2439
|
-
return Response.json(
|
|
2489
|
+
return Response.json(toAttachmentRef(result2.file), { status: 201 });
|
|
2440
2490
|
}
|
|
2441
2491
|
if (body.data) {
|
|
2442
2492
|
const result2 = await stub.writeFile(path, body.data, body.mimeType || "application/octet-stream", {
|
|
@@ -2446,7 +2496,7 @@ async function handlePut(stub, path, req) {
|
|
|
2446
2496
|
if (!result2.success) {
|
|
2447
2497
|
return Response.json({ error: result2.error }, { status: 400 });
|
|
2448
2498
|
}
|
|
2449
|
-
return Response.json(
|
|
2499
|
+
return Response.json(toAttachmentRef(result2.file), { status: 201 });
|
|
2450
2500
|
}
|
|
2451
2501
|
return Response.json({ error: "Invalid request body" }, { status: 400 });
|
|
2452
2502
|
}
|
|
@@ -2462,7 +2512,7 @@ async function handlePut(stub, path, req) {
|
|
|
2462
2512
|
if (!result.success) {
|
|
2463
2513
|
return Response.json({ error: result.error }, { status: 400 });
|
|
2464
2514
|
}
|
|
2465
|
-
return Response.json(
|
|
2515
|
+
return Response.json(toAttachmentRef(result.file), { status: 201 });
|
|
2466
2516
|
}
|
|
2467
2517
|
async function handleDelete(stub, path) {
|
|
2468
2518
|
const statResult = await stub.statFile(path);
|
|
@@ -2646,7 +2696,7 @@ var routeHandlers = {
|
|
|
2646
2696
|
"GET:/threads/:id/cost": cost_get_default,
|
|
2647
2697
|
"GET:/threads/:id/fs": fs_default,
|
|
2648
2698
|
"GET:/threads/:id/logs": logs_get_default,
|
|
2649
|
-
"POST:/threads/:id/
|
|
2699
|
+
"POST:/threads/:id/messages": messages_post_default,
|
|
2650
2700
|
"GET:/threads/:id/messages": messages_get_default,
|
|
2651
2701
|
"POST:/threads/:id/rpc": rpc_post_default,
|
|
2652
2702
|
"POST:/threads/:id/stop": stop_post_default,
|