Watch
1
0
Fork
You've already forked arc
0
forked from hesabix/arc
arc/hesabixUI/hesabix_ui/lib/widgets/ai/ai_subagent_trace.dart
2026-08-18 16:19:23 +00:00

39 lines
1.2 KiB
Dart

import 'package:hesabix_ui/models/ai_stream_event.dart';
const kSubagentLifecycleTools = {
'spawn_subagent',
'await_subagent',
'cancel_subagent',
};
bool isSubagentLifecycleTool(String? tool) =>
tool != null && kSubagentLifecycleTools.contains(tool);
List<AIAgentTraceStep> subagentChildSteps(
List<AIAgentTraceStep> all,
AIAgentTraceStep parent,
) {
final pid = parent.stepId;
final sid = parent.cancelableSubagentId ?? parent.subagentId;
return all.where((s) {
if (s.stepId == parent.stepId) return false;
if (s.kind == 'subagent') return false;
if (s.parentStepId != null && s.parentStepId == pid) return true;
if (sid != null &&
sid.isNotEmpty &&
s.subagentId == sid &&
s.parentStepId != null) {
return true;
}
return false;
}).toList();
}
/// گام‌های ریشهٔ تایم‌لاین — بدون ابزار spawn و بدون فرزندان تو در تو.
List<AIAgentTraceStep> timelineRootSteps(List<AIAgentTraceStep> all) {
return all.where((s) {
if (s.isNestedSubagentStep) return false;
if (s.kind != 'subagent' && isSubagentLifecycleTool(s.tool)) return false;
return true;
}).toList();
}