@standardagents/builder 0.11.0-next.730b472 → 0.11.0-next.80cee2e

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.
@@ -5003,14 +5003,14 @@ ${msg.content}` : `${imageDescriptions}${nonImageList}`;
5003
5003
  ${columns.join(", ")}
5004
5004
  FROM messages
5005
5005
  WHERE parent_id IS NULL
5006
- ORDER BY created_at ASC, rowid ASC
5006
+ ORDER BY created_at ASC
5007
5007
  `;
5008
5008
  const cursor = await storage.sql.exec(query);
5009
5009
  rows = cursor.toArray();
5010
5010
  }
5011
5011
  if (state.extraMessages && state.extraMessages.length > 0) {
5012
5012
  rows.push(...state.extraMessages);
5013
- rows.sort((a, b) => a.created_at - b.created_at || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
5013
+ rows.sort((a, b) => a.created_at - b.created_at);
5014
5014
  }
5015
5015
  const messages = rows.map((row) => ({
5016
5016
  id: row.id,
@@ -5804,10 +5804,24 @@ var index_post_default = defineController(() => {
5804
5804
  });
5805
5805
 
5806
5806
  // src/api/agents.get.ts
5807
- var agents_get_default = defineController(async ({ agents, agentNames }) => {
5807
+ var agents_get_default = defineController(async ({ agents, agentNames, prompts, promptNames }) => {
5808
5808
  if (!agents || !agentNames) {
5809
5809
  return Response.json({ agents: [] });
5810
5810
  }
5811
+ const promptMap = {};
5812
+ if (prompts && promptNames) {
5813
+ await Promise.all(
5814
+ promptNames.map(async (name) => {
5815
+ try {
5816
+ const loader = prompts[name];
5817
+ if (loader) {
5818
+ promptMap[name] = await loader();
5819
+ }
5820
+ } catch (error) {
5821
+ }
5822
+ })
5823
+ );
5824
+ }
5811
5825
  const agentList = await Promise.all(
5812
5826
  agentNames.map(async (name) => {
5813
5827
  try {
@@ -5816,19 +5830,38 @@ var agents_get_default = defineController(async ({ agents, agentNames }) => {
5816
5830
  return null;
5817
5831
  }
5818
5832
  const definition = await loader();
5833
+ const sideAPrompt = promptMap[definition.sideA?.prompt];
5834
+ const sideBPrompt = definition.sideB ? promptMap[definition.sideB?.prompt] : null;
5819
5835
  return {
5820
5836
  id: definition.name,
5821
5837
  name: definition.name,
5822
- title: definition.title || definition.name,
5838
+ title: definition.title,
5823
5839
  type: definition.type || "ai_human",
5824
- // Use sideA.prompt as the default prompt (new structure)
5825
- default_prompt: definition.sideA?.prompt || "",
5826
- // Model is now specified in the prompt definition, not the agent
5827
- default_model: "",
5828
- // Tools are now specified in the prompt definition, not the agent
5829
- tools: [],
5830
- side_a_agent_prompt: definition.sideA?.prompt || null,
5840
+ // Side A configuration
5841
+ side_a_label: definition.sideA?.label || null,
5842
+ side_a_agent_prompt: definition.sideA?.prompt,
5843
+ side_a_agent_prompt_name: sideAPrompt?.name || definition.sideA?.prompt,
5844
+ side_a_stop_on_response: definition.sideA?.stopOnResponse !== void 0 ? definition.sideA.stopOnResponse : true,
5845
+ side_a_stop_tool: definition.sideA?.stopTool || null,
5846
+ side_a_stop_tool_response_property: definition.sideA?.stopToolResponseProperty || null,
5847
+ side_a_max_steps: definition.sideA?.maxSteps || null,
5848
+ side_a_end_session_tool: definition.sideA?.endSessionTool || null,
5849
+ side_a_manual_stop_condition: definition.sideA?.manualStopCondition || false,
5850
+ // Side B configuration (if dual_ai)
5851
+ side_b_label: definition.sideB?.label || null,
5831
5852
  side_b_agent_prompt: definition.sideB?.prompt || null,
5853
+ side_b_agent_prompt_name: sideBPrompt?.name || definition.sideB?.prompt || null,
5854
+ side_b_stop_on_response: definition.sideB?.stopOnResponse !== void 0 ? definition.sideB.stopOnResponse : true,
5855
+ side_b_stop_tool: definition.sideB?.stopTool || null,
5856
+ side_b_stop_tool_response_property: definition.sideB?.stopToolResponseProperty || null,
5857
+ side_b_max_steps: definition.sideB?.maxSteps || null,
5858
+ side_b_end_session_tool: definition.sideB?.endSessionTool || null,
5859
+ side_b_manual_stop_condition: definition.sideB?.manualStopCondition || false,
5860
+ // Session configuration
5861
+ max_session_turns: definition.maxSessionTurns || null,
5862
+ // Tool exposure
5863
+ expose_as_tool: definition.exposeAsTool || false,
5864
+ tool_description: definition.toolDescription || null,
5832
5865
  created_at: Math.floor(Date.now() / 1e3)
5833
5866
  };
5834
5867
  } catch (error) {
@@ -6025,12 +6058,6 @@ function base64ToBuffer(base64) {
6025
6058
  }
6026
6059
 
6027
6060
  // src/middleware/auth.ts
6028
- var CORS_HEADERS = {
6029
- "Access-Control-Allow-Origin": "*",
6030
- "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
6031
- "Access-Control-Allow-Headers": "Content-Type, Authorization, X-Requested-With",
6032
- "Access-Control-Max-Age": "86400"
6033
- };
6034
6061
  function extractBearerToken(request) {
6035
6062
  const authHeader = request.headers.get("Authorization");
6036
6063
  if (authHeader && authHeader.startsWith("Bearer ")) {
@@ -6119,7 +6146,7 @@ async function requireAuth(request, env) {
6119
6146
  if (!authContext) {
6120
6147
  return new Response(JSON.stringify({ error: "Unauthorized" }), {
6121
6148
  status: 401,
6122
- headers: { "Content-Type": "application/json", ...CORS_HEADERS }
6149
+ headers: { "Content-Type": "application/json" }
6123
6150
  });
6124
6151
  }
6125
6152
  return authContext;
@@ -6134,7 +6161,7 @@ async function requireAdmin(request, env) {
6134
6161
  JSON.stringify({ error: "Forbidden: Admin access required" }),
6135
6162
  {
6136
6163
  status: 403,
6137
- headers: { "Content-Type": "application/json", ...CORS_HEADERS }
6164
+ headers: { "Content-Type": "application/json" }
6138
6165
  }
6139
6166
  );
6140
6167
  }