@standardagents/builder 0.9.9 → 0.9.11

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.
@@ -2262,6 +2262,54 @@ var messageId_delete_default = defineController(async ({ req, params, env }) =>
2262
2262
  }
2263
2263
  });
2264
2264
 
2265
+ // src/api/threads/[id]/messages/[messageId].patch.ts
2266
+ var messageId_patch_default = defineController(async ({ req, params, env }) => {
2267
+ const threadId = params.id;
2268
+ const messageId = params.messageId;
2269
+ if (!threadId) {
2270
+ return Response.json({ error: "Thread ID required" }, { status: 400 });
2271
+ }
2272
+ if (!messageId) {
2273
+ return Response.json({ error: "Message ID required" }, { status: 400 });
2274
+ }
2275
+ let body;
2276
+ try {
2277
+ body = await req.json();
2278
+ } catch {
2279
+ return Response.json({ error: "Invalid JSON body" }, { status: 400 });
2280
+ }
2281
+ if (typeof body.content !== "string") {
2282
+ return Response.json({ error: "Content is required and must be a string" }, { status: 400 });
2283
+ }
2284
+ try {
2285
+ const agentBuilderId = env.AGENT_BUILDER.idFromName("singleton");
2286
+ const agentBuilder = env.AGENT_BUILDER.get(agentBuilderId);
2287
+ const thread = await agentBuilder.getThread(threadId);
2288
+ if (!thread) {
2289
+ return Response.json(
2290
+ { error: `Thread not found: ${threadId}` },
2291
+ { status: 404 }
2292
+ );
2293
+ }
2294
+ const durableId = env.AGENT_BUILDER_THREAD.idFromName(threadId);
2295
+ const stub = env.AGENT_BUILDER_THREAD.get(durableId);
2296
+ const result = await stub.updateMessageContent(messageId, body.content);
2297
+ if (!result.success) {
2298
+ return Response.json(
2299
+ { error: result.error || "Failed to update message" },
2300
+ { status: 404 }
2301
+ );
2302
+ }
2303
+ return Response.json({ success: true });
2304
+ } catch (error) {
2305
+ console.error(`Error updating message ${messageId} in thread ${threadId}:`, error);
2306
+ return Response.json(
2307
+ { error: error.message || "Failed to update message" },
2308
+ { status: 500 }
2309
+ );
2310
+ }
2311
+ });
2312
+
2265
2313
  // src/built-in-routes.ts
2266
2314
  var routeHandlers = {
2267
2315
  "POST:/": index_post_default,
@@ -2303,7 +2351,8 @@ var routeHandlers = {
2303
2351
  "POST:/threads/:id/stop": stop_post_default,
2304
2352
  "GET:/threads/:id/stream": stream_default,
2305
2353
  "GET:/threads/:id/logs/:logId": logId_get_default,
2306
- "DELETE:/threads/:id/messages/:messageId": messageId_delete_default
2354
+ "DELETE:/threads/:id/messages/:messageId": messageId_delete_default,
2355
+ "PATCH:/threads/:id/messages/:messageId": messageId_patch_default
2307
2356
  };
2308
2357
  function registerBuiltInRoutes(router, runtimeData) {
2309
2358
  for (const [key, handler] of Object.entries(routeHandlers)) {