0xray 3.4.10 → 3.5.0

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.
@@ -9,6 +9,11 @@ import { getExecutionPlanner } from '../execution/execution-planner.js';
9
9
  import { mcpClientManager } from '../../../mcps/mcp-client.js';
10
10
  import { addObservations, extractOrchestrationObservations, spawnAside } from '../aside-context.js';
11
11
  import { getProvider } from '../config/memory-routing-bridge.js';
12
+ import {
13
+ delegationSummaryForResponse,
14
+ recordDeferredDelegations,
15
+ type PendingDelegation,
16
+ } from '../../../nucleus/pending-delegations.js';
12
17
  import type { OrchestrationResult, OrchestrationTask } from '../types.js';
13
18
 
14
19
  export interface TaskHandlerDeps {
@@ -66,6 +71,7 @@ export class TaskHandler {
66
71
  };
67
72
 
68
73
  const startTime = Date.now();
74
+ let pendingDelegations: PendingDelegation[] = [];
69
75
 
70
76
  try {
71
77
  // Validate tasks
@@ -90,6 +96,16 @@ export class TaskHandler {
90
96
 
91
97
  const results = await this.executePlan(executionPlan, sessionId, timeout);
92
98
 
99
+ if (results.deferredRecords.length > 0) {
100
+ pendingDelegations = recordDeferredDelegations(sessionId, results.deferredRecords);
101
+ await frameworkLogger.log(
102
+ 'orchestrator.task-handler',
103
+ 'pending-delegations-recorded',
104
+ 'info',
105
+ { count: pendingDelegations.length, sessionId },
106
+ );
107
+ }
108
+
93
109
  // Feed per-task outcomes back to memory provider (not aggregate session stats)
94
110
  if (memoryProvider.ingestFeedback) {
95
111
  const outcomeByKey = new Map(
@@ -150,7 +166,12 @@ export class TaskHandler {
150
166
 
151
167
  orchestrationResult.duration = Date.now() - startTime;
152
168
 
153
- const response = this.formatOrchestrationResponse(description, orchestrationResult, executionMode);
169
+ const response = this.formatOrchestrationResponse(
170
+ description,
171
+ orchestrationResult,
172
+ executionMode,
173
+ pendingDelegations,
174
+ );
154
175
 
155
176
  return { content: [{ type: 'text', text: response }] };
156
177
  }
@@ -173,6 +194,12 @@ export class TaskHandler {
173
194
  bottlenecks: string[];
174
195
  recommendations: string[];
175
196
  agentOutputs?: Record<string, string>;
197
+ deferredRecords: Array<{
198
+ taskId: string;
199
+ agent: string;
200
+ description: string;
201
+ type?: string;
202
+ }>;
176
203
  taskOutcomes: Array<{
177
204
  taskId: string;
178
205
  agent: string;
@@ -185,6 +212,12 @@ export class TaskHandler {
185
212
  let failedTasks = 0;
186
213
  let deferredTasks = 0;
187
214
  const agentOutputs: Record<string, string> = {};
215
+ const deferredRecords: Array<{
216
+ taskId: string;
217
+ agent: string;
218
+ description: string;
219
+ type?: string;
220
+ }> = [];
188
221
  const taskOutcomes: Array<{
189
222
  taskId: string;
190
223
  agent: string;
@@ -245,6 +278,12 @@ export class TaskHandler {
245
278
  } else {
246
279
  for (const task of tasks) {
247
280
  deferredTasks++;
281
+ deferredRecords.push({
282
+ taskId: task.id,
283
+ agent,
284
+ description: task.description,
285
+ type: task.type,
286
+ });
248
287
  taskOutcomes.push({
249
288
  taskId: task.id,
250
289
  agent,
@@ -288,6 +327,7 @@ export class TaskHandler {
288
327
  bottlenecks,
289
328
  recommendations,
290
329
  agentOutputs,
330
+ deferredRecords,
291
331
  taskOutcomes,
292
332
  };
293
333
  }
@@ -329,8 +369,18 @@ export class TaskHandler {
329
369
  private formatOrchestrationResponse(
330
370
  description: string,
331
371
  result: OrchestrationResult,
332
- executionMode: string
372
+ executionMode: string,
373
+ pendingDelegations: PendingDelegation[] = [],
333
374
  ): string {
375
+ const delegationsBlock =
376
+ pendingDelegations.length > 0
377
+ ? `\n**Delegations (host Task required):**\n\`\`\`json\n${JSON.stringify(
378
+ { delegations: delegationSummaryForResponse(pendingDelegations) },
379
+ null,
380
+ 2,
381
+ )}\n\`\`\`\n`
382
+ : '';
383
+
334
384
  return `🎯 Orchestration Complete: "${description}"
335
385
 
336
386
  **Session ID:** ${result.sessionId}
@@ -355,6 +405,6 @@ ${result.recommendations.length > 0 ? result.recommendations.map((r) => `•
355
405
 
356
406
  ${result.agentOutputs && Object.keys(result.agentOutputs).length > 0
357
407
  ? `**Agent Outputs (real MCP responses):**\n${Object.entries(result.agentOutputs).map(([k, v]) => `• ${k}: ${v.substring(0, 200)}${v.length > 200 ? '...' : ''}`).join('\n')}\n`
358
- : ''}`;
408
+ : ''}${delegationsBlock}`;
359
409
  }
360
410
  }
@@ -35,7 +35,8 @@
35
35
  "per_suite_test_triage": true,
36
36
  "phased_plan_threshold": 25,
37
37
  "auto_consult_major_work": true,
38
- "no_new_surface": true
38
+ "no_new_surface": true,
39
+ "auto_chain_delegations": true
39
40
  },
40
41
  "autonomous_reporting": {
41
42
  "enabled": true,