agents-relay 1.0.115 → 1.0.116
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/dist/planner.js +28 -2
- package/package.json +1 -1
package/dist/planner.js
CHANGED
|
@@ -139,15 +139,41 @@ export function parsePlannerOutput(output) {
|
|
|
139
139
|
const candidate = trimmed.replace(/^```(?:json)?\s*/i, '').replace(/\s*```$/, '').trim();
|
|
140
140
|
return parsePlannerResult(JSON.parse(candidate));
|
|
141
141
|
}
|
|
142
|
+
function boundedText(value, max = 4000) {
|
|
143
|
+
if (value === null || value === undefined || value.length <= max)
|
|
144
|
+
return value;
|
|
145
|
+
return value.slice(0, max) + `\n...[truncated ${value.length - max} chars]`;
|
|
146
|
+
}
|
|
142
147
|
export function plannerInput(context) {
|
|
143
148
|
const visibleAgents = context.executionContext?.agents.map(agent => ({
|
|
144
149
|
name: agent.name,
|
|
145
|
-
description: agent.description,
|
|
150
|
+
description: boundedText(agent.description, 1000),
|
|
146
151
|
capabilities: agent.capabilities,
|
|
147
152
|
boundaries: agent.restrictions,
|
|
148
153
|
runtime: agent.runtime,
|
|
149
154
|
}));
|
|
150
|
-
|
|
155
|
+
const project = context.executionContext?.project;
|
|
156
|
+
return JSON.stringify({
|
|
157
|
+
objective: context.objective,
|
|
158
|
+
retry_feedback: context.retryFeedback,
|
|
159
|
+
previous_planner_task_id: context.previousPlannerTaskId,
|
|
160
|
+
project: project ? { name: project.name, path: project.path } : undefined,
|
|
161
|
+
visible_agents: visibleAgents ?? [],
|
|
162
|
+
tasks: context.tasks.map(task => ({
|
|
163
|
+
id: task.id,
|
|
164
|
+
kind: task.kind ?? 'work',
|
|
165
|
+
parent_task_id: task.parentTaskId,
|
|
166
|
+
state: task.state,
|
|
167
|
+
input: task.kind === 'planner' ? undefined : boundedText(task.input),
|
|
168
|
+
result_summary: boundedText(task.result?.summary),
|
|
169
|
+
planner_result: task.plannerResult ? {
|
|
170
|
+
objective_status: task.plannerResult.objective_status,
|
|
171
|
+
assessment: boundedText(task.plannerResult.assessment),
|
|
172
|
+
next_task_ids: task.plannerResult.next_tasks.map(item => item.id),
|
|
173
|
+
} : undefined,
|
|
174
|
+
error: boundedText(task.error, 2000),
|
|
175
|
+
})),
|
|
176
|
+
});
|
|
151
177
|
}
|
|
152
178
|
export class CommandObjectivePlanner {
|
|
153
179
|
command;
|