@standardagents/builder 0.10.1-dev.b8746e9 → 0.10.1-next.bbd142a

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.
@@ -848,23 +848,12 @@ 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
- }
861
851
  var threads_default = defineController(async ({ req, env }) => {
862
852
  if (req.method !== "GET") {
863
853
  return new Response("Method Not Allowed", { status: 405 });
864
854
  }
865
855
  try {
866
856
  const url = new URL(req.url);
867
- const origin = url.origin;
868
857
  const limit = parseInt(url.searchParams.get("limit") || "50", 10);
869
858
  const offset = parseInt(url.searchParams.get("offset") || "0", 10);
870
859
  const agentName = url.searchParams.get("agent_id");
@@ -883,14 +872,11 @@ var threads_default = defineController(async ({ req, env }) => {
883
872
  try {
884
873
  const agentDef = await agentBuilder.loadAgent(thread.agent_name);
885
874
  agentDetails = {
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)
875
+ title: agentDef.title,
876
+ type: agentDef.type || "ai_human"
891
877
  };
892
878
  } catch {
893
- agentDetails = { name: thread.agent_name, title: thread.agent_name, type: "unknown" };
879
+ agentDetails = { title: thread.agent_name, type: "unknown" };
894
880
  }
895
881
  return {
896
882
  id: thread.id,
@@ -1461,16 +1447,6 @@ var id_patch_default = defineController(async ({ req, env, params }) => {
1461
1447
  });
1462
1448
 
1463
1449
  // 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
- }
1474
1450
  var id_default = defineController(async ({ req, params, env }) => {
1475
1451
  const threadId = params.id;
1476
1452
  if (!threadId) {
@@ -1486,10 +1462,6 @@ var id_default = defineController(async ({ req, params, env }) => {
1486
1462
  { status: 404 }
1487
1463
  );
1488
1464
  }
1489
- if (doData.agent?.icon) {
1490
- const origin = new URL(req.url).origin;
1491
- doData.agent.icon = resolveIconUrl2(doData.agent.icon, origin);
1492
- }
1493
1465
  return Response.json(doData);
1494
1466
  } catch (error) {
1495
1467
  console.error(`Error fetching thread ${threadId}:`, error);
@@ -2105,7 +2077,7 @@ var logs_get_default = defineController(async ({ req, params, env }) => {
2105
2077
  }
2106
2078
  });
2107
2079
 
2108
- // src/api/threads/[id]/messages.post.ts
2080
+ // src/api/threads/[id]/message.post.ts
2109
2081
  function needsProcessing(base64Data, mimeType) {
2110
2082
  const binarySize = Math.ceil(base64Data.length * 3 / 4);
2111
2083
  const MAX_SIZE = 2 * 1024 * 1024;
@@ -2117,7 +2089,7 @@ function needsProcessing(base64Data, mimeType) {
2117
2089
  }
2118
2090
  return false;
2119
2091
  }
2120
- var messages_post_default = defineController(async ({ req, params, env }) => {
2092
+ var message_post_default = defineController(async ({ req, params, env }) => {
2121
2093
  const threadId = params.id;
2122
2094
  if (!threadId) {
2123
2095
  return Response.json({ error: "Thread ID required" }, { status: 400 });
@@ -2351,20 +2323,6 @@ var stream_default = defineController(async ({ req, params, env }) => {
2351
2323
  });
2352
2324
 
2353
2325
  // 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
- }
2368
2326
  var path_default = defineController(async ({ req, params, env }) => {
2369
2327
  console.log("[fs] params received:", JSON.stringify(params));
2370
2328
  const threadId = params.id;
@@ -2486,7 +2444,7 @@ async function handlePut(stub, path, req) {
2486
2444
  if (!result2.success) {
2487
2445
  return Response.json({ error: result2.error }, { status: 400 });
2488
2446
  }
2489
- return Response.json(toAttachmentRef(result2.file), { status: 201 });
2447
+ return Response.json({ file: result2.file }, { status: 201 });
2490
2448
  }
2491
2449
  if (body.data) {
2492
2450
  const result2 = await stub.writeFile(path, body.data, body.mimeType || "application/octet-stream", {
@@ -2496,7 +2454,7 @@ async function handlePut(stub, path, req) {
2496
2454
  if (!result2.success) {
2497
2455
  return Response.json({ error: result2.error }, { status: 400 });
2498
2456
  }
2499
- return Response.json(toAttachmentRef(result2.file), { status: 201 });
2457
+ return Response.json({ file: result2.file }, { status: 201 });
2500
2458
  }
2501
2459
  return Response.json({ error: "Invalid request body" }, { status: 400 });
2502
2460
  }
@@ -2512,7 +2470,7 @@ async function handlePut(stub, path, req) {
2512
2470
  if (!result.success) {
2513
2471
  return Response.json({ error: result.error }, { status: 400 });
2514
2472
  }
2515
- return Response.json(toAttachmentRef(result.file), { status: 201 });
2473
+ return Response.json({ file: result.file }, { status: 201 });
2516
2474
  }
2517
2475
  async function handleDelete(stub, path) {
2518
2476
  const statResult = await stub.statFile(path);
@@ -2696,7 +2654,7 @@ var routeHandlers = {
2696
2654
  "GET:/threads/:id/cost": cost_get_default,
2697
2655
  "GET:/threads/:id/fs": fs_default,
2698
2656
  "GET:/threads/:id/logs": logs_get_default,
2699
- "POST:/threads/:id/messages": messages_post_default,
2657
+ "POST:/threads/:id/message": message_post_default,
2700
2658
  "GET:/threads/:id/messages": messages_get_default,
2701
2659
  "POST:/threads/:id/rpc": rpc_post_default,
2702
2660
  "POST:/threads/:id/stop": stop_post_default,